Skip to content

feat(parser): index generic YAML structure - #816

Open
wgu9 wants to merge 1 commit into
tirth8205:mainfrom
wgu9:feat/generic-yaml-indexing
Open

feat(parser): index generic YAML structure#816
wgu9 wants to merge 1 commit into
tirth8205:mainfrom
wgu9:feat/generic-yaml-indexing

Conversation

@wgu9

@wgu9 wgu9 commented Aug 3, 2026

Copy link
Copy Markdown

Partially addresses #436. JSON support remains out of scope for this PR.

What changed

Generic .yml / .yaml files now produce value-free, path-addressable graph
structure:

  • aggregated YamlPath nodes for mappings and repeated sequence shapes
  • occurrence counts plus bounded source-line/range samples
  • mapping-scoped duplicate-key diagnostics with exact line samples
  • canonical CONTAINS edges and REFERENCES edges for aliases/merge keys
  • distinct reference targets for typed and duplicate anchored definitions
  • changed_yaml_paths in change/review output
  • CLI kind filtering, safe graph serialization, visualization, and docs support

Scalar values are deliberately discarded. The graph stores structural key paths
and YAML types, not configuration values. Query, search, and change-analysis
responses share the same nested yaml metadata contract.

Safety and compatibility

This incorporates the earlier YAML review feedback from #539, #577, and #462:

  • malformed or pathologically recursive YAML fails safely
  • aliases, root/self aliases, merge sequences, and complex mapping keys have
    regression coverage
  • per-file limits bound node count, nesting depth, exact/schema/identity path
    length, and diagnostic samples
  • repeated sequence shapes aggregate under [*] paths
  • existing Ansible and Spring parsers retain precedence
  • files rejected by a specialized path heuristic fall back to generic YAML
  • full-build/query coverage asserts zero dangling YAML edges

How this differs from earlier attempts

Earlier review concern This PR
Bare or dangling graph endpoints Canonical persisted identities plus full-build dangling-edge assertions
Raw configuration values in metadata Values are never stored
Framework- or organization-specific YAML schema Generic structural paths and YAML types
One node per repeated list item Aggregated [*] schema paths with bounded occurrence samples
Missing malformed/cycle/size handling Error, recursion, node, depth, path, and metadata bounds
Parser-only coverage Persistence, query, change analysis, visualization, and specialization regressions

Verification

Verification uses only synthetic fixtures and this public project's test suite:

  • Full suite: 2,413 passed, 7 skipped, 2 xpassed
  • Focused YAML/change/incremental suite: 158 passed
  • Ruff (source and changed tests): clean
  • Mypy (same flags as CI): clean
  • git diff --check: clean
uv run --python 3.13 pytest tests/ --tb=short -q
uv run pytest tests/test_yaml_parser.py tests/test_changes.py \
  tests/test_incremental.py -q --tb=short
uv run ruff check code_review_graph/
uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional

The synthetic coverage includes persisted graph queries, zero dangling YAML
edges, scalar-value absence, malformed and recursive input, oversized paths,
duplicate keys, aliases, merges, multi-document YAML, and Spring/Ansible
precedence.

Deliberate non-goals

This first phase does not add JSON indexing, scalar-value indexing,
duplicate-value detection, cross-file business-rule validation, business-owner
inference, or Helm values-to-template resolution (#199). Those require explicit
policy and privacy semantics on top of structural indexing.

Partially addresses tirth8205#436 with value-free, bounded YAML path indexing.
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.

1 participant