Commit graph

8 commits

Author SHA1 Message Date
Shay
c3d139a2ba docs(cli): self-explanatory demos — preambles + per-directory READMEs
Two-pronged self-documentation pass so reviewers / investors / the
future team can revisit any artifact cold and immediately understand
what it tests, what to expect, and what to do if the numbers shift.

Inline preambles (`core demo`):

  Before each demo's results table, print a structured preamble:
    - WHAT THIS DEMO TESTS          mechanism + corpus shape
    - WHAT TO EXPECT IF WORKING     concrete pass numbers
    - WHAT TO LOOK FOR              specific signals on regression
    - WHEN TO TWEAK                 falsifiability + corpus authoring rules

  Suppressed under --json so machine-readable output is uncluttered.
  Wired into:
    core demo phase5      (5-family stratified mechanism-isolation)
    core demo phase6      (3-condition head-to-head vs baseline)
    core demo all         (combined; both preambles + a "what this means"
                           summary after the combined table)

Per-directory READMEs:

  evals/forward_semantic_control/results/README.md
    - Inventory of every JSON report with headline metrics
    - Per-report interpretation guide ("when to look here")
    - Per-case schema reference
    - "When something looks wrong" troubleshooting tree
    - Cross-links to ADRs, runtime_contracts, findings docs

  evals/forward_semantic_control/public/v2_phase5/README.md
    - The five failure-mode families, geometric construction, and
      expected behaviour per mode
    - Case schemas (single-step + chained) with field semantics
    - How cases were geometrically mined (phase5_mine.py)
    - Authoring rules: add cases, never relax assertions

  evals/forward_semantic_control/public/v2_phase6_demo/README.md
    - The three conditions with case counts and what each proves
    - Why the baseline is in-system (not a transformer LLM) — table
    - Case schema with the `condition` field
    - Authoring rules: surface specific asymmetry, never relax predicate

  evals/forward_semantic_control/public/inner_loop_benign/README.md
    - Why this corpus exists (replaces adversarial-by-accident v1/dev)
    - The Cl(4,1) signature quirk (23/85 tokens with negative
      self-cga_inner) and the 0.25 self-score authoring filter
    - Expected exhaustion_rate per condition
    - How to verify a new case before committing (one-liner snippet)

New contract tests (tests/test_cli_demo.py::TestDemoPreambles + ::TestResultsReadme):
  - Phase 6 preamble explains C1/C2/C3 and the in-system baseline rationale
  - Phase 5 preamble explains all five families AND that δ is falsifiable
  - Preamble suppressed under --json (parseable JSON from byte 0)
  - `demo all` runs both preambles + a "what this means" summary
  - results/README.md mentions every phase report file
  - All three corpus READMEs exist

Tests: 1107 passed, 2 skipped (+8 from preceding baseline).

No mechanism changes — all additions are documentation surface.
2026-05-17 16:39:50 -07:00
Shay
36aad75202 feat(cli): ADR-0024 chain test-suite aliases + core demo subcommand
Two layers of CLI surface so reviewers / investors / industry
observers can run the ADR-0024 chain evidence end-to-end without
typing test file paths or hunting for runner scripts.

Layer 1 — test-suite aliases:
  core test --suite refusal     (Phase 2 typed refusals)
  core test --suite margin      (Phase 3 / ADR-0026 ranked-with-margin)
  core test --suite rotor       (Phase 4 / ADR-0025 rotor admissibility)
  core test --suite inner-loop  (ADR-0024 inner-loop, all 4 sub-tests)
  core test --suite phase5      (stratified mechanism-isolation)
  core test --suite phase6      (3-condition comparative demo)
  core test --suite adr-0024    (full chain, 98 tests, ~2 min)

Layer 2 — `core demo` subcommand:
  core demo phase5              stratified pass/refuse table + per-family
                                breakdown (5 families, both modes)
  core demo phase6              three head-to-head verdicts vs baseline
                                (replay determinism / traced rejection /
                                coherent refusal)
  core demo all                 both phases + combined summary
  core demo list-results        index every JSON report in the central
                                results directory with headline metrics

