@memnexus-ai/mx-agent-cli 0.1.296-next.7 → 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/lib/templates.d.ts +1 -1
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +39 -3
- package/dist/lib/templates.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__/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,3473 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Post-creation existence assertions (#48), rows 1 to 5.
|
|
3
|
-
*
|
|
4
|
-
* Provisioning used to print "Team Created!" and a green checklist without
|
|
5
|
-
* reading back a single artifact. The completion contract
|
|
6
|
-
* (`roleguides/team-builder.md`) has twelve rows and the system asserted one of
|
|
7
|
-
* them: row 6, the exit code, which says only that the command did not crash.
|
|
8
|
-
*
|
|
9
|
-
* These tests pin two properties:
|
|
10
|
-
* 1. Every one of the thirteen rows (0 identity, 1 to 12 the contract's own)
|
|
11
|
-
* is printed BY NUMBER with asserted or not asserted against it.
|
|
12
|
-
* 2. Each of the five artifacts this version checks — the roleguide copy, the
|
|
13
|
-
* catalog entry, the three named memories — makes provisioning exit
|
|
14
|
-
* non-zero when it is absent, naming the row.
|
|
15
|
-
*/
|
|
16
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
17
|
-
import { existsSync, lstatSync, mkdtempSync, mkdirSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'fs';
|
|
18
|
-
import { join, dirname } from 'path';
|
|
19
|
-
import { tmpdir } from 'os';
|
|
20
|
-
// ── Test-controlled state. Declared before the mock factories that close over it.
|
|
21
|
-
/** Names `namedMemoryExists` should report as absent. */
|
|
22
|
-
let missingMemories = new Set();
|
|
23
|
-
/** Whether the catalog writer really writes `teams/<slug>.md`. */
|
|
24
|
-
let catalogWrites = true;
|
|
25
|
-
/** A path the catalog step deletes just before the check runs — see removeBeforeCheck below. */
|
|
26
|
-
let removeBeforeCheck = null;
|
|
27
|
-
/** What `isMxAvailable` answers. */
|
|
28
|
-
let mxAvailable = true;
|
|
29
|
-
/**
|
|
30
|
-
* Whether the project under test has an `origin` remote (#51). False is the
|
|
31
|
-
* scaffolded-project branch, which keeps provisioning's own catalog write; true
|
|
32
|
-
* is every `provision` in a project with a remote, where the entry must already
|
|
33
|
-
* be on `origin/main` and this command writes none.
|
|
34
|
-
*/
|
|
35
|
-
let hasOrigin = false;
|
|
36
|
-
/** What the `origin/main` precondition answers when `hasOrigin` is true. */
|
|
37
|
-
let entryOnOriginMain = 'present';
|
|
38
|
-
/**
|
|
39
|
-
* What row 7's read of `origin/<base>` answers (#406 part 1).
|
|
40
|
-
*
|
|
41
|
-
* `unresolvable` by default, which is what these fixtures really are: they have
|
|
42
|
-
* no reachable remote, so a run here cannot establish whether the roleguide is
|
|
43
|
-
* merged either way. Row 7 is not required, so no default here changes whether a
|
|
44
|
-
* fixture provision succeeds.
|
|
45
|
-
*/
|
|
46
|
-
let roleguideOnBaseState = 'unresolvable';
|
|
47
|
-
/**
|
|
48
|
-
* Rows 9 and 10 (#77). The three reads are mocked because the real ones run
|
|
49
|
-
* `git show` against `origin/<base>` and `az` against the dev Key Vault, and a
|
|
50
|
-
* unit suite must neither depend on a remote nor touch a vault.
|
|
51
|
-
*/
|
|
52
|
-
let rosterJsonState = 'present';
|
|
53
|
-
/** Asked only when the generated file does not hold the slug. */
|
|
54
|
-
let rosterSourceState = 'absent';
|
|
55
|
-
let vaultState = 'present';
|
|
56
|
-
const OBTAINABLE = {
|
|
57
|
-
kind: 'obtainable',
|
|
58
|
-
cachePath: '/tmp/.mx-coordination-token--mx-agent--newteam',
|
|
59
|
-
mode: 0o600,
|
|
60
|
-
};
|
|
61
|
-
let credentialState = OBTAINABLE;
|
|
62
|
-
/**
|
|
63
|
-
* Which projects take the credential path. Mutable so row 10's TWO shapes are
|
|
64
|
-
* both reachable from one fixture: this file's project is `mx-agent`, and every
|
|
65
|
-
* memory name, roleguide and remedy string in it is built from that slug. Which
|
|
66
|
-
* project is actually on the list is pinned against the real module in
|
|
67
|
-
* coordination-credential-endpoint.test.ts, not here.
|
|
68
|
-
*/
|
|
69
|
-
let credentialProjects = new Set(['mx-agent']);
|
|
70
|
-
/** What `mx-agent.config.json` declares as the coordination service URL. */
|
|
71
|
-
let configuredCoordinationUrl = '';
|
|
72
|
-
/**
|
|
73
|
-
* What a DIFFERENT project would declare: the one the current directory implies,
|
|
74
|
-
* which `findProjectRoot()` returns and which provisioning must not consult when
|
|
75
|
-
* it was given a root of its own (qa item 4b).
|
|
76
|
-
*/
|
|
77
|
-
let decoyCwdCoordinationUrl = '';
|
|
78
|
-
/**
|
|
79
|
-
* The operator's global config, in memory. Mocked so no test reads or writes the
|
|
80
|
-
* developer's ~/.mx-agent/config.json: provision now WRITES that store (#32), and
|
|
81
|
-
* a test must not leave a value behind on the machine that ran it.
|
|
82
|
-
*/
|
|
83
|
-
const globalConfig = new Map();
|
|
84
|
-
vi.mock('../lib/config.js', () => ({
|
|
85
|
-
getConfigValue: (key) => globalConfig.get(key),
|
|
86
|
-
setConfigValue: (key, value) => { globalConfig.set(key, value); },
|
|
87
|
-
// The URL resolver asks for this path to tell a corrupt operator config from an
|
|
88
|
-
// absent one. Omitting it made the call throw inside the resolver's own catch,
|
|
89
|
-
// which read as a read failure and printed the fallback warning to real stderr
|
|
90
|
-
// on every project-source case (red-team Step 6 at 7fb4567).
|
|
91
|
-
getConfigPath: () => '/nonexistent/config.json',
|
|
92
|
-
}));
|
|
93
|
-
const createGitWorktree = vi.fn((worktreePath) => {
|
|
94
|
-
mkdirSync(worktreePath, { recursive: true });
|
|
95
|
-
});
|
|
96
|
-
/**
|
|
97
|
-
* What step 6e's build reports (#123). The boundary is mocked, so no test in
|
|
98
|
-
* this file reaches npm or the network.
|
|
99
|
-
*/
|
|
100
|
-
let buildOutcome = 'built';
|
|
101
|
-
/** The version the freshly built binary reports, distinct from the runner's (S4). */
|
|
102
|
-
let builtVersion = '0.1.72';
|
|
103
|
-
/** The version the running `provision` reports (S4). */
|
|
104
|
-
let runnerVersion = '0.1.72';
|
|
105
|
-
/**
|
|
106
|
-
* Whether the mocked build really writes `dist/index.js`.
|
|
107
|
-
*
|
|
108
|
-
* It writes by default, for the reason the catalog mock really writes the
|
|
109
|
-
* catalog entry: row 14 re-reads the file at check time, so a spy alone would
|
|
110
|
-
* assert against a path that never existed. False is the row's "built and now
|
|
111
|
-
* absent" branch.
|
|
112
|
-
*/
|
|
113
|
-
let buildWritesDist = true;
|
|
114
|
-
const buildCliInWorktree = vi.fn((worktreePath) => {
|
|
115
|
-
if (buildOutcome === 'throws')
|
|
116
|
-
throw new Error('the build boundary exploded');
|
|
117
|
-
if (buildOutcome === 'not-applicable') {
|
|
118
|
-
return {
|
|
119
|
-
kind: 'not-applicable',
|
|
120
|
-
detail: 'no mx-agent-system/cli/package.json in this worktree (this project installs the published CLI)',
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
if (buildOutcome === 'could-not-run') {
|
|
124
|
-
return {
|
|
125
|
-
kind: 'could-not-run',
|
|
126
|
-
stage: 'ci',
|
|
127
|
-
detail: 'npm ci exited 1 (ECONNREFUSED registry.npmjs.org); run: cd <worktree>/mx-agent-system/cli && npm ci && npm run build',
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const distPath = join(worktreePath, 'mx-agent-system', 'cli', 'dist', 'index.js');
|
|
131
|
-
if (buildWritesDist) {
|
|
132
|
-
mkdirSync(dirname(distPath), { recursive: true });
|
|
133
|
-
writeFileSync(distPath, '#!/usr/bin/env node\n');
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
kind: 'built',
|
|
137
|
-
distPath,
|
|
138
|
-
version: builtVersion,
|
|
139
|
-
runnerVersion,
|
|
140
|
-
ciMs: 4500,
|
|
141
|
-
buildMs: 5100,
|
|
142
|
-
npmSource: 'node-adjacent',
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
vi.mock('../lib/cli-build.js', () => ({
|
|
146
|
-
buildCliInWorktree: (worktreePath, ..._rest) => buildCliInWorktree(worktreePath),
|
|
147
|
-
REBUILD_REMEDY: 'npm ci && npm run build',
|
|
148
|
-
}));
|
|
149
|
-
/** The catalog module's own path helper, spied so row 2 can be shown to use it. */
|
|
150
|
-
const getTeamCatalogPath = vi.fn((projectRoot, slug, teamsDir) => join(projectRoot, teamsDir, `${slug}.md`));
|
|
151
|
-
/** What `namedMemoryExists` reports for a name in `missingMemories`. */
|
|
152
|
-
let missingDetail = 'mx returned no such memory';
|
|
153
|
-
/** Names that already resolved BEFORE this run's create call. */
|
|
154
|
-
let preExistingMemories = new Set();
|
|
155
|
-
/** Names a create call in this test has already taken. Reset per test. */
|
|
156
|
-
let createdNames = new Set();
|
|
157
|
-
/** Whether this run's create call reports success. */
|
|
158
|
-
let createReportsOk = true;
|
|
159
|
-
/** Names whose create reports failure even when `createReportsOk` is true (#493). */
|
|
160
|
-
let createFailsFor = new Set();
|
|
161
|
-
/**
|
|
162
|
-
* What the pre-existence probe says about a taken name's owner (#493). Unset
|
|
163
|
-
* names carry no ownership, which is what every test before #493 modelled.
|
|
164
|
-
*/
|
|
165
|
-
let ownershipFor = new Map();
|
|
166
|
-
/**
|
|
167
|
-
* Extra-anchor suffixes the seeding path returns NO result for, the case
|
|
168
|
-
* `create.ts` reports as "the seeding path returned no result for this accepted
|
|
169
|
-
* anchor" (#493: such a spec must get no create command).
|
|
170
|
-
*/
|
|
171
|
-
let dropExtraResults = new Set();
|
|
172
|
-
/** Whether this run's create call yields an id (an older mx returns none). */
|
|
173
|
-
let createYieldsId = true;
|
|
174
|
-
/** Whether the pre-existence probe reached a verdict at all. */
|
|
175
|
-
let probeConclusive = true;
|
|
176
|
-
/**
|
|
177
|
-
* Whether the by-id read fails while the by-name read succeeds — the measured
|
|
178
|
-
* backend behaviour: `get <id>` returns Not Found for minutes after a create
|
|
179
|
-
* while `get --name` returns the same memory immediately.
|
|
180
|
-
*/
|
|
181
|
-
let idLags = false;
|
|
182
|
-
/**
|
|
183
|
-
* What the SHAPE read (rows 3 to 5, #6) gets back for a name.
|
|
184
|
-
*
|
|
185
|
-
* The default seed below is a hand-written copy of the block, not the real one:
|
|
186
|
-
* `../lib/memory.js` is mocked in this file, and the point here is what the
|
|
187
|
-
* checker does with a seed that is right, wrong, or unreadable. The real seed is
|
|
188
|
-
* pinned against the real parser in team-memory-commands.test.ts.
|
|
189
|
-
*/
|
|
190
|
-
let seedContentFor;
|
|
191
|
-
let seedCodeContextFor;
|
|
192
|
-
/** Names whose shape read cannot be performed at all — could-not-run, not a miss. */
|
|
193
|
-
let shapeReadFails = new Set();
|
|
194
|
-
/** What `mx-agent.config.json` configures as the project slug for this run. */
|
|
195
|
-
let configuredProjectSlug = 'mx-agent';
|
|
196
|
-
/**
|
|
197
|
-
* #190 / M5: a fourth anchor whose create reports a DIFFERENT conversation from
|
|
198
|
-
* the one it was given. The real module reports `conversationThreaded: false`
|
|
199
|
-
* for that; a computation that still enumerated two followers would report true.
|
|
200
|
-
*/
|
|
201
|
-
let extraConversationDiverges = false;
|
|
202
|
-
/** What the pre-existence probe read, for a name that was already taken. */
|
|
203
|
-
let preExistingContentFor;
|
|
204
|
-
let preExistingCodeContextFor;
|
|
205
|
-
const LEADER_SEED = [
|
|
206
|
-
'## Newteam Leader State, updated 2026-08-21 09:07',
|
|
207
|
-
'',
|
|
208
|
-
'### Async Status Block',
|
|
209
|
-
'- Async status: ok',
|
|
210
|
-
'- Decision needed: none',
|
|
211
|
-
'- Last finding: none (provisioned 2026-08-21, no session yet)',
|
|
212
|
-
'- Linkage: mx-agent-system/teams/newteam.md, mx-agent-system/roleguides/newteam-leader.md',
|
|
213
|
-
'',
|
|
214
|
-
'### Current Position',
|
|
215
|
-
'- Iteration: none',
|
|
216
|
-
'- Loop step: 0',
|
|
217
|
-
'- North star: not yet measured',
|
|
218
|
-
'',
|
|
219
|
-
'### What I Just Did',
|
|
220
|
-
].join('\n');
|
|
221
|
-
const FULL_CODE_CONTEXT = {
|
|
222
|
-
product: 'mx-agent',
|
|
223
|
-
service: 'team-provisioning',
|
|
224
|
-
team: 'newteam',
|
|
225
|
-
role: 'team-lead',
|
|
226
|
-
};
|
|
227
|
-
let idLagDetail = 'id 2aa310bb-9b70-4e4a-aaa9-33ed406ffc1e does not resolve';
|
|
228
|
-
vi.mock('../lib/worktree.js', async (importOriginal) => ({
|
|
229
|
-
// `findTeamWorktree` decides whether a run is a resume (#316). The REAL one:
|
|
230
|
-
// it reads `.git` off the candidate, and a stub that answered null would make
|
|
231
|
-
// every test here take the fresh-creation path whatever is on disk.
|
|
232
|
-
findTeamWorktree: (await importOriginal()).findTeamWorktree,
|
|
233
|
-
findProjectRoot: vi.fn(() => '/unused'),
|
|
234
|
-
assignSlot: vi.fn(() => 0),
|
|
235
|
-
getCurrentBranch: vi.fn(() => 'worktree/x'),
|
|
236
|
-
fetchOrigin: vi.fn(),
|
|
237
|
-
createGitWorktree: (worktreePath, ..._rest) => createGitWorktree(worktreePath),
|
|
238
|
-
addToGitSafeDirectory: vi.fn(),
|
|
239
|
-
createHuskySymlink: vi.fn(),
|
|
240
|
-
generateBranchName: vi.fn((s) => `worktree/${s}`),
|
|
241
|
-
generateWorktreeDirName: vi.fn((s) => `${s}-20260101`),
|
|
242
|
-
listRemotes: vi.fn(() => (hasOrigin ? ['origin'] : [])),
|
|
243
|
-
}));
|
|
244
|
-
vi.mock('../lib/claude.js', () => ({
|
|
245
|
-
syncClaudeConfig: vi.fn(),
|
|
246
|
-
deployClaudeMd: vi.fn(),
|
|
247
|
-
writeClaudeLocal: vi.fn(),
|
|
248
|
-
logSuccess: vi.fn(),
|
|
249
|
-
logWarning: vi.fn(),
|
|
250
|
-
logDim: vi.fn(),
|
|
251
|
-
}));
|
|
252
|
-
/**
|
|
253
|
-
* The catalog writer, which really writes the file so row 2 can be asserted
|
|
254
|
-
* against the filesystem rather than against a spy.
|
|
255
|
-
*
|
|
256
|
-
* It is also the LAST step before the completion check, which makes it the one
|
|
257
|
-
* place a test can remove an already-created artifact and produce a genuine
|
|
258
|
-
* row-1 miss: nothing else runs between the roleguide copy and the check.
|
|
259
|
-
*/
|
|
260
|
-
vi.mock('../lib/catalog.js', async (importOriginal) => {
|
|
261
|
-
// `importOriginal` for ONE export: the pure path rule row 7's detail consults.
|
|
262
|
-
// Nothing else in this module is taken from the real one, so the mocked
|
|
263
|
-
// surface below is unchanged.
|
|
264
|
-
const real = await importOriginal();
|
|
265
|
-
return {
|
|
266
|
-
getTeamCatalogPath: (projectRoot, slug, teamsDir) => getTeamCatalogPath(projectRoot, slug, teamsDir),
|
|
267
|
-
writeTeamCatalog: vi.fn((projectRoot, entry, teamsDir) => {
|
|
268
|
-
if (removeBeforeCheck)
|
|
269
|
-
unlinkSync(removeBeforeCheck);
|
|
270
|
-
if (!catalogWrites)
|
|
271
|
-
return;
|
|
272
|
-
const dir = join(projectRoot, teamsDir);
|
|
273
|
-
mkdirSync(dir, { recursive: true });
|
|
274
|
-
writeFileSync(join(dir, `${entry.slug}.md`), '# catalog entry\n');
|
|
275
|
-
}),
|
|
276
|
-
slugToDisplayName: vi.fn((s) => s),
|
|
277
|
-
catalogEntryOnOriginMain: vi.fn(() => entryOnOriginMain),
|
|
278
|
-
// Row 7 (#406 part 1). The real reader runs `git cat-file` against
|
|
279
|
-
// `origin/<base>`, so it is mocked here for the reason rows 9 and 10 are: a
|
|
280
|
-
// unit suite must not depend on a remote.
|
|
281
|
-
// `src/__tests__/completion-rows-discriminate.test.ts` runs the real one
|
|
282
|
-
// against a real git fixture, and `provision-resume.test.ts` asserts the path
|
|
283
|
-
// each of the two call sites computes.
|
|
284
|
-
roleguideOnOriginMain: vi.fn(() => roleguideOnBaseState),
|
|
285
|
-
// The REAL path rule, not a stub. Row 7's could-not-run detail asks it which
|
|
286
|
-
// of three causes to name, and a permissive stand-in here would let a test
|
|
287
|
-
// pass on a path the shipped binary refuses.
|
|
288
|
-
isReadableRepoPath: real.isReadableRepoPath,
|
|
289
|
-
// #190: the anchor validator asks the catalog for the OTHER slugs this project
|
|
290
|
-
// knows, so a table row cannot name another team's namespace (M2 check 2).
|
|
291
|
-
// Empty here: these tests provision into a scratch project with one team.
|
|
292
|
-
listTeams: vi.fn(() => []),
|
|
293
|
-
};
|
|
294
|
-
});
|
|
295
|
-
vi.mock('../lib/roster.js', async (importOriginal) => ({
|
|
296
|
-
// #607: the real ref builder, so the ref rows 9 and 10 name is the one the read uses.
|
|
297
|
-
rosterRefFor: (await importOriginal()).rosterRefFor,
|
|
298
|
-
rosterEntryOnRef: vi.fn(() => rosterJsonState),
|
|
299
|
-
rosterSourceHasSlug: vi.fn(() => rosterSourceState),
|
|
300
|
-
}));
|
|
301
|
-
vi.mock('../lib/vault.js', () => ({
|
|
302
|
-
vaultTokenPresent: vi.fn(() => vaultState),
|
|
303
|
-
VAULT_NAME: 'mx-dev-eastus2-kv-001',
|
|
304
|
-
}));
|
|
305
|
-
// Row 10's other half (#288): for a credential-endpoint project the row asks
|
|
306
|
-
// whether a credential is OBTAINABLE. The probe is an HTTPS request, so the
|
|
307
|
-
// boundary is stubbed by module, exactly as the vault read above is.
|
|
308
|
-
vi.mock('../lib/coordination-token.js', () => ({
|
|
309
|
-
usesCredentialEndpoint: (project) => credentialProjects.has(project),
|
|
310
|
-
// `forceMint` is row 12's one re-mint after a cached token was answered 401
|
|
311
|
-
// (v41, condition R1). It answers `remintState`, so a test states the
|
|
312
|
-
// re-mint's outcome separately from the first one.
|
|
313
|
-
provisionCredentialForWorktree: vi.fn(async (i) => (i.forceMint === true ? remintState : credentialState)),
|
|
314
|
-
}));
|
|
315
|
-
/**
|
|
316
|
-
* Row 12's probe (#15, v41). The REAL `probeTeamToken` runs: its classification,
|
|
317
|
-
* its dependency on row 10, its URL check and its one re-mint are the shipped
|
|
318
|
-
* code. Two things are injected, because a unit suite neither reads a token
|
|
319
|
-
* file nor opens a socket: the token read (a fake value) and the one request
|
|
320
|
-
* (`obligationsAnswers`, in call order, the last entry repeating).
|
|
321
|
-
*/
|
|
322
|
-
let obligationsAnswers = [200];
|
|
323
|
-
/** The URL each probe request went to. The token is never recorded. */
|
|
324
|
-
let obligationsCalls = [];
|
|
325
|
-
let remintState = {
|
|
326
|
-
kind: 'obtainable',
|
|
327
|
-
cachePath: '/tmp/.mx-coordination-token--mx-agent--newteam',
|
|
328
|
-
mode: 0o600,
|
|
329
|
-
};
|
|
330
|
-
vi.mock('../lib/team-token-probe.js', async (importOriginal) => {
|
|
331
|
-
const real = await importOriginal();
|
|
332
|
-
const client = await vi.importActual('../lib/coordination-client.js');
|
|
333
|
-
return {
|
|
334
|
-
...real,
|
|
335
|
-
probeTeamToken: vi.fn((i) => real.probeTeamToken({
|
|
336
|
-
...i,
|
|
337
|
-
readToken: () => 'fake-team-token-for-tests-only',
|
|
338
|
-
getObligations: async ({ url }) => {
|
|
339
|
-
obligationsCalls.push(url);
|
|
340
|
-
const a = obligationsAnswers[Math.min(obligationsCalls.length - 1, obligationsAnswers.length - 1)];
|
|
341
|
-
if (a === 'timeout')
|
|
342
|
-
throw new client.ServiceUnreachableError(new Error('The operation was aborted'));
|
|
343
|
-
if (a >= 200 && a < 300)
|
|
344
|
-
return {};
|
|
345
|
-
throw new client.ServiceHttpError(a, 'service-error-text-for-tests');
|
|
346
|
-
},
|
|
347
|
-
})),
|
|
348
|
-
};
|
|
349
|
-
});
|
|
350
|
-
vi.mock('../lib/memory.js', () => ({
|
|
351
|
-
// create.ts reads this for the generated roleguide's codeContext (#83 B2).
|
|
352
|
-
PROVISIONED_MEMORY_SERVICE: 'team-provisioning',
|
|
353
|
-
// #190: the real rule, not a stub. create.ts validates every anchor suffix
|
|
354
|
-
// against this before a name is built from it, and a permissive stand-in here
|
|
355
|
-
// would let a test pass on a name the shipped binary refuses.
|
|
356
|
-
EXTRA_ANCHOR_SUFFIX_RE: /^[a-z0-9]+(-[a-z0-9]+)*$/,
|
|
357
|
-
// Real implementation, not a stub: the refusal messages are asserted to be quoted.
|
|
358
|
-
shellSingleQuote: (s) => `'${s.replace(/'/g, "'\\''")}'`,
|
|
359
|
-
isMxAvailable: vi.fn(() => mxAvailable),
|
|
360
|
-
bootstrapTeamMemories: vi.fn((slug, _display, _rg, projectSlug, opts) => {
|
|
361
|
-
const creation = (suffix) => {
|
|
362
|
-
const name = `${projectSlug}-${slug}-${suffix}`;
|
|
363
|
-
// The real module refuses to create over a taken name
|
|
364
|
-
// (`lib/memory.ts:645-659`). A name created by an earlier call in the same
|
|
365
|
-
// test is taken for every later call, which is what makes a two-run chain
|
|
366
|
-
// testable at all. Computed before the add, so the creating call still
|
|
367
|
-
// reports `preExisting: false`.
|
|
368
|
-
const taken = preExistingMemories.has(name) || createdNames.has(name);
|
|
369
|
-
createdNames.add(name);
|
|
370
|
-
return {
|
|
371
|
-
ok: createReportsOk && !createFailsFor.has(name),
|
|
372
|
-
output: '',
|
|
373
|
-
id: createYieldsId ? `id-of-${name}` : null,
|
|
374
|
-
preExisting: taken,
|
|
375
|
-
preExistingOwnership: taken ? ownershipFor.get(name) : undefined,
|
|
376
|
-
probeConclusive,
|
|
377
|
-
probeReason: probeConclusive ? undefined : 'mx exited 7 (gateway timeout)',
|
|
378
|
-
// Only the taken-name branch returns this, and it is what the probe had
|
|
379
|
-
// already read — no second call to the backend.
|
|
380
|
-
preExistingRead: taken
|
|
381
|
-
? { content: preExistingContentFor(name), codeContext: preExistingCodeContextFor(name) }
|
|
382
|
-
: undefined,
|
|
383
|
-
};
|
|
384
|
-
};
|
|
385
|
-
const leaderState = creation('leader-state');
|
|
386
|
-
const iterationLog = creation('iteration-log');
|
|
387
|
-
const knownIssues = creation('known-issues');
|
|
388
|
-
// #190: anchors beyond the three, seeded through the same closure, so a
|
|
389
|
-
// pre-existing extra name reports `preExisting` exactly as the three do
|
|
390
|
-
// (M3). Empty unless the roleguide's table named extras.
|
|
391
|
-
const extras = (opts?.extraAnchorSuffixes ?? []).filter((suffix) => !dropExtraResults.has(suffix)).map((suffix) => ({
|
|
392
|
-
suffix,
|
|
393
|
-
name: `${projectSlug ? `${projectSlug}-` : ''}${slug}-${suffix}`,
|
|
394
|
-
creation: creation(suffix),
|
|
395
|
-
}));
|
|
396
|
-
// The real module reconciles the threading claim against EVERY follower
|
|
397
|
-
// create, not a fixed pair (#102, and M5 for the fourth anchor). The fixture
|
|
398
|
-
// models the same rule, so no test here rests on a result shape the module
|
|
399
|
-
// cannot produce.
|
|
400
|
-
const followers = [iterationLog, knownIssues, ...extras.map((e) => e.creation)];
|
|
401
|
-
const threaded = leaderState.ok && followers.every((c) => c.ok)
|
|
402
|
-
&& !extraConversationDiverges;
|
|
403
|
-
return {
|
|
404
|
-
leaderState,
|
|
405
|
-
iterationLog,
|
|
406
|
-
knownIssues,
|
|
407
|
-
extras,
|
|
408
|
-
conversationThreaded: threaded,
|
|
409
|
-
conversationId: threaded ? 'conv_testfixture' : null,
|
|
410
|
-
conversationOutcome: threaded
|
|
411
|
-
? 'threaded-by-this-run'
|
|
412
|
-
: extraConversationDiverges
|
|
413
|
-
? 'follower-create-rejected-the-conversation'
|
|
414
|
-
: 'create-returned-no-conversation-id',
|
|
415
|
-
};
|
|
416
|
-
}),
|
|
417
|
-
namedMemoryResolvesById: vi.fn((_id, expectedName) => idLags || missingMemories.has(expectedName)
|
|
418
|
-
? { ok: false, detail: idLagDetail }
|
|
419
|
-
: { ok: true, detail: '' }),
|
|
420
|
-
logMemoryResult: vi.fn(),
|
|
421
|
-
// Real shape: the pre-step-1 name-length check derives the three names from
|
|
422
|
-
// this, so an empty array would make every slug look zero-length. All four
|
|
423
|
-
// codeContext keys, because step 6a writes them into the new worktree's
|
|
424
|
-
// `.mx-code-context.json` (#62) and a two-key stub would refuse every
|
|
425
|
-
// provision here for a reason the real module cannot produce.
|
|
426
|
-
//
|
|
427
|
-
// Extras are APPENDED, as the real module appends them (`lib/memory.ts`,
|
|
428
|
-
// `teamMemorySpecs`), so the manual-command filter sees the same list the
|
|
429
|
-
// shipped binary builds (#493, security review Should Fix on #495).
|
|
430
|
-
teamMemorySpecs: vi.fn((slug, _d, _r, projectSlug, opts) => [
|
|
431
|
-
...['leader-state', 'iteration-log', 'known-issues'].map((suffix) => ({ key: suffix, suffix })),
|
|
432
|
-
...(opts?.extraAnchorSuffixes ?? []).map((suffix) => ({ key: `extra:${suffix}`, suffix })),
|
|
433
|
-
].map(({ key, suffix }) => ({
|
|
434
|
-
key,
|
|
435
|
-
name: `${projectSlug ? `${projectSlug}-` : ''}${slug}-${suffix}`,
|
|
436
|
-
content: '',
|
|
437
|
-
codeContext: {
|
|
438
|
-
product: projectSlug,
|
|
439
|
-
service: 'team-provisioning',
|
|
440
|
-
team: slug,
|
|
441
|
-
role: 'team-lead',
|
|
442
|
-
},
|
|
443
|
-
}))),
|
|
444
|
-
logManualMemoryCommands: vi.fn(),
|
|
445
|
-
namedMemoryExists: vi.fn((name) => missingMemories.has(name)
|
|
446
|
-
? { ok: false, detail: missingDetail }
|
|
447
|
-
: { ok: true, detail: '' }),
|
|
448
|
-
// The read rows 3 to 5 use for the shape assertion. Three-state, like the real
|
|
449
|
-
// one: a read that could not be performed is not a memory with a bad shape.
|
|
450
|
-
readNamedMemoryJson: vi.fn((name) => shapeReadFails.has(name)
|
|
451
|
-
? { status: 'unknown', content: '', exitCode: null, reason: 'mx was killed or timed out' }
|
|
452
|
-
: {
|
|
453
|
-
status: 'present',
|
|
454
|
-
content: seedContentFor(name),
|
|
455
|
-
body: { name, codeContext: seedCodeContextFor(name) },
|
|
456
|
-
exitCode: 0,
|
|
457
|
-
}),
|
|
458
|
-
}));
|
|
459
|
-
vi.mock('../lib/project-config.js', async (importOriginal) => ({
|
|
460
|
-
// Row 12's probe checks the URL with the real validator (v41): a permissive
|
|
461
|
-
// stand-in would let a test pass on a URL the shipped binary refuses.
|
|
462
|
-
validateCoordinationServiceUrl: (await importOriginal()).validateCoordinationServiceUrl,
|
|
463
|
-
// Root-aware: '/unused' is what the mocked findProjectRoot returns, so a config
|
|
464
|
-
// read at that root is a read of the WRONG project.
|
|
465
|
-
loadProjectConfig: vi.fn((root) => ({ __root: root })),
|
|
466
|
-
resolveProjectConfig: vi.fn((c) => ({
|
|
467
|
-
worktreeDir: '.worktrees',
|
|
468
|
-
baseBranch: 'main',
|
|
469
|
-
configSource: 'mx-agent-system/agent-config',
|
|
470
|
-
teamsDir: 'mx-agent-system/teams',
|
|
471
|
-
roleguidesDir: 'mx-agent-system/roleguides',
|
|
472
|
-
projectSlug: configuredProjectSlug,
|
|
473
|
-
coordinationServiceUrl: c?.__root === '/unused' ? decoyCwdCoordinationUrl : configuredCoordinationUrl,
|
|
474
|
-
})),
|
|
475
|
-
}));
|
|
476
|
-
vi.mock('../lib/config-generation.js', () => ({ checkConfigGeneration: vi.fn() }));
|
|
477
|
-
import { runCreate, CompletionCheckError, __testing, SELF_SERVICE_REFUSED_DETAIL } from '../commands/create.js';
|
|
478
|
-
import { TEAM_BUILDER_ROLEGUIDE } from '../lib/templates.js';
|
|
479
|
-
import { rosterEntryOnRef, rosterSourceHasSlug } from '../lib/roster.js';
|
|
480
|
-
import { roleguideOnOriginMain } from '../lib/catalog.js';
|
|
481
|
-
import { vaultTokenPresent } from '../lib/vault.js';
|
|
482
|
-
import { provisionCredentialForWorktree } from '../lib/coordination-token.js';
|
|
483
|
-
import { BEHAVIORAL_START_MARKER, BEHAVIORAL_END_MARKER } from '../lib/behavioral-injection.js';
|
|
484
|
-
const { checkCompletionRows, printCompletionRows } = __testing;
|
|
485
|
-
class ExitCalled extends Error {
|
|
486
|
-
code;
|
|
487
|
-
constructor(code) {
|
|
488
|
-
super(`process.exit(${code})`);
|
|
489
|
-
this.code = code;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
const RG = 'mx-agent-system/roleguides/newteam-leader.md';
|
|
493
|
-
const WORKTREE = '.worktrees/newteam-20260101';
|
|
494
|
-
const MEMORIES = [
|
|
495
|
-
'mx-agent-newteam-leader-state',
|
|
496
|
-
'mx-agent-newteam-iteration-log',
|
|
497
|
-
'mx-agent-newteam-known-issues',
|
|
498
|
-
];
|
|
499
|
-
const OWN_PROJECT = [
|
|
500
|
-
'# Newteam Leader Roleguide',
|
|
501
|
-
'',
|
|
502
|
-
BEHAVIORAL_START_MARKER,
|
|
503
|
-
'## Decision Authority',
|
|
504
|
-
'',
|
|
505
|
-
'- Ship without asking when the data is clear.',
|
|
506
|
-
BEHAVIORAL_END_MARKER,
|
|
507
|
-
'',
|
|
508
|
-
// #190: provisioning seeds one memory per row of this table, so a roleguide
|
|
509
|
-
// it accepts has to carry it. Three rows is the skeleton's shape.
|
|
510
|
-
'## Named Memory Anchors',
|
|
511
|
-
'',
|
|
512
|
-
'| Name | Content | Updated when |',
|
|
513
|
-
'|---|---|---|',
|
|
514
|
-
'| `mx-agent-newteam-leader-state` | State | Every change |',
|
|
515
|
-
'| `mx-agent-newteam-iteration-log` | Log | At iteration close |',
|
|
516
|
-
'| `mx-agent-newteam-known-issues` | Issues | When found |',
|
|
517
|
-
].join('\n');
|
|
518
|
-
let root;
|
|
519
|
-
let stdout;
|
|
520
|
-
let stderr;
|
|
521
|
-
/** Everything written to the real stderr stream, as opposed to console.error. */
|
|
522
|
-
let stderrStream;
|
|
523
|
-
beforeEach(() => {
|
|
524
|
-
root = mkdtempSync(join(tmpdir(), 'mx-completion-rows-'));
|
|
525
|
-
missingMemories = new Set();
|
|
526
|
-
missingDetail = 'mx returned no such memory';
|
|
527
|
-
preExistingMemories = new Set();
|
|
528
|
-
createdNames = new Set();
|
|
529
|
-
createReportsOk = true;
|
|
530
|
-
createFailsFor = new Set();
|
|
531
|
-
ownershipFor = new Map();
|
|
532
|
-
dropExtraResults = new Set();
|
|
533
|
-
createYieldsId = true;
|
|
534
|
-
probeConclusive = true;
|
|
535
|
-
idLags = false;
|
|
536
|
-
idLagDetail = 'id 2aa310bb-9b70-4e4a-aaa9-33ed406ffc1e does not resolve';
|
|
537
|
-
seedContentFor = (name) => name.endsWith('-leader-state') ? LEADER_SEED : `## Newteam log, updated 2026-08-21\n`;
|
|
538
|
-
seedCodeContextFor = () => ({ ...FULL_CODE_CONTEXT });
|
|
539
|
-
shapeReadFails = new Set();
|
|
540
|
-
configuredProjectSlug = 'mx-agent';
|
|
541
|
-
credentialState = OBTAINABLE;
|
|
542
|
-
remintState = { kind: 'obtainable', cachePath: '/tmp/.mx-coordination-token--mx-agent--newteam', mode: 0o600 };
|
|
543
|
-
obligationsAnswers = [200];
|
|
544
|
-
obligationsCalls = [];
|
|
545
|
-
credentialProjects = new Set(['mx-agent']);
|
|
546
|
-
extraConversationDiverges = false;
|
|
547
|
-
preExistingContentFor = (name) => (name.endsWith('-leader-state') ? LEADER_SEED : '## log');
|
|
548
|
-
preExistingCodeContextFor = () => ({ ...FULL_CODE_CONTEXT });
|
|
549
|
-
catalogWrites = true;
|
|
550
|
-
removeBeforeCheck = null;
|
|
551
|
-
buildOutcome = 'built';
|
|
552
|
-
builtVersion = '0.1.72';
|
|
553
|
-
runnerVersion = '0.1.72';
|
|
554
|
-
buildWritesDist = true;
|
|
555
|
-
mxAvailable = true;
|
|
556
|
-
hasOrigin = false;
|
|
557
|
-
entryOnOriginMain = 'present';
|
|
558
|
-
roleguideOnBaseState = 'unresolvable';
|
|
559
|
-
rosterJsonState = 'present';
|
|
560
|
-
rosterSourceState = 'absent';
|
|
561
|
-
vaultState = 'present';
|
|
562
|
-
configuredCoordinationUrl = '';
|
|
563
|
-
decoyCwdCoordinationUrl = '';
|
|
564
|
-
globalConfig.clear();
|
|
565
|
-
delete process.env.MX_COORD_SERVICE_URL;
|
|
566
|
-
stdout = [];
|
|
567
|
-
stderr = [];
|
|
568
|
-
stderrStream = [];
|
|
569
|
-
vi.clearAllMocks();
|
|
570
|
-
vi.spyOn(process.stderr, 'write').mockImplementation(((chunk) => {
|
|
571
|
-
stderrStream.push(String(chunk));
|
|
572
|
-
return true;
|
|
573
|
-
}));
|
|
574
|
-
vi.spyOn(console, 'log').mockImplementation((...a) => {
|
|
575
|
-
stdout.push(a.map(String).join(' '));
|
|
576
|
-
});
|
|
577
|
-
vi.spyOn(console, 'error').mockImplementation((...a) => {
|
|
578
|
-
stderr.push(a.map(String).join(' '));
|
|
579
|
-
});
|
|
580
|
-
vi.spyOn(process, 'exit').mockImplementation(((code) => {
|
|
581
|
-
throw new ExitCalled(code ?? 0);
|
|
582
|
-
}));
|
|
583
|
-
});
|
|
584
|
-
afterEach(() => {
|
|
585
|
-
rmSync(root, { recursive: true, force: true });
|
|
586
|
-
vi.restoreAllMocks();
|
|
587
|
-
});
|
|
588
|
-
/**
|
|
589
|
-
* Provision `newteam` from a roleguide that belongs to this project.
|
|
590
|
-
*
|
|
591
|
-
* A failed completion check THROWS rather than exiting, the same shape as the
|
|
592
|
-
* two provisioning refusals, so `mx-agent new project` keeps its handler. The
|
|
593
|
-
* message is what `index.ts` prints before it exits 1, so the tests read it.
|
|
594
|
-
*/
|
|
595
|
-
/**
|
|
596
|
-
* The fixture roleguide, with its Named Memory Anchors table spelled for the
|
|
597
|
-
* project slug this test configured (#190).
|
|
598
|
-
*
|
|
599
|
-
* Provisioning validates every row against `<projectSlug>-<slug>-`, and with no
|
|
600
|
-
* configured project slug `teamMemorySpecs` writes the UNPREFIXED name. A table
|
|
601
|
-
* hardcoded to `mx-agent-` would be refused in exactly the test that asserts the
|
|
602
|
-
* unprefixed path still works, so the fixture follows the same rule the code does.
|
|
603
|
-
*/
|
|
604
|
-
function ownProjectFor(projectSlug) {
|
|
605
|
-
const prefix = projectSlug ? `${projectSlug}-newteam` : 'newteam';
|
|
606
|
-
return OWN_PROJECT.replace(/mx-agent-newteam-/g, `${prefix}-`);
|
|
607
|
-
}
|
|
608
|
-
async function provision() {
|
|
609
|
-
const abs = join(root, RG);
|
|
610
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
611
|
-
writeFileSync(abs, ownProjectFor(configuredProjectSlug));
|
|
612
|
-
try {
|
|
613
|
-
await runCreate({ roleguide: RG, name: 'newteam', projectRoot: root });
|
|
614
|
-
return { failure: null };
|
|
615
|
-
}
|
|
616
|
-
catch (err) {
|
|
617
|
-
if (err instanceof CompletionCheckError)
|
|
618
|
-
return { failure: err };
|
|
619
|
-
if (err instanceof ExitCalled)
|
|
620
|
-
throw new Error(`unexpected process.exit(${err.code})`);
|
|
621
|
-
throw err;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
/** Every printed `row N:` line, in order. */
|
|
625
|
-
function rowLines() {
|
|
626
|
-
return stdout.filter((l) => /^\s*row \d+:/.test(l));
|
|
627
|
-
}
|
|
628
|
-
describe('completion check — the printed rows', () => {
|
|
629
|
-
it('prints sixteen rows, numbered 0 to 15, on a successful provision', async () => {
|
|
630
|
-
// Thirteen until #83 B3 added row 13, the placeholder scan; fifteen since #123
|
|
631
|
-
// added row 14, the CLI built in the worktree; sixteen since #440 part A added
|
|
632
|
-
// row 15, the per-team git identity.
|
|
633
|
-
const { failure } = await provision();
|
|
634
|
-
expect(failure).toBeNull();
|
|
635
|
-
const lines = rowLines();
|
|
636
|
-
expect(lines).toHaveLength(16);
|
|
637
|
-
for (let n = 0; n <= 15; n++) {
|
|
638
|
-
expect(lines[n]).toContain(`row ${n}:`);
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
it('reports row 15 as could-not-run in this fixture, because the "worktree" is not a git worktree', async () => {
|
|
642
|
-
// `createGitWorktree` is mocked to `mkdirSync` in this file, so the directory
|
|
643
|
-
// provisioning writes into is not a linked worktree and holds no git config
|
|
644
|
-
// at all. Could-not-run is the correct third outcome for that: the row did
|
|
645
|
-
// not look, so it neither passed nor failed
|
|
646
|
-
// (mx-agent-system/standards/fail-loud-standard.md). The row is not required,
|
|
647
|
-
// so it does not change this fixture's exit code — asserted here so that a
|
|
648
|
-
// future change making it required is a visible failure rather than a
|
|
649
|
-
// silently refused provision.
|
|
650
|
-
const { failure } = await provision();
|
|
651
|
-
expect(failure).toBeNull();
|
|
652
|
-
const lines = rowLines();
|
|
653
|
-
expect(lines[15]).toMatch(/row 15: could not run/);
|
|
654
|
-
expect(lines[15]).not.toMatch(/not asserted/);
|
|
655
|
-
});
|
|
656
|
-
it('marks rows 0 to 6, 8, 9, 10 and 13 asserted, row 7 could not run, the rest not asserted', async () => {
|
|
657
|
-
// Rows 9 and 10 are read now (#77): the roster entry on `origin/<base>` and
|
|
658
|
-
// the minted token. This fixture has both, which is the state team-builder
|
|
659
|
-
// steps 6a and 6a2 leave before `provision` runs.
|
|
660
|
-
//
|
|
661
|
-
// Row 7 moved out of the second group in #406 part 1. It reads
|
|
662
|
-
// `origin/<base>` for the roleguide, and this fixture has no reachable
|
|
663
|
-
// remote, so the row could not run rather than having run and not held.
|
|
664
|
-
//
|
|
665
|
-
// Row 8 moved out of it in #428 part 3, and this line is the change: it was
|
|
666
|
-
// hard-coded `asserted: false` and now resolves the team a
|
|
667
|
-
// `mx-agent start newteam` in this worktree would use and compares it with
|
|
668
|
-
// the `team` the worktree records. This fixture writes
|
|
669
|
-
// `.mx-code-context.json` for `newteam` at step 6a and the argument outranks
|
|
670
|
-
// `CLAUDE_TEAM_NAME`, so the two agree whatever the environment of the
|
|
671
|
-
// machine running the suite holds. Row 11 is the one this version still
|
|
672
|
-
// does not look at.
|
|
673
|
-
//
|
|
674
|
-
// Row 12 moved into the asserted group in v41 (#15): `provision` now makes
|
|
675
|
-
// one GET /obligations as the new team, and this fixture's injected probe
|
|
676
|
-
// answers 200.
|
|
677
|
-
await provision();
|
|
678
|
-
const lines = rowLines();
|
|
679
|
-
for (const n of [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13]) {
|
|
680
|
-
expect(lines[n]).toMatch(/row \d+: asserted/);
|
|
681
|
-
}
|
|
682
|
-
expect(lines[7]).toMatch(/row 7: could not run/);
|
|
683
|
-
expect(lines[7]).not.toMatch(/not asserted/);
|
|
684
|
-
expect(lines[11]).toMatch(/row 11: not asserted/);
|
|
685
|
-
// #507: this fixture's project, `mx-agent`, takes the credential endpoint
|
|
686
|
-
// and configures no URL, so the probe went to the built-in mx-agent service
|
|
687
|
-
// URL, and the row says where the URL came from.
|
|
688
|
-
expect(lines[12]).toContain('coordination URL from default');
|
|
689
|
-
});
|
|
690
|
-
it('names what each unasserted row would have covered', async () => {
|
|
691
|
-
await provision();
|
|
692
|
-
const joined = rowLines().join('\n');
|
|
693
|
-
expect(joined).toContain('merged to main');
|
|
694
|
-
expect(joined).toContain('mx-agent start newteam');
|
|
695
|
-
expect(joined).toContain('roster entry');
|
|
696
|
-
expect(joined).toContain('.mx-coordination-team');
|
|
697
|
-
// Row 12 asserts in this fixture (v41); what it names is the request it made.
|
|
698
|
-
expect(joined).toContain('GET /obligations');
|
|
699
|
-
});
|
|
700
|
-
it('an asserted row never carries a failure detail', async () => {
|
|
701
|
-
// The printer shows `detail` on asserted rows too, so rows 1 and 2 must not
|
|
702
|
-
// hand it a static "file not found": a green row that says the file is
|
|
703
|
-
// missing is a contradiction the reader has to stop and resolve.
|
|
704
|
-
await provision();
|
|
705
|
-
for (const line of rowLines()) {
|
|
706
|
-
if (/row \d+: asserted/.test(line)) {
|
|
707
|
-
expect(line).not.toContain('file not found');
|
|
708
|
-
expect(line).not.toContain('no such memory');
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
it('prints the rows BEFORE the success message', async () => {
|
|
713
|
-
await provision();
|
|
714
|
-
const firstRow = stdout.findIndex((l) => /^\s*row 0:/.test(l));
|
|
715
|
-
const created = stdout.findIndex((l) => l.includes('Team Created!'));
|
|
716
|
-
expect(firstRow).toBeGreaterThan(-1);
|
|
717
|
-
expect(created).toBeGreaterThan(firstRow);
|
|
718
|
-
});
|
|
719
|
-
it('row 0 is not asserted when the project configures no projectSlug', () => {
|
|
720
|
-
// Unit level: the integration path fixes projectSlug in its config mock.
|
|
721
|
-
const rows = checkCompletionRows({
|
|
722
|
-
slug: 'newteam',
|
|
723
|
-
projectSlug: '',
|
|
724
|
-
baseBranch: 'main',
|
|
725
|
-
roleguideInWorktree: null,
|
|
726
|
-
catalogEntry: join(root, 'nope.md'),
|
|
727
|
-
memoryNames: MEMORIES,
|
|
728
|
-
mxAvailable: false,
|
|
729
|
-
});
|
|
730
|
-
const row0 = rows.find((r) => r.n === 0);
|
|
731
|
-
expect(row0.asserted).toBe(false);
|
|
732
|
-
expect(row0.required).toBe(false);
|
|
733
|
-
expect(row0.detail).toContain('no projectSlug');
|
|
734
|
-
});
|
|
735
|
-
it('reports mx being absent as could-not-run, not as a missing memory', () => {
|
|
736
|
-
// Passed, failed and could-not-run are three outcomes
|
|
737
|
-
// (mx-agent-system/standards/fail-loud-standard.md).
|
|
738
|
-
const rows = checkCompletionRows({
|
|
739
|
-
slug: 'newteam',
|
|
740
|
-
projectSlug: 'mx-agent',
|
|
741
|
-
baseBranch: 'main',
|
|
742
|
-
roleguideInWorktree: null,
|
|
743
|
-
catalogEntry: join(root, 'nope.md'),
|
|
744
|
-
memoryNames: MEMORIES,
|
|
745
|
-
mxAvailable: false,
|
|
746
|
-
});
|
|
747
|
-
for (const n of [3, 4, 5]) {
|
|
748
|
-
const row = rows.find((r) => r.n === n);
|
|
749
|
-
expect(row.asserted).toBe(false);
|
|
750
|
-
expect(row.detail).toContain('could not run');
|
|
751
|
-
}
|
|
752
|
-
});
|
|
753
|
-
});
|
|
754
|
-
// ── The per-worktree scope file: row 1 (#62) ─────────────────────────────────
|
|
755
|
-
//
|
|
756
|
-
// `mx` reads `<projectRoot>/.mx-code-context.json` to label a memory, and inside
|
|
757
|
-
// a linked worktree the project root IS the worktree. Provisioning wrote no such
|
|
758
|
-
// file, so a new team's auto-captured memories carried no scope at all. Row 1
|
|
759
|
-
// asserts the new worktree's contents, so it asserts this file too.
|
|
760
|
-
describe('completion check: row 1 names the scope file', () => {
|
|
761
|
-
it('writes the four keys into the new worktree and names them on the row', async () => {
|
|
762
|
-
const { failure } = await provision();
|
|
763
|
-
expect(failure).toBeNull();
|
|
764
|
-
const written = join(root, WORKTREE, '.mx-code-context.json');
|
|
765
|
-
expect(JSON.parse(readFileSync(written, 'utf-8'))).toEqual({
|
|
766
|
-
product: 'mx-agent',
|
|
767
|
-
service: 'team-provisioning',
|
|
768
|
-
team: 'newteam',
|
|
769
|
-
role: 'team-lead',
|
|
770
|
-
});
|
|
771
|
-
expect(lstatSync(written).isFile()).toBe(true);
|
|
772
|
-
expect(rowLines()[1]).toMatch(/row 1: asserted/);
|
|
773
|
-
expect(rowLines()[1]).toContain('.mx-code-context.json: product, service, team, role');
|
|
774
|
-
});
|
|
775
|
-
it('reads the file back rather than trusting the write, and says missing when it is gone', () => {
|
|
776
|
-
// Unit level, both branches of the row, against a real directory.
|
|
777
|
-
const worktreePath = join(root, 'wt-unit');
|
|
778
|
-
const roleguide = join(worktreePath, RG);
|
|
779
|
-
mkdirSync(dirname(roleguide), { recursive: true });
|
|
780
|
-
writeFileSync(roleguide, OWN_PROJECT);
|
|
781
|
-
const missing = checkCompletionRows({
|
|
782
|
-
slug: 'newteam',
|
|
783
|
-
projectSlug: 'mx-agent',
|
|
784
|
-
baseBranch: 'main',
|
|
785
|
-
roleguideInWorktree: roleguide,
|
|
786
|
-
worktreePath,
|
|
787
|
-
catalogEntry: join(root, 'nope.md'),
|
|
788
|
-
memoryNames: MEMORIES,
|
|
789
|
-
mxAvailable: false,
|
|
790
|
-
}).find((r) => r.n === 1);
|
|
791
|
-
expect(missing.asserted).toBe(false);
|
|
792
|
-
expect(missing.required).toBe(true);
|
|
793
|
-
expect(missing.detail).toBe('.mx-code-context.json missing');
|
|
794
|
-
expect(missing.label).toContain('roleguide in the new worktree');
|
|
795
|
-
writeFileSync(join(worktreePath, '.mx-code-context.json'), JSON.stringify({ product: 'mx-agent', service: 'team-provisioning', team: 'newteam', role: 'team-lead' }));
|
|
796
|
-
const present = checkCompletionRows({
|
|
797
|
-
slug: 'newteam',
|
|
798
|
-
projectSlug: 'mx-agent',
|
|
799
|
-
baseBranch: 'main',
|
|
800
|
-
roleguideInWorktree: roleguide,
|
|
801
|
-
worktreePath,
|
|
802
|
-
catalogEntry: join(root, 'nope.md'),
|
|
803
|
-
memoryNames: MEMORIES,
|
|
804
|
-
mxAvailable: false,
|
|
805
|
-
}).find((r) => r.n === 1);
|
|
806
|
-
expect(present.asserted).toBe(true);
|
|
807
|
-
expect(present.detail).toBe('.mx-code-context.json: product, service, team, role');
|
|
808
|
-
// The label text is unchanged, and the row count is still 13.
|
|
809
|
-
expect(present.label).toBe(missing.label);
|
|
810
|
-
});
|
|
811
|
-
it('names the empty keys when the file holds fewer than four', async () => {
|
|
812
|
-
// A project with no projectSlug writes an empty `product`, which the writer
|
|
813
|
-
// omits and the capture hooks would drop. The row says which key is absent
|
|
814
|
-
// rather than printing a shorter list with no explanation.
|
|
815
|
-
configuredProjectSlug = '';
|
|
816
|
-
const { failure } = await provision();
|
|
817
|
-
expect(failure).toBeNull();
|
|
818
|
-
const written = join(root, WORKTREE, '.mx-code-context.json');
|
|
819
|
-
expect(JSON.parse(readFileSync(written, 'utf-8'))).toEqual({
|
|
820
|
-
service: 'team-provisioning',
|
|
821
|
-
team: 'newteam',
|
|
822
|
-
role: 'team-lead',
|
|
823
|
-
});
|
|
824
|
-
expect(rowLines()[1]).toMatch(/row 1: asserted/);
|
|
825
|
-
expect(rowLines()[1]).toContain('.mx-code-context.json: service, team, role (product empty)');
|
|
826
|
-
});
|
|
827
|
-
it('prints nothing a file put there, only the four key literals', () => {
|
|
828
|
-
// CWE-117: the row is one line of terminal output, and the file is not
|
|
829
|
-
// necessarily one this command wrote.
|
|
830
|
-
const worktreePath = join(root, 'wt-hostile');
|
|
831
|
-
const roleguide = join(worktreePath, RG);
|
|
832
|
-
mkdirSync(dirname(roleguide), { recursive: true });
|
|
833
|
-
writeFileSync(roleguide, OWN_PROJECT);
|
|
834
|
-
writeFileSync(join(worktreePath, '.mx-code-context.json'), JSON.stringify({
|
|
835
|
-
product: 'mx-agent',
|
|
836
|
-
service: 'team-provisioning',
|
|
837
|
-
team: 'newteam',
|
|
838
|
-
role: 'team-lead',
|
|
839
|
-
'\u001b[2K\rrow 1: asserted forged': 'x',
|
|
840
|
-
}));
|
|
841
|
-
const row = checkCompletionRows({
|
|
842
|
-
slug: 'newteam',
|
|
843
|
-
projectSlug: 'mx-agent',
|
|
844
|
-
baseBranch: 'main',
|
|
845
|
-
roleguideInWorktree: roleguide,
|
|
846
|
-
worktreePath,
|
|
847
|
-
catalogEntry: join(root, 'nope.md'),
|
|
848
|
-
memoryNames: MEMORIES,
|
|
849
|
-
mxAvailable: false,
|
|
850
|
-
}).find((r) => r.n === 1);
|
|
851
|
-
expect(row.detail).toBe('.mx-code-context.json: product, service, team, role');
|
|
852
|
-
expect(row.detail).not.toContain('forged');
|
|
853
|
-
expect(row.detail).not.toContain('\u001b');
|
|
854
|
-
});
|
|
855
|
-
it('does not assert a file that holds none of the four keys', () => {
|
|
856
|
-
const worktreePath = join(root, 'wt-empty');
|
|
857
|
-
const roleguide = join(worktreePath, RG);
|
|
858
|
-
mkdirSync(dirname(roleguide), { recursive: true });
|
|
859
|
-
writeFileSync(roleguide, OWN_PROJECT);
|
|
860
|
-
writeFileSync(join(worktreePath, '.mx-code-context.json'), JSON.stringify({ repo: 'memnexus' }));
|
|
861
|
-
const row = checkCompletionRows({
|
|
862
|
-
slug: 'newteam',
|
|
863
|
-
projectSlug: 'mx-agent',
|
|
864
|
-
baseBranch: 'main',
|
|
865
|
-
roleguideInWorktree: roleguide,
|
|
866
|
-
worktreePath,
|
|
867
|
-
catalogEntry: join(root, 'nope.md'),
|
|
868
|
-
memoryNames: MEMORIES,
|
|
869
|
-
mxAvailable: false,
|
|
870
|
-
}).find((r) => r.n === 1);
|
|
871
|
-
// The file exists and parses, and the consumer still gets no scope from it.
|
|
872
|
-
expect(row.asserted).toBe(false);
|
|
873
|
-
expect(row.detail).toBe('.mx-code-context.json holds none of the four keys');
|
|
874
|
-
});
|
|
875
|
-
it('says missing when the caller passes no worktree path at all', () => {
|
|
876
|
-
// Could-not-look is not a pass. A caller that omits the path gets the
|
|
877
|
-
// missing branch rather than a row that quietly asserts less than it says.
|
|
878
|
-
const row = checkCompletionRows({
|
|
879
|
-
slug: 'newteam',
|
|
880
|
-
projectSlug: 'mx-agent',
|
|
881
|
-
baseBranch: 'main',
|
|
882
|
-
roleguideInWorktree: null,
|
|
883
|
-
catalogEntry: join(root, 'nope.md'),
|
|
884
|
-
memoryNames: MEMORIES,
|
|
885
|
-
mxAvailable: false,
|
|
886
|
-
}).find((r) => r.n === 1);
|
|
887
|
-
expect(row.asserted).toBe(false);
|
|
888
|
-
});
|
|
889
|
-
});
|
|
890
|
-
describe('completion check — each missing artifact exits non-zero naming its row', () => {
|
|
891
|
-
it('row 1: the roleguide is not in the new worktree', async () => {
|
|
892
|
-
// The catalog mock removes the copied roleguide immediately before the
|
|
893
|
-
// check — the only point after the copy and before the assertions.
|
|
894
|
-
removeBeforeCheck = join(root, WORKTREE, RG);
|
|
895
|
-
const { failure } = await provision();
|
|
896
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
897
|
-
expect(failure.code).toBe('completion-check-failed');
|
|
898
|
-
expect(failure.message).toContain('Provisioning INCOMPLETE');
|
|
899
|
-
expect(failure.message).toContain('row 1:');
|
|
900
|
-
expect(failure.message).toContain(join(root, WORKTREE, RG));
|
|
901
|
-
});
|
|
902
|
-
it('row 1: the scope file is not in the new worktree', async () => {
|
|
903
|
-
// Same removal point as the roleguide case above: the catalog mock is the
|
|
904
|
-
// only step between step 6a's write and the completion check.
|
|
905
|
-
removeBeforeCheck = join(root, WORKTREE, '.mx-code-context.json');
|
|
906
|
-
const { failure } = await provision();
|
|
907
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
908
|
-
expect(failure.message).toContain('row 1:');
|
|
909
|
-
expect(failure.message).toContain('.mx-code-context.json missing');
|
|
910
|
-
});
|
|
911
|
-
it('row 2: the catalog entry was not written', async () => {
|
|
912
|
-
catalogWrites = false;
|
|
913
|
-
const { failure } = await provision();
|
|
914
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
915
|
-
expect(failure.message).toContain('row 2:');
|
|
916
|
-
expect(failure.message).toContain(join(root, 'mx-agent-system/teams/newteam.md'));
|
|
917
|
-
});
|
|
918
|
-
it('row 3: the leader-state memory does not resolve', async () => {
|
|
919
|
-
missingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
920
|
-
const { failure } = await provision();
|
|
921
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
922
|
-
expect(failure.message).toContain('row 3:');
|
|
923
|
-
expect(failure.message).toContain('mx-agent-newteam-leader-state');
|
|
924
|
-
expect(failure.message).not.toContain('row 4:');
|
|
925
|
-
});
|
|
926
|
-
it('row 4: the iteration-log memory does not resolve', async () => {
|
|
927
|
-
missingMemories = new Set(['mx-agent-newteam-iteration-log']);
|
|
928
|
-
const { failure } = await provision();
|
|
929
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
930
|
-
expect(failure.message).toContain('row 4:');
|
|
931
|
-
expect(failure.message).toContain('mx-agent-newteam-iteration-log');
|
|
932
|
-
});
|
|
933
|
-
it('row 5: the known-issues memory does not resolve', async () => {
|
|
934
|
-
missingMemories = new Set(['mx-agent-newteam-known-issues']);
|
|
935
|
-
const { failure } = await provision();
|
|
936
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
937
|
-
expect(failure.message).toContain('row 5:');
|
|
938
|
-
expect(failure.message).toContain('mx-agent-newteam-known-issues');
|
|
939
|
-
});
|
|
940
|
-
it('does NOT print the success message when a row fails', async () => {
|
|
941
|
-
catalogWrites = false;
|
|
942
|
-
await provision();
|
|
943
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
944
|
-
// The rows still print, so the operator can see which ones held.
|
|
945
|
-
expect(rowLines()).toHaveLength(16);
|
|
946
|
-
});
|
|
947
|
-
it('names the artifacts that DO exist, and deletes none of them', async () => {
|
|
948
|
-
// A failure after the worktree exists must leave a resume possible (#5).
|
|
949
|
-
missingMemories = new Set(['mx-agent-newteam-known-issues']);
|
|
950
|
-
const { failure } = await provision();
|
|
951
|
-
const message = failure.message;
|
|
952
|
-
expect(message).toContain('Nothing was deleted');
|
|
953
|
-
expect(message).toContain('Rows 0, 1, 2, 3, 4, 6');
|
|
954
|
-
expect(message).toContain(join(root, WORKTREE));
|
|
955
|
-
// The roleguide copy and the catalog entry are still on disk.
|
|
956
|
-
expect(rowLines()[1]).toMatch(/row 1: asserted/);
|
|
957
|
-
expect(rowLines()[2]).toMatch(/row 2: asserted/);
|
|
958
|
-
});
|
|
959
|
-
it('locates the catalog entry with the catalog module\'s own helper', async () => {
|
|
960
|
-
// Row 1 uses the destination step 6b actually wrote; row 2 must not rebuild a
|
|
961
|
-
// path by hand either, or the check can assert a different file than the
|
|
962
|
-
// writer wrote.
|
|
963
|
-
await provision();
|
|
964
|
-
expect(getTeamCatalogPath).toHaveBeenCalledWith(root, 'newteam', 'mx-agent-system/teams');
|
|
965
|
-
});
|
|
966
|
-
it('prints only the FIRST line of mx stderr in a row', async () => {
|
|
967
|
-
// An auth failure returns a paragraph with a login URL. The block is one line
|
|
968
|
-
// per row, and a multi-line detail breaks the count an operator reads it by.
|
|
969
|
-
missingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
970
|
-
missingDetail = 'not authenticated\nrun: mx auth login\nhttps://example.invalid/login';
|
|
971
|
-
const { failure } = await provision();
|
|
972
|
-
expect(rowLines()).toHaveLength(16);
|
|
973
|
-
expect(rowLines()[3]).toContain('not authenticated');
|
|
974
|
-
expect(rowLines()[3]).not.toContain('mx auth login');
|
|
975
|
-
expect(failure.message).not.toContain('example.invalid');
|
|
976
|
-
});
|
|
977
|
-
it('single-quotes the paths in the printed recovery commands', async () => {
|
|
978
|
-
// The failure message invites a paste of `git worktree remove <path>`; a path
|
|
979
|
-
// is not validated for its characters, only for where it resolves (CWE-78).
|
|
980
|
-
catalogWrites = false;
|
|
981
|
-
const { failure } = await provision();
|
|
982
|
-
expect(failure.message).toContain(`git worktree remove '${join(root, WORKTREE)}'`);
|
|
983
|
-
expect(failure.message).toContain(`--roleguide '${RG}' --name 'newteam'`);
|
|
984
|
-
});
|
|
985
|
-
it('does NOT assert a memory whose name existed BEFORE this run', async () => {
|
|
986
|
-
// `get --name` answers "a memory holds this name", not "this run created it".
|
|
987
|
-
// A re-provision of a retired slug, or a collision on the shared account,
|
|
988
|
-
// would otherwise light the row green over a failed write.
|
|
989
|
-
preExistingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
990
|
-
const { failure } = await provision();
|
|
991
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
992
|
-
expect(failure.message).toContain('row 3:');
|
|
993
|
-
expect(failure.message).toContain('the name was already taken');
|
|
994
|
-
expect(rowLines()[3]).toMatch(/row 3: not asserted/);
|
|
995
|
-
});
|
|
996
|
-
it('does NOT assert rows 3 to 5 when the names pre-existed and creation failed', async () => {
|
|
997
|
-
// The whole shape of the defect: three green rows over three failed writes.
|
|
998
|
-
preExistingMemories = new Set([
|
|
999
|
-
'mx-agent-newteam-leader-state',
|
|
1000
|
-
'mx-agent-newteam-iteration-log',
|
|
1001
|
-
'mx-agent-newteam-known-issues',
|
|
1002
|
-
]);
|
|
1003
|
-
createReportsOk = false;
|
|
1004
|
-
const { failure } = await provision();
|
|
1005
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1006
|
-
for (const n of [3, 4, 5]) {
|
|
1007
|
-
expect(rowLines()[n]).toMatch(new RegExp(`row ${n}: not asserted`));
|
|
1008
|
-
expect(failure.message).toContain(`row ${n}:`);
|
|
1009
|
-
}
|
|
1010
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
1011
|
-
});
|
|
1012
|
-
it('never writes over a name that is already taken, and says so', async () => {
|
|
1013
|
-
// `mx memories create --name` UPSERTS: on a name conflict the installed CLI
|
|
1014
|
-
// calls updateNamedMemory, replacing the content. The probe already knows the
|
|
1015
|
-
// name is taken, so creating anyway is the one action that destroys data —
|
|
1016
|
-
// on the shared account the victim may be a live team's leader state.
|
|
1017
|
-
preExistingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
1018
|
-
const { failure } = await provision();
|
|
1019
|
-
const { bootstrapTeamMemories } = await import('../lib/memory.js');
|
|
1020
|
-
expect(vi.mocked(bootstrapTeamMemories)).toHaveBeenCalled();
|
|
1021
|
-
expect(failure.message).toContain('already in use');
|
|
1022
|
-
expect(failure.message).toContain('mx-agent-newteam-leader-state');
|
|
1023
|
-
});
|
|
1024
|
-
it('drops the "provision again" advice when a name is taken, because it cannot work', async () => {
|
|
1025
|
-
preExistingMemories = new Set(['mx-agent-newteam-known-issues']);
|
|
1026
|
-
const { failure } = await provision();
|
|
1027
|
-
expect(failure.message).toContain('will NOT clear this');
|
|
1028
|
-
expect(failure.message).toContain('Delete or rename');
|
|
1029
|
-
expect(failure.message).not.toContain('git worktree remove');
|
|
1030
|
-
expect(failure.message).toContain('REPLACES its content');
|
|
1031
|
-
});
|
|
1032
|
-
it('keeps the ordinary retry advice when nothing was name-blocked', async () => {
|
|
1033
|
-
catalogWrites = false;
|
|
1034
|
-
const { failure } = await provision();
|
|
1035
|
-
expect(failure.message).toContain('git worktree remove');
|
|
1036
|
-
expect(failure.message).not.toContain('already in use');
|
|
1037
|
-
});
|
|
1038
|
-
it('ASSERTS when the id read lags but the probe was absent and the name resolves', async () => {
|
|
1039
|
-
// The measured backend behaviour: `get <id>` is Not Found for 3 to 20+
|
|
1040
|
-
// minutes after a create while `get --name` answers immediately. Requiring
|
|
1041
|
-
// the id read made rows 3 to 5 fail on essentially every real provision.
|
|
1042
|
-
idLags = true;
|
|
1043
|
-
const { failure } = await provision();
|
|
1044
|
-
expect(failure).toBeNull();
|
|
1045
|
-
for (const n of [3, 4, 5])
|
|
1046
|
-
expect(rowLines()[n]).toMatch(new RegExp(`row ${n}: asserted`));
|
|
1047
|
-
});
|
|
1048
|
-
it('says WHICH evidence held when the id read lagged', async () => {
|
|
1049
|
-
// A green row must not quietly rest on weaker proof than the reader assumes.
|
|
1050
|
-
idLags = true;
|
|
1051
|
-
await provision();
|
|
1052
|
-
expect(rowLines()[3]).toContain('attributed by pre-existence probe');
|
|
1053
|
-
expect(rowLines()[3]).toContain('id read lagged');
|
|
1054
|
-
});
|
|
1055
|
-
it('says nothing extra when the id read corroborated', async () => {
|
|
1056
|
-
await provision();
|
|
1057
|
-
expect(rowLines()[3]).toMatch(/row 3: asserted/);
|
|
1058
|
-
expect(rowLines()[3]).not.toContain('lagged');
|
|
1059
|
-
const { namedMemoryResolvesById } = await import('../lib/memory.js');
|
|
1060
|
-
expect(vi.mocked(namedMemoryResolvesById)).toHaveBeenCalled();
|
|
1061
|
-
});
|
|
1062
|
-
it('asks the id ONCE — no retry, no sleep', async () => {
|
|
1063
|
-
idLags = true;
|
|
1064
|
-
await provision();
|
|
1065
|
-
const { namedMemoryResolvesById } = await import('../lib/memory.js');
|
|
1066
|
-
// Three memories, one id read each.
|
|
1067
|
-
expect(vi.mocked(namedMemoryResolvesById)).toHaveBeenCalledTimes(3);
|
|
1068
|
-
});
|
|
1069
|
-
it('does NOT assert when the id lags AND the name does not resolve', async () => {
|
|
1070
|
-
idLags = true;
|
|
1071
|
-
missingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
1072
|
-
const { failure } = await provision();
|
|
1073
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1074
|
-
expect(rowLines()[3]).toMatch(/row 3: not asserted/);
|
|
1075
|
-
expect(failure.message).toContain('reported success but nothing resolves');
|
|
1076
|
-
});
|
|
1077
|
-
it('does NOT assert when this run\'s create reported failure', async () => {
|
|
1078
|
-
createReportsOk = false;
|
|
1079
|
-
const { failure } = await provision();
|
|
1080
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1081
|
-
expect(failure.message).toContain("create reported failure");
|
|
1082
|
-
});
|
|
1083
|
-
// ── #471: the warning, and the two runs it has to tell apart ───────────────
|
|
1084
|
-
/** Everything `logWarning` was called with. `lib/claude.js` is mocked here. */
|
|
1085
|
-
async function warnings() {
|
|
1086
|
-
const { logWarning } = await import('../lib/claude.js');
|
|
1087
|
-
return vi.mocked(logWarning).mock.calls.map((c) => String(c[0]));
|
|
1088
|
-
}
|
|
1089
|
-
it('STILL warns and prints the manual commands when a create genuinely fails (#471)', async () => {
|
|
1090
|
-
// The run the warning was written for: no name was taken, the create was
|
|
1091
|
-
// attempted, and it reported failure. This is the assertion that stops the
|
|
1092
|
-
// #471 fix from being a suppression. The flag now reads a second input, and
|
|
1093
|
-
// a genuinely failed create must not reach the operator any quieter.
|
|
1094
|
-
createReportsOk = false;
|
|
1095
|
-
const { failure } = await provision();
|
|
1096
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1097
|
-
expect((await warnings()).some((w) => w.startsWith('Some team memories are not there'))).toBe(true);
|
|
1098
|
-
const { logManualMemoryCommands } = await import('../lib/memory.js');
|
|
1099
|
-
expect(vi.mocked(logManualMemoryCommands)).toHaveBeenCalledTimes(1);
|
|
1100
|
-
});
|
|
1101
|
-
it('warns on a FIRST run that finds a name taken, because nothing attributed it (#471)', async () => {
|
|
1102
|
-
// `memoryStates` is built on a resume and by `--recheck` only. A first run
|
|
1103
|
-
// that finds the three names taken has classified nothing, rows 3 to 5 are
|
|
1104
|
-
// red, and the warning prints exactly as it did before the fix.
|
|
1105
|
-
preExistingMemories = new Set([
|
|
1106
|
-
'mx-agent-newteam-leader-state',
|
|
1107
|
-
'mx-agent-newteam-iteration-log',
|
|
1108
|
-
'mx-agent-newteam-known-issues',
|
|
1109
|
-
]);
|
|
1110
|
-
createReportsOk = false;
|
|
1111
|
-
const { failure } = await provision();
|
|
1112
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1113
|
-
expect((await warnings()).some((w) => w.startsWith('Some team memories are not there'))).toBe(true);
|
|
1114
|
-
});
|
|
1115
|
-
it('names NO cause in that warning, because the run established none (#471)', async () => {
|
|
1116
|
-
// It used to ask `is mx authenticated?` and print `mx auth login`. That was a
|
|
1117
|
-
// guess, and in the run that found this it was the wrong guess: mx was
|
|
1118
|
-
// authenticated throughout and rows 3 to 5 read the three memories back.
|
|
1119
|
-
createReportsOk = false;
|
|
1120
|
-
await provision();
|
|
1121
|
-
const memoryWarning = (await warnings()).find((w) => w.includes('team memories'));
|
|
1122
|
-
expect(memoryWarning).toBeDefined();
|
|
1123
|
-
expect(memoryWarning).not.toContain('auth');
|
|
1124
|
-
expect(memoryWarning).not.toContain('failed to initialise');
|
|
1125
|
-
// What it points at instead: evidence this run actually produced.
|
|
1126
|
-
expect(memoryWarning).toContain('rows 3 to 5');
|
|
1127
|
-
});
|
|
1128
|
-
// ── #493 / plan #494 amendment 1: no create command for a taken name ───────
|
|
1129
|
-
//
|
|
1130
|
-
// `mx memories create --name` is an upsert, so a pasted command for a taken
|
|
1131
|
-
// name replaces that memory's content, and another team's when it holds the
|
|
1132
|
-
// name. On a first run `memoryStates` is empty, so every taken name is
|
|
1133
|
-
// unsettled and reached this block, which printed a command for all three.
|
|
1134
|
-
it('first run, one name held by another team and one genuine failure: a command for the failed name only (#493)', async () => {
|
|
1135
|
-
const [leader, log] = MEMORIES;
|
|
1136
|
-
preExistingMemories = new Set([leader]);
|
|
1137
|
-
ownershipFor = new Map([[leader, 'not-this-team']]);
|
|
1138
|
-
// The real module returns ok:false for a taken name; `log` is a genuine failure.
|
|
1139
|
-
createFailsFor = new Set([leader, log]);
|
|
1140
|
-
const { failure } = await provision();
|
|
1141
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1142
|
-
const { logManualMemoryCommands } = await import('../lib/memory.js');
|
|
1143
|
-
const calls = vi.mocked(logManualMemoryCommands).mock.calls;
|
|
1144
|
-
expect(calls).toHaveLength(1);
|
|
1145
|
-
const names = calls[0][0].map((spec) => spec.name);
|
|
1146
|
-
expect(names).toEqual([log]);
|
|
1147
|
-
expect(names).not.toContain(leader);
|
|
1148
|
-
expect((await warnings()).some((w) => w.includes('Create them manually'))).toBe(true);
|
|
1149
|
-
});
|
|
1150
|
-
it('first run, all three names taken: no "Create them manually" and no create command (#493)', async () => {
|
|
1151
|
-
preExistingMemories = new Set(MEMORIES);
|
|
1152
|
-
ownershipFor = new Map([
|
|
1153
|
-
[MEMORIES[0], 'not-this-team'],
|
|
1154
|
-
[MEMORIES[1], 'unconfirmed'],
|
|
1155
|
-
[MEMORIES[2], 'this-team'],
|
|
1156
|
-
]);
|
|
1157
|
-
createReportsOk = false;
|
|
1158
|
-
const { failure } = await provision();
|
|
1159
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1160
|
-
const { logManualMemoryCommands } = await import('../lib/memory.js');
|
|
1161
|
-
expect(vi.mocked(logManualMemoryCommands)).not.toHaveBeenCalled();
|
|
1162
|
-
const all = [...(await warnings()), ...stdout, ...stderr, ...stderrStream].join('\n');
|
|
1163
|
-
expect(all).not.toContain('Create them manually');
|
|
1164
|
-
expect(all).not.toContain('mx memories create');
|
|
1165
|
-
// The warning still prints, still names no cause (#471 criterion 3), and
|
|
1166
|
-
// points at the per-memory lines and the rows.
|
|
1167
|
-
const memoryWarning = (await warnings()).find((w) => w.startsWith('Some team memories are not there'));
|
|
1168
|
-
expect(memoryWarning).toBeDefined();
|
|
1169
|
-
expect(memoryWarning).toContain('rows 3 to 5');
|
|
1170
|
-
expect(memoryWarning).not.toContain('auth');
|
|
1171
|
-
});
|
|
1172
|
-
it('notes the missing id when the probe gave no verdict and no id was returned', async () => {
|
|
1173
|
-
probeConclusive = false;
|
|
1174
|
-
createYieldsId = false;
|
|
1175
|
-
const { failure } = await provision();
|
|
1176
|
-
expect(failure.message).toContain('no verdict');
|
|
1177
|
-
expect(failure.message).toContain('no id was returned');
|
|
1178
|
-
});
|
|
1179
|
-
it('does NOT assert when the probe gave no verdict, the create failed, and the name resolves', async () => {
|
|
1180
|
-
// The hole the three-state probe closes. Read as a boolean, an unrunnable
|
|
1181
|
-
// probe recorded "the name was free"; the create then failed and returned no
|
|
1182
|
-
// id; and the fallback name read succeeded against a memory that had been
|
|
1183
|
-
// there all along. Row 3 asserted, over a write that never happened.
|
|
1184
|
-
// The create REPORTS SUCCESS here, so the only thing standing between the row
|
|
1185
|
-
// and a green tick is the probe's missing verdict. A failed create would be
|
|
1186
|
-
// caught one branch earlier and would not exercise this hole.
|
|
1187
|
-
probeConclusive = false;
|
|
1188
|
-
createReportsOk = true;
|
|
1189
|
-
createYieldsId = false;
|
|
1190
|
-
missingMemories = new Set(); // the name DOES resolve afterwards
|
|
1191
|
-
const { failure } = await provision();
|
|
1192
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1193
|
-
expect(rowLines()[3]).toMatch(/row 3: not asserted/);
|
|
1194
|
-
expect(failure.message).toContain('could not run');
|
|
1195
|
-
expect(failure.message).toContain('no verdict');
|
|
1196
|
-
});
|
|
1197
|
-
it('never consults the name read when the probe gave no verdict', async () => {
|
|
1198
|
-
probeConclusive = false;
|
|
1199
|
-
createYieldsId = false;
|
|
1200
|
-
await provision();
|
|
1201
|
-
const { namedMemoryExists } = await import('../lib/memory.js');
|
|
1202
|
-
expect(vi.mocked(namedMemoryExists)).not.toHaveBeenCalled();
|
|
1203
|
-
});
|
|
1204
|
-
it('names why the id could not corroborate, in the could-not-run detail', async () => {
|
|
1205
|
-
probeConclusive = false;
|
|
1206
|
-
createYieldsId = true;
|
|
1207
|
-
idLags = true;
|
|
1208
|
-
createReportsOk = true;
|
|
1209
|
-
const { failure } = await provision();
|
|
1210
|
-
expect(failure.message).toContain('the id read did not resolve either');
|
|
1211
|
-
});
|
|
1212
|
-
it('verifies by the id this run minted, not by the name', async () => {
|
|
1213
|
-
await provision();
|
|
1214
|
-
const { namedMemoryResolvesById } = await import('../lib/memory.js');
|
|
1215
|
-
expect(vi.mocked(namedMemoryResolvesById)).toHaveBeenCalledWith('id-of-mx-agent-newteam-leader-state', 'mx-agent-newteam-leader-state');
|
|
1216
|
-
});
|
|
1217
|
-
it('falls back to the name read when mx returned no id, and says nothing false', async () => {
|
|
1218
|
-
// Sound only because the pre-existence probe established the name was free.
|
|
1219
|
-
createYieldsId = false;
|
|
1220
|
-
const { failure } = await provision();
|
|
1221
|
-
expect(failure).toBeNull();
|
|
1222
|
-
const { namedMemoryResolvesById, namedMemoryExists } = await import('../lib/memory.js');
|
|
1223
|
-
expect(vi.mocked(namedMemoryResolvesById)).not.toHaveBeenCalled();
|
|
1224
|
-
expect(vi.mocked(namedMemoryExists)).toHaveBeenCalledWith('mx-agent-newteam-leader-state');
|
|
1225
|
-
});
|
|
1226
|
-
it('reports all six misses at once rather than the first', async () => {
|
|
1227
|
-
catalogWrites = false;
|
|
1228
|
-
removeBeforeCheck = join(root, WORKTREE, RG);
|
|
1229
|
-
missingMemories = new Set(MEMORIES);
|
|
1230
|
-
const { failure } = await provision();
|
|
1231
|
-
const message = failure.message;
|
|
1232
|
-
for (const n of [1, 2, 3, 4, 5, 13])
|
|
1233
|
-
expect(message).toContain(`row ${n}:`);
|
|
1234
|
-
// Eleven required rows: 0 identity, 1 to 5, rows 9 and 10 since ;77, row 13
|
|
1235
|
-
// since ;83, row 14 since ;123, and row 12 on the credential-endpoint path
|
|
1236
|
-
// since v41 (#15). Six did not hold; the roster entry, the token, the token
|
|
1237
|
-
// probe and the build did. Row 13
|
|
1238
|
-
// is could-not-run here rather than failed: this fixture deletes the
|
|
1239
|
-
// roleguide copy the row reads, and a row that could not look is not a row
|
|
1240
|
-
// that passed.
|
|
1241
|
-
expect(message).toContain('6 of the 11 rows');
|
|
1242
|
-
expect(message).toContain('could not run');
|
|
1243
|
-
});
|
|
1244
|
-
});
|
|
1245
|
-
/**
|
|
1246
|
-
* Rows 3 to 5 assert the SHAPE of each seed, not only that this run wrote it (#6).
|
|
1247
|
-
*
|
|
1248
|
-
* Attribution answers "did this provision create the memory holding this name".
|
|
1249
|
-
* It cannot answer "can `mx-agent window` read it": the seed used to be one flat
|
|
1250
|
-
* sentence, so every attributed row was green while the fleet view reported the
|
|
1251
|
-
* new team as `unknown` until a human rewrote the memory by hand.
|
|
1252
|
-
*/
|
|
1253
|
-
describe('completion check — rows 3 to 5 assert the seeded shape', () => {
|
|
1254
|
-
it('prints asserted (shape) for rows 3 to 5, and plain asserted for the rest', async () => {
|
|
1255
|
-
const { failure } = await provision();
|
|
1256
|
-
expect(failure).toBeNull();
|
|
1257
|
-
for (const n of [3, 4, 5]) {
|
|
1258
|
-
expect(rowLines()[n]).toContain('asserted (shape)');
|
|
1259
|
-
}
|
|
1260
|
-
for (const n of [0, 1, 2, 6]) {
|
|
1261
|
-
expect(rowLines()[n]).toMatch(/row \d+: asserted /);
|
|
1262
|
-
expect(rowLines()[n]).not.toContain('(shape)');
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1265
|
-
it('fails row 3 naming the missing line when the Async Status Block is gone', async () => {
|
|
1266
|
-
// The negative control criterion 3 of the plan asks for. A real provision
|
|
1267
|
-
// never writes a seed without the block, so a unit test is the only way to
|
|
1268
|
-
// show the checker can fail.
|
|
1269
|
-
seedContentFor = (name) => name.endsWith('-leader-state')
|
|
1270
|
-
? '## Newteam Leader State, updated 2026-08-21 09:07\n\nTeam provisioned.'
|
|
1271
|
-
: '## log';
|
|
1272
|
-
const { failure } = await provision();
|
|
1273
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1274
|
-
expect(failure.message).toContain('row 3:');
|
|
1275
|
-
expect(failure.message).toContain('### Async Status Block');
|
|
1276
|
-
expect(failure.message).toContain('"Async status:" line');
|
|
1277
|
-
expect(rowLines()[3]).toMatch(/row 3: not asserted/);
|
|
1278
|
-
// Rows 4 and 5 hold: only the leader-state seed lost its block.
|
|
1279
|
-
expect(rowLines()[4]).toContain('asserted (shape)');
|
|
1280
|
-
});
|
|
1281
|
-
it('fails row 3 when the status line is an unedited placeholder, naming the parser verdict', async () => {
|
|
1282
|
-
// `[ok | needs-human | blocked]` contains all three words, and the parser
|
|
1283
|
-
// resolves it to `unknown` rather than paging a human. A seed that ships the
|
|
1284
|
-
// placeholder is the same defect as a seed with no block at all.
|
|
1285
|
-
seedContentFor = (name) => name.endsWith('-leader-state')
|
|
1286
|
-
? LEADER_SEED.replace('- Async status: ok', '- Async status: [ok | needs-human | blocked]')
|
|
1287
|
-
: '## log';
|
|
1288
|
-
const { failure } = await provision();
|
|
1289
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1290
|
-
expect(failure.message).toContain('row 3:');
|
|
1291
|
-
expect(failure.message).toContain('parseLeaderState returned unknown');
|
|
1292
|
-
});
|
|
1293
|
-
it('fails all three rows naming the codeContext field a seed is missing', async () => {
|
|
1294
|
-
seedCodeContextFor = () => ({ product: 'mx-agent', team: 'newteam', role: 'team-lead' });
|
|
1295
|
-
const { failure } = await provision();
|
|
1296
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1297
|
-
for (const n of [3, 4, 5]) {
|
|
1298
|
-
expect(failure.message).toContain(`row ${n}:`);
|
|
1299
|
-
expect(rowLines()[n]).toContain('codeContext.service');
|
|
1300
|
-
}
|
|
1301
|
-
});
|
|
1302
|
-
it('names a codeContext the memory holds none of, rather than one field at a time', async () => {
|
|
1303
|
-
seedCodeContextFor = () => undefined;
|
|
1304
|
-
const { failure } = await provision();
|
|
1305
|
-
expect(failure.message).toContain('codeContext (the memory holds none)');
|
|
1306
|
-
});
|
|
1307
|
-
it('reports a shape read that could not run as could-not-run, not as a bad shape', async () => {
|
|
1308
|
-
// Passed, failed and could-not-run are three outcomes
|
|
1309
|
-
// (mx-agent-system/standards/fail-loud-standard.md). A killed read says
|
|
1310
|
-
// nothing about the seed.
|
|
1311
|
-
shapeReadFails = new Set(['mx-agent-newteam-iteration-log']);
|
|
1312
|
-
const { failure } = await provision();
|
|
1313
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
1314
|
-
expect(rowLines()[4]).toContain('could not run');
|
|
1315
|
-
expect(rowLines()[4]).toContain('mx was killed or timed out');
|
|
1316
|
-
expect(rowLines()[4]).not.toContain('missing');
|
|
1317
|
-
});
|
|
1318
|
-
it('never reads the shape of a memory this run could not attribute to itself', async () => {
|
|
1319
|
-
// Shape is an ADDITIONAL check after attribution, never a substitute: a
|
|
1320
|
-
// correctly shaped memory that was already there is still not this run's.
|
|
1321
|
-
preExistingMemories = new Set(MEMORIES);
|
|
1322
|
-
const { failure } = await provision();
|
|
1323
|
-
const { readNamedMemoryJson } = await import('../lib/memory.js');
|
|
1324
|
-
expect(vi.mocked(readNamedMemoryJson)).not.toHaveBeenCalled();
|
|
1325
|
-
expect(failure.message).toContain('the name was already taken');
|
|
1326
|
-
});
|
|
1327
|
-
it('keeps the attribution evidence note on a row that also asserted its shape', async () => {
|
|
1328
|
-
idLags = true;
|
|
1329
|
-
const { failure } = await provision();
|
|
1330
|
-
expect(failure).toBeNull();
|
|
1331
|
-
expect(rowLines()[3]).toContain('asserted (shape)');
|
|
1332
|
-
expect(rowLines()[3]).toContain('attributed by pre-existence probe');
|
|
1333
|
-
});
|
|
1334
|
-
});
|
|
1335
|
-
describe('assessSeedShape — the pure check behind rows 3 to 5', () => {
|
|
1336
|
-
const { assessSeedShape } = __testing;
|
|
1337
|
-
it('accepts the seed the provisioning path writes', () => {
|
|
1338
|
-
const r = assessSeedShape({
|
|
1339
|
-
content: LEADER_SEED,
|
|
1340
|
-
codeContext: FULL_CODE_CONTEXT,
|
|
1341
|
-
leaderState: true,
|
|
1342
|
-
requireProduct: true,
|
|
1343
|
-
});
|
|
1344
|
-
expect(r.ok).toBe(true);
|
|
1345
|
-
expect(r.detail).toBe('');
|
|
1346
|
-
});
|
|
1347
|
-
it('requires no Async Status Block of the log and issues memories', () => {
|
|
1348
|
-
const r = assessSeedShape({
|
|
1349
|
-
content: '## Newteam Iteration Log, updated 2026-08-21',
|
|
1350
|
-
codeContext: FULL_CODE_CONTEXT,
|
|
1351
|
-
leaderState: false,
|
|
1352
|
-
requireProduct: true,
|
|
1353
|
-
});
|
|
1354
|
-
expect(r.ok).toBe(true);
|
|
1355
|
-
});
|
|
1356
|
-
it('names every missing field at once rather than the first', () => {
|
|
1357
|
-
const r = assessSeedShape({
|
|
1358
|
-
content: LEADER_SEED,
|
|
1359
|
-
codeContext: { product: 'mx-agent', team: 'newteam' },
|
|
1360
|
-
leaderState: true,
|
|
1361
|
-
requireProduct: true,
|
|
1362
|
-
});
|
|
1363
|
-
expect(r.ok).toBe(false);
|
|
1364
|
-
expect(r.detail).toContain('codeContext.service');
|
|
1365
|
-
expect(r.detail).toContain('codeContext.role');
|
|
1366
|
-
});
|
|
1367
|
-
it('rejects an empty-string field, not only an absent one', () => {
|
|
1368
|
-
const r = assessSeedShape({
|
|
1369
|
-
content: LEADER_SEED,
|
|
1370
|
-
codeContext: { ...FULL_CODE_CONTEXT, service: ' ' },
|
|
1371
|
-
leaderState: true,
|
|
1372
|
-
requireProduct: true,
|
|
1373
|
-
});
|
|
1374
|
-
expect(r.ok).toBe(false);
|
|
1375
|
-
expect(r.detail).toContain('codeContext.service');
|
|
1376
|
-
});
|
|
1377
|
-
it('names each Async Status Block line that is absent', () => {
|
|
1378
|
-
const r = assessSeedShape({
|
|
1379
|
-
content: LEADER_SEED.replace('- Last finding: none (provisioned 2026-08-21, no session yet)', ''),
|
|
1380
|
-
codeContext: FULL_CODE_CONTEXT,
|
|
1381
|
-
leaderState: true,
|
|
1382
|
-
requireProduct: true,
|
|
1383
|
-
});
|
|
1384
|
-
expect(r.ok).toBe(false);
|
|
1385
|
-
expect(r.detail).toContain('"Last finding:" line');
|
|
1386
|
-
expect(r.detail).not.toContain('"Linkage:" line');
|
|
1387
|
-
});
|
|
1388
|
-
});
|
|
1389
|
-
/**
|
|
1390
|
-
* The configured project slug prefixes all three memory names, so it reaches a
|
|
1391
|
-
* MemNexus name build and every printed command. `validateProjectConfig` denies a
|
|
1392
|
-
* metacharacter list only, which accepts `a b*`; `isValidProjectSlug` is the rule
|
|
1393
|
-
* the coordination service applies to the same value.
|
|
1394
|
-
*/
|
|
1395
|
-
describe('provisioning refuses an invalid configured project slug', () => {
|
|
1396
|
-
it('refuses before anything is written, naming the slug and the rule', async () => {
|
|
1397
|
-
configuredProjectSlug = 'a b*';
|
|
1398
|
-
await expect(provision()).rejects.toThrow(/process\.exit\(1\)/);
|
|
1399
|
-
expect(stderr.join('\n')).toContain('"a b*" is invalid');
|
|
1400
|
-
expect(stderr.join('\n')).toContain('^[a-z][a-z0-9-]{0,48}[a-z0-9]$');
|
|
1401
|
-
expect(stderr.join('\n')).toContain('Nothing was created');
|
|
1402
|
-
// No worktree, no rows: the refusal precedes every write.
|
|
1403
|
-
expect(createGitWorktree).not.toHaveBeenCalled();
|
|
1404
|
-
expect(rowLines()).toHaveLength(0);
|
|
1405
|
-
});
|
|
1406
|
-
it('accepts an empty slug, the documented default meaning no prefix', async () => {
|
|
1407
|
-
// Validating the empty string would refuse provisioning in every project
|
|
1408
|
-
// without an mx-agent.config.json.
|
|
1409
|
-
configuredProjectSlug = '';
|
|
1410
|
-
// What the real path writes with no slug: `codeContextJson` DROPS an empty
|
|
1411
|
-
// value rather than emitting `product: ""`, so the seed holds three fields.
|
|
1412
|
-
seedCodeContextFor = () => ({ service: 'team-provisioning', team: 'newteam', role: 'team-lead' });
|
|
1413
|
-
seedContentFor = (name) => (name.endsWith('-leader-state') ? LEADER_SEED : '## log');
|
|
1414
|
-
const { failure } = await provision();
|
|
1415
|
-
// Rows 3 to 5 must not demand a field the writer cannot write. Row 0 already
|
|
1416
|
-
// reports the missing project identity, once, in the same run.
|
|
1417
|
-
expect(failure).toBeNull();
|
|
1418
|
-
expect(createGitWorktree).toHaveBeenCalled();
|
|
1419
|
-
for (const n of [3, 4, 5])
|
|
1420
|
-
expect(rowLines()[n]).toContain('asserted (shape)');
|
|
1421
|
-
expect(rowLines()[0]).toContain('not asserted');
|
|
1422
|
-
});
|
|
1423
|
-
it('accepts the slug this repository configures', async () => {
|
|
1424
|
-
configuredProjectSlug = 'mx-agent';
|
|
1425
|
-
const { failure } = await provision();
|
|
1426
|
-
expect(failure).toBeNull();
|
|
1427
|
-
});
|
|
1428
|
-
});
|
|
1429
|
-
describe('assessSeedShape — the product field follows the project identity', () => {
|
|
1430
|
-
const { assessSeedShape } = __testing;
|
|
1431
|
-
it('does not require product when the project configures no slug', () => {
|
|
1432
|
-
const r = assessSeedShape({
|
|
1433
|
-
content: LEADER_SEED,
|
|
1434
|
-
codeContext: { service: 'team-provisioning', team: 'newteam', role: 'team-lead' },
|
|
1435
|
-
leaderState: true,
|
|
1436
|
-
requireProduct: false,
|
|
1437
|
-
});
|
|
1438
|
-
expect(r.ok).toBe(true);
|
|
1439
|
-
});
|
|
1440
|
-
it('still requires the other three fields when product is not required', () => {
|
|
1441
|
-
const r = assessSeedShape({
|
|
1442
|
-
content: LEADER_SEED,
|
|
1443
|
-
codeContext: { team: 'newteam', role: 'team-lead' },
|
|
1444
|
-
leaderState: true,
|
|
1445
|
-
requireProduct: false,
|
|
1446
|
-
});
|
|
1447
|
-
expect(r.ok).toBe(false);
|
|
1448
|
-
expect(r.detail).toContain('codeContext.service');
|
|
1449
|
-
expect(r.detail).not.toContain('codeContext.product');
|
|
1450
|
-
});
|
|
1451
|
-
});
|
|
1452
|
-
/**
|
|
1453
|
-
* A name already taken is a failed row either way, and nothing is overwritten
|
|
1454
|
-
* either way. What the row must say is whether the memory standing in the way is
|
|
1455
|
-
* usable: a run killed between the first create and the third leaves a
|
|
1456
|
-
* leader-state behind, and a malformed one reads as `unknown` in `mx-agent window`
|
|
1457
|
-
* for as long as it exists.
|
|
1458
|
-
*/
|
|
1459
|
-
describe('completion check — a pre-existing memory is diagnosed, never overwritten', () => {
|
|
1460
|
-
it('keeps the plain name-taken wording when the leftover is well formed', async () => {
|
|
1461
|
-
preExistingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
1462
|
-
const { failure } = await provision();
|
|
1463
|
-
expect(failure.message).toContain('the name was already taken');
|
|
1464
|
-
expect(failure.message).not.toContain('malformed');
|
|
1465
|
-
expect(rowLines()[3]).toMatch(/row 3: not asserted/);
|
|
1466
|
-
});
|
|
1467
|
-
it('names the missing line when the leftover is malformed', async () => {
|
|
1468
|
-
preExistingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
1469
|
-
preExistingContentFor = () => '## Newteam Leader State, updated 2026-08-21 09:07\n\nTeam provisioned.';
|
|
1470
|
-
const { failure } = await provision();
|
|
1471
|
-
expect(rowLines()[3]).toContain('pre-existing and malformed');
|
|
1472
|
-
expect(rowLines()[3]).toContain('### Async Status Block');
|
|
1473
|
-
expect(rowLines()[3]).toContain('not overwritten, fix by hand or rename');
|
|
1474
|
-
expect(rowLines()[3]).toMatch(/row 3: not asserted/);
|
|
1475
|
-
});
|
|
1476
|
-
it('reports a malformed leftover on the log and issues memories by codeContext', async () => {
|
|
1477
|
-
preExistingMemories = new Set(['mx-agent-newteam-known-issues']);
|
|
1478
|
-
preExistingCodeContextFor = () => ({ product: 'mx-agent', team: 'newteam' });
|
|
1479
|
-
await provision();
|
|
1480
|
-
expect(rowLines()[5]).toContain('pre-existing and malformed');
|
|
1481
|
-
expect(rowLines()[5]).toContain('codeContext.service');
|
|
1482
|
-
});
|
|
1483
|
-
it('still refuses to write over either kind, and still says the name is in use', async () => {
|
|
1484
|
-
// memnexus#5485: `create --name` upserts, so a re-provision that created
|
|
1485
|
-
// would replace whatever the memory held, which may be a live team's state.
|
|
1486
|
-
preExistingMemories = new Set(['mx-agent-newteam-leader-state']);
|
|
1487
|
-
preExistingContentFor = () => 'nothing like a leader state';
|
|
1488
|
-
const { failure } = await provision();
|
|
1489
|
-
expect(failure.message).toContain('already in use');
|
|
1490
|
-
expect(failure.message).toContain('REPLACES its content');
|
|
1491
|
-
expect(failure.message).toContain('Delete or rename');
|
|
1492
|
-
});
|
|
1493
|
-
it('asks the backend for nothing extra: the diagnosis uses the probe read', async () => {
|
|
1494
|
-
preExistingMemories = new Set(MEMORIES);
|
|
1495
|
-
preExistingContentFor = () => 'malformed';
|
|
1496
|
-
await provision();
|
|
1497
|
-
const { readNamedMemoryJson } = await import('../lib/memory.js');
|
|
1498
|
-
expect(vi.mocked(readNamedMemoryJson)).not.toHaveBeenCalled();
|
|
1499
|
-
});
|
|
1500
|
-
});
|
|
1501
|
-
// ── Coordination service URL: row 12 (#32, #59) ──────────────────────────────
|
|
1502
|
-
//
|
|
1503
|
-
// Provisioning writes nothing to the operator's global config (#59 amendment).
|
|
1504
|
-
// What it does is report which level holds a URL, so a team created on a machine
|
|
1505
|
-
// that has none is told so at creation instead of at its first brief. Since v41
|
|
1506
|
-
// (#15) the row also makes one GET /obligations as the new team, and the URL
|
|
1507
|
-
// source is the second half of its detail. The hosts here end in `.memnexus.ai`
|
|
1508
|
-
// because the probe checks the URL with the real validator.
|
|
1509
|
-
describe('completion check — row 12', () => {
|
|
1510
|
-
it('reports the project config as the source on a machine that had no key', async () => {
|
|
1511
|
-
// The row names where the URL came FROM, not where it now sits: the seed
|
|
1512
|
-
// above has already written it into the operator config by this point.
|
|
1513
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai';
|
|
1514
|
-
await provision();
|
|
1515
|
-
const row12 = rowLines()[12];
|
|
1516
|
-
expect(row12).toMatch(/row 12: asserted/);
|
|
1517
|
-
expect(row12).toContain('coordination URL from project');
|
|
1518
|
-
expect(row12).toContain('the new team\'s token authenticates to the coordination service (GET /obligations 200)');
|
|
1519
|
-
// The clean read path: nothing failed, so nothing warns.
|
|
1520
|
-
expect(stderrStream.join('')).toBe('');
|
|
1521
|
-
});
|
|
1522
|
-
it('reports the operator config as the source when that key is already set', async () => {
|
|
1523
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai';
|
|
1524
|
-
globalConfig.set('coordination-service-url', 'https://operators-own.memnexus.ai');
|
|
1525
|
-
await provision();
|
|
1526
|
-
expect(rowLines()[12]).toMatch(/row 12: asserted/);
|
|
1527
|
-
expect(rowLines()[12]).toContain('coordination URL from config');
|
|
1528
|
-
});
|
|
1529
|
-
it('notes that the project declares a different URL, without printing either', async () => {
|
|
1530
|
-
// "coordination URL from config" reads as agreement when it says nothing
|
|
1531
|
-
// about the file the operator is looking at.
|
|
1532
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai';
|
|
1533
|
-
globalConfig.set('coordination-service-url', 'https://operators-own.memnexus.ai');
|
|
1534
|
-
await provision();
|
|
1535
|
-
const row12 = rowLines()[12];
|
|
1536
|
-
expect(row12).toContain('; note: mx-agent.config.json declares a different URL; the operator config takes precedence');
|
|
1537
|
-
expect(row12).not.toContain('operators-own.memnexus.ai');
|
|
1538
|
-
expect(row12).not.toContain('coord.memnexus.ai');
|
|
1539
|
-
});
|
|
1540
|
-
it('adds no note when the two levels agree, ignoring a trailing slash', async () => {
|
|
1541
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai';
|
|
1542
|
-
globalConfig.set('coordination-service-url', 'https://coord.memnexus.ai/');
|
|
1543
|
-
await provision();
|
|
1544
|
-
expect(rowLines()[12]).toContain('coordination URL from config');
|
|
1545
|
-
expect(rowLines()[12]).not.toContain('declares a different URL');
|
|
1546
|
-
});
|
|
1547
|
-
it('adds no note when the project declares nothing', async () => {
|
|
1548
|
-
configuredCoordinationUrl = '';
|
|
1549
|
-
globalConfig.set('coordination-service-url', 'https://operators-own.memnexus.ai');
|
|
1550
|
-
await provision();
|
|
1551
|
-
expect(rowLines()[12]).toContain('coordination URL from config');
|
|
1552
|
-
expect(rowLines()[12]).not.toContain('declares a different URL');
|
|
1553
|
-
});
|
|
1554
|
-
it('adds no note when the project itself is the source', async () => {
|
|
1555
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai';
|
|
1556
|
-
await provision();
|
|
1557
|
-
expect(rowLines()[12]).toContain('coordination URL from project');
|
|
1558
|
-
expect(rowLines()[12]).not.toContain('declares a different URL');
|
|
1559
|
-
expect(stderrStream.join('')).toBe('');
|
|
1560
|
-
});
|
|
1561
|
-
it('reads the project root provisioning was given, not the one the cwd implies', async () => {
|
|
1562
|
-
// `new project` runs from outside the project it scaffolds. Reading the cwd
|
|
1563
|
-
// project returned another repository's URL: `from project` for a value
|
|
1564
|
-
// from a file this project does not contain.
|
|
1565
|
-
configuredCoordinationUrl = 'https://project-of-record.memnexus.ai';
|
|
1566
|
-
decoyCwdCoordinationUrl = 'https://some-other-repository.memnexus.ai';
|
|
1567
|
-
await provision();
|
|
1568
|
-
const row12 = rowLines()[12];
|
|
1569
|
-
expect(row12).toContain('coordination URL from project');
|
|
1570
|
-
// The mismatch note would fire if the resolved URL came from the decoy, since
|
|
1571
|
-
// the provisioned project's own config declares the other value.
|
|
1572
|
-
expect(row12).not.toContain('declares a different URL');
|
|
1573
|
-
// And the probe asked the project-of-record service, not the decoy.
|
|
1574
|
-
expect(obligationsCalls).toEqual(['https://project-of-record.memnexus.ai']);
|
|
1575
|
-
});
|
|
1576
|
-
it('is not asserted when only the cwd project has a URL', async () => {
|
|
1577
|
-
// A Key Vault project: it has no #507 fallback, so an absent URL stays absent.
|
|
1578
|
-
credentialProjects = new Set();
|
|
1579
|
-
configuredCoordinationUrl = '';
|
|
1580
|
-
decoyCwdCoordinationUrl = 'https://some-other-repository.memnexus.ai';
|
|
1581
|
-
await provision();
|
|
1582
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1583
|
-
expect(rowLines()[12]).toContain('no coordination-service-url in env, config, or mx-agent.config.json');
|
|
1584
|
-
});
|
|
1585
|
-
it('names the field that fixes it when no level holds a URL', async () => {
|
|
1586
|
-
// A Key Vault project: it has no #507 fallback, so an absent URL stays absent.
|
|
1587
|
-
credentialProjects = new Set();
|
|
1588
|
-
configuredCoordinationUrl = '';
|
|
1589
|
-
const { failure } = await provision();
|
|
1590
|
-
// Not a failure: row 12 is not required for a Key Vault project, which
|
|
1591
|
-
// provision does not probe (v41 plan item 5).
|
|
1592
|
-
expect(failure).toBeNull();
|
|
1593
|
-
const row12 = rowLines()[12];
|
|
1594
|
-
expect(row12).toMatch(/row 12: not asserted/);
|
|
1595
|
-
expect(row12).toContain('no coordination-service-url in env, config, or mx-agent.config.json');
|
|
1596
|
-
expect(row12).toContain('set coordinationServiceUrl in mx-agent.config.json');
|
|
1597
|
-
expect(row12).not.toContain('roster and token not checked (#15)');
|
|
1598
|
-
});
|
|
1599
|
-
it('a credential-endpoint project with no URL configured probes the built-in mx-agent URL (#507)', async () => {
|
|
1600
|
-
configuredCoordinationUrl = '';
|
|
1601
|
-
const { failure } = await provision();
|
|
1602
|
-
expect(failure).toBeNull();
|
|
1603
|
-
const row12 = rowLines()[12];
|
|
1604
|
-
expect(row12).toMatch(/row 12: asserted/);
|
|
1605
|
-
expect(row12).toContain('coordination URL from default');
|
|
1606
|
-
expect(obligationsCalls).toEqual(['https://mxagent.dev.memnexus.ai']);
|
|
1607
|
-
});
|
|
1608
|
-
it('counts as asserted when the probe holds, so the asserted total is 13 of 16', async () => {
|
|
1609
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai';
|
|
1610
|
-
await provision();
|
|
1611
|
-
// 12 before v41: 7 before #77, rows 9 and 10, row 13, row 14 (#123), and
|
|
1612
|
-
// row 8 since #428 part 3. Row 12 is the thirteenth, now that it probes.
|
|
1613
|
-
const asserted = rowLines().filter((l) => /row \d+: asserted/.test(l));
|
|
1614
|
-
expect(asserted).toHaveLength(13);
|
|
1615
|
-
expect(rowLines()[12]).toMatch(/row 12: asserted/);
|
|
1616
|
-
expect(stderrStream.join('')).toBe('');
|
|
1617
|
-
});
|
|
1618
|
-
it('carries the source on the row, not only in the printed line', () => {
|
|
1619
|
-
const rows = checkCompletionRows({
|
|
1620
|
-
slug: 'newteam',
|
|
1621
|
-
projectSlug: 'mx-agent',
|
|
1622
|
-
baseBranch: 'main',
|
|
1623
|
-
roleguideInWorktree: null,
|
|
1624
|
-
catalogEntry: join(root, 'nope.md'),
|
|
1625
|
-
memoryNames: MEMORIES,
|
|
1626
|
-
mxAvailable: false,
|
|
1627
|
-
coordinationUrlSource: 'env',
|
|
1628
|
-
row12: { mode: 'probe', outcome: { kind: 'asserted', detail: 'GET /obligations answered 2xx to this team\'s token' } },
|
|
1629
|
-
});
|
|
1630
|
-
const row12 = rows.find((r) => r.n === 12);
|
|
1631
|
-
expect(row12.asserted).toBe(true);
|
|
1632
|
-
expect(row12.required).toBe(true);
|
|
1633
|
-
expect(row12.urlSource).toBe('env');
|
|
1634
|
-
printCompletionRows(rows);
|
|
1635
|
-
expect(rowLines()[12]).toMatch(/row 12: asserted/);
|
|
1636
|
-
expect(rowLines()[12]).toContain('coordination URL from env');
|
|
1637
|
-
});
|
|
1638
|
-
it('a caller that states no row-12 mode gets could-not-run, required, on the credential path', () => {
|
|
1639
|
-
// A caller that did not say is not a row that held.
|
|
1640
|
-
const rows = checkCompletionRows({
|
|
1641
|
-
slug: 'newteam',
|
|
1642
|
-
projectSlug: 'mx-agent',
|
|
1643
|
-
baseBranch: 'main',
|
|
1644
|
-
roleguideInWorktree: null,
|
|
1645
|
-
catalogEntry: join(root, 'nope.md'),
|
|
1646
|
-
memoryNames: MEMORIES,
|
|
1647
|
-
mxAvailable: false,
|
|
1648
|
-
coordinationUrlSource: null,
|
|
1649
|
-
});
|
|
1650
|
-
const row12 = rows.find((r) => r.n === 12);
|
|
1651
|
-
expect(row12.asserted).toBe(false);
|
|
1652
|
-
expect(row12.required).toBe(true);
|
|
1653
|
-
expect(row12.couldNotRun).toBe(true);
|
|
1654
|
-
printCompletionRows(rows);
|
|
1655
|
-
expect(rowLines()[12]).toMatch(/row 12: could not run/);
|
|
1656
|
-
expect(rowLines()[12]).toContain('no coordination-service-url in env, config, or mx-agent.config.json');
|
|
1657
|
-
});
|
|
1658
|
-
});
|
|
1659
|
-
// ── Row 12's token probe (#15; v41 plan criterion 1) ─────────────────────────
|
|
1660
|
-
//
|
|
1661
|
-
// One GET /obligations as the new team after row 10 cached its credential. The
|
|
1662
|
-
// injected request answers `obligationsAnswers`; everything else in
|
|
1663
|
-
// `probeTeamToken` and `checkCompletionRows` is the shipped code.
|
|
1664
|
-
describe('completion row 12 — the token probe (#15, v41)', () => {
|
|
1665
|
-
const CACHED = {
|
|
1666
|
-
kind: 'obtainable',
|
|
1667
|
-
cachePath: '/tmp/.mx-coordination-token--mx-agent--newteam',
|
|
1668
|
-
mode: 0o600,
|
|
1669
|
-
fromCache: true,
|
|
1670
|
-
};
|
|
1671
|
-
/** The serviceUrl each provisionCredentialForWorktree call was handed, and whether it forced a mint. */
|
|
1672
|
-
function mintCalls() {
|
|
1673
|
-
return vi.mocked(provisionCredentialForWorktree).mock.calls
|
|
1674
|
-
.map((c) => c[0]);
|
|
1675
|
-
}
|
|
1676
|
-
function everything() {
|
|
1677
|
-
return [...stdout, ...stderr, ...stderrStream].join('\n');
|
|
1678
|
-
}
|
|
1679
|
-
it('200: row 12 asserted, and the run prints Team Created!', async () => {
|
|
1680
|
-
obligationsAnswers = [200];
|
|
1681
|
-
const { failure } = await provision();
|
|
1682
|
-
expect(failure).toBeNull();
|
|
1683
|
-
expect(rowLines()[12]).toMatch(/row 12: asserted/);
|
|
1684
|
-
expect(rowLines()[12]).toContain('GET /obligations answered 2xx');
|
|
1685
|
-
expect(stdout.join('\n')).toContain('Team Created!');
|
|
1686
|
-
expect(obligationsCalls).toHaveLength(1);
|
|
1687
|
-
});
|
|
1688
|
-
for (const status of [401, 403, 404]) {
|
|
1689
|
-
it(`${status}: row 12 failed, the run exits non-zero, and no Team Created!`, async () => {
|
|
1690
|
-
obligationsAnswers = [status];
|
|
1691
|
-
const { failure } = await provision();
|
|
1692
|
-
expect(failure).not.toBeNull();
|
|
1693
|
-
expect(failure.message).toContain('row 12:');
|
|
1694
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
1695
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1696
|
-
expect(rowLines()[12]).toContain(`GET /obligations answered ${status}: the service refused this team's token`);
|
|
1697
|
-
// A fresh mint is not retried: only a CACHED token gets the one re-mint.
|
|
1698
|
-
expect(mintCalls()).toHaveLength(1);
|
|
1699
|
-
});
|
|
1700
|
-
}
|
|
1701
|
-
for (const answer of [503, 500, 429, 'timeout']) {
|
|
1702
|
-
it(`${answer}: row 12 could not run, the run exits non-zero, and no Team Created!`, async () => {
|
|
1703
|
-
obligationsAnswers = [answer];
|
|
1704
|
-
const { failure } = await provision();
|
|
1705
|
-
expect(failure).not.toBeNull();
|
|
1706
|
-
expect(failure.message).toContain('row 12:');
|
|
1707
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
1708
|
-
expect(rowLines()[12]).toMatch(/row 12: could not run/);
|
|
1709
|
-
expect(rowLines()[12]).toContain(answer === 'timeout' ? 'no answer (timeout or transport error)' : `GET /obligations answered ${answer}`);
|
|
1710
|
-
expect(mintCalls()).toHaveLength(1);
|
|
1711
|
-
});
|
|
1712
|
-
}
|
|
1713
|
-
it('a cached token answered 401 gets one re-mint, then 200: asserted', async () => {
|
|
1714
|
-
credentialState = CACHED;
|
|
1715
|
-
obligationsAnswers = [401, 200];
|
|
1716
|
-
const { failure } = await provision();
|
|
1717
|
-
expect(failure).toBeNull();
|
|
1718
|
-
expect(stdout.join('\n')).toContain('Team Created!');
|
|
1719
|
-
expect(rowLines()[12]).toMatch(/row 12: asserted/);
|
|
1720
|
-
expect(rowLines()[12]).toContain('the cached token was answered 401 and one re-mint ran');
|
|
1721
|
-
expect(obligationsCalls).toHaveLength(2);
|
|
1722
|
-
const calls = mintCalls();
|
|
1723
|
-
expect(calls).toHaveLength(2);
|
|
1724
|
-
expect(calls[0].forceMint).toBeUndefined();
|
|
1725
|
-
expect(calls[1].forceMint).toBe(true);
|
|
1726
|
-
// The re-mint went to the URL the first mint used.
|
|
1727
|
-
expect(calls[1].serviceUrl).toBe(calls[0].serviceUrl);
|
|
1728
|
-
// Row 10 reports the cache the team will read, which is the re-minted one.
|
|
1729
|
-
expect(rowLines()[10]).toContain('a credential was issued and cached');
|
|
1730
|
-
});
|
|
1731
|
-
it('a cached token answered 401, then 401 again after the re-mint: failed, and only one re-mint', async () => {
|
|
1732
|
-
credentialState = CACHED;
|
|
1733
|
-
obligationsAnswers = [401, 401];
|
|
1734
|
-
const { failure } = await provision();
|
|
1735
|
-
expect(failure).not.toBeNull();
|
|
1736
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
1737
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1738
|
-
expect(rowLines()[12]).toContain('one re-mint ran; GET /obligations answered 401');
|
|
1739
|
-
expect(obligationsCalls).toHaveLength(2);
|
|
1740
|
-
expect(mintCalls().filter((c) => c.forceMint === true)).toHaveLength(1);
|
|
1741
|
-
});
|
|
1742
|
-
it('a cached token answered 401 whose re-mint is refused: failed, no second request', async () => {
|
|
1743
|
-
credentialState = CACHED;
|
|
1744
|
-
remintState = { kind: 'refused', reason: 'not-authorized', detail: 'REFUSED-TEXT' };
|
|
1745
|
-
obligationsAnswers = [401];
|
|
1746
|
-
const { failure } = await provision();
|
|
1747
|
-
expect(failure).not.toBeNull();
|
|
1748
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1749
|
-
expect(rowLines()[12]).toContain('one re-mint did not produce a usable cache (refused)');
|
|
1750
|
-
expect(obligationsCalls).toHaveLength(1);
|
|
1751
|
-
});
|
|
1752
|
-
it('an issued re-mint whose cache write failed: row 10 reports the write failure, not the old cache (N-1)', async () => {
|
|
1753
|
-
credentialState = CACHED;
|
|
1754
|
-
remintState = {
|
|
1755
|
-
kind: 'could-not-run',
|
|
1756
|
-
detail: 'a credential was issued but it could not be written to the new worktree\'s token cache (WRITE-FAILED)',
|
|
1757
|
-
};
|
|
1758
|
-
obligationsAnswers = [401];
|
|
1759
|
-
const { failure } = await provision();
|
|
1760
|
-
expect(failure).not.toBeNull();
|
|
1761
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
1762
|
-
expect(rowLines()[10]).toMatch(/row 10: could not run/);
|
|
1763
|
-
expect(rowLines()[10]).toContain('WRITE-FAILED');
|
|
1764
|
-
expect(rowLines()[10]).not.toContain('a file is present at');
|
|
1765
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1766
|
-
expect(failure.message).toContain('row 10:');
|
|
1767
|
-
expect(failure.message).toContain('row 12:');
|
|
1768
|
-
});
|
|
1769
|
-
it('a cached token answered 403 is not re-minted: only 401 triggers it', async () => {
|
|
1770
|
-
credentialState = CACHED;
|
|
1771
|
-
obligationsAnswers = [403];
|
|
1772
|
-
await provision();
|
|
1773
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1774
|
-
expect(mintCalls()).toHaveLength(1);
|
|
1775
|
-
expect(obligationsCalls).toHaveLength(1);
|
|
1776
|
-
});
|
|
1777
|
-
it('row 10 not usable: row 12 "not run: depends on row 10", no request, and one fault is counted once', async () => {
|
|
1778
|
-
credentialState = { kind: 'refused', reason: 'not-authorized', detail: 'REFUSED-TEXT' };
|
|
1779
|
-
const { failure } = await provision();
|
|
1780
|
-
expect(obligationsCalls).toHaveLength(0);
|
|
1781
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1782
|
-
expect(rowLines()[12]).toContain('not run: depends on row 10');
|
|
1783
|
-
// The run fails on row 10, and row 12 is not listed beside it.
|
|
1784
|
-
expect(failure.message).toContain('row 10:');
|
|
1785
|
-
expect(failure.message).not.toContain('row 12:');
|
|
1786
|
-
});
|
|
1787
|
-
it('row 10 cached at the wrong mode: row 12 is not run either', async () => {
|
|
1788
|
-
credentialState = { kind: 'obtainable', cachePath: '/w/.mx-coordination-token--mx-agent--newteam', mode: 0o644 };
|
|
1789
|
-
await provision();
|
|
1790
|
-
expect(obligationsCalls).toHaveLength(0);
|
|
1791
|
-
expect(rowLines()[12]).toContain('not run: depends on row 10');
|
|
1792
|
-
});
|
|
1793
|
-
it('a Key Vault project is not probed, is not required, and names the brief step', async () => {
|
|
1794
|
-
credentialProjects = new Set();
|
|
1795
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai';
|
|
1796
|
-
const { failure } = await provision();
|
|
1797
|
-
expect(failure).toBeNull();
|
|
1798
|
-
expect(obligationsCalls).toHaveLength(0);
|
|
1799
|
-
expect(rowLines()[12]).toMatch(/row 12: not asserted/);
|
|
1800
|
-
expect(rowLines()[12]).toContain('run `mx-agent coordination brief` in the new worktree after its first `start`');
|
|
1801
|
-
const rows = checkCompletionRows({
|
|
1802
|
-
slug: 'newteam',
|
|
1803
|
-
projectSlug: 'memnexus',
|
|
1804
|
-
baseBranch: 'main',
|
|
1805
|
-
roleguideInWorktree: null,
|
|
1806
|
-
catalogEntry: join(root, 'nope.md'),
|
|
1807
|
-
memoryNames: MEMORIES,
|
|
1808
|
-
mxAvailable: false,
|
|
1809
|
-
coordinationUrlSource: 'project',
|
|
1810
|
-
});
|
|
1811
|
-
expect(rows.find((r) => r.n === 12).required).toBe(false);
|
|
1812
|
-
});
|
|
1813
|
-
it('the probe URL equals the mint URL', async () => {
|
|
1814
|
-
configuredCoordinationUrl = 'https://coord.memnexus.ai/';
|
|
1815
|
-
await provision();
|
|
1816
|
-
const mintUrl = mintCalls()[0].serviceUrl;
|
|
1817
|
-
expect(mintUrl).toBe('https://coord.memnexus.ai/');
|
|
1818
|
-
expect(obligationsCalls).toEqual([mintUrl.replace(/\/+$/, '')]);
|
|
1819
|
-
});
|
|
1820
|
-
it('a URL the validator refuses is could-not-run, makes no request, and does not echo the URL', async () => {
|
|
1821
|
-
process.env.MX_COORD_SERVICE_URL = 'http://not-allowed.example.com';
|
|
1822
|
-
try {
|
|
1823
|
-
const { failure } = await provision();
|
|
1824
|
-
expect(failure).not.toBeNull();
|
|
1825
|
-
expect(obligationsCalls).toHaveLength(0);
|
|
1826
|
-
expect(rowLines()[12]).toMatch(/row 12: could not run/);
|
|
1827
|
-
expect(rowLines()[12]).toContain('the coordination service URL was refused, so no request was made');
|
|
1828
|
-
expect(rowLines()[12]).not.toContain('not-allowed.example.com');
|
|
1829
|
-
}
|
|
1830
|
-
finally {
|
|
1831
|
-
delete process.env.MX_COORD_SERVICE_URL;
|
|
1832
|
-
}
|
|
1833
|
-
});
|
|
1834
|
-
it('prints status codes only: never the token, and never the text of a refusal', async () => {
|
|
1835
|
-
obligationsAnswers = [401];
|
|
1836
|
-
await provision();
|
|
1837
|
-
expect(everything()).not.toContain('fake-team-token-for-tests-only');
|
|
1838
|
-
// The injected ServiceHttpError carries a message standing in for the
|
|
1839
|
-
// service's `error` field; the row names the status in its own words and
|
|
1840
|
-
// never copies the message.
|
|
1841
|
-
expect(everything()).not.toContain('service-error-text-for-tests');
|
|
1842
|
-
});
|
|
1843
|
-
});
|
|
1844
|
-
// ── Row 12's mode is stated by the caller (bar-raiser Step 4 condition R2) ────
|
|
1845
|
-
describe('completion row 12 — the mode each caller states (R2)', () => {
|
|
1846
|
-
const base = {
|
|
1847
|
-
slug: 'newteam',
|
|
1848
|
-
projectSlug: 'mx-agent',
|
|
1849
|
-
baseBranch: 'main',
|
|
1850
|
-
roleguideInWorktree: null,
|
|
1851
|
-
memoryNames: MEMORIES,
|
|
1852
|
-
mxAvailable: false,
|
|
1853
|
-
coordinationUrlSource: 'project',
|
|
1854
|
-
};
|
|
1855
|
-
it('recheck: not run, not required, and says --recheck does not contact the service', () => {
|
|
1856
|
-
const rows = checkCompletionRows({ ...base, catalogEntry: join(root, 'nope.md'), row12: { mode: 'recheck' } });
|
|
1857
|
-
const row12 = rows.find((r) => r.n === 12);
|
|
1858
|
-
expect(row12.required).toBe(false);
|
|
1859
|
-
expect(row12.asserted).toBe(false);
|
|
1860
|
-
expect(row12.detail.startsWith('not run: --recheck does not contact the coordination service')).toBe(true);
|
|
1861
|
-
});
|
|
1862
|
-
it('failure handler: not run, not required, and says provision stopped before the probe', () => {
|
|
1863
|
-
const rows = checkCompletionRows({ ...base, catalogEntry: join(root, 'nope.md'), row12: { mode: 'not-run' } });
|
|
1864
|
-
const row12 = rows.find((r) => r.n === 12);
|
|
1865
|
-
expect(row12.required).toBe(false);
|
|
1866
|
-
expect(row12.asserted).toBe(false);
|
|
1867
|
-
expect(row12.detail.startsWith('not run: provision stopped before the probe')).toBe(true);
|
|
1868
|
-
});
|
|
1869
|
-
});
|
|
1870
|
-
/**
|
|
1871
|
-
* Row 2 with an `origin` (#51, plan #72).
|
|
1872
|
-
*
|
|
1873
|
-
* A project with a remote no longer has provisioning write the catalog entry:
|
|
1874
|
-
* team-builder step 5 writes it, step 6a merges it, and the precondition at step
|
|
1875
|
-
* 0c refuses the run if it is not on `origin/main`. The row states which of the
|
|
1876
|
-
* two facts it asserted, and the asserted count does not move.
|
|
1877
|
-
*/
|
|
1878
|
-
describe('completion row 2 — a project with an origin', () => {
|
|
1879
|
-
it('asserts the entry on origin/main and still counts 13 of 15', async () => {
|
|
1880
|
-
hasOrigin = true;
|
|
1881
|
-
entryOnOriginMain = 'present';
|
|
1882
|
-
const { failure } = await provision();
|
|
1883
|
-
expect(failure).toBeNull();
|
|
1884
|
-
expect(rowLines()).toHaveLength(16);
|
|
1885
|
-
expect(rowLines()[2]).toMatch(/row 2: asserted/);
|
|
1886
|
-
expect(rowLines()[2]).toContain('catalog entry on origin/main: mx-agent-system/teams/newteam.md');
|
|
1887
|
-
// 13: 11 before #428 part 3 gave row 8 a real verdict, 12 until v41 (#15)
|
|
1888
|
-
// gave row 12 its token probe, which this fixture's injected probe answers
|
|
1889
|
-
// 200. Row 2's own count is unchanged, which is what the test is about.
|
|
1890
|
-
expect(rowLines().filter((l) => /row \d+: asserted/.test(l))).toHaveLength(13);
|
|
1891
|
-
});
|
|
1892
|
-
it('writes no catalog entry into the project root', async () => {
|
|
1893
|
-
// The write that produced the untracked file in the main checkout. The
|
|
1894
|
-
// catalog mock in this file really writes, so the filesystem answers this.
|
|
1895
|
-
hasOrigin = true;
|
|
1896
|
-
entryOnOriginMain = 'present';
|
|
1897
|
-
await provision();
|
|
1898
|
-
expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(false);
|
|
1899
|
-
});
|
|
1900
|
-
});
|
|
1901
|
-
/**
|
|
1902
|
-
* Rows 9 and 10 — the coordination registration (#77).
|
|
1903
|
-
*
|
|
1904
|
-
* Both rows used to read `not asserted` with a fixed reason, so a team was
|
|
1905
|
-
* created with no cross-team channel and no named step to get one. They are read
|
|
1906
|
-
* now, and they are REQUIRED: the roster entry is merged and the token minted
|
|
1907
|
-
* before `provision` runs (product owner, AskUserQuestion 2026-08-22, "C strict:
|
|
1908
|
-
* roster and mint before provision").
|
|
1909
|
-
*
|
|
1910
|
-
* Row 9 has four texts because it reads two files. Row 10 has three. Each is
|
|
1911
|
-
* pinned here, because the text is the whole of what an operator gets.
|
|
1912
|
-
*/
|
|
1913
|
-
describe('completion rows 9 and 10 — the coordination registration', () => {
|
|
1914
|
-
/** The printed line for a row number. */
|
|
1915
|
-
function line(n) {
|
|
1916
|
-
return rowLines()[n];
|
|
1917
|
-
}
|
|
1918
|
-
// These texts are about the `origin/<base>` read, which a project with an
|
|
1919
|
-
// `origin` takes. A project with zero remotes reads `refs/heads/<base>`
|
|
1920
|
-
// instead (#607), pinned in the describe block after this one.
|
|
1921
|
-
beforeEach(() => {
|
|
1922
|
-
hasOrigin = true;
|
|
1923
|
-
entryOnOriginMain = 'present';
|
|
1924
|
-
});
|
|
1925
|
-
it('row 9 asserted names the roster it read and what it cannot see', async () => {
|
|
1926
|
-
rosterJsonState = 'present';
|
|
1927
|
-
const { failure } = await provision();
|
|
1928
|
-
expect(failure).toBeNull();
|
|
1929
|
-
expect(line(9)).toMatch(/row 9: asserted/);
|
|
1930
|
-
expect(line(9)).toContain('coordination roster entry for newteam');
|
|
1931
|
-
expect(line(9)).toContain('token-eligible per PROVISIONED_ROSTERS on origin/main');
|
|
1932
|
-
expect(line(9)).toContain('this row cannot see whether the service was redeployed');
|
|
1933
|
-
});
|
|
1934
|
-
it('row 9 is partly asserted when only rosters.ts holds the slug, and still fails', async () => {
|
|
1935
|
-
rosterJsonState = 'absent';
|
|
1936
|
-
rosterSourceState = 'present';
|
|
1937
|
-
const { failure } = await provision();
|
|
1938
|
-
expect(line(9)).toMatch(/row 9: partly asserted/);
|
|
1939
|
-
expect(line(9)).toContain('in rosters.ts on origin/main, generated JSON stale');
|
|
1940
|
-
expect(line(9)).toContain('run generate-rosters (step 6a)');
|
|
1941
|
-
expect(line(9)).toContain('npm run build');
|
|
1942
|
-
expect(line(9)).toContain('node dist/admin/generate-rosters.js > ../agent-config/coordination-rosters.generated.json');
|
|
1943
|
-
// Partly asserted is not asserted: the claim the label makes needs both files.
|
|
1944
|
-
expect(failure).not.toBeNull();
|
|
1945
|
-
expect(failure.message).toContain('row 9:');
|
|
1946
|
-
});
|
|
1947
|
-
it('row 9 not asserted names the array, the two commands and the PR', async () => {
|
|
1948
|
-
rosterJsonState = 'absent';
|
|
1949
|
-
rosterSourceState = 'absent';
|
|
1950
|
-
const { failure } = await provision();
|
|
1951
|
-
expect(line(9)).toMatch(/row 9: not asserted/);
|
|
1952
|
-
expect(line(9)).toContain("add newteam to the project's array in PROVISIONED_ROSTERS "
|
|
1953
|
-
+ '(coordination-service/src/config/rosters.ts)');
|
|
1954
|
-
expect(line(9)).toContain('regenerate mx-agent-system/agent-config/coordination-rosters.generated.json');
|
|
1955
|
-
expect(line(9)).toContain('npm run build');
|
|
1956
|
-
expect(line(9)).toContain('node dist/admin/generate-rosters.js');
|
|
1957
|
-
expect(line(9)).toContain('merge both in the step 6a PR');
|
|
1958
|
-
expect(failure).not.toBeNull();
|
|
1959
|
-
});
|
|
1960
|
-
it('row 9 reports a ref it could not read as could-not-run, not as a missing entry', async () => {
|
|
1961
|
-
// Passed, failed and could-not-run are three results
|
|
1962
|
-
// (mx-agent-system/standards/fail-loud-standard.md). Telling the operator to
|
|
1963
|
-
// add an entry that may already be on the base branch is the failure here.
|
|
1964
|
-
//
|
|
1965
|
-
// This asserted `not asserted` until #408. The detail already said the ref
|
|
1966
|
-
// could not be read and the verdict word beside it said the check had run
|
|
1967
|
-
// and failed, so the row printed the state this test's own name refuses.
|
|
1968
|
-
rosterJsonState = 'unresolvable';
|
|
1969
|
-
const { failure } = await provision();
|
|
1970
|
-
expect(line(9)).toMatch(/row 9: could not run/);
|
|
1971
|
-
expect(line(9)).toContain('could not read origin/main');
|
|
1972
|
-
expect(line(9)).not.toContain('add newteam to');
|
|
1973
|
-
expect(failure).not.toBeNull();
|
|
1974
|
-
});
|
|
1975
|
-
it('row 10 asserted claims an enabled secret of that name, and nothing more', async () => {
|
|
1976
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
1977
|
-
credentialProjects = new Set();
|
|
1978
|
-
vaultState = 'present';
|
|
1979
|
-
const { failure } = await provision();
|
|
1980
|
-
expect(failure).toBeNull();
|
|
1981
|
-
expect(line(10)).toMatch(/row 10: asserted/);
|
|
1982
|
-
expect(line(10)).toContain('Key Vault token for newteam');
|
|
1983
|
-
expect(line(10)).toContain('an enabled secret of that name in mx-dev-eastus2-kv-001');
|
|
1984
|
-
expect(line(10)).toContain('this row does not check that the token works');
|
|
1985
|
-
});
|
|
1986
|
-
it('row 10 not asserted names the mint, dry run first, as the product owner s step', async () => {
|
|
1987
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
1988
|
-
credentialProjects = new Set();
|
|
1989
|
-
vaultState = 'absent';
|
|
1990
|
-
const { failure } = await provision();
|
|
1991
|
-
expect(line(10)).toMatch(/row 10: not asserted/);
|
|
1992
|
-
expect(line(10)).toContain('no token; the product owner mints it');
|
|
1993
|
-
expect(line(10)).toContain('provision-team-tokens.sh --dry-run --team newteam --project mx-agent');
|
|
1994
|
-
expect(line(10)).toContain('then --apply (step 6a2)');
|
|
1995
|
-
expect(failure).not.toBeNull();
|
|
1996
|
-
expect(failure.message).toContain('row 10:');
|
|
1997
|
-
});
|
|
1998
|
-
it('row 10 reports a vault it could not read as could-not-run', async () => {
|
|
1999
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2000
|
-
credentialProjects = new Set();
|
|
2001
|
-
vaultState = 'unresolvable';
|
|
2002
|
-
const { failure } = await provision();
|
|
2003
|
-
expect(line(10)).toMatch(/row 10: not asserted/);
|
|
2004
|
-
expect(line(10)).toContain('could not read the vault (az not available in this session)');
|
|
2005
|
-
expect(line(10)).toContain("run under the product owner's az identity");
|
|
2006
|
-
expect(line(10)).not.toContain('no token');
|
|
2007
|
-
expect(failure).not.toBeNull();
|
|
2008
|
-
});
|
|
2009
|
-
it('the row 10 text names the vault and no secret, in all three states', () => {
|
|
2010
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2011
|
-
credentialProjects = new Set();
|
|
2012
|
-
// Unit level, so all three states are read in one test: the row detail is
|
|
2013
|
-
// fixed text plus the vault name, and nothing the vault said reaches it.
|
|
2014
|
-
for (const state of ['present', 'absent', 'unresolvable']) {
|
|
2015
|
-
vaultState = state;
|
|
2016
|
-
// Row 9 present, so the vault IS asked and all three of its answers are
|
|
2017
|
-
// reachable. The gate itself is covered by the four tests above.
|
|
2018
|
-
rosterJsonState = 'present';
|
|
2019
|
-
const row = checkCompletionRows({
|
|
2020
|
-
slug: 'newteam',
|
|
2021
|
-
projectSlug: 'mx-agent',
|
|
2022
|
-
baseBranch: 'main',
|
|
2023
|
-
roleguideInWorktree: null,
|
|
2024
|
-
projectRoot: root,
|
|
2025
|
-
fetchOk: true,
|
|
2026
|
-
catalogEntry: join(root, 'nope.md'),
|
|
2027
|
-
memoryNames: MEMORIES,
|
|
2028
|
-
mxAvailable: false,
|
|
2029
|
-
}).find((r) => r.n === 10);
|
|
2030
|
-
expect(row.required).toBe(true);
|
|
2031
|
-
expect(row.detail).not.toMatch(/coordination-token--/);
|
|
2032
|
-
expect(row.detail).not.toMatch(/--query|length\(/);
|
|
2033
|
-
expect(row.detail.includes('mx-dev-eastus2-kv-001')).toBe(state === 'present');
|
|
2034
|
-
}
|
|
2035
|
-
});
|
|
2036
|
-
it('both rows missing exits INCOMPLETE naming both, and leaves the worktree', async () => {
|
|
2037
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2038
|
-
credentialProjects = new Set();
|
|
2039
|
-
rosterJsonState = 'absent';
|
|
2040
|
-
rosterSourceState = 'absent';
|
|
2041
|
-
vaultState = 'absent';
|
|
2042
|
-
const { failure } = await provision();
|
|
2043
|
-
expect(failure).not.toBeNull();
|
|
2044
|
-
expect(failure.message).toContain('Provisioning INCOMPLETE');
|
|
2045
|
-
expect(failure.message).toContain('2 of the 10 rows');
|
|
2046
|
-
expect(failure.message).toContain('row 9: coordination roster entry for newteam');
|
|
2047
|
-
expect(failure.message).toContain('row 10: Key Vault token for newteam');
|
|
2048
|
-
// Nothing is deleted: a half-built team the operator can finish beats a
|
|
2049
|
-
// cleanup that removes work nobody can get back.
|
|
2050
|
-
expect(existsSync(join(root, WORKTREE))).toBe(true);
|
|
2051
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
2052
|
-
});
|
|
2053
|
-
it('asks the vault only when row 9 says the team is token-eligible', async () => {
|
|
2054
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2055
|
-
credentialProjects = new Set();
|
|
2056
|
-
// The gate is row 9's answer. A project this vault does not serve would get
|
|
2057
|
-
// a required row it can never satisfy, and an `az` session belonging to
|
|
2058
|
-
// someone else would send that session's bearer token to our vault host
|
|
2059
|
-
// (security review, Should Fix 1).
|
|
2060
|
-
rosterJsonState = 'present';
|
|
2061
|
-
await provision();
|
|
2062
|
-
expect(vi.mocked(vaultTokenPresent)).toHaveBeenCalledTimes(1);
|
|
2063
|
-
expect(vi.mocked(vaultTokenPresent)).toHaveBeenCalledWith('mx-agent', 'newteam');
|
|
2064
|
-
});
|
|
2065
|
-
it('spawns no vault read when row 9 is absent, and says so on row 10', async () => {
|
|
2066
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2067
|
-
credentialProjects = new Set();
|
|
2068
|
-
rosterJsonState = 'absent';
|
|
2069
|
-
rosterSourceState = 'absent';
|
|
2070
|
-
const { failure } = await provision();
|
|
2071
|
-
expect(vi.mocked(vaultTokenPresent)).not.toHaveBeenCalled();
|
|
2072
|
-
expect(line(10)).toMatch(/row 10: not asserted/);
|
|
2073
|
-
expect(line(10)).toContain('not token-eligible until the roster entry is on origin/main (row 9)');
|
|
2074
|
-
expect(line(10)).toContain('no vault read attempted');
|
|
2075
|
-
expect(failure).not.toBeNull();
|
|
2076
|
-
});
|
|
2077
|
-
it('spawns no vault read when row 9 is partly asserted', async () => {
|
|
2078
|
-
// The source holds the slug and the generated file does not. Eligibility is
|
|
2079
|
-
// what the generated file decides, so this is not eligible yet.
|
|
2080
|
-
rosterJsonState = 'absent';
|
|
2081
|
-
rosterSourceState = 'present';
|
|
2082
|
-
await provision();
|
|
2083
|
-
expect(vi.mocked(vaultTokenPresent)).not.toHaveBeenCalled();
|
|
2084
|
-
expect(line(10)).toContain('not token-eligible until the roster entry is on origin/main (row 9)');
|
|
2085
|
-
});
|
|
2086
|
-
it('spawns no vault read when row 9 could not be read, and reports that reason', async () => {
|
|
2087
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2088
|
-
credentialProjects = new Set();
|
|
2089
|
-
rosterJsonState = 'unresolvable';
|
|
2090
|
-
const { failure } = await provision();
|
|
2091
|
-
expect(vi.mocked(vaultTokenPresent)).not.toHaveBeenCalled();
|
|
2092
|
-
expect(line(10)).toMatch(/row 10: not asserted/);
|
|
2093
|
-
expect(line(10)).toContain('could not read origin/main (row 9), so token eligibility is not established');
|
|
2094
|
-
expect(line(10)).toContain('no vault read attempted');
|
|
2095
|
-
// Could-not-run, not a missing token: nothing here tells anyone to mint.
|
|
2096
|
-
expect(line(10)).not.toContain('no token; the product owner mints it');
|
|
2097
|
-
expect(failure).not.toBeNull();
|
|
2098
|
-
});
|
|
2099
|
-
it('both rows stay required whether or not the vault was asked', () => {
|
|
2100
|
-
for (const state of ['present', 'absent', 'unresolvable']) {
|
|
2101
|
-
rosterJsonState = state;
|
|
2102
|
-
const rows = checkCompletionRows({
|
|
2103
|
-
slug: 'newteam',
|
|
2104
|
-
projectSlug: 'mx-agent',
|
|
2105
|
-
baseBranch: 'main',
|
|
2106
|
-
roleguideInWorktree: null,
|
|
2107
|
-
catalogEntry: join(root, 'nope.md'),
|
|
2108
|
-
memoryNames: MEMORIES,
|
|
2109
|
-
mxAvailable: false,
|
|
2110
|
-
});
|
|
2111
|
-
expect(rows.find((r) => r.n === 9).required).toBe(true);
|
|
2112
|
-
expect(rows.find((r) => r.n === 10).required).toBe(true);
|
|
2113
|
-
}
|
|
2114
|
-
});
|
|
2115
|
-
it('the final checklist names both rows when they hold', async () => {
|
|
2116
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2117
|
-
credentialProjects = new Set();
|
|
2118
|
-
const { failure } = await provision();
|
|
2119
|
-
expect(failure).toBeNull();
|
|
2120
|
-
const out = stdout.join('\n');
|
|
2121
|
-
expect(out).toContain('Team Created!');
|
|
2122
|
-
expect(out).toContain('Coordination roster entry: token-eligible per PROVISIONED_ROSTERS on origin/main');
|
|
2123
|
-
expect(out).toContain('Key Vault token: an enabled secret of that name in mx-dev-eastus2-kv-001');
|
|
2124
|
-
});
|
|
2125
|
-
// ── Row 10 for a credential-endpoint project (#288) ──────────────────────
|
|
2126
|
-
//
|
|
2127
|
-
// The row asks a different question for `mx-agent`: not "has the operator
|
|
2128
|
-
// minted a Key Vault secret" but "is a credential OBTAINABLE for this team",
|
|
2129
|
-
// which is what now decides whether the new team has a cross-team channel.
|
|
2130
|
-
// Every other project keeps the vault row, pinned by the tests above.
|
|
2131
|
-
it('row 10 asserted names the cached credential and its mode, and claims nothing more', async () => {
|
|
2132
|
-
credentialState = { kind: 'obtainable', cachePath: '/w/.mx-coordination-token--mx-agent--newteam', mode: 0o600 };
|
|
2133
|
-
const { failure } = await provision();
|
|
2134
|
-
expect(failure).toBeNull();
|
|
2135
|
-
expect(line(10)).toMatch(/row 10: asserted/);
|
|
2136
|
-
expect(line(10)).toContain('coordination credential for newteam');
|
|
2137
|
-
expect(line(10)).toContain('a credential was issued and cached at /w/.mx-coordination-token--mx-agent--newteam');
|
|
2138
|
-
expect(line(10)).toContain('(mode 0600)');
|
|
2139
|
-
expect(line(10)).toContain('this row does not check that the token works');
|
|
2140
|
-
// The vault is never read on this path.
|
|
2141
|
-
expect(vi.mocked(vaultTokenPresent)).not.toHaveBeenCalled();
|
|
2142
|
-
});
|
|
2143
|
-
it('row 10 refused names the missing grant and fails the creation', async () => {
|
|
2144
|
-
credentialState = {
|
|
2145
|
-
kind: 'refused',
|
|
2146
|
-
detail: 'this identity is not authorized to hold a credential for the requested team: no grant exists for it. '
|
|
2147
|
-
+ 'An operator creates one with POST /admin/grant on the coordination service.',
|
|
2148
|
-
};
|
|
2149
|
-
const { failure } = await provision();
|
|
2150
|
-
expect(line(10)).toMatch(/row 10: not asserted/);
|
|
2151
|
-
expect(line(10)).toContain('no grant exists for it');
|
|
2152
|
-
expect(line(10)).toContain('POST /admin/grant');
|
|
2153
|
-
expect(line(10)).toContain('(step 6a2)');
|
|
2154
|
-
// A refusal must not read as could-not-run, and must not name the vault.
|
|
2155
|
-
expect(line(10)).not.toContain('could not');
|
|
2156
|
-
expect(line(10)).not.toContain('mx-dev-eastus2-kv-001');
|
|
2157
|
-
expect(failure).not.toBeNull();
|
|
2158
|
-
expect(failure.message).toContain('row 10:');
|
|
2159
|
-
});
|
|
2160
|
-
it('row 10 reports a service it could not reach as could-not-run, not as a refusal', async () => {
|
|
2161
|
-
credentialState = {
|
|
2162
|
-
kind: 'could-not-run',
|
|
2163
|
-
detail: 'the coordination service is UNAVAILABLE for credential issuance right now. Retry in a few seconds.',
|
|
2164
|
-
};
|
|
2165
|
-
const { failure } = await provision();
|
|
2166
|
-
// Could-not-run has its own verdict since #290 Should Fix 4.
|
|
2167
|
-
expect(line(10)).toMatch(/row 10: could not run/);
|
|
2168
|
-
expect(line(10)).toContain('UNAVAILABLE');
|
|
2169
|
-
expect(line(10)).toContain('Retry');
|
|
2170
|
-
expect(line(10)).not.toContain('no grant exists');
|
|
2171
|
-
expect(failure).not.toBeNull();
|
|
2172
|
-
});
|
|
2173
|
-
it('row 10 reports a run that made no probe as could-not-run, never as absent', async () => {
|
|
2174
|
-
// A caller written before this field existed, or a run whose probe never
|
|
2175
|
-
// happened. A row that did not look is not a row that passed, and it is not
|
|
2176
|
-
// a row that found nothing either.
|
|
2177
|
-
credentialState = undefined;
|
|
2178
|
-
const { failure } = await provision();
|
|
2179
|
-
expect(line(10)).toMatch(/row 10: could not run/);
|
|
2180
|
-
expect(line(10)).toContain('no credential was requested by this run');
|
|
2181
|
-
expect(line(10)).toContain('nothing is established either way');
|
|
2182
|
-
expect(failure).not.toBeNull();
|
|
2183
|
-
});
|
|
2184
|
-
it('row 10 asks for no credential until row 9 holds, and says which row it is waiting on', async () => {
|
|
2185
|
-
// A COMPILED credential-endpoint project: the roster file keys `mx-agent`
|
|
2186
|
-
// but not this team, so `absent`. The gate is unchanged by #507, which
|
|
2187
|
-
// lifts it only for a project the file keys no roster for (`project-absent`,
|
|
2188
|
-
// the tests below).
|
|
2189
|
-
rosterJsonState = 'absent';
|
|
2190
|
-
rosterSourceState = 'absent';
|
|
2191
|
-
credentialState = undefined;
|
|
2192
|
-
const { failure } = await provision();
|
|
2193
|
-
expect(line(10)).toMatch(/row 10: not asserted/);
|
|
2194
|
-
expect(line(10)).toContain('not token-eligible until the roster entry is on origin/main (row 9)');
|
|
2195
|
-
expect(line(10)).toContain('no credential requested');
|
|
2196
|
-
expect(vi.mocked(provisionCredentialForWorktree)).not.toHaveBeenCalled();
|
|
2197
|
-
expect(failure).not.toBeNull();
|
|
2198
|
-
});
|
|
2199
|
-
// ── A project the coordination service creates on login (#507) ────────────
|
|
2200
|
-
//
|
|
2201
|
-
// The roster file on the ref keys no roster for the project, so the project
|
|
2202
|
-
// is in no compiled roster and never will be. Row 10's credential request is
|
|
2203
|
-
// what registers the team, and row 9 is answered by it.
|
|
2204
|
-
it('#507: a login-created project requests the credential, holds rows 9 and 10, and prints Team Created!', async () => {
|
|
2205
|
-
rosterJsonState = 'project-absent';
|
|
2206
|
-
credentialState = { kind: 'obtainable', cachePath: '/w/.mx-coordination-token--mx-agent--newteam', mode: 0o600 };
|
|
2207
|
-
const { failure } = await provision();
|
|
2208
|
-
expect(failure).toBeNull();
|
|
2209
|
-
expect(vi.mocked(provisionCredentialForWorktree)).toHaveBeenCalledTimes(1);
|
|
2210
|
-
expect(line(9)).toMatch(/row 9: asserted/);
|
|
2211
|
-
expect(line(9)).toContain('is in no compiled roster on origin/main');
|
|
2212
|
-
expect(line(9)).toContain('the credential request in row 10 succeeded');
|
|
2213
|
-
expect(line(9)).not.toContain('PROVISIONED_ROSTERS');
|
|
2214
|
-
expect(line(10)).toMatch(/row 10: asserted/);
|
|
2215
|
-
// The compiled-roster source is never consulted for such a project.
|
|
2216
|
-
expect(vi.mocked(rosterSourceHasSlug)).not.toHaveBeenCalled();
|
|
2217
|
-
expect(stdout.join('\n')).toContain('Team Created!');
|
|
2218
|
-
});
|
|
2219
|
-
it('#507: a refused login-created project names the owner rule, never the compiled roster', async () => {
|
|
2220
|
-
rosterJsonState = 'project-absent';
|
|
2221
|
-
credentialState = {
|
|
2222
|
-
kind: 'refused',
|
|
2223
|
-
reason: 'not-authorized',
|
|
2224
|
-
detail: 'this identity is not authorized to hold a credential for the requested team: no grant exists for it. '
|
|
2225
|
-
+ 'An operator creates one with POST /admin/grant on the coordination service.',
|
|
2226
|
-
};
|
|
2227
|
-
const { failure } = await provision();
|
|
2228
|
-
expect(failure).not.toBeNull();
|
|
2229
|
-
expect(line(10)).toMatch(/row 10: not asserted/);
|
|
2230
|
-
expect(line(10)).toContain(SELF_SERVICE_REFUSED_DETAIL);
|
|
2231
|
-
expect(SELF_SERVICE_REFUSED_DETAIL).toContain("only the project's owner creates teams");
|
|
2232
|
-
expect(line(9)).toMatch(/row 9: not asserted/);
|
|
2233
|
-
expect(line(9)).toContain('it refused (row 10)');
|
|
2234
|
-
for (const n of [9, 10]) {
|
|
2235
|
-
expect(line(n)).not.toContain('PROVISIONED_ROSTERS');
|
|
2236
|
-
expect(line(n)).not.toContain('generate-rosters');
|
|
2237
|
-
expect(line(n)).not.toContain('(step 6a2)');
|
|
2238
|
-
}
|
|
2239
|
-
expect(stdout.join('\n')).not.toContain('Team Created!');
|
|
2240
|
-
});
|
|
2241
|
-
it('#507: a limit refusal on a login-created project reports the limit text unchanged', async () => {
|
|
2242
|
-
rosterJsonState = 'project-absent';
|
|
2243
|
-
credentialState = { kind: 'refused', reason: 'limit-reached', detail: 'LIMIT-TEXT' };
|
|
2244
|
-
const { failure } = await provision();
|
|
2245
|
-
expect(failure).not.toBeNull();
|
|
2246
|
-
expect(line(10)).toContain('LIMIT-TEXT');
|
|
2247
|
-
expect(line(10)).not.toContain(SELF_SERVICE_REFUSED_DETAIL);
|
|
2248
|
-
});
|
|
2249
|
-
it('#507: a login-created project whose request did not complete reads could-not-run on both rows', async () => {
|
|
2250
|
-
rosterJsonState = 'project-absent';
|
|
2251
|
-
credentialState = { kind: 'could-not-run', detail: 'the coordination service is UNAVAILABLE' };
|
|
2252
|
-
const { failure } = await provision();
|
|
2253
|
-
expect(failure).not.toBeNull();
|
|
2254
|
-
expect(line(9)).toMatch(/row 9: could not run/);
|
|
2255
|
-
expect(line(9)).toContain('did not complete');
|
|
2256
|
-
expect(line(10)).toMatch(/row 10: could not run/);
|
|
2257
|
-
});
|
|
2258
|
-
it('#507: a Key Vault project with no roster entry keeps the compiled-roster remedy', async () => {
|
|
2259
|
-
credentialProjects = new Set();
|
|
2260
|
-
rosterJsonState = 'project-absent';
|
|
2261
|
-
rosterSourceState = 'absent';
|
|
2262
|
-
const { failure } = await provision();
|
|
2263
|
-
expect(failure).not.toBeNull();
|
|
2264
|
-
expect(line(9)).toMatch(/row 9: not asserted/);
|
|
2265
|
-
expect(line(9)).toContain('PROVISIONED_ROSTERS');
|
|
2266
|
-
expect(vi.mocked(provisionCredentialForWorktree)).not.toHaveBeenCalled();
|
|
2267
|
-
});
|
|
2268
|
-
it('row 10 names an unreadable base ref as row 9\'s failure, not the credential\'s', async () => {
|
|
2269
|
-
rosterJsonState = 'unresolvable';
|
|
2270
|
-
credentialState = undefined;
|
|
2271
|
-
const { failure } = await provision();
|
|
2272
|
-
expect(line(10)).toContain('could not read origin/main (row 9)');
|
|
2273
|
-
expect(line(10)).toContain('no credential requested');
|
|
2274
|
-
expect(failure).not.toBeNull();
|
|
2275
|
-
});
|
|
2276
|
-
it('row 10 does NOT assert when the permissions could not be read back', async () => {
|
|
2277
|
-
// #290 Should Fix 3. The claim the label makes is that the new team's first
|
|
2278
|
-
// session can read a PRIVATE cache. A mode nobody could read is not evidence
|
|
2279
|
-
// of that, so it is could-not-run, not a pass. This test previously asserted
|
|
2280
|
-
// the opposite and encoded the defect.
|
|
2281
|
-
credentialState = { kind: 'obtainable', cachePath: '/w/.mx-coordination-token--mx-agent--newteam', mode: null };
|
|
2282
|
-
const { failure } = await provision();
|
|
2283
|
-
expect(line(10)).toMatch(/row 10: could not run/);
|
|
2284
|
-
expect(line(10)).toContain('its permissions could not be read back');
|
|
2285
|
-
expect(line(10)).toContain('cannot say the cache is private');
|
|
2286
|
-
expect(failure).not.toBeNull();
|
|
2287
|
-
expect(failure.message).toContain('row 10:');
|
|
2288
|
-
});
|
|
2289
|
-
it('row 10 does NOT assert on a world-readable cache, and names the mode', async () => {
|
|
2290
|
-
// #288 criterion 5 fails on a world-readable cache, and this is the row that
|
|
2291
|
-
// has to see it. 0644 used to assert the row with the mode in the detail.
|
|
2292
|
-
credentialState = { kind: 'obtainable', cachePath: '/w/.mx-coordination-token--mx-agent--newteam', mode: 0o644 };
|
|
2293
|
-
const { failure } = await provision();
|
|
2294
|
-
expect(line(10)).not.toMatch(/row 10: asserted/);
|
|
2295
|
-
expect(line(10)).toContain('its mode is 0644, not 0600');
|
|
2296
|
-
expect(line(10)).toContain('every account on this host can read it');
|
|
2297
|
-
expect(line(10)).toContain('Remove /w/.mx-coordination-token--mx-agent--newteam and re-run');
|
|
2298
|
-
expect(failure).not.toBeNull();
|
|
2299
|
-
});
|
|
2300
|
-
it('row 10 asserts only on 0600, and says so', async () => {
|
|
2301
|
-
credentialState = { kind: 'obtainable', cachePath: '/w/.mx-coordination-token--mx-agent--newteam', mode: 0o600 };
|
|
2302
|
-
const { failure } = await provision();
|
|
2303
|
-
expect(failure).toBeNull();
|
|
2304
|
-
expect(line(10)).toMatch(/row 10: asserted/);
|
|
2305
|
-
expect(line(10)).toContain('(mode 0600)');
|
|
2306
|
-
});
|
|
2307
|
-
it('row 10 renders a refusal and a could-not-run with DIFFERENT verdicts', () => {
|
|
2308
|
-
// #290 Should Fix 4. Both printed `not asserted`, so a 403 (the service
|
|
2309
|
-
// decided) and a 503 (the service never answered) read identically, and the
|
|
2310
|
-
// remedy an operator takes from them is not the same one. Unit level, so both
|
|
2311
|
-
// states are rendered in one test without re-running a creation.
|
|
2312
|
-
function row10For(cred) {
|
|
2313
|
-
stdout.length = 0;
|
|
2314
|
-
const rows = checkCompletionRows({
|
|
2315
|
-
slug: 'newteam',
|
|
2316
|
-
projectSlug: 'mx-agent',
|
|
2317
|
-
baseBranch: 'main',
|
|
2318
|
-
roleguideInWorktree: null,
|
|
2319
|
-
catalogEntry: join(root, 'nope.md'),
|
|
2320
|
-
memoryNames: MEMORIES,
|
|
2321
|
-
mxAvailable: false,
|
|
2322
|
-
projectRoot: root,
|
|
2323
|
-
fetchOk: true,
|
|
2324
|
-
credential: cred,
|
|
2325
|
-
});
|
|
2326
|
-
printCompletionRows(rows);
|
|
2327
|
-
const row = rows.find((r) => r.n === 10);
|
|
2328
|
-
return { row, line: stdout.find((l) => l.includes('row 10:')) ?? '' };
|
|
2329
|
-
}
|
|
2330
|
-
const refused = row10For({ kind: 'refused', detail: 'no grant exists for it.' });
|
|
2331
|
-
expect(refused.row.asserted).toBe(false);
|
|
2332
|
-
expect(refused.row.couldNotRun).toBeFalsy();
|
|
2333
|
-
expect(refused.line).toContain('not asserted');
|
|
2334
|
-
expect(refused.line).not.toContain('could not run');
|
|
2335
|
-
const unavailable = row10For({ kind: 'could-not-run', detail: 'the service is UNAVAILABLE. Retry.' });
|
|
2336
|
-
expect(unavailable.row.asserted).toBe(false);
|
|
2337
|
-
expect(unavailable.row.couldNotRun).toBe(true);
|
|
2338
|
-
expect(unavailable.line).toContain('could not run');
|
|
2339
|
-
expect(unavailable.line).not.toContain('not asserted');
|
|
2340
|
-
// Neither is a pass, and both keep the row required, so both fail a creation.
|
|
2341
|
-
expect(refused.row.required).toBe(true);
|
|
2342
|
-
expect(unavailable.row.required).toBe(true);
|
|
2343
|
-
});
|
|
2344
|
-
// ── Row 9's could-not-run word (#408) ──────────────────────────────────────
|
|
2345
|
-
//
|
|
2346
|
-
// The row computed a three-value read from the start and printed two verdicts.
|
|
2347
|
-
// On a ref it could not read it said `not asserted` while the detail beside it
|
|
2348
|
-
// said the roster is not established either way, and row 10 printed `could not
|
|
2349
|
-
// run` for the identical upstream cause. Passed, failed and could-not-run are
|
|
2350
|
-
// three results (`standards/fail-loud-standard.md`), and the verdict column is
|
|
2351
|
-
// where an operator reads which one this is.
|
|
2352
|
-
it('row 9 prints could-not-run on a ref it could not read, never not-asserted', async () => {
|
|
2353
|
-
rosterJsonState = 'unresolvable';
|
|
2354
|
-
rosterSourceState = 'absent';
|
|
2355
|
-
const { failure } = await provision();
|
|
2356
|
-
expect(line(9)).toMatch(/row 9: could not run/);
|
|
2357
|
-
expect(line(9)).not.toContain('not asserted');
|
|
2358
|
-
expect(line(9)).toContain('could not read origin/main');
|
|
2359
|
-
expect(line(9)).toContain('the roster is not established either way');
|
|
2360
|
-
// And it names no remedy, because an unread ref establishes no missing entry.
|
|
2361
|
-
expect(line(9)).not.toContain(`add newteam to`);
|
|
2362
|
-
});
|
|
2363
|
-
it('row 9 could-not-run still fails the creation, because the row is required', async () => {
|
|
2364
|
-
// Could-not-run is not a pass. `failedRows` is `rows.filter(r => r.required
|
|
2365
|
-
// && !r.asserted)`, and this row is required, so the word changes what the
|
|
2366
|
-
// operator reads and not whether the run succeeds.
|
|
2367
|
-
rosterJsonState = 'unresolvable';
|
|
2368
|
-
rosterSourceState = 'unresolvable';
|
|
2369
|
-
const { failure } = await provision();
|
|
2370
|
-
expect(line(9)).toMatch(/row 9: could not run/);
|
|
2371
|
-
expect(failure).not.toBeNull();
|
|
2372
|
-
expect(failure.message).toContain('row 9:');
|
|
2373
|
-
});
|
|
2374
|
-
it('row 9 stays partly asserted when the source names the team, even on an unreadable JSON read', async () => {
|
|
2375
|
-
// The one state where something DID hold: the array in rosters.ts on the ref
|
|
2376
|
-
// names the team, so the row has read a fact about it. Could-not-run and
|
|
2377
|
-
// partly-asserted are disjoint here rather than left to the renderer's order.
|
|
2378
|
-
rosterJsonState = 'unresolvable';
|
|
2379
|
-
rosterSourceState = 'present';
|
|
2380
|
-
await provision();
|
|
2381
|
-
expect(line(9)).toMatch(/row 9: partly asserted/);
|
|
2382
|
-
expect(line(9)).not.toContain('could not run');
|
|
2383
|
-
expect(line(9)).toContain('generated JSON stale');
|
|
2384
|
-
});
|
|
2385
|
-
it('row 9 keeps not-asserted for a ref it read that holds no entry', async () => {
|
|
2386
|
-
// The other half of the discrimination. A ref that resolved and holds no
|
|
2387
|
-
// entry is a failed check, not a check that could not run, and its remedy is
|
|
2388
|
-
// the edit.
|
|
2389
|
-
rosterJsonState = 'absent';
|
|
2390
|
-
rosterSourceState = 'absent';
|
|
2391
|
-
await provision();
|
|
2392
|
-
expect(line(9)).toMatch(/row 9: not asserted/);
|
|
2393
|
-
expect(line(9)).not.toContain('could not run');
|
|
2394
|
-
expect(line(9)).toContain(`add newteam to the project's array in PROVISIONED_ROSTERS`);
|
|
2395
|
-
});
|
|
2396
|
-
it('reads origin/<base> once per artifact and never writes a roster', async () => {
|
|
2397
|
-
// A Key Vault project: row 10 asks the vault, unchanged by #288.
|
|
2398
|
-
credentialProjects = new Set();
|
|
2399
|
-
// The reads take the fetch result from step 0c. No new network call, and
|
|
2400
|
-
// nothing here edits rosters.ts or the generated file.
|
|
2401
|
-
rosterJsonState = 'present';
|
|
2402
|
-
await provision();
|
|
2403
|
-
expect(vi.mocked(rosterEntryOnRef)).toHaveBeenCalledWith(root, 'newteam', expect.objectContaining({ project: 'mx-agent', baseBranch: 'main' }));
|
|
2404
|
-
// Asked only when the generated file does not hold the slug.
|
|
2405
|
-
expect(vi.mocked(rosterSourceHasSlug)).not.toHaveBeenCalled();
|
|
2406
|
-
expect(vi.mocked(vaultTokenPresent)).toHaveBeenCalledWith('mx-agent', 'newteam');
|
|
2407
|
-
});
|
|
2408
|
-
});
|
|
2409
|
-
/**
|
|
2410
|
-
* Row 7 — the roleguide on the base branch (#406 part 1).
|
|
2411
|
-
*
|
|
2412
|
-
* The row was hard-coded `asserted: false` with the detail "not checked here",
|
|
2413
|
-
* so it reported the same verdict for every team on every run: it could not
|
|
2414
|
-
* fail, and it could not hold. It reads `origin/<baseBranch>` now, and these
|
|
2415
|
-
* tests pin the three outcomes the read has and the words each one prints.
|
|
2416
|
-
*
|
|
2417
|
-
* `required` stays false, and that is asserted here rather than left implicit.
|
|
2418
|
-
* `provision` generates a team's first roleguide itself, so on a generated
|
|
2419
|
-
* creation the file is by definition not yet on the base branch when this row
|
|
2420
|
-
* reads, and a required row would refuse a run team-builder's own process
|
|
2421
|
-
* expects to succeed.
|
|
2422
|
-
*/
|
|
2423
|
-
describe('completion row 7 — roleguide on the base branch', () => {
|
|
2424
|
-
function row7For(state, extra = {}) {
|
|
2425
|
-
roleguideOnBaseState = state;
|
|
2426
|
-
stdout.length = 0;
|
|
2427
|
-
const rows = checkCompletionRows({
|
|
2428
|
-
slug: 'newteam',
|
|
2429
|
-
projectSlug: 'mx-agent',
|
|
2430
|
-
baseBranch: 'main',
|
|
2431
|
-
roleguideInWorktree: null,
|
|
2432
|
-
catalogEntry: join(root, 'nope.md'),
|
|
2433
|
-
memoryNames: MEMORIES,
|
|
2434
|
-
mxAvailable: false,
|
|
2435
|
-
projectRoot: root,
|
|
2436
|
-
fetchOk: true,
|
|
2437
|
-
roleguideOnBasePath: RG,
|
|
2438
|
-
...extra,
|
|
2439
|
-
});
|
|
2440
|
-
printCompletionRows(rows);
|
|
2441
|
-
const row = rows.find((r) => r.n === 7);
|
|
2442
|
-
return { row, line: stdout.find((l) => l.includes('row 7:')) ?? '' };
|
|
2443
|
-
}
|
|
2444
|
-
it('asserts when the roleguide is on the base branch, and names the file it read', () => {
|
|
2445
|
-
const { row, line } = row7For('present');
|
|
2446
|
-
expect(row.asserted).toBe(true);
|
|
2447
|
-
expect(row.couldNotRun).toBe(false);
|
|
2448
|
-
expect(row.detail).toBe(`roleguide on origin/main: ${RG}`);
|
|
2449
|
-
expect(line).toContain('asserted');
|
|
2450
|
-
expect(line).not.toContain('could not run');
|
|
2451
|
-
});
|
|
2452
|
-
it('does not assert when the base branch resolves and holds no roleguide, and names the remedy', () => {
|
|
2453
|
-
const { row, line } = row7For('absent');
|
|
2454
|
-
expect(row.asserted).toBe(false);
|
|
2455
|
-
expect(row.couldNotRun).toBe(false);
|
|
2456
|
-
expect(row.detail).toBe(`not on origin/main: ${RG} — commit it and merge the step 6a PR`);
|
|
2457
|
-
expect(line).toContain('not asserted');
|
|
2458
|
-
expect(line).not.toContain('could not run');
|
|
2459
|
-
});
|
|
2460
|
-
it('reports could-not-run on a read that failed, and never as absent', () => {
|
|
2461
|
-
// The whole point of the three-value read. A failed fetch leaves a
|
|
2462
|
-
// remote-tracking ref of unknown age, and the `absent` remedy above would
|
|
2463
|
-
// tell the operator to merge a file that is already on the base branch.
|
|
2464
|
-
const { row, line } = row7For('unresolvable');
|
|
2465
|
-
expect(row.asserted).toBe(false);
|
|
2466
|
-
expect(row.couldNotRun).toBe(true);
|
|
2467
|
-
expect(row.detail).toBe('could not run: origin/main could not be read, so whether the roleguide is merged '
|
|
2468
|
-
+ 'is not established either way');
|
|
2469
|
-
expect(row.detail).not.toContain('commit it and merge');
|
|
2470
|
-
expect(line).toContain('could not run');
|
|
2471
|
-
expect(line).not.toContain('not asserted');
|
|
2472
|
-
});
|
|
2473
|
-
it('reports could-not-run when no roleguide was copied, so the row has no path to read', () => {
|
|
2474
|
-
const { row } = row7For('present', { roleguideOnBasePath: undefined });
|
|
2475
|
-
expect(row.asserted).toBe(false);
|
|
2476
|
-
expect(row.couldNotRun).toBe(true);
|
|
2477
|
-
expect(row.detail).toContain('no roleguide was copied into the worktree (row 1)');
|
|
2478
|
-
// The mocked reader would have said `present`. A row with no path must not
|
|
2479
|
-
// reach it at all.
|
|
2480
|
-
expect(vi.mocked(roleguideOnOriginMain)).not.toHaveBeenCalled();
|
|
2481
|
-
});
|
|
2482
|
-
it('reports could-not-run with no calling checkout to read from', () => {
|
|
2483
|
-
const { row } = row7For('present', { projectRoot: undefined });
|
|
2484
|
-
expect(row.asserted).toBe(false);
|
|
2485
|
-
expect(row.couldNotRun).toBe(true);
|
|
2486
|
-
expect(row.detail).toBe('could not run: no calling checkout to read the base branch from');
|
|
2487
|
-
expect(vi.mocked(roleguideOnOriginMain)).not.toHaveBeenCalled();
|
|
2488
|
-
});
|
|
2489
|
-
it('stays not required on all three outcomes', () => {
|
|
2490
|
-
// Deliberate, and it is what keeps a generated-roleguide creation able to
|
|
2491
|
-
// succeed. `failedRows` is `rows.filter(r => r.required && !r.asserted)`, so
|
|
2492
|
-
// a required row 7 would refuse every provision that writes the roleguide.
|
|
2493
|
-
for (const state of ['present', 'absent', 'unresolvable']) {
|
|
2494
|
-
expect(row7For(state).row.required).toBe(false);
|
|
2495
|
-
}
|
|
2496
|
-
});
|
|
2497
|
-
it('reads the base branch the project configures, and the path the copy wrote', () => {
|
|
2498
|
-
row7For('present', { baseBranch: 'release', roleguideOnBasePath: 'guides/other.md' });
|
|
2499
|
-
expect(vi.mocked(roleguideOnOriginMain)).toHaveBeenCalledWith(root, 'guides/other.md', expect.objectContaining({ baseBranch: 'release', fetchOk: true }));
|
|
2500
|
-
});
|
|
2501
|
-
it('passes the run fetch result through, so a failed fetch cannot read as present', () => {
|
|
2502
|
-
row7For('present', { fetchOk: false });
|
|
2503
|
-
expect(vi.mocked(roleguideOnOriginMain)).toHaveBeenCalledWith(root, RG, expect.objectContaining({ fetchOk: false }));
|
|
2504
|
-
});
|
|
2505
|
-
// ── Which of the three causes the could-not-run detail names ───────────────
|
|
2506
|
-
//
|
|
2507
|
-
// One sentence blamed the ref for all three, and two of them are not the
|
|
2508
|
-
// ref's doing (security review 2026-09-04, Consider 1). The operator reads
|
|
2509
|
-
// this string to decide what to do next, and re-running the fetch, fixing the
|
|
2510
|
-
// path and "the ref is unreadable" are three different next actions. All three
|
|
2511
|
-
// are the same could-not-run state: nothing here adds a fourth.
|
|
2512
|
-
it('names the failed fetch, not the ref, when the fetch is what did not happen', () => {
|
|
2513
|
-
const { row, line } = row7For('unresolvable', { fetchOk: false });
|
|
2514
|
-
expect(row.couldNotRun).toBe(true);
|
|
2515
|
-
expect(row.detail).toContain('the fetch of origin failed this run');
|
|
2516
|
-
expect(row.detail).toContain('Re-run when the remote is reachable');
|
|
2517
|
-
// Not the sentence for a ref that was read and would not answer.
|
|
2518
|
-
expect(row.detail).not.toContain('origin/main could not be read');
|
|
2519
|
-
expect(row.detail).not.toContain('commit it and merge');
|
|
2520
|
-
expect(line).toContain('could not run');
|
|
2521
|
-
});
|
|
2522
|
-
it('names the path when the path is what the reader refuses', () => {
|
|
2523
|
-
// `isReadableRepoPath` refuses a component beginning with a dot, so this
|
|
2524
|
-
// path is never read and blaming the ref would send the operator to the
|
|
2525
|
-
// wrong place. The rule here is the real one, not a stub.
|
|
2526
|
-
const { row } = row7For('unresolvable', {
|
|
2527
|
-
roleguideOnBasePath: '.hidden/roleguides/newteam-leader.md',
|
|
2528
|
-
});
|
|
2529
|
-
expect(row.couldNotRun).toBe(true);
|
|
2530
|
-
expect(row.detail).toContain('.hidden/roleguides/newteam-leader.md');
|
|
2531
|
-
expect(row.detail).toContain('is not a path this row can read off origin/main');
|
|
2532
|
-
expect(row.detail).not.toContain('origin/main could not be read');
|
|
2533
|
-
expect(row.detail).not.toContain('the fetch of origin failed');
|
|
2534
|
-
});
|
|
2535
|
-
it('blames the ref only when the fetch held and the path is readable', () => {
|
|
2536
|
-
const { row } = row7For('unresolvable');
|
|
2537
|
-
expect(row.couldNotRun).toBe(true);
|
|
2538
|
-
expect(row.detail).toBe('could not run: origin/main could not be read, so whether the roleguide is merged '
|
|
2539
|
-
+ 'is not established either way');
|
|
2540
|
-
});
|
|
2541
|
-
it('all three causes stay one could-not-run state, and none names the absent remedy', () => {
|
|
2542
|
-
const causes = [
|
|
2543
|
-
row7For('unresolvable', { fetchOk: false }),
|
|
2544
|
-
row7For('unresolvable', { roleguideOnBasePath: '.hidden/x.md' }),
|
|
2545
|
-
row7For('unresolvable'),
|
|
2546
|
-
];
|
|
2547
|
-
for (const { row, line } of causes) {
|
|
2548
|
-
expect(row.asserted).toBe(false);
|
|
2549
|
-
expect(row.couldNotRun).toBe(true);
|
|
2550
|
-
expect(row.required).toBe(false);
|
|
2551
|
-
expect(row.detail.startsWith('could not run:')).toBe(true);
|
|
2552
|
-
expect(row.detail).not.toContain('commit it and merge');
|
|
2553
|
-
expect(line).toContain('could not run');
|
|
2554
|
-
expect(line).not.toContain('not asserted');
|
|
2555
|
-
}
|
|
2556
|
-
// Three causes, three sentences: an operator can tell them apart.
|
|
2557
|
-
expect(new Set(causes.map((c) => c.row.detail)).size).toBe(3);
|
|
2558
|
-
});
|
|
2559
|
-
});
|
|
2560
|
-
/**
|
|
2561
|
-
* Row 13 — no placeholder survives into a provisioned team (#83 B3).
|
|
2562
|
-
*
|
|
2563
|
-
* Provisioning generates the identity slice of a roleguide and leaves every
|
|
2564
|
-
* judgement placeholder literal (#83 B2). Without a required row reading the
|
|
2565
|
-
* result, a team could be created whose mission is `<TEAM_MISSION>` and whose
|
|
2566
|
-
* loop is `<STEP_0_DETAILS>`, under a banner reading Team Created. This row is
|
|
2567
|
-
* what makes the generation safe, so its three outcomes are pinned: asserted at
|
|
2568
|
-
* zero, not asserted with the count and the first five names, and could-not-run
|
|
2569
|
-
* when the file cannot be read.
|
|
2570
|
-
*/
|
|
2571
|
-
describe('completion row 13 — roleguide placeholders', () => {
|
|
2572
|
-
const BASE = {
|
|
2573
|
-
slug: 'newteam',
|
|
2574
|
-
projectSlug: 'mx-agent',
|
|
2575
|
-
baseBranch: 'main',
|
|
2576
|
-
catalogEntry: join(tmpdir(), 'nope.md'),
|
|
2577
|
-
memoryNames: MEMORIES,
|
|
2578
|
-
mxAvailable: false,
|
|
2579
|
-
};
|
|
2580
|
-
function row13For(roleguideInWorktree, extra = {}) {
|
|
2581
|
-
return checkCompletionRows({ ...BASE, roleguideInWorktree, ...extra }).find((r) => r.n === 13);
|
|
2582
|
-
}
|
|
2583
|
-
function writeRoleguide(name, body) {
|
|
2584
|
-
const abs = join(root, name);
|
|
2585
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
2586
|
-
writeFileSync(abs, body);
|
|
2587
|
-
return abs;
|
|
2588
|
-
}
|
|
2589
|
-
it('is asserted when no placeholder remains, and says nothing else', () => {
|
|
2590
|
-
const row = row13For(writeRoleguide('filled.md', OWN_PROJECT));
|
|
2591
|
-
expect(row.label).toBe('roleguide placeholders');
|
|
2592
|
-
expect(row.required).toBe(true);
|
|
2593
|
-
expect(row.asserted).toBe(true);
|
|
2594
|
-
expect(row.detail).toBe('');
|
|
2595
|
-
});
|
|
2596
|
-
it('names the count and the first five when placeholders remain', () => {
|
|
2597
|
-
const abs = writeRoleguide('unfilled.md', [
|
|
2598
|
-
'# Newteam Leader Roleguide',
|
|
2599
|
-
'<TEAM_MISSION>', '<TEAM_MISSION_DETAIL>', '<STEP_0_DETAILS>', '<STEP_1_DETAILS>',
|
|
2600
|
-
'<STEP_2_DETAILS>', '<STEP_3_DETAILS>', '<NORTH_STAR_DESCRIPTION>',
|
|
2601
|
-
].join('\n'));
|
|
2602
|
-
const row = row13For(abs);
|
|
2603
|
-
expect(row.asserted).toBe(false);
|
|
2604
|
-
expect(row.required).toBe(true);
|
|
2605
|
-
expect(row.detail).toBe('7 placeholders remain: <TEAM_MISSION>, <TEAM_MISSION_DETAIL>, <STEP_0_DETAILS>, ' +
|
|
2606
|
-
'<STEP_1_DETAILS>, <STEP_2_DETAILS>, ... (team-builder step 5)');
|
|
2607
|
-
});
|
|
2608
|
-
it('counts a repeated placeholder once and drops the trailing ellipsis at five', () => {
|
|
2609
|
-
const abs = writeRoleguide('few.md', ['<TEAM_MISSION>', '<TEAM_MISSION>', '<STEP_0_DETAILS>'].join('\n'));
|
|
2610
|
-
expect(row13For(abs).detail).toBe('2 placeholders remain: <TEAM_MISSION>, <STEP_0_DETAILS> (team-builder step 5)');
|
|
2611
|
-
});
|
|
2612
|
-
it('ignores prose metavariables the skeleton never ships', () => {
|
|
2613
|
-
// `roleguides/product-leader.md` writes `<N>`, `<X>` and `<YYYYMMDD>` inside
|
|
2614
|
-
// finished sentences about pull request numbers and dates, and
|
|
2615
|
-
// `roleguides/bootstrap-leader.md` writes `<N>`. This row is required, so a
|
|
2616
|
-
// raw `<[A-Z][A-Z0-9_]*>` scan would refuse to provision two of this
|
|
2617
|
-
// repository's own complete roleguides.
|
|
2618
|
-
const abs = writeRoleguide('prose.md', 'Open PR #<N> on <YYYYMMDD>, then re-run step <X>.\n');
|
|
2619
|
-
expect(row13For(abs).asserted).toBe(true);
|
|
2620
|
-
});
|
|
2621
|
-
it('prints the matched tokens only, never the file text around them', () => {
|
|
2622
|
-
// Security pre-ruling B-4 (#83 comment 5380868449): the row's detail reaches
|
|
2623
|
-
// a terminal, so it names tokens the character class matched and nothing
|
|
2624
|
-
// else. `<[A-Z][A-Z0-9_]*>` admits no control byte and no ANSI escape, and
|
|
2625
|
-
// the row never quotes the surrounding line (CWE-117).
|
|
2626
|
-
const abs = writeRoleguide('noisy.md', 'prefix \u001b[31mRED\u001b[0m <TEAM_MISSION> trailing text\n');
|
|
2627
|
-
const row = row13For(abs);
|
|
2628
|
-
expect(row.detail).toBe('1 placeholders remain: <TEAM_MISSION> (team-builder step 5)');
|
|
2629
|
-
expect(row.detail).not.toContain('RED');
|
|
2630
|
-
expect(row.detail).not.toContain('trailing text');
|
|
2631
|
-
expect(row.detail).not.toContain('\u001b');
|
|
2632
|
-
});
|
|
2633
|
-
it('reports an unreadable roleguide as could-not-run, not as filled', () => {
|
|
2634
|
-
// Passed, failed and could-not-run are three outcomes
|
|
2635
|
-
// (mx-agent-system/standards/fail-loud-standard.md).
|
|
2636
|
-
const missing = join(root, 'gone.md');
|
|
2637
|
-
const asDirectory = join(root, 'a-directory.md');
|
|
2638
|
-
mkdirSync(asDirectory, { recursive: true });
|
|
2639
|
-
for (const path of [missing, asDirectory]) {
|
|
2640
|
-
const row = row13For(path);
|
|
2641
|
-
expect(row.asserted).toBe(false);
|
|
2642
|
-
expect(row.required).toBe(true);
|
|
2643
|
-
expect(row.detail).toContain('could not run');
|
|
2644
|
-
expect(row.detail).toContain(path);
|
|
2645
|
-
}
|
|
2646
|
-
});
|
|
2647
|
-
it('reports no roleguide copy as could-not-run, pointing at row 1', () => {
|
|
2648
|
-
const row = row13For(null);
|
|
2649
|
-
expect(row.asserted).toBe(false);
|
|
2650
|
-
expect(row.detail).toBe('could not run: no roleguide was copied into the worktree (row 1)');
|
|
2651
|
-
});
|
|
2652
|
-
it('asserts on the bundled team-builder roleguide, which travels unfilled', () => {
|
|
2653
|
-
// The one file provisioned with its placeholders intact: templates.ts copies
|
|
2654
|
-
// it into projects whose slug it cannot know (#34). The caller decides this
|
|
2655
|
-
// with isPlaceholderRoleguide, on the exact path and the exact slug.
|
|
2656
|
-
const abs = writeRoleguide('team-builder.md', '<PROJECT_SLUG>-<TEAM>-leader-state\n<STEP_0_DETAILS>\n');
|
|
2657
|
-
const row = row13For(abs, { unfilledPlaceholdersAllowed: true });
|
|
2658
|
-
expect(row.asserted).toBe(true);
|
|
2659
|
-
expect(row.detail).toContain('travels unfilled by design');
|
|
2660
|
-
});
|
|
2661
|
-
/**
|
|
2662
|
-
* The draft marker (#71, red-team finding 5).
|
|
2663
|
-
*
|
|
2664
|
-
* `team-builder.md:271` marks a draft with an HTML comment holding the words
|
|
2665
|
-
* DRAFT and pending review, joined by U+2014. Until v11 nothing read that
|
|
2666
|
-
* marker: a grep over `create.ts` and `templates.ts`
|
|
2667
|
-
* returned template prose only. Step 3 also wrote its draft to the roleguide
|
|
2668
|
-
* path itself, so a marked draft could reach a step 6a commit and provision as
|
|
2669
|
-
* a finished roleguide. Row 13 refuses it now, and step 3 writes to
|
|
2670
|
-
* `<slug>-leader.draft-notes.md` instead.
|
|
2671
|
-
*/
|
|
2672
|
-
const MARKER = '<!-- DRAFT \u2014 pending review \u2014 do not use until approved -->';
|
|
2673
|
-
const MARKER_DETAIL = 'draft marker present: remove the DRAFT line after review ' +
|
|
2674
|
-
'(team-builder step 3, the checkpoint rule)';
|
|
2675
|
-
it('refuses a roleguide holding the draft marker, naming the line to remove', () => {
|
|
2676
|
-
const abs = writeRoleguide('marked.md', [MARKER, OWN_PROJECT].join('\n'));
|
|
2677
|
-
const row = row13For(abs);
|
|
2678
|
-
expect(row.asserted).toBe(false);
|
|
2679
|
-
expect(row.required).toBe(true);
|
|
2680
|
-
expect(row.detail).toBe(MARKER_DETAIL);
|
|
2681
|
-
});
|
|
2682
|
-
it('refuses the hyphen, en dash and colon spellings, in any case', () => {
|
|
2683
|
-
// The shipped marker uses U+2014, and this project's writing standard bans
|
|
2684
|
-
// em dashes, so an agent retyping the line writes a hyphen. An editor that
|
|
2685
|
-
// converts dashes writes U+2013. All three are the same draft (security
|
|
2686
|
-
// pre-ruling SF-1 on #106).
|
|
2687
|
-
const spellings = [
|
|
2688
|
-
'<!-- DRAFT \u2014 pending review -->',
|
|
2689
|
-
'<!-- DRAFT - pending review -->',
|
|
2690
|
-
'<!-- DRAFT \u2013 pending review -->',
|
|
2691
|
-
'<!-- DRAFT: pending review -->',
|
|
2692
|
-
'<!-- Draft - Pending Review -->',
|
|
2693
|
-
'<!--DRAFT-pending review-->',
|
|
2694
|
-
];
|
|
2695
|
-
for (const [n, line] of spellings.entries()) {
|
|
2696
|
-
const row = row13For(writeRoleguide(`spelling-${n}.md`, [line, OWN_PROJECT].join('\n')));
|
|
2697
|
-
expect(row.asserted).toBe(false);
|
|
2698
|
-
expect(row.detail).toBe(MARKER_DETAIL);
|
|
2699
|
-
}
|
|
2700
|
-
});
|
|
2701
|
-
it('cites a step that holds the removal rule, resolved against the shipped file', () => {
|
|
2702
|
-
// A refusal that names a step is only as useful as the step. The detail cited
|
|
2703
|
-
// 5b, which is about filling tokens and says nothing about the marker
|
|
2704
|
-
// (bar-raiser Must Fix on #106). This resolves the citation rather than
|
|
2705
|
-
// matching the string: it reads the step number out of the detail, finds that
|
|
2706
|
-
// section in the roleguide every project ships, and asserts the section holds
|
|
2707
|
-
// the marker and an instruction to delete the line.
|
|
2708
|
-
const cited = /team-builder step (\d+)/.exec(__testing.DRAFT_MARKER_DETAIL);
|
|
2709
|
-
expect(cited).not.toBeNull();
|
|
2710
|
-
const heading = new RegExp(`^### Step ${cited[1]}: `, 'm');
|
|
2711
|
-
const start = TEAM_BUILDER_ROLEGUIDE.search(heading);
|
|
2712
|
-
expect(start).toBeGreaterThan(-1);
|
|
2713
|
-
const rest = TEAM_BUILDER_ROLEGUIDE.slice(start + 1);
|
|
2714
|
-
const end = rest.search(/^### Step /m);
|
|
2715
|
-
const section = end === -1 ? rest : rest.slice(0, end);
|
|
2716
|
-
expect(section).toMatch(__testing.DRAFT_MARKER_RE);
|
|
2717
|
-
expect(section).toMatch(/delete the line|remove the DRAFT line/i);
|
|
2718
|
-
});
|
|
2719
|
-
it('states the detail as a constant and matches the marker the template ships', () => {
|
|
2720
|
-
expect(__testing.DRAFT_MARKER_DETAIL).toBe(MARKER_DETAIL);
|
|
2721
|
-
expect(__testing.DRAFT_MARKER_RE.test(MARKER)).toBe(true);
|
|
2722
|
-
// No `g` flag: a shared regex with `lastIndex` state answers differently on
|
|
2723
|
-
// alternate calls, and this one is asked twice per run (row and 6c gate).
|
|
2724
|
-
expect(__testing.DRAFT_MARKER_RE.global).toBe(false);
|
|
2725
|
-
});
|
|
2726
|
-
it('reports the marker rather than the count when both are present', () => {
|
|
2727
|
-
// One row prints one detail. Removing the DRAFT line comes first, because a
|
|
2728
|
-
// marked file is a draft whatever its token count says.
|
|
2729
|
-
const abs = writeRoleguide('marked-unfilled.md', [MARKER, '<TEAM_MISSION>'].join('\n'));
|
|
2730
|
-
expect(row13For(abs).detail).toBe(MARKER_DETAIL);
|
|
2731
|
-
});
|
|
2732
|
-
it('refuses a marker inside a code block, an accepted over-refusal', () => {
|
|
2733
|
-
// The scan is one literal `includes` over the whole file, so a roleguide
|
|
2734
|
-
// quoting the marker in a fenced block is refused too. That costs one edit;
|
|
2735
|
-
// the alternative parses markdown to decide, and misses a real draft whose
|
|
2736
|
-
// marker is indented.
|
|
2737
|
-
const abs = writeRoleguide('quoting.md', ['```', MARKER, '```', OWN_PROJECT].join('\n'));
|
|
2738
|
-
expect(row13For(abs).asserted).toBe(false);
|
|
2739
|
-
expect(row13For(abs).detail).toBe(MARKER_DETAIL);
|
|
2740
|
-
});
|
|
2741
|
-
it('refuses a marker inside a blockquote, the other way prose quotes it', () => {
|
|
2742
|
-
// A roleguide that quotes the step 3 instruction writes it as a blockquote
|
|
2743
|
-
// as readily as a fenced block. The scan reads the whole file, so both
|
|
2744
|
-
// refuse (red-team Minor 1). Same accepted over-refusal as the fence case.
|
|
2745
|
-
const abs = writeRoleguide('blockquoted.md', ['> ' + MARKER, '', OWN_PROJECT].join('\n'));
|
|
2746
|
-
expect(row13For(abs).asserted).toBe(false);
|
|
2747
|
-
expect(row13For(abs).detail).toBe(MARKER_DETAIL);
|
|
2748
|
-
});
|
|
2749
|
-
it('leaves a roleguide without the marker exactly as before', () => {
|
|
2750
|
-
// The two halves on separate lines, a separator the pattern excludes, and
|
|
2751
|
-
// the word DRAFT in ordinary prose: none of these is the marker. `[ \t]`
|
|
2752
|
-
// rather than `\s` is what keeps the two-line case out.
|
|
2753
|
-
const bodies = [
|
|
2754
|
-
'This section is a DRAFT of the routing table.\npending review by the owner.\n',
|
|
2755
|
-
'DRAFT / pending review is the old wording.\n',
|
|
2756
|
-
'The draft and the pending review are two separate steps.\n',
|
|
2757
|
-
];
|
|
2758
|
-
for (const [n, body] of bodies.entries()) {
|
|
2759
|
-
const row = row13For(writeRoleguide(`clean-${n}.md`, [body, OWN_PROJECT].join('\n')));
|
|
2760
|
-
expect(row.asserted).toBe(true);
|
|
2761
|
-
expect(row.detail).toBe('');
|
|
2762
|
-
}
|
|
2763
|
-
});
|
|
2764
|
-
it('keeps the team-builder exemption, on the bundled bytes that hold the marker', () => {
|
|
2765
|
-
// `team-builder.md` documents the marker, so the roleguide `mx-agent new
|
|
2766
|
-
// project` ships holds the literal. The exemption returns before the marker
|
|
2767
|
-
// scan; the other order refuses `provision --name team-builder` in every
|
|
2768
|
-
// project, forever, on the file the product ships (security MF-2 on #106).
|
|
2769
|
-
// The real embedded constant, not a fixture, because that is the file.
|
|
2770
|
-
const abs = writeRoleguide('team-builder.md', TEAM_BUILDER_ROLEGUIDE);
|
|
2771
|
-
expect(TEAM_BUILDER_ROLEGUIDE).toMatch(__testing.DRAFT_MARKER_RE);
|
|
2772
|
-
expect(row13For(abs, { unfilledPlaceholdersAllowed: true }).asserted).toBe(true);
|
|
2773
|
-
// Without the exemption the same bytes refuse, which is what the ordering
|
|
2774
|
-
// protects against.
|
|
2775
|
-
expect(row13For(abs).asserted).toBe(false);
|
|
2776
|
-
expect(row13For(abs).detail).toBe(MARKER_DETAIL);
|
|
2777
|
-
});
|
|
2778
|
-
});
|
|
2779
|
-
describe('completion row 13 — end to end', () => {
|
|
2780
|
-
/** Provision `newteam` from a roleguide with the given body. */
|
|
2781
|
-
async function provisionFrom(body) {
|
|
2782
|
-
const abs = join(root, RG);
|
|
2783
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
2784
|
-
writeFileSync(abs, body);
|
|
2785
|
-
try {
|
|
2786
|
-
await runCreate({ roleguide: RG, name: 'newteam', projectRoot: root });
|
|
2787
|
-
return null;
|
|
2788
|
-
}
|
|
2789
|
-
catch (err) {
|
|
2790
|
-
if (err instanceof CompletionCheckError)
|
|
2791
|
-
return err;
|
|
2792
|
-
throw err;
|
|
2793
|
-
}
|
|
2794
|
-
}
|
|
2795
|
-
it('exits INCOMPLETE naming row 13, the count and the first five tokens', async () => {
|
|
2796
|
-
const failure = await provisionFrom([
|
|
2797
|
-
'# Newteam Leader Roleguide',
|
|
2798
|
-
'',
|
|
2799
|
-
'Mission: <TEAM_MISSION>',
|
|
2800
|
-
'<STEP_0_DETAILS>',
|
|
2801
|
-
'<NORTH_STAR_DESCRIPTION>',
|
|
2802
|
-
'',
|
|
2803
|
-
BEHAVIORAL_START_MARKER,
|
|
2804
|
-
'## Decision Authority',
|
|
2805
|
-
'',
|
|
2806
|
-
'- Ship without asking when the data is clear.',
|
|
2807
|
-
BEHAVIORAL_END_MARKER,
|
|
2808
|
-
].join('\n'));
|
|
2809
|
-
expect(failure).not.toBeNull();
|
|
2810
|
-
expect(failure.message).toContain('Provisioning INCOMPLETE');
|
|
2811
|
-
expect(failure.message).toContain('row 13: roleguide placeholders');
|
|
2812
|
-
expect(failure.message).toContain('3 placeholders remain: <TEAM_MISSION>, <STEP_0_DETAILS>, <NORTH_STAR_DESCRIPTION> ' +
|
|
2813
|
-
'(team-builder step 5)');
|
|
2814
|
-
// The worktree stays, so the operator fills the file and re-runs (#5).
|
|
2815
|
-
expect(existsSync(join(root, WORKTREE))).toBe(true);
|
|
2816
|
-
});
|
|
2817
|
-
it('asserts row 13 when the same roleguide is filled', async () => {
|
|
2818
|
-
const failure = await provisionFrom(OWN_PROJECT);
|
|
2819
|
-
expect(failure).toBeNull();
|
|
2820
|
-
expect(rowLines()[13]).toMatch(/row 13: asserted/);
|
|
2821
|
-
expect(rowLines()[13]).toContain('roleguide placeholders');
|
|
2822
|
-
});
|
|
2823
|
-
it('exits INCOMPLETE on a filled roleguide that still holds the draft marker', async () => {
|
|
2824
|
-
const failure = await provisionFrom(['<!-- DRAFT \u2014 pending review \u2014 do not use until approved -->', OWN_PROJECT].join('\n'));
|
|
2825
|
-
expect(failure).not.toBeNull();
|
|
2826
|
-
expect(failure.message).toContain('row 13: roleguide placeholders');
|
|
2827
|
-
expect(failure.message).toContain(__testing.DRAFT_MARKER_DETAIL);
|
|
2828
|
-
expect(failure.message).toContain('draft marker present');
|
|
2829
|
-
// Row 13 refuses, so step 6c holds the three memory names back for the run
|
|
2830
|
-
// that passes (#90 red-team Critical).
|
|
2831
|
-
expect(failure.message).toContain('memories not created');
|
|
2832
|
-
});
|
|
2833
|
-
it('never reads the step 3 notes file, marker and all', async () => {
|
|
2834
|
-
// `team-builder.md` step 3 writes the interview to
|
|
2835
|
-
// `<slug>-leader.draft-notes.md` beside the roleguide, marker on line 1.
|
|
2836
|
-
// Provisioning opens the roleguide path it was given and nothing else in
|
|
2837
|
-
// that directory, so the notes file cannot refuse a finished roleguide.
|
|
2838
|
-
const notes = join(root, 'mx-agent-system/roleguides/newteam-leader.draft-notes.md');
|
|
2839
|
-
mkdirSync(dirname(notes), { recursive: true });
|
|
2840
|
-
writeFileSync(notes, ['<!-- DRAFT \u2014 pending review \u2014 do not use until approved -->', 'Q1: newteam'].join('\n'));
|
|
2841
|
-
const failure = await provisionFrom(OWN_PROJECT);
|
|
2842
|
-
expect(failure).toBeNull();
|
|
2843
|
-
expect(rowLines()[13]).toMatch(/row 13: asserted/);
|
|
2844
|
-
expect(existsSync(notes)).toBe(true);
|
|
2845
|
-
});
|
|
2846
|
-
});
|
|
2847
|
-
/**
|
|
2848
|
-
* The refused first run must leave the three memory names free (red-team
|
|
2849
|
-
* Critical on #90).
|
|
2850
|
-
*
|
|
2851
|
-
* `team-builder.md` step 5a runs provisioning once to generate the roleguide,
|
|
2852
|
-
* and that run is refused at row 13 by design. Step 7 ran anyway and created the
|
|
2853
|
-
* three named memories. `bootstrapTeamMemories` refuses to create over a taken
|
|
2854
|
-
* name (`lib/memory.ts:645-659`), correctly, so the run that finally passed row
|
|
2855
|
-
* 13 found all three names taken and could never assert rows 3 to 5. The
|
|
2856
|
-
* documented order could not finish, and no re-run clears it: the names stay
|
|
2857
|
-
* taken on every later pass.
|
|
2858
|
-
*
|
|
2859
|
-
* The fix is a gate, and this is the chain that proves it.
|
|
2860
|
-
*/
|
|
2861
|
-
describe('the run refused at row 13 creates nothing durable (#90 red-team Critical)', () => {
|
|
2862
|
-
const UNFILLED = [
|
|
2863
|
-
'# Newteam Leader Roleguide',
|
|
2864
|
-
'',
|
|
2865
|
-
'Mission: <TEAM_MISSION>',
|
|
2866
|
-
'<STEP_0_DETAILS>',
|
|
2867
|
-
'',
|
|
2868
|
-
BEHAVIORAL_START_MARKER,
|
|
2869
|
-
'## Decision Authority',
|
|
2870
|
-
'',
|
|
2871
|
-
'- Ship without asking when the data is clear.',
|
|
2872
|
-
BEHAVIORAL_END_MARKER,
|
|
2873
|
-
].join('\n');
|
|
2874
|
-
async function provisionFrom(body) {
|
|
2875
|
-
const abs = join(root, RG);
|
|
2876
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
2877
|
-
writeFileSync(abs, body);
|
|
2878
|
-
try {
|
|
2879
|
-
await runCreate({ roleguide: RG, name: 'newteam', projectRoot: root });
|
|
2880
|
-
return null;
|
|
2881
|
-
}
|
|
2882
|
-
catch (err) {
|
|
2883
|
-
if (err instanceof CompletionCheckError)
|
|
2884
|
-
return err;
|
|
2885
|
-
throw err;
|
|
2886
|
-
}
|
|
2887
|
-
}
|
|
2888
|
-
it('run 1 creates no memories, and run 2 then asserts rows 3 to 5', async () => {
|
|
2889
|
-
const { bootstrapTeamMemories } = await import('../lib/memory.js');
|
|
2890
|
-
// ── Run 1: the step 5a run. Refused at row 13.
|
|
2891
|
-
const first = await provisionFrom(UNFILLED);
|
|
2892
|
-
expect(first).not.toBeNull();
|
|
2893
|
-
expect(first.message).toContain('row 13: roleguide placeholders');
|
|
2894
|
-
expect(vi.mocked(bootstrapTeamMemories)).not.toHaveBeenCalled();
|
|
2895
|
-
for (const n of [3, 4, 5]) {
|
|
2896
|
-
expect(first.message).toContain(`row ${n}: named memory mx-agent-newteam-${n === 3 ? 'leader-state' : n === 4 ? 'iteration-log' : 'known-issues'} — memories not created; they are created on the run that passes row 13`);
|
|
2897
|
-
}
|
|
2898
|
-
// The operator fills the tokens and removes the worktree the refused run
|
|
2899
|
-
// left, which is what step 6b tells them to do with `git worktree remove`.
|
|
2900
|
-
rmSync(join(root, WORKTREE), { recursive: true, force: true });
|
|
2901
|
-
// ── Run 2: the step 6b run. Nothing is in its way.
|
|
2902
|
-
const second = await provisionFrom(OWN_PROJECT);
|
|
2903
|
-
expect(second).toBeNull();
|
|
2904
|
-
expect(vi.mocked(bootstrapTeamMemories)).toHaveBeenCalledTimes(1);
|
|
2905
|
-
// `stdout` holds both runs, so the second run's rows are the last sixteen.
|
|
2906
|
-
const runTwoRows = rowLines().slice(-16);
|
|
2907
|
-
for (const n of [3, 4, 5]) {
|
|
2908
|
-
expect(runTwoRows[n]).toMatch(new RegExp(`row ${n}: asserted`));
|
|
2909
|
-
}
|
|
2910
|
-
expect(runTwoRows[13]).toMatch(/row 13: asserted/);
|
|
2911
|
-
});
|
|
2912
|
-
it('run 1 writes no catalog entry into a project with no origin', async () => {
|
|
2913
|
-
// `writeTeamCatalog` is an unconditional write. On a refused run it would put
|
|
2914
|
-
// a placeholder entry in the project, and the next run would write over
|
|
2915
|
-
// whatever the operator edited in between.
|
|
2916
|
-
hasOrigin = false;
|
|
2917
|
-
const first = await provisionFrom(UNFILLED);
|
|
2918
|
-
expect(first).not.toBeNull();
|
|
2919
|
-
expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(false);
|
|
2920
|
-
});
|
|
2921
|
-
it('names the memories as not created rather than as missing', async () => {
|
|
2922
|
-
// Passed, failed and could-not-run are three outcomes, and "not attempted on
|
|
2923
|
-
// purpose" is not "the write failed"
|
|
2924
|
-
// (mx-agent-system/standards/fail-loud-standard.md).
|
|
2925
|
-
const first = await provisionFrom(UNFILLED);
|
|
2926
|
-
expect(first.message).not.toContain('mx returned no such memory');
|
|
2927
|
-
expect(first.message).not.toContain('could not run: mx CLI not found');
|
|
2928
|
-
});
|
|
2929
|
-
});
|
|
2930
|
-
describe('the advisory line for unrecognized bracketed tokens (#90 red-team Major 2)', () => {
|
|
2931
|
-
it('names tokens in neither the skeleton set nor the prose allowlist', () => {
|
|
2932
|
-
const found = __testing.unrecognizedBracketTokens('Mission: <TEAM_MISSION>. Renamed: <Team Mission>. Prose: <N> and <path>. Invented: <MISSION_2>.');
|
|
2933
|
-
// `<TEAM_MISSION>` is a shipped placeholder and row 13 already counts it.
|
|
2934
|
-
// `<N>` is the measured prose allowlist. `<path>` starts lowercase, which is
|
|
2935
|
-
// how ordinary prose in these files reads.
|
|
2936
|
-
expect(found).toEqual(['<Team Mission>', '<MISSION_2>']);
|
|
2937
|
-
});
|
|
2938
|
-
it('stays silent on a roleguide that renames nothing', () => {
|
|
2939
|
-
expect(__testing.unrecognizedBracketTokens(OWN_PROJECT)).toEqual([]);
|
|
2940
|
-
});
|
|
2941
|
-
it('prints as an advisory, and fails no row', async () => {
|
|
2942
|
-
const abs = join(root, RG);
|
|
2943
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
2944
|
-
writeFileSync(abs, OWN_PROJECT.replace('# Newteam Leader Roleguide', '# <Team Display Name> Roleguide'));
|
|
2945
|
-
let failure = null;
|
|
2946
|
-
try {
|
|
2947
|
-
await runCreate({ roleguide: RG, name: 'newteam', projectRoot: root });
|
|
2948
|
-
}
|
|
2949
|
-
catch (err) {
|
|
2950
|
-
if (err instanceof CompletionCheckError)
|
|
2951
|
-
failure = err;
|
|
2952
|
-
else
|
|
2953
|
-
throw err;
|
|
2954
|
-
}
|
|
2955
|
-
expect(failure).toBeNull();
|
|
2956
|
-
expect(stdout.join('\n')).toContain('1 unrecognized bracketed tokens: <Team Display Name>');
|
|
2957
|
-
expect(stdout.join('\n')).toContain('confirm these are not renamed placeholders');
|
|
2958
|
-
expect(rowLines()[13]).toMatch(/row 13: asserted/);
|
|
2959
|
-
});
|
|
2960
|
-
});
|
|
2961
|
-
/**
|
|
2962
|
-
* The gate reads what row 13 reads, on the path where the worktree copy is
|
|
2963
|
-
* absent (security review, Should Fix B at 5477d47).
|
|
2964
|
-
*
|
|
2965
|
-
* The first version of the gate asked `contract.raw`, and row 13 asked for the
|
|
2966
|
-
* worktree copy. A marker-carrying roleguide outside the configured roleguides
|
|
2967
|
-
* directory passes step 0 and is refused at the copy, so the copy is absent
|
|
2968
|
-
* while the contract bytes exist. The gate then said "this run is fine", step 7
|
|
2969
|
-
* took the three memory names, and row 13 refused the run anyway. The names
|
|
2970
|
-
* cannot be freed by any later run.
|
|
2971
|
-
*
|
|
2972
|
-
* This is the cheapest of the three paths and it needs no flags.
|
|
2973
|
-
*/
|
|
2974
|
-
describe('a run refused by row 13 could-not-run takes no memory names (#90 Should Fix B)', () => {
|
|
2975
|
-
it('creates no memories when the roleguide could not be copied into the worktree', async () => {
|
|
2976
|
-
const { bootstrapTeamMemories } = await import('../lib/memory.js');
|
|
2977
|
-
// Outside `mx-agent-system/roleguides/`, so step 6b refuses the copy. The
|
|
2978
|
-
// markers are present, so step 0 passes and `contract.raw` is non-null.
|
|
2979
|
-
const rel = '.claude/agents/newteam.md';
|
|
2980
|
-
const abs = join(root, rel);
|
|
2981
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
2982
|
-
writeFileSync(abs, OWN_PROJECT);
|
|
2983
|
-
let failure = null;
|
|
2984
|
-
try {
|
|
2985
|
-
await runCreate({ roleguide: rel, name: 'newteam', projectRoot: root });
|
|
2986
|
-
}
|
|
2987
|
-
catch (err) {
|
|
2988
|
-
if (err instanceof CompletionCheckError)
|
|
2989
|
-
failure = err;
|
|
2990
|
-
else
|
|
2991
|
-
throw err;
|
|
2992
|
-
}
|
|
2993
|
-
// Row 13 refuses the run as could-not-run, which is a refusal like any other.
|
|
2994
|
-
expect(failure).not.toBeNull();
|
|
2995
|
-
expect(failure.message).toContain('row 13: roleguide placeholders — could not run: no roleguide was copied into the worktree (row 1)');
|
|
2996
|
-
// And the names stay free for the run that fixes the path.
|
|
2997
|
-
expect(vi.mocked(bootstrapTeamMemories)).not.toHaveBeenCalled();
|
|
2998
|
-
for (const n of [3, 4, 5]) {
|
|
2999
|
-
expect(failure.message).toContain('memories not created; they are created on the run that passes row 13');
|
|
3000
|
-
expect(rowLines()[n]).toMatch(/not asserted/);
|
|
3001
|
-
}
|
|
3002
|
-
});
|
|
3003
|
-
it('writes no catalog entry on that path either', async () => {
|
|
3004
|
-
hasOrigin = false;
|
|
3005
|
-
const rel = '.claude/agents/newteam.md';
|
|
3006
|
-
const abs = join(root, rel);
|
|
3007
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
3008
|
-
writeFileSync(abs, OWN_PROJECT);
|
|
3009
|
-
try {
|
|
3010
|
-
await runCreate({ roleguide: rel, name: 'newteam', projectRoot: root });
|
|
3011
|
-
}
|
|
3012
|
-
catch (err) {
|
|
3013
|
-
if (!(err instanceof CompletionCheckError))
|
|
3014
|
-
throw err;
|
|
3015
|
-
}
|
|
3016
|
-
expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(false);
|
|
3017
|
-
});
|
|
3018
|
-
});
|
|
3019
|
-
describe('unrecognizedBracketTokens is linear (#90 Should Fix A)', () => {
|
|
3020
|
-
it('completes a 1 MiB input well under the budget', () => {
|
|
3021
|
-
// `Array.includes` on an unbounded accumulator made this quadratic: measured
|
|
3022
|
-
// standalone under node 20 at 7,822.6 ms for this input, against 31.9 ms
|
|
3023
|
-
// with a Set. MAX_ROLEGUIDE_BYTES is 1 MiB
|
|
3024
|
-
// (`lib/behavioral-injection.ts:153`), so this input is the worst case the
|
|
3025
|
-
// reader admits.
|
|
3026
|
-
//
|
|
3027
|
-
// The budget is 1,000 ms, not 200. A timing assertion measures the machine
|
|
3028
|
-
// as much as the code, and the two available in-runner measurements disagree
|
|
3029
|
-
// by 6x. Measured here, inside vitest, over three cold runs: 28.7, 26.8 and
|
|
3030
|
-
// 28.5 ms cold, with repeats between 19.4 and 37.1 ms. The security reviewer
|
|
3031
|
-
// measured the same function in the same runner at 168.6 ms cold, with
|
|
3032
|
-
// repeats of 109.7, 68.8, 45.3, 106.6 and 44.0 ms (#90 comment 5381529777).
|
|
3033
|
-
// Whichever machine a CI run resembles, 1,000 ms still fails the quadratic
|
|
3034
|
-
// version by 7.8x, and it stops the gate failing on a correct function.
|
|
3035
|
-
//
|
|
3036
|
-
// A required gate that fails on correct code teaches people to re-run it and
|
|
3037
|
-
// then to stop reading it, which is the reason ADVISORY_TOKEN_RE was
|
|
3038
|
-
// narrowed to `[A-Z]` two commits ago.
|
|
3039
|
-
const parts = [];
|
|
3040
|
-
let bytes = 0;
|
|
3041
|
-
for (let i = 0; bytes < 1024 * 1024; i++) {
|
|
3042
|
-
const token = `<T${i}> `;
|
|
3043
|
-
parts.push(token);
|
|
3044
|
-
bytes += token.length;
|
|
3045
|
-
}
|
|
3046
|
-
const text = parts.join('');
|
|
3047
|
-
const started = performance.now();
|
|
3048
|
-
const found = __testing.unrecognizedBracketTokens(text);
|
|
3049
|
-
const elapsed = performance.now() - started;
|
|
3050
|
-
// Correctness first: a timing assertion on a wrong answer proves nothing.
|
|
3051
|
-
expect(found.length).toBeGreaterThan(100_000);
|
|
3052
|
-
expect(new Set(found).size).toBe(found.length);
|
|
3053
|
-
expect(elapsed).toBeLessThan(1_000);
|
|
3054
|
-
});
|
|
3055
|
-
});
|
|
3056
|
-
/**
|
|
3057
|
-
* The roleguide's Named Memory Anchors table drives what provision seeds
|
|
3058
|
-
* (#138, plan #190, security pre-ruling comment 5428914046).
|
|
3059
|
-
*
|
|
3060
|
-
* The unit-level parser and validator tests are in
|
|
3061
|
-
* `provision-roleguide-anchors.test.ts`. These are the end-to-end ones: they run
|
|
3062
|
-
* `runCreate` and read the rows and the memory calls it produced, which is where
|
|
3063
|
-
* M1's all-or-nothing, M3's ownership and M5's threading are actually decided.
|
|
3064
|
-
*/
|
|
3065
|
-
describe('anchors from the roleguide table (#190)', () => {
|
|
3066
|
-
/** The fixture roleguide with `extra` suffixes appended to its anchors table. */
|
|
3067
|
-
function withExtras(...suffixes) {
|
|
3068
|
-
const rows = suffixes
|
|
3069
|
-
.map((s) => `| \`mx-agent-newteam-${s}\` | Whatever | Daily |`)
|
|
3070
|
-
.join('\n');
|
|
3071
|
-
return OWN_PROJECT.replace('| `mx-agent-newteam-known-issues` | Issues | When found |', `| \`mx-agent-newteam-known-issues\` | Issues | When found |\n${rows}`);
|
|
3072
|
-
}
|
|
3073
|
-
async function provisionWith(body) {
|
|
3074
|
-
const abs = join(root, RG);
|
|
3075
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
3076
|
-
writeFileSync(abs, body);
|
|
3077
|
-
try {
|
|
3078
|
-
await runCreate({ roleguide: RG, name: 'newteam', projectRoot: root });
|
|
3079
|
-
return { failure: null };
|
|
3080
|
-
}
|
|
3081
|
-
catch (err) {
|
|
3082
|
-
if (err instanceof CompletionCheckError)
|
|
3083
|
-
return { failure: err };
|
|
3084
|
-
if (err instanceof ExitCalled)
|
|
3085
|
-
throw new Error(`unexpected process.exit(${err.code})`);
|
|
3086
|
-
throw err;
|
|
3087
|
-
}
|
|
3088
|
-
}
|
|
3089
|
-
/** Every printed row line, including the lettered `3a` rows. */
|
|
3090
|
-
function allRowLines() {
|
|
3091
|
-
return stdout.filter((l) => /^\s*row \d+[a-z]*:/.test(l));
|
|
3092
|
-
}
|
|
3093
|
-
/**
|
|
3094
|
-
* Everything `logDim` and `logWarning` were called with. `lib/claude.js` is
|
|
3095
|
-
* mocked here, so those lines never reach `stdout` — the conversation line and
|
|
3096
|
-
* the anchor-refusal warning are both written through them.
|
|
3097
|
-
*/
|
|
3098
|
-
async function dimAndWarnLines() {
|
|
3099
|
-
const { logDim, logWarning } = await import('../lib/claude.js');
|
|
3100
|
-
return [
|
|
3101
|
-
...vi.mocked(logDim).mock.calls,
|
|
3102
|
-
...vi.mocked(logWarning).mock.calls,
|
|
3103
|
-
].map((c) => String(c[0]));
|
|
3104
|
-
}
|
|
3105
|
-
// ── Criterion 1: three anchors, unchanged behaviour ────────────────────────
|
|
3106
|
-
it('a table with only the three seeds three, prints no 3a row, and exits 0', async () => {
|
|
3107
|
-
const { failure } = await provisionWith(OWN_PROJECT);
|
|
3108
|
-
expect(failure).toBeNull();
|
|
3109
|
-
const lines = allRowLines();
|
|
3110
|
-
expect(lines).toHaveLength(16);
|
|
3111
|
-
expect(lines.some((l) => /row 3[a-z]:/.test(l))).toBe(false);
|
|
3112
|
-
// The header is what it was before #190, byte for byte.
|
|
3113
|
-
expect(stdout).toContain(' Completion check (15 rows; team-builder.md defines 0 to 14):');
|
|
3114
|
-
expect(await dimAndWarnLines()).toContain('the three memories are in one conversation (threaded-by-this-run)');
|
|
3115
|
-
});
|
|
3116
|
-
// ── Criterion 2 / M5: a fourth anchor is seeded and threaded ───────────────
|
|
3117
|
-
it('a table with four seeds four, prints 3a asserted, and names it', async () => {
|
|
3118
|
-
const { bootstrapTeamMemories } = await import('../lib/memory.js');
|
|
3119
|
-
const { failure } = await provisionWith(withExtras('watch-log'));
|
|
3120
|
-
expect(failure).toBeNull();
|
|
3121
|
-
// The suffix reached the seeding path, once, in table order.
|
|
3122
|
-
const call = vi.mocked(bootstrapTeamMemories).mock.calls[0];
|
|
3123
|
-
expect(call[4]).toMatchObject({ extraAnchorSuffixes: ['watch-log'] });
|
|
3124
|
-
const lines = allRowLines();
|
|
3125
|
-
expect(lines).toHaveLength(17);
|
|
3126
|
-
const row3a = lines.find((l) => l.includes('row 3a:'));
|
|
3127
|
-
expect(row3a).toBeDefined();
|
|
3128
|
-
expect(row3a).toMatch(/row 3a: asserted/);
|
|
3129
|
-
// S4: the accepted anchor is printed by name.
|
|
3130
|
-
expect(row3a).toContain('mx-agent-newteam-watch-log');
|
|
3131
|
-
// I2: rows 0 to 14 keep their numbers, and 3a sits between 5 and 6.
|
|
3132
|
-
expect(lines[5]).toMatch(/row 5:/);
|
|
3133
|
-
expect(lines[6]).toMatch(/row 3a:/);
|
|
3134
|
-
expect(lines[7]).toMatch(/row 6:/);
|
|
3135
|
-
expect(stdout).toContain(' Named memory anchors (1 from the roleguide table):');
|
|
3136
|
-
expect(await dimAndWarnLines()).toContain('the 4 memories are in one conversation (threaded-by-this-run)');
|
|
3137
|
-
});
|
|
3138
|
-
// ── #493: the manual-command filter applies to extras too ─────────────────
|
|
3139
|
-
/** The names of the specs handed to `logManualMemoryCommands`, per call. */
|
|
3140
|
-
async function manualCommandNames() {
|
|
3141
|
-
const { logManualMemoryCommands } = await import('../lib/memory.js');
|
|
3142
|
-
return vi.mocked(logManualMemoryCommands).mock.calls.map((c) => c[0].map((spec) => spec.name));
|
|
3143
|
-
}
|
|
3144
|
-
it('first run, an extra anchor genuinely fails: a create command for that extra (#493)', async () => {
|
|
3145
|
-
const extra = 'mx-agent-newteam-watch-log';
|
|
3146
|
-
createFailsFor = new Set([extra]);
|
|
3147
|
-
const { failure } = await provisionWith(withExtras('watch-log'));
|
|
3148
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
3149
|
-
expect(await manualCommandNames()).toEqual([[extra]]);
|
|
3150
|
-
const warn = (await dimAndWarnLines()).find((l) => l.startsWith('Some team memories are not there'));
|
|
3151
|
-
expect(warn).toContain('Create them manually');
|
|
3152
|
-
expect(warn).not.toContain('already taken');
|
|
3153
|
-
});
|
|
3154
|
-
it('first run, an extra anchor\'s name is held by another team: no create command for it (#493)', async () => {
|
|
3155
|
-
const extra = 'mx-agent-newteam-watch-log';
|
|
3156
|
-
preExistingMemories = new Set([extra]);
|
|
3157
|
-
ownershipFor = new Map([[extra, 'not-this-team']]);
|
|
3158
|
-
// The real module returns ok:false on the taken-name branch.
|
|
3159
|
-
createFailsFor = new Set([extra]);
|
|
3160
|
-
const { failure } = await provisionWith(withExtras('watch-log'));
|
|
3161
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
3162
|
-
expect((await manualCommandNames()).flat()).not.toContain(extra);
|
|
3163
|
-
const warn = (await dimAndWarnLines()).find((l) => l.startsWith('Some team memories are not there'));
|
|
3164
|
-
expect(warn).toBeDefined();
|
|
3165
|
-
expect(warn).not.toContain('Create them manually');
|
|
3166
|
-
expect(warn).toContain('already taken');
|
|
3167
|
-
});
|
|
3168
|
-
it('a spec the seeding path returned no result for gets no create command (#493)', async () => {
|
|
3169
|
-
// Nothing this run holds shows that its create genuinely failed, so there is
|
|
3170
|
-
// no evidence a create is the right action. The leader-state name is taken
|
|
3171
|
-
// so the warning block runs at all.
|
|
3172
|
-
const extra = 'mx-agent-newteam-watch-log';
|
|
3173
|
-
dropExtraResults = new Set(['watch-log']);
|
|
3174
|
-
preExistingMemories = new Set([MEMORIES[0]]);
|
|
3175
|
-
ownershipFor = new Map([[MEMORIES[0], 'not-this-team']]);
|
|
3176
|
-
createFailsFor = new Set([MEMORIES[0]]);
|
|
3177
|
-
const { failure } = await provisionWith(withExtras('watch-log'));
|
|
3178
|
-
expect(failure).toBeInstanceOf(CompletionCheckError);
|
|
3179
|
-
expect((await manualCommandNames()).flat()).not.toContain(extra);
|
|
3180
|
-
expect((await manualCommandNames()).flat()).not.toContain(MEMORIES[0]);
|
|
3181
|
-
});
|
|
3182
|
-
it('two extra anchors print as 3a and 3b, in table order', async () => {
|
|
3183
|
-
const { failure } = await provisionWith(withExtras('watch-log', 'completion-contract'));
|
|
3184
|
-
expect(failure).toBeNull();
|
|
3185
|
-
const lines = allRowLines();
|
|
3186
|
-
expect(lines).toHaveLength(18);
|
|
3187
|
-
expect(lines[6]).toContain('mx-agent-newteam-watch-log');
|
|
3188
|
-
expect(lines[6]).toMatch(/row 3a:/);
|
|
3189
|
-
expect(lines[7]).toContain('mx-agent-newteam-completion-contract');
|
|
3190
|
-
expect(lines[7]).toMatch(/row 3b:/);
|
|
3191
|
-
expect(stdout).toContain(' Named memory anchors (2 from the roleguide table):');
|
|
3192
|
-
});
|
|
3193
|
-
/**
|
|
3194
|
-
* M5. The threading verdict must cover N. With a fixed pair of followers this
|
|
3195
|
-
* would print "in one conversation" while the fourth anchor sat in its own,
|
|
3196
|
-
* which is #93 returning silently.
|
|
3197
|
-
*/
|
|
3198
|
-
it('reports separate conversations when a fourth anchor does not join (M5)', async () => {
|
|
3199
|
-
extraConversationDiverges = true;
|
|
3200
|
-
await provisionWith(withExtras('watch-log'));
|
|
3201
|
-
expect(await dimAndWarnLines()).toContain('the 4 memories are in separate conversations (follower-create-rejected-the-conversation)');
|
|
3202
|
-
});
|
|
3203
|
-
// ── M1: all-or-nothing ────────────────────────────────────────────────────
|
|
3204
|
-
/**
|
|
3205
|
-
* The condition with two recorded incidents behind it. A run that seeded three
|
|
3206
|
-
* and refused on the fourth would leave those three names permanently taken
|
|
3207
|
-
* for the slug, and no later run could ever assert rows 3 to 5.
|
|
3208
|
-
*
|
|
3209
|
-
* Both halves are asserted: zero creates on the refused run, and then a second
|
|
3210
|
-
* run for the SAME slug going green. The second half is what proves no name
|
|
3211
|
-
* was taken; the first alone proves only that nothing was created in a window
|
|
3212
|
-
* (pre-ruling I1).
|
|
3213
|
-
*/
|
|
3214
|
-
it.each([
|
|
3215
|
-
// The unsubstituted row is refused by ROW 13 first, not by the anchor stage:
|
|
3216
|
-
// `<PROJECT_SLUG>` and `<TEAM>` are skeleton placeholders, and the anchor
|
|
3217
|
-
// stage deliberately stays silent on a run row 13 already refuses rather
|
|
3218
|
-
// than printing the same defect twice. The outcome M1 cares about is
|
|
3219
|
-
// identical either way — nothing created, every name free — and the
|
|
3220
|
-
// anchor-stage refusal text for that row is pinned in
|
|
3221
|
-
// `provision-roleguide-anchors.test.ts`.
|
|
3222
|
-
['an unsubstituted template row', '| `<PROJECT_SLUG>-<TEAM>-watch-log` | W | Daily |', 'row 13: roleguide placeholders'],
|
|
3223
|
-
['a prose Name cell', '| the watch log memory | W | Daily |', 'is not a memory name'],
|
|
3224
|
-
['a name in another catalog slug\'s namespace', '| `mx-agent-newteam-extra-watch-log` | W | Daily |', "is in the `newteam-extra` team's namespace"],
|
|
3225
|
-
['a suffix ending in a universal anchor', '| `mx-agent-newteam-other-leader-state` | W | Daily |', 'whose suffix ends in `leader-state`'],
|
|
3226
|
-
['a misshapen suffix', '| `mx-agent-newteam--watch-log` | W | Daily |', 'is empty or misshapen'],
|
|
3227
|
-
])('refuses %s, creates NOTHING, and a corrected re-run then goes green (M1)', async (_label, badRow, expected) => {
|
|
3228
|
-
const { bootstrapTeamMemories, listTeams } = await import('../lib/memory.js')
|
|
3229
|
-
.then(async (m) => ({ ...m, listTeams: (await import('../lib/catalog.js')).listTeams }));
|
|
3230
|
-
// The colliding slug is a fixture catalog entry, not a live team.
|
|
3231
|
-
vi.mocked(listTeams).mockReturnValue([
|
|
3232
|
-
{ slug: 'newteam-extra', displayName: 'x', roleguide: 'x', namedMemories: [], goal: null },
|
|
3233
|
-
]);
|
|
3234
|
-
const bad = OWN_PROJECT.replace('| `mx-agent-newteam-known-issues` | Issues | When found |', `| \`mx-agent-newteam-known-issues\` | Issues | When found |\n${badRow}`);
|
|
3235
|
-
// ── Run 1: refused.
|
|
3236
|
-
const first = await provisionWith(bad);
|
|
3237
|
-
expect(first.failure).not.toBeNull();
|
|
3238
|
-
expect(first.failure.message).toContain(expected);
|
|
3239
|
-
// NOTHING was created. Not the fourth, and not the three either. This is the
|
|
3240
|
-
// half that matters: a run that seeded three and refused on the fourth would
|
|
3241
|
-
// make rows 3 to 5 unassertable for this slug forever.
|
|
3242
|
-
expect(vi.mocked(bootstrapTeamMemories)).not.toHaveBeenCalled();
|
|
3243
|
-
// The operator fixes the table and removes the worktree, per step 6b.
|
|
3244
|
-
rmSync(join(root, WORKTREE), { recursive: true, force: true });
|
|
3245
|
-
vi.mocked(listTeams).mockReturnValue([]);
|
|
3246
|
-
// ── Run 2: the same slug, corrected. Every name was still free.
|
|
3247
|
-
const second = await provisionWith(withExtras('watch-log'));
|
|
3248
|
-
expect(second.failure).toBeNull();
|
|
3249
|
-
expect(vi.mocked(bootstrapTeamMemories)).toHaveBeenCalledTimes(1);
|
|
3250
|
-
const runTwo = allRowLines().slice(-17);
|
|
3251
|
-
for (const n of [3, 4, 5])
|
|
3252
|
-
expect(runTwo[n]).toMatch(new RegExp(`row ${n}: asserted`));
|
|
3253
|
-
expect(runTwo[6]).toMatch(/row 3a: asserted/);
|
|
3254
|
-
});
|
|
3255
|
-
it('says the names stay free, at step 7, where the operator is reading (M1)', async () => {
|
|
3256
|
-
const body = OWN_PROJECT.replace('| `mx-agent-newteam-known-issues` | Issues | When found |', '| `mx-agent-newteam-known-issues` | Issues | When found |\n| the watch log memory | W | Daily |');
|
|
3257
|
-
await provisionWith(body);
|
|
3258
|
-
const lines = await dimAndWarnLines();
|
|
3259
|
-
expect(lines.some((l) => l.includes("Named Memory Anchors table was refused"))).toBe(true);
|
|
3260
|
-
expect(lines.some((l) => l.includes('No memories created.'))).toBe(true);
|
|
3261
|
-
expect(lines.some((l) => l.includes('Every name stays free'))).toBe(true);
|
|
3262
|
-
});
|
|
3263
|
-
it('refuses a table missing iteration-log, by name, and creates nothing (criterion 4)', async () => {
|
|
3264
|
-
const { bootstrapTeamMemories } = await import('../lib/memory.js');
|
|
3265
|
-
const body = OWN_PROJECT.replace('| `mx-agent-newteam-iteration-log` | Log | At iteration close |\n', '');
|
|
3266
|
-
const { failure } = await provisionWith(body);
|
|
3267
|
-
expect(failure).not.toBeNull();
|
|
3268
|
-
expect(failure.message).toContain('mx-agent-newteam-iteration-log');
|
|
3269
|
-
expect(vi.mocked(bootstrapTeamMemories)).not.toHaveBeenCalled();
|
|
3270
|
-
});
|
|
3271
|
-
it('refuses a roleguide with no anchors table at all, and creates nothing', async () => {
|
|
3272
|
-
const { bootstrapTeamMemories } = await import('../lib/memory.js');
|
|
3273
|
-
const body = OWN_PROJECT.split('## Named Memory Anchors')[0];
|
|
3274
|
-
const { failure } = await provisionWith(body);
|
|
3275
|
-
expect(failure).not.toBeNull();
|
|
3276
|
-
expect(failure.message).toContain('no `Named Memory Anchors` heading');
|
|
3277
|
-
expect(vi.mocked(bootstrapTeamMemories)).not.toHaveBeenCalled();
|
|
3278
|
-
});
|
|
3279
|
-
it('writes no catalog entry into an origin-less project on a refused table', async () => {
|
|
3280
|
-
hasOrigin = false;
|
|
3281
|
-
const body = OWN_PROJECT.split('## Named Memory Anchors')[0];
|
|
3282
|
-
await provisionWith(body);
|
|
3283
|
-
expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(false);
|
|
3284
|
-
});
|
|
3285
|
-
// ── M3: ownership on re-provision, for an anchor beyond the three ──────────
|
|
3286
|
-
/**
|
|
3287
|
-
* Criterion 9. The condition standing between a table row and a destructive
|
|
3288
|
-
* upsert: `mx memories create --name` REPLACES content on a name conflict, so
|
|
3289
|
-
* an extra anchor seeded by a direct create would lose the probe, the refusal
|
|
3290
|
-
* and the ownership classification the three already have.
|
|
3291
|
-
*/
|
|
3292
|
-
it('does not overwrite a pre-existing fourth anchor, and row 3a reports name-taken (M3)', async () => {
|
|
3293
|
-
preExistingMemories = new Set(['mx-agent-newteam-watch-log']);
|
|
3294
|
-
preExistingContentFor = (name) => name === 'mx-agent-newteam-watch-log' ? '## hand-written watch log\n' : LEADER_SEED;
|
|
3295
|
-
const { failure } = await provisionWith(withExtras('watch-log'));
|
|
3296
|
-
// Row 3a fails for exactly the reason rows 3 to 5 fail on a taken name, and
|
|
3297
|
-
// the exit is the same non-zero the three produce for that condition.
|
|
3298
|
-
expect(failure).not.toBeNull();
|
|
3299
|
-
const row3a = allRowLines().find((l) => l.includes('row 3a:'));
|
|
3300
|
-
expect(row3a).toMatch(/row 3a: not asserted/);
|
|
3301
|
-
expect(row3a).toContain('mx-agent-newteam-watch-log');
|
|
3302
|
-
expect(row3a).toContain('the name was already taken, so nothing was written');
|
|
3303
|
-
// The taken-name remedy names the EXTRA anchor, not the leader-state. The
|
|
3304
|
-
// old `memoryNames[n - 3]` indexing could not reach a row numbered `3a`.
|
|
3305
|
-
expect(failure.message).toContain('These names are already in use:');
|
|
3306
|
-
expect(failure.message).toContain('mx-agent-newteam-watch-log');
|
|
3307
|
-
});
|
|
3308
|
-
// ── M6: the exempt path is untouched ──────────────────────────────────────
|
|
3309
|
-
it('provision --name team-builder prints no anchor row and no anchor warning (M6)', async () => {
|
|
3310
|
-
const abs = join(root, 'mx-agent-system/roleguides/team-builder.md');
|
|
3311
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
3312
|
-
writeFileSync(abs, TEAM_BUILDER_ROLEGUIDE);
|
|
3313
|
-
try {
|
|
3314
|
-
await runCreate({
|
|
3315
|
-
roleguide: 'mx-agent-system/roleguides/team-builder.md',
|
|
3316
|
-
name: 'team-builder',
|
|
3317
|
-
projectRoot: root,
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
catch (err) {
|
|
3321
|
-
if (!(err instanceof CompletionCheckError))
|
|
3322
|
-
throw err;
|
|
3323
|
-
}
|
|
3324
|
-
// The bundled roleguide has no anchors table, so a parser that ran before
|
|
3325
|
-
// the exemption would refuse it. Nothing about anchors is printed.
|
|
3326
|
-
expect(allRowLines().some((l) => /row 3[a-z]:/.test(l))).toBe(false);
|
|
3327
|
-
expect((await dimAndWarnLines()).some((l) => l.includes('Named Memory Anchors table was refused'))).toBe(false);
|
|
3328
|
-
expect(stdout).toContain(' Completion check (15 rows; team-builder.md defines 0 to 14):');
|
|
3329
|
-
});
|
|
3330
|
-
});
|
|
3331
|
-
/**
|
|
3332
|
-
* Row 14 — the CLI is built inside the new worktree (#123).
|
|
3333
|
-
*
|
|
3334
|
-
* A fresh worktree used to ship with no `node_modules` and no `dist/`, so the
|
|
3335
|
-
* first push was refused by `.githooks/pre-push` with 17 test titles naming a
|
|
3336
|
-
* missing `dist/index.js` rather than the change, and the operator ran the build
|
|
3337
|
-
* by hand. Step 6e runs it and this row asserts it.
|
|
3338
|
-
*
|
|
3339
|
-
* The build boundary is mocked here, the way `lib/memory.ts` and `lib/vault.ts`
|
|
3340
|
-
* are: no test in this file reaches npm.
|
|
3341
|
-
*/
|
|
3342
|
-
describe('completion row 14 — the CLI built in the worktree', () => {
|
|
3343
|
-
it('asserts the row and prints BOTH versions when the build succeeded', async () => {
|
|
3344
|
-
// S4: `mx-agent` on PATH is npm-linked at the main repository, so the
|
|
3345
|
-
// `provision` that ran the build and the tree it built are two codebases.
|
|
3346
|
-
// One version string cannot tell them apart, so the row prints both, and
|
|
3347
|
-
// this test makes them differ so a single string cannot satisfy it.
|
|
3348
|
-
builtVersion = '0.1.99';
|
|
3349
|
-
runnerVersion = '0.1.72';
|
|
3350
|
-
const { failure } = await provision();
|
|
3351
|
-
expect(failure).toBeNull();
|
|
3352
|
-
expect(rowLines()[14]).toMatch(/row 14: asserted/);
|
|
3353
|
-
// Where row 14 applies its verdict is unchanged (#613 item 2): only the
|
|
3354
|
-
// no-CLI case below gets the not-applicable word.
|
|
3355
|
-
expect(rowLines()[14]).not.toContain('not applicable');
|
|
3356
|
-
expect(rowLines()[14]).toContain('0.1.99');
|
|
3357
|
-
expect(rowLines()[14]).toContain('0.1.72');
|
|
3358
|
-
expect(stdout).toContain(' Completion check (15 rows; team-builder.md defines 0 to 14):');
|
|
3359
|
-
});
|
|
3360
|
-
it('runs after the anchor stage and before the memories are seeded', async () => {
|
|
3361
|
-
// The ordering step 6e exists for: everything before step 7 is inside the
|
|
3362
|
-
// worktree and `git worktree remove` clears it, while a named memory is not
|
|
3363
|
-
// clearable that way.
|
|
3364
|
-
const { bootstrapTeamMemories } = await import('../lib/memory.js');
|
|
3365
|
-
await provision();
|
|
3366
|
-
const buildOrder = buildCliInWorktree.mock.invocationCallOrder[0];
|
|
3367
|
-
const memoryOrder = vi.mocked(bootstrapTeamMemories).mock.invocationCallOrder[0];
|
|
3368
|
-
expect(buildOrder).toBeDefined();
|
|
3369
|
-
expect(memoryOrder).toBeDefined();
|
|
3370
|
-
expect(buildOrder).toBeLessThan(memoryOrder);
|
|
3371
|
-
});
|
|
3372
|
-
it('exits INCOMPLETE naming row 14 and the remedy, with steps 7 and 8 still run', async () => {
|
|
3373
|
-
buildOutcome = 'could-not-run';
|
|
3374
|
-
const { failure } = await provision();
|
|
3375
|
-
expect(failure).not.toBeNull();
|
|
3376
|
-
expect(failure.message).toContain('row 14: CLI built in the worktree');
|
|
3377
|
-
expect(failure.message).toContain('npm ci && npm run build');
|
|
3378
|
-
// A failed build keeps its verdict (#613 item 2): `not asserted`, detail
|
|
3379
|
-
// `could not run: ...`, which the creation test scripts count as today.
|
|
3380
|
-
expect(rowLines()[14]).toMatch(/row 14: not asserted {6}CLI built in the worktree.* — could not run: /);
|
|
3381
|
-
expect(rowLines()[14]).not.toContain('not applicable');
|
|
3382
|
-
// Step 7 ran anyway: a failed build never skips the memories, and rows 3 to
|
|
3383
|
-
// 5 are what prove it rather than a spy call count.
|
|
3384
|
-
for (const n of [3, 4, 5])
|
|
3385
|
-
expect(rowLines()[n]).toMatch(new RegExp(`row ${n}: asserted`));
|
|
3386
|
-
// Step 8 ran too: the catalog entry exists.
|
|
3387
|
-
expect(rowLines()[2]).toMatch(/row 2: asserted/);
|
|
3388
|
-
// The worktree stays, so the operator can run the build by hand (#5).
|
|
3389
|
-
expect(existsSync(join(root, WORKTREE))).toBe(true);
|
|
3390
|
-
});
|
|
3391
|
-
it('prints the verdict `not applicable` and does not fail the run when there is no CLI source', async () => {
|
|
3392
|
-
buildOutcome = 'not-applicable';
|
|
3393
|
-
const { failure } = await provision();
|
|
3394
|
-
expect(failure).toBeNull();
|
|
3395
|
-
// The exact verdict word, padded to the verdict column (#613 item 2). The
|
|
3396
|
-
// creation test scripts parse this word, so a change to it is a change to
|
|
3397
|
-
// their VERDICTS lists as well.
|
|
3398
|
-
expect(rowLines()[14]).toMatch(/row 14: not applicable {4}CLI built in the worktree/);
|
|
3399
|
-
expect(rowLines()[14]).not.toContain('not asserted');
|
|
3400
|
-
// The detail states the reason without repeating the word.
|
|
3401
|
-
expect(rowLines()[14]).toContain(' — no mx-agent-system/cli/package.json in this worktree');
|
|
3402
|
-
});
|
|
3403
|
-
it('reads the build as could-not-run when the boundary throws, and still finishes', async () => {
|
|
3404
|
-
buildOutcome = 'throws';
|
|
3405
|
-
const { failure } = await provision();
|
|
3406
|
-
expect(failure).not.toBeNull();
|
|
3407
|
-
expect(failure.message).toContain('row 14: CLI built in the worktree');
|
|
3408
|
-
expect(rowLines()[14]).toContain('the build boundary exploded');
|
|
3409
|
-
for (const n of [3, 4, 5])
|
|
3410
|
-
expect(rowLines()[n]).toMatch(new RegExp(`row ${n}: asserted`));
|
|
3411
|
-
});
|
|
3412
|
-
it('does not assert the row when dist/index.js is gone by check time', async () => {
|
|
3413
|
-
// Row 1 re-reads the roleguide copy rather than trusting step 6b, and this
|
|
3414
|
-
// row re-reads `dist/index.js` for the same reason: the check reads what
|
|
3415
|
-
// exists now, not what a return value claimed.
|
|
3416
|
-
buildWritesDist = false;
|
|
3417
|
-
const { failure } = await provision();
|
|
3418
|
-
expect(failure).not.toBeNull();
|
|
3419
|
-
expect(rowLines()[14]).toMatch(/row 14: not asserted/);
|
|
3420
|
-
expect(rowLines()[14]).toContain('was built and is now absent');
|
|
3421
|
-
});
|
|
3422
|
-
it('skips the build and says so when row 13 refuses the run', async () => {
|
|
3423
|
-
const abs = join(root, RG);
|
|
3424
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
3425
|
-
writeFileSync(abs, [
|
|
3426
|
-
'# Newteam Leader Roleguide',
|
|
3427
|
-
'Mission: <TEAM_MISSION>',
|
|
3428
|
-
'<STEP_0_DETAILS>',
|
|
3429
|
-
'',
|
|
3430
|
-
BEHAVIORAL_START_MARKER,
|
|
3431
|
-
'## Decision Authority',
|
|
3432
|
-
'',
|
|
3433
|
-
'- Ship without asking when the data is clear.',
|
|
3434
|
-
BEHAVIORAL_END_MARKER,
|
|
3435
|
-
].join('\n'));
|
|
3436
|
-
let failure = null;
|
|
3437
|
-
try {
|
|
3438
|
-
await runCreate({ roleguide: RG, name: 'newteam', projectRoot: root });
|
|
3439
|
-
}
|
|
3440
|
-
catch (err) {
|
|
3441
|
-
if (!(err instanceof CompletionCheckError))
|
|
3442
|
-
throw err;
|
|
3443
|
-
failure = err;
|
|
3444
|
-
}
|
|
3445
|
-
expect(failure).not.toBeNull();
|
|
3446
|
-
// The refused run's worktree is removed at team-builder step 6b, so building
|
|
3447
|
-
// there spends 315 MB and tens of seconds on a directory about to be deleted.
|
|
3448
|
-
expect(buildCliInWorktree).not.toHaveBeenCalled();
|
|
3449
|
-
// Verdict unchanged by #613 item 2: `not asserted`, detail `not built: ...`.
|
|
3450
|
-
expect(rowLines()[14]).toMatch(/row 14: not asserted {6}CLI built in the worktree.* — not built: row 13 refuses this run/);
|
|
3451
|
-
expect(rowLines()[14]).toContain('built on the run that passes row 13');
|
|
3452
|
-
});
|
|
3453
|
-
it('still builds on the exempt team-builder path', async () => {
|
|
3454
|
-
// `isPlaceholderRoleguide` decides only whether row 13 tolerates
|
|
3455
|
-
// placeholders. It does not skip the build.
|
|
3456
|
-
const abs = join(root, 'mx-agent-system/roleguides/team-builder.md');
|
|
3457
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
3458
|
-
writeFileSync(abs, TEAM_BUILDER_ROLEGUIDE);
|
|
3459
|
-
try {
|
|
3460
|
-
await runCreate({
|
|
3461
|
-
roleguide: 'mx-agent-system/roleguides/team-builder.md',
|
|
3462
|
-
name: 'team-builder',
|
|
3463
|
-
projectRoot: root,
|
|
3464
|
-
});
|
|
3465
|
-
}
|
|
3466
|
-
catch (err) {
|
|
3467
|
-
if (!(err instanceof CompletionCheckError))
|
|
3468
|
-
throw err;
|
|
3469
|
-
}
|
|
3470
|
-
expect(buildCliInWorktree).toHaveBeenCalledTimes(1);
|
|
3471
|
-
});
|
|
3472
|
-
});
|
|
3473
|
-
//# sourceMappingURL=provision-completion-rows.test.js.map
|