@songsid/agend 2.4.0-beta.24 → 2.4.0-beta.25
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/README.md +1 -1
- package/README.zh-TW.md +1 -1
- package/dist/agend-home.js +5 -5
- package/dist/agend-home.js.map +1 -1
- package/dist/agent-endpoint.js +10 -0
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-workspace.d.ts +18 -2
- package/dist/agent-workspace.js +15 -4
- package/dist/agent-workspace.js.map +1 -1
- package/dist/backend/antigravity.js +8 -6
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-code.js +17 -0
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/claude-usage-credits.d.ts +8 -0
- package/dist/backend/claude-usage-credits.js +121 -0
- package/dist/backend/claude-usage-credits.js.map +1 -0
- package/dist/backend/types.d.ts +30 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/adapters/discord.js +7 -1
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/tool-router.js +1 -0
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/cli-audited.js +9 -4
- package/dist/cli-audited.js.map +1 -1
- package/dist/cli.js +184 -21
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +11 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/contact-auth-store.d.ts +18 -0
- package/dist/contact-auth-store.js +55 -8
- package/dist/contact-auth-store.js.map +1 -1
- package/dist/contact-auth-types.d.ts +3 -0
- package/dist/contact-auth-types.js.map +1 -1
- package/dist/contact-change-proposals.d.ts +34 -0
- package/dist/contact-change-proposals.js +1 -1
- package/dist/contact-change-proposals.js.map +1 -1
- package/dist/cross-instance-notice.d.ts +1 -0
- package/dist/cross-instance-notice.js +9 -8
- package/dist/cross-instance-notice.js.map +1 -1
- package/dist/daemon.d.ts +35 -0
- package/dist/daemon.js +234 -19
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +42 -1
- package/dist/delivery-outbox.js +194 -20
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-context.d.ts +8 -0
- package/dist/fleet-lock.d.ts +67 -2
- package/dist/fleet-lock.js +236 -2
- package/dist/fleet-lock.js.map +1 -1
- package/dist/fleet-manager.d.ts +163 -6
- package/dist/fleet-manager.js +1136 -75
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-windows-runtime.d.ts +20 -1
- package/dist/fleet-windows-runtime.js +98 -18
- package/dist/fleet-windows-runtime.js.map +1 -1
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +7 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +14 -4
- package/dist/home-update-lock.d.ts +35 -0
- package/dist/home-update-lock.js +81 -0
- package/dist/home-update-lock.js.map +1 -0
- package/dist/hub/compose/member.d.ts +5 -1
- package/dist/hub/compose/member.js +9 -5
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/member/room-ask.d.ts +5 -0
- package/dist/hub/member/room-ask.js +43 -16
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-mention-feedback.d.ts +2 -0
- package/dist/hub/member/room-mention-feedback.js +1 -1
- package/dist/hub/member/room-mention-feedback.js.map +1 -1
- package/dist/hub/member/room-post-answers.d.ts +2 -0
- package/dist/hub/member/room-post-answers.js +1 -1
- package/dist/hub/member/room-post-answers.js.map +1 -1
- package/dist/hub/member/room-post.d.ts +5 -0
- package/dist/hub/member/room-post.js +4 -1
- package/dist/hub/member/room-post.js.map +1 -1
- package/dist/hub/member/updates.d.ts +7 -1
- package/dist/hub/member/updates.js +7 -1
- package/dist/hub/member/updates.js.map +1 -1
- package/dist/hub/representative.d.ts +7 -0
- package/dist/hub/representative.js +38 -5
- package/dist/hub/representative.js.map +1 -1
- package/dist/install-lock.d.ts +15 -1
- package/dist/install-lock.js +16 -8
- package/dist/install-lock.js.map +1 -1
- package/dist/install-ownership.d.ts +165 -0
- package/dist/install-ownership.js +404 -0
- package/dist/install-ownership.js.map +1 -0
- package/dist/instance-config-impact.js +2 -0
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instructions.d.ts +4 -0
- package/dist/instructions.js +4 -0
- package/dist/instructions.js.map +1 -1
- package/dist/local-pane-endpoint.d.ts +4 -1
- package/dist/local-pane-endpoint.js +12 -2
- package/dist/local-pane-endpoint.js.map +1 -1
- package/dist/locale.js +160 -4
- package/dist/locale.js.map +1 -1
- package/dist/native-agent-admission.d.ts +7 -0
- package/dist/native-agent-admission.js +46 -3
- package/dist/native-agent-admission.js.map +1 -1
- package/dist/native-mcp.d.ts +16 -1
- package/dist/native-mcp.js +38 -5
- package/dist/native-mcp.js.map +1 -1
- package/dist/native-pane-lifecycle.d.ts +9 -0
- package/dist/native-pane-lifecycle.js +23 -0
- package/dist/native-pane-lifecycle.js.map +1 -1
- package/dist/native-pane-manager.d.ts +19 -6
- package/dist/native-pane-manager.js +79 -4
- package/dist/native-pane-manager.js.map +1 -1
- package/dist/needs-you.d.ts +8 -0
- package/dist/needs-you.js +1 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/outbound-handlers.d.ts +12 -0
- package/dist/outbound-handlers.js +30 -2
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/package-preimage.js +4 -0
- package/dist/package-preimage.js.map +1 -1
- package/dist/pane-port.d.ts +1 -0
- package/dist/plist-args.d.ts +9 -0
- package/dist/plist-args.js +22 -0
- package/dist/plist-args.js.map +1 -0
- package/dist/public-preview.d.ts +4 -6
- package/dist/public-preview.js +5 -2
- package/dist/public-preview.js.map +1 -1
- package/dist/public-web-gateway.js +8 -3
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +13 -1
- package/dist/public-web-link.js +28 -1
- package/dist/public-web-link.js.map +1 -1
- package/dist/recover.cjs +2452 -0
- package/dist/remote-card-prompt.d.ts +6 -2
- package/dist/remote-card-prompt.js +12 -3
- package/dist/remote-card-prompt.js.map +1 -1
- package/dist/reply-draft.d.ts +12 -0
- package/dist/reply-draft.js +81 -0
- package/dist/reply-draft.js.map +1 -0
- package/dist/request-contact-api.d.ts +15 -0
- package/dist/request-contact-api.js +120 -0
- package/dist/request-contact-api.js.map +1 -0
- package/dist/request-contact-card.d.ts +36 -0
- package/dist/request-contact-card.js +206 -0
- package/dist/request-contact-card.js.map +1 -0
- package/dist/request-contact-gate.d.ts +79 -0
- package/dist/request-contact-gate.js +262 -0
- package/dist/request-contact-gate.js.map +1 -0
- package/dist/request-contact-native.d.ts +52 -0
- package/dist/request-contact-native.js +83 -0
- package/dist/request-contact-native.js.map +1 -0
- package/dist/request-contact-types.d.ts +86 -0
- package/dist/request-contact-types.js +7 -0
- package/dist/request-contact-types.js.map +1 -0
- package/dist/request-context-call-protocol.d.ts +12 -0
- package/dist/request-context-call-protocol.js +14 -0
- package/dist/request-context-call-protocol.js.map +1 -0
- package/dist/request-context-call.d.ts +22 -0
- package/dist/request-context-call.js +35 -0
- package/dist/request-context-call.js.map +1 -0
- package/dist/request-context-drain.d.ts +39 -0
- package/dist/request-context-drain.js +159 -0
- package/dist/request-context-drain.js.map +1 -0
- package/dist/request-context-fence.d.ts +28 -0
- package/dist/request-context-fence.js +58 -0
- package/dist/request-context-fence.js.map +1 -0
- package/dist/request-context-migration.d.ts +64 -0
- package/dist/request-context-migration.js +158 -0
- package/dist/request-context-migration.js.map +1 -0
- package/dist/request-context-pane.d.ts +25 -0
- package/dist/request-context-pane.js +48 -0
- package/dist/request-context-pane.js.map +1 -0
- package/dist/request-context-policy.d.ts +74 -0
- package/dist/request-context-policy.js +116 -0
- package/dist/request-context-policy.js.map +1 -0
- package/dist/request-context-recovery.d.ts +14 -0
- package/dist/request-context-recovery.js +56 -0
- package/dist/request-context-recovery.js.map +1 -0
- package/dist/request-context-relay.d.ts +19 -0
- package/dist/request-context-relay.js +63 -0
- package/dist/request-context-relay.js.map +1 -0
- package/dist/request-context-returns.d.ts +67 -0
- package/dist/request-context-returns.js +211 -0
- package/dist/request-context-returns.js.map +1 -0
- package/dist/request-context-store.d.ts +2 -1
- package/dist/request-context-store.js +8 -1
- package/dist/request-context-store.js.map +1 -1
- package/dist/request-context-turns.d.ts +99 -0
- package/dist/request-context-turns.js +215 -0
- package/dist/request-context-turns.js.map +1 -0
- package/dist/request-context-view.d.ts +33 -0
- package/dist/request-context-view.js +36 -0
- package/dist/request-context-view.js.map +1 -0
- package/dist/request-hub-context.d.ts +130 -0
- package/dist/request-hub-context.js +89 -0
- package/dist/request-hub-context.js.map +1 -0
- package/dist/request-hub-output.d.ts +11 -0
- package/dist/request-hub-output.js +21 -0
- package/dist/request-hub-output.js.map +1 -0
- package/dist/runtime-cli-install.js +13 -11
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/runtime-client.d.ts +2 -0
- package/dist/runtime-client.js +17 -4
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +4 -1
- package/dist/runtime-coordinator.js +10 -3
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-pane-assets.d.ts +1 -1
- package/dist/runtime-pane-assets.js +1 -1
- package/dist/runtime-pane-assets.js.map +1 -1
- package/dist/runtime-pane-host.d.ts +3 -0
- package/dist/runtime-pane-host.js +39 -21
- package/dist/runtime-pane-host.js.map +1 -1
- package/dist/runtime-pane-link.d.ts +6 -2
- package/dist/runtime-pane-link.js +17 -4
- package/dist/runtime-pane-link.js.map +1 -1
- package/dist/runtime-pane-mcp-relay.d.ts +11 -1
- package/dist/runtime-pane-mcp-relay.js +69 -3
- package/dist/runtime-pane-mcp-relay.js.map +1 -1
- package/dist/runtime-pane-mcp.d.ts +28 -1
- package/dist/runtime-pane-mcp.js +92 -15
- package/dist/runtime-pane-mcp.js.map +1 -1
- package/dist/runtime-pane-port.d.ts +6 -0
- package/dist/runtime-pane-port.js +23 -4
- package/dist/runtime-pane-port.js.map +1 -1
- package/dist/runtime-pane-protocol.d.ts +4 -0
- package/dist/runtime-pane-protocol.js +11 -4
- package/dist/runtime-pane-protocol.js.map +1 -1
- package/dist/runtime-pane-service.d.ts +1 -0
- package/dist/runtime-pane-service.js +25 -9
- package/dist/runtime-pane-service.js.map +1 -1
- package/dist/runtime-pane-stdio-protocol.d.ts +4 -0
- package/dist/runtime-pane-stdio-protocol.js +12 -5
- package/dist/runtime-pane-stdio-protocol.js.map +1 -1
- package/dist/runtime-pane-stdio.js +5 -5
- package/dist/runtime-pane-stdio.js.map +1 -1
- package/dist/runtime-protocol.d.ts +3 -0
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/scheduler/scheduler.d.ts +6 -0
- package/dist/scheduler/scheduler.js +19 -1
- package/dist/scheduler/scheduler.js.map +1 -1
- package/dist/scheduler/task-board.d.ts +4 -0
- package/dist/scheduler/task-board.js +6 -0
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/scheduler/types.d.ts +1 -1
- package/dist/service-activation.js +3 -13
- package/dist/service-activation.js.map +1 -1
- package/dist/service-lock.d.ts +28 -0
- package/dist/service-lock.js +85 -0
- package/dist/service-lock.js.map +1 -0
- package/dist/settings-api.d.ts +6 -0
- package/dist/settings-api.js +35 -0
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +1 -1
- package/dist/settings-change.js.map +1 -1
- package/dist/state-lease.d.ts +24 -0
- package/dist/state-lease.js +103 -0
- package/dist/state-lease.js.map +1 -0
- package/dist/tmux-binary.js +1 -1
- package/dist/tmux-binary.js.map +1 -1
- package/dist/tool-receipt-output.d.ts +2 -0
- package/dist/topic-commands.js +21 -1
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.js +3 -0
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/tunnel/named-link-test.d.ts +27 -0
- package/dist/tunnel/named-link-test.js +41 -0
- package/dist/tunnel/named-link-test.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/ui/chat-store.js +5 -4
- package/dist/ui/fleet-office-card.js +15 -2
- package/dist/ui/fleet-office-skin.js +33 -9
- package/dist/ui/fleet-office-zones.js +8 -3
- package/dist/ui/fleet-office.js +136 -18
- package/dist/ui/fleet-task-files.js +1 -1
- package/dist/ui/panel-chat.js +15 -2
- package/dist/ui/panel-needs.js +22 -2
- package/dist/ui/panel-settings.js +22 -8
- package/dist/ui/settings-preview-address.js +156 -0
- package/dist/ui/settings-registry.js +2 -0
- package/dist/ui/settings-strings.js +6 -6
- package/dist/ui/shared/app.css +76 -2
- package/dist/ui/shared/chat-strings.js +6 -2
- package/dist/ui/shared/chat-thread.js +7 -1
- package/dist/ui/shared/preview-panel.js +1 -1
- package/dist/ui/shared/preview.js +11 -2
- package/dist/ui/shared/tokens.css +18 -3
- package/dist/ui/shared/ui-confirm.js +5 -4
- package/dist/ui/shared/workspace.css +7 -0
- package/dist/ui/usage-credits-card.js +84 -0
- package/dist/ui/workspace-ignored-strings.js +16 -0
- package/dist/ui/workspace-panel.js +15 -6
- package/dist/update-card.d.ts +193 -0
- package/dist/update-card.js +620 -0
- package/dist/update-card.js.map +1 -0
- package/dist/update-dispatch.d.ts +16 -1
- package/dist/update-dispatch.js +12 -4
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-forward.d.ts +73 -0
- package/dist/update-forward.js +283 -0
- package/dist/update-forward.js.map +1 -0
- package/dist/update-idle.d.ts +1 -0
- package/dist/update-idle.js +12 -3
- package/dist/update-idle.js.map +1 -1
- package/dist/update-install.d.ts +2 -1
- package/dist/update-install.js +18 -10
- package/dist/update-install.js.map +1 -1
- package/dist/update-journal.d.ts +351 -0
- package/dist/update-journal.js +717 -0
- package/dist/update-journal.js.map +1 -0
- package/dist/update-launch.js +1 -1
- package/dist/update-launch.js.map +1 -1
- package/dist/update-npm-env.d.ts +45 -12
- package/dist/update-npm-env.js +48 -0
- package/dist/update-npm-env.js.map +1 -1
- package/dist/update-package-restore.d.ts +75 -0
- package/dist/update-package-restore.js +318 -0
- package/dist/update-package-restore.js.map +1 -0
- package/dist/update-quiescence.d.ts +192 -0
- package/dist/update-quiescence.js +330 -0
- package/dist/update-quiescence.js.map +1 -0
- package/dist/update-readiness-host.d.ts +61 -0
- package/dist/update-readiness-host.js +297 -0
- package/dist/update-readiness-host.js.map +1 -0
- package/dist/update-readiness.d.ts +83 -0
- package/dist/update-readiness.js +459 -0
- package/dist/update-readiness.js.map +1 -0
- package/dist/update-recovery/kit.d.ts +35 -0
- package/dist/update-recovery/kit.js +99 -0
- package/dist/update-recovery/kit.js.map +1 -0
- package/dist/update-recovery/pre-start.d.ts +34 -0
- package/dist/update-recovery/pre-start.js +103 -0
- package/dist/update-recovery/pre-start.js.map +1 -0
- package/dist/update-recovery/recover-main.d.ts +1 -0
- package/dist/update-recovery/recover-main.js +4 -0
- package/dist/update-recovery/recover-main.js.map +1 -0
- package/dist/update-recovery/recover.d.ts +22 -0
- package/dist/update-recovery/recover.js +124 -0
- package/dist/update-recovery/recover.js.map +1 -0
- package/dist/update-recovery/route.d.ts +53 -0
- package/dist/update-recovery/route.js +262 -0
- package/dist/update-recovery/route.js.map +1 -0
- package/dist/update-recovery/runner.d.ts +58 -0
- package/dist/update-recovery/runner.js +196 -0
- package/dist/update-recovery/runner.js.map +1 -0
- package/dist/update-recovery/service-manager.d.ts +39 -0
- package/dist/update-recovery/service-manager.js +57 -0
- package/dist/update-recovery/service-manager.js.map +1 -0
- package/dist/update-restore.d.ts +44 -0
- package/dist/update-restore.js +355 -0
- package/dist/update-restore.js.map +1 -0
- package/dist/update-retained.d.ts +38 -0
- package/dist/update-retained.js +91 -0
- package/dist/update-retained.js.map +1 -0
- package/dist/update-rollback.d.ts +74 -0
- package/dist/update-rollback.js +221 -0
- package/dist/update-rollback.js.map +1 -0
- package/dist/update-settings.d.ts +36 -0
- package/dist/update-settings.js +122 -0
- package/dist/update-settings.js.map +1 -0
- package/dist/update-snapshot-manifest.d.ts +32 -0
- package/dist/update-snapshot-manifest.js +65 -0
- package/dist/update-snapshot-manifest.js.map +1 -0
- package/dist/update-snapshot-scope.d.ts +67 -0
- package/dist/update-snapshot-scope.js +172 -0
- package/dist/update-snapshot-scope.js.map +1 -0
- package/dist/update-snapshot.d.ts +34 -0
- package/dist/update-snapshot.js +246 -0
- package/dist/update-snapshot.js.map +1 -0
- package/dist/update-writers.d.ts +71 -0
- package/dist/update-writers.js +235 -0
- package/dist/update-writers.js.map +1 -0
- package/dist/web-api.d.ts +3 -0
- package/dist/web-api.js +43 -8
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +7 -0
- package/dist/web-chat-history.js +15 -0
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-preview.d.ts +5 -0
- package/dist/web-preview.js +1 -1
- package/dist/web-preview.js.map +1 -1
- package/dist/web-update.d.ts +6 -0
- package/dist/windows-agents.d.ts +12 -0
- package/dist/windows-agents.js +5 -0
- package/dist/windows-agents.js.map +1 -1
- package/launcher/agend +4 -1
- package/launcher/agend-agent +4 -1
- package/launcher/agend-install.cjs +16 -8
- package/launcher/install-admission.d.cts +8 -0
- package/launcher/npm-allow-scripts.cjs +72 -0
- package/launcher/npm-global-prefix.cjs +81 -0
- package/launcher/postinstall.cjs +9 -8
- package/launcher/runtime-select.cjs +8 -2
- package/package.json +3 -2
- package/scripts/preinstall-guard.cjs +1 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { RequestContextReturns } from "./request-context-returns.js";
|
|
2
|
+
import type { PreparedRequestContextInput, RequestContextRuntimeOwner } from "./request-context-turns.js";
|
|
3
|
+
import type { QuiescenceGate } from "./update-quiescence.js";
|
|
4
|
+
import { RequestContactCards, type RequestContactCardsHost } from "./request-contact-card.js";
|
|
5
|
+
import { RequestContextDrain } from "./request-context-drain.js";
|
|
6
|
+
import { RequestContextMigrationShadow, type RequestMigrationHost } from "./request-context-migration.js";
|
|
7
|
+
import { RequestContactGate, type RequestContactGateHost } from "./request-contact-gate.js";
|
|
1
8
|
import { WorkingRecoveryStore, type RecoveryEpisode } from "./working-recovery.js";
|
|
2
9
|
import { type SeenPerson } from "./guest-seen-people.js";
|
|
3
10
|
import { EventEmitter } from "node:events";
|
|
4
11
|
import type { QueueResumePolicy } from "./delivery-queue-evidence.js";
|
|
5
12
|
import { ContactAuthStore } from "./contact-auth-store.js";
|
|
13
|
+
import { RequestContextRecoveryStore } from "./request-context-recovery.js";
|
|
6
14
|
import { type RequestContextV1, type RequestOperationBindingV1 } from "./request-context-protocol.js";
|
|
7
15
|
import { type RequestContextCompatibilityOptions } from "./request-context-compatibility.js";
|
|
8
16
|
import { type RuntimeTranscriptReference } from "./runtime-pane-transcript-protocol.js";
|
|
@@ -134,6 +142,7 @@ export declare const SYSTEM_NOTICE_KIND = "system_notice";
|
|
|
134
142
|
*/
|
|
135
143
|
export declare const SYSTEM_NOTICE_MAX_AGE_MS: number;
|
|
136
144
|
export interface DeliveryStatusItem {
|
|
145
|
+
request_provenance?: import("./request-context-view.js").RequestProvenanceView;
|
|
137
146
|
delivery_id: string;
|
|
138
147
|
operation_id: string;
|
|
139
148
|
correlation_id: string | null;
|
|
@@ -298,6 +307,9 @@ export declare class DeliveryOutbox extends EventEmitter {
|
|
|
298
307
|
get workingRecovery(): WorkingRecoveryStore;
|
|
299
308
|
admitWorkingRecovery(episode: RecoveryEpisode, content: string, advisory?: boolean): boolean;
|
|
300
309
|
readonly managerBootId: string;
|
|
310
|
+
/** S-244: while the barrier flag is up, claimNext journals references and claims nothing. Unset: today's claim. */
|
|
311
|
+
private quiescence;
|
|
312
|
+
setQuiescence(gate: QuiescenceGate | null): void;
|
|
301
313
|
/** Observational extension: its failure never participates in delivery admission. */
|
|
302
314
|
observeWorkingState(instance: string, snapshot: Omit<WorkingStateSnapshot, "managerBootId">): import("./working-state-journal.js").WorkingStateEntry | null;
|
|
303
315
|
getWorkingState(instance: string): import("./working-state-journal.js").WorkingStateEntry | undefined;
|
|
@@ -330,7 +342,11 @@ export declare class DeliveryOutbox extends EventEmitter {
|
|
|
330
342
|
latestSentAt(source: string): number | null;
|
|
331
343
|
private noteWorkingReferences;
|
|
332
344
|
private readonly requestContextDispatchVersion;
|
|
333
|
-
|
|
345
|
+
private readonly requestContextRelayVersion;
|
|
346
|
+
private requestContextReturnsOwner?;
|
|
347
|
+
constructor(dbPath: string, managerBootId?: string, compatibility?: RequestContextCompatibilityOptions & {
|
|
348
|
+
requestContextRelayVersion?: 0 | 1;
|
|
349
|
+
});
|
|
334
350
|
/** Future slice L cutover port; all existing production constructors remain capability 0. */
|
|
335
351
|
activateRequestContextBarrier(): void;
|
|
336
352
|
private initialize;
|
|
@@ -383,11 +399,28 @@ export declare class DeliveryOutbox extends EventEmitter {
|
|
|
383
399
|
/** Rows admitted before #856 get the same message_id / digest a new row would. */
|
|
384
400
|
private backfillMessageEvidence;
|
|
385
401
|
private ensureColumn;
|
|
402
|
+
/** Internal same-card service; no production host installs it before L. */
|
|
403
|
+
requestContactCards(host: RequestContactCardsHost): RequestContactCards;
|
|
404
|
+
/** Scratch/cutover assembly only; a certificate is process-bound and never persisted as authority. */
|
|
405
|
+
/** Stable Fleet identity while its exclusive coordinator lease is current; never a boot id. */
|
|
406
|
+
requestContextDrain(owner: () => string | null): RequestContextDrain;
|
|
407
|
+
/** Read-only shadow is safe before activation; never initializes contact/context artifacts. */
|
|
408
|
+
requestContextMigrationShadow(host: RequestMigrationHost): RequestContextMigrationShadow;
|
|
409
|
+
/** Dormant central gate; no production caller until the controlled cutover. */
|
|
410
|
+
requestContactGate(host: RequestContactGateHost): RequestContactGate;
|
|
411
|
+
/** H owner assembly only. The ordinary E factory keeps the pre-H hold semantics. */
|
|
412
|
+
requestHubContactGate(host: RequestContactGateHost): RequestContactGate;
|
|
386
413
|
/** Internal future-dispatch port only; no production ingress calls this before slice L. */
|
|
387
414
|
admitWithRequestContext(input: NewOutboxDelivery, context: RequestContextV1, bindingInput: RequestOperationBindingV1): {
|
|
388
415
|
delivery: OutboxDelivery;
|
|
389
416
|
inserted: boolean;
|
|
390
417
|
};
|
|
418
|
+
private requireRequestContextRelay;
|
|
419
|
+
/** One dormant B-owned return manager, initialized only behind the active barrier and explicit H capability. */
|
|
420
|
+
get requestContextReturns(): RequestContextReturns;
|
|
421
|
+
prepareRequestContextDeliveryInput(deliveryId: string, attemptNo: number, owner: RequestContextRuntimeOwner, wireSha256: string, currentConsumption: () => boolean): PreparedRequestContextInput;
|
|
422
|
+
/** Internal dormant local-turn persistence; the record alone grants no turn or authority. */
|
|
423
|
+
get requestContextRecovery(): RequestContextRecoveryStore;
|
|
391
424
|
requestContextForDelivery(deliveryId: string): import("./request-context-store.js").RequestContextOperationRecord | null;
|
|
392
425
|
requestContext(id: string): RequestContextV1 | null;
|
|
393
426
|
requestContextOperation(source: string, operationId: string): import("./request-context-store.js").RequestContextOperationRecord | null;
|
|
@@ -451,6 +484,11 @@ export declare class DeliveryOutbox extends EventEmitter {
|
|
|
451
484
|
/** Claim the earliest eligible target row; one caller owns each target lane. */
|
|
452
485
|
claimNext(managerBootId: string, targetBootIdFor: (target: string) => string | null, blockedTargets: ReadonlySet<string>, eligible?: (delivery: OutboxDelivery) => boolean): ClaimedOutboxDelivery | undefined;
|
|
453
486
|
private claimNextSync;
|
|
487
|
+
/**
|
|
488
|
+
* Hand-back claims one referenced row and no other (M-3770 §2.6). The update is conditional, so a second claim
|
|
489
|
+
* does not land. A retry still inside its backoff is `ineligible` and is left queued.
|
|
490
|
+
*/
|
|
491
|
+
claimExact(deliveryId: string, managerBootId: string, targetBootId: string, now?: string): "claimed" | "ineligible" | "missing" | "settled";
|
|
454
492
|
/**
|
|
455
493
|
* #2785 (b): a message still waiting while a newer one from the same sender to the same target on the same thread
|
|
456
494
|
* (correlation_id) waits behind it is not delivered — the newer one replaces it (a review round for an older PR head, a
|
|
@@ -526,6 +564,9 @@ export declare class DeliveryOutbox extends EventEmitter {
|
|
|
526
564
|
* `delivery_status` can return "expired" for a pruned row — but only to the
|
|
527
565
|
* original source or target (ownership check, #1340 P2 🔒).
|
|
528
566
|
*/
|
|
567
|
+
private pruneDeliveryRows;
|
|
568
|
+
/** Dormant lifecycle port: only drained, terminal roots older than 30 days may retire atomically. */
|
|
569
|
+
private retireRequestContextRoot;
|
|
529
570
|
prune(days: number): Promise<{
|
|
530
571
|
pruned: number;
|
|
531
572
|
durationMs: number;
|
package/dist/delivery-outbox.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { assertRequestHubContactImage } from "./request-context-policy.js";
|
|
2
|
+
import { RequestContextReturns, requestContextDeliveryChildId, requestContextReturnBlockers, registerRequestContextReturnDispatcher, assertRequestContextReturnsCompatibility, REQUEST_CONTEXT_RETURNS_TABLE } from "./request-context-returns.js";
|
|
3
|
+
import { RequestContactCards } from "./request-contact-card.js";
|
|
4
|
+
import { RequestContextDrain } from "./request-context-drain.js";
|
|
5
|
+
import { RequestContextMigrationShadow } from "./request-context-migration.js";
|
|
6
|
+
import { RequestContactGate } from "./request-contact-gate.js";
|
|
1
7
|
import { WorkingRecoveryStore, WORKING_RECOVERY_KIND } from "./working-recovery.js";
|
|
2
8
|
import { initializeSeenPeople, isSeenPerson, listSeenPeople, noteSeenPerson, pruneSeenPeople, SEEN_PEOPLE_KEEP_DAYS } from "./guest-seen-people.js";
|
|
3
9
|
import { measureSyncWork } from "./sync-work-attribution.js";
|
|
@@ -9,6 +15,7 @@ import { dirname } from "node:path";
|
|
|
9
15
|
import { t } from "./locale.js";
|
|
10
16
|
import { ContactAuthStore } from "./contact-auth-store.js";
|
|
11
17
|
import { RequestContextStore, requestContextDigest, requestContextJson } from "./request-context-store.js";
|
|
18
|
+
import { RequestContextRecoveryStore } from "./request-context-recovery.js";
|
|
12
19
|
import { RequestOperationBindingV1Schema } from "./request-context-protocol.js";
|
|
13
20
|
import { registerRequestContextDispatcher, assertRequestContextCompatibility, activateRequestContextBarrier } from "./request-context-compatibility.js";
|
|
14
21
|
import { validateRuntimeTranscriptReference } from "./runtime-pane-transcript-protocol.js";
|
|
@@ -357,6 +364,9 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
357
364
|
return inserted;
|
|
358
365
|
}
|
|
359
366
|
managerBootId;
|
|
367
|
+
/** S-244: while the barrier flag is up, claimNext journals references and claims nothing. Unset: today's claim. */
|
|
368
|
+
quiescence = null;
|
|
369
|
+
setQuiescence(gate) { this.quiescence = gate; }
|
|
360
370
|
/** Observational extension: its failure never participates in delivery admission. */
|
|
361
371
|
observeWorkingState(instance, snapshot) {
|
|
362
372
|
const timeout = this.db.pragma("busy_timeout", { simple: true });
|
|
@@ -454,15 +464,22 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
454
464
|
catch { /* observation only */ }
|
|
455
465
|
}
|
|
456
466
|
requestContextDispatchVersion;
|
|
467
|
+
requestContextRelayVersion;
|
|
468
|
+
requestContextReturnsOwner;
|
|
457
469
|
constructor(dbPath, managerBootId = randomUUID(), compatibility = {}) {
|
|
458
470
|
super();
|
|
459
471
|
this.managerBootId = managerBootId;
|
|
460
472
|
this.requestContextDispatchVersion = compatibility.requestContextDispatchVersion ?? 0;
|
|
473
|
+
this.requestContextRelayVersion = compatibility.requestContextRelayVersion ?? 0;
|
|
461
474
|
mkdirSync(dirname(dbPath), { recursive: true, mode: 0o700 });
|
|
462
475
|
this.db = new Database(dbPath);
|
|
463
476
|
try {
|
|
464
477
|
registerRequestContextDispatcher(this.db, this.requestContextDispatchVersion);
|
|
465
478
|
assertRequestContextCompatibility(this.db, this.requestContextDispatchVersion);
|
|
479
|
+
registerRequestContextReturnDispatcher(this.db, this.requestContextRelayVersion);
|
|
480
|
+
assertRequestContextReturnsCompatibility(this.db, this.requestContextRelayVersion);
|
|
481
|
+
if (hasTable(this.db, REQUEST_CONTEXT_RETURNS_TABLE))
|
|
482
|
+
this.requestContextReturnsOwner = new RequestContextReturns(this.db, () => this.requireRequestContextRelay());
|
|
466
483
|
this.initialize(dbPath);
|
|
467
484
|
}
|
|
468
485
|
catch (error) {
|
|
@@ -895,6 +912,38 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
895
912
|
return;
|
|
896
913
|
this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
897
914
|
}
|
|
915
|
+
/** Internal same-card service; no production host installs it before L. */
|
|
916
|
+
requestContactCards(host) {
|
|
917
|
+
return new RequestContactCards(this.db, this.contactAuthorizations, () => this.requestContactGate(host), host);
|
|
918
|
+
}
|
|
919
|
+
/** Scratch/cutover assembly only; a certificate is process-bound and never persisted as authority. */
|
|
920
|
+
/** Stable Fleet identity while its exclusive coordinator lease is current; never a boot id. */
|
|
921
|
+
requestContextDrain(owner) {
|
|
922
|
+
const ready = () => { if (this.requestContextDispatchVersion !== 1 || assertRequestContextCompatibility(this.db, 1) !== "active")
|
|
923
|
+
throw Error("request-context dispatcher is not ready"); };
|
|
924
|
+
ready();
|
|
925
|
+
return new RequestContextDrain(this.db, ready, owner);
|
|
926
|
+
}
|
|
927
|
+
/** Read-only shadow is safe before activation; never initializes contact/context artifacts. */
|
|
928
|
+
requestContextMigrationShadow(host) {
|
|
929
|
+
return new RequestContextMigrationShadow(this.db, host);
|
|
930
|
+
}
|
|
931
|
+
/** Dormant central gate; no production caller until the controlled cutover. */
|
|
932
|
+
requestContactGate(host) {
|
|
933
|
+
const ready = () => {
|
|
934
|
+
if (this.requestContextDispatchVersion !== 1 || assertRequestContextCompatibility(this.db, 1) !== "active")
|
|
935
|
+
throw Error("request-context dispatcher is not ready");
|
|
936
|
+
};
|
|
937
|
+
ready();
|
|
938
|
+
return new RequestContactGate(this.db, this.contactAuthorizations, { ready,
|
|
939
|
+
admit: (input, context, binding) => this.admitWithRequestContext(input, context, binding),
|
|
940
|
+
retire: (root, proof) => this.retireRequestContextRoot(root, proof) }, host);
|
|
941
|
+
}
|
|
942
|
+
/** H owner assembly only. The ordinary E factory keeps the pre-H hold semantics. */
|
|
943
|
+
requestHubContactGate(host) {
|
|
944
|
+
this.requireRequestContextRelay();
|
|
945
|
+
return this.requestContactGate({ ...host, hubRelayAllowed: (context, binding, delivery) => assertRequestHubContactImage(context, binding, delivery) });
|
|
946
|
+
}
|
|
898
947
|
/** Internal future-dispatch port only; no production ingress calls this before slice L. */
|
|
899
948
|
admitWithRequestContext(input, context, bindingInput) {
|
|
900
949
|
if (this.requestContextDispatchVersion !== 1 || assertRequestContextCompatibility(this.db, 1) !== "active") {
|
|
@@ -903,6 +952,8 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
903
952
|
const admitted = this.db.transaction(() => {
|
|
904
953
|
const store = new RequestContextStore(this.db), binding = RequestOperationBindingV1Schema.parse(bindingInput);
|
|
905
954
|
const stored = store.recordContext(context);
|
|
955
|
+
if (this.requestContextRelayVersion === 1)
|
|
956
|
+
assertRequestHubContactImage(stored, binding, input);
|
|
906
957
|
if (binding.operationId !== input.operationId || binding.source.instance !== input.sourceInstance
|
|
907
958
|
|| binding.target.instance !== input.targetInstance || binding.contextId !== stored.ref.contextId
|
|
908
959
|
|| binding.rootContextId !== stored.ref.rootContextId || binding.source.instance !== stored.source.instance
|
|
@@ -919,6 +970,8 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
919
970
|
const delivery = this.get(prior.deliveryId);
|
|
920
971
|
if (!delivery || requestContextDigest(delivery.payload) !== binding.payloadSha256)
|
|
921
972
|
throw Error("request-context delivery unavailable");
|
|
973
|
+
if (this.requestContextRelayVersion === 1)
|
|
974
|
+
this.requestContextReturns.admitted(prior, stored, false);
|
|
922
975
|
return { delivery, inserted: false };
|
|
923
976
|
}
|
|
924
977
|
if (this.db.prepare("SELECT 1 FROM deliveries WHERE source_key=? OR (source_instance=? AND operation_id=?) LIMIT 1")
|
|
@@ -928,12 +981,48 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
928
981
|
if (requestContextDigest(admitted.delivery.payload) !== binding.payloadSha256)
|
|
929
982
|
throw Error("request-context admitted payload changed");
|
|
930
983
|
store.recordOperation({ binding, sourceKey: input.sourceKey, deliveryId: admitted.delivery.deliveryId, admissionSha256 });
|
|
984
|
+
if (this.requestContextRelayVersion === 1)
|
|
985
|
+
this.requestContextReturns.admitted(store.operation(input.sourceInstance, input.operationId), stored, admitted.inserted);
|
|
931
986
|
return admitted;
|
|
932
987
|
})();
|
|
933
988
|
if (admitted.inserted)
|
|
934
989
|
this.noteWorkingReferences([input.sourceInstance, input.targetInstance]);
|
|
935
990
|
return admitted;
|
|
936
991
|
}
|
|
992
|
+
requireRequestContextRelay() {
|
|
993
|
+
if (this.requestContextRelayVersion !== 1 || this.requestContextDispatchVersion !== 1 || assertRequestContextCompatibility(this.db, 1) !== "active")
|
|
994
|
+
throw Error("request-context relay dispatcher is not ready");
|
|
995
|
+
}
|
|
996
|
+
/** One dormant B-owned return manager, initialized only behind the active barrier and explicit H capability. */
|
|
997
|
+
get requestContextReturns() { this.requireRequestContextRelay(); return this.requestContextReturnsOwner ??= new RequestContextReturns(this.db, () => this.requireRequestContextRelay()); }
|
|
998
|
+
prepareRequestContextDeliveryInput(deliveryId, attemptNo, owner, wireSha256, currentConsumption) {
|
|
999
|
+
this.requireRequestContextRelay();
|
|
1000
|
+
if (!currentConsumption())
|
|
1001
|
+
throw Error("request-context delivery attempt is no longer current");
|
|
1002
|
+
if (!/^[a-f0-9]{64}$/.test(wireSha256) || !Number.isSafeInteger(attemptNo) || attemptNo < 1)
|
|
1003
|
+
throw Error("request-context delivery attempt unavailable");
|
|
1004
|
+
return this.db.transaction(() => {
|
|
1005
|
+
const store = new RequestContextStore(this.db), operation = store.forDelivery(deliveryId), delivery = this.get(deliveryId);
|
|
1006
|
+
if (!operation || !delivery || operation.binding.target.instance !== owner.instance || operation.binding.target.incarnation !== owner.incarnation || delivery.targetSession && delivery.targetSession !== owner.instance)
|
|
1007
|
+
throw Error("request-context delivery target unavailable");
|
|
1008
|
+
const returned = this.requestContextReturns.parentForResponse(deliveryId), parent = store.context(returned?.requesterContextId ?? operation.binding.contextId);
|
|
1009
|
+
if (!parent || parent.ref.rootContextId !== operation.binding.rootContextId)
|
|
1010
|
+
throw Error("request-context delivery parent unavailable");
|
|
1011
|
+
const context = { ...parent, ref: { version: 1, contextId: requestContextDeliveryChildId(deliveryId, operation.binding.target), rootContextId: parent.ref.rootContextId, parentContextId: parent.ref.contextId }, source: { instance: owner.instance, incarnation: owner.incarnation } };
|
|
1012
|
+
const retained = store.recordContext(context), sender = { kind: "peer", ...operation.binding.source };
|
|
1013
|
+
if (!currentConsumption())
|
|
1014
|
+
throw Error("request-context delivery attempt is no longer current");
|
|
1015
|
+
return { inputId: `delivery:${deliveryId}:${attemptNo}`, wireSha256, owner: structuredClone(owner), context: retained,
|
|
1016
|
+
proof: returned ? { kind: "expected-return", parentContextId: parent.ref.contextId, expectedSender: { kind: "peer", ...returned.responder }, actualSender: sender } : { kind: "admitted-delivery", parentContextId: parent.ref.contextId, deliveryId, sender } };
|
|
1017
|
+
})();
|
|
1018
|
+
}
|
|
1019
|
+
/** Internal dormant local-turn persistence; the record alone grants no turn or authority. */
|
|
1020
|
+
get requestContextRecovery() {
|
|
1021
|
+
return new RequestContextRecoveryStore(this.db, () => {
|
|
1022
|
+
if (this.requestContextDispatchVersion !== 1 || assertRequestContextCompatibility(this.db, 1) !== "active")
|
|
1023
|
+
throw Error("request-context dispatcher is not ready");
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
937
1026
|
requestContextForDelivery(deliveryId) { return new RequestContextStore(this.db).forDelivery(deliveryId); }
|
|
938
1027
|
requestContext(id) { return new RequestContextStore(this.db).context(id); }
|
|
939
1028
|
requestContextOperation(source, operationId) { return new RequestContextStore(this.db).operation(source, operationId); }
|
|
@@ -1195,6 +1284,13 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
1195
1284
|
return measureSyncWork("outbox.claimNext", () => this.claimNextSync(managerBootId, targetBootIdFor, blockedTargets, eligible));
|
|
1196
1285
|
}
|
|
1197
1286
|
claimNextSync(managerBootId, targetBootIdFor, blockedTargets, eligible) {
|
|
1287
|
+
const gate = this.quiescence;
|
|
1288
|
+
if (gate?.armed()) {
|
|
1289
|
+
const held = this.db.prepare(`SELECT delivery_id, created_seq FROM deliveries WHERE state IN ('queued','retry_wait') ORDER BY created_seq`).all();
|
|
1290
|
+
for (const row of held)
|
|
1291
|
+
gate.holdOutboxClaim(row.delivery_id, row.created_seq);
|
|
1292
|
+
return undefined;
|
|
1293
|
+
}
|
|
1198
1294
|
const now = new Date().toISOString();
|
|
1199
1295
|
const pending = this.db.prepare(`
|
|
1200
1296
|
SELECT * FROM deliveries WHERE state IN ('queued','retry_wait')
|
|
@@ -1240,6 +1336,26 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
1240
1336
|
}
|
|
1241
1337
|
return undefined;
|
|
1242
1338
|
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Hand-back claims one referenced row and no other (M-3770 §2.6). The update is conditional, so a second claim
|
|
1341
|
+
* does not land. A retry still inside its backoff is `ineligible` and is left queued.
|
|
1342
|
+
*/
|
|
1343
|
+
claimExact(deliveryId, managerBootId, targetBootId, now = new Date().toISOString()) {
|
|
1344
|
+
const row = this.get(deliveryId);
|
|
1345
|
+
if (!row)
|
|
1346
|
+
return "missing";
|
|
1347
|
+
if (row.state !== "queued" && row.state !== "retry_wait")
|
|
1348
|
+
return "settled";
|
|
1349
|
+
if (row.state === "retry_wait" && row.nextAttemptAt && row.nextAttemptAt > now)
|
|
1350
|
+
return "ineligible";
|
|
1351
|
+
const result = this.db.prepare(`
|
|
1352
|
+
UPDATE deliveries
|
|
1353
|
+
SET state='delivering', target_daemon_boot_id=?, manager_boot_id=?,
|
|
1354
|
+
attempt_no=attempt_no+1, updated_at=?, last_error=NULL, next_attempt_at=NULL
|
|
1355
|
+
WHERE delivery_id=? AND state IN ('queued','retry_wait')
|
|
1356
|
+
`).run(targetBootId, managerBootId, now, deliveryId);
|
|
1357
|
+
return result.changes === 1 ? "claimed" : "settled";
|
|
1358
|
+
}
|
|
1243
1359
|
/**
|
|
1244
1360
|
* #2785 (b): a message still waiting while a newer one from the same sender to the same target on the same thread
|
|
1245
1361
|
* (correlation_id) waits behind it is not delivered — the newer one replaces it (a review round for an older PR head, a
|
|
@@ -1766,6 +1882,82 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
1766
1882
|
* `delivery_status` can return "expired" for a pruned row — but only to the
|
|
1767
1883
|
* original source or target (ownership check, #1340 P2 🔒).
|
|
1768
1884
|
*/
|
|
1885
|
+
pruneDeliveryRows(rows, now) {
|
|
1886
|
+
const ids = rows.map(row => row.delivery_id);
|
|
1887
|
+
if (!ids.length)
|
|
1888
|
+
return;
|
|
1889
|
+
const placeholders = ids.map(() => "?").join(",");
|
|
1890
|
+
// Record (delivery_id, source, target) so delivery_status can return
|
|
1891
|
+
// "expired" to the row's own source/target (ownership-gated).
|
|
1892
|
+
const insertPruned = this.db.prepare("INSERT OR IGNORE INTO pruned_ids(delivery_id, source_instance, target_instance, pruned_at) VALUES (?, ?, ?, ?)");
|
|
1893
|
+
for (const row of rows)
|
|
1894
|
+
insertPruned.run(row.delivery_id, row.source_instance, row.target_instance, now);
|
|
1895
|
+
// Delete child rows first.
|
|
1896
|
+
this.db.prepare(`DELETE FROM delivery_attempts WHERE delivery_id IN (${placeholders})`).run(...ids);
|
|
1897
|
+
// Only closed reply_obligations (answered/expired): open ones were excluded above.
|
|
1898
|
+
if (hasTable(this.db, "reply_obligations")) {
|
|
1899
|
+
this.db.prepare(`
|
|
1900
|
+
DELETE FROM reply_obligations
|
|
1901
|
+
WHERE request_delivery_id IN (${placeholders}) AND state IN ('answered','expired')
|
|
1902
|
+
`).run(...ids);
|
|
1903
|
+
}
|
|
1904
|
+
this.db.prepare(`DELETE FROM outcome_notices WHERE notice_delivery_id IN (${placeholders})`).run(...ids);
|
|
1905
|
+
this.db.prepare(`DELETE FROM failure_notices WHERE parent_delivery_id IN (${placeholders}) OR notice_delivery_id IN (${placeholders})`).run(...ids, ...ids);
|
|
1906
|
+
this.db.prepare(`DELETE FROM delivery_forward_edges WHERE reference_kind='delivery' AND reference_id IN (${placeholders})`).run(...ids);
|
|
1907
|
+
this.db.prepare(`DELETE FROM deliveries WHERE delivery_id IN (${placeholders})`).run(...ids);
|
|
1908
|
+
}
|
|
1909
|
+
/** Dormant lifecycle port: only drained, terminal roots older than 30 days may retire atomically. */
|
|
1910
|
+
retireRequestContextRoot(root, retired) {
|
|
1911
|
+
if (this.requestContextDispatchVersion !== 1 || assertRequestContextCompatibility(this.db, 1) !== "active")
|
|
1912
|
+
throw Error("request-context dispatcher is not ready");
|
|
1913
|
+
return this.db.transaction(() => {
|
|
1914
|
+
const store = new RequestContextStore(this.db), context = store.context(root);
|
|
1915
|
+
if (!context || context.ref.rootContextId !== root || context.ref.parentContextId || !retired())
|
|
1916
|
+
throw Error("request-context root is not drained");
|
|
1917
|
+
const ids = this.db.prepare("SELECT context_id FROM request_contexts_v1 WHERE json_extract(context_json,'$.ref.rootContextId')=?").all(root).map(row => row.context_id);
|
|
1918
|
+
const slots = "SELECT context_id FROM request_contexts_v1 WHERE json_extract(context_json,'$.ref.rootContextId')=?", cutoff = new Date(Date.now() - 30 * 24 * 60 * 60_000).toISOString();
|
|
1919
|
+
const rows = this.db.prepare(`SELECT d.delivery_id,d.source_instance,d.target_instance,d.state,COALESCE(d.finished_at,d.updated_at) AS at
|
|
1920
|
+
FROM deliveries d JOIN request_context_operations_v1 o ON o.delivery_id=d.delivery_id WHERE o.context_id IN (${slots})`).all(root);
|
|
1921
|
+
if (rows.some(row => !["delivered", "failed", "cancelled"].includes(row.state) || !Number.isFinite(Date.parse(row.at)) || Date.parse(row.at) >= Date.parse(cutoff)))
|
|
1922
|
+
throw Error("request-context root retention not elapsed");
|
|
1923
|
+
if (this.db.prepare(`SELECT 1 FROM reply_obligations WHERE state='open' AND request_delivery_id IN (SELECT delivery_id FROM request_context_operations_v1 WHERE context_id IN (${slots})) LIMIT 1`).get(root))
|
|
1924
|
+
throw Error("request-context root has open reply");
|
|
1925
|
+
if (hasTable(this.db, "request_context_recovery_v1") && this.db.prepare(`SELECT 1 FROM request_context_recovery_v1 WHERE json_extract(pointer_json,'$.contextId') IN (${slots}) LIMIT 1`).get(root))
|
|
1926
|
+
throw Error("request-context root has recovery reference");
|
|
1927
|
+
if (hasTable(this.db, "request_context_contacts_v1")) {
|
|
1928
|
+
const tickets = this.db.prepare("SELECT t.id,t.ticket_json FROM contact_auth_tickets t JOIN request_context_contacts_v1 c ON c.ticket_id=t.id WHERE c.root_id=?").all(root);
|
|
1929
|
+
const resolved = tickets.map(row => this.contactAuthorizations.get(row.id));
|
|
1930
|
+
if (resolved.some(t => { if (!t)
|
|
1931
|
+
return true; const at = Date.parse(t.decidedAt ?? t.expiresAt ?? t.createdAt); return !['approved', 'delivered', 'declined', 'expired'].includes(t.state) || !Number.isFinite(at) || at >= Date.parse(cutoff); }))
|
|
1932
|
+
throw Error("request-context root has retained ticket");
|
|
1933
|
+
for (const ticket of tickets) {
|
|
1934
|
+
this.db.prepare("DELETE FROM contact_auth_outcome_notices WHERE ticket_id=?").run(ticket.id);
|
|
1935
|
+
this.db.prepare("DELETE FROM contact_auth_approval_notices WHERE ticket_id=?").run(ticket.id);
|
|
1936
|
+
}
|
|
1937
|
+
this.db.prepare("DELETE FROM request_context_contacts_v1 WHERE root_id=?").run(root);
|
|
1938
|
+
for (const ticket of tickets)
|
|
1939
|
+
this.db.prepare("DELETE FROM contact_auth_tickets WHERE id=?").run(ticket.id);
|
|
1940
|
+
}
|
|
1941
|
+
if (hasTable(this.db, REQUEST_CONTEXT_RETURNS_TABLE)) {
|
|
1942
|
+
this.requestContextReturns.closeNonDelivery(root);
|
|
1943
|
+
if (requestContextReturnBlockers(this.db, root).length)
|
|
1944
|
+
throw Error("request-context root has expected return");
|
|
1945
|
+
this.db.prepare(`DELETE FROM ${REQUEST_CONTEXT_RETURNS_TABLE} WHERE root_context_id=?`).run(root);
|
|
1946
|
+
}
|
|
1947
|
+
this.db.prepare(`DELETE FROM request_context_operations_v1 WHERE context_id IN (${slots})`).run(root);
|
|
1948
|
+
this.pruneDeliveryRows(rows, new Date().toISOString());
|
|
1949
|
+
// Single-parent contexts are deleted leaves first; no dependent recovery/ledger/work may remain.
|
|
1950
|
+
for (let left = ids.length; left > 0;) {
|
|
1951
|
+
const changed = this.db.prepare(`DELETE FROM request_contexts_v1 WHERE context_id IN (${slots}) AND context_id NOT IN (SELECT parent_id FROM request_contexts_v1 WHERE parent_id IS NOT NULL)`).run(root).changes;
|
|
1952
|
+
if (!changed)
|
|
1953
|
+
throw Error("request-context root has external descendant");
|
|
1954
|
+
left -= changed;
|
|
1955
|
+
}
|
|
1956
|
+
if (!retired())
|
|
1957
|
+
throw Error("request-context root retirement changed");
|
|
1958
|
+
return rows.length;
|
|
1959
|
+
})();
|
|
1960
|
+
}
|
|
1769
1961
|
async prune(days) {
|
|
1770
1962
|
const { performance } = await import("node:perf_hooks");
|
|
1771
1963
|
const t0 = performance.now();
|
|
@@ -1787,6 +1979,7 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
1787
1979
|
FROM deliveries
|
|
1788
1980
|
WHERE state IN ${PRUNABLE}
|
|
1789
1981
|
AND COALESCE(finished_at, updated_at) < ?
|
|
1982
|
+
${hasTable(this.db, "request_context_operations_v1") ? "AND delivery_id NOT IN (SELECT delivery_id FROM request_context_operations_v1)" : ""}
|
|
1790
1983
|
AND (
|
|
1791
1984
|
NOT EXISTS (SELECT 1 FROM reply_obligations WHERE request_delivery_id = delivery_id AND state = 'open')
|
|
1792
1985
|
)
|
|
@@ -1795,27 +1988,8 @@ export class DeliveryOutbox extends EventEmitter {
|
|
|
1795
1988
|
`).all(cutoff);
|
|
1796
1989
|
if (rows.length === 0)
|
|
1797
1990
|
break;
|
|
1798
|
-
const ids = rows.map(r => r.delivery_id);
|
|
1799
|
-
const placeholders = ids.map(() => "?").join(",");
|
|
1800
1991
|
this.db.transaction(() => {
|
|
1801
|
-
|
|
1802
|
-
// "expired" to the row's own source/target (ownership-gated).
|
|
1803
|
-
const insertPruned = this.db.prepare("INSERT OR IGNORE INTO pruned_ids(delivery_id, source_instance, target_instance, pruned_at) VALUES (?, ?, ?, ?)");
|
|
1804
|
-
for (const row of rows)
|
|
1805
|
-
insertPruned.run(row.delivery_id, row.source_instance, row.target_instance, now);
|
|
1806
|
-
// Delete child rows first.
|
|
1807
|
-
this.db.prepare(`DELETE FROM delivery_attempts WHERE delivery_id IN (${placeholders})`).run(...ids);
|
|
1808
|
-
// Only closed reply_obligations (answered/expired): open ones were excluded above.
|
|
1809
|
-
if (hasTable(this.db, "reply_obligations")) {
|
|
1810
|
-
this.db.prepare(`
|
|
1811
|
-
DELETE FROM reply_obligations
|
|
1812
|
-
WHERE request_delivery_id IN (${placeholders}) AND state IN ('answered','expired')
|
|
1813
|
-
`).run(...ids);
|
|
1814
|
-
}
|
|
1815
|
-
this.db.prepare(`DELETE FROM outcome_notices WHERE notice_delivery_id IN (${placeholders})`).run(...ids);
|
|
1816
|
-
this.db.prepare(`DELETE FROM failure_notices WHERE parent_delivery_id IN (${placeholders}) OR notice_delivery_id IN (${placeholders})`).run(...ids, ...ids);
|
|
1817
|
-
this.db.prepare(`DELETE FROM delivery_forward_edges WHERE reference_kind='delivery' AND reference_id IN (${placeholders})`).run(...ids);
|
|
1818
|
-
this.db.prepare(`DELETE FROM deliveries WHERE delivery_id IN (${placeholders})`).run(...ids);
|
|
1992
|
+
this.pruneDeliveryRows(rows, now);
|
|
1819
1993
|
})();
|
|
1820
1994
|
total += rows.length;
|
|
1821
1995
|
if (rows.length < CHUNK)
|