Commit graph

15 commits

Author SHA1 Message Date
Shay
07f49eb215 fix(drift): proper rotor-manifold scaling; restore respond contract
Three issues in the drift-fix landing (922bddc) addressed:

1. algebra/rotor.py: add rotor_power(R, alpha) — slerp on the rotor manifold
   via the rotor's exp/log decomposition. Handles both rotation planes
   (cos/sin) and boost planes (cosh/sinh); falls back to identity for
   non-simple bivectors or null cases.

2. generate/stream.py: the score-weighted vault recall previously did
   `weight*V + (1-weight)*np.eye(V.shape[0])`. Two bugs:
   - np.eye produced a 32x32 matrix for a 1D multivector, crashing
     versor_apply with a broadcasting error (2 cognition tests failing
     on main).
   - The linear blend produced multivectors with versor_condition up to
     2.2e-2, violating the non-negotiable 1e-6 invariant declared in
     CLAUDE.md. Now uses rotor_power(V, weight) which stays on the
     manifold by construction (versor_condition <= 1.1e-16).

3. session/context.py: respond() now re-binds result.final_state to
   self.state after finalize_turn's anchor pull, restoring the
   "respond returns the same object that was vaulted" contract
   (test_engine_loop_proof regression).

Verification:
- 41 new tests in tests/test_rotor_power.py covering closure preservation,
  alpha=0/1 boundaries, half-angle composition, and word-transition rotors.
- Empirical multi-turn versor_condition stays at machine epsilon with
  anchor pull, max 9.4e-7 without (under threshold either way after fix).
- Full suite: 609 passed, 4 skipped, 0 failed.
2026-05-16 11:44:45 -07:00
Shay
922bddc6ec fix(drift): address all 3 drift entry points
1. session/context.py — dialogue blade accumulation is now magnitude-preserving
   via EMA (α=0.15). Running blade grows stronger each turn a concept is
   confirmed rather than resetting to unit magnitude on every record_dialogue().

2. generate/stream.py — vault recall transitions are now score-weighted.
   Each recalled rotor is scaled by softmax(scores)[i] before application so
   high-confidence vault hits dominate and stale low-score entries barely move
   the field.

3. session/context.py — anchor pull added after _hemisphere_consistent_field().
   A mild α=0.05 slerp toward _anchor_field is applied at finalize_turn() to
   provide continuous conjugate correction against angular drift within the
   hemisphere. Unitized before writing back to state.
2026-05-16 09:03:56 -07:00
Shay
a6be96410c fix(session): CGA-only hemisphere consistency, remove forbidden Euclidean metric
_orient_result_to_anchor used np.dot (Euclidean dot product) alongside
cga_inner to decide hemisphere flips.  When CGA inner was positive
(correct hemisphere) but Euclidean was negative, the flip negated CGA
alignment — making correctly-oriented fields rank last in vault recall.

Changes:
- Move hemisphere check into finalize_turn so all paths (ChatRuntime,
  SessionContext.respond) get consistent protection.
- Use CGA inner product only, removing the forbidden Euclidean metric.
- Remove _orient_result_to_anchor (subsumed by finalize_turn).
- Remove SessionContext.arespond (dead code, no callers).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-15 21:51:16 -07:00
Shay
61c55e457d fix: harden session field invariants and eliminate hot-path inefficiencies
- Fix running_dialogue_blade grade explosion: replace outer_product
  accumulation (which pushed past grade-5 in Cl(4,1), silently zeroing
  the blade from turn 3 onward) with CGA-inner-oriented blade tracking
  that preserves grade-2 across arbitrary turn counts.

- Add versor_condition guard at session composition boundary: cross-turn
  field composition via versor_apply now fails closed (threshold 1e-2,
  matching algebra construction residue tolerance) instead of silently
  propagating degraded fields into vault and generation.

- Replace VaultStore list with deque(maxlen=max_entries): eliminates
  O(N) list.pop(0) on every bounded eviction; deque auto-evicts in O(1).

- Replace O(N) vocab scan in generate/stream.py stop_nodes construction
  with O(1) try/except index lookup per stop token.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-15 21:37:49 -07:00
Shay
c9a644e496
feat(dialogue-fluency): wire multi-turn dialogue runtime
Adds referent tracking, session graph traversal, unknown-domain gating, correction propagation, compositional surface assembly, and regression coverage.

Follow-up fixes included before merge:
- split probe/commit/finalize turn flow so unknown-domain checks run before current-query vault writes
- record real input tokens and input versors for sync and async session paths
- return true graph distances from backward walks and consume them in correction decay
- synchronize corrected graph outputs into vault-backed recall and live referent state
- regenerate correction responses from corrected context rather than correction text
- keep coreference pronouns lowercase in question bodies
- centralize elaboration-string construction to avoid plan/surface drift
- add targeted dialogue fluency regression tests
2026-05-15 21:05:59 -07:00
Shay
15ed2cee89
Tighten hot-path backend consistency
- route SessionContext anchor CGA through algebra.backend
- move aspect-weight carry into FieldEnergyOperator.compute
- remove duplicated propagate_step threshold patch and per-step imports
- add carry_aspect_weight tests for parity, fallback, and propagation preservation
- preserve normalization, propagation, vault, Rust dispatch, and energy cadence semantics
2026-05-15 08:14:38 -07:00
Shay
a683912ad2
Fix post-contract runtime regressions
- remove normalization and unitization calls from generation path
- skip invalid recalled fields instead of repairing them in generation
- punctuate selected articulation surfaces
- stabilize assertive dialogue roles
- anchor proposition slots to live field
- preserve session anchor orientation for coherence
2026-05-14 18:57:24 -07:00
Shay
541b1646b2 Fix test suite errors across core physics and generation
Key issues fixed:
- `CORE_BACKEND=numpy` was ignored, so tests mixed Python CGA embedding with Rust metric behavior.
- Dense construction seeds were being rejected by strict `unitize_versor()`, while sparse dirty inputs still needed to fail closed.
- Holonomy needed a construction-boundary path for raw/dense vocab fixtures and rare null final accumulators.
- Proposition storage polluted vault recall by storing the live field instead of the proposition’s subject versor.
- Dialogue qualitative frames rendered the same surface as assertive copular frames.
- Repeated session prompts could collapse into the same deterministic response path.
- Two proof fixtures were stale: one hand-built a non-null “null” vector, and one alignment proof omitted the English “with” anchor used by the resonance proof.

Verification:
`CORE_BACKEND=numpy CORE_STRICT_MLX_ON_APPLE=0 uv run core test -- -q`
Result: `277 passed in 59.52s`
2026-05-14 13:02:32 -07:00
Shay
6bad4189d2 Implement core physics and pack validation 2026-05-14 12:35:19 -07:00
Shay
aadaf11612
Add ADR-0008 salience attention
Add salience and attention operators, wire salience-gated candidate selection into generation, expose vault/salience trace telemetry, and add tests proving non-placeholder salience behavior.
2026-05-13 22:40:36 -07:00
Shay
2b78cd1179 Add dialogue frame selection 2026-05-13 20:19:21 -07:00
Shay
ed04fc5b15 Add session coherence across turns 2026-05-13 19:59:43 -07:00
Shay
d997b88d32 Tighten session node tracking and generation selection 2026-05-13 14:35:31 -07:00
Shay
1731ca6500 Add deterministic engine loop proof 2026-05-13 12:37:21 -07:00
Shay
b5989f35ec init: ingest, field, vocab, vault, persona, generate, session layers 2026-05-12 19:14:22 -07:00