Skip to content

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

Description

@Al-aminI

What happened?

An unclean shutdown left %APPDATA%\opencode-goal-plugin\goals.json at its full 28,454-byte length with every byte NUL — the standard NTFS failure mode where the rename's metadata commits but the data pages never flush.

On 0.1.31 this threw StateDecodeError out of the chat.message hook, which surfaced as Unexpected server error on every prompt in every session — the plugin took down the whole app. That part is fixed by #1 / 0.1.35, and the atomicWriteFile fsync work in 0.1.34 addresses the write side that produced the file. Both confirmed in main

Expected behavior

Since v0.1.35, parseStateText correctly stops a zero-filled goals.json from crashing every session (thanks — that resolved my incident's root cause). But the recovery path resets to emptyState() and reports it only through console.warn, which is invisible in the TUI. The result is that a recoverable corruption event becomes silent, total, unannounced loss of every goal.

I hit this on 2026-08-20 and lost a long-running goal that was only recoverable because I mined it back out of opencode.db by hand.

Steps to reproduce

opencode-goal-plugin-issue.md

Plugin version

0.1.31

OpenCode version

1.18.18

Operating system

windows

Model/provider in use

any model

Plugin options

Relevant goal state or logs


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions