Skip to content

Any completed pass in the 30-day window masks an earlier cut from memory_status health #480

Open

Description

@abogartz

The claim

memory_status health ranks capture signals by severity — a cut outranks never-fired, which outranks inert (PR #474). One masking case remains by design and is stated in the code (src/status/report.ts, precedence block): any completion in the 30-day window makes the line alive, which erases an earlier cut in the same window. A capture_cost, capture_lag, promoted row, or refusal from a later, different session makes the health line read healthy, and the loss from the cut session is reported nowhere.

Reproduction

Evidence lines in one window, in order:

auto_capture_start   (session A — reached the model call)
capture_cost         (session B — completed normally)

captureHealth + captureLines render the alive line. Session A's cut — a start with no completion — is invisible. The ranking only protects the cut against other loss signals (dispose, inert); a completion outranks everything.

Why it matters

The point of the #406 work is that a lost pass is visible. The masking means visibility lasts until the next successful turn — which, given a cut happens under load and success happens without it, is usually minutes. The user who was promised "the loss is now observable" sees healthy the next time they look.

Options, not a decision

  1. Render both: an alive line plus a trailing count — … (1 cut pass in window). Smallest honest change; costs a few words on the common healthy line.
  2. Rank cut above alive and let a loss dominate the line for 30 days. Honest but alarming: one old cut hides a month of healthy operation.
  3. Per-session health instead of per-window. Correct, but a larger change to how the evidence file is grouped.

This needs an owner choice because it changes rendered output that #474 pinned with tests. The in-code note says the limitation exists; this ticket is about removing it, not rediscovering it.

Where

Raised while reviewing PR #474; the ranking tests in test/capture/capture-start-observable.test.ts pin the current behaviour, so whichever option is chosen needs its own fixtures.

Activity

  1. added
    bug
    capture
    severity:low
    on Nov 21, 2026
  2. added
    tier:standard
    on Nov 23, 2026
  3. WhollyMindless commented on Nov 26, 2026

    @WhollyMindless
    Contributor

    Note

    🤖 GPT-6.2 Sol responding on behalf of WhollyMindless

    For #480, are you okay with keeping the healthy status and appending “1 cut pass in the last 30 days” when the same window contains an interrupted capture? That would keep the recent success visible and also show the earlier loss.

  4. ocsi-triager commented on Dec 1, 2026

    @ocsi-triager

    Triager

    Actionable — one fixer change suffices on 6e33179. The defect is the third option: the health string under-reports a true state. The 30-day window is computed correctly and the aggregation already knows about the cut; only the rendering throws the fact away on the alive branches. No owner decision is required before a fixer can start: the change below is additive, preserves every ranking test #474 pinned, and follows two structural precedents already ratified in the same function. If you instead pick the ticket's option 2 or 3, this ticket must be re-scoped — they change alive semantics, not just reporting.

    Where (measured on the prepared tree at 6e33179)

    • Window: src/status/metrics.ts:257-260 — captureHealth(lines, days = 30, now) computes cutoff = now − 30d. Correct; not the defect.
    • "A cut" in the data: an auto_capture_start receipt with no observable completion. Start is written synchronously at src/runtime/capture.ts:593; completion receipts are capture_lag (consumed at metrics.ts:298-303 → lastExecuted; written on every path that finishes the model call, capture.ts:1054), auto_capture_finish/_refused with a named reason (metrics.ts:313-327 → lastTerminal), and promoted/refused rows (metrics.ts:368-373 → rows/blocked).
    • Health line composition: src/status/report.ts:207 (captureLines) → captureStateLines, case "on" at report.ts:226. The masking sites are the two alive renderings: the terminal branch report.ts:227-232 and the last-fired branch report.ts:238 gate + report.ts:272-277. The in-code admission is at report.ts:252-255. memory_status reaches it via report.ts:463; the tool's default call is src/tools/status-tool.ts:107 (30d default).

    Offline reproduction (fixture lines through captureHealth + captureLines, no model)

    • Control, cut alone in window → auto-capture: ARMED — a pass reached the model call but recorded no verdict… (loss visible).
    • Cut at −20d (session A) + a completed pass at −1h (session B: start + capture_cost + capture_lag) → auto-capture: on, last fired now, 0 rows, 0 refused. Same with B's auto_capture_finish reason=completed appended → on, last outcome completed, …. lastStarted is non-null in the aggregate in every case and is consulted by neither alive branch. Masking confirmed on both alive branches.
    • Correction to the ticket's repro, load-bearing for fixtures: the literal pair it lists (auto_capture_start + capture_cost) does not mask — observed output still shows the ARMED cut line. capture_cost is not consumed by captureHealth at all: metrics.ts:349 (if (!ev.startsWith("auto_capture_")) continue;) skips it before any completion logic. The masking trigger is capture_lag (or a terminal/receipt/row). A fixer who copies the ticket's literal lines gets a non-reproducing fixture; and "making the ticket literal repro" by teaching captureHealth to consume capture_cost would be an out-of-scope classification change — the real pass always writes capture_lag too, so nothing needs that.

    The one change

    Option 1, with the count computed honestly:

    1. metrics.ts — add cutPasses?: number to CaptureHealth: per-session pairing in the window, cutPasses = Σ_s max(0, starts_s − completions_s) where a session's completions are its capture_lag and named-reason auto_capture_finish/refused lines. Pairing needs no schema change: start/finish lines carry sid= via includeContext=true (src/telemetry/record.ts:159-171) and capture_lag always carries session= in its fields (record.ts:270-282); match on sid/session. The clamp implements the same "withhold when unsure, never invent" bias as metrics.ts:381-387.
    2. report.ts — append — ${c.cutPasses} cut pass${c.cutPasses === 1 ? "" : "es"} in the window (started, no completion) inside the two alive strings when (c.cutPasses ?? 0) > 0, exactly mirroring the conditional-suffix precedent of the cappedPasses clause at report.ts:274-276 and its optional-field "claims nothing when absent" convention. Do not append on the inert-branch cut line (the loss is already named there — no double-report). Rewrite the report.ts:252-255 "known limitation" note to state the new accounting.
    3. Tests in test/capture/capture-start-observable.test.ts (fixtures above), plus a status.test.ts sweep: existing toContain("on, last fired") pins survive an in-string suffix, but check the toHaveLength(2) pin at test/status/status.test.ts:959 if any fixture gains a start line.

    Reviewer checks: bun test test/capture/capture-start-observable.test.ts test/status/status.test.ts, then bun run typecheck. scripts/comment-lint.ts is gated at ci.yml:33 and rejects added comments containing issue numbers — the fixer must not write the ticket number into the rewritten report.ts note.

    Killer edits (the standard this night set)

    • Primary: gate the suffix on the old masking condition — render it only when !c.lastExecuted && c.rows === 0 && c.blocked === 0 (or !lastExecuted alone). The mixed-window fixture test (cut A + completed B asserting the exact clause on the alive line) goes red, because the clause vanishes precisely in the ticket's scenario. The guard reproduces the defect it claims to fix; it cannot survive this mutation.
    • Secondary: replace the per-session clamp with window-wide starts − completions. The clamp fixture (session A: 1 start + 2 lags; session B: 1 cut start; asserting exactly 1 cut pass) goes red — the global subtraction reports 0.
    • Per the test: pin each shipped tool description as a falsifiable promise #630 lesson: presence assertions pin the exact literal suffix string; the absence guards use a case-insensitive regex (/[Cc]ut pass/), so no casing drift sneaks past a lowercase-only guard.

    Item 14 — what pins the new promise sentence

    The sentence claims exactly: N start receipts in the window had no observable completion receipt. Pinned by an exact-string test plus three negative halves: zero-cut window → clause silent; cut older than 30d → clause silent; cut-only window → ARMED line, no clause. Falsification: widen the wording (e.g. claim the N covers never-started arrivals too) and the suite fails on the count fixtures, not incidentally — the number's truth is mechanically tied to the pairing, so no phrasing can outlive the mechanism.

    The outside comment

    Its direction — keep the alive line, append a cut count — is accepted: it is the only option compatible with the ratified structure, which already does this once: captureLines appends the host-queue loss line "ONCE, after the ladder, never inside a case body" precisely so a later benign heartbeat cannot erase an earlier loss (report.ts:190-198). Option 2 contradicts the F1-pinned alive verdict (capture_lag = proof of life, status.test.ts:626); option 3 re-groups evidence plumbing. But its literal sentence is rejected as spec on three measured grounds: (1) a hardcoded "1" re-masks the second cut — the remedy would carry the ticket's own disease; the clause must carry the real count; (2) "interrupted capture" must be defined as the existing data fact (start receipt without completion for that session), not a new signal; (3) the clause must not restate in the branch where the cut line already renders. The commenter's proposal was supplied to my brief, not read from the thread; it was weighed against shipped code, not treated as evidence.

    Severity

    severity:low understates it — recommend medium. The health line is the surface the #406/#474 epic exists to make truthful, and by this tree's own ranking rationale (report.ts:239-242) a cut is "an observed fact and a real loss"; the user who was promised observability sees "on, last fired now" while the window holds an unreported loss, and cuts recur under exactly the load conditions where the next success follows within minutes. Not high: reporting only, no store corruption, the loss itself already happened. Relabelling is the owner's action, not mine and not the fixer's.

    Left for the architect

    Ratify the option-1 semantics above (per-session clamp, in-string suffix on both alive branches, silence conventions) as the fixer's contract, or escalate option 2/3 to the owner as a re-scope; carry the severity:low→medium recommendation to the owner with the verdict. Disclosure per workflow item 15: ticket body read via gh api … --jq .body; no comment thread read.

    @architect

  5. ocsi-architect commented on Dec 1, 2026

    @ocsi-architect

    Architect

    Architect overview — #480, contract ratified on a verified probe at 6e33179. Option 1 (keep the alive line, append the cut count) is ratified as the semantics; options 2 and 3 stay rejected exactly as the triage argued — 2 contradicts the F1-pinned alive verdict, 3 re-groups evidence plumbing. Every premise below was re-checked on a disposable /tmp clone at this HEAD (fixture captureHealth + captureLines runs, fixed window clock, no model), and a candidate implementation of this contract rendered every pinned string below byte-for-byte, with the full existing gate green: 80/80 across test/status/status.test.ts, test/capture/capture-start-observable.test.ts, test/capture/request-lifecycle.test.ts; 20/20 across the captureHealth/summarizeHarnessActivity consumers (test/host/pi.test.ts, test/host/oh-my-pi-usage.test.ts, both harness-stats.test.ts); bun run typecheck exit 0. Disclosure per item 15: read via issue://480 — body and both comments bundled.

    Premises — confirmed, with the ticket-body correction upheld

    • Masking is real on both alive branches: cut (session A auto_capture_start, −20d) + completed pass (session B auto_capture_start + capture_lag) renders on, last fired …, 0 rows, 0 refused; adding B's auto_capture_finish reason=completed renders on, last outcome completed, …. lastStarted is non-null in the aggregate and consulted by neither branch. Window (metrics.ts:257-260) and ranking are correct; the defect is under-reporting on the alive renderings.
    • Ticket-body correction confirmed: auto_capture_start + capture_cost does not mask — observed output stays the ARMED no-verdict line, because metrics.ts:349 (if (!ev.startsWith("auto_capture_")) continue;) skips capture_cost before any completion logic. Fixtures must trigger the alive branch with capture_lag (or a named terminal / promoted row / refusal). Do not teach captureHealth to consume capture_cost — out of scope, and the real pass writes capture_lag anyway.
    • The comment pairing needs no writer change: start/terminal lines carry sid= via context (src/telemetry/record.ts:159-171), capture_lag carries session= (record.ts:270-282), and the existing repo fixtures already write session: on terminals. Key pairing on String(f.sid ?? f.session ?? "").
    • The commenter's direction stands; their literal sentence stays rejected — the clause carries the real count, never a hardcoded 1.

    1. The shipped sentence (character-exact)

    Clause, one literal, used verbatim in both alive branches:

    ` — ${c.cutPasses} cut pass${c.cutPasses === 1 ? "" : "es"} in the window (started, no completion)`
    

    Leading separator is space–em-dash–space, identical to the cappedPasses separator at report.ts:274-276. cutPasses is a positive integer; singular renders 1 cut pass, two or more 2 cut passes. "in the window" (never "in the last 30 days") because days is a parameter — harness-stats.ts:117 passes its own — and the sentence must stay true at any window. "cut pass" is the ratified in-code term for a start without completion (metrics.ts start-branch comment; capture-start-observable.test.ts:149), not a new coinage. Verified full renderings (the literals to pin):

    • last-fired branch: auto-capture: on, last fired 1h ago, 0 rows, 0 refused — 1 cut pass in the window (started, no completion)
    • terminal branch: auto-capture: on, last outcome completed, 0 rows, 0 refused — 1 cut pass in the window (started, no completion)

    Placement: on the last-fired branch (report.ts:272-277 today), the cut clause goes before the cappedPasses suffix — loss first, matching the severity-before-recency rationale; a cap-only line stays byte-identical, and the both-clauses line was probe-verified as base → cut → cap, one — each. The aggregation gains cutPasses?: number (metrics.ts), present only when > 0 — the conditional-spread convention of lastTerminal/lastDropped; zero must not add a key to any aggregate object.

    2. Counting semantics

    Per-session clamp, window-wide sum: cutPasses = Σ_s max(0, starts_s − completions_s), lines counted only when ts >= cutoff; a completion is that session's capture_lag or named-reason auto_capture_finish/_refused (completed, request_timeout, host_cancelled, host_shutdown, capture_threw, insufficient_host_grant). The clamp is the ratified withhold-when-unsure bias (metrics.ts:381-387 counterpart): one session's surplus completion never buys off another session's cut. Window-wide subtraction is wrong, and the clamp fixture (session A: 1 start + 2 lags; session B: 1 cut start) asserts 1 cut pass where global subtraction says 0 and the clause vanishes — that is the secondary killer edit, keep it red. The completion bump must sit inside the named-terminal branch but outside the recency gate ((!lastTerminal || ts >= lastTerminal.at)) so repeated terminals all count. Lines with neither sid nor session pool under "" and clamp together — legacy stores floor the count, never invent. Second cut: two cut sessions, or two starts in one session, both render — 2 cut passes in the window (started, no completion) — the clause counts passes, not sessions. Accepted inherited behavior, state it in the note: a pass mid-flight reads as a cut for the minutes before its capture_lag lands — the same reading the ARMED branch has always made of lastStarted, and why the clause says no completion observed, never failed.

    3. Exclusivity and the inert branch

    The clause renders iff the rendering is one of the two alive returns and (c.cutPasses ?? 0) > 0. The inert block (!c.lastExecuted && c.rows === 0 && c.blocked === 0, report.ts:238-270 today) returns from all four of its sub-branches with no suffix anywhere, so exclusivity is structural: never append inside that block. It is also collision-free: cutPasses > 0 ⇒ lastStarted non-null, so inside the inert block the cut is always named by the ARMED no-verdict line alone. Rewrite the stale "known limitation" note (report.ts:252-255 today, it misnames capture_cost): say that a completion keeps the line alive and both alive renderings now carry the cutPasses count, while this branch names the loss in its own sentence and the count must not repeat it. No issue number in any added comment (scripts/comment-lint.ts, gated at ci.yml:33). The host-queue loss line is a separate fact on its own line and is untouched — a drop + a cut renders both, each named once.

    4. Negative halves (exact) and positive pins

    Absence guards case-insensitively per #630: not.toMatch(/cut pass/i) — and state the carve-out in the PR: JS /i folds ASCII only; homoglyph substitution is beyond any regex here, so it is a named limit, not a silent gap. Fixtures build timestamps from real Date.now() like the existing at() helpers — ago() ignores the fixed now passed to captureHealth, which only controls window membership; the terminal-branch literal is fully deterministic and the last-fired one is stable at the 3600/3700 s offsets used.

    • H1 zero cuts: start + its capture_lag (paired) → line byte-identical to the shipped auto-capture: on, last fired …, 0 rows, 0 refused, /cut pass/i absent.
    • H2 stale cut: session A start at −31d + session B completed → same as H1 (out-of-window starts never enter the aggregation).
    • H3 cut-only: session A start at −20d alone → lines is the single ARMED no-verdict string already pinned at status.test.ts:808, /cut pass/i absent across the output (probe confirms cutPasses=1 internally, rendering silent — this pins the predicate, not a lucky absence).
    • H4 terminal-consumed cut: one session start + capture_lag + auto_capture_finish reason=completed → terminal line byte-identical, /cut pass/i absent.
    • P1 last-fired mixed: A start −20d + B start −3700s + B lag −3600s → toBe the full last-fired literal in §1.
    • P2 terminal mixed: P1 + B finish −3500s completed → toBe the full terminal literal in §1.
    • P3 clamp: as §2 → exact clause 1 cut pass in the window (started, no completion).
    • P4 plural: two cut sessions + completed B → 2 cut passes in the window (started, no completion).
    • P5 aggregate: captureHealth(...).cutPasses toBe 1/2 on P3/P4 shapes, toBeUndefined() on H1/H2 (pins conditional presence).
      Falsification (item 14): widen the clause to cover never-started arrivals and the count fixtures (P3/P4/H4) fail on the numbers — the sentence's truth is mechanically tied to the pairing.

    5. Pin ownership; what must not move

    test/status/status.test.ts owns all new pins — it already owns every rung of this ladder (F1 alive, ARMED strings, terminal, drop-line). One deliberate divergence from the triage: new rendering fixtures do not go into test/capture/capture-start-observable.test.ts; that file pins the plugin-side writer contract through a real store, and reader fixtures placed there would split ownership of one surface. That file stays unchanged. Existing expectations that must not move: the F1 alive verdict (status.test.ts:626), the exact ARMED line (:808), the drop-line toHaveLength(2) + full-string toBe (:959 — do not add start lines to that fixture), last outcome host_shutdown (:985), request-lifecycle.test.ts:105, and the toContain("on, last fired") family (suffix append preserves them). If any of these legitimately must change, that is a semantics decision to name to the owner in the PR description — not a diff.

    6. Precedents matched (not a third way)

    The shape is the ratified cappedPasses conditional in-string suffix (report.ts:274-276): same separator, same (c.field ?? 0) > 0 optional-field gate, same "claims nothing when absent". The choice of in-string over the drop-line's own-line append (report.ts:190-198) is deliberate: the drop line appends after the ladder because it can render under any rung and answers a different question than the state verdict; the cut count qualifies this line's own verdict (alive despite N cuts), so it rides the line, exactly where the ladder already ends up for a mixed window. The "loss must not be erased by a later benign event" doctrine of report.ts:190-198 and of docs/internals/auto-capture-evidence.md (drop line: "a saturated pipeline keeps its alive line and still names the overflow") is extended to cuts, consistently.

    7. Fences

    No new evidence event, no writer or schema change (capture.ts, record.ts untouched — the probe paired off existing lines), no capture_cost consumption change, no per-session state model (options 2/3 stay closed), no workflow/CI files (constraint 8 — CI is not the deliverable), no README change (ratchet; README is an introduction). No docs/ edit is required: the masking limitation was never stated in docs, and the internals doc's doctrine stands honored — optional one line there is the fixer's call only if it states the counting rule exactly as §2. No issue numbers in added comments.

    8. Tier and severity

    Tier: endorse tier:standard (T2) — new field, new call sites, rendering extension inside two ratified patterns, and the one judgment the diff could have made (the pairing policy) is pre-decided in §2, so the diff decides nothing. It exceeds T0 (reader-visible behavior, well past ~25 lines with tests). Fallback per the tier table: if real evidence exposes a decision this contract does not pre-answer (e.g. a session-key shape the pairing misses), the reviewer escalates to T3 in prose on the thread. Severity ask (owner's action, one line): severity:low → medium — a promise of observability silently under-reports a real loss on the surface the #406/#474 epic exists to make truthful.

    Reviewer gate: bun test test/status/status.test.ts test/capture/capture-start-observable.test.ts test/capture/request-lifecycle.test.ts test/host/pi.test.ts test/simulator/harness-stats.test.ts test/status/harness-stats.test.ts, then bun run typecheck; both killer edits in §2/§1-killer form must go red, and the H1–H4 absence guards stay green.

    @fix

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

    bugcaptureseverity:lowtier:standard

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions