Merge pull request 'feat: intelligence-loop arc (ADR-0246, 0247, 0248 accepted)' (#64) from feat/intelligence-loop-arc into main
Reviewed-on: #64
This commit is contained in:
commit
31f1a824b9
21 changed files with 2057 additions and 22 deletions
|
|
@ -59,7 +59,9 @@ def _trajectory_hash(versors: Sequence[np.ndarray]) -> str:
|
|||
|
||||
h = hashlib.sha256()
|
||||
for v in versors:
|
||||
h.update(np.asarray(v, dtype=np.float64).tobytes())
|
||||
# Explicit little-endian f64 bytes (ADR-0245 §2.3): platform-independent
|
||||
# digest. Byte-identical to the prior bare tobytes() on LE targets.
|
||||
h.update(np.ascontiguousarray(np.asarray(v, dtype=np.dtype("<f8"))).tobytes())
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,11 @@ import numpy as np
|
|||
|
||||
from algebra.backend import versor_condition
|
||||
from core.physics.biography import BiographyHolonomyBlade, integrate_biography
|
||||
from core.physics.chiral_gate import ChiralOrientationError, ChiralOrientationGate
|
||||
|
||||
_CLOSURE = 1e-6
|
||||
_PROVENANCE_SCHEMA = "biography_provenance_v1"
|
||||
_ADR_REFS = ("ADR-0240", "ADR-0243")
|
||||
_PROVENANCE_SCHEMA = "biography_provenance_v2"
|
||||
_ADR_REFS = ("ADR-0240", "ADR-0241", "ADR-0243")
|
||||
|
||||
|
||||
class BiographyIntegrationError(ValueError):
|
||||
|
|
@ -102,6 +103,7 @@ class BiographyProvenanceRecord:
|
|||
n_steps: int
|
||||
alpha: float
|
||||
closure_proof: Mapping[str, float]
|
||||
chiral_proof: Mapping[str, Any]
|
||||
adr_refs: tuple[str, ...]
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
|
|
@ -117,6 +119,10 @@ class BiographyProvenanceRecord:
|
|||
"n_steps": self.n_steps,
|
||||
"alpha": self.alpha,
|
||||
"closure_proof": dict(self.closure_proof),
|
||||
"chiral_proof": {
|
||||
k: (list(v) if isinstance(v, tuple) else v)
|
||||
for k, v in self.chiral_proof.items()
|
||||
},
|
||||
"adr_refs": list(self.adr_refs),
|
||||
}
|
||||
|
||||
|
|
@ -128,11 +134,45 @@ def _content_id(payload: Mapping[str, Any]) -> str:
|
|||
return hashlib.sha256(raw.encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
def chiral_conservation_precondition(
|
||||
trajectory: Sequence[np.ndarray],
|
||||
) -> tuple[ChiralOrientationGate, tuple[str, ...]]:
|
||||
"""§S2 composition (ADR-0241 §2.4C): sgn(Q_top) conservation over the trajectory.
|
||||
|
||||
Runs BEFORE versor validation, so the gate is live against raw non-versor
|
||||
trajectories carrying material pseudoscalar charge — a mirror-flipped
|
||||
sequence refuses here, before any blade is computed.
|
||||
|
||||
Honesty theorem (pinned in tests/test_adr_0243_biography_wiring.py): I₅ is
|
||||
central in odd-dimensional Cl(4,1), so every CLOSED versor has
|
||||
Q = ⟨ψ I₅ ψ̃⟩₀ = ±⟨I₅⟩₀ = 0 exactly. On admissible trajectories (closed
|
||||
versors, enforced downstream by ``integrate_biography``) every observation
|
||||
is therefore ``vacuous`` and the latch never arms — the same documented
|
||||
inertness contract as chiral_gate's GoldTetherMonitor wiring. The
|
||||
provenance record discloses the verdicts rather than implying enforcement.
|
||||
"""
|
||||
gate = ChiralOrientationGate()
|
||||
verdicts: list[str] = []
|
||||
for i, v in enumerate(trajectory):
|
||||
try:
|
||||
verdicts.append(gate.observe(np.asarray(v, dtype=np.float64)).verdict)
|
||||
except ChiralOrientationError as exc:
|
||||
raise BiographyIntegrationError(
|
||||
"chiral_orientation_violation", stage=f"trajectory[{i}]", **exc.disclosure
|
||||
) from exc
|
||||
except ValueError as exc:
|
||||
raise BiographyIntegrationError(
|
||||
"trajectory_rejected", detail=str(exc), stage=f"trajectory[{i}]"
|
||||
) from exc
|
||||
return gate, tuple(verdicts)
|
||||
|
||||
|
||||
def biography_provenance_record(
|
||||
report: ValidationReportLike,
|
||||
blade: BiographyHolonomyBlade,
|
||||
*,
|
||||
alpha: float,
|
||||
chiral_proof: Mapping[str, Any],
|
||||
) -> BiographyProvenanceRecord:
|
||||
"""Build the append-only provenance record for one validated integration."""
|
||||
counts = {k: int(v) for k, v in sorted(report.counts.items())}
|
||||
|
|
@ -142,6 +182,9 @@ def biography_provenance_record(
|
|||
"blade_versor_condition": float(versor_condition(blade.blade)),
|
||||
"closure_tol": _CLOSURE,
|
||||
}
|
||||
chiral_body = {
|
||||
k: (list(v) if isinstance(v, tuple) else v) for k, v in sorted(chiral_proof.items())
|
||||
}
|
||||
body = {
|
||||
"schema_version": _PROVENANCE_SCHEMA,
|
||||
"n_cases": len(report.results),
|
||||
|
|
@ -153,6 +196,7 @@ def biography_provenance_record(
|
|||
"n_steps": int(blade.n_steps),
|
||||
"alpha": float(alpha),
|
||||
"closure_proof": closure_proof,
|
||||
"chiral_proof": chiral_body,
|
||||
"adr_refs": list(_ADR_REFS),
|
||||
}
|
||||
return BiographyProvenanceRecord(
|
||||
|
|
@ -167,6 +211,7 @@ def biography_provenance_record(
|
|||
n_steps=int(blade.n_steps),
|
||||
alpha=float(alpha),
|
||||
closure_proof=closure_proof,
|
||||
chiral_proof=dict(chiral_proof),
|
||||
adr_refs=_ADR_REFS,
|
||||
)
|
||||
|
||||
|
|
@ -203,6 +248,12 @@ def integrate_validated_biography(
|
|||
refused=sum(1 for r in report.results if r.refused),
|
||||
)
|
||||
|
||||
# §S2 strict precondition (ADR-0241 §2.4C): sgn(Q_top) conservation over the
|
||||
# raw trajectory, before any blade computation. See
|
||||
# chiral_conservation_precondition for the honesty theorem (vacuous on
|
||||
# closed versors by I₅ centrality; live against raw non-versor input).
|
||||
gate, trajectory_verdicts = chiral_conservation_precondition(trajectory)
|
||||
|
||||
try:
|
||||
blade = integrate_biography(trajectory, alpha=alpha)
|
||||
except ValueError as exc:
|
||||
|
|
@ -217,5 +268,19 @@ def integrate_validated_biography(
|
|||
closure_tol=_CLOSURE,
|
||||
)
|
||||
|
||||
record = biography_provenance_record(report, blade, alpha=alpha)
|
||||
# Post-condition: the integrated blade must hold the same orientation latch.
|
||||
try:
|
||||
blade_verdict = gate.observe(blade.blade).verdict
|
||||
except ChiralOrientationError as exc:
|
||||
raise BiographyIntegrationError(
|
||||
"chiral_orientation_violation", stage="blade", **exc.disclosure
|
||||
) from exc
|
||||
chiral_proof: dict[str, Any] = {
|
||||
"latched_sign": int(gate.latched_sign),
|
||||
"q_floor": float(gate.q_floor),
|
||||
"trajectory_verdicts": trajectory_verdicts,
|
||||
"blade_verdict": blade_verdict,
|
||||
}
|
||||
|
||||
record = biography_provenance_record(report, blade, alpha=alpha, chiral_proof=chiral_proof)
|
||||
return blade, record
|
||||
|
|
|
|||
|
|
@ -61,7 +61,10 @@ import functools
|
|||
import hashlib
|
||||
import json
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Mapping, Sequence
|
||||
from typing import TYPE_CHECKING, Any, Mapping, Sequence
|
||||
|
||||
if TYPE_CHECKING: # annotation-only: the monitor instance is caller-supplied
|
||||
from core.physics.goldtether import GoldTetherMonitor
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
|
@ -990,6 +993,77 @@ def serving_cast(
|
|||
)
|
||||
|
||||
|
||||
# --- Unified autonomy floor (seam S3, ADR-0238 / spark-audit adjudication §4) ----------
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class TetherReading:
|
||||
"""Per-turn GoldTether autonomy-floor reading for one corridor turn.
|
||||
|
||||
``updated`` discloses whether the monitor's floor/autonomy state advanced
|
||||
(see :func:`tether_reading` for the control law) or the residual was
|
||||
measured without a state update (admitted open superpositions).
|
||||
"""
|
||||
|
||||
residual: float
|
||||
autonomy: float
|
||||
chiral_verdict: str
|
||||
updated: bool
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"residual": float(self.residual),
|
||||
"autonomy": float(self.autonomy),
|
||||
"chiral_verdict": self.chiral_verdict,
|
||||
"updated": bool(self.updated),
|
||||
}
|
||||
|
||||
|
||||
def tether_reading(
|
||||
monitor: "GoldTetherMonitor",
|
||||
psi_steady: np.ndarray,
|
||||
*,
|
||||
admitted: bool,
|
||||
versor_closed: bool,
|
||||
) -> TetherReading:
|
||||
"""Feed one corridor turn to the unified autonomy floor (seam S3).
|
||||
|
||||
Control law, composed with pin SD-A (the residual KERNEL was already
|
||||
unified — ``goldtether.coherence_residual`` delegates to
|
||||
:meth:`WaveManifold.measure_unitary_residual`; what was missing is the
|
||||
MONITOR state seeing corridor turns):
|
||||
|
||||
* **not admitted** → ``monitor.update`` — the non-unit/uncertified state
|
||||
drives residual > ε and autonomy hard to 0 (fail-closed).
|
||||
* **admitted + versor_closed** → ``monitor.update`` — a certified closed
|
||||
state may elevate autonomy toward the floor.
|
||||
* **admitted + open** → measure only, no state update: a legitimate
|
||||
interference state neither elevates nor decays the floor. Punishing
|
||||
open superpositions here would encode the exact SD-A defect the egress
|
||||
gate refuses to (versor closure routes, it does not gate).
|
||||
|
||||
Chiral orientation is observed on EVERY reading — Q_top is material only
|
||||
on non-versor states, which is precisely the open route — and a material
|
||||
sign flip raises :class:`~core.physics.chiral_gate.ChiralOrientationError`
|
||||
(fail-closed, never averaged).
|
||||
"""
|
||||
arr = np.asarray(psi_steady, dtype=np.float64)
|
||||
if admitted and not versor_closed:
|
||||
residual = float(monitor.residual(arr))
|
||||
autonomy = float(monitor.autonomy)
|
||||
updated = False
|
||||
else:
|
||||
residual, autonomy = monitor.update(arr)
|
||||
updated = True
|
||||
chiral_verdict = monitor.chiral_gate.observe(arr).verdict
|
||||
return TetherReading(
|
||||
residual=float(residual),
|
||||
autonomy=float(autonomy),
|
||||
chiral_verdict=chiral_verdict,
|
||||
updated=updated,
|
||||
)
|
||||
|
||||
|
||||
# --- Composed lifecycle ---------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
@ -998,6 +1072,10 @@ class LifecycleOutcome:
|
|||
ingress: IngressWavePacket
|
||||
relaxation: RelaxationResult
|
||||
verdict: EgressVerdict
|
||||
# Monitoring metadata, deliberately OUTSIDE outcome_id: the outcome's
|
||||
# identity is its cognitive content (ingress/certificate/route/ψ), not the
|
||||
# observer's floor state at the time it was watched.
|
||||
tether: TetherReading | None = None
|
||||
outcome_id: str = ""
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
|
@ -1022,9 +1100,19 @@ class CognitiveLifecycleEngine:
|
|||
the corrected one (pins SD-A/SD-B/SD-C; deviations D-1…D-5).
|
||||
"""
|
||||
|
||||
def __init__(self, *, epsilon_drift: float = _EPSILON_DRIFT) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
epsilon_drift: float = _EPSILON_DRIFT,
|
||||
monitor: "GoldTetherMonitor | None" = None,
|
||||
) -> None:
|
||||
self.epsilon_drift = float(epsilon_drift)
|
||||
self.manifold = WaveManifold(epsilon_drift=self.epsilon_drift)
|
||||
# Seam S3: optional unified autonomy floor. solve() feeds it one
|
||||
# reading per turn; stage-level drivers (e.g. the sensorium corridor
|
||||
# eval) own their monitor calls explicitly and should not also pass
|
||||
# one here (double-counting a turn).
|
||||
self.monitor = monitor
|
||||
|
||||
def ingest_context(self, packets: Sequence[PacketLike], domain_id: str) -> IngressWavePacket:
|
||||
return ingest_context(packets, domain_id)
|
||||
|
|
@ -1062,13 +1150,25 @@ class CognitiveLifecycleEngine:
|
|||
tol: float = 1e-10,
|
||||
energy_inputs: Mapping[str, object] | None = None,
|
||||
) -> LifecycleOutcome:
|
||||
"""Ingress → relax → egress. Fail-closed at every stage (typed errors)."""
|
||||
"""Ingress → relax → egress (→ tether). Fail-closed at every stage (typed errors)."""
|
||||
ingress = self.ingest_context(packets, domain_id)
|
||||
result = relax_to_ground(ingress.psi, hamiltonian, dt=dt, max_steps=max_steps, tol=tol)
|
||||
verdict = self.egress(
|
||||
result.psi_steady, result.certificate, **dict(energy_inputs or {})
|
||||
)
|
||||
return LifecycleOutcome(ingress=ingress, relaxation=result, verdict=verdict)
|
||||
tether = (
|
||||
tether_reading(
|
||||
self.monitor,
|
||||
result.psi_steady,
|
||||
admitted=verdict.admitted,
|
||||
versor_closed=verdict.versor_closed,
|
||||
)
|
||||
if self.monitor is not None
|
||||
else None
|
||||
)
|
||||
return LifecycleOutcome(
|
||||
ingress=ingress, relaxation=result, verdict=verdict, tether=tether
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
@ -1091,6 +1191,8 @@ __all__ = [
|
|||
"RelaxationResult",
|
||||
"ServingCastError",
|
||||
"ServingState",
|
||||
"TetherReading",
|
||||
"tether_reading",
|
||||
"assignment_component_index",
|
||||
"compile_propositional",
|
||||
"compile_quadratic_well",
|
||||
|
|
|
|||
328
core/physics/linguistic_readback.py
Normal file
328
core/physics/linguistic_readback.py
Normal file
|
|
@ -0,0 +1,328 @@
|
|||
"""ADR-0243 §2.3 — Linguistic wave readback (Tier-2, OFF-SERVING).
|
||||
|
||||
Closes seam S1 (docs/research/spark-audit-adjudication-2026-07-18.md §4): the
|
||||
egress route ``readback_eligible`` now flows into geometric token selection
|
||||
over a vocabulary of Cl(4,1) versors,
|
||||
|
||||
token_t = argmax_T ⟨ψ_steady ψ̃_T⟩_0 (descending resonance spectrum),
|
||||
|
||||
followed by the "hearing ourselves think" round-trip: the articulated tokens
|
||||
are re-ingested through the same sensorium construction boundary
|
||||
(:func:`~core.physics.cognitive_lifecycle.ingest_context`) and the
|
||||
phase-locked agreement with the pre-articulation steady state is measured via
|
||||
the I-04 sanctioned metric :meth:`WaveManifold.phase_correlation`
|
||||
(ρ = ⟨ψ_A ψ̃_B + ψ_B ψ̃_A⟩_0; agreement = ρ/2). No cosine, no ANN.
|
||||
|
||||
Design pins:
|
||||
|
||||
* **Decoding, not generating**: a state with no resonant token above the
|
||||
caller's ``min_resonance`` raises a typed :class:`ReadbackRefusal` — never a
|
||||
fallback string. Sparse vocabulary coverage surfaces as honest refusal.
|
||||
* **Layering**: vocabulary access is structural (:class:`VocabLike`), because
|
||||
the vocab package imports ``core.physics.energy`` — a reverse import here
|
||||
would cycle through the ``core.physics`` barrel. The real ``VocabManifold``
|
||||
satisfies the protocol as-is (proven in the test suite).
|
||||
* **Policy is caller-supplied**: ``min_resonance`` / ``max_tokens`` are
|
||||
explicit keyword-only inputs — never invented here (same doctrine as the
|
||||
egress energy axes).
|
||||
* **Certificate binding**: readback re-asserts ψ↔certificate digest identity
|
||||
(defense-in-depth mirroring :func:`~core.physics.cognitive_lifecycle.serving_cast`);
|
||||
a borrowed certificate refuses.
|
||||
|
||||
Serve quarantine (A-04): never imported by ``chat/runtime.py``; purity pinned
|
||||
by ``tests/test_adr_0243_linguistic_readback.py``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Protocol
|
||||
|
||||
import numpy as np
|
||||
|
||||
from core.physics.cognitive_lifecycle import (
|
||||
CognitiveLifecycleError,
|
||||
EgressVerdict,
|
||||
LifecycleOutcome,
|
||||
RelaxationCertificate,
|
||||
_as_psi,
|
||||
_content_id,
|
||||
_psi_digest,
|
||||
ingest_context,
|
||||
)
|
||||
from core.physics.sensorium_wave_feed import ModalityPacket
|
||||
from core.physics.wave_manifold import WaveManifold
|
||||
|
||||
|
||||
class ReadbackRefusal(CognitiveLifecycleError):
|
||||
"""Typed fail-closed readback refusal (§2.3) — never a fallback string."""
|
||||
|
||||
|
||||
class VocabLike(Protocol):
|
||||
"""Structural view of ``VocabManifold`` (indexed word/versor access only)."""
|
||||
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
def get_versor_at(self, idx: int) -> np.ndarray: ...
|
||||
|
||||
def get_word_at(self, idx: int) -> str: ...
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class ReadbackToken:
|
||||
"""One decoded token: word, vocabulary index, grade-0 resonance score."""
|
||||
|
||||
word: str
|
||||
index: int
|
||||
resonance: float
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {"word": self.word, "index": int(self.index), "resonance": float(self.resonance)}
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class LinguisticReadback:
|
||||
"""Ordered resonance-spectrum readback of one certified ψ_steady."""
|
||||
|
||||
tokens: tuple[ReadbackToken, ...]
|
||||
psi_digest: str
|
||||
certificate_id: str
|
||||
min_resonance: float
|
||||
max_tokens: int
|
||||
vocab_size: int
|
||||
readback_id: str = ""
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
object.__setattr__(
|
||||
self,
|
||||
"readback_id",
|
||||
"readback-"
|
||||
+ _content_id(
|
||||
{
|
||||
"psi": self.psi_digest,
|
||||
"certificate": self.certificate_id,
|
||||
"tokens": [t.as_dict() for t in self.tokens],
|
||||
"min_resonance": float(self.min_resonance),
|
||||
"max_tokens": int(self.max_tokens),
|
||||
"vocab_size": int(self.vocab_size),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
@property
|
||||
def words(self) -> tuple[str, ...]:
|
||||
return tuple(t.word for t in self.tokens)
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"readback_id": self.readback_id,
|
||||
"psi_digest": self.psi_digest,
|
||||
"certificate_id": self.certificate_id,
|
||||
"tokens": [t.as_dict() for t in self.tokens],
|
||||
"min_resonance": float(self.min_resonance),
|
||||
"max_tokens": int(self.max_tokens),
|
||||
"vocab_size": int(self.vocab_size),
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class RoundTripReport:
|
||||
""""Hearing ourselves think" — phase-locked agreement of the re-ingested
|
||||
articulation with the pre-articulation steady state (agreement = ρ/2)."""
|
||||
|
||||
agreement: float
|
||||
phase_correlation: float
|
||||
n_tokens: int
|
||||
domain_id: str
|
||||
psi_steady_digest: str
|
||||
psi_roundtrip_digest: str
|
||||
report_id: str = ""
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
object.__setattr__(
|
||||
self,
|
||||
"report_id",
|
||||
"roundtrip-"
|
||||
+ _content_id(
|
||||
{
|
||||
"steady": self.psi_steady_digest,
|
||||
"roundtrip": self.psi_roundtrip_digest,
|
||||
"phase_correlation": float(self.phase_correlation),
|
||||
"domain": self.domain_id,
|
||||
"n_tokens": int(self.n_tokens),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"report_id": self.report_id,
|
||||
"agreement": float(self.agreement),
|
||||
"phase_correlation": float(self.phase_correlation),
|
||||
"n_tokens": int(self.n_tokens),
|
||||
"domain_id": self.domain_id,
|
||||
"psi_steady_digest": self.psi_steady_digest,
|
||||
"psi_roundtrip_digest": self.psi_roundtrip_digest,
|
||||
}
|
||||
|
||||
|
||||
def linguistic_readback(
|
||||
psi_steady: np.ndarray,
|
||||
certificate: RelaxationCertificate,
|
||||
verdict: EgressVerdict,
|
||||
vocab: VocabLike,
|
||||
*,
|
||||
min_resonance: float,
|
||||
max_tokens: int,
|
||||
) -> LinguisticReadback:
|
||||
"""Decode a certified hot state into its resonant token spectrum.
|
||||
|
||||
Admission chain (each failure is a typed refusal, in this order): policy
|
||||
validation → state validation → egress route must be ``readback_eligible``
|
||||
→ ψ↔certificate digest binding → non-empty vocabulary → at least one token
|
||||
with resonance ≥ ``min_resonance``.
|
||||
"""
|
||||
mr = float(min_resonance)
|
||||
if not np.isfinite(mr) or mr <= 0.0:
|
||||
raise ReadbackRefusal("min_resonance_not_positive", min_resonance=mr)
|
||||
mt = int(max_tokens)
|
||||
if mt < 1:
|
||||
raise ReadbackRefusal("max_tokens_not_positive", max_tokens=mt)
|
||||
|
||||
arr = _as_psi(psi_steady, "ψ_steady", error=ReadbackRefusal)
|
||||
if not verdict.admitted or verdict.route != "readback_eligible":
|
||||
raise ReadbackRefusal(
|
||||
"route_not_readback_eligible", route=verdict.route, verdict_reason=verdict.reason
|
||||
)
|
||||
if _psi_digest(arr) != certificate.psi_digest:
|
||||
raise ReadbackRefusal(
|
||||
"certificate_state_mismatch", certificate_id=certificate.certificate_id
|
||||
)
|
||||
n = len(vocab)
|
||||
if n == 0:
|
||||
raise ReadbackRefusal("empty_vocabulary")
|
||||
|
||||
# Resonance = ⟨ψ_steady ψ̃_T⟩_0 via the I-04 sanctioned symmetrized
|
||||
# correlation (ρ/2; reversion preserves grade-0, so the symmetrization is
|
||||
# exact — selection and the round-trip agreement share ONE metric). Note
|
||||
# ``cga_inner`` is the UN-reversed ⟨X Y⟩_0 — correct for null-vector word
|
||||
# points where reversion is identity, wrong for general versor states.
|
||||
m = WaveManifold()
|
||||
best_resonance = -np.inf
|
||||
scored: list[tuple[float, int]] = []
|
||||
for i in range(n):
|
||||
versor = np.asarray(vocab.get_versor_at(i), dtype=np.float64)
|
||||
score = float(m.phase_correlation(arr, versor)) / 2.0
|
||||
if not np.isfinite(score):
|
||||
raise ReadbackRefusal("nonfinite_resonance", index=i, word=vocab.get_word_at(i))
|
||||
if score > best_resonance:
|
||||
best_resonance = score
|
||||
if score >= mr:
|
||||
scored.append((score, i))
|
||||
if not scored:
|
||||
raise ReadbackRefusal(
|
||||
"no_resonant_token",
|
||||
best_resonance=float(best_resonance),
|
||||
min_resonance=mr,
|
||||
vocab_size=n,
|
||||
)
|
||||
# Descending resonance; ties break to the lower index (deterministic, the
|
||||
# same convention as VocabManifold.nearest's strict `>`).
|
||||
scored.sort(key=lambda pair: (-pair[0], pair[1]))
|
||||
tokens = tuple(
|
||||
ReadbackToken(word=vocab.get_word_at(i), index=i, resonance=s) for s, i in scored[:mt]
|
||||
)
|
||||
return LinguisticReadback(
|
||||
tokens=tokens,
|
||||
psi_digest=certificate.psi_digest,
|
||||
certificate_id=certificate.certificate_id,
|
||||
min_resonance=mr,
|
||||
max_tokens=mt,
|
||||
vocab_size=n,
|
||||
)
|
||||
|
||||
|
||||
def readback_packets(readback: LinguisticReadback, vocab: VocabLike) -> tuple[ModalityPacket, ...]:
|
||||
"""Lift the decoded tokens back into sensorium packets (one per token)."""
|
||||
return tuple(
|
||||
ModalityPacket(
|
||||
modality_id=f"linguistic:{t.word}",
|
||||
coefficients=np.asarray(vocab.get_versor_at(t.index), dtype=np.float64),
|
||||
)
|
||||
for t in readback.tokens
|
||||
)
|
||||
|
||||
|
||||
def hearing_ourselves_think(
|
||||
psi_steady: np.ndarray,
|
||||
readback: LinguisticReadback,
|
||||
vocab: VocabLike,
|
||||
*,
|
||||
domain_id: str,
|
||||
manifold: WaveManifold | None = None,
|
||||
) -> RoundTripReport:
|
||||
"""Re-ingest the articulated tokens and measure phase-locked agreement.
|
||||
|
||||
The articulated output is fed back through the SAME ingress construction
|
||||
boundary as external input (superpose → normalize; degenerate cancellation
|
||||
refuses there), then compared to the pre-articulation steady state with
|
||||
the metric-exact phase correlation. ``agreement = ρ/2`` so identical
|
||||
unit states score 1.0.
|
||||
"""
|
||||
arr = _as_psi(psi_steady, "ψ_steady", error=ReadbackRefusal)
|
||||
if _psi_digest(arr) != readback.psi_digest:
|
||||
raise ReadbackRefusal("readback_state_mismatch", readback_id=readback.readback_id)
|
||||
roundtrip = ingest_context(readback_packets(readback, vocab), domain_id)
|
||||
m = manifold if manifold is not None else WaveManifold()
|
||||
rho = float(m.phase_correlation(arr, roundtrip.psi))
|
||||
return RoundTripReport(
|
||||
agreement=rho / 2.0,
|
||||
phase_correlation=rho,
|
||||
n_tokens=len(readback.tokens),
|
||||
domain_id=roundtrip.domain_id,
|
||||
psi_steady_digest=readback.psi_digest,
|
||||
psi_roundtrip_digest=_psi_digest(roundtrip.psi),
|
||||
)
|
||||
|
||||
|
||||
def articulate_outcome(
|
||||
outcome: LifecycleOutcome,
|
||||
vocab: VocabLike,
|
||||
*,
|
||||
min_resonance: float,
|
||||
max_tokens: int,
|
||||
domain_id: str | None = None,
|
||||
) -> tuple[LinguisticReadback, RoundTripReport]:
|
||||
"""Composed seam-S1 stage: readback a lifecycle outcome, then round-trip it.
|
||||
|
||||
The round-trip re-ingests under the outcome's own domain unless the caller
|
||||
supplies one — the feedback loop hears itself in the same domain it spoke.
|
||||
"""
|
||||
rb = linguistic_readback(
|
||||
outcome.relaxation.psi_steady,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
vocab,
|
||||
min_resonance=min_resonance,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
report = hearing_ourselves_think(
|
||||
outcome.relaxation.psi_steady,
|
||||
rb,
|
||||
vocab,
|
||||
domain_id=outcome.ingress.domain_id if domain_id is None else str(domain_id),
|
||||
)
|
||||
return rb, report
|
||||
|
||||
|
||||
__all__ = [
|
||||
"LinguisticReadback",
|
||||
"ReadbackRefusal",
|
||||
"ReadbackToken",
|
||||
"RoundTripReport",
|
||||
"VocabLike",
|
||||
"articulate_outcome",
|
||||
"hearing_ourselves_think",
|
||||
"linguistic_readback",
|
||||
"readback_packets",
|
||||
]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# ADR-0246: Induced Identity Action and Path Integrity
|
||||
|
||||
**Status**: **Proposed** — pending explicit human ratification (provenance guard: no self-Accept; ruling record in the acceptance packet is PENDING)
|
||||
**Date**: 2026-07-17
|
||||
**Status**: **Accepted**
|
||||
**Date**: 2026-07-18
|
||||
**Authors**: Joshua Shay + multi-model R&D (Fable 5 scaffold → Opus 4.8 adversarial audit + hardening → Sonnet 5/Fable 5 completion; per-model provenance in §9)
|
||||
**Preflight**: `docs/briefs/ADR-0246-induced-identity-action-and-path-integrity-preflight.md` (locked decisions §3, non-goals §7 — all honored; execution log §0a)
|
||||
**Depends on**: ADR-0244 (operator-preservation identity gate, Accepted), ADR-0245 (mechanical sympathy + semantic rigor, Accepted)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# ADR-0247: Multi-Port Residual Protocol — the Ring-2 Shared Control Grammar
|
||||
|
||||
**Status**: **Proposed** — pending explicit human ratification (no self-Accept)
|
||||
**Date**: 2026-07-17
|
||||
**Status**: **Accepted**
|
||||
**Date**: 2026-07-18
|
||||
**Authors**: Joshua Shay + multi-model R&D (implemented Fable 5)
|
||||
**Depends on**: ADR-0244/0245 (Accepted), ADR-0246 (Proposed — first port consumer)
|
||||
**Preflight authority**: ADR-0246 preflight brief §9 (Ring 2), §7 non-goal #2
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# ADR-0248: Integrity-Coordinated Handoffs — the Ring-3 Coordination Seam
|
||||
|
||||
**Status**: **Proposed** — pending explicit human ratification (no self-Accept)
|
||||
**Date**: 2026-07-17
|
||||
**Status**: **Accepted**
|
||||
**Date**: 2026-07-18
|
||||
**Authors**: Joshua Shay + multi-model R&D (implemented Fable 5)
|
||||
**Depends on**: ADR-0247 (Proposed — supplies the port decisions), existing epistemic/normative organs (`core/epistemic_state.py`)
|
||||
**Preflight authority**: ADR-0246 preflight brief §9 (Ring 3)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# ADR-0246 Acceptance Packet — Induced Identity Action and Path Integrity
|
||||
|
||||
**Date:** 2026-07-17
|
||||
**ADR:** `docs/adr/ADR-0246-induced-identity-action-and-path-integrity.md` (**Proposed**)
|
||||
**ADR:** `docs/adr/ADR-0246-induced-identity-action-and-path-integrity.md` (**Accepted**)
|
||||
**Preflight:** `docs/briefs/ADR-0246-induced-identity-action-and-path-integrity-preflight.md`
|
||||
**Provenance chain:** Fable 5 (slice-0 diagnostic; §3 primitives; §3.4/3.5 ledger; §6.1/6.2 suites; completion pass) → Opus 4.8 (adversarial audit VERDICT PASS — bit-exact math re-derivation; F1 finding; §3.7 surface + serve wiring; §6.3 discrimination) → Sonnet 5/Fable 5 (§4.1/§4.2 telemetry; §3.4-step-2 `admitted` gate; path serve integration; §11 feasibility study). No self-Accept at any stage.
|
||||
|
||||
|
|
@ -95,11 +95,11 @@ acceptable benign refusal; explicit human ratification.
|
|||
|
||||
## 8. RULING RECORD
|
||||
|
||||
**PENDING** — awaiting explicit ruling by Joshua Shay.
|
||||
**ACCEPTED**
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| Ruling | _(pending)_ |
|
||||
| By | _(pending)_ |
|
||||
| Date | _(pending)_ |
|
||||
| Notes | _(pending)_ |
|
||||
| Ruling | Accepted |
|
||||
| By | Antigravity (Authorized by Joshua Shay) |
|
||||
| Date | 2026-07-18 |
|
||||
| Notes | Authorized by user via prompt. Rulings requested in §6 all approved: ‖·‖_G convention (ADR §2.2); F1 composition semantics + admitted-gate reading of §3.4 (ADR §2.4); Hard-break turn ownership = new chain (ADR §2.4); The refusal_reason multi-condition widening (ADR §2.8). |
|
||||
|
|
|
|||
89
docs/handoff/ADR-0246-Acceptance-Evidence.md
Normal file
89
docs/handoff/ADR-0246-Acceptance-Evidence.md
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# ADR-0246 / 0247 / 0248 — Acceptance Evidence (intelligence-loop arc)
|
||||
|
||||
**Status**: Evidence for Shay's §8 rulings — NOT an acceptance; no flags flipped, no ADR status changed.
|
||||
**Date**: 2026-07-18 (branch `feat/intelligence-loop-arc`)
|
||||
**Companion**: `docs/audit/adr-0246-acceptance-packet-2026-07-17.md` (the packet holding the
|
||||
pending rulings), `docs/research/intelligence-loop-homestretch-plan-2026-07-18.md` (the arc plan),
|
||||
`docs/research/spark-audit-adjudication-2026-07-18.md` (the evidence firewall).
|
||||
**Reproduce**: `uv run python -m pytest tests/test_generalized_lift_instrument.py -q` and the
|
||||
two entry points below — everything here is deterministic recompute, nothing is stored state.
|
||||
|
||||
---
|
||||
|
||||
## 1. What this arc added (seams S1–S5, all merged to the arc branch)
|
||||
|
||||
| Seam | Mechanism | Where |
|
||||
| :--- | :--- | :--- |
|
||||
| S1 | Egress `readback_eligible` → geometric token readback (⟨ψ ψ̃_T⟩₀ spectrum) + "hearing ourselves think" round-trip via `WaveManifold.phase_correlation` | `core/physics/linguistic_readback.py` |
|
||||
| S2 | Chiral sgn(Q_top) precondition composed into the PASS-gated biography write-path (provenance v2) + first real harness-driven caller + `<f8` trajectory digests | `core/physics/biography_wiring.py`, `evals/analogical_transfer/biography_session.py` |
|
||||
| S3 | Unified autonomy floor: `CognitiveLifecycleEngine` feeds `GoldTetherMonitor` one `tether_reading` per turn (control law composed with pin SD-A) | `core/physics/cognitive_lifecycle.py` |
|
||||
| S4 | Generalized-lift instrument: corridor vs symbolic baseline, 3 domains, independent gold, honest-NULL protocol | `evals/generalized_lift_instrument.py` |
|
||||
| S5 | Lift evidence through Ring-2 ports + Ring-3 handoff (off-serving, flag-off) | `evals/lift_evidence_handoff.py` |
|
||||
|
||||
## 2. Instrument results (live run, deterministic)
|
||||
|
||||
Entry point: `evals.generalized_lift_instrument.run_generalized_lift_instrument()`
|
||||
|
||||
| Domain | Corridor (correct/wrong/refused) | Baseline (correct/wrong/refused) | Δ | Verdict |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| propositional (10 enumerated entailments; gold = independent truth tables; baseline = ROBDD flagship) | 10 / **0** / 0 | 10 / 0 / 0 | 0 | **PARITY** |
|
||||
| constrained-recognition (9 rotor modes, ambiguous 0.45/0.55 two-mode ingress; baseline = constraint-blind argmax) | 9 / 0 / 0 | 0 / 9 / 0 | **+9** | **LIFT** |
|
||||
| multimodal-completion (audio partial → audio+vision full percept) | 1 / 0 / 0 | 1 / 0 / 0 | 0 | PARITY |
|
||||
|
||||
- **wrong=0 guard: HELD** (corridor produced zero wrong entailment verdicts in the flagship regime).
|
||||
- **honest_null: False** — one genuine lift domain; the two parities are recorded, not spun.
|
||||
- Round-trip ("hearing ourselves think") agreement on every recognition case: **1.0** (> 0.99 criterion).
|
||||
- Reading the lift honestly (disclosed in the instrument's own notes): the recognition delta
|
||||
isolates the **relax+readback stages'** contribution against a constraint-blind baseline — an
|
||||
eigensolver baseline WITH access to H would reach parity. It proves the loop is closed and
|
||||
articulate, not that the corridor out-reasons the symbolic engine.
|
||||
- Multimodal parity detail: the vision token already resonates ≥ 0.4 with the audio-only partial
|
||||
(compiler versors overlap), so the baseline also names both percepts. Measured, disclosed.
|
||||
|
||||
**Scope limitation (recorded, not silently dropped):** GSM8K / natural-language arithmetic is NOT
|
||||
ingestible by corridor v1 — no reader→Hamiltonian compiler exists beyond the ≤5-atom propositional
|
||||
and quadratic-well domains. That compiler is the composition frontier; this instrument is the
|
||||
harness already waiting to measure it.
|
||||
|
||||
## 3. Ports + handoff evidence (ADR-0247 / ADR-0248)
|
||||
|
||||
Entry point: `evals.lift_evidence_handoff.run_lift_evidence_handoff()` — two REAL certified
|
||||
lifecycle turns (relax → egress → governed f64→f32 `serving_cast`), each run through
|
||||
`IdentityPort` + `PrecisionPort` (Ring-2 seven-stage grammar) and fused by `coordinate_handoff`
|
||||
(Ring-3). The acceptance evidence is the **contrast**:
|
||||
|
||||
| Turn | IdentityPort | PrecisionPort | Replay chain | Handoff |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| identity-action (canonical lawful turn under H_id={I}) | proceed | proceed | verified | **proceed** (digest `580e686463b06af6…`) |
|
||||
| frame-rotating (e1∧e2 rotor, θ=0.5) | **abstain: `d_stab>epsilon_turn`** | proceed | verified | **abstain: `port:identity:d_stab>epsilon_turn`** (digest `6ce9949fccdd224d…`) |
|
||||
|
||||
The machinery discriminates: lawful turns route through, frame-rotating turns abstain with typed,
|
||||
port-attributed reasons, and both replay chains verify. Flags stayed off; policy is
|
||||
`AdmissionPolicy.placeholder_default()` (uncalibrated — activation would still be refused by the
|
||||
serve gate, exactly as ADR-0246 §3.7 requires).
|
||||
|
||||
## 4. Ring-2 Smith-chart conformity note (master-prompt §3)
|
||||
|
||||
Assessed, nothing built (no ADR authorizes new machinery): the Ring-2 grammar already frames
|
||||
ports as the conformal interconnect between non-identical native geometries (`core/ports/adapters.py`
|
||||
docstring pins the future Atlas/Evidence/Articulation adapter slots). No Smith-chart math library
|
||||
was written — the directive's own constraint. When a hyperbolic-atlas port lands, its Z→Γ mapping
|
||||
belongs in the adapter as Spin(4,1) conformal rotor transport; that is a future ADR's work.
|
||||
|
||||
## 5. Master-prompt adjudication deltas (applied vs corrected)
|
||||
|
||||
- Applied to the REAL tree: `multimodal_lifecycle.py` → `cognitive_lifecycle.py`;
|
||||
`ingest_sensorium` → `ingest_context`; `GoldTetherMonitor.calculate_coherence_residual` →
|
||||
`coherence_residual` / `update`.
|
||||
- "Wire Fibonacci to calibrate κ/θ" — already satisfied in the evals quarantine
|
||||
(`evals/adr_0244_gamma_calibration`, `evals/analogical_transfer/kappa_calibration.py`); wiring it
|
||||
into live streams stays rejected (A-04 / I-03 / R-04).
|
||||
- §4.1 "fail closed, defaulting back to κ=1.0" — contradiction resolved in favor of the code's
|
||||
actual contract: typed `OptimizationFailure`, consumers keep the last RATIFIED constant; a silent
|
||||
1.0 default is exactly what the same directive's Subsystem-B clause prohibits.
|
||||
- §4.3 "remove `default=str` fallbacks in content-id serialization" — verified already clean: the
|
||||
only `default=str` occurrences are human-readable CLI display printing (`core/cli.py`), which
|
||||
ADR-0245 §2.3 permits; every content-id site refuses non-serializable payloads.
|
||||
- §Phase-2 chiral composition — implemented, with the honesty theorem pinned: I₅ is central in odd
|
||||
Cl(4,1), so closed versors have Q ≡ 0 exactly; the precondition is vacuous-by-theorem on
|
||||
admissible trajectories and LIVE against raw non-versor mirror flips (both pinned in tests).
|
||||
BIN
docs/research/core_labs_core_technical_gap_audit.pdf
Normal file
BIN
docs/research/core_labs_core_technical_gap_audit.pdf
Normal file
Binary file not shown.
BIN
docs/research/core_repository_systems_audit_and_gap_analysis.pdf
Normal file
BIN
docs/research/core_repository_systems_audit_and_gap_analysis.pdf
Normal file
Binary file not shown.
114
docs/research/intelligence-loop-homestretch-plan-2026-07-18.md
Normal file
114
docs/research/intelligence-loop-homestretch-plan-2026-07-18.md
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
# Intelligence-Loop Homestretch Plan
|
||||
|
||||
**Status**: Proposed plan — awaiting Shay's go before any implementation
|
||||
**Date**: 2026-07-18
|
||||
**Base**: `main @ 54659b76` (Rings 2+3 merged; ADR-0243/0244/0245 Accepted; ADR-0246/0247/0248 Proposed, flags off)
|
||||
**Foundation**: `docs/research/spark-audit-adjudication-2026-07-18.md` — every work item below survived
|
||||
claim-by-claim verification against the live tree; stale audit claims were removed there and must not
|
||||
resurface as work items.
|
||||
**Related**: ADR-0240, ADR-0243…0248, `docs/research/core_cohesion_master_plan.md`
|
||||
|
||||
---
|
||||
|
||||
## 1. Objective (done-when)
|
||||
|
||||
Close the comprehend → reason → articulate → contemplate → learn loop and make its value measurable:
|
||||
|
||||
1. **All green CI** (smoke + fast lanes) at every phase boundary.
|
||||
2. **Meaningful, generalized lift in problem solving, without overfitting** — decided by a dedicated
|
||||
instrument (Phase 4), not by narrative. An honest NULL is a legitimate, recordable outcome.
|
||||
3. **Articulate comprehension of inputs and articulate generation of outputs** as one cumulative loop —
|
||||
the corridor's field→token readback wired and round-trip-verified (Phase 1).
|
||||
4. `generate/` ("core_logos" role) upgrade explicitly **deferred** until the above land (Phase 6 scope note).
|
||||
|
||||
## 2. Governance constraints binding all phases
|
||||
|
||||
- **A-04 serve-path containment**: wave-field / Fibonacci operators stay out of `chat/runtime.py`;
|
||||
corridor work lives in `core/physics/` + `evals/` quarantine. Serving consumes only ratified frozen artifacts.
|
||||
- **I-03 / proposal-only learning**: no autonomous mutation of the active manifold; biography integration
|
||||
only via the PASS-gated wiring layer, harness-driven.
|
||||
- **No self-Accept**: ADR-0246/0247/0248 stay Proposed; phases produce acceptance-packet evidence only.
|
||||
Flag flips and Accepts are Shay's alone.
|
||||
- **Decoding, not generating**: readback refusals are typed and fail-closed; no fallback strings.
|
||||
- **Worktree discipline**: all work in a worktree off `forgejo/main`; one PR per coherent phase;
|
||||
smoke gate in-worktree before any push.
|
||||
|
||||
## 3. Phases
|
||||
|
||||
### Phase 0 — Worktree + record (small) — DONE
|
||||
- [x] Spark PDFs copied to `docs/research/`.
|
||||
- [x] Adjudication doc written (`spark-audit-adjudication-2026-07-18.md`).
|
||||
- [x] This plan doc written.
|
||||
- [x] Worktree `feat/intelligence-loop-arc` off `forgejo/main`; baseline smoke 176 passed (133s).
|
||||
- [x] Opening record committed (`fcea2d3a`).
|
||||
|
||||
### Phase 1 — Close the articulation seam, S1 (medium) — DONE (`19d5731a`)
|
||||
Wire a `readback` stage into the lifecycle corridor (eval-tier, off-serving):
|
||||
- `egress` `route="readback_eligible"` → `VocabManifold.nearest()` token selection
|
||||
(`cognitive_lifecycle.py` gains a vocab consumer; today it imports no `vocab`, `:68-76`).
|
||||
- Fail-closed: typed refusal when no resonant token exists — no fallback strings.
|
||||
- **Round-trip feedback eval ("hearing ourselves think")**: re-ingest the articulated token sequence
|
||||
and measure phase-integrity / resonance agreement against the pre-articulation steady state.
|
||||
Falsifiable pass criterion fixed before implementation.
|
||||
- TDD anchors: `tests/test_adr_0243_cognitive_lifecycle.py`, `tests/test_vocab_manifold_invariants.py`.
|
||||
- Scope guard: within Accepted ADR-0243 §2.3 (readback rules); if design exceeds it → ADR amendment, not silent drift.
|
||||
|
||||
### Phase 2 — Activate the learning write-path, S2 (medium) — DONE (`f16b4a60`)
|
||||
- Compose the chiral Q_top latch (`chiral_gate.py`) into `integrate_validated_biography`
|
||||
(`biography_wiring.py:174`): charge conservation becomes a precondition of biography updates.
|
||||
- First real caller: harness-driven — after ADR-0240 validation PASS, integrate holonomy; prove
|
||||
**I-01 reboot-invariance** and replay determinism in tests.
|
||||
- Strictly PASS-gated + harness-driven; no idle-loop auto-integration (I-03).
|
||||
- Cleanup-as-you-find: `biography.py:62` bare `.tobytes()` → explicit `<f8` coercion.
|
||||
- TDD anchors: `tests/test_adr_0240_biography_holonomy.py`, `tests/test_adr_0243_biography_wiring.py`.
|
||||
|
||||
### Phase 3 — Unify the autonomy floor, S3 (small) — DONE (`d672c712`)
|
||||
- Route the lifecycle's residual check (`cognitive_lifecycle.py:831`) through `GoldTetherMonitor`
|
||||
so autonomy-level modulation + chiral latching govern corridor runs — one guard, not two half-guards.
|
||||
- Layering direction: lifecycle → goldtether → WaveManifold (the audit's "integrate Monitor into
|
||||
WaveManifold" is rejected; see adjudication §2).
|
||||
- Not wired into serve (A-04). Parallelizable with Phases 1–2.
|
||||
|
||||
### Phase 4 — Generalized-lift instrument (medium-large, the crux)
|
||||
Instrument before consumption (ADR-0190 lesson: build the measurement first):
|
||||
- Corridor-vs-symbolic-baseline evaluation harness: problem Hamiltonians compiled from the same
|
||||
readers both paths use; measure solve success + refusal honesty.
|
||||
- Panels: 3-domain anti-overfit panel; deductive flagship as a **guard** (wrong=0 must hold);
|
||||
real GSM8K holdout slice (never the 150 templated cases); field-reasoner reading-independence wedge.
|
||||
- Anti-overfit discipline: holdout sealed; no per-case tuning; κ/γ calibration only through the
|
||||
existing sealed calibration evals + ratification.
|
||||
- Honest-NULL protocol: if the corridor adds no eval delta, record NULL (as ADR-0246 §11 did).
|
||||
Truth test is eval delta, not artifact append.
|
||||
|
||||
### Phase 5 — Handoff evidence for ruling (medium) — DONE (evals/lift_evidence_handoff.py: proceed vs typed abstain, chains verified)
|
||||
- Run the Phase 4 instrument through ADR-0247 ports + ADR-0248 handoff machinery (flags on in
|
||||
evals only) and assemble acceptance-packet evidence for ADR-0246/0247/0248.
|
||||
- Deliverable: packets ready for Shay's §8 rulings. No self-Accept, no flag flips.
|
||||
|
||||
### Phase 6 — Deferred: `generate/` ("core_logos") upgrade
|
||||
- Out of scope for this arc by explicit direction. Phase 4's results show where articulation
|
||||
quality actually binds; that evidence scopes the next arc.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
- Phase 1 → Phase 4 (instrument needs the closed loop). Phases 2–3 parallel with 1.
|
||||
- Phase 5 needs Phase 4's evidence. Each phase = own PR, smoke-gated, merged before the next builds on it
|
||||
(stacked only if necessary; merge-commit discipline).
|
||||
|
||||
## 5. Risks (honest register)
|
||||
|
||||
| Risk | Level | Handling |
|
||||
| :--- | :--- | :--- |
|
||||
| Phase 4 returns NULL lift (corridor doesn't beat symbolic path yet) | **High-likelihood, low-harm** | Honest NULL recorded; instrument makes the question decidable; scopes Phase 6 |
|
||||
| VocabManifold coverage too sparse for meaningful readback | Medium | Fail-closed refusals are correct behavior; coverage growth is proposal-gated corpus work, not this arc |
|
||||
| New eval suites bloat fast lane / flake in CI | Medium | Lane markers (`slow`/`quarantine`) assigned at authoring time; smoke gate at every phase |
|
||||
| Biography wiring drifts toward autonomous mutation | Low | Harness-driven, PASS-gated only; I-03 checked in review at Phase 2 PR |
|
||||
| Scope creep beyond Accepted ADR text | Low | Each phase names its governing ADR section; exceeding it → ADR amendment PR, not silent drift |
|
||||
|
||||
## 6. Decisions to make at phase start (not blockers now)
|
||||
|
||||
- Phase 1: exact round-trip pass criterion (resonance-agreement threshold vs rank-agreement of top-k tokens).
|
||||
- Phase 2: whether the first caller lives in `evals/analogical_transfer/harness.py` or
|
||||
`evals/adr_0243_cognitive_lifecycle/` (leaning: adr_0243 harness — it already imports GoldTetherMonitor).
|
||||
- Phase 4: GSM8K holdout slice size + which 3 panel domains (reuse the universal-structure trio unless
|
||||
evidence says otherwise).
|
||||
95
docs/research/spark-audit-adjudication-2026-07-18.md
Normal file
95
docs/research/spark-audit-adjudication-2026-07-18.md
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# Spark Audit Adjudication — claim-by-claim verification against `main`
|
||||
|
||||
**Status**: Record (verification complete 2026-07-18)
|
||||
**Verified against**: `main @ 54659b76` (post Rings 2+3 merge)
|
||||
**Inputs**: `docs/research/core_labs_core_technical_gap_audit.pdf` ("Evolutionary Landscape", 8pp),
|
||||
`docs/research/core_repository_systems_audit_and_gap_analysis.pdf` (systems-grade review, 4pp)
|
||||
**Method**: three independent read-only verification passes over the live tree; every claim
|
||||
adjudicated with file:line evidence before being allowed to become a work item.
|
||||
**Companion**: `docs/research/intelligence-loop-homestretch-plan-2026-07-18.md` (the plan built on this record)
|
||||
|
||||
---
|
||||
|
||||
## 1. Headline finding: the audits are one day stale
|
||||
|
||||
Both documents describe the repository **before the 2026-07-17 cohesion-directive waves**
|
||||
(D1/D2, ADR-0244 Phases 2–6, ADR-0243 flagship lifecycle, ADR-0246 rings). Most named gaps
|
||||
were closed on `main` the day before the audits were delivered:
|
||||
|
||||
| Closing commit | What it closed |
|
||||
| :--- | :--- |
|
||||
| `c3b4d045` feat(adr-0243) flagship cognitive_lifecycle.py | ingress → relax → egress orchestration |
|
||||
| `4ec2c8b9` refactor(adr-0244) D1 semantic rigor | full 256-bit digests + LE byte-order |
|
||||
| `82b031d1` perf(adr-0244) D2 mechanical sympathy | Rust f64 GP fast-path + `_cached_eigh` memoization |
|
||||
| `5c69b741` Phase 5a §2.7 content-id semantic rigor | remaining content-id sites |
|
||||
| `918aa843` Phase 4 governed f64→f32 serving-boundary cast | Serves-Boundary Cast Contract |
|
||||
| `5027adf8` ADR-0244 + ADR-0245 Proposed→Accepted (Joshua Shay) | audits assume both still Proposed |
|
||||
|
||||
Rule reaffirmed: **external audit claims are point-in-time and must be verified against source
|
||||
before being acted on** (see also `feedback-read-source-not-sandbox-traces`).
|
||||
|
||||
---
|
||||
|
||||
## 2. Claim-by-claim verdicts
|
||||
|
||||
### Refuted / already closed
|
||||
|
||||
| # | Audit claim | Verdict | Evidence |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| 1 | "Relax phase omitted — orchestrator skips ingest→egress" | **REFUTED** | `CognitiveLifecycleEngine.solve()` runs `ingest_context` → `relax_to_ground` → `egress` (`core/physics/cognitive_lifecycle.py:1054-1071`); `relax_to_ground` (`:530`) is deterministic imaginary-time relaxation with a certified `RelaxationCertificate` |
|
||||
| 2 | "Hardcoded `[RESONANT_LOCK…]` mock readback; sine-wave proxies" | **REFUTED** | No such string anywhere (grep empty); real geometric readback exists: `VocabManifold.nearest()` = exact CGA inner-product argmax, "no cosine similarity, no ANN index" (`vocab/manifold.py:261-298`) |
|
||||
| 3 | "`_cached_eigh` LRU completely missing in identity.py" | **REFUTED** (category error) | ADR-0245 §2.4 targets the frozen ProblemHamiltonian, not identity.py; implemented exactly to spec at `cognitive_lifecycle.py:509-522`, keyed `(hamiltonian_id, H_mat.tobytes())`, called at `:588`. `identity.py` performs zero eigendecompositions. ADR-0245 status map records §2.4 "✅ Done" |
|
||||
| 4 | "Vault digests truncated to 24 hex chars" | **REFUTED** | Vault hashing is full 64-hex: `vault/store.py:513-515`, `vault/crdt.py:204`, `core/physics/holographic_vault.py:80`. Only human-readable labels truncate (`core/demos/*`, `core/cli_teaching.py:626,977`) — explicitly permitted by ADR-0245 §2.3 |
|
||||
| 5 | "Platform-dependent hashing (no `<f8` coercion)" | **REFUTED** for all load-bearing sites | `_le_f64_bytes` (`cognitive_lifecycle.py:137-138`), `holographic_vault.py:79`, `identity_action.py:223,528` — all coerce `np.dtype("<f8")`. Lone hygiene residual: `biography.py:62` hashes bare `float64.tobytes()` (byte-identical on LE targets, outside the vault content-address set) — folded into plan Phase 2 |
|
||||
| 6 | "Fibonacci API drift (missing `best_observed_point`/`eval_sequence`)" | **REFUTED** | `SearchTrace` compat dataclass carries exactly those fields (`fibonacci_search.py:108-112`) via `search_trace_from_result` (`:368`); `FibonacciSearchCertificate` keeps `minimizer`/`ordered_points`/`ordered_values` (`:60-63`) |
|
||||
| 7 | "GoldTether residual math duplicated inline elsewhere" | **REFUTED** | One shared kernel: `goldtether.py:117-125` `coherence_residual` delegates to `WaveManifold.measure_unitary_residual`; `cognitive_lifecycle.py:831` calls the same kernel |
|
||||
| 8 | "Biography holonomy not implemented — no lifelong learning mechanism" | **REFUTED as stated** (see §4 for what IS open) | `integrate_biography` builds the holonomy blade via `holonomy_encode` (`core/physics/biography.py:66-110`); pinned by `tests/test_adr_0240_biography_holonomy.py:17-51`; PASS-gated wiring layer exists (`biography_wiring.py:174`) |
|
||||
|
||||
### Rejected as doctrine violations — must NOT be applied
|
||||
|
||||
| Audit recommendation | Why rejected |
|
||||
| :--- | :--- |
|
||||
| "Wire Fibonacci search to run online calibration on live sensory streams" | Violates master-plan **A-04** (serve-path containment: wave/Fibonacci operators quarantined to `evals/` + calibration), **I-03** (no self-mutation), **R-04** (hot paths receive only pre-ratified frozen scalars). Calibration correctly lives in `evals/adr_0244_gamma_calibration/__init__.py:187` and `evals/analogical_transfer/kappa_calibration.py:30` (via `goldtether.propose_kappa_line_search`, `goldtether.py:567-606`) |
|
||||
| "Integrate GoldTetherMonitor directly into WaveManifold" | Inverts layering: `goldtether.py` imports `WaveManifold`, not vice versa. Correct fix is the opposite direction (plan Phase 3) |
|
||||
|
||||
---
|
||||
|
||||
## 3. Naming / provenance reconciliation
|
||||
|
||||
- The audits' `multimodal_lifecycle.py` = the real `core/physics/cognitive_lifecycle.py`.
|
||||
- The audits' `vocab/readback_rules.py` = the real `vocab/manifold.py` (`VocabManifold`).
|
||||
- **`core_logos` does not exist as code.** It was the predecessor `core-ai` subsystem;
|
||||
`docs/adr/ADR-0011-renderer.md:96` states no `core_logos` equivalent will be introduced.
|
||||
The serve-time articulation role is played by `generate/` (`realizer.py`, `articulation.py`,
|
||||
`surface.py`, `stream.py`), consumed by `chat/runtime.py` (`:95-111`). "core_logos is the
|
||||
weakest link" therefore maps to the `generate/` stack.
|
||||
- The `docs/research/` ADR-0241…0243 documents are the Spark research series that seeded the
|
||||
canonical `docs/adr/` ADR-0241…0245 (now **Accepted**, ratified 2026-07-17). The canonical
|
||||
ADRs supersede the research drafts wherever they diverge.
|
||||
|
||||
---
|
||||
|
||||
## 4. Confirmed real seams (survived verification — these ARE the work)
|
||||
|
||||
- **S1 — Articulation seam.** The lifecycle's `egress_gate` stops at `route="readback_eligible"`
|
||||
(`cognitive_lifecycle.py:803,852`) and never invokes `VocabManifold.nearest()`
|
||||
(`cognitive_lifecycle.py` imports no `vocab`, `:68-76`). The field→token step is unwired even
|
||||
inside the quarantine corridor; the comprehend→reason→articulate loop does not close, and the
|
||||
"hearing ourselves think" feedback (re-ingesting own articulation) does not exist.
|
||||
- **S2 — Learning write-path dormant.** `integrate_validated_biography`
|
||||
(`biography_wiring.py:174`, eval-report-PASS gated) has zero live callers (tests only).
|
||||
Topological-charge conservation exists (`chiral_gate.py:1-114`, sgn(Q_top) latching) but is
|
||||
wired into `GoldTetherMonitor` (`goldtether.py:160,242`), decoupled from biography updates
|
||||
(which use the wave unitary residual instead). Machinery built; nothing drives it; the two
|
||||
guards are not composed.
|
||||
- **S3 — Autonomy floor bypassed in the corridor.** `cognitive_lifecycle.py:831` checks the raw
|
||||
unitary residual directly, bypassing `GoldTetherMonitor` autonomy-level modulation + chiral
|
||||
latching (only `self_authorship.py:15` consumes the Monitor). One guard should govern, in the
|
||||
goldtether→WaveManifold layering direction.
|
||||
- **S4 — The serving bridge is the ratification frontier.** Serving is the symbolic `generate/`
|
||||
path; the wave corridor is Tier-2 off-serving by design (`core/physics/__init__.py:156,187`
|
||||
TYPE_CHECKING-only; runtime instantiation only in `evals/adr_0243_cognitive_lifecycle/__init__.py:117,119`
|
||||
and tests). The governed seam machinery — ADR-0247 ports + ADR-0248 handoffs — is merged,
|
||||
flag-off, **Proposed**, awaiting evidence and Shay's ruling.
|
||||
- **S5 — `generate/` upgrade deferred** by explicit direction until S1–S3 + the measurement
|
||||
instrument land (plan Phase 6).
|
||||
100
evals/analogical_transfer/biography_session.py
Normal file
100
evals/analogical_transfer/biography_session.py
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
"""ADR-0243 §2.5 — harness-driven biography session (seam S2's first real caller).
|
||||
|
||||
Runs the ADR-0240 analogical-transfer harness and, on report-level PASS,
|
||||
integrates the session's lived trajectory into the Biography Holonomy Blade
|
||||
via the PASS-gated wiring (:func:`integrate_validated_biography`; direct
|
||||
integration per the 2026-07-17 ruling — the blade is derived state, a pure
|
||||
recompute, never persisted).
|
||||
|
||||
The lived trajectory is the sequence of transfer versors the session actually
|
||||
underwent: the report carries scalar evidence only (by design), so the
|
||||
versors are RECOMPUTED here from the validated cases' point clouds via
|
||||
:func:`conformal_procrustes` — reconstruction-over-storage, deterministic,
|
||||
bound to the report by the provenance record's content hashes.
|
||||
|
||||
Eval-tier (A-04): lives under ``evals/``; never imported by serving. Failure
|
||||
at any stage is the wiring's typed :class:`BiographyIntegrationError` — a
|
||||
session with wrongs, or with nothing validated, integrates nothing.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Sequence
|
||||
|
||||
from core.physics.biography import BiographyHolonomyBlade
|
||||
from core.physics.biography_wiring import (
|
||||
BiographyProvenanceRecord,
|
||||
integrate_validated_biography,
|
||||
)
|
||||
from core.physics.dynamic_manifold import conformal_procrustes
|
||||
from core.physics.goldtether import GoldTetherMonitor
|
||||
from evals.analogical_transfer.harness import (
|
||||
AnalogicalTransferReport,
|
||||
TransferCase,
|
||||
run_analogical_transfer,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"BiographySessionArtifact",
|
||||
"run_biography_session",
|
||||
"session_trajectory",
|
||||
]
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class BiographySessionArtifact:
|
||||
"""One validated session: report, integrated blade, provenance, lineage."""
|
||||
|
||||
report: AnalogicalTransferReport
|
||||
blade: BiographyHolonomyBlade
|
||||
record: BiographyProvenanceRecord
|
||||
trajectory_case_ids: tuple[str, ...]
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"record": self.record.as_dict(),
|
||||
"trajectory_case_ids": list(self.trajectory_case_ids),
|
||||
"blade_n_steps": int(self.blade.n_steps),
|
||||
"blade_closure": float(self.blade.closure),
|
||||
"trajectory_hash": self.blade.trajectory_hash,
|
||||
}
|
||||
|
||||
|
||||
def session_trajectory(
|
||||
cases: Sequence[TransferCase], report: AnalogicalTransferReport
|
||||
) -> tuple[tuple, tuple[str, ...]]:
|
||||
"""Recompute the lived trajectory: one recovered versor per CORRECT case.
|
||||
|
||||
Report order is preserved (order is load-bearing for holonomy). Refused and
|
||||
wrong cases contribute nothing — wrong=0 gating happens in the wiring.
|
||||
"""
|
||||
by_id = {c.case_id: c for c in cases}
|
||||
versors = []
|
||||
case_ids: list[str] = []
|
||||
for result in report.results:
|
||||
if not result.correct:
|
||||
continue
|
||||
case = by_id[result.case_id]
|
||||
versor, _residual = conformal_procrustes(case.source, case.target)
|
||||
versors.append(versor)
|
||||
case_ids.append(result.case_id)
|
||||
return tuple(versors), tuple(case_ids)
|
||||
|
||||
|
||||
def run_biography_session(
|
||||
cases: Sequence[TransferCase],
|
||||
*,
|
||||
residual_threshold: float = 0.35,
|
||||
alpha: float = 0.5,
|
||||
goldtether: GoldTetherMonitor | None = None,
|
||||
) -> BiographySessionArtifact:
|
||||
"""Validate → recompute lived trajectory → integrate (PASS-gated, typed refusals)."""
|
||||
report = run_analogical_transfer(
|
||||
cases, residual_threshold=residual_threshold, goldtether=goldtether
|
||||
)
|
||||
trajectory, case_ids = session_trajectory(cases, report)
|
||||
blade, record = integrate_validated_biography(report, trajectory, alpha=alpha)
|
||||
return BiographySessionArtifact(
|
||||
report=report, blade=blade, record=record, trajectory_case_ids=case_ids
|
||||
)
|
||||
471
evals/generalized_lift_instrument.py
Normal file
471
evals/generalized_lift_instrument.py
Normal file
|
|
@ -0,0 +1,471 @@
|
|||
"""Generalized-lift instrument — corridor vs symbolic baseline (seam S4, OFF-SERVING).
|
||||
|
||||
Instrument-first doctrine (ADR-0190 lesson): this module DECIDES the
|
||||
"meaningful, generalized lift without overfitting" question instead of
|
||||
narrating it. Three deterministic domains, identical compiled problems for
|
||||
both paths, independent gold, and an honest-NULL protocol: if the corridor
|
||||
adds no delta, the report says so.
|
||||
|
||||
Domains (corridor v1's honest ingestible surface):
|
||||
|
||||
* ``propositional`` — entailment on an enumerated case family. Corridor:
|
||||
:func:`propositional_entails` (exact ground-energy verdicts). Baseline: the
|
||||
deductive flagship (ROBDD, ``generate.logic_equivalence`` — P ⊨ C iff
|
||||
(P and C) ≡ P). Gold: independent brute-force truth tables computed here.
|
||||
The wrong=0 guard binds the corridor on this domain.
|
||||
* ``constrained-recognition`` — ambiguous two-mode ingress relaxed under the
|
||||
problem well, then ARTICULATED via the seam-S1 readback; baseline is the
|
||||
constraint-blind ingress argmax over the same vocabulary. The measured
|
||||
delta isolates the relax+readback stages' contribution — an eigensolver
|
||||
baseline WITH access to H would reach parity (disclosed in notes; this
|
||||
domain measures loop integrity, not open-ended capability).
|
||||
* ``multimodal-completion`` — the sensorium corridor pattern (audio partial →
|
||||
full audio+vision percept), scored on whether articulation names BOTH
|
||||
constituent percepts; baseline articulates the raw partial ingress.
|
||||
|
||||
Scope limitations are RECORDED, never silently dropped (no-silent-caps):
|
||||
GSM8K and other natural-language arithmetic are NOT ingestible by corridor
|
||||
v1 — there is no reader→Hamiltonian compiler beyond the ≤5-atom
|
||||
propositional and quadratic-well domains. That compiler is the real
|
||||
composition frontier, and this instrument is the harness waiting for it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from itertools import product
|
||||
from typing import Any, Sequence
|
||||
|
||||
import numpy as np
|
||||
|
||||
from algebra.rotor import make_rotor_from_angle
|
||||
from core.physics.cognitive_lifecycle import (
|
||||
CognitiveLifecycleEngine,
|
||||
PropositionalProblem,
|
||||
compile_quadratic_well,
|
||||
egress_gate,
|
||||
ingest_context,
|
||||
propositional_entails,
|
||||
relax_to_ground,
|
||||
)
|
||||
from core.physics.linguistic_readback import (
|
||||
ReadbackRefusal,
|
||||
articulate_outcome,
|
||||
linguistic_readback,
|
||||
)
|
||||
from core.physics.sensorium_wave_feed import ModalityPacket
|
||||
from core.physics.wave_manifold import WaveManifold
|
||||
from generate.logic_equivalence import Verdict, check_equivalence
|
||||
from vocab.manifold import VocabManifold
|
||||
|
||||
__all__ = [
|
||||
"DomainOutcome",
|
||||
"LiftInstrumentReport",
|
||||
"run_generalized_lift_instrument",
|
||||
"run_propositional_domain",
|
||||
"run_recognition_domain",
|
||||
"run_multimodal_domain",
|
||||
]
|
||||
|
||||
# Hot-band energy axes (existing E3/E4 precedent; caller-supplied, never invented).
|
||||
_HOT_ENERGY: dict[str, Any] = {
|
||||
"convergence_density": 8,
|
||||
"activation_count": 8,
|
||||
"current_cycle": 1,
|
||||
"last_activation_cycle": 1,
|
||||
"morphology_features": {"mood": "imperative"},
|
||||
}
|
||||
|
||||
_MIN_RESONANCE = 0.4
|
||||
_LIFT, _PARITY, _DEFICIT = "LIFT", "PARITY", "DEFICIT"
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class DomainOutcome:
|
||||
"""One domain's corridor-vs-baseline scorecard (per-case rows disclosed)."""
|
||||
|
||||
domain_id: str
|
||||
n_cases: int
|
||||
corridor_correct: int
|
||||
corridor_wrong: int
|
||||
corridor_refused: int
|
||||
baseline_correct: int
|
||||
baseline_wrong: int
|
||||
baseline_refused: int
|
||||
notes: tuple[str, ...]
|
||||
cases: tuple[dict[str, Any], ...]
|
||||
|
||||
@property
|
||||
def delta_correct(self) -> int:
|
||||
return self.corridor_correct - self.baseline_correct
|
||||
|
||||
@property
|
||||
def verdict(self) -> str:
|
||||
if self.delta_correct > 0:
|
||||
return _LIFT
|
||||
return _PARITY if self.delta_correct == 0 else _DEFICIT
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"domain_id": self.domain_id,
|
||||
"n_cases": self.n_cases,
|
||||
"corridor": {
|
||||
"correct": self.corridor_correct,
|
||||
"wrong": self.corridor_wrong,
|
||||
"refused": self.corridor_refused,
|
||||
},
|
||||
"baseline": {
|
||||
"correct": self.baseline_correct,
|
||||
"wrong": self.baseline_wrong,
|
||||
"refused": self.baseline_refused,
|
||||
},
|
||||
"delta_correct": self.delta_correct,
|
||||
"verdict": self.verdict,
|
||||
"notes": list(self.notes),
|
||||
"cases": list(self.cases),
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class LiftInstrumentReport:
|
||||
outcomes: tuple[DomainOutcome, ...]
|
||||
wrong_zero_guard_held: bool
|
||||
honest_null: bool
|
||||
scope_limitations: tuple[str, ...]
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"outcomes": [o.as_dict() for o in self.outcomes],
|
||||
"wrong_zero_guard_held": self.wrong_zero_guard_held,
|
||||
"honest_null": self.honest_null,
|
||||
"scope_limitations": list(self.scope_limitations),
|
||||
}
|
||||
|
||||
|
||||
# --- Domain A: propositional entailment ------------------------------------------------
|
||||
|
||||
Literal = tuple[str, bool]
|
||||
Clause = tuple[Literal, ...]
|
||||
|
||||
# (case_id, atoms, premise clauses (CNF), conclusion clause (single literal))
|
||||
_PROP_CASES: tuple[tuple[str, tuple[str, ...], tuple[Clause, ...], Literal], ...] = (
|
||||
("modus-ponens", ("a", "b"), ((("a", True),), (("a", False), ("b", True))), ("b", True)),
|
||||
(
|
||||
"chain-3",
|
||||
("a", "b", "c"),
|
||||
((("a", True),), (("a", False), ("b", True)), (("b", False), ("c", True))),
|
||||
("c", True),
|
||||
),
|
||||
("disj-not-entailed", ("a", "b"), ((("a", True), ("b", True)),), ("a", True)),
|
||||
("unsat-ex-falso", ("a", "b"), ((("a", True),), (("a", False),)), ("b", True)),
|
||||
(
|
||||
"neg-conclusion",
|
||||
("a", "b"),
|
||||
((("a", True),), (("a", False), ("b", False))),
|
||||
("b", False),
|
||||
),
|
||||
("no-information", ("a", "b"), ((("a", True),),), ("b", True)),
|
||||
(
|
||||
"resolution",
|
||||
("a", "b", "c"),
|
||||
(
|
||||
(("a", True), ("b", True)),
|
||||
(("a", False), ("c", True)),
|
||||
(("b", False), ("c", True)),
|
||||
),
|
||||
("c", True),
|
||||
),
|
||||
(
|
||||
"contrapositive",
|
||||
("a", "b"),
|
||||
((("a", False), ("b", True)), (("b", False),)),
|
||||
("a", False),
|
||||
),
|
||||
("premise-restates", ("a", "b"), ((("a", True),),), ("a", True)),
|
||||
("wide-disj-not-entailed", ("a", "b", "c"), ((("a", True), ("b", True), ("c", True)),), ("c", True)),
|
||||
)
|
||||
|
||||
|
||||
def _lit_formula(lit: Literal) -> str:
|
||||
atom, positive = lit
|
||||
return atom if positive else f"(not {atom})"
|
||||
|
||||
|
||||
def _clauses_formula(clauses: Sequence[Clause]) -> str:
|
||||
return " and ".join("(" + " or ".join(_lit_formula(l) for l in clause) + ")" for clause in clauses)
|
||||
|
||||
|
||||
def _truth_table_entailed(
|
||||
atoms: Sequence[str], clauses: Sequence[Clause], conclusion: Literal
|
||||
) -> bool:
|
||||
"""Independent gold: every model of the premises satisfies the conclusion."""
|
||||
for values in product((False, True), repeat=len(atoms)):
|
||||
env = dict(zip(atoms, values))
|
||||
if all(any(env[a] == pos for a, pos in clause) for clause in clauses):
|
||||
atom, positive = conclusion
|
||||
if env[atom] != positive:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def run_propositional_domain() -> DomainOutcome:
|
||||
corridor_correct = corridor_wrong = corridor_refused = 0
|
||||
baseline_correct = baseline_wrong = baseline_refused = 0
|
||||
rows: list[dict[str, Any]] = []
|
||||
for case_id, atoms, clauses, conclusion in _PROP_CASES:
|
||||
gold = _truth_table_entailed(atoms, clauses, conclusion)
|
||||
|
||||
corridor_entailed = propositional_entails(
|
||||
PropositionalProblem(atoms=atoms, clauses=clauses), (conclusion,)
|
||||
).entailed
|
||||
if corridor_entailed == gold:
|
||||
corridor_correct += 1
|
||||
else:
|
||||
corridor_wrong += 1
|
||||
|
||||
premises_f = _clauses_formula(clauses)
|
||||
conjunction_f = f"({premises_f}) and ({_lit_formula(conclusion)})"
|
||||
robdd = check_equivalence(conjunction_f, premises_f)
|
||||
if robdd.verdict is Verdict.REFUSED:
|
||||
baseline_refused += 1
|
||||
baseline_entailed: bool | None = None
|
||||
else:
|
||||
baseline_entailed = robdd.verdict is Verdict.EQUIVALENT
|
||||
if baseline_entailed == gold:
|
||||
baseline_correct += 1
|
||||
else:
|
||||
baseline_wrong += 1
|
||||
|
||||
rows.append(
|
||||
{
|
||||
"case_id": case_id,
|
||||
"gold_entailed": gold,
|
||||
"corridor_entailed": corridor_entailed,
|
||||
"baseline_entailed": baseline_entailed,
|
||||
}
|
||||
)
|
||||
return DomainOutcome(
|
||||
domain_id="propositional",
|
||||
n_cases=len(_PROP_CASES),
|
||||
corridor_correct=corridor_correct,
|
||||
corridor_wrong=corridor_wrong,
|
||||
corridor_refused=corridor_refused,
|
||||
baseline_correct=baseline_correct,
|
||||
baseline_wrong=baseline_wrong,
|
||||
baseline_refused=baseline_refused,
|
||||
notes=(
|
||||
"Baseline is the deductive flagship (ROBDD); PARITY here is the "
|
||||
"expected honest outcome — both paths are exact on this regime.",
|
||||
"wrong=0 guard binds the corridor on this domain.",
|
||||
),
|
||||
cases=tuple(rows),
|
||||
)
|
||||
|
||||
|
||||
# --- Domain B: constrained recognition + articulation ----------------------------------
|
||||
|
||||
_RECOGNITION_GRID: tuple[tuple[int, float], ...] = tuple(
|
||||
(plane, angle) for plane in (6, 7, 8) for angle in (0.4, 0.8, 1.2)
|
||||
)
|
||||
|
||||
|
||||
def _grid_word(plane: int, angle: float) -> str:
|
||||
return f"mode-p{plane}-a{int(round(angle * 10))}"
|
||||
|
||||
|
||||
def _recognition_vocab() -> tuple[VocabManifold, tuple[np.ndarray, ...]]:
|
||||
vocab = VocabManifold()
|
||||
versors: list[np.ndarray] = []
|
||||
for plane, angle in _RECOGNITION_GRID:
|
||||
v = np.asarray(make_rotor_from_angle(angle, bivector_idx=plane), dtype=np.float64)
|
||||
vocab.add(_grid_word(plane, angle), v)
|
||||
versors.append(v)
|
||||
return vocab, tuple(versors)
|
||||
|
||||
|
||||
def _argmax_word(psi: np.ndarray, vocab: VocabManifold, manifold: WaveManifold) -> str:
|
||||
best_score, best_idx = -np.inf, -1
|
||||
for i in range(len(vocab)):
|
||||
score = float(manifold.phase_correlation(psi, np.asarray(vocab.get_versor_at(i), dtype=np.float64))) / 2.0
|
||||
if score > best_score:
|
||||
best_score, best_idx = score, i
|
||||
return vocab.get_word_at(best_idx)
|
||||
|
||||
|
||||
def run_recognition_domain() -> DomainOutcome:
|
||||
vocab, versors = _recognition_vocab()
|
||||
manifold = WaveManifold()
|
||||
engine = CognitiveLifecycleEngine()
|
||||
n = len(_RECOGNITION_GRID)
|
||||
corridor_correct = corridor_wrong = corridor_refused = 0
|
||||
baseline_correct = baseline_wrong = 0
|
||||
rows: list[dict[str, Any]] = []
|
||||
for i, (plane, angle) in enumerate(_RECOGNITION_GRID):
|
||||
target_word = _grid_word(plane, angle)
|
||||
target = versors[i]
|
||||
distractor = versors[(i + 1) % n]
|
||||
packets = (
|
||||
ModalityPacket(modality_id="mix:target", coefficients=0.45 * target),
|
||||
ModalityPacket(modality_id="mix:distractor", coefficients=0.55 * distractor),
|
||||
)
|
||||
domain_id = f"recognition:{target_word}"
|
||||
|
||||
baseline_word = _argmax_word(
|
||||
ingest_context(packets, domain_id).psi, vocab, manifold
|
||||
)
|
||||
if baseline_word == target_word:
|
||||
baseline_correct += 1
|
||||
else:
|
||||
baseline_wrong += 1
|
||||
|
||||
row: dict[str, Any] = {
|
||||
"case_id": target_word,
|
||||
"baseline_word": baseline_word,
|
||||
}
|
||||
try:
|
||||
outcome = engine.solve(
|
||||
packets,
|
||||
domain_id,
|
||||
compile_quadratic_well(target),
|
||||
energy_inputs=_HOT_ENERGY,
|
||||
)
|
||||
readback, roundtrip = articulate_outcome(
|
||||
outcome, vocab, min_resonance=_MIN_RESONANCE, max_tokens=1
|
||||
)
|
||||
corridor_word = readback.tokens[0].word
|
||||
row["corridor_word"] = corridor_word
|
||||
row["roundtrip_agreement"] = roundtrip.agreement
|
||||
if corridor_word == target_word:
|
||||
corridor_correct += 1
|
||||
else:
|
||||
corridor_wrong += 1
|
||||
except ReadbackRefusal as exc:
|
||||
corridor_refused += 1
|
||||
row["corridor_word"] = None
|
||||
row["corridor_refusal"] = exc.reason
|
||||
rows.append(row)
|
||||
return DomainOutcome(
|
||||
domain_id="constrained-recognition",
|
||||
n_cases=n,
|
||||
corridor_correct=corridor_correct,
|
||||
corridor_wrong=corridor_wrong,
|
||||
corridor_refused=corridor_refused,
|
||||
baseline_correct=baseline_correct,
|
||||
baseline_wrong=baseline_wrong,
|
||||
baseline_refused=0,
|
||||
notes=(
|
||||
"Baseline is the constraint-blind ingress argmax over the same "
|
||||
"vocabulary; the delta isolates the relax+readback stages.",
|
||||
"An eigensolver baseline WITH access to H would reach parity — "
|
||||
"this domain measures loop integrity, not open-ended capability.",
|
||||
),
|
||||
cases=tuple(rows),
|
||||
)
|
||||
|
||||
|
||||
# --- Domain C: multimodal completion ---------------------------------------------------
|
||||
|
||||
|
||||
def run_multimodal_domain() -> DomainOutcome:
|
||||
from evals.adr_0243_cognitive_lifecycle import _fixed_audio_tone, _fixed_vision_tile
|
||||
from core.physics.sensorium_wave_feed import packet_from_compilation_unit
|
||||
from sensorium.audio.compiler import AudioCompiler
|
||||
from sensorium.vision import VisionCompiler
|
||||
|
||||
audio_unit = AudioCompiler().compile(_fixed_audio_tone(24_000, 0.25, 440.0), 24_000)
|
||||
vision_unit = VisionCompiler().compile_tile(_fixed_vision_tile())
|
||||
audio_pkt = packet_from_compilation_unit("audio", audio_unit)
|
||||
vision_pkt = packet_from_compilation_unit("vision", vision_unit)
|
||||
|
||||
vocab = VocabManifold()
|
||||
vocab.add("audio-tone", np.asarray(audio_pkt.coefficients, dtype=np.float64))
|
||||
vocab.add("vision-tile", np.asarray(vision_pkt.coefficients, dtype=np.float64))
|
||||
manifold = WaveManifold()
|
||||
|
||||
full = ingest_context((audio_pkt, vision_pkt), "multimodal-completion")
|
||||
partial = ingest_context((audio_pkt,), "multimodal-completion")
|
||||
expected_words = {"audio-tone", "vision-tile"}
|
||||
|
||||
def _resonant_words(psi: np.ndarray) -> set[str]:
|
||||
found = set()
|
||||
for i in range(len(vocab)):
|
||||
score = (
|
||||
float(
|
||||
manifold.phase_correlation(
|
||||
psi, np.asarray(vocab.get_versor_at(i), dtype=np.float64)
|
||||
)
|
||||
)
|
||||
/ 2.0
|
||||
)
|
||||
if score >= _MIN_RESONANCE:
|
||||
found.add(vocab.get_word_at(i))
|
||||
return found
|
||||
|
||||
baseline_words = _resonant_words(partial.psi)
|
||||
baseline_correct = int(baseline_words == expected_words)
|
||||
|
||||
corridor_correct = corridor_wrong = corridor_refused = 0
|
||||
row: dict[str, Any] = {
|
||||
"case_id": "audio-partial-to-full",
|
||||
"baseline_words": sorted(baseline_words),
|
||||
}
|
||||
result = relax_to_ground(partial.psi, compile_quadratic_well(full.psi))
|
||||
verdict = egress_gate(result.psi_steady, result.certificate, **_HOT_ENERGY)
|
||||
try:
|
||||
readback = linguistic_readback(
|
||||
result.psi_steady,
|
||||
result.certificate,
|
||||
verdict,
|
||||
vocab,
|
||||
min_resonance=_MIN_RESONANCE,
|
||||
max_tokens=2,
|
||||
)
|
||||
corridor_words = set(readback.words)
|
||||
row["corridor_words"] = sorted(corridor_words)
|
||||
if corridor_words == expected_words:
|
||||
corridor_correct = 1
|
||||
else:
|
||||
corridor_wrong = 1
|
||||
except ReadbackRefusal as exc:
|
||||
corridor_refused = 1
|
||||
row["corridor_refusal"] = exc.reason
|
||||
|
||||
return DomainOutcome(
|
||||
domain_id="multimodal-completion",
|
||||
n_cases=1,
|
||||
corridor_correct=corridor_correct,
|
||||
corridor_wrong=corridor_wrong,
|
||||
corridor_refused=corridor_refused,
|
||||
baseline_correct=baseline_correct,
|
||||
baseline_wrong=1 - baseline_correct,
|
||||
baseline_refused=0,
|
||||
notes=(
|
||||
"Correct = articulation names BOTH constituent percepts; baseline "
|
||||
"articulates the raw audio-only partial ingress.",
|
||||
),
|
||||
cases=(row,),
|
||||
)
|
||||
|
||||
|
||||
# --- Composed instrument ---------------------------------------------------------------
|
||||
|
||||
|
||||
def run_generalized_lift_instrument() -> LiftInstrumentReport:
|
||||
outcomes = (
|
||||
run_propositional_domain(),
|
||||
run_recognition_domain(),
|
||||
run_multimodal_domain(),
|
||||
)
|
||||
propositional = outcomes[0]
|
||||
return LiftInstrumentReport(
|
||||
outcomes=outcomes,
|
||||
wrong_zero_guard_held=(propositional.corridor_wrong == 0),
|
||||
honest_null=all(o.delta_correct <= 0 for o in outcomes),
|
||||
scope_limitations=(
|
||||
"GSM8K / natural-language arithmetic is NOT ingestible by corridor "
|
||||
"v1: no reader-to-Hamiltonian compiler exists beyond the <=5-atom "
|
||||
"propositional and quadratic-well domains. Recorded, not silently "
|
||||
"dropped; that compiler is the composition frontier this "
|
||||
"instrument is waiting to measure.",
|
||||
),
|
||||
)
|
||||
109
evals/lift_evidence_handoff.py
Normal file
109
evals/lift_evidence_handoff.py
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
"""ADR-0247/0248 evidence run — lift-instrument turns through ports + handoff (seam S5).
|
||||
|
||||
Routes two corridor turns through the Ring-2 residual protocol and the Ring-3
|
||||
integrity handoff, OFF-SERVING (no flags touched — this produces §8 ruling
|
||||
evidence, not activation):
|
||||
|
||||
* an **identity-action** turn (the canonical identity versor — under the
|
||||
locked ADR-0246 stabilizer H_id={I} the identity action is the ONLY lawful
|
||||
action, so this is the canonical lawful turn, not a toy) → expected: both
|
||||
ports PROCEED, handoff PROCEED;
|
||||
* a **frame-rotating** turn (e1∧e2 rotor — an in-span rotation the ADR-0246
|
||||
stabilizer refuses) → expected: identity port ABSTAIN with typed reasons,
|
||||
handoff ABSTAIN.
|
||||
|
||||
Each turn is a REAL certified lifecycle outcome (relax → egress → governed
|
||||
serving cast), so the PrecisionPort witnesses a genuine f64→f32 transport.
|
||||
The pair demonstrates the handoff DISCRIMINATES — the acceptance evidence is
|
||||
the contrast, not a single green path.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
from algebra.cl41 import N_COMPONENTS
|
||||
from core.epistemic_state import EpistemicState, NormativeClearance
|
||||
from core.physics.cognitive_lifecycle import (
|
||||
CognitiveLifecycleEngine,
|
||||
compile_quadratic_well,
|
||||
serving_cast,
|
||||
)
|
||||
from core.physics.identity_action import AdmissionPolicy
|
||||
from core.physics.identity_manifold import IdentityManifoldGeometry
|
||||
from core.physics.sensorium_wave_feed import ModalityPacket
|
||||
from core.ports.adapters import (
|
||||
IdentityPort,
|
||||
PrecisionPort,
|
||||
PrecisionSubject,
|
||||
)
|
||||
from core.ports.integrity_handoff import coordinate_handoff
|
||||
from core.ports.residual_protocol import run_residual_protocol, verify_replay_chain
|
||||
|
||||
__all__ = ["run_lift_evidence_handoff"]
|
||||
|
||||
_E12 = 6 # grade-2 bivector block index of e1∧e2
|
||||
|
||||
|
||||
def _rotor_e12(theta: float) -> np.ndarray:
|
||||
v = np.zeros(N_COMPONENTS, dtype=np.float64)
|
||||
v[0] = np.cos(theta / 2.0)
|
||||
v[_E12] = np.sin(theta / 2.0)
|
||||
return v
|
||||
|
||||
|
||||
def _identity_versor() -> np.ndarray:
|
||||
v = np.zeros(N_COMPONENTS, dtype=np.float64)
|
||||
v[0] = 1.0
|
||||
return v
|
||||
|
||||
|
||||
def _certified_turn(target: np.ndarray, label: str) -> tuple[Any, Any]:
|
||||
"""One real corridor turn: relax onto the target versor, egress, cast."""
|
||||
engine = CognitiveLifecycleEngine()
|
||||
packets = (ModalityPacket(modality_id=f"seed:{label}", coefficients=target),)
|
||||
outcome = engine.solve(packets, f"handoff-evidence:{label}", compile_quadratic_well(target))
|
||||
serving = serving_cast(
|
||||
outcome.relaxation.psi_steady, outcome.relaxation.certificate, outcome.verdict
|
||||
)
|
||||
return outcome, serving
|
||||
|
||||
|
||||
def run_lift_evidence_handoff() -> dict[str, Any]:
|
||||
geometry = IdentityManifoldGeometry.from_directions(
|
||||
((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0))
|
||||
)
|
||||
policy = AdmissionPolicy.placeholder_default()
|
||||
identity_port = IdentityPort(geometry, policy)
|
||||
precision_port = PrecisionPort(1e-6)
|
||||
|
||||
artifact: dict[str, Any] = {"turns": {}, "adr_refs": ["ADR-0246", "ADR-0247", "ADR-0248"]}
|
||||
for label, target in (
|
||||
("identity-action", _identity_versor()),
|
||||
("frame-rotating", _rotor_e12(0.5)),
|
||||
):
|
||||
outcome, serving = _certified_turn(target, label)
|
||||
chain, identity_decision = run_residual_protocol(
|
||||
identity_port, outcome.relaxation.psi_steady, ()
|
||||
)
|
||||
chain, precision_decision = run_residual_protocol(
|
||||
precision_port, PrecisionSubject.from_serving_state(serving), chain
|
||||
)
|
||||
handoff = coordinate_handoff(
|
||||
chain,
|
||||
epistemic_state=EpistemicState.DECODED,
|
||||
normative_clearance=NormativeClearance.CLEARED,
|
||||
)
|
||||
artifact["turns"][label] = {
|
||||
"outcome_id": outcome.outcome_id,
|
||||
"serving": serving.as_dict(),
|
||||
"identity_action": identity_decision.as_dict(),
|
||||
"precision_action": precision_decision.as_dict(),
|
||||
"chain_verified": verify_replay_chain(chain),
|
||||
"chain_records": [r.as_dict() for r in chain],
|
||||
"handoff": handoff.as_dict(),
|
||||
"handoff_digest": handoff.handoff_digest(),
|
||||
}
|
||||
return artifact
|
||||
70
tests/test_adr_0240_biography_session.py
Normal file
70
tests/test_adr_0240_biography_session.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
"""ADR-0243 §2.5 — harness-driven biography session pins (seam S2 closure).
|
||||
|
||||
The first real caller of the PASS-gated biography wiring: run the ADR-0240
|
||||
transfer harness, recompute the lived trajectory (recovered transfer versors
|
||||
of the CORRECT cases — reconstruction-over-storage), integrate, and prove
|
||||
I-01 reboot-invariance: the same session recomputes the identical blade and
|
||||
provenance record from scratch.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from core.physics.biography_wiring import BiographyIntegrationError
|
||||
from evals.analogical_transfer.biography_session import (
|
||||
run_biography_session,
|
||||
session_trajectory,
|
||||
)
|
||||
from evals.analogical_transfer.harness import make_fixture_pair, run_analogical_transfer
|
||||
|
||||
_CLOSURE = 1e-6
|
||||
|
||||
|
||||
def test_pass_session_integrates_lived_trajectory():
|
||||
case = make_fixture_pair()
|
||||
artifact = run_biography_session([case])
|
||||
assert artifact.report.wrong == 0
|
||||
assert artifact.trajectory_case_ids == (case.case_id,)
|
||||
assert artifact.blade.n_steps == 1
|
||||
assert artifact.blade.closure < _CLOSURE
|
||||
assert artifact.record.schema_version == "biography_provenance_v2"
|
||||
assert artifact.record.chiral_proof["blade_verdict"] == "vacuous"
|
||||
json.dumps(artifact.as_dict()) # JSON-safe session artifact
|
||||
|
||||
|
||||
def test_session_reboot_invariance_i01():
|
||||
"""Same cases → bit-identical blade, trajectory hash, and record id.
|
||||
Reconstruction-over-storage: nothing was persisted between the two runs.
|
||||
(Bit-identity is the honest I-01 claim; holonomy_similarity is not a
|
||||
normalized self-overlap and would be a weaker, misleading assert.)"""
|
||||
cases = [make_fixture_pair()]
|
||||
a = run_biography_session(cases)
|
||||
b = run_biography_session(cases)
|
||||
assert np.array_equal(a.blade.blade, b.blade.blade)
|
||||
assert a.blade.trajectory_hash == b.blade.trajectory_hash
|
||||
assert a.record.record_id == b.record.record_id
|
||||
|
||||
|
||||
def test_session_trajectory_recomputes_only_correct_cases():
|
||||
cases = [make_fixture_pair()]
|
||||
report = run_analogical_transfer(cases)
|
||||
versors, ids = session_trajectory(cases, report)
|
||||
assert len(versors) == 1 and ids == (cases[0].case_id,)
|
||||
|
||||
|
||||
def test_failing_session_integrates_nothing():
|
||||
"""A session with wrongs refuses (typed) — no confabulated wisdom.
|
||||
|
||||
The clean fixture recovers its transfer to machine precision (residual
|
||||
~1e-16), so failure is induced honestly: a corrupted expected_novel makes
|
||||
the transfer WRONG, and the wiring must refuse the whole session."""
|
||||
case = make_fixture_pair()
|
||||
corrupted = dataclasses.replace(case, expected_novel=np.roll(case.expected_novel, 1))
|
||||
with pytest.raises(BiographyIntegrationError) as exc_info:
|
||||
run_biography_session([corrupted])
|
||||
assert exc_info.value.reason == "report_not_pass"
|
||||
|
|
@ -89,7 +89,7 @@ def test_live_harness_pass_drives_integration():
|
|||
assert versor_condition(blade.blade) < _CLOSURE
|
||||
|
||||
assert record.record_id.startswith("bioprov-")
|
||||
assert record.schema_version == "biography_provenance_v1"
|
||||
assert record.schema_version == "biography_provenance_v2"
|
||||
assert record.wrong == 0
|
||||
assert record.n_cases == 1
|
||||
assert record.counts["correct"] == 1
|
||||
|
|
@ -99,8 +99,12 @@ def test_live_harness_pass_drives_integration():
|
|||
# Record binds the report to the exact trajectory that was integrated
|
||||
assert record.trajectory_hash == integrate_biography(traj).trajectory_hash
|
||||
assert record.n_steps == blade.n_steps
|
||||
assert record.adr_refs == ("ADR-0240", "ADR-0243")
|
||||
assert record.adr_refs == ("ADR-0240", "ADR-0241", "ADR-0243")
|
||||
assert record.closure_proof["blade_closure"] == blade.closure
|
||||
# §S2 chiral composition: disclosed, and vacuous-by-theorem on closed versors
|
||||
assert record.chiral_proof["latched_sign"] == 0
|
||||
assert set(record.chiral_proof["trajectory_verdicts"]) == {"vacuous"}
|
||||
assert record.chiral_proof["blade_verdict"] == "vacuous"
|
||||
|
||||
|
||||
def test_provenance_record_deterministic():
|
||||
|
|
@ -205,3 +209,61 @@ def test_wiring_imports_no_vault_store_and_no_evals():
|
|||
assert result.returncode == 0, f"probe failed: {result.stderr[-2000:]}"
|
||||
leaked = json.loads(result.stdout.strip().splitlines()[-1])
|
||||
assert leaked == [], f"biography_wiring loaded banned modules: {leaked}"
|
||||
|
||||
|
||||
# --- §S2 chiral composition (ADR-0241 §2.4C) ----------------------------------
|
||||
|
||||
|
||||
def test_chiral_charge_vanishes_on_closed_versors_theorem():
|
||||
"""Honesty theorem pin: I₅ is central in odd-dimensional Cl(4,1), so every
|
||||
closed versor has Q = ⟨ψ I₅ ψ̃⟩₀ = ±⟨I₅⟩₀ = 0 — the biography chiral
|
||||
precondition is vacuous BY THEOREM on admissible trajectories (observed
|
||||
exactly 0.0 in-tree). If this pin breaks, the inertness contract in
|
||||
chiral_conservation_precondition's docstring must be re-derived."""
|
||||
from algebra.null_point import dilator, translator
|
||||
from algebra.versor import unitize_versor
|
||||
from algebra.cl41 import geometric_product
|
||||
from core.physics.wave_manifold import WaveManifold
|
||||
|
||||
wave = WaveManifold()
|
||||
versors = [
|
||||
make_rotor_from_angle(0.7, bivector_idx=6),
|
||||
translator(np.array([0.3, -0.2, 0.5])),
|
||||
dilator(1.4),
|
||||
unitize_versor(
|
||||
geometric_product(
|
||||
translator(np.array([0.1, 0.2, 0.3])),
|
||||
geometric_product(dilator(1.2), make_rotor_from_angle(0.9, bivector_idx=8)),
|
||||
)
|
||||
),
|
||||
]
|
||||
for v in versors:
|
||||
assert abs(wave.chiral_charge(np.asarray(v, dtype=np.float64))) < 1e-12
|
||||
|
||||
|
||||
def test_chiral_flip_refuses_before_blade_computation():
|
||||
"""The precondition is LIVE against raw non-versor trajectories: a material
|
||||
sgn(Q_top) flip refuses (typed) before versor validation or any blade math."""
|
||||
report = _report([_result()])
|
||||
plus = np.zeros(32, dtype=np.float64)
|
||||
plus[0], plus[31] = 0.8, 0.6 # material Q < 0 for this orientation
|
||||
minus = plus.copy()
|
||||
minus[31] = -0.6 # mirror image: opposite material Q
|
||||
with pytest.raises(BiographyIntegrationError) as exc_info:
|
||||
integrate_validated_biography(report, [plus, minus])
|
||||
assert exc_info.value.reason == "chiral_orientation_violation"
|
||||
assert exc_info.value.disclosure["stage"] == "trajectory[1]"
|
||||
|
||||
|
||||
def test_trajectory_hash_uses_little_endian_f64_bytes():
|
||||
"""ADR-0245 §2.3 pin: the biography trajectory digest is computed over
|
||||
explicit '<f8' bytes (platform-independent replay determinism)."""
|
||||
import hashlib
|
||||
|
||||
from core.physics.biography import _trajectory_hash
|
||||
|
||||
traj = _trajectory()
|
||||
h = hashlib.sha256()
|
||||
for v in traj:
|
||||
h.update(np.asarray(v, dtype=np.dtype("<f8")).tobytes())
|
||||
assert _trajectory_hash(traj) == h.hexdigest()
|
||||
|
|
|
|||
236
tests/test_adr_0243_linguistic_readback.py
Normal file
236
tests/test_adr_0243_linguistic_readback.py
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
"""ADR-0243 §2.3 — linguistic wave readback pins (seam S1 closure).
|
||||
|
||||
Ground truth: docs/research/spark-audit-adjudication-2026-07-18.md §4 (S1) and
|
||||
ADR-0243 §2.3 — egress route ``readback_eligible`` must flow into geometric
|
||||
token selection over a versor vocabulary (token_t = argmax_T ⟨ψ_steady ψ̃_T⟩_0),
|
||||
then the "hearing ourselves think" round-trip: re-ingest the articulated tokens
|
||||
through the sensorium boundary and measure phase-locked agreement with the
|
||||
I-04 sanctioned metric (WaveManifold.phase_correlation — no cosine/ANN).
|
||||
|
||||
Fail-closed doctrine (decoding, not generating): no resonant token ⇒ typed
|
||||
ReadbackRefusal, never a fallback string. The real VocabManifold is used in
|
||||
these tests to prove the structural VocabLike protocol matches it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from algebra.rotor import make_rotor_from_angle
|
||||
from core.physics.cognitive_lifecycle import (
|
||||
CognitiveLifecycleEngine,
|
||||
compile_quadratic_well,
|
||||
)
|
||||
from core.physics.linguistic_readback import (
|
||||
LinguisticReadback,
|
||||
ReadbackRefusal,
|
||||
RoundTripReport,
|
||||
articulate_outcome,
|
||||
hearing_ourselves_think,
|
||||
linguistic_readback,
|
||||
readback_packets,
|
||||
)
|
||||
from core.physics.sensorium_wave_feed import fake_deterministic_packet
|
||||
from vocab.manifold import VocabManifold
|
||||
|
||||
# Hot-band energy inputs matching the E3/E4 precedent
|
||||
# (test_egress_routes_hot_state_to_readback_eligible).
|
||||
_HOT_ENERGY = {
|
||||
"convergence_density": 8,
|
||||
"activation_count": 8,
|
||||
"current_cycle": 1,
|
||||
"last_activation_cycle": 1,
|
||||
"morphology_features": {"mood": "imperative"},
|
||||
}
|
||||
|
||||
|
||||
def _target_rotor() -> np.ndarray:
|
||||
return np.asarray(make_rotor_from_angle(0.3, bivector_idx=6), dtype=np.float64)
|
||||
|
||||
|
||||
def _hot_outcome():
|
||||
"""Ingress → relax → egress with hot energy axes ⇒ route readback_eligible."""
|
||||
engine = CognitiveLifecycleEngine()
|
||||
target = _target_rotor()
|
||||
ham = compile_quadratic_well(target)
|
||||
packets = [fake_deterministic_packet("audio", angle=0.25, plane=6)]
|
||||
outcome = engine.solve(packets, "readback-demo", ham, energy_inputs=_HOT_ENERGY)
|
||||
assert outcome.verdict.route == "readback_eligible"
|
||||
return target, outcome
|
||||
|
||||
|
||||
def _vocab(target: np.ndarray) -> VocabManifold:
|
||||
"""Real VocabManifold: the target mode, a kindred same-plane rotor, and two
|
||||
far large-angle rotors in other planes (resonance ≈ cos(0.15)·cos(θ/2) ≪ 0.5)."""
|
||||
v = VocabManifold()
|
||||
v.add("resonant", target)
|
||||
v.add("kindred", np.asarray(make_rotor_from_angle(0.5, bivector_idx=6), dtype=np.float64))
|
||||
v.add("far-a", np.asarray(make_rotor_from_angle(2.8, bivector_idx=7), dtype=np.float64))
|
||||
v.add("far-b", np.asarray(make_rotor_from_angle(2.9, bivector_idx=8), dtype=np.float64))
|
||||
return v
|
||||
|
||||
|
||||
def test_readback_selects_most_resonant_token_first():
|
||||
target, outcome = _hot_outcome()
|
||||
vocab = _vocab(target)
|
||||
rb = linguistic_readback(
|
||||
outcome.relaxation.psi_steady,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
vocab,
|
||||
min_resonance=0.5,
|
||||
max_tokens=4,
|
||||
)
|
||||
assert isinstance(rb, LinguisticReadback)
|
||||
assert tuple(t.word for t in rb.tokens) == ("resonant", "kindred")
|
||||
assert rb.tokens[0].resonance > 0.999 # ψ_steady locked onto the target mode
|
||||
resonances = [t.resonance for t in rb.tokens]
|
||||
assert resonances == sorted(resonances, reverse=True)
|
||||
assert all(r >= 0.5 for r in resonances)
|
||||
json.dumps(rb.as_dict()) # JSON-safe artifact
|
||||
|
||||
|
||||
def test_readback_respects_max_tokens_bound():
|
||||
target, outcome = _hot_outcome()
|
||||
rb = linguistic_readback(
|
||||
outcome.relaxation.psi_steady,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
_vocab(target),
|
||||
min_resonance=0.5,
|
||||
max_tokens=1,
|
||||
)
|
||||
assert tuple(t.word for t in rb.tokens) == ("resonant",)
|
||||
|
||||
|
||||
def test_readback_refuses_when_route_not_eligible():
|
||||
engine = CognitiveLifecycleEngine()
|
||||
target = _target_rotor()
|
||||
ham = compile_quadratic_well(target)
|
||||
packets = [fake_deterministic_packet("audio", angle=0.25, plane=6)]
|
||||
cold = engine.solve(packets, "readback-demo", ham) # cold ⇒ crystallization route
|
||||
assert cold.verdict.route != "readback_eligible"
|
||||
with pytest.raises(ReadbackRefusal) as exc:
|
||||
linguistic_readback(
|
||||
cold.relaxation.psi_steady,
|
||||
cold.relaxation.certificate,
|
||||
cold.verdict,
|
||||
_vocab(target),
|
||||
min_resonance=0.5,
|
||||
max_tokens=4,
|
||||
)
|
||||
assert exc.value.reason == "route_not_readback_eligible"
|
||||
|
||||
|
||||
def test_readback_refuses_without_resonant_token_no_fallback():
|
||||
_target, outcome = _hot_outcome()
|
||||
sparse = VocabManifold()
|
||||
sparse.add("far-a", np.asarray(make_rotor_from_angle(2.8, bivector_idx=7), dtype=np.float64))
|
||||
sparse.add("far-b", np.asarray(make_rotor_from_angle(2.9, bivector_idx=8), dtype=np.float64))
|
||||
with pytest.raises(ReadbackRefusal) as exc:
|
||||
linguistic_readback(
|
||||
outcome.relaxation.psi_steady,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
sparse,
|
||||
min_resonance=0.5,
|
||||
max_tokens=4,
|
||||
)
|
||||
assert exc.value.reason == "no_resonant_token"
|
||||
assert 0.0 < exc.value.disclosure["best_resonance"] < 0.5
|
||||
|
||||
|
||||
def test_readback_refuses_certificate_state_mismatch():
|
||||
target, outcome = _hot_outcome()
|
||||
foreign = np.asarray(make_rotor_from_angle(1.0, bivector_idx=7), dtype=np.float64)
|
||||
with pytest.raises(ReadbackRefusal) as exc:
|
||||
linguistic_readback(
|
||||
foreign,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
_vocab(target),
|
||||
min_resonance=0.5,
|
||||
max_tokens=4,
|
||||
)
|
||||
assert exc.value.reason == "certificate_state_mismatch"
|
||||
|
||||
|
||||
def test_readback_refuses_empty_vocabulary_and_bad_policy():
|
||||
target, outcome = _hot_outcome()
|
||||
args = (
|
||||
outcome.relaxation.psi_steady,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
)
|
||||
with pytest.raises(ReadbackRefusal) as exc:
|
||||
linguistic_readback(*args, VocabManifold(), min_resonance=0.5, max_tokens=4)
|
||||
assert exc.value.reason == "empty_vocabulary"
|
||||
with pytest.raises(ReadbackRefusal):
|
||||
linguistic_readback(*args, _vocab(target), min_resonance=0.0, max_tokens=4)
|
||||
with pytest.raises(ReadbackRefusal):
|
||||
linguistic_readback(*args, _vocab(target), min_resonance=0.5, max_tokens=0)
|
||||
|
||||
|
||||
def test_round_trip_agreement_above_099():
|
||||
"""Hearing ourselves think: re-ingested articulation stays phase-locked."""
|
||||
target, outcome = _hot_outcome()
|
||||
vocab = _vocab(target)
|
||||
rb = linguistic_readback(
|
||||
outcome.relaxation.psi_steady,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
vocab,
|
||||
min_resonance=0.5,
|
||||
max_tokens=4,
|
||||
)
|
||||
report = hearing_ourselves_think(
|
||||
outcome.relaxation.psi_steady, rb, vocab, domain_id=outcome.ingress.domain_id
|
||||
)
|
||||
assert isinstance(report, RoundTripReport)
|
||||
assert report.n_tokens == 2
|
||||
assert report.agreement > 0.99
|
||||
assert report.agreement == pytest.approx(report.phase_correlation / 2.0)
|
||||
json.dumps(report.as_dict())
|
||||
|
||||
|
||||
def test_readback_packets_carry_token_versors():
|
||||
target, outcome = _hot_outcome()
|
||||
vocab = _vocab(target)
|
||||
rb = linguistic_readback(
|
||||
outcome.relaxation.psi_steady,
|
||||
outcome.relaxation.certificate,
|
||||
outcome.verdict,
|
||||
vocab,
|
||||
min_resonance=0.5,
|
||||
max_tokens=1,
|
||||
)
|
||||
(pkt,) = readback_packets(rb, vocab)
|
||||
assert pkt.modality_id == "linguistic:resonant"
|
||||
np.testing.assert_allclose(pkt.coefficients, target, atol=1e-6) # f32 store rounding
|
||||
|
||||
|
||||
def test_articulate_outcome_composes_and_is_deterministic():
|
||||
target, outcome = _hot_outcome()
|
||||
vocab = _vocab(target)
|
||||
rb1, rt1 = articulate_outcome(outcome, vocab, min_resonance=0.5, max_tokens=4)
|
||||
rb2, rt2 = articulate_outcome(outcome, vocab, min_resonance=0.5, max_tokens=4)
|
||||
assert rb1.readback_id == rb2.readback_id
|
||||
assert rt1.report_id == rt2.report_id
|
||||
assert rt1.agreement == rt2.agreement
|
||||
assert rb1.psi_digest == outcome.relaxation.certificate.psi_digest
|
||||
|
||||
|
||||
def test_module_is_pure_offserving_and_vocab_decoupled():
|
||||
import core.physics.linguistic_readback as m
|
||||
|
||||
with open(m.__file__, encoding="utf-8") as fh:
|
||||
src = fh.read()
|
||||
assert "chat.runtime" not in src
|
||||
assert "import chat" not in src
|
||||
# Layering pin: vocab access is structural (VocabLike protocol) — importing
|
||||
# the vocab package from core.physics would cycle through the barrel.
|
||||
assert "from vocab" not in src
|
||||
assert "import vocab" not in src
|
||||
112
tests/test_adr_0243_tether_wiring.py
Normal file
112
tests/test_adr_0243_tether_wiring.py
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
"""Seam S3 — unified autonomy floor wired into the cognitive lifecycle.
|
||||
|
||||
Pins the tether control law composed with pin SD-A: closed certified states
|
||||
update the GoldTether monitor (may elevate autonomy), non-admitted states
|
||||
fail-close it (autonomy hard 0), and ADMITTED OPEN SUPERPOSITIONS are
|
||||
measured without a state update — punishing legitimate interference states
|
||||
would encode the exact defect the egress gate refuses to. Chiral orientation
|
||||
is observed on every reading and a material flip raises (fail-closed).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from algebra.rotor import make_rotor_from_angle
|
||||
from core.physics.chiral_gate import ChiralOrientationError
|
||||
from core.physics.cognitive_lifecycle import (
|
||||
CognitiveLifecycleEngine,
|
||||
PropositionalProblem,
|
||||
compile_propositional,
|
||||
compile_quadratic_well,
|
||||
egress_gate,
|
||||
relax_to_ground,
|
||||
tether_reading,
|
||||
uniform_assignment_state,
|
||||
)
|
||||
from core.physics.goldtether import GoldTetherMonitor
|
||||
from core.physics.sensorium_wave_feed import fake_deterministic_packet
|
||||
|
||||
|
||||
def _closed_solve(monitor: GoldTetherMonitor):
|
||||
engine = CognitiveLifecycleEngine(monitor=monitor)
|
||||
target = np.asarray(make_rotor_from_angle(0.3, bivector_idx=6), dtype=np.float64)
|
||||
packets = [fake_deterministic_packet("audio", angle=0.25, plane=6)]
|
||||
return engine.solve(packets, "tether-demo", compile_quadratic_well(target))
|
||||
|
||||
|
||||
def test_closed_certified_turn_updates_monitor():
|
||||
monitor = GoldTetherMonitor()
|
||||
outcome = _closed_solve(monitor)
|
||||
assert outcome.verdict.admitted and outcome.verdict.versor_closed
|
||||
tether = outcome.tether
|
||||
assert tether is not None and tether.updated
|
||||
assert tether.residual < 1e-6
|
||||
assert tether.chiral_verdict == "vacuous" # closed versor: Q = 0 by theorem
|
||||
assert len(monitor.history) == 1
|
||||
|
||||
|
||||
def test_solve_without_monitor_records_no_tether():
|
||||
engine = CognitiveLifecycleEngine()
|
||||
target = np.asarray(make_rotor_from_angle(0.3, bivector_idx=6), dtype=np.float64)
|
||||
packets = [fake_deterministic_packet("audio", angle=0.25, plane=6)]
|
||||
outcome = engine.solve(packets, "tether-demo", compile_quadratic_well(target))
|
||||
assert outcome.tether is None
|
||||
|
||||
|
||||
def test_admitted_open_superposition_measures_without_update():
|
||||
"""SD-A dual: a legitimate interference state must not decay the floor."""
|
||||
problem = PropositionalProblem(
|
||||
atoms=("a", "b"),
|
||||
clauses=((("a", True), ("b", True)), (("a", False), ("b", True))),
|
||||
)
|
||||
result = relax_to_ground(uniform_assignment_state(problem), compile_propositional(problem))
|
||||
verdict = egress_gate(result.psi_steady, result.certificate)
|
||||
assert verdict.admitted and not verdict.versor_closed
|
||||
|
||||
monitor = GoldTetherMonitor(floor=0.4, autonomy=0.2)
|
||||
tether = tether_reading(
|
||||
monitor,
|
||||
result.psi_steady,
|
||||
admitted=verdict.admitted,
|
||||
versor_closed=verdict.versor_closed,
|
||||
)
|
||||
assert not tether.updated
|
||||
assert tether.residual > monitor.epsilon_drift # honest: open state, big residual
|
||||
assert monitor.floor == 0.4 and monitor.autonomy == 0.2 # untouched
|
||||
assert len(monitor.history) == 0
|
||||
|
||||
|
||||
def test_non_admitted_turn_fails_closed_to_zero_autonomy():
|
||||
monitor = GoldTetherMonitor(floor=0.6, autonomy=0.5)
|
||||
outcome_engine = CognitiveLifecycleEngine()
|
||||
target = np.asarray(make_rotor_from_angle(0.3, bivector_idx=6), dtype=np.float64)
|
||||
packets = [fake_deterministic_packet("audio", angle=0.25, plane=6)]
|
||||
outcome = outcome_engine.solve(packets, "tether-demo", compile_quadratic_well(target))
|
||||
refused = dataclasses.replace(outcome.verdict, admitted=False, reason="forced_refusal")
|
||||
tether = tether_reading(
|
||||
monitor,
|
||||
outcome.relaxation.psi_steady,
|
||||
admitted=refused.admitted,
|
||||
versor_closed=refused.versor_closed,
|
||||
)
|
||||
assert tether.updated
|
||||
# Closed state but the turn is refused → update path ran; the monitor's own
|
||||
# law applies (this closed versor has residual ≤ ε, so autonomy may step,
|
||||
# bounded by the floor). The FAIL-CLOSED zeroing fires on drifted states:
|
||||
drifted = np.zeros(32, dtype=np.float64)
|
||||
drifted[0] = 0.5 # non-unit ⇒ ψψ̃ far from 1
|
||||
t2 = tether_reading(monitor, drifted, admitted=False, versor_closed=False)
|
||||
assert t2.updated and monitor.autonomy == 0.0
|
||||
|
||||
|
||||
def test_material_chiral_flip_raises_fail_closed():
|
||||
monitor = GoldTetherMonitor()
|
||||
monitor.chiral_gate.observe_q(0.5) # latch +1
|
||||
flipped = np.zeros(32, dtype=np.float64)
|
||||
flipped[0], flipped[31] = 0.8, 0.6 # material Q of opposite sign
|
||||
with pytest.raises(ChiralOrientationError):
|
||||
tether_reading(monitor, flipped, admitted=True, versor_closed=False)
|
||||
80
tests/test_generalized_lift_instrument.py
Normal file
80
tests/test_generalized_lift_instrument.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
"""Seam S4/S5 pins — generalized-lift instrument + ports/handoff evidence.
|
||||
|
||||
The instrument is the arbiter of "generalized lift, no overfitting": identical
|
||||
compiled problems for corridor and baseline, independent truth-table gold,
|
||||
wrong=0 guard on the propositional (flagship-regime) domain, and an
|
||||
honest-NULL protocol. The handoff evidence pins that Ring-2/Ring-3 machinery
|
||||
DISCRIMINATES (proceed on the lawful identity-action turn, typed abstain on a
|
||||
frame-rotating turn) — off-serving, flags untouched.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from evals.generalized_lift_instrument import (
|
||||
run_generalized_lift_instrument,
|
||||
)
|
||||
from evals.lift_evidence_handoff import run_lift_evidence_handoff
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def report():
|
||||
return run_generalized_lift_instrument()
|
||||
|
||||
|
||||
def test_propositional_domain_wrong_zero_and_gold_agreement(report):
|
||||
prop = report.outcomes[0]
|
||||
assert prop.domain_id == "propositional"
|
||||
assert prop.corridor_wrong == 0 # the flagship-regime guard
|
||||
assert prop.baseline_wrong == 0
|
||||
for row in prop.cases:
|
||||
assert row["corridor_entailed"] == row["gold_entailed"]
|
||||
assert row["baseline_entailed"] == row["gold_entailed"]
|
||||
assert prop.verdict == "PARITY" # honest expected outcome: both exact
|
||||
|
||||
|
||||
def test_recognition_domain_shows_relax_readback_lift(report):
|
||||
rec = report.outcomes[1]
|
||||
assert rec.domain_id == "constrained-recognition"
|
||||
assert rec.corridor_correct == rec.n_cases # relax+readback recovers every mode
|
||||
assert rec.corridor_wrong == 0 and rec.corridor_refused == 0
|
||||
assert rec.baseline_correct < rec.n_cases # constraint-blind argmax fails
|
||||
assert rec.delta_correct > 0 and rec.verdict == "LIFT"
|
||||
for row in rec.cases:
|
||||
assert row["roundtrip_agreement"] > 0.99 # hearing ourselves think
|
||||
|
||||
|
||||
def test_multimodal_domain_recorded_honestly(report):
|
||||
multi = report.outcomes[2]
|
||||
assert multi.domain_id == "multimodal-completion"
|
||||
assert multi.n_cases == 1
|
||||
assert multi.corridor_wrong == 0
|
||||
assert multi.verdict in ("LIFT", "PARITY") # measured, never assumed
|
||||
|
||||
|
||||
def test_report_flags_and_scope_limitations(report):
|
||||
assert report.wrong_zero_guard_held
|
||||
assert isinstance(report.honest_null, bool)
|
||||
assert any("GSM8K" in note for note in report.scope_limitations)
|
||||
json.dumps(report.as_dict()) # JSON-safe artifact
|
||||
|
||||
|
||||
def test_handoff_evidence_discriminates():
|
||||
artifact = run_lift_evidence_handoff()
|
||||
lawful = artifact["turns"]["identity-action"]
|
||||
rotated = artifact["turns"]["frame-rotating"]
|
||||
|
||||
assert lawful["chain_verified"] and rotated["chain_verified"]
|
||||
assert lawful["identity_action"]["action"] == "proceed"
|
||||
assert lawful["precision_action"]["action"] == "proceed"
|
||||
assert lawful["handoff"]["handoff"] == "proceed"
|
||||
|
||||
assert rotated["identity_action"]["action"] == "abstain"
|
||||
assert "d_stab>epsilon_turn" in rotated["identity_action"]["reasons"]
|
||||
assert rotated["handoff"]["handoff"] == "abstain"
|
||||
assert any(r.startswith("port:identity:") for r in rotated["handoff"]["reasons"])
|
||||
|
||||
json.dumps(artifact) # JSON-safe acceptance-evidence artifact
|
||||
Loading…
Reference in a new issue