feat(engine): structural audit stage one — the runtime-vs-owner divergence check #142
Closed
tim.lingo
wants to merge 1 commits from
feat/structural-audit into main
pull from: feat/structural-audit
merge into: :main
:main
:fix-mcp-wrapper-tool-schemas
:docs-cognitive-architecture
:docs/session-2026-08-13-language-faculty
:docs/geo-operators-el-cutover-reversal-2026-08-13
:docs/engram-cognitive-architecture-2026-08-12
:engram-store-wiring
:el-route-decorators
:fix/bound-session-payload
:feat/cgi-identity-accessors
:fix/restore-soul-identity-producer
:rebase/openai-tools-onto-main
:rebase/gate-state-key-reads-onto-main
:rebase/structural-audit-onto-main
:feat/self-seeded-context
:integrate/semantic-plus-writethrough
:feat/semantic-leg-dropout
:feat/semantic-substrate
:feat/gold-set-heldout
:feat/evidence-weighted-merge
:feat/structural-audit
:feat/claim24-unfloored-semantic
:feat/executive-filter-recall
:feat/bm25-lexical-leg
:feat/semantic-seeded-assoc
:feat/associative-recall-leg
:feat/hybrid-semantic-recall
:chore/retrieval-measurement-contract
:feat/retrieval-eval-harness
:feat/soul-write-through
:feat/recall-through-activation
:chore/regen-soul-amalgam-20260807
:feat/gate-state-key-reads
:fix/129-on-openai-tools
:fix/129-history-amplification
:fix/liveness-engine-91
:feat/soul-openai-tools-v2
:fix/resume-server-tool-replay
:fix/soul-history-provenance-20260805
:feat/soul-plain-chat-generation-20260805
:feat/soul-native-web-search-20260804
:ci/pin-vendored-runtime
:reconcile/soul-union-main
:fix/bound-session-payload-main
:fix/receipts-wrapper-forget
:fix/receipts-agent-tools
:reconcile/neuron-wip-to-main
:hotfix/trackb-threat-to-others
:reconcile/hotfix-to-main-launch
:hotfix/elc-source-typos
:fix/safety-contact-truncation
:fix/genesis-boot-crash
:fix/immutable-on-hotfix
:feat/bounded-persona-floor
:ci/rdynamic-http-handler
:ci/harden-gate-boot
:feat/agent-phase1-soul
:salvage/elh-state-20260704
:feat/soul-model-self-report
:feat/openai-format-providers
:el-runtime-repoint
:feat/plan-mode-endpoint
:fix/operator-identity-home-resolution
:fix/wrapper-backlog-endpoints
:fix/list-typed-slice-offset
:feat/connectors-call-route
:fix/chat-vision-attachments
:fix/prevent-engram-corruption
:fix/emergency-regressions
:fix/session-continuity-hook
:fix/context-dedup-shared-ids
:fix/engram-float-parser
:improve/recall-context-format
:improve/recall-context-dedup
:improve/recall-cross-session-continuity
:improve/recall-emotional-recall
:improve/recall-activation-seed
:improve/recall-recall-completeness
:improve/recall-temporal-precision
:improve/recall-engram-scoring
:improve/recall-recall-reliability
:improve/recall-session-start-recall
:improve/reliability-engram-write
:improve/reliability-state-management
:improve/soul-memory-formation
:improve/safety-crisis-detection
:improve/reliability-route-error-recovery
:improve/reliability-llm-retry
:improve/reliability-session-boundary
:improve/reliability-safety-resilience
:improve/reliability-engram-connection
:improve/soul-routes-api
:improve/reliability-cross-session-affective
:propose/agent-workspace-root-read
:improve/reliability-conv-history
:improve/soul-strip
:improve/soul-chat-pipeline
:docs/conversation-retrieval-design
:propose/no-fake-tools-in-chat-mode
:fix/ci-soul-build-single-file
:fix/canonical-self-bridge
:feat/agent-tool-workspace-scope
:fix/agentic-tools-duplicate-web-search
:green/agentic-fixes
:feat/connectors-soul
:feat/layer-safety
:feat/layer-imprint
:feat/layer-stewardship
:test/layer-composition
:test/layer-safety
:test/layer-stewardship
:test/layer-imprint
:feat/memory-delete-update
:feat/native-web-search
No Reviewers
Labels
Clear labels
BETA-CRITICAL
blocks-public-beta
HELD
ORTHOGONAL
P0
POST-BETA
security
On the beta critical path — must resolve before ship
Must be fixed before any public beta
Blocked pending an external decision (counsel / dual sign-off)
Parallel workstream (testing/hardening) — safe to assign off critical path
Drop-everything severity
Important but not blocking the beta ship
Security vulnerability
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: neuron-technologies/neuron#142
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "feat/structural-audit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stage one of the structural audit route. The graph-integrity check (
runStructuralAudit) is currently a stub that returns nothing real — inventory row H-14.Includes the runtime-versus-owner divergence check, whose absence let a ~24,000-node loss run for weeks with every boot reporting green (row G-17: read-back was confirming working memory, never the store that survives a restart).
Filed so it is reviewable rather than sitting on an unpushed branch. Not merged, not deployed.
🤖 Generated with Claude Code
`runStructuralAudit` has been an advertised MCP tool with nothing behind it: the dispatcher GET'd /session/begin and returned that unrelated session digest under an audit tool's name. Meanwhile the failure the audit would have caught ran silently for about three weeks — the soul reporting 103,089 nodes while the engram, which OWNS persistence, held ~79,900, a crash discarding the difference, and every boot reporting green throughout, because nothing in the system ever compared the two sides. WHAT THE PATENT SPECIFIES, AND HOW IT SHAPED THIS CGI provisional, 05-detailed-description.md, "Stage 1: Structural audit 430". Two clauses did the design work. First the four things the module evaluates: the density and typed distribution of causal edges; value/execution-record consistency; the richness and connectivity of the self-model; and wonder- manifest authenticity. Second, and decisively: it "produces a coherence assessment 432 — NOT A BINARY SCORE but an annotated characterization of the graph's structural properties." So every finding carries its numbers AND a plain-language note saying what they mean and how they were obtained. There is no pass/fail and no composite health figure, and `"score":null` is emitted explicitly so a reader cannot mistake its absence for an omission. WHAT IS IN STAGE 1 (four findings) owner_runtime_divergence — the motivating case. Runtime counts vs the owner's own GET /api/stats, the delta, and the trend against the previous audit, so a second call answers "is the gap growing?" rather than restating it. self_model_connectivity — the three identity pillars plus the self root: present, content length, one-hop degree. This RETIRES the Claude-side vitals identity block, which lived outside the system it was checking and went on reporting green while the memory-philosophy pillar was absent from the live graph. Asking the running soul is the designed mechanism; a shell probe was the fourth patch on the same hole. typed_edge_distribution — exact counts against the claim-10 vocabulary, plus density, plus a separate count of LOWERCASE near-misses ("causes" vs "Causes"): "the vocabulary is unused" and "the vocabulary is misspelled by the write paths" are different defects with different fixes. orphans_and_dangling_edges — the tool's own long-standing promise. WHAT IS DEFERRED, AND WHY IT IS DATA RATHER THAN A COMMENT Value/execution-record consistency and wonder-manifest authenticity ship as a `deferred` array that MEASURES the populations they would need (Prediction and WonderQuestion nodes) and reports those counts as the reason. Both are ~0 today — WonderQuestion because of a known write/read node-type mismatch. Asserting value coherence or a pull-weight correlation on an empty population would be a fabricated result, which is worse than a stated gap. MEASUREMENT HONESTY: EXACT WHERE CHEAP, SAMPLED WHERE NOT, ALWAYS LABELLED Counts, edge typing and self-model connectivity are exact. Orphan and dangling rates are sampled, because engram_find_node_index is a linear scan — an exhaustive dangling check is O(nodes x edges), ~2.2e9 string compares at today's scale. Samples are UNIFORM across the whole population (str_index_of_all gives every edge offset in one pass, so any index is O(1); json_array_get would have been O(n^2)), never head-of-list, and each figure ships with its own sampled / population / exhaustive fields. ?edge_sample= and ?node_sample= at population size run either check exhaustively. The real fix is an id index in the runtime. ONE BUG THIS FOUND IN ITSELF, CAUGHT IN TEST http_get does not return "" when the owner is unreachable — it returns a JSON error object. Testing only for "" made a DEAD owner read as reachable with node_count 0, so the audit reported 100% divergence and named it data loss. Reachability is now proved by the presence of the node_count field, and the owner's raw reply is attached. A confident wrong answer is exactly what this route exists to stop. Edge findings need relation labels and the runtime has no edge-enumeration builtin, so they use the same scratch export GET /api/graph/edges already uses (engram_save to TMPDIR, never the owner's canonical file — #117). That is a large write on a large graph, so this is a manual route, not a timer; ?edges=0 skips it. neuron-api.el:900-1273 handler + helpers routes.el:567,752 GET and POST /api/neuron/audit/structural mcp-wrapper/src/main.el:113,682 tool description + dispatch off /session/begin dist/soul.c regenerated (1255 bodies) Rung: E2E-VERIFIED. Soul built from this branch (gen-soul-amalgam + cc-brain, 921,192 bytes, 16 warnings, 0 errors), booted on throwaway ports 7893/7896/7897 with throwaway HOMEs against a stub owner on 7894. Three scenarios pass: owner reachable (runtime 62 vs owner 42, delta 20 / 32.2%, trend flat on the second call; 12/20 edges claim-10 typed, 3 lowercase near-misses; 50/62 orphans, 3/20 dangling — every figure matches the fixture by construction), owner unreachable (reported as a finding with the raw reply, not a crash), and file mode (owner "none", divergence undefined). Reached end-to-end through the MCP tool via a locally built wrapper. verify-soul-contract.sh: GATE PASS, 27/27 routes + immutability. No process left running; live :7770 and :8742 untouched (GET only). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>Rebased onto
main(post-bf52197) asrebase/structural-audit-onto-main— 27 commits of drift resolved.The rebase merged cleanly at source level, and that was misleading:
dist/soul.cended up holding one side's code and not the other. The stamp gate added in9fd8c11caught it on its first real use:Without it this branch would have looked clean and shipped an engine containing the structural audit but none of the 2026-08-09 engine work, or the reverse — which is #133 exactly, the defect that once hid five merged fixes including a P0.
Regenerated and verified:
dist/soul.cmatches the sources (1,204,442 bytes, 1,259 inlined bodies)/api/neuron/audit/structuralassessment_kind: annotated_characterization,score: nullby design per the spec, with findingsRung: E2E-VERIFIED in an isolated lab. Not deployed.
Worth landing on merit — this is the runtime-vs-owner divergence check whose absence let a ~24,000-node loss run for weeks with every boot reporting green.
Pull request closed