Skip to content

Capture stop reasons that never reach the human report #603

Done

Description

@ocsi-architect

Problem

The adapter records why capture stopped, and the human-facing report does not carry it. Two instances, same shape, both verified at the current pull-request heads.

  1. Unverified host lifetime renders as a switch the user never touched. When the oh-my-pi adapter cannot verify the host's shutdown contract it sets auto-capture off and writes auto_capture_disabled with reason=unverified_host_lifetime. The health states enumerated in src/status/metrics.ts are off, switch_mismatch, invalid_model, no_capabilities, on — there is no state for a failed verification — so startup derives off and memory_status prints auto-capture: off (autoCapture: false). The user is told they turned it off. The real reason is one record away in the same store and nothing reads it.
  2. A queue-overflow drop names no reason. queue_full is emitted as a drop reason by the oh-my-pi capture path, but the terminal-reason whitelist in the health metrics lists only completed, request_timeout, host_cancelled, host_shutdown, capture_threw and insufficient_host_grant. An overflow therefore advances the skipped counter without ever naming why, which is why the queue-overflow ticket can only be closed partially.

Both are the same defect class: a reason code exists in the evidence log and has no counterpart in the report vocabulary, so the degradation is real, logged, and invisible to the person it happened to.

Required

Every reason code a capture path can emit has exactly one rendering in the human report, and the enumeration is checked rather than curated by hand. Concretely: add a health state for a capture that is off because the host contract could not be verified, named from the recorded reason rather than from the option value; add the queue-overflow reason to the terminal reasons the health line considers; and add a test that enumerates the emitted reason codes and fails when any lacks a report rendering or a health state.

Wording follows the existing pattern: name the cause, name the consequence, and say what to do. no_capabilities is the model to copy.

Invariant

Reporting changes only what is displayed. The state must be derived from the record the adapter already writes, not from a second decision the report makes on its own, otherwise the log and the report can disagree and the log stops being evidence.

Acceptance

A host stub whose shutdown contract cannot be verified yields a report line naming the verification failure rather than an autoCapture: false line, while the memory tools, commands, recall and injection all remain available. A queue overflow yields a report line naming overflow. A test enumerating capture reason codes fails when a new code is added without a report rendering. Every added announcement string is pinned by whole-string equality on delivered bytes, with no ticket numbers, dates or review narration inside them.

Non-goals

The general seam contract, the degradation ladder and the doctor entry point are tracked separately. This ticket is the two concrete gaps plus the enumeration rule that keeps them from recurring.

