@bastani/atomic 0.10.11-alpha.2 → 0.10.11-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +150 -0
- package/README.md +5 -8
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +6 -6
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
- package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
- package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +36 -8
- package/dist/_shared/p1b-elig-TVB5CBLL.js.map +1 -0
- package/dist/_shared/p2-shell-main-B2WIALFD.js +6 -3
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +1218 -657
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-XJJDOIEC.js} +50 -48
- package/dist/_shared/startup-0-0-XJJDOIEC.js.map +1 -0
- package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-M6OWAYHH.js} +540 -136
- package/dist/_shared/startup-0-1-M6OWAYHH.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +47 -48
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
- package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +2144 -249
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +98 -1184
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +188 -37
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +376 -0
- package/dist/_shared/team-DOQKICG2.js.map +1 -0
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +42 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +1917 -381
- package/dist/builtin/intercom/broker/client.ts +8 -0
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +324 -68
- package/dist/builtin/intercom/broker/multinode-router.ts +256 -39
- package/dist/builtin/intercom/broker/multinode-state-store.ts +71 -5
- package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
- package/dist/builtin/intercom/broker/send-order-gate.ts +5 -2
- package/dist/builtin/intercom/broker/sql-add-column.ts +50 -5
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
- package/dist/builtin/intercom/broker/sql-lease-store.ts +473 -121
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +821 -79
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +256 -8
- package/dist/builtin/intercom/broker/sql-retention.ts +150 -0
- package/dist/builtin/intercom/broker/sql-schema.ts +175 -24
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
- package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +14 -4
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +8 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -10
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/bundled-sqlite.js +41 -0
- package/dist/bun/bundled-sqlite.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.code.js.map +1 -1
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +3 -3
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +19 -113
- package/dist/cli/team-command.code.js.map +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +5 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-rehydrate-errors.d.ts +4 -9
- package/dist/core/compaction/compactor.d.ts +3 -3
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +4 -4
- package/dist/core/export-html/index.code.js.map +1 -1
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.code.js +2 -2
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/process-start-token.d.ts +12 -3
- package/dist/core/process-tree-containment.d.ts +16 -0
- package/dist/core/sdk-types.d.ts +1 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-schema.d.ts +0 -3
- package/dist/core/storage/added-exports-0-10-11.js +19 -0
- package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
- package/dist/core/storage/creation-time.js +105 -0
- package/dist/core/storage/creation-time.js.map +1 -0
- package/dist/core/storage/database.d.ts +25 -5
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +1 -1
- package/dist/core/storage/dialect.js +1 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +13 -13
- package/dist/core/storage/errors.js +10 -16
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +18 -6
- package/dist/core/storage/fenced-paths.js +18 -6
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.d.ts +2 -0
- package/dist/core/storage/file-identity.js +24 -8
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -2
- package/dist/core/storage/index.js +5 -3
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/libsql-removed.d.ts +71 -0
- package/dist/core/storage/libsql-removed.js +123 -0
- package/dist/core/storage/libsql-removed.js.map +1 -0
- package/dist/core/storage/migrations.d.ts +78 -14
- package/dist/core/storage/migrations.js +375 -49
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.js +0 -15
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +215 -30
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +484 -72
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.d.ts +1 -1
- package/dist/core/storage/prefix.js +9 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +5 -5
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +76 -15
- package/dist/core/storage/schema-catalog.js +359 -68
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.d.ts +7 -82
- package/dist/core/storage/selection.js +20 -235
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-detach.d.ts +11 -1
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +4 -7
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-sweep.js +31 -7
- package/dist/core/storage/session/fork-sweep.js.map +1 -1
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-lock.d.ts +100 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +46 -24
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +9 -9
- package/dist/core/storage/session/released-history-files.code.js.map +1 -1
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/session-search-index.d.ts +52 -5
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +99 -18
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/sqlite-facade.d.ts +12 -1
- package/dist/core/storage/sqlite-facade.js +310 -33
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/sqlite-open-batch.js +10 -0
- package/dist/core/storage/sqlite-open-batch.js.map +1 -0
- package/dist/core/storage/storage-status.code.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.code.js +1 -1
- package/dist/core/storage/team.d.ts +26 -115
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/history-tasks.d.ts +3 -2
- package/dist/core/tools/read-url.code.js +4 -4
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.d.ts +44 -5
- package/dist/core/worktree-snapshot/blob-store.js +553 -30
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +2 -2
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
- package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +208 -50
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +3 -3
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -5
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/main.js +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +6 -6
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +2 -4
- package/dist/startup-stages/3.js +1 -3
- package/dist/startup-stages/4.js +1 -2
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/6.js +5 -7
- package/dist/startup-stages/7.js +3 -10
- package/dist/startup-stages/8.js +7 -2
- package/dist/startup-stages/9.js +1 -7
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/compile-cache-deferral.js +8 -13
- package/dist/utils/compile-cache-deferral.js.map +1 -1
- package/dist/utils/compile-cache-warmup-host.js +3 -4
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/compile-cache.js +12 -100
- package/dist/utils/compile-cache.js.map +1 -1
- package/dist/utils/startup-database-spare.code.js +2 -2
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/dist/utils/worker-threads.js +2 -15
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/build.md +3 -3
- package/docs/changelog.mdx +1470 -69
- package/docs/compaction/reference.md +5 -5
- package/docs/compaction.md +7 -9
- package/docs/containerization.md +2 -2
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/docs.json +37 -10
- package/docs/environment-variables.md +0 -2
- package/docs/extensions/api-reference.md +4 -4
- package/docs/getting-started/installation.md +3 -0
- package/docs/guides/configuration.md +1 -1
- package/docs/guides/non-interactive.md +1 -1
- package/docs/guides/resume-on-any-machine.md +14 -22
- package/docs/guides/team-setup.md +56 -83
- package/docs/guides.md +2 -4
- package/docs/herdr.md +1 -1
- package/docs/index.md +1 -1
- package/docs/intercom/operations.md +26 -21
- package/docs/intercom/reference.md +2 -2
- package/docs/intercom.md +1 -1
- package/docs/libraries/storage-postgres.md +9 -9
- package/docs/libraries.md +2 -3
- package/docs/models-configuration.md +2 -2
- package/docs/models.md +2 -3
- package/docs/packages/authoring.md +7 -7
- package/docs/packages.md +1 -1
- package/docs/programmatic.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +6 -11
- package/docs/reference.md +2 -2
- package/docs/rpc/extension-ui.md +2 -2
- package/docs/sdk/reference.md +5 -4
- package/docs/sdk/storage.md +8 -92
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +14 -4
- package/docs/security.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/sessions.md +29 -49
- package/docs/settings.md +7 -8
- package/docs/storage/custom-adapters.md +255 -0
- package/docs/storage/jsonl.md +117 -0
- package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
- package/docs/storage/postgres/tuning.md +337 -0
- package/docs/storage/postgres.md +556 -0
- package/docs/storage/sqlite.md +99 -0
- package/docs/storage.md +326 -990
- package/docs/subagents/authoring.md +1 -1
- package/docs/subagents.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/worktree-snapshots.md +2 -2
- package/package.json +9 -9
- package/schemas/models.schema.json +2 -2
- package/schemas/settings.schema.json +0 -14
- package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +0 -1
- package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
- package/dist/core/intercom-broker-control.d.ts +0 -129
- package/dist/startup-stages/13.js +0 -1
- package/docs/guides/postgres-tuning.md +0 -311
- package/docs/libraries/storage-libsql.md +0 -97
|
@@ -46,9 +46,14 @@ import {
|
|
|
46
46
|
type LeaseRenewalRequest,
|
|
47
47
|
type LeaseRenewResult,
|
|
48
48
|
type LeaseState,
|
|
49
|
+
MAINTENANCE_INTERVAL_MS,
|
|
50
|
+
MAINTENANCE_STALE_AFTER_MS,
|
|
51
|
+
type MaintenanceSubject,
|
|
49
52
|
OUTBOX_BACKUP_POLL_INTERVAL_MS,
|
|
50
53
|
OUTBOX_CLAIM_STALE_AFTER_MS,
|
|
51
54
|
type OutboxClaim,
|
|
55
|
+
type OutboxReleaseClaimResult,
|
|
56
|
+
type OutboxRenewClaimResult,
|
|
52
57
|
type OutboxEnqueueRequest,
|
|
53
58
|
type OutboxEnqueueResult,
|
|
54
59
|
type OutboxRow,
|
|
@@ -59,6 +64,7 @@ import {
|
|
|
59
64
|
type ReleasedAskRecord,
|
|
60
65
|
type RestoringReservation,
|
|
61
66
|
type RestoringReservationLease,
|
|
67
|
+
type RestoringReservationRenewResult,
|
|
62
68
|
reservationKeyFor,
|
|
63
69
|
returnAddressOf,
|
|
64
70
|
type SentMessageReservation,
|
|
@@ -150,6 +156,9 @@ const ROUTE_HOLDER_DOWN_WINDOW_MS = 10 * 60_000;
|
|
|
150
156
|
const BROKER_UNRESPONSIVE_AFTER_MS = (3 * BROKER_LEASE_RENEW_INTERVAL_MS) / 2;
|
|
151
157
|
export const SHARED_STORAGE_UNAVAILABLE_REASON =
|
|
152
158
|
"Session not found on this node, and Intercom could not reach the shared storage database to look for it on other nodes. Try again once the database is available.";
|
|
159
|
+
/** #6637: a send that would overtake its sender's earlier messages to the session, still undelivered at the save cap. */
|
|
160
|
+
export const EARLIER_SENDS_UNDELIVERED_REASON =
|
|
161
|
+
"Your earlier messages to this session are still waiting in the shared storage database, and this one may not overtake them. Try again once the database is available.";
|
|
153
162
|
const MAX_HELD_SENDS = 256;
|
|
154
163
|
/**
|
|
155
164
|
* #3983: how long the decision to keep a sender waiting may take before the sender is told to keep waiting while it
|
|
@@ -563,6 +572,11 @@ interface Waiter {
|
|
|
563
572
|
* wait as uncertain (#4443).
|
|
564
573
|
*/
|
|
565
574
|
missedSavingReport?: boolean;
|
|
575
|
+
/**
|
|
576
|
+
* #6637: its send was answered and its routing is over, so a later local send to its recipient goes after it
|
|
577
|
+
* (`waitForEarlierOutboxSends`); one still routing is ordered by the send-order gate, within its bounds.
|
|
578
|
+
*/
|
|
579
|
+
routed?: true;
|
|
566
580
|
}
|
|
567
581
|
|
|
568
582
|
interface SendProgress {
|
|
@@ -575,6 +589,7 @@ interface SendProgress {
|
|
|
575
589
|
readonly messageId: string;
|
|
576
590
|
readonly attemptId?: string;
|
|
577
591
|
readonly ticket?: SendOrderTicket;
|
|
592
|
+
readonly requirePendingReplyLocal?: true;
|
|
578
593
|
waitingOnReplyKey?: string;
|
|
579
594
|
scheduledFireAt?: number;
|
|
580
595
|
stopReporting?: () => void;
|
|
@@ -1085,6 +1100,8 @@ export class MultiNodeRouter {
|
|
|
1085
1100
|
private readonly processStartedAt: (pid: number) => number | null | undefined | Promise<number | null | undefined>;
|
|
1086
1101
|
private readonly lostBounds: LostRecipientBounds;
|
|
1087
1102
|
private membership: Lease | undefined;
|
|
1103
|
+
/** The maintenance lease while this broker is the swarm's maintainer (`maintain`). */
|
|
1104
|
+
private maintenance: Lease | undefined;
|
|
1088
1105
|
private subscription: WakeUpSubscription | undefined;
|
|
1089
1106
|
private readonly presence = new Map<BrokerConnectedSession, PresenceEntry>();
|
|
1090
1107
|
private readonly inflight = new Map<string, Inflight>();
|
|
@@ -1114,6 +1131,8 @@ export class MultiNodeRouter {
|
|
|
1114
1131
|
private readonly initialScans = new Map<string, { readonly promise: Promise<void>; readonly resolve: () => void }>();
|
|
1115
1132
|
/** Refcount of unsettled outbox waiters per `(senderKey, targetIdentity)` pair, maintained by `setWaiter`/`dropWaiter`. */
|
|
1116
1133
|
private readonly unsettledOutboxPairs = new Map<string, number>();
|
|
1134
|
+
/** #6637: local sends waiting for their sender's earlier outbox sends to their recipient (`waitForEarlierOutboxSends`). */
|
|
1135
|
+
private readonly outboxSendWatchers = new Set<() => void>();
|
|
1117
1136
|
private readonly sendOrder = new SendOrderGate();
|
|
1118
1137
|
private activeLocalCommit:
|
|
1119
1138
|
| { readonly clientMessage: SendClientMessage; reentrant?: RemoteSendRequest }
|
|
@@ -1307,6 +1326,7 @@ export class MultiNodeRouter {
|
|
|
1307
1326
|
if (subscribed.status === "subscribed") router.subscription = subscribed.subscription;
|
|
1308
1327
|
router.every(BROKER_LEASE_RENEW_INTERVAL_MS, () => router.renew());
|
|
1309
1328
|
router.every(OUTBOX_BACKUP_POLL_INTERVAL_MS, () => router.backupPoll());
|
|
1329
|
+
router.every(MAINTENANCE_INTERVAL_MS, () => router.maintain());
|
|
1310
1330
|
// #4992: what a broker that stopped mid-departure left is finished now, and at every backup poll.
|
|
1311
1331
|
// #5154: and the asks to recipients lost long enough.
|
|
1312
1332
|
void router
|
|
@@ -2873,7 +2893,12 @@ export class MultiNodeRouter {
|
|
|
2873
2893
|
});
|
|
2874
2894
|
if (enqueued.status === "invalid" || enqueued.status === "full") continue;
|
|
2875
2895
|
if (enqueued.status === "inserted" && owner.hostBrokerId !== undefined) {
|
|
2876
|
-
await this.bus.publish({
|
|
2896
|
+
await this.bus.publish({
|
|
2897
|
+
brokerId: owner.hostBrokerId,
|
|
2898
|
+
reason: "outbox",
|
|
2899
|
+
version: enqueued.row.sequence,
|
|
2900
|
+
targetIdentity: owner.identity,
|
|
2901
|
+
});
|
|
2877
2902
|
}
|
|
2878
2903
|
await this.state.releasedAsks.claim({
|
|
2879
2904
|
questionId: ask.questionId,
|
|
@@ -2991,7 +3016,12 @@ export class MultiNodeRouter {
|
|
|
2991
3016
|
});
|
|
2992
3017
|
}
|
|
2993
3018
|
if (enqueued.status === "inserted" && hosted !== undefined) {
|
|
2994
|
-
await this.bus.publish({
|
|
3019
|
+
await this.bus.publish({
|
|
3020
|
+
brokerId: hosted.holderId,
|
|
3021
|
+
reason: "outbox",
|
|
3022
|
+
version: enqueued.row.sequence,
|
|
3023
|
+
targetIdentity: asker.targetIdentity,
|
|
3024
|
+
});
|
|
2995
3025
|
}
|
|
2996
3026
|
}
|
|
2997
3027
|
}
|
|
@@ -3027,6 +3057,7 @@ export class MultiNodeRouter {
|
|
|
3027
3057
|
for (const [release, owner] of [...this.activeOpenings]) {
|
|
3028
3058
|
if (owner === session) release();
|
|
3029
3059
|
}
|
|
3060
|
+
this.outboxSendsChanged();
|
|
3030
3061
|
for (const waiter of [...this.waiters.values()]) {
|
|
3031
3062
|
// #4642: a hosted session shares its host's socket; only its own sends end with it.
|
|
3032
3063
|
const sentBySession =
|
|
@@ -3045,7 +3076,7 @@ export class MultiNodeRouter {
|
|
|
3045
3076
|
// this registration held itself is given back.
|
|
3046
3077
|
if (alias !== undefined) await this.releaseOwner(alias);
|
|
3047
3078
|
if (entry.fenced === true) {
|
|
3048
|
-
|
|
3079
|
+
await this.releaseClaims(claims.map((inflight) => inflight.claim));
|
|
3049
3080
|
const stillHere = [...this.presence.keys()].some((other) => deliveryTargetIdentity(other) === identity);
|
|
3050
3081
|
if (entry.lease !== undefined && !stillHere) {
|
|
3051
3082
|
await this.state.leases.release(entry.lease);
|
|
@@ -3086,7 +3117,7 @@ export class MultiNodeRouter {
|
|
|
3086
3117
|
// a reply never finds it offline with only its pending asks. A failed write loses them, as a lost local route
|
|
3087
3118
|
// does: the subagent then wakes at its reply deadline.
|
|
3088
3119
|
await keepReleasedAsks(this.state, session).catch((error: Error) => this.report(error));
|
|
3089
|
-
|
|
3120
|
+
await this.releaseClaims(claims.map((inflight) => inflight.claim));
|
|
3090
3121
|
// #4842: an ask that ends with its recipient fails for its asker on any node.
|
|
3091
3122
|
await (away ? Promise.resolve() : this.state.pendingAsks.pruneSender(sessionId).then(() => undefined))
|
|
3092
3123
|
.then(async () => {
|
|
@@ -3646,6 +3677,7 @@ export class MultiNodeRouter {
|
|
|
3646
3677
|
messageId: request.message.id,
|
|
3647
3678
|
...(request.attemptId === undefined ? {} : { attemptId: request.attemptId }),
|
|
3648
3679
|
ticket,
|
|
3680
|
+
...(request.localTarget !== undefined && request.requirePendingReply ? { requirePendingReplyLocal: true as const } : {}),
|
|
3649
3681
|
};
|
|
3650
3682
|
this.sendProgress.set(request.clientMessage, progress);
|
|
3651
3683
|
this.ticketProgress.set(ticket, progress);
|
|
@@ -3719,7 +3751,11 @@ export class MultiNodeRouter {
|
|
|
3719
3751
|
} finally {
|
|
3720
3752
|
const progress = this.sendProgress.get(request.clientMessage);
|
|
3721
3753
|
if (progress !== undefined) this.stopProgress(progress);
|
|
3722
|
-
if (ownsTicket)
|
|
3754
|
+
if (ownsTicket) {
|
|
3755
|
+
this.sendOrder.finish(ticket);
|
|
3756
|
+
const waiter = this.waiters.get(request.message.id);
|
|
3757
|
+
if (waiter !== undefined) waiter.routed = true;
|
|
3758
|
+
}
|
|
3723
3759
|
}
|
|
3724
3760
|
}
|
|
3725
3761
|
|
|
@@ -3965,9 +4001,31 @@ export class MultiNodeRouter {
|
|
|
3965
4001
|
if (upstream !== undefined && upstream.hadProgress) {
|
|
3966
4002
|
latest = latest === undefined ? upstream.lastProgressAt : Math.max(latest, upstream.lastProgressAt);
|
|
3967
4003
|
}
|
|
4004
|
+
const active = upstream ?? own;
|
|
4005
|
+
if (
|
|
4006
|
+
latest === undefined &&
|
|
4007
|
+
active.requirePendingReplyLocal === true &&
|
|
4008
|
+
active.waitingOnReplyKey === undefined &&
|
|
4009
|
+
this.storeAnsweredAt >= active.startedAt
|
|
4010
|
+
) {
|
|
4011
|
+
latest = this.storeAnsweredAt;
|
|
4012
|
+
}
|
|
3968
4013
|
return latest;
|
|
3969
4014
|
}
|
|
3970
4015
|
|
|
4016
|
+
/**
|
|
4017
|
+
* Store-silence window for a plain local send waiting on `earlier`. A local `requirePendingReply` reply has a
|
|
4018
|
+
* `PRESENCE_REGISTRATION_BOUND_MS` shared-route adoption budget, so once the shared store is proven responsive a
|
|
4019
|
+
* single contended write (> 300 ms) must not let later plain sends overtake it; soft replies and unsettled outbox
|
|
4020
|
+
* retries keep `LOCAL_RETRY_LOOKUP_BOUND_MS`.
|
|
4021
|
+
*/
|
|
4022
|
+
private localBlockerSilenceMs(earlier: SendOrderTicket): number {
|
|
4023
|
+
const own = this.ticketProgress.get(earlier);
|
|
4024
|
+
if (own === undefined) return LOCAL_RETRY_LOOKUP_BOUND_MS;
|
|
4025
|
+
const active = this.resolveBlockerProgress(own, earlier) ?? own;
|
|
4026
|
+
return active.requirePendingReplyLocal === true ? PRESENCE_REGISTRATION_BOUND_MS : LOCAL_RETRY_LOOKUP_BOUND_MS;
|
|
4027
|
+
}
|
|
4028
|
+
|
|
3971
4029
|
/** Wait for strictly earlier sends from the same sender to `target` before performing a local commit. */
|
|
3972
4030
|
private async waitForEarlierLocal(
|
|
3973
4031
|
ticket: SendOrderTicket,
|
|
@@ -4004,7 +4062,7 @@ export class MultiNodeRouter {
|
|
|
4004
4062
|
...(hasBound
|
|
4005
4063
|
? {
|
|
4006
4064
|
blockerProgressAt: (earlier) => this.blockerProgressAt(earlier),
|
|
4007
|
-
progressSilenceMs:
|
|
4065
|
+
progressSilenceMs: (earlier) => this.localBlockerSilenceMs(earlier),
|
|
4008
4066
|
maxLocalWaitUntil: (ownProgress?.startedAt ?? performance.now()) + PRESENCE_REGISTRATION_BOUND_MS,
|
|
4009
4067
|
}
|
|
4010
4068
|
: {}),
|
|
@@ -4013,21 +4071,79 @@ export class MultiNodeRouter {
|
|
|
4013
4071
|
}
|
|
4014
4072
|
|
|
4015
4073
|
/**
|
|
4016
|
-
*
|
|
4017
|
-
*
|
|
4018
|
-
*
|
|
4074
|
+
* #6637: a send to a session here goes after its sender's earlier sends to that session still in the shared outbox
|
|
4075
|
+
* (sent while it was offline or on another broker, and answered): it waits until this broker has written each of them
|
|
4076
|
+
* to the session, or each settled otherwise. A wait bounded by the local lookup's bound let it overtake them whenever the
|
|
4077
|
+
* session's registration and first claim took longer, as on a far-away database, or the claim found the rows still
|
|
4078
|
+
* held by the broker the session left. Only a sender with an unsettled outbox send to the session ever waits. The
|
|
4079
|
+
* sender is held meanwhile, and refused as retryable at the save cap. True to take the local path; false when the
|
|
4080
|
+
* send was answered or the router closed.
|
|
4019
4081
|
*/
|
|
4020
|
-
private async
|
|
4082
|
+
private async waitForEarlierOutboxSends(
|
|
4083
|
+
request: RemoteSendRequest,
|
|
4021
4084
|
senderKey: string,
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4085
|
+
target: BrokerConnectedSession,
|
|
4086
|
+
): Promise<boolean> {
|
|
4087
|
+
const identity = deliveryTargetIdentity(target);
|
|
4088
|
+
const pair = outboxPairKey(senderKey, identity);
|
|
4089
|
+
if (!this.unsettledOutboxPairs.has(pair)) return true;
|
|
4090
|
+
const earlier = new Set<string>();
|
|
4091
|
+
for (const waiter of this.waiters.values())
|
|
4092
|
+
if (
|
|
4093
|
+
waiter.routed === true &&
|
|
4094
|
+
waiter.messageId !== request.message.id &&
|
|
4095
|
+
outboxPairKey(waiter.senderKey, waiter.targetIdentity) === pair
|
|
4096
|
+
)
|
|
4097
|
+
earlier.add(waiter.messageId);
|
|
4098
|
+
const written = (): boolean => {
|
|
4099
|
+
for (const messageId of earlier)
|
|
4100
|
+
if (!this.waiters.has(messageId) || this.inflight.get(messageId)?.session === target) earlier.delete(messageId);
|
|
4101
|
+
return earlier.size === 0;
|
|
4102
|
+
};
|
|
4103
|
+
if (written()) return true;
|
|
4104
|
+
// A registration's first scan is still to come; otherwise a scan that ended without them looks again now.
|
|
4105
|
+
if (!this.initialScans.has(identity)) void this.scanIdentity(identity);
|
|
4106
|
+
const progress = this.sendProgress.get(request.clientMessage);
|
|
4107
|
+
const startedAt = progress?.startedAt ?? performance.now();
|
|
4108
|
+
const deadline = { clientDeadlineAt: progress?.clientDeadlineAt ?? startedAt + SEND_RESPONSE_TIMEOUT_MS };
|
|
4109
|
+
const capAt = startedAt + RECIPIENT_SAVE_MAX_WAIT_MS;
|
|
4110
|
+
while (!this.closed && !written()) {
|
|
4111
|
+
// A session that left takes the local path's fallback, which routes the send through the outbox behind them.
|
|
4112
|
+
if (this.host.sessions.get(target.info.id) !== target) return true;
|
|
4113
|
+
const now = performance.now();
|
|
4114
|
+
if (now >= capAt) {
|
|
4115
|
+
this.fail(request, EARLIER_SENDS_UNDELIVERED_REASON);
|
|
4116
|
+
return false;
|
|
4117
|
+
}
|
|
4118
|
+
const guardAt = deadline.clientDeadlineAt - MIN_WAIT_CLIENT_MARGIN_MS;
|
|
4119
|
+
if (now >= guardAt) {
|
|
4120
|
+
this.sendHoldFrame(
|
|
4121
|
+
request.socket,
|
|
4122
|
+
request.message.id,
|
|
4123
|
+
request.attemptId,
|
|
4124
|
+
Math.min(RECIPIENT_RECEIPT_TIMEOUT_MS, capAt - now),
|
|
4125
|
+
deadline,
|
|
4126
|
+
);
|
|
4127
|
+
if (progress !== undefined) progress.clientDeadlineAt = deadline.clientDeadlineAt;
|
|
4128
|
+
continue;
|
|
4129
|
+
}
|
|
4130
|
+
await new Promise<void>((resolve) => {
|
|
4131
|
+
const wake = (): void => {
|
|
4132
|
+
clearTimeout(timer);
|
|
4133
|
+
this.outboxSendWatchers.delete(wake);
|
|
4134
|
+
resolve();
|
|
4135
|
+
};
|
|
4136
|
+
const timer = setTimeout(wake, Math.min(capAt, guardAt) - now);
|
|
4137
|
+
timer.unref?.();
|
|
4138
|
+
this.outboxSendWatchers.add(wake);
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
4141
|
+
return !this.closed;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
/** #6637: an outbox send was written to its recipient here or settled, or a recipient left: waits look again. */
|
|
4145
|
+
private outboxSendsChanged(): void {
|
|
4146
|
+
for (const wake of [...this.outboxSendWatchers]) wake();
|
|
4031
4147
|
}
|
|
4032
4148
|
|
|
4033
4149
|
/**
|
|
@@ -4884,7 +5000,6 @@ export class MultiNodeRouter {
|
|
|
4884
5000
|
ticket: SendOrderTicket,
|
|
4885
5001
|
openingDeadlineAt: number,
|
|
4886
5002
|
): Promise<void> {
|
|
4887
|
-
const targetIdentity = deliveryTargetIdentity(target);
|
|
4888
5003
|
const lookup = this.state.outbox.read(request.message.id);
|
|
4889
5004
|
// #5607: a lookup that fails while an owner check is still answering is reported when it is awaited below, not
|
|
4890
5005
|
// left unobserved meanwhile. The checks are waited for within the lookup's own bound, counted from now.
|
|
@@ -4934,7 +5049,7 @@ export class MultiNodeRouter {
|
|
|
4934
5049
|
sending = adopted;
|
|
4935
5050
|
}
|
|
4936
5051
|
await this.waitForEarlierLocal(ticket, target, expired, boundExpired);
|
|
4937
|
-
await this.
|
|
5052
|
+
if (!(await this.waitForEarlierOutboxSends(sending, ticket.senderKey, target))) return;
|
|
4938
5053
|
this.extendBeforeLocalReceiptWait(sending, target);
|
|
4939
5054
|
await this.commitLocalNotFound(sending, ticket, openingDeadlineAt);
|
|
4940
5055
|
return;
|
|
@@ -4977,7 +5092,7 @@ export class MultiNodeRouter {
|
|
|
4977
5092
|
sending = adopted;
|
|
4978
5093
|
}
|
|
4979
5094
|
await this.waitForEarlierLocal(ticket, target, expired, boundExpired);
|
|
4980
|
-
await this.
|
|
5095
|
+
if (!(await this.waitForEarlierOutboxSends(sending, ticket.senderKey, target))) return;
|
|
4981
5096
|
this.extendBeforeLocalReceiptWait(sending, target);
|
|
4982
5097
|
await this.commitLocalNotFound(sending, ticket, openingDeadlineAt);
|
|
4983
5098
|
} finally {
|
|
@@ -5444,7 +5559,12 @@ export class MultiNodeRouter {
|
|
|
5444
5559
|
this.holdSender(waiter, receiptWaitMs);
|
|
5445
5560
|
}
|
|
5446
5561
|
if (asksTarget) await this.writeQuestionTarget(request.socket, message.id, request.attemptId, target);
|
|
5447
|
-
await this.bus.publish({
|
|
5562
|
+
await this.bus.publish({
|
|
5563
|
+
brokerId: target.hostBrokerId!,
|
|
5564
|
+
reason: "outbox",
|
|
5565
|
+
version: row.sequence,
|
|
5566
|
+
targetIdentity: row.targetIdentity,
|
|
5567
|
+
});
|
|
5448
5568
|
// A clean quit recorded before this send's row was written is seen here; one recorded after it wakes this
|
|
5449
5569
|
// broker (`wakeWaitingOrigins`), so a send racing its recipient's quit is queued either way. The waiter's own
|
|
5450
5570
|
// receipt wait keeps running meanwhile, so slow reads here never hold the sender past it.
|
|
@@ -5739,10 +5859,28 @@ export class MultiNodeRouter {
|
|
|
5739
5859
|
return done;
|
|
5740
5860
|
}
|
|
5741
5861
|
|
|
5862
|
+
/**
|
|
5863
|
+
* Scans every recipient this broker hosts. With several, one read first finds those with undelivered rows, and only
|
|
5864
|
+
* they are claimed for: a backup poll or resync across idle recipients costs one statement, not a claim each (#6560).
|
|
5865
|
+
* A row queued after the read is claimed when its send's wake-up hint arrives, or at the next scan, as one queued
|
|
5866
|
+
* right after a claim's own read is. When the read fails, every recipient is claimed for, as without it.
|
|
5867
|
+
*/
|
|
5742
5868
|
private scanAll(): void {
|
|
5743
|
-
|
|
5744
|
-
|
|
5869
|
+
const identities = [...new Set([...this.host.sessions.values()].map(deliveryTargetIdentity))];
|
|
5870
|
+
const outbox = this.state.outbox;
|
|
5871
|
+
if (identities.length < 2 || outbox.withUndelivered === undefined) {
|
|
5872
|
+
for (const identity of identities) this.scanIdentity(identity);
|
|
5873
|
+
return;
|
|
5745
5874
|
}
|
|
5875
|
+
void outbox.withUndelivered(identities).then(
|
|
5876
|
+
(found) => {
|
|
5877
|
+
for (const identity of identities) if (found.has(identity)) this.scanIdentity(identity);
|
|
5878
|
+
},
|
|
5879
|
+
(error: unknown) => {
|
|
5880
|
+
this.report(error);
|
|
5881
|
+
for (const identity of identities) this.scanIdentity(identity);
|
|
5882
|
+
},
|
|
5883
|
+
);
|
|
5746
5884
|
}
|
|
5747
5885
|
|
|
5748
5886
|
private localSessionFor(identity: string): BrokerConnectedSession | undefined {
|
|
@@ -5777,10 +5915,13 @@ export class MultiNodeRouter {
|
|
|
5777
5915
|
// The recipient left or was replaced while this batch was being delivered: release this row and every
|
|
5778
5916
|
// later row in the batch unwritten so a reconnected session never receives a later row ahead of an earlier
|
|
5779
5917
|
// released row.
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5918
|
+
const tail = claimed.rows.slice(index);
|
|
5919
|
+
const released = await this.releaseClaims(
|
|
5920
|
+
tail.map((pending) => pending.claim),
|
|
5921
|
+
{ unwritten: true },
|
|
5922
|
+
);
|
|
5923
|
+
for (let remaining = 0; remaining < tail.length; remaining++) {
|
|
5924
|
+
if (released[remaining]?.status === "released") await this.wakeOrigin(tail[remaining]!.row);
|
|
5784
5925
|
}
|
|
5785
5926
|
if (this.localSessionFor(identity) !== undefined) void this.scanIdentity(identity);
|
|
5786
5927
|
return;
|
|
@@ -5842,6 +5983,7 @@ export class MultiNodeRouter {
|
|
|
5842
5983
|
// A recipient that never confirms saves is delivered once the frame is written, as locally.
|
|
5843
5984
|
if (session.acknowledgesReceipt !== true) this.settleDelivered(inflight, session, frame);
|
|
5844
5985
|
});
|
|
5986
|
+
this.outboxSendsChanged();
|
|
5845
5987
|
}
|
|
5846
5988
|
}
|
|
5847
5989
|
|
|
@@ -5927,7 +6069,12 @@ export class MultiNodeRouter {
|
|
|
5927
6069
|
});
|
|
5928
6070
|
}
|
|
5929
6071
|
}
|
|
5930
|
-
|
|
6072
|
+
// Replies clear their shared pending-ask route after `markDelivered` commits; keeping `wakeOrigin` after
|
|
6073
|
+
// `clearReply` prevents the replier from hearing `delivered` and sending a second reply before the route
|
|
6074
|
+
// is cleared (#6715). Non-reply deliveries write the outcome hint atomically inside the settlement.
|
|
6075
|
+
const delivered = await this.state.outbox.markDelivered(inflight.claim, {
|
|
6076
|
+
wakeOrigin: frame.message.replyTo === undefined,
|
|
6077
|
+
});
|
|
5931
6078
|
this.storeAnswered();
|
|
5932
6079
|
marked = true;
|
|
5933
6080
|
this.firstHandedOverAt.delete(messageId);
|
|
@@ -5952,7 +6099,7 @@ export class MultiNodeRouter {
|
|
|
5952
6099
|
inflight.handedOverAt,
|
|
5953
6100
|
);
|
|
5954
6101
|
finishOpening?.();
|
|
5955
|
-
await this.wakeOrigin(inflight.row);
|
|
6102
|
+
if (delivered.woke !== inflight.row.originBrokerId) await this.wakeOrigin(inflight.row);
|
|
5956
6103
|
} finally {
|
|
5957
6104
|
finishOpening?.();
|
|
5958
6105
|
}
|
|
@@ -5980,6 +6127,20 @@ export class MultiNodeRouter {
|
|
|
5980
6127
|
}
|
|
5981
6128
|
}
|
|
5982
6129
|
|
|
6130
|
+
private async releaseClaims(
|
|
6131
|
+
claims: readonly OutboxClaim[],
|
|
6132
|
+
options?: { readonly unwritten?: boolean },
|
|
6133
|
+
): Promise<OutboxReleaseClaimResult[]> {
|
|
6134
|
+
if (claims.length === 0) return [];
|
|
6135
|
+
const outbox = this.state.outbox;
|
|
6136
|
+
if (claims.length > 1 && outbox.releaseClaims !== undefined) {
|
|
6137
|
+
return outbox.releaseClaims(claims, options);
|
|
6138
|
+
}
|
|
6139
|
+
const results: OutboxReleaseClaimResult[] = [];
|
|
6140
|
+
for (const claim of claims) results.push(await outbox.releaseClaim(claim, options));
|
|
6141
|
+
return results;
|
|
6142
|
+
}
|
|
6143
|
+
|
|
5983
6144
|
private async wakeOrigin(row: OutboxRow): Promise<void> {
|
|
5984
6145
|
if (row.originBrokerId === this.brokerId) void this.checkOutcomes();
|
|
5985
6146
|
else await this.bus.publish({ brokerId: row.originBrokerId, reason: "outcome", version: row.sequence });
|
|
@@ -6195,6 +6356,7 @@ export class MultiNodeRouter {
|
|
|
6195
6356
|
const next = (this.unsettledOutboxPairs.get(pair) ?? 0) - 1;
|
|
6196
6357
|
if (next <= 0) this.unsettledOutboxPairs.delete(pair);
|
|
6197
6358
|
else this.unsettledOutboxPairs.set(pair, next);
|
|
6359
|
+
this.outboxSendsChanged();
|
|
6198
6360
|
}
|
|
6199
6361
|
if (waiter.timer !== undefined) clearTimeout(waiter.timer);
|
|
6200
6362
|
if (waiter.capTimer !== undefined) clearTimeout(waiter.capTimer);
|
|
@@ -6212,8 +6374,12 @@ export class MultiNodeRouter {
|
|
|
6212
6374
|
void this.guard(this.deliverWakeRequests());
|
|
6213
6375
|
return;
|
|
6214
6376
|
}
|
|
6215
|
-
if (event.hint.reason === "outbox")
|
|
6216
|
-
|
|
6377
|
+
if (event.hint.reason === "outbox") {
|
|
6378
|
+
// A hint that names its recipient concerns that recipient's queue alone; one from an earlier release names none.
|
|
6379
|
+
const target = event.hint.targetIdentity;
|
|
6380
|
+
if (target === undefined) this.scanAll();
|
|
6381
|
+
else if (this.localSessionFor(target) !== undefined) void this.scanIdentity(target);
|
|
6382
|
+
} else {
|
|
6217
6383
|
void this.checkOutcomes();
|
|
6218
6384
|
void this.guard(this.checkHolds());
|
|
6219
6385
|
void this.guard(this.deliverWakeRequests());
|
|
@@ -6229,6 +6395,7 @@ export class MultiNodeRouter {
|
|
|
6229
6395
|
instanceKey: this.instanceKey,
|
|
6230
6396
|
pid: this.pid,
|
|
6231
6397
|
...(this.home === undefined ? {} : { home: this.home }),
|
|
6398
|
+
ownWakeUpChannel: true,
|
|
6232
6399
|
};
|
|
6233
6400
|
}
|
|
6234
6401
|
|
|
@@ -6366,16 +6533,34 @@ export class MultiNodeRouter {
|
|
|
6366
6533
|
}
|
|
6367
6534
|
});
|
|
6368
6535
|
}
|
|
6369
|
-
|
|
6370
|
-
|
|
6536
|
+
const inflights = [...this.inflight.values()];
|
|
6537
|
+
const dropUnrenewed = (inflight: Inflight, renewed: OutboxRenewClaimResult) => {
|
|
6371
6538
|
if (renewed.status !== "renewed" && this.inflight.get(inflight.row.messageId) === inflight) {
|
|
6372
6539
|
this.inflight.delete(inflight.row.messageId);
|
|
6373
6540
|
inflight.finishOpening?.();
|
|
6374
6541
|
}
|
|
6375
|
-
}
|
|
6376
|
-
|
|
6377
|
-
|
|
6542
|
+
};
|
|
6543
|
+
// #6560: every claim in flight renewed in one statement, not a transaction each.
|
|
6544
|
+
const outbox = this.state.outbox;
|
|
6545
|
+
if (inflights.length > 1 && outbox.renewClaims !== undefined) {
|
|
6546
|
+
const renewed = await outbox.renewClaims(inflights.map((inflight) => inflight.claim));
|
|
6547
|
+
inflights.forEach((inflight, index) => dropUnrenewed(inflight, renewed[index]!));
|
|
6548
|
+
} else for (const inflight of inflights) dropUnrenewed(inflight, await outbox.renewClaim(inflight.claim));
|
|
6549
|
+
const mirrors = [...this.mirrored];
|
|
6550
|
+
const dropUnrenewedMirror = (
|
|
6551
|
+
key: string,
|
|
6552
|
+
mirror: MirroredReservation,
|
|
6553
|
+
renewed: RestoringReservationRenewResult,
|
|
6554
|
+
) => {
|
|
6378
6555
|
if (renewed.status !== "renewed" && this.mirrored.get(key) === mirror) this.mirrored.delete(key);
|
|
6556
|
+
};
|
|
6557
|
+
const reservations = this.state.reservations;
|
|
6558
|
+
if (mirrors.length > 0 && reservations.renewMany !== undefined) {
|
|
6559
|
+
const renewed = await reservations.renewMany(mirrors.map(([, mirror]) => mirror.lease));
|
|
6560
|
+
mirrors.forEach(([key, mirror], index) => dropUnrenewedMirror(key, mirror, renewed[index]!));
|
|
6561
|
+
} else {
|
|
6562
|
+
for (const [key, mirror] of mirrors)
|
|
6563
|
+
dropUnrenewedMirror(key, mirror, await reservations.renew(mirror.lease));
|
|
6379
6564
|
}
|
|
6380
6565
|
// #5352: a reservation whose write failed or did not answer is written again, in order behind its key's steps.
|
|
6381
6566
|
for (const [key, pending] of this.unpublished) {
|
|
@@ -6401,6 +6586,33 @@ export class MultiNodeRouter {
|
|
|
6401
6586
|
this.wakeWaitingChild(reservationKey).finally(() => this.pendingWakeChecks.delete(reservationKey)),
|
|
6402
6587
|
);
|
|
6403
6588
|
}
|
|
6589
|
+
}
|
|
6590
|
+
|
|
6591
|
+
/**
|
|
6592
|
+
* The shared state's maintenance: the rows past their retention deleted, and outbox rows left queued past the
|
|
6593
|
+
* known-session retention expired. One broker of the swarm runs it each `MAINTENANCE_INTERVAL_MS`, the one holding
|
|
6594
|
+
* the maintenance lease, as Oban's pruner runs on its leader and River's on its maintenance leader: when every broker
|
|
6595
|
+
* ran it at every backup poll, a swarm of brokers sent the same deletes over and over. A broker that is not the
|
|
6596
|
+
* maintainer reads the lease and goes on while another holds it live; the maintainer takes it again, which renews
|
|
6597
|
+
* it, and so stays the maintainer while it runs. Once it stops, its lease goes stale after
|
|
6598
|
+
* `MAINTENANCE_STALE_AFTER_MS` (or is free at once, when it closed) and the next broker to check takes it over.
|
|
6599
|
+
* Nothing here is needed for delivery: a broker's own scans and the sweeps for a stopped broker's recipients stay in
|
|
6600
|
+
* `backupPoll`, on every broker.
|
|
6601
|
+
*/
|
|
6602
|
+
private async maintain(): Promise<void> {
|
|
6603
|
+
const { leases } = this.state;
|
|
6604
|
+
if (this.maintenance === undefined) {
|
|
6605
|
+
const found = await leases.read({ kind: "maintenance", task: RETENTION_MAINTENANCE.task });
|
|
6606
|
+
if (
|
|
6607
|
+
found.status === "found" &&
|
|
6608
|
+
found.lease.holderId !== this.brokerId &&
|
|
6609
|
+
found.lease.ageMs <= MAINTENANCE_STALE_AFTER_MS
|
|
6610
|
+
)
|
|
6611
|
+
return;
|
|
6612
|
+
}
|
|
6613
|
+
const acquired = await leases.acquire(RETENTION_MAINTENANCE, this.brokerId, MAINTENANCE_STALE_AFTER_MS);
|
|
6614
|
+
this.maintenance = acquired.status === "acquired" ? acquired.lease : undefined;
|
|
6615
|
+
if (this.maintenance === undefined || this.closed) return;
|
|
6404
6616
|
await this.state.outbox.prune(DELIVERED_MESSAGE_TTL_MS, KNOWN_SESSION_RETENTION_MS);
|
|
6405
6617
|
await this.state.sentMessages.prune(DELIVERED_MESSAGE_TTL_MS);
|
|
6406
6618
|
await this.state.reservations.prune(DELIVERED_MESSAGE_TTL_MS);
|
|
@@ -6543,13 +6755,15 @@ export class MultiNodeRouter {
|
|
|
6543
6755
|
this.holds.clear();
|
|
6544
6756
|
await Promise.all([...this.serials.values()]);
|
|
6545
6757
|
try {
|
|
6546
|
-
|
|
6758
|
+
await this.releaseClaims([...this.inflight.values()].map((inflight) => inflight.claim));
|
|
6547
6759
|
for (const entry of this.presence.values()) {
|
|
6548
6760
|
if (entry.lease !== undefined) await this.state.leases.release(entry.lease);
|
|
6549
6761
|
}
|
|
6550
6762
|
// #5607: its sessions' ids are free for them to take again on another broker, as their presences are.
|
|
6551
6763
|
await this.state.knownSessions.owners?.retireBroker(this.brokerId);
|
|
6552
6764
|
if (this.membership !== undefined) await this.state.leases.release(this.membership);
|
|
6765
|
+
// Free for the next broker to check, rather than once it went stale.
|
|
6766
|
+
if (this.maintenance !== undefined) await this.state.leases.release(this.maintenance);
|
|
6553
6767
|
} catch (error) {
|
|
6554
6768
|
this.report(error);
|
|
6555
6769
|
}
|
|
@@ -6561,6 +6775,9 @@ export class MultiNodeRouter {
|
|
|
6561
6775
|
}
|
|
6562
6776
|
}
|
|
6563
6777
|
|
|
6778
|
+
/** The maintenance lease of the shared state's retention (`maintain`). */
|
|
6779
|
+
const RETENTION_MAINTENANCE: MaintenanceSubject = { kind: "maintenance", task: "retention" };
|
|
6780
|
+
|
|
6564
6781
|
/** A target identity a return path can bind: a registration's return address, never a reusable bare session id. */
|
|
6565
6782
|
function stableIdentity(targetIdentity: string): string | undefined {
|
|
6566
6783
|
return targetIdentity.startsWith('["return",') ? targetIdentity : undefined;
|