feat: add structural Gherkin (.feature) document extraction - #2414
feat: add structural Gherkin (.feature) document extraction#2414hopstreax wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
This PR adds support for Gherkin .feature files to the extraction pipeline. It registers .feature as a document extension in detect.py, introduces a new graphify/extractors/gherkin.py extractor that parses Gherkin keywords (Feature, Background, Scenario, Scenario Outline, Examples) into structural nodes with contains edges reflecting their hierarchy, and wires this extractor into the dispatch table in extract.py. It also adds accompanying tests covering classification, dispatch, and various extraction scenarios. The surface area is the file-type detection extension set, the extract dispatcher/imports, one new extractor module, and additions to the detect and extract test suites.
Worth a look
- Duplicate-name Examples node collides and misattaches parent edge —
graphify/extractors/gherkin.py:78· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1916 functions depend on the 909 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_get_extractor()— 25 callers, 6 callees - worse:
classify_file()— 43 callers, 3 callees
Verification — 1916 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1750 function(s) in the blast radius were not formally verified this run
· 2 more finding(s) on lines outside this diff (see the check run).
Summary
This PR adds support for Gherkin (
.feature) files to Graphify's document extraction pipeline.Previously,
.featurefiles were not recognized byclassify_file(), causing them to be skipped during detection and never reach extraction. As a result, BDD specification files produced no graph nodes.This change classifies
.featurefiles as documents and introduces a lightweight structural extractor that models the document hierarchy using Graphify's existing document schema.Changes
Add
.featuretoDOC_EXTENSIONSso Gherkin files are classified asDOCUMENT.Implement a lightweight line-by-line Gherkin extractor.
Register the extractor in the extraction dispatch table.
Extract structural document nodes for:
FeatureBackgroundScenarioScenario OutlineExamplesEmit standard
containsedges between structural elements.Ignore executable step lines (
Given,When,Then,And,But,*) to keep the graph focused on document structure.Preserve the existing Graphify node and edge schema without introducing new graph concepts.
Add regression tests covering:
Design
The implementation follows the existing Markdown extractor philosophy:
containsrelationshipsThis keeps Gherkin support consistent with Graphify's existing document extraction architecture.
Verification
Automated
uv run pytest tests/test_detect.py -k gherkinuv run pytest tests/test_extract.py -k gherkinuv run ruff checkManual
Verified using the standard Graphify update pipeline:
The generated graph correctly contains:
while correctly excluding step keywords (
Given,When,Then, etc.).Fixes
Closes #2349.