Skip to content

fix: quarantine corrupt goal state - #43

Merged
danyel117 merged 2 commits into
mainfrom
fix/quarantine-corrupt-state
Sep 4, 2026
Merged

fix: quarantine corrupt goal state#43
danyel117 merged 2 commits into
mainfrom
fix/quarantine-corrupt-state

Conversation

@danyel117

@danyel117 danyel117 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve non-empty whitespace/BOM/NUL-only state files as durable, owner-only goals.json.corrupt-<timestamp>-<uuid> artifacts before recovered state is written
  • re-read the canonical file after quarantine and refuse to overwrite it if another process repaired or replaced it
  • keep async and sync reads side-effect free and retain fail-closed behavior for malformed non-empty JSON
  • report quarantine success, concurrent replacement, and quarantine failure through the OpenCode V1 application log, scoped to the configured state path and detached on plugin disposal
  • degrade safely when quarantine storage is unavailable: report the failure and continue recovery instead of making every prompt fail indefinitely
  • keep logging failures from blocking recovery and expose the quarantine path through console diagnostics for V2
  • document the recovery behavior and cover V1, V2, exact 28,454-byte NUL evidence, whitespace/BOM evidence, reporter lifecycle, and forced quarantine-write failure

Verification

  • bun run lint
  • bun run typecheck
  • bun test (221 passing)
  • bun run build
  • bun run pack:dry-run
  • internal standards/spec review: approved
  • Claude Opus review round 1: requested safe degradation when quarantine creation fails; fixed in 833a391 with regression coverage

Closes #35

AI assistance: implemented and reviewed with OpenCode agents and independently reviewed with Claude Opus.

@danyel117 danyel117 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Claude Opus final review: APPROVE.

The first review found that a quarantine-write failure could reintroduce the original every-prompt failure loop. Commit 833a391 resolves it structurally: quarantine failures are reported and recovery continues, while only a successfully observed concurrent content replacement remains fail-closed. Verification read errors and ENOENT no longer create an indefinite failure.

Opus independently reproduced the source-change refusal, confirmed exact preservation for NUL/whitespace/BOM content, verified listener scoping/disposal/failure isolation, rebuilt dist byte-identically, and ran the complete gate: 221 tests, lint, typecheck, build, and pack. All GitHub CI checks are also green. No merge-blocking findings remain.

@danyel117
danyel117 merged commit 87a2e72 into main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zero-filled state recovery silently discards all goals — quarantine the file before resetting

1 participant