Skip to content

Update --sub to latest Subduction#13

Open
expede wants to merge 8 commits intomainfrom
subductionjs
Open

Update --sub to latest Subduction#13
expede wants to merge 8 commits intomainfrom
subductionjs

Conversation

@expede
Copy link
Copy Markdown
Member

@expede expede commented Apr 2, 2026

No description provided.

@expede
Copy link
Copy Markdown
Member Author

expede commented Apr 2, 2026

@copilot thoughts?

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

@copilot thoughts?

The overall approach looks solid — keeping Subduction-specific logic well-isolated (repo-factory, waitForSync fallback, skipping recreateFailedDocuments) and the comments are thorough. A few observations worth considering:

Potential false positive in waitForHandleHeadStability: The function checks for 3 stable polls at 100ms intervals (300ms minimum). But periodicSyncInterval is set to 2000ms, meaning Subduction's first actual push attempt won't fire until ~2s. Since the heads are "stable" from the moment we finish writing local changes, waitForHandleHeadStability can resolve as "synced" after 300ms — before Subduction has had any chance to push to the server. For a "sync and exit" CLI workflow this means we might shut down before the data has actually reached the server. An initial delay of at least periodicSyncInterval before starting stability polling would help, or using a Subduction-specific event/callback if one is available.

waitForBidirectionalSync no longer uses getSyncInfo: Removing syncServerStorageId from its signature means even in non---sub mode, the bidirectional sync phase is now purely head-stability-based. This seems intentional (bidirectional sync is for the incoming/pull phase where stability is the right metric), but worth confirming the behaviour change was deliberate.

new Function ESM import: Clean and well-documented workaround for the CJS/ESM Wasm graph split. No concerns for a Node CLI.

@expede expede marked this pull request as ready for review April 8, 2026 17:12
@expede expede requested review from chee and Copilot April 8, 2026 17:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates pushwork’s Automerge dependencies to the latest Subduction-enabled automerge-repo and introduces/threads a --sub CLI flag to use the Subduction sync backend (including a new head-stability-based sync wait path when no StorageId is available).

Changes:

  • Bump Automerge/Repo packages to 2.6.0-subduction.9 and add @automerge/automerge-subduction.
  • Add --sub flag wiring through CLI → commands → repo creation + sync engine, with Subduction defaults and behavior tweaks.
  • Add unit/integration coverage for Subduction config, repo creation, and the new waitForSync mode.

Reviewed changes

Copilot reviewed 13 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/utils/repo-factory.ts Adds ESM dynamic import + Wasm init and conditional Subduction vs WebSocket repo setup
src/utils/network-sync.ts Adds head-stability polling path for waitForSync when StorageId is absent
src/core/sync-engine.ts Threads sub option to adjust sync verification + retry behavior
src/commands.ts Wires sub into repo creation and sync execution; sets default Subduction endpoint
src/cli.ts Adds --sub option to several commands and passes it through
src/types/config.ts Adds DEFAULT_SUBDUCTION_SERVER and sub?: boolean option fields
test/unit/*sub*.test.ts, test/integration/sub-flag.test.ts Adds unit + integration tests covering Subduction mode
package.json, pnpm-lock.yaml Dependency updates for Subduction-enabled Automerge packages
CLAUDE.md Documents Subduction backend behavior and implementation details
flake.nix, flake.lock, .gitignore Adds Nix dev shell support and ignores Nix/pnpm artifacts
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/repo-factory.ts
Comment thread src/commands.ts
Comment thread src/commands.ts
Comment thread src/utils/network-sync.ts
Comment thread src/utils/network-sync.ts
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.

5 participants