Commit graph

39 commits

Author SHA1 Message Date
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
f223e61352 fix(generate): wire intent-aware realizer into chat hot path
The realize_semantic / realize_target pipeline in realizer.py was fully
implemented but never called from chat/runtime.py. The hot path only called
realize() from articulation.py, which returns raw S-P-O word tokens with no
intent, tense, negation, quantifier or rhetorical-move awareness. This
disconnected the 13-construction realizer from every live chat turn.

New module generate/intent_bridge.py:
- classify_intent_from_input() runs the rule-based classifier against the
  raw input text to obtain a DialogueIntent
- articulate_with_intent() builds a PropositionGraph from that intent,
  grounds the <pending> obj slots with recalled vocabulary from the
  generation result, plans articulation via plan_articulation(), and calls
  realize_semantic() for the intent-specific template path
- Falls back cleanly to the existing ArticulationPlan surface when the
  realizer returns an empty plan (OOV-heavy or UNKNOWN intent)

chat/runtime.py change:
- Import and call articulate_with_intent() after the existing realize() call
- Replace articulation.surface with the intent-bridge surface whenever the
  bridge returns a non-empty, non-pending string
- The existing ArticulationPlan dataclass is preserved and passed downstream
  so SentenceAssembler, turn_log, ChatResponse, and all trace fields remain
  structurally unchanged

Effect: chat() now produces intent-differentiated surfaces:
  DEFINITION  → "X is defined as Y"         (was "X Y Z")
  CAUSE       → "X is grounded in Y"         (was "X Y Z")
  CORRECTION  → "correction: X corrects Y"   (was "X Y Z")
  RECALL      → "recalling X: Y"             (was "X Y Z")
  VERIFICATION→ "X is verified: Y"           (was "X Y Z")
  COMPARISON  → "X and Y are distinguished..." (was "X contrasts_with Y")
  PROCEDURE   → "first, Y; then, X follows"  (was "X Y Z")
  CONJUNCTION → "X P and Y P"               (realizer edge handling)
  RELATIVE    → "X, which Pv Y, Pv Z"       (realizer edge handling)

Articulation fidelity is now geometrically honest AND structurally expressive.
The surface corresponds to internal intent state, not a generic S-P-O join.
2026-05-16 08:38:59 -07:00
Shay
fa2712ebd7 feat(realizer): extend to all 13 English v1 constructions
Engineer the deterministic realizer to handle negation, conjunction,
disjunction, embedded clauses, relative clauses, quantification, tense,
and aspect — covering all 13 grammatical-coverage v1 constructions.

- generate/morphology.py: rule-based English inflection (past, participle,
  base form) for seed vocabulary predicates
- generate/templates.py: match-case inflection dispatch for tense/aspect/negation
- generate/graph_planner.py: add CONJUNCTION, DISJUNCTION, COMPLEMENT, RELATIVE
  relations; add grammatical feature fields to ArticulationStep
- generate/realizer.py: compound construction handling via graph edge traversal

grammatical-coverage eval: dev=100%, public v1=100% (from baseline of 24%/19%).
2026-05-16 05:55:49 -07:00
Shay
2aeb6f31dc fix(generate): close final generation field before return 2026-05-15 23:20:49 -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
eb30c75810 feat: Full Proof — surface realizer join, Rust diffusion parity, benchmark harness
Surface realizer join: pulse output_versor → vault recall → ground_graph fills
<pending> obj slots with recalled words → realize_semantic produces deterministic
sentences. PulseResult replaces bare word list. Every intent type surfaces.

Rust backend parity: unitize_f32 (exponential-map with boost/rotation blade
distinction) and graph_diffusion_step now in core-rs. Python dispatches through
algebra.backend, falls back transparently. 37x speedup on 200-step diffusion.

Benchmark harness (core bench): determinism (100% trace stability), latency
(~150ms median), backend speedup, versor closure audit (0 violations across all
intermediate states), convergence proof (41/45 exact, 4 bounded oscillation),
realizer coverage (8/8 intent types).

Proof property tests (31 tests): Rust/Python parity, pulse determinism across
prompts, V3 convergence for 10+ topologies, coupled V4 output validity, realizer
coverage per intent, versor closure at every intermediate step.

CLI: core pulse, core bench, core test --suite pulse, core test --suite proof.
Fix test_correction_pulls_toward_target (diffuse first, then correct).
2026-05-15 17:39:14 -07:00
Shay
523c072818 feat: vault recall index, Rust versor parity, cognitive pack expansion
Phase 3 — vault exact recall index:
- Replace O(N) np.array_equal scan with hash-based exact-match index
- Add optional max_entries with deterministic FIFO eviction
- Index rebuilds on reproject for consistency

