feat: bind served shadow recall evidence fields to exact V2/#157 state (#188) - #189
Merged
Conversation
#188) Admitted governed/exploratory items now present the exact risk_aware_shadow_v1 fresh evaluation the admission decision consumed, replacing the item-local review/conflict/verification epistemic heuristic on V2-bound profiles: - recall_signals.build_v2_evidence_fields: pure projection of the already-bound admission.v2 binding (source, profile/policy identity, decision hash, resolution status, epistemic/risk/retention state, effective #157 refs); impossible admitted combinations fail closed (V2EvidenceContractError) - top-level epistemic_state mirrors evidence.epistemic_state exactly - warning contract: evidence_unknown / evidence_contested / evidence_insufficient from the V2 state; risk_high / risk_unknown keep allowed high/unknown-risk exploratory items unmistakable; lifecycle marks (unreviewed, #159 stale/legacy_import) remain independently true - no second #157 selection, no second V2 evaluation, no per-item query, no provider call: evidence is computed after resolution from the decision - ranking, budgets, ordering, legacy packet (byte-for-byte), and the shadow-only rollout boundary are unchanged
…ity asserts, standalone query-count proof
…y items (#188) The human-readable mirror for risk_high said 'high risk — review required', which contradicts the exact V2 surface decision on an admitted exploratory candidate: semantic_exploratory may legitimately return surface_decision=allow with risk_state=high, served with warning_codes=[risk_high]. The text invented a review requirement the decision never imposed. Neutralize the mirror to 'high risk' (the machine-readable risk_high code is unchanged) and strengthen test_high_and_unknown_risk_stay_unmistakable_on_admitted_exploratory to prove the served packet stays internally consistent: surface_decision == allow, evidence.risk_state == high, risk_high in warning_codes, and no 'review required' claim in the human-readable warnings.
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #188 (ENG-RECALL-003C — parent #160, epic #153)
Summary
Admitted governed/exploratory shadow items now present the exact
risk_aware_shadow_v1V2/#157 fresh evaluation state that authorized admission — closing the gap whereadmission.v2.fresh.epistemic_state = "supported"whileitem.epistemic_state = "unknown"for the same admitted item.build_v2_evidence_fields(engram/recall_signals.py): one pure function projecting the already-boundRecallAdmissionDecision.v2into the servedevidenceblock. No second ENG-CLASSIFY-003 — Separate retention value from epistemic confidence and support versioned reassessment #157 selection, no per-itemmemory_assessmentsquery, no second V2 evaluation, no provider call — structurally (synchronous, no session parameter) and mechanically (counters pinned by tests).epistemic_statemirrorsevidence.epistemic_stateexactly; the item-local review/conflict/verification heuristic now serves only non-V2 local profiles (none registered).evidence_unknown/evidence_contested/evidence_insufficient/risk_high/risk_unknown(with_WARNING_TEXTmirrors). Impossible admitted combinations (non-currentresolution, non-allowsurface,not_applicableepistemic) fail closed viaV2EvidenceContractError.compute_signal_rank_score, utility weights), ordering, budgets, corpus eligibility, ENG-PROMOTION-003D — Persist promotion assessments and expose next-action state #159 local-withhold precedence,CERTIFIED_SERVING_PROFILES == {"legacy"}, legacy packet shape (byte-for-byte; new test pins noevidence/warning_codeskeys on legacy items), MCP surface, shadow read-only behavior. Noselection_statusadded to the V2 contract; no ENG-EVIDENCE-001 — Evidence-root-aware corroboration and usefulness lane #161/ENG-CALIBRATION-001 — Labeled admission evaluation and shadow-rollout certification #162/Context Ledger work.Representative before/after (governed-admitted qualified proposal)
admission.v2.fresh.epistemic_statesupportedsupportedepistemic_state(top level)unknown← mismatchsupportedwarning_codes["unreviewed", "evidence_unknown"]["unreviewed"]evidenceblock{source: v2_fresh_evaluation, …, epistemic_state: supported, risk_state: low, retention_state: retain, …}Warning matrix (test-pinned)
supportedunknownevidence_unknowncontestedevidence_contestedinsufficient_evidenceevidence_insufficientnot_applicableV2EvidenceContractErrorhighrisk_highunknownrisk_unknownlow/mediumLifecycle marks (
unreviewed,admission_assessment_stale,admission_legacy_import) remain where independently true (pinned with the canonical state in the stale-#159-binding test).Proof highlights
evidence.* == admission.v2.fresh.*field-by-field from the shared binding; DB tests re-verify against the real resolver path (test_served_evidence_state_is_the_exact_v2_fresh_evaluation— supported/unknown/contested/insufficient/high-risk/absent fixtures across both profiles).decision.v2; evaluation core runs exactly once per item per packet, bulk resolver once per packet (monkeypatchcounters); standalone resolverquery_countequals the packets' reported count; mutable item fields (confidence/trust/importance/counters/age/verification) cannot moveevidence.*with the decision held fixed.missing/stale/mismatched/unsupportedstay withheld, diagnosticv2identity intact, no served evidence block.Tests
tests/test_recall_signals.py: +10 unit tests (canonical serialization, warning matrix, local-derivation boundary, fail-closed, no-IO signature proofs).tests/test_recall_profile_semantic.py: evidence matrix integration test (real resolver), no-duplicate-evaluation/IO proof, read-only proof; pre-issue mismatch pins updated to the canonical contract.sdk/engram-client/tests/test_models.py:RecallResponseaccepts structuredevidenceblocks; unknown/null states stay structured, never numeric.Results
test_recall_signals.py50 passed;test_recall_profile_semantic.py+test_recall_v2_admission.py+test_recall_profiles.py108 passed; SDK model tests 8 passed.make check: lint +mypy --strict(engram 95 files, evals, SDK, MCP, hooks) clean; root suite failures are environment-only (noENGRAM_DATABASE_URLin that shell) and byte-identical to unmodifiedmain(diffed FAILED/ERROR lists).make compose-ci: passed — 3861 passed, 35 skipped against PostgreSQL 16 + pgvector under the non-owner app role (migrations, FORCE RLS, root/SDK/MCP/hooks suites).Remaining #160 slices (after this issue)
#157 enrichment on non-V2 paths (startup), signal-aware graph/tunnel expansion, diversity/root-redundancy + conflict-preserving packing, demonstrated-usefulness feedback, semantic Context Ledger receipts (packet is now receipt-ready), dogfood/exposure-concentration evaluation on the shadow surface (incl. keeping the V2 row corpus fresh), fresh #162 certification + default cutover.