All demo runs:
  - Write fresh JSON to evals/forward_semantic_control/results/
  - Refresh the results/index.json manifest so reviewers see every
    available report in one place
  - Accept --json for machine-readable output

Central results directory: evals/forward_semantic_control/results/
  phase2_inner_loop_report.json
  phase3_v2_report.json
  phase4_characterization_*.json
  phase5_report.json
  phase5_benign_inner_loop_report.json
  phase6_demo_report.json
  index.json (auto-generated manifest)

Files:
  core/cli.py                   — +9 suite aliases, +cmd_demo (3 targets +
                                  list-results), +index manifest writer
  tests/test_cli_demo.py        — 14 contract tests pinning Layer 1 + 2
  evals/forward_semantic_control/results/index.json — auto-generated

Tests: 1099 passed, 2 skipped (+14 from Phase 6 baseline).
2026-05-17 16:21:37 -07:00
Shay
a0765066b4 feat(adr-0024): Phase 6 — comparative demo, three head-to-head conditions
Closes the 6-phase ADR-0024 chain with a focused comparative demo
that distinguishes CORE (inner-loop + margin + typed refusals) from
the in-system boundary-only baseline (ADR-0023 ablation).

Three conditions, all passing under contract tests:

  C1. Replay determinism
        baseline: 8/8 stable across 5 reruns
        CORE:     8/8 stable across 5 reruns
        CORE additionally folds refusal_reason into trace hash so
        refusal events are replayable evidence.

  C2. Traced rejection
        baseline emits forbidden: 3/3 (admits=False but walk continues)
        CORE corrects-or-refuses:  3/3
        CORE rejection in trace:   3/3
        Demonstrates that inner-loop is causally responsible for the
        selection difference between baseline and CORE.

  C3. Coherent refusal
        baseline typed refusals:        0/3 (never raises typed refusal)
        baseline emits inadmissible:    3/3
        CORE typed refusals:            3/3 (all INNER_LOOP_EXHAUSTION)
        Demonstrates that typed refusal with rejected_attempts evidence
        is new in CORE, not present in boundary-only.

Why in-system baseline (not LLM):
  A transformer-LLM comparison would be non-deterministic by
  construction, could not be CI-enforced, and would be apples-to-
  oranges (different corpus / training / sampling).  The honest
  comparison is the ablation: same codebase with the Phase 2-5
  additions disabled.

Files:
  evals/forward_semantic_control/phase6_demo.py
  evals/forward_semantic_control/public/v2_phase6_demo/cases.jsonl   (8 cases)
  evals/forward_semantic_control/results/phase6_demo_report.json
  tests/test_phase6_demo.py                                          (17 passing)
  docs/evals/phase6_comparative_demo.md

Tests: 1085 passed, 2 skipped (+17 from Phase 5 baseline).

This closes the ADR-0024 6-phase chain:
  Phase 1 — pack-grounded fixture + architectural finding   (3940290)
  Phase 2 — typed refusals + trace fold                     (310793a)
  Phase 3 — ADR-0026 ranked-with-margin                     (639e107)
  Phase 4 — ADR-0025 rotor / frame admissibility            (542e13d)
  Phase 5 — stratified 5-family mechanism-isolation         (b664984)
  Phase 6 — comparative demo                                (this commit)
2026-05-17 16:02:37 -07:00
Shay
b6649848a6 feat(adr-0024): Phase 5 — stratified mechanism-isolation across 5 failure-mode families
Authors a 20-case corpus stratified across five geometric failure-mode
families and a separate 10-case benign corpus for the
EXHAUSTION_CEILING lane:

  A. near_forbidden_correct_endpoint  (6 cases, gaps 0.002 to 0.55)
  B. near_equal_admissible             (5 cases, diffs ≤ 0.01)
  C. no_admissible_path                (3 cases, honest refusal)
  D. multi_step_admissibility          (3 chained cases)
  E. heterogeneous_relation            (3 chained cases, blade-switching)

