Repository navigation
fix(opencode): rule-store writes take a machine-wide lock; a skipped store is logged (#217) - #226
Conversation
…store is logged (#217) - recordLearning and forgetLearningResult take a Flock lock next to the global store (#75 pattern), so a TUI and `opencode serve` writing at once no longer drop each other's rule. If the lock is not free within 10 s the write goes ahead under the in-process lock, with a LEARNING_STORE lock_failed diagnostics line. - Prompt injection writes one LEARNING_STORE skipped_unreadable line when it reads an unreadable store as empty (again only after a good read). - Tests: two processes recording at once lose no rule (fails 3/3 without the lock), the diagnostics line, and synapse_list_rules marking the global group as skipped (CodeRabbit on #221). - AGENTS.md: a learning-store note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # AGENTS.md
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…oment (#217) On Windows a rename onto learnings.json fails with EPERM/EBUSY/EACCES while another handle has the file open, so a rule was silently not saved (QA on #226). writeJsonAtomic now retries those codes up to 5 times (20 ms doubling). QA's 3-writer harness, 10 runs: 15 bad results without the retry, 0 with it. Adds a test for the lock_failed path: a write whose lock folder cannot be made still saves where it can and logs lock_failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Gate A record, head 70e66de
|
…ger hides server errors (#209) (#227) - finalizeSessionRetrospective returns null and writes/sends nothing when there are no records (a turn with no tool calls, a session.deleted right after an idle). It used to write a file and POST 0 calls. - ABORTED matches "The|This operation was aborted" only at the start (optionally after "Error: ") or right after "AbortError: ". An MCP server's own error that mentions an aborted operation further in now counts as a failure. - AGENTS.md: the #18 note names ABORTED separately from NOT_A_FAILURE, says empty retrospectives are skipped and that native failures are marked isError; the learning-store note no longer says "On Windows" for the EPERM/EBUSY retry (QA and architect nit on #226). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Closes #217 (the rest of it, after #221).
What changes
recordLearningandforgetLearningResultnow take a machine-wideFlocklock, using the opencode plugin: two processes can spend the same Synapse refresh token #75 pattern. The key islearning-store:<global store path>, and the lock folder sits next to the global store. A TUI andopencode servecan no longer drop each other's rule, and a forget's put-back can no longer overwrite another process's write. If the lock is not free within 10 s, the write goes ahead under the in-process lock alone, as before observer: silent skipped rule store, cross-process lost update, orphan tmp file (#216 follow-ups) #217, and aLEARNING_STORElock_faileddiagnostics line records it.selectInjectedreads an unreadable store as empty, it now writes oneLEARNING_STOREskipped_unreadablediagnostics line per store. It writes another only if the store breaks again after a good read.test/plugin/observer.test.ts):bun runchild processes (test/plugin/fixture/record-rules.ts) each record 12 rules at once into one test home. No rule is lost in either store.synapse_list_rulesmarks the global group as skipped (the CodeRabbit follow-up from fix(opencode): synapse_list_rules names a skipped rule store; failed writes leave no temp file (#217) #221).Validation
bun installpanics (dev env: bun install panics on Windows (Bun 1.3.14 internal assertion), so fresh worktrees cannot install #201). I ran a stubbed scratch copy ofobserver.tsandobserver.test.tsinstead. It uses the real coreFlock, and drops only the tests that needSynapseAuthPlugin. Results:SynapseAuthPlugintests, including the new global list-rules test, run only in CI. Fast tier:observer.test.tsand 3 more plugin tests.Not covered: the owner decision on mirroring (#211).
🤖 Generated with Claude Code
Summary by CodeRabbit