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
Closed
Conversation
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).
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
7 tasks
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
diffgraph/processing_modes/schema_v2_adapter.pytests/test_schema_v2_adapter.pyChanges to existing files
tree_sitter_dependency.py_get_pre_change_content(),_get_post_change_content(),analyze_changes_v2()processing_modes/__init__.pyopenai_agents_dependencyimport withtry/exceptGaps addressed (from PR-13-REVIEW.md)
analyze_changes_v2()returnssymbols[]+relationships[]withanalysis_sourcechange_kindnever computedcompute_symbol_diff()compares pre/post AST snapshotstest_no_network_callsuses socket monkeypatch_get_full_file_contentmixes pre/post intent_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-extractionas base so it can be squash-merged into #13 when ready, or Avikalp can cherry-pick the commit.Tests
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:
wild diffcan emit schema v2 JSON (structural tier) with--format jsonanalyze_changes_v2as the default local mode