phase5_runner runs each case under BOTH threshold and ADR-0026 margin
modes and reports per-family pass_rate, refusal_rate, and (for Family
A) rejection_traced_rate + boundary_overridden_rate.

Headline:
  pass_rate_threshold = 1.00 (20/20)
  pass_rate_margin    = 1.00 (20/20)
  mechanism_isolated  = true (both modes, all five families)
  replay determinism  = byte-identical across 3 reruns

Family C refuses with RefusalReason.INNER_LOOP_EXHAUSTION in both
modes (load-bearing evidence for ADR-0024 Phase 2 typed refusals).
Family B refuses under margin mode (validates ADR-0026 δ=0.4 gate).

Benign inner-loop corpus for EXHAUSTION_CEILING ≤ 0.05 gate:
  boundary_only:    exhaustion 0.00, pass 1.00
  null_control:     exhaustion 0.00, pass 1.00
  inner_loop_t0:    exhaustion 0.00, pass 1.00
  inner_loop_tpos:  exhaustion 0.00, pass 1.00 (threshold 0.25)

Geometric finding documented while authoring the benign corpus:
23 of 85 pack tokens have negative self-cga_inner under Cl(4,1).
Tokens with self-score ≤ 0 cannot serve as single-token expected
endpoints in threshold mode — the algebra's Lorentzian signature
forbids this geometrically.  Phase 5 benign corpus draws expected
endpoints from the 62-token positive-self-score subset.  This is
consistent with Phase 4 characterization: no static threshold
delivers separation_quality ≥ 0.8 — the margin lane survives
because margin compares differences, not absolute scores.

Files:
  evals/forward_semantic_control/public/v2_phase5/cases.jsonl
  evals/forward_semantic_control/public/inner_loop_benign/cases.jsonl
  evals/forward_semantic_control/phase5_runner.py
  evals/forward_semantic_control/phase5_mine.py
  evals/forward_semantic_control/results/phase5_report.json
  evals/forward_semantic_control/results/phase5_benign_inner_loop_report.json
  tests/test_phase5_corpus.py        (20 passing)
  docs/evals/phase5_stratified_findings.md

Tests: 1068 passed, 2 skipped (+20 from Phase 4 baseline).
2026-05-17 15:51:59 -07:00
Shay
394029008e feat(adr-0024): Phase 1 addendum — retire v1/dev fixture rot
Rewrite v1+dev FSC cases with pack-grounded tokens drawn from
en_core_cognition_v1. Closes the 9/9 region-construction failure
recorded in Phase 4 (chain_tokens alpha/beta/gamma/delta/etc. were
ungrounded in the active pack).

Token mappings preserve each case's test pattern:
* alpha→beta→gamma→delta  →  tone→evidence→memory→wisdom (causes)
* mu→nu→omicron           →  voice→memory→wisdom (means)
* pi→rho→sigma→tau        →  question→answer→understanding→wisdom (precedes)
* upsilon→phi→chi         →  word→discourse→narrative (part_of)
* eta/theta/zeta + means-distractors → symbol/word/meaning + image/light

Result post-rewrite:
* skipped_count: 9/9 → 0/9 (region constructible)
* causal_attribution_valid: True (preserved)
* code_path_residual: 0.0 (preserved)
* inner_loop_t0 hash stability: 1.0 (preserved)
* best_separation_quality: 0.0 → 0.056 (still below 0.8 gate)

The rewrite exposes a deeper architectural finding documented in the
ADR addendum: v1/dev case schema (prime + chain_tokens) probes
teaching-driven walk (ADR-0022/0023), not the inner-loop's
blade-admissibility mechanism (ADR-0024). The Phase 2 corpus-
observation runner's reuse of v1/dev was a categorical error.
v1/dev belong to the boundary-walk lane (runner.py); v2 belongs to
the inner-loop lane (v2_runner.py). Phase 5 will author the benign
inner-loop corpus the EXHAUSTION_CEILING gate was designed against.

