Skip to content

Fix auto-resync and partial sync metadata#8

Merged
critesjosh merged 4 commits intomainfrom
fix/auto-resync-and-partial-metadata
Mar 4, 2026
Merged

Fix auto-resync and partial sync metadata#8
critesjosh merged 4 commits intomainfrom
fix/auto-resync-and-partial-metadata

Conversation

@critesjosh
Copy link
Collaborator

Summary

  • Force re-clone on auto-resync: When the MCP server version changes, the auto-resync now passes force: true to syncRepos, ensuring tag/commit-pinned repos are actually re-cloned with potentially updated sparse paths and config rather than silently skipped.
  • Skip metadata write on partial syncs: writeSyncMetadata is now only called on full syncs (no repos filter), preventing a single-repo refresh from overwriting global state with a misleading version/timestamp that could cause incorrect auto-resyncs later.
  • New sync metadata system: Adds .sync-metadata.json tracking (MCP version, Aztec version, timestamp) and MCP_VERSION derived from package.json, plus the needsResync() check that triggers auto-resync on version mismatch.

Test plan

  • All 129 existing + new tests pass
  • Verify auto-resync triggers on MCP version upgrade (metadata mcpVersion differs from current)
  • Verify auto-resync is skipped when versions match
  • Verify partial sync (repos: ["aztec-examples"]) does not overwrite .sync-metadata.json
  • Verify full sync writes metadata correctly

🤖 Generated with Claude Code

critesjosh and others added 4 commits March 3, 2026 11:31
Introduces sync metadata (.sync-metadata.json) to track MCP server version,
Aztec version, and last sync timestamp. When the MCP server version changes,
repos are automatically force-resynced to pick up config changes (new sparse
paths, renamed repos, etc.).

Also fixes two correctness issues:
- Auto-resync now passes force:true so tag/commit-pinned repos are actually
  re-cloned rather than silently skipped
- Sync metadata is only written on full syncs, preventing partial syncs from
  recording misleading global state

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move tool name and required argument validation before the auto-resync
  so unknown tools and missing args don't trigger an expensive forced sync
- Check syncRepos result and throw an McpError when auto-resync fails,
  instead of silently continuing against a partially updated checkout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…retry loops

- Abort sync when aztec-packages fails during any version-targeted or forced
  re-clone to prevent mixed-version workspaces
- Add metadataSafe flag to SyncResult; only write .sync-metadata.json when
  all repos succeed and it's a full sync
- Add stampMetadataMcpVersion for partial syncs so they aren't mistaken for
  legacy installs that need a full auto-resync
- Add retryable/hard_failure/deferred result types to auto-resync attempts
  with 30-minute backoff for retryable failures
- Treat docs-missing as cosmetic (write metadata anyway) to avoid infinite
  retry loops for versions without versioned docs
- Use atomic 3-step rename swap (.old backup) in cloneRepo so a failed
  rename doesn't leave the repo unavailable
- Block read-only tools on in-flight syncs to prevent filesystem races,
  but only trigger sync once per MCP version change (stance A)
- Use while loop for manual sync lock to prevent waiter races

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@critesjosh critesjosh merged commit 984be99 into main Mar 4, 2026
6 checks passed
@critesjosh critesjosh deleted the fix/auto-resync-and-partial-metadata branch March 4, 2026 01:28
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

🎉 This PR is included in version 1.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant