Commit graph

155 commits

Author SHA1 Message Date
Shay
f82f4d36de
Harden pack validator trust boundary
- reject unsafe pack IDs, path traversal, absolute paths, and separators
- require --allow-arbitrary-code for dynamic validator execution
- add --dry-run validation that does not import or execute validators
- preserve JSON/report behavior with explicit trust boundary
- add focused CLI security tests
2026-05-15 11:50:15 -07:00
Shay
40cabdec09
Speed up validation lanes and pack loading
- add core test --suite fast for lightweight iteration validation
- cache parsed pack entries and compiled/mounted language packs
- return defensive manifold/list copies so transient mutations cannot leak through caches
- add CLI fast-suite coverage and pack cache isolation tests
- preserve exact recall, backend dispatch, and runtime semantics
2026-05-15 08:26:11 -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
f973e61bc2
Add agent efficiency and security doctrine
- update AGENTS.md with standing efficiency/performance and security doctrine
- align CLAUDE.md with current performance/security expectations
- update Copilot/Codex instructions with hot-path, trust-boundary, and CLI validation defaults
- refresh work sequencing now that eval and calibration are on main
2026-05-15 08:13:29 -07:00
Shay
366f7a08c4
Add cognitive eval harness and calibration replay (#30)
* feat: add cognitive eval harness with CLI integration

20 eval cases across 8 categories (definition, comparison, cause,
procedure, recall, correction, verification, unknown). Metrics:
intent accuracy, term capture, surface groundedness, versor closure,
trace determinism. CLI: `core eval cognition [--json] [--report PATH]`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add operator calibration replay with deterministic grid search

Bounded parameter tuning via eval replay evidence. Grid search over
salience_top_k and inhibition_threshold with invariant regression
guard (versor closure must not regress). Frozen CalibrationParams,
before/after metrics, no pack or identity mutation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-15 07:41:36 -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
33aed4e550
Update agent guidance for current CORE roadmap
- update AGENTS.md with current cognitive architecture and operating doctrine
- align CLAUDE.md with current CORE roadmap and invariants
- add GitHub Copilot/Codex instructions for agentic coding tools
- document CLI validation lanes, teaching safety, semantic pack discipline, and PR standards
2026-05-15 06:36:07 -07:00
Shay
b4ecf67e35
Fix CLI test suite pytest flags
- allow pytest flags after core test --suite without requiring separator
- preserve strict unknown-argument rejection for non-test commands
- add regression coverage for core test --suite packs -q
2026-05-15 06:25:37 -07:00
Shay
3d0b632e3b
Add CLI curated test suites
- add core test --suite aliases for smoke, runtime, cognition, teaching, packs, algebra, and full lanes
- preserve direct pytest passthrough through core test -- ...
- add core test --list-suites
- add focused CLI tests for suite listing, suite expansion, and passthrough
2026-05-15 06:21:21 -07:00
Shay
a6fd31e4bb
Add core cognition semantic seed pack
- add en_core_cognition_v1 deterministic seed lexicon
- mount the pack after en_minimal_v1 in default runtime config
- add pack smoke tests for loadability, required concepts, runtime mounting, prompt compatibility, and deterministic ordering
2026-05-15 06:16:40 -07:00
Shay
a5f9074adb
Merge pull request #23 from AssetOverflow/feat/wire-teaching-loop-into-pipeline
feat: wire teaching loop into cognitive pipeline
2026-05-14 20:47:18 -07:00
Shay
2b756a6044 feat: wire teaching loop into cognitive pipeline
- Add teaching_candidate, reviewed_teaching_example, pack_mutation_proposal fields to CognitiveTurnResult
- Extend trace_hash to include teaching_review_hash and teaching_proposal_id for deterministic audit trail
- Integrate correction capture → review → store pipeline into CognitiveTurnPipeline.run()
- Track prior turn surface and number for correction binding
- Emit PackMutationProposal without applying (external approval required)
- Add 5 integration tests: capture, identity rejection, proposal-only, trace inclusion, non-correction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-14 20:46:50 -07:00
Shay
97971bd636 feat: add reviewed teaching loop for controlled correction learning
Introduces teaching/ module with three-stage correction pipeline:

1. correction.py — extracts CorrectionCandidate from correction intents,
   binding correction text to the prior turn it references
2. review.py — validates candidates: rejects identity overrides (17
   marker patterns) and empty corrections; produces ReviewedTeachingExample
   with deterministic SHA-256 review hash
3. store.py — bounded FIFO store for accepted examples; emits
   PackMutationProposal objects instead of mutating the vocab manifold
   directly; retrievable by subject

Design invariants:
- Identity override attempts are rejected at the review gate
- Pack mutations are proposal-only (applied=False by default)
- All traces are deterministic: same input → same candidate_id and review_hash

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-14 20:32:28 -07:00
Shay
364e1fdd34
fix: use rotors instead of reflectors in session coherence test (#22)
_farther_unrelated searched for grade-1 reflectors whose cga_inner
score was below the prompt score. Field states are even-grade
(grade 0+2+4), so cga_inner with a grade-1 reflector is always zero
— making the search impossible when prompt_score is negative.

Replaced with _random_rotor (product of two reflectors) which lives
in the same even-grade subspace and produces nonzero inner products.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-14 20:24:25 -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
c68b0734a2
Wire intent graph into cognitive pipeline
- add intent, proposition graph, and articulation target to CognitiveTurnResult
- compute classify_intent -> graph_from_intent -> plan_articulation in CognitiveTurnPipeline
- include intent_tag in deterministic trace hash payload
- add pipeline tests for definition/comparison graph capture, articulation target exposure, trace hash changes, and ChatResponse contract stability
2026-05-14 20:05:00 -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
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