KB-3E49

FIX5 02 Authoritative Callgraph v2

2 min read Revision 1
qt001fix5callgraphlegacy

02 — Authoritative Callgraph v2 (recursive, structural)

Reproduces Codex's method: trace the ACTUAL dependency closure, not a name list.

  • v_qt001_callgraph_edges_v2: caller→callee edge for every qt001 function/proc/view, extracted by word-boundary match of the callee name inside pg_get_functiondef/pg_get_viewdef(caller). _ is a word char in PG regex so fn_qt001_machine_tier does NOT match inside ..._v4 — versions are distinguished.
  • v_qt001_authoritative_callgraph_v2: MATERIALIZED edges + node-deduped recursive reachability from the 3 registered roots (is_root): writer fn_dot_birth_qt001_apply, driver sp_dot_birth_qt001_apply, builder fn_qt001_build_plan_registry. Everything else authoritative is REACHED from these.
  • qt001_authoritative_object_registry: classifies every node (authoritative_root/current, governed_engine/registry, safe_planner, diagnostic_only, routed_2_6b, legacy_superseded, external_dependency) + is_sentinel_planner. It is a TABLE (data) — never scanned for edges — so legacy NAMES live here, not in any reachable view body.
  • v_qt001_authoritative_legacy_dependency_guard: FAILS CLOSED if any reached node is legacy_superseded OR UNCLASSIFIED. LIVE: pass=true, legacy_reached=0, unclassified_reached=0.

CRITICAL design rule discovered live: a reachable guard that embeds a legacy object NAME as a string literal (even to assert its absence) creates a spurious structural edge and explodes the closure (first rehearsal: 60 legacy-reached, all via no_legacy_planner_guard's literal IN-list). Fix: identify legacy via registry joins / is_sentinel_planner, never via literals in reachable views. v_qt001_no_legacy_planner_guard and v_qt001_planner_v2_sentinel_only_guard were rewritten registry-driven.

Back to Knowledge Hub knowledge/dev/reports/architecture/birth-stage2-6a-fix5-qt001-remove-legacy-planner-false-proof-rebuild-2026-06-07/02-authoritative-callgraph-v2.md