@cohortapp/agent-sdk 2.17.0 → 2.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +18 -0
- package/.env.example +18 -5
- package/README.md +1 -0
- package/bin/maestro.mjs +62 -0
- package/docs/guides/billing-console-keys.md +60 -0
- package/docs/guides/front-door-session.md +54 -9
- package/docs/guides/mac-mini.md +20 -25
- package/docs/guides/setup-wizard.md +1 -1
- package/docs/runbooks/fleet-rollout.md +156 -0
- package/docs/runbooks/mac-mini-bootstrap.md +12 -14
- package/lib/action-executor.js +19 -3
- package/lib/budget-guard.mjs +279 -3
- package/lib/channels/base-adapter.mjs +3 -1
- package/lib/channels/contract.mjs +2 -1
- package/lib/channels/inbox-item.mjs +8 -0
- package/lib/claude-bin.mjs +5 -6
- package/lib/cli/doctor-checks.mjs +141 -10
- package/lib/cli/global-setup-extras.mjs +5 -1
- package/lib/cli/inbox.mjs +100 -15
- package/lib/cli/seat-auth.mjs +463 -0
- package/lib/cli/session.mjs +80 -12
- package/lib/collective/capture.mjs +8 -6
- package/lib/collective/global-config.mjs +63 -1
- package/lib/collective/presence.mjs +142 -5
- package/lib/comms/send-gate.mjs +559 -1
- package/lib/diagnostics/alerts.mjs +49 -0
- package/lib/diagnostics/cadence-output-freshness.mjs +288 -0
- package/lib/engine/agents/definitions.mjs +343 -0
- package/lib/engine/agents/persist.mjs +275 -0
- package/lib/engine/agents/runtime.mjs +748 -0
- package/lib/engine/agents/usage.mjs +95 -0
- package/lib/engine/auth-status.mjs +139 -0
- package/lib/engine/budget.mjs +194 -0
- package/lib/engine/cli.mjs +1204 -0
- package/lib/engine/commands/index.mjs +269 -0
- package/lib/engine/context/budget.mjs +219 -0
- package/lib/engine/context/cache.mjs +125 -0
- package/lib/engine/context/child-env.mjs +215 -0
- package/lib/engine/context/compaction.mjs +342 -0
- package/lib/engine/context/images.mjs +90 -0
- package/lib/engine/context/instructions.mjs +327 -0
- package/lib/engine/context/lazy-instructions.mjs +169 -0
- package/lib/engine/context/manager.mjs +182 -0
- package/lib/engine/context/real-path.mjs +91 -0
- package/lib/engine/context/secret-values.mjs +163 -0
- package/lib/engine/context/settings.mjs +274 -0
- package/lib/engine/context/stream-input.mjs +159 -0
- package/lib/engine/guard.mjs +152 -0
- package/lib/engine/hooks.mjs +713 -0
- package/lib/engine/loop.mjs +560 -0
- package/lib/engine/mcp/client.mjs +254 -0
- package/lib/engine/mcp/config.mjs +301 -0
- package/lib/engine/mcp/http.mjs +201 -0
- package/lib/engine/mcp/index.mjs +146 -0
- package/lib/engine/mcp/jsonrpc.mjs +147 -0
- package/lib/engine/mcp/naming.mjs +66 -0
- package/lib/engine/mcp/resources.mjs +89 -0
- package/lib/engine/mcp/results.mjs +133 -0
- package/lib/engine/mcp/stdio.mjs +137 -0
- package/lib/engine/mcp/supervisor.mjs +116 -0
- package/lib/engine/messages.mjs +104 -0
- package/lib/engine/output/json.mjs +164 -0
- package/lib/engine/output/stream-json.mjs +266 -0
- package/lib/engine/permissions.mjs +845 -0
- package/lib/engine/process-identity.mjs +164 -0
- package/lib/engine/process-tree.mjs +551 -0
- package/lib/engine/prompt.mjs +60 -0
- package/lib/engine/session/store.mjs +299 -0
- package/lib/engine/session-runtime/args.mjs +97 -0
- package/lib/engine/session-runtime/host.mjs +143 -0
- package/lib/engine/session-runtime/inbox.mjs +122 -0
- package/lib/engine/session-runtime/notifications.mjs +129 -0
- package/lib/engine/session-runtime/registry.mjs +328 -0
- package/lib/engine/session-runtime/runner.mjs +344 -0
- package/lib/engine/session-runtime/socket.mjs +212 -0
- package/lib/engine/session-runtime/wakeup.mjs +115 -0
- package/lib/engine/skills/index.mjs +321 -0
- package/lib/engine/tools/bash-background.mjs +533 -0
- package/lib/engine/tools/bash.mjs +216 -0
- package/lib/engine/tools/edit.mjs +97 -0
- package/lib/engine/tools/glob.mjs +81 -0
- package/lib/engine/tools/grep.mjs +224 -0
- package/lib/engine/tools/index.mjs +84 -0
- package/lib/engine/tools/list-agents.mjs +32 -0
- package/lib/engine/tools/ls.mjs +127 -0
- package/lib/engine/tools/monitor.mjs +82 -0
- package/lib/engine/tools/notebook-edit.mjs +218 -0
- package/lib/engine/tools/read.mjs +103 -0
- package/lib/engine/tools/schedule-wakeup.mjs +45 -0
- package/lib/engine/tools/schema.mjs +144 -0
- package/lib/engine/tools/send-message.mjs +77 -0
- package/lib/engine/tools/session.mjs +70 -0
- package/lib/engine/tools/todo.mjs +144 -0
- package/lib/engine/tools/toolsearch.mjs +217 -0
- package/lib/engine/tools/walk.mjs +193 -0
- package/lib/engine/tools/web-switch.mjs +31 -0
- package/lib/engine/tools/webfetch-html.mjs +387 -0
- package/lib/engine/tools/webfetch-net.mjs +340 -0
- package/lib/engine/tools/webfetch.mjs +198 -0
- package/lib/engine/tools/websearch.mjs +91 -0
- package/lib/engine/tools/workflow.mjs +95 -0
- package/lib/engine/tools/write.mjs +76 -0
- package/lib/engine/tui/line-editor.mjs +137 -0
- package/lib/engine/tui/render.mjs +86 -0
- package/lib/engine/tui/tui.mjs +274 -0
- package/lib/engine/wire/anthropic-messages.mjs +263 -0
- package/lib/engine/wire/effort.mjs +36 -0
- package/lib/engine/wire/errors.mjs +496 -0
- package/lib/engine/wire/http.mjs +441 -0
- package/lib/engine/wire/index.mjs +76 -0
- package/lib/engine/wire/openai-chat.mjs +332 -0
- package/lib/engine/wire/prompt-cache.mjs +79 -0
- package/lib/engine/wire/search.mjs +140 -0
- package/lib/engine/wire/sse.mjs +114 -0
- package/lib/engine/wire/stall.mjs +349 -0
- package/lib/engine/wire/token-provider.mjs +175 -0
- package/lib/engine/wire/usage.mjs +192 -0
- package/lib/engine/workflow/host.mjs +524 -0
- package/lib/engine/workflow/journal.mjs +188 -0
- package/lib/engine/workflow/json-schema.mjs +171 -0
- package/lib/engine/workflow/meta.mjs +329 -0
- package/lib/engine/workflow/notifications.mjs +52 -0
- package/lib/engine/workflow/runtime.mjs +447 -0
- package/lib/engine/workflow/sandbox.mjs +534 -0
- package/lib/engine/workflow/worker.mjs +141 -0
- package/lib/engine/workflow/worktree.mjs +74 -0
- package/lib/execution/disposition.mjs +1 -1
- package/lib/execution/intake.mjs +10 -0
- package/lib/execution/surface-policy.mjs +15 -0
- package/lib/learning/curator.mjs +8 -6
- package/lib/learning/reflect.mjs +8 -6
- package/lib/model-router/catalog/cohort.yaml +137 -0
- package/lib/model-router/catalog.mjs +118 -1
- package/lib/model-router/failover.mjs +67 -16
- package/lib/model-router/llm-task.mjs +39 -3
- package/lib/model-router/resolve.mjs +89 -3
- package/lib/model-router/spawn.mjs +46 -47
- package/lib/model-router/taxonomy.mjs +126 -4
- package/lib/org/cost-sync.mjs +141 -11
- package/lib/org/inbound/broadcast.mjs +289 -0
- package/lib/org/inbound/collective.mjs +375 -0
- package/lib/org/inbound/directedness.mjs +96 -8
- package/lib/org/inbound/facts.mjs +78 -2
- package/lib/org/inbound/project.mjs +22 -0
- package/lib/org/inbound/surfaces.mjs +14 -0
- package/lib/org/llm-token.mjs +879 -0
- package/lib/org/mesh.mjs +61 -0
- package/lib/org/messaging.mjs +3 -1
- package/lib/org/protocol.checksum +1 -1
- package/lib/org/protocol.mjs +15 -0
- package/lib/org/quota.mjs +520 -0
- package/lib/org/tool-surface.mjs +104 -16
- package/lib/org/ui-parity.mjs +16 -1
- package/lib/org/work-ledger.mjs +37 -6
- package/lib/rate-guard.mjs +114 -1
- package/lib/resource-governor.mjs +41 -6
- package/lib/runtime/adapter.mjs +823 -0
- package/lib/runtime/child-env.mjs +191 -0
- package/lib/runtime/legacy-shell-guard.mjs +97 -0
- package/lib/runtime/seat-engine.mjs +162 -0
- package/lib/session/ask-ledger.mjs +271 -0
- package/lib/session/current-work.mjs +676 -0
- package/lib/session/feed-core.mjs +40 -3
- package/lib/session/launch-args.mjs +56 -4
- package/lib/session/status-summary.mjs +26 -9
- package/lib/session/upgrade-notice.mjs +42 -0
- package/lib/setup/claude-probe.mjs +117 -13
- package/lib/setup/enrich.mjs +13 -10
- package/lib/setup/sections/model.mjs +39 -13
- package/lib/telemetry/collect.mjs +208 -9
- package/lib/upgrade/ignored-drift.mjs +105 -0
- package/lib/voice/post-call-brief.mjs +30 -17
- package/package.json +13 -3
- package/plugins/maestro-skills/skills/board-work.md +5 -0
- package/plugins/maestro-skills/skills/inbound-triage.md +56 -15
- package/plugins/maestro-skills/skills/main-session.md +18 -7
- package/scripts/ci/check-tarball-fidelity.mjs +126 -2
- package/scripts/ci/run-tests.mjs +47 -19
- package/scripts/cohort-llm/api-key-helper.mjs +92 -0
- package/scripts/collective/hook-runner.mjs +29 -2
- package/scripts/continuous-monitor.sh +13 -0
- package/scripts/cost/track-claude-usage.mjs +15 -0
- package/scripts/daemon/agent-daemon.mjs +408 -20
- package/scripts/daemon/assurance.mjs +48 -12
- package/scripts/daemon/cadence-consumer.mjs +218 -68
- package/scripts/daemon/cadence-handlers.mjs +73 -4
- package/scripts/daemon/classifier.mjs +75 -26
- package/scripts/daemon/context-compiler.mjs +51 -37
- package/scripts/daemon/deliver.mjs +30 -1
- package/scripts/daemon/dispatcher.mjs +595 -149
- package/scripts/daemon/health.mjs +14 -1
- package/scripts/daemon/maestro-daemon.mjs +11 -0
- package/scripts/daemon/prompt-builder.mjs +24 -0
- package/scripts/daemon/responder.mjs +246 -79
- package/scripts/daemon/sdk-version.mjs +98 -16
- package/scripts/eval/probe-gateway.mjs +635 -0
- package/scripts/eval/replay/extract.mjs +270 -0
- package/scripts/eval/replay/grade.mjs +260 -0
- package/scripts/eval/replay/lib/config.mjs +50 -0
- package/scripts/eval/replay/lib/effects.mjs +65 -0
- package/scripts/eval/replay/lib/fixture.mjs +188 -0
- package/scripts/eval/replay/lib/judge.mjs +72 -0
- package/scripts/eval/replay/lib/redact.mjs +136 -0
- package/scripts/eval/replay/lib/sandbox.mjs +170 -0
- package/scripts/eval/replay/lib/schema-check.mjs +63 -0
- package/scripts/eval/replay/lib/transcript.mjs +76 -0
- package/scripts/eval/replay/mcp-replay-stub.mjs +101 -0
- package/scripts/eval/replay/report.mjs +185 -0
- package/scripts/eval/replay/run.mjs +404 -0
- package/scripts/fleet/rollout.mjs +1094 -0
- package/scripts/hooks/pre-send-audit.sh +36 -245
- package/scripts/hooks/pre-write-yaml-validate.mjs +275 -0
- package/scripts/hooks/validate-state-yaml.sh +190 -0
- package/scripts/huddle/huddle-llm.mjs +361 -0
- package/scripts/huddle/huddle-server.mjs +46 -121
- package/scripts/local-triggers/autoupdate.sh +448 -78
- package/scripts/local-triggers/run-trigger.sh +13 -0
- package/scripts/maintenance/pin-integrity.mjs +364 -0
- package/scripts/poll-slack-events.sh +41 -9
- package/scripts/poller/slack-socket-mode.mjs +28 -3
- package/scripts/session/supervisor.mjs +80 -13
- package/scripts/spawn-session.sh +13 -0
- package/bin/maestro.test.mjs +0 -1574
- package/lib/action-executor.test.mjs +0 -871
- package/lib/archetype.test.mjs +0 -132
- package/lib/assurance/plan-note.test.mjs +0 -234
- package/lib/assurance/room-budget.test.mjs +0 -486
- package/lib/assurance/tier.test.mjs +0 -174
- package/lib/autonomy.test.mjs +0 -66
- package/lib/backlog.test.mjs +0 -302
- package/lib/backup/policy.test.mjs +0 -305
- package/lib/budget-escalate.test.mjs +0 -232
- package/lib/budget-guard.envelope.test.mjs +0 -476
- package/lib/budget-guard.test.mjs +0 -427
- package/lib/cadence-bus-requeue.test.mjs +0 -83
- package/lib/cadence-bus-schedule.test.mjs +0 -194
- package/lib/cadence-bus.test.mjs +0 -720
- package/lib/cadences.test.mjs +0 -230
- package/lib/capability/inventory.test.mjs +0 -232
- package/lib/capability.test.mjs +0 -78
- package/lib/channels/base-adapter.test.mjs +0 -590
- package/lib/channels/channels.test.mjs +0 -371
- package/lib/channels/contract.test.mjs +0 -162
- package/lib/channels/inbox-item.test.mjs +0 -368
- package/lib/channels/orgmail/adapter.test.mjs +0 -448
- package/lib/channels/pairing.test.mjs +0 -270
- package/lib/channels/repeat-suppressor.test.mjs +0 -134
- package/lib/channels/slack-adapter.test.mjs +0 -212
- package/lib/channels/telegram-adapter.test.mjs +0 -306
- package/lib/channels/voice/adapter.test.mjs +0 -278
- package/lib/channels/whatsapp/adapter-baileys.test.mjs +0 -359
- package/lib/channels/whatsapp/baileys-typing.test.mjs +0 -154
- package/lib/charter.test.mjs +0 -89
- package/lib/claude-bin.test.mjs +0 -131
- package/lib/cli/board.test.mjs +0 -227
- package/lib/cli/design.test.mjs +0 -270
- package/lib/cli/doctor-checks.test.mjs +0 -336
- package/lib/cli/global-setup-extras.test.mjs +0 -462
- package/lib/cli/inbox.test.mjs +0 -230
- package/lib/cli/session-ack.test.mjs +0 -63
- package/lib/cli/session.test.mjs +0 -613
- package/lib/collective/capture.test.mjs +0 -121
- package/lib/collective/cards.test.mjs +0 -114
- package/lib/collective/config.test.mjs +0 -123
- package/lib/collective/global-config.test.mjs +0 -220
- package/lib/collective/global-skills.test.mjs +0 -126
- package/lib/collective/presence.test.mjs +0 -95
- package/lib/collective/recall.test.mjs +0 -116
- package/lib/collective/vendor-skills.test.mjs +0 -306
- package/lib/comms/send-gate.test.mjs +0 -770
- package/lib/comms.test.mjs +0 -41
- package/lib/context/budget.test.mjs +0 -252
- package/lib/context/history-scope.test.mjs +0 -79
- package/lib/cost/ledger-row.test.mjs +0 -183
- package/lib/design/design-md.test.mjs +0 -318
- package/lib/design/fixtures/DESIGN.golden.md +0 -238
- package/lib/design/fixtures/PRODUCT.golden.md +0 -67
- package/lib/design/fixtures/foundation.json +0 -133
- package/lib/design/refresh-gate.test.mjs +0 -144
- package/lib/design/write.test.mjs +0 -241
- package/lib/diagnostics/alerts.test.mjs +0 -318
- package/lib/diagnostics/backup-freshness.test.mjs +0 -185
- package/lib/diagnostics/counters.test.mjs +0 -206
- package/lib/diagnostics/events.test.mjs +0 -290
- package/lib/diagnostics/otel.test.mjs +0 -196
- package/lib/diagnostics/trace.test.mjs +0 -251
- package/lib/env-compat.test.mjs +0 -104
- package/lib/execution/disposition.test.mjs +0 -553
- package/lib/execution/drive.test.mjs +0 -270
- package/lib/execution/effects.test.mjs +0 -344
- package/lib/execution/intake.test.mjs +0 -389
- package/lib/execution/journal.test.mjs +0 -261
- package/lib/execution/match.test.mjs +0 -235
- package/lib/execution/pipeline.test.mjs +0 -392
- package/lib/execution/route.test.mjs +0 -186
- package/lib/execution/surface-policy.test.mjs +0 -162
- package/lib/fs-atomic.test.mjs +0 -72
- package/lib/fs-ownership.test.mjs +0 -158
- package/lib/goals/admission.test.mjs +0 -164
- package/lib/goals/classify.test.mjs +0 -167
- package/lib/goals/collaborate.test.mjs +0 -336
- package/lib/goals/gaps.test.mjs +0 -284
- package/lib/goals/loop.test.mjs +0 -845
- package/lib/hooks/bus.test.mjs +0 -387
- package/lib/identity/persona.test.mjs +0 -142
- package/lib/kpi-sensors.test.mjs +0 -278
- package/lib/kpi.test.mjs +0 -244
- package/lib/learning/config.test.mjs +0 -75
- package/lib/learning/counters.test.mjs +0 -69
- package/lib/learning/curator-consolidate.test.mjs +0 -238
- package/lib/learning/curator.test.mjs +0 -106
- package/lib/learning/reflect.test.mjs +0 -0
- package/lib/learning/session-index.test.mjs +0 -125
- package/lib/learning/skill-writer.test.mjs +0 -210
- package/lib/mandate/audit.test.mjs +0 -195
- package/lib/mandate/contract.test.mjs +0 -185
- package/lib/mandate/derive.test.mjs +0 -274
- package/lib/mandate/model.test.mjs +0 -164
- package/lib/mandate/refresh.test.mjs +0 -389
- package/lib/mcp/server.test.mjs +0 -426
- package/lib/model-router/auth-profiles.test.mjs +0 -580
- package/lib/model-router/catalog.test.mjs +0 -385
- package/lib/model-router/economics.test.mjs +0 -438
- package/lib/model-router/failover.test.mjs +0 -439
- package/lib/model-router/health.test.mjs +0 -338
- package/lib/model-router/integration-coverage.test.mjs +0 -831
- package/lib/model-router/integration.test.mjs +0 -564
- package/lib/model-router/ledger.test.mjs +0 -415
- package/lib/model-router/llm-task.test.mjs +0 -392
- package/lib/model-router/org-credentials.test.mjs +0 -265
- package/lib/model-router/pricing-refresh.test.mjs +0 -286
- package/lib/model-router/reconcile.test.mjs +0 -316
- package/lib/model-router/repair.test.mjs +0 -180
- package/lib/model-router/spawn.test.mjs +0 -446
- package/lib/model-router/taxonomy.test.mjs +0 -410
- package/lib/model-router.test.mjs +0 -1207
- package/lib/org/activity.test.mjs +0 -134
- package/lib/org/approvals.test.mjs +0 -216
- package/lib/org/awareness.test.mjs +0 -159
- package/lib/org/board-mine-cache.test.mjs +0 -53
- package/lib/org/board.test.mjs +0 -187
- package/lib/org/bootstrap-context.test.mjs +0 -153
- package/lib/org/client.test.mjs +0 -1206
- package/lib/org/cohort-client.test.mjs +0 -126
- package/lib/org/cost-sync.test.mjs +0 -153
- package/lib/org/doctor.test.mjs +0 -346
- package/lib/org/engagement-ledger.test.mjs +0 -112
- package/lib/org/engagement.test.mjs +0 -739
- package/lib/org/handoff.test.mjs +0 -269
- package/lib/org/inbound/directedness.test.mjs +0 -668
- package/lib/org/inbound/facts.test.mjs +0 -471
- package/lib/org/inbound/hydrate.test.mjs +0 -908
- package/lib/org/inbound/index.test.mjs +0 -429
- package/lib/org/inbound/project.test.mjs +0 -287
- package/lib/org/integration-tools.test.mjs +0 -160
- package/lib/org/keys.test.mjs +0 -92
- package/lib/org/knowledge.test.mjs +0 -326
- package/lib/org/leases.test.mjs +0 -235
- package/lib/org/mesh-directives.test.mjs +0 -110
- package/lib/org/mesh-integration.test.mjs +0 -127
- package/lib/org/mesh.test.mjs +0 -400
- package/lib/org/messaging.test.mjs +0 -471
- package/lib/org/param-contract.test.mjs +0 -477
- package/lib/org/policy.test.mjs +0 -237
- package/lib/org/protocol.checksum.test.mjs +0 -90
- package/lib/org/protocol.test.mjs +0 -323
- package/lib/org/push.test.mjs +0 -792
- package/lib/org/registry.test.mjs +0 -100
- package/lib/org/resource-tools.test.mjs +0 -361
- package/lib/org/tool-access.test.mjs +0 -144
- package/lib/org/tool-surface-integration.test.mjs +0 -120
- package/lib/org/tool-surface.test.mjs +0 -1268
- package/lib/org/typing.test.mjs +0 -291
- package/lib/org/ui-parity.test.mjs +0 -560
- package/lib/org/verify.test.mjs +0 -194
- package/lib/org/work-ledger.test.mjs +0 -273
- package/lib/plan/adoption-e2e.test.mjs +0 -366
- package/lib/plan/budget-enforcement.test.mjs +0 -400
- package/lib/plan/compile.test.mjs +0 -382
- package/lib/plan/emit.test.mjs +0 -269
- package/lib/plan/explain.test.mjs +0 -188
- package/lib/prompts/parallelism.test.mjs +0 -177
- package/lib/rag/rag.test.mjs +0 -505
- package/lib/rate-guard.test.mjs +0 -272
- package/lib/reactive-gate.test.mjs +0 -57
- package/lib/render.test.mjs +0 -68
- package/lib/resource-governor.test.mjs +0 -488
- package/lib/scheduling/dynamic-jobs.test.mjs +0 -344
- package/lib/scheduling/jitter.test.mjs +0 -140
- package/lib/secrets/broker.test.mjs +0 -280
- package/lib/secrets/providers.test.mjs +0 -274
- package/lib/security/audit-engine.test.mjs +0 -424
- package/lib/security/coerce-args.test.mjs +0 -281
- package/lib/security/dangerous-tools.test.mjs +0 -68
- package/lib/security/external-content.test.mjs +0 -84
- package/lib/security/redact.test.mjs +0 -441
- package/lib/security/secret-equal.test.mjs +0 -55
- package/lib/session/config.test.mjs +0 -92
- package/lib/session/feed-core.test.mjs +0 -198
- package/lib/session/first-run.test.mjs +0 -121
- package/lib/session/frontdoor.test.mjs +0 -205
- package/lib/session/handoffs.test.mjs +0 -183
- package/lib/session/identity.test.mjs +0 -180
- package/lib/session/inbox-claims.test.mjs +0 -286
- package/lib/session/launch-args.test.mjs +0 -157
- package/lib/session/liveness.test.mjs +0 -100
- package/lib/session/status-summary.test.mjs +0 -118
- package/lib/session-permissions.test.mjs +0 -120
- package/lib/setup/claude-probe.test.mjs +0 -187
- package/lib/setup/completeness.test.mjs +0 -110
- package/lib/setup/context-pack.test.mjs +0 -89
- package/lib/setup/enrich.test.mjs +0 -115
- package/lib/setup/enroll-from-cohort.test.mjs +0 -300
- package/lib/setup/integration.test.mjs +0 -162
- package/lib/setup/io.test.mjs +0 -77
- package/lib/setup/runner.test.mjs +0 -132
- package/lib/setup/sections/identity.test.mjs +0 -234
- package/lib/setup/sections/inventory.test.mjs +0 -198
- package/lib/setup/sections/learning.test.mjs +0 -81
- package/lib/setup/sections/mandate.test.mjs +0 -388
- package/lib/setup/sections/messaging.test.mjs +0 -127
- package/lib/setup/sections/model.test.mjs +0 -240
- package/lib/setup/sections/org.test.mjs +0 -346
- package/lib/setup/sections/orgmail.test.mjs +0 -118
- package/lib/setup/sections/recovery.test.mjs +0 -98
- package/lib/setup/sections/subagents.test.mjs +0 -429
- package/lib/setup/sections/verify.test.mjs +0 -175
- package/lib/setup/sot.test.mjs +0 -81
- package/lib/setup/state.test.mjs +0 -115
- package/lib/singleton.test.mjs +0 -151
- package/lib/subagents/cli.test.mjs +0 -389
- package/lib/subagents/client.test.mjs +0 -309
- package/lib/subagents/gap.test.mjs +0 -234
- package/lib/subagents/lock.test.mjs +0 -248
- package/lib/subagents/manifest.test.mjs +0 -175
- package/lib/subagents/refs.test.mjs +0 -204
- package/lib/subagents/resolve.test.mjs +0 -422
- package/lib/subagents/schema.test.mjs +0 -328
- package/lib/telemetry/alerts.test.mjs +0 -109
- package/lib/telemetry/collect.test.mjs +0 -1274
- package/lib/tool-definitions-integration.test.mjs +0 -83
- package/lib/tool-definitions.test.mjs +0 -437
- package/lib/upgrade/global-refresh.test.mjs +0 -65
- package/lib/upgrade/launchd-reconcile.test.mjs +0 -272
- package/lib/upgrade/post-steps.test.mjs +0 -200
- package/lib/upgrade/verify.test.mjs +0 -164
- package/lib/util/fetch-timeout.test.mjs +0 -202
- package/lib/util/reconnect.test.mjs +0 -369
- package/lib/util/unhandled.test.mjs +0 -216
- package/lib/voice/outbound.test.mjs +0 -69
- package/lib/voice/session-rotation.test.mjs +0 -114
- package/lib/voice/stt.test.mjs +0 -226
- package/lib/voice/voice.test.mjs +0 -990
- package/scripts/cadence/enqueue-cadence-tick.test.mjs +0 -187
- package/scripts/ci/check-docs-accuracy.test.mjs +0 -409
- package/scripts/ci/check-durable-write-seam.test.mjs +0 -90
- package/scripts/ci/check-no-build-artifacts.test.mjs +0 -71
- package/scripts/ci/check-no-residual-identity.test.mjs +0 -202
- package/scripts/ci/check-skill-packs.test.mjs +0 -495
- package/scripts/ci/check-subagent-frontmatter.test.mjs +0 -124
- package/scripts/ci/check.test.mjs +0 -194
- package/scripts/ci/conformance-org-api.test.mjs +0 -425
- package/scripts/cloud-relay/voice/relay-identity.test.mjs +0 -96
- package/scripts/collective/hook-runner.test.mjs +0 -173
- package/scripts/cost/fleet-digest.test.mjs +0 -207
- package/scripts/cost/track-claude-usage-pricing.test.mjs +0 -183
- package/scripts/cost/track-claude-usage.test.mjs +0 -148
- package/scripts/daemon/agent-daemon-board-mine.test.mjs +0 -96
- package/scripts/daemon/agent-daemon-design.test.mjs +0 -238
- package/scripts/daemon/agent-daemon-frontdoor.test.mjs +0 -60
- package/scripts/daemon/agent-daemon.test.mjs +0 -995
- package/scripts/daemon/assurance-e2e.test.mjs +0 -613
- package/scripts/daemon/assurance.test.mjs +0 -1791
- package/scripts/daemon/board-mirror.test.mjs +0 -165
- package/scripts/daemon/cadence-consumer-frontdoor.test.mjs +0 -393
- package/scripts/daemon/cadence-consumer-governance.test.mjs +0 -276
- package/scripts/daemon/cadence-consumer.test.mjs +0 -776
- package/scripts/daemon/cadence-handlers.test.mjs +0 -837
- package/scripts/daemon/classifier-identity.test.mjs +0 -137
- package/scripts/daemon/classifier.test.mjs +0 -266
- package/scripts/daemon/classify-kind.test.mjs +0 -40
- package/scripts/daemon/context-compiler.test.mjs +0 -406
- package/scripts/daemon/deliver.test.mjs +0 -564
- package/scripts/daemon/dispatcher-cooldown.test.mjs +0 -122
- package/scripts/daemon/dispatcher-governance.test.mjs +0 -1013
- package/scripts/daemon/dispatcher-resume.test.mjs +0 -166
- package/scripts/daemon/dispatcher-session-continuity.test.mjs +0 -365
- package/scripts/daemon/execution-ladder.test.mjs +0 -470
- package/scripts/daemon/goal-steward-cadence.test.mjs +0 -312
- package/scripts/daemon/inbox-deferral-session.test.mjs +0 -49
- package/scripts/daemon/inbox-deferral.test.mjs +0 -336
- package/scripts/daemon/inbox-wake.test.mjs +0 -199
- package/scripts/daemon/integration.test.mjs +0 -149
- package/scripts/daemon/lib/self-echo.test.mjs +0 -153
- package/scripts/daemon/lib/session-router.test.mjs +0 -554
- package/scripts/daemon/prompt-builder-preamble.test.mjs +0 -210
- package/scripts/daemon/prompt-builder.test.mjs +0 -556
- package/scripts/daemon/responder-cost.test.mjs +0 -68
- package/scripts/daemon/responder-history.test.mjs +0 -221
- package/scripts/daemon/sdk-version.test.mjs +0 -31
- package/scripts/daemon/session-lock.test.mjs +0 -252
- package/scripts/daemon/session-outcomes.test.mjs +0 -533
- package/scripts/daemon/typing-registry.test.mjs +0 -102
- package/scripts/hooks/pre-send-audit.test.mjs +0 -354
- package/scripts/huddle/huddle-prompt.test.mjs +0 -176
- package/scripts/local-triggers/autoupdate.test.mjs +0 -518
- package/scripts/local-triggers/generate-plists.test.mjs +0 -456
- package/scripts/media-generation/brand-clause.test.mjs +0 -135
- package/scripts/org/send-orgmail.first-contact.test.mjs +0 -102
- package/scripts/poller/inbox-privilege-injection.test.mjs +0 -167
- package/scripts/poller/inbox-scan-poller.test.mjs +0 -295
- package/scripts/poller/lib/cloud-relay-dedup.test.mjs +0 -133
- package/scripts/poller/slack-socket-mode.test.mjs +0 -805
- package/scripts/poller-launchd/install.test.mjs +0 -243
- package/scripts/restore-from-backup.test.mjs +0 -181
- package/scripts/session/feed.test.mjs +0 -196
- package/scripts/session/supervisor-sh.test.mjs +0 -218
- package/scripts/session/supervisor.test.mjs +0 -482
- package/scripts/setup/configure-macos.test.mjs +0 -306
- package/scripts/setup/gen-subagent-manifest.test.mjs +0 -124
- package/scripts/setup/generate-agent-package-json.test.mjs +0 -143
- package/scripts/setup/generate-capability.test.mjs +0 -134
- package/scripts/setup/init-agent.test.mjs +0 -370
- package/scripts/setup/init-skill-marketplace.test.mjs +0 -193
- package/scripts/vendor/sync-skill-packs.test.mjs +0 -103
- package/scripts/watchdog/memory-watchdog.test.mjs +0 -64
|
@@ -1,770 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for lib/comms/send-gate.mjs — the shared outbound send-gate chokepoint.
|
|
3
|
-
*
|
|
4
|
-
* Covers (gaps-product-quality P0-3):
|
|
5
|
-
* - every banned phrase / AI-tell opener blocks
|
|
6
|
-
* - AI-disclosure: a concealed first-contact message under a disclose-always
|
|
7
|
-
* posture blocks; a denial-of-AI ("I'm not a bot") blocks under any posture
|
|
8
|
-
* - information-barrier wall blocks a walled topic to a matching recipient
|
|
9
|
-
* - benign internal + external messages pass
|
|
10
|
-
* - unreadable policy fails CLOSED for external, OPEN for internal
|
|
11
|
-
* - recipient allowlist (opt-in)
|
|
12
|
-
*
|
|
13
|
-
* The filesystem reader is injected so every branch (including "unreadable
|
|
14
|
-
* policy") is driven without touching disk.
|
|
15
|
-
*
|
|
16
|
-
* @module lib/comms/send-gate.test
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { describe, it } from "node:test";
|
|
20
|
-
import assert from "node:assert/strict";
|
|
21
|
-
import { mkdtempSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
|
|
22
|
-
import { join } from "node:path";
|
|
23
|
-
import { tmpdir } from "node:os";
|
|
24
|
-
import {
|
|
25
|
-
screenOutbound,
|
|
26
|
-
screenBannedPhrases,
|
|
27
|
-
screenPersona,
|
|
28
|
-
screenDisclosure,
|
|
29
|
-
screenBarriers,
|
|
30
|
-
screenAllowlist,
|
|
31
|
-
classifyRecipient,
|
|
32
|
-
BANNED_SUBSTRINGS,
|
|
33
|
-
BANNED_OPENERS,
|
|
34
|
-
} from "./send-gate.mjs";
|
|
35
|
-
|
|
36
|
-
/* ─── fixtures ─────────────────────────────────────────────────────────────
|
|
37
|
-
* A minimal but realistic ai-disclosure.yaml and information-barriers.yaml.
|
|
38
|
-
* The disclosure file mirrors the real one's resolution semantics: EU →
|
|
39
|
-
* disclose-always, default → disclose-always, internal-style on-ask posture
|
|
40
|
-
* available for non-first-contact testing.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
const DISCLOSURE_YAML = `
|
|
44
|
-
version: 1
|
|
45
|
-
invariant:
|
|
46
|
-
answer_truthfully_if_asked: true
|
|
47
|
-
posture:
|
|
48
|
-
disclose-always:
|
|
49
|
-
proactive_disclosure: true
|
|
50
|
-
machine_readable_marking: true
|
|
51
|
-
disclose-on-ask:
|
|
52
|
-
proactive_disclosure: false
|
|
53
|
-
machine_readable_marking: true
|
|
54
|
-
concealed-where-legal:
|
|
55
|
-
proactive_disclosure: false
|
|
56
|
-
machine_readable_marking: false
|
|
57
|
-
requires_sign_off: true
|
|
58
|
-
default_posture: disclose-always
|
|
59
|
-
governance:
|
|
60
|
-
sign_off:
|
|
61
|
-
required_for: [concealed-where-legal]
|
|
62
|
-
approver: null
|
|
63
|
-
jurisdictions: []
|
|
64
|
-
jurisdictions:
|
|
65
|
-
EU:
|
|
66
|
-
posture: disclose-always
|
|
67
|
-
US-CA:
|
|
68
|
-
posture: disclose-on-ask
|
|
69
|
-
US-NV:
|
|
70
|
-
posture: concealed-where-legal
|
|
71
|
-
default:
|
|
72
|
-
posture: disclose-always
|
|
73
|
-
resolution:
|
|
74
|
-
unsigned_concealed_posture: disclose-always
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
const BARRIERS_YAML = `
|
|
78
|
-
domains:
|
|
79
|
-
financial:
|
|
80
|
-
default_sensitivity: high
|
|
81
|
-
barriers:
|
|
82
|
-
- name: partner-wall
|
|
83
|
-
recipient_pattern: "@partnerco\\\\.com$"
|
|
84
|
-
blocked_topics:
|
|
85
|
-
- "cap table"
|
|
86
|
-
- "acquisition target"
|
|
87
|
-
reason: "PartnerCo must not see Northwind cap table / M&A pipeline"
|
|
88
|
-
- name: external-financials
|
|
89
|
-
recipient_class: external
|
|
90
|
-
blocked_topics:
|
|
91
|
-
- "runway"
|
|
92
|
-
`;
|
|
93
|
-
|
|
94
|
-
/** Build an injectable fs over an in-memory map of relPath → contents|null. */
|
|
95
|
-
function memFs(files) {
|
|
96
|
-
return {
|
|
97
|
-
existsSync: (p) => {
|
|
98
|
-
for (const [rel, val] of Object.entries(files)) {
|
|
99
|
-
if (p.endsWith(rel)) return val !== null && val !== undefined;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
},
|
|
103
|
-
readFileSync: (p) => {
|
|
104
|
-
for (const [rel, val] of Object.entries(files)) {
|
|
105
|
-
if (p.endsWith(rel)) {
|
|
106
|
-
if (val === null || val === undefined) {
|
|
107
|
-
const e = new Error("EACCES");
|
|
108
|
-
e.code = "EACCES";
|
|
109
|
-
throw e;
|
|
110
|
-
}
|
|
111
|
-
return val;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const e = new Error("ENOENT");
|
|
115
|
-
e.code = "ENOENT";
|
|
116
|
-
throw e;
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const ROOT = "/repo";
|
|
122
|
-
const GOOD_FILES = {
|
|
123
|
-
"policies/ai-disclosure.yaml": DISCLOSURE_YAML,
|
|
124
|
-
"policies/information-barriers.yaml": BARRIERS_YAML,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/* ─── banned phrases ───────────────────────────────────────────────────────*/
|
|
128
|
-
|
|
129
|
-
describe("screenBannedPhrases", () => {
|
|
130
|
-
for (const phrase of BANNED_SUBSTRINGS) {
|
|
131
|
-
it(`blocks banned substring: ${phrase}`, () => {
|
|
132
|
-
const reason = screenBannedPhrases(`Hi there. ${phrase} so let's go.`);
|
|
133
|
-
assert.ok(reason, `expected a block for "${phrase}"`);
|
|
134
|
-
assert.match(reason, /banned AI-tell phrase/);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
for (const opener of BANNED_OPENERS) {
|
|
139
|
-
it(`blocks banned opener at message start: ${opener}`, () => {
|
|
140
|
-
const reason = screenBannedPhrases(`${opener} Here we go.`);
|
|
141
|
-
assert.ok(reason);
|
|
142
|
-
assert.match(reason, /banned filler opener/);
|
|
143
|
-
});
|
|
144
|
-
it(`blocks banned opener at line start: ${opener}`, () => {
|
|
145
|
-
const reason = screenBannedPhrases(`First line.\n${opener} second.`);
|
|
146
|
-
assert.ok(reason);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
it("allows benign prose with no AI-tells", () => {
|
|
151
|
-
assert.equal(screenBannedPhrases("In progress — only blocker is DBA approval."), null);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("does not block 'absolutely' mid-sentence (opener-only rule)", () => {
|
|
155
|
-
assert.equal(screenBannedPhrases("That is absolutely the right call."), null);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("is case-insensitive", () => {
|
|
159
|
-
assert.ok(screenBannedPhrases("AS AN AI, I cannot do that."));
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
/* ─── end-to-end: banned phrase blocks via screenOutbound ──────────────────*/
|
|
164
|
-
|
|
165
|
-
describe("screenOutbound — banned phrases", () => {
|
|
166
|
-
it("blocks a message containing a banned phrase (external)", async () => {
|
|
167
|
-
const res = await screenOutbound({
|
|
168
|
-
channel: "email",
|
|
169
|
-
recipient: "graham@kpm.com",
|
|
170
|
-
text: "I'd be happy to set up a call.",
|
|
171
|
-
agentRoot: ROOT,
|
|
172
|
-
fs: memFs(GOOD_FILES),
|
|
173
|
-
});
|
|
174
|
-
assert.equal(res.allow, false);
|
|
175
|
-
assert.match(res.reason, /banned AI-tell phrase/);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it("blocks banned phrase even for internal recipients", async () => {
|
|
179
|
-
const res = await screenOutbound({
|
|
180
|
-
channel: "slack",
|
|
181
|
-
recipient: "C0123456",
|
|
182
|
-
text: "As an AI, I think we should ship.",
|
|
183
|
-
agentRoot: ROOT,
|
|
184
|
-
fs: memFs(GOOD_FILES),
|
|
185
|
-
});
|
|
186
|
-
assert.equal(res.allow, false);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
/* ─── disclosure ───────────────────────────────────────────────────────────*/
|
|
191
|
-
|
|
192
|
-
describe("screenDisclosure (unit)", () => {
|
|
193
|
-
const policy = {
|
|
194
|
-
posture: {
|
|
195
|
-
"disclose-always": { proactive_disclosure: true },
|
|
196
|
-
"disclose-on-ask": { proactive_disclosure: false },
|
|
197
|
-
},
|
|
198
|
-
default_posture: "disclose-always",
|
|
199
|
-
jurisdictions: { EU: { posture: "disclose-always" }, "US-CA": { posture: "disclose-on-ask" }, default: { posture: "disclose-always" } },
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
it("blocks a concealed first-contact message under disclose-always", () => {
|
|
203
|
-
const r = screenDisclosure("Hi, can we move the meeting to 3pm?", {
|
|
204
|
-
policy,
|
|
205
|
-
jurisdiction: "EU",
|
|
206
|
-
firstContact: true,
|
|
207
|
-
});
|
|
208
|
-
assert.ok(r);
|
|
209
|
-
assert.match(r, /proactive disclosure/);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it("allows a first-contact message that discloses AI nature", () => {
|
|
213
|
-
const r = screenDisclosure(
|
|
214
|
-
"Hi — I'm an AI assistant working on behalf of Alex. Can we move to 3pm?",
|
|
215
|
-
{ policy, jurisdiction: "EU", firstContact: true },
|
|
216
|
-
);
|
|
217
|
-
assert.equal(r, null);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("does not require disclosure on a non-first-contact reply", () => {
|
|
221
|
-
const r = screenDisclosure("Sounds good, 3pm works.", {
|
|
222
|
-
policy,
|
|
223
|
-
jurisdiction: "EU",
|
|
224
|
-
firstContact: false,
|
|
225
|
-
});
|
|
226
|
-
assert.equal(r, null);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("does not require proactive disclosure under disclose-on-ask", () => {
|
|
230
|
-
const r = screenDisclosure("Sure, let's do 3pm.", {
|
|
231
|
-
policy,
|
|
232
|
-
jurisdiction: "US-CA",
|
|
233
|
-
firstContact: true,
|
|
234
|
-
});
|
|
235
|
-
assert.equal(r, null);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("blocks an explicit denial of AI nature under ANY posture (invariant)", () => {
|
|
239
|
-
const r = screenDisclosure("No, I'm not a bot, I'm a real person.", {
|
|
240
|
-
policy,
|
|
241
|
-
jurisdiction: "US-CA", // even the on-ask posture cannot relax the invariant
|
|
242
|
-
firstContact: false,
|
|
243
|
-
});
|
|
244
|
-
assert.ok(r);
|
|
245
|
-
assert.match(r, /invariant/);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it("blocks denial even with no policy loaded (embedded invariant list)", () => {
|
|
249
|
-
const r = screenDisclosure("I am not an AI.", { policy: null });
|
|
250
|
-
assert.ok(r);
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it("collapses unsigned concealed-where-legal to disclose-always", () => {
|
|
254
|
-
const concealedPolicy = {
|
|
255
|
-
posture: {
|
|
256
|
-
"disclose-always": { proactive_disclosure: true },
|
|
257
|
-
"concealed-where-legal": { proactive_disclosure: false },
|
|
258
|
-
},
|
|
259
|
-
default_posture: "disclose-always",
|
|
260
|
-
governance: { sign_off: { approver: null, jurisdictions: [] } },
|
|
261
|
-
jurisdictions: { "US-NV": { posture: "concealed-where-legal" } },
|
|
262
|
-
};
|
|
263
|
-
const r = screenDisclosure("Hi, moving the meeting to 3pm.", {
|
|
264
|
-
policy: concealedPolicy,
|
|
265
|
-
jurisdiction: "US-NV",
|
|
266
|
-
firstContact: true,
|
|
267
|
-
});
|
|
268
|
-
assert.ok(r, "unsigned concealed posture must fail safe to disclose-always");
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe("screenOutbound — disclosure", () => {
|
|
273
|
-
it("blocks a concealed first-contact external EU message", async () => {
|
|
274
|
-
const res = await screenOutbound({
|
|
275
|
-
channel: "email",
|
|
276
|
-
recipient: "client@example.eu",
|
|
277
|
-
text: "Following up on the contract — can we sign Friday?",
|
|
278
|
-
agentRoot: ROOT,
|
|
279
|
-
jurisdiction: "EU",
|
|
280
|
-
firstContact: true,
|
|
281
|
-
fs: memFs(GOOD_FILES),
|
|
282
|
-
});
|
|
283
|
-
assert.equal(res.allow, false);
|
|
284
|
-
assert.match(res.reason, /disclosure/i);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("blocks a denial of AI nature regardless of jurisdiction", async () => {
|
|
288
|
-
const res = await screenOutbound({
|
|
289
|
-
channel: "whatsapp",
|
|
290
|
-
recipient: "+15551234567",
|
|
291
|
-
text: "Haha no, I'm a real person, not a bot.",
|
|
292
|
-
agentRoot: ROOT,
|
|
293
|
-
jurisdiction: "US-CA",
|
|
294
|
-
firstContact: false,
|
|
295
|
-
fs: memFs(GOOD_FILES),
|
|
296
|
-
});
|
|
297
|
-
assert.equal(res.allow, false);
|
|
298
|
-
assert.match(res.reason, /invariant/);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
/* ─── information barriers ─────────────────────────────────────────────────*/
|
|
303
|
-
|
|
304
|
-
describe("screenBarriers (unit)", () => {
|
|
305
|
-
let policy;
|
|
306
|
-
it("loads the barriers fixture for unit checks", async () => {
|
|
307
|
-
const yaml = (await import("js-yaml")).default;
|
|
308
|
-
policy = yaml.load(BARRIERS_YAML);
|
|
309
|
-
assert.ok(Array.isArray(policy.barriers));
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it("blocks a walled topic to a pattern-matched recipient", () => {
|
|
313
|
-
const r = screenBarriers("Here's the latest cap table figures.", {
|
|
314
|
-
policy,
|
|
315
|
-
recipient: "deals@partnerco.com",
|
|
316
|
-
recipientClass: "external",
|
|
317
|
-
});
|
|
318
|
-
assert.ok(r);
|
|
319
|
-
assert.match(r, /information barrier/);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it("allows a non-walled topic to the same recipient", () => {
|
|
323
|
-
const r = screenBarriers("Confirming the JV ops sync at 10am.", {
|
|
324
|
-
policy,
|
|
325
|
-
recipient: "deals@partnerco.com",
|
|
326
|
-
recipientClass: "external",
|
|
327
|
-
});
|
|
328
|
-
assert.equal(r, null);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it("blocks a recipient_class wall (runway → any external)", () => {
|
|
332
|
-
const r = screenBarriers("Our runway is 14 months.", {
|
|
333
|
-
policy,
|
|
334
|
-
recipient: "investor@somefund.com",
|
|
335
|
-
recipientClass: "external",
|
|
336
|
-
});
|
|
337
|
-
assert.ok(r);
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
it("does not apply a recipient_class wall to internal recipients", () => {
|
|
341
|
-
const r = screenBarriers("Our runway is 14 months.", {
|
|
342
|
-
policy,
|
|
343
|
-
recipient: "C0123456",
|
|
344
|
-
recipientClass: "internal",
|
|
345
|
-
});
|
|
346
|
-
assert.equal(r, null);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
it("is a no-op when no barriers section is present", () => {
|
|
350
|
-
const r = screenBarriers("anything at all cap table runway", {
|
|
351
|
-
policy: { domains: {} },
|
|
352
|
-
recipient: "x@y.com",
|
|
353
|
-
recipientClass: "external",
|
|
354
|
-
});
|
|
355
|
-
assert.equal(r, null);
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
describe("screenOutbound — barriers", () => {
|
|
360
|
-
it("blocks a walled topic to a walled recipient end-to-end", async () => {
|
|
361
|
-
const res = await screenOutbound({
|
|
362
|
-
channel: "email",
|
|
363
|
-
recipient: "deals@partnerco.com",
|
|
364
|
-
// Discloses AI to pass the disclosure gate; barrier is what trips.
|
|
365
|
-
text: "Writing as the AI assistant for Alex — here's our cap table.",
|
|
366
|
-
agentRoot: ROOT,
|
|
367
|
-
jurisdiction: "default",
|
|
368
|
-
firstContact: true,
|
|
369
|
-
fs: memFs(GOOD_FILES),
|
|
370
|
-
});
|
|
371
|
-
assert.equal(res.allow, false);
|
|
372
|
-
assert.match(res.reason, /information barrier/);
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
/* ─── allowlist ────────────────────────────────────────────────────────────*/
|
|
377
|
-
|
|
378
|
-
describe("screenAllowlist", () => {
|
|
379
|
-
it("is a no-op when not configured", () => {
|
|
380
|
-
assert.equal(screenAllowlist("x@y.com", undefined), null);
|
|
381
|
-
assert.equal(screenAllowlist("x@y.com", []), null);
|
|
382
|
-
});
|
|
383
|
-
it("allows a recipient on the list", () => {
|
|
384
|
-
assert.equal(screenAllowlist("x@y.com", ["x@y.com", "z@y.com"]), null);
|
|
385
|
-
});
|
|
386
|
-
it("blocks a recipient not on the list", () => {
|
|
387
|
-
const r = screenAllowlist("intruder@evil.com", ["x@y.com"]);
|
|
388
|
-
assert.ok(r);
|
|
389
|
-
assert.match(r, /not on the configured send allowlist/);
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
describe("screenOutbound — allowlist", () => {
|
|
394
|
-
it("blocks an off-allowlist recipient", async () => {
|
|
395
|
-
const res = await screenOutbound({
|
|
396
|
-
channel: "email",
|
|
397
|
-
recipient: "intruder@evil.com",
|
|
398
|
-
text: "Writing as the AI assistant for Alex — quick question.",
|
|
399
|
-
agentRoot: ROOT,
|
|
400
|
-
jurisdiction: "default",
|
|
401
|
-
allowlist: ["client@example.eu"],
|
|
402
|
-
fs: memFs(GOOD_FILES),
|
|
403
|
-
});
|
|
404
|
-
assert.equal(res.allow, false);
|
|
405
|
-
assert.match(res.reason, /allowlist/);
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
/* ─── benign passes ────────────────────────────────────────────────────────*/
|
|
410
|
-
|
|
411
|
-
describe("screenOutbound — benign", () => {
|
|
412
|
-
it("passes a benign internal Slack reply", async () => {
|
|
413
|
-
const res = await screenOutbound({
|
|
414
|
-
channel: "slack",
|
|
415
|
-
recipient: "C0123456",
|
|
416
|
-
text: "In progress — only blocker is DBA approval, expected by EOD.",
|
|
417
|
-
agentRoot: ROOT,
|
|
418
|
-
firstContact: false,
|
|
419
|
-
fs: memFs(GOOD_FILES),
|
|
420
|
-
});
|
|
421
|
-
assert.equal(res.allow, true, res.reason);
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
it("passes a benign external email that discloses AI on first contact", async () => {
|
|
425
|
-
const res = await screenOutbound({
|
|
426
|
-
channel: "email",
|
|
427
|
-
recipient: "client@example.eu",
|
|
428
|
-
text: "Writing as the AI assistant for Alex — can we sign the contract Friday?",
|
|
429
|
-
agentRoot: ROOT,
|
|
430
|
-
jurisdiction: "EU",
|
|
431
|
-
firstContact: true,
|
|
432
|
-
fs: memFs(GOOD_FILES),
|
|
433
|
-
});
|
|
434
|
-
assert.equal(res.allow, true, res.reason);
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
/* ─── fail posture ─────────────────────────────────────────────────────────*/
|
|
439
|
-
|
|
440
|
-
describe("screenOutbound — fail posture (unreadable policy)", () => {
|
|
441
|
-
it("fails CLOSED for an external recipient when ai-disclosure.yaml is unreadable", async () => {
|
|
442
|
-
const res = await screenOutbound({
|
|
443
|
-
channel: "email",
|
|
444
|
-
recipient: "client@example.eu", // external
|
|
445
|
-
text: "Writing as the AI assistant for Alex — quick note.",
|
|
446
|
-
agentRoot: ROOT,
|
|
447
|
-
jurisdiction: "default",
|
|
448
|
-
firstContact: true,
|
|
449
|
-
fs: memFs({
|
|
450
|
-
"policies/ai-disclosure.yaml": null, // unreadable (EACCES)
|
|
451
|
-
"policies/information-barriers.yaml": BARRIERS_YAML,
|
|
452
|
-
}),
|
|
453
|
-
});
|
|
454
|
-
assert.equal(res.allow, false);
|
|
455
|
-
assert.match(res.reason, /unreadable.*external|failing closed/i);
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
it("fails CLOSED for external when information-barriers.yaml is unreadable", async () => {
|
|
459
|
-
const res = await screenOutbound({
|
|
460
|
-
channel: "email",
|
|
461
|
-
recipient: "client@example.eu",
|
|
462
|
-
text: "Writing as the AI assistant for Alex — quick note.",
|
|
463
|
-
agentRoot: ROOT,
|
|
464
|
-
jurisdiction: "default",
|
|
465
|
-
firstContact: true,
|
|
466
|
-
fs: memFs({
|
|
467
|
-
"policies/ai-disclosure.yaml": DISCLOSURE_YAML,
|
|
468
|
-
"policies/information-barriers.yaml": null, // unreadable
|
|
469
|
-
}),
|
|
470
|
-
});
|
|
471
|
-
assert.equal(res.allow, false);
|
|
472
|
-
assert.match(res.reason, /unreadable|failing closed/i);
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
it("fails OPEN for an internal recipient when a policy file is unreadable", async () => {
|
|
476
|
-
const res = await screenOutbound({
|
|
477
|
-
channel: "slack",
|
|
478
|
-
recipient: "C0123456", // internal Slack id
|
|
479
|
-
text: "Heads up — deploy is going out at 4pm.",
|
|
480
|
-
agentRoot: ROOT,
|
|
481
|
-
firstContact: false,
|
|
482
|
-
fs: memFs({
|
|
483
|
-
"policies/ai-disclosure.yaml": null,
|
|
484
|
-
"policies/information-barriers.yaml": null,
|
|
485
|
-
}),
|
|
486
|
-
});
|
|
487
|
-
assert.equal(res.allow, true, res.reason);
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
it("fails CLOSED for external when disclosure YAML is malformed", async () => {
|
|
491
|
-
const res = await screenOutbound({
|
|
492
|
-
channel: "email",
|
|
493
|
-
recipient: "client@example.eu",
|
|
494
|
-
text: "Writing as the AI assistant for Alex — quick note.",
|
|
495
|
-
agentRoot: ROOT,
|
|
496
|
-
jurisdiction: "default",
|
|
497
|
-
firstContact: true,
|
|
498
|
-
fs: memFs({
|
|
499
|
-
"policies/ai-disclosure.yaml": "{[ this is : not valid yaml :::",
|
|
500
|
-
"policies/information-barriers.yaml": BARRIERS_YAML,
|
|
501
|
-
}),
|
|
502
|
-
});
|
|
503
|
-
assert.equal(res.allow, false);
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
it("still blocks a banned phrase even when policy files are missing (embedded SoT)", async () => {
|
|
507
|
-
// Internal recipient + missing files would otherwise fail-open; the banned
|
|
508
|
-
// phrase screen runs first off the embedded constant list, so it still trips.
|
|
509
|
-
const res = await screenOutbound({
|
|
510
|
-
channel: "slack",
|
|
511
|
-
recipient: "C0123456",
|
|
512
|
-
text: "As an AI I will help.",
|
|
513
|
-
agentRoot: ROOT,
|
|
514
|
-
fs: memFs({}),
|
|
515
|
-
});
|
|
516
|
-
assert.equal(res.allow, false);
|
|
517
|
-
assert.match(res.reason, /banned/);
|
|
518
|
-
});
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
/* ─── recipient classification ─────────────────────────────────────────────*/
|
|
522
|
-
|
|
523
|
-
describe("classifyRecipient", () => {
|
|
524
|
-
it("classifies Slack channel/DM ids as internal", () => {
|
|
525
|
-
assert.equal(classifyRecipient("slack", "C0123456"), "internal");
|
|
526
|
-
assert.equal(classifyRecipient("slack", "D0ABCDEFG"), "internal");
|
|
527
|
-
assert.equal(classifyRecipient("slack", "U0ABCDEFG"), "internal");
|
|
528
|
-
});
|
|
529
|
-
it("classifies Telegram numeric chat ids as internal", () => {
|
|
530
|
-
assert.equal(classifyRecipient("telegram", "123456789"), "internal");
|
|
531
|
-
assert.equal(classifyRecipient("telegram", "-1001234567"), "internal");
|
|
532
|
-
});
|
|
533
|
-
it("classifies emails as external by default", () => {
|
|
534
|
-
assert.equal(classifyRecipient("email", "x@external.com"), "external");
|
|
535
|
-
});
|
|
536
|
-
it("classifies emails on internal domains as internal", () => {
|
|
537
|
-
assert.equal(
|
|
538
|
-
classifyRecipient("email", "alex@internal.example", ["internal.example"]),
|
|
539
|
-
"internal",
|
|
540
|
-
);
|
|
541
|
-
assert.equal(
|
|
542
|
-
classifyRecipient("email", "ops@eng.internal.example", ["internal.example"]),
|
|
543
|
-
"internal",
|
|
544
|
-
);
|
|
545
|
-
});
|
|
546
|
-
it("classifies phone numbers as external", () => {
|
|
547
|
-
assert.equal(classifyRecipient("whatsapp", "+15551234567"), "external");
|
|
548
|
-
assert.equal(classifyRecipient("sms", "+15551234567"), "external");
|
|
549
|
-
});
|
|
550
|
-
it("treats empty recipient as external (conservative)", () => {
|
|
551
|
-
assert.equal(classifyRecipient("email", ""), "external");
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
// REGRESSION — observed live, 2026-08-11, tracing a public-space thread reply
|
|
555
|
-
// end to end for a real seat. `sendMessage` screens every org post as
|
|
556
|
-
// {channel:"cohort", recipient:<channelId>}; with no `cohort` case the switch
|
|
557
|
-
// fell through and a cuid has no "@", so the agent's OWN #general channel
|
|
558
|
-
// classified EXTERNAL. That flipped `failPolicy` to fail-closed and the reply
|
|
559
|
-
// was refused with: outbound policy "policies/ai-disclosure.yaml" unreadable
|
|
560
|
-
// — failing closed for external recipient.
|
|
561
|
-
it("classifies Cohort channel/member ids as internal — the agent's own workspace", () => {
|
|
562
|
-
// The literal ids from the live trace.
|
|
563
|
-
assert.equal(classifyRecipient("cohort", "cmqs5i86p0008ta0129ql6rv9"), "internal"); // #general
|
|
564
|
-
assert.equal(classifyRecipient("cohort", "cmqh0tcml004ihhl6zev6ocb5"), "internal"); // a member (DM)
|
|
565
|
-
// lib/org/tool-surface.mjs spells the same surface "cohort-org".
|
|
566
|
-
assert.equal(classifyRecipient("cohort-org", "cms6vuxjw00a7mx01ljlyrluu"), "internal");
|
|
567
|
-
// uuid-shaped org ids too.
|
|
568
|
-
assert.equal(
|
|
569
|
-
classifyRecipient("cohort", "3f2504e0-4f89-11d3-9a0c-0305e82c3301"),
|
|
570
|
-
"internal",
|
|
571
|
-
);
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
// REGRESSION — the SAME defect one shape further on. `deliver.mjs` answers a
|
|
575
|
-
// roomless surface on its entity thread and addresses it `task:<id>` /
|
|
576
|
-
// `file:<id>` / `decision:<id>`. The colon fails COHORT_ID, so every board,
|
|
577
|
-
// doc and decision reply classified EXTERNAL — fail-CLOSED policy faults for
|
|
578
|
-
// the whole board lane, and `recipient_class: external` barrier rules applied
|
|
579
|
-
// to internal board chatter. The module printed its own warning about it on
|
|
580
|
-
// every process.
|
|
581
|
-
it("classifies Cohort ENTITY threads as internal — a board reply is not an outsider", () => {
|
|
582
|
-
assert.equal(classifyRecipient("cohort", "task:cmrlw2l3600e9hh8n10hprdrd"), "internal");
|
|
583
|
-
assert.equal(classifyRecipient("cohort", "file:cmsspqi9500dmo401gg51ntz7"), "internal");
|
|
584
|
-
assert.equal(classifyRecipient("cohort", "decision:cmdec0000000000000000000"), "internal");
|
|
585
|
-
// The chat-attachment fileKey is opaque, not cuid-shaped.
|
|
586
|
-
assert.equal(classifyRecipient("cohort", "file:fk_abc123"), "internal");
|
|
587
|
-
assert.equal(classifyRecipient("cohort-org", "task:cmrlw2l3600e9hh8n10hprdrd"), "internal");
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
it("the entity-ref prefix set is CLOSED — it is not a colon wildcard", () => {
|
|
591
|
-
// Otherwise "internal" becomes a thing anyone can claim by adding a colon.
|
|
592
|
-
assert.equal(classifyRecipient("cohort", "mailto:someone@external.com"), "external");
|
|
593
|
-
assert.equal(classifyRecipient("cohort", "approval:aprv_journey_msopegu4"), "external");
|
|
594
|
-
assert.equal(classifyRecipient("cohort", "task:"), "external");
|
|
595
|
-
assert.equal(classifyRecipient("cohort", "task:someone@external.com"), "external");
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
it("does NOT launder a genuinely external address arriving on the org channel", () => {
|
|
599
|
-
// The whole point of scoping the case to id-shaped recipients: an email or
|
|
600
|
-
// a phone number handed to an org surface must still be external, or the
|
|
601
|
-
// fix would open the AI-disclosure gate for real outsiders.
|
|
602
|
-
assert.equal(classifyRecipient("cohort", "someone@external.com"), "external");
|
|
603
|
-
assert.equal(classifyRecipient("cohort-org", "client@bank.example"), "external");
|
|
604
|
-
assert.equal(classifyRecipient("cohort", "+15551234567"), "external");
|
|
605
|
-
// …and an allow-listed internal domain still resolves through the domain test.
|
|
606
|
-
assert.equal(
|
|
607
|
-
classifyRecipient("cohort", "alex@internal.example", ["internal.example"]),
|
|
608
|
-
"internal",
|
|
609
|
-
);
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
it("an unreadable required policy no longer gags the agent in its own workspace", async () => {
|
|
613
|
-
// The end-to-end symptom, reduced: no policies/ on disk at all.
|
|
614
|
-
const emptyFs = { existsSync: () => false, readFileSync: () => { throw new Error("ENOENT"); } };
|
|
615
|
-
const org = await screenOutbound({
|
|
616
|
-
channel: "cohort",
|
|
617
|
-
recipient: "cmqs5i86p0008ta0129ql6rv9",
|
|
618
|
-
text: "Already voted espresso — I'm in the count.",
|
|
619
|
-
fs: emptyFs,
|
|
620
|
-
});
|
|
621
|
-
assert.equal(org.allow, true, `org post must fail OPEN, got: ${org.reason}`);
|
|
622
|
-
|
|
623
|
-
// The external posture is untouched — this is the half that must NOT regress.
|
|
624
|
-
const outsider = await screenOutbound({
|
|
625
|
-
channel: "email",
|
|
626
|
-
recipient: "someone@external.com",
|
|
627
|
-
text: "Already voted espresso — I'm in the count.",
|
|
628
|
-
fs: emptyFs,
|
|
629
|
-
});
|
|
630
|
-
assert.equal(outsider.allow, false);
|
|
631
|
-
assert.match(outsider.reason, /failing closed for external recipient/);
|
|
632
|
-
});
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
/* ─── real-disk integration smoke (uses the actual readPolicy path) ────────*/
|
|
636
|
-
|
|
637
|
-
describe("screenOutbound — real-disk read path", () => {
|
|
638
|
-
it("reads policies from a real agentRoot and blocks a barrier", async () => {
|
|
639
|
-
const dir = mkdtempSync(join(tmpdir(), "send-gate-"));
|
|
640
|
-
try {
|
|
641
|
-
mkdirSync(join(dir, "policies"), { recursive: true });
|
|
642
|
-
writeFileSync(join(dir, "policies", "ai-disclosure.yaml"), DISCLOSURE_YAML);
|
|
643
|
-
writeFileSync(join(dir, "policies", "information-barriers.yaml"), BARRIERS_YAML);
|
|
644
|
-
const res = await screenOutbound({
|
|
645
|
-
channel: "email",
|
|
646
|
-
recipient: "deals@partnerco.com",
|
|
647
|
-
text: "Writing as the AI assistant for Alex — our acquisition target list.",
|
|
648
|
-
agentRoot: dir,
|
|
649
|
-
jurisdiction: "default",
|
|
650
|
-
firstContact: true,
|
|
651
|
-
});
|
|
652
|
-
assert.equal(res.allow, false);
|
|
653
|
-
assert.match(res.reason, /information barrier/);
|
|
654
|
-
} finally {
|
|
655
|
-
rmSync(dir, { recursive: true, force: true });
|
|
656
|
-
}
|
|
657
|
-
});
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
/* ─── persona discipline (front-door session §3.6) ─────────────────────────
|
|
661
|
-
* The agent is one persona to every human. The machinery — Claude Code, a
|
|
662
|
-
* session, a sub-session, a subagent that "said", a workflow agent, the model,
|
|
663
|
-
* an internal session name — never appears in outbound text. This screen runs
|
|
664
|
-
* inside screenOutbound so EVERY lane gets it: the daemon's delivery
|
|
665
|
-
* (`maestro inbox reply`), lib/org/messaging.sendMessage, the org MCP tools
|
|
666
|
-
* (messaging_send, email_send, email_draft_send, org_rpc) and the adapters —
|
|
667
|
-
* not only the PreToolUse shell hook.
|
|
668
|
-
*/
|
|
669
|
-
|
|
670
|
-
describe("screenPersona (unit)", () => {
|
|
671
|
-
for (const [label, text] of [
|
|
672
|
-
["Claude Code", "I'll have Claude Code pick that up this afternoon."],
|
|
673
|
-
["Claude session", "A separate claude session is running the numbers."],
|
|
674
|
-
["sub-session", "I kicked off a sub-session for the deck."],
|
|
675
|
-
["subagent said", "The subagent said the deploy finished."],
|
|
676
|
-
["sub-agent reported", "My sub-agent reported two blockers."],
|
|
677
|
-
["subagent session", "The subagent session is still going."],
|
|
678
|
-
["workflow agent", "The workflow agent will file the summary."],
|
|
679
|
-
["language model", "Every language model has limits, mine included."],
|
|
680
|
-
]) {
|
|
681
|
-
it(`blocks "${label}" and names the phrase`, () => {
|
|
682
|
-
const reason = screenPersona(text);
|
|
683
|
-
assert.ok(reason, `expected a block for "${label}"`);
|
|
684
|
-
assert.match(reason, /persona leak/i);
|
|
685
|
-
assert.match(reason.toLowerCase(), new RegExp(label.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\s+/g, "\\s+")));
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
it("session names are BOUNDED: <first>-main always, other <first>-<x> only when registered as a peer", () => {
|
|
690
|
-
assert.ok(screenPersona("Check with alex-main for the latest.", { first: "alex" }));
|
|
691
|
-
assert.ok(screenPersona("Ask ALEX-MAIN.", { first: "alex" }), "case-insensitive");
|
|
692
|
-
assert.equal(screenPersona("alex-research has the draft ready.", { first: "alex" }), null, "unregistered peer name: not a session name");
|
|
693
|
-
assert.ok(screenPersona("alex-research has the draft ready.", { first: "alex", sessionNames: ["alex-research"] }));
|
|
694
|
-
assert.ok(screenPersona("alex-research has the draft ready.", { sessionNames: ["alex-research"] }), "names work without a first name");
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
it("does not block a colleague's hyphenated name, a URL slug or an email local part that starts with the first name", () => {
|
|
698
|
-
for (const [first, text] of [
|
|
699
|
-
["marc", "Marc-Antoine confirmed the numbers."],
|
|
700
|
-
["james", "See https://os.cohortapp.com/spaces/james-kirkland for the thread."],
|
|
701
|
-
["ethan", "Loop in ethan-miller@example.com on the invoice."],
|
|
702
|
-
["alex", "Alexandra-Maine sent the invoice."],
|
|
703
|
-
["alex", "alex-mainland is the venue."],
|
|
704
|
-
]) {
|
|
705
|
-
assert.equal(screenPersona(text, { first }), null, `"${text}" must pass for first=${first}`);
|
|
706
|
-
}
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
it("colleague phrasing, the bare noun 'subagents', and the calendar sense of 'session' all pass", () => {
|
|
710
|
-
for (const text of [
|
|
711
|
-
"One of my analysts is on it; I'll have the numbers by 3.",
|
|
712
|
-
"My team has the deck in review — sending the draft after lunch.",
|
|
713
|
-
"We use subagents internally for the heavy lifting.",
|
|
714
|
-
"The session on Thursday (the board session) starts at 9.",
|
|
715
|
-
"",
|
|
716
|
-
]) {
|
|
717
|
-
assert.equal(screenPersona(text, { first: "alex" }), null, `"${text}" must pass`);
|
|
718
|
-
}
|
|
719
|
-
assert.equal(screenPersona(null), null);
|
|
720
|
-
});
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
describe("screenOutbound — persona", () => {
|
|
724
|
-
const PERSONA_FILES = {
|
|
725
|
-
...GOOD_FILES,
|
|
726
|
-
"config/agent.json": JSON.stringify({ firstName: "Alex", fullName: "Alex Rivera" }),
|
|
727
|
-
"state/session/peers.json": JSON.stringify([{ name: "alex-deck", muxName: "maestro-alex-deck", purpose: "deck" }]),
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
it("blocks a persona leak for an internal Cohort recipient (the `maestro inbox reply` lane)", async () => {
|
|
731
|
-
const res = await screenOutbound({
|
|
732
|
-
channel: "cohort",
|
|
733
|
-
recipient: "clx0123456789abcdefghij",
|
|
734
|
-
text: "My sub-session is on it, check with alex-main.",
|
|
735
|
-
agentRoot: ROOT,
|
|
736
|
-
firstContact: false,
|
|
737
|
-
fs: memFs(PERSONA_FILES),
|
|
738
|
-
});
|
|
739
|
-
assert.equal(res.allow, false);
|
|
740
|
-
assert.match(res.reason, /persona leak/i);
|
|
741
|
-
assert.match(res.reason, /sub-session/i);
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
it("reads the first name from config/agent.json and the peer names from state/session/peers.json under agentRoot", async () => {
|
|
745
|
-
const fs = memFs(PERSONA_FILES);
|
|
746
|
-
const main = await screenOutbound({ channel: "cohort", recipient: "clx0123456789abcdefghij", text: "alex-main will chase it.", agentRoot: ROOT, firstContact: false, fs });
|
|
747
|
-
assert.equal(main.allow, false);
|
|
748
|
-
assert.match(main.reason, /alex-main/);
|
|
749
|
-
const peer = await screenOutbound({ channel: "cohort", recipient: "clx0123456789abcdefghij", text: "alex-deck has the slides.", agentRoot: ROOT, firstContact: false, fs });
|
|
750
|
-
assert.equal(peer.allow, false, "a registered peer name is a session name");
|
|
751
|
-
const other = await screenOutbound({ channel: "cohort", recipient: "clx0123456789abcdefghij", text: "alex-research is not a peer here.", agentRoot: ROOT, firstContact: false, fs });
|
|
752
|
-
assert.equal(other.allow, true, "an unregistered <first>-x is ordinary text");
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
it("explicit agentFirst / sessionNames override the disk read; no identity on disk → phrase gate still applies, name gate skipped", async () => {
|
|
756
|
-
const fs = memFs(GOOD_FILES);
|
|
757
|
-
const named = await screenOutbound({ channel: "cohort", recipient: "clx0123456789abcdefghij", text: "robin-main will chase it.", agentRoot: ROOT, firstContact: false, fs, agentFirst: "Robin" });
|
|
758
|
-
assert.equal(named.allow, false);
|
|
759
|
-
const none = await screenOutbound({ channel: "cohort", recipient: "clx0123456789abcdefghij", text: "robin-main will chase it.", agentRoot: ROOT, firstContact: false, fs });
|
|
760
|
-
assert.equal(none.allow, true, "no first name resolvable → the name check is skipped (fail-open on that one check)");
|
|
761
|
-
const phrase = await screenOutbound({ channel: "cohort", recipient: "clx0123456789abcdefghij", text: "Claude Code is on it.", agentRoot: ROOT, firstContact: false, fs });
|
|
762
|
-
assert.equal(phrase.allow, false, "the phrase gate needs no identity");
|
|
763
|
-
});
|
|
764
|
-
|
|
765
|
-
it("applies to external email too", async () => {
|
|
766
|
-
const res = await screenOutbound({ channel: "email", recipient: "graham@kpm.com", text: "Our workflow agent will send the summary. I am an AI assistant, for the record.", agentRoot: ROOT, fs: memFs(PERSONA_FILES) });
|
|
767
|
-
assert.equal(res.allow, false);
|
|
768
|
-
assert.match(res.reason, /persona leak/i);
|
|
769
|
-
});
|
|
770
|
-
});
|