Tests pinning new state:
* TestV1ChainBladeUngrounded → TestV1ChainBladePostGrounding
  (assertions inverted: skipped_count == 0; separation_quality < 0.5)
* TestPhase2 (unchanged) continues to assert causal_attribution_valid
  and hash stability; exhaustion remains a finding, not an invariant.
2026-05-17 14:43:34 -07:00
Shay
8146844d90 feat(adr-0024): Phases 2-5 — corpus eval, v2 adversarial, threshold characterization, ADR-0025 design note
Phase 2 — Corpus observation runner (inner_loop_runner.py):
- Four-condition matrix: boundary_only / null_control / inner_loop_t0 / inner_loop_tpos.
- Added `inner_loop_force_admit` to generate() — exercises the inner-loop
  code path but force-breaks on first candidate.  Eval-only null control:
  isolates rejection as the causal factor for any pass-rate delta.
- Metrics: pass_rate, mean_rejection_count_per_turn,
  non_empty_rejected_attempts_rate, exhaustion_rate (gated at 5%),
  mean_admissibility_checks_per_turn, mean/p95 added_latency_ms,
  trace_hash_stability across 5 reruns per case.
- Finding on v1+dev: causal_attribution_valid=True, code_path_residual=0.0,
  but exhaustion_rate=0.33 at t=0 — chain outer-product blade is
  geometrically blind to the active pack.
- Tests (tests/test_inner_loop_phase2.py, 5 pass): pin
  causal-attribution and live-corpus trace-hash stability invariants.

Phase 3 — Mechanism-isolation v2 corpus (5 cases, v2_runner.py):
- Synthetic adversarial cases with controlled geometry — each case
  specifies seed_token, admissible_tokens, relation_blade_token, and
  admissibility_threshold.  Field state is constructed directly from
  the seed token versor, not via priming.
- For every case: boundary-only selects the forbidden decoy and
  inner-loop selects the expected endpoint with the forbidden token
  appearing in rejected_attempts.
- Result: mechanism_isolated=true on 5/5.  boundary_decoy_rate=1.0,
  rejection_traced_rate=1.0.  Inner-loop rejection is demonstrably
  doing causal semantic work on real packs.
- Tests (tests/test_inner_loop_phase3.py, 8 pass): GATE on
  mechanism_isolated.

Phase 4 — Threshold characterization (threshold_characterization.py):
- Distribution mapping per-case AND globally on v1+dev, v2, combined.
- Per-threshold sweep over [-1.0, -0.5, 0.0, 0.1, 0.25, 0.5, 1.0].
- Finding: per-case geometry separates cleanly (correct_min > incorrect_max
  on every v2 case), BUT no global static threshold passes the
  separation_quality >= 0.8 gate.  Blade norms vary ~10x across cases.
- Static thresholds (global, relation-typed, or constant frame-derived)
  are geometrically insufficient.  Per-case-normalized thresholds
  (e.g. fraction of blade self-score) are the recommended next step.
- v1 chain-token outer-product cases all skipped — the corpus's chain
  tokens (alpha, beta, gamma, delta) are not grounded in the active
  pack.  Load-bearing finding for ADR-0025 region construction.
- Tests (tests/test_inner_loop_phase4.py, 5 pass): pin the finding
  diagnostically (not gated).

