Skip to content

feat: add structural Gherkin (.feature) document extraction - #2414

Open
hopstreax wants to merge 3 commits into
Graphify-Labs:v8from
hopstreax:feat/2349-gherkin-extractor
Open

hopstreax wants to merge 3 commits into
Graphify-Labs:v8from
hopstreax:feat/2349-gherkin-extractor

Conversation

@hopstreax

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for Gherkin (.feature) files to Graphify's document extraction pipeline.

Previously, .feature files were not recognized by classify_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 .feature files as documents and introduces a lightweight structural extractor that models the document hierarchy using Graphify's existing document schema.

Changes

  • Add .feature to DOC_EXTENSIONS so Gherkin files are classified as DOCUMENT.

  • Implement a lightweight line-by-line Gherkin extractor.

  • Register the extractor in the extraction dispatch table.

  • Extract structural document nodes for:

    • Feature
    • Background
    • Scenario
    • Scenario Outline
    • Examples
  • Emit standard contains edges 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:

    • document classification
    • extractor dispatch
    • structural hierarchy
    • duplicate title handling
    • comments
    • empty titles
    • Scenario Outline / Examples ownership
    • outline state regression

Design

The implementation follows the existing Markdown extractor philosophy:

  • lightweight line-by-line parsing
  • no parser generators
  • no additional dependencies
  • standard document nodes
  • standard contains relationships

This keeps Gherkin support consistent with Graphify's existing document extraction architecture.

Verification

Automated

  • uv run pytest tests/test_detect.py -k gherkin
  • uv run pytest tests/test_extract.py -k gherkin
  • uv run ruff check

Manual

Verified using the standard Graphify update pipeline:

uv run python -m graphify update repro-2349

The generated graph correctly contains:

login.feature
└── Feature: Login
    └── Scenario: Successful login

while correctly excluding step keywords (Given, When, Then, etc.).

Fixes

Closes #2349.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 graphify extraction pipeline. - It registers .feature as a document extension in detect.py (classified as DOCUMENT) and wires it into the extractor dispatch table in extract.py. - It introduces a new graphify/extractors/gherkin.py module that parses feature files line-by-line, emitting nodes for Feature/Background/Scenario/Scenario Outline/Examples keywords and contains edges representing their hierarchy. - It adds accompanying tests in test_detect.py and test_extract.py covering classification, dispatch, and various extraction scenarios; the large set of renamed test/rationale symbols appears to reflect renumbering rather than behavioral changes.

No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2167 functions depend on the 969 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: _get_extractor() — 27 callers, 6 callees
  • worse: classify_file() — 44 callers, 3 callees
  • new: extract_gherkin() — 10 callers, 4 callees

Verification — 2167 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: 1988 function(s) in the blast radius were not formally verified this run

· 1 grounded finding(s) anchored inline below; 2 more finding(s) on lines outside this diff (see the check run).

}


def extract_gherkin(path: Path) -> dict:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — extract_gherkin()

10 callers depend on it (afferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 introduces a new graphify/extractors/gherkin.py module that parses feature files into structural nodes (Feature, Background, Scenario, Scenario Outline, Examples) with contains edges, registers .feature in the extractor dispatch table, and classifies .feature files as documents in detect.py (along with newly added CODE_EXTENSIONS/DOC_EXTENSIONS sets). Accompanying tests cover classification, dispatch, and various Gherkin parsing scenarios. The surface area touches detect.py, extract.py, the new extractor module, and the two test files. Note the diff was truncated, so additional test changes beyond what's shown may exist.

No blocking issues surfaced. 4 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2231 functions depend on the 1013 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 454 callers, 41 callees
  • new: _rebuild_code() — 95 callers, 51 callees
  • new: detect() — 93 callers, 14 callees
  • new: save_manifest() — 34 callers, 11 callees
  • new: extract_files_direct() — 17 callers, 20 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: extract_corpus_parallel() — 26 callers, 10 callees
  • new: dispatch_command() — 2 callers, 117 callees
  • …and 37 more

Verification — 2231 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: 2052 function(s) in the blast radius were not formally verified this run

· 1 grounded finding(s) anchored inline below; 44 more finding(s) on lines outside this diff (see the check run).

}


def extract_gherkin(path: Path) -> dict:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — extract_gherkin()

10 callers depend on it (afferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Gherkin (.feature) support — BDD spec files are currently invisible to the graph

1 participant