@boyingliu01/xp-gate 0.38.125 → 0.39.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/README.md +93 -0
- package/adapters/gate-3.sh +45 -1
- package/adapters/gate-7.sh +15 -6
- package/adapters/python.sh +36 -38
- package/bin/xp-gate.js +35 -0
- package/build-integrity/gate-10-lines.ts +98 -0
- package/build-integrity/gate-10.ts +131 -117
- package/build-integrity/quote-masker.ts +17 -3
- package/gate-3.sh +45 -1
- package/gate-registry.sh +3 -1
- package/gates/common-process.ts +116 -34
- package/gates/common.ts +51 -15
- package/gates/gate-3.ts +166 -61
- package/gates/gate-8.ts +76 -24
- package/gates/gate-9.ts +276 -82
- package/gates/pbt-detect.ts +70 -39
- package/gates/python-health.ts +236 -98
- package/gates/test-layers.ts +103 -30
- package/hooks/deploy-manifest.sh +1 -0
- package/hooks/gate-3.sh +45 -1
- package/hooks/gate-entries/gate-1-entry.sh +44 -24
- package/hooks/gate-entries/gate-5-entry.sh +60 -20
- package/hooks/gate-entries/gate-6-entry.sh +15 -6
- package/hooks/gate-registry.sh +3 -1
- package/hooks/lib/gate-status.sh +164 -0
- package/hooks/lib/jscpd-run.sh +9 -1
- package/hooks/lib/native-path.sh +54 -0
- package/hooks/lib/toolchain-path.sh +38 -0
- package/hooks/lib/validate-code-walkthrough.cjs +324 -99
- package/hooks/pre-commit +52 -0
- package/hooks/pre-push +67 -7
- package/lib/agent-runtime-journal.js +104 -37
- package/lib/arch.js +6 -0
- package/lib/baseline.js +329 -201
- package/lib/check.js +38 -2
- package/lib/deploy-manifest.js +1 -0
- package/lib/doctor-constants.js +43 -0
- package/lib/doctor-tool-checks.js +129 -0
- package/lib/doctor.js +2014 -1038
- package/lib/flaky.js +178 -79
- package/lib/gate-audit.ts +80 -0
- package/lib/gate-runner.js +115 -63
- package/lib/init.js +6 -0
- package/lib/language-capability-surfaces.js +75 -8
- package/lib/language-capability.js +3 -0
- package/lib/language-registry.js +608 -0
- package/lib/language-tools.js +679 -894
- package/lib/phase-transition.js +646 -446
- package/lib/prepush-evidence.js +174 -0
- package/lib/sprint-audit.js +52 -22
- package/lib/sprint-discovery.js +66 -35
- package/lib/sprint-format.js +114 -0
- package/lib/sprint-init.js +372 -118
- package/lib/sprint-status.js +134 -90
- package/lib/star-notice.js +346 -0
- package/lib/tool-audit.js +729 -0
- package/lib/tool-display.js +52 -0
- package/lib/tool-install.js +179 -0
- package/lib/uninstall.js +331 -188
- package/mock-policy/gate-m3.ts +74 -23
- package/mock-policy/mock-decision-engine.ts +21 -7
- package/mock-policy/scope-scanner.ts +128 -69
- package/mutation/detect-ai-test.ts +20 -12
- package/mutation/gate-m.ts +6 -2
- package/mutation/init-baseline.ts +49 -13
- package/mutation/runners/go-mutant-runner.ts +7 -49
- package/mutation/runners/gremlins-runner.ts +53 -18
- package/mutation/runners/mutmut-runner.ts +455 -163
- package/mutation/runners/pitest-runner.ts +85 -131
- package/mutation/runners/spawn-with-capture.ts +304 -0
- package/mutation/runners/stryker-runner.ts +14 -55
- package/mutation/update-baseline.ts +25 -18
- package/package.json +20 -8
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/bin/delphi-review-guard.sh +12 -61
- package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +6 -11
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/reinstall-xp-gate/.architecture-skip +8 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/LICENSE +21 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/README.md +167 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/SKILL.md +271 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/TODO.md +253 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/VERSION +1 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/package.json +28 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
- package/plugins/claude-code/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/scripts/prepack.cjs +43 -18
- package/plugins/dsh/scripts/verify-skill-provider.mjs +39 -14
- package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +6 -11
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/src/skills.test.ts +9 -0
- package/plugins/opencode/index.ts +337 -123
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/scripts/prepack.cjs +41 -16
- package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +6 -11
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/reinstall-xp-gate/.architecture-skip +8 -0
- package/plugins/opencode/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
- package/plugins/opencode/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
- package/plugins/opencode/skills/reinstall-xp-gate/LICENSE +21 -0
- package/plugins/opencode/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
- package/plugins/opencode/skills/reinstall-xp-gate/README.md +167 -0
- package/plugins/opencode/skills/reinstall-xp-gate/SKILL.md +271 -0
- package/plugins/opencode/skills/reinstall-xp-gate/TODO.md +253 -0
- package/plugins/opencode/skills/reinstall-xp-gate/VERSION +1 -0
- package/plugins/opencode/skills/reinstall-xp-gate/package.json +28 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
- package/plugins/opencode/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
- package/plugins/opencode/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/bin/sprint-flow-guard.sh +12 -60
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +6 -11
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/shared/README.md +3 -0
- package/plugins/shared/bin/delphi-review-guard.sh +68 -0
- package/principles/adapters/control-nesting.ts +481 -168
- package/principles/adapters/cpp.ts +61 -22
- package/principles/adapters/csharp.ts +183 -66
- package/principles/adapters/dart.ts +11 -1
- package/principles/adapters/duplication.ts +49 -16
- package/principles/adapters/import-clause.ts +62 -15
- package/principles/adapters/java.ts +199 -70
- package/principles/adapters/line-comment.ts +18 -0
- package/principles/adapters/member-scan.ts +50 -8
- package/principles/adapters/php.ts +232 -103
- package/principles/adapters/python.ts +25 -18
- package/principles/adapters/quote-state.ts +21 -8
- package/principles/adapters/typescript-mask.ts +276 -0
- package/principles/adapters/typescript.ts +206 -200
- package/principles/analyzer.ts +16 -6
- package/principles/baseline-prune.ts +18 -8
- package/principles/baseline.ts +28 -11
- package/principles/boy-scout-usage.ts +26 -0
- package/principles/boy-scout.ts +261 -180
- package/principles/config.ts +183 -57
- package/principles/direct-execution.ts +24 -12
- package/principles/lint-baseline.ts +235 -122
- package/principles/rules/arch/dependency.ts +34 -25
- package/principles/rules/arch/shared.ts +24 -20
- package/principles/rules/clean-code/deep-nesting.ts +23 -13
- package/principles/rules/clean-code/god-class.ts +67 -41
- package/principles/rules/clean-code/large-file.ts +30 -23
- package/principles/rules/clean-code/long-function.ts +51 -37
- package/principles/rules/clean-code/magic-numbers.ts +51 -36
- package/principles/rules/clean-code/many-exports.ts +46 -29
- package/principles/rules/clean-code/missing-error-handling.ts +38 -20
- package/principles/rules/clean-code/too-many-params.ts +41 -22
- package/principles/rules/function-source.ts +62 -0
- package/principles/rules/solid/dip.ts +10 -6
- package/principles/rules/solid/isp.ts +64 -24
- package/principles/rules/solid/lsp.ts +66 -18
- package/principles/rules/solid/ocp.ts +29 -13
- package/principles/rules/solid/srp.ts +34 -18
- package/principles/warnings-count.ts +43 -0
- package/scripts/__tests__/prepush-source-classification.test.js +129 -0
- package/scripts/delphi-config-read.cjs +245 -0
- package/scripts/delphi-external-review.cjs +410 -585
- package/scripts/delphi-json-extract.cjs +108 -0
- package/scripts/delphi-model-validation.cjs +297 -0
- package/scripts/delphi-prompts.cjs +55 -0
- package/scripts/delphi-repo-tools.cjs +273 -0
- package/scripts/delphi-seat-calibration.cjs +204 -0
- package/scripts/run-bats-ci.cjs +240 -97
- package/scripts/sync-package-content.js +18 -2
- package/skills/delphi-review/.delphi-config.json.example +6 -11
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
- package/lib/__tests__/agent-runtime-journal.test.js +0 -326
- package/lib/__tests__/arch-config-template.test.js +0 -190
- package/lib/__tests__/arch.test.js +0 -424
- package/lib/__tests__/assertion-debt.test.js +0 -99
- package/lib/__tests__/audit-cli-contract.test.ts +0 -117
- package/lib/__tests__/audit-log.test.ts +0 -107
- package/lib/__tests__/baseline-completeness.test.js +0 -264
- package/lib/__tests__/baseline-shell-scope.test.js +0 -60
- package/lib/__tests__/baseline-unevaluated.test.js +0 -142
- package/lib/__tests__/baseline.test.js +0 -212
- package/lib/__tests__/bootstrap.test.js +0 -60
- package/lib/__tests__/check-alignment-cli.test.mjs +0 -94
- package/lib/__tests__/check-alignment-reasons.test.mjs +0 -101
- package/lib/__tests__/check-all-skip-accounting.test.js +0 -171
- package/lib/__tests__/check-changed-brief.test.js +0 -63
- package/lib/__tests__/check-normalize-exit.test.js +0 -24
- package/lib/__tests__/check-single-file.test.js +0 -114
- package/lib/__tests__/check-version.test.js +0 -463
- package/lib/__tests__/coverage-scope.test.js +0 -140
- package/lib/__tests__/coverage-threshold.test.js +0 -80
- package/lib/__tests__/crap-cli.test.js +0 -87
- package/lib/__tests__/crap.test.js +0 -494
- package/lib/__tests__/debt-classify.test.js +0 -78
- package/lib/__tests__/delphi-channel-doctor.test.js +0 -116
- package/lib/__tests__/delphi-channel-uninstall.test.js +0 -128
- package/lib/__tests__/delphi-channel.test.js +0 -109
- package/lib/__tests__/delphi-setup.test.js +0 -203
- package/lib/__tests__/deploy-manifest-check-wired.test.js +0 -138
- package/lib/__tests__/deploy-manifest-completeness.test.js +0 -151
- package/lib/__tests__/deploy-manifest-consumers-adapter-uninstall.test.js +0 -40
- package/lib/__tests__/deploy-manifest-consumers-no-private-lists.test.js +0 -74
- package/lib/__tests__/deploy-manifest-projection.test.js +0 -66
- package/lib/__tests__/deploy-manifest-shell-parity.test.js +0 -108
- package/lib/__tests__/deploy-manifest.test.js +0 -97
- package/lib/__tests__/detect-deps-dsh-profile.test.js +0 -323
- package/lib/__tests__/detect-deps-gate-identity.test.js +0 -135
- package/lib/__tests__/detect-deps.test.js +0 -655
- package/lib/__tests__/doctor-469-hook-env.test.js +0 -211
- package/lib/__tests__/doctor-arch-tools.test.js +0 -169
- package/lib/__tests__/doctor-audit-ledger.test.js +0 -61
- package/lib/__tests__/doctor-brief.test.js +0 -59
- package/lib/__tests__/doctor-delphi.test.js +0 -628
- package/lib/__tests__/doctor-drift-direction.test.js +0 -104
- package/lib/__tests__/doctor-drift-round2.test.js +0 -215
- package/lib/__tests__/doctor-exec-retry.test.js +0 -162
- package/lib/__tests__/doctor-executed-surface.test.js +0 -230
- package/lib/__tests__/doctor-helpers.test.js +0 -139
- package/lib/__tests__/doctor-hook-drift.test.js +0 -329
- package/lib/__tests__/doctor-hook-signatures.test.js +0 -65
- package/lib/__tests__/doctor-machine-mutation.test.js +0 -116
- package/lib/__tests__/doctor-module-drift.test.js +0 -212
- package/lib/__tests__/doctor-module-resolution-parity.test.js +0 -463
- package/lib/__tests__/doctor-path-equivalence.test.js +0 -70
- package/lib/__tests__/doctor-repair-boundary.test.js +0 -52
- package/lib/__tests__/doctor-signature-stability.test.js +0 -55
- package/lib/__tests__/doctor-spawn-capability.test.js +0 -116
- package/lib/__tests__/doctor-timeout-partial.test.js +0 -79
- package/lib/__tests__/doctor-tui-skill-freshness.test.js +0 -385
- package/lib/__tests__/doctor.test.js +0 -1320
- package/lib/__tests__/find-bash-wsl.test.js +0 -121
- package/lib/__tests__/flaky.test.js +0 -128
- package/lib/__tests__/foreign-hooks-global.test.js +0 -125
- package/lib/__tests__/gate-audit-skip.test.ts +0 -81
- package/lib/__tests__/gate-audit.test.ts +0 -440
- package/lib/__tests__/gate-coverage-hook-floor.test.js +0 -94
- package/lib/__tests__/gate-coverage.test.js +0 -204
- package/lib/__tests__/gate-entry-provenance.test.js +0 -71
- package/lib/__tests__/gate-numbering.test.js +0 -79
- package/lib/__tests__/gate-rules.test.js +0 -58
- package/lib/__tests__/gate-runner-tsx-invocation.test.js +0 -149
- package/lib/__tests__/gate-runner-verdict.test.js +0 -105
- package/lib/__tests__/gate-runner.test.js +0 -371
- package/lib/__tests__/gate2-verdict.test.js +0 -183
- package/lib/__tests__/helpers/lib-sandbox.cjs +0 -55
- package/lib/__tests__/hook-health-path.test.js +0 -109
- package/lib/__tests__/hook-health.test.js +0 -85
- package/lib/__tests__/init-gitignore.test.js +0 -204
- package/lib/__tests__/init-gitleaks-notice.test.js +0 -57
- package/lib/__tests__/init.test.js +0 -530
- package/lib/__tests__/install-cmd.test.js +0 -6
- package/lib/__tests__/install-sh-deploy-manifest.test.js +0 -80
- package/lib/__tests__/install-skill-full-dir.test.js +0 -194
- package/lib/__tests__/install-skill.test.js +0 -416
- package/lib/__tests__/issue-519-phase-transition-guard.test.js +0 -233
- package/lib/__tests__/issue-566-sync-hooks-backup.test.js +0 -228
- package/lib/__tests__/issue-583-hook-deploy-log.test.js +0 -121
- package/lib/__tests__/issue-586-principles-cmdline.test.js +0 -218
- package/lib/__tests__/issue-589-check-all-gate3.test.js +0 -190
- package/lib/__tests__/issue-590-archlint-vacuous-pass.test.js +0 -138
- package/lib/__tests__/issue-618-gate-not-run.test.js +0 -100
- package/lib/__tests__/jscpd-entry-resolution.test.js +0 -143
- package/lib/__tests__/language-capability.test.js +0 -291
- package/lib/__tests__/language-tools-build-file-install.test.js +0 -82
- package/lib/__tests__/language-tools-detect.test.js +0 -301
- package/lib/__tests__/migrate.test.js +0 -232
- package/lib/__tests__/mirror-manifest.test.js +0 -64
- package/lib/__tests__/mirror-sync.test.js +0 -803
- package/lib/__tests__/next-sprint.test.js +0 -231
- package/lib/__tests__/npm-package.test.js +0 -140
- package/lib/__tests__/phase-transition.test.js +0 -1136
- package/lib/__tests__/principles-csharp-coverage.test.js +0 -227
- package/lib/__tests__/principles-directory.test.js +0 -87
- package/lib/__tests__/qoder-delphi-agents.test.js +0 -316
- package/lib/__tests__/retro-gate-m.test.js +0 -144
- package/lib/__tests__/retro.test.js +0 -131
- package/lib/__tests__/rework.test.js +0 -127
- package/lib/__tests__/rollback.test.js +0 -183
- package/lib/__tests__/runtime-journal.test.js +0 -164
- package/lib/__tests__/sastd-client.test.js +0 -514
- package/lib/__tests__/shared-paths-lazy-home.test.js +0 -67
- package/lib/__tests__/shared-paths.test.js +0 -130
- package/lib/__tests__/shared-utils-copyHooks-manifest.test.js +0 -69
- package/lib/__tests__/shared-utils.test.js +0 -180
- package/lib/__tests__/skill-flags.test.js +0 -48
- package/lib/__tests__/slo.test.js +0 -89
- package/lib/__tests__/sprint-audit.test.js +0 -207
- package/lib/__tests__/sprint-discovery.test.ts +0 -366
- package/lib/__tests__/sprint-state-manager.test.js +0 -310
- package/lib/__tests__/sprint-status-rework-704.test.js +0 -149
- package/lib/__tests__/sprint-status-rework.test.js +0 -329
- package/lib/__tests__/sprint-status.test.js +0 -193
- package/lib/__tests__/sprint-status.test.ts +0 -213
- package/lib/__tests__/test-alignment-java-702.test.ts +0 -177
- package/lib/__tests__/test-alignment-range-guard.test.ts +0 -82
- package/lib/__tests__/test-alignment.test.ts +0 -853
- package/lib/__tests__/tsconfig.json +0 -8
- package/lib/__tests__/tsx-resolution.test.js +0 -89
- package/lib/__tests__/ui-detector.test.ts +0 -459
- package/lib/__tests__/ui-review.test.ts +0 -132
- package/lib/__tests__/uninstall-global-residue.test.js +0 -545
- package/lib/__tests__/uninstall-skill.test.js +0 -189
- package/lib/__tests__/uninstall.test.js +0 -717
- package/lib/__tests__/update-hooks.test.js +0 -737
- package/lib/__tests__/update-skill-flags.test.js +0 -78
- package/lib/__tests__/update-skill.test.js +0 -644
- package/lib/__tests__/upgrade-exec.test.js +0 -273
- package/lib/__tests__/upgrade-skill-sync.test.js +0 -65
- package/lib/__tests__/upgrade.test.js +0 -78
- package/lib/__tests__/windows-bash-probe.test.js +0 -123
- package/lib/check-alignment-runner.cjs +0 -97
- package/lib/coverage-total.sh +0 -92
- package/lib/layer-baseline.cjs +0 -94
- package/lib/mattpocock-license-verdict.json +0 -7
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @intent #519: A real pointer-drift incident (#507) showed that a MISSED
|
|
3
|
-
* phase transition is invisible — the state file cannot distinguish
|
|
4
|
-
* "never ran" from "not yet advanced". Guards under test:
|
|
5
|
-
* (1) sequence guard: `completed` on phase n is refused unless phase
|
|
6
|
-
* n-1 is completed/skipped, with `--force` as the explicit escape;
|
|
7
|
-
* (2) before/after echo so "command didn't run" and "ran without
|
|
8
|
-
* effect" are distinguishable in the output;
|
|
9
|
-
* (3) an append-only transition audit log;
|
|
10
|
-
* (4) phase_history field normalization (`name` → `phase_name`).
|
|
11
|
-
* @covers handlePhaseTransition guard/echo, appendTransitionAudit, migrateState
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
15
|
-
import fs from 'node:fs';
|
|
16
|
-
import path from 'node:path';
|
|
17
|
-
import os from 'node:os';
|
|
18
|
-
import { handlePhaseTransition } from '../phase-transition.js';
|
|
19
|
-
import { SprintStateManager } from '../sprint-state-manager.js';
|
|
20
|
-
import { migrateState } from '../sprint-state-migrator.js';
|
|
21
|
-
|
|
22
|
-
function writeState(dir, state) {
|
|
23
|
-
try {
|
|
24
|
-
fs.mkdirSync(path.join(dir, '.sprint-state'), { recursive: true });
|
|
25
|
-
fs.writeFileSync(
|
|
26
|
-
path.join(dir, '.sprint-state', 'sprint-state.json'),
|
|
27
|
-
JSON.stringify(state, null, 2),
|
|
28
|
-
);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
throw new Error(`writeState failed for ${dir}: ${err.message}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function baseState(overrides = {}) {
|
|
35
|
-
return {
|
|
36
|
-
_schema_version: 1,
|
|
37
|
-
id: 'sprint-519',
|
|
38
|
-
task_description: 'test',
|
|
39
|
-
phase: 2,
|
|
40
|
-
status: 'in_progress',
|
|
41
|
-
started_at: '2026-10-14T00:00:00Z',
|
|
42
|
-
phase_history: [],
|
|
43
|
-
isolation: { worktree_path: null, branch: null },
|
|
44
|
-
...overrides,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
describe('#519 phase-transition sequence guard', () => {
|
|
49
|
-
let dir;
|
|
50
|
-
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'p519-'));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
afterEach(() => {
|
|
56
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('refuses `completed` on phase 3 when phase 2 is not completed/skipped', async () => {
|
|
60
|
-
writeState(dir, baseState({
|
|
61
|
-
phase: 3,
|
|
62
|
-
phase_history: [{ phase: 2, phase_name: 'DESIGN', status: 'in_progress' }],
|
|
63
|
-
}));
|
|
64
|
-
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
65
|
-
const code = await handlePhaseTransition(['3', 'completed', '--dir', dir, '--skip-evidence', 'x']);
|
|
66
|
-
const stderr = errSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
67
|
-
errSpy.mockRestore();
|
|
68
|
-
expect(code).toBe(1);
|
|
69
|
-
expect(stderr).toContain('Cannot complete phase 3');
|
|
70
|
-
expect(stderr).toContain('phase 2');
|
|
71
|
-
expect(stderr).toContain('phase history');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('refuses the jump and names --force as the override', async () => {
|
|
75
|
-
writeState(dir, baseState({ phase: 3, phase_history: [] }));
|
|
76
|
-
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
77
|
-
await handlePhaseTransition(['5', 'completed', '--dir', dir, '--skip-evidence', 'x']);
|
|
78
|
-
const stderr = errSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
79
|
-
errSpy.mockRestore();
|
|
80
|
-
expect(stderr).toContain('--force');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('allows `completed` when the previous phase is completed', async () => {
|
|
84
|
-
writeState(dir, baseState({
|
|
85
|
-
phase: 2,
|
|
86
|
-
phase_history: [{ phase: 2, phase_name: 'DESIGN', status: 'completed' }],
|
|
87
|
-
}));
|
|
88
|
-
const outSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
89
|
-
const code = await handlePhaseTransition(['3', 'completed', '--dir', dir, '--skip-evidence', 'x']);
|
|
90
|
-
outSpy.mockRestore();
|
|
91
|
-
expect(code).toBe(0);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('treats a skipped previous phase as valid', async () => {
|
|
95
|
-
writeState(dir, baseState({
|
|
96
|
-
phase: 2,
|
|
97
|
-
phase_history: [{ phase: 2, phase_name: 'DESIGN', status: 'skipped' }],
|
|
98
|
-
}));
|
|
99
|
-
const outSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
100
|
-
const code = await handlePhaseTransition(['3', 'completed', '--dir', dir, '--skip-evidence', 'x']);
|
|
101
|
-
outSpy.mockRestore();
|
|
102
|
-
expect(code).toBe(0);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('--force overrides the guard and warns', async () => {
|
|
106
|
-
writeState(dir, baseState({ phase: 3, phase_history: [] }));
|
|
107
|
-
const outSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
108
|
-
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
109
|
-
const code = await handlePhaseTransition(['3', 'completed', '--dir', dir, '--skip-evidence', 'x', '--force']);
|
|
110
|
-
const warned = warnSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
111
|
-
outSpy.mockRestore();
|
|
112
|
-
warnSpy.mockRestore();
|
|
113
|
-
expect(code).toBe(0);
|
|
114
|
-
expect(warned).toContain('overridden');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('does not guard phase 1 (no predecessor)', async () => {
|
|
118
|
-
writeState(dir, baseState({ phase: 1, phase_history: [] }));
|
|
119
|
-
const outSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
120
|
-
const code = await handlePhaseTransition(['1', 'completed', '--dir', dir, '--skip-evidence', 'x']);
|
|
121
|
-
outSpy.mockRestore();
|
|
122
|
-
expect(code).toBe(0);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('does not guard non-completed statuses', async () => {
|
|
126
|
-
writeState(dir, baseState({ phase: 3, phase_history: [] }));
|
|
127
|
-
const outSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
128
|
-
const code = await handlePhaseTransition(['3', 'in_progress', '--dir', dir]);
|
|
129
|
-
outSpy.mockRestore();
|
|
130
|
-
expect(code).toBe(0);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe('#519 before/after echo', () => {
|
|
135
|
-
let dir;
|
|
136
|
-
beforeEach(() => {
|
|
137
|
-
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'p519echo-'));
|
|
138
|
-
});
|
|
139
|
-
afterEach(() => {
|
|
140
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('prints before→after for the top-level phase/status and the entry', async () => {
|
|
144
|
-
// Phase 1 must be completed for the phase-2 completion to pass the
|
|
145
|
-
// sequence guard (#519) — otherwise the echo is never reached.
|
|
146
|
-
writeState(dir, baseState({
|
|
147
|
-
phase: 2,
|
|
148
|
-
status: 'in_progress',
|
|
149
|
-
phase_history: [
|
|
150
|
-
{ phase: 1, name: 'PREP', status: 'completed' },
|
|
151
|
-
{ phase: 2, phase_name: 'DESIGN', status: 'in_progress' },
|
|
152
|
-
],
|
|
153
|
-
}));
|
|
154
|
-
const outSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
155
|
-
const code = await handlePhaseTransition(['2', 'completed', '--dir', dir, '--skip-evidence', 'x']);
|
|
156
|
-
const output = outSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
157
|
-
outSpy.mockRestore();
|
|
158
|
-
expect(code).toBe(0);
|
|
159
|
-
expect(output).toContain('before→after');
|
|
160
|
-
expect(output).toContain('in_progress → completed');
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
describe('#519 transition audit log + field normalization', () => {
|
|
165
|
-
let dir;
|
|
166
|
-
beforeEach(() => {
|
|
167
|
-
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'p519audit-'));
|
|
168
|
-
});
|
|
169
|
-
afterEach(() => {
|
|
170
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('appends one JSON line per transition with from/to', () => {
|
|
174
|
-
writeState(dir, baseState({ phase: 2, phase_history: [] }));
|
|
175
|
-
const manager = new SprintStateManager(dir);
|
|
176
|
-
manager.transitionPhase(2, 'in_progress');
|
|
177
|
-
manager.transitionPhase(2, 'completed');
|
|
178
|
-
const auditFile = path.join(dir, '.sprint-state', 'transition-audit.jsonl');
|
|
179
|
-
expect(fs.existsSync(auditFile)).toBe(true);
|
|
180
|
-
const lines = fs.readFileSync(auditFile, 'utf8').trim().split('\n');
|
|
181
|
-
expect(lines.length).toBe(2);
|
|
182
|
-
const first = JSON.parse(lines[0]);
|
|
183
|
-
expect(first.phase).toBe(2);
|
|
184
|
-
expect(first.phase_name).toBe('DESIGN');
|
|
185
|
-
expect(first.to_status).toBe('in_progress');
|
|
186
|
-
expect(first.timestamp).toBeTruthy();
|
|
187
|
-
const second = JSON.parse(lines[1]);
|
|
188
|
-
expect(second.to_status).toBe('completed');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('audit is best-effort: a write failure does not break the transition', () => {
|
|
192
|
-
writeState(dir, baseState({ phase: 2, phase_history: [] }));
|
|
193
|
-
const manager = new SprintStateManager(dir);
|
|
194
|
-
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
195
|
-
// Break the real appendFileSync so appendTransitionAudit's OWN try/catch is
|
|
196
|
-
// exercised (mocking the method itself would bypass the production guard).
|
|
197
|
-
const appendSpy = vi.spyOn(fs, 'appendFileSync').mockImplementation(() => {
|
|
198
|
-
throw new Error('disk full');
|
|
199
|
-
});
|
|
200
|
-
expect(() => manager.transitionPhase(2, 'in_progress')).not.toThrow();
|
|
201
|
-
const warned = warnSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
202
|
-
appendSpy.mockRestore();
|
|
203
|
-
warnSpy.mockRestore();
|
|
204
|
-
expect(warned).toContain('transition audit write failed');
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('migrateState normalizes legacy `name` into `phase_name`', () => {
|
|
208
|
-
// A legacy file (no _schema_version) whose phase 1 entry carries `name`
|
|
209
|
-
// rather than `phase_name` — the exact shape #507 left behind.
|
|
210
|
-
const legacy = baseState({
|
|
211
|
-
_schema_version: undefined,
|
|
212
|
-
phase_history: [{ phase: 1, name: 'PREP', status: 'completed' }],
|
|
213
|
-
});
|
|
214
|
-
const migrated = migrateState(legacy, dir);
|
|
215
|
-
const entry = migrated.phase_history[0];
|
|
216
|
-
// The canonical field is populated (via the legacy remap and/or the
|
|
217
|
-
// name→phase_name normalization) and the legacy field is preserved.
|
|
218
|
-
expect(entry.phase_name).toBeTruthy();
|
|
219
|
-
expect(entry.name).toBe('PREP');
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('migrateState backfills `name` from `phase_name` (both directions)', () => {
|
|
223
|
-
const legacy = baseState({
|
|
224
|
-
_schema_version: undefined,
|
|
225
|
-
phase_history: [{ phase: 2, phase_name: 'DESIGN', status: 'in_progress' }],
|
|
226
|
-
});
|
|
227
|
-
const migrated = migrateState(legacy, dir);
|
|
228
|
-
const entry = migrated.phase_history[0];
|
|
229
|
-
expect(entry.phase_name).toBeTruthy();
|
|
230
|
-
// `name` is backfilled so a reader consulting either field agrees.
|
|
231
|
-
expect(entry.name).toBe(entry.phase_name);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-599
|
|
3
|
-
* @intent #566 was a hook that existed on exactly one machine and in no commit:
|
|
4
|
-
* the installed `~/.config/xp-gate/hooks/pre-push` carried a local
|
|
5
|
-
* `_score()` helper plus `gates_skipped` that no branch had ever held,
|
|
6
|
-
* and `xp-gate doctor --sync-hooks` replaced it without a word. The repo
|
|
7
|
-
* side then looked correct and the only copy of that work was gone.
|
|
8
|
-
*
|
|
9
|
-
* doctor already REFUSES to overwrite a file whose content diverges, and
|
|
10
|
-
* says "there is no automatic backup ... nothing records the previous
|
|
11
|
-
* version". That refusal covers divergence; it does not cover the
|
|
12
|
-
* legitimate overwrites that also destroy a previous version -- `--force`,
|
|
13
|
-
* and files that differ only in whitespace. So the loss #566 describes
|
|
14
|
-
* was still possible after the refusal landed.
|
|
15
|
-
*
|
|
16
|
-
* These cases assert that every overwrite keeps the previous version,
|
|
17
|
-
* in a `backups/` directory beside the installed hooks (not in the user's
|
|
18
|
-
* work tree), timestamped so a later sync cannot destroy an earlier
|
|
19
|
-
* backup.
|
|
20
|
-
* @covers AC-599-13
|
|
21
|
-
*/
|
|
22
|
-
const fs = require('fs');
|
|
23
|
-
const path = require('path');
|
|
24
|
-
const os = require('os');
|
|
25
|
-
|
|
26
|
-
const DESCRIBE_ID = String(Math.random().toString(36).slice(2, 8));
|
|
27
|
-
|
|
28
|
-
describe('doctor --sync-hooks keeps the previous version (#566)', () => {
|
|
29
|
-
let tmpHome;
|
|
30
|
-
let originalHome;
|
|
31
|
-
let originalUserProfile;
|
|
32
|
-
|
|
33
|
-
beforeAll(() => {
|
|
34
|
-
originalHome = process.env.HOME;
|
|
35
|
-
originalUserProfile = process.env.USERPROFILE;
|
|
36
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), `xp-gate-566-home-${DESCRIBE_ID}-`));
|
|
37
|
-
process.env.HOME = tmpHome;
|
|
38
|
-
process.env.USERPROFILE = tmpHome;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
afterAll(() => {
|
|
42
|
-
process.env.HOME = originalHome;
|
|
43
|
-
process.env.USERPROFILE = originalUserProfile;
|
|
44
|
-
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
function loadDoctor() {
|
|
48
|
-
return require('../doctor');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Build a repo-like githooks/ plus an installed hooks dir.
|
|
53
|
-
* @param {{installedPrePush?: string}} [opts] content for the installed pre-push
|
|
54
|
-
*/
|
|
55
|
-
function makeLayout(opts = {}) {
|
|
56
|
-
// Wrap the fixture setup so a failure names the fixture that broke instead of
|
|
57
|
-
// surfacing later as "doctor reported the wrong thing". Without this, an
|
|
58
|
-
// unreadable tmpHome looks like a product defect in the assertion.
|
|
59
|
-
try {
|
|
60
|
-
const root = fs.mkdtempSync(path.join(tmpHome, `layout-${DESCRIBE_ID}-`));
|
|
61
|
-
const repoRoot = path.join(root, 'repo');
|
|
62
|
-
const repoHooks = path.join(repoRoot, 'githooks');
|
|
63
|
-
const installedHooks = path.join(root, 'installed-hooks');
|
|
64
|
-
fs.mkdirSync(repoHooks, { recursive: true });
|
|
65
|
-
fs.mkdirSync(installedHooks, { recursive: true });
|
|
66
|
-
|
|
67
|
-
// The canonical hook carries the xp-gate signature doctor looks for.
|
|
68
|
-
fs.writeFileSync(
|
|
69
|
-
path.join(repoHooks, 'pre-push'),
|
|
70
|
-
'#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# Pre-push Hook: Gate 10 (Build Integrity)\necho canonical\n',
|
|
71
|
-
);
|
|
72
|
-
if (opts.installedPrePush !== undefined) {
|
|
73
|
-
fs.writeFileSync(path.join(installedHooks, 'pre-push'), opts.installedPrePush);
|
|
74
|
-
}
|
|
75
|
-
return { root, repoRoot, repoHooks, installedHooks };
|
|
76
|
-
} catch (err) {
|
|
77
|
-
throw new Error(`fixture: could not build hook layout under ${tmpHome}: ${err.message}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
it('AC-599-13: overwriting an existing hook keeps a copy of the previous version', () => {
|
|
82
|
-
const { repoHooks, installedHooks } = makeLayout({
|
|
83
|
-
installedPrePush: '#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# GHOST LOCAL EDIT\n',
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const { syncGlobalHooksFromRepo } = loadDoctor();
|
|
87
|
-
const result = syncGlobalHooksFromRepo({ repoHooks, installedHooks });
|
|
88
|
-
|
|
89
|
-
expect(result.synced).toContain('pre-push');
|
|
90
|
-
expect(result.backups.length).toBeGreaterThan(0);
|
|
91
|
-
|
|
92
|
-
const backup = result.backups.find((b) => path.basename(b).startsWith('pre-push.'));
|
|
93
|
-
expect(backup).toBeTruthy();
|
|
94
|
-
expect(fs.readFileSync(backup, 'utf8')).toContain('GHOST LOCAL EDIT');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('AC-599-13: the backup lives beside the installed hooks, not in a work tree', () => {
|
|
98
|
-
const { repoRoot, repoHooks, installedHooks } = makeLayout({
|
|
99
|
-
installedPrePush: '#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# local only\n',
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const { syncGlobalHooksFromRepo } = loadDoctor();
|
|
103
|
-
syncGlobalHooksFromRepo({ repoHooks, installedHooks });
|
|
104
|
-
|
|
105
|
-
const backupsDir = path.join(installedHooks, 'backups');
|
|
106
|
-
expect(fs.existsSync(backupsDir)).toBe(true);
|
|
107
|
-
// Nothing was written into the repository: a backup must not become the
|
|
108
|
-
// user's problem to clean out of `git status`.
|
|
109
|
-
const repoEntries = fs.readdirSync(repoRoot).sort();
|
|
110
|
-
expect(repoEntries).toEqual(['githooks']);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('AC-599-13: installing into an empty hooks dir creates no backup', () => {
|
|
114
|
-
// Nothing was overwritten, so there is nothing to keep -- a backup directory
|
|
115
|
-
// of empty files would be noise that trains the operator to ignore it.
|
|
116
|
-
const { repoHooks, installedHooks } = makeLayout();
|
|
117
|
-
|
|
118
|
-
const { syncGlobalHooksFromRepo } = loadDoctor();
|
|
119
|
-
const result = syncGlobalHooksFromRepo({ repoHooks, installedHooks });
|
|
120
|
-
|
|
121
|
-
expect(result.synced).toContain('pre-push');
|
|
122
|
-
expect(result.backups).toEqual([]);
|
|
123
|
-
expect(fs.existsSync(path.join(installedHooks, 'backups'))).toBe(false);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('AC-599-13: two successive overwrites keep both previous versions', () => {
|
|
127
|
-
// A timestamped name is the point: the second sync must not destroy the
|
|
128
|
-
// backup the first sync made, or the work it was protecting is lost anyway.
|
|
129
|
-
const { repoHooks, installedHooks } = makeLayout({
|
|
130
|
-
installedPrePush: '#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# EDIT ONE\n',
|
|
131
|
-
});
|
|
132
|
-
const { syncGlobalHooksFromRepo } = loadDoctor();
|
|
133
|
-
syncGlobalHooksFromRepo({ repoHooks, installedHooks });
|
|
134
|
-
|
|
135
|
-
fs.writeFileSync(path.join(installedHooks, 'pre-push'), '#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# EDIT TWO\n');
|
|
136
|
-
const second = syncGlobalHooksFromRepo({ repoHooks, installedHooks });
|
|
137
|
-
|
|
138
|
-
const backupsDir = path.join(installedHooks, 'backups');
|
|
139
|
-
const files = fs.readdirSync(backupsDir).filter((f) => f.startsWith('pre-push.'));
|
|
140
|
-
expect(files.length).toBe(2);
|
|
141
|
-
const contents = files.map((f) => fs.readFileSync(path.join(backupsDir, f), 'utf8'));
|
|
142
|
-
expect(contents.some((c) => c.includes('EDIT ONE'))).toBe(true);
|
|
143
|
-
expect(contents.some((c) => c.includes('EDIT TWO'))).toBe(true);
|
|
144
|
-
expect(second.backups.length).toBeGreaterThan(0);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('AC-599-13: an identical file is not re-copied and leaves no backup', () => {
|
|
148
|
-
const canonical = '#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# Pre-push Hook: Gate 10 (Build Integrity)\necho canonical\n';
|
|
149
|
-
const { repoHooks, installedHooks } = makeLayout({ installedPrePush: canonical });
|
|
150
|
-
|
|
151
|
-
const { syncGlobalHooksFromRepo } = loadDoctor();
|
|
152
|
-
const result = syncGlobalHooksFromRepo({ repoHooks, installedHooks });
|
|
153
|
-
|
|
154
|
-
expect(result.synced).not.toContain('pre-push');
|
|
155
|
-
expect(result.skipped).toContain('pre-push');
|
|
156
|
-
expect(result.backups).toEqual([]);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('AC-599-13: shared lib/ libraries are backed up before being replaced too', () => {
|
|
160
|
-
// The lib/ channel overwrites unconditionally unless it refuses, so it is the
|
|
161
|
-
// channel most likely to erase machine-only hardening.
|
|
162
|
-
const { repoRoot, repoHooks, installedHooks } = makeLayout();
|
|
163
|
-
fs.mkdirSync(path.join(repoHooks, 'lib'), { recursive: true });
|
|
164
|
-
fs.writeFileSync(path.join(repoHooks, 'lib', 'coverage-total.sh'), 'echo canonical-lib\n');
|
|
165
|
-
fs.mkdirSync(path.join(installedHooks, 'lib'), { recursive: true });
|
|
166
|
-
fs.writeFileSync(path.join(installedHooks, 'lib', 'coverage-total.sh'), 'echo LOCAL-LIB-EDIT\n');
|
|
167
|
-
|
|
168
|
-
// Force, because otherwise the divergence guard refuses before the overwrite.
|
|
169
|
-
const { syncGlobalHooksFromRepo } = loadDoctor();
|
|
170
|
-
const result = syncGlobalHooksFromRepo({ repoRoot, repoHooks, installedHooks, force: true });
|
|
171
|
-
|
|
172
|
-
const backup = result.backups.find((b) => path.basename(b).startsWith('coverage-total.sh.'));
|
|
173
|
-
expect(backup).toBeTruthy();
|
|
174
|
-
expect(fs.readFileSync(backup, 'utf8')).toContain('LOCAL-LIB-EDIT');
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('AC-599-13: two syncs inside the same millisecond both keep their version', () => {
|
|
178
|
-
// The CI failure that motivated this case: "two successive overwrites keep
|
|
179
|
-
// both previous versions" passed locally and failed on a fast runner with
|
|
180
|
-
// `expected 1 to be 2`. The stamp has millisecond resolution, so when two
|
|
181
|
-
// syncs land in the SAME millisecond they compute the SAME backup name and
|
|
182
|
-
// the second copy silently destroys the first. Local runs usually straddled
|
|
183
|
-
// a millisecond boundary and never saw it.
|
|
184
|
-
//
|
|
185
|
-
// Pin Date so the collision is guaranteed rather than hoped for: asserting a
|
|
186
|
-
// bug that only appears under a timing race is how the suite went green while
|
|
187
|
-
// the defect shipped.
|
|
188
|
-
const { repoHooks, installedHooks } = makeLayout({
|
|
189
|
-
installedPrePush: '#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# SAME-MS-ONE\n',
|
|
190
|
-
});
|
|
191
|
-
const { syncGlobalHooksFromRepo } = loadDoctor();
|
|
192
|
-
|
|
193
|
-
// Freeze ONLY the clock the stamp reads. Nothing else is replaced: an earlier
|
|
194
|
-
// draft overrode Date.prototype.toISOString, which made the backup helper
|
|
195
|
-
// recurse into itself and threw "Maximum call stack size exceeded" -- the
|
|
196
|
-
// case then appeared to fail for a reason that had nothing to do with backups.
|
|
197
|
-
const RealDate = Date;
|
|
198
|
-
const frozen = 1767225600123; // any instant; only that it never advances
|
|
199
|
-
global.Date = class extends RealDate {
|
|
200
|
-
constructor(...args) {
|
|
201
|
-
if (args.length === 0) super(frozen);
|
|
202
|
-
else super(...args);
|
|
203
|
-
}
|
|
204
|
-
static now() {
|
|
205
|
-
return frozen;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
try {
|
|
209
|
-
syncGlobalHooksFromRepo({ repoHooks, installedHooks, force: true });
|
|
210
|
-
|
|
211
|
-
fs.writeFileSync(
|
|
212
|
-
path.join(installedHooks, 'pre-push'),
|
|
213
|
-
'#!/usr/bin/env bash\n# XP-Gate Pre-Push Hook\n# SAME-MS-TWO\n',
|
|
214
|
-
);
|
|
215
|
-
syncGlobalHooksFromRepo({ repoHooks, installedHooks, force: true });
|
|
216
|
-
} finally {
|
|
217
|
-
global.Date = RealDate;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const backupsDir = path.join(installedHooks, 'backups');
|
|
221
|
-
const files = fs.readdirSync(backupsDir).filter((f) => f.startsWith('pre-push.'));
|
|
222
|
-
expect(files.length).toBe(2);
|
|
223
|
-
|
|
224
|
-
const contents = files.map((f) => fs.readFileSync(path.join(backupsDir, f), 'utf8'));
|
|
225
|
-
expect(contents.some((c) => c.includes('SAME-MS-ONE'))).toBe(true);
|
|
226
|
-
expect(contents.some((c) => c.includes('SAME-MS-TWO'))).toBe(true);
|
|
227
|
-
});
|
|
228
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-604
|
|
3
|
-
* @intent A deploy that overwrites an installed hook must leave a record of what
|
|
4
|
-
* it replaced and which version did it.
|
|
5
|
-
*
|
|
6
|
-
* #583: `xp-gate doctor --sync-hooks` overwrote `~/.config/xp-gate/hooks/
|
|
7
|
-
* pre-commit` three times in one day, each time silently. A downstream
|
|
8
|
-
* that had hardened its hooks (and kept the vendored copy in sync, with a
|
|
9
|
-
* consistency test guarding it) discovered it only by running its own
|
|
10
|
-
* SHA256 comparison. The consequences were not cosmetic: one overwrite
|
|
11
|
-
* reverted a fixed fail-open in Gate 5's coverage arm, so commits started
|
|
12
|
-
* passing on unmeasurable coverage again — a defect that had already been
|
|
13
|
-
* filed, fixed and tested.
|
|
14
|
-
*
|
|
15
|
-
* #566 added the backup, which makes the damaged file recoverable. It
|
|
16
|
-
* does not answer the question the downstream actually has: "was my patch
|
|
17
|
-
* eaten, and by which version?" A directory of timestamped `.bak` files
|
|
18
|
-
* can be read, but only by someone who already suspects an overwrite.
|
|
19
|
-
*
|
|
20
|
-
* So the invariant here is narrow and provable without a network, a
|
|
21
|
-
* registry, or a real install: when sync-hooks overwrites file X, one
|
|
22
|
-
* line is appended to a deploy log naming X, the version that did it, and
|
|
23
|
-
* the backup that holds the previous content. Nothing more.
|
|
24
|
-
*
|
|
25
|
-
* Deliberately NOT in scope (the issue's option 2): refusing to overwrite
|
|
26
|
-
* a locally-modified hook without `--force`. That changes the deploy
|
|
27
|
-
* contract for every consumer and needs a product decision, not a bug fix.
|
|
28
|
-
* @covers AC-604-01, AC-604-02, AC-604-03
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
const fs = require('fs');
|
|
32
|
-
const os = require('os');
|
|
33
|
-
const path = require('path');
|
|
34
|
-
|
|
35
|
-
const { syncGlobalHooksFromRepo } = require('../doctor.js');
|
|
36
|
-
|
|
37
|
-
function writeHook(dir, name, body) {
|
|
38
|
-
const p = path.join(dir, name);
|
|
39
|
-
try {
|
|
40
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
41
|
-
fs.writeFileSync(p, body, { mode: 0o755 });
|
|
42
|
-
} catch (err) {
|
|
43
|
-
// A fixture that cannot create its file must fail the case loudly, not leave
|
|
44
|
-
// a partially-built directory for the assertions to interpret (#583).
|
|
45
|
-
throw new Error(`fixture setup failed writing ${p}: ${err.message}`);
|
|
46
|
-
}
|
|
47
|
-
return p;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
describe('REQ-604: sync-hooks leaves a deploy record', () => {
|
|
51
|
-
let tmp;
|
|
52
|
-
let repoHooks;
|
|
53
|
-
let installedHooks;
|
|
54
|
-
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'xp-gate-deploy-log-'));
|
|
57
|
-
repoHooks = path.join(tmp, 'repo', 'githooks');
|
|
58
|
-
installedHooks = path.join(tmp, 'installed', 'hooks');
|
|
59
|
-
fs.mkdirSync(installedHooks, { recursive: true });
|
|
60
|
-
// The banner line is the signature doctor uses to recognise an xp-gate hook.
|
|
61
|
-
writeHook(repoHooks, 'pre-commit', '#!/bin/bash\n# XP-GATE QUALITY GATES v0.31.1.0\necho new\n');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
afterEach(() => {
|
|
65
|
-
fs.rmSync(tmp, { recursive: true, force: true });
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('AC-604-01: an overwrite appends one line naming the file, the version and the backup', () => {
|
|
69
|
-
// The downstream's hardened copy: different from upstream, so it IS replaced.
|
|
70
|
-
writeHook(installedHooks, 'pre-commit', '#!/bin/bash\n# XP-GATE QUALITY GATES v0.30.0.0\n# downstream hardening\necho old\n');
|
|
71
|
-
|
|
72
|
-
const result = syncGlobalHooksFromRepo({ repoHooks, installedHooks, version: '0.31.1.0' });
|
|
73
|
-
|
|
74
|
-
expect(result.errors).toEqual([]);
|
|
75
|
-
expect(result.synced).toContain('pre-commit');
|
|
76
|
-
|
|
77
|
-
const logPath = path.join(installedHooks, 'deploy.log');
|
|
78
|
-
expect(fs.existsSync(logPath)).toBe(true);
|
|
79
|
-
|
|
80
|
-
const lines = fs.readFileSync(logPath, 'utf8').trim().split('\n').filter(Boolean);
|
|
81
|
-
const entry = lines.find((l) => l.includes('pre-commit'));
|
|
82
|
-
expect(entry, `deploy log must name pre-commit, got:\n${lines.join('\n')}`).toBeTruthy();
|
|
83
|
-
|
|
84
|
-
// The three facts the downstream needs, all in that one line: which file,
|
|
85
|
-
// which version replaced it, and where the previous content went.
|
|
86
|
-
expect(entry).toMatch(/pre-commit/);
|
|
87
|
-
expect(entry).toMatch(/0\.31\.1\.0/);
|
|
88
|
-
expect(entry, `names the backup holding the old content, got: ${entry}`).toMatch(/\.bak/);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('AC-604-02: an unchanged file produces no deploy entry', () => {
|
|
92
|
-
// Identical content: sync skips it, so there is nothing to report. A log that
|
|
93
|
-
// records non-events is noise, and noise is what makes real overwrites
|
|
94
|
-
// invisible.
|
|
95
|
-
writeHook(installedHooks, 'pre-commit', '#!/bin/bash\n# XP-GATE QUALITY GATES v0.31.1.0\necho new\n');
|
|
96
|
-
|
|
97
|
-
const result = syncGlobalHooksFromRepo({ repoHooks, installedHooks, version: '0.31.1.0' });
|
|
98
|
-
expect(result.skipped).toContain('pre-commit');
|
|
99
|
-
|
|
100
|
-
const logPath = path.join(installedHooks, 'deploy.log');
|
|
101
|
-
if (fs.existsSync(logPath)) {
|
|
102
|
-
const content = fs.readFileSync(logPath, 'utf8');
|
|
103
|
-
expect(content).not.toContain('pre-commit');
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('AC-604-03: repeated overwrites accumulate rather than replacing history', () => {
|
|
108
|
-
// The whole point of the log is answering "how many times, and when" — one
|
|
109
|
-
// day saw three overwrites. Overwriting the log each run would destroy
|
|
110
|
-
// exactly the evidence the downstream needs.
|
|
111
|
-
writeHook(installedHooks, 'pre-commit', '#!/bin/bash\n# XP-GATE QUALITY GATES v0.30.0.0\necho v1\n');
|
|
112
|
-
syncGlobalHooksFromRepo({ repoHooks, installedHooks, version: '0.31.1.0' });
|
|
113
|
-
|
|
114
|
-
writeHook(installedHooks, 'pre-commit', '#!/bin/bash\n# XP-GATE QUALITY GATES v0.30.0.0\necho v1-patched-by-downstream\n');
|
|
115
|
-
syncGlobalHooksFromRepo({ repoHooks, installedHooks, version: '0.31.1.0' });
|
|
116
|
-
|
|
117
|
-
const logPath = path.join(installedHooks, 'deploy.log');
|
|
118
|
-
const lines = fs.readFileSync(logPath, 'utf8').trim().split('\n').filter((l) => l.includes('pre-commit'));
|
|
119
|
-
expect(lines).toHaveLength(2);
|
|
120
|
-
});
|
|
121
|
-
});
|