Skip to content

fix(resident): report unflushed changes after crash - #331

Open
y4ho0 wants to merge 1 commit into
iOfficeAI:mainfrom
y4ho0:agent/warn-lost-resident-edits
Open

fix(resident): report unflushed changes after crash#331
y4ho0 wants to merge 1 commit into
iOfficeAI:mainfrom
y4ho0:agent/warn-lost-resident-edits

Conversation

@y4ho0

@y4ho0 y4ho0 commented Aug 20, 2026

Copy link
Copy Markdown

Summary

  • write a small durable marker before acknowledging the first resident mutation that is still only in memory
  • clear the marker after every successful save, autosave, flush barrier, rollback, or normal shutdown
  • surface a one-shot warning when the next resident reopens the last saved file after an abnormal exit
  • make save and close return resident_unflushed_changes_lost instead of claiming the stale file is already saved

Scope

This implements the issue's minimum honest-recovery option. It does not replay lost edits: replaying arbitrary resident operations as a WAL can duplicate non-idempotent mutations if a process dies after saving the document but before clearing the journal. The warning instead tells the caller that the resident may have lost acknowledged in-memory edits and points short-lived agent harnesses to OFFICECLI_RESIDENT_FLUSH=each.

The marker contains only a version, process ID, and timestamp. Its filename is derived from the same canonical per-document identity used by resident IPC; it does not store the document path.

Validation

  • dotnet build src/officecli/officecli.csproj -c Release --no-restore (0 errors; one pre-existing nullable warning in ExcelHandler.SheetShift.cs)
  • controlled deferred edit + validated resident PID + SIGKILL: memory held after crash, disk held before crash, and the next save --json exited 1 with resident_unflushed_changes_lost
  • explicit save control + validated resident PID + SIGKILL: disk retained saved value, and the next save --json succeeded without a recovery warning
  • reopen control: the first get --json returned the last saved value with the recovery warning; the second returned the value without repeating the warning
  • git diff --check

Refs #328

@y4ho0
y4ho0 marked this pull request as ready for review August 20, 2026 14:44
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.

1 participant