Skip to content

feat: schema v2 output adapter + symbol diff layer (addresses PR #13 gaps 1, 2, 6, 7)#18

Closed
avikalpg wants to merge 8 commits into
phase1-tree-sitter-dependency-extractionfrom
nia/pr13-schema-v2-adapter
Closed

feat: schema v2 output adapter + symbol diff layer (addresses PR #13 gaps 1, 2, 6, 7)#18
avikalpg wants to merge 8 commits into
phase1-tree-sitter-dependency-extractionfrom
nia/pr13-schema-v2-adapter

Conversation

@avikalpg

Copy link
Copy Markdown
Contributor

What

Adds the schema v2 output adapter to the tree-sitter processor. This is a follow-up to PR #13 that was identified as needed in docs/DiffGraph-CLI/design/PR-13-REVIEW.md.

New files

File Purpose
diffgraph/processing_modes/schema_v2_adapter.py Pure functions: symbol diff computation + schema v2 assembly
tests/test_schema_v2_adapter.py 21 deterministic unit tests

Changes to existing files

File Change
tree_sitter_dependency.py Added _get_pre_change_content(), _get_post_change_content(), analyze_changes_v2()
processing_modes/__init__.py Guard openai_agents_dependency import with try/except

Gaps addressed (from PR-13-REVIEW.md)

Gap Description Status
Gap 1 Output format is GraphManager, not schema v2 analyze_changes_v2() returns symbols[] + relationships[] with analysis_source
Gap 2 No symbol diff layer — change_kind never computed compute_symbol_diff() compares pre/post AST snapshots
Gap 6 No test for zero network calls test_no_network_calls uses socket monkeypatch
Gap 7 _get_full_file_content mixes pre/post intent ✅ Split into _get_pre_change_content() / _get_post_change_content()

Gaps 3–5, 8 (analysis_source fields, privacy_tier, optional dep, TypeScript API) are handled within the adapter and the analyze_changes_v2() method.

Why a separate PR (not a commit on #13)

PR #13 is Avikalp's branch. This PR targets phase1-tree-sitter-dependency-extraction as base so it can be squash-merged into #13 when ready, or Avikalp can cherry-pick the commit.

Tests

21 passed in 0.28s

All 21 tests are deterministic (no LLM, no network, no filesystem writes). The zero-network-calls test uses a socket monkeypatch.

What this enables

Once this is merged into #13 and #13 merges to main:

Nia (Avikalp's assistant) and others added 8 commits June 8, 2026 22:03
Adds diffgraph/schema/diffgraph-v2.schema.json — the JSON Schema 2020-12
draft that operationalises the v2 output contract from design/JSON-SCHEMA.md.

Covers: FileEntry, SymbolEntry, RelationshipEntry, SummaryEntry, Evidence,
Metadata, Warning, AnalysisSource. Required fields enforced; inferred claims
must carry evidence + confidence. privacy_tier is a top-level required
metadata field. Consumers can use this for validation in CI, typed generation,
and VS Code schema hints.

This satisfies one of the four schema ratification criteria in JSON-SCHEMA.md
(the machine-readable file). Still needs: Avikalp sign-off on sub-questions,
one end-to-end worked example validated, PR #11 updated to target this schema.
Three fixes per coderabbit review:
- Evidence.line_start/line_end: minimum 0 → 1 (schema said 1-indexed,
  minimum was inconsistently 0; line 0 is not a valid source location)
- SymbolEntry.location.line_start/line_end: same fix; added descriptions
- SummaryEntry: add 'evidence' to required array and add allOf contains
  constraints enforcing at least one llm_inference + one structural_basis
  entry (matches the described contract that was previously unenforced)
- llms.txt at repo root: compact context for LLMs crawling the repo
- skill.md: agent skill file so AI agents know how to use wild CLI
- mcp_server.py: MCP server exposing run_wild_diff, list_docs, get_docs,
  search_docs tools and a wildestai://llms.txt resource

Replaces the need for a paid DocsALot subscription — all AI
discoverability infrastructure built in-house.
Three issues:
- mcp_server.py get_docs(): add is_relative_to() guard against path traversal
  for both REPO_ROOT and DOCS_DIR candidate paths
- mcp_server.py run_wild_diff(): sanitize output_file to resolve inside repo dir;
  reject traversal attempts; create parent dirs before passing to wild
- skill.md: fix Python version '3.8+' → '3.7+' to match setup.py python_requires;
  add output_file param to run_wild_diff() signature doc
schema: add machine-readable JSON Schema v2 (diffgraph-v2.schema.json)
feat: add AI discoverability layer (llms.txt, skill.md, MCP server)
Addresses the two blocking gaps from PR-13-REVIEW.md:

Gap 1 — Output format: new schema_v2_adapter.py module produces
symbols[] + relationships[] with analysis_source='structural' and
evidence pointers, conforming to diffgraph-v2.schema.json.

Gap 2 — Symbol diff layer: compute_symbol_diff() compares pre-change
and post-change AST snapshots to assign change_kind (added / modified /
deleted / unchanged) to every symbol. Uses content-slice comparison so
symbols that shift in line number without changing body are correctly
marked 'unchanged'.

Also adds:
- _get_pre_change_content() / _get_post_change_content() to
  TreeSitterProcessor (Gap 7 — explicit pre/post split)
- analyze_changes_v2() entry point on TreeSitterProcessor, which calls
  the adapter and returns a schema v2 dict. No GraphManager, no Mermaid,
  no network calls. metadata.privacy_tier='local' always.
- Guard openai_agents_dependency import with try/except so the module
  loads without the openai-agents SDK installed.
- 21 deterministic unit tests (test_schema_v2_adapter.py), including
  a zero-network-calls assertion (Gap 6).
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • feature/*
  • akg/*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cf516a92-c2ea-4c69-83e6-5cf36f6ed213

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nia/pr13-schema-v2-adapter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@avikalpg

avikalpg commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing — the 3 commits from this PR have been cherry-picked directly onto the phase1-tree-sitter-dependency-extraction branch (PR #13). PR #13 now includes all Phase 1 work including the schema v2 adapter + validation fixes. See updated PR #13 description for the full acceptance criteria list.

@avikalpg avikalpg closed this Jul 8, 2026
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