Phase 4 — Rust versor_apply parity:
- Fix CGA metric signature (+,+,+,+,-) and blade ordering to match Python
- Implement versor_apply_closed with null-vector preservation, f64 unitize,
  and construction seed fallback matching Python closure semantics
- Gate Rust dispatch behind CORE_BACKEND=rust; Python remains default
- Add f64 geometric product for closure-path precision

Phase 5 — cognitive quality pack expansion:
- Expand lexicon from 55 to 70 entries (evidence, inference, procedure,
  verification, distinction, relation, thought, understanding, judgment,
  principle, order, connectives)
- Improve semantic templates for cause, procedure, comparison, recall,
  verification intents
- Expand eval cases from 20 to 45 across all categories

Validation: 491 tests pass, 45 eval cases at 100% all metrics.
2026-05-15 15:34:39 -07:00
Shay
a7febd48ef
Integrate semantic realizer into cognition pipeline
- add intent-aware semantic templates for seed-pack relation predicates
- add semantic realization path for ArticulationTarget outputs
- wire semantic realization into CognitiveTurnPipeline results without changing ChatRuntime.chat
- expand cognition CLI suite coverage for semantic realizer integration
- add focused tests for deterministic semantic surfaces and response contract stability
2026-05-15 07:08:37 -07:00
Shay
58a06124bf
Add articulation realizer v2
- add deterministic ArticulationTarget realizer
- add rhetorical move templates and predicate humanization
- handle definition, comparison, correction, unknown, and empty targets
- keep runtime ChatResponse path unchanged
- add focused realizer tests
2026-05-14 20:14:50 -07:00
Shay
8dcc26581a feat: add intent-proposition graph comprehension layer
Implements the dialogue understanding pipeline:
  prompt -> dialogue intent -> proposition graph -> articulation target

New modules:
  - generate/intent.py: rule-based classifier (7 intent tags + UNKNOWN)
  - generate/graph_planner.py: immutable PropositionGraph DAG, topological
    walk to ArticulationTarget with rhetorical moves

Tests cover definition, cause, comparison, correction with prior-turn
linking, and deterministic serialization.
2026-05-14 19:52:57 -07:00
Shay
2bd70d0a9d
Fix remaining runtime regressions after contract cleanup
- close versor_apply outputs at algebra boundary
- route backend versor_apply through canonical closure semantics
- keep selected ChatResponse surface equal to ArticulationPlan surface
- derive proposition relation from selected slots
- rank proposition slots with pure CGA metric
2026-05-14 19:05:36 -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
dcb0b34ccc
Fix full-suite regressions after chat telemetry merge
- restore articulation surface as ChatResponse.surface while retaining walk_surface telemetry
- calibrate moderate E2 energy boundary
- reclose generated field states after propagation and recall
- restore pytest-safe REPL parsing and field_walk helper
- anchor proposition predicate selection to prompt field
- make vault exact self-recall deterministic
- align chat telemetry regression with restored surface contract
2026-05-14 18:23:31 -07:00
Shay
216a789808
Fix identity gating and vault telemetry
- calibrate identity threshold and per-axis telemetry
- keep walk surfaces visible when identity flags are telemetry
- report real vault recall hits through generation/runtime logs
- record selected surface in TurnEvent
- fix async chat persona reference
- add regression coverage for chat telemetry
2026-05-14 15:44:01 -07:00
Shay
59e8683b6e fix: versor norm explosion — normalize F after each propagate_step and guard _recall_state rotor inputs 2026-05-14 14:21:35 -07:00
Shay
bdf0716af4 fix: SyntaxError on elif lang=grc — restore correct indentation in SentenceAssembler.assemble() 2026-05-14 14:07:58 -07:00
Shay
0fa498e98b
fix(surface): add empty-slot guard — fallback when subject+predicate both empty
Add fallback mechanism for empty subject and predicate in surface generation.
2026-05-14 13:44:09 -07:00
Shay
bab4790c10
feat(generate): export SentenceAssembler, SentencePlan, assemble_surface from __init__ 2026-05-14 13:24:19 -07:00
Shay
565c48bdf0
feat(generate): add surface.py — SentenceAssembler (ADR-0012)
Implement SentenceAssembler for generating coherent surface sentences from articulation plans and token sequences.
2026-05-14 13:21:24 -07:00
Shay
6cb28566ec generate/stream: fix agenerate() — add vault recall parity with generate()
agenerate() skipped _recall_state() entirely, meaning async streaming
responses were disconnected from session memory. This patch brings
agenerate() to full parity with the synchronous path:

