@memnexus-ai/mx-agent-cli 0.1.294 → 0.1.296-next.0
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/__tests__/agents-md-canonicalization.test.js +31 -1
- package/dist/__tests__/agents-md-canonicalization.test.js.map +1 -1
- package/dist/__tests__/behavioral-extraction.test.js +50 -0
- package/dist/__tests__/behavioral-extraction.test.js.map +1 -1
- package/dist/__tests__/bootstrap-behavioral-contract.test.js +6 -3
- package/dist/__tests__/bootstrap-behavioral-contract.test.js.map +1 -1
- package/dist/__tests__/bundle-config.test.js +28 -2
- package/dist/__tests__/bundle-config.test.js.map +1 -1
- package/dist/__tests__/catalog-interaction.test.d.ts +25 -0
- package/dist/__tests__/catalog-interaction.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-interaction.test.js +269 -0
- package/dist/__tests__/catalog-interaction.test.js.map +1 -0
- package/dist/__tests__/catalog-named-memories.test.d.ts +2 -0
- package/dist/__tests__/catalog-named-memories.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-named-memories.test.js +204 -0
- package/dist/__tests__/catalog-named-memories.test.js.map +1 -0
- package/dist/__tests__/catalog-origin-main.test.d.ts +15 -0
- package/dist/__tests__/catalog-origin-main.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-origin-main.test.js +296 -0
- package/dist/__tests__/catalog-origin-main.test.js.map +1 -0
- package/dist/__tests__/catalog.test.d.ts +2 -0
- package/dist/__tests__/catalog.test.d.ts.map +1 -0
- package/dist/__tests__/catalog.test.js +131 -0
- package/dist/__tests__/catalog.test.js.map +1 -0
- package/dist/__tests__/claude-local-sanitizer.test.d.ts +24 -0
- package/dist/__tests__/claude-local-sanitizer.test.d.ts.map +1 -0
- package/dist/__tests__/claude-local-sanitizer.test.js +906 -0
- package/dist/__tests__/claude-local-sanitizer.test.js.map +1 -0
- package/dist/__tests__/cli-build-integration.test.d.ts +2 -0
- package/dist/__tests__/cli-build-integration.test.d.ts.map +1 -0
- package/dist/__tests__/cli-build-integration.test.js +64 -0
- package/dist/__tests__/cli-build-integration.test.js.map +1 -0
- package/dist/__tests__/cli-build.test.d.ts +2 -0
- package/dist/__tests__/cli-build.test.d.ts.map +1 -0
- package/dist/__tests__/cli-build.test.js +640 -0
- package/dist/__tests__/cli-build.test.js.map +1 -0
- package/dist/__tests__/codex-deploy-config.test.js +60 -0
- package/dist/__tests__/codex-deploy-config.test.js.map +1 -1
- package/dist/__tests__/completion-rows-discriminate.test.d.ts +20 -0
- package/dist/__tests__/completion-rows-discriminate.test.d.ts.map +1 -0
- package/dist/__tests__/completion-rows-discriminate.test.js +481 -0
- package/dist/__tests__/completion-rows-discriminate.test.js.map +1 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts +2 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts.map +1 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js +127 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js.map +1 -0
- package/dist/__tests__/config-fidelity-display.test.d.ts +2 -0
- package/dist/__tests__/config-fidelity-display.test.d.ts.map +1 -0
- package/dist/__tests__/config-fidelity-display.test.js +77 -0
- package/dist/__tests__/config-fidelity-display.test.js.map +1 -0
- package/dist/__tests__/config-fidelity.test.js +166 -33
- package/dist/__tests__/config-fidelity.test.js.map +1 -1
- package/dist/__tests__/config-generation-gate.test.js +78 -0
- package/dist/__tests__/config-generation-gate.test.js.map +1 -1
- package/dist/__tests__/config-sync.test.js +89 -1
- package/dist/__tests__/config-sync.test.js.map +1 -1
- package/dist/__tests__/coordination-401-production-wiring.test.js +12 -7
- package/dist/__tests__/coordination-401-production-wiring.test.js.map +1 -1
- package/dist/__tests__/coordination-401-recovery.test.js +39 -32
- package/dist/__tests__/coordination-401-recovery.test.js.map +1 -1
- package/dist/__tests__/coordination-brief-pin.test.js +21 -8
- package/dist/__tests__/coordination-brief-pin.test.js.map +1 -1
- package/dist/__tests__/coordination-client.test.js +316 -3
- package/dist/__tests__/coordination-client.test.js.map +1 -1
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts +24 -0
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-credential-endpoint.test.js +1290 -0
- package/dist/__tests__/coordination-credential-endpoint.test.js.map +1 -0
- package/dist/__tests__/coordination-memory.test.js +20 -4
- package/dist/__tests__/coordination-memory.test.js.map +1 -1
- package/dist/__tests__/coordination-provision.test.js +22 -14
- package/dist/__tests__/coordination-provision.test.js.map +1 -1
- package/dist/__tests__/coordination-status-registration.test.d.ts +16 -0
- package/dist/__tests__/coordination-status-registration.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-status-registration.test.js +480 -0
- package/dist/__tests__/coordination-status-registration.test.js.map +1 -0
- package/dist/__tests__/coordination-token-multitenant.test.js +24 -24
- package/dist/__tests__/coordination-token-multitenant.test.js.map +1 -1
- package/dist/__tests__/coordination-token.test.js +35 -28
- package/dist/__tests__/coordination-token.test.js.map +1 -1
- package/dist/__tests__/creation-pr-class-check.test.d.ts +17 -0
- package/dist/__tests__/creation-pr-class-check.test.d.ts.map +1 -0
- package/dist/__tests__/creation-pr-class-check.test.js +346 -0
- package/dist/__tests__/creation-pr-class-check.test.js.map +1 -0
- package/dist/__tests__/decision-check.test.d.ts +2 -0
- package/dist/__tests__/decision-check.test.d.ts.map +1 -0
- package/dist/__tests__/decision-check.test.js +105 -0
- package/dist/__tests__/decision-check.test.js.map +1 -0
- package/dist/__tests__/digest-team-omission.test.d.ts +15 -0
- package/dist/__tests__/digest-team-omission.test.d.ts.map +1 -0
- package/dist/__tests__/digest-team-omission.test.js +247 -0
- package/dist/__tests__/digest-team-omission.test.js.map +1 -0
- package/dist/__tests__/doctor-worktree-path.test.d.ts +17 -0
- package/dist/__tests__/doctor-worktree-path.test.d.ts.map +1 -0
- package/dist/__tests__/doctor-worktree-path.test.js +158 -0
- package/dist/__tests__/doctor-worktree-path.test.js.map +1 -0
- package/dist/__tests__/fleet-data.test.js +40 -7
- package/dist/__tests__/fleet-data.test.js.map +1 -1
- package/dist/__tests__/fleet-tmux.test.js +2 -2
- package/dist/__tests__/fleet-tmux.test.js.map +1 -1
- package/dist/__tests__/generate-claude.test.js +137 -3
- package/dist/__tests__/generate-claude.test.js.map +1 -1
- package/dist/__tests__/git-env.test.d.ts +14 -0
- package/dist/__tests__/git-env.test.d.ts.map +1 -0
- package/dist/__tests__/git-env.test.js +131 -0
- package/dist/__tests__/git-env.test.js.map +1 -0
- package/dist/__tests__/git-identity-isolation.test.d.ts +33 -0
- package/dist/__tests__/git-identity-isolation.test.d.ts.map +1 -0
- package/dist/__tests__/git-identity-isolation.test.js +626 -0
- package/dist/__tests__/git-identity-isolation.test.js.map +1 -0
- package/dist/__tests__/harness-extract.test.d.ts +19 -0
- package/dist/__tests__/harness-extract.test.d.ts.map +1 -0
- package/dist/__tests__/harness-extract.test.js +566 -0
- package/dist/__tests__/harness-extract.test.js.map +1 -0
- package/dist/__tests__/harness-wiring.test.d.ts +16 -0
- package/dist/__tests__/harness-wiring.test.d.ts.map +1 -0
- package/dist/__tests__/harness-wiring.test.js +469 -0
- package/dist/__tests__/harness-wiring.test.js.map +1 -0
- package/dist/__tests__/hook-heal.test.js +17 -0
- package/dist/__tests__/hook-heal.test.js.map +1 -1
- package/dist/__tests__/init-coordination-url.test.d.ts +11 -0
- package/dist/__tests__/init-coordination-url.test.d.ts.map +1 -0
- package/dist/__tests__/init-coordination-url.test.js +114 -0
- package/dist/__tests__/init-coordination-url.test.js.map +1 -0
- package/dist/__tests__/memory-autocreate.test.js +574 -8
- package/dist/__tests__/memory-autocreate.test.js.map +1 -1
- package/dist/__tests__/memory-log-result.test.d.ts +13 -0
- package/dist/__tests__/memory-log-result.test.d.ts.map +1 -0
- package/dist/__tests__/memory-log-result.test.js +113 -0
- package/dist/__tests__/memory-log-result.test.js.map +1 -0
- package/dist/__tests__/memory-named-exists.test.d.ts +16 -0
- package/dist/__tests__/memory-named-exists.test.d.ts.map +1 -0
- package/dist/__tests__/memory-named-exists.test.js +288 -0
- package/dist/__tests__/memory-named-exists.test.js.map +1 -0
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js +23 -47
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js.map +1 -1
- package/dist/__tests__/mx-agent-cli-version-pin.test.js +34 -88
- package/dist/__tests__/mx-agent-cli-version-pin.test.js.map +1 -1
- package/dist/__tests__/new-project-first-team.test.d.ts +15 -0
- package/dist/__tests__/new-project-first-team.test.d.ts.map +1 -0
- package/dist/__tests__/new-project-first-team.test.js +263 -0
- package/dist/__tests__/new-project-first-team.test.js.map +1 -0
- package/dist/__tests__/otel-env.test.d.ts +2 -0
- package/dist/__tests__/otel-env.test.d.ts.map +1 -0
- package/dist/__tests__/otel-env.test.js +127 -0
- package/dist/__tests__/otel-env.test.js.map +1 -0
- package/dist/__tests__/project-config.test.js +283 -1
- package/dist/__tests__/project-config.test.js.map +1 -1
- package/dist/__tests__/provision-behavioral-contract.test.js +96 -4
- package/dist/__tests__/provision-behavioral-contract.test.js.map +1 -1
- package/dist/__tests__/provision-catalog-precondition.test.d.ts +26 -0
- package/dist/__tests__/provision-catalog-precondition.test.d.ts.map +1 -0
- package/dist/__tests__/provision-catalog-precondition.test.js +620 -0
- package/dist/__tests__/provision-catalog-precondition.test.js.map +1 -0
- package/dist/__tests__/provision-completion-rows.test.d.ts +17 -0
- package/dist/__tests__/provision-completion-rows.test.d.ts.map +1 -0
- package/dist/__tests__/provision-completion-rows.test.js +3187 -0
- package/dist/__tests__/provision-completion-rows.test.js.map +1 -0
- package/dist/__tests__/provision-identity-gate.test.d.ts +20 -0
- package/dist/__tests__/provision-identity-gate.test.d.ts.map +1 -0
- package/dist/__tests__/provision-identity-gate.test.js +600 -0
- package/dist/__tests__/provision-identity-gate.test.js.map +1 -0
- package/dist/__tests__/provision-resume.test.d.ts +26 -0
- package/dist/__tests__/provision-resume.test.d.ts.map +1 -0
- package/dist/__tests__/provision-resume.test.js +1164 -0
- package/dist/__tests__/provision-resume.test.js.map +1 -0
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts +27 -0
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts.map +1 -0
- package/dist/__tests__/provision-roleguide-anchors.test.js +747 -0
- package/dist/__tests__/provision-roleguide-anchors.test.js.map +1 -0
- package/dist/__tests__/provision-skeleton-fill.test.d.ts +16 -0
- package/dist/__tests__/provision-skeleton-fill.test.d.ts.map +1 -0
- package/dist/__tests__/provision-skeleton-fill.test.js +488 -0
- package/dist/__tests__/provision-skeleton-fill.test.js.map +1 -0
- package/dist/__tests__/provision-teambuilder-flow.test.js +93 -7
- package/dist/__tests__/provision-teambuilder-flow.test.js.map +1 -1
- package/dist/__tests__/repo-guard-wiring.test.d.ts +21 -0
- package/dist/__tests__/repo-guard-wiring.test.d.ts.map +1 -0
- package/dist/__tests__/repo-guard-wiring.test.js +638 -0
- package/dist/__tests__/repo-guard-wiring.test.js.map +1 -0
- package/dist/__tests__/report-format.test.d.ts +2 -0
- package/dist/__tests__/report-format.test.d.ts.map +1 -0
- package/dist/__tests__/report-format.test.js +219 -0
- package/dist/__tests__/report-format.test.js.map +1 -0
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts +20 -0
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts.map +1 -0
- package/dist/__tests__/row15-detail-sanitizer.test.js +61 -0
- package/dist/__tests__/row15-detail-sanitizer.test.js.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts +2 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js +309 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts +2 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.js +163 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.js.map +1 -0
- package/dist/__tests__/runtime-identity.test.d.ts +2 -0
- package/dist/__tests__/runtime-identity.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-identity.test.js +117 -0
- package/dist/__tests__/runtime-identity.test.js.map +1 -0
- package/dist/__tests__/session-pause-provisioning.test.js +6 -1
- package/dist/__tests__/session-pause-provisioning.test.js.map +1 -1
- package/dist/__tests__/session-record-disclosure.test.d.ts +24 -0
- package/dist/__tests__/session-record-disclosure.test.d.ts.map +1 -0
- package/dist/__tests__/session-record-disclosure.test.js +494 -0
- package/dist/__tests__/session-record-disclosure.test.js.map +1 -0
- package/dist/__tests__/session.test.js +35 -0
- package/dist/__tests__/session.test.js.map +1 -1
- package/dist/__tests__/slug-validation.test.js +27 -21
- package/dist/__tests__/slug-validation.test.js.map +1 -1
- package/dist/__tests__/standards-injection.test.d.ts +2 -0
- package/dist/__tests__/standards-injection.test.d.ts.map +1 -0
- package/dist/__tests__/standards-injection.test.js +179 -0
- package/dist/__tests__/standards-injection.test.js.map +1 -0
- package/dist/__tests__/start-interactive-role.test.d.ts +22 -0
- package/dist/__tests__/start-interactive-role.test.d.ts.map +1 -0
- package/dist/__tests__/start-interactive-role.test.js +204 -0
- package/dist/__tests__/start-interactive-role.test.js.map +1 -0
- package/dist/__tests__/start-team-identity.test.d.ts +25 -0
- package/dist/__tests__/start-team-identity.test.d.ts.map +1 -0
- package/dist/__tests__/start-team-identity.test.js +307 -0
- package/dist/__tests__/start-team-identity.test.js.map +1 -0
- package/dist/__tests__/team-memory-commands.test.js +142 -19
- package/dist/__tests__/team-memory-commands.test.js.map +1 -1
- package/dist/__tests__/template-sync.test.d.ts +19 -0
- package/dist/__tests__/template-sync.test.d.ts.map +1 -0
- package/dist/__tests__/template-sync.test.js +270 -0
- package/dist/__tests__/template-sync.test.js.map +1 -0
- package/dist/__tests__/test-project.test.d.ts +18 -0
- package/dist/__tests__/test-project.test.d.ts.map +1 -0
- package/dist/__tests__/test-project.test.js +465 -0
- package/dist/__tests__/test-project.test.js.map +1 -0
- package/dist/__tests__/usage-per-call-grouping.test.d.ts +25 -0
- package/dist/__tests__/usage-per-call-grouping.test.d.ts.map +1 -0
- package/dist/__tests__/usage-per-call-grouping.test.js +952 -0
- package/dist/__tests__/usage-per-call-grouping.test.js.map +1 -0
- package/dist/__tests__/verify-hooks-check-all.test.d.ts +32 -0
- package/dist/__tests__/verify-hooks-check-all.test.d.ts.map +1 -0
- package/dist/__tests__/verify-hooks-check-all.test.js +553 -0
- package/dist/__tests__/verify-hooks-check-all.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-fixture.test.d.ts +17 -0
- package/dist/__tests__/worktree-sync-fixture.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-fixture.test.js +519 -0
- package/dist/__tests__/worktree-sync-fixture.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-hardening.test.d.ts +13 -0
- package/dist/__tests__/worktree-sync-hardening.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-hardening.test.js +919 -0
- package/dist/__tests__/worktree-sync-hardening.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts +25 -0
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-shell-free.test.js +185 -0
- package/dist/__tests__/worktree-sync-shell-free.test.js.map +1 -0
- package/dist/__tests__/worktree.test.js +75 -1
- package/dist/__tests__/worktree.test.js.map +1 -1
- package/dist/agent-config/.mx-config-generation.json +2 -2
- package/dist/agent-config/AGENTS.md.template +2 -2
- package/dist/agent-config/agents/bar-raiser.md +34 -1
- package/dist/agent-config/agents/red-team.md +34 -1
- package/dist/agent-config/agents/security-reviewer.md +22 -1
- package/dist/agent-config/claude-md/CLAUDE.core.md +6 -1
- package/dist/agent-config/claude-md/CLAUDE.overlay.memnexus.md +1 -3
- package/dist/agent-config/coordination-rosters.generated.json +10 -0
- package/dist/agent-config/hooks/HOOK-TIMEOUTS.md +27 -1
- package/dist/agent-config/hooks/OR-TRUE-AUDIT.md +8 -8
- package/dist/agent-config/hooks/auto-capture-precompact.sh +180 -83
- package/dist/agent-config/hooks/auto-capture-session-end.sh +216 -87
- package/dist/agent-config/hooks/auto-checkpoint.sh +75 -5
- package/dist/agent-config/hooks/coordination-brief.sh +290 -245
- package/dist/agent-config/hooks/deploy-verification-reminder.sh +359 -22
- package/dist/agent-config/hooks/git-mutation-guard.sh +85 -13
- package/dist/agent-config/hooks/observability-sync.sh +46 -9
- package/dist/agent-config/hooks/session-idle-gate.sh +177 -12
- package/dist/agent-config/hooks/subagent-write-guard.sh +670 -0
- package/dist/agent-config/hooks/worktree-guard.sh +36 -7
- package/dist/agent-config/settings.json +15 -2
- package/dist/agent-config/shared/creation-pr-review-checklist.md +317 -0
- package/dist/commands/bootstrap.d.ts.map +1 -1
- package/dist/commands/bootstrap.js +22 -10
- package/dist/commands/bootstrap.js.map +1 -1
- package/dist/commands/config-sync.d.ts +37 -0
- package/dist/commands/config-sync.d.ts.map +1 -1
- package/dist/commands/config-sync.js +36 -18
- package/dist/commands/config-sync.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +28 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/coordination.d.ts +150 -8
- package/dist/commands/coordination.d.ts.map +1 -1
- package/dist/commands/coordination.js +524 -25
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/create.d.ts +922 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +4934 -345
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +10 -2
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/decision.d.ts +20 -0
- package/dist/commands/decision.d.ts.map +1 -0
- package/dist/commands/decision.js +54 -0
- package/dist/commands/decision.js.map +1 -0
- package/dist/commands/digest.d.ts.map +1 -1
- package/dist/commands/digest.js +91 -7
- package/dist/commands/digest.js.map +1 -1
- package/dist/commands/fleet-tmux.js +1 -1
- package/dist/commands/fleet-tmux.js.map +1 -1
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +26 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +32 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +98 -5
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/monitor.d.ts.map +1 -1
- package/dist/commands/monitor.js +8 -2
- package/dist/commands/monitor.js.map +1 -1
- package/dist/commands/new.d.ts +2 -0
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +114 -21
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/report.d.ts +33 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +73 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/session.js +1 -1
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/start.d.ts +42 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +183 -8
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/sync.d.ts +57 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +117 -3
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/update.d.ts +13 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +50 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/usage.d.ts +64 -0
- package/dist/commands/usage.d.ts.map +1 -1
- package/dist/commands/usage.js +96 -3
- package/dist/commands/usage.js.map +1 -1
- package/dist/commands/verify-hooks.d.ts +37 -1
- package/dist/commands/verify-hooks.d.ts.map +1 -1
- package/dist/commands/verify-hooks.js +114 -2
- package/dist/commands/verify-hooks.js.map +1 -1
- package/dist/commands/window.d.ts +10 -0
- package/dist/commands/window.d.ts.map +1 -0
- package/dist/commands/window.js +265 -0
- package/dist/commands/window.js.map +1 -0
- package/dist/commands/worktree-sync.d.ts +54 -0
- package/dist/commands/worktree-sync.d.ts.map +1 -0
- package/dist/commands/worktree-sync.js +135 -0
- package/dist/commands/worktree-sync.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +189 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-session.d.ts +12 -0
- package/dist/lib/agent-session.d.ts.map +1 -1
- package/dist/lib/agent-session.js +189 -42
- package/dist/lib/agent-session.js.map +1 -1
- package/dist/lib/behavioral-injection.d.ts +9 -0
- package/dist/lib/behavioral-injection.d.ts.map +1 -1
- package/dist/lib/behavioral-injection.js +10 -1
- package/dist/lib/behavioral-injection.js.map +1 -1
- package/dist/lib/catalog.d.ts +321 -2
- package/dist/lib/catalog.d.ts.map +1 -1
- package/dist/lib/catalog.js +490 -11
- package/dist/lib/catalog.js.map +1 -1
- package/dist/lib/claude.d.ts +113 -23
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +498 -32
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/cli-build.d.ts +172 -0
- package/dist/lib/cli-build.d.ts.map +1 -0
- package/dist/lib/cli-build.js +654 -0
- package/dist/lib/cli-build.js.map +1 -0
- package/dist/lib/code-context-file.d.ts +109 -0
- package/dist/lib/code-context-file.d.ts.map +1 -0
- package/dist/lib/code-context-file.js +219 -0
- package/dist/lib/code-context-file.js.map +1 -0
- package/dist/lib/code-context-file.test.d.ts +19 -0
- package/dist/lib/code-context-file.test.d.ts.map +1 -0
- package/dist/lib/code-context-file.test.js +202 -0
- package/dist/lib/code-context-file.test.js.map +1 -0
- package/dist/lib/config-fidelity.d.ts +40 -20
- package/dist/lib/config-fidelity.d.ts.map +1 -1
- package/dist/lib/config-fidelity.js +144 -56
- package/dist/lib/config-fidelity.js.map +1 -1
- package/dist/lib/coordination-client.d.ts +101 -0
- package/dist/lib/coordination-client.d.ts.map +1 -1
- package/dist/lib/coordination-client.js +232 -8
- package/dist/lib/coordination-client.js.map +1 -1
- package/dist/lib/coordination-token.d.ts +333 -6
- package/dist/lib/coordination-token.d.ts.map +1 -1
- package/dist/lib/coordination-token.js +875 -52
- package/dist/lib/coordination-token.js.map +1 -1
- package/dist/lib/decision-check.d.ts +48 -0
- package/dist/lib/decision-check.d.ts.map +1 -0
- package/dist/lib/decision-check.js +149 -0
- package/dist/lib/decision-check.js.map +1 -0
- package/dist/lib/fleet-data.d.ts +34 -0
- package/dist/lib/fleet-data.d.ts.map +1 -1
- package/dist/lib/fleet-data.js +37 -9
- package/dist/lib/fleet-data.js.map +1 -1
- package/dist/lib/fleet-render.js +1 -1
- package/dist/lib/fleet-render.js.map +1 -1
- package/dist/lib/git-identity.d.ts +302 -0
- package/dist/lib/git-identity.d.ts.map +1 -0
- package/dist/lib/git-identity.js +546 -0
- package/dist/lib/git-identity.js.map +1 -0
- package/dist/lib/harness/console/announce.d.ts +45 -0
- package/dist/lib/harness/console/announce.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.js +48 -0
- package/dist/lib/harness/console/announce.js.map +1 -0
- package/dist/lib/harness/console/announce.test.d.ts +2 -0
- package/dist/lib/harness/console/announce.test.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.test.js +104 -0
- package/dist/lib/harness/console/announce.test.js.map +1 -0
- package/dist/lib/harness/console/by-session.d.ts +50 -0
- package/dist/lib/harness/console/by-session.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.js +83 -0
- package/dist/lib/harness/console/by-session.js.map +1 -0
- package/dist/lib/harness/console/by-session.test.d.ts +2 -0
- package/dist/lib/harness/console/by-session.test.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.test.js +86 -0
- package/dist/lib/harness/console/by-session.test.js.map +1 -0
- package/dist/lib/harness/console/console.d.ts +67 -0
- package/dist/lib/harness/console/console.d.ts.map +1 -0
- package/dist/lib/harness/console/console.js +373 -0
- package/dist/lib/harness/console/console.js.map +1 -0
- package/dist/lib/harness/console/console.test.d.ts +2 -0
- package/dist/lib/harness/console/console.test.d.ts.map +1 -0
- package/dist/lib/harness/console/console.test.js +269 -0
- package/dist/lib/harness/console/console.test.js.map +1 -0
- package/dist/lib/harness/console/decision-request.d.ts +32 -0
- package/dist/lib/harness/console/decision-request.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.js +112 -0
- package/dist/lib/harness/console/decision-request.js.map +1 -0
- package/dist/lib/harness/console/decision-request.test.d.ts +2 -0
- package/dist/lib/harness/console/decision-request.test.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.test.js +75 -0
- package/dist/lib/harness/console/decision-request.test.js.map +1 -0
- package/dist/lib/harness/console/fixtures.d.ts +16 -0
- package/dist/lib/harness/console/fixtures.d.ts.map +1 -0
- package/dist/lib/harness/console/fixtures.js +49 -0
- package/dist/lib/harness/console/fixtures.js.map +1 -0
- package/dist/lib/harness/console/index.d.ts +15 -0
- package/dist/lib/harness/console/index.d.ts.map +1 -0
- package/dist/lib/harness/console/index.js +14 -0
- package/dist/lib/harness/console/index.js.map +1 -0
- package/dist/lib/harness/console/rank.d.ts +73 -0
- package/dist/lib/harness/console/rank.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.js +113 -0
- package/dist/lib/harness/console/rank.js.map +1 -0
- package/dist/lib/harness/console/rank.test.d.ts +2 -0
- package/dist/lib/harness/console/rank.test.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.test.js +124 -0
- package/dist/lib/harness/console/rank.test.js.map +1 -0
- package/dist/lib/harness/console/render.d.ts +22 -0
- package/dist/lib/harness/console/render.d.ts.map +1 -0
- package/dist/lib/harness/console/render.js +65 -0
- package/dist/lib/harness/console/render.js.map +1 -0
- package/dist/lib/harness/console/render.test.d.ts +2 -0
- package/dist/lib/harness/console/render.test.d.ts.map +1 -0
- package/dist/lib/harness/console/render.test.js +96 -0
- package/dist/lib/harness/console/render.test.js.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts +2 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.js +96 -0
- package/dist/lib/harness/console/replay-cli.test.js.map +1 -0
- package/dist/lib/harness/console/replay.d.ts +36 -0
- package/dist/lib/harness/console/replay.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.js +59 -0
- package/dist/lib/harness/console/replay.js.map +1 -0
- package/dist/lib/harness/console/replay.test.d.ts +2 -0
- package/dist/lib/harness/console/replay.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.test.js +81 -0
- package/dist/lib/harness/console/replay.test.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.d.ts +50 -0
- package/dist/lib/harness/console/turn-reader.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.js +184 -0
- package/dist/lib/harness/console/turn-reader.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts +2 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.js +108 -0
- package/dist/lib/harness/console/turn-reader.test.js.map +1 -0
- package/dist/lib/harness/console/types.d.ts +109 -0
- package/dist/lib/harness/console/types.d.ts.map +1 -0
- package/dist/lib/harness/console/types.js +2 -0
- package/dist/lib/harness/console/types.js.map +1 -0
- package/dist/lib/harness/contract.d.ts +229 -0
- package/dist/lib/harness/contract.d.ts.map +1 -0
- package/dist/lib/harness/contract.js +22 -0
- package/dist/lib/harness/contract.js.map +1 -0
- package/dist/lib/harness/credential.d.ts +23 -0
- package/dist/lib/harness/credential.d.ts.map +1 -0
- package/dist/lib/harness/credential.js +81 -0
- package/dist/lib/harness/credential.js.map +1 -0
- package/dist/lib/harness/credential.test.d.ts +2 -0
- package/dist/lib/harness/credential.test.d.ts.map +1 -0
- package/dist/lib/harness/credential.test.js +74 -0
- package/dist/lib/harness/credential.test.js.map +1 -0
- package/dist/lib/harness/evaluate.d.ts +390 -0
- package/dist/lib/harness/evaluate.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.js +988 -0
- package/dist/lib/harness/evaluate.js.map +1 -0
- package/dist/lib/harness/evaluate.test.d.ts +2 -0
- package/dist/lib/harness/evaluate.test.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.test.js +621 -0
- package/dist/lib/harness/evaluate.test.js.map +1 -0
- package/dist/lib/harness/extract.d.ts +152 -0
- package/dist/lib/harness/extract.d.ts.map +1 -0
- package/dist/lib/harness/extract.js +1601 -0
- package/dist/lib/harness/extract.js.map +1 -0
- package/dist/lib/harness/gate.d.ts +48 -0
- package/dist/lib/harness/gate.d.ts.map +1 -0
- package/dist/lib/harness/gate.js +60 -0
- package/dist/lib/harness/gate.js.map +1 -0
- package/dist/lib/harness/gate.test.d.ts +2 -0
- package/dist/lib/harness/gate.test.d.ts.map +1 -0
- package/dist/lib/harness/gate.test.js +111 -0
- package/dist/lib/harness/gate.test.js.map +1 -0
- package/dist/lib/harness/self-check.d.ts +59 -0
- package/dist/lib/harness/self-check.d.ts.map +1 -0
- package/dist/lib/harness/self-check.js +56 -0
- package/dist/lib/harness/self-check.js.map +1 -0
- package/dist/lib/harness/self-check.test.d.ts +2 -0
- package/dist/lib/harness/self-check.test.d.ts.map +1 -0
- package/dist/lib/harness/self-check.test.js +43 -0
- package/dist/lib/harness/self-check.test.js.map +1 -0
- package/dist/lib/harness/transcript.d.ts +65 -0
- package/dist/lib/harness/transcript.d.ts.map +1 -0
- package/dist/lib/harness/transcript.js +144 -0
- package/dist/lib/harness/transcript.js.map +1 -0
- package/dist/lib/harness/transcript.test.d.ts +2 -0
- package/dist/lib/harness/transcript.test.d.ts.map +1 -0
- package/dist/lib/harness/transcript.test.js +118 -0
- package/dist/lib/harness/transcript.test.js.map +1 -0
- package/dist/lib/harness-wiring.d.ts +145 -0
- package/dist/lib/harness-wiring.d.ts.map +1 -0
- package/dist/lib/harness-wiring.js +280 -0
- package/dist/lib/harness-wiring.js.map +1 -0
- package/dist/lib/hook-staleness.d.ts +95 -0
- package/dist/lib/hook-staleness.d.ts.map +1 -0
- package/dist/lib/hook-staleness.js +304 -0
- package/dist/lib/hook-staleness.js.map +1 -0
- package/dist/lib/jsonl.d.ts +270 -2
- package/dist/lib/jsonl.d.ts.map +1 -1
- package/dist/lib/jsonl.js +472 -76
- package/dist/lib/jsonl.js.map +1 -1
- package/dist/lib/memory.d.ts +350 -23
- package/dist/lib/memory.d.ts.map +1 -1
- package/dist/lib/memory.js +751 -38
- package/dist/lib/memory.js.map +1 -1
- package/dist/lib/otel-env.d.ts +90 -0
- package/dist/lib/otel-env.d.ts.map +1 -0
- package/dist/lib/otel-env.js +98 -0
- package/dist/lib/otel-env.js.map +1 -0
- package/dist/lib/project-config.d.ts +167 -0
- package/dist/lib/project-config.d.ts.map +1 -1
- package/dist/lib/project-config.js +321 -5
- package/dist/lib/project-config.js.map +1 -1
- package/dist/lib/projects-registry.d.ts +82 -0
- package/dist/lib/projects-registry.d.ts.map +1 -0
- package/dist/lib/projects-registry.js +145 -0
- package/dist/lib/projects-registry.js.map +1 -0
- package/dist/lib/projects-registry.test.d.ts +2 -0
- package/dist/lib/projects-registry.test.d.ts.map +1 -0
- package/dist/lib/projects-registry.test.js +176 -0
- package/dist/lib/projects-registry.test.js.map +1 -0
- package/dist/lib/repo-guard-scope.d.ts +126 -0
- package/dist/lib/repo-guard-scope.d.ts.map +1 -0
- package/dist/lib/repo-guard-scope.js +249 -0
- package/dist/lib/repo-guard-scope.js.map +1 -0
- package/dist/lib/report-format.d.ts +132 -0
- package/dist/lib/report-format.d.ts.map +1 -0
- package/dist/lib/report-format.js +317 -0
- package/dist/lib/report-format.js.map +1 -0
- package/dist/lib/roster.d.ts +99 -0
- package/dist/lib/roster.d.ts.map +1 -0
- package/dist/lib/roster.js +336 -0
- package/dist/lib/roster.js.map +1 -0
- package/dist/lib/roster.test.d.ts +15 -0
- package/dist/lib/roster.test.d.ts.map +1 -0
- package/dist/lib/roster.test.js +299 -0
- package/dist/lib/roster.test.js.map +1 -0
- package/dist/lib/runtime/codex-adapter.d.ts.map +1 -1
- package/dist/lib/runtime/codex-adapter.js +5 -0
- package/dist/lib/runtime/codex-adapter.js.map +1 -1
- package/dist/lib/runtime/codex-config.d.ts +129 -0
- package/dist/lib/runtime/codex-config.d.ts.map +1 -1
- package/dist/lib/runtime/codex-config.js +225 -0
- package/dist/lib/runtime/codex-config.js.map +1 -1
- package/dist/lib/runtime/identity.d.ts +72 -0
- package/dist/lib/runtime/identity.d.ts.map +1 -0
- package/dist/lib/runtime/identity.js +128 -0
- package/dist/lib/runtime/identity.js.map +1 -0
- package/dist/lib/standards.d.ts +99 -0
- package/dist/lib/standards.d.ts.map +1 -0
- package/dist/lib/standards.js +201 -0
- package/dist/lib/standards.js.map +1 -0
- package/dist/lib/team-identity.d.ts +134 -0
- package/dist/lib/team-identity.d.ts.map +1 -0
- package/dist/lib/team-identity.js +193 -0
- package/dist/lib/team-identity.js.map +1 -0
- package/dist/lib/templates.d.ts +29 -2
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +1042 -82
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/terminal-ui.d.ts.map +1 -1
- package/dist/lib/terminal-ui.js +12 -1
- package/dist/lib/terminal-ui.js.map +1 -1
- package/dist/lib/test-project.d.ts +95 -0
- package/dist/lib/test-project.d.ts.map +1 -0
- package/dist/lib/test-project.js +103 -0
- package/dist/lib/test-project.js.map +1 -0
- package/dist/lib/vault.d.ts +60 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +102 -0
- package/dist/lib/vault.js.map +1 -0
- package/dist/lib/vault.test.d.ts +17 -0
- package/dist/lib/vault.test.d.ts.map +1 -0
- package/dist/lib/vault.test.js +169 -0
- package/dist/lib/vault.test.js.map +1 -0
- package/dist/lib/window-view.d.ts +63 -0
- package/dist/lib/window-view.d.ts.map +1 -0
- package/dist/lib/window-view.js +217 -0
- package/dist/lib/window-view.js.map +1 -0
- package/dist/lib/window-view.test.d.ts +2 -0
- package/dist/lib/window-view.test.d.ts.map +1 -0
- package/dist/lib/window-view.test.js +168 -0
- package/dist/lib/window-view.test.js.map +1 -0
- package/dist/lib/worktree-sync.d.ts +439 -0
- package/dist/lib/worktree-sync.d.ts.map +1 -0
- package/dist/lib/worktree-sync.js +1167 -0
- package/dist/lib/worktree-sync.js.map +1 -0
- package/dist/lib/worktree.d.ts +58 -1
- package/dist/lib/worktree.d.ts.map +1 -1
- package/dist/lib/worktree.js +91 -4
- package/dist/lib/worktree.js.map +1 -1
- package/dist/standards/decision-request.md +98 -0
- package/dist/standards/fail-loud-standard.md +495 -0
- package/dist/standards/po-communication-standard.md +126 -0
- package/dist/standards/report-format.md +128 -0
- package/dist/standards/writing-standard.md +382 -0
- package/package.json +3 -2
- package/scripts/generate-claude.mjs +119 -46
|
@@ -10,7 +10,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
10
10
|
// Mock child_process before importing the module under test.
|
|
11
11
|
vi.mock('child_process', () => ({ spawnSync: vi.fn(), execSync: vi.fn() }));
|
|
12
12
|
import { spawnSync } from 'child_process';
|
|
13
|
-
import { createNamedMemory, bootstrapTeamMemories } from '../lib/memory.js';
|
|
13
|
+
import { createNamedMemory, bootstrapTeamMemories, logManualMemoryCommands, teamMemorySpecs, leaderStateNameCandidates, } from '../lib/memory.js';
|
|
14
14
|
const mockSpawnSync = spawnSync;
|
|
15
15
|
function ok(stdout = 'created mem_123') {
|
|
16
16
|
return { status: 0, stdout, stderr: '', error: undefined };
|
|
@@ -94,7 +94,10 @@ describe('createNamedMemory — codeContext', () => {
|
|
|
94
94
|
// scope-stripping retry. stderr is clean, so no downgrade.
|
|
95
95
|
mockSpawnSync
|
|
96
96
|
.mockReturnValueOnce({ status: 1, stdout: "unknown option '--code-context'", stderr: '', error: undefined }) // echoed on stdout
|
|
97
|
-
|
|
97
|
+
// The verify read now goes through readNamedMemoryJson, which requires a
|
|
98
|
+
// JSON body: "exited 0 and printed nothing parseable" is unknown, never a
|
|
99
|
+
// rescue (#48). A verify that confirms existence therefore returns one.
|
|
100
|
+
.mockReturnValueOnce(ok('{"id":"mem_123","name":"memnexus-retrieval-leader-state"}'));
|
|
98
101
|
const r = createNamedMemory({
|
|
99
102
|
name: 'memnexus-retrieval-leader-state',
|
|
100
103
|
content: 'c',
|
|
@@ -110,7 +113,8 @@ describe('createNamedMemory — codeContext', () => {
|
|
|
110
113
|
it('does NOT downgrade on a real (non-unknown-option) failure — keeps codeContext, falls to verify', () => {
|
|
111
114
|
mockSpawnSync
|
|
112
115
|
.mockReturnValueOnce(fail('server 500: internal error')) // create fails, but not an unknown-option error
|
|
113
|
-
|
|
116
|
+
// JSON body required by the verify read — see the note above.
|
|
117
|
+
.mockReturnValueOnce(ok('{"id":"mem_123","name":"memnexus-retrieval-leader-state"}'));
|
|
114
118
|
const r = createNamedMemory({
|
|
115
119
|
name: 'memnexus-retrieval-leader-state',
|
|
116
120
|
content: 'c',
|
|
@@ -123,8 +127,8 @@ describe('createNamedMemory — codeContext', () => {
|
|
|
123
127
|
expect(r.ok).toBe(true); // verify confirmed existence
|
|
124
128
|
});
|
|
125
129
|
});
|
|
126
|
-
describe('bootstrapTeamMemories —
|
|
127
|
-
it('passes
|
|
130
|
+
describe('bootstrapTeamMemories — codeContext on the created memories', () => {
|
|
131
|
+
it('passes the same four-field scope on all three: product, service, team, role (#6)', () => {
|
|
128
132
|
mockSpawnSync.mockReturnValue(ok());
|
|
129
133
|
bootstrapTeamMemories('retrieval', 'Retrieval', 'rg.md', 'memnexus');
|
|
130
134
|
const createCalls = mockSpawnSync.mock.calls
|
|
@@ -135,9 +139,571 @@ describe('bootstrapTeamMemories — per-key codeContext', () => {
|
|
|
135
139
|
const i = call[1].indexOf('--code-context');
|
|
136
140
|
return JSON.parse(call[1][i + 1]);
|
|
137
141
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
142
|
+
// The seeds carried product + team only (role on leader-state alone), so a new
|
|
143
|
+
// team's three memories scoped differently from every memory it wrote after.
|
|
144
|
+
const expected = {
|
|
145
|
+
product: 'memnexus',
|
|
146
|
+
service: 'team-provisioning',
|
|
147
|
+
team: 'retrieval',
|
|
148
|
+
role: 'team-lead',
|
|
149
|
+
};
|
|
150
|
+
expect(ctxFor('leader-state')).toEqual(expected);
|
|
151
|
+
expect(ctxFor('iteration-log')).toEqual(expected);
|
|
152
|
+
expect(ctxFor('known-issues')).toEqual(expected);
|
|
153
|
+
});
|
|
154
|
+
it('creates the leader-state with the Async Status Block, not a flat sentence', () => {
|
|
155
|
+
// The content that reaches `mx memories create` is the seed itself: the row
|
|
156
|
+
// the completion check reads back is only as good as what was written.
|
|
157
|
+
mockSpawnSync.mockReturnValue(ok());
|
|
158
|
+
bootstrapTeamMemories('retrieval', 'Retrieval', 'rg.md', 'memnexus', {
|
|
159
|
+
catalogPath: 'mx-agent-system/teams/retrieval.md',
|
|
160
|
+
now: new Date('2026-08-21T09:07:00.000Z'),
|
|
161
|
+
});
|
|
162
|
+
const createCalls = mockSpawnSync.mock.calls
|
|
163
|
+
.filter(([, args]) => args[0] === 'memories' && args[1] === 'create');
|
|
164
|
+
const leader = createCalls.find(([, args]) => args.some((a) => a.includes('leader-state')));
|
|
165
|
+
const content = leader[1][leader[1].indexOf('--content') + 1];
|
|
166
|
+
expect(content).toContain('## Retrieval Leader State, updated 2026-08-21 09:07');
|
|
167
|
+
expect(content).toContain('### Async Status Block');
|
|
168
|
+
expect(content).toContain('- Async status: ok');
|
|
169
|
+
expect(content).toContain('- Linkage: mx-agent-system/teams/retrieval.md, rg.md');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Conversation threading (#93, #101), and the sink that validates the value.
|
|
174
|
+
*
|
|
175
|
+
* A team's three seeds belong in ONE conversation: conversation is a retrieval
|
|
176
|
+
* grouping, so a seed in its own conversation is a seed no retrieval of the
|
|
177
|
+
* other two surfaces. Every create defaulted to `NEW`, and one rehearsal team
|
|
178
|
+
* recorded three distinct conversation ids (`.mx-qa-report-24.md:159-163`).
|
|
179
|
+
*
|
|
180
|
+
* These cases live in this file because it mocks `child_process` at module scope
|
|
181
|
+
* (line 13). That mock is per-file: a new test file omitting it reaches the real
|
|
182
|
+
* `mx` against the live account, where `mx memories create --name` is an upsert
|
|
183
|
+
* and would replace a live team's leader-state content.
|
|
184
|
+
*
|
|
185
|
+
* Every case sets a default `mockReturnValue` as well as its branches, so an
|
|
186
|
+
* unexpected call fails as an assertion rather than as a TypeError on
|
|
187
|
+
* `undefined.stdout`, and the exact call count is asserted in each.
|
|
188
|
+
*/
|
|
189
|
+
describe('bootstrapTeamMemories — the three seeds share one conversation', () => {
|
|
190
|
+
const absent = { status: 1, stdout: '', stderr: '✖ not found', error: undefined, signal: null };
|
|
191
|
+
const unexpected = { status: 1, stdout: '', stderr: 'unexpected call', error: undefined, signal: null };
|
|
192
|
+
const created = (id, conversationId) => ({
|
|
193
|
+
status: 0,
|
|
194
|
+
stdout: JSON.stringify(conversationId === undefined ? { id } : { id, conversationId }),
|
|
195
|
+
stderr: '',
|
|
196
|
+
error: undefined,
|
|
197
|
+
signal: null,
|
|
198
|
+
});
|
|
199
|
+
/** A standing memory, with the codeContext a seeded memory of this team holds. */
|
|
200
|
+
const standing = (opts) => ({
|
|
201
|
+
status: 0,
|
|
202
|
+
stdout: JSON.stringify({
|
|
203
|
+
id: 'standing-id',
|
|
204
|
+
name: opts.name,
|
|
205
|
+
content: 'seeded by an earlier run',
|
|
206
|
+
...(opts.conversationId === undefined ? {} : { conversationId: opts.conversationId }),
|
|
207
|
+
codeContext: 'codeContext' in opts
|
|
208
|
+
? opts.codeContext
|
|
209
|
+
: {
|
|
210
|
+
product: opts.product ?? 'mx-agent',
|
|
211
|
+
service: 'team-provisioning',
|
|
212
|
+
team: opts.team ?? 'newteam',
|
|
213
|
+
role: 'team-lead',
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
stderr: '',
|
|
217
|
+
error: undefined,
|
|
218
|
+
signal: null,
|
|
219
|
+
});
|
|
220
|
+
const createCalls = () => mockSpawnSync.mock.calls
|
|
221
|
+
.filter(([, args]) => args[0] === 'memories' && args[1] === 'create');
|
|
222
|
+
/** Every `--conversation-id` value passed to a create, in call order. */
|
|
223
|
+
const conversationArgs = () => createCalls().map(([, args]) => args[args.indexOf('--conversation-id') + 1]);
|
|
224
|
+
it('threads calls two and three into the conversation call one opened', () => {
|
|
225
|
+
let creates = 0;
|
|
226
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
227
|
+
if (args[1] === 'get')
|
|
228
|
+
return absent;
|
|
229
|
+
creates += 1;
|
|
230
|
+
return created(`mem-${creates}`, 'conv_9a1f4c2b7e');
|
|
231
|
+
});
|
|
232
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
233
|
+
// Three probes and three creates. Nothing else runs.
|
|
234
|
+
expect(mockSpawnSync).toHaveBeenCalledTimes(6);
|
|
235
|
+
expect(conversationArgs()).toEqual(['NEW', 'conv_9a1f4c2b7e', 'conv_9a1f4c2b7e']);
|
|
236
|
+
expect(result.conversationThreaded).toBe(true);
|
|
237
|
+
expect(result.conversationId).toBe('conv_9a1f4c2b7e');
|
|
238
|
+
expect(result.conversationOutcome).toBe('threaded-by-this-run');
|
|
239
|
+
});
|
|
240
|
+
it('falls back to NEW when call one returned no conversation id', () => {
|
|
241
|
+
mockSpawnSync.mockImplementation((_cmd, args) => args[1] === 'get' ? absent : created('mem-x'));
|
|
242
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
243
|
+
// Three NEWs is the pre-fix behaviour, and it is the right fallback: the
|
|
244
|
+
// alternative is an empty string as the flag value.
|
|
245
|
+
expect(mockSpawnSync).toHaveBeenCalledTimes(6);
|
|
246
|
+
expect(conversationArgs()).toEqual(['NEW', 'NEW', 'NEW']);
|
|
247
|
+
expect(result.conversationThreaded).toBe(false);
|
|
248
|
+
expect(result.conversationId).toBeNull();
|
|
249
|
+
expect(result.conversationOutcome).toBe('create-returned-no-conversation-id');
|
|
250
|
+
});
|
|
251
|
+
it.each([
|
|
252
|
+
['a value too short', 'conv_'],
|
|
253
|
+
['a value without the prefix', 'oops'],
|
|
254
|
+
['a flag-shaped token', '--content'],
|
|
255
|
+
['a trailing newline', 'conv_9a1f4c2b7e\n'],
|
|
256
|
+
['an empty string', ''],
|
|
257
|
+
['a number', 42],
|
|
258
|
+
['null', null],
|
|
259
|
+
])('falls back to NEW when call one returned %s', (_label, value) => {
|
|
260
|
+
mockSpawnSync.mockImplementation((_cmd, args) => args[1] === 'get' ? absent : created('mem-x', value));
|
|
261
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
262
|
+
expect(conversationArgs()).toEqual(['NEW', 'NEW', 'NEW']);
|
|
263
|
+
expect(result.conversationThreaded).toBe(false);
|
|
264
|
+
expect(result.conversationOutcome).toBe('create-returned-no-conversation-id');
|
|
265
|
+
});
|
|
266
|
+
it('re-provision: joins the conversation the standing leader-state is in', () => {
|
|
267
|
+
// The interrupted case. A run killed after the first create leaves the
|
|
268
|
+
// leader-state behind; the next run refuses that name and still puts the
|
|
269
|
+
// other two memories where the first one is.
|
|
270
|
+
mockSpawnSync.mockReturnValue(unexpected);
|
|
271
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
272
|
+
if (args[1] === 'get') {
|
|
273
|
+
const name = args[3];
|
|
274
|
+
return name.endsWith('-leader-state')
|
|
275
|
+
? standing({ name, conversationId: 'conv_fromrunone' })
|
|
276
|
+
: absent;
|
|
277
|
+
}
|
|
278
|
+
return created('mem-x', 'conv_fromrunone');
|
|
279
|
+
});
|
|
280
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
281
|
+
// Three probes and two creates. No fourth read: the conversation comes from
|
|
282
|
+
// the probe body this run already has.
|
|
283
|
+
expect(mockSpawnSync).toHaveBeenCalledTimes(5);
|
|
284
|
+
expect(result.leaderState.preExisting).toBe(true);
|
|
285
|
+
expect(conversationArgs()).toEqual(['conv_fromrunone', 'conv_fromrunone']);
|
|
286
|
+
expect(result.conversationThreaded).toBe(true);
|
|
287
|
+
expect(result.conversationId).toBe('conv_fromrunone');
|
|
288
|
+
expect(result.conversationOutcome).toBe('threaded-onto-the-standing-leader-state');
|
|
289
|
+
});
|
|
290
|
+
it.each([
|
|
291
|
+
['another team holds the name', { team: 'otherteam' }],
|
|
292
|
+
['another project holds the name', { product: 'otherproject' }],
|
|
293
|
+
])('re-provision: NEW when %s', (_label, overrides) => {
|
|
294
|
+
// The probe resolves by name alone, and with no configured project slug the
|
|
295
|
+
// name is unprefixed on an account shared across projects. Threading a
|
|
296
|
+
// foreign memory's conversation would group two teams' state as one unit.
|
|
297
|
+
mockSpawnSync.mockReturnValue(unexpected);
|
|
298
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
299
|
+
if (args[1] === 'get') {
|
|
300
|
+
const name = args[3];
|
|
301
|
+
return name.endsWith('-leader-state')
|
|
302
|
+
? standing({ name, conversationId: 'conv_someoneelses', ...overrides })
|
|
303
|
+
: absent;
|
|
304
|
+
}
|
|
305
|
+
return created('mem-x');
|
|
306
|
+
});
|
|
307
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
308
|
+
expect(result.leaderState.preExistingOwnership).toBe('not-this-team');
|
|
309
|
+
expect(conversationArgs()).toEqual(['NEW', 'NEW']);
|
|
310
|
+
expect(result.conversationThreaded).toBe(false);
|
|
311
|
+
expect(result.conversationId).toBeNull();
|
|
312
|
+
expect(result.conversationOutcome).toBe('standing-leader-state-is-not-this-team');
|
|
313
|
+
});
|
|
314
|
+
it.each([
|
|
315
|
+
['the standing memory has no codeContext', { codeContext: undefined }],
|
|
316
|
+
['its codeContext is not an object', { codeContext: 'team-provisioning' }],
|
|
317
|
+
['its codeContext names no team', { codeContext: { product: 'mx-agent', role: 'team-lead' } }],
|
|
318
|
+
['its codeContext names no product and a slug is configured', { codeContext: { team: 'newteam' } }],
|
|
319
|
+
])('re-provision: NEW, ownership unconfirmed, when %s', (_label, overrides) => {
|
|
320
|
+
// A memory that answers the ownership question with nothing has not said it
|
|
321
|
+
// is another team's. Reporting it as another team's would be a claim this
|
|
322
|
+
// run cannot make, and the fallback is the same either way.
|
|
323
|
+
mockSpawnSync.mockReturnValue(unexpected);
|
|
324
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
325
|
+
if (args[1] === 'get') {
|
|
326
|
+
const name = args[3];
|
|
327
|
+
return name.endsWith('-leader-state')
|
|
328
|
+
? standing({ name, conversationId: 'conv_someoneelses', ...overrides })
|
|
329
|
+
: absent;
|
|
330
|
+
}
|
|
331
|
+
return created('mem-x');
|
|
332
|
+
});
|
|
333
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
334
|
+
expect(result.leaderState.preExistingOwnership).toBe('unconfirmed');
|
|
335
|
+
expect(conversationArgs()).toEqual(['NEW', 'NEW']);
|
|
336
|
+
expect(result.conversationThreaded).toBe(false);
|
|
337
|
+
expect(result.conversationOutcome).toBe('standing-leader-state-ownership-unconfirmed');
|
|
338
|
+
});
|
|
339
|
+
it('re-provision: NEW when this team\'s standing memory reports no conversation', () => {
|
|
340
|
+
mockSpawnSync.mockReturnValue(unexpected);
|
|
341
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
342
|
+
if (args[1] === 'get') {
|
|
343
|
+
const name = args[3];
|
|
344
|
+
return name.endsWith('-leader-state') ? standing({ name }) : absent;
|
|
345
|
+
}
|
|
346
|
+
return created('mem-x');
|
|
347
|
+
});
|
|
348
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
349
|
+
expect(result.leaderState.preExistingOwnership).toBe('this-team');
|
|
350
|
+
expect(conversationArgs()).toEqual(['NEW', 'NEW']);
|
|
351
|
+
expect(result.conversationThreaded).toBe(false);
|
|
352
|
+
expect(result.conversationOutcome).toBe('standing-leader-state-has-no-conversation-id');
|
|
353
|
+
});
|
|
354
|
+
it('is not threaded when call two fails after a well-formed call one', () => {
|
|
355
|
+
// The claim is about where three memories ARE. Call one opened a
|
|
356
|
+
// conversation, call two wrote nothing, so two of the three are not in it.
|
|
357
|
+
let creates = 0;
|
|
358
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
359
|
+
if (args[1] === 'get')
|
|
360
|
+
return absent;
|
|
361
|
+
creates += 1;
|
|
362
|
+
return creates === 2
|
|
363
|
+
? { status: 1, stdout: '', stderr: 'server 500: internal error', error: undefined, signal: null }
|
|
364
|
+
: created(`mem-${creates}`, 'conv_9a1f4c2b7e');
|
|
365
|
+
});
|
|
366
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
367
|
+
// The failed create falls back to a verify read, so seven calls: three
|
|
368
|
+
// probes, three creates, one verify.
|
|
369
|
+
expect(mockSpawnSync).toHaveBeenCalledTimes(7);
|
|
370
|
+
expect(result.iterationLog.ok).toBe(false);
|
|
371
|
+
expect(result.conversationThreaded).toBe(false);
|
|
372
|
+
expect(result.conversationId).toBeNull();
|
|
373
|
+
expect(result.conversationOutcome).toBe('follower-create-rejected-the-conversation');
|
|
374
|
+
});
|
|
375
|
+
it('is not threaded when a follower reports a different conversation', () => {
|
|
376
|
+
// Passing the id is a request. A follower that answers with another
|
|
377
|
+
// conversation is the service declining it, and the memory is elsewhere.
|
|
378
|
+
let creates = 0;
|
|
379
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
380
|
+
if (args[1] === 'get')
|
|
381
|
+
return absent;
|
|
382
|
+
creates += 1;
|
|
383
|
+
return created(`mem-${creates}`, creates === 3 ? 'conv_somewhereelse' : 'conv_9a1f4c2b7e');
|
|
384
|
+
});
|
|
385
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
386
|
+
expect(result.conversationThreaded).toBe(false);
|
|
387
|
+
expect(result.conversationOutcome).toBe('follower-create-rejected-the-conversation');
|
|
388
|
+
});
|
|
389
|
+
it('stays threaded when a follower reports no conversation at all', () => {
|
|
390
|
+
// An older mx prints no such key. Absence is not a contradiction, and the
|
|
391
|
+
// leader-state's own absence is already covered by its own outcome.
|
|
392
|
+
let creates = 0;
|
|
393
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
394
|
+
if (args[1] === 'get')
|
|
395
|
+
return absent;
|
|
396
|
+
creates += 1;
|
|
397
|
+
return creates === 1 ? created('mem-1', 'conv_9a1f4c2b7e') : created(`mem-${creates}`);
|
|
398
|
+
});
|
|
399
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
400
|
+
expect(result.conversationThreaded).toBe(true);
|
|
401
|
+
expect(result.conversationOutcome).toBe('threaded-by-this-run');
|
|
402
|
+
});
|
|
403
|
+
it('is not threaded when a preamble precedes the JSON on stdout', () => {
|
|
404
|
+
// `mx` can print an update notice before the body. The parser requires the
|
|
405
|
+
// trimmed stdout to START with the object, so this yields no id, both
|
|
406
|
+
// followers pass NEW, and the run behaves as every provision before #93.
|
|
407
|
+
// Reported rather than guessed at: a conv_ value scanned out of free text
|
|
408
|
+
// could come from a memory's own echoed content.
|
|
409
|
+
mockSpawnSync.mockImplementation((_cmd, args) => args[1] === 'get'
|
|
410
|
+
? absent
|
|
411
|
+
: {
|
|
412
|
+
status: 0,
|
|
413
|
+
stdout: 'Warning: update available\n{"id":"x"}',
|
|
414
|
+
stderr: '',
|
|
415
|
+
error: undefined,
|
|
416
|
+
signal: null,
|
|
417
|
+
});
|
|
418
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
419
|
+
expect(result.leaderState.ok).toBe(true);
|
|
420
|
+
expect(conversationArgs()).toEqual(['NEW', 'NEW', 'NEW']);
|
|
421
|
+
expect(result.conversationThreaded).toBe(false);
|
|
422
|
+
expect(result.conversationOutcome).toBe('create-returned-no-conversation-id');
|
|
423
|
+
});
|
|
424
|
+
it('never passes an empty or undefined --conversation-id value', () => {
|
|
425
|
+
// The one shape that must never reach the flag.
|
|
426
|
+
mockSpawnSync.mockImplementation((_cmd, args) => args[1] === 'get' ? absent : created('mem-x', ''));
|
|
427
|
+
bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
428
|
+
for (const [, args] of createCalls()) {
|
|
429
|
+
const i = args.indexOf('--conversation-id');
|
|
430
|
+
expect(i).toBeGreaterThan(-1);
|
|
431
|
+
expect(typeof args[i + 1]).toBe('string');
|
|
432
|
+
expect(args[i + 1].length).toBeGreaterThan(0);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
describe('createNamedMemory — the conversation id is validated at the sink', () => {
|
|
437
|
+
it.each([
|
|
438
|
+
['an empty string', ''],
|
|
439
|
+
['a flag-shaped token', '--code-context'],
|
|
440
|
+
['a value without the prefix', 'oops'],
|
|
441
|
+
['a value too short', 'conv_'],
|
|
442
|
+
['a trailing newline', 'conv_9a1f4c2b7e\n'],
|
|
443
|
+
['a value over the 64-character bound', `conv_${'a'.repeat(65)}`],
|
|
444
|
+
])('replaces %s with NEW', (_label, value) => {
|
|
445
|
+
mockSpawnSync.mockReturnValue(ok('{"id":"mem-x"}'));
|
|
446
|
+
// The type allows a string, and the destructuring default fired on undefined
|
|
447
|
+
// only, so every value here reached the argv before the sink check.
|
|
448
|
+
createNamedMemory({ name: 'x-leader-state', content: 'c', conversationId: value });
|
|
449
|
+
const args = mockSpawnSync.mock.calls[0][1];
|
|
450
|
+
expect(args[args.indexOf('--conversation-id') + 1]).toBe('NEW');
|
|
451
|
+
});
|
|
452
|
+
it('passes a well-formed id through unchanged', () => {
|
|
453
|
+
mockSpawnSync.mockReturnValue(ok('{"id":"mem-x"}'));
|
|
454
|
+
createNamedMemory({ name: 'x-known-issues', content: 'c', conversationId: 'conv_9a1f4c2b7e' });
|
|
455
|
+
const args = mockSpawnSync.mock.calls[0][1];
|
|
456
|
+
expect(args[args.indexOf('--conversation-id') + 1]).toBe('conv_9a1f4c2b7e');
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
describe('logManualMemoryCommands — the printed fallback seeds one conversation', () => {
|
|
460
|
+
it('opens with NEW, joins with a quoted placeholder, and says to replace it', () => {
|
|
461
|
+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
462
|
+
try {
|
|
463
|
+
logManualMemoryCommands(teamMemorySpecs('newteam', 'Newteam', 'rg.md', 'mx-agent'));
|
|
464
|
+
const lines = logSpy.mock.calls.map((c) => String(c[0]));
|
|
465
|
+
// Three commands and one instruction line, in the step 6c order.
|
|
466
|
+
expect(lines).toHaveLength(4);
|
|
467
|
+
expect(lines[0]).toContain('--conversation-id NEW');
|
|
468
|
+
expect(lines[0]).toContain('mx-agent-newteam-leader-state');
|
|
469
|
+
expect(lines[1]).toContain('PASTE_CONVERSATION_ID_FROM_STEP_1');
|
|
470
|
+
expect(lines[1]).toContain('Replace');
|
|
471
|
+
expect(lines[2]).toContain("--conversation-id 'PASTE_CONVERSATION_ID_FROM_STEP_1'");
|
|
472
|
+
expect(lines[2]).toContain('mx-agent-newteam-iteration-log');
|
|
473
|
+
expect(lines[3]).toContain("--conversation-id 'PASTE_CONVERSATION_ID_FROM_STEP_1'");
|
|
474
|
+
expect(lines[3]).toContain('mx-agent-newteam-known-issues');
|
|
475
|
+
// Exactly one command opens a conversation.
|
|
476
|
+
expect(lines.filter((l) => l.includes('--conversation-id NEW'))).toHaveLength(1);
|
|
477
|
+
}
|
|
478
|
+
finally {
|
|
479
|
+
logSpy.mockRestore();
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
it('the placeholder holds no shell metacharacter and is not id-shaped', () => {
|
|
483
|
+
// Pasted verbatim, the line must not redirect, quote or word-split, and it
|
|
484
|
+
// must not look like a value a reader can leave in place.
|
|
485
|
+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
486
|
+
try {
|
|
487
|
+
logManualMemoryCommands(teamMemorySpecs('newteam', 'Newteam', 'rg.md', 'mx-agent'));
|
|
488
|
+
const joinLine = String(logSpy.mock.calls[2][0]);
|
|
489
|
+
const placeholder = joinLine.split("--conversation-id ")[1].split(' ')[0];
|
|
490
|
+
expect(placeholder).toBe("'PASTE_CONVERSATION_ID_FROM_STEP_1'");
|
|
491
|
+
expect(placeholder).not.toMatch(/[<>|&;$`(){}[\]*?~!#]/);
|
|
492
|
+
expect(placeholder.replace(/'/g, '')).not.toMatch(/^conv_/);
|
|
493
|
+
}
|
|
494
|
+
finally {
|
|
495
|
+
logSpy.mockRestore();
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
/**
|
|
500
|
+
* Anchors beyond the three, against the REAL module (#138, plan #190).
|
|
501
|
+
*
|
|
502
|
+
* These are the conditions that cannot be proved against a fixture, because they
|
|
503
|
+
* are about what `bootstrapTeamMemories` itself does: which path an extra anchor
|
|
504
|
+
* takes, which conversation it is given, and what the threading verdict counts.
|
|
505
|
+
*/
|
|
506
|
+
describe('bootstrapTeamMemories — anchors beyond the three (#190)', () => {
|
|
507
|
+
const absent = { status: 1, stdout: '', stderr: '✖ not found', error: undefined, signal: null };
|
|
508
|
+
const created = (id, conversationId) => ({
|
|
509
|
+
status: 0,
|
|
510
|
+
stdout: JSON.stringify(conversationId === undefined ? { id } : { id, conversationId }),
|
|
511
|
+
stderr: '',
|
|
512
|
+
error: undefined,
|
|
513
|
+
signal: null,
|
|
514
|
+
});
|
|
515
|
+
const createCalls = () => mockSpawnSync.mock.calls
|
|
516
|
+
.filter(([, args]) => args[0] === 'memories' && args[1] === 'create');
|
|
517
|
+
const conversationArgs = () => createCalls().map(([, args]) => args[args.indexOf('--conversation-id') + 1]);
|
|
518
|
+
const createdNames = () => createCalls().map(([, args]) => args[args.indexOf('--name') + 1]);
|
|
519
|
+
/**
|
|
520
|
+
* M3. The extras take the SAME probe-then-create path, so a probe runs for
|
|
521
|
+
* each one before its create, in table order, on one conversation.
|
|
522
|
+
*/
|
|
523
|
+
it('probes then creates each extra, in table order, on the leader-state conversation (M3, M5)', () => {
|
|
524
|
+
let creates = 0;
|
|
525
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
526
|
+
if (args[1] === 'get')
|
|
527
|
+
return absent;
|
|
528
|
+
creates += 1;
|
|
529
|
+
return created(`mem-${creates}`, 'conv_9a1f4c2b7e');
|
|
530
|
+
});
|
|
531
|
+
const result = bootstrapTeamMemories('surface', 'Surface', 'rg.md', 'mx-agent', {
|
|
532
|
+
extraAnchorSuffixes: ['watch-log', 'completion-contract'],
|
|
533
|
+
});
|
|
534
|
+
// Five probes and five creates. One probe per anchor, and no extra call.
|
|
535
|
+
expect(mockSpawnSync).toHaveBeenCalledTimes(10);
|
|
536
|
+
expect(createdNames()).toEqual([
|
|
537
|
+
'mx-agent-surface-leader-state',
|
|
538
|
+
'mx-agent-surface-iteration-log',
|
|
539
|
+
'mx-agent-surface-known-issues',
|
|
540
|
+
'mx-agent-surface-watch-log',
|
|
541
|
+
'mx-agent-surface-completion-contract',
|
|
542
|
+
]);
|
|
543
|
+
expect(conversationArgs()).toEqual([
|
|
544
|
+
'NEW', 'conv_9a1f4c2b7e', 'conv_9a1f4c2b7e', 'conv_9a1f4c2b7e', 'conv_9a1f4c2b7e',
|
|
545
|
+
]);
|
|
546
|
+
expect(result.conversationThreaded).toBe(true);
|
|
547
|
+
expect(result.extras.map((e) => e.suffix)).toEqual(['watch-log', 'completion-contract']);
|
|
548
|
+
expect(result.extras.every((e) => e.creation.ok)).toBe(true);
|
|
549
|
+
});
|
|
550
|
+
/**
|
|
551
|
+
* M5, the condition this test exists for. The old computation enumerated
|
|
552
|
+
* `[iterationLog, knownIssues]`. With a fourth anchor reporting a DIFFERENT
|
|
553
|
+
* conversation, that computation would have reported `true` while the fourth
|
|
554
|
+
* memory sat somewhere no retrieval of the other three would surface, which is
|
|
555
|
+
* exactly the #93 defect returning silently.
|
|
556
|
+
*/
|
|
557
|
+
it('reports followersJoined false when a FOURTH anchor lands in another conversation (M5)', () => {
|
|
558
|
+
let creates = 0;
|
|
559
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
560
|
+
if (args[1] === 'get')
|
|
561
|
+
return absent;
|
|
562
|
+
creates += 1;
|
|
563
|
+
// The first three agree. The fourth is given `conv_aaa` and reports its own.
|
|
564
|
+
return created(`mem-${creates}`, creates === 4 ? 'conv_elsewhere' : 'conv_aaaaaaaaaa');
|
|
565
|
+
});
|
|
566
|
+
const result = bootstrapTeamMemories('surface', 'Surface', 'rg.md', 'mx-agent', {
|
|
567
|
+
extraAnchorSuffixes: ['watch-log'],
|
|
568
|
+
});
|
|
569
|
+
expect(result.conversationThreaded).toBe(false);
|
|
570
|
+
expect(result.conversationId).toBeNull();
|
|
571
|
+
expect(result.conversationOutcome).toBe('follower-create-rejected-the-conversation');
|
|
572
|
+
// The three still agree with each other, which is why a two-follower
|
|
573
|
+
// computation would have said true.
|
|
574
|
+
expect(result.iterationLog.conversationId).toBe('conv_aaaaaaaaaa');
|
|
575
|
+
expect(result.knownIssues.conversationId).toBe('conv_aaaaaaaaaa');
|
|
576
|
+
expect(result.extras[0].creation.conversationId).toBe('conv_elsewhere');
|
|
577
|
+
});
|
|
578
|
+
it('reports followersJoined false when a fourth anchor create FAILS', () => {
|
|
579
|
+
let creates = 0;
|
|
580
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
581
|
+
if (args[1] === 'get')
|
|
582
|
+
return absent;
|
|
583
|
+
creates += 1;
|
|
584
|
+
if (creates === 4)
|
|
585
|
+
return { status: 1, stdout: '', stderr: 'rejected', error: undefined, signal: null };
|
|
586
|
+
return created(`mem-${creates}`, 'conv_aaaaaaaaaa');
|
|
587
|
+
});
|
|
588
|
+
const result = bootstrapTeamMemories('surface', 'Surface', 'rg.md', 'mx-agent', {
|
|
589
|
+
extraAnchorSuffixes: ['watch-log'],
|
|
590
|
+
});
|
|
591
|
+
expect(result.extras[0].creation.ok).toBe(false);
|
|
592
|
+
expect(result.conversationThreaded).toBe(false);
|
|
593
|
+
});
|
|
594
|
+
/**
|
|
595
|
+
* M3. `mx memories create --name` is an upsert, so a taken name must not be
|
|
596
|
+
* written over. The extras get the same refusal and the same ownership
|
|
597
|
+
* classification as the three, because they go through the same closure.
|
|
598
|
+
*/
|
|
599
|
+
it('never creates over a taken extra anchor, and classifies its ownership (M3)', () => {
|
|
600
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
601
|
+
if (args[1] === 'get') {
|
|
602
|
+
const name = args[args.indexOf('--name') + 1];
|
|
603
|
+
if (name === 'mx-agent-surface-watch-log') {
|
|
604
|
+
return {
|
|
605
|
+
status: 0,
|
|
606
|
+
stdout: JSON.stringify({
|
|
607
|
+
id: 'standing-id',
|
|
608
|
+
name,
|
|
609
|
+
content: 'hand-written watch log',
|
|
610
|
+
conversationId: 'conv_standing1',
|
|
611
|
+
codeContext: { product: 'mx-agent', service: 'x', team: 'surface', role: 'team-lead' },
|
|
612
|
+
}),
|
|
613
|
+
stderr: '', error: undefined, signal: null,
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
return absent;
|
|
617
|
+
}
|
|
618
|
+
return created('mem-x', 'conv_aaaaaaaaaa');
|
|
619
|
+
});
|
|
620
|
+
const result = bootstrapTeamMemories('surface', 'Surface', 'rg.md', 'mx-agent', {
|
|
621
|
+
extraAnchorSuffixes: ['watch-log'],
|
|
622
|
+
});
|
|
623
|
+
// Three creates, not four: the taken name was probed and left alone.
|
|
624
|
+
expect(createdNames()).toEqual([
|
|
625
|
+
'mx-agent-surface-leader-state',
|
|
626
|
+
'mx-agent-surface-iteration-log',
|
|
627
|
+
'mx-agent-surface-known-issues',
|
|
628
|
+
]);
|
|
629
|
+
const extra = result.extras[0].creation;
|
|
630
|
+
expect(extra.ok).toBe(false);
|
|
631
|
+
expect(extra.preExisting).toBe(true);
|
|
632
|
+
expect(extra.preExistingOwnership).toBe('this-team');
|
|
633
|
+
expect(extra.output).toContain('name already taken');
|
|
634
|
+
expect(extra.preExistingRead?.content).toBe('hand-written watch log');
|
|
635
|
+
// A follower that was never written is not in the conversation.
|
|
636
|
+
expect(result.conversationThreaded).toBe(false);
|
|
637
|
+
});
|
|
638
|
+
it('classifies an extra anchor held by ANOTHER team as not-this-team (M3)', () => {
|
|
639
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
640
|
+
if (args[1] === 'get') {
|
|
641
|
+
const name = args[args.indexOf('--name') + 1];
|
|
642
|
+
if (name === 'mx-agent-surface-watch-log') {
|
|
643
|
+
return {
|
|
644
|
+
status: 0,
|
|
645
|
+
stdout: JSON.stringify({
|
|
646
|
+
id: 'standing-id', name, content: 'someone else\'s',
|
|
647
|
+
codeContext: { product: 'mx-agent', service: 'x', team: 'product', role: 'team-lead' },
|
|
648
|
+
}),
|
|
649
|
+
stderr: '', error: undefined, signal: null,
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
return absent;
|
|
653
|
+
}
|
|
654
|
+
return created('mem-x', 'conv_aaaaaaaaaa');
|
|
655
|
+
});
|
|
656
|
+
const result = bootstrapTeamMemories('surface', 'Surface', 'rg.md', 'mx-agent', {
|
|
657
|
+
extraAnchorSuffixes: ['watch-log'],
|
|
658
|
+
});
|
|
659
|
+
expect(result.extras[0].creation.preExistingOwnership).toBe('not-this-team');
|
|
660
|
+
});
|
|
661
|
+
it('with no extras, makes exactly the three calls it always made', () => {
|
|
662
|
+
let creates = 0;
|
|
663
|
+
mockSpawnSync.mockImplementation((_cmd, args) => {
|
|
664
|
+
if (args[1] === 'get')
|
|
665
|
+
return absent;
|
|
666
|
+
creates += 1;
|
|
667
|
+
return created(`mem-${creates}`, 'conv_9a1f4c2b7e');
|
|
668
|
+
});
|
|
669
|
+
const result = bootstrapTeamMemories('newteam', 'Newteam', 'rg.md', 'mx-agent');
|
|
670
|
+
expect(mockSpawnSync).toHaveBeenCalledTimes(6);
|
|
671
|
+
expect(result.extras).toEqual([]);
|
|
672
|
+
expect(result.conversationThreaded).toBe(true);
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
/**
|
|
676
|
+
* Gap 1 of the security re-check: `lib/fleet-data.ts:27` imports
|
|
677
|
+
* `leaderStateNameCandidates`, which is leader-state NAMING — the exact surface
|
|
678
|
+
* #190 moves. The plan's stated importer command missed that file, so this pins
|
|
679
|
+
* the behaviour rather than relying on a reviewer running the right grep.
|
|
680
|
+
*
|
|
681
|
+
* `leaderStateNameCandidates` reads `teamMemorySpecs(...).find(key === 'leaderState')`.
|
|
682
|
+
* Widening the key union and appending extra specs must not move that `find`,
|
|
683
|
+
* and no caller of it passes `extraAnchorSuffixes` at all.
|
|
684
|
+
*/
|
|
685
|
+
describe('leaderStateNameCandidates is unchanged by the anchor work (#190 gap 1)', () => {
|
|
686
|
+
it('probes the fleet spelling first when no project slug is configured', () => {
|
|
687
|
+
expect(leaderStateNameCandidates('retrieval')).toEqual([
|
|
688
|
+
'memnexus-retrieval-leader-state',
|
|
689
|
+
'retrieval-leader-state',
|
|
690
|
+
]);
|
|
691
|
+
});
|
|
692
|
+
it('probes the configured spelling first when a project slug is configured', () => {
|
|
693
|
+
expect(leaderStateNameCandidates('bootstrap', 'mx-agent')).toEqual([
|
|
694
|
+
'mx-agent-bootstrap-leader-state',
|
|
695
|
+
'bootstrap-leader-state',
|
|
696
|
+
]);
|
|
697
|
+
});
|
|
698
|
+
it('still resolves the leader-state spec when extra anchors are appended', () => {
|
|
699
|
+
const specs = teamMemorySpecs('surface', 'Surface', 'rg.md', 'mx-agent', {
|
|
700
|
+
extraAnchorSuffixes: ['watch-log', 'completion-contract'],
|
|
701
|
+
});
|
|
702
|
+
// The three keep their positions, so index-based readers are unaffected too.
|
|
703
|
+
expect(specs.slice(0, 3).map((s) => s.key)).toEqual([
|
|
704
|
+
'leaderState', 'iterationLog', 'knownIssues',
|
|
705
|
+
]);
|
|
706
|
+
expect(specs.find((s) => s.key === 'leaderState').name).toBe('mx-agent-surface-leader-state');
|
|
141
707
|
});
|
|
142
708
|
});
|
|
143
709
|
//# sourceMappingURL=memory-autocreate.test.js.map
|