Skip to content

Record what happened after a memory rode: a row-to-outcome edge, so usefulness is measurable #332

Closed

Description

@abogartz

Problem

The plugin records that a memory rode, and nothing about what happened next.

recordHits (src/hits/ledger.ts:112) writes ev=memory_used ts src sid mem=[ids] terms=[…]. That is the whole use record. Consequences:

  • neverRetrieved (src/hits/ledger.ts:233) is reporting-only — src/status/store-summary.ts reads it, nothing mutates on it.
  • useBoost (src/recall/relevant.ts:41) is a +1 tie-break, not a quality signal.
  • Nothing distinguishes a row that helped from a row that misled. A row that reliably sends the agent the wrong way accrues hits and therefore gets boosted.

The Prime Agent paper's continual-harness claim rests on each refinement recording its trigger and the outcome it produced, with rollback of a bad edit by ID. Our store has the trigger half only. That gap, not capture volume, is why no benchmark we run can currently say the plugin helped — see #123 and the non-equivalence analysis for #315.

What already exists (checked, not assumed)

  • Turn index: SessionState.turns, bumped by markTurn (src/capture/triggers.ts:322) from session.prompt (src/events.ts:184). Not on any ledger line.
  • Tool outcome: classify PASS/FAIL from exit code and regex (src/capture/triggers.ts:122-138), already used for FAIL→PASS pairs (t4_learning).
  • Ledger readers filter on f.ev !== "memory_used" and read named fields only (src/hits/ledger.ts:187, :224), so extra fields and new ev= kinds in hits.logfmt are backward-compatible. No store format migration is needed: toMemory (src/store/files/load.ts:64-91) drops unknown keys, so an outcome counter cannot live on the row anyway.
  • No session-end hook, and no user-correction observer. session.execution.failed is declared and deliberately unsubscribed (src/capture/runtime.ts:94-96).

Work

  1. Add an optional turn to recordHits and to the memory_used line. Pass it from the callers that know it; do not import session state into the ledger.
  2. Emit one aggregated line per turn into the same ledger: ev=turn_outcome ts sid turn outcome=clean|fail calls n fails n. Source it from the existing classify, worst-outcome-wins, so volume stays ~1 line per turn inside the 2 MB ring.
  3. Read-only join in src/hits/: for each row, rides, turns-with-a-fail after the ride, turns clean. Expose through memory_status as used=n clean=m fail_after=k.
  4. Report eviction candidates — rows with ≥5 rides and 0 clean turns. Do not supersede automatically.

Non-goals

  • No user-correction detector. Nothing parses prompt text today; inferring "the user is correcting me" is a separate, error-prone problem.
  • No auto-eviction. A loop that edits its own memory on an inferred signal is exactly the failure the paper reports as reward hacking in Factorio, and closure/merge authority here sits with the human.
  • No row format migration.

Honesty constraints

  • recordHits drops writes on lock contention and is documented as "a best-effort ledger, not proof of non-use" (src/hits/ledger.ts:149-151). Every count it yields is a floor, never a tally. Say so in the report.
  • A FAIL after a ride is correlation. The report must not print a causal word.
  • The ring rotates, so since bounds the window; a row with zero rides is "zero since since", not unused.

Follows from the #315 benchmark work and the Prime Agent non-equivalence finding. Blocks a paper-shaped eval under #123.

Activity

  1. added
    enhancement
    on Nov 7, 2026
  2. abogartz commented on Nov 8, 2026

    @abogartz
    OwnerAuthor

    A proof-of-concept exists and is now pushed for safekeeping: branch 332-outcome-edge, commit e70d61f ("turn on rides, gate verdicts, join, status line"). Deliberately NOT proposed for merge, and the commit message says why: an outcome signal built on an end-to-end loop that is still being proven measures the wrong thing. The bench side of this loop now exists (per-stage attribution from the published harness), so when the current confidence windows land, this POC becomes the natural starting point for the real implementation.

  3. abogartz commented on Nov 9, 2026

    @abogartz
    OwnerAuthor

    Not shipped in this pass, and the reason is worth recording so the next run does not start from zero.

    A WIP implementation already exists: origin/332-outcome-edge at e70d61f ("wip(332): row-to-outcome edge — turn on rides, gate verdicts, join, status line", 9 files, +591). It covers all four work items — turn on the memory_used line, ev=turn_outcome sourced from classify via recordOutcome in src/capture/triggers.ts:201, the read-only join in src/hits/ledger.ts, and eviction candidates in src/status/store-summary.ts at five rides with no clean turn, with no auto-supersede.

    State of that branch, measured today:

    • bun x tsc --noEmit clean.
    • bun test test/hits.test.ts — 29 pass / 1 skip / 0 fail.
    • bun run test — 1049 pass / 0 fail across 101 files, against main's 1190 pass across 111 files.

    That gap is the blocker, not the code. The branch is 93 commits behind main (merge-base 0561d05), and four of the files it edits also changed on main:

    src/index.ts
    src/status/payload.ts
    src/status/report.ts
    src/tools/status-tool.ts
    

    So this ticket needs a rebase, not new code: replay e70d61f onto current main, resolve those four, and re-run the suite against main's 1190-pass baseline. The design in that commit matches the ticket's honesty constraints as written — rides stay a floor (the throttle key deliberately excludes turn), a turn with no gate command records no line so the surfaces say "outcome unknown" rather than "clean", and no causal wording appears in the report.

    Left alone deliberately: the branch is unmerged and untouched, so nothing was lost either way.

  4. added
    retrieval
    severity:low
    on Nov 14, 2026
  5. WhollyMindless commented on Nov 19, 2026

    @WhollyMindless
    Contributor

    Claiming this follow-up. I will bring e70d61f onto current main, verify the turn-level ledger and status behavior, and post a tested PR.

  6. abogartz-opencode-self-improvement commented on Nov 19, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.32.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleasedretrievalseverity:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions