Commit graph

338 commits

Author SHA1 Message Date
Shay
a67a3cc465 feat(evals): deterministic_fluency lane — six structural predicates
Closes the gap the 2026-05-19 design review flagged:

  > Some evals are too permissive to protect fluency; they accept
  > fragments or ungrammatical strings.

This lane defines fluency as six DETERMINISTIC predicates over the
user-facing surface — no LLM judge, no embedding similarity, no
aesthetics.  Each predicate is a testable bool.

The six predicates:

  no_placeholder        — no ..., <pending>, <prior>, <empty>
  no_provenance_only    — surface is not bare structured disclosure
  complete_punctuation  — ends with . / ? / ! / ;
  finite_predicate_shape — at least one finite-verb token present
  no_dotted_inventory   — no 3+ dotted-paths joined by ;
  surface_provenance_match — grounding_source agrees with surface text

Each is a regex / substring check.  Subjective fluency (rhythm,
idiom, register) is deliberately out of scope — that would require
an LLM judge (doctrine violation) or human review (not CI-pinnable).

Baseline measured on current main (this commit, all v1 public cases):

  cases:                          15
  no_placeholder_rate:            1.0000   (hard floor — pinned)
  complete_punctuation_rate:      1.0000   (hard floor — pinned)
  finite_predicate_shape_rate:    1.0000   (>= 0.90 — pinned)
  no_provenance_only_rate:        1.0000   (varies — lift target)
  no_dotted_inventory_rate:       0.3333   (varies — lift target)
  surface_provenance_match_rate:  1.0000
  expected_predicates_pass_rate:  1.0000   (per-case contracts hold)

The dotted-inventory rate at 33% is the exact gap the gloss feature
is designed to close.  Today 10 of 15 cases emit surfaces like

  doubt — pack-grounded (en_core_meta_v1):
    meta.mental_state.uncertainty; meta.mental_state; cognition.epistemic.
    No session evidence yet.

After glosses land:

  Doubt is a mental state of uncertainty about a claim.
  Pack-grounded (en_core_meta_v1).

The lane records both metrics today; thresholds are extended in the
gloss-wiring commit so the rates DROP if the lift fails to land.

Files:

  evals/deterministic_fluency/contract.md
    The six predicates with implementation notes and pass thresholds.
    Documents which thresholds are pinned today vs. which are gloss-
    landing lift targets.
  evals/deterministic_fluency/public/v1/cases.jsonl
    15 cases across four categories: pack_definition (10),
    oov_invitation (2), cause_no_chain_unknown_domain (2),
    teaching_grounded (1).  Each case declares its own
    ``expected_predicates`` — the subset of the six it must satisfy
    today; e.g. OOV cases don't assert finite_predicate_shape because
    the invitation surface is intentionally explanatory.
  evals/deterministic_fluency/dev/cases.jsonl
    2 representative cases for fast iteration.
  evals/deterministic_fluency/runner.py
    Six predicate functions + framework-compliant run_lane.  Returns
    per-predicate rates + per-case predicate dicts so debugging a
    regression is one read of case_details away.
  tests/test_deterministic_fluency_lane.py
    14 contract tests covering: case-set integrity, valid predicate
    names, lane discovery, every predicate rate emitted, per-case
    predicates dict carries every signal, the three hard invariants
    (no_placeholder == 1, complete_punctuation == 1,
    finite_predicate_shape >= 0.90), expected_predicates_pass_rate
    == 1 (every case satisfies its own contract), lift-target
    metrics are recorded for the gloss-feature substrate.

Verification: 14/14 lane tests green on current main.
2026-05-19 07:16:44 -07:00
Shay
0cf1a8fdc4 feat(evals): warmed_session_consistency lane — pipeline override regression substrate
Asymmetric counterpart to cold_start_grounding.  Builds the
measurement substrate for the Phase B1 pipeline-override usefulness
gate.  Lane is committed now (red baseline measured) so the fix is
landed against a fixed regression target.

The 2026-05-19 design review surfaced the bug this lane catches:

  > pipeline overrode a runtime surface with a placeholder realizer
  > surface because realized_plan.surface was non-empty, even though
  > it contained '...'.  The runtime audit log still held a different
  > surface.  This is the central fluency/design fault: the system
  > can be "green" while user-facing selection, pipeline selection,
  > and telemetry selection disagree.

The lane reproduces this exactly on the current main:

  Surface "Soon is defined as ..." emitted on turn 2 of "What does
  soon mean?" (where turn 1 grounded as pack correctly).  Telemetry
  recorded a different surface than the pipeline returned.

Initial red baseline (THIS commit):
  no_placeholder_rate        = 0.4444  (target after Phase B1: 1.00)
  telemetry_consistency_rate = 0.4444  (target after Phase B1: 1.00)
  warm_grounding_stability   = 0.0000  (target after Phase B1: >=0.95)

Cold-start-grounding stays at 1.00 on its own metrics.  The cold lane
measures routing, the warmed lane measures override discipline; they
are deliberately not the same.

Files:
  evals/warmed_session_consistency/contract.md
    What is measured, why, and the asymmetry with cold_start_grounding.
    Documents the four binary per-turn signals (no_placeholder,
    pipeline_match_telemetry, pipeline_match_walk, grounded_holds_on_warm)
    and the per-case warm_grounding_stable invariant.
  evals/warmed_session_consistency/public/v1/cases.jsonl
    8 cases / 18 turns.  Mix of:
      - replay-the-same-prompt (catches override drift)
      - mixed-intent sequences (catches OOV / pack interaction)
      - cause-no-chain (must stay none across replays)
      - what-does-x-mean (the warmed variant of the cold-start test)
  evals/warmed_session_consistency/dev/cases.jsonl
    2 representative cases for fast iteration.
  evals/warmed_session_consistency/runner.py
    Framework-compliant run_lane(cases, config=None) -> LaneReport.
    Constructs ONE ChatRuntime + CognitiveTurnPipeline per case,
    plays the turn sequence through them.  Per-turn signals:
      no_placeholder       — surface free of ..., <pending>, <prior>
      telemetry_match      — pipeline result.surface == turn_log[-1].surface
      grounding_match      — actual_grounding == expected_grounding
    Per-case signal:
      warm_grounding_stable — every replayed prompt produces the same
                              grounding across turns
  tests/test_warmed_session_lane.py
    8 contract tests covering: case-set integrity, replay-pattern
    presence, lane discovery, runner emits every required metric,
    per-turn details carry all signals, and the warmed-runtime
    invariant (static check that ChatRuntime is constructed
    per-case, not per-turn and not module-scope).

NOT pinned in this commit (deliberate):
  Threshold assertions are NOT in the test file.  They will land in
  Phase B1 alongside the pipeline-override usefulness gate.  This
  lane's role at present is to PROVIDE the regression target, not
  to enforce it before the fix.

Verification: 8/8 lane tests green; the lane itself runs and emits
the red metrics documented above.
2026-05-19 07:13:41 -07:00
Shay
c6b4f1d21e fix(runtime): config-replace + thin API wrappers + stale docstring
Three independent hygiene fixes named in the 2026-05-19 design review.
All small, all observable, none architectural.

1. ``RuntimeConfig`` flag drop on pack_id / frame_pack override
   chat/runtime.py:306-320 used to enumerate fields by hand when
   reconstructing RuntimeConfig under the pack_id / frame_pack
   override path.  The list stopped at ``admissibility_margin`` and
   silently dropped FIVE newer flags: identity_pack, ethics_pack,
   forward_graph_constraint, composed_surface, thread_anaphora.
   Caller side-effect:

     ChatRuntime(pack_id="x", config=RuntimeConfig(composed_surface=True))
       .config.composed_surface == False  # silently lost

   Fix: ``dataclasses.replace(config, input_packs=..., frame_pack=...)``.
   Every field on the dataclass survives by construction; future
   additions never need a synchronized edit on this path.

2. Stale CAUSE / VERIFICATION docstring
   tests/test_intent_classification_extensions.py described a sixth
   runtime-side fix (pack_grounded_surface fallback for
   CAUSE/VERIFICATION) that was considered, reverted, and the file's
   own test classes pin the opposite contract.  Docstring now states
   the doctrine correctly: no fallback, deliberately, so the discovery
   layer can log the teaching-gap signal.

3. Thin convenience wrappers: respond / achat / arespond
   tests/test_achat.py and tests/test_language_pack_runtime.py
   referenced these public methods since 2026-05-14, but they were
   never implemented on ChatRuntime — those 12 tests had been red on
   every full-lane run since the rebase.  Added as thin wrappers:

     respond(text) -> ChatResponse.surface
     achat(text)   -> async wrapper around chat()
     arespond(text)-> async wrapper around respond()

   The async wrappers are deliberately NOT genuinely non-blocking —
   the underlying CPU-bound walk/recall/composition remains sync.
   Docstrings say so explicitly.  Callers needing real concurrency
   should wrap in asyncio.to_thread at the call site; promoting the
   wrappers to true async event-loop integration is a future change
   gated by an actual concurrent caller.

Regression coverage:
  tests/test_runtime_config_passthrough.py — 4 tests
    - all 19 RuntimeConfig fields survive a pack_id override
    - all five newer flags survive a frame_pack override
    - no-override path preserves caller config by identity (no rebuild)
    - the four public methods exist and are callable

Verification:
  44/44 affected tests green (was 12 red pre-fix).
  Cognition eval byte-identical on both splits.
  No surface-format change; this commit is pure plumbing.
2026-05-19 07:04:10 -07:00
Shay
a084f1db21 feat(evals): cold_start_grounding lane — 44-prompt routing probe
Commits the 2026-05-19 probe as a durable, replayable eval lane.
This is *step 1* of the gloss-feature rollout sequence agreed
upstream: establish a stable measurement substrate before any
further intent/grounding changes, so the 52%→0% lift (and any
future regression) is reproducible and CI-pinned.

The lane is deliberately named ``cold_start_grounding`` rather than
``fluency``:
  - It measures **routing** (intent → grounding source), not
    sentence quality, morphology, or surface diversity.
  - The cold-start qualifier reflects the fresh-``ChatRuntime()``-
    per-case design.  Re-using a runtime across cases would
    contaminate the vault from earlier turns and was the exact bug
    observed during the probe before the per-case-runtime fix.

Files:

  evals/cold_start_grounding/contract.md
    Lane contract: what is measured, scoring rubric, pass thresholds
    (intent ≥ 0.95 / grounding ≥ 0.95 / subject ≥ 0.90), and the
    rationale for the deliberate non-fallback on CAUSE/VERIFICATION
    without teaching chains.
  evals/cold_start_grounding/public/v1/cases.jsonl
    44 cases across 16 categories.  Each case carries id, prompt,
    category, expected_intent, expected_grounding_source, and an
    optional expected_subject.  Categories cover every intent
    pattern fixed in b52e04a (Define, What-does-X-mean, infinitive,
    How-does-X-work, What-causes-X) plus OOV controls and CAUSE
    cases with/without teaching chains.
  evals/cold_start_grounding/dev/cases.jsonl
    5 representative cases for fast local iteration.
  evals/cold_start_grounding/runner.py
    Framework-compliant ``run_lane(cases, config=None) -> LaneReport``.
    Constructs a fresh ChatRuntime() inside ``_run_case`` (cold-start
    invariant).  Emits intent_accuracy, grounding_accuracy,
    subject_accuracy, full grounding distributions, and a per-
    category breakdown for regression attribution.
  tests/test_cold_start_grounding_lane.py
    16 contract tests covering: case-set integrity, valid enum
    values, unique ids, lane discovery, pass thresholds, expected-
    vs-actual distribution match (drift detection), the architectural
    invariants on oov_control and cause_no_teaching_chain cases, the
    cold-start invariant (static check that the runner constructs
    ChatRuntime() inside the per-case helper, not at module scope),
    and result JSON-serialization round-trip.

Baseline metrics (this commit, all v1 public cases):
  intent_accuracy:    1.0000  (44/44)
  grounding_accuracy: 1.0000  (44/44)
  subject_accuracy:   1.0000  (44/44)

  grounding distribution (actual == expected exactly):
    pack:      37
    oov:        4
    teaching:   1
    none:       2  (deliberate — CAUSE without teaching chain)

Why "none" cases are *expected* to ground as none:
  CAUSE / VERIFICATION on a pack-resident lemma WITHOUT an active
  teaching chain stays grounding_source='none' on purpose.  Falling
  through to pack_grounded_surface here would mask the discovery-
  candidate signal the teaching pipeline uses to identify chains
  worth authoring.  The contract test in
  TestArchitecturalInvariants::test_cause_no_chain_cases_route_to_none
  pins this doctrine.

Verification: 16/16 lane tests green; full lane run via
``core eval cold_start_grounding`` reports 100% on every metric.

Subsequent steps in the agreed sequence (NOT in this commit):
  2. Hygiene: runtime API wrappers (achat/arespond/respond) + the
     stale CAUSE/VERIFICATION docstring in
     tests/test_intent_classification_extensions.py.
  3. Harden gloss resolver in feat/pack-glosses-wip
     (lexicon-residency check, dual checksum, cache clearing,
     malformed-JSONL skip tests).
  4. Wire gloss-backed pack_grounded_surface().
  5. Author starter glosses with checksum discipline.
