fix(agent-memory-sync): watch push is base-snapshot-aware, stop mirror-deleting unpulled peer files#65
Merged
Conversation
…r-deleting unpulled peer files watch's pushSnapshot() now routes through the same performPush machinery as run --mode sync/push (3-way merge over localFiles and baseFiles) instead of the whole-subtree mirror commitAndPushSnapshot: remote-only peer files are never delete targets, concurrent remote edits get the configured conflict strategy, and an unreachable remote queues locally instead of hard-exiting (documented contract change; config/data errors stay fail-loud). Red-test first: 3 new integration tests pinned the hazard against the old code before the fix. Refs: agent-tasks a2bb475d (toolchain-parity-2026-07-22:followup-watch-mirror) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…apshot refresh; clarify --max-runs tick semantics Review follow-up: the queued-instead-of-fail-loud watch path and the stateDir/base refresh were untested (a regression to the old mirror-push contract would have passed the suite). --max-runs keeps counting ticks (applied or queued), consistent with run.ts and required as termination for the offline test; help text and README now say so. Refs: agent-tasks a2bb475d Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ady; deterministic test arming + tick deadlines The new watch integration tests armed their trigger edit after a fixed sleep; on Linux/inotify the edit can land before chokidar finishes its initial scan, the event is lost, watch never ticks, and CI hangs until the job timeout. The 'watching N path(s)' line now fires in the 'ready' handler (it previously claimed watching before the watcher was armed), tests wait for that line before editing, and every spawned watch child is bounded by a 20s deadline with a kill, so a regression fails in seconds instead of orphaning the job. Refs: agent-tasks a2bb475d Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rt watch-restore tests off fixed-sleep arming watch-restore.test.ts used the same sleep-then-edit arming that hung the new tests on Linux; under the higher parallel suite load it now hangs CI too. Both watch test files use one helper (chokidar-ready wait, 20s tick deadline with kill, --verbose for the ready line); no assertion changes. Refs: agent-tasks a2bb475d Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
watchpushed the local tree as a full mirror ofrepositorySubdir: any remote path missing locally (e.g. a peer machine's file this workspace never pulled) was deleted, and concurrently changed remote files were overwritten without a merge. Empirically reproduced in the 2026-07-22 review (task ff75687e follow-up): a watch tick from machine B deterministically deletedmachine-state/mac-mini.jsonfrom the bare remote.This PR routes the watch tick through the existing base-snapshot-aware
performPushmachinery (therun --mode sync/pushpath) instead of the removedcommitAndPushSnapshotmirror:localFilesandbaseFiles.run --mode sync.docs/machine-setup.md.performPushgains two backward-compatible optional fields (commitMessage,tempDirLabel); watch keeps its human-readable commit messages and an isolated working copy.docs/machine-setup.mdmirror-delete warnings rolled back to describe the fixed behavior; the periodicrun --mode syncjob remains required (watch still never pulls).Verification
watchitself, plus a directstateDir/basepost-merge assertion.Risks
run --mode syncon the same profile (pre-existing race class, consciously out of scope; the working-copy race is avoided viatempDirLabel: "watch").Refs: agent-tasks a2bb475d (toolchain-parity-2026-07-22:followup-watch-mirror)