feat(adr-0249): P2 affine relation compiler #67

Merged
core-labs merged 1 commit from feat/adr-0249-p2-relation-compiler into main 2026-07-18 19:31:37 +00:00

1 commit

Author SHA1 Message Date
Shay
3098971fd2 feat(adr-0249): P2 affine relation compiler
Compiles output = scale*input + offset (Tier-1: scale > 0) into a quadratic-well
constraint Hamiltonian, reusing the ratified compile_quadratic_well +
HamiltonianCompileError contracts.

Anti-hollow (spike §4.1): the compiler never evaluates scale*input+offset in
Python — it embeds the input (P1) and applies the relation's structure as
versor operators (dilator for scale, translator for offset), so the substrate's
geometric product performs the arithmetic. The returned well is a bare
projector carrying no answer and no coefficients (metadata = {curvature,
target_digest} only); relaxation + projective readback recover the output.
Verified end-to-end: multiply/add/subtract/divide/negative-input all decode
exactly; ablation confirms the start decodes to the input and only the relaxed
state to the answer.

Fail-closed on non-positive scale (outside positive-dilation Tier-1) and
non-finite coefficients. Golden-bytes canary pins the compiled matrix.
Serve-quarantined (A-04). Single-relation primitive; state-chaining is P4.

21/21 pins green.

[Verification]: uv run python -m pytest tests/test_adr_0249_relation_compiler.py -q
2026-07-18 12:25:38 -07:00