2026-05-19 06:33:42 -07:00
Shay
b52e04a72f fix(intent): five conversational definition patterns + polarity-stopword
The 2026-05-19 cumulative live probe surfaced a stark gap: ~52% of
realistic conversational definition prompts ("Define X", "What does
X mean?", "What is to V?", "How does X work?", "What causes X?")
returned ``grounding_source="none"`` *even though every subject
lemma was pack-resident* across the 9 mounted English packs.

Root cause: the bottleneck was intent classification + subject
extraction, not lexicon coverage.  Five patterns either had no rule
or routed to an intent the runtime dispatcher couldn't handle.  The
fluency assessment at
``/Users/kaizenpro/.codex/worktrees/6533/core/notes/fluency_assessment_2026-05-19.md``
named these as Root Cause #1 ("public chat path does not use the
cognitive spine") and Root Cause #3 ("proposition graphs are too
thin").  This commit closes the surface-level half of that gap;
the deeper answer-plan layer (gloss propositions, P3 in the
assessment) is the next step.

Patterns fixed in ``generate/intent.py``:

  1. ``Define X``        — added ``^define\s+`` rule mapping to
                           DEFINITION (placed after ``^what is/are``
                           so multi-word DEFINITION patterns still
                           prefer the question form).
  2. ``What does X mean?`` — was matching TRANSITIVE_QUERY with
                            relation=``mean``.  Now re-routes to
                            DEFINITION inside ``classify_intent`` so
                            ``pack_grounded_surface`` fires on X.
                            Other transitive relations (precede,
                            ground, etc.) remain TRANSITIVE_QUERY.
  3. ``What is to V?``   — added infinitive-marker strip to
                           ``_normalize_subject`` for DEFINITION /
                           RECALL.  ``to`` is gated on intent tag so
                           it never strips a transfer preposition
                           from CAUSE / VERIFICATION.
  4. ``How does X work?`` — added ``_HOW_DOES_X_RE`` (third-person
                            mechanistic-cause).  Distinct from the
                            first-person PROCEDURE rule ("How do I
                            X?").  Verbs: work / function / operate /
                            happen / exist / behave / act / emerge.
  5. ``What causes X?``   — added causative-verb rule (causes /
                            triggers / enables / prevents / drives /
                            produces / induces / yields) routing to
                            CAUSE with X as subject.

Deliberate NON-fix: I considered adding a ``pack_grounded_surface``
fallback in the CAUSE / VERIFICATION dispatcher when no teaching
chain matches the subject.  Reverted on review — that masks the
"would_have_grounded" discovery-candidate signal the teaching
pipeline uses to identify teaching-content gaps (see
``tests/test_discovery_candidates``).  CAUSE on a pack-resident
lemma without a teaching chain stays ``grounding_source=='none'``
so the discovery layer can log the gap honestly.

``chat/pack_grounding.py``:
  Extended ``_CORRECTION_TOPIC_STOPWORDS`` to include polarity
  markers (no / yes / maybe / perhaps / hardly / indeed / surely /
  definitely).  Without this the CORRECTION composer would
  short-circuit on ``no`` from "No, my parent disagrees" and miss
  the topical lemma ``parent``.

Cumulative probe lift (44 realistic conversational prompts):
  BEFORE: pack=16  none=23  oov=4  teaching=1  (52% NONE)
  AFTER:  pack=37  none=2   oov=4  teaching=1   ( 5% NONE)

  The remaining 2 NONE responses are CAUSE-shaped prompts with no
  teaching chain — deliberately preserved as the discovery-gap
  signal described above.

Tests: tests/test_intent_classification_extensions.py — 23 new
tests covering each pattern + the lift invariant.

Verification:
  Cognition eval byte-identical on both splits (100/100/91.7/100
  public, 100/100/83.3/100 holdout).
  All 111 intent-affected tests green:
    test_intent_classification_extensions.py (23)
    test_intent_proposition_graph.py / test_intent_ratifier.py /
    test_intent_subject_extraction.py / test_narrative_example_intents.py
    test_procedure_surface.py
    test_correction_topic_lemma.py
    test_cross_pack_grounding.py (including the polarity-stopword fix)
    test_discovery_candidates.py
    test_contemplation_wiring.py
    test_en_core_polarity_v1_pack.py
2026-05-19 06:12:05 -07:00
Shay
1c8f2ee943 feat(packs): en_core_polarity_v1 — polarity + frequency (16 lemmas)
Workstream 1 eighth pack.  Closes the polarity-marker + frequency-
adverb gap.  Common conversational markers (yes/no/maybe/always/never)
had zero coverage in any prior pack.

Pack composition (16 entries — 2 INTJ / 14 ADV):

  polarity.affirm.*      yes indeed surely definitely
  polarity.negate.*      no hardly
  polarity.uncertain.*   maybe perhaps
  polarity.frequency.*   always sometimes often rarely never
                         usually occasionally frequently

``certain``/``certainly``/``uncertain`` deliberately excluded — those
remain in en_core_attitude_v1 (epistemic.certainty/uncertainty).
Regression test pins the invariant.

tests/test_correction_topic_lemma.py:
  Three fixtures swapped from "No that is wrong" to "Nope that is
  wrong".  ``no`` is now correctly pack-resident in en_core_polarity_v1
  (polarity.negate.dissent), so the "no pack-resident lemma" contract
  these tests pin needed a fixture where every content token is
  genuinely OOV.  ``nope`` is OOV across all 10 mounted packs; ``wrong``
  remains OOV (collision with attitude's ``right`` blocked spatial-
  direction ``right`` but did not add ``wrong``).

Authoring:
  Three parallel subagents — affirm / negate+uncertain / frequency.
2026-05-19 05:38:13 -07:00
Shay
e72e946c0b feat(packs): en_core_causation_v1 — causation vocabulary (15 lemmas)
Workstream 1 seventh pack.  Extends the causal apparatus beyond
cognition_v1's ``cause`` (NOUN+VERB) and ``because`` (SCONJ).

Pack composition (15 entries — 6 NOUN / 6 VERB / 3 ADJ):

  causation.effect.*     effect result consequence outcome impact influence
  causation.verb.*       trigger induce yield enable prevent drive
  causation.adjective.*  causal resultant consequent

``cause`` was deliberately retained in en_core_cognition_v1.  Test
pins the invariant.

Verification:
  Cognition eval byte-identical (100/100/91.7/100 public,
  100/100/83.3/100 holdout).
2026-05-19 05:38:12 -07:00
Shay
390c2834f8 feat(packs): en_core_spatial_v1 — spatial vocabulary (24 lemmas)
Workstream 1 sixth pack.  Closes the spatial-vocabulary gap.  Prior
packs had zero coverage of here/there, location nouns, or spatial
prepositions.

Pack composition (24 entries — 7 ADV / 8 ADP / 9 NOUN):

  spatial.deictic.*          here there  (2 ADV)
  spatial.direction.*        forward backward left up down  (5 ADV)
  spatial.relation.*         near far above below inside outside
                             between beyond  (8 ADP)
  spatial.noun.*             place location area region space
                             end top bottom side  (9 NOUN)

``right`` was deliberately omitted — en_core_attitude_v1 already owns
it as evaluative.positive, and first-match-wins resolution preserves
that claim.  A regression test pins this invariant explicitly.

Files: lexicon.jsonl / manifest.json + 12 contract tests.

Verification: full lane 2204 passed / 2 skipped / 0 failed.
Cognition eval byte-identical both splits.
2026-05-19 05:38:12 -07:00
Shay
891ffa8969 feat(packs): en_core_quantitative_v1 — quantifiers + numeric basics (24 lemmas)
Workstream 1 fifth pack.  Closes the quantifier + basic-numeric gap.
Prior packs had zero coverage of universal / existential / comparative
quantifiers — queries about *all*, *some*, *many*, *more*, *most* all
fell through to OOV.

Pack composition (24 entries — mixed POS, 18 DET / 3 NUM / 2 ADJ / 1 NOUN):

  quantitative.universal.*    (6 DET) all every each both none neither
  quantitative.existential.*  (6 DET) some any several few many much
  quantitative.comparative.*  (6 DET) more less fewer most least enough
  quantitative.numeric.*      (3 NUM) one two three
  quantitative.unit.*         (3 mix) single (ADJ) half (NOUN) whole (ADJ)

The composer is POS-agnostic; surface composition uses
``semantic_domains`` rather than POS, so DET/NUM/ADJ/NOUN entries all
surface identically.

Files:
  language_packs/data/en_core_quantitative_v1/
    lexicon.jsonl   — 24 entries, SHA-256 checksum-sealed
    manifest.json   — operational_base / D0
  chat/pack_resolver.py
    Appended to DEFAULT_RESOLVABLE_PACK_IDS after action.
  core/config.py
    Added to RuntimeConfig.input_packs default mount.
  tests/test_en_core_quantitative_v1_pack.py
    11 contract tests (load / POS-dist / namespace / no-collision /
    contiguous-ids / mount / resolver-order / routing / invariance).

Authoring:
  Three parallel subagents — universal+existential / comparative /
  numeric.  Strict exemplar + forbidden-lemma list against all 7
  prior packs.

Verification:
  Full lane: 2192 passed, 2 skipped, 0 failed.
  Cognition eval byte-identical on both splits.
2026-05-19 05:38:12 -07:00
Shay
cb1eba72ae feat(packs): en_core_action_v1 — action verbs (26 lemmas)
Workstream 1 fourth pack.  Closes the common-action verb gap.  Prior
packs covered reasoning (cognition), speech/perception (meta), and
adjectives (attitude); this pack covers what an agent *does*.

Pack composition (26 VERB entries):

  action.doing.perform     do perform execute carry conduct
  action.doing.make        make
  action.doing.achieve     achieve accomplish
  action.creating.originate create build form produce generate develop
  action.changing.transform change transform
  action.moving.translate  move
  action.moving.depart_arrive go come
  action.moving.transfer   send receive
  action.possessing.acquire get take
  action.possessing.transfer give
  action.possessing.retain keep
  action.possessing.deploy use

Files:
  language_packs/data/en_core_action_v1/
    lexicon.jsonl   — 26 entries, SHA-256 checksum-sealed
    manifest.json   — operational_base / D0
  chat/pack_resolver.py
    Appended to DEFAULT_RESOLVABLE_PACK_IDS after temporal.
  core/config.py
    Added to RuntimeConfig.input_packs default mount.
  tests/test_en_core_action_v1_pack.py
    11 contract tests covering load / POS / namespace / no-collision /
    contiguous-ids / mounted-by-default / resolver-order / routing /
    prior-pack invariance.
  tests/test_procedure_surface.py
    Swapped two test fixtures from "do stuff" to "fix bugs".  ``do``
    is now correctly pack-resident in en_core_action_v1 (semantically
    correct — "How do I do stuff?" should ground on ``do``), so the
    "no pack lemma exists" contract needed a fixture where both verb
    and noun are genuinely OOV.  ``fix bugs`` satisfies this across
    all 7 mounted packs.

Authoring:
  Three parallel subagents — doing / creating / moving+possessing.
  Strict exemplar + forbidden-lemma list against all 6 prior packs.

Verification:
  Cognition eval byte-identical on both splits (100/100/91.7/100 and
  100/100/83.3/100).
  All 70 pack tests pass (cognition + meta + attitude + temporal +
  action + quant tests run together).
  Live composer probes confirm every action lemma surfaces
  deterministically from en_core_action_v1.
2026-05-19 05:38:12 -07:00
Shay
1c7408f7d0 feat(packs): en_core_temporal_v1 — temporal pack (28 lemmas)
Workstream 1 third pack.  Closes the temporal-vocabulary gap — prior
to this pack zero time/sequence/aspect terms existed in any mounted
English pack, so queries about *when*, *before*, *after*, *now*,
*future*, *past* all fell through to OOV.

Pack composition (28 entries, mixed POS — 12 ADV / 9 NOUN / 5 ADP /
1 SCONJ / 1 ADJ):

  temporal.deictic.*    (10 ADV)  now today tomorrow yesterday soon
                                  later recently eventually currently
                                  formerly
  temporal.relative.*    (9 mix)  before after during while until since
                                  ago prior henceforth
  temporal.noun.*        (9 NOUN) moment period duration instant era
                                  future past present time

The pack composer is POS-agnostic — surface composition uses the
ratified ``semantic_domains`` list rather than the POS tag.  Mixed-POS
entries surface identically to noun/verb entries.

Files:
  language_packs/data/en_core_temporal_v1/
    lexicon.jsonl   — 28 entries, SHA-256 checksum-sealed
    manifest.json   — operational_base / D0 / checksum-verified
  chat/pack_resolver.py
    Appended to DEFAULT_RESOLVABLE_PACK_IDS after attitude.
  core/config.py
    Added to RuntimeConfig.input_packs default mount.
  tests/test_en_core_temporal_v1_pack.py
    11 contract tests: checksum, POS-distribution invariant, primary-
    domain namespace, no-collision regression gate against all 5 prior
    packs, contiguous entry_ids, mounted-by-default, resolver-order
    invariant, routing correctness, and prior-pack resolution unchanged.

Authoring:
  Three parallel subagents — deictic / relative / nouns.  Strict
  exemplar + forbidden-lemma list against all 5 prior packs.

Verification:
  Full lane: 2170 passed, 2 skipped, 0 failed (+11 new tests).
  Cognition eval byte-identical on both splits.
  Live composer probes confirm every temporal lemma surfaces
  deterministically from en_core_temporal_v1.
2026-05-19 05:38:12 -07:00
Shay
f074ba729e feat(packs): en_core_attitude_v1 — adjective pack (40 lemmas)
Workstream 1 second pack.  Closes the ADJ POS gap — prior to this pack
zero adjectives existed in any mounted English content pack, so the
runtime could not emit grounded surfaces for predicative queries like
"What is true?" or "What is important?".

Pack composition (40 ADJ entries):

  attitude.truth_value.*   (8)  true false valid invalid accurate
                                inaccurate factual sound
  attitude.evaluative.*    (6)  good bad right better worse best
  attitude.epistemic.*    (10)  certain uncertain possible impossible
                                likely unlikely probable clear obscure
                                evident
  attitude.modal.*         (4)  necessary sufficient required optional
  attitude.importance.*    (6)  important essential relevant central
                                primary useful
  attitude.scope.*         (6)  general specific broad narrow universal
                                particular

Files:
  language_packs/data/en_core_attitude_v1/
    lexicon.jsonl   — 40 entries, SHA-256 checksum-sealed
    manifest.json   — operational_base / D0 / checksum-verified
  chat/pack_resolver.py
    Appended to DEFAULT_RESOLVABLE_PACK_IDS after cognition + meta.
  core/config.py
    Added to RuntimeConfig.input_packs default mount.
  tests/test_en_core_attitude_v1_pack.py
    11 contract tests: checksum, POS=ADJ uniformity, primary-domain
    namespace, no-collision regression gate against all 4 prior packs,
    contiguous entry_ids, mounted-by-default, resolver-order invariant,
    routing correctness, and cognition+meta resolution unchanged.

Authoring:
  Three parallel subagents (1 per cluster) — truth/eval, epistemic/modal,
  importance/scope.  Strict exemplar + forbidden-lemma list against all
  prior packs.  Main pass assembled, validated, sealed.

Verification:
  Full lane: 2159 passed, 2 skipped, 0 failed (+11 new tests over the
  previous 2148 baseline).
  Cognition eval byte-identical on both splits:
    public  100 / 100 / 91.7 / 100
    holdout 100 / 100 / 83.3 / 100
  Live composer probes: every ADJ lemma emits a deterministic
  pack-grounded surface from en_core_attitude_v1.
2026-05-19 05:38:12 -07:00
Shay
a376a30bf8 feat(packs): en_core_meta_v1 — conversational substrate (73 lemmas)
Workstream 1 (pack content scale-up) first load-bearing step.

Adds a new ratified content pack covering the conversational vocabulary
en_core_cognition_v1 deliberately omits — speech acts, mental states,
perception, self-reference, and discourse-object nouns.  These are the
lemmas that show up in nearly every model response and that previously
fell through to the OOV invitation surface.

Pack composition (73 entries, 49 VERB + 24 NOUN):

  meta.speech_act.*     (20 verbs)  say tell speak reply claim state
                                    describe express name mention note
                                    observe declare assert deny confirm
                                    suggest propose articulate respond
  meta.mental_state.*   (18 verbs)  know believe think suppose assume
                                    expect hope want prefer doubt wonder
                                    guess recognize realize consider intend
                                    decide hold
  meta.perception.*     (11 verbs)  see hear feel sense perceive watch
                                    look listen find detect notice
  meta.self_reference.* (10 nouns)  self mind view perspective position
                                    role agent model system speaker
  meta.discourse.*      (14 nouns)  response reply statement fact idea
                                    point argument proposal suggestion
                                    case instance example kind type

Files:
  language_packs/data/en_core_meta_v1/
    lexicon.jsonl   — 73 entries, SHA-256 checksum-sealed
    manifest.json   — operational_base / D0 / checksum-verified
  chat/pack_resolver.py
    Appended en_core_meta_v1 to DEFAULT_RESOLVABLE_PACK_IDS after
    en_core_cognition_v1 so cognition lemma resolution stays first-
    match-wins on any future collision (preserves cognition-lane
    byte-identity invariant).
  core/config.py
    Added en_core_meta_v1 to RuntimeConfig.input_packs default mount.
  tests/test_en_core_meta_v1_pack.py
    11 contract tests: checksum-verified load, POS split, primary-
    domain namespace, no-collision-with-cognition-v1 regression gate,
    pack registration order, resolver routing, and cognition-lemma
    resolution unchanged.
  tests/test_procedure_surface.py
    Swapped two test fixtures from "claim" to "hypothesis".  ``claim``
    is now correctly pack-resident (meta.speech_act.claim) so the
    procedure composer's object-first selector picks it over the verb
    — the new behavior is semantically correct.  ``hypothesis`` is
    genuinely OOV across all mounted packs and preserves the verb-
    fallback contract these tests pin.

Authoring methodology:
  Four parallel subagents authored one cluster each from a strict
  exemplar + word list + forbidden-lemma list (every en_core_cognition_v1
  lemma listed explicitly to prevent collision).  Each subagent wrote
  only its cluster JSONL; the main pass assembled, validated, computed
  the SHA-256 over bytes-on-disk, and wrote the manifest.

Verification:
  Full lane: 2148 passed, 2 skipped, 0 failed (+11 new tests).
  Cognition eval byte-identical on both splits:
    public  100 / 100 / 91.7 / 100
    holdout 100 / 100 / 83.3 / 100
  Live runtime probes: fresh ChatRuntime() for "What is X?" with
  X ∈ {fact, doubt, statement, model, self} all emit a
  pack-grounded sentence from en_core_meta_v1.
  OOV path still honest for genuinely-unknown terms (e.g. hypothesis).

Scope note:
  This is one pack of ~70 lemmas, not "the model now articulates
  open-domain English."  The architecturally-honest articulation
  story still requires more pack and teaching-chain content; this
  pack moves the conversational-substrate boundary forward by ~70
  lemmas in one ratifiable, replay-stable step.
2026-05-19 05:38:12 -07:00
Shay
bf8284fd47 Phase 2 — proposition-slot grounding for articulate_with_intent
Root cause: recalled_words was built from result.tokens (versor walk
neighbours) rather than the pack-resolved proposition slots. The walk
produces nearest-neighbour traversal artifacts; the proposition already
carries the correct subject/predicate/object from realize(). This made
ground_graph() fill <pending> obj slots with stop-word-adjacent tokens
instead of the actual answer content.

Fix — two changes, one new helper:

generate/intent_bridge.py
  • build_recalled_words_from_plan(plan, proposition, walk_tokens)
    Constructs the grounding tuple in priority order:
      1. plan.object  (ArticulationPlan — pack-resolved, already a word)
      2. proposition.object_  (Proposition — versor-decoded object slot)
      3. plan.predicate  (descriptive predicate word, richer than walk)
      4. plan.subject  (subject as last-resort semantic anchor)
      5. walk_tokens  (result.tokens alpha-filtered — supplemental backfill)
    Strips <pending>/<prior>/empty/non-alpha before deduplicating.
    Returns a deduplicated tuple in that priority order.
  • articulate_with_intent() gains an optional `proposition` param
    (typed as object to avoid import coupling at the call site).
    When provided, build_recalled_words_from_plan() is called to
    replace the raw recalled_words before ground_graph() runs.
    When omitted, behaviour is byte-identical to Phase 1 (backward
    compatible: all existing callers and tests pass unchanged).

chat/runtime.py
  • The single articulate_with_intent() call site now passes
    proposition=proposition so the bridge receives the full
    pack-resolved proposition for grounding. walk_tokens (the old
    recalled_words) are passed through as supplemental backfill.
  • No change to ChatResponse, TurnEvent, GenerationResult, or any
    ADR-gated schema.
2026-05-18 18:18:31 -07:00
Shay
b9778b85df Phase 1 — bridge trace instrumentation (observation-only)
Adds generate/bridge_trace.py: a structured sink + serializer for
per-turn articulation-bridge trace records, following the exact
ADR-0040 telemetry sink pattern (JsonlBufferSink / JsonlFileSink /
FanOutSink, no wall-clock, redact-by-default).

Modifies generate/intent_bridge.py: articulate_with_intent() emits
one BridgeTraceRecord per call through a module-level opt-in sink
(attach_bridge_trace_sink / detach_bridge_trace_sink).  When no
sink is attached the call is a pure no-op — zero behavior change on
all existing paths.

The record captures:
  - intent_tag / intent_subject  (classifier output)
  - plan_subject / plan_predicate / plan_object  (articulation slots)
  - recalled_words_len / recalled_words_sample  (grounding supply)
  - pre_ground_obj  (what the graph node held before ground_graph)
  - post_ground_obj  (what it held after, or same if no grounding ran)
  - bridge_surface / bridge_useful  (final output + usefulness gate)
  - fallback_surface  (the plan.surface the runtime falls back to)

This is the Phase 1 measurement instrumentation described in the
full-sentence output mastery plan.  Phases 2-5 act on the data this
produces; Phase 1 itself is pure observation.
2026-05-18 18:04:57 -07:00
Shay
4670e391ec feat(phase5+bench): cross-pack supersede + articulation benchmark suite
Phase 5 (ADR-0067 follow-up):
  teaching/cross_pack_supersede.py — supersede_cross_pack_chain()
  CLI: core teaching supersede ... --cross-pack
    --subject-pack-id ... --object-pack-id ...
  Strict per-chain residency, anti-leakage, byte-identical rollback
  on any post-append re-load failure.  9 new tests.

Articulation benchmark suite (Phase 4 capability proof):
  benchmarks/articulation.py — 5 sub-benches
    [1] breadth        — every intent shape (9 + OOV + cross-pack)
    [2] determinism    — N reruns / unique-surface count
    [3] footprint      — psutil RSS profile across T turns
    [4] cross-topic    — thread context across mixed subjects
    [5] ollama-compare — opt-in side-by-side with local Ollama
  CLI: core bench --suite articulation
    --runs N (det rerun count)
    --turns N (footprint sample window)
    --ollama-model MODEL --ollama-reruns N
  Full operator preamble + JSON report path.
  10 new tests cover the bench shape (psutil import-skipped).

Documentation:
  benchmarks/README.md — full operator manual: catalogue of every
    bench suite, how to read good/neutral/bad results for each sub-
    bench, why CORE vs Ollama comparisons are valid on the
    determinism axis and not on linguistic quality, workflow guide.
  README.md — articulation bench listed in the live-demo grid and
    quick-start examples.

Reference run (llama3:8b, 100 turns, 5 reruns):
  determinism_all_identical=True
  per-turn ΔRSS ≈ 23 KiB
  CORE byte_identical_on_every_prompt=True
  Ollama unique_surfaces≥2 on every prompt

Verification:
  18 new tests pass
  Full lane: 2116 passed, 2 skipped, 0 failed in 2:38
2026-05-18 17:44:59 -07:00
Shay
d5a6e81b33 feat(adr-0067): cross-pack teaching chains — Plan Phase 4 closed
ADR-0064 bound each teaching corpus 1:1 to a single ratified pack;
chains whose subject + object resolved to different packs were
dropped at load time. Phases 1–3 ratified the per-pack DAGs needed
to lift that constraint safely.

ADR-0067 introduces a deliberately narrow cross-pack chain shape.
Each entry carries explicit subject_pack_id and object_pack_id
fields, and the loader verifies per-chain residency. Same-pack
entries are rejected as corpus-misfilings (anti-leakage). The
cross-pack composer is the fall-through after the in-pack composer,
so the cognition lane stays byte-identical.

Files:
- chat/cross_pack_grounding.py — CrossPackChain + loader +
  single-chain composer + multi-chain enumerators
- teaching/cross_pack_chains/cross_pack_chains_v1.jsonl — 5 seed
  chains (family×identity, parent×understanding, family×memory,
  identity×family, understanding×parent)
- chat/runtime.py — fall-through wiring in CAUSE/VERIFICATION
- chat/narrative_surface.py, chat/example_surface.py — merge
  cross-pack chains, per-chain pack-residency helpers
- tests/test_cross_pack_chains.py — 31 tests covering loader,
  surface, multi-chain access, runtime integration, in-pack
  precedence
- tests/test_narrative_example_intents.py — corpus-tag assertions
  widened to allow cross-pack aggregation

Verification:
- 31 new tests pass
- Curated lanes: smoke 67 / cognition 121 / teaching 17 / packs 6 /
  runtime 19 — all green
- Cognition eval byte-identical (public 100/100/91.7/100, holdout
  100/100/83.3/100)
- Full lane: 2098 passed, 2 skipped, 0 failed in 2:30
2026-05-18 17:22:43 -07:00
Shay
ce8226e9a2 feat(adr-0066): NARRATIVE + EXAMPLE intents with multi-clause composers (Phase 3.3 + 3.4)
Two new intent shapes + composers turn the runtime's corpus
density into operator-visible articulation.  Both consult the
cross-corpus aggregator from ADR-0064; no new ratification needed.

P3.3 — chat/narrative_surface.py + IntentTag.NARRATIVE.

  Classifier patterns (registered BEFORE generic DEFINITION):
    ^tell\s+me\s+about\s+
    ^describe\s+
    ^what\s+(?:can|do)\s+you\s+(?:say|know)\s+about\s+

  narrative_grounded_surface(subject, max_clauses=4) walks every
  reviewed chain rooted on subject across all registered teaching
  corpora.  Dedupes by (connective, object) — cause + verification
  carrying the same predicate emit one clause, not two.  Sorts by
  (intent, connective, object) for replay stability.

  Surface format:
    "{X} — narrative-grounded ({corpus_ids}): {dX1}; {dX2}.
     {X} {conn1} {O1} ({dO1}); {X} {conn2} {O2} ({dO2}).
     No session evidence yet."

  Cross-corpus subjects (e.g. mother in relations_v2) emit
  narrative-grounded (relations_chains_v2) tag; cognition subjects
  emit cognition_chains_v1 tag.  Multi-corpus subjects (when
  applicable) emit composite "corpus_a + corpus_b" tag.

P3.4 — chat/example_surface.py + IntentTag.EXAMPLE.

  Classifier patterns:
    ^(?:give|show)\s+(?:me\s+)?an?\s+(?:example|instance)\s+of\s+
    ^example\s+of\s+

  example_grounded_surface(object_lemma, max_examples=3) walks chains
  where the lemma is the OBJECT — inverts the typical subject-keyed
  access pattern.  Dedupes by subject; sorts by (intent, subject,
  connective).

  Surface format:
    "{X} — example-grounded ({corpus_ids}): {dX1}.
     Example: {subj1} {conn1} {X}; {subj2} {conn2} {X}.
     No session evidence yet."

Cross-cutting:
  - Both intents added to _OOV_INTENT_TAGS — fall through to OOV
    invitation when subject is unknown (Phase 2 gradient discipline).
  - Both tagged grounding_source="teaching" (same provenance tier
    as the existing teaching_grounded_surface).
  - No prose generation, no new mutation surface.

Live verification:
  > Tell me about truth.
    [teaching] truth — narrative-grounded (cognition_chains_v1):
    cognition.truth; logos.core. truth grounds knowledge
    (cognition.knowledge); truth requires evidence (cognition.evidence).

  > Give me an example of knowledge.
    [teaching] knowledge — example-grounded (cognition_chains_v1):
    cognition.knowledge. Example: truth grounds knowledge;
    understanding requires knowledge; evidence grounds knowledge.

  > Tell me about mother.
    [teaching] mother — narrative-grounded (relations_chains_v2):
    kinship.parent.female. mother precedes daughter (kinship.child.female).

  > Describe photosynthesis.
    [oov] I haven't learned 'photosynthesis' yet (intent: narrative). ...

ADR-0066 (this commit completes the ADR).  30 new tests passed.
Full lane: 2067 passed, 2 skipped, 0 failed in 2:32.
2026-05-18 17:01:55 -07:00
Shay
fe4cc2cd1f feat(adr-0066): session-thread context + opt-in anaphora prefix (Phase 3.1 + 3.2)
ADR-0066 P3.1 + P3.2.  Conversation now reads as a thread: turns
carry structured summaries of their predecessors and (optionally)
prefix new pack/teaching surfaces with deterministic backreferences.

P3.1 — chat/thread_context.py.

  TurnSummary(turn_index, intent_tag_name, subject, grounding_source,
              chain_id, corpus_id) — frozen, structured-fields-only.
  ThreadContext — bounded FIFO (default MAX_THREAD_TURNS=8) with
    snapshot(), recent_for_subject(), recent_subjects(), clear().
  recent_for_subject() excludes ungrounded tiers (oov/partial/none)
    by default — those are not strong-enough anchors.
  ChatRuntime.thread_context is owned at construction.
  _push_thread_summary runs at end-of-turn on BOTH stub and walk
    paths.  Teaching-grounded turns carry chain_id + corpus_id so
    downstream composers (P3.2) can detect same-chain reference.
  Cold-start intent classification now runs unconditionally (was:
    gated on sink attachment) so thread context captures subject
    regardless of sink state.

P3.2 — chat/anaphora.py.

  thread_anaphora_prefix(ctx, subject, intent_name, source) returns
  a deterministic prefix when:
    - current turn is pack/teaching tier
    - a prior pack/teaching turn on the same subject exists
    - the prior intent differs from the current intent

  Format (structural-fields-only — no prose):
    "(Recalling turn N: chain <chain_id>.) "    # prior was teaching
    "(Recalling turn N: <subject> grounded pack.) "  # prior was pack

  Opt-in via RuntimeConfig.thread_anaphora=False.  Default off keeps
  every existing surface byte-identical.

Live verification (with thread_anaphora=True + seeded context):
  > What is light?  # following a "Why does light exist?" teaching turn
  [pack] (Recalling turn 0: chain cause_light_reveals_truth.)
  light — pack-grounded (en_core_cognition_v1): cognition.illumination;
  logos.core; perception.clarity. No session evidence yet.

32 new tests passed.  Curated lanes green.  Cognition eval
byte-identical to pre-ADR baseline.
2026-05-18 17:01:34 -07:00
Shay
ea298bdc28 feat(teaching): OOV signal flywheel — sink, aggregator, auto-promotion (Phase 2.3)
Mirrors the chain-gap pipeline (Phase 1.1+1.2) for vocabulary gaps:
the OOV invitation surface (P2.1) now emits structured signals that
operators can aggregate, rank, and auto-promote into reviewed
PackMutationProposal candidates — closing the OOV loop the same way
Phase 1 closed the chain loop.

Three new modules + two new CLI surfaces:

teaching/oov_sink.py.
  OOVCandidate dataclass mirroring teaching.discovery.DiscoveryCandidate.
  OOVBufferSink (in-memory) + OOVMonthlyFileSink (append-only JSONL
  under <root>/<YYYY>/<YYYY-MM>.jsonl — same layout as discovery sink
  so the aggregator reuses the file-walk machinery).
  hash_oov_candidate_id(token, intent, trace_hash) — deterministic
  32-char hex id matching DiscoveryCandidate's replay invariant.
  format_oov_candidate_jsonl — sorted-keys compact JSONL line.

teaching/oov_gaps.py.
  aggregate_oov_gaps(root, since, sample_limit) groups emitted
  candidates by token, tracks intent-shape union (a token asked under
  multiple intents is a stronger curriculum signal), splits
  boundary_clean from boundary_tainted counts, supports --since
  YYYY-MM filtering via the sink's file naming convention.
  Pure reader; never mutates the sink.  Deterministic ordering:
  (count desc, token asc).

teaching/oov_promotion.py.
  promote_oov_gaps(gaps, threshold, include_tainted, suggested_packs)
  lifts threshold-crossing tokens to OOVPromotion records.
  - boundary_clean_count gates promotion by default (tainted-only
    tokens may indicate the prompt hit a safety axis rather than a
    vocab gap).
  - --include-tainted flag for operator override.
  - threshold < 1 raises.
  - queue_id deterministic: ``oov:<token>@<threshold>`` — diffable
    across runs.
  - suggested_packs lists mounted packs but does NOT recommend one
    — domain inference is out of scope (would require a stochastic
    classifier).  Operator picks the destination.

Runtime wiring:
  ChatRuntime.attach_oov_sink(sink) mirrors attach_discovery_sink.
  Runtime emits one OOVCandidate JSONL line per turn whose
  grounding_source == "oov", no-op when no sink is attached.
  Intent classifier is now invoked when EITHER sink is attached
  (was: only discovery sink) — both downstream paths need it.

CLI:
  core teaching oov-gaps [--top N] [--since YYYY-MM] [--root PATH]
                          [--sample-limit N] [--json]
  core teaching oov-queue [--threshold N] [--include-tainted]
                          [--root PATH] [--since YYYY-MM] [--json]

ADR-0065 documents the full design (five-tier honesty gradient,
P2.1-P2.4 architecture).  README.md updated with the ADR-0065
index entry.

Verification:
  tests/test_oov_pipeline.py                      24 passed
  Operator workflow round-trip verified live:
    > rt.attach_oov_sink(sink); rt.chat("What is photosynthesis?")
    → sink receives:
      {"boundary_clean":true,"candidate_id":"f51bf8...",
       "intent":"definition","token":"photosynthesis","trigger":"unresolved_subject",
       "source_turn_trace":"","review_state":"unreviewed"}
    > core teaching oov-gaps --root /tmp/oov_demo
    → ranked table by count, intent-set per token
    > core teaching oov-queue --root /tmp/oov_demo --threshold 2
    → promoted tokens + suggested mounted packs

Full lane: 2005 passed, 2 skipped, 0 failed in 2:34 (xdist).
2026-05-18 16:42:26 -07:00
Shay
a435411be5 feat(packs): en_core_relations_v2 — pronouns + role-fillers (Phase 2.4)
ADR-0065 P2.4.  Eight specialization lemmas, each a typed
specialization of an en_core_relations_v1 primitive:

  mother / father           is-a parent
  daughter / son            is-a child
  sister / brother          is-a sibling
  grandparent / grandchild  is-a ancestor / descendant (1-step)

Strict pack-internal taxonomy under kinship.*:

  mother      → kinship.parent.female
  father      → kinship.parent.male
  daughter    → kinship.child.female
  son         → kinship.child.male
  brother     → kinship.sibling.male
  sister      → kinship.sibling.female
  grandparent → kinship.ascendant.transitive_1step
  grandchild  → kinship.descendant.transitive_1step

Pack ratification:
  - SHA-256 checksum 7d0583f7e6a13ce72a5b0b191786cfc57af31583dc5111b24c3466e89ee70856
  - Orthogonal to en_core_relations_v1 + en_core_cognition_v1 (zero
    lemma collision in either direction)
  - Mounted by default in RuntimeConfig.input_packs + added to the
    cross-pack resolver's DEFAULT_RESOLVABLE_PACK_IDS

Companion corpus relations_chains_v2.jsonl seeds 7 v2-internal
reviewed chains so DEFINITION/CAUSE/VERIFICATION on every v2 lemma
grounds (not just DEFINITION via the pack path):

  cause_mother_precedes_daughter
  cause_father_precedes_son
  cause_grandparent_precedes_grandchild
  cause_daughter_follows_mother
  cause_son_follows_father
  verification_daughter_requires_mother
  verification_son_requires_father

Registered as a third TeachingCorpusSpec alongside cognition and
relations_v1.  Strict pack-internal: every chain's subject AND
object reside in en_core_relations_v2.  Cross-pack chain shapes
(e.g. v2 subject + v1 object) deferred per teaching_order.md §5.

Live verification:
  > What is mother?
    [pack] mother — pack-grounded (en_core_relations_v2):
    kinship.parent.female; kinship.parent; biology.maternal.
  > Why does mother exist?
    [teaching] mother — teaching-grounded (relations_chains_v2):
    mother precedes daughter (kinship.child.female).
  > Does daughter require mother?
    [teaching] daughter requires mother — verification-grounded.

10 pack-contract tests passed.  Curated lanes all green; cognition
eval byte-identical.
2026-05-18 16:42:02 -07:00
Shay
51aad0c2cd feat(adr-0065): OOV cliff → five-tier honesty gradient (Phase 2.1 + 2.2)
Replaces the flat "I don't know — insufficient grounding" disclosure
with a deterministic gradient that names specific vocabulary gaps
and gives operators concrete next steps.

P2.1 — OOV "teach me" surface (chat/oov_surface.py).

  When the intent classifier extracts a clean subject lemma but that
  lemma is not resident in any mounted lexicon pack, the runtime now
  emits a deterministic learning-invitation surface tagged
  ``grounding_source="oov"`` instead of the universal disclosure.

  Surface format (fixed template):

    "I haven't learned '{token}' yet (intent: {intent}).
     Mounted lexicon packs: {pack_list}.
     Teach me via a reviewed PackMutationProposal."

  The OOV token passes through ``core._safe_display.safe_display``
  before persistence — user-input sanitization at the trust boundary.
  No vocabulary is invented; no domain is inferred.  Honours the
  ADR-0027 proposal-only invariant: the surface invites a reviewed
  pack mutation, never silently mutates any pack.

  Refactored ``_maybe_pack_grounded_surface`` so every existing
  intent branch (COMPARISON / CAUSE / VERIFICATION / CORRECTION /
  PROCEDURE / DEFINITION+RECALL) falls through on a None composer
  result instead of early-returning.  The OOV invitation is the
  deterministic fall-through for any clean-subject prompt whose
  subject doesn't resolve.

P2.2 — Partial-grounding tier (chat/partial_surface.py).

  When exactly one of two COMPARISON lemmas resolves, the runtime
  emits a hedged surface that grounds the known side verbatim and
  disclaims the OOV side explicitly:

    "Whatever '{oov}' is, I can ground '{known}' — pack-grounded
     ({pack_id}): {d1}; {d2}.  I cannot ground the comparison
     without learning '{oov}' — teach me via a reviewed
     PackMutationProposal."

  Tagged ``grounding_source="partial"``.  Falls through to OOV
  invitation when both lemmas are OOV, and to full pack-grounded
  COMPARISON when both resolve — partial is the middle tier in the
  five-tier gradient.

  Also normalises trailing sentence punctuation on
  intent.secondary_subject at the COMPARISON boundary so prompts
  like "Compare A and B." (with the period) still resolve B
  correctly.

Five-tier gradient (vault → teaching → pack → partial → oov → none).

Test debt retired: four pre-existing tests asserted "OOV → universal
disclosure", which is exactly the contract P2.1/P2.2 inverted.
Rewritten to the new contract.  Plus test_procedure_surface.py
gained a test for the OOV gradient on procedure intents.

Verification:
  tests/test_oov_surface.py                       22 passed
  tests/test_partial_surface.py                   16 passed
  Cognition eval byte-identical:
    public  100% / 100% / 91.7% / 100%
    holdout 100% / 100% / 83.3% / 100%
  Curated lanes all green.
2026-05-18 16:41:45 -07:00
Shay
34295e55ce perf(test-infra): pytest-xdist + module-scoped demo fixtures
Full lane wall-time: 6:35 → 2:25 (2.7× speedup).  No behavioral
changes; same 1933 passed, 2 skipped.

Three wins, biggest first:

1. pytest-xdist as a project dependency.

   ``pyproject.toml`` gains ``pytest-xdist>=3.6``.  ``cmd_test``
   injects ``-n auto`` for ``--suite full`` when xdist is importable;
   curated suites stay single-process because worker-spawn overhead
   is net-negative on the smaller suites.  Operator can override
   via passing ``-n <N>`` or ``--dist`` explicitly.

   Verified: ``core test --suite full -q`` prints ``bringing up
   nodes...`` and parallelises across the runner's CPUs.

2. Module-scoped fixture for run_demo() in test_learning_loop_demo.py.

   The 7 demo tests each previously called ``run_demo(emit_json=True)``
   from scratch — and ``run_demo`` itself runs the cognition lane
   twice via the replay-equivalence gate.  ~15s/file → ~3s/file.

   Module scope (not session) is intentional: pytest-xdist
   distributes by test, so a session-scoped fixture would still be
   re-evaluated per worker that picks up a test from this file.
   Module scope keeps the cost paid once per worker per file, which
   is the actual lower bound.

3. Module-scoped fixture for the teaching-loop bench.

   ``test_teaching_loop_bench.py``'s 5 tests previously each ran
   ``run_teaching_loop_determinism(runs=2 or 3)`` — 12 pipeline
   invocations across the file.  One ``runs=3`` invocation shared
   across all 5 tests covers every assertion: ~25s → ~7s.

For local iteration, ``core test --suite cognition -q`` etc. remain
fast (no xdist overhead).  The full-lane speedup is most visible
under CI / pre-merge runs.
2026-05-18 16:12:27 -07:00
Shay
84e74eede8 feat(teaching): discovery gaps aggregator + auto-promotion queue (Phase 1.1+1.2)
Closes the corpus flywheel.  ADR-0055 Phase B emits DiscoveryCandidate
JSONL to the discovery sink, but until now there was no operator-facing
view: candidates accumulated to disk, no one grepped them, the system's
"I would have grounded this if I had a chain" signal went into a void.

P1.1 — Discovery aggregator (teaching/gaps.py).

  Pure reader over the discovery-sink monthly-rollover layout
  (<root>/<YYYY>/<YYYY-MM>.jsonl).  aggregate_gaps(root, since,
  sample_limit) groups emitted candidates by (subject, intent) cell
  and returns a deterministic ranked tuple of Gap records.

  - count: total emissions
  - boundary_clean_count: subset whose boundary_clean flag held
    (refusal/hedge-tainted emissions split out so operators can filter)
  - sample_candidate_ids: up to N retained ids per cell, sorted
  - months_seen: every month token where the cell appeared

  --since YYYY-MM filters by file naming convention (no timestamp
  dependency).  Malformed lines silently skipped.  Default root:
  teaching/discovery_log.

  CLI: core teaching gaps [--root PATH] [--since YYYY-MM] [--top N]
                          [--sample-limit N] [--json]

P1.2 — Auto-promotion queue (teaching/promotion.py).

  promote_gaps(gaps, threshold, include_tainted) lifts cells whose
  effective count meets the threshold into GapPromotion records.

  - Default mode: boundary_clean_count gates promotion.  Tainted-only
    cells (count > 0 but all emissions refusal/hedge-tainted) do not
    auto-promote — those may indicate the prompt hit a safety axis,
    not a curriculum gap.
  - include_tainted=True counts every emission (operator override).
  - Threshold must be >= 1 (zero threshold defeats the queue).
  - queue_id is stable + deterministic (gap:<intent>:<subject>@<N>).
  - No content synthesis — promotion never invents connective or
    object; only an operator can author a complete chain via the
    propose/replay/accept pipeline.

  CLI: core teaching queue [--threshold N] [--include-tainted]
                           [--root PATH] [--since YYYY-MM] [--json]

Operator workflow (closed loop):

  operator → core chat                            # asks question
           ← cold turn emits DiscoveryCandidate
  operator → core teaching gaps --top 10          # ranked gaps
  operator → core teaching queue --threshold 3    # auto-promoted
  operator → authors candidate JSONL
  operator → core teaching propose <path>         # replay gate runs
  operator → core teaching review <id> --accept   # corpus mutates

24 new tests (13 gaps + 11 promotion), all pure / no I/O dependencies,
fast (<1s combined).  Full lane: 1933 passed, 2 skipped.
2026-05-18 16:04:39 -07:00
Shay
b5ba9b6d6f feat(adr-0064): cross-pack teaching chains + relations_chains_v1 seed (Phase 1.3+1.4)
ADR-0064 is the corpus-layer sibling of ADR-0063.  The teaching-grounded
surface composer was hardcoded to cognition_chains_v1, so kinship CAUSE/
VERIFICATION prompts fell through to the universal disclosure even though
en_core_relations_v1 was mounted on the live runtime (ADR-0063).

Architectural change in chat/teaching_grounding.py:

  - New TeachingCorpusSpec dataclass (corpus_id, path, pack_id).
  - TEACHING_CORPORA tuple registers every active corpus.  Each
    corpus is 1:1-bound to one lexicon pack — cross-domain triples
    deferred per docs/teaching_order.md §5.
  - _load_corpus(spec) loads one corpus with pack-residency scoped
    to its declared pack.
  - _all_chains_index() aggregates across all registered corpora
    (first-match-wins; cognition first preserves byte-identity).
  - _pack_for_corpus(corpus_id) → bound pack lexicon.
  - clear_teaching_caches() atomic cache invalidation.
  - TeachingChain gains corpus_id field → surface tag follows resolving corpus.

Wiring updates:

  - teaching_grounded_surface + teaching_grounded_surface_composed
    consult _all_chains_index; surface tag follows chain.corpus_id.
  - teaching/discovery.py gate uses chat.pack_resolver.is_resolvable
    (any mounted pack) + _all_chains_index (any registered corpus).
  - teaching/replay.py _swap_corpus_path rewrites the registry path
    + clears all teaching caches during the gate's transient phase.
    Active corpus bytes unchanged (replay invariant preserved).
  - evals/learning_loop/run_demo.py scene-5 swap mirrors the new
    pattern so the demo still grounds against transient corpora.

Back-compat preserved: _corpus_index, _CORPUS_PATH, TEACHING_CORPUS_ID
remain cognition-corpus-specific for audit/replay consumers.

Phase 1.4 — relations_chains_v1 seeded with 7 reviewed kinship chains:
  cause_parent_precedes_child
  cause_child_follows_parent
  cause_ancestor_precedes_descendant
  cause_descendant_follows_ancestor
  cause_family_grounds_parent
  verification_child_requires_parent
  verification_descendant_requires_ancestor

5 of 8 relations lemmas covered.  All connectives already humanised.
Strict pack-internal to en_core_relations_v1 (no cross-domain in v1).
Seed pattern matches cognition_chains_v1's original pre-ADR-0055 seed.

Live verification:
  > Why does parent exist?
  parent — teaching-grounded (relations_chains_v1):
  kinship.ascendant.direct; kinship.parent.
  parent precedes child (kinship.descendant.direct).
  grounding_source = teaching

Cognition eval byte-identical to pre-ADR baseline:
  public:  intent 100% / surface 100% / term 91.7% / closure 100%
  holdout: intent 100% / surface 100% / term 83.3% / closure 100%

Lanes green: smoke 67 / cognition 121 / teaching 17 / packs 6 /
runtime 19 / algebra 132 / full 1933 passed.
2026-05-18 16:04:20 -07:00
Shay
7c80b791ec fix(tests): retire 13 stale failures from full lane — corpus saturation drift
The full lane carried 13 long-standing red tests whose premises were
invalidated by reviewed-corpus growth that landed in earlier commits.
None reflected runtime bugs — all four classes are corpus-state drift
where the test fixture became stale.  Curated lanes were green, full
lane stayed quietly red.  Closes that gap.

1. test_teaching_audit (2 tests).
   * test_audit_real_corpus_runs_clean asserted dropped == () and
     lines_on_disk == lines_loaded — premise written before any
     supersession existed.  Curriculum saturation v2 (commit a0edbb4)
     ratified the wisdom_grounds_judgment → wisdom_requires_knowledge
     supersession; the audit now correctly shows 1 dropped line.
     Rewritten as the line-conservation invariant:
       lines_loaded + len(dropped) == lines_on_disk
     plus a typed-reason check on every dropped entry.
   * test_default_superseded_by_is_null_in_loaded_entries asserted
     ALL loaded entries have superseded_by == None.  Wrong even by
     ADR-0055 design: the replacement entry IS loaded and carries
     the back-pointer to the retired chain.  Rewritten as the
     active-set invariant: any non-null superseded_by on a loaded
     entry must reference a dropped (retired) chain id, never a live
     one — no double-live state.

2. test_learning_loop_demo (7 tests).
   The demo's headline prompt was "Why does thought exist?", and the
   ADR-0057 demo trilogy (commit 82dac4b) chose (thought, cause) as
   the cold cell.  Cognition saturation v2 (commit a0edbb4) ratified
   cause_thought_reveals_meaning into the active corpus — so the
   cold turn now grounds, no discovery candidate is emitted, every
   demo scene breaks.  Rotated the cold subject to ``narrative``
   (pack-resident, no chain, same thematic shape, same affirming
   evidence pointer cause_creation_reveals_meaning).  Demo headline,
   evals/learning_loop/run_demo.py, core/cli.py preamble, and the
   test assertions all updated together so the demo reads cleanly:
       before: [none]     I don't know — insufficient grounding...
       after : [teaching] narrative — teaching-grounded ... narrative
                          reveals meaning ...

3. test_discovery_candidates (4 tests).
   Test fixture used (judgment, CAUSE) as the still-cold pair.
   Epistemology v1 (commit 2acf71f) ratified
   cause_judgment_requires_wisdom — (judgment, cause) is no longer
   cold.  Rotated to ``principle`` (pack-resident, no chain on either
   intent today).  Added a pytest.skip self-guard so when a future
   curriculum unit ratifies a (principle, *) chain the test rotates
   cleanly instead of going red.

Full lane: 1892 passed, 2 skipped, 0 failed (was 4 failed pre-fix,
13 failed pre-ADR-0063).  Cognition eval unchanged: public 100/100/
91.7/100, holdout 100/100/83.3/100.
2026-05-18 15:23:22 -07:00
Shay
9f83b27a7c feat(adr-0063): cross-pack surface resolver — kinship lemmas ground on live path
ADR-0063 closes the ADR-0048/0050/0053/0061 hardcoded-cognition-pack
asymmetry. New chat/pack_resolver.py provides resolve_lemma(lemma,
pack_ids) → (resolving_pack_id, semantic_domains) across an ordered
tuple of mounted lexicon packs (first-match-wins, lru_cache per-pack).

Surface composers in chat/pack_grounding.py now consult the resolver
instead of a hardcoded en_core_cognition_v1. en_core_relations_v1
joins RuntimeConfig.input_packs defaults; kinship lemmas now ground
on the live path:

  > What is a parent?
  parent — pack-grounded (en_core_relations_v1):
  kinship.ascendant.direct; kinship.parent; biology.progenitor.
  No session evidence yet.

Cross-pack comparison (knowledge × parent) renders composite tag
(en_core_cognition_v1 × en_core_relations_v1). Cognition lane
remains byte-identical: cognition is resolved first and the surface
format for cognition lemmas is unchanged.

Cognition eval (byte-identical to pre-ADR baseline):
  public  → intent 100% / surface 100% / term 91.7% / closure 100%
  holdout → intent 100% / surface 100% / term 83.3% / closure 100%

Curated lanes green: smoke 67 / cognition 121 / teaching 17 /
packs 6 / runtime 19 / algebra 132.

New tests: test_pack_resolver.py (28) + test_cross_pack_grounding.py
(17). test_en_core_relations_v1_pack.py: default-input-packs guard
inverted. test_pack_grounding.py: two stale ADR-0048 tests rewritten
(premises invalidated by ADR-0052/0061; now use fully-out-of-pack
prompts).

chat/teaching_grounding.py UNCHANGED — cognition_chains_v1 corpus
stays cognition-only. Cross-pack teaching corpora are the natural
ADR-0064.
2026-05-18 15:00:58 -07:00
Shay
f0c57eb32e feat(packs): en_core_relations_v1 — kinship starter pack (8 lemmas)
Per teaching_order.md §5 — pick one commercial domain and run the
full 1→4 progression inside it before opening a second.  Kinship is
the doctrinally classic starter: tight DAG, well-bounded primitives,
and orthogonal to the cognition pack.

Lemmas (8): parent, child, sibling, family, ancestor, descendant,
spouse, offspring.  Each carries ≥2 semantic_domains under a
deterministic taxonomy (kinship.*, lineage.*, biology.*, social.*).

Deliberate exclusions:
  - `person` — lives in en_core_cognition_v1; orthogonality test
    pins that boundary.
  - Specializations (mother/father/son/daughter/grandparent/...) —
    derived from v1 primitives; land in v2 after v1 produces
    reviewed chains.
  - Quantifiers (one/two/many) — separate domain
    (en_core_quantification_v1); cross-domain triples come last.
  - Verbs of relation (begets/marries/...) — separate composer
    work; no relations_chains_v1.jsonl yet.

Engagement is opt-in:
  - Pack is NOT in RuntimeConfig.input_packs defaults.
  - Programmatic mount via RuntimeConfig(input_packs=(..., "en_core_relations_v1")).
  - CLI: core chat --pack en_core_relations_v1 (existing surface).
  - Default-not-mounted preserves the cognition lane unchanged
    until cross-pack teaching-grounded composition exists.

- language_packs/data/en_core_relations_v1/lexicon.jsonl
  — 8 entries, JSONL format matching en_core_cognition_v1.
- language_packs/data/en_core_relations_v1/manifest.json
  — pack_id, language, role=operational_base, checksum
  (SHA-256 of lexicon bytes per CLAUDE.md pack-discipline),
  version 1.0.0, determinism_class D0, oov_policy tagged_fallback.
- tests/test_en_core_relations_v1_pack.py — 6 tests pin:
  checksum-match load, lemma roster, per-lemma primary domain,
  ≥2 domains/lemma (composer headroom), zero collision with
  cognition pack (kinship DAG stays orthogonal), pack-not-in-
  default-input-packs (opt-in engagement contract).
- docs/curriculum/relations_pack_v1.md — full pack log:
  rationale per included/excluded lemma, opt-in engagement path,
  4-step ADR roadmap (cross-pack composition → first kinship
  chains → pronoun v2 → cross-domain triples).

Mounted-manifold sanity check (en_core_cognition_v1 +
en_core_relations_v1): 93 lemmas combined, no collisions, both
packs' surfaces individually addressable.

Lanes (regression): smoke 67 / packs 6 / algebra 132 / relations-pack 6.
The non-negotiable field invariant (versor_condition < 1e-6) is
unaffected: this is pure pack data + a contract test.
2026-05-18 14:40:54 -07:00
Shay
c492014815 feat(adr-0062): composed teaching-grounded surface (chain-of-chains)
Pre-ADR-0062, the teaching-grounded composer emitted exactly one
reviewed chain per surface — "light reveals truth" — even when the
corpus already contained an immediate follow-up "truth grounds
knowledge".  With 21 active chains after curriculum saturation v2,
many grounded prompts had a corpus-ratified follow-up the composer
silently dropped.

ADR-0062 adds the composed composer + an opt-in config flag:

  flag OFF (default):
    light — teaching-grounded (cognition_chains_v1): cognition.illumination;
    logos.core. light reveals truth (cognition.truth). No session evidence yet.

  flag ON:
    light — teaching-grounded (cognition_chains_v1): cognition.illumination;
    logos.core. light reveals truth (cognition.truth), which grounds
    knowledge (cognition.knowledge). No session evidence yet.

Follow-up resolution:
  - prefer cause; fall back to verification (deterministic preference)
  - cycle guard: 1-step cycles (A→B, B→A) blocked
  - pack-residency guard: follow-up's object must be pack-resident
  - bounded depth: v1 follows exactly one hop
  - degrades to single-chain BYTE-IDENTICALLY when no follow-up
    survives the guards (drop-in replacement)

Trust-boundary invariants preserved:
  - Every visible non-template token is lemma / pack-domain /
    humanize_predicate connective / template constant.  Only added
    template constant: ", which "
  - Deterministic: same chains → same surface bytes
  - Default-False flag pattern mirrors ADR-0047/0058
  - `versor_condition < 1e-6` invariant untouched (surface composition only)

Cognition lane null-drop invariant CI-pinned:
  Composed mode emits a strictly LONGER surface (extra follow-up
  clause); every expected_term passing flag-OFF must still pass flag-ON.
  Asserted in test_cognition_lane_metrics_unchanged_with_composed_flag
  for both public and holdout splits.  If a future change drops tokens,
  the test fails as a deliberate regression.

  public  flag OFF: intent 100% / surface 100% / term 91.7% / versor 100%
  public  flag ON : intent 100% / surface 100% / term 91.7% / versor 100% (identical)
  holdout flag OFF: intent 100% / surface 100% / term 83.3% / versor 100%
  holdout flag ON : intent 100% / surface 100% / term 83.3% / versor 100% (identical)

Live-prompt lift visible on ~12 of 21 active chains; the rest hit
cycle or pack-residency guards.  Saturation v2's clusters were
authored partly with composition in mind (thought→meaning→
understanding, inference→evidence→knowledge, etc.).

- core/config.py — `RuntimeConfig.composed_surface: bool = False`
- chat/teaching_grounding.py — `teaching_grounded_surface_composed`
  sibling to `teaching_grounded_surface`
- chat/runtime.py — dispatch branch in `_maybe_pack_grounded_surface`
  selects composed vs single-chain based on config flag
- tests/test_composed_surface.py — 11 tests pin: function-level
  (None on no chain / degrades when no follow-up / two-clause when
  follow-up exists / includes intermediate + final domains /
  deterministic / cycle guard / trust label preserved); runtime
  integration (default single-chain / flag-on composed / frozen
  config); cognition-lane null-drop invariant.

Lanes (regression): smoke 67 / cognition 121 / teaching 17 /
composed-surface 11 — all green.
2026-05-18 14:34:45 -07:00
Shay
a0edbb4bdb curriculum(cognition-saturation-v2): seven reviewed chains; pack coverage 14→21
Second curriculum unit through the production operator surfaces.
Pure saturation — no cognition-lane lift expected (the eval splits
test fixed 32 cases that don't overlap with this unit's subjects),
but the live-prompt grounding surface expands materially: seven
prompts that previously fell through to disclosure now route to
deterministic teaching-grounded surfaces.

Three coherent clusters:

  A. Cognition-source
     cause_thought_reveals_meaning
     cause_question_reveals_understanding
     cause_recall_reveals_memory

  B. Conceptual structure (bidirectional)
     cause_definition_grounds_concept
     verification_concept_requires_definition

  C. Semantic content
     cause_meaning_grounds_understanding
     cause_analogy_reveals_relation

All pack-consistent (subject + object in en_core_cognition_v1),
canonical predicates (reveals / grounds / requires), each opens a
previously-empty (subject, intent) cell.

Replay-equivalence gate reported replay_equivalent=True for all
seven proposals (public cognition lane byte-identical pre/post
every accept).

Cognition lane:
  public  : intent 100% / surface 100% / term 91.7% / versor 100%   (unchanged)
  holdout : intent 100% / surface 100% / term 83.3% / versor 100%   (unchanged)

Saturation lift is visible at the live-prompt level, not at the
eval level:

  Why does thought exist?              → [teaching] thought reveals meaning (...)
  Why does a question exist?           → [teaching] question reveals understanding (...)
  Why does definition exist?           → [teaching] definition grounds concept (...)
  Why does meaning exist?              → [teaching] meaning grounds understanding (...)
  Why does an analogy exist?           → [teaching] analogy reveals relation (...)
  Does a concept require definition?   → [teaching] concept requires definition (...)
  Why does recall exist?               → [teaching] recall reveals memory (...)

Why saturation matters: the cognition pack has 78 lemmas; we've
now covered ~21 (subject, intent) cells of the hundreds available.
Without saturation, prompts outside the 32 fixed eval cases are
coin-flips between vault recall and disclosure.  Saturation moves
marginal prompts to deterministic teaching-grounded surfaces — the
foundation the composed-surface ADR (next) will compose over.

- teaching/cognition_chains/cognition_chains_v1.jsonl — 15 → 22 lines
  (7 appends).  Active set: 14 → 21 chains.
- teaching/proposals/proposals.jsonl — 7 new (created → replay →
  transition → accepted_corpus_append) event sequences appended.
- docs/curriculum/cognition_saturation_v2.md — full curriculum log:
  cluster rationale, live-prompt lift, operator-wall-time profile,
  saturation-state-of-the-pack.

Lanes (regression check):
  core test --suite smoke           67 passed
  core test --suite cognition      121 passed
  core test --suite teaching        17 passed

The non-negotiable field invariant (versor_condition < 1e-6) is
unaffected: this is corpus growth only; no code path changed.
2026-05-18 14:29:30 -07:00
Shay
bf7f7895fe feat(adr-0061): PROCEDURE intent routes to pack-grounded surface
Pre-ADR-0061 every "How do I X?" question fell through to the
universal disclosure even when X was a pack-resident lemma.  The
teaching corpus carries CAUSE/VERIFICATION chains only — procedural
knowledge is fundamentally different in kind from propositional
claims and deserves its own ratification path (deliberately out of
scope; a future parallel `procedure_chains_v1.jsonl` schema is
discussed in the ADR's non-goals).

ADR-0061 adds the honest cold-start fallback: ground the topic in
pack semantic_domains and note explicitly that ratified step-by-step
guidance does not exist yet.

Surface format:
  "procedure-grounded ({pack_id}): {lemma} ({d1}; {d2}).
   Step-by-step guidance for {lemma} is not yet ratified
   in this session."

Selector — **last** pack-resident lemma in the verb-phrase subject:
  "define a concept" → concept    (object beats verb)
  "verify a claim"   → verify     (verb wins when object is OOV)
  "correct an error" → correct
  "learn this"       → learn
  "do stuff"         → None       (falls through to universal disclosure)

Stopwords: only `be` and `have` (dialogue fillers).  Procedure verbs
are deliberately NOT stopworded so the verb-as-fallback rule fires
when the object is OOV — keeps surface coverage.

Trust-boundary invariants:
  - Every visible non-template token is lemma / pack-domain / template.
  - Deterministic: same subject_text → same bytes.
  - Returns None for fully-unknown utterances → universal disclosure
    fires.  Never fabricates surface from nothing (ADR-0053 contract).
  - "not yet ratified" trust-label preserved.

Cognition lane lift:
  public  : intent 100% / surface 100% / term 91.7% / versor 100%      (unchanged)
  holdout : intent 100% / surface 94.7%→100.0% / term 79.2%→83.3% / versor 100%

Two cases fixed:
  - procedure_define_010 ("How do I define a concept?") — surface +
    term `concept` now captured.
  - procedure_verify_034 ("How do I verify a claim?") — surface only
    (case has no expected_terms; the verb fallback grounds it).

Combined effect: holdout `surface_groundedness` closes to 100%; 4 of
5 architectural holdout misses now resolved (this ADR + ADR-0060 +
the supersede from epistemology v1).  Remaining 2 are UNKNOWN-intent
cases (unknown_spirit_041, unknown_word_018) — out of scope; deserve
their own ADR with distinct selector semantics.

- chat/pack_grounding.py — `_extract_procedure_topic_lemma` helper +
  `pack_grounded_procedure_surface` composer.
- chat/runtime.py — import + dispatch branch for `IntentTag.PROCEDURE`.
- tests/test_procedure_surface.py — 15 tests pin: extraction
  (last-wins / verb-by-elimination / be+have skipped / None on empty /
  strips punctuation / case-insensitive); surface (contains lemma /
  contains domains / pack_id / "not yet ratified" label / None for
  no-pack-lemma / deterministic); end-to-end through ChatRuntime.

Lanes (regression): smoke 67 / cognition 121 / teaching 17 /
procedure 15 — all green.

The non-negotiable field invariant (versor_condition < 1e-6) is
unaffected: this ADR changes surface composition only.
2026-05-18 14:22:19 -07:00
Shay
c9e858c266 feat(adr-0060): correction acknowledgement carries corrected-topic lemma
ADR-0053's cold-start CORRECTION surface was topic-blind: a user who
said "Actually, truth requires evidence" got a response referencing
`correction` but never `truth`.  The holdout case correction_truth_040
expected `term=['truth']` and missed — one of the architectural gaps
surfaced by the epistemology v1 curriculum unit.

ADR-0060 closes that gap by weaving the first pack-resident topical
lemma from the utterance into a fixed-template extension:

  correction received — pack-grounded ({pack_id}):
  {correction_domains}. Noted topic: {lemma} ({lemma_domains}).
  No prior turn in this session to correct yet.

Selection rule (deterministic, left-to-right token order):
  - skip stopwords: `correction`, `correct`, `be`, `have`
  - pick first pack-resident lemma
  - if none found → ADR-0053 topic-less template byte-identically

Trust-boundary invariants preserved:
  - Every visible non-template token is still lemma / pack-domain / template
  - Deterministic: same text → same bytes
  - Backward compatible: existing 15 ADR-0053 tests pass byte-identically
  - "No prior turn in this session to correct yet." trust label kept

Cognition lane lift:
  public  : intent 100% / surface 100% / term 91.7% / versor 100%   (unchanged)
  holdout : intent 100% / surface 94.7% / term 75.0%→79.2% / versor 100%

The +4.2pp matches the single-case fix exactly (correction_truth_040).
Remaining 3 holdout misses (procedure_define_010, unknown_spirit_041,
unknown_word_018) are out of scope for this ADR.

- chat/pack_grounding.py — `_extract_correction_topic_lemma` helper +
  optional `text` parameter on `pack_grounded_correction_surface`.
- chat/runtime.py — single-line call-site change to pass `text` through.
- tests/test_correction_topic_lemma.py — 14 new tests pin:
  extraction (first lemma / skips correction / skips fillers / None on
  empty / strips punctuation / case-insensitive); surface (contains
  corrected lemma / contains topic domains / degrades to ADR-0053
  byte-identically / preserves trust label / deterministic / correct
  pack_id); end-to-end (correction_truth_040 emits 'truth' / no-pack-
  lemma still grounds).

Why text-level extraction, not intent.subject:
  `intent.subject` after ADR-0049 head-noun extraction returns
  ", truth requires evidence" for the test prompt — the CORRECTION
  intent's subject-extractor preserves the post-marker tail.  Parsing
  the raw text at the surface layer is cleaner; isolates the fix;
  doesn't perturb upstream classification logic.

Lanes (regression): smoke 67 / cognition 121 / teaching 17 /
correction tests 29 (15 ADR-0053 backward-compat + 14 ADR-0060 new) —
all green.

The non-negotiable field invariant (versor_condition < 1e-6) is
unaffected: this ADR changes surface composition only.
2026-05-18 14:14:27 -07:00
Shay
2acf71f024 curriculum(epistemology-v1): five reviewed chains; holdout term_capture +4.2pp
First end-to-end curriculum unit through the production
propose / review --accept / supersede operator surfaces against the
active teaching corpus.  Replay-equivalence gate passed for every
proposal; public split byte-identical; holdout term_capture lifted
exactly as predicted.

- Supersede `verification_wisdom_grounds_judgment` →
  `verification_wisdom_requires_knowledge`.  Fixes the only corpus-
  fixable holdout miss: `verification_wisdom_036`
  ("Is wisdom the same as knowledge?") now grounds with both
  expected terms.  Provenance carries
  `:supersede(verification_wisdom_grounds_judgment)`.
- Propose + accept four new chains closing epistemology subgraph
  cells:
    cause_understanding_requires_knowledge
    cause_judgment_requires_wisdom
    verification_evidence_grounds_knowledge
    cause_inference_requires_evidence

Each chain is pack-consistent, uses canonical predicates, and opens
a previously-empty (subject, intent) cell.  Replay gate confirmed
no metric regression on the public split before each accept.

Lift (cognition eval):
  public  : intent 100% / surface 100% / term 91.7% / versor 100%   (unchanged)
  holdout : intent 100% / surface 94.7% / term 70.8%→75.0% / versor 100%

The remaining four holdout misses (correction_truth_040,
procedure_define_010, unknown_spirit_041, unknown_word_018) are
architectural — surface-composition gaps in the correction-
acknowledgment template, procedure-intent routing, and unknown-
intent surface — and out of scope for corpus surgery.

- teaching/cognition_chains/cognition_chains_v1.jsonl — 10 → 15 lines
  (4 appends + 1 supersession marker; 1 retired chain still on disk
  per the audit doctrine of append-only at the file level).
- teaching/proposals/proposals.jsonl — new append-only proposal log
  with `created` / `replay` / `transition` / `accepted_corpus_append`
  events for every accepted proposal.
- docs/curriculum/epistemology_v1.md — full curriculum log:
  rationale per chain, prediction-vs-result on the holdout lift,
  reproducibility commands, architectural-gap analysis.

Lanes (regression check):
  core test --suite smoke           67 passed
  core test --suite cognition      121 passed
  core test --suite teaching        17 passed
  tests/test_eval_holdout_split    10 passed

The first curriculum unit that *measurably moves a cognition-lane
metric* through the operator surfaces, with full provenance from
operator note back to corpus append.
2026-05-18 14:02:37 -07:00
Shay
29449f3775 feat(adr-0059): correction-pass telemetry emission — backward perturbation auditable
`ChatRuntime.correct()` propagates a backward perturbation through the
session graph (per session/correction.py): each past turn whose output
versor has non-trivial CGA-alignment with the correction versor is
blended toward it (decayed by graph distance).  The forward regen turn
that followed already emitted a TurnEvent — but the backward
perturbation itself was invisible to the telemetry sink.

ADR-0059 closes that gap with a discriminated event line.

- chat/telemetry.py — adds `serialize_correction_event` +
  `format_correction_event_jsonl` emitting one JSONL line discriminated
  by `"type": "correction"`.  Payload: target_turn, records_count,
  turns_skipped, turn_idxs_affected, max_delta_norm, mean_delta_norm,
  SHA-256 correction_versor_digest, pack ids.  No raw versor coordinates.
- chat/runtime.py — `_emit_correction_event` (mirrors
  `_emit_turn_event`); called from `correct()` after the graph state
  is updated but before the forward regen turn.  No-op without sink.
- tests/test_correction_telemetry.py — 7 tests pin: no-op without
  sink, emission with sink, payload shape (required keys + types +
  ranges), SHA-256 digest shape, trust boundary (no versor
  coordinates leaked), determinism (byte-identical lines across
  runs), correction event and turn event coexist in the sink.

Trust boundary (per CLAUDE.md):
  - Metadata-only: only L2 deltas + SHA-256 digest.
  - No implicit wall-clock.
  - Deterministic: same CorrectionResult → byte-identical line.
  - Sink contract unchanged: `emit(line: str)`.
  - `versor_condition < 1e-6` invariant: untouched (telemetry-only).

Verification: smoke 67 / runtime 19 / correction telemetry 7 — green.
2026-05-18 13:47:48 -07:00
Shay
fd80da6ac0 docs(adr-0058): forward_graph_constraint engaged-but-inert; null-lift pinned
ADR-0058 closes the ADR-0047 follow-up question ("should the
forward_graph_constraint flag become default-on or pack-opt-in?")
with the explicit answer: neither, yet.

The ADR-0047 A/B characterisation found that the flag is observably
inert on every public-cognition-lane metric — narrowing which tokens
the walk may visit did not change which surface gets emitted.  That
finding scoped ADR-0048..0053, which closed the cognition lane to
100.0% surface_groundedness / 91.7% term_capture_rate via realizer /
surface-assembly work downstream of propagation.

This ADR makes three load-bearing decisions:

  1. `forward_graph_constraint` remains opt-in with default `False`.
     No identity pack (including precision_first_v1) opts in.
  2. No `runtime_preferences` block is added to identity packs; no
     path from pack JSON to RuntimeConfig is opened.  Deferring the
     pack-to-runtime composition layer until at least one such
     preference has demonstrated lift avoids letting the wiring lead
     the lift and locking in an abstraction at the wrong level.
  3. The ADR-0047 null-lift finding is promoted from a historical
     observation to a CI-enforced invariant.  A new regression test
     runs the public cognition split twice (flag OFF vs ON) and
     asserts every watched metric is pair-wise identical.  If
     downstream realizer work later moves a metric on the flag flip,
     the test fails as a deliberate transition rather than silent drift.

- docs/decisions/ADR-0058-forward-graph-constraint-status.md — ADR doc.
- docs/decisions/README.md — index entry.
- tests/test_forward_graph_constraint_null_lift.py — 2 tests:
  null-lift invariant across the cognition lane, default-False contract.

Verification:
  smoke 67 passed; flag tests 7 passed (5 wiring + 2 null-lift).
  No runtime behaviour change; versor_condition < 1e-6 invariant unaffected.
2026-05-18 13:36:37 -07:00
Shay
763ed16d1c docs(adr-0055-0057): writeups + asciinema captures for the demo trilogy
Three shareable demo / benchmark writeups modeled on the existing
`docs/evals/phase6_comparative_demo.md` treatment, each accompanied
by an asciinema-rendered GIF for at-a-glance viewing on the repo page.

- docs/evals/anti_regression_demo.md — three-gate defense; per-gate
  table; honesty paragraph about the synthetic regression in S2 (real
  ReplayEvidence shape via documented run_replay= kwarg); sample run
  output; falsifiable claims index.
- docs/evals/learning_loop_demo.md — headline before/after; CORE-vs-
  pretraining comparison table; trust-boundary code snippet showing
  the _CORPUS_PATH swap; per-scene table; full sample run; subject-
  selection rationale (pack-resident ∧ no active chain ∧ deterministic
  intent classification).
- docs/evals/teaching_loop_bench.md — what's byte-identical and why
  it matters per artifact; 100-run reference numbers (unique=1 across
  all five artifacts; mean=1.849s p50=1.838s p95=1.851s); pairing
  paragraph with ADR-0045 (read vs write determinism).

GIF captures (rendered with asciinema 3.2.0 + agg 1.8.1, github-dark
theme, JetBrains Mono):
- docs/evals/assets/anti_regression.gif   (120K, 944x843)
- docs/evals/assets/learning_loop.gif     (332K, 944x1039)
- docs/evals/assets/teaching_loop_bench.gif (64K, 860x1000)

Raw .cast files preserved alongside the GIFs for re-rendering at
different themes / speeds / sizes without re-recording.

README.md — added writeup-link column to the Inter-Session Memory
three-demo table.
2026-05-18 11:18:56 -07:00
Shay
d24e98906e docs(adr-0055-0057): preambles + README index for the demo trilogy
Three external-facing demos / benchmarks now match the existing
audit-tour / pack-measurements / long-context-comparison treatment:
preamble printed before the run, README index entries, claims table.

- core/cli.py — _ANTI_REGRESSION_PREAMBLE, _LEARNING_LOOP_PREAMBLE,
  _TEACHING_LOOP_BENCH_PREAMBLE.  Each lists reference ADRs, what to
  expect, trust boundary, test gate, and machine-readable invocation.
  Wired through _print_preamble in the demo dispatch + bench dispatch
  (suppressed under --json).
- README.md — new "Inter-Session Memory — Reviewed Learning" section
  between Teaching Order and Architecture: the three-gate trust
  property table, the three live-demo table, and the operator-surface
  command list.  Quick-start block lists `core demo anti-regression`,
  `core demo learning-loop`, and `core bench --suite teaching-loop
  --runs 100` alongside the existing demos.

No code paths changed — preambles are stdout-only when not under JSON.
Tests unchanged; 17/17 green (5 anti-regression + 7 learning-loop + 5 bench).
2026-05-18 11:08:55 -07:00
Shay
82dac4b16f feat(adr-0055-0057): teaching-loop determinism benchmark — replayable learning
`core bench --suite teaching-loop [--runs N]` runs the full reviewed-
corpus extension pipeline (propose → real replay-equivalence gate →
operator accept) N times against an identical input and asserts
byte-identical artifacts every run:

  - proposal_id          (SHA-256 of canonical-JSON payload)
  - replay_baseline      (cognition lane metrics on active corpus)
  - replay_candidate     (cognition lane metrics on transient corpus)
  - regressed_metrics    (sorted tuple)
  - chain_id_written

Also reports per-iteration latency (mean / p50 / p95) and total wall.

100-run result against today's main:
  unique(proposal_id)=1  unique(baseline)=1  unique(candidate)=1
  unique(chain_id)=1     active_corpus_byte_eq=True
  mean=1.849s  p50=1.838s  p95=1.851s

The full learning loop is replayable bit-identically across N
independent invocations.  Pairs naturally with ADR-0045's 100% exact-
NIAH recall numbers — same epistemic class of guarantee, applied to
the *learning loop* itself rather than only to retrieval.  No LLM
provider can publish equivalent numbers on a learning path.

- benchmarks/teaching_loop.py — `run_teaching_loop_determinism(runs)`
  returns a typed `TeachingLoopBenchReport` with uniqueness counts,
  determinism flag, byte-identical-active-corpus flag, and latency
  distribution (mean / p50 / p95 / total).  Pure-stdlib percentile —
  no numpy dep on this path.
- benchmarks/run_benchmarks.py — `bench_teaching_loop_determinism`
  shim + `_SUITES["teaching-loop"]` registration + runs= passthrough.
- core/cli.py — `--suite teaching-loop` choice added to bench parser.
- tests/test_teaching_loop_bench.py — 5 tests pin determinism at
  small N, proposal_id SHA-256 shape, canonical chain_id layout,
  latency stats well-formedness, JSON serialisation.

Trust boundary: every write is confined to a tempdir created inside
the bench loop; the active corpus is read once at start, once at end,
and any byte difference would fail the bench.
2026-05-18 11:03:48 -07:00
Shay
a71b321a9a feat(adr-0055-0057): learning-loop demo — cold turn to grounded surface, end-to-end
`core demo learning-loop` (+ `--json`) walks a single prompt through the
full ADR-0055..0057 inter-session-memory architecture:

  S1. Cold turn          → universal disclosure, grounding_source=none
  S2. Discovery emission → DiscoveryCandidate to attached sink
  S3. Operator proposal  → real replay-equivalence gate, no regression
  S4. Operator accept    → TRANSIENT corpus only; active untouched
  S5. Same prompt        → teaching-grounded surface with the new chain

Before / after on the deterministic prompt "Why does thought exist?":

  before: [none]     I don't know — insufficient grounding for that yet.
  after:  [teaching] thought — teaching-grounded (cognition_chains_v1):
          cognition.thought; logos.internal. thought reveals meaning
          (cognition.meaning). No session evidence yet.

The active corpus on disk is byte-identical pre/post.  The demo writes
only to a transient corpus, then swaps `_CORPUS_PATH` for the after
turn — the same pattern the replay-equivalence gate uses.

- evals/learning_loop/run_demo.py — `run_demo(emit_json=False)` returns
  a structured `DemoReport` with both surfaces and per-scene detail.
- core/cli.py — `core demo learning-loop` target wired.
- tests/test_learning_loop_demo.py — 7 tests pin: full loop closes,
  before is ungrounded, after contains new chain atoms (thought /
  reveal / meaning), discovery emits ≥1, replay gate reports no
  regression, S4 byte-identical active + 1 line on transient, same
  prompt drives both surfaces.

Lane state: learning-loop-demo 7 new — green.  Demo runs in ~15s
end-to-end (cognition lane runs twice via replay gate).

No LLM provider has a published equivalent of this loop: per-fact
provenance from operator accept to surface, replay-equivalence gate
proving non-regression, byte-identical active state regardless of
outcome, full audit trail back to the originating cold turn.
2026-05-18 10:57:41 -07:00
Shay
6f4b2b7b2c feat(adr-0057): anti-regression demo — three-gate defense against learning harm
`core demo anti-regression` (+ `--json`) is a self-contained walkthrough of
the three independent gates that every reviewed-corpus extension must pass.
Designed for showcasing CORE's epistemic discipline to reviewers / industry
observers — no LLM provider has a published equivalent.

Scenes:
- S1. Eligibility predicate refuses an undetermined-polarity candidate
  before any replay is invoked.  ProposalError raised; no log row.
- S2. Replay-equivalence gate auto-rejects a regressing candidate with
  the named regressed metrics in the operator note.  Uses the documented
  `run_replay=` kwarg of `propose_from_candidate` to inject a controlled
  regression of the same `ReplayEvidence` shape the real gate produces.
- S3. Real `teaching.replay.run_replay_equivalence` runs the cognition
  public lane.  A replay-equivalent candidate reaches 'pending' — operator
  `--accept` is still required to write.

Each scene asserts the active corpus is byte-identical pre/post.

- evals/anti_regression/run_demo.py — `run_demo(emit_json=False)` returns
  a structured `DemoReport`; verbose human output by default, JSON on flag.
- core/cli.py — `core demo anti-regression` target wired alongside
  audit-tour / pack-measurements / long-context-comparison.
- tests/test_anti_regression_demo.py — 5 tests pin each scene's
  load-bearing claim + the corpus-byte-identical invariant.

Lane state: anti-regression-demo 5 new — green.  Demo runs in ~10s end-to-end.
2026-05-18 10:52:23 -07:00
Shay
3cad6686cc feat(adr-0057): operator supersession history view — closes the supersede loop
`core teaching supersessions` (+ `--json`) pairs each retired chain with its
active replacement.  Derived view over `audit_corpus()`; pure, read-only.

- teaching/audit.py — `SupersessionRecord` + `supersession_history(report)`
  returns retired→replacement pairs ordered by retired-line (disk order,
  oldest first).  Orphan supersessions (retired with no live entry carrying
  the matching `superseded_by` — e.g. chained retirements where the middle
  link itself was retired) surface as `replacement=None` so silent corpus
  drift is inspectable.
- core/cli.py — `core teaching supersessions [--json]`.  Exit 1 if any
  orphan is detected (catches silent drift in CI); 0 otherwise.
- tests/test_supersession_history.py — 7 tests pin empty-history,
  single-pair shape, chained-supersession surfaces both pairs, line-no
  ordering, orphan detection, JSON round-trip, no corpus mutation.

Lane state: smoke 67 / cognition 121 / supersession-history 7 new / supersede 13 /
audit 23 — green.  `core eval cognition`: unchanged (intent 100% / surface 100% /
term 91.7% / versor 100%).  Real corpus today reports `(no supersessions)`.
2026-05-18 10:40:38 -07:00
Shay
8d2c84a041 feat(adr-0057): operator supersede CLI — retire active chain by appended replacement
`core teaching supersede <old_chain_id> --subject ... --intent ... --connective ...
--object ... --review-date YYYY-MM-DD` is the second corpus mutation surface
(alongside accept_proposal). No replay gate — it's a deliberate operator action
that replaces a hand-authored or previously discovery-promoted chain.

- teaching/supersede.py — `supersede_chain()` orchestrator with pre-checks
  (review_date format, intent whitelist, pack-consistency via re-audit,
  no double-supersede, no self-supersede, no new-chain-id collision) and
  byte-identical rollback on post-audit failure.
- teaching/proposals.py — extended `append_chain_to_corpus` with optional
  `superseded_by` kwarg; remains the only function in the codebase that
  writes to the active teaching corpus.
- core/cli.py — `core teaching supersede` subcommand wired to the live
  `_CORPUS_PATH`; EPILOG updated with example.
- tests/test_supersede.py — 13 tests pin every gate, byte-identical
  rollback on rejection, append-only at disk level, audit-and-runtime
  parity after supersession, hand_authored provenance with
  `supersede(<old_chain_id>)` tag.

Lane state: smoke 67 / cognition 121 / teaching 17 / supersede 13 / audit 23 /
proposals 16 / contemplation 16 / contemplation-wiring 6 / discovery 24 — green.
`core eval cognition`: intent 100% / surface 100% / term 91.7% / versor 100% — unchanged.
2026-05-18 10:35:49 -07:00
Shay
e03ab4b609 feat(adr-0057): Phase C2 — TeachingChainProposal + replay gate + review CLI
The only path by which CORE extends its own active teaching corpus.
Closes ADR-0055 Phase C alongside ADR-0056's cognitive surface.

Three load-bearing calls (recorded in ADR-0057):
  1. Replay-equivalence is a precondition, not a permission;
     operator --accept remains required.
  2. Eligibility = polarity in {affirms, falsifies} AND at least
     one source='corpus' evidence pointer AND boundary_clean AND
     claim_domain != evaluative (unless --allow-evaluative) AND
     proposed_chain complete.
  3. Append-only proposal log; corpus history append-only too.

Changes
- teaching/proposals.py — TeachingChainProposal, ReplayEvidence,
  ProposalLog (event-sourced replay → current_state), eligibility
  predicate, propose_from_candidate, accept/reject/withdraw,
  append_chain_to_corpus (the sole corpus-write surface).  Uses
  TYPE_CHECKING guards to break the circular import with
  chat.pack_grounding.
- teaching/replay.py — run_replay_equivalence; swaps _corpus_index
  path to a tmp file, runs cognition lane on the active corpus
  AND a transient copy with the proposed chain appended, returns
  regressed-metrics list; trust-boundary assertion that the active
  corpus bytes are byte-identical pre/post.
- teaching/discovery.py — moved chat.pack_grounding /
  chat.teaching_grounding imports inside extract_discovery_candidates
  to break the cycle (was masked when chat.runtime was the entry
  point; surfaced by CLI entry).
- core/cli.py — three new subcommands:
    core teaching propose <candidate-jsonl-path> [--allow-evaluative]
    core teaching proposals [--state pending|accepted|rejected|withdrawn] [--json]
    core teaching review <proposal_id> --accept --review-date YYYY-MM-DD
    core teaching review <proposal_id> --reject [--note ...]
    core teaching review <proposal_id> --withdraw [--note ...]
- tests/test_teaching_proposals.py — 16 tests covering: every
  eligibility gate, proposal_id idempotency, append-only log,
  replay-equivalent stays pending, regression auto-rejects with
  named regressed metrics, --accept appends one line with typed
  Provenance, --accept refused on non-equivalent, state-machine
  blocks double-accept, real replay gate runs cognition lane
  twice and asserts byte-clean active corpus pre/post.

Invariants preserved
- versor_condition(F) < 1e-6 — C2 touches no algebra path.
- Active corpus bytes byte-identical regardless of replay outcome.
- No clock-time reads, no LLM, no async.
- Proposal-only — accept_proposal is the sole corpus-write path.

Lanes: smoke 67 / cognition 121 / runtime 19 / teaching 17 /
new proposals 16.  Cognition eval unchanged.

Open follow-ups (not in scope):
- supersession via operator review action
- cross-pack falsification arbitration (ADR-0056 Call 2 deferred)
- pack-data migration of frame-dependent connectives

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 10:23:14 -07:00
Shay
db6ce08589 feat(adr-0056): wire contemplation into live turn path (opt-in)
ChatRuntime.attach_contemplation(enabled=True) flips an opt-in
flag; when on, each emitted DiscoveryCandidate runs through
teaching.contemplation.contemplate before the sink writes the
JSONL line.  Default off ⇒ Phase B raw output preserved byte-
identical.

Trust boundary
- Contemplation is read-only over pack + corpus.
- Without an attached discovery sink the flag is inert (no hidden
  work — emission requires an observable destination).
- Active teaching corpus on disk byte-identical pre/post.

Lanes: smoke 67 / runtime 19 / cognition 121 / contemplation-
wiring 6 — all green.  Cognition eval unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 10:13:44 -07:00
Shay
f78def7f3a docs(adr-0056): mark Accepted in decisions index
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 10:10:53 -07:00
Shay
4e03a7f872 docs(adr-0056): Accepted (Phase C1 implemented at 4eecf73)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 10:07:27 -07:00
Shay
4eecf73a05 feat(adr-0056): Phase C1 — contemplation loop landed
Implements ADR-0056's cognitive surface: takes a Phase B
DiscoveryCandidate and returns an enriched candidate with composed
polarity, classified claim_domain, evidence pointers, and recursive
sub-questions.  No corpus mutation; no async; no LLM step.

Changes
- teaching/discovery.py: DiscoveryCandidate gains six C1 fields
  with defaults that preserve Phase B JSONL byte-equality.  Adds
  EvidencePointer, SubQuestion, ClaimDomain types.
- teaching/contemplation.py (new): contemplate(candidate) +
  canonical probe order (vault → pack → corpus), deterministic
  decomposition over corpus-known intent objects, composition
  rules from ADR-0056 §Composition, bounded-depth failsafe with
  recursion_overflow audit signal.  Vault probe is injectable;
  None means no vault contribution this pass.
- tests/test_contemplation.py (16 tests): determinism (byte-
  identical JSONL), no input/corpus mutation, empty pack+corpus
  termination with gap-recorded sub-question, factual affirming
  composition, direct same-pack contradiction → falsifies, mixed
  evidence → undetermined + domain upgrade, recursion overflow,
  frame-dependent connective → relational, Phase B byte-equality
  preserved on uncontemplated candidates, sub_id stability,
  evidence pointer admissibility, vault probe injection +
  exception isolation.

Invariants preserved
- versor_condition(F) < 1e-6 — C1 touches no algebra path.
- No corpus / pack / runtime mutation — trust boundary intact.
- No clock-time, no LLM, no stochastic sampling, no async.

Lanes
- smoke 67, cognition 121, runtime 19, teaching 17, contemplation 16.
- core eval cognition: intent 100% / surface 100% /
  term_capture 91.7% / versor 100% — unchanged.

Open questions stay open: frame-dependent connective table
authorship (v1 lives as a small constant in contemplation.py
pending pack-data migration), person-axis intent classification
for auto-evaluative, recursion-overflow telemetry shape, sub-
question deduplication.  None block C1.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 10:06:18 -07:00
Shay
f1121b5822 docs(adr-0056): Contemplation loop C1 — Proposed
Splits ADR-0055 Phase C into:
- C1 (this ADR): cognitive contemplation loop — question
  decomposition + polarity (affirms/falsifies/undetermined) +
  claim_domain typing (factual/relational/evaluative)
- C2 (future ADR): review-and-apply — TeachingChainProposal,
  replay-equivalence gate, corpus append-on-accept

Documents four load-bearing design calls with explicit reasoning
so future sessions can re-derive without re-arguing:

1. Stopping condition: record-the-gap-and-stop primary, bounded
   depth failsafe; failsafe firing emits recursion_overflow audit
   signal — never silent truncation.
2. Falsification evidence: reviewed-only, same pack family;
   session-tier contests but does not falsify. Cross-pack
   arbitration deferred.
3. Order: C1 before C2. Reversed instinct to land 'small thing
   first' — C2 alone is useless without enriched input; C1
   physically cannot mutate corpus until C2 wires the apply path.
4. Sync, not async. CORE hot path is deterministic; concurrency
   overhead exceeds probe cost on local-only probes. Async
   deferred to a future ADR if a blocking probe surface emerges.

Trust boundary: C1 never mutates the corpus. C1 reads pack,
corpus, vault, and most recent TurnEvent; writes only to the
existing Phase B discovery sink. Gap-recorded sub-questions
emit as new top-level candidates on the same sink — recursion
reified into the stream.

Maps directly onto user-stated framing recorded verbatim in the
ADR:
- 'contemplation always starts with a question' → candidate is
  the posing; contemplate() is the answering
- 'truths and/or falsities' → polarity on the chain itself
- 'remain humble' → claim_domain with escalating evidence
  thresholds, mandatory hedge for evaluative
2026-05-18 08:52:43 -07:00
Shay
07d35c0f54 feat(adr-0055): Phase B — DiscoveryCandidate emission from turn loop
Lands the first deterministic trigger of the discovery → reviewed-
memory loop. Candidates are structured evidence; emission is
opt-in via attach_discovery_sink and NEVER mutates the active
teaching corpus.

- teaching/discovery.py: DiscoveryCandidate dataclass + pure
  extract_discovery_candidates(turn_event, intent, subject) rule
  firing. Phase B fires only the would_have_grounded trigger:
    grounding_source == "none"
    AND intent ∈ {CAUSE, VERIFICATION}
    AND subject lemma in ratified cognition pack
    AND (subject, intent) NOT in active corpus
  candidate_id = SHA-256 of canonical JSON payload — replay-stable.
  Other DiscoveryTrigger literals (successful_comparison,
  hedge_acknowledged, oov_resolved_via_decomp) are reserved for
  later phases.

- teaching/discovery_sink.py: DiscoveryCandidateSink protocol,
  DiscoveryBufferSink (in-memory), DiscoveryMonthlyFileSink
  (append-only JSONL, <root>/<YYYY>/<YYYY-MM>.jsonl rollover,
  injectable clock).

- chat/runtime.py: opt-in attach_discovery_sink, post-turn
  emission inside _stub_response only when caller threads
  classified intent forward (gate-fire fall-through site).
  Intent classification at the call site reuses the same
  deterministic classifier already invoked by
  _maybe_pack_grounded_surface for the empty-vault English path.

Trust boundary: candidates write to a separate sink/file path
only; the active corpus on disk is never touched. Tests
explicitly assert corpus bytes are byte-identical before and
after a candidate-emitting turn.

Tests: tests/test_discovery_candidates.py — 24 tests covering
pure-predicate rule firing, every short-circuit path,
deterministic candidate_id, sink opt-in, runtime parity with no
sink, monthly rollover semantics, append-only behaviour, no
corpus mutation.

Lanes: smoke 67, cognition 121, runtime 19, teaching 17, packs 6
— all green. Cognition eval metrics unchanged on dev / public /
holdout splits. versor_condition < 1e-6 invariant untouched.
2026-05-18 08:26:04 -07:00
Shay
7aa77806f9 feat(adr-0055): Phase A — teaching corpus audit, supersession, typed provenance
Lands the three load-bearing pieces of ADR-0055 Phase A so later
phases (DiscoveryCandidate, TeachingChainProposal) have a safe
substrate to write into.

- teaching/audit.py: pure, deterministic re-parse of the reviewed
  corpus with same gates as the runtime loader but keeps drop
  reasons (invalid_json, missing_required_field:*, unsupported_intent,
  pack_missing_subject, pack_missing_object, superseded_by:*).
- teaching/provenance.py: typed Provenance(adr_id, source,
  review_date, raw); legacy "reviewed" maps to "hand_authored" so
  current corpus reports the canonical enum without a file rewrite.
- chat/teaching_grounding._corpus_index honors superseded_by —
  active view drops superseded entries while disk preserves history.
- core teaching audit CLI subcommand (--json optional); exits 1 on
  any drop so CI catches silent corpus shrinkage from pack swaps.

Observable behaviour unchanged: corpus is 10/10 loaded, all five
core lanes green (smoke 67, cognition 121, runtime 19, teaching 17,
packs 6), cognition eval metrics identical on dev / public /
holdout splits. versor_condition < 1e-6 invariant untouched.

Tests: tests/test_teaching_audit.py — 23 tests covering provenance
parser, real-corpus determinism, every drop-reason path,
supersession semantics, runtime/audit parity, read-only contract.
2026-05-18 08:15:23 -07:00