core/docs/analysis/adr-0244-cohesion-directive-audit-2026-07-17.md
Shay 12a9ca0b2a docs(cohesion): D0 governance — land ADR-0244, directive, and mandate audit
First step of the cohesion-directive arc (docs only; no code).

- docs/adr/ADR-0244-…md: committed Proposed, verbatim from the R&D export
  (matching the ADR-0241/2/3 landing convention), plus a clearly-marked
  governance annotation holding two items open for the D4 implementation plan:
  (1) §2.3 Q_top is likely vacuous — central I5 in odd Cl(4,1) collapses the
  charge on versor states (the #19 pseudoscalar failure mode); it must not be an
  egress gate without an empirical discriminating counterexample; (2) §4's
  conformed implementation contradicts §2.1-2.2 (per-axis resonance vs.
  Gram-projection/leakage-norm/ManifoldConditioningError), references a dangling
  ADR-0245, and uses a bare assert for the byte-order guard.
- docs/analysis/engineering_cohesion_refactoring_directive.md: the technical
  directive moved to its own canonical path, verbatim (content byte-identical).
- docs/analysis/adr-0244-cohesion-directive-audit-2026-07-17.md: the code-level
  audit of all 7 mandates vs. main@24078b11 — per-mandate verdicts, the six
  spec-level wrinkles, the amended mandate→work-item mapping, the missing sixth
  acceptance criterion (Mechanical-Sympathy gain), and the five decisions (Q1-Q5).

Notable finding: the default=str + 24-char-digest drift the directive flags was
replicated into Lane C (biography_wiring.py) AFTER the directive was written —
raising the priority of the D1 semantic-rigor batch.

[Verification]: docs-only; ADR governance provenance-guard green (unchanged).
2026-07-17 13:58:17 -07:00

8.5 KiB
Raw Blame History

Cohesion Directive Audit — repo state vs. engineering_cohesion_refactoring_directive.md

Date: 2026-07-17 Scope: Code-level verification of the seven mandates in docs/analysis/engineering_cohesion_refactoring_directive.md against main @ 24078b11 (post ADR-0243 Phase 3, which landed after the directive was drafted). Related: ADR-0244, ADR-0241, ADR-0242, ADR-0243, docs/analysis/core_cohesion_master_plan.md.


Verdict

The directive is directionally sound but was drafted against a pre-Phase-3 snapshot and, in places, against imagined code. Two mandates (2, 4+5) are accurate and actionable as written. Mandate 1's diagnosis is right but its prescription is already built — the real gap is different (f64, not f32). Mandate 6 is ~85% already implemented; one legibility residual remains. Mandates 3 and 7 describe seams that do not exist yet — they are ADR-0244 implementation work, not refactors of drift. Notable: the default=str + 24-char-digest drift the directive flags was replicated into Lane C (biography_wiring.py) after the directive was written — the drift is spreading, raising the priority of the semantic-rigor batch.


Per-mandate findings

# Mandate Verdict Evidence
1 Rust geometric_product fast path Diagnosis right, prescription stale The 32×32 CPython loop exists (algebra/cl41.py:116). But no _rust_cl41 module — algebra/backend.py:67 already implements the exact f32-gated Rust dispatch the directive prescribes (opt-in via CORE_BACKEND=rust). The real gap: the hot wave-field substrate runs f64; Rust geometric_product_f64 exists (core-rs/src/cl41.rs:126) but is not exported in lib.rs. The D9 parity suite explicitly pins against f32-truncating f64 workloads — the directive's f32-only gate never fires on the actual hot path.
2 _cached_eigh memoization Accurate — apply as written relax_to_ground runs fresh np.linalg.eigh per call on dense H (cognitive_lifecycle.py:546); ProblemHamiltonian is frozen + content-addressed — an ideal memoization key.
3 f64→f32 serving cast Premise false today; prospective identity.py has no numpy/f32 path — pure-Python scalar heuristics; no ψ handoff to IdentityCheck exists. The seam this mandate casts across only comes into being with ADR-0244 §2.12.2. cognitive_lifecycle is also A-04-banned from serve. → fold into the ADR-0244 arc (D4).
4 Full 256-bit digests; kill default=str Accurate; 3 live sites + spreading cognitive_lifecycle.py:128133 (default=str + [:24], incl. _psi_digest), self_authorship.py:4243, and biography_wiring.py:125126 (Lane C, post-directive). holographic_vault.py:74 is already full-length; TurnEvent.trace_hash is already full SHA-256 (the directive's trace-hash claim is stale — already satisfied). CRDT-collision rationale overstates current exposure (multi-writer deferred), but the fix is right and cheap.
5 Little-endian byte-order contract Accurate; zero-risk No byte-order coercion at any digest site. astype('<f8') is a byte-level no-op on our LE platforms → digests unchanged, contract made explicit. Pure hardening.
6 "No sampled unimodality violation" ~85% already built (ADR-0242 V1 + Lane A) fibonacci_search.py already has the sampled check, typed OptimizationFailure, fail-closed nonfinite/bounds, the bracketed-interval contract, and "never a bare float." Lane A's kappa_calibration.py is proposal-only and R-04-compliant. Residual: propose_kappa_from_search returns baseline κ=1.0 on failure — but κ=1.0 is the "parameters unchanged" no-op the directive demands, and the typed failure is already the second tuple element. The fix is legibility + the reason rename, not a behavior change.
7 Insertion-order-independent allocation Premise stale; no live consumer atlas_packing.py is already ordinal-reconstructible (ALLOCATOR_VERSION pinned, "layout regenerates from identity + ordinal k") and has zero production call sites. Building AnchorAllocator now would be a hollow gate; its consumer arrives with ADR-0244 §2.9. → fold into the ADR-0244 arc (D4).

Spec-level wrinkles (all surfaced)

  1. ADR-0244 §2.3 Q_top is likely vacuous — central I₅ in odd Cl(4,1) ⇒ the charge collapses on versor states (the #19 pseudoscalar failure mode). Pending an empirical discriminating counterexample before it can be an egress gate. (Annotated in ADR-0244.)
  2. ADR-0244 §4 contradicts §2.12.2 — per-axis resonance vs. Gram-projection/leakage-norm/ManifoldConditioningError; dangling "ADR-0245"; assert byte-order guard (stripped under -O). §2 governs; reconcile before implementation. (Annotated in ADR-0244.)
  3. Directive §4 says "six criteria" but lists five — the missing one is the Mechanical-Sympathy gate (see below); criteria 12 cover Semantic Rigor, 34 honesty/falsifiability, 5 Autonomy/Third-Door — Pillar I had no acceptance criterion.
  4. Quarantine wording — "every refactored module must reside strictly inside evals/" can't apply to an in-place algebra/cl41.py refactor. Adopted reading: new capabilities live in evals/; in-place core refactors keep the A-04 transitive serve-quarantine + smoke/fast-lane gates until acceptance.
  5. Doc placement — the directive's canonical path is docs/analysis/; it sat untracked at docs/. The untracked docs/research/core_cohesion_master_plan.md and docs/research/ADR-0243-…md are stale raw re-exports (the research master-plan predates the AGENTS.md R-01 doctrine note the tracked docs/analysis/ copy carries); removed, not committed.
  6. Directive perf numbers (~40µs/call GP, 50200µs eigh) are unverified assertions — benchmarks/apple_uma_mechanical_sympathy.py measures them as the D2 evidence rather than taking them on faith.

Amended mandate → work-item mapping

Directive mandate Where it lands Amendment
M4 + M5 (digests, byte-order) D1 semantic rigor apply as written; +Lane C site
M2 (_cached_eigh) D2 mechanical sympathy apply as written
M1 (Rust GP) D2 mechanical sympathy f64, bit-identical parity (not the already-built f32 gate)
M6 (unimodality) D3 search honesty legibility + rename; behavior already correct
M3 (f64→f32 cast) D4 ADR-0244 arc seam does not exist yet
M7 (allocator) D4 ADR-0244 arc no live consumer yet

The sixth acceptance criterion (Pillar I coverage gap)

Directive §4 lists five gates but claims six. The missing one closes the Mechanical-Sympathy pillar, which otherwise has no acceptance test:

6. Mechanical-Sympathy Gain. An accelerated path must demonstrate a measured, reproducible M1/UMA speedup (committed benchmark artifact, benchmarks/apple_uma_mechanical_sympathy.py) while the parity gate (criterion 1) holds. An "accelerated" path that does not beat the pure-Python baseline is rejected. This prevents shipping a fast path that isn't faster.


Decisions (per the "most genius/optimal" directive)

  • Q1 (M1): expose Rust f64 GP; parity contract = bit-identical (matched i-major scatter order, no FMA), not tol-matched — else flipping CORE_BACKEND=rust breaks I-02 replay-determinism (_psi_digest/wave-residual bytes shift). Fail-closed on any ULP divergence over N=10,000; if bit-identity is unattainable, the f64 Rust path is not shipped.
  • Q2 (M6): κ=1.0-on-failure is the required "parameters unchanged" no-op, and the typed OptimizationFailure is already returned alongside — so the fix is legibility (a test pinning that failure surfaces as OptimizationFailure) + the reason rename to sampled_unimodality_violation_observed, not breaking the working seam.
  • Q3: the sixth criterion is the Mechanical-Sympathy gate above; adopt the quarantine reading in wrinkle #4.
  • Q4 (ADR-0244 §2.3): keep Q_top pending an empirical non-vacuity demonstration; do not wire it as an egress gate; retire if no counterexample.
  • Q5 sequencing: ADR-0243 Phase 4 → Phase 5 → D0 (this) → D1 (semantic rigor) → D2 (mechanical sympathy) → D3 (search honesty). D4 = ADR-0244 implementation, own plan after §4-vs-§2 + Q_top are resolved in the ADR.

Every D-batch PR: in-worktree smoke gate + fast lane green before merge; merge-commit on explicit authorization; local-first CI.