@memnexus-ai/mx-agent-cli 0.1.296 → 0.1.297
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/dist/commands/create.d.ts +36 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +85 -8
- package/dist/commands/create.js.map +1 -1
- package/dist/standards/decision-request.md +6 -57
- package/dist/standards/po-communication-standard.md +0 -34
- package/dist/standards/report-format.md +0 -90
- package/dist/standards/writing-standard.md +0 -312
- package/package.json +3 -1
- package/dist/__tests__/agent-attribution.test.d.ts +0 -16
- package/dist/__tests__/agent-attribution.test.d.ts.map +0 -1
- package/dist/__tests__/agent-attribution.test.js +0 -250
- package/dist/__tests__/agent-attribution.test.js.map +0 -1
- package/dist/__tests__/agents-md-canonicalization.test.d.ts +0 -23
- package/dist/__tests__/agents-md-canonicalization.test.d.ts.map +0 -1
- package/dist/__tests__/agents-md-canonicalization.test.js +0 -319
- package/dist/__tests__/agents-md-canonicalization.test.js.map +0 -1
- package/dist/__tests__/behavioral-compliance.test.d.ts +0 -8
- package/dist/__tests__/behavioral-compliance.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-compliance.test.js +0 -226
- package/dist/__tests__/behavioral-compliance.test.js.map +0 -1
- package/dist/__tests__/behavioral-extraction.test.d.ts +0 -12
- package/dist/__tests__/behavioral-extraction.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-extraction.test.js +0 -330
- package/dist/__tests__/behavioral-extraction.test.js.map +0 -1
- package/dist/__tests__/behavioral-git-read.test.d.ts +0 -21
- package/dist/__tests__/behavioral-git-read.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-git-read.test.js +0 -955
- package/dist/__tests__/behavioral-git-read.test.js.map +0 -1
- package/dist/__tests__/behavioral-injection.test.d.ts +0 -13
- package/dist/__tests__/behavioral-injection.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-injection.test.js +0 -384
- package/dist/__tests__/behavioral-injection.test.js.map +0 -1
- package/dist/__tests__/binary-smoke.test.d.ts +0 -12
- package/dist/__tests__/binary-smoke.test.d.ts.map +0 -1
- package/dist/__tests__/binary-smoke.test.js +0 -88
- package/dist/__tests__/binary-smoke.test.js.map +0 -1
- package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts +0 -18
- package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts.map +0 -1
- package/dist/__tests__/bootstrap-behavioral-contract.test.js +0 -104
- package/dist/__tests__/bootstrap-behavioral-contract.test.js.map +0 -1
- package/dist/__tests__/bundle-config.test.d.ts +0 -18
- package/dist/__tests__/bundle-config.test.d.ts.map +0 -1
- package/dist/__tests__/bundle-config.test.js +0 -123
- package/dist/__tests__/bundle-config.test.js.map +0 -1
- package/dist/__tests__/catalog-interaction.test.d.ts +0 -25
- package/dist/__tests__/catalog-interaction.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-interaction.test.js +0 -269
- package/dist/__tests__/catalog-interaction.test.js.map +0 -1
- package/dist/__tests__/catalog-named-memories.test.d.ts +0 -2
- package/dist/__tests__/catalog-named-memories.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-named-memories.test.js +0 -204
- package/dist/__tests__/catalog-named-memories.test.js.map +0 -1
- package/dist/__tests__/catalog-origin-main.test.d.ts +0 -15
- package/dist/__tests__/catalog-origin-main.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-origin-main.test.js +0 -305
- package/dist/__tests__/catalog-origin-main.test.js.map +0 -1
- package/dist/__tests__/catalog.test.d.ts +0 -2
- package/dist/__tests__/catalog.test.d.ts.map +0 -1
- package/dist/__tests__/catalog.test.js +0 -131
- package/dist/__tests__/catalog.test.js.map +0 -1
- package/dist/__tests__/claude-local-sanitizer.test.d.ts +0 -24
- package/dist/__tests__/claude-local-sanitizer.test.d.ts.map +0 -1
- package/dist/__tests__/claude-local-sanitizer.test.js +0 -906
- package/dist/__tests__/claude-local-sanitizer.test.js.map +0 -1
- package/dist/__tests__/claude-md-compose.test.d.ts +0 -17
- package/dist/__tests__/claude-md-compose.test.d.ts.map +0 -1
- package/dist/__tests__/claude-md-compose.test.js +0 -119
- package/dist/__tests__/claude-md-compose.test.js.map +0 -1
- package/dist/__tests__/claude-sync.test.d.ts +0 -2
- package/dist/__tests__/claude-sync.test.d.ts.map +0 -1
- package/dist/__tests__/claude-sync.test.js +0 -571
- package/dist/__tests__/claude-sync.test.js.map +0 -1
- package/dist/__tests__/cli-build-integration.test.d.ts +0 -2
- package/dist/__tests__/cli-build-integration.test.d.ts.map +0 -1
- package/dist/__tests__/cli-build-integration.test.js +0 -64
- package/dist/__tests__/cli-build-integration.test.js.map +0 -1
- package/dist/__tests__/cli-build.test.d.ts +0 -2
- package/dist/__tests__/cli-build.test.d.ts.map +0 -1
- package/dist/__tests__/cli-build.test.js +0 -640
- package/dist/__tests__/cli-build.test.js.map +0 -1
- package/dist/__tests__/codex-agent-gate.test.d.ts +0 -2
- package/dist/__tests__/codex-agent-gate.test.d.ts.map +0 -1
- package/dist/__tests__/codex-agent-gate.test.js +0 -480
- package/dist/__tests__/codex-agent-gate.test.js.map +0 -1
- package/dist/__tests__/codex-deploy-config.test.d.ts +0 -2
- package/dist/__tests__/codex-deploy-config.test.d.ts.map +0 -1
- package/dist/__tests__/codex-deploy-config.test.js +0 -1230
- package/dist/__tests__/codex-deploy-config.test.js.map +0 -1
- package/dist/__tests__/codex-trust-keys.test.d.ts +0 -2
- package/dist/__tests__/codex-trust-keys.test.d.ts.map +0 -1
- package/dist/__tests__/codex-trust-keys.test.js +0 -731
- package/dist/__tests__/codex-trust-keys.test.js.map +0 -1
- package/dist/__tests__/codex-write-race.test.d.ts +0 -2
- package/dist/__tests__/codex-write-race.test.d.ts.map +0 -1
- package/dist/__tests__/codex-write-race.test.js +0 -2253
- package/dist/__tests__/codex-write-race.test.js.map +0 -1
- package/dist/__tests__/completion-rows-discriminate.test.d.ts +0 -20
- package/dist/__tests__/completion-rows-discriminate.test.d.ts.map +0 -1
- package/dist/__tests__/completion-rows-discriminate.test.js +0 -481
- package/dist/__tests__/completion-rows-discriminate.test.js.map +0 -1
- package/dist/__tests__/config-command.test.d.ts +0 -9
- package/dist/__tests__/config-command.test.d.ts.map +0 -1
- package/dist/__tests__/config-command.test.js +0 -75
- package/dist/__tests__/config-command.test.js.map +0 -1
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts +0 -2
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js +0 -127
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js.map +0 -1
- package/dist/__tests__/config-fidelity-display.test.d.ts +0 -2
- package/dist/__tests__/config-fidelity-display.test.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity-display.test.js +0 -77
- package/dist/__tests__/config-fidelity-display.test.js.map +0 -1
- package/dist/__tests__/config-fidelity-unreadable-fixture.d.ts +0 -32
- package/dist/__tests__/config-fidelity-unreadable-fixture.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity-unreadable-fixture.js +0 -37
- package/dist/__tests__/config-fidelity-unreadable-fixture.js.map +0 -1
- package/dist/__tests__/config-fidelity.test.d.ts +0 -16
- package/dist/__tests__/config-fidelity.test.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity.test.js +0 -2679
- package/dist/__tests__/config-fidelity.test.js.map +0 -1
- package/dist/__tests__/config-generation-gate.test.d.ts +0 -46
- package/dist/__tests__/config-generation-gate.test.d.ts.map +0 -1
- package/dist/__tests__/config-generation-gate.test.js +0 -435
- package/dist/__tests__/config-generation-gate.test.js.map +0 -1
- package/dist/__tests__/config-generation.test.d.ts +0 -7
- package/dist/__tests__/config-generation.test.d.ts.map +0 -1
- package/dist/__tests__/config-generation.test.js +0 -141
- package/dist/__tests__/config-generation.test.js.map +0 -1
- package/dist/__tests__/config-sync.test.d.ts +0 -10
- package/dist/__tests__/config-sync.test.d.ts.map +0 -1
- package/dist/__tests__/config-sync.test.js +0 -268
- package/dist/__tests__/config-sync.test.js.map +0 -1
- package/dist/__tests__/coordination-401-production-wiring.test.d.ts +0 -19
- package/dist/__tests__/coordination-401-production-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-401-production-wiring.test.js +0 -286
- package/dist/__tests__/coordination-401-production-wiring.test.js.map +0 -1
- package/dist/__tests__/coordination-401-recovery.test.d.ts +0 -22
- package/dist/__tests__/coordination-401-recovery.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-401-recovery.test.js +0 -601
- package/dist/__tests__/coordination-401-recovery.test.js.map +0 -1
- package/dist/__tests__/coordination-brief-pin.test.d.ts +0 -20
- package/dist/__tests__/coordination-brief-pin.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-brief-pin.test.js +0 -66
- package/dist/__tests__/coordination-brief-pin.test.js.map +0 -1
- package/dist/__tests__/coordination-brief.test.d.ts +0 -9
- package/dist/__tests__/coordination-brief.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-brief.test.js +0 -290
- package/dist/__tests__/coordination-brief.test.js.map +0 -1
- package/dist/__tests__/coordination-client.test.d.ts +0 -9
- package/dist/__tests__/coordination-client.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-client.test.js +0 -517
- package/dist/__tests__/coordination-client.test.js.map +0 -1
- package/dist/__tests__/coordination-command.test.d.ts +0 -9
- package/dist/__tests__/coordination-command.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-command.test.js +0 -1082
- package/dist/__tests__/coordination-command.test.js.map +0 -1
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts +0 -24
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-credential-endpoint.test.js +0 -1292
- package/dist/__tests__/coordination-credential-endpoint.test.js.map +0 -1
- package/dist/__tests__/coordination-expected-team.test.d.ts +0 -19
- package/dist/__tests__/coordination-expected-team.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-expected-team.test.js +0 -423
- package/dist/__tests__/coordination-expected-team.test.js.map +0 -1
- package/dist/__tests__/coordination-fallback.test.d.ts +0 -9
- package/dist/__tests__/coordination-fallback.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-fallback.test.js +0 -192
- package/dist/__tests__/coordination-fallback.test.js.map +0 -1
- package/dist/__tests__/coordination-file-guards.test.d.ts +0 -29
- package/dist/__tests__/coordination-file-guards.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-file-guards.test.js +0 -380
- package/dist/__tests__/coordination-file-guards.test.js.map +0 -1
- package/dist/__tests__/coordination-history.test.d.ts +0 -8
- package/dist/__tests__/coordination-history.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-history.test.js +0 -447
- package/dist/__tests__/coordination-history.test.js.map +0 -1
- package/dist/__tests__/coordination-memory.test.d.ts +0 -14
- package/dist/__tests__/coordination-memory.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-memory.test.js +0 -401
- package/dist/__tests__/coordination-memory.test.js.map +0 -1
- package/dist/__tests__/coordination-mode.test.d.ts +0 -13
- package/dist/__tests__/coordination-mode.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-mode.test.js +0 -180
- package/dist/__tests__/coordination-mode.test.js.map +0 -1
- package/dist/__tests__/coordination-plain-shell-commands.test.d.ts +0 -22
- package/dist/__tests__/coordination-plain-shell-commands.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-plain-shell-commands.test.js +0 -1875
- package/dist/__tests__/coordination-plain-shell-commands.test.js.map +0 -1
- package/dist/__tests__/coordination-provision.test.d.ts +0 -12
- package/dist/__tests__/coordination-provision.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-provision.test.js +0 -103
- package/dist/__tests__/coordination-provision.test.js.map +0 -1
- package/dist/__tests__/coordination-render.test.d.ts +0 -9
- package/dist/__tests__/coordination-render.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-render.test.js +0 -335
- package/dist/__tests__/coordination-render.test.js.map +0 -1
- package/dist/__tests__/coordination-setup.test.d.ts +0 -6
- package/dist/__tests__/coordination-setup.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-setup.test.js +0 -448
- package/dist/__tests__/coordination-setup.test.js.map +0 -1
- package/dist/__tests__/coordination-status-plain-shell.test.d.ts +0 -19
- package/dist/__tests__/coordination-status-plain-shell.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-status-plain-shell.test.js +0 -332
- package/dist/__tests__/coordination-status-plain-shell.test.js.map +0 -1
- package/dist/__tests__/coordination-status-registration.test.d.ts +0 -16
- package/dist/__tests__/coordination-status-registration.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-status-registration.test.js +0 -480
- package/dist/__tests__/coordination-status-registration.test.js.map +0 -1
- package/dist/__tests__/coordination-token-multitenant.test.d.ts +0 -11
- package/dist/__tests__/coordination-token-multitenant.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-token-multitenant.test.js +0 -106
- package/dist/__tests__/coordination-token-multitenant.test.js.map +0 -1
- package/dist/__tests__/coordination-token.test.d.ts +0 -11
- package/dist/__tests__/coordination-token.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-token.test.js +0 -201
- package/dist/__tests__/coordination-token.test.js.map +0 -1
- package/dist/__tests__/coordination-wiring.test.d.ts +0 -11
- package/dist/__tests__/coordination-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-wiring.test.js +0 -43
- package/dist/__tests__/coordination-wiring.test.js.map +0 -1
- package/dist/__tests__/creation-pr-class-check.test.d.ts +0 -17
- package/dist/__tests__/creation-pr-class-check.test.d.ts.map +0 -1
- package/dist/__tests__/creation-pr-class-check.test.js +0 -346
- package/dist/__tests__/creation-pr-class-check.test.js.map +0 -1
- package/dist/__tests__/creation-step6a-push-check.test.d.ts +0 -15
- package/dist/__tests__/creation-step6a-push-check.test.d.ts.map +0 -1
- package/dist/__tests__/creation-step6a-push-check.test.js +0 -150
- package/dist/__tests__/creation-step6a-push-check.test.js.map +0 -1
- package/dist/__tests__/decision-check.test.d.ts +0 -2
- package/dist/__tests__/decision-check.test.d.ts.map +0 -1
- package/dist/__tests__/decision-check.test.js +0 -105
- package/dist/__tests__/decision-check.test.js.map +0 -1
- package/dist/__tests__/digest-fail-closed.test.d.ts +0 -16
- package/dist/__tests__/digest-fail-closed.test.d.ts.map +0 -1
- package/dist/__tests__/digest-fail-closed.test.js +0 -248
- package/dist/__tests__/digest-fail-closed.test.js.map +0 -1
- package/dist/__tests__/digest-team-omission.test.d.ts +0 -15
- package/dist/__tests__/digest-team-omission.test.d.ts.map +0 -1
- package/dist/__tests__/digest-team-omission.test.js +0 -247
- package/dist/__tests__/digest-team-omission.test.js.map +0 -1
- package/dist/__tests__/doctor-config-fidelity.test.d.ts +0 -19
- package/dist/__tests__/doctor-config-fidelity.test.d.ts.map +0 -1
- package/dist/__tests__/doctor-config-fidelity.test.js +0 -324
- package/dist/__tests__/doctor-config-fidelity.test.js.map +0 -1
- package/dist/__tests__/doctor-framework-version.test.d.ts +0 -2
- package/dist/__tests__/doctor-framework-version.test.d.ts.map +0 -1
- package/dist/__tests__/doctor-framework-version.test.js +0 -146
- package/dist/__tests__/doctor-framework-version.test.js.map +0 -1
- package/dist/__tests__/doctor-worktree-path.test.d.ts +0 -17
- package/dist/__tests__/doctor-worktree-path.test.d.ts.map +0 -1
- package/dist/__tests__/doctor-worktree-path.test.js +0 -158
- package/dist/__tests__/doctor-worktree-path.test.js.map +0 -1
- package/dist/__tests__/doctor.test.d.ts +0 -20
- package/dist/__tests__/doctor.test.d.ts.map +0 -1
- package/dist/__tests__/doctor.test.js +0 -849
- package/dist/__tests__/doctor.test.js.map +0 -1
- package/dist/__tests__/event-shipper.test.d.ts +0 -16
- package/dist/__tests__/event-shipper.test.d.ts.map +0 -1
- package/dist/__tests__/event-shipper.test.js +0 -287
- package/dist/__tests__/event-shipper.test.js.map +0 -1
- package/dist/__tests__/fleet-data.test.d.ts +0 -2
- package/dist/__tests__/fleet-data.test.d.ts.map +0 -1
- package/dist/__tests__/fleet-data.test.js +0 -501
- package/dist/__tests__/fleet-data.test.js.map +0 -1
- package/dist/__tests__/fleet-devpod.test.d.ts +0 -12
- package/dist/__tests__/fleet-devpod.test.d.ts.map +0 -1
- package/dist/__tests__/fleet-devpod.test.js +0 -260
- package/dist/__tests__/fleet-devpod.test.js.map +0 -1
- package/dist/__tests__/fleet-tmux.test.d.ts +0 -2
- package/dist/__tests__/fleet-tmux.test.d.ts.map +0 -1
- package/dist/__tests__/fleet-tmux.test.js +0 -289
- package/dist/__tests__/fleet-tmux.test.js.map +0 -1
- package/dist/__tests__/fleet.test.d.ts +0 -16
- package/dist/__tests__/fleet.test.d.ts.map +0 -1
- package/dist/__tests__/fleet.test.js +0 -75
- package/dist/__tests__/fleet.test.js.map +0 -1
- package/dist/__tests__/generate-claude.test.d.ts +0 -18
- package/dist/__tests__/generate-claude.test.d.ts.map +0 -1
- package/dist/__tests__/generate-claude.test.js +0 -1015
- package/dist/__tests__/generate-claude.test.js.map +0 -1
- package/dist/__tests__/gh-remote.test.d.ts +0 -2
- package/dist/__tests__/gh-remote.test.d.ts.map +0 -1
- package/dist/__tests__/gh-remote.test.js +0 -136
- package/dist/__tests__/gh-remote.test.js.map +0 -1
- package/dist/__tests__/git-env.test.d.ts +0 -14
- package/dist/__tests__/git-env.test.d.ts.map +0 -1
- package/dist/__tests__/git-env.test.js +0 -131
- package/dist/__tests__/git-env.test.js.map +0 -1
- package/dist/__tests__/git-identity-isolation.test.d.ts +0 -33
- package/dist/__tests__/git-identity-isolation.test.d.ts.map +0 -1
- package/dist/__tests__/git-identity-isolation.test.js +0 -626
- package/dist/__tests__/git-identity-isolation.test.js.map +0 -1
- package/dist/__tests__/harness-extract.test.d.ts +0 -19
- package/dist/__tests__/harness-extract.test.d.ts.map +0 -1
- package/dist/__tests__/harness-extract.test.js +0 -566
- package/dist/__tests__/harness-extract.test.js.map +0 -1
- package/dist/__tests__/harness-wiring.test.d.ts +0 -16
- package/dist/__tests__/harness-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/harness-wiring.test.js +0 -469
- package/dist/__tests__/harness-wiring.test.js.map +0 -1
- package/dist/__tests__/hook-completeness.test.d.ts +0 -13
- package/dist/__tests__/hook-completeness.test.d.ts.map +0 -1
- package/dist/__tests__/hook-completeness.test.js +0 -238
- package/dist/__tests__/hook-completeness.test.js.map +0 -1
- package/dist/__tests__/hook-heal.test.d.ts +0 -8
- package/dist/__tests__/hook-heal.test.d.ts.map +0 -1
- package/dist/__tests__/hook-heal.test.js +0 -156
- package/dist/__tests__/hook-heal.test.js.map +0 -1
- package/dist/__tests__/human-turn-classifier.test.d.ts +0 -17
- package/dist/__tests__/human-turn-classifier.test.d.ts.map +0 -1
- package/dist/__tests__/human-turn-classifier.test.js +0 -311
- package/dist/__tests__/human-turn-classifier.test.js.map +0 -1
- package/dist/__tests__/init-coordination-url.test.d.ts +0 -11
- package/dist/__tests__/init-coordination-url.test.d.ts.map +0 -1
- package/dist/__tests__/init-coordination-url.test.js +0 -217
- package/dist/__tests__/init-coordination-url.test.js.map +0 -1
- package/dist/__tests__/isolation-probe.test.d.ts +0 -15
- package/dist/__tests__/isolation-probe.test.d.ts.map +0 -1
- package/dist/__tests__/isolation-probe.test.js +0 -611
- package/dist/__tests__/isolation-probe.test.js.map +0 -1
- package/dist/__tests__/leader-lock.test.d.ts +0 -12
- package/dist/__tests__/leader-lock.test.d.ts.map +0 -1
- package/dist/__tests__/leader-lock.test.js +0 -293
- package/dist/__tests__/leader-lock.test.js.map +0 -1
- package/dist/__tests__/memory-archive-checks.test.d.ts +0 -22
- package/dist/__tests__/memory-archive-checks.test.d.ts.map +0 -1
- package/dist/__tests__/memory-archive-checks.test.js +0 -748
- package/dist/__tests__/memory-archive-checks.test.js.map +0 -1
- package/dist/__tests__/memory-archive-prep.test.d.ts +0 -8
- package/dist/__tests__/memory-archive-prep.test.d.ts.map +0 -1
- package/dist/__tests__/memory-archive-prep.test.js +0 -524
- package/dist/__tests__/memory-archive-prep.test.js.map +0 -1
- package/dist/__tests__/memory-autocreate.test.d.ts +0 -10
- package/dist/__tests__/memory-autocreate.test.d.ts.map +0 -1
- package/dist/__tests__/memory-autocreate.test.js +0 -709
- package/dist/__tests__/memory-autocreate.test.js.map +0 -1
- package/dist/__tests__/memory-log-result.test.d.ts +0 -13
- package/dist/__tests__/memory-log-result.test.d.ts.map +0 -1
- package/dist/__tests__/memory-log-result.test.js +0 -149
- package/dist/__tests__/memory-log-result.test.js.map +0 -1
- package/dist/__tests__/memory-named-exists.test.d.ts +0 -16
- package/dist/__tests__/memory-named-exists.test.d.ts.map +0 -1
- package/dist/__tests__/memory-named-exists.test.js +0 -288
- package/dist/__tests__/memory-named-exists.test.js.map +0 -1
- package/dist/__tests__/message-bus.test.d.ts +0 -10
- package/dist/__tests__/message-bus.test.d.ts.map +0 -1
- package/dist/__tests__/message-bus.test.js +0 -526
- package/dist/__tests__/message-bus.test.js.map +0 -1
- package/dist/__tests__/monitor.test.d.ts +0 -6
- package/dist/__tests__/monitor.test.d.ts.map +0 -1
- package/dist/__tests__/monitor.test.js +0 -458
- package/dist/__tests__/monitor.test.js.map +0 -1
- package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts +0 -2
- package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts.map +0 -1
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js +0 -232
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js.map +0 -1
- package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts +0 -2
- package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts.map +0 -1
- package/dist/__tests__/mx-agent-cli-version-pin.test.js +0 -236
- package/dist/__tests__/mx-agent-cli-version-pin.test.js.map +0 -1
- package/dist/__tests__/new-project-first-team.test.d.ts +0 -15
- package/dist/__tests__/new-project-first-team.test.d.ts.map +0 -1
- package/dist/__tests__/new-project-first-team.test.js +0 -444
- package/dist/__tests__/new-project-first-team.test.js.map +0 -1
- package/dist/__tests__/otel-env.test.d.ts +0 -2
- package/dist/__tests__/otel-env.test.d.ts.map +0 -1
- package/dist/__tests__/otel-env.test.js +0 -127
- package/dist/__tests__/otel-env.test.js.map +0 -1
- package/dist/__tests__/pager-fail-closed.test.d.ts +0 -19
- package/dist/__tests__/pager-fail-closed.test.d.ts.map +0 -1
- package/dist/__tests__/pager-fail-closed.test.js +0 -229
- package/dist/__tests__/pager-fail-closed.test.js.map +0 -1
- package/dist/__tests__/pr-set-body.test.d.ts +0 -29
- package/dist/__tests__/pr-set-body.test.d.ts.map +0 -1
- package/dist/__tests__/pr-set-body.test.js +0 -314
- package/dist/__tests__/pr-set-body.test.js.map +0 -1
- package/dist/__tests__/prior-sync-failure.test.d.ts +0 -2
- package/dist/__tests__/prior-sync-failure.test.d.ts.map +0 -1
- package/dist/__tests__/prior-sync-failure.test.js +0 -81
- package/dist/__tests__/prior-sync-failure.test.js.map +0 -1
- package/dist/__tests__/project-config.test.d.ts +0 -2
- package/dist/__tests__/project-config.test.d.ts.map +0 -1
- package/dist/__tests__/project-config.test.js +0 -458
- package/dist/__tests__/project-config.test.js.map +0 -1
- package/dist/__tests__/provision-behavioral-contract.test.d.ts +0 -13
- package/dist/__tests__/provision-behavioral-contract.test.d.ts.map +0 -1
- package/dist/__tests__/provision-behavioral-contract.test.js +0 -548
- package/dist/__tests__/provision-behavioral-contract.test.js.map +0 -1
- package/dist/__tests__/provision-catalog-precondition.test.d.ts +0 -26
- package/dist/__tests__/provision-catalog-precondition.test.d.ts.map +0 -1
- package/dist/__tests__/provision-catalog-precondition.test.js +0 -622
- package/dist/__tests__/provision-catalog-precondition.test.js.map +0 -1
- package/dist/__tests__/provision-completion-rows.test.d.ts +0 -17
- package/dist/__tests__/provision-completion-rows.test.d.ts.map +0 -1
- package/dist/__tests__/provision-completion-rows.test.js +0 -3473
- package/dist/__tests__/provision-completion-rows.test.js.map +0 -1
- package/dist/__tests__/provision-copy-containment.test.d.ts +0 -19
- package/dist/__tests__/provision-copy-containment.test.d.ts.map +0 -1
- package/dist/__tests__/provision-copy-containment.test.js +0 -187
- package/dist/__tests__/provision-copy-containment.test.js.map +0 -1
- package/dist/__tests__/provision-identity-gate.test.d.ts +0 -20
- package/dist/__tests__/provision-identity-gate.test.d.ts.map +0 -1
- package/dist/__tests__/provision-identity-gate.test.js +0 -602
- package/dist/__tests__/provision-identity-gate.test.js.map +0 -1
- package/dist/__tests__/provision-resume.test.d.ts +0 -26
- package/dist/__tests__/provision-resume.test.d.ts.map +0 -1
- package/dist/__tests__/provision-resume.test.js +0 -1344
- package/dist/__tests__/provision-resume.test.js.map +0 -1
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts +0 -27
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts.map +0 -1
- package/dist/__tests__/provision-roleguide-anchors.test.js +0 -747
- package/dist/__tests__/provision-roleguide-anchors.test.js.map +0 -1
- package/dist/__tests__/provision-row12-stub-server.test.d.ts +0 -21
- package/dist/__tests__/provision-row12-stub-server.test.d.ts.map +0 -1
- package/dist/__tests__/provision-row12-stub-server.test.js +0 -264
- package/dist/__tests__/provision-row12-stub-server.test.js.map +0 -1
- package/dist/__tests__/provision-skeleton-fill.test.d.ts +0 -16
- package/dist/__tests__/provision-skeleton-fill.test.d.ts.map +0 -1
- package/dist/__tests__/provision-skeleton-fill.test.js +0 -490
- package/dist/__tests__/provision-skeleton-fill.test.js.map +0 -1
- package/dist/__tests__/provision-step8-commit.test.d.ts +0 -40
- package/dist/__tests__/provision-step8-commit.test.d.ts.map +0 -1
- package/dist/__tests__/provision-step8-commit.test.js +0 -529
- package/dist/__tests__/provision-step8-commit.test.js.map +0 -1
- package/dist/__tests__/provision-teambuilder-flow.test.d.ts +0 -22
- package/dist/__tests__/provision-teambuilder-flow.test.d.ts.map +0 -1
- package/dist/__tests__/provision-teambuilder-flow.test.js +0 -253
- package/dist/__tests__/provision-teambuilder-flow.test.js.map +0 -1
- package/dist/__tests__/provision-write-integrity.test.d.ts +0 -18
- package/dist/__tests__/provision-write-integrity.test.d.ts.map +0 -1
- package/dist/__tests__/provision-write-integrity.test.js +0 -141
- package/dist/__tests__/provision-write-integrity.test.js.map +0 -1
- package/dist/__tests__/repo-guard-wiring.test.d.ts +0 -21
- package/dist/__tests__/repo-guard-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/repo-guard-wiring.test.js +0 -638
- package/dist/__tests__/repo-guard-wiring.test.js.map +0 -1
- package/dist/__tests__/report-format.test.d.ts +0 -2
- package/dist/__tests__/report-format.test.d.ts.map +0 -1
- package/dist/__tests__/report-format.test.js +0 -219
- package/dist/__tests__/report-format.test.js.map +0 -1
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts +0 -20
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts.map +0 -1
- package/dist/__tests__/row15-detail-sanitizer.test.js +0 -61
- package/dist/__tests__/row15-detail-sanitizer.test.js.map +0 -1
- package/dist/__tests__/rows-9-10-zero-remotes.test.d.ts +0 -32
- package/dist/__tests__/rows-9-10-zero-remotes.test.d.ts.map +0 -1
- package/dist/__tests__/rows-9-10-zero-remotes.test.js +0 -203
- package/dist/__tests__/rows-9-10-zero-remotes.test.js.map +0 -1
- package/dist/__tests__/runtime-claude-adapter.test.d.ts +0 -2
- package/dist/__tests__/runtime-claude-adapter.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-claude-adapter.test.js +0 -70
- package/dist/__tests__/runtime-claude-adapter.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-adapter.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-adapter.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-adapter.test.js +0 -558
- package/dist/__tests__/runtime-codex-adapter.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-config.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-config.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-config.test.js +0 -1421
- package/dist/__tests__/runtime-codex-config.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js +0 -309
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-provider.test.js +0 -163
- package/dist/__tests__/runtime-codex-gateway-provider.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-guard-proof.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-guard-proof.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-guard-proof.test.js +0 -822
- package/dist/__tests__/runtime-codex-guard-proof.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-version-pin.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-version-pin.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-version-pin.test.js +0 -86
- package/dist/__tests__/runtime-codex-version-pin.test.js.map +0 -1
- package/dist/__tests__/runtime-identity.test.d.ts +0 -2
- package/dist/__tests__/runtime-identity.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-identity.test.js +0 -117
- package/dist/__tests__/runtime-identity.test.js.map +0 -1
- package/dist/__tests__/runtime-resolve.test.d.ts +0 -2
- package/dist/__tests__/runtime-resolve.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-resolve.test.js +0 -172
- package/dist/__tests__/runtime-resolve.test.js.map +0 -1
- package/dist/__tests__/security-posture.test.d.ts +0 -8
- package/dist/__tests__/security-posture.test.d.ts.map +0 -1
- package/dist/__tests__/security-posture.test.js +0 -82
- package/dist/__tests__/security-posture.test.js.map +0 -1
- package/dist/__tests__/session-model.test.d.ts +0 -2
- package/dist/__tests__/session-model.test.d.ts.map +0 -1
- package/dist/__tests__/session-model.test.js +0 -74
- package/dist/__tests__/session-model.test.js.map +0 -1
- package/dist/__tests__/session-pause-provisioning.test.d.ts +0 -19
- package/dist/__tests__/session-pause-provisioning.test.d.ts.map +0 -1
- package/dist/__tests__/session-pause-provisioning.test.js +0 -115
- package/dist/__tests__/session-pause-provisioning.test.js.map +0 -1
- package/dist/__tests__/session-reclamation.test.d.ts +0 -15
- package/dist/__tests__/session-reclamation.test.d.ts.map +0 -1
- package/dist/__tests__/session-reclamation.test.js +0 -73
- package/dist/__tests__/session-reclamation.test.js.map +0 -1
- package/dist/__tests__/session-record-disclosure.test.d.ts +0 -24
- package/dist/__tests__/session-record-disclosure.test.d.ts.map +0 -1
- package/dist/__tests__/session-record-disclosure.test.js +0 -494
- package/dist/__tests__/session-record-disclosure.test.js.map +0 -1
- package/dist/__tests__/session-status.test.d.ts +0 -11
- package/dist/__tests__/session-status.test.d.ts.map +0 -1
- package/dist/__tests__/session-status.test.js +0 -76
- package/dist/__tests__/session-status.test.js.map +0 -1
- package/dist/__tests__/session.test.d.ts +0 -15
- package/dist/__tests__/session.test.d.ts.map +0 -1
- package/dist/__tests__/session.test.js +0 -366
- package/dist/__tests__/session.test.js.map +0 -1
- package/dist/__tests__/shim-deploy-safety.test.d.ts +0 -24
- package/dist/__tests__/shim-deploy-safety.test.d.ts.map +0 -1
- package/dist/__tests__/shim-deploy-safety.test.js +0 -174
- package/dist/__tests__/shim-deploy-safety.test.js.map +0 -1
- package/dist/__tests__/slug-validation.test.d.ts +0 -13
- package/dist/__tests__/slug-validation.test.d.ts.map +0 -1
- package/dist/__tests__/slug-validation.test.js +0 -202
- package/dist/__tests__/slug-validation.test.js.map +0 -1
- package/dist/__tests__/standards-injection.test.d.ts +0 -2
- package/dist/__tests__/standards-injection.test.d.ts.map +0 -1
- package/dist/__tests__/standards-injection.test.js +0 -179
- package/dist/__tests__/standards-injection.test.js.map +0 -1
- package/dist/__tests__/start-config-conflict.test.d.ts +0 -17
- package/dist/__tests__/start-config-conflict.test.d.ts.map +0 -1
- package/dist/__tests__/start-config-conflict.test.js +0 -101
- package/dist/__tests__/start-config-conflict.test.js.map +0 -1
- package/dist/__tests__/start-interactive-role.test.d.ts +0 -22
- package/dist/__tests__/start-interactive-role.test.d.ts.map +0 -1
- package/dist/__tests__/start-interactive-role.test.js +0 -204
- package/dist/__tests__/start-interactive-role.test.js.map +0 -1
- package/dist/__tests__/start-rebase-never-ran.test.d.ts +0 -25
- package/dist/__tests__/start-rebase-never-ran.test.d.ts.map +0 -1
- package/dist/__tests__/start-rebase-never-ran.test.js +0 -227
- package/dist/__tests__/start-rebase-never-ran.test.js.map +0 -1
- package/dist/__tests__/start-report-generation-capture.test.d.ts +0 -17
- package/dist/__tests__/start-report-generation-capture.test.d.ts.map +0 -1
- package/dist/__tests__/start-report-generation-capture.test.js +0 -127
- package/dist/__tests__/start-report-generation-capture.test.js.map +0 -1
- package/dist/__tests__/start-report-integration.test.d.ts +0 -12
- package/dist/__tests__/start-report-integration.test.d.ts.map +0 -1
- package/dist/__tests__/start-report-integration.test.js +0 -138
- package/dist/__tests__/start-report-integration.test.js.map +0 -1
- package/dist/__tests__/start-runtime-wiring.test.d.ts +0 -31
- package/dist/__tests__/start-runtime-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/start-runtime-wiring.test.js +0 -735
- package/dist/__tests__/start-runtime-wiring.test.js.map +0 -1
- package/dist/__tests__/start-stash.test.d.ts +0 -2
- package/dist/__tests__/start-stash.test.d.ts.map +0 -1
- package/dist/__tests__/start-stash.test.js +0 -131
- package/dist/__tests__/start-stash.test.js.map +0 -1
- package/dist/__tests__/start-sync-hardstop.test.d.ts +0 -15
- package/dist/__tests__/start-sync-hardstop.test.d.ts.map +0 -1
- package/dist/__tests__/start-sync-hardstop.test.js +0 -280
- package/dist/__tests__/start-sync-hardstop.test.js.map +0 -1
- package/dist/__tests__/start-team-identity.test.d.ts +0 -25
- package/dist/__tests__/start-team-identity.test.d.ts.map +0 -1
- package/dist/__tests__/start-team-identity.test.js +0 -307
- package/dist/__tests__/start-team-identity.test.js.map +0 -1
- package/dist/__tests__/startup-health-render.test.d.ts +0 -11
- package/dist/__tests__/startup-health-render.test.d.ts.map +0 -1
- package/dist/__tests__/startup-health-render.test.js +0 -60
- package/dist/__tests__/startup-health-render.test.js.map +0 -1
- package/dist/__tests__/startup-policy.test.d.ts +0 -2
- package/dist/__tests__/startup-policy.test.d.ts.map +0 -1
- package/dist/__tests__/startup-policy.test.js +0 -27
- package/dist/__tests__/startup-policy.test.js.map +0 -1
- package/dist/__tests__/startup-report.test.d.ts +0 -13
- package/dist/__tests__/startup-report.test.d.ts.map +0 -1
- package/dist/__tests__/startup-report.test.js +0 -278
- package/dist/__tests__/startup-report.test.js.map +0 -1
- package/dist/__tests__/startup-shipper.test.d.ts +0 -13
- package/dist/__tests__/startup-shipper.test.d.ts.map +0 -1
- package/dist/__tests__/startup-shipper.test.js +0 -149
- package/dist/__tests__/startup-shipper.test.js.map +0 -1
- package/dist/__tests__/stream-input-controller.test.d.ts +0 -10
- package/dist/__tests__/stream-input-controller.test.d.ts.map +0 -1
- package/dist/__tests__/stream-input-controller.test.js +0 -167
- package/dist/__tests__/stream-input-controller.test.js.map +0 -1
- package/dist/__tests__/team-memory-commands.test.d.ts +0 -11
- package/dist/__tests__/team-memory-commands.test.d.ts.map +0 -1
- package/dist/__tests__/team-memory-commands.test.js +0 -240
- package/dist/__tests__/team-memory-commands.test.js.map +0 -1
- package/dist/__tests__/team-name-propagation.test.d.ts +0 -13
- package/dist/__tests__/team-name-propagation.test.d.ts.map +0 -1
- package/dist/__tests__/team-name-propagation.test.js +0 -198
- package/dist/__tests__/team-name-propagation.test.js.map +0 -1
- package/dist/__tests__/team-token-probe.test.d.ts +0 -16
- package/dist/__tests__/team-token-probe.test.d.ts.map +0 -1
- package/dist/__tests__/team-token-probe.test.js +0 -295
- package/dist/__tests__/team-token-probe.test.js.map +0 -1
- package/dist/__tests__/template-budget.test.d.ts +0 -2
- package/dist/__tests__/template-budget.test.d.ts.map +0 -1
- package/dist/__tests__/template-budget.test.js +0 -119
- package/dist/__tests__/template-budget.test.js.map +0 -1
- package/dist/__tests__/template-sync.test.d.ts +0 -19
- package/dist/__tests__/template-sync.test.d.ts.map +0 -1
- package/dist/__tests__/template-sync.test.js +0 -480
- package/dist/__tests__/template-sync.test.js.map +0 -1
- package/dist/__tests__/test-project.test.d.ts +0 -18
- package/dist/__tests__/test-project.test.d.ts.map +0 -1
- package/dist/__tests__/test-project.test.js +0 -465
- package/dist/__tests__/test-project.test.js.map +0 -1
- package/dist/__tests__/tracked-instruction-files.test.d.ts +0 -21
- package/dist/__tests__/tracked-instruction-files.test.d.ts.map +0 -1
- package/dist/__tests__/tracked-instruction-files.test.js +0 -489
- package/dist/__tests__/tracked-instruction-files.test.js.map +0 -1
- package/dist/__tests__/unlock.test.d.ts +0 -11
- package/dist/__tests__/unlock.test.d.ts.map +0 -1
- package/dist/__tests__/unlock.test.js +0 -100
- package/dist/__tests__/unlock.test.js.map +0 -1
- package/dist/__tests__/usage-per-call-grouping.test.d.ts +0 -25
- package/dist/__tests__/usage-per-call-grouping.test.d.ts.map +0 -1
- package/dist/__tests__/usage-per-call-grouping.test.js +0 -952
- package/dist/__tests__/usage-per-call-grouping.test.js.map +0 -1
- package/dist/__tests__/usage-pricing.test.d.ts +0 -20
- package/dist/__tests__/usage-pricing.test.d.ts.map +0 -1
- package/dist/__tests__/usage-pricing.test.js +0 -176
- package/dist/__tests__/usage-pricing.test.js.map +0 -1
- package/dist/__tests__/usage-subagent-discovery.test.d.ts +0 -17
- package/dist/__tests__/usage-subagent-discovery.test.d.ts.map +0 -1
- package/dist/__tests__/usage-subagent-discovery.test.js +0 -213
- package/dist/__tests__/usage-subagent-discovery.test.js.map +0 -1
- package/dist/__tests__/verify-hooks-check-all.test.d.ts +0 -32
- package/dist/__tests__/verify-hooks-check-all.test.d.ts.map +0 -1
- package/dist/__tests__/verify-hooks-check-all.test.js +0 -563
- package/dist/__tests__/verify-hooks-check-all.test.js.map +0 -1
- package/dist/__tests__/verify-hooks-heal-log.test.d.ts +0 -11
- package/dist/__tests__/verify-hooks-heal-log.test.d.ts.map +0 -1
- package/dist/__tests__/verify-hooks-heal-log.test.js +0 -172
- package/dist/__tests__/verify-hooks-heal-log.test.js.map +0 -1
- package/dist/__tests__/worker-cap.test.d.ts +0 -14
- package/dist/__tests__/worker-cap.test.d.ts.map +0 -1
- package/dist/__tests__/worker-cap.test.js +0 -97
- package/dist/__tests__/worker-cap.test.js.map +0 -1
- package/dist/__tests__/worktree-link-repair.test.d.ts +0 -2
- package/dist/__tests__/worktree-link-repair.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-link-repair.test.js +0 -471
- package/dist/__tests__/worktree-link-repair.test.js.map +0 -1
- package/dist/__tests__/worktree-sync-fixture.test.d.ts +0 -17
- package/dist/__tests__/worktree-sync-fixture.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-sync-fixture.test.js +0 -519
- package/dist/__tests__/worktree-sync-fixture.test.js.map +0 -1
- package/dist/__tests__/worktree-sync-hardening.test.d.ts +0 -13
- package/dist/__tests__/worktree-sync-hardening.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-sync-hardening.test.js +0 -919
- package/dist/__tests__/worktree-sync-hardening.test.js.map +0 -1
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts +0 -25
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-sync-shell-free.test.js +0 -185
- package/dist/__tests__/worktree-sync-shell-free.test.js.map +0 -1
- package/dist/__tests__/worktree.test.d.ts +0 -2
- package/dist/__tests__/worktree.test.d.ts.map +0 -1
- package/dist/__tests__/worktree.test.js +0 -168
- package/dist/__tests__/worktree.test.js.map +0 -1
- package/dist/lib/code-context-file.test.d.ts +0 -19
- package/dist/lib/code-context-file.test.d.ts.map +0 -1
- package/dist/lib/code-context-file.test.js +0 -202
- package/dist/lib/code-context-file.test.js.map +0 -1
- package/dist/lib/harness/console/announce.test.d.ts +0 -2
- package/dist/lib/harness/console/announce.test.d.ts.map +0 -1
- package/dist/lib/harness/console/announce.test.js +0 -104
- package/dist/lib/harness/console/announce.test.js.map +0 -1
- package/dist/lib/harness/console/by-session.test.d.ts +0 -2
- package/dist/lib/harness/console/by-session.test.d.ts.map +0 -1
- package/dist/lib/harness/console/by-session.test.js +0 -86
- package/dist/lib/harness/console/by-session.test.js.map +0 -1
- package/dist/lib/harness/console/console.test.d.ts +0 -2
- package/dist/lib/harness/console/console.test.d.ts.map +0 -1
- package/dist/lib/harness/console/console.test.js +0 -269
- package/dist/lib/harness/console/console.test.js.map +0 -1
- package/dist/lib/harness/console/decision-request.test.d.ts +0 -2
- package/dist/lib/harness/console/decision-request.test.d.ts.map +0 -1
- package/dist/lib/harness/console/decision-request.test.js +0 -75
- package/dist/lib/harness/console/decision-request.test.js.map +0 -1
- package/dist/lib/harness/console/rank.test.d.ts +0 -2
- package/dist/lib/harness/console/rank.test.d.ts.map +0 -1
- package/dist/lib/harness/console/rank.test.js +0 -124
- package/dist/lib/harness/console/rank.test.js.map +0 -1
- package/dist/lib/harness/console/render.test.d.ts +0 -2
- package/dist/lib/harness/console/render.test.d.ts.map +0 -1
- package/dist/lib/harness/console/render.test.js +0 -96
- package/dist/lib/harness/console/render.test.js.map +0 -1
- package/dist/lib/harness/console/replay-cli.test.d.ts +0 -2
- package/dist/lib/harness/console/replay-cli.test.d.ts.map +0 -1
- package/dist/lib/harness/console/replay-cli.test.js +0 -96
- package/dist/lib/harness/console/replay-cli.test.js.map +0 -1
- package/dist/lib/harness/console/replay.test.d.ts +0 -2
- package/dist/lib/harness/console/replay.test.d.ts.map +0 -1
- package/dist/lib/harness/console/replay.test.js +0 -81
- package/dist/lib/harness/console/replay.test.js.map +0 -1
- package/dist/lib/harness/console/turn-reader.test.d.ts +0 -2
- package/dist/lib/harness/console/turn-reader.test.d.ts.map +0 -1
- package/dist/lib/harness/console/turn-reader.test.js +0 -108
- package/dist/lib/harness/console/turn-reader.test.js.map +0 -1
- package/dist/lib/harness/credential.test.d.ts +0 -2
- package/dist/lib/harness/credential.test.d.ts.map +0 -1
- package/dist/lib/harness/credential.test.js +0 -74
- package/dist/lib/harness/credential.test.js.map +0 -1
- package/dist/lib/harness/evaluate.test.d.ts +0 -2
- package/dist/lib/harness/evaluate.test.d.ts.map +0 -1
- package/dist/lib/harness/evaluate.test.js +0 -621
- package/dist/lib/harness/evaluate.test.js.map +0 -1
- package/dist/lib/harness/gate.test.d.ts +0 -2
- package/dist/lib/harness/gate.test.d.ts.map +0 -1
- package/dist/lib/harness/gate.test.js +0 -111
- package/dist/lib/harness/gate.test.js.map +0 -1
- package/dist/lib/harness/self-check.test.d.ts +0 -2
- package/dist/lib/harness/self-check.test.d.ts.map +0 -1
- package/dist/lib/harness/self-check.test.js +0 -43
- package/dist/lib/harness/self-check.test.js.map +0 -1
- package/dist/lib/harness/transcript.test.d.ts +0 -2
- package/dist/lib/harness/transcript.test.d.ts.map +0 -1
- package/dist/lib/harness/transcript.test.js +0 -118
- package/dist/lib/harness/transcript.test.js.map +0 -1
- package/dist/lib/projects-registry.test.d.ts +0 -2
- package/dist/lib/projects-registry.test.d.ts.map +0 -1
- package/dist/lib/projects-registry.test.js +0 -176
- package/dist/lib/projects-registry.test.js.map +0 -1
- package/dist/lib/roster.test.d.ts +0 -15
- package/dist/lib/roster.test.d.ts.map +0 -1
- package/dist/lib/roster.test.js +0 -299
- package/dist/lib/roster.test.js.map +0 -1
- package/dist/lib/vault.test.d.ts +0 -17
- package/dist/lib/vault.test.d.ts.map +0 -1
- package/dist/lib/vault.test.js +0 -169
- package/dist/lib/vault.test.js.map +0 -1
- package/dist/lib/window-view.test.d.ts +0 -2
- package/dist/lib/window-view.test.d.ts.map +0 -1
- package/dist/lib/window-view.test.js +0 -168
- package/dist/lib/window-view.test.js.map +0 -1
- package/dist/standards/fail-loud-standard.md +0 -495
- package/dist/standards/known-issues-standard.md +0 -380
- package/dist/standards/rulings.md +0 -104
|
@@ -1,1292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* #288 (C3 of #164) — `mx-agent` obtains its coordination token from
|
|
3
|
-
* POST /admin/credential, and every other project keeps Key Vault.
|
|
4
|
-
*
|
|
5
|
-
* What these tests are written to catch, stated as mutations they must fail on:
|
|
6
|
-
* - the switch widening, so a `spearmint-private` or `memnexus` session starts
|
|
7
|
-
* presenting a user key to a service that holds no grant for it;
|
|
8
|
-
* - the 403 message growing a word that distinguishes a registered team from
|
|
9
|
-
* an unregistered one, which turns a shared deployment into an enumeration
|
|
10
|
-
* oracle;
|
|
11
|
-
* - a 503 being reported as `unprovisioned`, which sends an operator to
|
|
12
|
-
* provision something that already exists, or being swallowed entirely;
|
|
13
|
-
* - the #220 interlock being dropped, so a cwd mismatch obtains a real token
|
|
14
|
-
* for a team the session never selected;
|
|
15
|
-
* - the refresh path deleting the cache before it holds a replacement (#4970);
|
|
16
|
-
* - the user key reaching stdout, stderr, an error, or the cache.
|
|
17
|
-
*
|
|
18
|
-
* NO NETWORK LEAVES THIS MACHINE. The wire-level cases run against an
|
|
19
|
-
* http.Server on 127.0.0.1; the classification cases inject a fetcher. No test
|
|
20
|
-
* reads the operator's real MemNexus key: every key here is the literal
|
|
21
|
-
* FAKE_USER_KEY below.
|
|
22
|
-
*/
|
|
23
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
24
|
-
import { createServer } from 'node:http';
|
|
25
|
-
import { lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync, existsSync, } from 'node:fs';
|
|
26
|
-
import { join, dirname } from 'node:path';
|
|
27
|
-
import { fileURLToPath } from 'node:url';
|
|
28
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
29
|
-
import { tmpdir } from 'node:os';
|
|
30
|
-
// No configured token and no configured URL: every test states its own service
|
|
31
|
-
// URL, so nothing reads the developer's ~/.mx-agent/config.json.
|
|
32
|
-
vi.mock('../lib/config.js', () => ({
|
|
33
|
-
getConfigValue: vi.fn(() => undefined),
|
|
34
|
-
getConfigPath: () => '/nonexistent/config.json',
|
|
35
|
-
}));
|
|
36
|
-
/**
|
|
37
|
-
* The coordination URL resolves to nothing unless a test states one.
|
|
38
|
-
*
|
|
39
|
-
* Without this the resolver reads the committed `mx-agent.config.json` of
|
|
40
|
-
* whatever checkout runs the suite, and this repository names a real service
|
|
41
|
-
* there, so "no URL is configured" was unreachable and the case it guards went
|
|
42
|
-
* untested. Every other export is the real one.
|
|
43
|
-
*/
|
|
44
|
-
vi.mock('../lib/coordination-client.js', async (importOriginal) => ({
|
|
45
|
-
...(await importOriginal()),
|
|
46
|
-
resolveCoordinationUrl: vi.fn(() => null),
|
|
47
|
-
projectUrlValidationError: vi.fn(() => undefined),
|
|
48
|
-
}));
|
|
49
|
-
import { resolveCoordinationToken, refreshCoordinationToken, usesCredentialEndpoint, provisionCredentialForWorktree, credentialCacheState, KEY_VAULT_PROJECTS, CREDENTIAL_NOT_AUTHORIZED_DETAIL, CREDENTIAL_INVALID_KEY_DETAIL, CREDENTIAL_UNAVAILABLE_DETAIL, CREDENTIAL_LIMIT_REACHED_DETAIL, USER_KEY_HEADER, ENV_KEY_ROSTER_FILE, KEYVAULT_NAME, } from '../lib/coordination-token.js';
|
|
50
|
-
/** The only key any test in this file uses. It is not a real credential. */
|
|
51
|
-
const FAKE_USER_KEY = 'mx-fake-user-key-DO-NOT-USE-0123456789';
|
|
52
|
-
const PROJECT = 'mx-agent';
|
|
53
|
-
const TEAM = 'bootstrap';
|
|
54
|
-
const CACHE = `.mx-coordination-token--${PROJECT}--${TEAM}`;
|
|
55
|
-
let dir;
|
|
56
|
-
beforeEach(() => {
|
|
57
|
-
dir = mkdtempSync(join(tmpdir(), 'coord-credential-'));
|
|
58
|
-
});
|
|
59
|
-
afterEach(() => {
|
|
60
|
-
rmSync(dir, { recursive: true, force: true });
|
|
61
|
-
vi.restoreAllMocks();
|
|
62
|
-
});
|
|
63
|
-
/** A worktree with a marker naming `team`. */
|
|
64
|
-
function worktree(team = TEAM) {
|
|
65
|
-
writeFileSync(join(dir, '.mx-coordination-team'), `${team}\n`);
|
|
66
|
-
return { CLAUDE_WORKTREE_PATH: dir };
|
|
67
|
-
}
|
|
68
|
-
/** A fetcher that records every request and answers with a fixed outcome. */
|
|
69
|
-
function fetcher(outcome) {
|
|
70
|
-
const calls = [];
|
|
71
|
-
const fn = async (req) => {
|
|
72
|
-
calls.push({ url: req.url, project: req.project, team: req.team, userKey: req.userKey });
|
|
73
|
-
return typeof outcome === 'function' ? outcome(calls.length) : outcome;
|
|
74
|
-
};
|
|
75
|
-
return { fn, calls };
|
|
76
|
-
}
|
|
77
|
-
/** The deps every credential test shares, minus the fetcher. */
|
|
78
|
-
function baseDeps(env) {
|
|
79
|
-
return {
|
|
80
|
-
env,
|
|
81
|
-
project: PROJECT,
|
|
82
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
83
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
// ── The switch ───────────────────────────────────────────────────────────────
|
|
87
|
-
describe('the project switch (#288; a denylist since #507)', () => {
|
|
88
|
-
it('names memnexus and spearmint-private as the Key Vault projects, and nothing else', () => {
|
|
89
|
-
// The list is the whole switch. Before #507 it was an allowlist of
|
|
90
|
-
// credential-endpoint projects (`mx-agent`, `mx-agent-test`), so a project
|
|
91
|
-
// created the day before needed a vault secret per team. #507 lets the
|
|
92
|
-
// service create a new project on its first authenticated request, so the
|
|
93
|
-
// default flipped. Removing an entry moves that project off Key Vault, a
|
|
94
|
-
// deliberate migration, and this pins the list so one cannot happen silently.
|
|
95
|
-
expect([...KEY_VAULT_PROJECTS]).toEqual(['memnexus', 'spearmint-private']);
|
|
96
|
-
expect(usesCredentialEndpoint('memnexus')).toBe(false);
|
|
97
|
-
expect(usesCredentialEndpoint('spearmint-private')).toBe(false);
|
|
98
|
-
});
|
|
99
|
-
it('sends every other project to the credential endpoint, including one nobody has seen', () => {
|
|
100
|
-
// `mx-agent` and `mx-agent-test` keep the path they had. `life-planner` is
|
|
101
|
-
// the first real project #507 is for; the other two stand for any slug.
|
|
102
|
-
for (const project of ['mx-agent', 'mx-agent-test', 'life-planner', 'brand-new-project', 'zz']) {
|
|
103
|
-
expect(usesCredentialEndpoint(project), project).toBe(true);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
describe('a project that is not on the denylist resolves from POST /admin/credential (#507)', () => {
|
|
108
|
-
it('a new project with no roster entry anywhere requests a credential and reads no vault', async () => {
|
|
109
|
-
// No roster file lists `life-planner`. Before #507 this was `not-on-roster`
|
|
110
|
-
// from the offline gate, with no request made.
|
|
111
|
-
const env = worktree('planner');
|
|
112
|
-
const fetchSecret = vi.fn(() => 'kv-token');
|
|
113
|
-
const f = fetcher({ status: 'issued', token: 'issued-token-new-project' });
|
|
114
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), project: 'life-planner', fetchSecret, fetchCredential: f.fn });
|
|
115
|
-
expect(res.status).toBe('resolved');
|
|
116
|
-
expect(res.source).toBe('credential');
|
|
117
|
-
expect(res.token).toBe('issued-token-new-project');
|
|
118
|
-
expect(f.calls).toEqual([expect.objectContaining({ project: 'life-planner', team: 'planner' })]);
|
|
119
|
-
expect(fetchSecret).not.toHaveBeenCalled();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
// ── The first resolve ────────────────────────────────────────────────────────
|
|
123
|
-
describe('mx-agent resolves its token from POST /admin/credential', () => {
|
|
124
|
-
it('a cold cache obtains a token, caches it born 0600, and asks once', async () => {
|
|
125
|
-
const env = worktree();
|
|
126
|
-
const f = fetcher({ status: 'issued', token: 'issued-token-1' });
|
|
127
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
128
|
-
expect(res.status).toBe('resolved');
|
|
129
|
-
expect(res.source).toBe('credential');
|
|
130
|
-
expect(res.token).toBe('issued-token-1');
|
|
131
|
-
expect(res.project).toBe(PROJECT);
|
|
132
|
-
expect(res.slug).toBe(TEAM);
|
|
133
|
-
expect(f.calls).toHaveLength(1);
|
|
134
|
-
expect(f.calls[0]).toMatchObject({ project: PROJECT, team: TEAM, userKey: FAKE_USER_KEY });
|
|
135
|
-
const cachePath = join(dir, CACHE);
|
|
136
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('issued-token-1');
|
|
137
|
-
expect(statSync(cachePath).mode & 0o777).toBe(0o600);
|
|
138
|
-
});
|
|
139
|
-
it('a warm cache makes no credential call at all', async () => {
|
|
140
|
-
const env = worktree();
|
|
141
|
-
writeFileSync(join(dir, CACHE), 'cached-token\n', { mode: 0o600 });
|
|
142
|
-
const f = fetcher({ status: 'issued', token: 'should-never-be-fetched' });
|
|
143
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
144
|
-
expect(res.status).toBe('resolved');
|
|
145
|
-
expect(res.source).toBe('cache');
|
|
146
|
-
expect(res.token).toBe('cached-token');
|
|
147
|
-
expect(f.calls).toHaveLength(0);
|
|
148
|
-
});
|
|
149
|
-
it('MX_COORD_SERVICE_TOKEN still short-circuits everything', async () => {
|
|
150
|
-
const env = { ...worktree(), MX_COORD_SERVICE_TOKEN: 'env-token' };
|
|
151
|
-
const f = fetcher({ status: 'issued', token: 'never' });
|
|
152
|
-
const readUserKey = vi.fn(() => FAKE_USER_KEY);
|
|
153
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), readUserKey, fetchCredential: f.fn });
|
|
154
|
-
expect(res.status).toBe('already-configured');
|
|
155
|
-
expect(res.source).toBe('env');
|
|
156
|
-
expect(f.calls).toHaveLength(0);
|
|
157
|
-
// The key is not even read on this path.
|
|
158
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
159
|
-
});
|
|
160
|
-
it('serves a team the offline roster file does not list', async () => {
|
|
161
|
-
// The service's grant table decides membership on this path. An offline file
|
|
162
|
-
// that predates a registration must not refuse a team the service admits.
|
|
163
|
-
const env = { ...worktree('a-team-no-file-lists'), [ENV_KEY_ROSTER_FILE]: join(dir, 'nope.json') };
|
|
164
|
-
const f = fetcher({ status: 'issued', token: 'issued-for-unrostered' });
|
|
165
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
166
|
-
expect(res.status).toBe('resolved');
|
|
167
|
-
expect(res.token).toBe('issued-for-unrostered');
|
|
168
|
-
expect(f.calls[0].team).toBe('a-team-no-file-lists');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
// ── The four refusals, each said in its own words ────────────────────────────
|
|
172
|
-
describe('what a refusal says', () => {
|
|
173
|
-
it('401 names the key and says nothing about the team', async () => {
|
|
174
|
-
const env = worktree();
|
|
175
|
-
const f = fetcher({ status: 'invalid-key' });
|
|
176
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
177
|
-
expect(res.status).toBe('invalid-key');
|
|
178
|
-
expect(res.detail).toBe(CREDENTIAL_INVALID_KEY_DETAIL);
|
|
179
|
-
expect(res.detail).toMatch(/user key/i);
|
|
180
|
-
// Nothing about the team, which the service has not looked at yet.
|
|
181
|
-
expect(res.detail).not.toContain(TEAM);
|
|
182
|
-
// Not the word at all: a sentence about "the team" would be a sentence the
|
|
183
|
-
// 403 case does not get, and the two must not be told apart by shape.
|
|
184
|
-
expect(res.detail).not.toMatch(/team/i);
|
|
185
|
-
expect(res.detail).not.toContain(FAKE_USER_KEY);
|
|
186
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
187
|
-
});
|
|
188
|
-
it('403 reads identically for a registered and an unregistered team', async () => {
|
|
189
|
-
// The service answers a byte-identical 403 either way. The CLI must add no
|
|
190
|
-
// word that separates them: same detail, same status, for both teams.
|
|
191
|
-
const registered = fetcher({ status: 'not-authorized' });
|
|
192
|
-
const unregistered = fetcher({ status: 'not-authorized' });
|
|
193
|
-
const a = await resolveCoordinationToken({
|
|
194
|
-
...baseDeps(worktree('bootstrap')),
|
|
195
|
-
fetchCredential: registered.fn,
|
|
196
|
-
});
|
|
197
|
-
rmSync(join(dir, '.mx-coordination-team'));
|
|
198
|
-
const b = await resolveCoordinationToken({
|
|
199
|
-
...baseDeps(worktree('no-such-team-anywhere')),
|
|
200
|
-
fetchCredential: unregistered.fn,
|
|
201
|
-
});
|
|
202
|
-
expect(a.status).toBe('not-authorized');
|
|
203
|
-
expect(b.status).toBe('not-authorized');
|
|
204
|
-
expect(a.detail).toBe(b.detail);
|
|
205
|
-
expect(a.detail).toBe(CREDENTIAL_NOT_AUTHORIZED_DETAIL);
|
|
206
|
-
// Neither team's name appears, so the two messages cannot be told apart.
|
|
207
|
-
expect(a.detail).not.toContain('bootstrap');
|
|
208
|
-
expect(b.detail).not.toContain('no-such-team-anywhere');
|
|
209
|
-
// It names the remedy, which is the same remedy in both cases.
|
|
210
|
-
expect(a.detail).toContain('grant');
|
|
211
|
-
});
|
|
212
|
-
it('503 at the concurrency ceiling is unavailable with a retry, never unprovisioned', async () => {
|
|
213
|
-
const env = worktree();
|
|
214
|
-
const f = fetcher({ status: 'unavailable' });
|
|
215
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
216
|
-
expect(res.status).toBe('unavailable');
|
|
217
|
-
expect(res.status).not.toBe('unprovisioned');
|
|
218
|
-
expect(res.detail).toContain('UNAVAILABLE');
|
|
219
|
-
expect(res.detail).toMatch(/retry/i);
|
|
220
|
-
// Could-not-run is not a refusal and not a missing team.
|
|
221
|
-
expect(res.detail).not.toContain('grant');
|
|
222
|
-
expect(res.token).toBeUndefined();
|
|
223
|
-
// Nothing is cached from a failure.
|
|
224
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
225
|
-
});
|
|
226
|
-
it('409 reports the service roster, which only a grant holder can reach', async () => {
|
|
227
|
-
const env = worktree();
|
|
228
|
-
const f = fetcher({ status: 'not-registered' });
|
|
229
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
230
|
-
expect(res.status).toBe('not-on-roster');
|
|
231
|
-
expect(res.detail).toMatch(/roster/i);
|
|
232
|
-
});
|
|
233
|
-
it('a 200 carrying a blank token is unavailable, and writes no cache', async () => {
|
|
234
|
-
const env = worktree();
|
|
235
|
-
const writeCache = vi.fn();
|
|
236
|
-
for (const blank of ['', ' ', '\n\t ']) {
|
|
237
|
-
const f = fetcher({ status: 'issued', token: blank });
|
|
238
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn, writeCache });
|
|
239
|
-
expect(res.status).toBe('unavailable');
|
|
240
|
-
expect(res.token).toBeUndefined();
|
|
241
|
-
}
|
|
242
|
-
expect(writeCache).not.toHaveBeenCalled();
|
|
243
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
// ── The #220 interlock ───────────────────────────────────────────────────────
|
|
247
|
-
describe('the #220 interlock refuses before any network call', () => {
|
|
248
|
-
it('refuses a team mismatch and asks for no credential', async () => {
|
|
249
|
-
const env = { ...worktree('bootstrap'), MX_COORD_EXPECT_TEAM: 'surface' };
|
|
250
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
251
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
252
|
-
expect(res.status).toBe('identity-mismatch');
|
|
253
|
-
expect(res.detail).toContain('bootstrap');
|
|
254
|
-
expect(res.detail).toContain('surface');
|
|
255
|
-
expect(f.calls).toHaveLength(0);
|
|
256
|
-
expect(res.token).toBeUndefined();
|
|
257
|
-
});
|
|
258
|
-
it('refuses a project mismatch and asks for no credential', async () => {
|
|
259
|
-
const env = { ...worktree(), MX_COORD_EXPECT_PROJECT: 'memnexus' };
|
|
260
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
261
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
262
|
-
expect(res.status).toBe('identity-mismatch');
|
|
263
|
-
expect(res.detail).toContain('mx-agent');
|
|
264
|
-
expect(res.detail).toContain('memnexus');
|
|
265
|
-
expect(f.calls).toHaveLength(0);
|
|
266
|
-
});
|
|
267
|
-
it('refuses a mismatch the CALLER asserts, not only one the environment does', async () => {
|
|
268
|
-
const env = worktree('bootstrap');
|
|
269
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
270
|
-
const res = await resolveCoordinationToken({
|
|
271
|
-
...baseDeps(env),
|
|
272
|
-
expect: { project: PROJECT, team: 'gateway' },
|
|
273
|
-
fetchCredential: f.fn,
|
|
274
|
-
});
|
|
275
|
-
expect(res.status).toBe('identity-mismatch');
|
|
276
|
-
expect(f.calls).toHaveLength(0);
|
|
277
|
-
});
|
|
278
|
-
it('proceeds when the assertion agrees with the resolved identity', async () => {
|
|
279
|
-
const env = { ...worktree(), MX_COORD_EXPECT_TEAM: TEAM, MX_COORD_EXPECT_PROJECT: PROJECT };
|
|
280
|
-
const f = fetcher({ status: 'issued', token: 'issued-token-2' });
|
|
281
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
282
|
-
expect(res.status).toBe('resolved');
|
|
283
|
-
expect(f.calls).toHaveLength(1);
|
|
284
|
-
});
|
|
285
|
-
it('refuses the same mismatch on the refresh path', async () => {
|
|
286
|
-
const env = { ...worktree('bootstrap'), MX_COORD_EXPECT_TEAM: 'surface' };
|
|
287
|
-
writeFileSync(join(dir, CACHE), 'rejected-token', { mode: 0o600 });
|
|
288
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
289
|
-
const res = await refreshCoordinationToken('rejected-token', { ...baseDeps(env), fetchCredential: f.fn });
|
|
290
|
-
expect(res.status).toBe('identity-mismatch');
|
|
291
|
-
expect(f.calls).toHaveLength(0);
|
|
292
|
-
// A refusal deletes nothing.
|
|
293
|
-
expect(readFileSync(join(dir, CACHE), 'utf-8')).toBe('rejected-token');
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
// ── The 401 refresh, with #4970's ordering intact ────────────────────────────
|
|
297
|
-
describe('the 401 refresh on the credential path', () => {
|
|
298
|
-
it('refetches exactly once and replaces the cache born 0600', async () => {
|
|
299
|
-
const env = worktree();
|
|
300
|
-
const cachePath = join(dir, CACHE);
|
|
301
|
-
writeFileSync(cachePath, 'rejected-token', { mode: 0o600 });
|
|
302
|
-
const f = fetcher({ status: 'issued', token: 'fresh-token' });
|
|
303
|
-
const res = await refreshCoordinationToken('rejected-token', { ...baseDeps(env), fetchCredential: f.fn });
|
|
304
|
-
expect(res.status).toBe('refreshed');
|
|
305
|
-
expect(res.token).toBe('fresh-token');
|
|
306
|
-
expect(res.source).toBe('credential');
|
|
307
|
-
expect(res.cacheInvalidated).toBe(true);
|
|
308
|
-
expect(f.calls).toHaveLength(1);
|
|
309
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('fresh-token');
|
|
310
|
-
expect(statSync(cachePath).mode & 0o777).toBe(0o600);
|
|
311
|
-
});
|
|
312
|
-
it('uses a cache another process already replaced, and asks for nothing', async () => {
|
|
313
|
-
const env = worktree();
|
|
314
|
-
writeFileSync(join(dir, CACHE), 'someone-elses-fresh-token', { mode: 0o600 });
|
|
315
|
-
const f = fetcher({ status: 'issued', token: 'unnecessary' });
|
|
316
|
-
const res = await refreshCoordinationToken('rejected-token', { ...baseDeps(env), fetchCredential: f.fn });
|
|
317
|
-
expect(res.status).toBe('refreshed');
|
|
318
|
-
expect(res.source).toBe('cache');
|
|
319
|
-
expect(res.token).toBe('someone-elses-fresh-token');
|
|
320
|
-
expect(f.calls).toHaveLength(0);
|
|
321
|
-
});
|
|
322
|
-
it('keeps the rejected token on disk when the service refuses, and says why', async () => {
|
|
323
|
-
// #4970: fetch first, delete only on success. Deleting a cache we have no
|
|
324
|
-
// replacement for turns a loud repeating failure into permanent silence.
|
|
325
|
-
const env = worktree();
|
|
326
|
-
const cachePath = join(dir, CACHE);
|
|
327
|
-
writeFileSync(cachePath, 'rejected-token', { mode: 0o600 });
|
|
328
|
-
const f = fetcher({ status: 'not-authorized' });
|
|
329
|
-
const res = await refreshCoordinationToken('rejected-token', { ...baseDeps(env), fetchCredential: f.fn });
|
|
330
|
-
expect(res.status).toBe('not-authorized');
|
|
331
|
-
expect(res.cacheInvalidated).toBe(false);
|
|
332
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('rejected-token');
|
|
333
|
-
expect(res.detail).toContain(CREDENTIAL_NOT_AUTHORIZED_DETAIL);
|
|
334
|
-
expect(res.detail).toContain('stays loud every session');
|
|
335
|
-
});
|
|
336
|
-
it('says a worktree with NO cache needs a human before the next session', async () => {
|
|
337
|
-
const env = worktree();
|
|
338
|
-
const f = fetcher({ status: 'unavailable' });
|
|
339
|
-
const res = await refreshCoordinationToken('rejected-token', { ...baseDeps(env), fetchCredential: f.fn });
|
|
340
|
-
expect(res.status).toBe('unavailable');
|
|
341
|
-
expect(res.detail).toContain('NEEDS MANUAL ATTENTION BEFORE THE NEXT SESSION');
|
|
342
|
-
expect(res.detail).toContain('empty inbox');
|
|
343
|
-
expect(res.cacheInvalidated).toBe(false);
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
// ── Every other project keeps Key Vault ──────────────────────────────────────
|
|
347
|
-
describe('the two denylisted projects resolve through Key Vault, unchanged (#507)', () => {
|
|
348
|
-
/** A roster file that lists the team, so the offline gate admits it. */
|
|
349
|
-
function rosterFile(project, teams) {
|
|
350
|
-
const path = join(dir, 'rosters.json');
|
|
351
|
-
writeFileSync(path, JSON.stringify({ projects: { [project]: teams } }));
|
|
352
|
-
return path;
|
|
353
|
-
}
|
|
354
|
-
for (const project of ['spearmint-private', 'memnexus']) {
|
|
355
|
-
it(`${project} reads the vault, requests no credential, and reads no user key`, async () => {
|
|
356
|
-
const env = { ...worktree('eval'), [ENV_KEY_ROSTER_FILE]: rosterFile(project, ['eval']) };
|
|
357
|
-
const fetchSecret = vi.fn(() => 'kv-token');
|
|
358
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
359
|
-
const readUserKey = vi.fn(() => FAKE_USER_KEY);
|
|
360
|
-
const res = await resolveCoordinationToken({
|
|
361
|
-
env,
|
|
362
|
-
project,
|
|
363
|
-
fetchSecret,
|
|
364
|
-
fetchCredential: f.fn,
|
|
365
|
-
readUserKey,
|
|
366
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
367
|
-
});
|
|
368
|
-
expect(res.status).toBe('resolved');
|
|
369
|
-
expect(res.source).toBe('keyvault');
|
|
370
|
-
expect(res.token).toBe('kv-token');
|
|
371
|
-
expect(fetchSecret).toHaveBeenCalledWith(KEYVAULT_NAME, `coordination-token--${project}--eval`);
|
|
372
|
-
expect(f.calls).toHaveLength(0);
|
|
373
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
for (const project of ['spearmint-private', 'memnexus']) {
|
|
377
|
-
it(`${project} still fails CLOSED on a team its roster does not list`, async () => {
|
|
378
|
-
const env = { ...worktree('not-a-member'), [ENV_KEY_ROSTER_FILE]: rosterFile(project, ['eval']) };
|
|
379
|
-
const fetchSecret = vi.fn();
|
|
380
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
381
|
-
const res = await resolveCoordinationToken({
|
|
382
|
-
env,
|
|
383
|
-
project,
|
|
384
|
-
fetchSecret,
|
|
385
|
-
fetchCredential: f.fn,
|
|
386
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
387
|
-
});
|
|
388
|
-
expect(res.status).toBe('not-on-roster');
|
|
389
|
-
expect(fetchSecret).not.toHaveBeenCalled();
|
|
390
|
-
expect(f.calls).toHaveLength(0);
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
it('the #220 interlock does not fire on the vault path, which fails safe already', async () => {
|
|
394
|
-
const env = {
|
|
395
|
-
...worktree('eval'),
|
|
396
|
-
[ENV_KEY_ROSTER_FILE]: rosterFile('memnexus', ['eval']),
|
|
397
|
-
MX_COORD_EXPECT_TEAM: 'something-else',
|
|
398
|
-
};
|
|
399
|
-
const fetchSecret = vi.fn(() => 'kv-token');
|
|
400
|
-
const res = await resolveCoordinationToken({ env, project: 'memnexus', fetchSecret });
|
|
401
|
-
// Unchanged behaviour: under Key Vault a mismatch names a secret that does
|
|
402
|
-
// not exist, so the interlock is not what stops it and this path is byte for
|
|
403
|
-
// byte what it was.
|
|
404
|
-
expect(res.status).toBe('resolved');
|
|
405
|
-
expect(fetchSecret).toHaveBeenCalled();
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
// ── Missing prerequisites ────────────────────────────────────────────────────
|
|
409
|
-
describe('what happens with no key and no URL', () => {
|
|
410
|
-
it('no user key is unprovisioned, names the remedy, and asks for nothing', async () => {
|
|
411
|
-
const env = worktree();
|
|
412
|
-
const f = fetcher({ status: 'issued', token: 'never' });
|
|
413
|
-
const res = await resolveCoordinationToken({
|
|
414
|
-
env,
|
|
415
|
-
project: PROJECT,
|
|
416
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
417
|
-
readUserKey: () => undefined,
|
|
418
|
-
fetchCredential: f.fn,
|
|
419
|
-
});
|
|
420
|
-
expect(res.status).toBe('unprovisioned');
|
|
421
|
-
expect(res.detail).toContain('mx auth login');
|
|
422
|
-
expect(res.detail).toContain('MX_API_KEY');
|
|
423
|
-
expect(f.calls).toHaveLength(0);
|
|
424
|
-
});
|
|
425
|
-
it('no service URL is unprovisioned, and the key is never read', async () => {
|
|
426
|
-
const env = worktree();
|
|
427
|
-
const readUserKey = vi.fn(() => FAKE_USER_KEY);
|
|
428
|
-
const f = fetcher({ status: 'issued', token: 'never' });
|
|
429
|
-
const res = await resolveCoordinationToken({
|
|
430
|
-
env,
|
|
431
|
-
project: PROJECT,
|
|
432
|
-
// Unset, so the resolver decides. It is mocked to answer null above.
|
|
433
|
-
readUserKey,
|
|
434
|
-
fetchCredential: f.fn,
|
|
435
|
-
});
|
|
436
|
-
expect(res.status).toBe('unprovisioned');
|
|
437
|
-
expect(res.detail).toContain('coordination service URL not set');
|
|
438
|
-
expect(f.calls).toHaveLength(0);
|
|
439
|
-
// The URL is checked first, so a machine with no service configured never
|
|
440
|
-
// touches the key at all.
|
|
441
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
// ── The wire, against a local fake endpoint ──────────────────────────────────
|
|
445
|
-
describe('the wire contract, against a fake /admin/credential', () => {
|
|
446
|
-
let server;
|
|
447
|
-
let url;
|
|
448
|
-
let seen;
|
|
449
|
-
let reply;
|
|
450
|
-
beforeEach(async () => {
|
|
451
|
-
seen = [];
|
|
452
|
-
reply = { status: 200, body: { project: PROJECT, team: TEAM, tokenId: 't1', token: 'wire-token', expiresAt: null } };
|
|
453
|
-
server = createServer((req, res) => {
|
|
454
|
-
const chunks = [];
|
|
455
|
-
req.on('data', (c) => chunks.push(c));
|
|
456
|
-
req.on('end', () => {
|
|
457
|
-
seen.push({
|
|
458
|
-
method: req.method ?? '',
|
|
459
|
-
path: req.url ?? '',
|
|
460
|
-
headers: req.headers,
|
|
461
|
-
body: Buffer.concat(chunks).toString('utf-8'),
|
|
462
|
-
});
|
|
463
|
-
res.writeHead(reply.status, { 'content-type': 'application/json' });
|
|
464
|
-
res.end(JSON.stringify(reply.body));
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
468
|
-
const addr = server.address();
|
|
469
|
-
url = `http://127.0.0.1:${typeof addr === 'object' && addr ? addr.port : 0}`;
|
|
470
|
-
});
|
|
471
|
-
afterEach(async () => {
|
|
472
|
-
await new Promise((resolve) => server.close(() => resolve()));
|
|
473
|
-
});
|
|
474
|
-
it('posts to /admin/credential with both slugs and the key in ONE header', async () => {
|
|
475
|
-
const env = worktree();
|
|
476
|
-
const res = await resolveCoordinationToken({
|
|
477
|
-
env,
|
|
478
|
-
project: PROJECT,
|
|
479
|
-
serviceUrl: url,
|
|
480
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
481
|
-
});
|
|
482
|
-
expect(res.status).toBe('resolved');
|
|
483
|
-
expect(res.token).toBe('wire-token');
|
|
484
|
-
expect(seen).toHaveLength(1);
|
|
485
|
-
expect(seen[0].method).toBe('POST');
|
|
486
|
-
expect(seen[0].path).toBe('/admin/credential');
|
|
487
|
-
expect(seen[0].headers[USER_KEY_HEADER]).toBe(FAKE_USER_KEY);
|
|
488
|
-
expect(JSON.parse(seen[0].body)).toEqual({ project: PROJECT, team: TEAM });
|
|
489
|
-
// The key is in the header and in no other part of the request: not the
|
|
490
|
-
// path, not a query string, not the body.
|
|
491
|
-
expect(seen[0].path).not.toContain(FAKE_USER_KEY);
|
|
492
|
-
expect(seen[0].body).not.toContain(FAKE_USER_KEY);
|
|
493
|
-
const otherHeaders = Object.entries(seen[0].headers).filter(([k]) => k !== USER_KEY_HEADER);
|
|
494
|
-
expect(JSON.stringify(otherHeaders)).not.toContain(FAKE_USER_KEY);
|
|
495
|
-
});
|
|
496
|
-
for (const [status, expected] of [
|
|
497
|
-
[401, 'invalid-key'],
|
|
498
|
-
[403, 'not-authorized'],
|
|
499
|
-
[409, 'not-on-roster'],
|
|
500
|
-
[429, 'limit-reached'],
|
|
501
|
-
[503, 'unavailable'],
|
|
502
|
-
[500, 'unavailable'],
|
|
503
|
-
]) {
|
|
504
|
-
it(`maps HTTP ${status} to ${expected}`, async () => {
|
|
505
|
-
// A server message that WOULD distinguish the two 403 cases, to prove the
|
|
506
|
-
// CLI never reads it.
|
|
507
|
-
reply = { status, body: { error: `server text for ${status}: team ${TEAM} exists` } };
|
|
508
|
-
const env = worktree();
|
|
509
|
-
const res = await resolveCoordinationToken({
|
|
510
|
-
env,
|
|
511
|
-
project: PROJECT,
|
|
512
|
-
serviceUrl: url,
|
|
513
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
514
|
-
});
|
|
515
|
-
expect(res.status).toBe(expected);
|
|
516
|
-
expect(res.detail).not.toContain('server text');
|
|
517
|
-
expect(res.detail).not.toContain(`team ${TEAM} exists`);
|
|
518
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
it('reports HTTP 429 as a limit refusal naming the limits, never as a retry-soon outage (#507)', async () => {
|
|
522
|
-
// The service's 429 body names which limit was met. The CLI reads none of
|
|
523
|
-
// it: the detail is the fixed constant, byte for byte.
|
|
524
|
-
reply = { status: 429, body: { error: 'server text: this identity already owns 10 projects' } };
|
|
525
|
-
const env = worktree();
|
|
526
|
-
const res = await resolveCoordinationToken({ env, project: PROJECT, serviceUrl: url, readUserKey: () => FAKE_USER_KEY });
|
|
527
|
-
expect(res.status).toBe('limit-reached');
|
|
528
|
-
expect(res.detail).toBe(CREDENTIAL_LIMIT_REACHED_DETAIL);
|
|
529
|
-
expect(res.detail).not.toContain('server text');
|
|
530
|
-
expect(res.detail).not.toMatch(/retry in a few seconds/i);
|
|
531
|
-
expect(res.detail).not.toContain('UNAVAILABLE');
|
|
532
|
-
for (const limit of ['10 projects per identity', '50 teams per project', '20 new projects across the service in 24 hours']) {
|
|
533
|
-
expect(CREDENTIAL_LIMIT_REACHED_DETAIL).toContain(limit);
|
|
534
|
-
}
|
|
535
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
536
|
-
});
|
|
537
|
-
it('reports an unreachable service as unavailable, not as unprovisioned', async () => {
|
|
538
|
-
await new Promise((resolve) => server.close(() => resolve()));
|
|
539
|
-
const env = worktree();
|
|
540
|
-
const res = await resolveCoordinationToken({
|
|
541
|
-
env,
|
|
542
|
-
project: PROJECT,
|
|
543
|
-
serviceUrl: url,
|
|
544
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
545
|
-
});
|
|
546
|
-
expect(res.status).toBe('unavailable');
|
|
547
|
-
expect(res.detail).toMatch(/retry/i);
|
|
548
|
-
// Re-open a server so afterEach's close() has something to close.
|
|
549
|
-
server = createServer(() => { });
|
|
550
|
-
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
551
|
-
});
|
|
552
|
-
});
|
|
553
|
-
// ── Row 10 of the creation contract ──────────────────────────────────────────
|
|
554
|
-
describe('row 10: is a credential obtainable for a new team', () => {
|
|
555
|
-
it('200 caches the token in the NEW worktree, born 0600, and reports obtainable', async () => {
|
|
556
|
-
const f = fetcher({ status: 'issued', token: 'row10-token' });
|
|
557
|
-
const out = await provisionCredentialForWorktree({
|
|
558
|
-
project: PROJECT,
|
|
559
|
-
team: 'gateway',
|
|
560
|
-
worktreePath: dir,
|
|
561
|
-
env: {},
|
|
562
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
563
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
564
|
-
fetchCredential: f.fn,
|
|
565
|
-
});
|
|
566
|
-
expect(out.kind).toBe('obtainable');
|
|
567
|
-
const cachePath = join(dir, `.mx-coordination-token--${PROJECT}--gateway`);
|
|
568
|
-
expect(out).toMatchObject({ cachePath, mode: 0o600 });
|
|
569
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('row10-token');
|
|
570
|
-
expect(statSync(cachePath).mode & 0o777).toBe(0o600);
|
|
571
|
-
expect(f.calls[0]).toMatchObject({ project: PROJECT, team: 'gateway' });
|
|
572
|
-
});
|
|
573
|
-
it('429 is a refusal row naming the limits, not could-not-run (#507)', async () => {
|
|
574
|
-
const f = fetcher({ status: 'limit-reached' });
|
|
575
|
-
const out = await provisionCredentialForWorktree({
|
|
576
|
-
project: PROJECT,
|
|
577
|
-
team: 'gateway',
|
|
578
|
-
worktreePath: dir,
|
|
579
|
-
env: {},
|
|
580
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
581
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
582
|
-
fetchCredential: f.fn,
|
|
583
|
-
});
|
|
584
|
-
expect(out).toEqual({ kind: 'refused', detail: CREDENTIAL_LIMIT_REACHED_DETAIL, reason: 'limit-reached' });
|
|
585
|
-
});
|
|
586
|
-
it('a 429 on the 401 refresh path is the same limit refusal, and deletes nothing', async () => {
|
|
587
|
-
const env = worktree();
|
|
588
|
-
writeFileSync(join(dir, CACHE), 'rejected-token');
|
|
589
|
-
const f = fetcher({ status: 'limit-reached' });
|
|
590
|
-
const res = await refreshCoordinationToken('rejected-token', { ...baseDeps(env), fetchCredential: f.fn });
|
|
591
|
-
expect(res.status).toBe('limit-reached');
|
|
592
|
-
expect(res.detail).toContain(CREDENTIAL_LIMIT_REACHED_DETAIL);
|
|
593
|
-
expect(res.cacheInvalidated).toBe(false);
|
|
594
|
-
});
|
|
595
|
-
it('403 refuses, names the missing grant, and writes no cache', async () => {
|
|
596
|
-
const f = fetcher({ status: 'not-authorized' });
|
|
597
|
-
const out = await provisionCredentialForWorktree({
|
|
598
|
-
project: PROJECT,
|
|
599
|
-
team: 'gateway',
|
|
600
|
-
worktreePath: dir,
|
|
601
|
-
env: {},
|
|
602
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
603
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
604
|
-
fetchCredential: f.fn,
|
|
605
|
-
});
|
|
606
|
-
expect(out).toEqual({ kind: 'refused', detail: CREDENTIAL_NOT_AUTHORIZED_DETAIL, reason: 'not-authorized' });
|
|
607
|
-
expect(out.kind === 'refused' && out.detail).toContain('grant');
|
|
608
|
-
expect(readdirSync(dir)).not.toContain(`.mx-coordination-token--${PROJECT}--gateway`);
|
|
609
|
-
});
|
|
610
|
-
it('503 is could-not-run, which is neither a refusal nor a pass', async () => {
|
|
611
|
-
const f = fetcher({ status: 'unavailable' });
|
|
612
|
-
const out = await provisionCredentialForWorktree({
|
|
613
|
-
project: PROJECT,
|
|
614
|
-
team: 'gateway',
|
|
615
|
-
worktreePath: dir,
|
|
616
|
-
env: {},
|
|
617
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
618
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
619
|
-
fetchCredential: f.fn,
|
|
620
|
-
});
|
|
621
|
-
expect(out.kind).toBe('could-not-run');
|
|
622
|
-
expect(out.kind === 'could-not-run' && out.detail).toContain(CREDENTIAL_UNAVAILABLE_DETAIL);
|
|
623
|
-
});
|
|
624
|
-
it('an issued credential that cannot be cached is could-not-run, not a pass', async () => {
|
|
625
|
-
const f = fetcher({ status: 'issued', token: 'row10-token' });
|
|
626
|
-
const out = await provisionCredentialForWorktree({
|
|
627
|
-
project: PROJECT,
|
|
628
|
-
team: 'gateway',
|
|
629
|
-
worktreePath: dir,
|
|
630
|
-
env: {},
|
|
631
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
632
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
633
|
-
fetchCredential: f.fn,
|
|
634
|
-
writeCache: () => false,
|
|
635
|
-
});
|
|
636
|
-
expect(out.kind).toBe('could-not-run');
|
|
637
|
-
expect(out.kind === 'could-not-run' && out.detail).toContain('could not be written');
|
|
638
|
-
});
|
|
639
|
-
// ── #316 change B: the mint is idempotent across resumes ──────────────────
|
|
640
|
-
//
|
|
641
|
-
// The service mints on every call (`coordination-token.ts:1349-1351`), so a
|
|
642
|
-
// provisioning run that resumes and asks again leaves a second live token for
|
|
643
|
-
// one team. These four pin the pre-mint cache check and the in-process retry.
|
|
644
|
-
it('an existing usable cache asserts the row and asks the service for nothing', async () => {
|
|
645
|
-
const f = fetcher({ status: 'issued', token: 'second-token' });
|
|
646
|
-
const cachePath = join(dir, `.mx-coordination-token--${PROJECT}--gateway`);
|
|
647
|
-
writeFileSync(cachePath, 'first-token', { mode: 0o600 });
|
|
648
|
-
const out = await provisionCredentialForWorktree({
|
|
649
|
-
project: PROJECT,
|
|
650
|
-
team: 'gateway',
|
|
651
|
-
worktreePath: dir,
|
|
652
|
-
env: {},
|
|
653
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
654
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
655
|
-
fetchCredential: f.fn,
|
|
656
|
-
});
|
|
657
|
-
expect(out).toMatchObject({ kind: 'obtainable', cachePath, mode: 0o600, fromCache: true });
|
|
658
|
-
expect(f.calls).toHaveLength(0);
|
|
659
|
-
// The cache the first run wrote is the cache that stays.
|
|
660
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('first-token');
|
|
661
|
-
});
|
|
662
|
-
it('two runs against the same worktree fetch exactly once', async () => {
|
|
663
|
-
const f = fetcher({ status: 'issued', token: 'row10-token' });
|
|
664
|
-
const call = () => provisionCredentialForWorktree({
|
|
665
|
-
project: PROJECT,
|
|
666
|
-
team: 'gateway',
|
|
667
|
-
worktreePath: dir,
|
|
668
|
-
env: {},
|
|
669
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
670
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
671
|
-
fetchCredential: f.fn,
|
|
672
|
-
});
|
|
673
|
-
const first = await call();
|
|
674
|
-
const second = await call();
|
|
675
|
-
expect(f.calls).toHaveLength(1);
|
|
676
|
-
expect(first).toMatchObject({ kind: 'obtainable', mode: 0o600 });
|
|
677
|
-
expect(first.kind === 'obtainable' && first.fromCache).toBeUndefined();
|
|
678
|
-
expect(second).toMatchObject({ kind: 'obtainable', mode: 0o600, fromCache: true });
|
|
679
|
-
});
|
|
680
|
-
it('a cache file holding only whitespace is not a credential, so the run mints', async () => {
|
|
681
|
-
const f = fetcher({ status: 'issued', token: 'row10-token' });
|
|
682
|
-
const cachePath = join(dir, `.mx-coordination-token--${PROJECT}--gateway`);
|
|
683
|
-
writeFileSync(cachePath, ' \n', { mode: 0o600 });
|
|
684
|
-
const out = await provisionCredentialForWorktree({
|
|
685
|
-
project: PROJECT,
|
|
686
|
-
team: 'gateway',
|
|
687
|
-
worktreePath: dir,
|
|
688
|
-
env: {},
|
|
689
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
690
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
691
|
-
fetchCredential: f.fn,
|
|
692
|
-
});
|
|
693
|
-
expect(f.calls).toHaveLength(1);
|
|
694
|
-
expect(out).toMatchObject({ kind: 'obtainable' });
|
|
695
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('row10-token');
|
|
696
|
-
});
|
|
697
|
-
it('a cache write that fails once is retried in process, and the issued token is kept', async () => {
|
|
698
|
-
const f = fetcher({ status: 'issued', token: 'row10-token' });
|
|
699
|
-
const writes = [];
|
|
700
|
-
const cachePath = join(dir, `.mx-coordination-token--${PROJECT}--gateway`);
|
|
701
|
-
const out = await provisionCredentialForWorktree({
|
|
702
|
-
project: PROJECT,
|
|
703
|
-
team: 'gateway',
|
|
704
|
-
worktreePath: dir,
|
|
705
|
-
env: {},
|
|
706
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
707
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
708
|
-
fetchCredential: f.fn,
|
|
709
|
-
writeCache: (path, value) => {
|
|
710
|
-
writes.push(path);
|
|
711
|
-
if (writes.length === 1)
|
|
712
|
-
return false;
|
|
713
|
-
writeFileSync(path, value, { mode: 0o600 });
|
|
714
|
-
return true;
|
|
715
|
-
},
|
|
716
|
-
});
|
|
717
|
-
expect(writes).toHaveLength(2);
|
|
718
|
-
expect(f.calls).toHaveLength(1);
|
|
719
|
-
expect(out).toMatchObject({ kind: 'obtainable', cachePath, mode: 0o600 });
|
|
720
|
-
});
|
|
721
|
-
it('a SYMLINK at the cache path is not a credential: the run mints and does not follow it', async () => {
|
|
722
|
-
// Security review round 2, Must Fix. The pre-mint check runs before the
|
|
723
|
-
// writer's remove-then-create, so the link is no longer unlinked before it is
|
|
724
|
-
// read. A reader that followed it would answer `usable` with the TARGET's
|
|
725
|
-
// mode, assert row 10, and suppress the mint: whoever planted the link would
|
|
726
|
-
// decide that the team holds a credential, and the team's first session would
|
|
727
|
-
// read a file it does not control.
|
|
728
|
-
const target = join(dir, 'planted-target');
|
|
729
|
-
writeFileSync(target, 'not-this-teams-token', { mode: 0o600 });
|
|
730
|
-
const cachePath = join(dir, `.mx-coordination-token--${PROJECT}--gateway`);
|
|
731
|
-
symlinkSync(target, cachePath);
|
|
732
|
-
const f = fetcher({ status: 'issued', token: 'row10-token' });
|
|
733
|
-
const state = credentialCacheState({ project: PROJECT, team: 'gateway', worktreePath: dir });
|
|
734
|
-
const out = await provisionCredentialForWorktree({
|
|
735
|
-
project: PROJECT,
|
|
736
|
-
team: 'gateway',
|
|
737
|
-
worktreePath: dir,
|
|
738
|
-
env: {},
|
|
739
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
740
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
741
|
-
fetchCredential: f.fn,
|
|
742
|
-
});
|
|
743
|
-
expect(state.kind).toBe('blank');
|
|
744
|
-
expect(f.calls).toHaveLength(1);
|
|
745
|
-
expect(out).toMatchObject({ kind: 'obtainable', cachePath, mode: 0o600 });
|
|
746
|
-
// The writer's remove-then-create replaced the LINK, and the target it
|
|
747
|
-
// pointed at is untouched.
|
|
748
|
-
expect(lstatSync(cachePath).isSymbolicLink()).toBe(false);
|
|
749
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('row10-token');
|
|
750
|
-
expect(readFileSync(target, 'utf-8')).toBe('not-this-teams-token');
|
|
751
|
-
});
|
|
752
|
-
it('a directory at the cache path reads as blank rather than as absent', async () => {
|
|
753
|
-
mkdirSync(join(dir, `.mx-coordination-token--${PROJECT}--gateway`));
|
|
754
|
-
const state = credentialCacheState({ project: PROJECT, team: 'gateway', worktreePath: dir });
|
|
755
|
-
expect(state.kind).toBe('blank');
|
|
756
|
-
});
|
|
757
|
-
it('a cache write that fails twice is could-not-run and says the write was retried', async () => {
|
|
758
|
-
const f = fetcher({ status: 'issued', token: 'row10-token' });
|
|
759
|
-
const writes = [];
|
|
760
|
-
const out = await provisionCredentialForWorktree({
|
|
761
|
-
project: PROJECT,
|
|
762
|
-
team: 'gateway',
|
|
763
|
-
worktreePath: dir,
|
|
764
|
-
env: {},
|
|
765
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
766
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
767
|
-
fetchCredential: f.fn,
|
|
768
|
-
writeCache: (path) => { writes.push(path); return false; },
|
|
769
|
-
});
|
|
770
|
-
expect(writes).toHaveLength(2);
|
|
771
|
-
expect(out.kind).toBe('could-not-run');
|
|
772
|
-
expect(out.kind === 'could-not-run' && out.detail).toContain('retried once');
|
|
773
|
-
});
|
|
774
|
-
it('no user key is could-not-run and asks for no credential', async () => {
|
|
775
|
-
const f = fetcher({ status: 'issued', token: 'never' });
|
|
776
|
-
const out = await provisionCredentialForWorktree({
|
|
777
|
-
project: PROJECT,
|
|
778
|
-
team: 'gateway',
|
|
779
|
-
worktreePath: dir,
|
|
780
|
-
env: {},
|
|
781
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
782
|
-
readUserKey: () => undefined,
|
|
783
|
-
fetchCredential: f.fn,
|
|
784
|
-
});
|
|
785
|
-
expect(out.kind).toBe('could-not-run');
|
|
786
|
-
expect(f.calls).toHaveLength(0);
|
|
787
|
-
});
|
|
788
|
-
});
|
|
789
|
-
// ── The no-echo rule ─────────────────────────────────────────────────────────
|
|
790
|
-
describe('the MemNexus user key never reaches any output', () => {
|
|
791
|
-
it('appears in no captured stdout, stderr, result, or file, on any outcome', async () => {
|
|
792
|
-
const captured = [];
|
|
793
|
-
vi.spyOn(console, 'log').mockImplementation((...a) => { captured.push(a.map(String).join(' ')); });
|
|
794
|
-
vi.spyOn(console, 'error').mockImplementation((...a) => { captured.push(a.map(String).join(' ')); });
|
|
795
|
-
vi.spyOn(process.stdout, 'write').mockImplementation(((c) => { captured.push(String(c)); return true; }));
|
|
796
|
-
vi.spyOn(process.stderr, 'write').mockImplementation(((c) => { captured.push(String(c)); return true; }));
|
|
797
|
-
const env = worktree();
|
|
798
|
-
const outcomes = [
|
|
799
|
-
{ status: 'issued', token: 'ok-token' },
|
|
800
|
-
{ status: 'invalid-key' },
|
|
801
|
-
{ status: 'not-authorized' },
|
|
802
|
-
{ status: 'unavailable' },
|
|
803
|
-
{ status: 'not-registered' },
|
|
804
|
-
{ status: 'limit-reached' },
|
|
805
|
-
];
|
|
806
|
-
for (const outcome of outcomes) {
|
|
807
|
-
const f = fetcher(outcome);
|
|
808
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
809
|
-
captured.push(JSON.stringify(res));
|
|
810
|
-
const refreshed = await refreshCoordinationToken('rejected', { ...baseDeps(env), fetchCredential: f.fn });
|
|
811
|
-
captured.push(JSON.stringify(refreshed));
|
|
812
|
-
rmSync(join(dir, CACHE), { force: true });
|
|
813
|
-
}
|
|
814
|
-
const all = captured.join('\n');
|
|
815
|
-
expect(all).not.toContain(FAKE_USER_KEY);
|
|
816
|
-
// Nor any distinctive fragment of it, which a partial redaction would leave.
|
|
817
|
-
expect(all).not.toContain('mx-fake-user-key');
|
|
818
|
-
expect(all).not.toContain('0123456789');
|
|
819
|
-
// Nor its length, in any of the shapes a diagnostic would use.
|
|
820
|
-
expect(all).not.toMatch(/(key|apiKey|MX_API_KEY)[^\n]{0,40}\b(chars|characters|bytes|length)\b/i);
|
|
821
|
-
expect(all).not.toMatch(/\blength\b[^\n]{0,20}\b38\b/);
|
|
822
|
-
// And nothing on disk in the worktree holds it, cache included.
|
|
823
|
-
for (const name of readdirSync(dir)) {
|
|
824
|
-
const path = join(dir, name);
|
|
825
|
-
if (!statSync(path).isFile())
|
|
826
|
-
continue;
|
|
827
|
-
expect(readFileSync(path, 'utf-8')).not.toContain(FAKE_USER_KEY);
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
it('the cache holds the issued token and nothing else', async () => {
|
|
831
|
-
const env = worktree();
|
|
832
|
-
const f = fetcher({ status: 'issued', token: 'only-the-token' });
|
|
833
|
-
await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
834
|
-
expect(readFileSync(join(dir, CACHE), 'utf-8')).toBe('only-the-token');
|
|
835
|
-
});
|
|
836
|
-
});
|
|
837
|
-
// ── #290 Must Fix 1: the URL that receives the key is validated ──────────────
|
|
838
|
-
describe('the service URL is scheme- and host-checked before the key is read', () => {
|
|
839
|
-
/** Point the resolver at a URL, as if that level had supplied it. */
|
|
840
|
-
async function resolveWithResolvedUrl(url, source) {
|
|
841
|
-
const { resolveCoordinationUrl } = await import('../lib/coordination-client.js');
|
|
842
|
-
vi.mocked(resolveCoordinationUrl).mockReturnValue({ url, source });
|
|
843
|
-
const readUserKey = vi.fn(() => FAKE_USER_KEY);
|
|
844
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
845
|
-
const res = await resolveCoordinationToken({
|
|
846
|
-
env: worktree(),
|
|
847
|
-
project: PROJECT,
|
|
848
|
-
readUserKey,
|
|
849
|
-
fetchCredential: f.fn,
|
|
850
|
-
});
|
|
851
|
-
vi.mocked(resolveCoordinationUrl).mockReturnValue(null);
|
|
852
|
-
return { res, readUserKey, f };
|
|
853
|
-
}
|
|
854
|
-
it('refuses a plaintext non-loopback URL from MX_COORD_SERVICE_URL, before reading the key', async () => {
|
|
855
|
-
const { res, readUserKey, f } = await resolveWithResolvedUrl('http://evil.example.com', 'env');
|
|
856
|
-
expect(res.status).toBe('misconfigured');
|
|
857
|
-
expect(res.detail).toMatch(/must use https/);
|
|
858
|
-
// The remedy names the source that supplied it, not a file that did not.
|
|
859
|
-
expect(res.detail).toContain('MX_COORD_SERVICE_URL');
|
|
860
|
-
// The order is the point: no key is read and no request is made.
|
|
861
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
862
|
-
expect(f.calls).toHaveLength(0);
|
|
863
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
864
|
-
});
|
|
865
|
-
it('refuses an https host outside the allowed set, from the global config key', async () => {
|
|
866
|
-
const { res, readUserKey, f } = await resolveWithResolvedUrl('https://attacker.example.net', 'config');
|
|
867
|
-
expect(res.status).toBe('misconfigured');
|
|
868
|
-
expect(res.detail).toMatch(/outside the allowed set/);
|
|
869
|
-
expect(res.detail).toContain('coordination-service-url');
|
|
870
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
871
|
-
expect(f.calls).toHaveLength(0);
|
|
872
|
-
});
|
|
873
|
-
it('refuses a URL embedding credentials, and never echoes the URL back', async () => {
|
|
874
|
-
const { res, readUserKey } = await resolveWithResolvedUrl('https://user:pw@coord.memnexus.ai', 'env');
|
|
875
|
-
expect(res.status).toBe('misconfigured');
|
|
876
|
-
expect(res.detail).toMatch(/must not embed credentials/);
|
|
877
|
-
// A rejected URL can carry a password in its userinfo.
|
|
878
|
-
expect(res.detail).not.toContain('pw@');
|
|
879
|
-
expect(res.detail).not.toContain('user:pw');
|
|
880
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
881
|
-
});
|
|
882
|
-
it('accepts an allowed https host and proceeds to the request', async () => {
|
|
883
|
-
const { res, readUserKey, f } = await resolveWithResolvedUrl('https://coord.memnexus.ai', 'project');
|
|
884
|
-
expect(res.status).toBe('resolved');
|
|
885
|
-
expect(readUserKey).toHaveBeenCalled();
|
|
886
|
-
expect(f.calls).toHaveLength(1);
|
|
887
|
-
});
|
|
888
|
-
it('accepts loopback plaintext, which is how a developer runs the service', async () => {
|
|
889
|
-
const { res, f } = await resolveWithResolvedUrl('http://127.0.0.1:8080', 'env');
|
|
890
|
-
expect(res.status).toBe('resolved');
|
|
891
|
-
expect(f.calls[0].url).toBe('http://127.0.0.1:8080');
|
|
892
|
-
});
|
|
893
|
-
});
|
|
894
|
-
// ── #290 Should Fix 1: the team slug is shape-checked ───────────────────────
|
|
895
|
-
describe('the team slug is validated now that the roster gate no longer does it', () => {
|
|
896
|
-
it('refuses a traversal marker and writes nothing outside the worktree', async () => {
|
|
897
|
-
const env = worktree('../../../../tmp/pwned');
|
|
898
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
899
|
-
const readUserKey = vi.fn(() => FAKE_USER_KEY);
|
|
900
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), readUserKey, fetchCredential: f.fn });
|
|
901
|
-
expect(res.status).toBe('misconfigured');
|
|
902
|
-
expect(f.calls).toHaveLength(0);
|
|
903
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
904
|
-
expect(existsSync('/tmp/.mx-coordination-token--mx-agent--../../../../tmp/pwned')).toBe(false);
|
|
905
|
-
});
|
|
906
|
-
it('refuses the same shape on the row-10 provisioning path', async () => {
|
|
907
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
908
|
-
const out = await provisionCredentialForWorktree({
|
|
909
|
-
project: PROJECT,
|
|
910
|
-
team: '../../../../tmp/pwned',
|
|
911
|
-
worktreePath: dir,
|
|
912
|
-
env: {},
|
|
913
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
914
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
915
|
-
fetchCredential: f.fn,
|
|
916
|
-
});
|
|
917
|
-
expect(out.kind).toBe('could-not-run');
|
|
918
|
-
expect(f.calls).toHaveLength(0);
|
|
919
|
-
});
|
|
920
|
-
it('still accepts every ordinary team slug', async () => {
|
|
921
|
-
for (const team of ['bootstrap', 'customer-portal', 'mcp', 'eval']) {
|
|
922
|
-
rmSync(join(dir, '.mx-coordination-team'), { force: true });
|
|
923
|
-
const f = fetcher({ status: 'issued', token: `tok-${team}` });
|
|
924
|
-
const res = await resolveCoordinationToken({ ...baseDeps(worktree(team)), fetchCredential: f.fn });
|
|
925
|
-
expect(res.status).toBe('resolved');
|
|
926
|
-
rmSync(join(dir, `.mx-coordination-token--${PROJECT}--${team}`), { force: true });
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
});
|
|
930
|
-
// ── #290 Must Fix 2: a redirect never carries the key to another origin ─────
|
|
931
|
-
describe('a redirect is refused, not followed', () => {
|
|
932
|
-
let service;
|
|
933
|
-
let attacker;
|
|
934
|
-
let serviceUrl;
|
|
935
|
-
let attackerHits;
|
|
936
|
-
beforeEach(async () => {
|
|
937
|
-
attackerHits = [];
|
|
938
|
-
attacker = createServer((req, res) => {
|
|
939
|
-
attackerHits.push(req.headers);
|
|
940
|
-
res.writeHead(200, { 'content-type': 'application/json' });
|
|
941
|
-
res.end(JSON.stringify({ token: 'attacker-supplied-token' }));
|
|
942
|
-
});
|
|
943
|
-
await new Promise((r) => attacker.listen(0, '127.0.0.1', r));
|
|
944
|
-
const aAddr = attacker.address();
|
|
945
|
-
const attackerUrl = `http://127.0.0.1:${typeof aAddr === 'object' && aAddr ? aAddr.port : 0}`;
|
|
946
|
-
service = createServer((req, res) => {
|
|
947
|
-
// A 302 from the service, its ingress, or anything answering for it.
|
|
948
|
-
res.writeHead(302, { location: `${attackerUrl}/admin/credential` });
|
|
949
|
-
res.end();
|
|
950
|
-
});
|
|
951
|
-
await new Promise((r) => service.listen(0, '127.0.0.1', r));
|
|
952
|
-
const sAddr = service.address();
|
|
953
|
-
serviceUrl = `http://127.0.0.1:${typeof sAddr === 'object' && sAddr ? sAddr.port : 0}`;
|
|
954
|
-
});
|
|
955
|
-
afterEach(async () => {
|
|
956
|
-
await new Promise((r) => service.close(() => r()));
|
|
957
|
-
await new Promise((r) => attacker.close(() => r()));
|
|
958
|
-
});
|
|
959
|
-
it('a 302 yields unavailable, and the redirect target receives no request', async () => {
|
|
960
|
-
// Without `redirect: 'error'` fetch follows this and forwards the custom
|
|
961
|
-
// header: `Authorization` is stripped cross-origin, `x-mx-user-key` is not.
|
|
962
|
-
const res = await resolveCoordinationToken({
|
|
963
|
-
env: worktree(),
|
|
964
|
-
project: PROJECT,
|
|
965
|
-
serviceUrl,
|
|
966
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
967
|
-
});
|
|
968
|
-
expect(res.status).toBe('unavailable');
|
|
969
|
-
expect(res.status).not.toBe('resolved');
|
|
970
|
-
// The whole point: nothing reached the second origin.
|
|
971
|
-
expect(attackerHits).toHaveLength(0);
|
|
972
|
-
// And its reply was never adopted as this team's token.
|
|
973
|
-
expect(res.token).toBeUndefined();
|
|
974
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
975
|
-
});
|
|
976
|
-
it('the key never reaches the redirect target, on any capture', async () => {
|
|
977
|
-
await resolveCoordinationToken({
|
|
978
|
-
env: worktree(),
|
|
979
|
-
project: PROJECT,
|
|
980
|
-
serviceUrl,
|
|
981
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
982
|
-
});
|
|
983
|
-
expect(JSON.stringify(attackerHits)).not.toContain(FAKE_USER_KEY);
|
|
984
|
-
});
|
|
985
|
-
});
|
|
986
|
-
// ── #290 Should Fix 2: the 200 body is bounded ──────────────────────────────
|
|
987
|
-
describe('the 200 body has a size cap', () => {
|
|
988
|
-
let server;
|
|
989
|
-
let url;
|
|
990
|
-
let declaredLength;
|
|
991
|
-
beforeEach(async () => {
|
|
992
|
-
declaredLength = String(64 * 1024 + 1);
|
|
993
|
-
server = createServer((req, res) => {
|
|
994
|
-
res.writeHead(200, { 'content-type': 'application/json', 'content-length': declaredLength });
|
|
995
|
-
res.end(JSON.stringify({ token: 'a-token-behind-a-huge-declared-length' }));
|
|
996
|
-
});
|
|
997
|
-
await new Promise((r) => server.listen(0, '127.0.0.1', r));
|
|
998
|
-
const addr = server.address();
|
|
999
|
-
url = `http://127.0.0.1:${typeof addr === 'object' && addr ? addr.port : 0}`;
|
|
1000
|
-
});
|
|
1001
|
-
afterEach(async () => {
|
|
1002
|
-
await new Promise((r) => server.close(() => r()));
|
|
1003
|
-
});
|
|
1004
|
-
it('refuses a declared body over 64 KiB as unavailable, and caches nothing', async () => {
|
|
1005
|
-
const res = await resolveCoordinationToken({
|
|
1006
|
-
env: worktree(),
|
|
1007
|
-
project: PROJECT,
|
|
1008
|
-
serviceUrl: url,
|
|
1009
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
1010
|
-
});
|
|
1011
|
-
expect(res.status).toBe('unavailable');
|
|
1012
|
-
expect(res.detail).toContain('65536 bytes');
|
|
1013
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
1014
|
-
});
|
|
1015
|
-
it('accepts a body at the ordinary size', async () => {
|
|
1016
|
-
const body = JSON.stringify({ token: 'a-token-behind-a-huge-declared-length' });
|
|
1017
|
-
declaredLength = String(Buffer.byteLength(body));
|
|
1018
|
-
const res = await resolveCoordinationToken({
|
|
1019
|
-
env: worktree(),
|
|
1020
|
-
project: PROJECT,
|
|
1021
|
-
serviceUrl: url,
|
|
1022
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
1023
|
-
});
|
|
1024
|
-
expect(res.status).toBe('resolved');
|
|
1025
|
-
expect(res.token).toBe('a-token-behind-a-huge-declared-length');
|
|
1026
|
-
});
|
|
1027
|
-
});
|
|
1028
|
-
// ── #290 Must Fix 3: the interlock is ARMED on the paths that reach the wire ──
|
|
1029
|
-
describe('the #220 interlock is armed by the production callers', () => {
|
|
1030
|
-
const saved = { ...process.env };
|
|
1031
|
-
afterEach(() => {
|
|
1032
|
-
for (const k of ['CLAUDE_WORKTREE_PATH', 'MX_COORD_EXPECT_TEAM', 'MX_COORD_EXPECT_PROJECT', 'MX_PRODUCT_SLUG', 'MX_COORDINATION_MODE', 'MX_COORD_SERVICE_TOKEN']) {
|
|
1033
|
-
if (saved[k] === undefined)
|
|
1034
|
-
delete process.env[k];
|
|
1035
|
-
else
|
|
1036
|
-
process.env[k] = saved[k];
|
|
1037
|
-
}
|
|
1038
|
-
});
|
|
1039
|
-
it('prepareClient refuses a marker that disagrees with MX_COORD_EXPECT_TEAM, with no request', async () => {
|
|
1040
|
-
// Changed on purpose by #548 (security review on PR #549). prepareClient now
|
|
1041
|
-
// runs the expected-team check itself, before the resolver, so the refusal a
|
|
1042
|
-
// mismatched team gets here is #548's (console.error, "coordination: WRONG
|
|
1043
|
-
// TEAM"), not the resolver's #220 line. The #220 interlock is unchanged and
|
|
1044
|
-
// is still exercised by the resolveCoordinationToken tests in this file.
|
|
1045
|
-
// What this test pins is the same outcome: a null client, both teams named,
|
|
1046
|
-
// and nothing cached for either team.
|
|
1047
|
-
writeFileSync(join(dir, '.mx-coordination-team'), 'product\n');
|
|
1048
|
-
process.env.CLAUDE_WORKTREE_PATH = dir;
|
|
1049
|
-
process.env.MX_PRODUCT_SLUG = PROJECT;
|
|
1050
|
-
process.env.MX_COORDINATION_MODE = 'queue';
|
|
1051
|
-
process.env.MX_COORD_EXPECT_TEAM = 'bootstrap';
|
|
1052
|
-
delete process.env.MX_COORD_SERVICE_TOKEN;
|
|
1053
|
-
const errs = [];
|
|
1054
|
-
vi.spyOn(process.stderr, 'write').mockImplementation(((c) => { errs.push(String(c)); return true; }));
|
|
1055
|
-
vi.spyOn(console, 'error').mockImplementation(((c) => { errs.push(String(c)); }));
|
|
1056
|
-
const { prepareClient } = await import('../commands/coordination.js');
|
|
1057
|
-
const client = await prepareClient();
|
|
1058
|
-
expect(client).toBeNull();
|
|
1059
|
-
const all = errs.join('');
|
|
1060
|
-
expect(all).toContain('coordination: WRONG TEAM');
|
|
1061
|
-
expect(all).toContain('product');
|
|
1062
|
-
expect(all).toContain('bootstrap');
|
|
1063
|
-
// Nothing was cached for either team.
|
|
1064
|
-
expect(existsSync(join(dir, `.mx-coordination-token--${PROJECT}--product`))).toBe(false);
|
|
1065
|
-
expect(existsSync(join(dir, `.mx-coordination-token--${PROJECT}--bootstrap`))).toBe(false);
|
|
1066
|
-
});
|
|
1067
|
-
it('both production call sites pass an assertion the resolver can disagree with', () => {
|
|
1068
|
-
// A behavioural test cannot see an UNARMED interlock: with nothing passed,
|
|
1069
|
-
// resolution succeeds and looks correct, which is exactly how this shipped.
|
|
1070
|
-
// So the wiring is read from the source, the way #5189's call-site test does.
|
|
1071
|
-
const coordination = readFileSync(join(__dirname, '..', 'commands', 'coordination.ts'), 'utf-8');
|
|
1072
|
-
expect(coordination).toMatch(/resolveCoordinationToken\(\{\s*\n\s*expect: \{/);
|
|
1073
|
-
expect(coordination).toContain('project: process.env[ENV_KEY_EXPECT_PROJECT]');
|
|
1074
|
-
expect(coordination).toContain('team: process.env[ENV_KEY_EXPECT_TEAM]');
|
|
1075
|
-
const start = readFileSync(join(__dirname, '..', 'commands', 'start.ts'), 'utf-8');
|
|
1076
|
-
// `name` is the team the command was asked to start, read from the command
|
|
1077
|
-
// line. An assertion derived from the marker would compare the marker with
|
|
1078
|
-
// itself and could never disagree.
|
|
1079
|
-
expect(start).toContain('expect: { team: name }');
|
|
1080
|
-
});
|
|
1081
|
-
it('start refuses when the worktree marker names a different team', async () => {
|
|
1082
|
-
// The behaviour start.ts wires: the team asked for is X, the marker says Y.
|
|
1083
|
-
writeFileSync(join(dir, '.mx-coordination-team'), 'surface\n');
|
|
1084
|
-
const f = fetcher({ status: 'issued', token: 'must-not-be-issued' });
|
|
1085
|
-
const res = await resolveCoordinationToken({
|
|
1086
|
-
env: { CLAUDE_WORKTREE_PATH: dir },
|
|
1087
|
-
project: PROJECT,
|
|
1088
|
-
serviceUrl: 'http://127.0.0.1:9',
|
|
1089
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
1090
|
-
fetchCredential: f.fn,
|
|
1091
|
-
expect: { team: 'gateway' },
|
|
1092
|
-
});
|
|
1093
|
-
expect(res.status).toBe('identity-mismatch');
|
|
1094
|
-
expect(f.calls).toHaveLength(0);
|
|
1095
|
-
});
|
|
1096
|
-
});
|
|
1097
|
-
// ── #290 Informational 2: a rewrite resets the mode ─────────────────────────
|
|
1098
|
-
describe('the cache is born 0600 even when a file is already there', () => {
|
|
1099
|
-
it('resets a pre-existing world-readable cache file to 0600', async () => {
|
|
1100
|
-
// `mode` applies on create only, so writing over an existing entry used to
|
|
1101
|
-
// inherit its mode. A 0644 cache is readable by every account on the host.
|
|
1102
|
-
const env = worktree();
|
|
1103
|
-
const cachePath = join(dir, CACHE);
|
|
1104
|
-
writeFileSync(cachePath, '', { mode: 0o644 });
|
|
1105
|
-
expect(statSync(cachePath).mode & 0o777).toBe(0o644);
|
|
1106
|
-
const f = fetcher({ status: 'issued', token: 'fresh-after-rewrite' });
|
|
1107
|
-
const res = await resolveCoordinationToken({ ...baseDeps(env), fetchCredential: f.fn });
|
|
1108
|
-
expect(res.status).toBe('resolved');
|
|
1109
|
-
expect(readFileSync(cachePath, 'utf-8')).toBe('fresh-after-rewrite');
|
|
1110
|
-
expect(statSync(cachePath).mode & 0o777).toBe(0o600);
|
|
1111
|
-
});
|
|
1112
|
-
it('resets the mode on the refresh path too', async () => {
|
|
1113
|
-
const env = worktree();
|
|
1114
|
-
const cachePath = join(dir, CACHE);
|
|
1115
|
-
writeFileSync(cachePath, 'rejected-token', { mode: 0o644 });
|
|
1116
|
-
const f = fetcher({ status: 'issued', token: 'fresh-token' });
|
|
1117
|
-
const res = await refreshCoordinationToken('rejected-token', { ...baseDeps(env), fetchCredential: f.fn });
|
|
1118
|
-
expect(res.status).toBe('refreshed');
|
|
1119
|
-
expect(statSync(cachePath).mode & 0o777).toBe(0o600);
|
|
1120
|
-
});
|
|
1121
|
-
});
|
|
1122
|
-
// ── #290 second delta: the credential path has its OWN allowlist key ────────
|
|
1123
|
-
describe('the key-bearing request reads only the credential suffix key', () => {
|
|
1124
|
-
/** Resolve with a URL from a given source, and chosen suffix keys in config. */
|
|
1125
|
-
async function resolveWith(url, source, keys = {}) {
|
|
1126
|
-
const { resolveCoordinationUrl } = await import('../lib/coordination-client.js');
|
|
1127
|
-
const { getConfigValue } = await import('../lib/config.js');
|
|
1128
|
-
vi.mocked(resolveCoordinationUrl).mockReturnValue({ url, source });
|
|
1129
|
-
vi.mocked(getConfigValue).mockImplementation(((key) => key === 'coordination-url-allowed-suffixes' ? keys.url
|
|
1130
|
-
: key === 'coordination-credential-allowed-suffixes' ? keys.credential
|
|
1131
|
-
: undefined));
|
|
1132
|
-
const readUserKey = vi.fn(() => FAKE_USER_KEY);
|
|
1133
|
-
const f = fetcher({ status: 'issued', token: 'issued-under-extension' });
|
|
1134
|
-
const res = await resolveCoordinationToken({
|
|
1135
|
-
env: worktree(),
|
|
1136
|
-
project: PROJECT,
|
|
1137
|
-
readUserKey,
|
|
1138
|
-
fetchCredential: f.fn,
|
|
1139
|
-
});
|
|
1140
|
-
vi.mocked(resolveCoordinationUrl).mockReturnValue(null);
|
|
1141
|
-
vi.mocked(getConfigValue).mockImplementation((() => undefined));
|
|
1142
|
-
return { res, readUserKey, f };
|
|
1143
|
-
}
|
|
1144
|
-
// The finding, on its second appearance: the previous round exempted the
|
|
1145
|
-
// `project` source on the reasoning that a committed file and the operator's
|
|
1146
|
-
// config are two parties. Nothing on this path consults git. `MX_PROJECT_ROOT`
|
|
1147
|
-
// names any directory, so both "parties" are files one uid can write.
|
|
1148
|
-
for (const source of ['env', 'config', 'project']) {
|
|
1149
|
-
it(`refuses a host that only coordination-url-allowed-suffixes permits, from ${source}`, async () => {
|
|
1150
|
-
const { res, readUserKey, f } = await resolveWith('https://coord.evil.example.com', source, { url: '.evil.example.com' });
|
|
1151
|
-
expect(res.status).toBe('misconfigured');
|
|
1152
|
-
expect(res.detail).toMatch(/outside the allowed set/);
|
|
1153
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
1154
|
-
expect(f.calls).toHaveLength(0);
|
|
1155
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
1156
|
-
});
|
|
1157
|
-
it(`accepts a host coordination-credential-allowed-suffixes permits, from ${source}`, async () => {
|
|
1158
|
-
// The deliberate opt-in: authorising a host to receive a non-expiring user
|
|
1159
|
-
// key is its own act, and this is that act.
|
|
1160
|
-
rmSync(join(dir, CACHE), { force: true });
|
|
1161
|
-
const { res, f } = await resolveWith('https://coord.acme.test', source, { credential: '.acme.test' });
|
|
1162
|
-
expect(res.status).toBe('resolved');
|
|
1163
|
-
expect(f.calls).toHaveLength(1);
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
it('the ordinary key does not widen the credential path even when both are set for other hosts', async () => {
|
|
1167
|
-
const { res, f } = await resolveWith('https://coord.evil.example.com', 'project', { url: '.evil.example.com', credential: '.something-else.test' });
|
|
1168
|
-
expect(res.status).toBe('misconfigured');
|
|
1169
|
-
expect(f.calls).toHaveLength(0);
|
|
1170
|
-
});
|
|
1171
|
-
it('refuses an unlisted host when only the credential key is set, for another suffix', async () => {
|
|
1172
|
-
const { res, f } = await resolveWith('https://coord.other.test', 'project', { credential: '.acme.test' });
|
|
1173
|
-
expect(res.status).toBe('misconfigured');
|
|
1174
|
-
expect(f.calls).toHaveLength(0);
|
|
1175
|
-
});
|
|
1176
|
-
it('accepts the built-in suffix from every source with no extension at all', async () => {
|
|
1177
|
-
for (const source of ['env', 'config', 'project']) {
|
|
1178
|
-
rmSync(join(dir, CACHE), { force: true });
|
|
1179
|
-
const { res } = await resolveWith('https://coord.memnexus.ai', source);
|
|
1180
|
-
expect(res.status).toBe('resolved');
|
|
1181
|
-
}
|
|
1182
|
-
});
|
|
1183
|
-
});
|
|
1184
|
-
// ── #290 delta review 2: the cap counts bytes, it does not trust a header ────
|
|
1185
|
-
describe('the body cap does not trust content-length', () => {
|
|
1186
|
-
let server;
|
|
1187
|
-
let url;
|
|
1188
|
-
beforeEach(async () => {
|
|
1189
|
-
server = createServer((req, res) => {
|
|
1190
|
-
// Chunked: no content-length at all, so the header check cannot fire.
|
|
1191
|
-
res.writeHead(200, { 'content-type': 'application/json', 'transfer-encoding': 'chunked' });
|
|
1192
|
-
// 2.6 MB of filler, then a token, as a hostile peer would.
|
|
1193
|
-
const chunk = 'x'.repeat(64 * 1024);
|
|
1194
|
-
res.write('{"padding":"');
|
|
1195
|
-
for (let i = 0; i < 40; i++)
|
|
1196
|
-
res.write(chunk);
|
|
1197
|
-
res.end('","token":"never-reached"}');
|
|
1198
|
-
});
|
|
1199
|
-
await new Promise((r) => server.listen(0, '127.0.0.1', r));
|
|
1200
|
-
const addr = server.address();
|
|
1201
|
-
url = `http://127.0.0.1:${typeof addr === 'object' && addr ? addr.port : 0}`;
|
|
1202
|
-
});
|
|
1203
|
-
afterEach(async () => {
|
|
1204
|
-
await new Promise((r) => server.close(() => r()));
|
|
1205
|
-
});
|
|
1206
|
-
it('refuses a chunked 200 of 2.6 MB as unavailable, and caches nothing', async () => {
|
|
1207
|
-
const res = await resolveCoordinationToken({
|
|
1208
|
-
env: worktree(),
|
|
1209
|
-
project: PROJECT,
|
|
1210
|
-
serviceUrl: url,
|
|
1211
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
1212
|
-
});
|
|
1213
|
-
expect(res.status).toBe('unavailable');
|
|
1214
|
-
expect(res.detail).toContain('65536 bytes');
|
|
1215
|
-
expect(res.token).toBeUndefined();
|
|
1216
|
-
expect(existsSync(join(dir, CACHE))).toBe(false);
|
|
1217
|
-
});
|
|
1218
|
-
});
|
|
1219
|
-
// ── #290 delta review 3: ordinary traffic is gated too, end to end ──────────
|
|
1220
|
-
describe('the team token is not sent to an unvalidated URL', () => {
|
|
1221
|
-
const saved = { ...process.env };
|
|
1222
|
-
afterEach(() => {
|
|
1223
|
-
for (const k of ['CLAUDE_WORKTREE_PATH', 'MX_PRODUCT_SLUG', 'MX_COORDINATION_MODE', 'MX_COORD_SERVICE_TOKEN', 'MX_COORD_SERVICE_URL', 'MX_COORD_EXPECT_TEAM']) {
|
|
1224
|
-
if (saved[k] === undefined)
|
|
1225
|
-
delete process.env[k];
|
|
1226
|
-
else
|
|
1227
|
-
process.env[k] = saved[k];
|
|
1228
|
-
}
|
|
1229
|
-
});
|
|
1230
|
-
it('prepareClient builds no client for a plaintext MX_COORD_SERVICE_URL, with a token set', async () => {
|
|
1231
|
-
// Through the REAL validator, not the mocked one: the credential path was
|
|
1232
|
-
// gated in the first #290 round and this is the path that carries the TEAM
|
|
1233
|
-
// token, which the short-circuit below supplies.
|
|
1234
|
-
writeFileSync(join(dir, '.mx-coordination-team'), `${TEAM}\n`);
|
|
1235
|
-
process.env.CLAUDE_WORKTREE_PATH = dir;
|
|
1236
|
-
process.env.MX_PRODUCT_SLUG = PROJECT;
|
|
1237
|
-
process.env.MX_COORDINATION_MODE = 'queue';
|
|
1238
|
-
process.env.MX_COORD_SERVICE_TOKEN = 'a-team-token';
|
|
1239
|
-
process.env.MX_COORD_SERVICE_URL = 'http://evil.example.com';
|
|
1240
|
-
delete process.env.MX_COORD_EXPECT_TEAM;
|
|
1241
|
-
const errs = [];
|
|
1242
|
-
vi.spyOn(process.stderr, 'write').mockImplementation(((c) => { errs.push(String(c)); return true; }));
|
|
1243
|
-
const { prepareClient } = await import('../commands/coordination.js');
|
|
1244
|
-
const client = await prepareClient();
|
|
1245
|
-
expect(client).toBeNull();
|
|
1246
|
-
const all = errs.join('');
|
|
1247
|
-
expect(all).toContain('could not provision a service token');
|
|
1248
|
-
expect(all).toMatch(/must use https/);
|
|
1249
|
-
// The token was never handed to a client pointed at that host.
|
|
1250
|
-
expect(all).not.toContain('a-team-token');
|
|
1251
|
-
});
|
|
1252
|
-
});
|
|
1253
|
-
// ── #290 second delta, Informational 2: the right remedy for a refused URL ───
|
|
1254
|
-
describe('a project URL that is refused is not reported as "not set"', () => {
|
|
1255
|
-
it('reports misconfigured with the validator message, not unprovisioned', async () => {
|
|
1256
|
-
// The project config validates at LOAD, inside a try whose catch discards
|
|
1257
|
-
// the reason, so a URL that is set and refused reached the operator as "URL
|
|
1258
|
-
// not set" and a remedy that is already done.
|
|
1259
|
-
const { resolveCoordinationUrl, projectUrlValidationError } = await import('../lib/coordination-client.js');
|
|
1260
|
-
vi.mocked(resolveCoordinationUrl).mockReturnValue(null);
|
|
1261
|
-
vi.mocked(projectUrlValidationError).mockReturnValue('mx-agent.config.json: "coordinationServiceUrl" must use https. Plain http is accepted only for host localhost, 127.0.0.1 or [::1].');
|
|
1262
|
-
const readUserKey = vi.fn(() => FAKE_USER_KEY);
|
|
1263
|
-
const f = fetcher({ status: 'issued', token: 'never' });
|
|
1264
|
-
const res = await resolveCoordinationToken({
|
|
1265
|
-
env: worktree(),
|
|
1266
|
-
project: PROJECT,
|
|
1267
|
-
readUserKey,
|
|
1268
|
-
fetchCredential: f.fn,
|
|
1269
|
-
});
|
|
1270
|
-
expect(res.status).toBe('misconfigured');
|
|
1271
|
-
expect(res.status).not.toBe('unprovisioned');
|
|
1272
|
-
expect(res.detail).toMatch(/must use https/);
|
|
1273
|
-
expect(res.detail).not.toMatch(/URL not set/);
|
|
1274
|
-
expect(readUserKey).not.toHaveBeenCalled();
|
|
1275
|
-
expect(f.calls).toHaveLength(0);
|
|
1276
|
-
vi.mocked(projectUrlValidationError).mockReturnValue(undefined);
|
|
1277
|
-
});
|
|
1278
|
-
it('still reports unprovisioned when nothing is configured at all', async () => {
|
|
1279
|
-
const { resolveCoordinationUrl, projectUrlValidationError } = await import('../lib/coordination-client.js');
|
|
1280
|
-
vi.mocked(resolveCoordinationUrl).mockReturnValue(null);
|
|
1281
|
-
vi.mocked(projectUrlValidationError).mockReturnValue(undefined);
|
|
1282
|
-
const res = await resolveCoordinationToken({
|
|
1283
|
-
env: worktree(),
|
|
1284
|
-
project: PROJECT,
|
|
1285
|
-
readUserKey: () => FAKE_USER_KEY,
|
|
1286
|
-
fetchCredential: fetcher({ status: 'issued', token: 'never' }).fn,
|
|
1287
|
-
});
|
|
1288
|
-
expect(res.status).toBe('unprovisioned');
|
|
1289
|
-
expect(res.detail).toContain('coordination service URL not set');
|
|
1290
|
-
});
|
|
1291
|
-
});
|
|
1292
|
-
//# sourceMappingURL=coordination-credential-endpoint.test.js.map
|