Squashes the arc's work into one commit; the workflow-file edit it originally carried is excluded (see the end of this message). ## Lane 1 — Workbench recorded a proved answer as ungrounded With deduction_serving_enabled ratified ON (ADR-0256), workbench/api.py's live chat route builds a bare ChatRuntime(), so the deduction composer decides Workbench turns and stamps grounding_source="deduction" — but _coerce_grounding_source carried a hand-copied whitelist of the six pre-arc labels and silently rewrote anything else to "none". The runtime comment reasoned this was inert because "REPL turns do not flow through Workbench's CognitivePipelineRecord path". True, and irrelevant: the traffic flows the other way. Stale since 2026-07-24. Scope is one field. workbench/api.py:818 prefers TurnEvent.epistemic_state, which read epistemic_state_needed — honest. So the UNregistered path degraded honestly while the hand-copied whitelist asserted a falsehood; a second copy of a closed enum was worse than no copy. Hence registration AND derivation: GROUNDING_SOURCES exposes the Literal's members, and the coercion reads it. workbench-ui badges/tokens/snapshot follow; enumCoverage.test.ts forces atomicity. ## Lane 2 — the ratification ceremony The discovery loop was instrumented but not closed. teaching/ratification.py turns a reviewed decision into a chain record, a corpus commit, and a receipt. Its design turns on one observation: _ratified_rows DROPS unadmissible rows silently — correct when serving, a trap when ratifying, because the file grows, the commit lands, and the band count does not move. So the ceremony refuses to call an append a ratification until it has re-read the curriculum through the real loader and seen the chain arrive; a non-admitted append is rolled back. Validation is a pre-flight courtesy, admission is the proof. Arena queue entry and ledger reseal are deliberately NOT performed (bridge rule 1); the receipt names them. Front door: `core proposal-queue ratify`, a sibling of `review` rather than a flag on it. ## Lane 3 — structural closures - ADR-0263 gains rule 5: absence policy is DECLARED in CAPABILITY_LEDGERS, not passed at the call site. An AST-matched test fails if a serving path passes missing_ok again. - Deductive suite added WHOLE to the pre-push gate: 285 tests in 29s against smoke's 216 in 62s, so no coverage trade was needed. - Smoke/CI parity assertion made bidirectional. It was one-directional, and had drifted. - test_prior_surface_deduction_binding.py pins correction binding on the deduction path. The review's diagnosis did NOT reproduce — hash_surface moves in lockstep — so it pins what is there. Mutation-checked. - Domain-keyed ADR index over 312 flat-numbered files, explicitly partial. - Arc-close brief template, plus this arc's own brief filled in against it. ## Lanes 4 and 5 — two premises falsified by measurement, one of them mine Math 4.2: baseline reproduced (correct=5 wrong=0 refused=495); all four named cases traced to one seam with each gap isolated by one-variable probes. Then the number that changes the recommendation: the gap blocking case 0000 affects 1 case in 500, the 'than' gap blocking 0001 affects 2. ADR-0251's prohibition on per-case growth now rests on a count. No reader change made. CGA: versor_condition is 0.22% of a turn, not the "~10x proof latency" I claimed — that multiplied an isolated microbenchmark by a call count and compared it to a single verdict's latency. The real cost is geometric_product at 33,986 calls/turn (~73%) via cga_inner in search paths. The obvious closed form is NOT bit-exact (954/4000 in f32); backend.vault_recall's serial fold IS (3000/3000, worst-rel 0) and is the correct target. cargo test could not run — static.crates.io is denied by the sandbox network policy — so the Rust parity question stays open and the typestate lane is carried forward, not shipped uncompiled. ## Not landed: three lines owed to .github/workflows/smoke.yml The CI smoke gate is narrower than the local one — test_pack_draft_serve_boundary.py (ADR-0253 INV-33) has been local-only, unseen because the parity pin checked one direction. The edit was authored and rejected at push for lacking the `workflow` OAuth scope, so it is recorded as a named, dated PENDING_IN_CI exception rather than dropped: the assertion still fires on any new divergence, and a second guard fires once the three land. [Verification]: pre-push gates all green — smoke 236 passed, warmed_session 10 passed, deductive 285 passed. Ratification 14, ADR index 5, CLI suites 10. Grounding/epistemic sweep 741 passed 1 skipped. workbench-ui 598 passed across 73 files, tsc -b clean. capability index 11 passed, digest unchanged. Math holdout correct=5 wrong=0 refused=495. Committed chain corpora byte-unchanged after the tests that write to them. Environment caveat: the repo pins requires-python ==3.12.13, which uv cannot fetch for linux-x86_64, so `uv sync --locked` fails. All Python runs used a scratch venv on 3.12.11 with declared deps — not the locked universe, not the full ~12k suite. The pin was left untouched. Re-run on a 3.12.13 host before treating this as merge evidence. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FduW6Krm3PPQv3P5iwBYtx
192 lines
7.8 KiB
Python
192 lines
7.8 KiB
Python
"""First-class epistemic-state and normative-clearance enums.
|
|
|
|
Phase 3 of the epistemic-state program makes the ratified taxonomy
|
|
queryable from runtime artifacts without entangling callers with the
|
|
scope document. The values are intentionally lower_snake_case so they
|
|
serialize stably into JSONL, metadata dictionaries, and test fixtures.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import Enum, unique
|
|
from typing import Any, Literal, get_args
|
|
|
|
|
|
GroundingSource = Literal[
|
|
"pack",
|
|
"teaching",
|
|
"vault",
|
|
"partial",
|
|
"oov",
|
|
"none",
|
|
"deduction",
|
|
"curriculum",
|
|
]
|
|
"""Ratified grounding-source labels.
|
|
|
|
Single source of truth for the values ``epistemic_state_for_grounding_source``
|
|
maps, the cold-start-grounding lane validates, the Workbench API coerces
|
|
against, and the Workbench UI badges bind to (ADR-0162 §3d). Adding a value
|
|
here without adding a corresponding badge fails the build-time enum coverage
|
|
test under ``workbench-ui/``.
|
|
|
|
``deduction`` (ADR-0256) and ``curriculum`` (ADR-0262) joined the closed set
|
|
once deduction serving was ratified ON: ``workbench/api.py``'s live chat route
|
|
builds a bare ``ChatRuntime()``, so those composers decide Workbench turns and
|
|
stamp their label on the ``TurnEvent``. While the labels were unregistered the
|
|
API's coercion floored them to ``"none"`` — recording a proved answer as
|
|
ungrounded in a durable audit artifact. Registration is what makes the
|
|
recorded provenance true; ``GROUNDING_SOURCES`` below is what keeps any second
|
|
copy of this set from drifting away from it again.
|
|
"""
|
|
|
|
GROUNDING_SOURCES: frozenset[str] = frozenset(get_args(GroundingSource))
|
|
"""The runtime-iterable form of :data:`GroundingSource`.
|
|
|
|
A ``Literal`` is invisible at runtime, which is why consumers historically
|
|
restated its members by hand — and why one of those restatements silently fell
|
|
behind. Anything that needs to *check* a grounding source reads this set;
|
|
nothing re-types the members.
|
|
"""
|
|
|
|
|
|
@unique
|
|
class EpistemicState(str, Enum):
|
|
PERCEIVED = "perceived"
|
|
EVIDENCED = "evidenced"
|
|
EVIDENCED_INCOMPLETE = "evidenced_incomplete"
|
|
VERIFIED = "verified"
|
|
DECODED = "decoded"
|
|
DECODED_UNARTICULATED = "decoded_unarticulated"
|
|
INFERRED = "inferred"
|
|
UNVERIFIED_POSSIBLE = "unverified_possible"
|
|
UNVERIFIED_NOVEL = "unverified_novel"
|
|
CONTRADICTED = "contradicted"
|
|
AMBIGUOUS = "ambiguous"
|
|
UNDETERMINED = "undetermined"
|
|
SCOPE_BOUNDARY = "scope_boundary"
|
|
COMPUTATIONALLY_BOUNDED = "computationally_bounded"
|
|
EPISTEMIC_STATE_NEEDED = "epistemic_state_needed"
|
|
|
|
|
|
@unique
|
|
class NormativeClearance(str, Enum):
|
|
CLEARED = "cleared"
|
|
VIOLATED = "violated"
|
|
UNASSESSABLE = "unassessable"
|
|
SUPPRESSED = "suppressed"
|
|
|
|
|
|
def coerce_epistemic_state(value: object | None, *, default: EpistemicState = EpistemicState.UNDETERMINED) -> EpistemicState:
|
|
if isinstance(value, EpistemicState):
|
|
return value
|
|
if isinstance(value, str):
|
|
normalized = value.strip().lower().replace("-", "_")
|
|
for state in EpistemicState:
|
|
if normalized in {state.value, state.name.lower()}:
|
|
return state
|
|
return default
|
|
|
|
|
|
def coerce_normative_clearance(value: object | None, *, default: NormativeClearance = NormativeClearance.UNASSESSABLE) -> NormativeClearance:
|
|
if isinstance(value, NormativeClearance):
|
|
return value
|
|
if isinstance(value, str):
|
|
normalized = value.strip().lower().replace("-", "_")
|
|
for clearance in NormativeClearance:
|
|
if normalized in {clearance.value, clearance.name.lower()}:
|
|
return clearance
|
|
return default
|
|
|
|
|
|
def clearance_from_verdicts(verdicts: Any = None, *, safety_verdict: Any = None, ethics_verdict: Any = None) -> NormativeClearance:
|
|
"""Derive the orthogonal normative-clearance state for a turn.
|
|
|
|
Refusal replacement is a SUPPRESSED surface. Otherwise any failed
|
|
safety/ethics verdict is VIOLATED. If every available verdict is
|
|
upheld but at least one result was not runtime-checkable, the turn is
|
|
UNASSESSABLE rather than positively CLEARED. Only fully upheld and
|
|
fully runtime-checkable verdicts are CLEARED.
|
|
"""
|
|
if verdicts is not None:
|
|
if bool(getattr(verdicts, "refusal_emitted", False)):
|
|
return NormativeClearance.SUPPRESSED
|
|
safety_verdict = safety_verdict if safety_verdict is not None else getattr(verdicts, "safety_verdict", None)
|
|
ethics_verdict = ethics_verdict if ethics_verdict is not None else getattr(verdicts, "ethics_verdict", None)
|
|
|
|
saw_unassessable = False
|
|
saw_verdict = False
|
|
for verdict in (safety_verdict, ethics_verdict):
|
|
if verdict is None:
|
|
continue
|
|
saw_verdict = True
|
|
if not bool(getattr(verdict, "upheld", True)):
|
|
return NormativeClearance.VIOLATED
|
|
results = tuple(getattr(verdict, "results", ()) or ())
|
|
if any(not bool(getattr(result, "runtime_checkable", True)) for result in results):
|
|
saw_unassessable = True
|
|
elif int(getattr(verdict, "runtime_checkable_count", 0) or 0) == 0:
|
|
saw_unassessable = True
|
|
if not saw_verdict or saw_unassessable:
|
|
return NormativeClearance.UNASSESSABLE
|
|
return NormativeClearance.CLEARED
|
|
|
|
|
|
def normative_detail_from_verdicts(verdicts: Any = None, *, safety_verdict: Any = None, ethics_verdict: Any = None) -> str:
|
|
"""Return a sorted, comma-separated string of violated boundary/commitment IDs.
|
|
|
|
Non-empty only when normative clearance is VIOLATED or SUPPRESSED —
|
|
i.e. when at least one runtime-checkable boundary or commitment failed.
|
|
Returns "" when CLEARED or UNASSESSABLE so callers can test truthiness.
|
|
Uses the same duck-typing pattern as ``clearance_from_verdicts``.
|
|
"""
|
|
if verdicts is not None:
|
|
safety_verdict = safety_verdict if safety_verdict is not None else getattr(verdicts, "safety_verdict", None)
|
|
ethics_verdict = ethics_verdict if ethics_verdict is not None else getattr(verdicts, "ethics_verdict", None)
|
|
|
|
ids: list[str] = []
|
|
for r in getattr(safety_verdict, "results", []):
|
|
if getattr(r, "runtime_checkable", False) and not getattr(r, "upheld", True):
|
|
bid = getattr(r, "boundary_id", None)
|
|
if bid:
|
|
ids.append(str(bid))
|
|
for r in getattr(ethics_verdict, "results", []):
|
|
if getattr(r, "runtime_checkable", False) and not getattr(r, "upheld", True):
|
|
cid = getattr(r, "commitment_id", None)
|
|
if cid:
|
|
ids.append(str(cid))
|
|
return ",".join(sorted(ids))
|
|
|
|
|
|
def epistemic_state_for_grounding_source(source: str | None) -> EpistemicState:
|
|
"""Default runtime mapping for existing grounding-source labels."""
|
|
normalized = (source or "none").strip().lower()
|
|
# ``deduction`` / ``curriculum`` rank with the decoded sources rather than
|
|
# the evidenced ones: both are *decided* by the ROBDD entailment engine
|
|
# over ratified structure (an argument's own premises, or a subject's
|
|
# ratified curriculum), not retrieved as supporting evidence. Serving them
|
|
# authoritatively additionally requires a SERVE license on the sealed
|
|
# ledger — an unearned band is served DISCLOSED, which is a surface-level
|
|
# hedge and does not change how the turn was grounded.
|
|
if normalized in {"pack", "teaching", "vault", "deduction", "curriculum"}:
|
|
return EpistemicState.DECODED
|
|
if normalized == "partial":
|
|
return EpistemicState.EVIDENCED_INCOMPLETE
|
|
if normalized == "oov":
|
|
return EpistemicState.UNVERIFIED_NOVEL
|
|
if normalized == "none":
|
|
return EpistemicState.UNDETERMINED
|
|
return EpistemicState.EPISTEMIC_STATE_NEEDED
|
|
|
|
|
|
__all__ = [
|
|
"GROUNDING_SOURCES",
|
|
"EpistemicState",
|
|
"GroundingSource",
|
|
"NormativeClearance",
|
|
"clearance_from_verdicts",
|
|
"coerce_epistemic_state",
|
|
"coerce_normative_clearance",
|
|
"epistemic_state_for_grounding_source",
|
|
"normative_detail_from_verdicts",
|
|
]
|