pathway_memory: audit-consensus → retire wire
lakehouse/auditor 1 blocking issue: todo!() macro call in tests/real-world/scrum_master_pipeline.ts

When observer's hand-review explicitly rejects the output of a
hot-swap-recommended model, the matrix's recommendation was wrong
for this context. Auto-retire the trace so future agents don't
get the same poisoned recommendation in their preamble.

crates/vectord/src/pathway_memory.rs — add `trace_uid` to
HotSwapCandidate response and populate from the matched trace.
This gives consumers single-trace precision for /pathway/retire.

tests/real-world/scrum_master_pipeline.ts:
  - HotSwapCandidate interface gains trace_uid
  - new retirePathwayTrace() helper (fire-and-forget, fall-open)
  - in the obsVerdict reject branch: if hotSwap was active AND
    the rejected model is the hot-swap-recommended one AND
    observer confidence ≥0.7, fire retire and null hotSwap so
    post-loop replay bookkeeping doesn't double-process.
  - hotSwap declared `let` (was const) so it can be nulled

Cycle verdicts ("needs different angle") don't trigger retire —
only outright rejects do. Confidence gate avoids retiring on
heuristic-fallback verdicts that come back without a confidence
number. Closes the "audit-consensus → retire" item from
HANDOVER.md.

Live-tested: insert synthetic trace → /pathway/retire by trace_uid
→ retired counter 1 → 2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-04-26 00:01:20 -05:00
co-authored by Claude Opus 4.7
parent e1ef185868
commit 626f18d491
2 changed files with 51 additions and 1 deletions
+6
View File
@@ -373,6 +373,11 @@ pub struct PathwayMemory {
#[derive(Debug, Serialize)]
pub struct HotSwapCandidate {
pub pathway_id: String,
/// trace_uid of the SPECIFIC trace this hot-swap recommendation
/// came from. Lets a caller call /pathway/retire with single-trace
/// precision when observer rejects the result — the audit-consensus
/// → retire wire (HANDOVER §queued, ADR-021).
pub trace_uid: String,
pub similarity: f32,
pub replay_count: u32,
pub success_rate: f32,
@@ -754,6 +759,7 @@ impl PathwayMemory {
let accepted = p.ladder_attempts.iter().find(|a| a.accepted)?;
Some(HotSwapCandidate {
pathway_id: p.pathway_id.clone(),
trace_uid: p.trace_uid.clone(),
similarity,
replay_count: p.replay_count,
success_rate: p.success_rate(),