Phase 5 — ADR-0025 design note (draft):
- No code changes proposed.  Scopes three architectural questions:
  (1) home (algebra/versor.py vs field/propagate.py vs generate/) —
      preliminary stance: algebra/versor.py.
  (2) threshold scheme (blade-normalized fraction recommended over
      static; learned/adaptive rejected for determinism).
  (3) teaching-loop boundary — Stance A confirmed: rejections are
      runtime hygiene only, no entanglement with teaching/*.
- Decisions to be closed before Draft → Accepted.

Phase 1 acceptance criteria from previous commit (7fccf36) carry
forward: wired, deterministic-when-wired, legacy hash preserved.

Suite: 1014 passed, 0 failed, 2 skipped.
2026-05-17 14:07:50 -07:00
Shay
c504796165 feat(adr-0023): Forward Semantic Control proof evidence — Accepted
Extends ADR-0022 with inspection/telemetry surfaces that turn the
forward-semantic-control claim from "mechanism exists" into "mechanism
is causally load-bearing, isolated, and replayable."

Changes (zero runtime semantics change beyond a pipeline bug fix):

- AdmissibilityTraceStep + GenerationResult.admissibility_trace —
  per-transition record of region label, candidates before/after,
  selected destination, and the typed AdmissibilityVerdict.
- ChatResponse + CognitiveTurnResult expose admissibility_trace,
  admissibility_trace_hash, ratification_outcome,
  region_was_unconstrained.
- hash_admissibility_trace + compute_trace_hash fold the new fields
  only when they carry non-default values, so pre-ADR-0023 turn
  hashes remain byte-preserved.
- Same-path ablation leg in evals/forward_semantic_control/runner.py:
  generate(..., region=None) vs generate(..., region=R) on the same
  runtime/vocab/field/persona/prompt — isolates the region as cause.
- Lane expansion: 8 dev cases across 4 relation axes (cause, means,
  precedes, part_of) including 2 adversarial distractor cases.
- Lane metrics now report region_only_constrained_rate /
  region_only_gap / ratified_rate / demoted_rate / passthrough_rate /
  passthrough_on_scored.
- Bug fix surfaced by the new accounting: _ratify_intent looked up
  runtime.vocab (always None) instead of runtime.session.vocab —
  every production turn was silently PASSTHROUGH. Fixed; ratifier
  now actually gates intent classification.
- tests/test_admissibility_trace.py: hash determinism +
  pre-ADR-0023 byte-preservation tests.

Lane evidence (dev, 8 cases):
- constrained_pass_rate=0.80, causality_gap=0.80
- region_only_gap=1.00 (5/5 with region, 0/5 without — same path)
- ratified_rate=1.00, passthrough_on_scored=false
- overall_pass=true

Bench: 9.41s / 20 turns (~470ms/turn), well inside the +5% budget.

Full pytest: 922 passed, 1 pre-existing failure
(test_language_pack_cache, unrelated to ADR-0023).
2026-05-17 12:55:19 -07:00
Shay
21c22b2201 feat(adr-0022): Forward Semantic Control — Accepted
Resolves all 5 TBDs and closes all 8 acceptance gates for ADR-0022.

TBD-1 (intent oracle): regex seed + field ratification —
generate/intent_ratifier.py. RATIFIED / DEMOTED / PASSTHROUGH
outcomes; DEMOTED routes through honest refusal.

TBD-2 (region intersection algebra): generate/admissibility.py.
Token-set composition via sorted set intersection; blade composition
via outer product with zero-blade as neutral element; rotor
composition via sandwich conjugation routed through
algebra.backend.versor_apply (Rust parity preserved by construction).
Empty intersections preserved — no silent relaxation.

Wiring: propose() and generate() accept an AdmissibilityRegion
(default None preserves legacy behavior); pipeline ratifies intent
at step 1b.i before graph construction.

Eval lane: evals/forward_semantic_control/ — both legs run against
CognitiveTurnPipeline (constrained) vs bare ChatRuntime.chat()
(unconstrained baseline). Dev (3 cases) and public/v1 (1 case) both
report overall_pass=true, causality_gap=1.0, coincidence_rate=0.0.
Chain-endpoint probe surfaces 'delta' only under forward semantic
control.

Bench cost (30 turns): -2.8% wall-clock (within +5% budget the ADR
set for the ratification gate on every turn). 138x cheaper than
Sonnet 4.5; main was 142x.

Tests: 33 new (25 admissibility + 8 ratifier). Full suite 912/913
pass — the single failure is pre-existing pack-size drift on main,
unrelated.
2026-05-17 12:10:20 -07:00