diff --git a/.gitignore b/.gitignore index 7331f4a8..53c8c3c8 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,7 @@ engine_state/_life_backup_*/ # Local MCP configuration (contains local tokens) .mcp.json + +# Google Drive sync pointer stubs (JSON pointers to Drive docs, not content). +# The canonical committed copy of any R&D doc lives under docs/ as real markdown. +*.gdoc diff --git a/docs/adr/ADR-0243-wave-field-cognitive-lifecycle-comprehension-reasoning-and-resonant-learning.md b/docs/adr/ADR-0243-wave-field-cognitive-lifecycle-comprehension-reasoning-and-resonant-learning.md new file mode 100644 index 00000000..b21967dd --- /dev/null +++ b/docs/adr/ADR-0243-wave-field-cognitive-lifecycle-comprehension-reasoning-and-resonant-learning.md @@ -0,0 +1,309 @@ +# ADR-0243: Wave-Field Cognitive Lifecycle — Comprehension, Resonant Reasoning, and Lifelong Learning + +**Status**: Proposed (acceptance path: benchmark evidence \+ Joshua review) +**Date**: 2026-07-14 +**Deciders**: Joshua Shay \+ multi-model R\&D +**Traceability**: Notion R\&D (Engineering Reference Vault Interconnection: `core_HA` Patterns) +**Related**: ADR-0003, ADR-0006, ADR-0238, ADR-0239, ADR-0240, ADR-0241, ADR-0242, `core/physics/wave_manifold.py` +**Canonical path**: `docs/adr/` + +--- + +## 1\. Context and Problem Statement + +With the successful unification of the **$Cl(4,1)$ Conformal Wave-Field ($\\psi$)** substrate ([ADR-0241](https://drive.google.com/file/d/1F_7QYtPysBP4qMbLGlGPnXgYx9IXug8nUYrpiCGSunE/view?usp=drivesdk)) and the implementation of the **Deterministic Fibonacci search** ([ADR-0242](https://drive.google.com/file/d/15_NECCPy-tEWGfYi_BNqawm8GytUTMkz1DsOqGVMXhI/view?usp=drivesdk)), CORE's physical layer has reached structural maturity. + +However, we must now define how these new physical and geometric evolutions are leveraged to solve the fundamental cognitive tasks where traditional architectures struggle: + +- **Comprehension & Ingress**: Traditional architectures parse and embed inputs into flat, context-dry vectors, leading to representation drift, attention decay over long contexts, and loss of structural relations. +- **Problem Solving & Reasoning**: Traditional systems treat reasoning as probabilistic path-search or auto-regressive step generation. This lacks mathematical guarantees of correctness and suffers from cumulative error propagation. +- **Egress & Generation**: Probabilistic autoregressive decoding selects discrete tokens one-by-one via softmax sampling, which has no global coherence guarantees, leading to hallucinations and semantic drift. +- **Contemplation & Learning**: Standard models require gradient-descent backpropagation to update static weights, which is computationally expensive, non-reconstructible, and prone to catastrophic forgetting. + +This ADR defines the complete **Wave-Field Cognitive Lifecycle**, leveraging the wave function to establish a fully deterministic, closed-loop, physical-relaxation-based paradigm for comprehension, reasoning, generation, and learning. + +--- + +## 2\. Decision and Architectural Formulation + +We dissolve the probabilistic, token-by-token paradigm of classical AI. We establish that **cognition is the continuous physical evolution, resonance, and relaxation of a Conformal Wave-Field ($\\psi$) across a single $Cl(4,1)$ geometric substrate**. + + \[INGRESS\] \[REASONING\] \[EGRESS\] + + Continuous Modalities Hamiltonian Well (H\_p) Thermodynamic State + + | | | + + v (Superposition) v (Physical Relaxation) v (Energy Class check) + + Ingress Wave (psi\_in) \=======\> Steady State (psi\_final) \=======\> Linguistic Readback + + ^ ^ | + + | (Resonant recall) | (Unitary update) v (GoldTether Gate) + + Standing-Wave Atlas \<===================+===========================\> safe, aligned output + + | + + v (Verified holonomy R) + + Biography update (R\_bio) + +--- + +### 2.1 Ingress and Reading Comprehension: Wave Ingestion and Holomorphic Dispersion + +Reading comprehension is modeled as **Wave-Packet Ingestion and Holomorphic Dispersion**, replacing flat token embeddings. + +1. **Ingress Wave Packet**: An incoming text block, symbolic formula, or multimodal sensory stream is compiled into a localized, coherent wave packet $\\psi\_{ ext{context}}(X)$. This compilation preserves spatial-temporal phase relationships: $$\\psi\_{ ext{context}}(X) \= \\sum\_i c\_i \\psi\_{ ext{token}\_i}(X)$$ +2. **Holomorphic Dispersion**: As $\\psi\_{ ext{context}}$ is injected, it propagates through the `VocabManifold`. Proximity and meaning are not calculated via nearest-neighbor vector scans. Instead, the wave disperses and performs parallel cross-correlation with the registered standing-wave modes ${\\psi\_k}$ of the Hyperbolic Atlas, generating a spectrum of resonant coefficients: $$R\_k \= \\int\_M \\langle \\psi\_{ ext{context}}(X) \\widetilde{\\psi}\_k(X) angle\_0 dX$$ This represents the instant, parallel projection of the input context onto the entire known semantic manifold. + +--- + +### 2.2 Reasoning and Problem Solving: Hamiltonian Well Relaxation + +Problem-solving is re-engineered as a **Physical Wave-Field Relaxation Process**, replacing probabilistic step-by-step tree search. + +1. **The Problem Hamiltonian**: The constraints and boundary conditions of a given problem (e.g. mathematical equalities, safety rules, or logical premises) are formulated as potential energy barriers or wells in a problem-specific Hamiltonian operator $\\mathcal{H}\_{ ext{problem}}$. +2. **Relaxation to Eigenstates**: The ingress wave field $\\psi\_{ ext{context}}(X)$ is set as the initial state $\\psi(X, 0)$. The system is allowed to evolve under the Algebraic Schrödinger Equation: $$\\partial\_t \\psi \= \\mathcal{H}*{ ext{problem}}(\\psi) I$$ Through this evolution, the wave field naturally disperses away from high-potential barriers (representing logical contradictions or safety violations) and settles (relaxes) into the lowest-energy, stable standing-wave eigenmodes of the problem manifold: $$\\psi*{ ext{steady}}(X) \= \\lim\_{t o \\infty} \\exp\\left( \\mathcal{H}*{ ext{problem}} I t ight) \\psi*{ ext{context}}(X)$$ The resulting steady-state wave $\\psi\_{ ext{steady}}(X)$ represents the exact, geometrically congruent solution to the problem. It is mathematically guaranteed to satisfy all boundary conditions with zero room for intermediate fabrication. + +--- + +### 2.3 Egress and Generative Articulation: Thermodynamic Wave Readback + +We replace probabilistic softmax token generation with **Thermodynamic Wave Readback**, providing ironclad coherence guarantees. + +1. **Thermodynamic Energy Classes**: The Field Energy Operator ($H$, defined in [ADR-0006](https://core-gitquarters.acbcontent.org/core-labs/core/src/branch/main/docs/adr/ADR-0006-field-energy-operator.md)) evaluates the "energy class" (E0 to E4) of the relaxed wave-field $\\psi\_{ ext{steady}}(X)$. + - **E0/E1 (Crystalline/Stable)**: Represents cold, settled knowledge. It is bypassed for generation and vaulted into the sharded Delta-CRDT registers. + - **E3/E4 (Hot/Critical)**: Indicates a high-activation, settled state that carries maximum semantic charge and "wants" to be articulated. +2. **Linguistic Readback**: For E3/E4 states, the system invokes the readback rules of the active language pack (`en/readback_rules.py`, `he/readback_rules.py`, `el/readback_rules.py`). These rules map the geometric components—the principal bivector directions and scale-invariant parameters of the wave field—directly to symbolic tokens or motor commands. +3. **GoldTether Gate**: Before any token or continuous action is permitted to exit the boundary, the **GoldTether unit residual** is evaluated: $$R\_{ ext{GoldTether}} \= \\sup\_{X \\in M} \\left| \\psi\_{ ext{steady}}(X) \\widetilde{\\psi}\_{ ext{steady}}(X) \- 1 ight|\_F \< 10^{-6}$$ If the generated state would introduce non-unitary drift (hallucination or ungrounded statements), the gate closes instantly, blocking the output and prompting a pre-ratified, safe fallback. + +--- + +### 2.4 Speculative Contemplation and Non-Resonant Curiosity + +Active thinking, self-reflection, and learning are modeled as **Speculative Contemplation and Non-Resonant Curiosity**, replacing classical gradient-descent backpropagation. + +1. **Speculative Generation**: During idle cycles, the contemplation loop (`core/contemplation/runner.py`) speculatively generates wave-packets $\\psi\_{ ext{speculative}}(X)$ representing potential hypotheses or analogical transfers. +2. **Orthogonal Surprise Check**: The non-resonant surprise residual of the speculative wave is evaluated: $$\\mathcal{S}(\\psi) \= \\psi\_{ ext{speculative}} \- \\mathcal{P}*{ ext{resonance}}(\\psi*{ ext{speculative}})$$ + - **Low Surprise**: The hypothesis is fully explained by the existing resonant schema. It is integrated immediately with no learning required. + - **High Surprise (Discovery Signal)**: If $E\_{ ext{surprise}} \> \\gamma$, the speculative wave contains structural novelty. This signal is held as a `DiscoveryCandidate` and routed to the offline review corridor. It does *not* alter active knowledge but directs the self-authorship loop (`core/physics/self_authorship.py`) to generate a proposal to expand the active Hamiltonian $\\mathcal{H}$, enabling structured learning without catastrophic forgetting. + +--- + +### 2.5 Lifelong Resonant Learning: Biography Holonomy Update + +CORE-native learning is the permanent record of the entity's lived experiences as a sequence of geometric transformations. + +Once a sequence of reasoning and action steps is validated (via the validation harness, [ADR-0240](https://drive.google.com/file/d/1eFNoXQl5BbUo6g4GBzRXi5tyIhT5RUGZQG6afaVXTg4/view?usp=drivesdk)), the exact unitary transformation $R \\in Spin(4,1)$ undergone by the wave-field is compiled into the **Biography Holonomy Blade** (`biography.py`): $$\\mathcal{H}*{ ext{bio}} \\leftarrow \\mathcal{H}*{ ext{bio}} \\cdot R$$ This is the ultimate, non-lossy, reconstruction-over-storage compilation of experience. It represents the "wisdom" of the entity, which can be replayed and audited byte-for-byte\! + +--- + +## 3\. Implementation Specification (The Cognitive Relaxation Loop) + +Below is the Python prototype implementing wave-field ingestion, Hamiltonian well relaxation (problem-solving), and the GoldTether egress gate inside the active reasoning pipeline. + +\# core/physics/cognitive\_lifecycle.py + +from \_\_future\_\_ import annotations + +import numpy as np + +import scipy.linalg as la + +from dataclasses import dataclass + +from typing import Callable, Tuple + +N\_COMPONENTS \= 32 + +@dataclass(frozen=True, slots=True) + +class IngressWavePacket: + + psi: np.ndarray \# 32-vector coefficients + + domain\_id: str + +@dataclass(frozen=True, slots=True) + +class EgressVerdict: + + admitted: bool + + wave\_out: np.ndarray + + residual: float + + message: str + +class CognitiveLifecycleEngine: + + def \_\_init\_\_(self, epsilon\_drift: float \= 1e-6): + + self.epsilon\_drift \= epsilon\_drift + + self.I \= np.zeros((N\_COMPONENTS, N\_COMPONENTS)) + + \# Central pseudoscalar proxy + + for i in range(N\_COMPONENTS // 2): + + self.I\[2\*i, 2\*i+1\] \= 1.0 + + self.I\[2\*i+1, 2\*i\] \= \-1.0 + + def ingest\_context(self, tokens: list\[np.ndarray\], domain\_id: str) \-\> IngressWavePacket: + + """ + + Compiles discrete symbolic token wave-packets into a superposed, + + coherent IngressWavePacket. + + """ + + psi\_sum \= np.zeros(N\_COMPONENTS, dtype=np.float64) + + for t in tokens: + + arr \= np.asarray(t, dtype=np.float64) + + psi\_sum \+= arr + + \# Normalize to preserve unitary probability amplitude + + norm \= np.linalg.norm(psi\_sum) + + psi\_norm \= (psi\_sum / norm) if norm \> 1e-12 else psi\_sum + + return IngressWavePacket(psi=psi\_norm, domain\_id=domain\_id) + + def solve\_via\_relaxation( + + self, + + ingress: IngressWavePacket, + + H\_problem: np.ndarray, + + relaxation\_steps: int \= 100, + + dt: float \= 0.01 + + ) \-\> np.ndarray: + + """ + + Solves a problem via continuous wave-field relaxation. + + The wave relaxes into the minimum-energy eigenstate of H\_problem. + + """ + + psi \= ingress.psi.copy() + + \# Schrödinger propagator: R \= exp(H\_problem \* I \* dt) + + generator \= np.dot(H\_problem, self.I) + + R \= la.expm(generator \* dt) + + + + \# Relaxation loop (Euler/exponential integrator) + + for \_ in range(relaxation\_steps): + + psi \= np.dot(R, psi) + + \# Enforce the null-cone amplitude normalization step + + norm \= np.linalg.norm(psi) + + if norm \> 1e-12: + + psi /= norm + + + + return psi + + def egress\_gate(self, psi\_steady: np.ndarray) \-\> EgressVerdict: + + """ + + Unitary GoldTether egress gate: blocks non-unitary/hallucinated + + wave-states from entering the readback and serving paths. + + """ + + psi\_arr \= np.asarray(psi\_steady, dtype=np.float64) + + \# Unitary residual check: || psi \* rev(psi) \- 1 ||\_F + + \# rev(psi) proxied via conjugate transpose under I-metric + + psi\_rev \= np.dot(self.I.T, psi\_arr) + + norm\_product \= np.dot(psi\_arr.T, psi\_rev) + + drift \= np.abs(norm\_product \- 1.0) + + + + if drift \> self.epsilon\_drift: + + return EgressVerdict( + + admitted=False, + + wave\_out=np.zeros\_like(psi\_arr), + + residual=float(drift), + + message="REJECTED: Unitary propagator drift exceeds epsilon\_drift limit (ungrounded state)." + + ) + + + + return EgressVerdict( + + admitted=True, + + wave\_out=psi\_arr, + + residual=float(drift), + + message="ADMITTED: Wave-field verified and promoted to readback path." + + ) + +--- + +## 4\. Consequences and Gating Rules + +### 4.1 Benefits + +- **Autoregressive Hallucination Eliminated**: By replacing step-by-step probabilistic token sampling with physical wave relaxation, output generation is strictly constrained by the geometry of the problem Hamiltonian. +- **Zero Coordinate Loss**: Resonant standing-wave lock-in ensures that recalled memories are mathematically exact, preventing the fuzzy centroid degradation of legacy architectures. +- **Topologically Protected Wisdom**: Experience is compiled directly into the Biography Holonomy Blade as unitary rotor products, providing an untamperable, replayable audit trail of lifelong learning. + +### 4.2 Gating Rules + +- **No Direct Hot-Path Promotion**: Reconstructed wave-fields or proposed Hamiltonian adjustments from the self-authorship loop (`core/physics/self_authorship.py`) must never bypass the one-mutation-path. Speculative changes must reside strictly within the `evals/` and `calibration/` quarantine zones until ratified by a signed human certificate. + +--- + +## 5\. References + +1. `docs/adr/ADR-0003-coordinate-system-dissolution.md` — Relational fields replacing coordinate frames. +2. `docs/adr/ADR-0238-GoldTether-Modulated-Supervised-Autonomy.md` — GoldTether residual monitoring. +3. `docs/adr/ADR-0239-Conformal-Procrustes-Surprise-Dual-Operator.md` — Conformal Procrustes and surprise. +4. `docs/adr/ADR-0241-wave-field-driven-hyperbolic-atlas-and-resonant-cognition.md` — Continuous wave-field framework. +5. `docs/adr/ADR-0242-deterministic-fibonacci-operators-and-evidence-gated-optimization.md` — Fibonacci search contract. + diff --git a/docs/plans/adr-0241-0242-mastery-close-status.md b/docs/plans/adr-0241-0242-mastery-close-status.md index 00dad05a..959f84a7 100644 --- a/docs/plans/adr-0241-0242-mastery-close-status.md +++ b/docs/plans/adr-0241-0242-mastery-close-status.md @@ -78,7 +78,7 @@ GitHub Actions became billing-locked (~$6, account-level) mid-arc, forcing a piv ## Current state (2026-07-16) - Both ADRs: **Accepted**, ratified, full audit trail. -- `main` was @ `18d3c70d` at arc close; post-Accept backlog follow-through is on `feat/adr-0241-0242-implementation` (tip includes `d388fc9e` feature commit + status notes; local-first validation; merge when ready). +- Post-Accept backlog **merged**: PR #55 (`d388fc9e` feature commit + status notes) landed on `main` @ `19819194`; all `[Verification]` numbers were independently reproduced by the 2026-07-16 audit (smoke 176; fast lane 11709 passed / 108 skipped; f64 parity 21/21 incl. Rust-path; invariants+demos+A-04 140). Three seam-vs-integration caveats carried into the ADR-0243 arc — see `docs/plans/adr-0243-implementation-plan.md` §1. - CI: **local-first is the real merge gate** (no Docker CI for merge); `uv.lock` committed and locked installs enforced in workflows; optional Mac Act runner must be `ubuntu-latest:host` (native), not `docker://…`. ## Remaining backlog (post-Accept follow-through; 2026-07-16 mastery close) diff --git a/docs/plans/adr-0243-implementation-plan.md b/docs/plans/adr-0243-implementation-plan.md new file mode 100644 index 00000000..77ae2f48 --- /dev/null +++ b/docs/plans/adr-0243-implementation-plan.md @@ -0,0 +1,158 @@ +# ADR-0243 Implementation Plan — Wave-Field Cognitive Lifecycle + +**Status**: Approved by Shay 2026-07-16 (plan-of-record for the 0243 arc) +**Authority docs**: `docs/adr/ADR-0243-wave-field-cognitive-lifecycle-comprehension-reasoning-and-resonant-learning.md` (Proposed), `docs/analysis/core_cohesion_master_plan.md` (canonical, doctrine-annotated) +**Related**: ADR-0006, ADR-0055, ADR-0145, ADR-0238, ADR-0239, ADR-0240, ADR-0241, ADR-0242 +**Prior-arc record**: `docs/plans/adr-0241-0242-mastery-close-status.md` + +--- + +## 1. Inputs carried from the ADR-0241/0242 close audit (2026-07-16) + +The independent audit of PR #55 confirmed the 0241/0242 close as genuine, with three +seam-vs-integration caveats that this arc must resolve or consciously inherit: + +1. **D9 "f64 GP parity" is a Python-SOT freeze, not cross-implementation parity.** + No Rust f64 geometric product exists. All f64 wave-field math stays in Python + until a `geometric_product_f64` PyO3 export is built *and* parity-gated. + Consequence here: the ADR-0243 relaxer is pure-Python f64 by doctrine, and the + master plan's §5 Rust bindings are **deferred** (see §7 below). +2. **The ADR-0242 §5 carry seams have zero live call sites.** `kappa_search_event` + (goldtether) and `cross_band_discovery_gate` (multi_scale_energy) are tested + primitives that nothing live invokes. Phase 3 Lane A wires them. +3. **The I-04 real-compiler sensorium feed is test-only** (correct per A-04 + quarantine) and the audio versor is float32-origin upcast to f64. Phase 3 + Lane B gives the feed its first (off-serving) consumer. + +## 2. Substrate inventory — what exists vs. what this arc builds + +Already landed (verified on `main` @ `19819194`): + +| Lifecycle stage | Existing organ | +| --- | --- | +| §2.1 ingress superposition | `core/physics/sensorium_wave_feed.py` (`ModalityPacket`, `compile_packet_to_psi`, `superpose_packets`, `phase_correlate`) | +| §2.1 resonant projection R_k | `WaveManifold.phase_correlation` / `resonant_recall` / `resonant_reconstruct` | +| §2.3 energy classes E0–E4 | `core/physics/energy.py` (`EnergyClass`, `FieldEnergyOperator`; ADR-0006) | +| §2.3 readback rules | `packs/en/readback_rules.py` (ADR-0145 energy-modulated readback) | +| §2.3 GoldTether residual | `core/physics/goldtether.py` (`coherence_residual`, `GoldTetherMonitor`) + `WaveManifold.measure_unitary_residual` | +| §2.4 surprise + γ check | `core/physics/surprise.py` (`surprise_residual`, `is_discovery_eligible`, `dual_operator`; ADR-0239) | +| §2.4 discovery plumbing | `core/contemplation/runner.py` already accepts a `DiscoveryCandidateSink`; `teaching/discovery.py` `DiscoveryCandidate` (ADR-0055 Phase B) | +| §2.4 self-authorship | `core/physics/self_authorship.py` (`SelfAuthorshipMiner`, I-03 pinned speculative-only) | +| §2.5 biography holonomy | `core/physics/biography.py` (`integrate_biography`, `reconstruct_biography`) — **no live call sites yet** | +| I-01…I-05, A-02/A-04, `core_ha` absence | `tests/test_third_door_cohesion.py` (master plan §3/§8 already pinned; §7 `core_ha` migration is **moot** — package absent and test-pinned) | + +Genuinely unbuilt: the §2.2 relaxation reasoner (`cognitive_lifecycle.py`), the +inter-organ wiring (three lanes), and the §4 falsifiability benchmarks. + +## 3. Sketch-defect ledger (ADR §3 reference prototype) + +Pinned executable in `tests/test_adr_0243_sketch_defect_pins.py`; the reference +prototype must **never** be ported verbatim (precedent: PR #52 sketch-defect pins). + +- **SD-A — the sketch egress gate always rejects.** It computes + `drift = |ψᵀIᵀψ − 1|` with `I` antisymmetric; `ψᵀIᵀψ ≡ 0` identically, so + `drift ≡ 1 > ε` for *every* state, valid or not. A fail-always gate is the + inverse of a hollow gate and equally worthless. The real residual already + exists: `WaveManifold.measure_unitary_residual` / `goldtether.coherence_residual`. +- **SD-B — the sketch "relaxation" cannot relax.** Iterating + `R = expm(H·I·dt)` with renormalization does not settle into the minimum-energy + eigenmode: the generator's spectrum is (block-wise) purely imaginary, so the + iterates oscillate and preserve mode magnitudes; nothing dissipates. Relaxation + to the ground state requires the **dissipative (imaginary-time) semigroup** + `ψ ← normalize(exp(−H·dt)·ψ)` — deterministic power iteration converging at a + rate set by the spectral gap of H. +- **SD-C — the sketch's block matrix "I" is not the Cl(4,1) pseudoscalar action.** + It shares the property I² = −Id but is a different operator from + left-multiplication by e₀e₁e₂e₃e₄ in the real algebra. All algebra goes + through `algebra/` — no bespoke component-shuffling proxies. + +## 4. Deviations ledger (implementation vs. ADR prose — for the acceptance packet) + +- **D-1 imaginary-time relaxer** replaces the sketch's `exp(H·I·t)` loop (SD-B). + Implemented via `np.linalg.eigh` on symmetric H: `exp(−H·dt) = Q·exp(−Λ·dt)·Qᵀ`, + pure numpy f64, no scipy dependency added. +- **D-2 honest guarantee restatement.** The ADR's "mathematically guaranteed … + zero room for intermediate fabrication" is conditional: it holds only insofar + as (a) the Hamiltonian compiler encodes the constraints faithfully, (b) the + ground state is separated by a positive spectral gap, and (c) the iteration has + converged (certified, not assumed). The acceptance packet states it this way. +- **D-3 I-05 reconciliation.** Relaxation is *deliberately non-unitary* inside + the off-serving solver — that is what dissipation is. I-05 (amplitude + conservation) governs live serve-path transitions; the relaxer's terminal + normalize is an **owned construction boundary** per the master plan's + doctrine note (no hot-path drift repair; breaches at the boundary fail closed). +- **D-4 R-02 premise retired at v1 scale.** `expm` of a 32×32 symmetric matrix + in numpy is trivial; no Rust port is needed or permitted (caveat 1) for v1. +- **D-5 E0/E1 crystallization is proposal-only.** No vault writes from the + lifecycle; cold states emit a typed crystallization *proposal artifact* + through the one-mutation-path (I-03), never a direct `COHERENT` write. + +## 5. Phases + +- **Phase 0 — Governance + doc hygiene** (this PR): commit ADR-0243 verbatim as + Proposed; sketch-defect pins; `*.gdoc` gitignored; stale prior-arc status line + fixed; this plan committed. Local strays (research-copy duplicates, + `core-rs/uv.lock`) removed from the working tree. +- **Phase 1 — merged into Phase 0** (pins land with the plan). +- **Phase 2 — flagship `core/physics/cognitive_lifecycle.py`** (1 PR): Tier-2 + off-serving (A-04 list + lazy barrel + transitive guard). Typed + content-addressed `ProblemHamiltonian` compiler for two checkable domains only + (propositional penalty projectors; convex quadratic). Imaginary-time relaxer + (D-1) with convergence certificate (eigen-residual + gap estimate) and typed + fail-closed errors. Egress verdict composing `measure_unitary_residual` + + `coherence_residual` + `EnergyClass` routing (E0/E1 → proposal artifact per + D-5; E3/E4 → readback-eligible). Ingress delegates to `sensorium_wave_feed` / + `WaveManifold` — no duplication. TDD; ground-state property test vs. direct + eigensolve; determinism digests. +- **Phase 3 — wiring lanes** (three independent PRs after Phase 2 API lands): + - **Lane A (§2.4; closes caveat 2):** wire `is_discovery_eligible` + + `cross_band_discovery_gate` into the contemplation runner's existing sink; + high-surprise speculative packets emit `DiscoveryCandidate`s + (proposal-only). Give `kappa_search_event` its live telemetry call site at + the κ line-search (calibration-gated per R-04). + - **Lane B (§2.1→§2.3; closes caveat 3):** off-serving corridor in `evals/`: + real Audio/Vision compilers → ψ_in → relaxation → E-class → `en` readback + rules → GoldTether gate. First live consumer of the I-04 feed. + - **Lane C (§2.5):** ADR-0240 validation-harness PASS → + `integrate_biography`, with I-01 closure asserts and provenance recording. +- **Phase 4 — falsifiability benchmarks** (1 PR): + `evals/adr_0243_cognitive_lifecycle/` fixed-replay eval + (`adr_0242_v2_energy_compare` pattern): fidelity score, surprise separation + (ID vs OOD), insertion cost, f32 drift over T=1000, typed failure thresholds. + **Decisive falsifier:** a propositional slice scored against + `evals/deductive_logic` ROBDD gold with wrong=0 accounting. "Field engine is + NOT the reasoner today" stands unless this evidence says otherwise. +- **Phase 5 — acceptance packet** (1 PR): D10-pattern packet — claims vs. + evidence, deviations D-1…D-5, deferred items — for Joshua's ruling. Status + flip via governance commit only (provenance-guard compliant). + +## 6. Dependencies and process + +Phase 2 precedes 3/4; Lanes A/B/C are mutually independent; Phase 5 last. +Every PR: dedicated worktree off `forgejo/main`, in-worktree smoke gate +(`uv run core test --suite smoke -q`) before push, `[Verification]:` line in the +PR description, Forgejo MCP for PR operations (no `gh`, no `tea`), stacked +merges substrate-first, merged branches + worktrees deleted immediately. +Lane briefs for Phase 3 are written at Phase 2 completion (production-line +pattern, `docs/handoff/`); dispatch is Shay's call. + +## 7. Explicitly deferred (not in this arc) + +- Master plan §5 Rust bindings (`cl41::wedge` exists; `expm`/`versor_unit_residual` + SIMD do not) — blocked on a Rust f64 GP + D9-style parity gate (caveat 1). +- MLX / Apple-UMA lanes — aspirational prose; no benchmark evidence. +- Delta-CRDT multi-writer vault — behind the multi-writer gate (PR #42 ruling). +- `he`/`el` readback rules — packs are skeletal; `en` only for the corridor. +- Any serve-path activation of lifecycle machinery — A-04 quarantine holds + until ratification. + +## 8. Risks + +- **H-compiler scope explosion** → v1 fixed at two typed domains; extensions + require new evidence, not new matchers (ADR-0175 discipline). +- **Reasoner overclaim / thesis drift** → the Phase 4 wrong=0 ROBDD cross-check + is the gate; disagreements fail the run and go in the packet verbatim. +- **Hollow gates in egress wiring** → every gate ships with a must-reject test + (and SD-A shows the dual failure mode: a gate that rejects everything). +- **I-05 doctrinal tension** → D-3 reconciliation text; normalize only at the + owned construction boundary; boundary breaches fail closed, never repaired. diff --git a/tests/test_adr_0243_sketch_defect_pins.py b/tests/test_adr_0243_sketch_defect_pins.py new file mode 100644 index 00000000..68c23312 --- /dev/null +++ b/tests/test_adr_0243_sketch_defect_pins.py @@ -0,0 +1,140 @@ +"""ADR-0243 §3 reference-prototype sketch-defect pins (SD-A, SD-B, SD-C). + +Authority: docs/plans/adr-0243-implementation-plan.md §3 (sketch-defect ledger). +Precedent: PR #52 sketch-defect pins for the rejected Drive-draft re-implementation. + +The ADR-0243 §3 Python prototype (``CognitiveLifecycleEngine``) contains +mathematical defects that make a verbatim port worthless or misleading. These +pins prove each defect with a deterministic counterexample so the sketch can +never be re-landed as-is: + +SD-A The sketch egress gate computes ``drift = |psi^T I^T psi - 1|`` with an + antisymmetric ``I``. The quadratic form of an antisymmetric matrix is + identically zero, so drift == 1 for EVERY state and the gate rejects + everything — valid and invalid alike. A fail-always gate is the inverse + of a hollow gate and equally worthless. The real residual is + ``WaveManifold.measure_unitary_residual`` / ``goldtether.coherence_residual``. + +SD-B The sketch "relaxation" loop iterates ``R = expm(H @ I * dt)`` with + renormalization. The generator's spectrum is (block-wise) purely + imaginary, so iterates oscillate and nothing dissipates: the loop never + settles into the minimum-energy eigenmode of H. Honest deterministic + relaxation is the dissipative (imaginary-time) semigroup + ``psi <- normalize(exp(-H dt) psi)`` — power iteration whose convergence + rate is the spectral gap of H. + +SD-C The sketch's block matrix "I" ("central pseudoscalar proxy") is NOT the + Cl(4,1) pseudoscalar action: it shares I^2 = -Id but is a different + operator from left-multiplication by e0 e1 e2 e3 e4 in the real algebra. + All algebra goes through ``algebra/`` — no component-shuffling proxies. + +Deterministic fixtures only — no random spinors as truth. +""" + +from __future__ import annotations + +import numpy as np + +from algebra.cl41 import N_COMPONENTS, geometric_product + + +def _sketch_proxy_i() -> np.ndarray: + """The ADR-0243 §3 prototype's 'central pseudoscalar proxy' matrix.""" + proxy = np.zeros((N_COMPONENTS, N_COMPONENTS), dtype=np.float64) + for i in range(N_COMPONENTS // 2): + proxy[2 * i, 2 * i + 1] = 1.0 + proxy[2 * i + 1, 2 * i] = -1.0 + return proxy + + +def _expm_series(M: np.ndarray, terms: int = 60) -> np.ndarray: + """Deterministic truncated-series matrix exponential (no scipy).""" + out = np.eye(M.shape[0], dtype=np.float64) + term = np.eye(M.shape[0], dtype=np.float64) + for k in range(1, terms): + term = term @ M / float(k) + out = out + term + return out + + +def _onehot(i: int) -> np.ndarray: + v = np.zeros(N_COMPONENTS, dtype=np.float64) + v[i] = 1.0 + return v + + +# --- SD-A: the sketch egress gate rejects every state ------------------------- + + +def test_sd_a_sketch_egress_gate_rejects_every_state(): + proxy = _sketch_proxy_i() + mixed = np.arange(1, N_COMPONENTS + 1, dtype=np.float64) + mixed /= np.linalg.norm(mixed) + candidates = [_onehot(0), _onehot(5), _onehot(31), mixed] + + for psi in candidates: + # Exactly the sketch's egress computation. + psi_rev = proxy.T @ psi + norm_product = psi @ psi_rev + drift = abs(norm_product - 1.0) + # Antisymmetric quadratic form vanishes identically... + assert abs(norm_product) < 1e-12 + # ...so the sketch gate rejects EVERYTHING, unit-norm states included. + assert drift > 1e-6 # sketch epsilon_drift + assert abs(drift - 1.0) < 1e-12 + + +# --- SD-B: the sketch loop cannot relax; imaginary time can ------------------- + + +def test_sd_b_sketch_loop_oscillates_while_imaginary_time_relaxes(): + energies = np.linspace(0.5, 4.0, N_COMPONENTS) + hamiltonian = np.diag(energies) # ground state = component 0 + psi0 = np.ones(N_COMPONENTS, dtype=np.float64) + psi0 /= np.linalg.norm(psi0) + + # Exactly the sketch's relaxation loop: R = expm(H @ I * dt), 100 steps. + propagator = _expm_series(hamiltonian @ _sketch_proxy_i() * 0.01) + psi = psi0.copy() + for _ in range(100): + psi = propagator @ psi + norm = np.linalg.norm(psi) + if norm > 1e-12: + psi /= norm + sketch_ground_overlap = abs(psi[0]) + + # Honest dissipative semigroup: psi <- normalize(exp(-H dt) psi). + decay = np.exp(-energies * 0.5) + phi = psi0.copy() + for _ in range(200): + phi = decay * phi + phi /= np.linalg.norm(phi) + imaginary_time_ground_overlap = abs(phi[0]) + + # The sketch never concentrates on the ground state... + assert sketch_ground_overlap < 0.9 + # ...while imaginary time converges to it (rate = spectral gap). + assert imaginary_time_ground_overlap > 1.0 - 1e-8 + + +# --- SD-C: the proxy matrix is not the Cl(4,1) pseudoscalar action ------------ + + +def test_sd_c_proxy_matrix_is_not_the_pseudoscalar_action(): + # Real pseudoscalar e0 e1 e2 e3 e4 (0-indexed basis vectors, f64). + pseudoscalar = _onehot(1) # e0 lives at component 1 + for i in range(1, 5): + pseudoscalar = geometric_product(pseudoscalar, _onehot(1 + i)) + + # Left-multiplication-by-pseudoscalar as a 32x32 matrix. + action = np.zeros((N_COMPONENTS, N_COMPONENTS), dtype=np.float64) + for j in range(N_COMPONENTS): + action[:, j] = geometric_product(pseudoscalar, _onehot(j)) + + proxy = _sketch_proxy_i() + identity = np.eye(N_COMPONENTS) + # Both square to -Id (I5^2 = -1 in Cl(4,1)) — the proxy mimics the square... + assert np.allclose(action @ action, -identity, atol=1e-12) + assert np.allclose(proxy @ proxy, -identity, atol=1e-12) + # ...but is a DIFFERENT operator: the actions disagree outright. + assert float(np.max(np.abs(action - proxy))) > 0.5