@sleep2agi/commhub-server 0.9.0-preview.25 → 0.9.0-preview.251
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 +129 -9
- package/bin/commhub.ts +93 -9
- package/build-info.json +7 -0
- package/package.json +10 -8
- package/src/ack-create-request-transport.test.ts +182 -0
- package/src/ack-create-request.test.ts +52 -8
- package/src/admin-delete-network-http.test.ts +228 -0
- package/src/admin-networks-http.test.ts +88 -0
- package/src/adoption-candidates-http.test.ts +140 -0
- package/src/adoption-candidates.ts +158 -0
- package/src/agent-access-batch.test.ts +210 -0
- package/src/agent-access.ts +487 -0
- package/src/agent-acl-groups-http.test.ts +247 -0
- package/src/agent-acl-http.test.ts +675 -0
- package/src/agent-acl-slice3-http.test.ts +717 -0
- package/src/agent-department-http.test.ts +215 -0
- package/src/agent-groups-perf.test.ts +223 -0
- package/src/agent-notice.ts +48 -0
- package/src/agent-team-whoami-http.test.ts +98 -0
- package/src/agent-teams-http.test.ts +330 -0
- package/src/agent-teams.ts +244 -0
- package/src/alias-baseline-2571.test.ts +162 -0
- package/src/alias-baseline.ts +113 -0
- package/src/alias-filter.test.ts +72 -0
- package/src/alias-filter.ts +42 -0
- package/src/api-host-supervisors-can-create-nodes.test.ts +350 -0
- package/src/api-host-supervisors-fallback.test.ts +6 -7
- package/src/api-host-supervisors-runtime-readiness.test.ts +195 -0
- package/src/api-nodes-shape.test.ts +95 -4
- package/src/auth-password-change-cli-tokens-http.test.ts +423 -0
- package/src/auth-sessions-http.test.ts +260 -0
- package/src/auth-validate.test.ts +5 -1
- package/src/auth-weak-password-login.test.ts +176 -0
- package/src/auth.ts +609 -51
- package/src/avatar-validate.test.ts +52 -2
- package/src/avatar-validate.ts +35 -1
- package/src/backfill-node-ids-2664.test.ts +128 -0
- package/src/binding-generation-http.test.ts +132 -0
- package/src/blocked-exit-on-reply.test.ts +122 -0
- package/src/broadcast-fanout-2721.test.ts +149 -0
- package/src/broadcast-fanout.ts +117 -0
- package/src/build-info.test.ts +60 -0
- package/src/build-info.ts +85 -0
- package/src/chain-attempt-dedup.test.ts +447 -0
- package/src/clip.test.ts +36 -0
- package/src/clip.ts +48 -0
- package/src/clone-node.test.ts +262 -0
- package/src/clone-node.ts +289 -0
- package/src/codex-config-flags.ts +77 -0
- package/src/codex-fork-contract.ts +23 -0
- package/src/codex-fork-migration.test.ts +38 -0
- package/src/commhub-bin-args.test.ts +85 -0
- package/src/config-apply-validate.test.ts +188 -1
- package/src/config-apply-validate.ts +222 -3
- package/src/cors-origins.test.ts +73 -0
- package/src/create-node-blocked-gate.test.ts +356 -0
- package/src/create-node-network-id.test.ts +91 -0
- package/src/create-node-tool-schema.test.ts +49 -0
- package/src/create-node-unicode-name.test.ts +126 -0
- package/src/create-node-validate.test.ts +199 -7
- package/src/create-node-validate.ts +232 -15
- package/src/create-node-workdir.test.ts +298 -0
- package/src/create-node.ts +88 -23
- package/src/daemon-provider-snapshots.test.ts +445 -0
- package/src/daemon-provider-snapshots.ts +327 -0
- package/src/daemon-token-owner-http.test.ts +292 -0
- package/src/dashboard-slash-routing-http.test.ts +109 -0
- package/src/db-adapter-guard.test.ts +148 -0
- package/src/db-adapter-translate.test.ts +128 -0
- package/src/db-adapter.ts +377 -91
- package/src/db-timestamp.test.ts +38 -0
- package/src/db-timestamp.ts +15 -0
- package/src/db.ts +1264 -153
- package/src/delivered-without-push.test.ts +140 -0
- package/src/department-groups-http.test.ts +209 -0
- package/src/department-groups-sync-http.test.ts +328 -0
- package/src/department-groups.ts +434 -0
- package/src/department-heads-http.test.ts +350 -0
- package/src/department-heads.ts +226 -0
- package/src/departments-agent-count.test.ts +132 -0
- package/src/departments-http.test.ts +185 -0
- package/src/departments-mcp.test.ts +128 -0
- package/src/departments.ts +318 -0
- package/src/desktop-message-seam.test.ts +150 -0
- package/src/desktop-message.test.ts +368 -0
- package/src/dm-file-scope-http.test.ts +178 -0
- package/src/empty-node-sweeper.test.ts +104 -0
- package/src/empty-node-sweeper.ts +88 -0
- package/src/env-transport-gate-http.test.ts +240 -0
- package/src/env-transport-gate.ts +80 -0
- package/src/env-transport-policy.ts +56 -0
- package/src/etag-of.test.ts +57 -0
- package/src/event-loop-lag.test.ts +180 -0
- package/src/event-loop-lag.ts +201 -0
- package/src/expiry-counters.test.ts +141 -0
- package/src/expiry-counters.ts +112 -0
- package/src/ext-token-shared.test.ts +60 -0
- package/src/ext-validation-regression.test.ts +131 -0
- package/src/external-schedule-edits-http.test.ts +321 -0
- package/src/external-schedule-edits-timestamps.test.ts +64 -0
- package/src/external-schedule-edits.ts +327 -0
- package/src/file-download-authz-dev-open.test.ts +1 -1
- package/src/file-download-authz.test.ts +75 -20
- package/src/file-download-date-bucket.test.ts +8 -26
- package/src/file-network-scope-dev-open.test.ts +97 -0
- package/src/file-network-scope.test.ts +732 -0
- package/src/group-membership-events-http.test.ts +264 -0
- package/src/group-messages-http.test.ts +483 -0
- package/src/group-messages.ts +297 -0
- package/src/health-anon-readers.ts +60 -0
- package/src/health-host-disk-2756.test.ts +71 -0
- package/src/health-redaction.test.ts +1541 -7
- package/src/host-supervisor-identity-http.test.ts +152 -0
- package/src/host-supervisor-identity.ts +92 -0
- package/src/host-supervisors-daemon-version.test.ts +137 -0
- package/src/http-gzip.test.ts +94 -0
- package/src/http-gzip.ts +112 -0
- package/src/hub-catalog-read-http.test.ts +641 -0
- package/src/hub-provider-config.test.ts +166 -0
- package/src/hub-provider-config.ts +202 -0
- package/src/hub-timestamp.test.ts +38 -0
- package/src/hub-timestamp.ts +27 -0
- package/src/human-dm.ts +215 -0
- package/src/human-inbox.ts +42 -0
- package/src/inbox-caller.ts +49 -0
- package/src/inbox-count-sse.test.ts +310 -0
- package/src/inbox-count.ts +29 -0
- package/src/index.ts +6 -2
- package/src/license-state.test.ts +56 -0
- package/src/license-state.ts +48 -0
- package/src/list-host-supervisors.test.ts +15 -4
- package/src/mcp-context-cost-http.test.ts +127 -0
- package/src/mcp-inflight.test.ts +92 -0
- package/src/mcp-inflight.ts +38 -0
- package/src/mcp-projects-events-http.test.ts +165 -0
- package/src/mcp-route-label-http.test.ts +120 -0
- package/src/mcp-write-network-resolution.test.ts +435 -0
- package/src/member-audit-network-id-http.test.ts +93 -0
- package/src/member-presence-http.test.ts +210 -0
- package/src/messages-ack-by-agent-http.test.ts +142 -0
- package/src/migrate-sqlite-to-pg.test.ts +47 -0
- package/src/migrate-sqlite-to-pg.ts +263 -0
- package/src/model-auth-notify-http.test.ts +181 -0
- package/src/model-auth-notify.ts +116 -0
- package/src/network-name-http.test.ts +75 -0
- package/src/network-rules-http.test.ts +169 -0
- package/src/network-rules.ts +129 -0
- package/src/network-scope.ts +276 -0
- package/src/network-token-membership-http.test.ts +186 -0
- package/src/node-alias-control.ts +12 -0
- package/src/node-attrs.test.ts +47 -2
- package/src/node-caller-identity-http.test.ts +1108 -0
- package/src/node-create-request-status-http.test.ts +105 -0
- package/src/node-daemon-bindings.test.ts +132 -0
- package/src/node-daemon-bindings.ts +135 -0
- package/src/node-failure-alert.test.ts +150 -0
- package/src/node-failure-alert.ts +177 -0
- package/src/node-files-transport.test.ts +347 -0
- package/src/node-health-codex-login.test.ts +120 -0
- package/src/node-health-dispatch-http.test.ts +373 -0
- package/src/node-health-guard.ts +121 -0
- package/src/node-health-passthrough.test.ts +115 -0
- package/src/node-health-store.ts +101 -0
- package/src/node-id-alias.test.ts +190 -0
- package/src/node-identity-conflict-http.test.ts +269 -0
- package/src/node-identity-conflict.ts +142 -0
- package/src/node-identity-mismatch.test.ts +74 -0
- package/src/node-in-flight-tasks.ts +31 -0
- package/src/node-lifecycle-controllable.test.ts +64 -0
- package/src/node-lifecycle-controllable.ts +53 -0
- package/src/node-lifecycle-read-http.test.ts +257 -0
- package/src/node-lifecycle-read.ts +124 -0
- package/src/node-logs-transport.test.ts +263 -0
- package/src/node-peer-allowlist.test.ts +114 -0
- package/src/node-permissions-http.test.ts +728 -0
- package/src/node-permissions.ts +494 -0
- package/src/node-request-retention.test.ts +281 -0
- package/src/node-request-retention.ts +120 -0
- package/src/node-secret-rest-http.test.ts +190 -0
- package/src/node-serviceability.test.ts +86 -0
- package/src/node-serviceability.ts +124 -0
- package/src/node-session-control-http.test.ts +310 -0
- package/src/node-session-control.ts +258 -0
- package/src/node-skills-transport.test.ts +212 -0
- package/src/node-token-identity.ts +35 -0
- package/src/node-token-ownership.ts +51 -0
- package/src/node-token-privilege-http.test.ts +158 -0
- package/src/not-found-api-http.test.ts +67 -0
- package/src/observer-avatar-http.test.ts +103 -10
- package/src/observer-push.test.ts +76 -0
- package/src/opencode-catalog-report-http.test.ts +139 -0
- package/src/opencode-v2-catalog.test.ts +268 -0
- package/src/opencode-v2-catalog.ts +356 -0
- package/src/package-version-consistency.test.ts +25 -0
- package/src/parent-source-marker.test.ts +50 -0
- package/src/password-network-tokens.ts +25 -0
- package/src/peer-reply-atomic.test.ts +462 -0
- package/src/peer-reply-capability.test.ts +70 -0
- package/src/pg-worker.ts +87 -0
- package/src/poll-pacing.test.ts +74 -0
- package/src/poll-pacing.ts +123 -0
- package/src/project-dir-warn-clear-http.test.ts +132 -0
- package/src/project-viewer-can-http.test.ts +116 -0
- package/src/provider-tools-shape.test.ts +150 -0
- package/src/push.test.ts +20 -10
- package/src/push.ts +373 -9
- package/src/redact-tokens.test.ts +86 -0
- package/src/redact-tokens.ts +43 -0
- package/src/rejection-counters.test.ts +72 -0
- package/src/rejection-counters.ts +173 -0
- package/src/rename.ts +38 -10
- package/src/reply-target-derivation.test.ts +96 -0
- package/src/report-status-handover-capabilities-http.test.ts +124 -0
- package/src/report-status-host-schema.test.ts +235 -0
- package/src/report-status-resume-id-handover.test.ts +184 -0
- package/src/report-status-secret-keys.test.ts +140 -0
- package/src/require-explicit-test-db.ts +9 -0
- package/src/requirement-due-reminders-http.test.ts +620 -0
- package/src/requirement-due-reminders.ts +416 -0
- package/src/requirement-events-http.test.ts +318 -0
- package/src/requirement-events.test.ts +45 -0
- package/src/requirement-events.ts +144 -0
- package/src/requirement-notify.ts +165 -0
- package/src/requirement-participant-notify-http.test.ts +309 -0
- package/src/requirement-tag-ops-http.test.ts +454 -0
- package/src/requirement-tag-tree-http.test.ts +275 -0
- package/src/requirement-tag-tree.ts +127 -0
- package/src/requirement-tags.ts +102 -0
- package/src/requirements-abandoned-http.test.ts +236 -0
- package/src/requirements-assignee-drift.test.ts +154 -0
- package/src/requirements-comment-http.test.ts +174 -0
- package/src/requirements-completed-at-migration.test.ts +70 -0
- package/src/requirements-errors-mcp-http.test.ts +164 -0
- package/src/requirements-errors.ts +158 -0
- package/src/requirements-etag-http.test.ts +91 -0
- package/src/requirements-http.test.ts +709 -0
- package/src/requirements-last-event-http.test.ts +349 -0
- package/src/requirements-list-mcp-slim-http.test.ts +155 -0
- package/src/requirements-list-slim-http.test.ts +324 -0
- package/src/requirements-mcp.test.ts +164 -0
- package/src/requirements-migrate.ts +283 -0
- package/src/requirements-owner-strict-mcp-http.test.ts +145 -0
- package/src/requirements-people-http.test.ts +114 -0
- package/src/requirements-people-mcp-http.test.ts +231 -0
- package/src/requirements-people.ts +196 -0
- package/src/requirements-priority-lowest.test.ts +114 -0
- package/src/requirements-projects-network-echo.test.ts +57 -0
- package/src/requirements-projects-parent-http.test.ts +123 -0
- package/src/requirements-search-http.test.ts +182 -0
- package/src/requirements-search.test.ts +32 -0
- package/src/requirements-search.ts +145 -0
- package/src/requirements-seq-http.test.ts +193 -0
- package/src/requirements-seq-migration.test.ts +63 -0
- package/src/requirements-start-date.test.ts +125 -0
- package/src/requirements-stats-http.test.ts +357 -0
- package/src/requirements-stats.ts +195 -0
- package/src/requirements-status-participants-http.test.ts +222 -0
- package/src/requirements-upgrade-e2e.test.ts +126 -0
- package/src/requirements-upgrade-migration.test.ts +98 -0
- package/src/requirements.ts +2205 -0
- package/src/resolve-port.test.ts +57 -0
- package/src/resolve-port.ts +44 -0
- package/src/rest-alias-network-fallback-http.test.ts +123 -0
- package/src/rest-alias-network-fallback.test.ts +60 -0
- package/src/rest-alias-network-fallback.ts +65 -0
- package/src/rest-explicit-columns-http.test.ts +266 -0
- package/src/rest-identity.test.ts +130 -0
- package/src/rest-identity.ts +141 -0
- package/src/rest-projections.ts +72 -0
- package/src/rest-read-network-real-chain.test.ts +97 -0
- package/src/rest-write-network-resolution.test.ts +133 -0
- package/src/restart-readiness-http.test.ts +121 -0
- package/src/restricted-files.ts +76 -0
- package/src/retention-first-sweep-quiet.test.ts +31 -0
- package/src/retention.test.ts +100 -40
- package/src/retention.ts +423 -104
- package/src/route-callers-http.test.ts +120 -0
- package/src/route-timing.test.ts +218 -0
- package/src/route-timing.ts +262 -0
- package/src/rules-file-duplicate-alias.test.ts +234 -0
- package/src/rules-file-session-target.test.ts +207 -0
- package/src/rules-file-transport.test.ts +237 -0
- package/src/runtime-label.test.ts +22 -0
- package/src/runtime-label.ts +21 -0
- package/src/runtime-readiness.ts +90 -0
- package/src/schedule-agent-mcp-http.test.ts +475 -0
- package/src/schedule-agent.ts +252 -0
- package/src/schedule-starved.test.ts +92 -0
- package/src/schedule-starved.ts +114 -0
- package/src/scheduled-backoff-http.test.ts +203 -0
- package/src/scheduled-backoff.ts +64 -0
- package/src/scheduled-doorbell-nodeless-session.test.ts +134 -0
- package/src/scheduled-failure-backoff-2622.test.ts +145 -0
- package/src/scheduled-failure-code.test.ts +73 -0
- package/src/scheduled-failure-code.ts +105 -0
- package/src/scheduled-failures-http.test.ts +279 -0
- package/src/scheduled-failures.ts +425 -0
- package/src/scheduled-noprogress-backoff-2622.test.ts +163 -0
- package/src/scheduled-offline-backoff-probe.test.ts +56 -0
- package/src/scheduled-offline.test.ts +131 -0
- package/src/scheduled-offline.ts +66 -0
- package/src/scheduled-outcome-guidance-http.test.ts +139 -0
- package/src/scheduled-outcome-guidance.ts +9 -0
- package/src/scheduled-reply-unread-http.test.ts +212 -0
- package/src/scheduled-requirement-wake-http.test.ts +285 -0
- package/src/scheduled-requirement-wake.ts +125 -0
- package/src/scheduled-run-terminal.test.ts +290 -0
- package/src/scheduled-skip-blocking-task.test.ts +120 -0
- package/src/scheduled-skip-path-backoff-2622.test.ts +98 -0
- package/src/scheduled-stuck-http.test.ts +316 -0
- package/src/scheduled-stuck-notice-cap.test.ts +80 -0
- package/src/scheduled-stuck.ts +219 -0
- package/src/scheduled-tasks-http.test.ts +679 -0
- package/src/scheduled-tasks.ts +959 -0
- package/src/scheduled-work-outcome-http.test.ts +154 -0
- package/src/scheduled-work-outcome.ts +50 -0
- package/src/scoped-secrets.ts +141 -0
- package/src/secret-echo-negative-control.test.ts +118 -0
- package/src/send-dedup-request-id.test.ts +229 -0
- package/src/send-reply-agent-warning.test.ts +38 -38
- package/src/send-reply-alias-optional.test.ts +131 -0
- package/src/send-reply-attachments.test.ts +458 -0
- package/src/send_dedup.test.ts +54 -0
- package/src/send_dedup.ts +52 -6
- package/src/serve-error.test.ts +73 -0
- package/src/serve-error.ts +56 -0
- package/src/server.ts +5134 -503
- package/src/session-task-on-dispatch.ts +14 -0
- package/src/session-token-ownership-http.test.ts +122 -0
- package/src/shared/codex-inventory.ts +41 -0
- package/src/shared/daemon-provider-login.ts +31 -0
- package/src/shared/daemon-provider-snapshot.ts +52 -0
- package/src/shared/external-schedule-contract.ts +60 -0
- package/src/shared/node-name.test.ts +62 -0
- package/src/shared/node-name.ts +161 -0
- package/src/shared/probe-host-allowlist-drift.test.ts +45 -0
- package/src/shared/provider-application.ts +29 -0
- package/src/shared/provider-collection.ts +14 -0
- package/src/shared/provider-initialization.ts +8 -0
- package/src/shared/reserved-env-drift.test.ts +10 -0
- package/src/shared/scoped-secret-contract.ts +5 -0
- package/src/shared/task-content-limit-drift.test.ts +28 -0
- package/src/shared/task-content-limit.ts +25 -0
- package/src/side-thread-command-transport.test.ts +312 -0
- package/src/side-thread-command-transport.ts +318 -0
- package/src/side-thread-http-integration.test.ts +233 -0
- package/src/side-thread-http.ts +504 -0
- package/src/side-thread-production.test.ts +72 -0
- package/src/side-thread-production.ts +118 -0
- package/src/side-thread.test.ts +1067 -0
- package/src/side-thread.ts +2499 -0
- package/src/skillhub-http.test.ts +142 -0
- package/src/sqlite-close-checkpoint.test.ts +78 -0
- package/src/start-node.test.ts +265 -0
- package/src/stats-versions-http.test.ts +65 -0
- package/src/status-alias-filter-http.test.ts +106 -0
- package/src/status-alias-resolver-http.test.ts +163 -0
- package/src/status-alias-resolver.ts +19 -0
- package/src/status-node-id-filter-http.test.ts +161 -0
- package/src/status-read-cache-http.test.ts +229 -0
- package/src/status-read-cache.ts +129 -0
- package/src/stop-delete-node.test.ts +567 -1
- package/src/task-access-http.test.ts +402 -0
- package/src/task-access.ts +420 -0
- package/src/task-activity.ts +60 -0
- package/src/task-auth-origin-http.test.ts +93 -0
- package/src/task-auth-origin.test.ts +24 -0
- package/src/task-auth-origin.ts +7 -0
- package/src/task-consumption.test.ts +498 -0
- package/src/task-diagnostic-http.test.ts +149 -0
- package/src/task-diagnostic.test.ts +115 -0
- package/src/task-diagnostic.ts +118 -0
- package/src/task-expiry-notice-http.test.ts +298 -0
- package/src/task-expiry-notice.ts +318 -0
- package/src/task-idempotency-mcp.test.ts +142 -0
- package/src/task-idempotency.test.ts +76 -0
- package/src/task-idempotency.ts +81 -0
- package/src/task-late-replies.ts +54 -0
- package/src/task-late-reply-http.test.ts +227 -0
- package/src/task-lifecycle-watcher-busy.test.ts +114 -0
- package/src/task-lifecycle-watcher.test.ts +209 -0
- package/src/task-lifecycle-watcher.ts +109 -0
- package/src/task-network-resolution-http.test.ts +140 -0
- package/src/task-offline-delivery-2668.test.ts +119 -0
- package/src/task-offline-delivery.ts +81 -0
- package/src/task-orphan-http.test.ts +287 -0
- package/src/task-orphan.ts +119 -0
- package/src/task-queue-ahead-http.test.ts +309 -0
- package/src/task-queue-ahead-scale.test.ts +236 -0
- package/src/task-queue-ahead.ts +186 -0
- package/src/task-rejection-log-http.test.ts +160 -0
- package/src/task-rejection-log.ts +61 -0
- package/src/task-sender-http.test.ts +143 -0
- package/src/task-stale-open-http.test.ts +292 -0
- package/src/task-stale-open.ts +103 -0
- package/src/tasks-pagination-http.test.ts +141 -0
- package/src/team-rules-status-http.test.ts +90 -0
- package/src/team-rules-status.test.ts +59 -0
- package/src/team-rules-status.ts +72 -0
- package/src/tmux-allowlist.test.ts +48 -0
- package/src/tool-audience-http.test.ts +230 -0
- package/src/tool-audience.ts +127 -0
- package/src/tools-list-json-schema.test.ts +94 -0
- package/src/tools.ts +4326 -420
- package/src/upload-early-reject-guard.test.ts +155 -0
- package/src/uploads-http.test.ts +86 -7
- package/src/uploads.ts +38 -4
- package/src/user-avatar-http.test.ts +74 -0
- package/src/user-avatar-image.ts +160 -0
- package/src/user-avatar-migration.test.ts +25 -0
- package/src/user-avatar-upload-http.test.ts +348 -0
- package/src/user-inbox-by-agent-http.test.ts +165 -0
- package/src/user-inbox-netid-notnull.test.ts +122 -0
- package/src/user-inbox-read-http.test.ts +223 -0
- package/src/user-inbox-schema.test.ts +54 -0
- package/src/version-stats.test.ts +66 -0
- package/src/version-stats.ts +109 -0
|
@@ -60,8 +60,10 @@ describe("#462 validateAvatarUrl", () => {
|
|
|
60
60
|
expect(validateAvatarUrl("ftp://example.com/a.png").ok).toBe(false);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
test("rejects
|
|
64
|
-
|
|
63
|
+
test("rejects protocol-relative / non-URL / schemeless strings", () => {
|
|
64
|
+
// SPEC CHANGE (通信龙 裁定, avatar 接线单): same-origin pool paths
|
|
65
|
+
// (/avatars/<name>.<ext>) are now ACCEPTED — that case moved to the
|
|
66
|
+
// dedicated relative-branch suite below. Everything here stays rejected.
|
|
65
67
|
expect(validateAvatarUrl("//cdn.example.com/1.png").ok).toBe(false);
|
|
66
68
|
expect(validateAvatarUrl("not a url").ok).toBe(false);
|
|
67
69
|
expect(validateAvatarUrl("example.com/x.png").ok).toBe(false);
|
|
@@ -111,3 +113,51 @@ describe("#462 validateAvatarUrl", () => {
|
|
|
111
113
|
expect(validateAvatarUrl(ok + "a").ok).toBe(false);
|
|
112
114
|
});
|
|
113
115
|
});
|
|
116
|
+
|
|
117
|
+
// ── Same-origin relative branch (通信龙 裁定: relax to portable pool paths;
|
|
118
|
+
// absolute URLs would weld one hostname into the DB across multi-origin
|
|
119
|
+
// entry points). Each direction is its OWN test so any single guard
|
|
120
|
+
// being deleted turns its OWN assertion red (no merged catch-all).
|
|
121
|
+
describe("validateAvatarUrl — same-origin relative pool paths", () => {
|
|
122
|
+
test("accepts a pool path: /avatars/avatar-09.webp", () => {
|
|
123
|
+
const r = validateAvatarUrl("/avatars/avatar-09.webp");
|
|
124
|
+
expect(r).toEqual({ ok: true, value: "/avatars/avatar-09.webp" });
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("accepts png and svg pool files", () => {
|
|
128
|
+
expect(validateAvatarUrl("/avatars/intern_avatar.png")).toEqual({ ok: true, value: "/avatars/intern_avatar.png" });
|
|
129
|
+
expect(validateAvatarUrl("/avatars/team-logo.svg")).toEqual({ ok: true, value: "/avatars/team-logo.svg" });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("rejects protocol-relative //host (classic same-origin bypass)", () => {
|
|
133
|
+
const r = validateAvatarUrl("//evil.com/x.png");
|
|
134
|
+
expect(r.ok).toBe(false);
|
|
135
|
+
if (!r.ok) expect(r.reason).toContain("protocol-relative");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("rejects javascript: scheme (still, after the relax)", () => {
|
|
139
|
+
expect(validateAvatarUrl("javascript:alert(1)").ok).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("rejects non-/avatars/ absolute paths (/etc/passwd)", () => {
|
|
143
|
+
expect(validateAvatarUrl("/etc/passwd").ok).toBe(false);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("rejects non-whitelisted extensions under /avatars/", () => {
|
|
147
|
+
expect(validateAvatarUrl("/avatars/payload.html").ok).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("rejects nested/traversal paths (charset forbids further slashes)", () => {
|
|
151
|
+
expect(validateAvatarUrl("/avatars/../secrets.webp").ok).toBe(false);
|
|
152
|
+
expect(validateAvatarUrl("/avatars/sub/x.webp").ok).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("rejects percent-encoding inside the filename (no encoded surprises)", () => {
|
|
156
|
+
expect(validateAvatarUrl("/avatars/a%2f..%2fx.webp").ok).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("absolute http(s) branch is UNTOUCHED by the relax (positive control)", () => {
|
|
160
|
+
const r = validateAvatarUrl("https://example.com/pic.png");
|
|
161
|
+
expect(r.ok).toBe(true);
|
|
162
|
+
});
|
|
163
|
+
});
|
package/src/avatar-validate.ts
CHANGED
|
@@ -15,9 +15,26 @@ export type AvatarValidation =
|
|
|
15
15
|
* Normalize + validate an untrusted avatar_url patch value.
|
|
16
16
|
*
|
|
17
17
|
* null / undefined / "" / whitespace-only → { ok, value: null } (clear)
|
|
18
|
-
*
|
|
18
|
+
* same-origin pool path /avatars/<name>.<ext> → { ok, value: trimmed }
|
|
19
|
+
* valid absolute http(s) URL → { ok, value: normalized }
|
|
19
20
|
* anything else → { ok: false, reason }
|
|
21
|
+
*
|
|
22
|
+
* Relative branch rationale (通信龙 裁定, avatar 接线单): the hub is
|
|
23
|
+
* reached through several origins (localhost dev, public domains) — an
|
|
24
|
+
* absolute URL would weld ONE hostname into the DB and break the image
|
|
25
|
+
* for every other entry point; a same-origin relative path is portable.
|
|
26
|
+
* 🔴 Trap this branch must block: "starts with /" ≠ "same-origin" —
|
|
27
|
+
* "//evil.com/x.png" ALSO starts with "/" but is a protocol-relative URL
|
|
28
|
+
* the browser resolves to evil.com. Hence: single leading slash with the
|
|
29
|
+
* SECOND char not "/", then an exact value-set match (the /avatars/ pool
|
|
30
|
+
* prefix + extension whitelist), not a shape match.
|
|
20
31
|
*/
|
|
32
|
+
|
|
33
|
+
// Exact allowed set for same-origin values: the dashboard's designed pool
|
|
34
|
+
// under /avatars/. Filename charset excludes "/" (no traversal, no nested
|
|
35
|
+
// paths) and "%" (no encoded surprises); extensions mirror the actual
|
|
36
|
+
// pool contents. Widen ONLY by extending this list deliberately.
|
|
37
|
+
const SAME_ORIGIN_AVATAR_RE = /^\/avatars\/[A-Za-z0-9._-]+\.(webp|png|svg)$/;
|
|
21
38
|
export function validateAvatarUrl(raw: unknown): AvatarValidation {
|
|
22
39
|
if (raw === null || raw === undefined) return { ok: true, value: null };
|
|
23
40
|
if (typeof raw !== "string") {
|
|
@@ -35,6 +52,23 @@ export function validateAvatarUrl(raw: unknown): AvatarValidation {
|
|
|
35
52
|
if (/[\u0000-\u001f\u007f-\u009f\s]/.test(trimmed)) {
|
|
36
53
|
return { ok: false, reason: "avatar_url must not contain whitespace or control characters" };
|
|
37
54
|
}
|
|
55
|
+
// Same-origin relative branch (runs AFTER the whitespace/control gate
|
|
56
|
+
// above — that check protects this branch too). Order of the two tests
|
|
57
|
+
// matters for the reason string, not for safety: the exact-set regex
|
|
58
|
+
// alone already rejects "//…" (second char is "/", first segment must
|
|
59
|
+
// literally be "avatars"), the explicit double-slash check just names
|
|
60
|
+
// the classic bypass in its own words.
|
|
61
|
+
if (trimmed.startsWith("/")) {
|
|
62
|
+
if (trimmed.startsWith("//")) {
|
|
63
|
+
return { ok: false, reason: "avatar_url must not be protocol-relative (//host/…)" };
|
|
64
|
+
}
|
|
65
|
+
if (!SAME_ORIGIN_AVATAR_RE.test(trimmed)) {
|
|
66
|
+
return { ok: false, reason: "relative avatar_url must match /avatars/<name>.(webp|png|svg)" };
|
|
67
|
+
}
|
|
68
|
+
return { ok: true, value: trimmed };
|
|
69
|
+
}
|
|
70
|
+
// Absolute http(s) branch — unchanged from #462 (do not touch while
|
|
71
|
+
// relaxing: 通信龙 裁定 condition 3).
|
|
38
72
|
let parsed: URL;
|
|
39
73
|
try {
|
|
40
74
|
parsed = new URL(trimmed);
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// #2664 —— `backfillMessageNodeIds()` 从「逐行相关子查询」改成「物化的别名→node_id 表 + UPDATE … FROM」。
|
|
2
|
+
//
|
|
3
|
+
// 这次改写**只为了快**(生产副本实测单条 6.56s → 0.29s;boot 期六条约 10s → 约 0.75s),
|
|
4
|
+
// 而“快”最容易顺手改坏的是**选哪一行 / 谁不该被改**:
|
|
5
|
+
// · 人的用户名不能被映射成节点(`NOT EXISTS users.username`);
|
|
6
|
+
// · 改过名的节点走 rename_txn(只认 `committed`);
|
|
7
|
+
// · 已经有 node_id 的行**不能被覆盖**;
|
|
8
|
+
// · 重复调用幂等。
|
|
9
|
+
//
|
|
10
|
+
// 注:`sessions` 上有 `UNIQUE (network_id, alias)` 且 `network_id NOT NULL`,
|
|
11
|
+
// 所以“同一 alias 多条 session 时取 updated_at 最新”在当前 schema 下**不可构造**;
|
|
12
|
+
// 窗口函数只是为了在 PG / 老库形状下保持与旧 `ORDER BY … LIMIT 1` 等价,不是新语义。
|
|
13
|
+
|
|
14
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
15
|
+
import { db, backfillMessageNodeIds } from "./db.js";
|
|
16
|
+
|
|
17
|
+
let networkId = "";
|
|
18
|
+
const stamp = `${Date.now()}`;
|
|
19
|
+
|
|
20
|
+
function session(alias: string, nodeId: string | null, updatedAt: string, network = networkId) {
|
|
21
|
+
db.run(
|
|
22
|
+
`INSERT INTO sessions (resume_id, alias, node_id, status, network_id, registered_at, updated_at)
|
|
23
|
+
VALUES (?1, ?2, ?3, 'idle', ?4, ?5, ?5)`,
|
|
24
|
+
[`res_${alias}_${stamp}`, alias, nodeId, network, updatedAt],
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function task(id: string, fromName: string, toName: string, network = networkId) {
|
|
29
|
+
db.run(
|
|
30
|
+
`INSERT INTO tasks (task_id, from_name, to_name, content, status, network_id)
|
|
31
|
+
VALUES (?1, ?2, ?3, 'fixture', 'delivered', ?4)`,
|
|
32
|
+
[id, fromName, toName, network],
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function nodeIds(id: string) {
|
|
37
|
+
return db.get<{ from_node_id: string | null; to_node_id: string | null }>(
|
|
38
|
+
"SELECT from_node_id, to_node_id FROM tasks WHERE task_id = ?1",
|
|
39
|
+
[`${id}-${stamp}`],
|
|
40
|
+
)!;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
beforeAll(async () => {
|
|
44
|
+
const { register } = await import("./auth.js");
|
|
45
|
+
const auth = register(`bf_owner_${stamp}`, "Bf-Owner-Strong-1!", undefined, "tester");
|
|
46
|
+
expect(auth.ok).toBe(true);
|
|
47
|
+
networkId = auth.network_id!;
|
|
48
|
+
|
|
49
|
+
session(`bf-node-${stamp}`, `node-${stamp}`, "2026-10-20 00:00:00");
|
|
50
|
+
// 人类用户:即便 sessions 里出现过同名行,也不能把任务归到那个 node
|
|
51
|
+
session(`bf-human-${stamp}`, `node-should-not-win-${stamp}`, "2026-10-20 00:00:00");
|
|
52
|
+
db.run(
|
|
53
|
+
`INSERT INTO users (user_id, username, display_name, role, password_hash, created_at)
|
|
54
|
+
VALUES (?1, ?2, '人类', 'member', 'x', datetime('now'))`,
|
|
55
|
+
[`u_bf_${stamp}`, `bf-human-${stamp}`],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
task(`bf-fresh-${stamp}`, `bf-node-${stamp}`, `bf-node-${stamp}`);
|
|
59
|
+
task(`bf-human-task-${stamp}`, `bf-human-${stamp}`, `bf-node-${stamp}`);
|
|
60
|
+
task(`bf-preset-${stamp}`, `bf-node-${stamp}`, `bf-node-${stamp}`);
|
|
61
|
+
db.run(`UPDATE tasks SET from_node_id = 'preset-node', to_node_id = 'preset-node' WHERE task_id = ?1`, [
|
|
62
|
+
`bf-preset-${stamp}`,
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
// rename_txn:旧别名 → 新别名(committed 生效;pending 不生效)
|
|
66
|
+
session(`bf-new-alias-${stamp}`, `node-renamed-${stamp}`, "2026-10-20 00:00:00");
|
|
67
|
+
db.run(
|
|
68
|
+
`INSERT INTO rename_txn (txn_id, old_alias, new_alias, status, network_id, committed_at)
|
|
69
|
+
VALUES (?1, ?2, ?3, 'committed', ?4, '2026-10-21 00:00:00')`,
|
|
70
|
+
[`txn_bf_${stamp}`, `bf-old-alias-${stamp}`, `bf-new-alias-${stamp}`, networkId],
|
|
71
|
+
);
|
|
72
|
+
task(`bf-renamed-${stamp}`, `bf-old-alias-${stamp}`, `bf-old-alias-${stamp}`);
|
|
73
|
+
|
|
74
|
+
db.run(
|
|
75
|
+
`INSERT INTO rename_txn (txn_id, old_alias, new_alias, status, network_id, committed_at)
|
|
76
|
+
VALUES (?1, ?2, ?3, 'pending', ?4, NULL)`,
|
|
77
|
+
[`txn_bf_pending_${stamp}`, `bf-pending-alias-${stamp}`, `bf-new-alias-${stamp}`, networkId],
|
|
78
|
+
);
|
|
79
|
+
task(`bf-pending-${stamp}`, `bf-pending-alias-${stamp}`, `bf-pending-alias-${stamp}`);
|
|
80
|
+
|
|
81
|
+
backfillMessageNodeIds();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
afterAll(() => {
|
|
85
|
+
try {
|
|
86
|
+
db.run(`DELETE FROM tasks WHERE task_id LIKE ?1`, [`bf-%-${stamp}`]);
|
|
87
|
+
db.run(`DELETE FROM sessions WHERE alias LIKE ?1`, [`bf-%-${stamp}`]);
|
|
88
|
+
db.run(`DELETE FROM rename_txn WHERE txn_id LIKE ?1`, [`txn_bf%${stamp}`]);
|
|
89
|
+
db.run(`DELETE FROM users WHERE username LIKE ?1`, [`bf-human-${stamp}`]);
|
|
90
|
+
} catch {}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe("#2664 backfill semantics unchanged by the join rewrite", () => {
|
|
94
|
+
test("普通别名能补上 from/to 两侧的 node_id", () => {
|
|
95
|
+
expect(nodeIds("bf-fresh").from_node_id).toBe(`node-${stamp}`);
|
|
96
|
+
expect(nodeIds("bf-fresh").to_node_id).toBe(`node-${stamp}`);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("人的用户名不会被映射成节点", () => {
|
|
100
|
+
expect(nodeIds("bf-human-task").from_node_id).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("已经有 node_id 的行不被覆盖", () => {
|
|
104
|
+
expect(nodeIds("bf-preset").from_node_id).toBe("preset-node");
|
|
105
|
+
expect(nodeIds("bf-preset").to_node_id).toBe("preset-node");
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("改过名的节点按 rename_txn 的旧别名补上", () => {
|
|
109
|
+
expect(nodeIds("bf-renamed").from_node_id).toBe(`node-renamed-${stamp}`);
|
|
110
|
+
expect(nodeIds("bf-renamed").to_node_id).toBe(`node-renamed-${stamp}`);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("未提交(pending)的改名不生效", () => {
|
|
114
|
+
expect(nodeIds("bf-pending").from_node_id).toBeNull();
|
|
115
|
+
expect(nodeIds("bf-pending").to_node_id).toBeNull();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("第二次调用是幂等的", () => {
|
|
119
|
+
const count = () =>
|
|
120
|
+
db.get<{ n: number }>(
|
|
121
|
+
`SELECT COUNT(*) AS n FROM tasks WHERE network_id = ?1 AND (from_node_id IS NOT NULL OR to_node_id IS NOT NULL)`,
|
|
122
|
+
[networkId],
|
|
123
|
+
)!.n;
|
|
124
|
+
const before = count();
|
|
125
|
+
backfillMessageNodeIds();
|
|
126
|
+
expect(count()).toBe(before);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { beforeAll, afterAll, expect, test } from "bun:test";
|
|
2
|
+
import { mkdtempSync } from "node:fs";
|
|
3
|
+
import { preflightCodexStart } from "../../agent-node/src/runtime/adopt-codex-start-preflight.js";
|
|
4
|
+
|
|
5
|
+
process.env.COMMHUB_DB ||= `${mkdtempSync("/tmp/binding-http-")}/hub.db`;
|
|
6
|
+
process.env.COMMHUB_AUTH_TOKEN ||= "binding-master-fixture";
|
|
7
|
+
let db:any, hub:ReturnType<typeof Bun.serve>, base:string, owner:any, other:any;
|
|
8
|
+
const daemon="n_binding_daemon", child="n_binding_child";
|
|
9
|
+
let token:string, wrong:string, cross:string, ordinary:string, revoked:string;
|
|
10
|
+
async function mcp(credential:string,name:string,args:Record<string,unknown>={}) {
|
|
11
|
+
const res=await fetch(`${base}/mcp`, {method:"POST",headers:{Authorization:`Bearer ${credential}`,
|
|
12
|
+
"Content-Type":"application/json",Accept:"application/json, text/event-stream","MCP-Protocol-Version":"2025-03-26"},
|
|
13
|
+
body:JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name,arguments:args}})});
|
|
14
|
+
const raw=await res.text();
|
|
15
|
+
if(res.status!==200)return {ok:false,http_status:res.status};
|
|
16
|
+
const lines=raw.split("\n").filter(s=>s.startsWith("data:"));
|
|
17
|
+
const payload=JSON.parse(lines.length?lines.at(-1)!.slice(5):raw);
|
|
18
|
+
return payload.result?.content?.[0]?.text ? JSON.parse(payload.result.content[0].text) : {ok:false,error:payload.error};
|
|
19
|
+
}
|
|
20
|
+
const list=(t=token)=>mcp(t,"list_my_children");
|
|
21
|
+
const request=()=>mcp(owner.token,"request_adopt_node",{node_id:child,daemon_node_id:daemon,workdir:"/fixture/project"});
|
|
22
|
+
const ack=(id:string,status="adopted")=>mcp(token,"ack_adopt_request",{request_id:id,status});
|
|
23
|
+
const unadopt=()=>mcp(owner.token,"unadopt_node",{node_id:child});
|
|
24
|
+
async function activate(){
|
|
25
|
+
const r=await request();
|
|
26
|
+
// 2026-10-31 —— #3275:request_adopt_node 的形状(收养也是**下发一个请求**)。
|
|
27
|
+
// status 一并回来,调用方不必再查一次「这条请求现在是什么状态」。
|
|
28
|
+
expect(Object.keys(r).sort()).toEqual(["ok","request_id","status"]);
|
|
29
|
+
expect(r.ok).toBe(true);
|
|
30
|
+
expect((await ack(r.request_id)).status).toBe("active");return r.request_id;}
|
|
31
|
+
beforeAll(async()=>{
|
|
32
|
+
({db}=await import("./db.js"));
|
|
33
|
+
const {register}=await import("./auth.js");
|
|
34
|
+
owner=register("binding_owner","Fixture-Strong1!");other=register("binding_other","Fixture-Strong1!");
|
|
35
|
+
expect(owner.ok&&other.ok).toBe(true);
|
|
36
|
+
db.run("UPDATE users SET role='user' WHERE user_id=?1",[other.user.user_id]);
|
|
37
|
+
db.run("INSERT INTO network_members(network_id,user_id,role) VALUES(?1,?2,'member')",[owner.network_id,other.user.user_id]);
|
|
38
|
+
const {generateNetworkToken,hashToken}=await import("./db.js");
|
|
39
|
+
function node(id:string,network:string,user:string,supervisor=true){
|
|
40
|
+
db.run("INSERT INTO nodes(node_id,node_name,alias,network_id,owner_user_id,hostname,config_snapshot,lifecycle_state) VALUES(?1,?1,?1,?2,?3,'fixture-host',?4,'active')",
|
|
41
|
+
[id,network,user,JSON.stringify(supervisor?{role:"host_supervisor",daemon_capabilities:{adopt_capable:true}}:{})]);
|
|
42
|
+
db.run("INSERT INTO sessions(resume_id,alias,node_id,network_id,status,last_seen_at) VALUES(?1,?1,?1,?2,'idle',datetime('now'))",[id,network]);
|
|
43
|
+
const raw=generateNetworkToken();
|
|
44
|
+
db.run("INSERT INTO api_tokens(token_id,user_id,network_id,scope,name,token_hash) VALUES(?1,?2,?3,'network',?4,?5)",[id,user,network,`node:${id}`,hashToken(raw)]);
|
|
45
|
+
return raw;
|
|
46
|
+
}
|
|
47
|
+
token=node(daemon,owner.network_id,owner.user.user_id);
|
|
48
|
+
wrong=node("n_binding_other",owner.network_id,other.user.user_id);
|
|
49
|
+
cross=node("n_binding_cross",other.network_id,other.user.user_id);
|
|
50
|
+
node(child,owner.network_id,owner.user.user_id,false);
|
|
51
|
+
ordinary=generateNetworkToken();revoked=generateNetworkToken();
|
|
52
|
+
for(const [id,raw,name,dead] of [["ordinary",ordinary,"general",null],["revoked",revoked,`node:${daemon}`,"2020-01-01"]])
|
|
53
|
+
db.run("INSERT INTO api_tokens(token_id,user_id,network_id,scope,name,token_hash,revoked_at) VALUES(?1,?2,?3,'network',?4,?5,?6)",[id,owner.user.user_id,owner.network_id,name,hashToken(raw as string),dead]);
|
|
54
|
+
db.run("INSERT INTO nodes(node_id,node_name,alias,network_id,lifecycle_state) VALUES('node_binding_created','created','created',?1,'active')",[owner.network_id]);
|
|
55
|
+
db.run("INSERT INTO node_create_requests(request_id,daemon_node_id,child_name,network_id,runtime,flags_json,env_keys,status,created_at,created_by_token) VALUES('cr_binding_created',?1,'created',?2,'codex-sdk','{}','[]','succeeded',1,'fixture')",[daemon,owner.network_id]);
|
|
56
|
+
const {bootServer}=await import("./server.js");hub=bootServer({port:0,hostname:"127.0.0.1"});base=`http://127.0.0.1:${hub.port}`;
|
|
57
|
+
},60000);
|
|
58
|
+
afterAll(()=>hub?.stop(true));
|
|
59
|
+
|
|
60
|
+
test("generation projection and unchanged created row",async()=>{
|
|
61
|
+
const id=await activate();
|
|
62
|
+
const r=await list();expect(r.ok).toBe(true);
|
|
63
|
+
expect((await mcp(token,"get_adopt_request",{request_id:id})).error).toBe("request_not_pending");
|
|
64
|
+
expect(r.children.find((n:any)=>n.child_node_id===child)).toEqual({child_node_id:child,alias:child,lifecycle_state:"active",managed:"adopted",binding_request_id:id});
|
|
65
|
+
expect(r.children.find((n:any)=>n.child_node_id==="node_binding_created")).toEqual({child_node_id:"node_binding_created",alias:"created",lifecycle_state:"active"});
|
|
66
|
+
// Old consumers continue reading exactly the same fields; additive only.
|
|
67
|
+
expect(r.children.map(({child_node_id,alias,lifecycle_state,managed}:any)=>({child_node_id,alias,lifecycle_state,managed}))).toContainEqual({child_node_id:child,alias:child,lifecycle_state:"active",managed:"adopted"});
|
|
68
|
+
// 2026-10-31 —— #3275:unadopt_node 的成功体 {ok, status},且 status 必须是**第二终态**
|
|
69
|
+
// 「revoked」而不是「unadopted」—— 名字与载荷不是一回事(同 #3214 里 list_node_files 那一课)。
|
|
70
|
+
const un = await unadopt();
|
|
71
|
+
expect(Object.keys(un).sort()).toEqual(["ok", "status"]);
|
|
72
|
+
expect(un.status).toBe("revoked");
|
|
73
|
+
expect(un.ok).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
test("token boundary denies humans general revoked and other owners",async()=>{
|
|
76
|
+
await activate();
|
|
77
|
+
for(const t of [owner.token,other.token,ordinary,revoked])expect((await list(t)).ok).toBe(false);
|
|
78
|
+
for(const t of [wrong,cross]){const r=await list(t);expect(r.ok).toBe(true);expect(r.children).toEqual([]);}
|
|
79
|
+
expect((await unadopt()).ok).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
test("child node token sees an empty list, not its parent binding",async()=>{
|
|
82
|
+
const id=await activate();
|
|
83
|
+
try {
|
|
84
|
+
const issued=await fetch(`${base}/api/auth/node-token`,{method:"POST",
|
|
85
|
+
headers:{Authorization:`Bearer ${owner.token}`,"Content-Type":"application/json"},
|
|
86
|
+
body:JSON.stringify({network_id:owner.network_id,node_name:child,node_id:child})});
|
|
87
|
+
expect(issued.status).toBe(200);
|
|
88
|
+
const credential=await issued.json() as any;
|
|
89
|
+
expect(credential.ok).toBe(true);
|
|
90
|
+
expect(typeof credential.token).toBe("string");
|
|
91
|
+
// Same owner and network do not confer the parent's daemon identity.
|
|
92
|
+
expect((await list()).children.find((n:any)=>n.child_node_id===child).binding_request_id).toBe(id);
|
|
93
|
+
expect(await list(credential.token)).toEqual({ok:true,count:0,children:[]});
|
|
94
|
+
} finally {expect((await unadopt()).ok).toBe(true);}
|
|
95
|
+
});
|
|
96
|
+
test("network predicate rejects corrupted cross-network binding sentinel",async()=>{
|
|
97
|
+
const id=await activate();
|
|
98
|
+
// Deliberately inconsistent test DB: daemon stays in A, binding and child in B.
|
|
99
|
+
// This makes the network predicate independently load-bearing, HTTP still real.
|
|
100
|
+
try {
|
|
101
|
+
db.run("UPDATE node_daemon_bindings SET network_id=?1 WHERE request_id=?2",[other.network_id,id]);
|
|
102
|
+
db.run("UPDATE nodes SET network_id=?1 WHERE node_id=?2",[other.network_id,child]);
|
|
103
|
+
expect((await list()).children.some((n:any)=>n.child_node_id===child)).toBe(false);
|
|
104
|
+
} finally {
|
|
105
|
+
db.run("UPDATE node_daemon_bindings SET network_id=?1 WHERE request_id=?2",[owner.network_id,id]);
|
|
106
|
+
db.run("UPDATE nodes SET network_id=?1 WHERE node_id=?2",[owner.network_id,child]);await unadopt();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
test("node join rejects mismatched node network sentinel",async()=>{
|
|
110
|
+
await activate();
|
|
111
|
+
try {db.run("UPDATE nodes SET network_id=?1 WHERE node_id=?2",[other.network_id,child]);expect((await list()).children.some((n:any)=>n.child_node_id===child)).toBe(false);}
|
|
112
|
+
finally {db.run("UPDATE nodes SET network_id=?1 WHERE node_id=?2",[owner.network_id,child]);await unadopt();}
|
|
113
|
+
});
|
|
114
|
+
test("non-active bindings never project generation",async()=>{
|
|
115
|
+
const r=await request();expect(r.ok).toBe(true);
|
|
116
|
+
expect((await list()).children.some((n:any)=>n.child_node_id===child)).toBe(false);
|
|
117
|
+
expect((await ack(r.request_id,"refused")).status).toBe("refused");
|
|
118
|
+
expect((await list()).children.some((n:any)=>n.child_node_id===child)).toBe(false);
|
|
119
|
+
await activate();await unadopt();expect((await list()).children.some((n:any)=>n.child_node_id===child)).toBe(false);
|
|
120
|
+
});
|
|
121
|
+
test("revocation rotates generation and old acknowledgements cannot revive",async()=>{
|
|
122
|
+
const r1=await activate();await unadopt();
|
|
123
|
+
expect((await ack(r1)).error).toBe("request_not_pending");
|
|
124
|
+
const r2=await request();expect(r2.ok).toBe(true);expect(r2.request_id).not.toBe(r1);
|
|
125
|
+
expect((await list()).children.some((n:any)=>n.child_node_id===child)).toBe(false);
|
|
126
|
+
expect((await ack(r2.request_id)).status).toBe("active");
|
|
127
|
+
const current=(await list()).children.find((n:any)=>n.child_node_id===child).binding_request_id;
|
|
128
|
+
expect(current).toBe(r2.request_id);expect(current).not.toBe(r1);
|
|
129
|
+
// Real HTTP authority feeds the existing daemon gate; later probes must not run.
|
|
130
|
+
for(const authority of [current,undefined])await expect(preflightCodexStart({request_id:r1} as any,{} as any,{} as any,authority,()=>true)).rejects.toThrow("adopt_codex_binding_generation_unproven");
|
|
131
|
+
await unadopt();
|
|
132
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { afterAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { db } from "./db.js";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { registerTools } from "./tools.js";
|
|
5
|
+
|
|
6
|
+
// #1548 —— 一个活着、能收发任务的节点可以在名册里永远显示 `blocked`:
|
|
7
|
+
// 只有 report_completion 会把 sessions.status 拉回 idle,而现在大多数 agent 用
|
|
8
|
+
// send_reply(终态)结束任务、用 send_task 派活 —— 这两条路径此前都不碰 sessions.status。
|
|
9
|
+
// 「它刚回了我一条终态消息 / 刚派了一条任务」本身就是最强的活性证据。
|
|
10
|
+
// 只出 `blocked`;`working` 可能真在忙别的任务,不碰(保守)。
|
|
11
|
+
const NET_ID = "net_1548_blocked";
|
|
12
|
+
const USER_ID = "u_1548";
|
|
13
|
+
const NODE_ID = "node_1548_agent";
|
|
14
|
+
const AGENT_ALIAS = "agent-1548";
|
|
15
|
+
const DISPATCHER_NODE_ID = "node_1548_dispatcher";
|
|
16
|
+
const DISPATCHER_ALIAS = "dispatcher-1548";
|
|
17
|
+
const AGENT_TOK_ID = "tok_1548";
|
|
18
|
+
|
|
19
|
+
type ToolHandler = (args: any, extra?: any) => Promise<{ content: Array<{ type: "text"; text: string }> }>;
|
|
20
|
+
|
|
21
|
+
function cleanup() {
|
|
22
|
+
for (const [sql, params] of [
|
|
23
|
+
["DELETE FROM tasks WHERE network_id = ?1", [NET_ID]],
|
|
24
|
+
["DELETE FROM inbox WHERE network_id = ?1", [NET_ID]],
|
|
25
|
+
["DELETE FROM task_events WHERE network_id = ?1", [NET_ID]],
|
|
26
|
+
["DELETE FROM sessions WHERE network_id = ?1", [NET_ID]],
|
|
27
|
+
["DELETE FROM nodes WHERE network_id = ?1", [NET_ID]],
|
|
28
|
+
["DELETE FROM api_tokens WHERE network_id = ?1", [NET_ID]],
|
|
29
|
+
["DELETE FROM network_members WHERE network_id = ?1", [NET_ID]],
|
|
30
|
+
["DELETE FROM networks WHERE network_id = ?1", [NET_ID]],
|
|
31
|
+
["DELETE FROM users WHERE user_id = ?1", [USER_ID]],
|
|
32
|
+
] as const) {
|
|
33
|
+
try { db.run(sql, params as any); } catch {}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
beforeEach(cleanup);
|
|
37
|
+
afterAll(cleanup);
|
|
38
|
+
|
|
39
|
+
function seed(agentStatus: string) {
|
|
40
|
+
db.run(`INSERT INTO users (user_id, username, password_hash, role, created_at) VALUES (?1, ?2, 'x', 'user', datetime('now'))`, [USER_ID, USER_ID]);
|
|
41
|
+
db.run(`INSERT INTO networks (network_id, network_name, owner_id, created_at) VALUES (?1, ?2, ?3, datetime('now'))`, [NET_ID, NET_ID, USER_ID]);
|
|
42
|
+
db.run(
|
|
43
|
+
`INSERT INTO network_members (user_id, network_id, role, joined_at)
|
|
44
|
+
VALUES (?1, ?2, 'owner', datetime('now'))`,
|
|
45
|
+
[USER_ID, NET_ID],
|
|
46
|
+
);
|
|
47
|
+
for (const [nodeId, alias] of [[DISPATCHER_NODE_ID, DISPATCHER_ALIAS], [NODE_ID, AGENT_ALIAS]] as const) {
|
|
48
|
+
db.run(
|
|
49
|
+
`INSERT INTO nodes (node_id, node_name, alias, network_id, hostname, created_at, updated_at, lifecycle_state)
|
|
50
|
+
VALUES (?1, ?2, ?3, ?4, ?5, datetime('now'), datetime('now'), 'active')`,
|
|
51
|
+
[nodeId, alias, alias, NET_ID, `host-${alias}`],
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
db.run(
|
|
55
|
+
`INSERT INTO sessions (resume_id, alias, status, node_id, network_id, updated_at, last_seen_at)
|
|
56
|
+
VALUES (?1, ?2, 'idle', ?3, ?4, datetime('now'), datetime('now'))`,
|
|
57
|
+
[`res_${DISPATCHER_ALIAS}`, DISPATCHER_ALIAS, DISPATCHER_NODE_ID, NET_ID],
|
|
58
|
+
);
|
|
59
|
+
db.run(
|
|
60
|
+
`INSERT INTO sessions (resume_id, alias, status, node_id, network_id, updated_at, last_seen_at)
|
|
61
|
+
VALUES (?1, ?2, ?3, ?4, ?5, datetime('now'), datetime('now'))`,
|
|
62
|
+
[`res_${AGENT_ALIAS}`, AGENT_ALIAS, agentStatus, NODE_ID, NET_ID],
|
|
63
|
+
);
|
|
64
|
+
db.run(
|
|
65
|
+
`INSERT INTO api_tokens (token_id, user_id, network_id, scope, name, token_hash, expires_at, revoked_at)
|
|
66
|
+
VALUES (?1, ?2, ?3, 'network', ?4, ?5, NULL, NULL)`,
|
|
67
|
+
[AGENT_TOK_ID, USER_ID, NET_ID, `node:${AGENT_ALIAS}`, `hash_${AGENT_TOK_ID}`],
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function makeTask(): string {
|
|
71
|
+
const id = "t_" + Math.random().toString(36).slice(2, 14);
|
|
72
|
+
db.run(
|
|
73
|
+
`INSERT INTO tasks (task_id, from_name, to_name, to_node_id, priority, status, content, requires_response, created_at, network_id)
|
|
74
|
+
VALUES (?1, ?2, ?3, ?4, 'normal', 'delivered', 'test', 'reply', datetime('now'), ?5)`,
|
|
75
|
+
[id, DISPATCHER_ALIAS, AGENT_ALIAS, NODE_ID, NET_ID],
|
|
76
|
+
);
|
|
77
|
+
return id;
|
|
78
|
+
}
|
|
79
|
+
function buildHandlers(): Record<string, ToolHandler> {
|
|
80
|
+
const server = new McpServer({ name: "test", version: "0" }) as any;
|
|
81
|
+
const tools: Record<string, ToolHandler> = {};
|
|
82
|
+
const origTool = server.tool.bind(server);
|
|
83
|
+
server.tool = (name: string, _desc: string, _schema: any, handler: ToolHandler) => { tools[name] = handler; return origTool(name, _desc, _schema, handler); };
|
|
84
|
+
const origRegisterTool = server.registerTool?.bind(server);
|
|
85
|
+
if (origRegisterTool) {
|
|
86
|
+
server.registerTool = (name: string, _cfg: any, handler: ToolHandler) => { tools[name] = handler; return origRegisterTool(name, _cfg, handler); };
|
|
87
|
+
}
|
|
88
|
+
registerTools(server, undefined, NET_ID, USER_ID, AGENT_ALIAS, true, AGENT_TOK_ID);
|
|
89
|
+
return tools;
|
|
90
|
+
}
|
|
91
|
+
async function call(handler: ToolHandler, args: any): Promise<any> {
|
|
92
|
+
const r = await handler(args);
|
|
93
|
+
return JSON.parse(r.content[0]!.text);
|
|
94
|
+
}
|
|
95
|
+
function agentStatus(): string {
|
|
96
|
+
return (db.get("SELECT status FROM sessions WHERE alias = ?1 AND network_id = ?2", [AGENT_ALIAS, NET_ID]) as { status: string }).status;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
describe("#1548 blocked has an exit: a terminal reply or an outbound task proves the agent is alive", () => {
|
|
100
|
+
test("terminal send_reply from a blocked agent puts it back to idle", async () => {
|
|
101
|
+
seed("blocked");
|
|
102
|
+
const tools = buildHandlers();
|
|
103
|
+
const taskId = makeTask();
|
|
104
|
+
const r = await call(tools.send_reply!, { text: "done", in_reply_to: taskId, status: "replied", from_session: AGENT_ALIAS, network_id: NET_ID });
|
|
105
|
+
expect(r.ok, JSON.stringify(r)).toBe(true);
|
|
106
|
+
expect(agentStatus()).toBe("idle");
|
|
107
|
+
});
|
|
108
|
+
test("send_task from a blocked agent puts it back to idle", async () => {
|
|
109
|
+
seed("blocked");
|
|
110
|
+
const tools = buildHandlers();
|
|
111
|
+
const r = await call(tools.send_task!, { alias: DISPATCHER_ALIAS, task: "ping", priority: "normal", from_session: AGENT_ALIAS, network_id: NET_ID });
|
|
112
|
+
expect(r.ok, JSON.stringify(r)).toBe(true);
|
|
113
|
+
expect(agentStatus()).toBe("idle");
|
|
114
|
+
});
|
|
115
|
+
test("a working agent is left alone (it may be busy with another task)", async () => {
|
|
116
|
+
seed("working");
|
|
117
|
+
const tools = buildHandlers();
|
|
118
|
+
const taskId = makeTask();
|
|
119
|
+
await call(tools.send_reply!, { text: "done", in_reply_to: taskId, status: "replied", from_session: AGENT_ALIAS, network_id: NET_ID });
|
|
120
|
+
expect(agentStatus()).toBe("working");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// #2721 —— 广播扇出分批:把「一条广播 = 几百次同步写」摊成「每批一次事务 + 批间让出」。
|
|
2
|
+
//
|
|
3
|
+
// 现场(2026-10-27 07:10,生产 `.165`):384 行 inbox 让 Hub 出现 143.9 秒的 timer 饥饿,
|
|
4
|
+
// RSS 冲到 2.9GB,`requests_since_last_tick` 高达 1175(饱和而非阻塞)。
|
|
5
|
+
//
|
|
6
|
+
// 这个文件钉住四件事:
|
|
7
|
+
// 1. 收件人逐个入库,条数与收件人一致(语义不变);
|
|
8
|
+
// 2. 每 chunk 一批、批间**真的**让出(`yieldBetweenChunks` 被调用 ⌈n/chunk⌉ 次);
|
|
9
|
+
// 3. 非 active 的收件人静默跳过(RFC-027 best-effort),且不推事件;
|
|
10
|
+
// 4. 事件只推给**真的入库了**的收件人(#1440 的语义)。
|
|
11
|
+
|
|
12
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
13
|
+
import { db } from "./db.js";
|
|
14
|
+
import { BROADCAST_CHUNK, enqueueBroadcast, broadcastRecentState } from './broadcast-fanout.js';
|
|
15
|
+
|
|
16
|
+
const stamp = `${Date.now()}`;
|
|
17
|
+
let NET = "";
|
|
18
|
+
|
|
19
|
+
function targets(n: number, netId = NET) {
|
|
20
|
+
return Array.from({ length: n }, (_, i) => ({
|
|
21
|
+
alias: `fan-${i}-${stamp}`,
|
|
22
|
+
node_id: `n_fan_${i}_${stamp}`,
|
|
23
|
+
network_id: netId,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const inboxRows = (netId = NET) =>
|
|
28
|
+
db.get<{ n: number }>("SELECT COUNT(*) AS n FROM inbox WHERE network_id = ?1 AND type = 'broadcast'", [netId])!.n;
|
|
29
|
+
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
const { register } = await import("./auth.js");
|
|
32
|
+
const auth = register(`fan_owner_${stamp}`, "Fan-Owner-Strong-1!", undefined, "tester");
|
|
33
|
+
expect(auth.ok).toBe(true);
|
|
34
|
+
NET = auth.network_id!;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
try { db.run("DELETE FROM inbox WHERE network_id = ?1 AND type = 'broadcast'", [NET]); } catch {}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("#2721 broadcast fan-out is chunked", () => {
|
|
42
|
+
test("逐条入库,条数等于收件人数", async () => {
|
|
43
|
+
const before = inboxRows();
|
|
44
|
+
const res = await enqueueBroadcast(targets(120), "hello", "hub", NET, {
|
|
45
|
+
isActive: () => true,
|
|
46
|
+
notify: () => {},
|
|
47
|
+
yieldBetweenChunks: async () => {},
|
|
48
|
+
});
|
|
49
|
+
expect(res.ids).toHaveLength(120);
|
|
50
|
+
expect(res.delivered).toHaveLength(120);
|
|
51
|
+
expect(inboxRows() - before).toBe(120);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("批间真的让出:⌈120/50⌉ = 3 次", async () => {
|
|
55
|
+
let yields = 0;
|
|
56
|
+
await enqueueBroadcast(targets(120), "hello", "hub", NET, {
|
|
57
|
+
isActive: () => true,
|
|
58
|
+
notify: () => {},
|
|
59
|
+
yieldBetweenChunks: async () => { yields += 1; },
|
|
60
|
+
});
|
|
61
|
+
expect(yields).toBe(Math.ceil(120 / BROADCAST_CHUNK));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("自定义 chunk 生效(10 → 12 批)", async () => {
|
|
65
|
+
let yields = 0;
|
|
66
|
+
await enqueueBroadcast(targets(120), "hello", "hub", NET, {
|
|
67
|
+
isActive: () => true,
|
|
68
|
+
notify: () => {},
|
|
69
|
+
chunkSize: 10,
|
|
70
|
+
yieldBetweenChunks: async () => { yields += 1; },
|
|
71
|
+
});
|
|
72
|
+
expect(yields).toBe(12);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("非 active 收件人:不入库、不推事件", async () => {
|
|
76
|
+
const notified: string[] = [];
|
|
77
|
+
const ts = targets(10);
|
|
78
|
+
const res = await enqueueBroadcast(ts, "hello", "hub", NET, {
|
|
79
|
+
// 只让偶数号 active
|
|
80
|
+
isActive: (alias) => Number(alias.split("-")[1]) % 2 === 0,
|
|
81
|
+
notify: (alias) => notified.push(alias),
|
|
82
|
+
yieldBetweenChunks: async () => {},
|
|
83
|
+
});
|
|
84
|
+
expect(res.ids).toHaveLength(5);
|
|
85
|
+
expect(notified).toHaveLength(5);
|
|
86
|
+
expect(notified.every(a => Number(a.split("-")[1]) % 2 === 0)).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("空收件人列表:不写、不推、不让出", async () => {
|
|
90
|
+
let yields = 0;
|
|
91
|
+
const res = await enqueueBroadcast([], "hello", "hub", NET, {
|
|
92
|
+
isActive: () => true,
|
|
93
|
+
notify: () => {},
|
|
94
|
+
yieldBetweenChunks: async () => { yields += 1; },
|
|
95
|
+
});
|
|
96
|
+
expect(res.ids).toEqual([]);
|
|
97
|
+
expect(yields).toBe(0);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// #2721 —— /health 的 `broadcast` 一格:最近一次广播的时间/人数/批数/耗时。
|
|
102
|
+
describe('broadcastRecentState', () => {
|
|
103
|
+
test('records the last broadcast so a stall can be reconciled afterwards', async () => {
|
|
104
|
+
const targets = Array.from({ length: 7 }, (_, i) => ({ alias: `r${i}`, node_id: null, network_id: 'n1' }));
|
|
105
|
+
await enqueueBroadcast(targets, 'hello', 'hub', 'n1', {
|
|
106
|
+
isActive: () => true,
|
|
107
|
+
notify: () => {},
|
|
108
|
+
yieldBetweenChunks: async () => {},
|
|
109
|
+
chunkSize: 3,
|
|
110
|
+
});
|
|
111
|
+
const rec = broadcastRecentState();
|
|
112
|
+
expect(rec).not.toBeNull();
|
|
113
|
+
expect(rec!.recipients).toBe(7);
|
|
114
|
+
expect(rec!.chunks).toBe(3); // ceil(7/3)
|
|
115
|
+
expect(typeof rec!.took_ms).toBe('number');
|
|
116
|
+
expect(Number.isNaN(Date.parse(rec!.at))).toBe(false);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// 🔴 这条是 2026-10-30 补的:上半句只把 INSERT 摊开,notify 仍然在所有批次之后。
|
|
120
|
+
// 那等于「入库分 3 批、唤醒仍旧同一 tick」—— 而唤醒才是让 Hub 停顿 143.9 秒的原因。
|
|
121
|
+
test("通知与入库同批(不是全部入库完再一起推)", async () => {
|
|
122
|
+
const order: string[] = [];
|
|
123
|
+
const targets = Array.from({ length: 120 }, (_, i) => ({ alias: `a${i}`, node_id: null, network_id: "net_x" }));
|
|
124
|
+
await enqueueBroadcast(targets, "hi", "hub", "net_x", {
|
|
125
|
+
isActive: () => true,
|
|
126
|
+
notify: (alias) => order.push(`n:${alias}`),
|
|
127
|
+
yieldBetweenChunks: async () => { order.push("y"); },
|
|
128
|
+
chunkSize: 50,
|
|
129
|
+
});
|
|
130
|
+
// 结构应为 n×50 y n×50 y n×20 y —— 每一批后面紧跟一个让出,而不是 n×120 全在末尾
|
|
131
|
+
const firstYield = order.indexOf("y");
|
|
132
|
+
expect(firstYield).toBe(50);
|
|
133
|
+
expect(order.filter((x) => x === "y").length).toBe(3);
|
|
134
|
+
// 最后一批的通知必须在最后一次让出之前
|
|
135
|
+
const lastNotify = order.lastIndexOf(order.filter((x) => x.startsWith("n:")).at(-1)!);
|
|
136
|
+
expect(lastNotify).toBeLessThan(order.lastIndexOf("y"));
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("某一条通知抛错:其余收件人照常入库(不能因为推不出去就漏发)", async () => {
|
|
140
|
+
const targets = Array.from({ length: 120 }, (_, i) => ({ alias: `b${i}`, node_id: null, network_id: "net_y" }));
|
|
141
|
+
const { ids } = await enqueueBroadcast(targets, "hi", "hub", "net_y", {
|
|
142
|
+
isActive: () => true,
|
|
143
|
+
notify: (alias) => { if (alias === "b0") throw new Error("sse down"); },
|
|
144
|
+
yieldBetweenChunks: async () => {},
|
|
145
|
+
chunkSize: 50,
|
|
146
|
+
});
|
|
147
|
+
expect(ids.length).toBe(120);
|
|
148
|
+
});
|
|
149
|
+
});
|