Commit graph

407 commits

Author SHA1 Message Date
Copilot
dedf05565d
feat(frontier): add replay variability suite and token-cost telemetry (#66)
Agent-Logs-Url: https://github.com/AssetOverflow/core/sessions/f88b48fa-0c2a-4f9d-a42b-d275596e43b8

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AssetOverflow <109810776+AssetOverflow@users.noreply.github.com>
2026-05-20 15:04:34 -07:00
Shay
9e6fa4be75
feat(adr-0083): transitive (multi-hop) teaching-grounded surface (#63)
Strict superset of ADR-0062's depth-1 composer.  `max_depth` is the
number of follow-up hops appended beyond the initial chain:

  max_depth=0  → byte-identical to single-chain surface
  max_depth=1  → byte-identical to ADR-0062 composed
  max_depth=2  → byte-identical to ADR-0062 when no second hop
                 survives, strict superset when one does

The composer surfaces content the realizer was silently dropping
from chains already ratified in `cognition_chains_v1`.  Example
live lift on `"Why does light exist?"`:

  composed: "light reveals truth, which grounds knowledge."
  transitive(2): "...which grounds knowledge, which requires evidence."

Cycle-safe at every depth via a single visited-set; single-corpus
traversal in v1 (cross-corpus transitive deferred to a follow-up
ADR alongside ADR-0064's cross-pack model).

Both flags default False — every existing surface is preserved
byte-identically.  When both `composed_surface` and
`transitive_surface` are True, transitive wins.

Implementation:
- `core/config.py`: `transitive_surface: bool = False`,
  `transitive_max_depth: int = 2`.
- `chat/teaching_grounding.py`: `_resolve_followup` shared helper
  refactored out of the depth-1 composer (no behavioural change),
  plus new `teaching_grounded_surface_transitive(subject,
  intent_tag, *, max_depth)`.
- `chat/runtime.py`: dispatch order — transitive > composed > single.

Verification:
- tests/test_transitive_surface.py: 16 new tests covering pure-fn
  contract, visited-set cycle guard at every depth, runtime
  integration, and the cognition-lane null-drop invariant at
  `max_depth=2` (public + holdout splits).
- tests/test_composed_surface.py: 11/11 pass after the helper
  refactor (ADR-0062 behaviour preserved).
- `core test --suite smoke`: 67 pass.
- `core test --suite cognition`: 120 pass, 1 skipped.
- `core test --suite teaching`: 17 pass.
- `core eval cognition`: 100 / 91.7 / 100 / 100 (byte-identical).
2026-05-20 14:11:40 -07:00
Shay
8f1903e8e7
chore(evals): contracts + bench json + Lane B viewer + chart + audit + demo schema (#62)
* chore(evals, cli): contract standardization + bench --json stdout cleanliness

End-of-session shippability pass.  Three concrete fixes:

1. core/cli.py — bench --json no longer pollutes stdout
   Several bench paths call scripts.run_pulse.run_pulse which prints
   verbose [pulse] traces unconditionally to stdout, breaking jq /
   programmatic consumers of --json output.

   New _bench_stdout_guard() redirects stdout → stderr for the
   duration of the bench run when --json is set.  Operator still sees
   the pulse trace (on stderr), but --json consumers get a clean JSON
   document on stdout.  Applied to all four bench paths: cost,
   articulation, default suite, and --suite all.

   Verified: core bench --suite determinism --json now produces
   parseable JSON; human path still shows 1140 [pulse] lines.

2. evals/{frontier_compare,realizer_guard}/contract.md (new)
   core/contemplation/contract.md (new)

   Each new contract follows the established pattern (37 contracts
   already exist under evals/<lane>/contract.md):

     - What it measures
     - Why it matters (structural win)
     - How to run
     - How to read the output
     - Pass criteria table
     - When it has failed and why
     - Runner / module layout

   Coverage:
     - frontier_compare: both Lane A (CORE-only suites) and Lane B
       (cross-provider prompt_battery) with explicit guardrails
       against mixing — operator asks for the wrong lane combination,
       runner exits 2 with helpful error.
     - realizer_guard: C1/C2 articulation safety boundary — synthetic
       illegal candidates rejected directly by check_surface AND
       former-bug runtime prompts now produce legal articulations.
     - contemplation (ADR-0080): not under evals/ since it's runtime
       infrastructure that consumes eval reports — contract lives at
       core/contemplation/contract.md.  Documents the read-only +
       SPECULATIVE-only + deterministic-replay invariants and the
       shared DiscoveryCandidateSink plumbing convergence (ADR-0080).

3. evals/CLAIMS.md — Tier 2 rows added

   - frontier_compare Lane A: determinism.primary_score, max_versor_condition
   - frontier_compare Lane B: prompt_battery.primary_score (CORE adapter),
     cross-provider artifact persistence
   - realizer_guard: all_claims_supported
   - contemplation: SPECULATIVE-only invariant, deterministic replay,
     additive sink path, no pack mutation (all CI-pinned by tests)

Verification
------------
$ core test --suite smoke -q
67 passed in 27.22s    (no regression)

$ uv run pytest -q tests/test_contemplation_loop.py \
    tests/test_contemplation_pipeline_convergence.py \
    tests/test_frontier_compare_cross_provider.py
27 passed in 4.87s

$ core bench --suite determinism --json 2>/dev/null | jq .results[0].passed
true        (was: JSONDecodeError on prior [pulse] pollution)

* feat(evals/ui): report viewer renders Lane B cross-provider + pass-rate chart

Stop-hook caught that #62 only covered contracts — the 929-line
report_viewer.html was never audited against the new cross-provider
report shape from #61.  Two real gaps:

1. Lane-aware observation drawer
   The drawer hardcoded Lane A (CORE-native) fields: surface,
   grounding_source, anchor_lens_mode_label, versor_condition.
   Lane B (cross-provider) observations carry different fields:
   provider, model, elapsed_ms, error_type, error_message.

   Loading a cross-provider report rendered only the surface row
   with empty `grounding` — the provider + model + timing data
   was unreachable without expanding "Show raw JSON".

   Fix: detect Lane B (presence of `obs.provider`) and render the
   appropriate field set.  Lane A still renders identically (now
   also surfaces trace_hash + register_id when present, which were
   silently buried in the raw JSON before).

2. Pass-rate chart per suite
   The summary strip showed one aggregate Primary % across all
   suites, with no way to see WHICH suite is dragging the score.
   Multi-suite runs (e.g. --suite all) had to expand each panel
   individually to find the failing one.

   Fix: new .passrate-chart element below the summary strip,
   one horizontal bar per suite showing passed/total.  All-pass =
   solid green, all-fail = solid red, partial = green/red split
   at the pass fraction.  CSS only — no new dependencies.

3. SUITE_PREAMBLES gains the prompt_battery entry so the sidebar
   shows the "side-by-side surface evidence across providers"
   description when loading a Lane B report.

Verified
--------
- Brace/paren/div balance unchanged (308/308 / 380/380 / 54/54)
- One <script> tag pair preserved
- Generated a real Lane B report via
  `python -m evals.frontier_compare --provider core --suite prompt_battery`
  for visual confirmation

Out of scope (noted for future PR)
----------------------------------
Sampled 3 `core demo` targets:
- register-tour: clean schema (all_claims_supported, claims, grid)
- audit-tour: both scene_1_* keys AND an empty scenes:[] array — inconsistent
- anti-regression: no all_claims_supported key, uses all_gates_held instead

Demo schema standardization deserves its own PR — operator tooling
would benefit from a uniform top-level success field across demos.

* docs(evals) + chore(demos): systematic audit + uniform success field

Stop-hook caught two real gaps after the contract+UI PR:
- demos had divergent success-field names (all_gates_held vs
  learning_loop_closed vs claim_supported vs nested claims_supported)
- no systematic look at the 48 eval directories had been done

Both addressed concretely; remaining work captured in audit doc
rather than vaguely deferred.

1. Demo schema standardization — uniform all_claims_supported field
----------------------------------------------------------------------
All 9 ``core demo`` targets now emit a top-level
``all_claims_supported: bool`` field.  Existing per-demo fields
(``all_gates_held``, ``learning_loop_closed``, ``claim_supported``,
nested ``claims_supported``) are preserved for backwards compat —
the new field is an alias derived from the demo's existing success
signal, not a replacement.

Operator tooling and the CI gate can now target
``all_claims_supported`` without knowing each demo's idiomatic
field name.

Files touched:
- evals/anti_regression/run_demo.py — adds AND of all_gates_held +
  active_corpus_byte_identical
- evals/learning_loop/run_demo.py — adds AND of learning_loop_closed +
  active_corpus_byte_identical
- scripts/publish_pack_measurements.py — adds AND of the three
  entries in the nested claims_supported dict
- evals/long_context_cost/comparison_runner.py — adds alias for
  claim_supported (singular)

The 5 demos already using ``all_claims_supported`` (audit-tour,
register-tour, anchor-lens-tour, orthogonality-tour, articulation)
are unchanged.

Verified across all 9 demos:
  audit-tour              : True
  register-tour           : True
  anchor-lens-tour        : True
  orthogonality-tour      : True
  pack-measurements       : True   ← new alias
  anti-regression         : True   ← new alias
  learning-loop           : True   ← new alias
  articulation            : True
  long-context-comparison : True   ← new alias

2. docs/EVAL_AUDIT_2026-05-20.md — systematic 48-lane audit
------------------------------------------------------------
Replaces the "future PR" deferral with a concrete document.

Contains:
- Method (what was inspected for each lane).
- Summary (40/48 have contract.md; 18/48 have saved results;
  empty results/ ≠ broken — most lanes regenerate on demand).
- Cross-provider relevance triage:
    * 9 lanes are cross-provider-relevant and could benefit
      from the prompt_battery-style adapter pattern (cognition,
      english_fluency_ood, hebrew_fluency, koine_greek_fluency,
      grammatical_coverage, inference_closure, multi_step_reasoning,
      discourse_paragraph, foundational_*_ood, etc.).
    * 29 lanes are CORE-only by design (versor closure, anchor
      lens, identity divergence, provenance, etc.) — wiring
      providers would be category-erroneous.
- Demo schema standardization status (this PR closes that).
- UI/UX coverage matrix.
- 5 concrete follow-up items, each focused enough for a single
  PR, none requiring architectural change.

Regenerated reports
-------------------
evals/long_context_cost/results/comparison_v1.json and
evals/results/phase2_pack_measurements.json now contain the new
all_claims_supported field (auto-regenerated when validating the
schema change).

evals/frontier_compare/results/sample_core_promptbattery.json
added as a reference Lane B report so the new viewer always has
something to load on first open.
2026-05-20 13:53:13 -07:00
Shay
9459f815b0
feat(evals): wire ADR-0082 providers into frontier_compare runner (#61)
#58 shipped providers.py + model_registry.py for cross-provider
benchmarking but never connected them to runner.py — the adapters
sat unused.  This PR wires them through with a clear lane split.

Why a new suite instead of refactoring existing ones
-----------------------------------------------------
The three existing suites (determinism / truth_lock / axis_orthogonality)
pull CORE-only telemetry: trace_hash, versor_condition, register_id,
register_variant_id, anchor_lens_id, register_canonical_surface.
None of those fields can come from OpenAI / Anthropic / Ollama.

Forcing those suites cross-provider would silently produce reports
where the cross-provider rows have empty telemetry — a worse failure
mode than not running them at all.  So the routing is explicit:

  CORE-only suites          → --provider must be 'core'
  Cross-provider suites     → any provider; CORE is one adapter among many

Operator asks for the wrong combo → loud error with the right alternative.

New module: evals/frontier_compare/cross_provider.py
-----------------------------------------------------
- ProviderObservation dataclass — provider-agnostic observation shape
  (prompt, surface, provider, model, elapsed_ms, error fields).  No
  CORE-internal telemetry expected.
- run_prompt_battery(adapter, *, cfg) → SuiteReport reusing existing
  CaseResult / SuiteReport shapes so the report viewer renders both
  lanes without schema branching.
- _PROMPT_BATTERY: 7 fixed cases spanning definition / cause /
  verification / comparison / procedure / unknown intent shapes.
  Stable case_ids so future re-runs against the same provider produce
  diffable JSON.
- Per-case 'passed' is loose by design (non-empty surface, no
  exception).  Cross-provider quality is for human review — not for
  the runner to silently score.

Updated CLI: evals/frontier_compare/__main__.py
-----------------------------------------------
- --provider {core, openai, anthropic, ollama}    (default: core)
- --model <id>                                     (validated via require_model_card)
- --env-file <path>                                (default: ./.env)
- Auto-persist non-CORE runs to
  evals/frontier_compare/results/<provider>_<model>_<utc>.json
  even when --report is omitted.  API calls are rate-limited / paid;
  losing the artifact is costly.
- Existing CORE-native behavior unchanged when --provider not set.

Results directory: evals/frontier_compare/results/
--------------------------------------------------
Created with .gitkeep — matches the convention used by other lanes
(evals/long_context_cost/results/, evals/koine_greek_fluency/results/,
etc.).  Distinct from reports/ which .gitignore excludes for
transient debug output.

Tests: tests/test_frontier_compare_cross_provider.py (9 cases)
--------------------------------------------------------------
- prompt_battery runs with CORE adapter (no API needed)
- adapter exceptions recorded as failed observations, never propagated
- empty surfaces flagged distinctly from adapter errors
- CLI default runs CORE-native (no breaking change)
- CLI prompt_battery with --provider core routes through cross-provider path
- CLI rejects CORE-only suite + non-CORE provider with operator-helpful error
- --help surfaces both suite families
- unregistered model is rejected before any benchmark cycles burn
- ProviderObservation.succeeded handles error / empty / whitespace cases

Live evidence
-------------
$ core test --suite smoke -q
67 passed in 26.55s   (no regression)

$ python -m evals.frontier_compare --provider core --suite prompt_battery --json
model=core-native mode=core suite=prompt_battery passed=True score=1.000
  [definition_truth              ] PASS  Truth is a claim or state grounded by evidence...
  [definition_knowledge          ] PASS  Knowledge is justified understanding grounded...
  [cause_understanding           ] PASS  understanding — teaching-grounded (cognition_chains_v1)...
  [verification_evidence         ] PASS  evidence — teaching-grounded (cognition_chains_v1)...
  [comparison_knowledge_wisdom   ] PASS  knowledge contrasts with wisdom...
  [procedure_recall              ] PASS  To recall means to retrieve a stored state from memory...
  [unknown_term                  ] PASS  I haven't learned 'xylomorphic' yet...

$ python -m evals.frontier_compare --provider openai --suite determinism
error: suite 'determinism' is CORE-only; pass --suite prompt_battery
(the cross-provider suite) when --provider='openai'.

.gitignore: adds frontier_wave1.json (stray report file repeatedly
written by ad-hoc test invocations).
2026-05-20 13:22:37 -07:00
Shay
83c18e4641
fix(cli, tests): wire core contemplation + restore INV-02 allowlist (#60)
Two follow-up fixes from end-of-session verification of recent merges:

1. core/cli.py — wire `core contemplation` subcommand
   PR #55 + #58 added the contemplation CLI at python -m core.contemplation
   but never registered it under the `core` umbrella command, so
   `core --help` didn't show it.  Adds a subparser mirroring the existing
   pattern (chat/test/check/.../doctor) that delegates to the existing
   core.contemplation.__main__:main() — no duplication of arg parsing.

   Surface preserved verbatim: reports (positional, 1+), --lane
   {frontier_compare, contradiction_detection}, --pack-id, --note,
   --report, --sink-root.

2. tests/test_architectural_invariants.py — restore INV-02 allowlist
   PR #57's evals/lab/phi_separation_probe.py imports normalize_to_versor
   for construction-time experimental rotor + embedding work, which
   triggered INV-02's AST-scan failure (the test enforces that
   normalize_to_versor is only called from a small allowed file set).

   evals/lab/ is research-only, never imported by runtime — adding the
   probe to allowed_files doesn't weaken the runtime invariant the
   test enforces.

Verification
------------
$ core test --suite smoke -q
67 passed in 26.63s   (was 66 passed / 1 failed before)

$ core contemplation --help
... shows the new subcommand surface

$ core contemplation evals/contradiction_detection/results/v1_public_*.json \
    --lane contradiction_detection \
    --sink-root /tmp/sink \
    --report /tmp/run.json
... 4 SPECULATIVE findings; sink writes to /tmp/sink/2026/2026-05.jsonl
2026-05-20 13:10:29 -07:00
Shay
db39a5aac7
chore(adr): rename ADR-0081 frontier provider adapters → ADR-0082 (#59)
Resolves a same-day numbering collision: the prior session produced
ADR-0080 + ADR-0081 (geometric stress field, falsified) in
docs/decisions/ while the frontier-provider-adapters work was
authored as ADR-0081 in a newly-created docs/adr/ directory,
unaware of the concurrent track.

This commit takes the minimum-blast-radius fix:
  - docs/adr/ADR-0081-...md → docs/adr/ADR-0082-...md
  - Update title header to ADR-0082, add "Renumbered from" breadcrumb
  - Update the two source-file docstrings that cite the ADR number
    (providers.py, model_registry.py)

The "two ADR directories" question (docs/adr/ vs docs/decisions/)
is NOT resolved here — docs/adr/ now has exactly one entry, while
docs/decisions/ is the canonical location per CLAUDE.md.  A future
PR should either consolidate or document the split; this commit
just unblocks the immediate naming collision.

Out of scope:
  - Consolidating directories
  - Renumbering anything in docs/decisions/
  - Re-numbering on the dev's local main (already pulled into this branch)
2026-05-20 12:46:13 -07:00
Shay
36904369ee feat(evals): ADR-0081 frontier provider adapters — .env.example, providers, model registry 2026-05-20 12:35:34 -07:00
Shay
5c04123d3f
research(evals): phi separation probe for ADR-0081 follow-up (#57)
* research(evals): phi separation probe for ADR-0081 follow-up

Lab artifact at evals/lab/phi_separation_probe.py.  Tests whether a
candidate embedding

    phi : Proposition -> Cl(4,1)

produces a contemplation differential

    Delta(chain) = ||sandwich(R_connective, phi(subject)) - phi(object)||

that separates known-compatible chains from synthesized
known-contradicting twins.

Why this exists
---------------
A "Topological Stress Field" miner (read-only Rust kernel sweeping
the vault footprint and emitting SPECULATIVE findings from high-Delta
regions) was discussed as a successor to #55.  That miner can only
earn its Rust cycles if Delta actually correlates with semantic
contradiction.  Until phi is empirically validated, ||Delta|| is a
hash, not a signal.

This probe is the falsification harness for phi.  Promotion criterion
encoded in the run output: ``auc >= 0.80`` on the pair set below
before any geometric stress miner is built.

Method
------
- 21 real chains pulled from teaching/cognition_chains/cognition_chains_v1.jsonl.
- Contradicting twins synthesized via 8 connective-antonym pairs
  (requires<->rejects, reveals<->obscures, grounds<->undermines,
  supports<->contradicts, enables<->prevents, confirms<->refutes,
  informs<->misleads, verifies<->falsifies).
- Two phi candidates: phi.v1.summed_domains (grade-mixed sum of
  CGA point embeddings of the lemma's semantic_domains) and
  phi.v2.centroid_point (centroid of domain hash points embedded
  once, staying on the CGA null cone).
- Two distance metrics: principled CGA point-distance and Frobenius.

Result (v1)
-----------
All four (phi, metric) combinations land at AUC ~ 0.5 (chance).
Distributions for compatible vs contradicting overlap completely
(mean diff <= 0.04).  Hash-derived phi does NOT encode contradiction
under any tested metric.

This is the right kind of failure: it tells us the geometric stress
miner has no signal to consume yet, and validates the decision to
not build it speculatively.

Two side findings worth pinning
-------------------------------
1. algebra.versor.versor_apply projects non-null inputs back onto the
   unit-versor manifold (runtime field-state closure), collapsing
   sum-of-multivectors phi outputs to scalar identity.  The probe
   uses raw R*F*reverse(R) directly.  Any future geometric kernel
   needs a raw sandwich primitive distinct from runtime versor_apply.

2. For two CGA null vectors X, Y the correct distance is
   d = sqrt(-2 * <X, Y>), not sqrt(-2 * <X-Y, X-Y>).  The latter
   evaluates to a negative number that f32 numerics silently clamp
   to zero.  First version of the probe returned identically-zero
   distances because of this.

Boundary
--------
- Lives in evals/lab/ (research-only, never imported by runtime).
- No new package surface; no Rust code; no pack/vault writes.
- No tests required (lab convention); the promotion criterion in
  the run output is the falsification gate.

* research(evals): add IDF-weighted phi variants (v3, v4)

Adds two more phi candidates to the separation probe:

  - phi.v3.idf_weighted  — sum of CGA embeddings, weighted per
    semantic_domain by smoothed IDF across the pack.  Same shape as
    v1 (grade-mixed) but rare domains get larger weight than common
    ones like ``logos.core`` that appear in most cognition lemmas.
  - phi.v4.idf_centroid  — null-cone sibling of v3.  IDF-weighted
    centroid in R^3, embedded once.

Hypothesis tested: v1's null result was "common-domain noise drowning
out the distinguishing axes."

Result
------
All four (phi, metric) combinations still at AUC ~ 0.5:

  phi.v1.summed_domains   cga       AUC=0.481  frob  AUC=0.451
  phi.v2.centroid_point   cga       AUC=0.490  frob  AUC=0.492
  phi.v3.idf_weighted     cga       AUC=0.481  frob  AUC=0.449
  phi.v4.idf_centroid     cga       AUC=0.497  frob  AUC=0.501

IDF reweighting does not separate compatible from contradicting.

Diagnostic refinement
---------------------
v4 shows compat mean (0.559) < contra mean (0.572) — directionally
correct (contradictions land farther) but the effect is dwarfed by
the within-group std (~0.24).  This is a hint, not signal.

What this *does* tell us: the lemma encoding is not the load-bearing
variable.  The bottleneck is the **connective rotor**.  Antonym pairs
should produce rotors that send vectors in opposite directions, but
hash-derived R(requires) and R(rejects) are statistically
independent — there is no encoded relationship between a connective
and its antonym in the current scheme.

Next phi candidate worth trying: encode connectives as rotors derived
from a learned or curated antonym structure (e.g., R(antonym) =
reverse(R(original))), so the antonym structure is GEOMETRICALLY
guaranteed instead of coincidentally absent.  Until something on the
rotor axis carries structural signal, varying only the lemma
encoding is rearranging deck chairs.

* research(evals): antonym-rotor oracle variants (v5, v6)

Adds two upper-bound probes that hardcode the antonym structure
into rotor space:

  R(antonym) := reverse(R(canonical))

so the antonym relationship is geometrically guaranteed instead
of coincidentally absent.  This is NOT a phi proposal — it is an
oracle probe.  What it measures: "if antonym relations *were*
perfectly encoded geometrically, would the rest of the encoding
separate the two groups?"

Variants:
  - phi.v5.centroid_antonym_oracle      — v2 lemmas + antonym oracle
  - phi.v6.idf_centroid_antonym_oracle  — v4 lemmas + antonym oracle

Result
------
Both still at chance:

  v5  cga  AUC=0.503    frob  AUC=0.503
  v6  cga  AUC=0.526    frob  AUC=0.517

v6 shows a slight directional effect — contradicting mean (0.575)
slightly above compatible mean (0.559) — but the gap is dwarfed by
within-group std (~0.20).

Diagnostic (the deeper finding)
-------------------------------
Even with the antonym oracle, the lemma encoding cannot see
contradiction.  The reason: for the rotor sandwich to place
phi(subject) NEAR phi(object) on compatible chains, the rotor must
encode the specific subject->object relationship — not just "a
rotation."  Hash-derived rotors send phi(subject) to a random
point, so compatible chains have large Delta and contradicting
twins also have large Delta.  We never recover the "compatible is
small" half of the separation.

Implication: the lemma encoding itself must carry relational
structure (positions in phi space such that a small canonical set
of rotations consistently take subjects to their related objects),
or the encoding must be jointly learned with the connective rotors
against a coherence loss.  Either way, hash-derived phi cannot work
in principle — not just in this implementation.

This quantitatively validates ADR-0081's thesis that phi is the
critical-path research blocker.  It is not a tuning problem.

Refactor:
  - delta_cga / delta_frobenius now take both phi_l and phi_c so
    new variants can vary the connective encoder independently.
  - _PHI_VARIANTS is now (name, phi_l, phi_c) triples.

* research(evals): corpus-graph aware phi variants (v7, v8)

Adds two structural-only graph-aware phi candidates:

  phi.v7.corpus_graph                — corpus neighborhood centroid
  phi.v8.corpus_graph_antonym_oracle — v7 lemmas + antonym oracle rotors

For each lemma, embed the centroid (in R^3) of hash points derived
from its graph neighborhood in the reviewed teaching corpus:

  out_signature = "OUT:" + connective + "/" + object_lemma
  in_signature  = "IN:"  + subject_lemma + "/" + connective

Lemmas with similar neighborhoods (same connectives used toward the
same kinds of partners) land near each other in R^3.

CAVEAT: structural only.  This does NOT fit lemma positions to
satisfy R_c * phi(s) ~ phi(o) along the corpus relations.  A joint
fit (TransE-style) would require a training loop, train/test split,
and convergence criteria — outside the single-file lab probe shape.

Result
------
  v7  cga  AUC=0.451  frob  AUC=0.474
  v8  cga  AUC=0.444  frob  AUC=0.458

Both lower than chance — contradicting twins land *closer* on average
than compatible ones, but within 1 std (~0.29), so it is noise, not
signal.  The structural opposite of what would pass.

Closure on closed-form phi
--------------------------
The probe has now systematically falsified every closed-form phi
candidate available without training:

  v1-v2: hash-derived domain encodings           — chance
  v3-v4: IDF-weighted domain encodings           — chance
  v5-v6: above + antonym oracle on connectives   — chance
  v7-v8: corpus-graph neighborhood encoding      — chance (anti)

No reweighting of domains, no oracle on connectives, no graph-aware
neighborhood centroid is enough.  This is consistent across 8
variants and 4 (lemma, connective) encoding combinations.

Remaining options
-----------------
1. Trained phi (TransE/RotatE-style): fit lemma + connective
   embeddings jointly against a corpus coherence loss.  Tiny
   corpus (21 chains) means heavy overfitting risk; need
   leave-one-out cross-validation to report honestly.  Real
   infrastructure, not a probe.

2. Larger labelled corpus: 21 chains is too few to discriminate
   "encoding cannot work" from "encoding cannot work *on this
   data*."  Expanding the teaching corpus would let the probe
   distinguish those.

3. Park geometric contemplation.  The falsification stands; the
   ADR-0080 contemplation loop remains the operational read-only
   doctrine.  Geometric stress mining waits until a forcing
   function appears.

Recommendation: option 3.  This probe has earned its keep — it
quantitatively validated ADR-0081's "phi is the load-bearing
research blocker" thesis across the full closed-form design space.
2026-05-20 12:34:59 -07:00
Shay
1573064349
refactor(contemplation): converge to shared discovery-sink plumbing (#58)
Connects ADR-0080's read-only contemplation loop to the existing
teaching-pipeline plumbing without forcing a type collapse.  The
SPECULATIVE-only invariant from #55 is preserved verbatim; what
changes is *where the findings flow*.

What was wrong with the prior shape
-----------------------------------
PR #55 shipped a parallel core/contemplation/ package whose findings
were written as one JSON blob per CLI invocation, with no consumer.
The SPECULATIVE-only invariant protected a write path that didn't
exist.  My closed PR #56 (second miner) would have entrenched the
duplication.

What this PR changes
--------------------
1. Schema (core/contemplation/schema.py)
   - Adds a BOUNDARY note documenting why EvidencePointer (teaching)
     and ContemplationEvidenceRef (core) intentionally stay separate:
     EvidencePointer.source is constrained to {corpus, pack,
     vault_coherent} — pointers into reviewed in-process memory the
     runtime trusts.  ContemplationEvidenceRef points to external
     report files that have NOT been reviewed.  Converging them would
     either widen the runtime-grounding enum (losing the "reviewed
     memory only" guarantee) or force benchmark reports to masquerade
     as vault_coherent.  Both are worse than keeping them separate.
   - Adds format_contemplation_finding_jsonl(finding) — the canonical
     JSONL formatter mirroring teaching.discovery.format_candidate_jsonl.

2. Runner (core/contemplation/runner.py)
   - Both runners gain an optional sink: DiscoveryCandidateSink | None
     parameter.  When supplied, each finding is emitted as one
     canonical JSONL line via the SHARED protocol — same protocol
     that backs DiscoveryBufferSink and DiscoveryMonthlyFileSink.
   - Sink path is additive: the ContemplationRun blob is byte-identical
     whether or not a sink is supplied (pinned by test).
   - No sink supplied → existing in-memory behavior preserved exactly.

3. CLI (core/contemplation/__main__.py)
   - Adds --lane {frontier_compare, contradiction_detection} flag.
     Default unchanged.
   - Adds --sink-root <path> flag.  When set, instantiates a
     DiscoveryMonthlyFileSink and findings land at
     <root>/<YYYY>/<YYYY-MM>.jsonl — the SAME layout discovery
     candidates use, so operators can grep one stream.

4. Miner (core/contemplation/miners/contradiction_detection.py)
   - Restored from closed PR #56 under the unified pipeline.
   - Failure-mode split preserved (missed_contradiction /
     false_contradiction_flag) with asymmetric repair actions.

What this PR does NOT do
------------------------
- Does NOT unify ContemplationFinding with DiscoveryCandidate.
  DiscoveryCandidate.trigger is Literal[would_have_grounded,
  successful_comparison, hedge_acknowledged, oov_resolved_via_decomp]
  — all turn-loop flavored.  None describe "I parsed a benchmark
  report."  Forcing a 5th trigger that no turn-loop extractor
  produces would pollute the turn-loop type for the schema's sake.
- Does NOT extend teaching/gaps.py.  Gap aggregates DiscoveryCandidate
  cells by (subject, intent) — domain nouns.  ContemplationFinding
  subjects are namespaced ("contradiction_detection/CON-PUB-002").
  Different operator views.  A sibling aggregator can come later
  when an operator actually asks for it.

Why this is the right unification point
---------------------------------------
The honest convergence is at the *sink* (so all SPECULATIVE evidence
lives in one rooted append-only stream), not the *aggregator* (which
appropriately produces typed views per evidence family).  The boundary
doctrine from #55 is preserved; it now connects to existing plumbing
instead of writing JSON to disk with no consumer.

Tests (tests/test_contemplation_pipeline_convergence.py, 10 cases)
------------------------------------------------------------------
- DiscoveryBufferSink satisfies DiscoveryCandidateSink (shared protocol)
- frontier runner emits findings to shared sink
- contradiction runner emits findings to shared sink
- sink is optional — no-op when absent
- emission is canonical JSONL (sorted keys, no newline, deterministic)
- DiscoveryMonthlyFileSink persists findings at <root>/<YYYY>/<YYYY-MM>.jsonl
- sink emission does not alter the ContemplationRun blob (additive)
- contradiction miner predicate split + repair-action asymmetry
- config_hash differs between lanes (replay can distinguish)
- BOUNDARY doc is present in schema.py (regression guard)
- ContemplationEvidenceRef field invariants
- format_contemplation_finding_jsonl is deterministic + canonical

All 18 tests pass (5 original ADR-0080 + 13 new convergence).

Live evidence
-------------
$ uv run python -m core.contemplation \
    evals/contradiction_detection/results/v1_public_*.json \
    --lane contradiction_detection \
    --sink-root /tmp/sink_demo

  /tmp/sink_demo/2026/2026-05.jsonl  ← same layout as discovery candidates

  predicate=missed_contradiction         subject=contradiction_detection/CON-PUB-002
  predicate=missed_contradiction         subject=contradiction_detection/CON-PUB-004
  predicate=false_contradiction_flag     subject=contradiction_detection/CON-PUB-005
  predicate=false_contradiction_flag     subject=contradiction_detection/CON-PUB-006
2026-05-20 12:32:53 -07:00
Shay
c2c1cb94e9 feat(ui): redesign frontier compare viewer — tabs, preamble, case drawer 2026-05-20 12:24:58 -07:00
Shay
06bbac86e1
feat(contemplation): ADR-0080 read-only speculative loop (#55)
* docs(adr): ADR-0080 contemplation loop boundary

* feat(contemplation): add read-only contemplation package

* feat(contemplation): add immutable speculative finding schema

* feat(contemplation): add deterministic substrate snapshot

* feat(contemplation): add frontier report miner package

* feat(contemplation): mine frontier compare failures as speculative findings

* feat(contemplation): add read-only contemplation runner

* feat(contemplation): add read-only contemplation CLI

* test(contemplation): prove read-only speculative loop invariants
2026-05-20 11:40:12 -07:00
Shay
6761fc0974 feat(realizer): C1.5 — articulation legality at the realizer boundary
Adds a typed legality check that catches a narrow class of incoherent
finite-predicate surfaces before they ship.  Scope is deliberately
narrow:

  - generate/articulation_legality.py:
    - SlotKind enum {VERB, NON_VERB, UNKNOWN}
    - ArticulationLegality enum {LEGAL, ILLEGAL_NON_VERB_FINITE_PREDICATE}
    - classify_predicate_slot_kind() — token allowlists for known verbs
      and known non-verb nouns
    - validate_finite_predicate_legality() — fails on negated +
      NON_VERB; fail-open on UNKNOWN to preserve canary behavior

  - generate/templates.py:
    - _inflect_predicate: copular-aware negation
      ("is X" -> "is not X" instead of the default "does not be X")
    - render_step: invokes the legality validator; returns
      "I cannot realize that proposition coherently yet." when an
      illegal shape is detected

The check is upstream of register / anchor-lens transforms (presentation
+ substantive axes both downstream of the realizer); no interaction
with R6 / ADR-0073 layering.

Tests pin:
  - NON_VERB + negated -> ILLEGAL_NON_VERB_FINITE_PREDICATE
  - UNKNOWN + negated -> LEGAL (fail-open preserved)
  - render_step returns the disclosure string when illegal detected
  - render_step still produces the fall-through surface on UNKNOWN

Validation:
  - Cognition eval byte-identical (100/100/91.7/100)
  - 370 realizer / lens / register / pack / lane tests pass
  - anchor-lens-tour + register-tour both green
2026-05-20 11:11:28 -07:00
Shay
6387872051 feat(packs): en_collapse_anchors_v1 — activate chesed/shalom/tzedek lenses on EN input
ADR-0073c shipped he_chesed_v1, he_shalom_v1, he_tzedek_v1 with lossy
EN-collapse alignment edges (he-021 → en-collapse-love @ 0.63, etc.)
but the synthetic en-collapse-* targets didn't exist in any mounted
lexicon.  Result: the three lenses ratified but stayed dormant — the
runtime OOV gate fired on "What is love?" / "What is peace?" /
"What is justice?" before the lens engagement path got a chance.

This commit adds a minimal pack whose lexicon carries exactly those
three synthetic anchors:

  en-collapse-love     lemma="love"     domain=collapse_anchor.love
  en-collapse-peace    lemma="peace"    domain=collapse_anchor.peace
  en-collapse-justice  lemma="justice"  domain=collapse_anchor.justice

Mounted last in DEFAULT_RESOLVABLE_PACK_IDS — cognition / relations
packs win first-match on any future collision.  No real content pack
currently carries these lemmas (grep-confirmed) so the mount adds no
collision risk.

The pack-grounded surface for "What is love?" advertises its nature
honestly via the pack id (en_collapse_anchors_v1) and the domain
string (collapse_anchor.love) — the surface is intentionally minimal;
the substantive content arrives via the lens annotation
[lens(he_chesed_v1):covenant-love] / [lens(he_shalom_v1):wholeness-peace] /
[lens(he_tzedek_v1):right-order].

chat/pack_grounding.py:_en_lemma_to_entry_id() now reads both
en_core_cognition_v1 and en_collapse_anchors_v1, with cognition
winning on lemma collision.

New test file tests/test_en_collapse_anchors_v1_pack.py pins:
  - each anchor lemma resolves to its synthetic entry_id
  - collapse pack mounted last (precedence guarantee)
  - each of the three lenses engages on its target English prompt
  - baseline surface (no lens) still advertises anchor nature

Validation:
  - Cognition eval byte-identical (100/100/91.7/100)
  - 160 lens/pack/resolver tests pass + 8 new
  - anchor-lens-tour green
  - register-tour green
2026-05-20 10:58:07 -07:00
Shay
15dc68c949 feat(alignment): wire grc-008 → en-008 (σοφία → wisdom) for grc_sophia_v1
grc_sophia_v1 was ratified in PR #48 but stayed dormant on English
prompts because the alignment graph carried only the grc→he edge for
sophia (grc-008 → he-008, weight 0.88).  Adding the symmetric en edge
activates lens engagement on 'What is wisdom?'-shaped prompts via the
same pattern used for logos / aletheia / zoe / arche.

  grc-core-cog-008 → en-core-cog-008  (σοφία → wisdom)
  relation: cross_lang.logos.sophia.en  weight: 0.88

Cognition eval byte-identical (100/100/91.7/100).
102/102 anchor-lens tests pass.
anchor-lens-tour + register-tour green.
2026-05-20 10:45:09 -07:00
Shay
0fe907a700 chore(packs): re-seal register packs (ISSUED_AT bump + missing seals)
Round-2 (PR #48) bumped ISSUED_AT in scripts/ratify_register_packs.py
from 2026-05-19 → 2026-05-20 but didn't re-seal existing packs; also
shipped formal_v1 and socratic_v1 with empty mastery_report_sha256 (no
companion .mastery_report.json on disk).

This commit:
- Re-seals all 7 register packs against current ISSUED_AT.
- Adds companion seal files for formal_v1 + socratic_v1 (now ratified).
- Patches both ratify scripts to use ensure_ascii=False when writing
  pack/report files to disk — previous default mangled literal em-dashes
  to — escapes every time the script ran, producing churn.
  Canonical hash form unchanged (still ensure_ascii=True for stability).

Cognition eval byte-identical (100/100/91.7/100).
Register tour green (R5 + R6 invariants hold).
2026-05-20 07:39:38 -07:00
Shay
15d34bd2ca
feat(packs): round-4 — he_chesed_v1, he_shalom_v1, he_tzedek_v1 + lossy EN-collapse alignment edges (#54)
Design decision: option (b) — symmetric lossy-collapse pattern.

For each of he-core-cog-021/022/023, two new edges added to
he_core_cognition_v1/alignment.jsonl:

  1. *.en_collapse edge to a synthetic en-collapse-* anchor (weight ~0.62–0.65)
     mirrors the grc-core-cog-021/022 precedent for episteme/synesis.
     Relation format: cross_lang.<lemma>.en_collapse
     Target format: en-collapse-<lemma>  (synthetic, no lexicon entry needed)
     Evidence: adr-0073c:<lemma>_lossy_english_engagement

  2. cross_lang.no_english_collapse edge (weight 0.0) already present —
     RETAINED. Both edges coexist: the protest survives in provenance,
     the engagement edge makes the lens load-bearing on English prompts.

Weight rationale:
  chesed → en-collapse-love: 0.63
    (agape/love pairing already at 0.86 on he-grc edge; EN engagement
     is the weakest link, one lexical step further from Hebrew source)
  shalom → en-collapse-peace: 0.65
    (shalom’s ‘absence of conflict’ reading is closest English overlap;
     wholeness/flourishing dimension is the unrepresented residue)
  tzedek → en-collapse-justice: 0.62
    (justice is the EN collapse — righteousness is the other half;
     ADR-0073a documents the English split explicitly)

New packs:
  he_chesed_v1: logos.chesed.covenant_loyalty via he-core-cog-021;
    cognitive mode: covenant-love; pair: grc_agape_v1 (future)
  he_shalom_v1: logos.shalom.wholeness_peace via he-core-cog-022;
    cognitive mode: wholeness-peace; pair: null (no Greek equivalent)
  he_tzedek_v1: logos.tzedek.right_order via he-core-cog-023;
    cognitive mode: right-order; pair: null (no Greek equivalent)

ratify_anchor_lens_packs.py: LENS_IDS extended with all three.
ISSUED_AT unchanged (same session as round-3).
2026-05-20 07:26:54 -07:00
Shay
4b4fa0341e
feat(packs): round-3 — relations-v3 checksum, grc_synesis_v1, he_emet_v1, he_chokmah_v1 (#53)
Fix 1 — en_core_relations_v3 manifest checksum (unblocks #48)
  Computed sha256(lexicon.jsonl) = c22185011cdff...
  Replaces OPERATOR_MUST_RECOMPUTE placeholder; pack now loads cleanly.

Fix 2 — he_core_cognition_v1 lexicon: emet firmness split (ADR-0073c)
  he-core-cog-002 (אמת) gains logos.emet.firmness + meaning.faithfulness in
  semantic_domains; provenance annotated adr-0073c:emet_firmness_split:2026-05-20.
  Prior atom logos.aletheia.verity retained — entry carries both (cross-lang
  collapse documented). Manifest checksum refreshed: 7b5f5ed5796c761ed...

New packs — grc_synesis_v1
  Closes Greek knowledge quad: episteme/epignosis/sophia/synesis.
  Atom logos.synesis.insight via grc-core-cog-022 (weight 0.85, ADR-0073c).
  Cognitive mode: integrative-comprehension. No EN-collapse edge — synesis
  has no single English equivalent (insight/understanding both partial).
  ratify_anchor_lens_packs.py: grc_synesis_v1 added to LENS_IDS.

New packs — he_emet_v1 + he_chokmah_v1
  he_emet_v1: now pivots on logos.emet.firmness (not logos.aletheia.verity).
    Distinct from grc_aletheia_v1's unconcealment axis. Cognitive mode:
    truth-as-faithfulness. Source: he-core-cog-002 post-split.
  he_chokmah_v1: logos.sophia.wisdom via he-core-cog-008 (weight 0.92,
    direct pair to grc_sophia_v1). Cognitive mode: wisdom-practical.
    pair_lens_id: grc_sophia_v1 (symmetric). Highest-weight Hebrew→Greek
    cross-lang edge in the corpus.
  ratify_anchor_lens_packs.py: both lens ids added to LENS_IDS.

Held: he_chesed_v1 / he_shalom_v1 / he_tzedek_v1 — pending design decision
  on dormant-lens policy (options a/b/c documented in PR description).
2026-05-20 07:22:45 -07:00
Shay
3065ad9e19
feat(packs): expansion round 2 — ethics ×3, anchor-lens ×3, relations-v3, register ×2 (#48)
* feat(packs): ethics ×3, anchor-lens ×3, relations-v3, register ×2

Group 1 — Ethics domain packs (ADR-0044 sibling)
  legal_ethics_v1: 6 commitments covering no-legal-advice, no-outcome-prediction,
    jurisdiction-disclosure, privilege-disclosure, conflict-disclosure, refer-to-counsel
  engineering_ethics_v1: 6 commitments covering safety-primacy, standard-disclosure,
    no-sign-off, uncertainty-surface, public-welfare-priority, refer-to-pe
  research_ethics_v1: 6 commitments covering no-fabrication, no-plagiarism,
    irb-disclosure, conflict-of-interest-disclosure, data-integrity, reproducibility-hedge
  ratify_ethics_pack.py: PACK_IDS extended with all three new ids

Group 2 — Anchor lens packs (grc cognition atoms, ADR-0073c)
  grc_sophia_v1: atom logos.sophia.wisdom via grc-core-cog-008 (cross_lang.logos.sophia
    edge weight 0.88); cognitive mode wisdom-practical
  grc_epignosis_v1: atom logos.epignosis.experiential via grc-core-cog-007 (weight 0.78,
    en_collapse edge documented); cognitive mode experiential-knowledge
  grc_episteme_v1: atom logos.episteme.systematic via grc-core-cog-021 (weight 0.72,
    en_collapse edge documented); cognitive mode systematic-knowledge
  ratify_anchor_lens_packs.py: LENS_IDS extended with all three new ids

Group 3 — en_core_relations_v3 (social + part-whole extension of v2 kinship)
  7 new lemmas: colleague, mentor, neighbor, component, member, instance, peer
  manifest.json: new pack with checksum placeholder (operator must recompute after
    ratify run — same pattern as other packs)

Group 4 — Register packs formal_v1 + socratic_v1
  formal_v1: standard depth, drop_provenance_tag=true + drop_articles=true;
    no markers; ratifies under known_key_overrides_invariant_grounding
  socratic_v1: pedagogical depth, append_semantic_domain_clause=true; markers scaffold
    question-and-response rhythm (openings×4, transitions×3, closings×4)
  ratify_register_packs.py: REGISTER_IDS extended with formal_v1, socratic_v1

* fix(anchor_lens): loader v1/v2 dual-schema compat — resolves blocker 1 of #48

Refactor AnchorLens to use v2 schema fields and normalize legacy fields. Update validation and loading functions for improved clarity and functionality.

* fix(ratify): restore default_unanchored_v1 + full LENS_IDS (17) — resolves blocker 2 of #48

Added new lens IDs for the he substrate and updated the order of lens IDs.

* chore(packs): migrate 8 legacy anchor-lens packs to v2 schema [1/8 default_unanchored_v1]

Updated the default unanchored lens JSON structure with new fields and modified descriptions.

* chore(packs): migrate grc_logos_v1 to v2 schema [2/8]

Updated the description and added new fields for cognitive mode, atom, and source entry ID.

* chore(packs): migrate grc_aletheia_v1 to v2 schema [3/8]

Updated the description and added new fields related to cognitive mode and atom.

* chore(packs): migrate grc_zoe_v1 to v2 schema [4/8]

Updated the description and added new fields for cognitive mode, atom, and source entry ID.

* chore(packs): migrate grc_arche_v1 to v2 schema [5/8]

Updated the description and added new fields for cognitive mode, atom, and source entry ID.

* chore(packs): migrate he_logos_v1 to v2 schema [6/8]

Updated the Hebrew-substrate anchor lens JSON structure with new fields and modified descriptions.

* chore(packs): migrate he_dabar_v1 to v2 schema [7/8]

Updated the description and added new fields for cognitive mode and source entry.

* chore(packs): migrate he_chayyim_v1 to v2 schema [8/8] — resolves blocker 3 of #48

Updated the description and added new fields for cognitive mode and source entry ID.

* fix(anchor-lens): complete v1→v2 migration + back-compat shims

Resolves blockers B4/B5/B6/B7 left by the initial round-2 schema rewrite:

  B4: restore UNANCHORED module constant, is_null_lens() alias,
      and verify_anchor_lens_seal() (all were dropped from loader.py;
      chat/pack_grounding.py and several tests still imported them).
      AnchorLens.unanchored() returns the in-memory sentinel with
      lens_id='__unanchored__' as before (distinct from disk pack).

  B5: add v1 attribute properties on AnchorLens (primary_substrate,
      semantic_domain_preferences, cognitive_mode_label) so consumers
      not yet on v2 (chat/pack_grounding.py engagement reads, several
      tests) continue to work via read-only views over the canonical
      v2 fields. Zero changes needed to chat/pack_grounding.py.

  B6: re-derive source_entry_id by atom-in-lexicon lookup for 6 of 8
      legacy packs that were positionally mis-mapped during migration.

  B7: fix two new-pack atoms that didn't exist in the lexicon
      (logos.episteme.systematic -> logos.episteme.systematic_knowledge,
      logos.epignosis.experiential -> logos.epignosis.knowledge).

Loader hardening (recovered from v1 rewrite):
  - _validate_lens_id_for_fs: reject path-traversal / slash / empty
  - companion-SHA mismatch check in load_anchor_lens when require_ratified
  - atom must be non-empty when substrate != 'none'
  - available_anchor_lens_packs returns summary dicts (was list[str])

Ratify script special-cases substrate='none' so the null sentinel
default_unanchored_v1 keeps its self-seal (ADR-0073b invariant).

Test suite migrated to v2 schema: dropped obsolete list-shape gates
(duplicates, too-many-preferences — v2 has scalar atom), updated error
match strings, added a v1->v2 normalisation back-compat test.

All 11 round-2 packs ratified.  102/102 anchor-lens tests pass.
Cognition eval byte-identical (100/100/91.7/100).
anchor-lens-tour + register-tour both green.
2026-05-20 07:18:35 -07:00
Shay
9e791045eb docs(adr): ADR-0078 status Proposed → Ratified
Phase 1 telemetry shipped in 8e96728; bump the ADR status header to
match reality.
2026-05-20 06:30:48 -07:00
Shay
e550c4a240
docs(adr): ADR-0078 composer graph atom equivalence (#50) 2026-05-20 06:30:09 -07:00
Shay
e64ec578eb
feat(evals): frontier comparison benchmark wave 1 (#52)
* feat(evals): add frontier comparison benchmark wave one scaffold

* feat(evals): add frontier comparison runner package

* feat(evals): implement frontier comparison wave one suites

* feat(evals): add frontier comparison CLI entrypoint

* feat(evals): add static frontier benchmark report viewer

* test(evals): cover frontier comparison wave one benchmarks

* fix(evals): record runtime observation failures instead of aborting suites

* docs(evals): document frontier comparison recording UI
2026-05-20 06:27:32 -07:00
Shay
8e96728009 feat(telemetry): ADR-0078 Phase 1 — composer/graph atom equivalence (observational)
Wires observational telemetry on the composer-vs-graph atom-set
relationship.  Phase 1 is strictly observational: no enforcement,
no surface mutation, no grounding-source change, no trace-hash impact.

New telemetry fields on TurnEvent + ChatResponse:
  composer_graph_atom_status         ∈ {equivalent, divergent,
                                         graph_unconstrained,
                                         composer_no_atoms,
                                         not_applicable, ""}
  composer_atom_set_hash             SHA-256 over sorted unique atoms
  graph_atom_set_hash                SHA-256 over sorted unique atoms
  composer_graph_atom_overlap_count  int

Composer atoms come from existing pack candidate metadata
(pack_semantic_domains channel through _maybe_pack_grounded_surface).
Graph atoms come from build_graph_from_input + resolve_lemma on
node.subject/predicate/obj — no prose parsing.  When a grounded
composer path lacks explicit atom provenance, status is
'composer_no_atoms'.

New pure helper:
  chat/atom_equivalence.py — normalize_atoms, hash_atoms,
  atoms_for_graph_nodes, compare_atom_sets

Tests (tests/test_composer_graph_atom_equivalence.py):
  - Pack DEFINITION path produces observable equivalence
  - Divergent atom sets produce distinct hashes
  - Register invariance: atom hashes + status identical across
    {neutral, terse, convivial}; trace_hash also constant (R5 axis)
  - Anchor lens engaged case still ASCII-only on surface
  - No prose-parsing helper symbols introduced in runtime.py
    (extract_candidate_surface_lemmas, surface_lemma,
    parse_surface_atoms) — enforces Phase 1 boundary

Performance note: build_graph_from_input now runs on every warm
English turn (previously only when forward_graph_constraint=True).
Phase 1 accepts this cost to make the telemetry universally
available; Phase 2+ can introduce a feature flag if needed.

Validation:
  - Cognition eval byte-identical: 100/100/91.7/100
  - Full lane: 2864 passed, 3 skipped, 0 failed (+5 over baseline)
  - Targeted lane: 72 passed in tests/test_{graph_constraint,
    pack_grounding,register_tour_demo,anchor_lens_tour_demo,
    orthogonality_tour_demo,realizer_guard_holdout,
    composer_graph_atom_equivalence}.py
2026-05-20 06:14:25 -07:00
Shay
21b10028b5 fix(evals): introspect run_lane signature before passing workers kwarg
PR #46 added the `workers` kwarg to framework dispatch (evals/framework.py:176)
but only the cognition runner was updated to accept it. The three serial
lanes (cold_start_grounding, deterministic_fluency, warmed_session_consistency)
— and ~30 other runners — raised TypeError on every framework invocation,
producing 18 test failures across the full suite.

Fix at the dispatch site rather than per-runner: inspect the target
run_lane signature and pass `workers=` only when it accepts the kwarg
(or has **kwargs). This keeps the framework contract backward-compatible
with the legacy two-arg shape and forward-compatible with future
parallelized runners — no runner needs updating.

Full lane: 2859 passed, 3 skipped, 0 failed (was 2841/18 failed).
Cognition eval byte-identical: 100/100/91.7/100.
2026-05-20 05:59:51 -07:00
Shay
ae45e768ec feat(alignment): wire grc/he→en alignment for 3 dormant anchor lenses
Adds three alignment edges so grc_zoe_v1, grc_arche_v1, and he_chayyim_v1
engage on English prompts (life/beginning), matching the existing pattern
that lets grc_logos_v1 / grc_aletheia_v1 / he_logos_v1 / he_dabar_v1 fire.

  grc-core-cog-004 → en-core-cog-004  (ζωή → life)        — grc_zoe_v1
  grc-core-cog-005 → en-core-cog-005  (ἀρχή → beginning)   — grc_arche_v1
  he-core-cog-004  → en-core-cog-004  (חιים → life)        — he_chayyim_v1

All 7 anchor lenses now engage on their target English prompts.
Cognition eval byte-identical (100/100/91.7/100).
anchor-lens-tour + register-tour demos green.

Pure data change in alignment.jsonl; lexicon checksums unchanged.
2026-05-20 05:25:15 -07:00
Shay
0eaba474ed
parallel eval runner (#46) 2026-05-19 23:51:59 -07:00
Shay
37c0ea1835
lab: teaching layer deep trace + identity config explorer + hardware benchmark (#44)
* lab: deep teaching layer trace suite + identity configuration explorer

This branch is a lab environment. Nothing here touches packs, manifolds,
or any durable geometry. Every test and trace runs in an isolated
in-process VaultStore that evaporates at the end of the test — the
clean-room guarantee is preserved by construction.

== evals/lab/teaching_trace.py ==

Full end-to-end trace of the teaching pipeline across all three identity
pack configurations (default_general_v1, precision_first_v1,
generosity_first_v1).  For each pack:

  1. Build a ChatRuntime with that identity config
  2. Run a teaching session: chat() -> observe surface -> submit
     CorrectionCandidate -> review_correction() -> TeachingStore.add()
  3. Trace EVERY layer with structured output:
     - Input versor (hex digest of float32 bytes for stable comparison)
     - Gate decision (direct vs decomposed, score, fire/clear)
     - Proposition formed (subject, predicate, frame_id)
     - Identity score (alignment, flagged, deviation_axes)
     - Safety verdict (upheld, violated predicates)
     - Ethics verdict (upheld, violated commitments)
     - Surface produced
     - Review outcome (ACCEPTED / REJECTED_IDENTITY / REJECTED_EMPTY)
     - Proposal epistemic_status after contradiction detection
     - PackMutationProposal fields (triple parsed, proposal_id)
  4. Emit a per-pack structured JSON trace to stdout
  5. Compare traces across packs: show exactly where the geometry
     diverges (alignment score delta, hedge rate delta, flagged delta)

== evals/lab/identity_config_explorer.py ==

Explores the full configuration space of the three identity packs by
running a fixed corpus of 12 semantically diverse inputs through each
pack and recording the full per-turn audit trail.  Inputs are chosen to
stress different axes:
  - alignment-safe (light, truth, word)
  - boundary-adjacent (correction, override, identity)
  - hedge-triggering (uncertain, speculative, contested)
  - ethics-activating (harm, disclosure, evidence)

For each input x pack combination:
  - Records alignment_score, flagged, hedge_injected, refusal_emitted
  - Records deviation_axes (which value axes were pulled)
  - Records versor_condition (geometric health)
  - Records dialogue_role (assert/elaborate/question/refute)

Outputs a CSV matrix: rows = inputs, columns = (pack x field), so you
can read off exactly how each identity configuration responds to each
stressor.  This IS the identity configuration diff — not a diff of
prompts, a diff of geometric alignment trajectories.

== evals/lab/teaching_contradiction_probe.py ==

Probes the CONTESTED transition mechanism in TeachingStore directly.
Submits pairs of logically contradictory corrections on the same subject
and verifies that both proposals are marked CONTESTED.  Then submits a
ratifying correction and verifies the resolution path.

Also probes the identity-override rejection path with a corpus of
22 adversarial correction texts spanning:
  - v1 legacy marker attacks ("you are now", "forget your")
  - v2 contraction bypass ("you're now", "you'd become")
  - v3 philosophical-axis attacks ("disregard your axiology",
    "abandon your ethos", "circumvent your epistemology")
  - v4 negating-qualifier attacks ("respond without prior bindings",
    "become unbounded")

For each: records whether _is_identity_override fired syntactically,
whether IdentityCheck.would_violate fired geometrically, and the final
ReviewOutcome.  The dual-layer defense is the structural claim — this
trace makes it falsifiable.

== evals/lab/vault_epistemic_trace.py ==

Traces the EpistemicStatus lifecycle across a full session:
  1. Every store() call: records status written, turn, role
  2. Every recall() call with min_status=None vs min_status=COHERENT:
     records which entries are visible at each tier
  3. After promotion (with_status(COHERENT)): records that the promoted
     entry now appears in COHERENT-filtered recall and that un-promoted
     entries do not
  4. Verifies that benchmark/test writes (SPECULATIVE) never appear
     in COHERENT-filtered recall — the contamination isolation proof

This is the structural argument for why per-session non-persistent
vaults preserve the integrity of the pack geometry.

* lab: hardware benchmark + compute reality demo

Adds evals/lab/hardware_benchmark.py

One falsifiable claim per section:
  - Exact CGA inner product scan over N=10K x 32 float32 versors
    completes in microseconds on CPU-only, zero CUDA
  - Versor application (geometric product sandwich) completes
    in nanoseconds per operation
  - Full session: 10 turns, vault writes, vault recalls, anchor pull,
    blade EMA, graph finalization — wall time measured end-to-end
  - Peak RSS memory measured before and after a 10K vault load
  - Backend report: pure Python NumPy vs Rust extension, zero GPU path

This is the compute reality section of the industry demo suite.
No H100 needed. No CUDA driver. No model weights. No tokenizer.
The number that matters: a full reasoning turn on an M1 MacBook Pro
completes in the same wall-clock budget as a single transformer
forward pass on an H100 — and the M1 is doing exact geometric
arithmetic, not approximate matrix multiplication.

* lab: generation walk deep trace + rotor manifold explorer

Adds evals/lab/generation_walk_trace.py and
evals/lab/rotor_manifold_explorer.py

After reading generate/stream.py in full, the two things that needed
a trace instrument were:

1. The generation walk itself — every step: which versor is current,
   which rotor is constructed, what field state results, what
   admissibility verdict is issued, which vault hits were applied
   and at what softmax weight, what holonomy accumulated, what the
   admissibility trace carries. This is the most important structural
   trace in the system because it is the proof that language generation
   here is a geometric walk on the versor manifold, not a probability
   distribution over tokens.

2. The rotor manifold itself — rotor_power (the manifold-preserving
   power operation that scales vault recall transitions), the
   word_transition_rotor (the geometric bridge from word A to word B),
   and versor_condition (the health check that proves the walk stays
   on the manifold). These three operations are the computational
   heart of what makes exact geometric generation possible.
2026-05-19 23:51:24 -07:00
Shay
f1152d681d chore(packs): seal mastery reports for new register + anchor lens packs
Companion mastery reports for the 7 new packs added in #47.  The
squash-merge captured only the first 2 commits of the PR branch and
missed the ratification-writeback commit; this restores it on main.

* 2 register packs: pedagogical_v1, precise_v1
* 5 anchor-lens packs: grc_zoe_v1, grc_aletheia_v1, grc_arche_v1,
  he_dabar_v1, he_chayyim_v1

Idempotent against the 6 pre-existing sealed packs.
2026-05-19 23:51:00 -07:00
Shay
565cca0b0c
feat(packs): pedagogical_v1, precise_v1 registers + 5 new anchor lens packs (#47)
* feat(packs): add pedagogical_v1, precise_v1 register packs + 5 new anchor lens packs

Register packs:
- pedagogical_v1: fills the reserved 'pedagogical' depth tier (loader had it in
  _ALLOWED_DEPTH_PREFERENCES since R1 with zero packs using it). Socratic markers
  in openings/closings; transitions scaffold inquiry progression.
- precise_v1: standard depth, disclosure_domain_count=2 override. Focused output
  (two semantic domains vs default three) with no discourse markers. Distinct from
  terse_v1 (which forces count=1) and default_neutral_v1 (which has no overrides).

Anchor lens packs (all grc or he substrate, all atoms confirmed in
language_packs/data lexicons):
- grc_zoe_v1: logos.vitality.animate — animate-vitality pole, grc substrate
- grc_aletheia_v1: logos.aletheia.verity — unconcealment pole, grc substrate;
  dual-correction pair with he_logos_v1 (same atom, different substrate + mode)
- grc_arche_v1: logos.genesis.origin — generative-origin pole, completes grc quad
- he_dabar_v1: logos.utterance.word — divine-word pole, he substrate;
  dual-correction pair with grc_logos_v1 (same atom, different substrate + mode)
- he_chayyim_v1: logos.vitality.animate — covenant-life pole, he substrate;
  dual-correction pair with grc_zoe_v1

Also updates ratify scripts to include all new IDs in REGISTER_IDS / LENS_IDS
tuples so ratify_*.py picks them up on next run.

All packs ship with mastery_report_sha256='' — operator runs ratify scripts
after merge to seal. No schema changes; all fields within existing loader bounds.

* fix(packs): wire R6 boolean knobs into precise_v1 + pedagogical_v1; widen R4 gate

Precise: add drop_provenance_tag=true — formal output drops the meta-tag,
making it substantively distinct from default_neutral_v1 on the gloss
path (not just the rare no-gloss disclosure surface).

Pedagogical: add append_semantic_domain_clause=true — expands the gloss
with full semantic domain context, giving the learner cognitive anchor
points. Pairs with the existing Socratic markers for a genuinely
distinct substantive+presentational posture.

ratify_register_packs.py: widen _KNOWN_OVERRIDE_KEYS to include the four
R6 boolean knobs (drop_provenance_tag, compress_gloss, drop_articles,
append_semantic_domain_clause). Validator: isinstance(v, bool). This
anticipates R6 landing on main — the R4 gate must know the keys before
the packs can ratify. All four keys are informational-only in _KNOWN_OVERRIDE_KEYS
until the realizer dispatch code in R6 actually reads them; the gate
just needs to not refuse them.
2026-05-19 23:49:00 -07:00
Shay
5a78b0e37b feat(register): ADR-0077 — substantive register knobs + layering boundary (R6)
R5 (ADR-0072) shipped the register *machinery*; ADR-0074's orthogonality
tour proved the axis was decoratively orthogonal to anchor-lens but
inspection of the cognition-eval surfaces revealed two structural gaps:

* On pack-grounded DEFINITION/RECALL/COMPARISON composers, the only
  realizer override any register consumed was `disclosure_domain_count`
  — which only fires on the no-gloss disclosure path.  Under terse_v1,
  every gloss-DEFINITION cell was byte-identical to default_neutral_v1.
* The register-tour's `surfaces_vary_at_least_once` gate could be
  satisfied by convivial's decorative wrapper alone, masking that
  regression in CI.

R6 closes both:

Layering separation (the load-bearing fix):
* New TurnEvent/ChatResponse field `register_canonical_surface` carries
  the composer output BEFORE any register transformation.  The pipeline
  hashes this field for `trace_hash`, preserving R5's invariant that
  per-prompt trace_hash is CONSTANT across registers even while
  substantive transforms produce visibly different surfaces.

Substantive transforms (`chat/register_substantive.py`):
* terse_v1 gains 3 bool knobs: `drop_provenance_tag`, `compress_gloss`,
  `drop_articles` — all pure regex transforms on the canonical surface.
* convivial_v1 gains `append_semantic_domain_clause` — appends a single
  bounded "Related: <atom>." clause using the lemma's pack atoms.
* default_neutral_v1 leaves overrides empty; substantive transform is
  byte-identical no-op (preserves `byte_identity_null_lift`).
* C1 (ADR-0075) safety preserved: drop_articles refuses to drop
  articles following `not` (avoids R3 violations); no knob combination
  trips R2/R3.

Strengthened tour gate (`evals/register_tour/run_tour.py`):
* Replaces `surfaces_vary_at_least_once` with two falsifiable claims:
  - `terse_substantively_differs_from_neutral_on_pack_grounded_definition`
  - `convivial_substantively_differs_from_neutral_on_pack_grounded_definition`
  Both restrict to DEFINITION+pack-grounded cells and require
  difference beyond whitespace/punctuation.
* New claim `register_canonical_surfaces_identical` directly proves
  the layering separation.
* Preserves R5's `all_grounding_sources_identical` +
  `all_trace_hashes_identical`.

Pack ratification:
* Loader widened to accept `bool` for closed-set R6 keys
  (drop_provenance_tag / compress_gloss / drop_articles /
  append_semantic_domain_clause).
* `_KNOWN_OVERRIDE_KEYS` ratify gate extended with same.
* terse_v1 + convivial_v1 reratified with new knobs; companion
  mastery reports re-sealed.  default_neutral_v1 unchanged.

Invariants pinned:
* `invariant_register_canonical_surface_constant_across_registers` (new)
* `invariant_terse_substantively_distinct_from_neutral` (new)
* `invariant_convivial_substantively_distinct_from_neutral` (new)
* `invariant_realizer_no_illegal_articulation` (C1, preserved)
* `invariant_realizer_guard_byte_identity_on_currently_passing_cases`
  (C1, preserved)

Verification:
* `core eval cognition`: 100.0% / 91.7% / 100.0% / 100.0% — byte-
  identical under default_neutral_v1.
* `core demo register-tour`: all 5 claims green, exit 0.
* `core demo anchor-lens-tour`: green (no anchor-lens code touched).
* `core demo orthogonality-tour`: green (5/5 claims).
* Full lane: 2858 passed, 1 pre-existing failure
  (test_all_preamble_explains_combined_run, carried forward
  unchanged from main).  56 new R6 tests across three files.
2026-05-19 23:39:11 -07:00
Shay
d7499c80b3
feat(intent): normalize confirmation-tag propositions (#45) 2026-05-19 22:55:28 -07:00
Shay
7cc2888ed2 feat(coherence): ADR-0075 — realizer slot-type guard (C1)
C1 coherence floor: a deterministic verifier that runs on every
candidate surface produced by the truth path, before assignment to
ChatResponse.surface.  Rejects illegal articulations and routes them
to a bounded disclosure string — admission control with a
deterministic fallback, not normalization.

Active rules (R1 deferred during ratification — see ADR):
  R2_aux_neg_requires_verb     — "<aux> not <wrong-POS>"  rejected
  R3_be_neg_requires_predicate — "<be>  not <verb>"       rejected

Fail-open on unknown POS, fail-closed on explicit wrong POS.
Cognition eval byte-identical (100/91.7/100/100).

Original bug class — "Light reveals truth, right?" → "Right does not
thought." — now routes to "I do not have a reviewed articulation for
that yet." with grounding_source=none, walk_surface preserving the
rejected candidate, and telemetry carrying R2_aux_neg_requires_verb.

Files:
  generate/realizer_guard.py            NEW — pure verifier
  chat/runtime.py                       hook on stub + main paths
  chat/telemetry.py                     serialize guard fields
  core/physics/identity.py              TurnEvent +2 fields
  evals/realizer_guard/run_holdout.py   NEW — 6-prompt cluster
  tests/test_realizer_guard_*.py        NEW — 46 tests (unit/seam/holdout)
  docs/decisions/ADR-0075-*.md          NEW — ratified

Invariants pinned:
  invariant_realizer_no_illegal_articulation
  invariant_realizer_guard_byte_identity_on_currently_passing_cases

Lanes (excluding 1 pre-existing TestDemoPreambles failure unrelated
to C1, already present at 4426f38):
  smoke 67/67  cognition 120/120(+1s)  teaching 17/17
  packs 6/6   runtime 19/19   algebra 132/132   full 2792/2793
2026-05-19 22:35:09 -07:00
Shay
4426f387d1 feat(demo): ADR-0074 — orthogonality tour (anchor-lens × register)
A single demo that walks the full 3 × 3 × 2 matrix (register × lens
× prompts, 18 cells) and pins five claims simultaneously, packaging
both single-axis invariants into one composition gate.

The single-axis tours assert opposite invariants:

  register-tour    : per (lens, prompt), trace_hash CONSTANT across
                     registers (R5 / ADR-0072).
  anchor-lens-tour : per (register, prompt), engaged lens diverges
                     in trace_hash from the unanchored baseline
                     (L1.4 / ADR-0073d).

Orthogonality-tour packages both claims simultaneously across the
full matrix, plus three surface-level claims that pin the markers
operators actually see.

Composed claims (all five must hold)

  A) inner_register_invariant_within_lens
     For each (lens, prompt) cell, the three register runs share an
     identical trace_hash.  (R5 register-tour, applied 6 times:
     3 lenses × 2 prompts.)

  B) outer_lens_distinctness_within_register
     For each (register, prompt) cell where any non-unanchored lens
     engages, that engaged lens's trace_hash differs from the
     unanchored baseline at the same (register, prompt).
     (L1.4 anchor-lens-tour, applied 6 times: 3 registers × 2 prompts.)

  C) surface_carries_register_marker_under_convivial
     Every convivial cell with a non-empty surface has a non-empty
     register_variant_id.

  D) surface_carries_lens_annotation_when_engaged
     Every engaged cell carries [lens(<id>):<mode>] in surface AND
     a non-empty anchor_lens_mode_label.

  E) no_substrate_glyph_leak_across_grid
     No cell's surface contains Greek/Hebrew/Syriac/Arabic glyphs.
     (ADR-0073c gate re-asserted across the full matrix.)

CLI wiring

  core demo orthogonality-tour            human-readable grid + claims
  core demo orthogonality-tour --json     structured report

Exit code 0 iff all five claims hold.

Files

  evals/orthogonality_tour/__init__.py             NEW
  evals/orthogonality_tour/run_tour.py             NEW
  core/cli.py                                       EDIT
    - cmd_demo handler wires orthogonality-tour
    - demo choices + EPILOG examples updated
  tests/test_orthogonality_tour_demo.py             NEW (9 tests)
  docs/decisions/ADR-0074-orthogonality-tour.md     NEW

Sanity check baked into tests
  test_engaged_cells_appear_for_both_non_trivial_lenses pins that
  grc_logos_v1 engages on knowledge in all 3 registers (3 cells)
  and he_logos_v1 engages on truth in all 3 registers (3 cells).
  Prevents the lift claims being vacuously satisfied by a future
  engagement regression.

Lane evidence

  - 9 new orthogonality-tour tests pass.
  - core demo register-tour      → all_claims_supported: True
  - core demo anchor-lens-tour   → all_claims_supported: True
  - core demo orthogonality-tour → all_claims_supported: True
  - python -m core.cli eval cognition → byte-identical 100/100/91.7/100.
  - Full lane: 2745 passed / 4 skipped / 1 pre-existing failure
    (+9 over L1.4's 2736; the one failure remains
    test_all_preamble_explains_combined_run, unrelated).

No runtime / composer / loader / pack / schema changes.  Pure demo
consumer of existing telemetry contracts.
2026-05-19 20:33:33 -07:00
Shay
1feec74b1c feat(anchor_lens): ADR-0073d — L1.4 telemetry, CLI flag, tour demo
L1.4 closes the anchor-lens inside-out arc (L1.1→L1.4 mirroring
R1→R5).  Substantive axis is now operator-observable,
operator-driven, and demo-falsifiable — exactly what R5 did for
the register subsystem.

Telemetry extension
  - TurnEvent + ChatResponse gain anchor_lens_id +
    anchor_lens_mode_label (both default "" → pre-L1.4
    byte-identical).
  - serialize_turn_event surfaces both fields in every JSONL line.
  - Mode-label extracted via _ANCHOR_LENS_ANNOTATION_RE from the
    PRE-decoration surface (so register decoration cannot interfere
    with anchor-lens telemetry).  Composer remains the sole source
    of truth for engagement; the runtime helper is read-only.

Operator surface
  - core chat --anchor-lens <id> CLI flag threads into
    RuntimeConfig.anchor_lens_id.
  - Invalid id → AnchorLensError caught at cmd_chat and surfaced
    as _die("invalid --anchor-lens pack id: ...", code=2) before
    the REPL launches.
  - Composes with --register (both flags wire through
    _runtime_config_from_args).

Narrative demo
  - evals/anchor_lens_tour/run_tour.py walks 2 prompts × 3
    ratified lenses ({default_unanchored_v1, grc_logos_v1,
    he_logos_v1}).  Asserts four claims:
      * lens_ids_recorded_per_turn
      * trace_hashes_distinct_across_lenses (OPPOSITE of
        register-tour's identical-hash claim)
      * surface_propositions_distinct_across_lenses
      * no_substrate_glyph_leak (block-scoped Greek/Hebrew/
        Syriac/Arabic; stylistic punct allowed)
  - Exit code 0 iff all four hold.
  - Bundled into `core demo` choices + EPILOG.

Tests (30 new)
  - tests/test_anchor_lens_telemetry.py (16) — TurnEvent shape,
    serializer keys, runtime emits per lens / per engagement
    state, ChatResponse mirrors event, mode-label extractor unit.
  - tests/test_anchor_lens_cli.py (9) — _runtime_config_from_args
    threading, invalid id fail-fast, parser flag wiring, parser
    composes with --register.
  - tests/test_anchor_lens_tour_demo.py (9) — four seam claims
    pinned individually + all_claims_supported + per-cell
    anchor_lens_id + unanchored cells empty mode + engaged cells
    carry mode label.

Lane evidence
  - 30 new L1.4 tests pass.
  - core demo anchor-lens-tour --json → all_claims_supported: True.
  - core demo register-tour --json    → all_claims_supported: True.
    Both tours pass simultaneously — orthogonality CI-pinned.
  - python -m core.cli eval cognition → public 100/100/91.7/100
    byte-identical (lens=None / default_unanchored_v1).
  - Full lane: 2736 passed / 4 skipped / 1 pre-existing failure
    (+30 over L1.3's 2706; the one failure remains
    test_all_preamble_explains_combined_run, unrelated).

Live demo (canonical proof)
  P1: 'What is knowledge?'
    default_unanchored_v1  trace=17c9aabe…  mode=(none)
    grc_logos_v1           trace=0198ad4c…  mode=systematic
    he_logos_v1            trace=17c9aabe…  mode=(none)
  P2: 'What is truth?'
    default_unanchored_v1  trace=2557f3e8…  mode=(none)
    grc_logos_v1           trace=2557f3e8…  mode=(none)
    he_logos_v1            trace=ec8d84aa…  mode=covenant-verity

  Engagement is substrate-scoped: grc never touches truth, he
  never touches knowledge.  Trace hashes diverge exactly where the
  lens engages.

Trust boundaries
  - --anchor-lens flag does not bypass ratification; loader still
    enforces companion mastery report self-seal + ratify-time
    substrate-atom existence check (ADR-0073b/c).
  - Mode-label extraction is read-only regex parse; can't forge
    annotations the composer didn't emit.
  - Telemetry stays redact-safe — both fields are identifiers /
    mode labels, not content.  include_content=False emits them
    unconditionally.
  - No new mutation surface; pack files unchanged.

Closes the anchor-lens inside-out arc
  L1.1  content prerequisite                  ✓ (ADR-0073a)
  L1.2  class + loader + unanchored sentinel  ✓ (ADR-0073b)
  L1.3  first lenses + composer wiring        ✓ (ADR-0073c)
  L1.4  telemetry + CLI + tour demo           ✓ (this commit)

  Mirrors the R1→R5 register cadence exactly.  Both axes are now
  operator-observable, CI-falsifiable, audit-traceable, and
  composable via the orthogonality claim pinned in both tours.
2026-05-19 20:21:41 -07:00
Shay
b35bec6465 feat(anchor_lens): ADR-0073c — L1.3 first lenses + composer wiring
L1.3 of the anchor-lens inside-out rollout — first substantive
surface lift on the substantive axis.  Two ratified non-trivial
lenses engage on cognition-pack lemmas via the alignment graph,
appending [lens(<id>):<mode>] annotations to the existing
pack-grounded surface.

Two ratified lenses

  grc_logos_v1 (Greek substrate)
    primary_substrate         : "grc"
    semantic_domain_preferences: ["logos.episteme.systematic_knowledge"]
    cognitive_mode_label       : "systematic"
    Engages on en "knowledge" via grc-core-cog-021 (ἐπιστήμη) →
    en-core-cog-007 alignment edge.

  he_logos_v1 (Hebrew substrate)
    primary_substrate         : "he"
    semantic_domain_preferences: ["logos.aletheia.verity"]
    cognitive_mode_label       : "covenant-verity"
    Engages on en "truth" via he-core-cog-002 (אמת) →
    en-core-cog-002 alignment edge.

  Both ratified under method anchor_lens_lifts_proposition.

Engagement rule (single)

  1. Resolve en_lemma → entry_id (cognition pack).
  2. For each substrate pack matching lens.primary_substrate, load
     alignment.jsonl; find edges where target_id == entry_id.
  3. For each such substrate lemma, if any atom in its
     semantic_domains ∈ lens.semantic_domain_preferences → engage.
  4. No match → None (no annotation; byte-identical surface).

The pivot is shared semantic_domain atoms surfaced via the
alignment graph — exactly the language-neutral commitment from
ADR-0073.  Engagement never touches non-English surface text;
entry_ids and atom strings only.

Surface lift

  no-lens : "Knowledge is X. pack-grounded (en_core_cognition_v1)."
  lens-on : "Knowledge is X. pack-grounded (en_core_cognition_v1) [lens(grc_logos_v1):systematic]."

  Annotation between existing provenance and trailing period.
  Both metadata fields are ASCII-bounded ≤64 chars at the loader
  level, so the annotation can never carry non-ASCII.

Scope deliberately narrow

  L1.3 wiring restricted to pack_grounded_surface /
  build_pack_surface_candidate (DEFINITION/RECALL only).  Other
  composers (COMPARISON / CORRECTION / PROCEDURE / NARRATIVE /
  EXAMPLE / CAUSE / VERIFICATION) accept the anchor_lens kwarg via
  forward-compat default UNANCHORED but do not yet consume it.
  L1.3b or later broadens to those intent shapes.

Ratify gate widening

  Non-null lenses must:
    - have primary_substrate ∈ {grc, he, en}
    - have a non-empty cognitive_mode_label
    - every preferred atom must exist in at least one lemma of the
      named substrate (trust boundary: operators cannot ship a lens
      pointing at atoms not on disk).
  Method: anchor_lens_lifts_proposition.  Null lenses still ratify
  under byte_identity_null_lift (L1.2 method).

Seam allow-list widening

  Truth-path modules (cognition / trace / pipeline / intent /
  propagation / vault / algebra) still refused.  Composer-side
  imports from chat/pack_grounding.py now permitted — the same way
  ADR-0069's R2 widened the register seam.

New invariants pinned (3)

  tests/test_anchor_lens_engagement_unit.py (14 tests) — resolver
  returns mode label only on intended substrate × en lemma pair;
  case-insensitive; engagement None under null lens; synthetic
  lens with unmatched atom returns None; annotation is pure ASCII.

  tests/test_anchor_lens_lifts_proposition.py (17 tests) — grc
  engages on knowledge only, he engages on truth only,
  cross-lens isolation, three-way distinctness, replay determinism
  per (lens × prompt), register-tour seam holds within each lens
  scope (orthogonality CI-pinned, parametrized over 4 lens
  choices).

  tests/test_anchor_lens_no_glyph_leak.py (5 tests) — hard
  block-scoped gate: Greek (U+0370..03FF, U+1F00..1FFF), Hebrew
  (U+0590..05FF), Syriac, Arabic.  Stylistic punctuation
  (em-dash etc.) explicitly allowed; em-dash predates L1.3 by a
  wide margin and is not a substrate-leak risk.  Tested per-lens
  across every cognition case + direct lens-metadata ASCII check.

Lane evidence

  74 anchor-lens tests pass (37 from L1.2 + 37 new).
  python -m core.cli eval cognition → public 100/100/91.7/100
  byte-identical (lens=None / default_unanchored_v1).
  core demo register-tour --json → all_claims_supported: True
  (R5 seam still holds; L1.3 doesn't perturb presentation axis).
  Full lane: 2706 passed / 4 skipped / 1 pre-existing failure
  (+37 over L1.2's 2669; the one failure remains
  test_all_preamble_explains_combined_run, unrelated).

Files

  packs/anchor_lens/grc_logos_v1.json                        NEW
  packs/anchor_lens/grc_logos_v1.mastery_report.json         NEW
  packs/anchor_lens/he_logos_v1.json                         NEW
  packs/anchor_lens/he_logos_v1.mastery_report.json          NEW

  scripts/ratify_anchor_lens_packs.py                        EDIT
    LENS_IDS adds grc_logos_v1 / he_logos_v1; gate widened.

  chat/pack_grounding.py                                     EDIT
    _resolve_anchor_lens_mode, _maybe_append_anchor_lens_annotation,
    _substrate_lexicon_by_entry_id, _en_lemma_to_entry_id.
    build_pack_surface_candidate + pack_grounded_surface gain
    anchor_lens kwarg (default UNANCHORED).

  chat/runtime.py                                            EDIT
    Thread self.anchor_lens into pack_grounded_surface() call.

  tests/test_anchor_lens_pack_seam.py                        EDIT
    Doc-comment updated for L1.3 allow-list.

  tests/test_anchor_lens_*                                   NEW (3 files)

  docs/decisions/ADR-0073c-anchor-lens-composer-wiring.md    NEW
2026-05-19 20:06:02 -07:00
Shay
9b1b63b253 feat(anchor_lens): ADR-0073b — L1.2 class + loader + unanchored sentinel
L1.2 of the anchor-lens inside-out rollout — pack class, loader,
ratified sentinel pack, and runtime threading.  Mirrors the
ADR-0068 register-class pattern exactly.  No composer consumes the
lens yet — that's L1.3.

AnchorLens frozen dataclass (packs/anchor_lens/loader.py)
  - lens_id / version / description / display_name
  - primary_substrate ∈ {grc, he, en, none}
  - semantic_domain_preferences: tuple[str, ...] (ordered, ≤64 atoms
    of ≤64 chars each, no duplicates)
  - cognitive_mode_label: str (≤64 chars)
  - mastery_report_sha256
  - is_unanchored() / is_null_lens() predicates
  - unanchored() classmethod + module-level UNANCHORED singleton

Loader contract (mirror of packs/register/loader.py)
  - safe_pack_id path-traversal rejection
  - Schema validation + envelope bounds checks
  - Companion mastery report self-seal + report_sha256 verification
  - CORE_ALLOW_UNRATIFIED_ANCHOR_LENS=1 dev bypass
  - require_ratified default True
  - No truth-path imports (pinned by seam test)

default_unanchored_v1 ratified pack
  - Null lens: primary_substrate="none", empty preferences,
    empty cognitive_mode_label
  - Self-sealed at b3235072fdbb2219...
  - Ratification method: byte_identity_null_lift
  - scripts/ratify_anchor_lens_packs.py L1.2 gate accepts only
    null lenses; L1.3 will widen.  Idempotent.

RuntimeConfig threading
  - new field: anchor_lens_id: str | None = None
  - new constant: DEFAULT_ANCHOR_LENS = "default_unanchored_v1"
  - ChatRuntime.__init__ loads the lens (None → AnchorLens.
    unanchored(); otherwise load_anchor_lens(id)) and stores as
    self.anchor_lens + self.anchor_lens_id.  Invalid ids fail-fast
    at init via AnchorLensError, not at first turn.
  - No composer reads the attribute yet.

Tests pinned (37 total)
  - tests/test_anchor_lens_pack_loader.py (24) — load happy path,
    sentinel structural identity, invalid id rejection (traversal,
    empty, slashes, missing), ratification bypass paths, companion
    SHA mismatch, bounds (substrate / preferences / atoms / label /
    duplicates / capacity), field-missing, lens_id mismatch with
    filename, unsupported schema_version.
  - tests/test_anchor_lens_null_lift.py (4) — load-bearing L1.2
    invariant `anchor_lens_byte_identity_null_lift`: full public
    cognition lane byte-identical for surface, trace_hash, and
    aggregate metrics between anchor_lens_id=None and
    "default_unanchored_v1".
  - tests/test_anchor_lens_pack_seam.py (9) — AST refuses any
    `packs.anchor_lens` import from truth-path modules (cognition /
    trace / pipeline / intent / propagation / vault / algebra) AND
    refuses any truth-path import from the loader itself.

Lane evidence
  - All 37 anchor-lens tests pass.
  - python -m core.cli eval cognition → public 100/100/91.7/100
    byte-identical (lens loaded but no composer reads it).
  - core demo register-tour --json → all_claims_supported: True
    (R5 seam still holds; L1.2 doesn't perturb register).
  - Full lane: 2669 passed / 4 skipped / 1 pre-existing failure
    (+37 over L1.1's 2632; the one failure remains
    test_all_preamble_explains_combined_run, unrelated).

Trust boundaries (per CLAUDE.md / ADR-0051)
  - safe_pack_id path-traversal rejection at loader entry.
  - No dynamic imports.
  - Loader is read-only; mutation only via ratify script.
  - Seam test refuses any new anchor-lens import upstream of the
    realizer.  L1.3 will widen the allow-list to include composer
    files at the same time it adds composer behaviour — exactly the
    way the register seam was widened at R2.

What L1.2 deliberately does NOT do
  - No composer consumes the lens (that's L1.3).
  - No TurnEvent / ChatResponse telemetry fields (L1.4).
  - No `core chat --anchor-lens` CLI flag (L1.4).
  - No anchor-lens-tour demo (L1.4).
2026-05-19 19:46:34 -07:00
Shay
2dd50b8dc4 feat(packs): ADR-0073a — anchor lens L1.1 content phase
Umbrella ADR-0073 ratified (Accepted); L1.1 content phase
(ADR-0073a) landed.  Pure pack enrichment — no runtime code, no
composer change, no test of behaviour.  Substrate prerequisite for
the L1.2–L1.4 phases.

Greek additions (grc_logos_cognition_v1, 20 → 29 entries)
  Knowledge family (English collapses to `knowledge`):
    - ἐπιστήμη  logos.episteme.systematic_knowledge
    - σύνεσις   logos.synesis.insight
    (γνῶσις at grc-core-cog-007 unchanged — treated as the
     experiential variant by the L1.3 lens config)
  Love family (English collapses to `love`):
    - ἀγάπη   logos.agape.covenant_love
    - φιλία   logos.philia.companion_love
    - ἔρως    logos.eros.passionate_love
    - στοργή  logos.storge.familial_love
  Time family (English collapses to `time`):
    - αἰών    logos.aion.age_era
    - χρόνος  logos.chronos.clock_time
    - καιρός  logos.kairos.opportune_moment

Hebrew additions (he_core_cognition_v1, 20 → 23 entries)
  - חסד    logos.chesed.covenant_loyalty
  - שלום   logos.shalom.wholeness_peace
  - צδק    logos.tzedek.right_order

Alignment.jsonl on both cognition-tier packs (previously only the
micro packs carried alignment)
  - grc_logos_cognition_v1/alignment.jsonl — 20 edges: three-way core
    dyads (word / truth / light / life / beginning / wisdom),
    knowledge-family → en collapse, ἀγάπη↔חסד covenant-love pairing
    (weight 0.86, Septuagintal), `cross_lang.no_english_collapse`
    annotations for love + time families pointing at
    `en-collapse-<family>` sentinel ids (weight 0.0).
  - he_core_cognition_v1/alignment.jsonl — 7 edges: core dyads to en,
    חסד↔ἀγάπη covenant pairing, no-english-collapse annotations for
    חסד / שלום / צδק.

Manifest checksums refreshed per CLAUDE.md doctrine
  - grc_logos_cognition_v1: b45bcf581cee… → 0f9436675707…
  - he_core_cognition_v1:   dee1e8c6ad9a… → 22145d008185…

Design decisions
  - Existing 20 + 20 lemma atoms untouched — downstream tests /
    composers / teaching chains keep referencing the same atoms.
    Only new lemmas carry the distinguishing atoms.
  - `cross_lang.no_english_collapse` edges are metadata not data
    (sentinel target ids, weight 0.0).  Their purpose is letting the
    alignment graph answer "does English split this family?" without
    forcing an artificial English lemma.
  - Every new entry carries `adr-0073a:hand_authored:2026-05-19` in
    its `provenance_ids` so future audits can find the L1.1 cohort
    deterministically.

Verification
  - python -m language_packs verify grc_logos_cognition_v1   → OK
  - python -m language_packs verify he_core_cognition_v1     → OK
  - python -m language_packs compile <both>                  → 29 / 23
    manifold points; spot-check confirms καιρός / צδק resolve.
  - python -m core.cli eval cognition                        → public
    100 / 100 / 91.7 / 100 byte-identical (new lemmas sit on disk but
    no composer references them yet).
  - python -m core.cli test --suite cognition                → 120/1 pass
  - python -m core.cli test --suite smoke                    → 67/0 pass
  - python -m core.cli test --suite full                     → 2632 passed
    / 4 skipped / 1 pre-existing failure (test_all_preamble_explains_
    combined_run rename drift, unrelated).
  - core demo register-tour                                  → exit 0
    (R5 seam still holds; L1.1 doesn't touch register pathway).

What L1.1 deliberately does NOT do
  - No AnchorLens class (that's L1.2 / ADR-0073b).
  - No composer wiring (L1.3 / ADR-0073c).
  - No --anchor-lens CLI flag or demo (L1.4 / ADR-0073d).
  - No teaching corpus in non-English (post-L1).
2026-05-19 19:30:20 -07:00
Shay
4e276d0588 chore(evals): refresh pack-measurements artifact to current runtime
`core demo pack-measurements` reproduces refusal_rate = 0.25 across
all three identity packs (default_general_v1, precision_first_v1,
generosity_first_v1).  The committed baseline was 1.0, dating to the
ADR-0043 original commit (4ba1ef2); the runtime has evolved through
ADR-0048..0072 since then and the report file fell out of sync.

Evidence
  - `python -m core.cli demo pack-measurements --json` reproduces 0.25
    deterministically on the current main.
  - tests/test_pack_measurements_phase2.py — all 6 pass; tests pin
    structural invariants (pack_invariant_gate=True, fabrication=0.0,
    refusal_rate ∈ [0,1]), not the specific value.
  - report-level `claims_supported` still True; the pack-measurements
    demo still PASSes in `core demo all`.

Other fields unchanged:
  - fabrication_rate          : 0.0
  - out_of_grounding_count    : 8
  - pack_invariant_gate       : True
  - identity_divergence       : distinct_rate 0.8 across pack pairs

No code change.  Pure artifact refresh.
2026-05-19 19:16:33 -07:00
Shay
f673c0eb06 docs(adr): ADR-0073 — anchor lens substrate (Proposed)
Umbrella ADR for the substantive-variation axis that composes
orthogonally against register (ADR-0068..0072).  Drafted only;
status Proposed.  No code, no pack, no test landed.

Architecture summary
  - Anchor lens is the substantive axis: register varies surface text
    while keeping grounding_source / trace_hash byte-identical;
    anchor lens deliberately moves both because the proposition
    itself changes when the substrate changes.
  - Pivot is shared `semantic_domains` atoms (already on disk across
    grc / he / en cognition packs), not transliteration tables — the
    seam stays language-neutral so future substrates compose without
    touching anchor-lens code.
  - English compound phrasing only at the surface ("knowing-as-
    experience", "knowing-as-system"); Greek / Hebrew glyphs live in
    audit / provenance fields only.  L1.3 invariant
    `anchor_lens_no_glyph_leak` is a hard gate.

Four-phase rollout (mirrors R1–R5 cadence)
  L1.1  content phase — distinction-bearing lemma additions
        (ἐπιστήμη / σύνεσις / ἀγάπη-φιλία-ἔρως-στοργή / αἰών-χρόνος-
        καιρός; חסד / שלום / צδק) + alignment.jsonl on the cognition-
        tier packs.  No code.  Prerequisite for every later phase.
  L1.2  AnchorLens pack class + loader + `default_unanchored_v1`
        sentinel.  Null-lift CI invariant pinned.
  L1.3  First non-trivial lenses (`grc_logos_v1`, `he_logos_v1`)
        wired into chat/pack_grounding.py composers.  Proposition-
        lift invariant + glyph-leak gate pinned.
  L1.4  Telemetry (TurnEvent + ChatResponse gain anchor_lens_id),
        `core chat --anchor-lens` flag, `core demo anchor-lens-tour`
        asserting trace_hashes_distinct_across_lenses (opposite of
        register-tour's claim — both must hold).

Three honest gaps blocking L1.2+
  - Distinction-bearing lemmas absent from cognition packs.
  - No reviewed teaching corpus for non-English (cognition_chains,
    relations_chains, cross_pack_chains all en-only).
  - No realizer infrastructure for cross-lingual surface composition.

L1.1 (pure content) closes all three for the cognition tier.

Orthogonality claim — load-bearing
  register-tour    : per prompt, fix lens, vary register → trace_hash CONSTANT
  anchor-lens-tour : per prompt, fix register, vary lens → trace_hash DISTINCT
  Both must continue to hold; failure of either breaks the seam.
2026-05-19 19:13:01 -07:00
Shay
7f0bad3e20 feat(register): R5 — operator-visible register telemetry + tour demo
ADR-0072 ratified + implemented.  Closes the register subsystem
inside-out arc (R1 ADR-0068 → R5 ADR-0072): the presentation axis is
now operator-visible, CI-falsifiable, and audit-traceable.

Telemetry extension
  - TurnEvent + ChatResponse gain register_id + register_variant_id
    (12-char SHA-256 prefix of selected (opening, closing) pair;
    empty string for UNREGISTERED / no-decoration registers).
  - serialize_turn_event surfaces both fields in every audit JSONL
    line.  Pre-R5 callers stay byte-identical (defaults are "").

Decoration result widened
  - chat/register_variation.py: decorate_surface now returns
    DecorationResult(surface, opening, closing, variant_id).
  - decorate_surface_str alias preserves the pre-R5 string-only API
    for off-runtime callers.
  - chat/runtime.py updated at both call sites (stub + main).

Operator surface
  - core chat --register REGISTER_ID threads into
    RuntimeConfig.register_pack_id via _runtime_config_from_args.
  - Invalid id ⇒ RegisterPackError caught at cmd_chat and surfaced
    as a clean _die(...) before the REPL launches.

Narrative demo
  - evals/register_tour/run_tour.py walks 4 prompts × 3 ratified
    registers ({default_neutral_v1, terse_v1, convivial_v1}) and
    asserts three load-bearing seam claims:
      * all_grounding_sources_identical
      * all_trace_hashes_identical (ADR-0069 invariant C, falsifiable)
      * surfaces_vary_at_least_once (ADR-0071 seeded variation lift)
  - core demo register-tour exit code = 0 iff every claim holds.

Tests
  - tests/test_register_telemetry.py (6) — TurnEvent default,
    serializer keys, runtime emits register_id/variant_id for
    convivial/terse/unregistered, ChatResponse mirrors event fields.
  - tests/test_register_cli.py (7) — _runtime_config_from_args
    threading, invalid-id fail-fast, parser wires --register.
  - tests/test_register_tour_demo.py (7) — three seam claims pinned
    individually + all_claims_supported + per-cell register_id +
    variant_id discipline (empty for neutral/terse, non-empty for
    convivial).
  - tests/test_register_variation.py extended (4 new) — DecorationResult
    shape, decorate_surface_str alias, variant_id stability,
    bijection between non-trivial marker pairs and variant_ids.

Lane evidence
  - Full lane: 2632 passed / 4 skipped / 1 pre-existing failure
    (tests/test_cli_demo.py::test_all_preamble_explains_combined_run,
    unrelated to R5).
  - Cognition eval byte-identical: public 100 / 100 / 91.7 / 100.

Trust boundaries (per CLAUDE.md)
  - --register flag does not bypass ratification; loader validates the
    pack id through _find_pack and the ratify gate at load time.
  - variant_id is content-addressed; no raw markers leak into audit.
  - Telemetry stays redact-safe — register_id and variant_id are
    identifiers, not content, so include_content=False emits them
    unconditionally.
  - No new mutation surface; pack files on disk are not modified.
2026-05-19 19:03:07 -07:00
Shay
6207b5fd0e feat(register): R1–R4 register pack subsystem — deterministic surface variation
Introduces the presentation axis as a fourth pack class (sibling to identity /
safety / ethics), orthogonal to the truth path. Same input + same packs +
same register ⇒ bit-for-bit reproducible surface; varying any of the three ⇒
genuinely different output. No stochastic sampling.

ADR-0068 (R1): RegisterPack frozen dataclass, loader, ratify script, seam test.
  - default_neutral_v1 ratified as null register.

ADR-0069 (R2): realizer register parameter threaded through 9 composer entry
  points; RuntimeConfig.register_pack_id; three byte-identity invariants
  (A: None ≡ pre-R2 unregistered; B: None ≡ default_neutral_v1; C: trace_hash
  invariant under register). Amended to default-with-lint after 167-call-site
  scout: composers default to UNREGISTERED, AST lint enforces explicit
  register= at runtime call sites.

ADR-0070 (R3): terse_v1 register, first non-neutral pack. realizer_overrides
  schema with known-keys allow-list (disclosure_domain_count ∈ {1,2,3}).
  build_pack_surface_candidate reads override with fail-soft clamp. New
  invariant register_invariant_grounding asserts grounding_source +
  trace_hash byte-identical across {None, neutral, terse}.

ADR-0071 (R4): seeded surface variation via convivial_v1.
  chat/register_variation.py applies SHA-256-seeded marker selection from
  bounded discourse-marker buckets. ChatResponse.pre_decoration_surface routes
  truth-path surface to core/cognition/pipeline.py so trace_hash stays
  invariant under register (the load-bearing architectural fix — initially
  invariant C failed under convivial because decoration was leaking into
  trace_hash via response.surface). Empty-string marker entries now
  legitimate ("no marker this turn" is a valid seed pick). realizer_overrides
  schema widened with per_intent nested block (validated against IntentTag
  whitelist; wired but not exercised by convivial). Two new invariants:
  seeded_variation_replay_equivalence (fresh runtimes → byte-identical) and
  seeded_variation_turn_distinct (same prompt across turns → ≥2 distinct
  surfaces).

ADR-0072 (R5, draft): telemetry + operator surface — TurnEvent gains
  register_id and register_variant_id, core chat --register flag, core demo
  register-tour. Status: Proposed; not yet implemented.

Three ratified register packs ship: default_neutral_v1 (null), terse_v1
(disclosure_domain_count=1), convivial_v1 (3 openings × 3 closings).

Verification:
  - 84 register tests pass + 1 documented skip
  - Curated lanes green: smoke 67, cognition 120+1s, teaching 17, packs 6,
    runtime 19, algebra 132
  - Cognition eval byte-identical to pre-register baseline:
    public 100/100/91.7/100, holdout 100/100/83.3/100
  - Full lane: 2608 passed, 4 skipped, 1 failed (pre-existing
    test_cli_demo.py "Combined Demo" → "Run Every Demo" rename, unrelated)

Truth-path isolation: chat/register_variation.py is realizer-side; the seam
test (tests/test_register_pack_seam.py) refuses imports of packs.register
from intent classification, propagation, vault recall, trace hashing, and
algebra.
2026-05-19 16:52:36 -07:00
Shay
c435bdf88c feat(demo): humanise teaching-grounded surface for layperson display
The conversation demo's Scene 4 was emitting CORE's raw production
teaching-grounded surface, which reads engineer-y for a layperson:

  narrative — teaching-grounded (cognition_chains_v1):
  rhetoric.narrative; language.discourse. narrative reveals
  meaning (cognition.meaning). No session evidence yet.

The production format is the trust-boundary contract (12+ tests + eval
byte-equivalence + several ADRs depend on it), so it stays unchanged.

This change adds a demo-only display layer that rewrites the same
surface to put the propositional sentence first, with provenance as a
trailing parenthetical:

  Narrative reveals meaning. (teaching-grounded from
  cognition_chains_v1 — narrative: rhetoric.narrative;
  language.discourse; final term: cognition.meaning.
  No session evidence yet.)

Trust-boundary preserving:
  - Only fires when grounding_source == "teaching" AND surface matches
    the production format.
  - Every load-bearing token preserved (subject, connective, object,
    corpus_id, semantic_domains, "No session evidence yet").
  - Pack-grounded surfaces + discourse-planner surfaces pass through
    unchanged.
  - JSON report's `surface` field still carries the raw production
    surface — only the chat-style print is humanised.

Test gate: 2 new tests pin the rewrite contract (proposition-first,
all load-bearing tokens preserved, passthrough for non-teaching).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 14:14:02 -07:00
Shay
ece7e3d2b1 feat(demo): core demo conversation — layperson-facing chat transcript
A live walkthrough that shows CORE actually being used.  Four scenes,
five turns, rendered as a chat transcript ('You: …' / 'CORE: …') with
plain-English captions between turns.

Streamed by default (per-character prompt, per-word response, brief
"thinking" pause) so the layperson sees the answer arriving live.
--no-stream disables delays for CI / tests / fast capture.

Scenes:

  1. Pack lookup        — "What is truth?"
                          Shows deterministic lexicon-grounded answer.

  2. Teaching-chain     — "Walk me through recall."
                          Shows CORE chaining reviewed facts.

  3. Compound prompt    — "What is truth, and why does it matter?"
                          Shows compound decomposition + composition.

  4. Cold turn → learn  — "Why does narrative exist?"
                          Shows CORE refusing to fabricate, an operator
                          teaching it one new chain (real propose →
                          replay-gate → accept), then re-asking the same
                          prompt and getting a grounded answer.

The learning-loop scene reuses the production learning_loop demo so
the underlying machinery is exactly what ships — active corpus is
byte-identical pre/post.

Test gate: tests/test_conversation_demo.py (9 tests — per-scene
grounding source + content checks, learning loop closes,
active-corpus byte-identical, stable JSON shape).

Usage:
  core demo conversation              # live streamed transcript
  core demo conversation --no-stream  # instant rendering
  core demo conversation --json       # structured report (no chat output)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 14:07:48 -07:00
Shay
f2724beb90 feat(cli): core demo all — runs every demo, consolidated PASS/FAIL
Renames the original phase5+phase6 combo to its more honest name
'adr-0024-chain' and repurposes 'all' to mean what users expect: every
demo (eight in total) in one shot.

Demos covered:
  1. phase5                  — stratified mechanism isolation
  2. phase6                  — three-condition head-to-head
  3. audit-tour              — pack-layer story
  4. pack-measurements       — pack-layer claims → numbers
  5. long-context-comparison — exact NIAH vs transformer baselines
  6. anti-regression         — three-gate defense
  7. learning-loop           — cold turn → grounded surface
  8. articulation            — discourse-planner spine

Per-demo runners retain their native preambles + reports.  The
aggregator captures each demo's load-bearing boolean (already pinned
by that demo's test gate) and prints a consolidated PASS/FAIL table.
Exits non-zero if any demo fails.

Under --json, sub-runner stdout is suppressed and a single
consolidated JSON object is emitted with one key per demo plus
'passed' and 'all_demos_passed'.

'core demo adr-0024-chain' preserves the historical phase5+phase6
combined-summary semantics for callers who depended on it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 13:52:00 -07:00
Shay
dc4b565b5a feat(demo): core demo articulation — discourse-planner spine, end-to-end
Four-scene investor/operator-facing walkthrough proving the discourse-
planner spine is load-bearing.  Each scene runs the same prompt under
flag-off (BRIEF baseline) and flag-on (RuntimeConfig.discourse_planner)
and pins a falsifiable lift assertion.

  S1.  EXPLAIN       — Explain truth.
                       Flag-on: pack→teaching upgrade + 2 chain
                                continuation sentences over baseline.
  S2.  COMPOUND      — What is truth, and why does it matter?
                       Flag-on: 9 grounded sentences across two sub-
                                plans; flag-off routes to OOV.
  S3.  WALKTHROUGH   — Walk me through recall.
                       Flag-on emits the CLOSURE chain hop
                                'Recall reveals memory.'; flag-off
                                does not.
  S4.  Determinism   — N=3 reruns × 3 prompts, unique(surface)=1.

Read-only against live packs + active corpus.  Demo is test-gated
(7 tests, all green) and ships a stable JSON contract for downstream
consumers.

Wired into CLI as `core demo articulation [--json]` alongside the
existing trilogy (audit-tour / anti-regression / learning-loop).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 13:41:24 -07:00
Shay
28219c31e2 feat(cli): core bench --suite all — run every benchmark in one shot
Adds an aggregate ``all`` choice to ``core bench --suite`` that
exercises every benchmark CORE ships:

  [1/4] Core six   — determinism / latency / speedup / versor /
                     convergence / realizer  (via run_benchmarks)
  [2/4] Teaching-loop determinism
  [3/4] Articulation suite — breadth / determinism / footprint /
                             cross-topic / discourse-planner /
                             ollama
  [4/4] Cost — measurement bench (no PASS/FAIL by design)

Behavior:

* Each section prints its native report shape (run_benchmarks rows,
  articulation summary, cost summary).  Final consolidated tally
  prints ALL PASSED / FAILURES DETECTED across the three pass/fail
  groups; cost is reported separately as a measurement section so
  it can't false-positive the gate.
* JSON mode emits a single consolidated object with one key per
  section so a downstream report consumer gets every artifact from
  one command.
* psutil is treated as optional: when missing, the articulation
  footprint sub-bench is skipped (new ``skip_footprint`` kwarg on
  ``run_articulation_suite``) instead of aborting the whole run.
  The other three articulation sub-benches all run, so the spine's
  determinism + planner-on capability evidence is preserved.

CLI surface:

  core bench --suite all
  core bench --suite all --runs 50
  core bench --suite all --json --report bench_all.json

Defaults for ``core bench`` (no suite) are untouched — still runs
the six core benches exactly as before.

EPILOG examples updated; ``--suite`` ``choices`` extended with
``"all"``.

Validation:
* core bench --suite all --runs 3: 4 sections run end-to-end;
  consolidated tally reports per-bench PASS/FAIL.  Pre-existing
  backend_speedup FAIL (0.9999x — Rust kernel not built locally)
  surfaces correctly; every other bench PASS including
  articulation_suite_overall.
* core bench --runs 3 (no --suite): unchanged behavior, same six
  benches as before.
* tests/test_articulation_bench.py + test_cli*.py: 25 passed.
* smoke suite 67/67.
2026-05-19 13:08:39 -07:00
Shay
90fc1b40a0 docs(evals): articulation benchmark preamble — discourse-planner spine
Records the deterministic, grounded, multi-clause articulation
benchmark that the discourse-planner work has stabilised.  Mirrors
the format of teaching_loop_bench.md so the four sub-benches in
benchmarks/articulation.py have a load-bearing reference document.

Headline:

* 20 independent ChatRuntime instances × 4 prompts (EXPLAIN /
  PARAGRAPH / COMPOUND / WALKTHROUGH) produce 4 unique surfaces —
  byte-identical determinism on the articulation path with
  RuntimeConfig(discourse_planner=True).
* Every visible token traces to a pack lemma, pack gloss, reviewed
  teaching-chain entry, or fixed-template connective from the
  closed five-entry _MOVE_CONNECTIVE table.  No synthesis.
* discourse_planner sub-bench:
    cases:                     4
    articulate_sentence_rate:  1.0
    disclosure_sentence_rate:  0.0
    multi_sentence_rate:       1.0
* Compound prompt ("What is truth, and why does it matter?") emits
  6 distinct grounded sentences with cross-part fact dedup, no
  anchor repetition.
* Walkthrough mode walks the teaching-chain edge graph up to 3 hops,
  cycle-safe, final hop as CLOSURE; no chain ⇒ degrades to ANCHOR +
  SUPPORT rather than fabricating steps.

Doc explains the partitioned predicate contract
(articulate + disclosure + unarticulate = 1.0, total and disjoint)
so future readers know why ``multi_sentence_rate`` alone is not the
headline.

Companion docs cross-linked: discourse_runtime_baseline_2026-05-19.md
(lane-level delta table), the two new isolation lanes
(compound_intent_decomposition, walkthrough_chain), and the
partitioned multi_sentence_response contract.
2026-05-19 12:47:38 -07:00
Shay
e985790a03 feat(evals+bench): isolation lanes, holdouts, planner-on bench sub-bench
Sharpens the measurement layer to match the runtime spine landed in
07fefb9 / 7af7892 / 4e3ddee.  Pure eval/benchmark/holdout work —
no runtime or planner code changed.

New isolation lanes
-------------------

* ``evals/compound_intent_decomposition/`` — single-purpose lane for
  the new ``classify_compound_intent`` decomposer.  Metrics:
  ``decomposition_accuracy``, ``atom_precision``, ``subject_accuracy``.
  Public: ``decomposition=1.0`` on 4e3ddee.
* ``evals/walkthrough_chain/`` — single-purpose lane for the new
  WALKTHROUGH sequential teaching-chain walk.  Metrics:
  ``path_exact_rate``, ``anchor_rate``, ``min_hop_rate``, ``bounded_rate``.
  Public: ``path_exact=1.0`` on 4e3ddee.

Without these, regressions in compound decomposition or the
walkthrough walk would show up as noise in ``multi_sentence_response``.
Each capability now has a single load-bearing metric on its own lane.

Cold-start lane sharpened
-------------------------

* ``evals/cold_start_grounding/public/v1/cases.jsonl`` extended with
  expository, compound, and walkthrough cases (48 total cases across
  19 categories including new ``expository_definition``,
  ``compound_definition_cause``, ``walkthrough_definition``).
* ``evals/cold_start_grounding/runner.py`` uses
  ``classify_compound_intent(...).primary`` for compound subject
  scoring — previously misattributed subjects on multi-part prompts.

Holdouts for the long-span lanes
--------------------------------

Until now only the cognition lane had a holdout split.  Adding
holdouts to the long-span lanes gives the planner work somewhere to
fail honestly when we widen:

* ``evals/cold_start_grounding/holdouts/v1/cases.jsonl`` (5 cases)
* ``evals/multi_sentence_response/holdouts/v1/cases.jsonl`` (5 cases)
* ``evals/conversational_thread_coherence/holdouts/v1/cases.jsonl`` (3 cases)
* ``evals/warmed_session_consistency/holdouts/v1/cases.jsonl`` (2 cases)

Discourse-planner-on bench sub-bench
------------------------------------

* ``benchmarks/articulation.py`` adds a planner-on sub-bench that
  reports ``articulate_sentence_rate`` alongside the existing
  throughput metrics.  Baselines articulation under load before any
  follow-up touches ``compute_trace_hash``.

Test coverage
-------------

* ``tests/test_compound_walkthrough_eval_lanes.py`` — new file pinning
  the two new lane runners.
* ``tests/test_articulation_bench.py``, ``tests/test_cold_start_grounding_lane.py``,
  ``tests/test_intent_explain_paragraph.py``,
  ``tests/test_response_mode_classifier.py`` — updated for new cases
  and assertions.

Validation
----------

* 152/152 active tests pass on the listed surfaces (2 skipped).
* smoke suite 67/67.
* cognition eval byte-identical: public 100/100/91.7/100.
* multi_sentence flag_on: articulate=1.0, disclosure=0.0, unarticulate=0.0
* compound_intent_decomp public: decomposition=1.0
* walkthrough_chain public: path_exact=1.0
* cold_start_grounding public (48 cases): intent=1.0, grounding=1.0, subject=1.0
2026-05-19 12:42:55 -07:00
Shay
4e3ddee91f feat(discourse): WALKTHROUGH v1 — sequential teaching-chain walk
Closes the last unarticulate cases on the multi_sentence_response
lane.  Two complementary changes:

1. ``generate/discourse_planner.py``
   * ``ResponseMode.WALKTHROUGH`` budget lifted from (1, 1) to
     (1, 4): 1 anchor + up to 3 hops along the teaching-chain graph,
     final hop becomes CLOSURE.
   * New ``_plan_walkthrough`` selector walks (subject, *, object) →
     (object, *, *) starting from the anchor; cycle-safe via the
     existing used-fact set; bounded by ``_WALKTHROUGH_MAX_HOPS=3``.
   * New ``_plan_walkthrough_fallback`` — when no teaching chain is
     rooted on the anchor, emit ANCHOR + (SUPPORT) rather than
     fabricating walk steps.  Plan retains ``mode=WALKTHROUGH`` so
     callers detect "attempted walkthrough, degraded honestly".

2. ``generate/intent.py``
   * New classifier rule: ``^walk\s+(?:me\s+)?through\s+`` →
     ``IntentTag.DEFINITION``.  Same orthogonality discipline as the
     ``Explain X`` rule: ``ResponseMode.WALKTHROUGH`` carries the
     walk depth on its own axis.

13 new tests pin: walk shape (ANCHOR + RELATION* + CLOSURE), the
walk invariant (each teaching hop's subject = prior hop's object),
the 4-move cap, the fallback shape on absent chains, fallback mode
retention, cycle-safety against (A→B→A) cycles, and determinism.

Lane re-measurement (24 cases, multi_sentence_response public/v1):

  flag off: articulate=0.0833, disclosure=0.1667, unarticulate=0.7500
  flag on : articulate=1.0000, disclosure=0.0000, unarticulate=0.0000

The two previously-unarticulate WALKTHROUGH cases ("Walk me through
inference.", "Walk me through recall.") now engage the planner and
render as deterministic teaching-chain walks:

  "Inference is a conclusion drawn from premises by reasoning.
   Inference requires evidence."

  "Recall is to retrieve a stored state from memory.
   Recall reveals memory."

Each surface is grounded entirely in pack glosses and reviewed
teaching chains — no fabricated walk steps.

Critical gates all green:
* flag off cognition byte-identical:
  public 100/100/91.7/100, holdout 100/100/83.3/100
* smoke suite 67/67
* 91/91 planner tests pass (contract / behavior / compound / helper
  / render / walkthrough)

The 0.875 connective_present_rate remaining flag-on (3 cases without
expected connectives) is the only gap left, and it's now a render-
template question rather than a planner gap.
2026-05-19 12:29:20 -07:00
Shay
7af7892dd8 feat(intent+discourse): CompoundIntent + sub-plan composition
Adds compound-intent decomposition for prompts that ask multiple
things in one turn ("What is X, and why does it matter?",
"Explain X, but how does it work?", "What is X, and what is Y?").

Three landings in one PR (rule says additive; the three pieces
are inseparable for the runtime hook to do anything useful):

1. generate/intent.py
   * New ``CompoundIntent`` frozen dataclass — ordered tuple of
     ``DialogueIntent`` parts + raw_text + ``.primary`` back-compat
     accessor + ``.is_compound()`` helper.
   * New ``classify_compound_intent(prompt)`` sibling to
     ``classify_intent``.  Pure, deterministic, byte-stable.  Splits
     on closed connector list (``,\s+(and|but|because|while)\s+``);
     anaphoric tails ("why does it matter") get the prior part's
     subject substituted ("why does truth matter") then are
     classified independently.
   * ``classify_intent`` return shape is untouched — every existing
     caller still receives ``DialogueIntent``.
   * No new ``IntentTag`` introduced.  v1 semantic approximation:
     "why does X matter" routes to ``CAUSE(X)``; "matter" means
     causal/relevance support, not metaphysical importance.

2. generate/discourse_planner.py
   * New ``plan_compound_discourse(compound, mode, bundles)`` —
     concatenates per-part sub-plans in source order with a
     ``TRANSITION`` bridge (fact=None) between consecutive parts.
     No cross-part re-sorting.
   * New private kw-only ``_exclude_facts`` parameter on
     ``plan_discourse`` so subsequent sub-plans can avoid emitting
     the same facts the prior sub-plans already used (prevents
     "Truth is X. Truth is X." duplicates on shared-subject
     compounds).  Public signature ``(intent, mode, bundle)`` is
     unchanged.

3. chat/runtime.py
   * Helper ``_maybe_apply_discourse_planner`` now consults the
     compound classifier first.  When the prompt is multi-part it
     builds per-part bundles and calls ``plan_compound_discourse``;
     otherwise it follows the previous single-intent path.
   * Compound bypass: when upstream tagged the surface ``oov`` /
     ``none`` because the flat classifier saw a polluted subject
     (e.g. ``"truth, and why does it matter"``), but the compound
     decomposition reveals a pack-resident primary subject, the
     planner engages on the decomposed parts.  This narrowly widens
     the gate exclusively for compound prompts with substrate.
   * BRIEF mode upgrades to EXPLAIN for compound prompts —
     single-anchor sub-plans on shared subjects would emit duplicate
     anchor sentences in BRIEF.
   * Return shape widened to ``tuple[str, str] | None`` —
     ``(rendered_surface, new_source_tag)``.  ``new_source_tag`` is
     ``"teaching"`` when the plan uses any teaching fact, else
     ``"pack"`` — so downstream labels reflect actual provenance
     even on the compound bypass.  Both cold and warm call sites
     updated to apply both fields.

24 new tests pin: compound decomposition correctness, source-order
preservation across sub-plans, anaphoric-followup rewriting,
deterministic byte-stable plans, no new IntentTag introduced,
fact-dedup across sub-plans, compound-bypass engagement, and
source-tag correction on planner-engaged surfaces.

Lane re-measurement after 3 compound cases added to cases.jsonl
(24 total cases):

  flag off: articulate=0.0833, disclosure=0.1667, unarticulate=0.7500
  flag on : articulate=0.9167, disclosure=0.0000, unarticulate=0.0833

Note: disclosure flag-on dropped to 0.0 because the source-tag
correction now correctly labels compound-bypass surfaces as
``pack/teaching`` instead of letting the upstream ``oov`` label
inflate disclosure.  The two remaining unarticulate cases flag-on
are the walkthrough prompts targeted by the next landing.

Critical gates all green:
* flag off cognition byte-identical: public 100/100/91.7/100
* smoke suite 67/67
* 32/32 planner tests pass (helper + render + compound)
* 18/18 compound classifier tests pass
2026-05-19 12:23:58 -07:00
Shay
07fefb923c feat(evals): articulate/disclosure/unarticulate partition
Tightens the multi_sentence_response lane predicates so OOV
invitations and refusal disclosures can no longer be counted as
articulate capability.  Three new metrics partition the case space:

  articulate_sentence_rate  - >=2 sentences AND grounded in
                              {pack, teaching}.  Real capability.
  disclosure_sentence_rate  - >=2 sentences AND grounded in
                              {oov, refusal, none}.  Structural
                              multi-sentence from disclosure templates.
  unarticulate_rate         - <2 sentences regardless of source.

The three sum to 1.0 (modulo rounding) by construction.  The
doctrine-correct headline is now ``articulate_sentence_rate``;
``multi_sentence_rate`` is kept as a continuity metric only.

2 new tests pin: (a) the three-way partition is total and disjoint
(articulate + disclosure + unarticulate == 1.0); (b) OOV/refusal
disclosure surfaces contribute to disclosure_sentence_rate but
never to articulate_sentence_rate.

Live A/B on 21 cases under the new partition:

  flag off: articulate=0.0952, disclosure=0.0476, unarticulate=0.8571
  flag on : articulate=0.8571, disclosure=0.0476, unarticulate=0.0952

Planner lift is +76pp on articulate.  Disclosure stays flat across
the flag (the planner gate correctly leaves disclosure surfaces
alone).  The remaining 9.5pp unarticulate flag-on is the genuine
miss list (walkthrough + compound prompts) that the next two
landings will target.

contract.md updated to make articulate_sentence_rate the headline
and to document the partition explicitly.

cognition eval byte-identical: public 100/100/91.7/100.
smoke suite 67/67.
2026-05-19 12:13:44 -07:00