feat: v0.7.0 code graph developer preview#91
Draft
theDakshJaitly wants to merge 35 commits into
Draft
Conversation
Lay down the frozen interfaces, schema, types, and config for the .mex/ code-graph layer (spec §10 Phase 0). Contracts only — no engine logic, extraction, fingerprinting, reconciliation, or checker bodies. Everything typechecks/builds; existing eleven checkers + CLI untouched (graph is additive). - 0.1 src/graph/schema.sql: ported CG base (nodes+body_hash, edges, files, unresolved_refs, nodes_fts FTS5, indexes, schema_versions, project_metadata) + net-new node_fingerprints, lsh_buckets, _mex_grounded_source (keyed by scaffold_file, the one demo->OSS adaptation). - 0.2 Frozen TS contracts under src/graph/: LanguageExtractor (§8.1) + ExtractedNode/Edge + TSTree surface; FrameworkResolver + ResolutionContext; GraphEngine (build/sync/searchNodes/getNode/getCallers/getCallees) with throwing stub; Reconciler + Resolution (MOVED|GONE|AMBIGUOUS) + Fingerprint; GroundingChecker signature (matches checkEdges) + createGroundingChecker. Reader methods are sync so the grounding checker matches the existing synchronous drift-checker shape; build/sync async for lazy grammar loading. - 0.3 src/types.ts: add Grounding + ScaffoldFrontmatter.grounds_to (§5, backward-compatible) + grounding IssueCodes (GROUNDING_GONE/DRIFT/AMBIGUOUS) so Track B never has to reopen this shared union. - 0.4 src/graph/config.ts: reconciler params as named consts (HI/LO/W_BODY/ W_NBR/MIN_TOKENS/K/BANDS/ROWS) — placeholders, eval-tuned later (§12). - 0.5 package.json engines.node >=22.5 for node:sqlite (used by the DB adapter Track A ports in Phase 1). No heavy deps added yet. Also scope vitest to exclude the gitignored .demo/ reference clone (its own suite needs mex-engine-cg, which we don't install).
Implements the port-heavy graph engine against the frozen Phase-0
contracts (spec §10 Track A). Ports from .demo/ (never committed) and
ships the 0.7.0 base: a deterministic tree-sitter → SQLite code graph for
TypeScript/JavaScript/TSX/JSX, no LLM.
- A1 Clean, exemplary TS/JS reference extractor implementing the frozen
LanguageExtractor seam (the copy-template every 0.7.x contributor
language clones), plus a self-verifying test harness + fixture (§8.2).
- A2 Line-independent node id ported verbatim (Tier-1 identity).
- A3 node:sqlite adapter, schema loader (writes a schema_versions row),
store with FTS5 search + reader queries.
- A4 Cross-file reference resolution (import-aware name binding) and
callers/callees traversal.
- A5 Lazy web-tree-sitter grammar loading; TS/JS/TSX .wasm vendored and
shipped in the published package, resolved from the install location.
- A6 `mex graph` command wired additively into src/cli.ts.
- GraphEngine implementation: async build/sync (lazy grammars),
synchronous reads; engine assigns body_hash + updatedAt.
Frozen contracts (schema.sql, types, engine/extractor/resolver interfaces,
config, reconcile, grounding, drift) are unchanged; src/graph/index.ts
gains only an additive createGraphEngine export. Verified: typecheck,
build, 259 tests, and an npm pack + install-from-tarball that builds a
real graph from the installed package (WASM + schema resolve at runtime).
Merge Gate 1, part 1 of 2. Additive graph engine: extraction, db, traversal, resolver, mex graph command. No frozen-contract signature changes.
…rounding) Merge Gate 1, part 2 of 2. Additive fingerprint/reconcile/grounding layer + grounding checker body. grounding.ts stub filled behind the unchanged createGroundingChecker signature. Resolved src/graph/index.ts export conflict by keeping both tracks' additive exports.
# Conflicts: # README.md
# Conflicts: # CONTRIBUTING.md
Co-authored-by: Daksh Jaitly <[email protected]>
Co-authored-by: Yashasvi Pandey <[email protected]>
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.
Status
Important
Developer preview: do not merge yet.
mainand npm remain on stable v0.6.3. This PR tracks the upcoming v0.7.0 code graph while it is tested, improved through contributions, documented, and prepared for a stable release. No v0.7.0 GitHub release or npm publish should happen from the current state.Overview
This PR adds a deterministic, local code knowledge graph beneath Mex's markdown memory scaffold. Tree-sitter extraction writes structural code facts to SQLite so scaffold memory can point at exact symbols, detect when grounded behavior changes, and survive confident renames or moves through fingerprint reconciliation.
The preview package version is
0.7.0-dev.0. The graph is additive: existing scaffolds and the original filesystem/lexical drift checks continue to work when no graph is present.What is included
grounds_toentries and inlinemex://anchors.mex sync.LanguageExtractorandFrameworkResolvercontribution seams.New commands
The scope, query, and impact commands emit compact JSONL intended for coding-agent retrieval and structural analysis.
Architecture
mex checkdetects stale grounding;mex syncrepairs prose and pointers.The identity, reconciliation, schema, and drift semantics are core behavior. Changes to those areas require discussion before implementation.
Current constraints
node:sqlite.Testing
Validated on the preview branch with:
npm run typecheck npm test npm run buildCurrent result: 30 test files and 301 tests passing. The build also verifies that the graph schema and three grammar WASM assets are copied into
dist/.Contribution workflow
Code-graph issues must state:
Create contribution branches from the preview branch:
Open contributor PRs with:
code-graph-previewDo not target
mainwith code-graph contributions. Relevant labels includecode-graph,developer-preview,language-support,tree-sitter,testing,performance,help wanted, andgood first issue. Work affecting graph identity, reconciliation, schema, or drift semantics should usecore / discuss-first.Release checklist
Preview foundation
0.7.0-dev.0code-graph-previewBefore stable v0.7.0
0.7.0main[email protected]to npmRelease flow
Until every required release item is complete, this PR should remain open and in Draft state.