Skip to content

feat: add compiler-backed Tetra symbol graph extraction - #2491

Open
BoSuY0 wants to merge 2 commits into
Graphify-Labs:v8from
BoSuY0:feat/tetra-symbol-graph
Open

feat: add compiler-backed Tetra symbol graph extraction#2491
BoSuY0 wants to merge 2 commits into
Graphify-Labs:v8from
BoSuY0:feat/tetra-symbol-graph

Conversation

@BoSuY0

@BoSuY0 BoSuY0 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • register .tetra and .t4 as supported code files
  • invoke tetra inspect symbols --format=json once per corpus and map tetra.symbol-graph.v1 into Graphify nodes/edges
  • cache batch results by schema, compiler version, paths, and source bytes
  • validate explicit cross-domain links from docs/contracts/knowledge_graph_links.v1.json
  • report detected/indexed/diagnostic/failed/skipped Tetra coverage
  • refresh built_at_commit when graphify update . sees commit-only changes

Safety and behavior

  • compiler lookup order: GRAPHIFY_TETRA_BIN, tetra on PATH, repository self-host fallback
  • invalid compiler output, absolute paths, dangling edges, and ambiguous manifest endpoints fail closed
  • missing compiler retains portable file anchors
  • change, rename, and delete update paths have integration coverage

Verification

  • uv run --with openai pytest -q: 3943 passed, 36 skipped
  • uv run ruff check ...: passed
  • real Tetra_Language graph: 52,555 nodes, 126,234 edges, 7,045 Tetra nodes, 5 manifest edges, 78.1 MiB
  • 12/12 project known-answer queries passed

BoSuY0 added 2 commits August 5, 2026 22:42
Register .tetra/.t4 as a single batch extraction surface, validate explicit cross-domain links, and report Tetra coverage without duplicating the compiler grammar.

Tests: uv run --with openai pytest -q (3943 passed, 36 skipped)
Keep graph topology optimization while allowing the exact graphify update command to advance built_at_commit for same-head release checks.

Tests: uv run pytest -q tests/test_watch.py tests/test_tetra_extraction.py tests/test_knowledge_links.py tests/test_report.py

@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 a compiler-backed extractor for Tetra source files (.tetra and .t4). - It registers the new extensions in detect.py (as code) and extract.py (dispatch table and language-family map), and adds a new graphify/extractors/tetra.py module that shells out to a tetra/go run compiler, converts a symbol-graph payload into nodes/edges, and caches batch results. - The extract() function is modified to pull Tetra files out of the normal per-file/parallel path and run them through a single whole-corpus batch (extract_tetra_batch), merging results back by source file and threading tetra metadata into the return value. A knowledge_links application step is also wired into build_from_json. - Accompanying test changes cover Tetra batch extraction, watch/incremental-rebuild behavior, and report output (token cost, Tetra coverage). Surface area spans build.py, detect.py, extract.py, the new extractors/tetra.py, plus knowledge_links and report code, along with watch/report/tetra test files.

Worth a look

  • Tetra batch cache key ignores files that fail to read, silently reusing stale resultsgraphify/extractors/tetra.py · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Non-atomic write-then-replace of tetra cache can leave stale .tmp races between concurrent extractionsgraphify/extractors/tetra.py · 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 — 2398 functions depend on the 709 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 367 callers, 40 callees
  • worse: _rebuild_code() — 89 callers, 51 callees
  • worse: build_from_json() — 142 callers, 17 callees
  • worse: build_merge() — 29 callers, 12 callees
  • worse: extract_files_direct() — 15 callers, 21 callees
  • worse: to_wiki() — 33 callers, 7 callees
  • worse: generate() — 31 callers, 6 callees
  • worse: make_inputs() — 15 callers, 5 callees
  • …and 5 more

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

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

return f"L{line}:C{column}" if isinstance(column, int) and column > 0 else f"L{line}"


def convert_symbol_graph(payload: dict[str, Any], root: Path) -> dict[str, Any]:

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 regressionconvert_symbol_graph()

high coupling complexity (Ca·Ce = 12).

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

return result


def extract_tetra_batch(

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 regressionextract_tetra_batch()

fans out to 10 callees (efferent coupling).

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

return candidates[0]


def apply_knowledge_links(G: nx.Graph, root: str | Path | None) -> dict[str, int]:

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 regressionapply_knowledge_links()

6 callers depend on it (afferent coupling).

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

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