Commit graph

1738 commits

Author SHA1 Message Date
Shay
8ed6793a03 fix: use raw string for deprecated_call match pattern in test_identity_gate
The backslash escapes in the regex match pattern were plain string
escapes, not regex escapes. Add r-prefix to fix SyntaxWarning.
2026-05-14 19:52:47 -07:00
Shay
92be98fbdf
feat(cognition): add CognitiveTurnPipeline spine (#19) 2026-05-14 19:35:03 -07:00
Shay
249592c37e
Fix final runtime suite regressions
- preserve null vectors through versor_apply
- keep algebra closure for non-null sandwich outputs
- downgrade declarative refute telemetry to elaborate
- make minimal English question surfaces prompt-sensitive
2026-05-14 19:16: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
7401eae7ae
Clean up runtime contracts before cognitive pipeline
- document ChatResponse, TurnEvent, identity, memory/teaching, and test-organization contracts
- add local trace and build metadata ignore rules
- warn on deprecated IdentityCheck constructor injection
- update identity gate tests to canonical ValueAxis and ReasoningTrajectory usage
- keep cleanup scoped ahead of cognitive pipeline work
2026-05-14 18:47:59 -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
c46eae8fc8
Fix main chat test regressions
- make async chat reuse initialized synchronous chat lifecycle
- restore make_rotor_from_angle compatibility helper
- restore identity ValueAxis export and legacy IdentityCheck call style
- preserve legacy reasoning trajectory fixtures for existing tests
2026-05-14 15:48:45 -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
4852fcc704
test(chat): achat() and arespond() smoke tests — surface, fields, OOV grace, structural determinism 2026-05-14 14:31:49 -07:00
Shay
9f2b2acbf0
test(identity): IdentityCheck gate wiring, IdentityScore invariants, TurnEvent field coverage 2026-05-14 14:30:56 -07:00
Shay
1343171fab
test(surface): full unit test suite for SentenceAssembler — roles, guard, elaboration, languages, determinism 2026-05-14 14:29:46 -07:00
Shay
e4374301f9
fix(probe): rewrite repl.py — print ChatResponse.surface as response; add --verbose TurnEvent trace 2026-05-14 14:28:26 -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
d7edc7a813 fix: TypeError float(EnergyProfile) — unwrap EnergyProfile.raw in _make_trajectory_from_result and _apply_drive_bias 2026-05-14 14:10:15 -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
95f212c69d fix: IndentationError on TurnEvent.elaboration; align IdentityScore fields with runtime expectations
- Fix IndentationError: `elaboration` field was indented inside the
  docstring block instead of at the class body level (line 149).
- Add `value` and `alignment` aliases on IdentityScore so that
  run_examples.py / review_trace.py can read `.value` and `.alignment`
  (runtime.py and the serialiser both reference these names).
  `value` mirrors `score`; `alignment` mirrors `1.0 - deviation fraction`.
- Add `axes_evaluated` property returning the deviation_axes frozenset
  as a sorted list, matching the serialiser expectation in run_examples.py.
2026-05-14 14:04:13 -07:00
Shay
f91063f771 scripts: add run_examples.py + review_trace.py; cli: surface TurnEvent in trace/session
run_examples.py
  Runs a curated set of example conversations through ChatRuntime,
  writing one JSONL trace file per scenario to traces/. Each line in the
  file is one TurnEvent serialised as JSON, giving the complete
  determinism record for that turn. Scenarios cover:
    - single-turn field probe
    - multi-turn dialogue with memory (vault recall across turns)
    - identity alignment pressure (input designed to approach the flag threshold)
    - fatigue arc (many turns to observe ExertionMeter drain)
    - versor drift (watches versor_condition across a session)
  Run with:  python scripts/run_examples.py
  Output:    traces/<scenario>.jsonl

review_trace.py
  CLI reader for JSONL trace files produced by run_examples.py or
  `core session`. Supports:
    --summary      one-line-per-turn table (turn, surface, role, score, cost, flagged)
    --turn N       full detail for a single turn
    --flagged      show only flagged turns
    --drift        print versor_condition per turn (tracks algebraic drift)
    --identity     print identity_score + alignment per turn
    --fatigue      print cycle_cost_total per turn (exertion arc)
  Run with:  python scripts/review_trace.py traces/<scenario>.jsonl [options]

cli: cmd_trace now includes identity_score, flagged, cycle_cost (from turn_log[-1])
cli: new cmd_session subcommand - multi-turn REPL that writes a trace file on exit
2026-05-14 13:54:25 -07:00
Shay
97bfd3b1d8
feat(chat): add achat()/arespond(), wire elaboration into TurnEvent
Add async methods for chat and respond functionality.
2026-05-14 13:47:11 -07:00
Shay
55f95f3629
feat(identity): add elaboration field to TurnEvent — full sentence provenance trace 2026-05-14 13:45:28 -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
9ee27e0792
feat(chat): wire SentenceAssembler into chat/runtime — coherent surface sentences
Refactor sentence assembly to use SentenceAssembler for coherent sentence generation.
2026-05-14 13:23:21 -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
3711fad448 chat/runtime: wire identity check, character motor, CharacterProfile, drive gradients, TurnEvent log
Six identity table rows → all green:

1. Non-identity PersonaMotor
   PersonaMotor.from_identity_manifold() replaces PersonaMotor.identity().
   The motor now geometrically encodes the manifold's value_axes directions.

2. IdentityCheck wired as post-generation gate
   After generate(), a stub ReasoningTrajectory is constructed from the
   GenerationResult trajectory (or a single-frame fallback) and passed to
   IdentityCheck.check(). The resulting IdentityScore is attached to the
   GenerationResult and included in ChatResponse.

3. CharacterProfile populated and projected
   CharacterProfile.from_manifold() is called at __init__ time and stored
   as self.character_profile. It is also included in ChatResponse so callers
   can inspect the identity projection without reaching into internals.

4. drive_gradients influencing field walk
   DriveGradientMap.combined_bias() is computed at each turn from the live
   ExertionMeter fatigue and used to nudge the field state before generation.
   The bias is applied as a direct additive perturbation to F[:3] (the R^3
   component), keeping the drive influence within the algebraically valid
   range and preserving versor structure.

5. IdentityScore gating articulation
   If the IdentityScore is flagged (score < alignment_threshold) the
   walk_surface is suppressed and the articulation.surface is used as the
   sole response surface. The flag is propagated in ChatResponse.flagged.

6. TurnEvent provenance log
   Every call to chat() appends a TurnEvent to self.turn_log. The log is
   a plain list — append-only by convention. Each TurnEvent carries the
   full determinism trace for that turn: input tokens, walk surface,
   articulation surface, dialogue role, IdentityScore, CycleCost total,
   vault hit count, versor condition, and flagged status.
2026-05-14 13:15: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
424a67a9ce persona: add PersonaMotor.from_identity_manifold() factory
Builds a real, non-identity CGA motor from the value_axes directions
carried by an IdentityManifold. Each axis.direction is treated as a
3-vector in R^3, composed additively into a single translator, and
scaled by the axis's index to separate the directions in concept space.

This replaces the unconditional PersonaMotor.identity() call in
ChatRuntime with a motor that geometrically encodes CORE's character.
2026-05-14 13:10:34 -07:00
Shay
9be12b9a14 identity: add CharacterProfile.from_manifold() factory + TurnEvent provenance record
- CharacterProfile.from_manifold() populates traits/theological grounding
  directly from a live IdentityManifold — no longer orphaned.
- TurnEvent is a frozen, append-only provenance record for one chat turn.
  Carries: turn index, dialogue role, IdentityScore, CycleCost, vault hit
  count, walk surface, and articulation surface. Enables full determinism
  tracing across every turn without mutation.
- IdentityCheck.check() is unchanged in contract.
2026-05-14 13:10:00 -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
47975dbcc7 ADR-0006: wire energy recomputation into propagate_step, add test_energy.py, mark ADR Implemented 2026-05-14 12:39:49 -07:00
Shay
6bad4189d2 Implement core physics and pack validation 2026-05-14 12:35:19 -07:00
Shay
fbbd7c52e3 Fix fail-closed versor construction 2026-05-14 12:13:04 -07:00
Shay
2e8169bbb0 Allow float32 residue roundoff in versor construction 2026-05-14 12:13:04 -07:00
Shay
79e28c5835 Fail closed on invalid versor construction 2026-05-14 12:12:43 -07:00
Shay
9723941a38
Fail closed on invalid versor construction
Make versor construction fail closed instead of synthesizing hash-derived fallback rotors.

- remove pseudo-random construction fallback from unitize_versor
- add signed residual helper for +1 field states vs ±1 manifold entries
- validate vocab manifold entries with full residuals
- document antipodal transition rotor failure contract
- add focused invariant tests for versor closure and manifold validation
2026-05-14 10:55:11 -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
df9ced7104
Activate and verify Rust backend
Add Rust backend CLI controls, fix core-rs build/test configuration, align Rust Cl(4,1)/CGA conventions with Python, and validate core_rs activation.
2026-05-13 22:23:48 -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
09c3664773
Fix CLI help/runtime imports and add doctor command (#4)
* Make core CLI help robust and intuitive

* Package runtime support modules for core CLI

* Add CLI help and doctor tests

* Fix CLI trace help and pack listing

* Export language pack listing helper

* Bootstrap repo root for console runtime imports

* Align trace formatter with Proposition schema

* Cover real trace payload formatting
2026-05-13 21:15:51 -07:00
Shay
7f302760ef Fix setuptools flat-layout package discovery 2026-05-13 20:58:01 -07:00
Shay
0800f8d35f Add core CLI (chat, test, check, trace, oov, pack) 2026-05-13 20:54:54 -07:00
Shay
454b7d9f9e Thread vault recall through generation 2026-05-13 20:50:31 -07:00
Shay
abf7398ca6 Bridge chat OOV grounding 2026-05-13 20:47:28 -07:00
Shay
0780ca8166 Add live chat runtime 2026-05-13 20:40:56 -07:00
Shay
9ba6abfa3e Ground unknown tokens in ingest 2026-05-13 20:33:20 -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