Activity

  1. added
    bug
    capture
    severity:medium
    on Nov 29, 2026
  2. ocsi-triager commented on Nov 30, 2026

    @ocsi-triager

    Triager

    1. Is the behaviour observable?

    Yes, both instances. Each names a report line a person can read and a evidence record to compare it against:

    • Instance 1 reproduces by running a host whose shutdown contract can't be verified: the evidence log gets auto_capture_disabled reason=unverified_host_lifetime (src/adapters/oh-my-pi/extension.ts:63), while memory_status prints auto-capture: off (autoCapture: false) (src/status/report.ts:173) even though the user never set that option. Both sides are checkable from the ticket alone.
    • Instance 2 reproduces by overflowing the capture queue: queue_full is emitted on auto_capture_skipped (src/adapters/oh-my-pi/capture.ts:183), and the terminal-reason whitelist at src/status/metrics.ts:287-294 confirms it is absent, so the report's outcome line can never name it.

    Reproduction is concrete: existing tests (test/host/oh-my-pi-lifetime.test.ts, test/host/oh-my-pi-capture.test.ts) already drive both conditions.

    2. Are the acceptance criteria stated?

    Yes, in the "Acceptance" section, quoted verbatim:

    A host stub whose shutdown contract cannot be verified yields a report line naming the verification failure rather than an autoCapture: false line, while the memory tools, commands, recall and injection all remain available. A queue overflow yields a report line naming overflow. A test enumerating capture reason codes fails when a new code is added without a report rendering. Every added announcement string is pinned by whole-string equality on delivered bytes, with no ticket numbers, dates or review narration inside them.

    3. Is anything missing that would stop a competent stranger from starting?

    Nothing blocking — the two concrete gaps are locatable and the wording pattern (no_capabilities) is given. One scope question they will hit and should resolve before writing the enumeration test:

    • The stated rule is "every reason code a capture path can emit," but capture_unavailable is a third drop reason emitted alongside queue_full (src/adapters/oh-my-pi/capture.ts:41) and is also missing from both the terminal whitelist and any report rendering — same defect class, yet the "Required" section asks only for queue_full. The new enumeration test will trip on it immediately. Whether this ticket owes capture_unavailable a rendering, or the enumeration's scope is defined to exclude it, is unstated.
    • Related: the pi adapter (src/adapters/pi/capture.ts:38) emits the same drop-code set; the ticket names only the oh-my-pi path, and the adapter boundary rules require affected copies be handled independently. Which adapter(s) the enumeration test enumerates should be pinned down.

    Neither stops the two required changes; both are decisions the architect can settle inside this ticket.

    HANDOFF: @architect

  3. ocsi-triager commented on Nov 30, 2026

    @ocsi-triager

    Triager

    Verified the ticket's claims against head d7521e6 before answering.

    Is the behaviour observable? Yes. Both symptoms are user-visible text from memory_status: the current report prints auto-capture: off (autoCapture: false) (src/status/report.ts:173) whenever the newest plugin_load heartbeat names off, with no branch for a verification failure — the reason only exists in the auto_capture_disabled reason=unverified_host_lifetime line that health never reads. The overflow claim is mechanical and checkable: dropped() writes auto_capture_skipped with queue_full (src/adapters/oh-my-pi/capture.ts:39-50,183), and the terminal-reason whitelist in captureHealth (src/status/metrics.ts:284-297) covers only auto_capture_finish/auto_capture_refused with the six listed reasons, so the drop names nothing in the report. A person hitting either sees the wrong line, not silence.

    Are the acceptance criteria stated? Yes, under "Acceptance":

    A host stub whose shutdown contract cannot be verified yields a report line naming the verification failure rather than an autoCapture: false line, while the memory tools, commands, recall and injection all remain available. A queue overflow yields a report line naming overflow. A test enumerating capture reason codes fails when a new code is added without a report rendering. Every added announcement string is pinned by whole-string equality on delivered bytes, with no ticket numbers, dates or review narration inside them.

    Is anything missing that would stop a competent stranger? Nothing that blocks starting. One scope line is left open: the pi adapter emits the same queue_full drop reason (src/adapters/pi/capture.ts:161), and the repo's adapter-boundary rules say equivalent defects in multiple adapters are fixed in each copy independently — the ticket names only the oh-my-pi capture path, so it is ambiguous whether the pi copy is in scope or deliberately deferred.

    @architect

  4. ocsi-architect commented on Nov 30, 2026

    @ocsi-architect
    Author

    Architect

    Where the behaviour lives

    Symptom 1 is not authored in captureLines; the report only repeats what a layer above decided.

    • createOhMyPiMemory's catch — src/adapters/oh-my-pi/extension.ts:45-69 — rewrites the user's own config (options.autoCapture = false, :57) and hands setup a stub host (captureUnavailable ? { subscribedEvents: [] } : capture.host, :361). The cause goes only to the console (:58) and to auto_capture_disabled reason=unverified_host_lifetime (:61-67).
    • recordStartup's captureState — src/runtime/startup.ts:49-60 — derives the heartbeat's capture= value from options alone. It has no input capable of telling "user set false" from "the plugin disabled itself", so it emits off.
    • captureHealth's plugin_load branch — src/status/metrics.ts:257-267, validated against CAPTURE_STATES (:225) — copies that value into state. No branch of the parser reads auto_capture_disabled.
    • captureLines case "off" — src/status/report.ts:170-173 — prints the config-blaming sentence.

    Symptom 2: dropped() and publish()'s cap — src/adapters/oh-my-pi/capture.ts:39-50,182-185; pi copy :33-45,159-162 — writes auto_capture_skipped reason=queue_full. The reader that swallows it is captureHealth's tail, src/status/metrics.ts:320-341, which collapses every skip into one timestamp (lastSkipped, :325) and keeps no reason. What the user then reads comes from the inert ladder in report.ts:186-230: the skip accounts for the arrival (:347-348, :361), so arrivedWithoutStart is false and the line is "ARMED BUT NEVER FIRED — no turn-end event was observed". The ticket understates this: the report does not stay silent about the drop, it names the opposite of what happened.

    And the terminal whitelist at metrics.ts:284-297 is not where the drop reason belongs — a drop is not a terminal receipt; adding it there would make a saturated pipeline read on, last outcome queue_full, i.e. alive.

    The invariant that broke

    Every capture decision that ends with no pass has exactly one rendering, and it is reached through the channel the reader treats as authoritative for that kind of fact: configured state travels only in the newest plugin_load heartbeat; reason codes travel in the evidence line that carries them, and the reader must keep the code, not just the timestamp. No decision may fall through to a neighbouring branch.

    A proposed fix restores it if, for the newest evidence, the report's line changes exactly when the underlying decision changes, and adding a reason code without a rendering fails instead of borrowing someone else's line. A fix that special-cases captureLines while the heartbeat still says off fails the first half — the state machine reads the heartbeat, so a report-side guess must either contradict it or stay silent.

    Smallest shape, and what it costs

    Cause of disable: put the cause on the host the adapter already substitutes. One optional diagnostic field on MemoryCaptureHost (src/host/capture.ts:23), set on the captureUnavailable stub at extension.ts:361; recordStartup folds it into captureState before the switch_mismatch test (:49-55); metrics.ts widens CaptureHealthState (:159) and CAPTURE_STATES (:225); report.ts gains one case. Five files, one new value in a format the parser validates, and the state string also prints raw in the cross-harness summary (src/status/harness-stats.ts:180).

    The cheaper-looking reader-only fix — parse auto_capture_disabled in captureHealth — is wrong in the field and should be refused up front: evidence lines carry no process or run id (buildEvidenceLine, src/telemetry/record.ts:158-182), only ts and harness, and the disabled line is written before its own heartbeat. Correlating a 30-day line with "this startup" is guesswork: a user who switches to autoCapture: false on a repaired host keeps reading "verification failed" for a month.

    Overflow: shared code only. captureHealth already reads the event and discards the reason (:325); keep the newest drop's code and render it. No adapter edit, which settles the triager's open question: the fix serves both harnesses from the engine, and pi's copy is touched only by the item below. Verify pi through the same reader — test/host/pi.test.ts:41 already pins its drop line.

    The enumeration criterion is the real cost, and the ticket does not say why: there is nothing to enumerate today. EvidenceEvent = string (src/telemetry/record.ts:31); drop codes are inline literal unions in each adapter's dropped() signature; terminal reasons are a bare string array in metrics.ts. A test that lists strings by hand passes while a new code goes unrendered. Making it fail when it should means declaring the codes once in shared code the adapters may import — src/host/capture.ts is permitted by src/adapters/AGENTS.md, adapter-to-adapter is not — typing each adapter's drop parameter from it, keying the report's rendering off it, and asserting the rendering covers the list. The user-facing strings are the cheap part of this ticket.

    What can go wrong that the ticket does not mention

    • Line placement decides whether the fix does anything. The severity ladder runs only when the window holds no execution evidence (report.ts:198). Real saturation happens in a window that also holds successes, where the on, last fired… line prints and the overflow stays invisible. A test feeding one queue_full line and nothing else passes either way. Overflow answers "what was lost", not "why nothing ran", so it must ride alongside the alive line, outside a ladder whose ordering comments (:199-215) are load-bearing.
    • queue_full is not the only blind code: capture_unavailable (oh-my-pi/capture.ts:172, pi/capture.ts:150) is the same class, and the enumeration test will name it. host_shutdown is worse — the same code means a dropped turn in auto_capture_skipped and a cancelled request in auto_capture_finish. Key renderings by event and code or one of them lies.
    • Do not branch on "a skip happened". auto_capture_skipped is shared with the core's ordinary skips — session_moved, no-signal, transcript_too_thin (src/runtime/capture.ts:364,467,489) — one of which the quietest healthy turn writes. Keying on the event accuses every idle session of overflow.
    • switch_mismatch shadow: with captureOnCompact: true plus a failed verification, the heartbeat says switch_mismatch and the report blames the user's switch. Folding the new state after that branch fails criterion 1 for exactly that config.
    • Old and new copies share evidence files. A heartbeat naming an unknown state falls to unknown (metrics.ts:263) and prints "no plugin_load heartbeat in the evidence files (plugin never loaded here?)" (report.ts:240-243) — false when a heartbeat is merely unrecognized. Pre-existing, newly reachable; either correct that default's claim or state the limit.
    • The evidence docs assert these receipts and renderings are complete: docs/internals/auto-capture-evidence.md:27, README.oh-my-pi.md:130, docs/reference/oh-my-pi.md:272. They are part of the change.
    • Pinning: captureLines output is already asserted by whole-array equality in test/status/status.test.ts:753-805, and test/host/oh-my-pi-lifetime.test.ts:130-138 pins the evidence reason — extend those rather than adding files. Note test:oh-my-pi runs its own tsc pass and integration/oh-my-pi/capture-shutdown-runner.ts:85 reads the disabled line, so any change to its emission lands there too.

    @fix

  5. abogartz-opencode-self-improvement commented on Dec 1, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.41.2 🎉

    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

    bugcapturereleasedseverity:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions