From 5ebad71ab674fb7b814d572d6f5b9946070f2135 Mon Sep 17 00:00:00 2001 From: Shay Date: Wed, 15 Jul 2026 12:49:00 -0700 Subject: [PATCH] docs(research): W1 adversarial findings + 4-blueprint integration plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - adversarial-and-fidelity-findings: executed hostile verification of the merged ADR-0241/0242 surface (chiral non-vacuity Q=-2.5 conserved exactly; Fibonacci cert budget-exact across 8/15/20/21 + digest-stable; P9 seal SPECULATIVE-only; ledger spot-check incl. the prose-only anyon V5 row; Finding #2 serve breach — fixed in the preceding commit). - blueprint-integration-plan: every mechanism of the 4 authority docs dispositioned (faithful / honest-deviation / missing-piece / scrap / staged). Missing pieces tracked: chiral sign-preservation gate (§5.2, next PR) and CRDT-vs-bit-exact determinism clarification. ADR-0242 memo slice pending its local export. --- ...-0242-adversarial-and-fidelity-findings.md | 122 ++++++++++++++++++ ...dr-0241-0242-blueprint-integration-plan.md | 91 +++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 docs/research/adr-0241-0242-adversarial-and-fidelity-findings.md create mode 100644 docs/research/adr-0241-0242-blueprint-integration-plan.md diff --git a/docs/research/adr-0241-0242-adversarial-and-fidelity-findings.md b/docs/research/adr-0241-0242-adversarial-and-fidelity-findings.md new file mode 100644 index 00000000..e2c05561 --- /dev/null +++ b/docs/research/adr-0241-0242-adversarial-and-fidelity-findings.md @@ -0,0 +1,122 @@ +# ADR-0241/0242 — Adversarial Verification & Blueprint-Fidelity Findings (W1) + +**Author:** Claude (fresh-eyes adversary; did not author the code under attack — P7/P8/cert/seal are Gemini/Grok-session work). +**Date:** 2026-07-15 +**Base under attack:** `forgejo/main @ 4853a55c` (post #38 merge + debug-print revert), worktree `feat/adr-0241-0242-mastery-close`. +**Method:** line-level read **plus hostile execution** (grade decomposition, live func-call counters, `sys.modules` import-graph trace, `-X importtime` ancestry), not read-only inspection. All 3 dedicated suites independently re-run green (46 passed). + +**Yardstick:** the 4 authority blueprints in `docs/research/*.gdoc`. ADR-0241 read in full; core_ha + fibonacci_applications read; **ADR-0242 "deterministic-fibonacci-operators-and-evidence-gated-optimization" memo not yet available as a local export** — its fidelity slice is partial (noted below). + +--- + +## Verdict summary + +| # | Attack target | Verdict | Severity | +|---|---------------|---------|----------| +| 1 | Chiral non-vacuity (P8) | ✅ **CONFIRMED SOLID** — genuinely non-vacuous, exactly conserved | — | +| 3 | Fibonacci cert: budget exactness + digest stability (V1) | ✅ **CONFIRMED SOLID** | — | +| 4 | P9 seal discipline (SPECULATIVE-only) | ✅ **SOLID** + one precision wrinkle | LOW | +| 5 | Fidelity-ledger spot-check | 🟡 mostly honest, **one prose-only green row** | LOW | +| 2 | Serve-quarantine transitivity (A-04) | 🔴 **LIVE BREACH — not a coverage gap** | **HIGH** | + +--- + +## 🔴 Finding #2 (HIGH) — the serve quarantine is breached transitively + +**Claimed invariant.** A-04 (`test_phase0_a04_serve_path_quarantines_wave_and_fibonacci`) + ledger §12 row *"Serve path not wired to wave / Fibonacci (containment) 🟢"* + module docstrings (`wave_manifold`: "Off-serving until explicit gates"; `wave_energy_boundary`/`multi_scale_energy`: **"never serve"**). The stated invariant is **process-level**: the serve path must not pull in the wave/fibonacci substrate. + +**What is actually true.** Importing `chat.runtime` transitively loads **five** banned modules into `sys.modules`: +`core.physics.wave_manifold`, `core.physics.holographic_vault`, `core.physics.fibonacci_search`, `core.physics.multi_scale_energy`, `core.physics.wave_energy_boundary`. + +**Exact chain (`-X importtime` ancestry):** +``` +chat.runtime → chat.pack_grounding → packs.anchor_lens.loader → formation.smelter + → teaching.correction → generate.intent → generate.proposition + → field.state → field.propagate → core.physics.energy → [core/physics/__init__.py barrel] + → goldtether → wave_manifold + → wave_energy_boundary → fibonacci_search + → multi_scale_energy + → holographic_vault +``` + +**Root cause.** `core/physics/__init__.py` is a **barrel init that eagerly imports the entire physics surface**, including `wave_manifold` (line 72), `goldtether` (line 28, which itself hard-imports `WaveManifold` at `goldtether.py:35`), `holographic_vault`, `wave_energy_boundary`, `multi_scale_energy`. `field/propagate.py` needs only `from core.physics.energy import FieldEnergyOperator` — one lightweight submodule — but importing any `core.physics.*` submodule runs the barrel and drags in everything. + +**Why the pin missed it.** The A-04 test walks only `chat/runtime.py`'s **own** AST import nodes → catches **direct** imports only. A 2+-hop chain through a package barrel is invisible to it. Demonstrated: direct `import wave_manifold` → flagged `True`; transitive chain → flagged `False`. No complementary `sys.modules` guard exists anywhere in the suite. + +**Severity = HIGH.** This directly falsifies a 🟢 acceptance-checklist row Joshua would rely on to Accept, loads modules explicitly labeled "never serve" into the serve process (startup cost + memory + containment-doctrine violation), and — because the guarding pin stays green — a future edit to `energy.py`/`goldtether` could begin *invoking* wave functions on the hot path with nothing to catch it. + +### Design-intent fork (Joshua's call — not mine to decide) +`wave_manifold` sits on **both** sides: the subsumption map says `goldtether`/`surprise`/`biography` (Third-Door serve operators) **delegate to** `WaveManifold` (`goldtether.coherence_residual` → `WaveManifold().measure_unitary_residual`), yet `wave_manifold` is on the A-04 **ban** list. Both cannot be true. Two honest resolutions: + +- **(A) Quarantine wave_manifold for real:** de-barrel the off-serving modules (PEP 562 lazy `__getattr__` in `core/physics/__init__.py`) **and** make `goldtether`'s `WaveManifold` import lazy (2 call sites). Restores the letter of A-04. Only coherent if serving never calls `coherence_residual` on the hot path. +- **(B) Accept wave_manifold as serve substrate:** remove `wave_manifold` from the A-04 ban list, correct the ledger row, and keep only the genuinely-off-serving research modules quarantined (`multi_scale_energy`, `wave_energy_boundary`, `holographic_vault`, `fibonacci_search`, `wave_seam`, `sensorium_wave_feed`, `atlas_packing`). + +**Unambiguous either way:** the modules labeled *"never serve"* must leave the barrel's eager path, and a **transitive `sys.modules` guard test** must replace/augment the direct-AST pin so this can never regress silently. + +--- + +## ✅ Finding #1 — Chiral non-vacuity (P8): CONFIRMED SOLID + +Blueprint ADR-0241 §2.4C: `Q = ⟨ψ I₅ ψ̃⟩₀`, non-vacuous for odd-capable mixed-parity spinors, conserved under `ψ → Rψ`. + +Executed with the algebra's **graded-lexicographic** convention (grade-1 = idx 1–5; my first probe's bit-count grade map was wrong and is discarded): +- Fixture `psi = v + v·I₅`, `v = e1 + 0.5·e3` → grades **{1: 1.118 (odd), 4: 1.118 (even)}** — genuinely mixed parity, **not** a pure even field-state. +- `Q(psi) = −2.5` (|Q| ≫ 0.1 threshold — comfortably non-zero, not borderline). +- Conserved under `left_spinor_step`: drift `|q0 − q1| = 0.000e+00` (exact). +- Even unit versor → `Q = 0.000e+00` (honest; does **not** revive the retired-#19 vacuous gate). + +**Fidelity win:** the blueprint's own §4 prototype used `np.outer(psi_B, psi_A)` + `la.svd` (Euclidean matrix proxies). The implementation correctly rejected that in favor of exact `geometric_product`/`cga_inner`. The impl is *more faithful to the algebra than the blueprint's reference code.* + +--- + +## ✅ Finding #3 — Fibonacci cert (V1): CONFIRMED SOLID + +- **Budget exactness** via a live func-call counter across budgets **8/15/20/21**: actual `func` calls == `cert.evaluations` == `budget` == `len(ordered_points)` in every case. No off-by-one at bracket init. (Structurally: 2 initial evals + `(n−2)` single-eval loop iterations = `n`.) +- **Digest stability:** dual independent runs → identical `cert_id` (64-hex) and identical `as_dict()`. Pure arithmetic (no RNG / set-ordering), so bit-stable by construction. +- Typed `Certificate | Failure` surface; fail-closed on nonfinite / unimodality / bounds; never a bare float. + +**Precision nit (LOW):** the certificate's `minimizer` returns `best_x` (a sampled point) when it lies inside the final bracket, else the midpoint — but the docstring says *"Drive cert uses midpoint of final bracket."* Code prefers the better sample; harmless, but doc and code disagree. One-line doc fix. + +--- + +## ✅ Finding #4 — P9 seal discipline: SOLID (one precision wrinkle, LOW) + +- `HolographicVaultStore.seal_mode` sets `EpistemicStatus.SPECULATIVE` by construction (`holographic_vault.py:153`); COHERENT lives only in `seal_mode_reviewed(authorized=True)` (refuses without authorization). `speculative_seal_from_contemplation` calls **only** `seal_mode`, with a defensive re-check that raises on any non-SPECULATIVE return. Contemplation can never emit COHERENT. ✅ +- `reconstruct_as_evidence` excludes SPECULATIVE (min_status=COHERENT) and refuses on empty spectrum. ✅ + +**Precision wrinkle:** the stated invariant is *"physics never imports teaching,"* but `core/physics/holographic_vault.py:30` imports `teaching.epistemic.EpistemicStatus`. The **tested** invariant (`test_wave_manifold_module_does_not_import_teaching`) guards only `wave_manifold.py`, which is clean. Not a live breach — `EpistemicStatus` is boundary vocabulary — but the clean "physics ⊥ teaching" story has one sanctioned seam. Design note: consider relocating `EpistemicStatus` to a shared non-teaching kernel (e.g. `core/epistemic_state.py`) so the boundary is literal. + +--- + +## 🟡 Finding #5 — Fidelity-ledger spot-check: mostly honest, one prose-only green + +Mapped 4 §12 rows → named pins: +1. *"Chiral non-vacuous … conserved … even ~0"* → `test_chiral_charge_{nonzero,conserved,honest}` — fails if Q=0 / not conserved. ✅ real behavioral pin. +2. *"Fibonacci cert/failure (V1)"* → `test_fibonacci_search_eval_count_equals_budget` + `test_certificate_digest_stable_dual_run` — fails on off-by-one / digest drift. ✅ real. +3. *"Serve path not wired (containment)"* → `test_phase0_a04…` — maps to a real pin, **but the prose "not wired" overstates a direct-import-only test** (see Finding #2). Downgrade the claim or strengthen the pin. +4. *"Fibonacci anyons (V5) 🟢 quarantine package only; zero production imports"* → **no anyon package exists in the repo and no test references "anyon."** A 🟢 row with no code and no pin — the "namesake-green" trap §7 warns about. "Zero production imports" is vacuously true of a nonexistent module. **Downgrade to "not built / claim-quarantined"** (consistent with the R&D-memo anyon "immune to float32 drift" claim being deliberately not implemented). + +Other V-vectors (V2 `multi_scale_energy`, V4 `fibonacci_word_schedule`, sensorium, `wave_energy_boundary`, `atlas_packing`) each carry 2–4 real test files. + +--- + +## Blueprint fidelity (ADR-0241) — deviations for the acceptance packet + +| Blueprint clause | Implementation | Fidelity | +|---|---|---| +| §2.4A analogical = **closed-form Clifford polar** `C=RS`, extract R directly | **Demoted** to numerical sandwich conjugacy (SVD + Spin GN); `test_true_clifford_polar_fails_on_multigrade_field` proves `~C C` is non-scalar for multigrade fields → analytic polar **ill-posed** | **Honest deviation** — recommend accept-as-honest per the #19 RETIRE precedent. **P7 headline for Joshua.** | +| §2.4C chiral grade-5 charge | Faithful + non-vacuous (Finding #1) | ✅ | +| §2.4D GoldTether = unitary amplitude residual | `measure_unitary_residual` dual-checks `‖ψψ̃−1‖` | ✅ | +| §2.2 holographic recall = **exact reconstruction, zero thaw loss** | `resonant_recall`/`resonant_reconstruct` + durable `HolographicVaultStore`, but **float32 storage** (I-02 honest tol 1e-6, not bit-exact 1e-12) | Softened to "float32-honest" — already flagged in-suite; note for ruling | +| §2.3 continuous multimodal / sensorium | **Staged/fake sensorium packets** + real ρ (`sensorium_wave_feed`) | Open by design (W5) | +| §5.2 MLX/UMA + Rust exact GP | `algebra.backend` P11a (Rust-ready; Python is truth); f64 GP parity deferred (D9) | Staged | + +**ADR-0242 memo slice — partial:** the "deterministic-fibonacci-operators-and-evidence-gated-optimization" R&D memo is not yet available as a local export, so the memo-vs-impl fidelity check is incomplete. What is verifiable: the implementation's Fibonacci cert is solid (Finding #3), and the memo's flagged-dubious claims appear correctly filtered — the **anyon** claim is not built (Finding #5), and the "Fibonacci division-cost" R&D claim did not land as a production optimization. Full slice pending the memo export. + +--- + +## Recommended actions + +1. **Finding #2 (HIGH)** — resolve before Accept. Unambiguous part: de-barrel the "never serve" modules from `core/physics/__init__.py` (lazy `__getattr__`) + add a transitive `sys.modules` guard test. Design fork (A vs B on `wave_manifold`) → Joshua. +2. **Finding #4 / #5 / #3 nits (LOW)** — batch: relocate `EpistemicStatus` (or document the sanctioned seam); downgrade the anyon ledger row; fix the Fibonacci `minimizer` docstring. +3. Everything else verified solid — no other fix-forward required. diff --git a/docs/research/adr-0241-0242-blueprint-integration-plan.md b/docs/research/adr-0241-0242-blueprint-integration-plan.md new file mode 100644 index 00000000..7a960d05 --- /dev/null +++ b/docs/research/adr-0241-0242-blueprint-integration-plan.md @@ -0,0 +1,91 @@ +# ADR-0241/0242 + core_ha + Fibonacci — Blueprint↔Codebase Integration Plan + +**Purpose:** audit **all four authority blueprints** against the current codebase and plan how each mechanism is masterfully worked into the implemented design — retiring or re-shaping old work that doesn't fit the R&D vision **without ever losing the capability it provided**. +**Author:** Claude (fresh-eyes). **Date:** 2026-07-15. **Base:** `feat/adr-0241-0242-mastery-close` off `forgejo/main @ 4853a55c`. +**Companion:** `adr-0241-0242-adversarial-and-fidelity-findings.md` (the W1 hostile-verification results this plan builds on). + +**Authority docs & availability:** +| Doc | Read | Status | +|---|---|---| +| ADR-0241 wave-field hyperbolic atlas + resonant cognition | ✅ full | audited deep | +| core_ha unification & deprecation plan | ✅ full | audited | +| fibonacci_applications_in_core_substrate | ✅ full | audited | +| ADR-0242 deterministic-fibonacci-operators + evidence-gated-optimization | ❌ **no local export** | **BLOCKED — needs export**; cert impl verified against its own contract | + +--- + +## 1. The governing reconciliation + +The recurring pattern across all four docs: the blueprints were written when the **wave-field was speculative**, so they hedged it as "off-serving / separate database / optional." The implementation then made the wave substrate **load-bearing** (Third-Door serve operators delegate to it). Where an old boundary or claim no longer fits, we **retire it and re-develop the capability in the shape the R&D actually validated** — matching your "field = electricity" principle: the field is the substrate everything runs on. + +**Already landed this session (first instance):** the serve-quarantine reconciliation — one substrate, two tiers (T1 sanctioned serve = `wave_manifold`; T2 evidence-gated off-serving = holographic vault, Fibonacci/energy research). De-barreled `core/physics/__init__.py`, added the transitive `sys.modules` guard, corrected A-04 + ledger. 179 affected tests green. + +--- + +## 2. Per-mechanism disposition (every clause, 5 buckets) + +### ✅ FAITHFUL — built and verified +| Blueprint clause | Landed | Evidence | +|---|---|---| +| ADR-0241 §2 ψ transport (sandwich + left-spinor) | `wave_manifold.sandwich_step`/`left_spinor_step` | unitary residual <1e-6, determinism pinned | +| §2.4B surprise = non-resonant spectral leakage | `compute_spectral_leakage` (metric-exact) | delegates from `surprise_residual` | +| §2.4C chiral grade-5 charge (readout) | `chiral_charge` | **Q=−2.5 non-vacuous, conserved exactly** (executed) | +| §2.4D GoldTether unitary residual | `measure_unitary_residual` | dual-checked ‖ψψ̃−1‖ | +| §2.2 holographic recall / standing-wave spectrum | `resonant_recall`/`resonant_reconstruct` + `HolographicVaultStore` | I-01/I-02 suite | +| core_ha runtime_memory → Field Energy E0–E1 deep / E2–E3 active | `energy.py EnergyClass` | E0/E1 `is_deep` ✓ | +| core_ha steward → GoldTether drift gating | `goldtether.py` | ✓ | +| core_ha §5.1 unitary <1e-6 fail-closed | `versor_condition`/`measure_unitary_residual` gates | behavior present | +| core_ha §5.3 Hamiltonian energy boundary `E_exertion ≤ κ·E_sensory` | `trajectory_invariants.energy_boundary_ok` | **exact, +refuses negative energy** | +| Fibonacci §2.1 golden-spiral phyllotaxis packing | `atlas_packing.golden_angle_pack` (`golden_angle_v1`, 137.5°) | V1/V3 | +| Fibonacci §2.3 evidence-gated section search | `fibonacci_section_search` → `FibonacciSearchCertificate` | **budget-exact + digest-stable** (executed) | +| Fibonacci §4 multi-scale `τ_n=F_n·τ_0` | `multi_scale_energy`, `wave_energy_boundary.fibonacci_tau_schedule` | V2 pins | + +### 🟢 HONEST DEVIATION — the impl is *more correct than the blueprint*; keep, document for Joshua +| Blueprint said | Impl did | Why it's forward, not backward | +|---|---|---| +| §2.4A analogical = closed-form Clifford polar `C=RS` | numerical sandwich conjugacy (SVD+Spin-GN) | `test_true_clifford_polar_fails_on_multigrade_field` **proves** `~C C` non-scalar → analytic polar ill-posed for multigrade fields (P7; #19-RETIRE precedent). **Headline for ruling.** | +| §4 prototype `np.outer` + `la.svd` | exact `geometric_product`/`cga_inner` | rejects the blueprint's own Euclidean-matrix proxy | +| Fibonacci §2.3 "avoids division, addition-only" | uses `f_{n-1}/f_{n+1}` float division | the "no-division" micro-claim only holds on an integer lattice; real-bracket subdivision needs division. Dubious perf claim correctly filtered. | +| core_ha §5.1 `ClosureViolationException` (named) | `ValueError`/`WaveSpectralLeakageError` + versor gate | equivalent fail-closed behavior, different type name | +| §2.2 "exact recall / zero thaw loss" | float32-honest (I-02 tol 1e-6, not 1e-12) | honest about storage precision instead of over-claiming bit-exactness | + +### 🔨 MISSING PIECE — capability the vision specifies but the code does **not** yet enforce; **build anew** so we don't go backwards +| Missing invariant | Current state | Build | +|---|---|---| +| **Chiral SIGN-preservation gate** (ADR-0241 §2.4C + core_ha §5.2: `sgn(∫⟨ψIψ̃⟩₀)=const`, mirror-inversion protection) | `chiral_charge` is a verified non-vacuous **readout**, but its only consumer (`goldtether.py:230`) takes `abs(...)` — **discarding the sign** — and it's ~0 on serve-path even-versors. No fail-closed `sgn(Q)=const` gate exists. | A `chiral_orientation_gate` that latches the initial sign and fails closed on flip during transport; wire the *signed* charge (not `abs`) where a non-vacuous spinor path exists. Preserves the "topologically secure alignment" the blueprint promises. | +| **CRDT delta-sync semilattice** (core_ha §2/§3 tombstone → "commutative/associative/idempotent Delta-CRDT in `core/sync/`") | `core/sync/` is a journal/object-store (no `merge`/idempotent/semilattice semantics found). Determinism today = bit-exact `array_codec` + single-writer `VaultStore` (Shape B+), **not** multi-writer CRDT merge. | Decide: either build the CRDT (needed for genuine multi-agent/multi-writer "one continuous life") **or** correct the doc to state determinism is single-writer bit-exact. Don't leave the claim floating. | + +### ⛔ SCRAP / DO-NOT-BUILD — correctly rejected over-claims +| Blueprint clause | Disposition | +|---|---| +| Fibonacci §2.2 **anyons** "immune to float32 drift" | Most speculative claim in the corpus; **not built** (no package, no test). Correct call — "float32-immune topological logic" is an over-promise. **Action:** downgrade the ledger's `V5 anyons 🟢` row to "not built / claim-quarantined" (namesake-green, Finding #5). Revisit only if non-abelian braiding is explicitly greenlit. | + +### 🕗 STAGED / GATED — deferred by design, not regression +- Rust wave kernels (bivector exp-map, `C_AB`, `versor_unit_residual`) in `core-rs/{lib,versor,diffusion,vault}.rs` — files exist; f64 GP parity **deferred (D9)**; Python is truth via `algebra.backend` (P11a). +- Sensorium §2.3 continuous multimodal — staged/fake packets + real ρ (`sensorium_wave_feed`); real compilers open. +- Continuous field integrals — mode samples today. +- T2 serve promotion — evidence-gated (ADR-0242 cert discipline). + +--- + +## 3. Invariant preservation (your named guardrails) + +| Requirement | Held? | How the reconciliation protects it | +|---|---|---| +| **Determinism** | ✅ | T1 wave ops closed-by-construction, no RNG; Fibonacci cert bit-stable; T2 gating = "evidence-gated optimization" (never promote without replayable cert). The one open item (CRDT vs bit-exact) is a *determinism-mechanism* clarification, not a hole. | +| **Safety + alignment** | ✅/🔨 | GoldTether stays the alignment gate on the real substrate (strengthened). **The missing chiral sign-gate is an alignment capability to restore** — mirror-orientation is part of "topologically secure alignment." Safety/ethics/refusal packs untouched. | +| **core_logos** | ✅ | Articulation layer above physics; unaffected by substrate boundary moves. | +| **Substrate goals: memory / logic-topology / thermodynamics** | ✅ | Memory = holographic vault (T2, persistence-gated). Logic-topology = Cl(4,1) ψ field promoted to live substrate (T1). Thermodynamics = `energy.py` + `energy_boundary_ok` (faithful) + gated multi-scale research (T2). | + +--- + +## 4. Sequenced build plan (no capability regression) + +1. **DONE** — Finding #2 serve-boundary reconciliation (de-barrel + transitive guard + A-04/ledger correction). Green. +2. **Next fix-forward (LOW, batch):** downgrade anyon ledger row; `EpistemicStatus` boundary note (or relocate to shared kernel); Fibonacci `minimizer` docstring; `ClosureViolationException` naming note. +3. **Build-anew (capability):** chiral **sign-preservation gate** (§5.2) — the one true missing safeguard; TDD a `sgn(Q)=const` fail-closed gate + signed wiring. +4. **Decision + build/doc:** CRDT-vs-bit-exact determinism story for `core/sync` (affects multi-agent "one continuous life"). +5. **Get ADR-0242 memo export** → close its fidelity slice (evidence-gated-optimization vs the cert impl; confirm no further deviations). +6. Staged/gated items (Rust parity D9, sensorium compilers, continuous integrals) remain post-Accept backlog. + +**Acceptance framing:** ADR-0241/0242 are Accept-ready on the FAITHFUL + HONEST-DEVIATION set once #2 lands green (in progress). The MISSING-PIECE items (chiral sign-gate, CRDT clarification) are **new capability work**, not blockers — but they must be tracked so the vision's safeguards aren't quietly dropped.