@memnexus-ai/mx-agent-cli 0.1.296 → 0.1.297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/create.d.ts +36 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +85 -8
- package/dist/commands/create.js.map +1 -1
- package/dist/standards/decision-request.md +6 -57
- package/dist/standards/po-communication-standard.md +0 -34
- package/dist/standards/report-format.md +0 -90
- package/dist/standards/writing-standard.md +0 -312
- package/package.json +3 -1
- package/dist/__tests__/agent-attribution.test.d.ts +0 -16
- package/dist/__tests__/agent-attribution.test.d.ts.map +0 -1
- package/dist/__tests__/agent-attribution.test.js +0 -250
- package/dist/__tests__/agent-attribution.test.js.map +0 -1
- package/dist/__tests__/agents-md-canonicalization.test.d.ts +0 -23
- package/dist/__tests__/agents-md-canonicalization.test.d.ts.map +0 -1
- package/dist/__tests__/agents-md-canonicalization.test.js +0 -319
- package/dist/__tests__/agents-md-canonicalization.test.js.map +0 -1
- package/dist/__tests__/behavioral-compliance.test.d.ts +0 -8
- package/dist/__tests__/behavioral-compliance.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-compliance.test.js +0 -226
- package/dist/__tests__/behavioral-compliance.test.js.map +0 -1
- package/dist/__tests__/behavioral-extraction.test.d.ts +0 -12
- package/dist/__tests__/behavioral-extraction.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-extraction.test.js +0 -330
- package/dist/__tests__/behavioral-extraction.test.js.map +0 -1
- package/dist/__tests__/behavioral-git-read.test.d.ts +0 -21
- package/dist/__tests__/behavioral-git-read.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-git-read.test.js +0 -955
- package/dist/__tests__/behavioral-git-read.test.js.map +0 -1
- package/dist/__tests__/behavioral-injection.test.d.ts +0 -13
- package/dist/__tests__/behavioral-injection.test.d.ts.map +0 -1
- package/dist/__tests__/behavioral-injection.test.js +0 -384
- package/dist/__tests__/behavioral-injection.test.js.map +0 -1
- package/dist/__tests__/binary-smoke.test.d.ts +0 -12
- package/dist/__tests__/binary-smoke.test.d.ts.map +0 -1
- package/dist/__tests__/binary-smoke.test.js +0 -88
- package/dist/__tests__/binary-smoke.test.js.map +0 -1
- package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts +0 -18
- package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts.map +0 -1
- package/dist/__tests__/bootstrap-behavioral-contract.test.js +0 -104
- package/dist/__tests__/bootstrap-behavioral-contract.test.js.map +0 -1
- package/dist/__tests__/bundle-config.test.d.ts +0 -18
- package/dist/__tests__/bundle-config.test.d.ts.map +0 -1
- package/dist/__tests__/bundle-config.test.js +0 -123
- package/dist/__tests__/bundle-config.test.js.map +0 -1
- package/dist/__tests__/catalog-interaction.test.d.ts +0 -25
- package/dist/__tests__/catalog-interaction.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-interaction.test.js +0 -269
- package/dist/__tests__/catalog-interaction.test.js.map +0 -1
- package/dist/__tests__/catalog-named-memories.test.d.ts +0 -2
- package/dist/__tests__/catalog-named-memories.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-named-memories.test.js +0 -204
- package/dist/__tests__/catalog-named-memories.test.js.map +0 -1
- package/dist/__tests__/catalog-origin-main.test.d.ts +0 -15
- package/dist/__tests__/catalog-origin-main.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-origin-main.test.js +0 -305
- package/dist/__tests__/catalog-origin-main.test.js.map +0 -1
- package/dist/__tests__/catalog.test.d.ts +0 -2
- package/dist/__tests__/catalog.test.d.ts.map +0 -1
- package/dist/__tests__/catalog.test.js +0 -131
- package/dist/__tests__/catalog.test.js.map +0 -1
- package/dist/__tests__/claude-local-sanitizer.test.d.ts +0 -24
- package/dist/__tests__/claude-local-sanitizer.test.d.ts.map +0 -1
- package/dist/__tests__/claude-local-sanitizer.test.js +0 -906
- package/dist/__tests__/claude-local-sanitizer.test.js.map +0 -1
- package/dist/__tests__/claude-md-compose.test.d.ts +0 -17
- package/dist/__tests__/claude-md-compose.test.d.ts.map +0 -1
- package/dist/__tests__/claude-md-compose.test.js +0 -119
- package/dist/__tests__/claude-md-compose.test.js.map +0 -1
- package/dist/__tests__/claude-sync.test.d.ts +0 -2
- package/dist/__tests__/claude-sync.test.d.ts.map +0 -1
- package/dist/__tests__/claude-sync.test.js +0 -571
- package/dist/__tests__/claude-sync.test.js.map +0 -1
- package/dist/__tests__/cli-build-integration.test.d.ts +0 -2
- package/dist/__tests__/cli-build-integration.test.d.ts.map +0 -1
- package/dist/__tests__/cli-build-integration.test.js +0 -64
- package/dist/__tests__/cli-build-integration.test.js.map +0 -1
- package/dist/__tests__/cli-build.test.d.ts +0 -2
- package/dist/__tests__/cli-build.test.d.ts.map +0 -1
- package/dist/__tests__/cli-build.test.js +0 -640
- package/dist/__tests__/cli-build.test.js.map +0 -1
- package/dist/__tests__/codex-agent-gate.test.d.ts +0 -2
- package/dist/__tests__/codex-agent-gate.test.d.ts.map +0 -1
- package/dist/__tests__/codex-agent-gate.test.js +0 -480
- package/dist/__tests__/codex-agent-gate.test.js.map +0 -1
- package/dist/__tests__/codex-deploy-config.test.d.ts +0 -2
- package/dist/__tests__/codex-deploy-config.test.d.ts.map +0 -1
- package/dist/__tests__/codex-deploy-config.test.js +0 -1230
- package/dist/__tests__/codex-deploy-config.test.js.map +0 -1
- package/dist/__tests__/codex-trust-keys.test.d.ts +0 -2
- package/dist/__tests__/codex-trust-keys.test.d.ts.map +0 -1
- package/dist/__tests__/codex-trust-keys.test.js +0 -731
- package/dist/__tests__/codex-trust-keys.test.js.map +0 -1
- package/dist/__tests__/codex-write-race.test.d.ts +0 -2
- package/dist/__tests__/codex-write-race.test.d.ts.map +0 -1
- package/dist/__tests__/codex-write-race.test.js +0 -2253
- package/dist/__tests__/codex-write-race.test.js.map +0 -1
- package/dist/__tests__/completion-rows-discriminate.test.d.ts +0 -20
- package/dist/__tests__/completion-rows-discriminate.test.d.ts.map +0 -1
- package/dist/__tests__/completion-rows-discriminate.test.js +0 -481
- package/dist/__tests__/completion-rows-discriminate.test.js.map +0 -1
- package/dist/__tests__/config-command.test.d.ts +0 -9
- package/dist/__tests__/config-command.test.d.ts.map +0 -1
- package/dist/__tests__/config-command.test.js +0 -75
- package/dist/__tests__/config-command.test.js.map +0 -1
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts +0 -2
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js +0 -127
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js.map +0 -1
- package/dist/__tests__/config-fidelity-display.test.d.ts +0 -2
- package/dist/__tests__/config-fidelity-display.test.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity-display.test.js +0 -77
- package/dist/__tests__/config-fidelity-display.test.js.map +0 -1
- package/dist/__tests__/config-fidelity-unreadable-fixture.d.ts +0 -32
- package/dist/__tests__/config-fidelity-unreadable-fixture.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity-unreadable-fixture.js +0 -37
- package/dist/__tests__/config-fidelity-unreadable-fixture.js.map +0 -1
- package/dist/__tests__/config-fidelity.test.d.ts +0 -16
- package/dist/__tests__/config-fidelity.test.d.ts.map +0 -1
- package/dist/__tests__/config-fidelity.test.js +0 -2679
- package/dist/__tests__/config-fidelity.test.js.map +0 -1
- package/dist/__tests__/config-generation-gate.test.d.ts +0 -46
- package/dist/__tests__/config-generation-gate.test.d.ts.map +0 -1
- package/dist/__tests__/config-generation-gate.test.js +0 -435
- package/dist/__tests__/config-generation-gate.test.js.map +0 -1
- package/dist/__tests__/config-generation.test.d.ts +0 -7
- package/dist/__tests__/config-generation.test.d.ts.map +0 -1
- package/dist/__tests__/config-generation.test.js +0 -141
- package/dist/__tests__/config-generation.test.js.map +0 -1
- package/dist/__tests__/config-sync.test.d.ts +0 -10
- package/dist/__tests__/config-sync.test.d.ts.map +0 -1
- package/dist/__tests__/config-sync.test.js +0 -268
- package/dist/__tests__/config-sync.test.js.map +0 -1
- package/dist/__tests__/coordination-401-production-wiring.test.d.ts +0 -19
- package/dist/__tests__/coordination-401-production-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-401-production-wiring.test.js +0 -286
- package/dist/__tests__/coordination-401-production-wiring.test.js.map +0 -1
- package/dist/__tests__/coordination-401-recovery.test.d.ts +0 -22
- package/dist/__tests__/coordination-401-recovery.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-401-recovery.test.js +0 -601
- package/dist/__tests__/coordination-401-recovery.test.js.map +0 -1
- package/dist/__tests__/coordination-brief-pin.test.d.ts +0 -20
- package/dist/__tests__/coordination-brief-pin.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-brief-pin.test.js +0 -66
- package/dist/__tests__/coordination-brief-pin.test.js.map +0 -1
- package/dist/__tests__/coordination-brief.test.d.ts +0 -9
- package/dist/__tests__/coordination-brief.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-brief.test.js +0 -290
- package/dist/__tests__/coordination-brief.test.js.map +0 -1
- package/dist/__tests__/coordination-client.test.d.ts +0 -9
- package/dist/__tests__/coordination-client.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-client.test.js +0 -517
- package/dist/__tests__/coordination-client.test.js.map +0 -1
- package/dist/__tests__/coordination-command.test.d.ts +0 -9
- package/dist/__tests__/coordination-command.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-command.test.js +0 -1082
- package/dist/__tests__/coordination-command.test.js.map +0 -1
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts +0 -24
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-credential-endpoint.test.js +0 -1292
- package/dist/__tests__/coordination-credential-endpoint.test.js.map +0 -1
- package/dist/__tests__/coordination-expected-team.test.d.ts +0 -19
- package/dist/__tests__/coordination-expected-team.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-expected-team.test.js +0 -423
- package/dist/__tests__/coordination-expected-team.test.js.map +0 -1
- package/dist/__tests__/coordination-fallback.test.d.ts +0 -9
- package/dist/__tests__/coordination-fallback.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-fallback.test.js +0 -192
- package/dist/__tests__/coordination-fallback.test.js.map +0 -1
- package/dist/__tests__/coordination-file-guards.test.d.ts +0 -29
- package/dist/__tests__/coordination-file-guards.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-file-guards.test.js +0 -380
- package/dist/__tests__/coordination-file-guards.test.js.map +0 -1
- package/dist/__tests__/coordination-history.test.d.ts +0 -8
- package/dist/__tests__/coordination-history.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-history.test.js +0 -447
- package/dist/__tests__/coordination-history.test.js.map +0 -1
- package/dist/__tests__/coordination-memory.test.d.ts +0 -14
- package/dist/__tests__/coordination-memory.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-memory.test.js +0 -401
- package/dist/__tests__/coordination-memory.test.js.map +0 -1
- package/dist/__tests__/coordination-mode.test.d.ts +0 -13
- package/dist/__tests__/coordination-mode.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-mode.test.js +0 -180
- package/dist/__tests__/coordination-mode.test.js.map +0 -1
- package/dist/__tests__/coordination-plain-shell-commands.test.d.ts +0 -22
- package/dist/__tests__/coordination-plain-shell-commands.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-plain-shell-commands.test.js +0 -1875
- package/dist/__tests__/coordination-plain-shell-commands.test.js.map +0 -1
- package/dist/__tests__/coordination-provision.test.d.ts +0 -12
- package/dist/__tests__/coordination-provision.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-provision.test.js +0 -103
- package/dist/__tests__/coordination-provision.test.js.map +0 -1
- package/dist/__tests__/coordination-render.test.d.ts +0 -9
- package/dist/__tests__/coordination-render.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-render.test.js +0 -335
- package/dist/__tests__/coordination-render.test.js.map +0 -1
- package/dist/__tests__/coordination-setup.test.d.ts +0 -6
- package/dist/__tests__/coordination-setup.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-setup.test.js +0 -448
- package/dist/__tests__/coordination-setup.test.js.map +0 -1
- package/dist/__tests__/coordination-status-plain-shell.test.d.ts +0 -19
- package/dist/__tests__/coordination-status-plain-shell.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-status-plain-shell.test.js +0 -332
- package/dist/__tests__/coordination-status-plain-shell.test.js.map +0 -1
- package/dist/__tests__/coordination-status-registration.test.d.ts +0 -16
- package/dist/__tests__/coordination-status-registration.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-status-registration.test.js +0 -480
- package/dist/__tests__/coordination-status-registration.test.js.map +0 -1
- package/dist/__tests__/coordination-token-multitenant.test.d.ts +0 -11
- package/dist/__tests__/coordination-token-multitenant.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-token-multitenant.test.js +0 -106
- package/dist/__tests__/coordination-token-multitenant.test.js.map +0 -1
- package/dist/__tests__/coordination-token.test.d.ts +0 -11
- package/dist/__tests__/coordination-token.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-token.test.js +0 -201
- package/dist/__tests__/coordination-token.test.js.map +0 -1
- package/dist/__tests__/coordination-wiring.test.d.ts +0 -11
- package/dist/__tests__/coordination-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/coordination-wiring.test.js +0 -43
- package/dist/__tests__/coordination-wiring.test.js.map +0 -1
- package/dist/__tests__/creation-pr-class-check.test.d.ts +0 -17
- package/dist/__tests__/creation-pr-class-check.test.d.ts.map +0 -1
- package/dist/__tests__/creation-pr-class-check.test.js +0 -346
- package/dist/__tests__/creation-pr-class-check.test.js.map +0 -1
- package/dist/__tests__/creation-step6a-push-check.test.d.ts +0 -15
- package/dist/__tests__/creation-step6a-push-check.test.d.ts.map +0 -1
- package/dist/__tests__/creation-step6a-push-check.test.js +0 -150
- package/dist/__tests__/creation-step6a-push-check.test.js.map +0 -1
- package/dist/__tests__/decision-check.test.d.ts +0 -2
- package/dist/__tests__/decision-check.test.d.ts.map +0 -1
- package/dist/__tests__/decision-check.test.js +0 -105
- package/dist/__tests__/decision-check.test.js.map +0 -1
- package/dist/__tests__/digest-fail-closed.test.d.ts +0 -16
- package/dist/__tests__/digest-fail-closed.test.d.ts.map +0 -1
- package/dist/__tests__/digest-fail-closed.test.js +0 -248
- package/dist/__tests__/digest-fail-closed.test.js.map +0 -1
- package/dist/__tests__/digest-team-omission.test.d.ts +0 -15
- package/dist/__tests__/digest-team-omission.test.d.ts.map +0 -1
- package/dist/__tests__/digest-team-omission.test.js +0 -247
- package/dist/__tests__/digest-team-omission.test.js.map +0 -1
- package/dist/__tests__/doctor-config-fidelity.test.d.ts +0 -19
- package/dist/__tests__/doctor-config-fidelity.test.d.ts.map +0 -1
- package/dist/__tests__/doctor-config-fidelity.test.js +0 -324
- package/dist/__tests__/doctor-config-fidelity.test.js.map +0 -1
- package/dist/__tests__/doctor-framework-version.test.d.ts +0 -2
- package/dist/__tests__/doctor-framework-version.test.d.ts.map +0 -1
- package/dist/__tests__/doctor-framework-version.test.js +0 -146
- package/dist/__tests__/doctor-framework-version.test.js.map +0 -1
- package/dist/__tests__/doctor-worktree-path.test.d.ts +0 -17
- package/dist/__tests__/doctor-worktree-path.test.d.ts.map +0 -1
- package/dist/__tests__/doctor-worktree-path.test.js +0 -158
- package/dist/__tests__/doctor-worktree-path.test.js.map +0 -1
- package/dist/__tests__/doctor.test.d.ts +0 -20
- package/dist/__tests__/doctor.test.d.ts.map +0 -1
- package/dist/__tests__/doctor.test.js +0 -849
- package/dist/__tests__/doctor.test.js.map +0 -1
- package/dist/__tests__/event-shipper.test.d.ts +0 -16
- package/dist/__tests__/event-shipper.test.d.ts.map +0 -1
- package/dist/__tests__/event-shipper.test.js +0 -287
- package/dist/__tests__/event-shipper.test.js.map +0 -1
- package/dist/__tests__/fleet-data.test.d.ts +0 -2
- package/dist/__tests__/fleet-data.test.d.ts.map +0 -1
- package/dist/__tests__/fleet-data.test.js +0 -501
- package/dist/__tests__/fleet-data.test.js.map +0 -1
- package/dist/__tests__/fleet-devpod.test.d.ts +0 -12
- package/dist/__tests__/fleet-devpod.test.d.ts.map +0 -1
- package/dist/__tests__/fleet-devpod.test.js +0 -260
- package/dist/__tests__/fleet-devpod.test.js.map +0 -1
- package/dist/__tests__/fleet-tmux.test.d.ts +0 -2
- package/dist/__tests__/fleet-tmux.test.d.ts.map +0 -1
- package/dist/__tests__/fleet-tmux.test.js +0 -289
- package/dist/__tests__/fleet-tmux.test.js.map +0 -1
- package/dist/__tests__/fleet.test.d.ts +0 -16
- package/dist/__tests__/fleet.test.d.ts.map +0 -1
- package/dist/__tests__/fleet.test.js +0 -75
- package/dist/__tests__/fleet.test.js.map +0 -1
- package/dist/__tests__/generate-claude.test.d.ts +0 -18
- package/dist/__tests__/generate-claude.test.d.ts.map +0 -1
- package/dist/__tests__/generate-claude.test.js +0 -1015
- package/dist/__tests__/generate-claude.test.js.map +0 -1
- package/dist/__tests__/gh-remote.test.d.ts +0 -2
- package/dist/__tests__/gh-remote.test.d.ts.map +0 -1
- package/dist/__tests__/gh-remote.test.js +0 -136
- package/dist/__tests__/gh-remote.test.js.map +0 -1
- package/dist/__tests__/git-env.test.d.ts +0 -14
- package/dist/__tests__/git-env.test.d.ts.map +0 -1
- package/dist/__tests__/git-env.test.js +0 -131
- package/dist/__tests__/git-env.test.js.map +0 -1
- package/dist/__tests__/git-identity-isolation.test.d.ts +0 -33
- package/dist/__tests__/git-identity-isolation.test.d.ts.map +0 -1
- package/dist/__tests__/git-identity-isolation.test.js +0 -626
- package/dist/__tests__/git-identity-isolation.test.js.map +0 -1
- package/dist/__tests__/harness-extract.test.d.ts +0 -19
- package/dist/__tests__/harness-extract.test.d.ts.map +0 -1
- package/dist/__tests__/harness-extract.test.js +0 -566
- package/dist/__tests__/harness-extract.test.js.map +0 -1
- package/dist/__tests__/harness-wiring.test.d.ts +0 -16
- package/dist/__tests__/harness-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/harness-wiring.test.js +0 -469
- package/dist/__tests__/harness-wiring.test.js.map +0 -1
- package/dist/__tests__/hook-completeness.test.d.ts +0 -13
- package/dist/__tests__/hook-completeness.test.d.ts.map +0 -1
- package/dist/__tests__/hook-completeness.test.js +0 -238
- package/dist/__tests__/hook-completeness.test.js.map +0 -1
- package/dist/__tests__/hook-heal.test.d.ts +0 -8
- package/dist/__tests__/hook-heal.test.d.ts.map +0 -1
- package/dist/__tests__/hook-heal.test.js +0 -156
- package/dist/__tests__/hook-heal.test.js.map +0 -1
- package/dist/__tests__/human-turn-classifier.test.d.ts +0 -17
- package/dist/__tests__/human-turn-classifier.test.d.ts.map +0 -1
- package/dist/__tests__/human-turn-classifier.test.js +0 -311
- package/dist/__tests__/human-turn-classifier.test.js.map +0 -1
- package/dist/__tests__/init-coordination-url.test.d.ts +0 -11
- package/dist/__tests__/init-coordination-url.test.d.ts.map +0 -1
- package/dist/__tests__/init-coordination-url.test.js +0 -217
- package/dist/__tests__/init-coordination-url.test.js.map +0 -1
- package/dist/__tests__/isolation-probe.test.d.ts +0 -15
- package/dist/__tests__/isolation-probe.test.d.ts.map +0 -1
- package/dist/__tests__/isolation-probe.test.js +0 -611
- package/dist/__tests__/isolation-probe.test.js.map +0 -1
- package/dist/__tests__/leader-lock.test.d.ts +0 -12
- package/dist/__tests__/leader-lock.test.d.ts.map +0 -1
- package/dist/__tests__/leader-lock.test.js +0 -293
- package/dist/__tests__/leader-lock.test.js.map +0 -1
- package/dist/__tests__/memory-archive-checks.test.d.ts +0 -22
- package/dist/__tests__/memory-archive-checks.test.d.ts.map +0 -1
- package/dist/__tests__/memory-archive-checks.test.js +0 -748
- package/dist/__tests__/memory-archive-checks.test.js.map +0 -1
- package/dist/__tests__/memory-archive-prep.test.d.ts +0 -8
- package/dist/__tests__/memory-archive-prep.test.d.ts.map +0 -1
- package/dist/__tests__/memory-archive-prep.test.js +0 -524
- package/dist/__tests__/memory-archive-prep.test.js.map +0 -1
- package/dist/__tests__/memory-autocreate.test.d.ts +0 -10
- package/dist/__tests__/memory-autocreate.test.d.ts.map +0 -1
- package/dist/__tests__/memory-autocreate.test.js +0 -709
- package/dist/__tests__/memory-autocreate.test.js.map +0 -1
- package/dist/__tests__/memory-log-result.test.d.ts +0 -13
- package/dist/__tests__/memory-log-result.test.d.ts.map +0 -1
- package/dist/__tests__/memory-log-result.test.js +0 -149
- package/dist/__tests__/memory-log-result.test.js.map +0 -1
- package/dist/__tests__/memory-named-exists.test.d.ts +0 -16
- package/dist/__tests__/memory-named-exists.test.d.ts.map +0 -1
- package/dist/__tests__/memory-named-exists.test.js +0 -288
- package/dist/__tests__/memory-named-exists.test.js.map +0 -1
- package/dist/__tests__/message-bus.test.d.ts +0 -10
- package/dist/__tests__/message-bus.test.d.ts.map +0 -1
- package/dist/__tests__/message-bus.test.js +0 -526
- package/dist/__tests__/message-bus.test.js.map +0 -1
- package/dist/__tests__/monitor.test.d.ts +0 -6
- package/dist/__tests__/monitor.test.d.ts.map +0 -1
- package/dist/__tests__/monitor.test.js +0 -458
- package/dist/__tests__/monitor.test.js.map +0 -1
- package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts +0 -2
- package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts.map +0 -1
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js +0 -232
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js.map +0 -1
- package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts +0 -2
- package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts.map +0 -1
- package/dist/__tests__/mx-agent-cli-version-pin.test.js +0 -236
- package/dist/__tests__/mx-agent-cli-version-pin.test.js.map +0 -1
- package/dist/__tests__/new-project-first-team.test.d.ts +0 -15
- package/dist/__tests__/new-project-first-team.test.d.ts.map +0 -1
- package/dist/__tests__/new-project-first-team.test.js +0 -444
- package/dist/__tests__/new-project-first-team.test.js.map +0 -1
- package/dist/__tests__/otel-env.test.d.ts +0 -2
- package/dist/__tests__/otel-env.test.d.ts.map +0 -1
- package/dist/__tests__/otel-env.test.js +0 -127
- package/dist/__tests__/otel-env.test.js.map +0 -1
- package/dist/__tests__/pager-fail-closed.test.d.ts +0 -19
- package/dist/__tests__/pager-fail-closed.test.d.ts.map +0 -1
- package/dist/__tests__/pager-fail-closed.test.js +0 -229
- package/dist/__tests__/pager-fail-closed.test.js.map +0 -1
- package/dist/__tests__/pr-set-body.test.d.ts +0 -29
- package/dist/__tests__/pr-set-body.test.d.ts.map +0 -1
- package/dist/__tests__/pr-set-body.test.js +0 -314
- package/dist/__tests__/pr-set-body.test.js.map +0 -1
- package/dist/__tests__/prior-sync-failure.test.d.ts +0 -2
- package/dist/__tests__/prior-sync-failure.test.d.ts.map +0 -1
- package/dist/__tests__/prior-sync-failure.test.js +0 -81
- package/dist/__tests__/prior-sync-failure.test.js.map +0 -1
- package/dist/__tests__/project-config.test.d.ts +0 -2
- package/dist/__tests__/project-config.test.d.ts.map +0 -1
- package/dist/__tests__/project-config.test.js +0 -458
- package/dist/__tests__/project-config.test.js.map +0 -1
- package/dist/__tests__/provision-behavioral-contract.test.d.ts +0 -13
- package/dist/__tests__/provision-behavioral-contract.test.d.ts.map +0 -1
- package/dist/__tests__/provision-behavioral-contract.test.js +0 -548
- package/dist/__tests__/provision-behavioral-contract.test.js.map +0 -1
- package/dist/__tests__/provision-catalog-precondition.test.d.ts +0 -26
- package/dist/__tests__/provision-catalog-precondition.test.d.ts.map +0 -1
- package/dist/__tests__/provision-catalog-precondition.test.js +0 -622
- package/dist/__tests__/provision-catalog-precondition.test.js.map +0 -1
- package/dist/__tests__/provision-completion-rows.test.d.ts +0 -17
- package/dist/__tests__/provision-completion-rows.test.d.ts.map +0 -1
- package/dist/__tests__/provision-completion-rows.test.js +0 -3473
- package/dist/__tests__/provision-completion-rows.test.js.map +0 -1
- package/dist/__tests__/provision-copy-containment.test.d.ts +0 -19
- package/dist/__tests__/provision-copy-containment.test.d.ts.map +0 -1
- package/dist/__tests__/provision-copy-containment.test.js +0 -187
- package/dist/__tests__/provision-copy-containment.test.js.map +0 -1
- package/dist/__tests__/provision-identity-gate.test.d.ts +0 -20
- package/dist/__tests__/provision-identity-gate.test.d.ts.map +0 -1
- package/dist/__tests__/provision-identity-gate.test.js +0 -602
- package/dist/__tests__/provision-identity-gate.test.js.map +0 -1
- package/dist/__tests__/provision-resume.test.d.ts +0 -26
- package/dist/__tests__/provision-resume.test.d.ts.map +0 -1
- package/dist/__tests__/provision-resume.test.js +0 -1344
- package/dist/__tests__/provision-resume.test.js.map +0 -1
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts +0 -27
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts.map +0 -1
- package/dist/__tests__/provision-roleguide-anchors.test.js +0 -747
- package/dist/__tests__/provision-roleguide-anchors.test.js.map +0 -1
- package/dist/__tests__/provision-row12-stub-server.test.d.ts +0 -21
- package/dist/__tests__/provision-row12-stub-server.test.d.ts.map +0 -1
- package/dist/__tests__/provision-row12-stub-server.test.js +0 -264
- package/dist/__tests__/provision-row12-stub-server.test.js.map +0 -1
- package/dist/__tests__/provision-skeleton-fill.test.d.ts +0 -16
- package/dist/__tests__/provision-skeleton-fill.test.d.ts.map +0 -1
- package/dist/__tests__/provision-skeleton-fill.test.js +0 -490
- package/dist/__tests__/provision-skeleton-fill.test.js.map +0 -1
- package/dist/__tests__/provision-step8-commit.test.d.ts +0 -40
- package/dist/__tests__/provision-step8-commit.test.d.ts.map +0 -1
- package/dist/__tests__/provision-step8-commit.test.js +0 -529
- package/dist/__tests__/provision-step8-commit.test.js.map +0 -1
- package/dist/__tests__/provision-teambuilder-flow.test.d.ts +0 -22
- package/dist/__tests__/provision-teambuilder-flow.test.d.ts.map +0 -1
- package/dist/__tests__/provision-teambuilder-flow.test.js +0 -253
- package/dist/__tests__/provision-teambuilder-flow.test.js.map +0 -1
- package/dist/__tests__/provision-write-integrity.test.d.ts +0 -18
- package/dist/__tests__/provision-write-integrity.test.d.ts.map +0 -1
- package/dist/__tests__/provision-write-integrity.test.js +0 -141
- package/dist/__tests__/provision-write-integrity.test.js.map +0 -1
- package/dist/__tests__/repo-guard-wiring.test.d.ts +0 -21
- package/dist/__tests__/repo-guard-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/repo-guard-wiring.test.js +0 -638
- package/dist/__tests__/repo-guard-wiring.test.js.map +0 -1
- package/dist/__tests__/report-format.test.d.ts +0 -2
- package/dist/__tests__/report-format.test.d.ts.map +0 -1
- package/dist/__tests__/report-format.test.js +0 -219
- package/dist/__tests__/report-format.test.js.map +0 -1
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts +0 -20
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts.map +0 -1
- package/dist/__tests__/row15-detail-sanitizer.test.js +0 -61
- package/dist/__tests__/row15-detail-sanitizer.test.js.map +0 -1
- package/dist/__tests__/rows-9-10-zero-remotes.test.d.ts +0 -32
- package/dist/__tests__/rows-9-10-zero-remotes.test.d.ts.map +0 -1
- package/dist/__tests__/rows-9-10-zero-remotes.test.js +0 -203
- package/dist/__tests__/rows-9-10-zero-remotes.test.js.map +0 -1
- package/dist/__tests__/runtime-claude-adapter.test.d.ts +0 -2
- package/dist/__tests__/runtime-claude-adapter.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-claude-adapter.test.js +0 -70
- package/dist/__tests__/runtime-claude-adapter.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-adapter.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-adapter.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-adapter.test.js +0 -558
- package/dist/__tests__/runtime-codex-adapter.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-config.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-config.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-config.test.js +0 -1421
- package/dist/__tests__/runtime-codex-config.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js +0 -309
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-gateway-provider.test.js +0 -163
- package/dist/__tests__/runtime-codex-gateway-provider.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-guard-proof.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-guard-proof.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-guard-proof.test.js +0 -822
- package/dist/__tests__/runtime-codex-guard-proof.test.js.map +0 -1
- package/dist/__tests__/runtime-codex-version-pin.test.d.ts +0 -2
- package/dist/__tests__/runtime-codex-version-pin.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-codex-version-pin.test.js +0 -86
- package/dist/__tests__/runtime-codex-version-pin.test.js.map +0 -1
- package/dist/__tests__/runtime-identity.test.d.ts +0 -2
- package/dist/__tests__/runtime-identity.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-identity.test.js +0 -117
- package/dist/__tests__/runtime-identity.test.js.map +0 -1
- package/dist/__tests__/runtime-resolve.test.d.ts +0 -2
- package/dist/__tests__/runtime-resolve.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-resolve.test.js +0 -172
- package/dist/__tests__/runtime-resolve.test.js.map +0 -1
- package/dist/__tests__/security-posture.test.d.ts +0 -8
- package/dist/__tests__/security-posture.test.d.ts.map +0 -1
- package/dist/__tests__/security-posture.test.js +0 -82
- package/dist/__tests__/security-posture.test.js.map +0 -1
- package/dist/__tests__/session-model.test.d.ts +0 -2
- package/dist/__tests__/session-model.test.d.ts.map +0 -1
- package/dist/__tests__/session-model.test.js +0 -74
- package/dist/__tests__/session-model.test.js.map +0 -1
- package/dist/__tests__/session-pause-provisioning.test.d.ts +0 -19
- package/dist/__tests__/session-pause-provisioning.test.d.ts.map +0 -1
- package/dist/__tests__/session-pause-provisioning.test.js +0 -115
- package/dist/__tests__/session-pause-provisioning.test.js.map +0 -1
- package/dist/__tests__/session-reclamation.test.d.ts +0 -15
- package/dist/__tests__/session-reclamation.test.d.ts.map +0 -1
- package/dist/__tests__/session-reclamation.test.js +0 -73
- package/dist/__tests__/session-reclamation.test.js.map +0 -1
- package/dist/__tests__/session-record-disclosure.test.d.ts +0 -24
- package/dist/__tests__/session-record-disclosure.test.d.ts.map +0 -1
- package/dist/__tests__/session-record-disclosure.test.js +0 -494
- package/dist/__tests__/session-record-disclosure.test.js.map +0 -1
- package/dist/__tests__/session-status.test.d.ts +0 -11
- package/dist/__tests__/session-status.test.d.ts.map +0 -1
- package/dist/__tests__/session-status.test.js +0 -76
- package/dist/__tests__/session-status.test.js.map +0 -1
- package/dist/__tests__/session.test.d.ts +0 -15
- package/dist/__tests__/session.test.d.ts.map +0 -1
- package/dist/__tests__/session.test.js +0 -366
- package/dist/__tests__/session.test.js.map +0 -1
- package/dist/__tests__/shim-deploy-safety.test.d.ts +0 -24
- package/dist/__tests__/shim-deploy-safety.test.d.ts.map +0 -1
- package/dist/__tests__/shim-deploy-safety.test.js +0 -174
- package/dist/__tests__/shim-deploy-safety.test.js.map +0 -1
- package/dist/__tests__/slug-validation.test.d.ts +0 -13
- package/dist/__tests__/slug-validation.test.d.ts.map +0 -1
- package/dist/__tests__/slug-validation.test.js +0 -202
- package/dist/__tests__/slug-validation.test.js.map +0 -1
- package/dist/__tests__/standards-injection.test.d.ts +0 -2
- package/dist/__tests__/standards-injection.test.d.ts.map +0 -1
- package/dist/__tests__/standards-injection.test.js +0 -179
- package/dist/__tests__/standards-injection.test.js.map +0 -1
- package/dist/__tests__/start-config-conflict.test.d.ts +0 -17
- package/dist/__tests__/start-config-conflict.test.d.ts.map +0 -1
- package/dist/__tests__/start-config-conflict.test.js +0 -101
- package/dist/__tests__/start-config-conflict.test.js.map +0 -1
- package/dist/__tests__/start-interactive-role.test.d.ts +0 -22
- package/dist/__tests__/start-interactive-role.test.d.ts.map +0 -1
- package/dist/__tests__/start-interactive-role.test.js +0 -204
- package/dist/__tests__/start-interactive-role.test.js.map +0 -1
- package/dist/__tests__/start-rebase-never-ran.test.d.ts +0 -25
- package/dist/__tests__/start-rebase-never-ran.test.d.ts.map +0 -1
- package/dist/__tests__/start-rebase-never-ran.test.js +0 -227
- package/dist/__tests__/start-rebase-never-ran.test.js.map +0 -1
- package/dist/__tests__/start-report-generation-capture.test.d.ts +0 -17
- package/dist/__tests__/start-report-generation-capture.test.d.ts.map +0 -1
- package/dist/__tests__/start-report-generation-capture.test.js +0 -127
- package/dist/__tests__/start-report-generation-capture.test.js.map +0 -1
- package/dist/__tests__/start-report-integration.test.d.ts +0 -12
- package/dist/__tests__/start-report-integration.test.d.ts.map +0 -1
- package/dist/__tests__/start-report-integration.test.js +0 -138
- package/dist/__tests__/start-report-integration.test.js.map +0 -1
- package/dist/__tests__/start-runtime-wiring.test.d.ts +0 -31
- package/dist/__tests__/start-runtime-wiring.test.d.ts.map +0 -1
- package/dist/__tests__/start-runtime-wiring.test.js +0 -735
- package/dist/__tests__/start-runtime-wiring.test.js.map +0 -1
- package/dist/__tests__/start-stash.test.d.ts +0 -2
- package/dist/__tests__/start-stash.test.d.ts.map +0 -1
- package/dist/__tests__/start-stash.test.js +0 -131
- package/dist/__tests__/start-stash.test.js.map +0 -1
- package/dist/__tests__/start-sync-hardstop.test.d.ts +0 -15
- package/dist/__tests__/start-sync-hardstop.test.d.ts.map +0 -1
- package/dist/__tests__/start-sync-hardstop.test.js +0 -280
- package/dist/__tests__/start-sync-hardstop.test.js.map +0 -1
- package/dist/__tests__/start-team-identity.test.d.ts +0 -25
- package/dist/__tests__/start-team-identity.test.d.ts.map +0 -1
- package/dist/__tests__/start-team-identity.test.js +0 -307
- package/dist/__tests__/start-team-identity.test.js.map +0 -1
- package/dist/__tests__/startup-health-render.test.d.ts +0 -11
- package/dist/__tests__/startup-health-render.test.d.ts.map +0 -1
- package/dist/__tests__/startup-health-render.test.js +0 -60
- package/dist/__tests__/startup-health-render.test.js.map +0 -1
- package/dist/__tests__/startup-policy.test.d.ts +0 -2
- package/dist/__tests__/startup-policy.test.d.ts.map +0 -1
- package/dist/__tests__/startup-policy.test.js +0 -27
- package/dist/__tests__/startup-policy.test.js.map +0 -1
- package/dist/__tests__/startup-report.test.d.ts +0 -13
- package/dist/__tests__/startup-report.test.d.ts.map +0 -1
- package/dist/__tests__/startup-report.test.js +0 -278
- package/dist/__tests__/startup-report.test.js.map +0 -1
- package/dist/__tests__/startup-shipper.test.d.ts +0 -13
- package/dist/__tests__/startup-shipper.test.d.ts.map +0 -1
- package/dist/__tests__/startup-shipper.test.js +0 -149
- package/dist/__tests__/startup-shipper.test.js.map +0 -1
- package/dist/__tests__/stream-input-controller.test.d.ts +0 -10
- package/dist/__tests__/stream-input-controller.test.d.ts.map +0 -1
- package/dist/__tests__/stream-input-controller.test.js +0 -167
- package/dist/__tests__/stream-input-controller.test.js.map +0 -1
- package/dist/__tests__/team-memory-commands.test.d.ts +0 -11
- package/dist/__tests__/team-memory-commands.test.d.ts.map +0 -1
- package/dist/__tests__/team-memory-commands.test.js +0 -240
- package/dist/__tests__/team-memory-commands.test.js.map +0 -1
- package/dist/__tests__/team-name-propagation.test.d.ts +0 -13
- package/dist/__tests__/team-name-propagation.test.d.ts.map +0 -1
- package/dist/__tests__/team-name-propagation.test.js +0 -198
- package/dist/__tests__/team-name-propagation.test.js.map +0 -1
- package/dist/__tests__/team-token-probe.test.d.ts +0 -16
- package/dist/__tests__/team-token-probe.test.d.ts.map +0 -1
- package/dist/__tests__/team-token-probe.test.js +0 -295
- package/dist/__tests__/team-token-probe.test.js.map +0 -1
- package/dist/__tests__/template-budget.test.d.ts +0 -2
- package/dist/__tests__/template-budget.test.d.ts.map +0 -1
- package/dist/__tests__/template-budget.test.js +0 -119
- package/dist/__tests__/template-budget.test.js.map +0 -1
- package/dist/__tests__/template-sync.test.d.ts +0 -19
- package/dist/__tests__/template-sync.test.d.ts.map +0 -1
- package/dist/__tests__/template-sync.test.js +0 -480
- package/dist/__tests__/template-sync.test.js.map +0 -1
- package/dist/__tests__/test-project.test.d.ts +0 -18
- package/dist/__tests__/test-project.test.d.ts.map +0 -1
- package/dist/__tests__/test-project.test.js +0 -465
- package/dist/__tests__/test-project.test.js.map +0 -1
- package/dist/__tests__/tracked-instruction-files.test.d.ts +0 -21
- package/dist/__tests__/tracked-instruction-files.test.d.ts.map +0 -1
- package/dist/__tests__/tracked-instruction-files.test.js +0 -489
- package/dist/__tests__/tracked-instruction-files.test.js.map +0 -1
- package/dist/__tests__/unlock.test.d.ts +0 -11
- package/dist/__tests__/unlock.test.d.ts.map +0 -1
- package/dist/__tests__/unlock.test.js +0 -100
- package/dist/__tests__/unlock.test.js.map +0 -1
- package/dist/__tests__/usage-per-call-grouping.test.d.ts +0 -25
- package/dist/__tests__/usage-per-call-grouping.test.d.ts.map +0 -1
- package/dist/__tests__/usage-per-call-grouping.test.js +0 -952
- package/dist/__tests__/usage-per-call-grouping.test.js.map +0 -1
- package/dist/__tests__/usage-pricing.test.d.ts +0 -20
- package/dist/__tests__/usage-pricing.test.d.ts.map +0 -1
- package/dist/__tests__/usage-pricing.test.js +0 -176
- package/dist/__tests__/usage-pricing.test.js.map +0 -1
- package/dist/__tests__/usage-subagent-discovery.test.d.ts +0 -17
- package/dist/__tests__/usage-subagent-discovery.test.d.ts.map +0 -1
- package/dist/__tests__/usage-subagent-discovery.test.js +0 -213
- package/dist/__tests__/usage-subagent-discovery.test.js.map +0 -1
- package/dist/__tests__/verify-hooks-check-all.test.d.ts +0 -32
- package/dist/__tests__/verify-hooks-check-all.test.d.ts.map +0 -1
- package/dist/__tests__/verify-hooks-check-all.test.js +0 -563
- package/dist/__tests__/verify-hooks-check-all.test.js.map +0 -1
- package/dist/__tests__/verify-hooks-heal-log.test.d.ts +0 -11
- package/dist/__tests__/verify-hooks-heal-log.test.d.ts.map +0 -1
- package/dist/__tests__/verify-hooks-heal-log.test.js +0 -172
- package/dist/__tests__/verify-hooks-heal-log.test.js.map +0 -1
- package/dist/__tests__/worker-cap.test.d.ts +0 -14
- package/dist/__tests__/worker-cap.test.d.ts.map +0 -1
- package/dist/__tests__/worker-cap.test.js +0 -97
- package/dist/__tests__/worker-cap.test.js.map +0 -1
- package/dist/__tests__/worktree-link-repair.test.d.ts +0 -2
- package/dist/__tests__/worktree-link-repair.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-link-repair.test.js +0 -471
- package/dist/__tests__/worktree-link-repair.test.js.map +0 -1
- package/dist/__tests__/worktree-sync-fixture.test.d.ts +0 -17
- package/dist/__tests__/worktree-sync-fixture.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-sync-fixture.test.js +0 -519
- package/dist/__tests__/worktree-sync-fixture.test.js.map +0 -1
- package/dist/__tests__/worktree-sync-hardening.test.d.ts +0 -13
- package/dist/__tests__/worktree-sync-hardening.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-sync-hardening.test.js +0 -919
- package/dist/__tests__/worktree-sync-hardening.test.js.map +0 -1
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts +0 -25
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts.map +0 -1
- package/dist/__tests__/worktree-sync-shell-free.test.js +0 -185
- package/dist/__tests__/worktree-sync-shell-free.test.js.map +0 -1
- package/dist/__tests__/worktree.test.d.ts +0 -2
- package/dist/__tests__/worktree.test.d.ts.map +0 -1
- package/dist/__tests__/worktree.test.js +0 -168
- package/dist/__tests__/worktree.test.js.map +0 -1
- package/dist/lib/code-context-file.test.d.ts +0 -19
- package/dist/lib/code-context-file.test.d.ts.map +0 -1
- package/dist/lib/code-context-file.test.js +0 -202
- package/dist/lib/code-context-file.test.js.map +0 -1
- package/dist/lib/harness/console/announce.test.d.ts +0 -2
- package/dist/lib/harness/console/announce.test.d.ts.map +0 -1
- package/dist/lib/harness/console/announce.test.js +0 -104
- package/dist/lib/harness/console/announce.test.js.map +0 -1
- package/dist/lib/harness/console/by-session.test.d.ts +0 -2
- package/dist/lib/harness/console/by-session.test.d.ts.map +0 -1
- package/dist/lib/harness/console/by-session.test.js +0 -86
- package/dist/lib/harness/console/by-session.test.js.map +0 -1
- package/dist/lib/harness/console/console.test.d.ts +0 -2
- package/dist/lib/harness/console/console.test.d.ts.map +0 -1
- package/dist/lib/harness/console/console.test.js +0 -269
- package/dist/lib/harness/console/console.test.js.map +0 -1
- package/dist/lib/harness/console/decision-request.test.d.ts +0 -2
- package/dist/lib/harness/console/decision-request.test.d.ts.map +0 -1
- package/dist/lib/harness/console/decision-request.test.js +0 -75
- package/dist/lib/harness/console/decision-request.test.js.map +0 -1
- package/dist/lib/harness/console/rank.test.d.ts +0 -2
- package/dist/lib/harness/console/rank.test.d.ts.map +0 -1
- package/dist/lib/harness/console/rank.test.js +0 -124
- package/dist/lib/harness/console/rank.test.js.map +0 -1
- package/dist/lib/harness/console/render.test.d.ts +0 -2
- package/dist/lib/harness/console/render.test.d.ts.map +0 -1
- package/dist/lib/harness/console/render.test.js +0 -96
- package/dist/lib/harness/console/render.test.js.map +0 -1
- package/dist/lib/harness/console/replay-cli.test.d.ts +0 -2
- package/dist/lib/harness/console/replay-cli.test.d.ts.map +0 -1
- package/dist/lib/harness/console/replay-cli.test.js +0 -96
- package/dist/lib/harness/console/replay-cli.test.js.map +0 -1
- package/dist/lib/harness/console/replay.test.d.ts +0 -2
- package/dist/lib/harness/console/replay.test.d.ts.map +0 -1
- package/dist/lib/harness/console/replay.test.js +0 -81
- package/dist/lib/harness/console/replay.test.js.map +0 -1
- package/dist/lib/harness/console/turn-reader.test.d.ts +0 -2
- package/dist/lib/harness/console/turn-reader.test.d.ts.map +0 -1
- package/dist/lib/harness/console/turn-reader.test.js +0 -108
- package/dist/lib/harness/console/turn-reader.test.js.map +0 -1
- package/dist/lib/harness/credential.test.d.ts +0 -2
- package/dist/lib/harness/credential.test.d.ts.map +0 -1
- package/dist/lib/harness/credential.test.js +0 -74
- package/dist/lib/harness/credential.test.js.map +0 -1
- package/dist/lib/harness/evaluate.test.d.ts +0 -2
- package/dist/lib/harness/evaluate.test.d.ts.map +0 -1
- package/dist/lib/harness/evaluate.test.js +0 -621
- package/dist/lib/harness/evaluate.test.js.map +0 -1
- package/dist/lib/harness/gate.test.d.ts +0 -2
- package/dist/lib/harness/gate.test.d.ts.map +0 -1
- package/dist/lib/harness/gate.test.js +0 -111
- package/dist/lib/harness/gate.test.js.map +0 -1
- package/dist/lib/harness/self-check.test.d.ts +0 -2
- package/dist/lib/harness/self-check.test.d.ts.map +0 -1
- package/dist/lib/harness/self-check.test.js +0 -43
- package/dist/lib/harness/self-check.test.js.map +0 -1
- package/dist/lib/harness/transcript.test.d.ts +0 -2
- package/dist/lib/harness/transcript.test.d.ts.map +0 -1
- package/dist/lib/harness/transcript.test.js +0 -118
- package/dist/lib/harness/transcript.test.js.map +0 -1
- package/dist/lib/projects-registry.test.d.ts +0 -2
- package/dist/lib/projects-registry.test.d.ts.map +0 -1
- package/dist/lib/projects-registry.test.js +0 -176
- package/dist/lib/projects-registry.test.js.map +0 -1
- package/dist/lib/roster.test.d.ts +0 -15
- package/dist/lib/roster.test.d.ts.map +0 -1
- package/dist/lib/roster.test.js +0 -299
- package/dist/lib/roster.test.js.map +0 -1
- package/dist/lib/vault.test.d.ts +0 -17
- package/dist/lib/vault.test.d.ts.map +0 -1
- package/dist/lib/vault.test.js +0 -169
- package/dist/lib/vault.test.js.map +0 -1
- package/dist/lib/window-view.test.d.ts +0 -2
- package/dist/lib/window-view.test.d.ts.map +0 -1
- package/dist/lib/window-view.test.js +0 -168
- package/dist/lib/window-view.test.js.map +0 -1
- package/dist/standards/fail-loud-standard.md +0 -495
- package/dist/standards/known-issues-standard.md +0 -380
- package/dist/standards/rulings.md +0 -104
|
@@ -1,1015 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the `.claude/` generator (scripts/generate-claude.mjs) — Direction B
|
|
3
|
-
* config single-source-of-truth (#4304), Phase 2.
|
|
4
|
-
*
|
|
5
|
-
* The load-bearing guarantee is the BYTE-IDENTICAL NO-OP: generating from the
|
|
6
|
-
* committed `agent-config/` (+ `local/`) must reproduce the committed `.claude/`
|
|
7
|
-
* exactly, so shipping the generator while `.claude/` is still committed changes
|
|
8
|
-
* nothing.
|
|
9
|
-
*
|
|
10
|
-
* NO SYMLINKS, ANYWHERE (PO directive 2026-07-20): the generator emits only plain
|
|
11
|
-
* files and real directories and FAILS CLOSED on any symlink in the source tree
|
|
12
|
-
* (nothing materialized). These tests lock down the no-op, idempotence, the
|
|
13
|
-
* symlink ban, the container-boot split (permission layer from origin / rest from
|
|
14
|
-
* working tree), and the fail-closed guards — including through the REAL
|
|
15
|
-
* production path (`generateClaudeConfigFromGit` against a committed git fixture).
|
|
16
|
-
*/
|
|
17
|
-
import { describe, it, expect, beforeAll, beforeEach, afterEach, afterAll, vi } from 'vitest';
|
|
18
|
-
import { cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, rmSync, statSync, symlinkSync, writeFileSync, } from 'fs';
|
|
19
|
-
import { tmpdir } from 'os';
|
|
20
|
-
import { dirname, join } from 'path';
|
|
21
|
-
import { fileURLToPath } from 'url';
|
|
22
|
-
import { spawnSync } from 'child_process';
|
|
23
|
-
// @ts-expect-error — plain ESM script, no type declarations.
|
|
24
|
-
import { generateClaudeConfig, generateClaudeConfigFromGit, generateClaudeConfigForBoot, refreshPermissionCache, sweepOrphanSiblings } from '../../scripts/generate-claude.mjs';
|
|
25
|
-
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
26
|
-
/** Walk up from the test file to the repo root that holds mx-agent-system/agent-config. */
|
|
27
|
-
function findRepoRoot() {
|
|
28
|
-
let dir = HERE;
|
|
29
|
-
for (let i = 0; i < 20; i++) {
|
|
30
|
-
if (existsSync(join(dir, 'mx-agent-system', 'agent-config', 'settings.json')))
|
|
31
|
-
return dir;
|
|
32
|
-
const parent = dirname(dir);
|
|
33
|
-
if (parent === dir)
|
|
34
|
-
break;
|
|
35
|
-
dir = parent;
|
|
36
|
-
}
|
|
37
|
-
throw new Error('could not locate repo root from ' + HERE);
|
|
38
|
-
}
|
|
39
|
-
const REPO_ROOT = findRepoRoot();
|
|
40
|
-
const CONFIG_SOURCE = 'mx-agent-system/agent-config';
|
|
41
|
-
const SRC = join(REPO_ROOT, CONFIG_SOURCE);
|
|
42
|
-
/** The generator script itself, for the cases that exercise its argv parsing. */
|
|
43
|
-
const SCRIPT = join(HERE, '..', '..', 'scripts', 'generate-claude.mjs');
|
|
44
|
-
const COMMITTED_CLAUDE = join(REPO_ROOT, '.claude');
|
|
45
|
-
/**
|
|
46
|
-
* Post-Phase-4 mode switch (#4304). The byte-identical NO-OP-vs-committed
|
|
47
|
-
* assertions below only make sense while `.claude/` is git-TRACKED (the committed
|
|
48
|
-
* artifact is authoritative). Phase 4 gitignores + untracks `.claude/`; the
|
|
49
|
-
* committed tree is then no longer authoritative (and absent in a fresh CI clone),
|
|
50
|
-
* so those assertions SKIP and generation stability is carried by the idempotence
|
|
51
|
-
* + symlink-ban + fail-closed suites (which read no committed state). Keyed on
|
|
52
|
-
* git-tracking (not existsSync) so a still-on-disk-but-untracked worktree copy
|
|
53
|
-
* behaves the same locally as a fresh CI clone. Fails toward untracked.
|
|
54
|
-
*/
|
|
55
|
-
function claudeIsTracked(repoRoot) {
|
|
56
|
-
try {
|
|
57
|
-
const out = spawnSync('git', ['ls-files', '.claude/'], { cwd: repoRoot, encoding: 'utf-8' });
|
|
58
|
-
return out.status === 0 && typeof out.stdout === 'string' && out.stdout.trim().length > 0;
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const CLAUDE_TRACKED = claudeIsTracked(REPO_ROOT);
|
|
65
|
-
/** baseDir/overlayDir for a copied agent-config tree at <root>/<CONFIG_SOURCE>. */
|
|
66
|
-
function layers(srcRoot) {
|
|
67
|
-
return { baseDir: srcRoot, overlayDir: join(srcRoot, 'local') };
|
|
68
|
-
}
|
|
69
|
-
/** Recursively list files (relative POSIX paths) and symlinks under a dir. */
|
|
70
|
-
function walk(root, base = '') {
|
|
71
|
-
const files = [];
|
|
72
|
-
const links = [];
|
|
73
|
-
for (const ent of readdirSync(join(root, base), { withFileTypes: true })) {
|
|
74
|
-
const rel = base ? `${base}/${ent.name}` : ent.name;
|
|
75
|
-
if (ent.isSymbolicLink())
|
|
76
|
-
links.push(rel);
|
|
77
|
-
else if (ent.isDirectory()) {
|
|
78
|
-
const sub = walk(root, rel);
|
|
79
|
-
files.push(...sub.files);
|
|
80
|
-
links.push(...sub.links);
|
|
81
|
-
}
|
|
82
|
-
else if (ent.isFile())
|
|
83
|
-
files.push(rel);
|
|
84
|
-
}
|
|
85
|
-
return { files: files.sort(), links: links.sort() };
|
|
86
|
-
}
|
|
87
|
-
let tmpRoots = [];
|
|
88
|
-
function mkTmp(prefix) {
|
|
89
|
-
const d = mkdtempSync(join(tmpdir(), prefix));
|
|
90
|
-
tmpRoots.push(d);
|
|
91
|
-
return d;
|
|
92
|
-
}
|
|
93
|
-
afterEach(() => {
|
|
94
|
-
for (const d of tmpRoots)
|
|
95
|
-
rmSync(d, { recursive: true, force: true });
|
|
96
|
-
tmpRoots = [];
|
|
97
|
-
});
|
|
98
|
-
// Isolate the origin-verified permission cache (~/.mx-agent/, Red Team CRITICAL B)
|
|
99
|
-
// to a throwaway HOME so the fromGit/boot paths — which now refresh the cache —
|
|
100
|
-
// never touch the real home dir. Each test gets a fresh HOME (cleaned by afterEach
|
|
101
|
-
// via tmpRoots), so cache state does not leak between tests.
|
|
102
|
-
let ORIG_HOME;
|
|
103
|
-
beforeAll(() => { ORIG_HOME = process.env.HOME; });
|
|
104
|
-
beforeEach(() => { process.env.HOME = mkTmp('mx-genclaude-home-'); });
|
|
105
|
-
afterAll(() => {
|
|
106
|
-
if (ORIG_HOME === undefined)
|
|
107
|
-
delete process.env.HOME;
|
|
108
|
-
else
|
|
109
|
-
process.env.HOME = ORIG_HOME;
|
|
110
|
-
});
|
|
111
|
-
/**
|
|
112
|
-
* Copy the real committed agent-config source into an isolated <tmp>/<CONFIG_SOURCE>.
|
|
113
|
-
* The source is symlink-free now (the mx-find/mx-rules/mx-save command files are
|
|
114
|
-
* plain files), so a plain recursive copy is a faithful reproduction.
|
|
115
|
-
*/
|
|
116
|
-
function buildFixture() {
|
|
117
|
-
const root = mkTmp('mx-genclaude-fx-');
|
|
118
|
-
const src = join(root, CONFIG_SOURCE);
|
|
119
|
-
mkdirSync(dirname(src), { recursive: true });
|
|
120
|
-
cpSync(SRC, src, { recursive: true });
|
|
121
|
-
return { root, src };
|
|
122
|
-
}
|
|
123
|
-
// ── byte-identical no-op ──────────────────────────────────────────────────────
|
|
124
|
-
describe('generateClaudeConfig — byte-identical no-op vs committed .claude', () => {
|
|
125
|
-
let dest;
|
|
126
|
-
let root;
|
|
127
|
-
beforeAll(() => {
|
|
128
|
-
root = mkdtempSync(join(tmpdir(), 'mx-genclaude-noop-'));
|
|
129
|
-
const src = join(root, CONFIG_SOURCE);
|
|
130
|
-
mkdirSync(dirname(src), { recursive: true });
|
|
131
|
-
cpSync(SRC, src, { recursive: true });
|
|
132
|
-
dest = join(root, '.claude');
|
|
133
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
134
|
-
});
|
|
135
|
-
(CLAUDE_TRACKED ? it : it.skip)('reproduces every committed regular file byte-for-byte', () => {
|
|
136
|
-
const committed = walk(COMMITTED_CLAUDE);
|
|
137
|
-
// Ignore runtime-only artifacts that live in .claude/ but are not managed
|
|
138
|
-
// config (settings.local.json, scheduled task locks).
|
|
139
|
-
const managed = committed.files.filter(f => f !== 'settings.local.json' && !f.endsWith('.lock') && !f.startsWith('scheduled_tasks'));
|
|
140
|
-
for (const rel of managed) {
|
|
141
|
-
const g = join(dest, rel);
|
|
142
|
-
expect(existsSync(g), `generated missing ${rel}`).toBe(true);
|
|
143
|
-
expect(readFileSync(g).equals(readFileSync(join(COMMITTED_CLAUDE, rel))), `content mismatch: ${rel}`).toBe(true);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
it('emits ZERO symlinks in generated output', () => {
|
|
147
|
-
expect(walk(dest).links).toEqual([]);
|
|
148
|
-
});
|
|
149
|
-
(CLAUDE_TRACKED ? it : it.skip)('the committed .claude tree has zero symlinks', () => {
|
|
150
|
-
expect(walk(COMMITTED_CLAUDE).links).toEqual([]);
|
|
151
|
-
});
|
|
152
|
-
it('emits the mx-find/mx-rules/mx-save commands as plain regular files', () => {
|
|
153
|
-
for (const name of ['mx-find.md', 'mx-rules.md', 'mx-save.md']) {
|
|
154
|
-
const g = join(dest, 'commands', name);
|
|
155
|
-
expect(lstatSync(g).isSymbolicLink(), `${name} must not be a symlink`).toBe(false);
|
|
156
|
-
expect(lstatSync(g).isFile(), `${name} must be a regular file`).toBe(true);
|
|
157
|
-
// Byte-compare against the committed copy only while it is authoritative.
|
|
158
|
-
if (CLAUDE_TRACKED) {
|
|
159
|
-
expect(readFileSync(g).equals(readFileSync(join(COMMITTED_CLAUDE, 'commands', name)))).toBe(true);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
(CLAUDE_TRACKED ? it : it.skip)('produces no managed files absent from committed .claude', () => {
|
|
164
|
-
const committed = new Set(walk(COMMITTED_CLAUDE).files);
|
|
165
|
-
for (const rel of walk(dest).files) {
|
|
166
|
-
expect(committed.has(rel), `generated an extra file not in committed: ${rel}`).toBe(true);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
it('marks *.sh hooks executable (0755) and .conf non-executable', () => {
|
|
170
|
-
const shMode = statSync(join(dest, 'hooks', 'git-mutation-guard.sh')).mode & 0o777;
|
|
171
|
-
const confMode = statSync(join(dest, 'hooks', 'ci-validate-routes.conf')).mode & 0o777;
|
|
172
|
-
expect(shMode).toBe(0o755);
|
|
173
|
-
expect(confMode).toBe(0o644);
|
|
174
|
-
});
|
|
175
|
-
it('unions shipped + local agents (31) and skills (12)', () => {
|
|
176
|
-
// 27 before 2026-08-27; the gateway team added four local agent types
|
|
177
|
-
// (proxy-data-plane-engineer, token-composition-analyst,
|
|
178
|
-
// credential-custody-reviewer, wire-reliability-engineer).
|
|
179
|
-
// Skills were 13 until 2026-09-01, when the `codex` differential-review skill
|
|
180
|
-
// was removed by product owner ruling. The wrapper it named,
|
|
181
|
-
// `dev-tools/scripts/codex-review.sh`, has never existed in this repository,
|
|
182
|
-
// so the skill told every agent here to run a missing script. The review is
|
|
183
|
-
// scoped to the `memnexus` repository; see
|
|
184
|
-
// agent-config/local/skills/README.md.
|
|
185
|
-
expect(readdirSync(join(dest, 'agents')).filter(f => f.endsWith('.md')).length).toBe(31);
|
|
186
|
-
expect(readdirSync(join(dest, 'skills')).length).toBe(12);
|
|
187
|
-
});
|
|
188
|
-
it('(cleanup) removes the shared no-op fixture', () => {
|
|
189
|
-
rmSync(root, { recursive: true, force: true });
|
|
190
|
-
expect(existsSync(root)).toBe(false);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
// ── the SessionStart registration the stale-hook check ships as (#306) ────────
|
|
194
|
-
describe('generateClaudeConfig — SessionStart carries the stale-hook check first', () => {
|
|
195
|
-
// #306 criterion 1(e), at the generator level. config-generation-gate.test.ts
|
|
196
|
-
// asserts the same block in more detail; this one pins that the generator
|
|
197
|
-
// REPRODUCES it from agent-config/settings.json at all, so a transform added
|
|
198
|
-
// to the settings path cannot drop or reorder the entry unnoticed.
|
|
199
|
-
it('reproduces the check-all entry as the first SessionStart entry, with both timeouts', () => {
|
|
200
|
-
const { root, src } = buildFixture();
|
|
201
|
-
try {
|
|
202
|
-
const dest = join(root, '.claude');
|
|
203
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
204
|
-
const parsed = JSON.parse(readFileSync(join(dest, 'settings.json'), 'utf-8'));
|
|
205
|
-
const sessionStart = parsed.hooks.SessionStart;
|
|
206
|
-
expect(sessionStart[0].matcher).toBe('');
|
|
207
|
-
expect(sessionStart[0].hooks[0].command).toBe('bash -c \'if ! command -v mx-agent >/dev/null 2>&1; ' +
|
|
208
|
-
'then echo "hook freshness check COULD NOT RUN: mx-agent is not on PATH. Remedy: npm install -g @memnexus-ai/mx-agent-cli@latest"; ' +
|
|
209
|
-
'exit 0; fi; if ! timeout 5 mx-agent verify-hooks --help 2>/dev/null | grep -q -- --check-all; ' +
|
|
210
|
-
'then echo "hook freshness check COULD NOT RUN: this mx-agent build has no verify-hooks --check-all. Remedy: rebuild the fleet CLI from origin/main"; ' +
|
|
211
|
-
'exit 0; fi; timeout 10 mx-agent verify-hooks --check-all; c=$?; case "$c" in 0|2|3) ;; ' +
|
|
212
|
-
'*) echo "hook freshness check COULD NOT RUN: verify-hooks --check-all exited $c. Remedy: run it by hand";; ' +
|
|
213
|
-
'esac; exit 0\'');
|
|
214
|
-
expect(sessionStart[0].hooks[0].timeout).toBe(15);
|
|
215
|
-
// The check runs as a CLI command, not through a hook file: a check that
|
|
216
|
-
// was a file in .claude/hooks/ could itself be the stale file.
|
|
217
|
-
expect(sessionStart[0].hooks[0].command).not.toContain('.claude/hooks/');
|
|
218
|
-
expect(sessionStart).toHaveLength(3);
|
|
219
|
-
}
|
|
220
|
-
finally {
|
|
221
|
-
rmSync(root, { recursive: true, force: true });
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
// ── idempotence ────────────────────────────────────────────────────────────────
|
|
226
|
-
describe('generateClaudeConfig — idempotence', () => {
|
|
227
|
-
it('two runs produce identical output', () => {
|
|
228
|
-
const { root, src } = buildFixture();
|
|
229
|
-
const destA = join(root, '.claude');
|
|
230
|
-
generateClaudeConfig({ ...layers(src), destRoot: destA });
|
|
231
|
-
const snap1 = snapshot(destA);
|
|
232
|
-
generateClaudeConfig({ ...layers(src), destRoot: destA });
|
|
233
|
-
const snap2 = snapshot(destA);
|
|
234
|
-
expect(snap2).toEqual(snap1);
|
|
235
|
-
});
|
|
236
|
-
function snapshot(dest) {
|
|
237
|
-
const out = {};
|
|
238
|
-
const { files, links } = walk(dest);
|
|
239
|
-
for (const f of files)
|
|
240
|
-
out[f] = 'F:' + readFileSync(join(dest, f)).toString('base64');
|
|
241
|
-
for (const l of links)
|
|
242
|
-
out[l] = 'L:' + readlinkSync(join(dest, l));
|
|
243
|
-
return out;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
// ── symlink ban / FAIL-CLOSED ────────────────────────────────────────────────
|
|
247
|
-
describe('generateClaudeConfig — FAIL-CLOSED symlink ban (nothing materialized)', () => {
|
|
248
|
-
it('throws and materializes NOTHING when a command is a symlink', () => {
|
|
249
|
-
const { root, src } = buildFixture();
|
|
250
|
-
const dest = join(root, '.claude');
|
|
251
|
-
symlinkSync('../../../../etc/passwd', join(src, 'local', 'commands', 'evil.md'));
|
|
252
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
253
|
-
expect(existsSync(dest)).toBe(false);
|
|
254
|
-
});
|
|
255
|
-
it('throws and materializes NOTHING when a skill file is a symlink (deep)', () => {
|
|
256
|
-
const { root, src } = buildFixture();
|
|
257
|
-
const dest = join(root, '.claude');
|
|
258
|
-
const skillDir = join(src, 'skills', 'mx-save');
|
|
259
|
-
symlinkSync('SKILL.md', join(skillDir, 'aliased.md'));
|
|
260
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
261
|
-
expect(existsSync(dest)).toBe(false);
|
|
262
|
-
});
|
|
263
|
-
it('throws and materializes NOTHING when a rules file is a symlink', () => {
|
|
264
|
-
const { root, src } = buildFixture();
|
|
265
|
-
const dest = join(root, '.claude');
|
|
266
|
-
symlinkSync('eval-harness.md', join(src, 'rules', 'aliased-rule.md'));
|
|
267
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
268
|
-
expect(existsSync(dest)).toBe(false);
|
|
269
|
-
});
|
|
270
|
-
it('accepts a fully symlink-free source (control)', () => {
|
|
271
|
-
const { root, src } = buildFixture();
|
|
272
|
-
const dest = join(root, '.claude');
|
|
273
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).not.toThrow();
|
|
274
|
-
expect(walk(dest).links).toEqual([]);
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
describe('generateClaudeConfig — prune guard (Red Team MAJOR 4)', () => {
|
|
278
|
-
it('FAILS CLOSED when a managed dest subdir is itself a symlink', () => {
|
|
279
|
-
const { root, src } = buildFixture();
|
|
280
|
-
const dest = join(root, '.claude');
|
|
281
|
-
mkdirSync(dest, { recursive: true });
|
|
282
|
-
// Attacker pre-plants a `hooks` symlink pointing outside .claude/.
|
|
283
|
-
const outside = mkTmp('mx-genclaude-outside-');
|
|
284
|
-
symlinkSync(outside, join(dest, 'hooks'));
|
|
285
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
286
|
-
// The symlinked-away directory was never pruned/written through.
|
|
287
|
-
expect(walk(outside).files).toEqual([]);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
// ── nested dest-side symlink guard (Red Team CRITICAL A) ──────────────────────
|
|
291
|
-
//
|
|
292
|
-
// guardManagedDir was only applied to the 4 apex managed dirs. A pre-planted
|
|
293
|
-
// symlink at a NESTED dest dir (.claude/skills/<name>, .claude/commands/<name>,
|
|
294
|
-
// or a deeper subdir) was followed by mkdirSync/writeFileSync, letting a write
|
|
295
|
-
// escape .claude/. The fix guards every dest-dir mkdir; these tests plant symlinks
|
|
296
|
-
// at each nested level and assert FAIL-CLOSED with the target sentinel untouched.
|
|
297
|
-
describe('generateClaudeConfig — nested dest symlink guard (Red Team CRITICAL A)', () => {
|
|
298
|
-
/** Scratch dir holding a sentinel that a followed symlink would clobber. */
|
|
299
|
-
function scratchWithSentinel() {
|
|
300
|
-
const dir = mkTmp('mx-genclaude-target-');
|
|
301
|
-
const sentinel = join(dir, 'sentinel.txt');
|
|
302
|
-
const bytes = 'DO NOT TOUCH\n';
|
|
303
|
-
writeFileSync(sentinel, bytes);
|
|
304
|
-
return { dir, sentinel, bytes };
|
|
305
|
-
}
|
|
306
|
-
it('FAILS CLOSED when .claude/skills/<name> (apex skill dir) is a symlink', () => {
|
|
307
|
-
const { root, src } = buildFixture();
|
|
308
|
-
const dest = join(root, '.claude');
|
|
309
|
-
const { dir: target, sentinel, bytes } = scratchWithSentinel();
|
|
310
|
-
// Pick a skill that exists in the source so the loop reaches it.
|
|
311
|
-
const skillName = readdirSync(join(src, 'skills'), { withFileTypes: true })
|
|
312
|
-
.find(e => e.isDirectory()).name;
|
|
313
|
-
mkdirSync(join(dest, 'skills'), { recursive: true });
|
|
314
|
-
symlinkSync(target, join(dest, 'skills', skillName));
|
|
315
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
316
|
-
expect(readFileSync(sentinel, 'utf-8')).toBe(bytes);
|
|
317
|
-
expect(walk(target).files).toEqual(['sentinel.txt']); // nothing written through
|
|
318
|
-
});
|
|
319
|
-
it('FAILS CLOSED when a DEEP nested skill subdir is a symlink', () => {
|
|
320
|
-
const { root, src } = buildFixture();
|
|
321
|
-
const dest = join(root, '.claude');
|
|
322
|
-
const { dir: target, sentinel, bytes } = scratchWithSentinel();
|
|
323
|
-
// Give a source skill a `sub/` subdir so copyFileTree recurses into it.
|
|
324
|
-
const skillName = readdirSync(join(src, 'skills'), { withFileTypes: true })
|
|
325
|
-
.find(e => e.isDirectory()).name;
|
|
326
|
-
mkdirSync(join(src, 'skills', skillName, 'sub'), { recursive: true });
|
|
327
|
-
writeFileSync(join(src, 'skills', skillName, 'sub', 'note.md'), '# note\n');
|
|
328
|
-
// Pre-plant the parent as a REAL dir and the nested `sub` as a symlink.
|
|
329
|
-
mkdirSync(join(dest, 'skills', skillName), { recursive: true });
|
|
330
|
-
symlinkSync(target, join(dest, 'skills', skillName, 'sub'));
|
|
331
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
332
|
-
expect(readFileSync(sentinel, 'utf-8')).toBe(bytes);
|
|
333
|
-
expect(walk(target).files).toEqual(['sentinel.txt']);
|
|
334
|
-
});
|
|
335
|
-
it('FAILS CLOSED when .claude/commands/<name> (a command DIR) is a symlink', () => {
|
|
336
|
-
const { root, src } = buildFixture();
|
|
337
|
-
const dest = join(root, '.claude');
|
|
338
|
-
const { dir: target, sentinel, bytes } = scratchWithSentinel();
|
|
339
|
-
// Add a directory-shaped command to the overlay so the per-command dir loop runs.
|
|
340
|
-
const cmdDir = join(src, 'local', 'commands', 'evil-cmd');
|
|
341
|
-
mkdirSync(cmdDir, { recursive: true });
|
|
342
|
-
writeFileSync(join(cmdDir, 'inner.md'), '# inner\n');
|
|
343
|
-
mkdirSync(join(dest, 'commands'), { recursive: true });
|
|
344
|
-
symlinkSync(target, join(dest, 'commands', 'evil-cmd'));
|
|
345
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
346
|
-
expect(readFileSync(sentinel, 'utf-8')).toBe(bytes);
|
|
347
|
-
expect(walk(target).files).toEqual(['sentinel.txt']);
|
|
348
|
-
});
|
|
349
|
-
it('FAILS CLOSED when the dest APEX (.claude) itself is a symlink', () => {
|
|
350
|
-
const { root, src } = buildFixture();
|
|
351
|
-
const { dir: target, sentinel, bytes } = scratchWithSentinel();
|
|
352
|
-
// Pre-plant `.claude` itself as a symlink to an outside sentinel dir. Without
|
|
353
|
-
// the apex guard, mkdirSync(destRoot) follows it and every write escapes.
|
|
354
|
-
const dest = join(root, '.claude');
|
|
355
|
-
symlinkSync(target, dest);
|
|
356
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).toThrow(/FAIL-CLOSED/);
|
|
357
|
-
expect(readFileSync(sentinel, 'utf-8')).toBe(bytes);
|
|
358
|
-
expect(walk(target).files).toEqual(['sentinel.txt']); // nothing written through
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
// ── generate-to-staging + atomic swap (Phase 4 prereq, Red Team finding 1) ─────
|
|
362
|
-
//
|
|
363
|
-
// Generation builds the whole tree in a `.claude.staging-*` sibling and swaps it
|
|
364
|
-
// into place. A crash mid-generation must leave the existing `.claude/` BYTE-
|
|
365
|
-
// untouched and leave no staging/prev debris behind. The swap must also carry
|
|
366
|
-
// over user-local, non-generated files (settings.local.json + any stray file).
|
|
367
|
-
describe('generateClaudeConfig — generate-to-staging + atomic swap', () => {
|
|
368
|
-
/** Content+mode snapshot of every regular file under dest, keyed by rel path. */
|
|
369
|
-
function snapshotWithModes(dest) {
|
|
370
|
-
const out = {};
|
|
371
|
-
for (const rel of walk(dest).files) {
|
|
372
|
-
const abs = join(dest, rel);
|
|
373
|
-
out[rel] = `${(statSync(abs).mode & 0o777).toString(8)}:${readFileSync(abs).toString('base64')}`;
|
|
374
|
-
}
|
|
375
|
-
return out;
|
|
376
|
-
}
|
|
377
|
-
/** Names of transient swap artifacts left as siblings of destRoot, if any. */
|
|
378
|
-
function swapDebris(parent) {
|
|
379
|
-
return readdirSync(parent)
|
|
380
|
-
.filter((n) => n.startsWith('.claude.staging-') || n.startsWith('.claude.prev-'))
|
|
381
|
-
.sort();
|
|
382
|
-
}
|
|
383
|
-
it('crash before swap leaves existing .claude byte-untouched and no staging debris', () => {
|
|
384
|
-
const { root, src } = buildFixture();
|
|
385
|
-
const dest = join(root, '.claude');
|
|
386
|
-
// First generation succeeds and materializes the tree.
|
|
387
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
388
|
-
const before = snapshotWithModes(dest);
|
|
389
|
-
expect(Object.keys(before).length).toBeGreaterThan(0);
|
|
390
|
-
// Second generation crashes AFTER staging is fully built, BEFORE the swap.
|
|
391
|
-
process.env.MX_GENCLAUDE_TEST_FAIL_BEFORE_SWAP = '1';
|
|
392
|
-
try {
|
|
393
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest }))
|
|
394
|
-
.toThrow(/injected pre-swap failure/);
|
|
395
|
-
}
|
|
396
|
-
finally {
|
|
397
|
-
delete process.env.MX_GENCLAUDE_TEST_FAIL_BEFORE_SWAP;
|
|
398
|
-
}
|
|
399
|
-
// Existing .claude is byte- AND mode-identical to before the failed run.
|
|
400
|
-
expect(snapshotWithModes(dest)).toEqual(before);
|
|
401
|
-
// No `.claude.staging-*` / `.claude.prev-*` sibling survived the failure.
|
|
402
|
-
expect(swapDebris(root)).toEqual([]);
|
|
403
|
-
});
|
|
404
|
-
it('first-ever generation crash before swap materializes NO .claude and no debris', () => {
|
|
405
|
-
const { root, src } = buildFixture();
|
|
406
|
-
const dest = join(root, '.claude');
|
|
407
|
-
process.env.MX_GENCLAUDE_TEST_FAIL_BEFORE_SWAP = '1';
|
|
408
|
-
try {
|
|
409
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest }))
|
|
410
|
-
.toThrow(/injected pre-swap failure/);
|
|
411
|
-
}
|
|
412
|
-
finally {
|
|
413
|
-
delete process.env.MX_GENCLAUDE_TEST_FAIL_BEFORE_SWAP;
|
|
414
|
-
}
|
|
415
|
-
expect(existsSync(dest)).toBe(false);
|
|
416
|
-
expect(swapDebris(root)).toEqual([]);
|
|
417
|
-
});
|
|
418
|
-
it('mid-swap failure restores the previous .claude byte-identical, leaves no debris, and warns on stderr', () => {
|
|
419
|
-
const { root, src } = buildFixture();
|
|
420
|
-
const dest = join(root, '.claude');
|
|
421
|
-
// First generation succeeds and materializes the tree.
|
|
422
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
423
|
-
const before = snapshotWithModes(dest);
|
|
424
|
-
expect(Object.keys(before).length).toBeGreaterThan(0);
|
|
425
|
-
// Second generation crashes AFTER the existing dest was moved to prev but
|
|
426
|
-
// BEFORE staging is swapped in, exercising the prev→destRoot restore path.
|
|
427
|
-
const stderr = vi.spyOn(process.stderr, 'write').mockReturnValue(true);
|
|
428
|
-
let stderrOut = '';
|
|
429
|
-
process.env.MX_GENCLAUDE_TEST_FAIL_MID_SWAP = '1';
|
|
430
|
-
try {
|
|
431
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest }))
|
|
432
|
-
.toThrow(/injected mid-swap failure/);
|
|
433
|
-
// Capture BEFORE mockRestore — restoring the spy clears mock.calls.
|
|
434
|
-
stderrOut = stderr.mock.calls.map((c) => String(c[0])).join('');
|
|
435
|
-
}
|
|
436
|
-
finally {
|
|
437
|
-
delete process.env.MX_GENCLAUDE_TEST_FAIL_MID_SWAP;
|
|
438
|
-
stderr.mockRestore();
|
|
439
|
-
}
|
|
440
|
-
// Restore path emitted the loud recovery warning on stderr.
|
|
441
|
-
expect(stderrOut).toMatch(/staging swap failed; restored the previous \.claude\//);
|
|
442
|
-
// The restored .claude is byte- AND mode-identical to before the failed run.
|
|
443
|
-
expect(snapshotWithModes(dest)).toEqual(before);
|
|
444
|
-
// No `.claude.staging-*` / `.claude.prev-*` sibling survived the failure.
|
|
445
|
-
expect(swapDebris(root)).toEqual([]);
|
|
446
|
-
});
|
|
447
|
-
it('swap carries over settings.local.json and unmanaged stray files, and regenerates managed output identically', () => {
|
|
448
|
-
const { root, src } = buildFixture();
|
|
449
|
-
const dest = join(root, '.claude');
|
|
450
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
451
|
-
const managedBefore = snapshotWithModes(dest);
|
|
452
|
-
// User-local + stray files that the generator does NOT manage.
|
|
453
|
-
writeFileSync(join(dest, 'settings.local.json'), '{"local":"KEEP-ME"}\n');
|
|
454
|
-
writeFileSync(join(dest, 'stray.txt'), 'do not lose me\n');
|
|
455
|
-
// Regenerate — the swap must preserve the unmanaged files...
|
|
456
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
457
|
-
expect(existsSync(join(dest, 'settings.local.json'))).toBe(true);
|
|
458
|
-
expect(readFileSync(join(dest, 'settings.local.json'), 'utf-8')).toContain('KEEP-ME');
|
|
459
|
-
expect(existsSync(join(dest, 'stray.txt'))).toBe(true);
|
|
460
|
-
expect(readFileSync(join(dest, 'stray.txt'), 'utf-8')).toBe('do not lose me\n');
|
|
461
|
-
// ...and the managed output is byte-for-byte the same as the in-place result
|
|
462
|
-
// (compare against the committed .claude, ignoring the unmanaged carry-overs).
|
|
463
|
-
for (const [rel, snap] of Object.entries(managedBefore)) {
|
|
464
|
-
const g = join(dest, rel);
|
|
465
|
-
expect(existsSync(g), `managed file lost after swap: ${rel}`).toBe(true);
|
|
466
|
-
expect(`${(statSync(g).mode & 0o777).toString(8)}:${readFileSync(g).toString('base64')}`).toBe(snap);
|
|
467
|
-
// Byte-compare against the committed tree only while it is authoritative
|
|
468
|
-
// (pre-Phase-4). Post-flip the managedBefore snapshot equality above already
|
|
469
|
-
// proves the swap regenerates identical managed output.
|
|
470
|
-
if (CLAUDE_TRACKED) {
|
|
471
|
-
expect(readFileSync(g).equals(readFileSync(join(COMMITTED_CLAUDE, rel))), `managed content drifted from committed .claude: ${rel}`).toBe(true);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
expect(swapDebris(root)).toEqual([]);
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
// ── traversal scope: foreign debris under the DEST must not block generation ──
|
|
478
|
-
//
|
|
479
|
-
// KI-GENERATOR-SCAN-WALKS-FOREIGN-TREES (customer-portal, 2026-08-01). The
|
|
480
|
-
// carry-over scan walked the ENTIRE existing `.claude/`, including stale Claude
|
|
481
|
-
// Code agent worktrees parked at `.claude/worktrees/agent-*/` — each a full
|
|
482
|
-
// checkout with its own generated `.claude/` (and, in the field, a symlinked
|
|
483
|
-
// command file) inside. One orphaned file in the main repo therefore hard-blocked
|
|
484
|
-
// every session start that needed to regenerate `.claude/`:
|
|
485
|
-
//
|
|
486
|
-
// FAIL-CLOSED — symlink found in source tree at
|
|
487
|
-
// .claude/worktrees/agent-a31f43ab/.claude/commands/mx-find.md
|
|
488
|
-
//
|
|
489
|
-
// ...which also named the wrong tree: that path is the DESTINATION, not the
|
|
490
|
-
// source. The scan now skips the top-level `worktrees/` debris dir when scanning
|
|
491
|
-
// the dest, and names the tree it actually walked. The SOURCE scan is unchanged —
|
|
492
|
-
// it still walks everything and still fails closed.
|
|
493
|
-
//
|
|
494
|
-
// The skip is keyed on NAME + POSITION, never on a `.git` marker (SF-13/SF-14,
|
|
495
|
-
// security review of #4818): a marker-keyed skip is plantable by anything that
|
|
496
|
-
// can write under `.claude/`, and in degrade mode an unscanned link in a carried-
|
|
497
|
-
// over `hooks/` goes live in a directory settings.json executes.
|
|
498
|
-
describe('generateClaudeConfig — scan traversal scope (foreign debris)', () => {
|
|
499
|
-
/** Nested-worktree-shaped debris under dest: `.git` marker + a symlink inside. */
|
|
500
|
-
function plantWorktreeDebris(dest, opts) {
|
|
501
|
-
const agentDir = join(dest, 'worktrees', 'agent-a31f43ab');
|
|
502
|
-
const cmds = join(agentDir, '.claude', 'commands');
|
|
503
|
-
mkdirSync(cmds, { recursive: true });
|
|
504
|
-
if (opts.gitMarker) {
|
|
505
|
-
// A linked git worktree's `.git` is a FILE containing a gitdir pointer.
|
|
506
|
-
writeFileSync(join(agentDir, '.git'), 'gitdir: /workspace/.git/worktrees/agent-a31f43ab\n');
|
|
507
|
-
}
|
|
508
|
-
writeFileSync(join(agentDir, 'README.md'), 'debris\n');
|
|
509
|
-
const link = join(cmds, 'mx-find.md');
|
|
510
|
-
symlinkSync(opts.linkTarget, link);
|
|
511
|
-
return { agentDir, link };
|
|
512
|
-
}
|
|
513
|
-
it('a symlink inside a nested worktree under dest worktrees/ does NOT block generation', () => {
|
|
514
|
-
const { root, src } = buildFixture();
|
|
515
|
-
const dest = join(root, '.claude');
|
|
516
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
517
|
-
const managedBefore = walk(dest).files;
|
|
518
|
-
// Sentinel outside the tree: if any step FOLLOWED the debris symlink, the
|
|
519
|
-
// sentinel dir would be written into.
|
|
520
|
-
const outside = mkTmp('mx-genclaude-outside-');
|
|
521
|
-
writeFileSync(join(outside, 'sentinel.txt'), 'DO NOT TOUCH\n');
|
|
522
|
-
const { link } = plantWorktreeDebris(dest, { gitMarker: true, linkTarget: outside });
|
|
523
|
-
// Regeneration must SUCCEED — the debris is not agent-config.
|
|
524
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).not.toThrow();
|
|
525
|
-
// Managed output is intact...
|
|
526
|
-
expect(walk(dest).files).toEqual(expect.arrayContaining(managedBefore));
|
|
527
|
-
// ...the debris survived the swap (nothing silently deleted)...
|
|
528
|
-
expect(existsSync(join(dest, 'worktrees', 'agent-a31f43ab', 'README.md'))).toBe(true);
|
|
529
|
-
// ...the symlink was carried over AS a symlink, never followed or emitted...
|
|
530
|
-
expect(lstatSync(link).isSymbolicLink()).toBe(true);
|
|
531
|
-
expect(readlinkSync(link)).toBe(outside);
|
|
532
|
-
// ...and nothing was written through it.
|
|
533
|
-
expect(walk(outside).files).toEqual(['sentinel.txt']);
|
|
534
|
-
});
|
|
535
|
-
it('carries dest worktrees/ across the swap by RENAME, never by recursive copy', () => {
|
|
536
|
-
// Agent worktrees are full checkouts (node_modules included) — tens of GB in
|
|
537
|
-
// the field. Copying them into staging made a container build hang for hours
|
|
538
|
-
// and needed 2x their size in free disk. The debris must move by rename, which
|
|
539
|
-
// preserves the inode; a cpSync would allocate a new one.
|
|
540
|
-
const { root, src } = buildFixture();
|
|
541
|
-
const dest = join(root, '.claude');
|
|
542
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
543
|
-
const { agentDir } = plantWorktreeDebris(dest, { gitMarker: true, linkTarget: '/etc/passwd' });
|
|
544
|
-
const readmeInoBefore = statSync(join(agentDir, 'README.md')).ino;
|
|
545
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
546
|
-
expect(existsSync(join(agentDir, 'README.md'))).toBe(true);
|
|
547
|
-
expect(statSync(join(agentDir, 'README.md')).ino).toBe(readmeInoBefore);
|
|
548
|
-
});
|
|
549
|
-
it('a symlink under a top-level dest worktrees/ dir with NO .git marker does NOT block generation', () => {
|
|
550
|
-
const { root, src } = buildFixture();
|
|
551
|
-
const dest = join(root, '.claude');
|
|
552
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
553
|
-
plantWorktreeDebris(dest, { gitMarker: false, linkTarget: '../../../../etc/passwd' });
|
|
554
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest })).not.toThrow();
|
|
555
|
-
expect(existsSync(join(dest, 'worktrees', 'agent-a31f43ab', 'README.md'))).toBe(true);
|
|
556
|
-
});
|
|
557
|
-
it('a symlink in ORDINARY unmanaged dest content still FAILS CLOSED, naming the destination tree', () => {
|
|
558
|
-
const { root, src } = buildFixture();
|
|
559
|
-
const dest = join(root, '.claude');
|
|
560
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
561
|
-
// Unmanaged, no repo boundary, not under worktrees/ — the guard must still fire.
|
|
562
|
-
mkdirSync(join(dest, 'notes'), { recursive: true });
|
|
563
|
-
symlinkSync('/etc/passwd', join(dest, 'notes', 'leak.md'));
|
|
564
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest }))
|
|
565
|
-
.toThrow(/FAIL-CLOSED — symlink found in existing destination tree at \.claude\/notes\/leak\.md/);
|
|
566
|
-
});
|
|
567
|
-
it('a symlinked unmanaged entry at the dest apex still FAILS CLOSED', () => {
|
|
568
|
-
const { root, src } = buildFixture();
|
|
569
|
-
const dest = join(root, '.claude');
|
|
570
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
571
|
-
symlinkSync('/etc/passwd', join(dest, 'settings.local.json'));
|
|
572
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest }))
|
|
573
|
-
.toThrow(/FAIL-CLOSED — symlink found in existing destination tree/);
|
|
574
|
-
});
|
|
575
|
-
// SF-13 (security review of #4818). The skip must never apply to a MANAGED dir.
|
|
576
|
-
// Normally a managed dir is regenerated and its old copy is discarded by the
|
|
577
|
-
// swap, so an unscanned link there dies. Not in degrade mode: with
|
|
578
|
-
// skipPermissionLayer:true (the real path at generateClaudeConfigForBoot when
|
|
579
|
-
// the origin fetch fails — fresh clone / offline) neither settings.json nor
|
|
580
|
-
// hooks/ is written into staging, so carry-over copies the EXISTING hooks/
|
|
581
|
-
// wholesale. An unscanned symlink there lands LIVE in .claude/hooks/, which
|
|
582
|
-
// settings.json executes.
|
|
583
|
-
it('degrade mode: a symlink in dest hooks/ FAILS CLOSED even with a .git marker planted beside it', () => {
|
|
584
|
-
const { root, src } = buildFixture();
|
|
585
|
-
const dest = join(root, '.claude');
|
|
586
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
587
|
-
const outside = mkTmp('mx-genclaude-outside-');
|
|
588
|
-
writeFileSync(join(outside, 'payload.sh'), '#!/bin/bash\necho pwned\n');
|
|
589
|
-
// Shelter attempt: repo-boundary marker inside a MANAGED dir.
|
|
590
|
-
writeFileSync(join(dest, 'hooks', '.git'), 'gitdir: /elsewhere\n');
|
|
591
|
-
const evil = join(dest, 'hooks', 'evil.sh');
|
|
592
|
-
symlinkSync(join(outside, 'payload.sh'), evil);
|
|
593
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest, skipPermissionLayer: true }))
|
|
594
|
-
.toThrow(/FAIL-CLOSED/);
|
|
595
|
-
// And the run materialized nothing through the swap: the pre-existing dest is
|
|
596
|
-
// untouched, so the link is not "live" via a newly swapped-in tree.
|
|
597
|
-
expect(readdirSync(root).filter((n) => n.startsWith('.claude.staging-'))).toEqual([]);
|
|
598
|
-
});
|
|
599
|
-
// SF-14 (same review, same mechanism). An unmanaged sibling dir was also
|
|
600
|
-
// shelterable by a planted .git marker. Nothing under it is executed as config,
|
|
601
|
-
// so impact is lower — but the skip is now scoped to the one debris shape we
|
|
602
|
-
// actually have to tolerate, so this fails closed too. This also pins the
|
|
603
|
-
// accepted tradeoff of dropping the marker rule: a real nested checkout parked
|
|
604
|
-
// somewhere OTHER than `worktrees/` now blocks generation, loudly and with a
|
|
605
|
-
// message naming the destination path, rather than being tolerated.
|
|
606
|
-
it('a symlink in an unmanaged dest sibling dir FAILS CLOSED even with a .git marker planted beside it', () => {
|
|
607
|
-
const { root, src } = buildFixture();
|
|
608
|
-
const dest = join(root, '.claude');
|
|
609
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
610
|
-
const tasks = join(dest, 'scheduled-tasks');
|
|
611
|
-
mkdirSync(tasks, { recursive: true });
|
|
612
|
-
writeFileSync(join(tasks, '.git'), 'gitdir: /elsewhere\n');
|
|
613
|
-
symlinkSync('/etc/passwd', join(tasks, 'leak.json'));
|
|
614
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest }))
|
|
615
|
-
.toThrow(/FAIL-CLOSED — symlink found in existing destination tree/);
|
|
616
|
-
});
|
|
617
|
-
it('the SOURCE scan skips nothing — neither a .git marker nor a worktrees/ dir shelters a source symlink', () => {
|
|
618
|
-
const { root, src } = buildFixture();
|
|
619
|
-
const dest = join(root, '.claude');
|
|
620
|
-
// Same shelter that works on the dest side, planted in real agent-config
|
|
621
|
-
// source: a `.git` marker beside a smuggled symlink. Source must fail closed.
|
|
622
|
-
const skillName = readdirSync(join(src, 'skills'), { withFileTypes: true })
|
|
623
|
-
.find(e => e.isDirectory()).name;
|
|
624
|
-
const sheltered = join(src, 'skills', skillName, 'worktrees');
|
|
625
|
-
mkdirSync(sheltered, { recursive: true });
|
|
626
|
-
writeFileSync(join(sheltered, '.git'), 'gitdir: /elsewhere\n');
|
|
627
|
-
symlinkSync('../../../../../etc/passwd', join(sheltered, 'smuggled.md'));
|
|
628
|
-
expect(() => generateClaudeConfig({ ...layers(src), destRoot: dest }))
|
|
629
|
-
.toThrow(/FAIL-CLOSED — symlink found in source tree/);
|
|
630
|
-
expect(existsSync(dest)).toBe(false); // nothing materialized
|
|
631
|
-
});
|
|
632
|
-
});
|
|
633
|
-
// ── REAL production path: --from-git against a committed git fixture (MAJOR 3) ──
|
|
634
|
-
/** Init a git repo with an agent-config tree committed at HEAD; return its root. */
|
|
635
|
-
function buildGitFixture() {
|
|
636
|
-
const root = mkTmp('mx-genclaude-git-');
|
|
637
|
-
const src = join(root, CONFIG_SOURCE);
|
|
638
|
-
const localCmds = join(src, 'local', 'commands');
|
|
639
|
-
const localAgents = join(src, 'local', 'agents');
|
|
640
|
-
const skillDir = join(src, 'skills', 'demo');
|
|
641
|
-
const hooksDir = join(src, 'hooks');
|
|
642
|
-
const rulesDir = join(src, 'rules');
|
|
643
|
-
const agentsDir = join(src, 'agents');
|
|
644
|
-
for (const d of [localCmds, localAgents, skillDir, hooksDir, rulesDir, agentsDir]) {
|
|
645
|
-
mkdirSync(d, { recursive: true });
|
|
646
|
-
}
|
|
647
|
-
writeFileSync(join(src, 'settings.json'), '{"allow":["Bash(git*)"],"deny":[]}\n');
|
|
648
|
-
writeFileSync(join(hooksDir, 'guard.sh'), '#!/bin/bash\necho guard\n');
|
|
649
|
-
writeFileSync(join(hooksDir, 'notes.conf'), 'k=v\n');
|
|
650
|
-
writeFileSync(join(rulesDir, 'rule.md'), '# rule\n');
|
|
651
|
-
writeFileSync(join(agentsDir, 'shipped.md'), '# shipped agent\n');
|
|
652
|
-
writeFileSync(join(localAgents, 'local.md'), '# local agent\n');
|
|
653
|
-
writeFileSync(join(skillDir, 'SKILL.md'), '# skill\n');
|
|
654
|
-
writeFileSync(join(localCmds, 'mx-demo.md'), '# demo command\n');
|
|
655
|
-
const git = (args) => {
|
|
656
|
-
const r = spawnSync('git', args, { cwd: root, encoding: 'utf-8' });
|
|
657
|
-
if (r.status !== 0)
|
|
658
|
-
throw new Error(`git ${args.join(' ')} failed: ${r.stderr}`);
|
|
659
|
-
};
|
|
660
|
-
git(['init', '-q']);
|
|
661
|
-
git(['config', 'user.email', 't@t']);
|
|
662
|
-
git(['config', 'user.name', 't']);
|
|
663
|
-
git(['add', '-A']);
|
|
664
|
-
git(['commit', '-q', '-m', 'fixture']);
|
|
665
|
-
return root;
|
|
666
|
-
}
|
|
667
|
-
describe('generateClaudeConfigFromGit — real production path', () => {
|
|
668
|
-
it('reproduces the tree from HEAD, emitting only plain files', () => {
|
|
669
|
-
const root = buildGitFixture();
|
|
670
|
-
const dest = join(root, 'out', '.claude');
|
|
671
|
-
const res = generateClaudeConfigFromGit({ ref: 'HEAD', repoRoot: root, destRoot: dest, configSource: CONFIG_SOURCE });
|
|
672
|
-
expect(res.counts.hooks).toBe(2); // guard.sh + notes.conf
|
|
673
|
-
expect(res.counts.agents).toBe(2); // shipped + local
|
|
674
|
-
expect(res.counts.commands).toBe(1); // mx-demo.md
|
|
675
|
-
expect(walk(dest).links).toEqual([]);
|
|
676
|
-
expect(readFileSync(join(dest, 'settings.json'), 'utf-8')).toContain('Bash(git*)');
|
|
677
|
-
expect(statSync(join(dest, 'hooks', 'guard.sh')).mode & 0o777).toBe(0o755);
|
|
678
|
-
expect(statSync(join(dest, 'hooks', 'notes.conf')).mode & 0o777).toBe(0o644);
|
|
679
|
-
});
|
|
680
|
-
it('FAILS CLOSED with nothing materialized when a symlink is committed into the source', () => {
|
|
681
|
-
const root = buildGitFixture();
|
|
682
|
-
// Smuggle a symlink into the committed config source and commit it.
|
|
683
|
-
const evil = join(root, CONFIG_SOURCE, 'local', 'commands', 'evil.md');
|
|
684
|
-
symlinkSync('../../../../../../etc/passwd', evil);
|
|
685
|
-
const g = (args) => spawnSync('git', args, { cwd: root, encoding: 'utf-8' });
|
|
686
|
-
g(['add', '-A']);
|
|
687
|
-
g(['commit', '-q', '-m', 'smuggle symlink']);
|
|
688
|
-
const dest = join(root, 'out', '.claude');
|
|
689
|
-
expect(() => generateClaudeConfigFromGit({ ref: 'HEAD', repoRoot: root, destRoot: dest, configSource: CONFIG_SOURCE })).toThrow(/FAIL-CLOSED/);
|
|
690
|
-
// QA obs: nothing materialized.
|
|
691
|
-
expect(existsSync(dest)).toBe(false);
|
|
692
|
-
});
|
|
693
|
-
});
|
|
694
|
-
// ── container-boot split (permission from origin / rest from working tree) ─────
|
|
695
|
-
describe('generateClaudeConfigForBoot — permission-layer split (Red Team CRITICAL 1)', () => {
|
|
696
|
-
it('sources settings.json + hooks from the git ref, and rules/commands from the working tree', () => {
|
|
697
|
-
const root = buildGitFixture();
|
|
698
|
-
const src = join(root, CONFIG_SOURCE);
|
|
699
|
-
// Tamper the WORKING-TREE permission layer + add a working-tree-only rule/command.
|
|
700
|
-
writeFileSync(join(src, 'settings.json'), '{"allow":["TAMPERED"],"deny":[]}\n');
|
|
701
|
-
writeFileSync(join(src, 'hooks', 'guard.sh'), '#!/bin/bash\necho TAMPERED\n');
|
|
702
|
-
writeFileSync(join(src, 'rules', 'wt-only.md'), '# working-tree rule\n');
|
|
703
|
-
writeFileSync(join(src, 'local', 'commands', 'wt-cmd.md'), '# working-tree command\n');
|
|
704
|
-
const dest = join(root, 'out', '.claude');
|
|
705
|
-
const { result, permissionPinned } = generateClaudeConfigForBoot({
|
|
706
|
-
permissionRef: 'HEAD', repoRoot: root, destRoot: dest, configSource: CONFIG_SOURCE,
|
|
707
|
-
});
|
|
708
|
-
expect(permissionPinned).toBe(true);
|
|
709
|
-
// Permission layer came from HEAD (committed), NOT the tampered working tree.
|
|
710
|
-
expect(readFileSync(join(dest, 'settings.json'), 'utf-8')).toContain('Bash(git*)');
|
|
711
|
-
expect(readFileSync(join(dest, 'settings.json'), 'utf-8')).not.toContain('TAMPERED');
|
|
712
|
-
expect(readFileSync(join(dest, 'hooks', 'guard.sh'), 'utf-8')).not.toContain('TAMPERED');
|
|
713
|
-
// Behavioral layers came from the WORKING TREE (the uncommitted additions show).
|
|
714
|
-
expect(existsSync(join(dest, 'rules', 'wt-only.md'))).toBe(true);
|
|
715
|
-
expect(existsSync(join(dest, 'commands', 'wt-cmd.md'))).toBe(true);
|
|
716
|
-
expect(result.counts.hooks).toBe(2);
|
|
717
|
-
expect(walk(dest).links).toEqual([]);
|
|
718
|
-
});
|
|
719
|
-
it('DEGRADES (warns, skips permission layer) when the git ref is unavailable', () => {
|
|
720
|
-
const root = buildGitFixture();
|
|
721
|
-
const src = join(root, CONFIG_SOURCE);
|
|
722
|
-
writeFileSync(join(src, 'rules', 'wt-only.md'), '# working-tree rule\n');
|
|
723
|
-
const dest = join(root, 'out', '.claude');
|
|
724
|
-
const warnings = [];
|
|
725
|
-
const { permissionPinned } = generateClaudeConfigForBoot({
|
|
726
|
-
permissionRef: 'origin/does-not-exist', repoRoot: root, destRoot: dest,
|
|
727
|
-
configSource: CONFIG_SOURCE, warn: (m) => warnings.push(m),
|
|
728
|
-
});
|
|
729
|
-
expect(permissionPinned).toBe(false);
|
|
730
|
-
expect(warnings.join('\n')).toMatch(/origin-pin/);
|
|
731
|
-
// Non-permission layers still generated from the working tree...
|
|
732
|
-
expect(existsSync(join(dest, 'rules', 'wt-only.md'))).toBe(true);
|
|
733
|
-
// ...but settings.json + hooks are NOT written (committed backstop left in place).
|
|
734
|
-
expect(existsSync(join(dest, 'settings.json'))).toBe(false);
|
|
735
|
-
expect(existsSync(join(dest, 'hooks'))).toBe(false);
|
|
736
|
-
});
|
|
737
|
-
});
|
|
738
|
-
// ── the hook heal writes the permission layer ONLY (#247, red-team Critical 1) ──
|
|
739
|
-
//
|
|
740
|
-
// `generateClaudeConfig` rewrites the WHOLE tree on every call. So the heal —
|
|
741
|
-
// which is asked for a missing hook and reports only the hooks it restored —
|
|
742
|
-
// reverted the origin-sourced behavioural layers to working-tree content every
|
|
743
|
-
// time it fired after `syncClaudeConfig`, on a worktree that may be many commits
|
|
744
|
-
// behind. `skipBehavioralLayer` is the narrow fix: the container-boot behaviour
|
|
745
|
-
// above is untouched, and only the heal's invocation carries the flag.
|
|
746
|
-
describe('generateClaudeConfigForBoot — skipBehavioralLayer (#247)', () => {
|
|
747
|
-
/** Materialise the whole tree from the ref first, the way a session start does. */
|
|
748
|
-
function deployFromRef(root, dest) {
|
|
749
|
-
generateClaudeConfigFromGit({ ref: 'HEAD', repoRoot: root, destRoot: dest, configSource: CONFIG_SOURCE });
|
|
750
|
-
}
|
|
751
|
-
it('leaves every behavioural layer byte-identical while restoring the permission layer', () => {
|
|
752
|
-
const root = buildGitFixture();
|
|
753
|
-
const src = join(root, CONFIG_SOURCE);
|
|
754
|
-
const dest = join(root, 'out', '.claude');
|
|
755
|
-
deployFromRef(root, dest);
|
|
756
|
-
const beforeAgents = readFileSync(join(dest, 'agents', 'shipped.md'), 'utf-8');
|
|
757
|
-
const beforeTree = walk(dest).files;
|
|
758
|
-
// The worktree diverges from the ref in every behavioural layer, and a
|
|
759
|
-
// registered hook is lost — the exact state the heal fires in.
|
|
760
|
-
writeFileSync(join(src, 'agents', 'shipped.md'), '# TAMPERED working-tree agent\n');
|
|
761
|
-
writeFileSync(join(src, 'rules', 'wt-only.md'), '# working-tree rule\n');
|
|
762
|
-
writeFileSync(join(src, 'local', 'commands', 'wt-cmd.md'), '# working-tree command\n');
|
|
763
|
-
rmSync(join(dest, 'hooks', 'guard.sh'));
|
|
764
|
-
const { result, permissionPinned } = generateClaudeConfigForBoot({
|
|
765
|
-
permissionRef: 'HEAD', repoRoot: root, destRoot: dest, configSource: CONFIG_SOURCE,
|
|
766
|
-
skipBehavioralLayer: true,
|
|
767
|
-
});
|
|
768
|
-
// The hook is back, from the ref.
|
|
769
|
-
expect(permissionPinned).toBe(true);
|
|
770
|
-
expect(readFileSync(join(dest, 'hooks', 'guard.sh'), 'utf-8')).toContain('echo guard');
|
|
771
|
-
// And NOTHING behavioural moved: not the diverged file, not the file set.
|
|
772
|
-
expect(readFileSync(join(dest, 'agents', 'shipped.md'), 'utf-8')).toBe(beforeAgents);
|
|
773
|
-
expect(existsSync(join(dest, 'rules', 'wt-only.md'))).toBe(false);
|
|
774
|
-
expect(existsSync(join(dest, 'commands', 'wt-cmd.md'))).toBe(false);
|
|
775
|
-
expect(walk(dest).files).toEqual(beforeTree);
|
|
776
|
-
// The counts say what was written, so a caller cannot read a zero as a loss.
|
|
777
|
-
expect(result.counts.hooks).toBe(2);
|
|
778
|
-
expect(result.counts.agents).toBe(0);
|
|
779
|
-
expect(result.counts.skills).toBe(0);
|
|
780
|
-
expect(result.counts.commands).toBe(0);
|
|
781
|
-
expect(result.counts.rules).toBe(0);
|
|
782
|
-
expect(walk(dest).links).toEqual([]);
|
|
783
|
-
});
|
|
784
|
-
it('CONTROL: the same call WITHOUT the flag does rewrite them from the working tree', () => {
|
|
785
|
-
// The container-boot property this change had to preserve (prior red-team
|
|
786
|
-
// CRITICAL 1). Without the control, the test above cannot tell the fix from
|
|
787
|
-
// a generator that stopped writing behavioural layers altogether.
|
|
788
|
-
const root = buildGitFixture();
|
|
789
|
-
const src = join(root, CONFIG_SOURCE);
|
|
790
|
-
const dest = join(root, 'out', '.claude');
|
|
791
|
-
deployFromRef(root, dest);
|
|
792
|
-
writeFileSync(join(src, 'agents', 'shipped.md'), '# TAMPERED working-tree agent\n');
|
|
793
|
-
writeFileSync(join(src, 'rules', 'wt-only.md'), '# working-tree rule\n');
|
|
794
|
-
rmSync(join(dest, 'hooks', 'guard.sh'));
|
|
795
|
-
generateClaudeConfigForBoot({
|
|
796
|
-
permissionRef: 'HEAD', repoRoot: root, destRoot: dest, configSource: CONFIG_SOURCE,
|
|
797
|
-
});
|
|
798
|
-
expect(readFileSync(join(dest, 'agents', 'shipped.md'), 'utf-8')).toContain('TAMPERED');
|
|
799
|
-
expect(existsSync(join(dest, 'rules', 'wt-only.md'))).toBe(true);
|
|
800
|
-
});
|
|
801
|
-
it('rides through the DEGRADE path too — an offline heal rewrites nothing behavioural', () => {
|
|
802
|
-
const root = buildGitFixture();
|
|
803
|
-
const src = join(root, CONFIG_SOURCE);
|
|
804
|
-
const dest = join(root, 'out', '.claude');
|
|
805
|
-
deployFromRef(root, dest);
|
|
806
|
-
const beforeTree = walk(dest).files;
|
|
807
|
-
writeFileSync(join(src, 'rules', 'wt-only.md'), '# working-tree rule\n');
|
|
808
|
-
const warnings = [];
|
|
809
|
-
const { permissionPinned } = generateClaudeConfigForBoot({
|
|
810
|
-
permissionRef: 'origin/does-not-exist', repoRoot: root, destRoot: dest,
|
|
811
|
-
configSource: CONFIG_SOURCE, skipBehavioralLayer: true,
|
|
812
|
-
warn: (m) => warnings.push(m),
|
|
813
|
-
});
|
|
814
|
-
expect(permissionPinned).toBe(false);
|
|
815
|
-
expect(warnings.join('\n')).toMatch(/origin-pin/);
|
|
816
|
-
expect(existsSync(join(dest, 'rules', 'wt-only.md'))).toBe(false);
|
|
817
|
-
expect(walk(dest).files).toEqual(beforeTree);
|
|
818
|
-
});
|
|
819
|
-
it('the CLI refuses --skip-behavioral-layer without --permission-from-git', () => {
|
|
820
|
-
// A flag that silently does nothing is a fail-quiet. It narrows the boot
|
|
821
|
-
// split and has no meaning on the whole-tree paths.
|
|
822
|
-
const root = buildGitFixture();
|
|
823
|
-
const r = spawnSync(process.execPath, [SCRIPT, '--repo-root', root, '--dest', join(root, 'out', '.claude'), '--skip-behavioral-layer', '--quiet'], { encoding: 'utf-8' });
|
|
824
|
-
expect(r.status).toBe(1);
|
|
825
|
-
expect(r.stderr).toContain('--skip-behavioral-layer applies only to --permission-from-git');
|
|
826
|
-
expect(existsSync(join(root, 'out', '.claude'))).toBe(false);
|
|
827
|
-
});
|
|
828
|
-
});
|
|
829
|
-
// ── degrade path must not trust the working tree (Red Team CRITICAL B / Major 3) ──
|
|
830
|
-
//
|
|
831
|
-
// An attacker who commits a weakened settings/hooks to the LOCAL checkout and then
|
|
832
|
-
// blocks the origin fetch (rename remote, break DNS) must NOT get their layer kept
|
|
833
|
-
// on boot. The degrade path restores the last ORIGIN-VERIFIED permission layer
|
|
834
|
-
// from ~/.mx-agent/ cache instead. HOME is isolated per-test (see beforeEach), so
|
|
835
|
-
// these exercise a real on-disk cache without touching the real home dir.
|
|
836
|
-
describe('generateClaudeConfigForBoot — degrade restores origin-verified cache (Red Team CRITICAL B)', () => {
|
|
837
|
-
/** Build a trusted (origin-verified) permission source dir and prime the cache. */
|
|
838
|
-
function primeCacheWith(settingsContent) {
|
|
839
|
-
const trusted = mkTmp('mx-genclaude-trusted-');
|
|
840
|
-
writeFileSync(join(trusted, 'settings.json'), settingsContent);
|
|
841
|
-
mkdirSync(join(trusted, 'hooks'), { recursive: true });
|
|
842
|
-
writeFileSync(join(trusted, 'hooks', 'guard.sh'), '#!/bin/bash\necho cached-guard\n');
|
|
843
|
-
refreshPermissionCache(trusted);
|
|
844
|
-
}
|
|
845
|
-
it('with a populated cache, writes the CACHED layer — not the malicious committed one', () => {
|
|
846
|
-
const root = buildGitFixture();
|
|
847
|
-
const src = join(root, CONFIG_SOURCE);
|
|
848
|
-
// Attacker weakens the working-tree + committed permission layer.
|
|
849
|
-
const MALICIOUS = '{"allow":["MALICIOUS-BACKDOOR"],"deny":[]}\n';
|
|
850
|
-
writeFileSync(join(src, 'settings.json'), MALICIOUS);
|
|
851
|
-
writeFileSync(join(src, 'hooks', 'guard.sh'), '#!/bin/bash\necho MALICIOUS\n');
|
|
852
|
-
const g = (args) => spawnSync('git', args, { cwd: root, encoding: 'utf-8' });
|
|
853
|
-
g(['add', '-A']);
|
|
854
|
-
g(['commit', '-q', '-m', 'weaken permission layer']); // HEAD now malicious
|
|
855
|
-
// Prime the cache with a known-good origin-verified layer.
|
|
856
|
-
const BENIGN = '{"allow":["ORIGIN-VERIFIED-BENIGN"],"deny":[]}\n';
|
|
857
|
-
primeCacheWith(BENIGN);
|
|
858
|
-
// Pre-plant a malicious committed backstop on disk (the Phase 2 .claude/).
|
|
859
|
-
const dest = join(root, 'out', '.claude');
|
|
860
|
-
mkdirSync(dest, { recursive: true });
|
|
861
|
-
writeFileSync(join(dest, 'settings.json'), MALICIOUS);
|
|
862
|
-
const warnings = [];
|
|
863
|
-
const { permissionPinned } = generateClaudeConfigForBoot({
|
|
864
|
-
permissionRef: 'origin/does-not-exist', repoRoot: root, destRoot: dest,
|
|
865
|
-
configSource: CONFIG_SOURCE, warn: (m) => warnings.push(m),
|
|
866
|
-
});
|
|
867
|
-
expect(permissionPinned).toBe(false);
|
|
868
|
-
const written = readFileSync(join(dest, 'settings.json'), 'utf-8');
|
|
869
|
-
expect(written).toContain('ORIGIN-VERIFIED-BENIGN'); // cached layer restored
|
|
870
|
-
expect(written).not.toContain('MALICIOUS'); // neither working tree nor committed
|
|
871
|
-
expect(readFileSync(join(dest, 'hooks', 'guard.sh'), 'utf-8')).toContain('cached-guard');
|
|
872
|
-
expect(readFileSync(join(dest, 'hooks', 'guard.sh'), 'utf-8')).not.toContain('MALICIOUS');
|
|
873
|
-
expect(walk(dest).links).toEqual([]);
|
|
874
|
-
});
|
|
875
|
-
it('with NO cache, leaves the committed backstop and warns UNVERIFIED', () => {
|
|
876
|
-
const root = buildGitFixture();
|
|
877
|
-
const dest = join(root, 'out', '.claude');
|
|
878
|
-
// Committed backstop already on disk; cache is empty (fresh isolated HOME).
|
|
879
|
-
mkdirSync(dest, { recursive: true });
|
|
880
|
-
writeFileSync(join(dest, 'settings.json'), '{"allow":["COMMITTED-BACKSTOP"],"deny":[]}\n');
|
|
881
|
-
const warnings = [];
|
|
882
|
-
const { permissionPinned } = generateClaudeConfigForBoot({
|
|
883
|
-
permissionRef: 'origin/does-not-exist', repoRoot: root, destRoot: dest,
|
|
884
|
-
configSource: CONFIG_SOURCE, warn: (m) => warnings.push(m),
|
|
885
|
-
});
|
|
886
|
-
expect(permissionPinned).toBe(false);
|
|
887
|
-
expect(warnings.join('\n')).toContain('UNVERIFIED');
|
|
888
|
-
// Committed backstop left untouched (no cache to restore, working tree not trusted).
|
|
889
|
-
expect(readFileSync(join(dest, 'settings.json'), 'utf-8')).toContain('COMMITTED-BACKSTOP');
|
|
890
|
-
});
|
|
891
|
-
it('with a populated cache whose hash.txt is MISSING, FAILS CLOSED to UNVERIFIED backstop (S1)', () => {
|
|
892
|
-
const root = buildGitFixture();
|
|
893
|
-
// Prime a full cache, then strip its hash.txt (a hash-stripped / partially
|
|
894
|
-
// written cache). Restore must NOT trust it — it falls to the committed backstop.
|
|
895
|
-
primeCacheWith('{"allow":["CACHED-BENIGN"],"deny":[]}\n');
|
|
896
|
-
const hashPath = join(process.env.HOME, '.mx-agent', 'permission-cache', 'hash.txt');
|
|
897
|
-
expect(existsSync(hashPath)).toBe(true);
|
|
898
|
-
rmSync(hashPath, { force: true });
|
|
899
|
-
const dest = join(root, 'out', '.claude');
|
|
900
|
-
mkdirSync(dest, { recursive: true });
|
|
901
|
-
writeFileSync(join(dest, 'settings.json'), '{"allow":["COMMITTED-BACKSTOP"],"deny":[]}\n');
|
|
902
|
-
const warnings = [];
|
|
903
|
-
const { permissionPinned } = generateClaudeConfigForBoot({
|
|
904
|
-
permissionRef: 'origin/does-not-exist', repoRoot: root, destRoot: dest,
|
|
905
|
-
configSource: CONFIG_SOURCE, warn: (m) => warnings.push(m),
|
|
906
|
-
});
|
|
907
|
-
expect(permissionPinned).toBe(false);
|
|
908
|
-
expect(warnings.join('\n')).toContain('UNVERIFIED');
|
|
909
|
-
// Unverified cache rejected: neither the cached bytes nor a rewrite landed.
|
|
910
|
-
const written = readFileSync(join(dest, 'settings.json'), 'utf-8');
|
|
911
|
-
expect(written).toContain('COMMITTED-BACKSTOP');
|
|
912
|
-
expect(written).not.toContain('CACHED-BENIGN');
|
|
913
|
-
});
|
|
914
|
-
});
|
|
915
|
-
// ── orphan-sibling sweep (KI-GENERATOR-SWAP-SIBLINGS-UNGUARDED) ────────────────
|
|
916
|
-
//
|
|
917
|
-
// A crash mid-generation leaves a `.claude.staging-*` sibling; a failed
|
|
918
|
-
// prev-cleanup leaves a `.claude.prev-*` sibling. The generator sweeps both at
|
|
919
|
-
// entry so stale settings/hooks copies never accumulate at an unguarded path.
|
|
920
|
-
describe('generateClaudeConfig — orphan-sibling sweep', () => {
|
|
921
|
-
it('removes stale .claude.staging-* and .claude.prev-* siblings at generation entry', () => {
|
|
922
|
-
const { root, src } = buildFixture();
|
|
923
|
-
const dest = join(root, '.claude');
|
|
924
|
-
// Plant orphan siblings (as a crashed prior run would leave them).
|
|
925
|
-
const stale = [
|
|
926
|
-
join(root, '.claude.staging-deadbeef'),
|
|
927
|
-
join(root, '.claude.prev-1700000000000-123'),
|
|
928
|
-
];
|
|
929
|
-
for (const d of stale) {
|
|
930
|
-
mkdirSync(join(d, 'hooks'), { recursive: true });
|
|
931
|
-
writeFileSync(join(d, 'settings.json'), '{"stale":true}');
|
|
932
|
-
}
|
|
933
|
-
// An UNRELATED sibling that must survive.
|
|
934
|
-
const keep = join(root, '.claude.notes');
|
|
935
|
-
mkdirSync(keep, { recursive: true });
|
|
936
|
-
writeFileSync(join(keep, 'x'), 'keep');
|
|
937
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
938
|
-
for (const d of stale)
|
|
939
|
-
expect(existsSync(d), `orphan not swept: ${d}`).toBe(false);
|
|
940
|
-
expect(existsSync(keep), 'unrelated sibling wrongly swept').toBe(true);
|
|
941
|
-
// Generation still succeeded.
|
|
942
|
-
expect(existsSync(join(dest, 'settings.json'))).toBe(true);
|
|
943
|
-
});
|
|
944
|
-
it('sweepOrphanSiblings reports the swept names and is a no-op when none exist', () => {
|
|
945
|
-
const { root } = buildFixture();
|
|
946
|
-
const dest = join(root, '.claude');
|
|
947
|
-
expect(sweepOrphanSiblings(dest)).toEqual([]);
|
|
948
|
-
mkdirSync(join(root, '.claude.staging-aaa'), { recursive: true });
|
|
949
|
-
mkdirSync(join(root, '.claude.prev-bbb'), { recursive: true });
|
|
950
|
-
const swept = sweepOrphanSiblings(dest).sort();
|
|
951
|
-
expect(swept).toEqual(['.claude.prev-bbb', '.claude.staging-aaa']);
|
|
952
|
-
});
|
|
953
|
-
// The crash window the rename design opens, and what closes it. Between
|
|
954
|
-
// `staging`->`.claude/` and `prev/worktrees`->`.claude/worktrees` the debris
|
|
955
|
-
// lives only inside `.claude.prev-*`. A SIGKILL there runs no catch and no
|
|
956
|
-
// finally, so the NEXT run has to recover it before the sweep deletes it.
|
|
957
|
-
// Blocked PR #5160 on this exact hazard (Must Fix 2).
|
|
958
|
-
it('sweep RECOVERS worktrees/ stranded in an orphan by an interrupted run, never deletes it', () => {
|
|
959
|
-
const { root, src } = buildFixture();
|
|
960
|
-
const dest = join(root, '.claude');
|
|
961
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
962
|
-
// Reconstruct the on-disk state a crash mid-swap leaves: debris in prev,
|
|
963
|
-
// none in the live tree.
|
|
964
|
-
const orphan = join(root, '.claude.prev-1-2');
|
|
965
|
-
const stranded = join(orphan, 'worktrees', 'agent-a31f43ab');
|
|
966
|
-
mkdirSync(stranded, { recursive: true });
|
|
967
|
-
writeFileSync(join(stranded, 'unshipped.txt'), 'work nobody has seen\n');
|
|
968
|
-
const ino = statSync(join(stranded, 'unshipped.txt')).ino;
|
|
969
|
-
const swept = sweepOrphanSiblings(dest);
|
|
970
|
-
// Restored into the live tree by rename (inode preserved), orphan then swept.
|
|
971
|
-
const restored = join(dest, 'worktrees', 'agent-a31f43ab', 'unshipped.txt');
|
|
972
|
-
expect(existsSync(restored)).toBe(true);
|
|
973
|
-
expect(statSync(restored).ino).toBe(ino);
|
|
974
|
-
expect(swept).toContain('.claude.prev-1-2');
|
|
975
|
-
expect(existsSync(orphan)).toBe(false);
|
|
976
|
-
});
|
|
977
|
-
it('sweep PRESERVES an orphan worktrees/ as .rescue-* when the live tree already has one', () => {
|
|
978
|
-
const { root, src } = buildFixture();
|
|
979
|
-
const dest = join(root, '.claude');
|
|
980
|
-
generateClaudeConfig({ ...layers(src), destRoot: dest });
|
|
981
|
-
const liveDebris = join(dest, 'worktrees', 'agent-a31f43ab');
|
|
982
|
-
mkdirSync(liveDebris, { recursive: true });
|
|
983
|
-
writeFileSync(join(liveDebris, 'README.md'), 'debris\n');
|
|
984
|
-
const orphan = join(root, '.claude.prev-9-9');
|
|
985
|
-
const stranded = join(orphan, 'worktrees', 'agent-older');
|
|
986
|
-
mkdirSync(stranded, { recursive: true });
|
|
987
|
-
writeFileSync(join(stranded, 'unshipped.txt'), 'older work\n');
|
|
988
|
-
const swept = sweepOrphanSiblings(dest);
|
|
989
|
-
// Not swept, not deleted — parked under a name no sweep prefix matches.
|
|
990
|
-
expect(swept).not.toContain('.claude.prev-9-9');
|
|
991
|
-
expect(existsSync(orphan)).toBe(false);
|
|
992
|
-
const rescue = join(root, '.claude.rescue-.claude.prev-9-9');
|
|
993
|
-
expect(existsSync(join(rescue, 'worktrees', 'agent-older', 'unshipped.txt'))).toBe(true);
|
|
994
|
-
// The live tree is untouched, and a second sweep leaves the rescue alone.
|
|
995
|
-
expect(existsSync(join(dest, 'worktrees', 'agent-a31f43ab', 'README.md'))).toBe(true);
|
|
996
|
-
sweepOrphanSiblings(dest);
|
|
997
|
-
expect(existsSync(join(rescue, 'worktrees', 'agent-older', 'unshipped.txt'))).toBe(true);
|
|
998
|
-
});
|
|
999
|
-
it('FAILS SAFE on a symlink sibling — unlinks the link, never deletes through it', () => {
|
|
1000
|
-
const { root } = buildFixture();
|
|
1001
|
-
const dest = join(root, '.claude');
|
|
1002
|
-
// A sentinel dir a followed link would clobber.
|
|
1003
|
-
const outside = mkTmp('mx-genclaude-sweep-target-');
|
|
1004
|
-
writeFileSync(join(outside, 'sentinel.txt'), 'DO NOT TOUCH\n');
|
|
1005
|
-
// Plant a staging-named symlink pointing at the sentinel dir.
|
|
1006
|
-
symlinkSync(outside, join(root, '.claude.staging-linky'));
|
|
1007
|
-
const swept = sweepOrphanSiblings(dest);
|
|
1008
|
-
// The link entry itself was removed...
|
|
1009
|
-
expect(existsSync(join(root, '.claude.staging-linky'))).toBe(false);
|
|
1010
|
-
expect(swept).toContain('.claude.staging-linky');
|
|
1011
|
-
// ...but the link TARGET (outside .claude/) was NOT deleted through.
|
|
1012
|
-
expect(existsSync(join(outside, 'sentinel.txt'))).toBe(true);
|
|
1013
|
-
});
|
|
1014
|
-
});
|
|
1015
|
-
//# sourceMappingURL=generate-claude.test.js.map
|