- Accepts vault and recall_top_k parameters (default 3, matching generate())
- Calls _recall_state(_voiced_state(current, persona), vault, recall_top_k)
  at each step before nearest-node selection
- Does not add stop_nodes or salience (those remain sync-only for now;
  the core correctness gap is vault recall)

The async return value is still token-by-token via yield. Callers that
want final_state should use the synchronous path or wrap in a collector.
2026-05-14 13:12:59 -07:00
Shay
2c51338de7 generate/result: add identity_score field to GenerationResult
IdentityCheck runs after generation in ChatRuntime and must travel
forward with the result without requiring a second pass or a wrapper.
The field is Optional so all existing call sites that don't supply it
continue to work unmodified.
2026-05-14 13:10:54 -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
4ab148149f Graceful fallback in realize() when slot versors are missing 2026-05-13 21:41:52 -07:00
Shay
0dd22bb4dd
Add ADR-0009 articulation planner
Add geometry-backed ArticulationPlan and realize(), wire articulation into ChatRuntime and trace output, expose proposition relation_norm, and add articulation/runtime/CLI tests.
2026-05-13 21:39:25 -07:00
Shay
30757ccc63
Add runtime output-language policy
Add RuntimeConfig with English default output policy, wire output language through runtime/frame selection/generation/CLI, preserve language metadata in mounted manifolds, and add runtime/CLI policy tests.
2026-05-13 21:29:43 -07:00
Shay
454b7d9f9e Thread vault recall through generation 2026-05-13 20:50:31 -07:00
Shay
2b78cd1179 Add dialogue frame selection 2026-05-13 20:19:21 -07:00
Shay
3a52cf3517 Add proposition generation 2026-05-13 20:08:49 -07:00
Shay
ed04fc5b15 Add session coherence across turns 2026-05-13 19:59:43 -07:00
Shay
531acfd40b Implement trilingual field coherence 2026-05-13 19:53:37 -07:00
Shay
d997b88d32 Tighten session node tracking and generation selection 2026-05-13 14:35:31 -07:00
Shay
a87c7a9c6f Fix full test suite after cognitive runtime 2026-05-13 13:52:11 -07:00
Shay
d781ba71db Avoid identity stalls in generation loop 2026-05-13 13:16:48 -07:00
Shay
3746f06898 fix: cohesive seam pass — frozen FieldState, GenerationResult, generation/vocab/algebra separation, normalization doctrine
- field/state.py: FieldState is now frozen+slotted; constructor copies and
  enforces float32 shape (32,); advance() updated to pass raw arrays.
  np.ndarray inside frozen dataclass is ref-frozen — copy() at construction
  is the explicit contract boundary.

- generate/result.py: NEW — GenerationResult frozen dataclass carrying
  tokens + final_state. Async variant yields tokens and exposes final_state
  on completion.

- generate/stream.py: generate() now returns GenerationResult, not list[str].
  vocab.edge_rotor() call replaced with:
    A = vocab.get_versor_at(current.node)
    B = vocab.get_versor_at(word_idx)
    V = word_transition_rotor(A, B)
  agenerate() updated to yield tokens and surface final_state.

- vocab/manifold.py: added get_versor_at(idx) and get_word_at(idx) indexed
  accessors. VocabManifold stores points; algebra constructs operators.
  normalize_to_versor() call-site in docstring clarified: callers must call
  unitize_versor() (algebra construction primitive) before add(), not
  normalize_to_versor() directly.

- algebra/versor.py: unitize_versor() added as the explicit construction-time
  primitive. normalize_to_versor() kept but marked internal/gate-only.
  Distinction encoded in docstrings and __all__.

- persona/motor.py + ingest/gate.py: SessionContext.respond() is not yet in
  the repo as a separate file; gate.py docstring updated to reflect the
  three-tier normalization doctrine:
    unitize_versor()    — algebra construction only
    inject()            — gate, once per raw input
    normalization       — forbidden in propagate/generate/vault recall
2026-05-13 12:32:36 -07:00
Shay
0fbc2e92a2 feat(generate): add render.py — default TextRenderer and Renderer protocol (ADR-0011) 2026-05-13 10:51:52 -07:00
Shay
b5989f35ec init: ingest, field, vocab, vault, persona, generate, session layers 2026-05-12 19:14:22 -07:00