Fix /buddy off not syncing across concurrent dreb instances#306
Conversation
Implementation PlanProblem analysis
Crucially, no running process ever re-reads
This is the same root cause as the Telegram reproduction (TUI DeliverableMake the persisted Approach (event-driven re-sync — no watchers/timers)Re-read the
Files to create or modify
Testing approachMandatory regression coverage in
Risks and open questions
Plan created by mach6 |
Vitest coverage
|
Progress UpdateImplemented the plan. The buddy Changes
Tests — 6 cross-instance regression tests (stop reacting on agent_end / on user message, re-enable propagation, transition-only firing, Verification — biome clean, full build clean, entire suite green (pre-commit hook: 3974 passed). Maps to acceptance criteria 1–6 in the scope definition. Commit: Progress tracked by mach6 |
Code ReviewCriticalNone. Important1.
A cosmetic companion should never be able to take down message submission. Recommend wrapping the Suggestions2. 3. Non-atomic 4. 5. Re-enable path doesn't verify the in-memory buddy state is refreshed from disk (test-reviewer, confidence 85) 6. Same-instance no-double-fire after local 7. 8. Three identical "make visible" blocks in Strengths
Agents run: code-reviewer, error-auditor, test-reviewer, completeness-checker, simplifier Reviewed by mach6 |
Review AssessmentIndependent verification of the review findings against actual source. Classifications
Tally: 6 genuine (1 high, 2 medium-ish, 3 coverage gaps), 2 nitpicks, 0 false positives, 0 deferred. Action Plan
No tracking issue needed — items 1–3 all land in this PR. Skip: findings 7 and 8 (nitpicks). Finding 2 needs no separate work once item 2 lands. Assessment by mach6 |
…ave, fill test gaps
Progress UpdateAddressed all five genuine findings from the review assessment (nitpicks 7 and 8 intentionally skipped). Production fixes
Test coverage gaps closed (
Verification — biome clean; full build clean; full suite green (pre-commit hook: 3963 passed, 0 failed). Buddy suite specifically: 151 tests pass. Commit: Progress tracked by mach6 |
Code Review (round 2 — post-fix state)Fresh review of the current state after the round-1 fixes landed in CriticalNone. Important1. InteractiveMode's 2. Cross-process lost-update race can silently clobber a concurrent Suggestions3. Atomic-write fix only tests the happy-path no-temp case, not failure-atomicity (test-reviewer, confidence 82) 4. Two-read TOCTOU window inside 5. Orphaned temp files accumulate on hard crash between write and rename (error-auditor, confidence 80) Strengths
Agents run: code-reviewer, error-auditor, test-reviewer, completeness-checker, simplifier Reviewed by mach6 |
Review Assessment (round 2)Independent verification of the round-2 review findings against actual source. Classifications
Tally: 2 genuine (both medium, both test gaps on new code), 1 deferred (pre-existing race), 2 nitpicks, 0 false positives. Action PlanBoth genuine findings are test gaps on code newly added by this PR, so per the repo completeness rule (test gaps don't auto-defer; the package already has buddy test infra) they ship with the PR.
Deferred (track, do not block merge):
Skip (nitpicks): Findings 4 and 5. Finding 4 is optionally worth a one-line simplification (collapse the two Assessment by mach6 |
…unmount Extract the TUI onVisibilityChange closure into a testable syncBuddyWidget() method and add mount/remove/fallback/render coverage. Add a saveStored failure-atomicity regression: a thrown renameSync leaves buddy.json intact and cleans up the temp file.
Progress UpdateAddressed the two genuine findings from the round-2 review assessment (finding 2 deferred as a pre-existing race; findings 4 and 5 are nitpicks, intentionally skipped). Finding 1 — TUI visibility-sync callback now covered
Finding 3 — atomic-save failure-atomicity now covered
No production logic changed beyond the extract-method refactor. Verification — Deferred (tracked, not blocking): finding 2 — pre-existing full-object lost-update race in Commit: Progress tracked by mach6 |
Closes #302
Make the buddy
hiddenflag the authoritative, live source of truth so that/buddy off(and re-enable via/buddy) converges across all concurrently-running dreb instances within one interaction cycle — instead of only taking effect at the next process start.PR-248 fixed the TUI startup mount gate, but the flag is never re-read during a live session, so a second concurrent instance keeps showing/reacting with the buddy. The reporter runs multiple long-lived instances, which is exactly the condition that surfaces this.
Implementation plan posted as a comment below.