Commit graph

3 commits

Author SHA1 Message Date
Shay
00c3968937
fix(ADR-0167): route contemplation and proposal replay by candidate domain (#363)
* fix(teaching): select proposal replay gate from candidate domain

* test(teaching): pin domain-selected proposal replay gates

* fix(teaching): make contemplation probes domain-aware

* test(teaching): pin domain-aware contemplation partition
2026-05-27 09:43:16 -07:00
Shay
08c5e0e82f
feat(ADR-0163.C): contemplation ingests admissibility exemplars and emits DerivedRecognizer proposals through the HITL corridor (#301)
Phase C is the first phase where operator-authored exemplar corpora
become engine-derived recognizer proposals automatically.  The math
thesis ("decodes, not generates") manifests in the math lane here.

Modules
- teaching/exemplar_ingest.py — pure-function loader for Phase B
  exemplar JSONLs.  ExemplarCorpus carries a sha256 digest over its
  canonical (sorted-by-exemplar_id, sort-keyed) bytes.
- teaching/recognizer_synthesis.py — per-category synthesizers
  (_synthesize_descriptive_setup_no_quantity / _temporal_aggregation /
  _rate_with_currency) distil a corpus into one RecognizerSpec.
  Determinism: same corpus -> byte-identical spec.  Narrowness: the
  spec records only observed sub-shapes; an out-of-corpus currency
  symbol or window unit does not match.  Phase B author_notes surface
  in canonical_pattern.unresolved_notes — never silently dropped.
- teaching/contemplation.py — contemplate_exemplar_corpus(corpus)
  returns a DiscoveryCandidate whose proposed_chain encodes the
  RecognizerSpec as a synthetic four-field chain plus the full
  recognizer_spec submap.  Evidence cites every exemplar's case_id.
- teaching/replay.py — run_admissibility_replay_gate(spec, *,
  active_corpus_path=None) runs cognition + G1..G5+S1 + GSM8K
  train_sample.  In-process baseline cache keyed on the active
  corpus digest.  WRONG-COUNT INVARIANT: if a candidate run lifts
  the GSM8K train_sample wrong count, gate returns
  replay_equivalent=False with
  regressed_metrics=["gsm8k_train_sample_wrong_count"].
- teaching/source.py — ProposalKind widened with "exemplar_corpus";
  exhaustive-match docs + tests updated.

CLI
- core teaching propose-from-exemplars <path> [--all] [--review-date]
  [--log] [--json].  Routes the candidate through the existing
  propose_from_candidate path with the admissibility gate substituted
  for the cognition-only run_replay_equivalence.  Never auto-accepts;
  proposals land as pending for operator review.

Tests (38 new)
- tests/test_exemplar_ingest.py (12) — load, digest stability,
  malformed-record rejection, file-name binding, read-only purity.
- tests/test_recognizer_synthesis.py (16) — determinism, purity,
  per-category subsumption, narrowness (out-of-corpus seeds rejected),
  author_notes surfaced.
- tests/test_admissibility_replay_gate.py (6) — happy path, cache
  hit/invalidation, WRONG-COUNT INVARIANT regression, capability-axis
  regression, cognition regression.
- tests/test_propose_from_exemplars_cli.py (4) — single corpus, --all,
  determinism, read-only snapshot.

Acceptance evidence (dry run)
- All three Phase B corpora produce replay_equivalent=true,
  wrong_count_delta=0.  Proposal IDs:
    descriptive_setup_no_quantity: 59223f13722f906a1cf9b65d9b01c990
    rate_with_currency:            46ce297f797ff16da12db5de422ca3c9
    temporal_aggregation:          a3b892546977c5f0f64c578d6052adbd
- G1..G5+S1 wrong=0 unchanged; GSM8K train_sample 3/47/0 unchanged.
- core test --suite smoke -q: 67 passed.
- uv run core eval refusal_taxonomy: case_digest
  d030f826cb0f4088771d90c52c8be2ff75054ab27c7d47eae8dbfe1225b2eea1
  unchanged.

Cross-refs: ADR-0163 (Phase C), ADR-0057 (gating discipline),
ADR-0151 (auto-proposal), ADR-0152 (learning-arc), ADR-0149/0154
(recognizer pipeline), ADR-0094 (ProposalSource), Phase A PR #297,
Phase B PR #298.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 12:26:56 -07:00
Shay
4eecf73a05 feat(adr-0056): Phase C1 — contemplation loop landed
Implements ADR-0056's cognitive surface: takes a Phase B
DiscoveryCandidate and returns an enriched candidate with composed
polarity, classified claim_domain, evidence pointers, and recursive
sub-questions.  No corpus mutation; no async; no LLM step.

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

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

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

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

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 10:06:18 -07:00