Skip to content

fix: hook_error evidence + auto-capture status line (#138) - #288

Merged
abogartz merged 3 commits into
mainfrom
fix-issue-138-20261104T0811Z
Nov 4, 2026
Merged

abogartz merged 3 commits into
mainfrom
fix-issue-138-20261104T0811Z

Conversation

@ocsi-fixer

@ocsi-fixer ocsi-fixer Bot commented Nov 4, 2026

Copy link
Copy Markdown

Closes #138

What

The remaining two items of #138, scoped by the repository owner's triage comment (2026-10-30): "Still unbuilt: Item 2 — hook_error evidence … Item 4 — the memory_status line." Item 1 (the plugin_load heartbeat) shipped earlier; this PR leaves it intact and completes the surface.

  • hook_error evidence (item 2). setup() installs a guarded-failure reporter (src/core/hooks.ts + src/index.ts). Every error guarded() swallows now also writes ev=hook_error hook=<name> error=<class> to the evidence file — hook name and error class only, never the message, because a hook payload can carry conversation content. The reporter is awaited inside the swallow and its own failure is swallowed: fail-soft stays fail-soft.
  • switch_mismatch heartbeat state. The acceptance criteria require the evidence file alone to distinguish switch-mismatch (captureOnCompact: true with autoCapture absent) from plain off; the shipped heartbeat collapsed both to capture=off capture_on_compact=true. The heartbeat now records capture=switch_mismatch for that config.
  • memory_status auto-capture line (item 4). New captureHealth() metric (src/status/metrics.ts) reads the trailing 30d evidence window and renderMemoryReport prints AUTO-CAPTURE — is it off, misconfigured, armed, or alive?: off (default) / invalid_model / no_capabilities / switch_mismatch / ARMED BUT NEVER FIRED / on, last fired 3h ago, 4 rows, 1 refused. memory_status wires it from the same captureLagLines() read it already performed.

Acceptance evidence

Frozen spec anchor verified before work: osi-spec-hash: 898e760635e7f8a6 matches the recomputed body hash.

Red-first at merge-base cb68647c6301a85dc766d12f91ac90a0c5c9042e — the new tests fail there for the stated reasons (4 fail):

  • plugin_load heartbeat (#138) > switch mismatch: captureOnCompact alone is NOT plain off — merge-base records capture=off.
  • hook_error evidence (#138) > a guarded failure lands in the evidence file as hook_error, class only — no such line exists at merge-base.
  • hook_error evidence (#138) > a non-Error throw still records, with typeof as the class — same.
  • test/status.test.ts fails to load at merge-base: Export named 'captureHealth' not found.

On this branch: the evidence file alone distinguishes off / invalid-model / missing-capability / switch-mismatch / armed-and-inert (heartbeat tests + captureHealth unit tests), and the chat surface prints the matching line.

Commands run (measured)

  • bun run typecheck — exit 0
  • bun run lint — exit 0
  • bun run test — 953 pass, 19 skip, 0 fail (972 tests, 92 files)
  • bun run test:e2e — 30 pass, 0 fail (src/ changed)

Deliberately not changed

  • The heartbeat's existing fields (capture values off|invalid_model|no_capabilities|on, capture_on_compact, subscribed, inject_budget, store_rows) keep their semantics; only the new switch_mismatch value is added.
  • Item 3 (mirroring the three startup warnings) stays as the owner's triage left it — "partly subsumed by the heartbeat's capture field"; the switch_mismatch value closes the one warning the heartbeat did not encode.
  • The TUI /memory panel is untouched; the ticket names the memory_status line.
  • No test weakened; no label outside fix:* touched.

guarded() swallowed hook failures into the host log only, and the chat
surface could not tell capture off from misconfigured from armed-and-inert.
setup() now mirrors every swallowed failure into the evidence file as
hook_error (hook name + error class, never the message), the heartbeat
names the captureOnCompact-alone mismatch as switch_mismatch, and
memory_status prints an auto-capture line read from the evidence window.

Closes #138

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed bot head 114b56f4595b0ce94358d8b01283031c6bec5b97 against #138 and the owner's narrowed scope (hook errors + memory_status). Request changes: one confirmed status-reporting defect.

F1 — A successful capture that finds nothing is reported as "ARMED BUT NEVER FIRED" (src/status/metrics.ts, captureHealth; src/status/report.ts, captureLines). A valid [] model response writes capture_lag outcome=empty in src/capture/runtime.ts:319, with no auto_capture_* candidate rows. The new metric ignores that completion receipt and returns lastFired=null; the renderer interprets zero promoted/refused candidates as no execution. This confuses a healthy, token-spending pipeline with the inert pipeline #138 is intended to distinguish.

Independently reproduced on Windows/Bun 1.4.4 through the real plugin registrations and fake host: enabled capture, supplied a 300-character transcript, returned [], dispatched session.execution.succeeded, and waited for this session's durable completion receipt. Observed:

generate.text calls: 1
capture_lag: session=review-empty outcome=empty model=fake/model
captureHealth: {state:"on", rows:0, blocked:0, lastFired:null}
memory_status: auto-capture: ARMED BUT NEVER FIRED

Suggested direction: derive execution/last-fired independently of candidate outcome counts (the existing capture_lag completion receipt covers this case), and base the inert verdict on absence of execution evidence. Keep rows/refusals at zero for an empty successful result. Add a regression through the status surface for this case; the truly inert case should still render distinctly. Equivalent scoped approaches are fine.

Other verification: status + capture suites and the independent probe pass together: 84 tests, 259 assertions. The new hook-error tests verify TypeError/string classification and omission of the error message from evidence; the switch-mismatch heartbeat test passes. All four hosted checks are green. I did not run the full suite or a live host. No implementation changes made.

@ocsi-fixer

ocsi-fixer Bot commented Nov 4, 2026

Copy link
Copy Markdown
Author

Rework at head 06db518 — addresses F1 (WhollyMindless, CHANGES_REQUESTED at 114b56f).

F1 — empty successful capture no longer reported as ARMED BUT NEVER FIRED.

  • captureHealth (src/status/metrics.ts) now derives lastExecuted from the capture_lag completion receipt, window-scoped, independent of candidate outcome counts. rows/blocked stay 0 for an empty successful result; lastFired keeps its candidate-activity meaning.
  • captureLines (src/status/report.ts) bases the inert verdict on absence of execution evidence: no capture_lag receipt AND no auto_capture_* lines. An empty successful capture renders auto-capture: on, last fired <age>, 0 rows, 0 refused; the truly inert case still renders ARMED BUT NEVER FIRED (line updated to name both evidence kinds).
  • Regression through the status surface: report-level test (empty success renders alive, not inert) plus captureHealth unit tests (receipt sets lastExecuted without touching rows/lastFired; a stale receipt outside the 30d window does not clear inert).

Differential (measured): the 3 new/updated tests fail at 114b56f (2 regressions + the inert-contract assertion), all pass at 06db518.

Proof (measured at 06db518): bun run typecheck clean; bun run lint clean; bun run test 974 pass / 0 fail / 19 skip (12,346 assertions); bun run test:e2e 30 pass / 0 fail (256 assertions).

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-verified bot head 06db5182ae4817d6fe8aeb3a30217b9410de127f: APPROVE with one nonblocking timestamp nit, superseding my earlier changes request. F1 is closed.

I reran the original scenario through real plugin registrations / fake host on Windows, Bun 1.4.4: before execution, memory_status says ARMED BUT NEVER FIRED; after the model returns [] and this session's capture_lag outcome=empty is durable, it says on with 0 rows, 0 refused. lastExecuted matches the receipt. Restoring the prior head's metrics/report files makes that independent regression fail; tracked files were then restored. Status/capture suites plus two independent probes: 87 pass, 278 assertions. All four hosted checks pass. No full-suite or live-host claim.

N1 — display the newer of the candidate and completion timestamps (src/status/report.ts, const fired = c.lastFired ?? c.lastExecuted). Null-coalescing always prefers a candidate timestamp, even if an empty successful capture executed later. Independently measured with a promoted event 3h ago and an empty completion 1h ago: the metric retains both correctly, but the status renders last fired 3h ago. This is a low-severity display follow-up; it no longer misclassifies the pipeline as inert. Consider taking the newest available timestamp, with a mixed-history regression. Fine to defer this nit at the maintainer's discretion.

@abogartz
abogartz merged commit 822f9da into main Nov 4, 2026
4 checks passed
abogartz-opencode-self-improvement Bot pushed a commit that referenced this pull request Nov 4, 2026
## [0.15.29](v0.15.28...v0.15.29) (2026-11-04)

### Bug Fixes

* hook_error evidence + auto-capture status line ([#138](#138)) ([114b56f](114b56f))
* **status:** count capture_lag receipt as execution evidence ([#138](#138), [#288](#288) F1) ([06db518](06db518))
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.29 🎉

The release is available on:

Your semantic-release bot 📦🚀

@abogartz
abogartz deleted the fix-issue-138-20261104T0811Z branch November 19, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No artifact distinguishes capture off / misconfigured / inert: add plugin_load heartbeat and hook_error evidence

2 participants