@boyingliu01/xp-gate 0.38.126 → 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 +13 -2
- package/adapters/python.sh +36 -38
- package/bin/xp-gate.js +11 -0
- package/build-integrity/gate-10-lines.ts +98 -0
- package/build-integrity/gate-10.ts +98 -109
- package/build-integrity/quote-masker.ts +17 -3
- package/gate-3.sh +13 -2
- 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/gate-3.sh +13 -2
- package/hooks/gate-entries/gate-1-entry.sh +10 -1
- package/hooks/gate-entries/gate-5-entry.sh +5 -1
- package/hooks/lib/validate-code-walkthrough.cjs +324 -99
- package/hooks/pre-commit +52 -0
- package/hooks/pre-push +54 -3
- 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/doctor-constants.js +43 -0
- package/lib/doctor.js +2008 -1001
- package/lib/flaky.js +178 -79
- package/lib/gate-runner.js +110 -63
- package/lib/init.js +6 -0
- package/lib/language-capability-surfaces.js +5 -2
- package/lib/language-registry.js +608 -0
- package/lib/language-tools.js +487 -1018
- 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-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/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 -430
- 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__/audit-skip-reasons.test.ts +0 -143
- 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-tools-list.test.js +0 -155
- 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-tool-delegation.test.js +0 -156
- 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__/install-tools-repair.test.js +0 -263
- 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 -318
- 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__/tool-audit-collect.test.js +0 -184
- package/lib/__tests__/tool-audit-fixtures.js +0 -87
- package/lib/__tests__/tool-audit-latest.test.js +0 -84
- package/lib/__tests__/tool-audit.test.js +0 -428
- 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,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
|
-
});
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-613
|
|
3
|
-
* @intent `xp-gate check . --all` could never run Gate 4 on Windows:
|
|
4
|
-
*
|
|
5
|
-
* Failed to run principles check: The command line is too long.
|
|
6
|
-
*
|
|
7
|
-
* Two causes added together in `lib/principles.js`:
|
|
8
|
-
*
|
|
9
|
-
* 1. `shell: process.platform === 'win32'` routes through cmd.exe, whose
|
|
10
|
-
* command line is capped at 8191 characters (CreateProcess allows
|
|
11
|
-
* 32767).
|
|
12
|
-
* 2. every path is joined into ONE argv element — `files.join(' ')` — so
|
|
13
|
-
* the whole file list becomes part of that command line. Measured in
|
|
14
|
-
* the issue: 135 Java files came to 12944 characters before the
|
|
15
|
-
* `npx -y tsx <entry> --files --format json` prefix was added.
|
|
16
|
-
*
|
|
17
|
-
* This is not "the occasional huge project"; it is a mid-sized project on
|
|
18
|
-
* Windows, every time.
|
|
19
|
-
*
|
|
20
|
-
* Splitting the argv was explicitly ruled out in the issue and the reasoning
|
|
21
|
-
* holds: the bottleneck is total character count, not quoting, and `npx` on
|
|
22
|
-
* Windows still needs `shell: true` to be found at all.
|
|
23
|
-
*
|
|
24
|
-
* The other half of the issue is what the failure is CALLED. "Failed to run
|
|
25
|
-
* principles check" reads like a principles violation. It is not — the tool
|
|
26
|
-
* never ran. #596 fixed the same confusion in the shell toolchain
|
|
27
|
-
* (`classify_tool_failure`); this pins it for the JS side.
|
|
28
|
-
* @covers AC-613-01, AC-613-02, AC-613-03
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
const fs = require('fs');
|
|
32
|
-
const os = require('os');
|
|
33
|
-
const path = require('path');
|
|
34
|
-
|
|
35
|
-
const principles = require('../principles.js');
|
|
36
|
-
|
|
37
|
-
// cmd.exe's command-line ceiling. Named rather than repeated: it is the number the
|
|
38
|
-
// whole issue is about, and a bare 8191 in several places reads as unrelated facts.
|
|
39
|
-
const CMD_EXE_LIMIT = 8191;
|
|
40
|
-
|
|
41
|
-
// The measured case from the issue: 135 Java files => 12944 characters, which blocked
|
|
42
|
-
// every `--all` run on Windows.
|
|
43
|
-
const ISSUE_FILE_COUNT = 135;
|
|
44
|
-
|
|
45
|
-
// Comfortably past the limit, used where the exact count does not matter — only that
|
|
46
|
-
// the list is too long to inline.
|
|
47
|
-
const LARGE_FILE_COUNT = 400;
|
|
48
|
-
|
|
49
|
-
/** A path-only string of roughly `len` characters (the join() payload). */
|
|
50
|
-
function longFileList(count) {
|
|
51
|
-
// Paths must be long enough that `count` of them realistically exceeds the
|
|
52
|
-
// Windows limit; the issue's own measurement was ~90 chars per path.
|
|
53
|
-
return Array.from(
|
|
54
|
-
{ length: count },
|
|
55
|
-
(_, i) =>
|
|
56
|
-
`src/main/java/com/example/deeply/nested/module${i}/service/implementation/File${i}ImplementationImpl.java`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
describe('REQ-613: Gate 4 must not blow the Windows command-line limit', () => {
|
|
61
|
-
it('AC-613-01: the command line for a mid-sized Java project stays under cmd.exe\\u2019s character limit', () => {
|
|
62
|
-
// The measured case from the issue: 135 files, 12944 characters, blocked.
|
|
63
|
-
const files = longFileList(ISSUE_FILE_COUNT);
|
|
64
|
-
const joined = files.join(' ');
|
|
65
|
-
expect(joined.length).toBeGreaterThan(CMD_EXE_LIMIT);
|
|
66
|
-
|
|
67
|
-
const plan = principles.buildPrinciplesInvocation(files, 'json');
|
|
68
|
-
// The contract: whatever is handed to the OS is a single argument list, and the
|
|
69
|
-
// total of that list's characters is what must fit. A plan that still carries the
|
|
70
|
-
// whole list in one argument has not solved anything.
|
|
71
|
-
const longest = Math.max(...plan.args.map((a) => String(a).length));
|
|
72
|
-
expect(longest, `longest single argument is ${longest} chars`).toBeLessThan(CMD_EXE_LIMIT);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('AC-613-01: a large file list is passed by reference, not by value', () => {
|
|
76
|
-
// The fix that the issue recommends first: use the project's own tsx through
|
|
77
|
-
// node.exe (an absolute path, no shim, no shell) and keep the argv bounded. If a
|
|
78
|
-
// future change puts every path back on the command line, this fails.
|
|
79
|
-
const files = longFileList(LARGE_FILE_COUNT);
|
|
80
|
-
const plan = principles.buildPrinciplesInvocation(files, 'json');
|
|
81
|
-
|
|
82
|
-
const argvChars = plan.args.reduce((n, a) => n + String(a).length + 1, 0);
|
|
83
|
-
expect(argvChars, `argv carries ${argvChars} chars`).toBeLessThan(CMD_EXE_LIMIT);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('AC-613-02: the invocation never opts into a shell on any platform', () => {
|
|
87
|
-
// `shell: true` is what routes through cmd.exe and its 8191 limit. It must not be
|
|
88
|
-
// requested at all: the correct target is node.exe, which needs no shim.
|
|
89
|
-
const plan = principles.buildPrinciplesInvocation(['a.ts'], 'json');
|
|
90
|
-
expect(plan.useShell).toBe(false);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('AC-613-02: the plan names an executable that needs no shell shim', () => {
|
|
94
|
-
// Either node.exe (preferred — absolute, no shim) or a resolved tool path. A bare
|
|
95
|
-
// 'npx' string would force the caller back to shell:true on Windows.
|
|
96
|
-
const plan = principles.buildPrinciplesInvocation(['a.ts'], 'json');
|
|
97
|
-
expect(plan.command.length).toBeGreaterThan(0);
|
|
98
|
-
expect(plan.command).not.toBe('npx');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('AC-613-03: a command-line-too-long failure is classified as a toolchain problem, not a finding', () => {
|
|
102
|
-
// The message used to be "Failed to run principles check", which reads as a code
|
|
103
|
-
// verdict. It never was one.
|
|
104
|
-
expect(principles.classifyPrinciplesFailure({ error: new Error('E2BIG') })).toBe('TOOLCHAIN');
|
|
105
|
-
expect(principles.classifyPrinciplesFailure({ error: new Error('spawn ENAMETOOLONG') })).toBe('TOOLCHAIN');
|
|
106
|
-
expect(
|
|
107
|
-
principles.classifyPrinciplesFailure({
|
|
108
|
-
stdout: 'The command line is too long.',
|
|
109
|
-
status: 1,
|
|
110
|
-
})
|
|
111
|
-
).toBe('TOOLCHAIN');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('AC-613-03: a real principles violation is still classified as a finding', () => {
|
|
115
|
-
// The control. If everything classified as TOOLCHAIN, Gate 4 could never block on
|
|
116
|
-
// an actual violation again — worse than the bug being fixed.
|
|
117
|
-
expect(principles.classifyPrinciplesFailure({ stdout: '1 violations total', status: 1 })).toBe('FINDING');
|
|
118
|
-
expect(principles.classifyPrinciplesFailure({ status: 1 })).toBe('FINDING');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('AC-613-01: a file list that fits is still passed directly', () => {
|
|
122
|
-
// Small lists must not be needlessly diverted; the direct path is well tested and
|
|
123
|
-
// has different failure semantics.
|
|
124
|
-
const plan = principles.buildPrinciplesInvocation(['src/a.ts', 'src/b.ts'], 'json');
|
|
125
|
-
const flat = plan.args.join(' ');
|
|
126
|
-
expect(flat).toContain('src/a.ts');
|
|
127
|
-
expect(flat).toContain('src/b.ts');
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('AC-613-01: the by-reference handoff writes the list somewhere the child can read', () => {
|
|
131
|
-
// Sanity on the mechanism itself: if the plan says "by reference", the reference
|
|
132
|
-
// has to be a real file path the child will be given, not a placeholder.
|
|
133
|
-
const files = longFileList(LARGE_FILE_COUNT);
|
|
134
|
-
const plan = principles.buildPrinciplesInvocation(files, 'json');
|
|
135
|
-
const refArg = plan.args.find((a) => String(a).startsWith('@'));
|
|
136
|
-
expect(refArg, 'no @file argument in the plan').toBeTruthy();
|
|
137
|
-
const refPath = refArg.slice(1);
|
|
138
|
-
expect(path.isAbsolute(refPath) || refPath.includes('tmp') || refPath.includes('TEMP') || refPath.toLowerCase().includes('temp')).toBe(true);
|
|
139
|
-
// And the file must not be left behind by merely planning.
|
|
140
|
-
expect(fs.existsSync(refPath) && plan.cleanup === false).toBe(false);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('AC-613-02: without a local tsx, npm\u2019s own npx entry runs under node.exe', () => {
|
|
144
|
-
// `spawnSync('npx', ..., { shell: false })` is ENOENT on Windows: CreateProcess
|
|
145
|
-
// resolves only `.exe`, while the installed entry point is `npx.cmd`. Running
|
|
146
|
-
// npm's JS entry with the current node binary is the same program, without a shim
|
|
147
|
-
// — and without handing the file list to cmd.exe.
|
|
148
|
-
const existsSpy = vi.spyOn(fs, 'existsSync').mockImplementation((candidate) =>
|
|
149
|
-
String(candidate).endsWith(path.join('npm', 'bin', 'npx-cli.js'))
|
|
150
|
-
);
|
|
151
|
-
try {
|
|
152
|
-
const plan = principles.buildPrinciplesInvocation(['a.ts'], 'json');
|
|
153
|
-
expect(plan.command).toBe(process.execPath);
|
|
154
|
-
expect(plan.args[0]).toMatch(/npx-cli\.js$/);
|
|
155
|
-
expect(plan.useShell).toBe(false);
|
|
156
|
-
} finally {
|
|
157
|
-
existsSpy.mockRestore();
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('AC-613-02: the bare-npx fallback asks for a shell exactly where the shim needs one', () => {
|
|
162
|
-
// Last resort when neither tsx nor npm's entry can be found. The shell flag must
|
|
163
|
-
// still travel with the plan: hard-coding false is what produced ENOENT on
|
|
164
|
-
// Windows, hard-coding true is what produced the 8191-character limit.
|
|
165
|
-
const existsSpy = vi.spyOn(fs, 'existsSync').mockReturnValue(false);
|
|
166
|
-
try {
|
|
167
|
-
const direct = principles.buildPrinciplesInvocation(['a.ts'], 'json');
|
|
168
|
-
expect(direct.command).toBe('npx');
|
|
169
|
-
expect(direct.useShell).toBe(process.platform === 'win32');
|
|
170
|
-
|
|
171
|
-
const byReference = principles.buildPrinciplesInvocation(longFileList(LARGE_FILE_COUNT), 'json');
|
|
172
|
-
expect(byReference.useShell).toBe(process.platform === 'win32');
|
|
173
|
-
} finally {
|
|
174
|
-
existsSpy.mockRestore();
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('AC-613-02: the WIRE test \u2014 the call site actually uses the plan it builds', () => {
|
|
179
|
-
// This case exists because the first version of this suite had a hole: every
|
|
180
|
-
// other case asserts on `buildPrinciplesInvocation`'s OUTPUT, and reverting the
|
|
181
|
-
// call site to the old `spawnSync('npx', [...files.join(' ') ...], { shell: true })`
|
|
182
|
-
// left all 8 green. A perfectly correct planner that nobody consults.
|
|
183
|
-
//
|
|
184
|
-
// Intercepting child_process.spawnSync does NOT work here: principles.js
|
|
185
|
-
// destructures `{ spawnSync }` at load time, so replacing the property afterwards
|
|
186
|
-
// never reaches the bound local. (I tried that first and the case failed with
|
|
187
|
-
// "spawnSync was never called" — which is itself a useful demonstration that an
|
|
188
|
-
// indirect assertion can fail for a reason unrelated to the defect.)
|
|
189
|
-
//
|
|
190
|
-
// So this asserts the wiring structurally, plus the one property that is cheap to
|
|
191
|
-
// check at runtime: the module must expose the planner, meaning the call site has
|
|
192
|
-
// something to consume.
|
|
193
|
-
const source = fs.readFileSync(path.join(__dirname, '..', 'principles.js'), 'utf8');
|
|
194
|
-
|
|
195
|
-
// The shell:true on the call site, verbatim.
|
|
196
|
-
expect(source, 'the shell:true spawn is back at the call site').not.toContain(
|
|
197
|
-
"shell: process.platform === 'win32'"
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
// The wiring: spawnSync must be fed the plan, and the plan must control the shell.
|
|
201
|
-
expect(source).toContain('spawnSync(plan.command, plan.args');
|
|
202
|
-
expect(source).toContain('shell: plan.useShell');
|
|
203
|
-
|
|
204
|
-
// The planner bounds the list; the join() is still allowed for SHORT lists inside
|
|
205
|
-
// buildPrinciplesInvocation (that is the correct path for small inputs), but it
|
|
206
|
-
// must never appear in the spawnSync argument position any more.
|
|
207
|
-
const spawnIdx = source.indexOf('spawnSync(plan.command, plan.args');
|
|
208
|
-
const joinAfterSpawn = source.indexOf('files.join(', spawnIdx);
|
|
209
|
-
expect(joinAfterSpawn, 'the spawn call still joins the whole list inline').toBe(-1);
|
|
210
|
-
|
|
211
|
-
// And the planner must really exist and be exported, so the call site cannot be
|
|
212
|
-
// referencing a name that only looks right.
|
|
213
|
-
expect(typeof principles.buildPrinciplesInvocation).toBe('function');
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// Keep the imports referenced so linting does not flag them when the module grows.
|
|
218
|
-
void os;
|