@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,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-670 doctor: classify module drift by DIRECTION, not by line counts
|
|
3
|
-
* @intent `xp-gate doctor` used to report five gate modules as
|
|
4
|
-
*
|
|
5
|
-
* diverged both ways — githooks/ has 70 line(s) the install lacks,
|
|
6
|
-
* the install has 2 line(s) githooks/ lacks; sync refuses without an
|
|
7
|
-
* explicit decision
|
|
8
|
-
*
|
|
9
|
-
* I checked every "<" line (installed-only) by hand: all of them were
|
|
10
|
-
* OLDER versions of code the repository had already rewritten. The
|
|
11
|
-
* "install has 2 lines githooks lacks" was purely the shape a re-wrapped
|
|
12
|
-
* line leaves in a line-level diff — the same logic, with a `&&` or a
|
|
13
|
-
* pipe moved onto a new line, produces a line present on neither side.
|
|
14
|
-
*
|
|
15
|
-
* The wording matters more than it looks. "diverged both ways" plus
|
|
16
|
-
* "sync refuses without an explicit decision" tells the reader that both
|
|
17
|
-
* sides hold something worth keeping and a human must choose. The
|
|
18
|
-
* consequence is not extra keystrokes: it makes people AVOID syncing,
|
|
19
|
-
* because syncing appears to discard the installed copy's work. And not
|
|
20
|
-
* syncing is exactly #451 — editing githooks/ and having nothing happen.
|
|
21
|
-
*
|
|
22
|
-
* So the classifier must ask "does the installed copy hold anything the
|
|
23
|
-
* repo genuinely lacks?" instead of "are both line counts non-zero?".
|
|
24
|
-
* Token-level comparison answers the real question: whitespace and line
|
|
25
|
-
* breaks are formatting, and formatting is not work.
|
|
26
|
-
* @covers AC-670-64, AC-670-65, AC-670-66
|
|
27
|
-
*/
|
|
28
|
-
'use strict';
|
|
29
|
-
|
|
30
|
-
const { moduleDriftDetail } = require('../doctor');
|
|
31
|
-
|
|
32
|
-
/** Join lines the way a formatter re-wraps them: same tokens, different breaks. */
|
|
33
|
-
const wrap = (...lines) => lines.join('\n');
|
|
34
|
-
|
|
35
|
-
describe('moduleDriftDetail direction classification (#667)', () => {
|
|
36
|
-
it('AC-670-64: a pure re-wrap is "behind", not "diverged both ways"', () => {
|
|
37
|
-
// Same logic; the `&&` moved to the next line. A line-level diff calls this
|
|
38
|
-
// two-sided drift. Nothing was authored on the installed side.
|
|
39
|
-
// Real shape measured on gate-3.sh: an older install re-wrapped the same
|
|
40
|
-
// statements, so a line-level diff reports lines unique to BOTH sides while
|
|
41
|
-
// the token content is identical (measured: repoOnly=0, installedOnly=0).
|
|
42
|
-
const repo = wrap(
|
|
43
|
-
'RATCHET_LIB="$GATE_DIR/lib/ccn-ratchet.sh"',
|
|
44
|
-
'if [ -f "$RATCHET_LIB" ]; then . "$RATCHET_LIB"; fi',
|
|
45
|
-
'known.set(norm(f.file) + "::" + f.name, Number(f.ccn) || 0);',
|
|
46
|
-
);
|
|
47
|
-
const installed = wrap(
|
|
48
|
-
' RATCHET_LIB="$GATE_DIR/lib/ccn-ratchet.sh"',
|
|
49
|
-
' if [ -f "$RATCHET_LIB" ]; then',
|
|
50
|
-
' . "$RATCHET_LIB"',
|
|
51
|
-
' fi',
|
|
52
|
-
'known.set(norm(f.file) + "::" + f.name,',
|
|
53
|
-
' Number(f.ccn) || 0);',
|
|
54
|
-
);
|
|
55
|
-
const detail = moduleDriftDetail(repo, installed);
|
|
56
|
-
expect(detail).not.toMatch(/diverged both ways/i);
|
|
57
|
-
expect(detail).toMatch(/formatting|stale|behind/i);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('AC-670-65: a genuine two-sided edit still refuses to sync silently', () => {
|
|
61
|
-
// The installed copy carries a real, machine-only hardening: a fail-closed
|
|
62
|
-
// branch that exists nowhere in the repo. Overwriting it would destroy work.
|
|
63
|
-
const repo = wrap(
|
|
64
|
-
'if [ -z "$COV" ]; then',
|
|
65
|
-
' echo "no coverage tool";',
|
|
66
|
-
' return 0;',
|
|
67
|
-
'fi',
|
|
68
|
-
);
|
|
69
|
-
const installed = wrap(
|
|
70
|
-
'if [ -z "$COV" ]; then',
|
|
71
|
-
' # FAIL CLOSED: cannot determine coverage means the check failed.',
|
|
72
|
-
' echo "❌ BLOCKED - could not determine coverage";',
|
|
73
|
-
' return 1;',
|
|
74
|
-
'fi',
|
|
75
|
-
);
|
|
76
|
-
const detail = moduleDriftDetail(repo, installed);
|
|
77
|
-
expect(detail).toMatch(/diverged both ways/i);
|
|
78
|
-
expect(detail).toMatch(/refuses|explicit decision/i);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('AC-670-66: an unreadable pair is reported honestly, never as identical', () => {
|
|
82
|
-
// readPair() returns null when either side cannot be read. Reporting that as
|
|
83
|
-
// "matches" would be a fail-open: the drift could be real and unseen.
|
|
84
|
-
const detail = moduleDriftDetail(null, null);
|
|
85
|
-
expect(detail).toMatch(/could not be read|cannot be compared/i);
|
|
86
|
-
expect(detail).not.toMatch(/matches|identical/i);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('re-wrap is not drift (#667)', () => {
|
|
91
|
-
it('AC-670-64: a pure re-wrap yields no unique tokens on either side', () => {
|
|
92
|
-
// The end-to-end property: formatting-only differences must not count as an
|
|
93
|
-
// issue, because failing on them teaches the reader to distrust `doctor`
|
|
94
|
-
// and to skip the sync that #451 exists to encourage.
|
|
95
|
-
const { tokenDelta } = require('../doctor.js');
|
|
96
|
-
const NL = String.fromCharCode(10);
|
|
97
|
-
const repo = 'a &&' + NL + ' b' + NL;
|
|
98
|
-
const installed = 'a' + NL + ' && b' + NL;
|
|
99
|
-
const delta = tokenDelta(repo, installed);
|
|
100
|
-
expect(delta.repoOnly).toBe(0);
|
|
101
|
-
expect(delta.installedOnly).toBe(0);
|
|
102
|
-
expect(moduleDriftDetail(repo, installed)).toMatch(/formatting/i);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-495 Round 2: the drift surface must not lie in either direction
|
|
3
|
-
* @intent 三位专家对 origin/main..HEAD 的走查给出三条同族判定:(1) 字节不同但行集
|
|
4
|
-
* 相同(仅行尾/缩进差异)落入 moduleDriftDetail 兜底分支,报 FAIL 却写着
|
|
5
|
-
* "0 line(s) absent from the repo",方向断言为伪且 --fix 清不掉;(2)
|
|
6
|
-
* diagnoseModuleDrift 认 XP_GATE_REPO_ROOT 而 syncModulesFromRepo 只认
|
|
7
|
-
* process.cwd(),在仓库外带 env 运行 --sync-hooks 时诊断报 FAIL、同步静默
|
|
8
|
-
* 空转(#488/#416 已明令禁止的"被忽略的选项"缺陷类);(3) drift 结果被
|
|
9
|
-
* Promise.race 的全局 10s 超时整份丢弃并返回 issues:0,doctor 随即打印
|
|
10
|
-
* "✓ All checks passed" —— 正是 #495 要消灭的"模块陈旧但 doctor 全绿"。
|
|
11
|
-
* 外加 lib/ 通道:syncGlobalHooksFromRepo 对 githooks/lib/*.sh 无条件覆盖,
|
|
12
|
-
* 而同一次发布里模块同步对同类风险显式拒绝,破坏性写入标准不对称。
|
|
13
|
-
* @covers AC-495-07, AC-495-08, AC-495-09, AC-495-10, AC-495-13, AC-488-05
|
|
14
|
-
*/
|
|
15
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
|
|
16
|
-
import { tmpdir } from 'node:os';
|
|
17
|
-
import { join } from 'node:path';
|
|
18
|
-
import { describe, expect, it } from 'vitest';
|
|
19
|
-
|
|
20
|
-
function fixture(spec) {
|
|
21
|
-
const root = mkdtempSync(join(tmpdir(), 'xp-gate-r2-'));
|
|
22
|
-
const repoHooks = join(root, 'githooks');
|
|
23
|
-
const installedHooks = join(root, 'hooks');
|
|
24
|
-
const installedAdapters = join(root, 'adapters');
|
|
25
|
-
mkdirSync(join(repoHooks, 'adapters'), { recursive: true });
|
|
26
|
-
mkdirSync(join(repoHooks, 'lib'), { recursive: true });
|
|
27
|
-
mkdirSync(installedHooks, { recursive: true });
|
|
28
|
-
mkdirSync(installedHooks + '/lib', { recursive: true });
|
|
29
|
-
mkdirSync(installedAdapters, { recursive: true });
|
|
30
|
-
|
|
31
|
-
const write = (file, text) => {
|
|
32
|
-
mkdirSync(join(file, '..'), { recursive: true });
|
|
33
|
-
writeFileSync(file, text);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
for (const [name, sides] of Object.entries(spec)) {
|
|
37
|
-
const rootLevel = name.startsWith('gate-') || name === 'adapter-common.sh' || name.startsWith('lib/');
|
|
38
|
-
if (sides.repo !== null) {
|
|
39
|
-
write(join(repoHooks, rootLevel ? name : join('adapters', name)), sides.repo);
|
|
40
|
-
}
|
|
41
|
-
if (sides.installed !== undefined && sides.installed !== null) {
|
|
42
|
-
write(join(installedAdapters, name), sides.installed);
|
|
43
|
-
}
|
|
44
|
-
// lib/ lives under hooks/, not under the adapters dir, so it needs its own pair.
|
|
45
|
-
if (sides.installedLib !== undefined) {
|
|
46
|
-
write(join(installedHooks, name), sides.installedLib);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
write(join(repoHooks, 'pre-commit'), '#!/bin/bash\necho repo\n');
|
|
51
|
-
write(join(installedHooks, 'pre-commit'), '#!/bin/bash\necho repo\n');
|
|
52
|
-
|
|
53
|
-
// Resolution anchors: the installed dir only becomes ADAPTER_DIR / GATE_DIR if
|
|
54
|
-
// adapter-common.sh (githooks/pre-commit:34) and gate-3.sh (:80) live in it.
|
|
55
|
-
// Without them the fixture describes a tier the hook never resolves to, and the
|
|
56
|
-
// comparison silently targets a directory outside the test (#495 Round 3).
|
|
57
|
-
//
|
|
58
|
-
// The anchors go to the GLOBAL tier only. Precedence is project-first
|
|
59
|
-
// (AC-495-23), so anchoring both trees would make the repo tier execute and
|
|
60
|
-
// these global-vs-repo comparisons would have no executed counterpart left.
|
|
61
|
-
const ANCHOR = '#!/bin/bash\nanchor\n';
|
|
62
|
-
for (const anchor of ['adapter-common.sh', 'gate-3.sh']) {
|
|
63
|
-
if (spec[anchor]) continue;
|
|
64
|
-
write(join(installedAdapters, anchor), ANCHOR);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return { root, repoHooks, installedHooks, installedAdapters, write };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Name every tier the hook can resolve into so no fixture can reach this
|
|
72
|
-
* machine's real `~/.config/xp-gate`.
|
|
73
|
-
*/
|
|
74
|
-
function ctxFor(f, extra = {}) {
|
|
75
|
-
return {
|
|
76
|
-
repoRoot: f.root,
|
|
77
|
-
repoHooks: f.repoHooks,
|
|
78
|
-
installedAdapters: f.installedAdapters,
|
|
79
|
-
scriptDir: f.installedHooks,
|
|
80
|
-
...extra,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
describe('doctor drift Round 2 (#495)', () => {
|
|
85
|
-
it('AC-495-07: a line-ending-only difference is not reported as drift, and never claims zero unique lines', () => {
|
|
86
|
-
const { diagnoseModuleDrift } = require('../doctor');
|
|
87
|
-
const repo = '#!/bin/bash\ngate_line_one\ngate_line_two\n';
|
|
88
|
-
const f = fixture({
|
|
89
|
-
'gate-4.sh': { repo, installed: repo.replace(/\n/g, '\r\n') },
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const result = diagnoseModuleDrift(ctxFor(f));
|
|
93
|
-
const check = result.checks.find((c) => c.name === 'Module drift: gate-4.sh');
|
|
94
|
-
expect(check).toBeDefined();
|
|
95
|
-
expect(check.status).not.toBe('FAIL');
|
|
96
|
-
expect(result.issues).toBe(0);
|
|
97
|
-
// The self-contradicting verdict ("newer ... 0 line(s) absent") must be gone.
|
|
98
|
-
expect(check.detail).not.toMatch(/0 line\(s\)/);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('AC-495-08: sync resolves the repo root the same way the diagnosis does', () => {
|
|
102
|
-
const { syncModulesFromRepo, diagnoseModuleDrift } = require('../doctor');
|
|
103
|
-
const f = fixture({
|
|
104
|
-
'gate-4.sh': { repo: '#!/bin/bash\nline_a\nline_b\n', installed: '#!/bin/bash\nline_a\n' },
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Run from OUTSIDE the repository with the repo located by env only.
|
|
108
|
-
const previous = process.env.XP_GATE_REPO_ROOT;
|
|
109
|
-
process.env.XP_GATE_REPO_ROOT = f.root;
|
|
110
|
-
try {
|
|
111
|
-
const diagnosis = diagnoseModuleDrift(ctxFor(f));
|
|
112
|
-
expect(diagnosis.issues).toBe(1);
|
|
113
|
-
|
|
114
|
-
// Only the install target is named: the repo must come from the same env
|
|
115
|
-
// the diagnosis used, or the FAIL this produces can never be cleared.
|
|
116
|
-
const synced = syncModulesFromRepo({ installedAdapters: f.installedAdapters, scriptDir: f.installedHooks });
|
|
117
|
-
expect(synced.synced).toContain('gate-4.sh');
|
|
118
|
-
expect(readFileSync(join(f.installedAdapters, 'gate-4.sh'), 'utf8')).toContain('line_b');
|
|
119
|
-
expect(diagnoseModuleDrift(ctxFor(f)).issues).toBe(0);
|
|
120
|
-
} finally {
|
|
121
|
-
if (previous === undefined) delete process.env.XP_GATE_REPO_ROOT;
|
|
122
|
-
else process.env.XP_GATE_REPO_ROOT = previous;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('AC-495-09: sync with no canonical repo source says so instead of returning an empty success', () => {
|
|
127
|
-
const { syncModulesFromRepo } = require('../doctor');
|
|
128
|
-
const root = mkdtempSync(join(tmpdir(), 'xp-gate-r2-nosource-'));
|
|
129
|
-
const installedAdapters = join(root, 'adapters');
|
|
130
|
-
mkdirSync(installedAdapters, { recursive: true });
|
|
131
|
-
writeFileSync(join(installedAdapters, 'gate-4.sh'), '#!/bin/bash\ninstalled\n');
|
|
132
|
-
|
|
133
|
-
const previous = process.env.XP_GATE_REPO_ROOT;
|
|
134
|
-
process.env.XP_GATE_REPO_ROOT = root; // no githooks/ under here at all
|
|
135
|
-
try {
|
|
136
|
-
const result = syncModulesFromRepo({ repoRoot: root, installedAdapters });
|
|
137
|
-
expect(result.sourceMissing).toBe(true);
|
|
138
|
-
expect(result.errors.join('\n')).toMatch(/no (canonical )?githooks/i);
|
|
139
|
-
} finally {
|
|
140
|
-
if (previous === undefined) delete process.env.XP_GATE_REPO_ROOT;
|
|
141
|
-
else process.env.XP_GATE_REPO_ROOT = previous;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('AC-495-10: a timed-out diagnosis can never print "All checks passed"', () => {
|
|
146
|
-
const source = readFileSync(join(__dirname, '..', 'doctor.js'), 'utf8');
|
|
147
|
-
|
|
148
|
-
// The race outcome must carry timedOut out of the destructuring...
|
|
149
|
-
expect(source).toMatch(/const \{[^}]*timedOut[^}]*\} = await Promise\.race/);
|
|
150
|
-
// ...and branch on it, because a timeout discards every computed FAIL.
|
|
151
|
-
expect(source).toMatch(/if \(timedOut\)[\s\S]{0,200}issues\s*(\+\+|\+=|= Math\.max)/);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('AC-495-13: a flat copy inside the project githooks/ is diagnosed when the project tier is what executes', () => {
|
|
155
|
-
const { diagnoseModuleDrift } = require('../doctor');
|
|
156
|
-
// Project mode (no global install): pre-commit:36-37 resolves ADAPTER_DIR to
|
|
157
|
-
// <repo>/githooks, and resolve_adapter_path() then tries $ADAPTER_DIR/<lang>.sh
|
|
158
|
-
// before the nested source. The installer wrote those flat copies once and
|
|
159
|
-
// .gitignore:42 keeps them out of the repo, so a later repo fix that only
|
|
160
|
-
// touches adapters/<lang>.sh leaves the stale flat copy executing -- a
|
|
161
|
-
// #493-class repair inert in the very repository that shipped it.
|
|
162
|
-
const root = mkdtempSync(join(tmpdir(), 'xp-gate-project-tier-'));
|
|
163
|
-
const repoHooks = join(root, 'githooks');
|
|
164
|
-
mkdirSync(join(repoHooks, 'adapters'), { recursive: true });
|
|
165
|
-
writeFileSync(join(repoHooks, 'pre-commit'), '#!/bin/bash\necho repo\n');
|
|
166
|
-
writeFileSync(join(repoHooks, 'adapter-common.sh'), '#!/bin/bash\nshared\n');
|
|
167
|
-
writeFileSync(join(repoHooks, 'gate-3.sh'), '#!/bin/bash\ngate3\n');
|
|
168
|
-
writeFileSync(join(repoHooks, 'adapters', 'iac.sh'), '#!/bin/bash\nfixed_count_guard\n');
|
|
169
|
-
writeFileSync(join(repoHooks, 'iac.sh'), '#!/bin/bash\nstale_echo_zero\n');
|
|
170
|
-
|
|
171
|
-
const result = diagnoseModuleDrift({
|
|
172
|
-
repoRoot: root,
|
|
173
|
-
installedAdapters: join(root, 'nothing-installed-globally'),
|
|
174
|
-
scriptDir: join(root, 'nothing-installed-hooks'),
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const projectCheck = result.checks.find((c) => /Module drift \(project\): iac\.sh/.test(c.name));
|
|
178
|
-
expect(projectCheck, 'the executed project-tier flat copy is invisible to doctor').toBeDefined();
|
|
179
|
-
expect(projectCheck.status).toBe('FAIL');
|
|
180
|
-
// The verdict has to say what to do with a gitignored installer residue.
|
|
181
|
-
expect(projectCheck.detail).toMatch(/flat|shadow/i);
|
|
182
|
-
expect(result.issues).toBe(1);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('AC-488-05: lib/ sync refuses an installed library the repo does not have lines for', () => {
|
|
186
|
-
const { syncGlobalHooksFromRepo } = require('../doctor');
|
|
187
|
-
const f = fixture({
|
|
188
|
-
'lib/test-failure.sh': {
|
|
189
|
-
repo: '#!/bin/bash\nrepo_shared_helper\n',
|
|
190
|
-
installedLib: '#!/bin/bash\ninstalled_machine_hardening\n',
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
const result = syncGlobalHooksFromRepo({
|
|
195
|
-
repoHooks: f.repoHooks,
|
|
196
|
-
installedHooks: f.installedHooks,
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
expect(result.refused.map((r) => r.name)).toContain('lib/test-failure.sh');
|
|
200
|
-
expect(readFileSync(join(f.installedHooks, 'lib', 'test-failure.sh'), 'utf8'))
|
|
201
|
-
.toContain('installed_machine_hardening');
|
|
202
|
-
expect(existsSync(join(f.installedHooks, 'lib', 'test-failure.sh'))).toBe(true);
|
|
203
|
-
|
|
204
|
-
// A one-way-stale library still syncs: the guard is for divergence, not staleness.
|
|
205
|
-
const stale = fixture({
|
|
206
|
-
'lib/test-failure.sh': {
|
|
207
|
-
repo: '#!/bin/bash\nshared_a\nshared_b\n',
|
|
208
|
-
installedLib: '#!/bin/bash\nshared_a\n',
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
|
-
const second = syncGlobalHooksFromRepo({ repoHooks: stale.repoHooks, installedHooks: stale.installedHooks });
|
|
212
|
-
expect(second.synced).toContain('lib/test-failure.sh');
|
|
213
|
-
expect(readFileSync(join(stale.installedHooks, 'lib', 'test-failure.sh'), 'utf8')).toContain('shared_b');
|
|
214
|
-
});
|
|
215
|
-
});
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-DOCTOR retry-on-empty-stream guard
|
|
3
|
-
* @intent On win32, cmd.exe (exec's shell) can deliver exit 0 with an EMPTY
|
|
4
|
-
* stdout+stderr when many spawns are in flight — doctor read that as
|
|
5
|
-
* "Not found" and red-flagged Node/Git/hooksPath on a healthy machine.
|
|
6
|
-
* execWithTimeout must retry an empty-but-successful probe before
|
|
7
|
-
* reporting it, and must NOT retry real failures or real output.
|
|
8
|
-
* @covers AC-DOCTOR-RETRY-01
|
|
9
|
-
*/
|
|
10
|
-
const path = require('path');
|
|
11
|
-
const { describe, it, expect, afterEach } = await import('vitest');
|
|
12
|
-
|
|
13
|
-
const cpPath = require.resolve('child_process');
|
|
14
|
-
|
|
15
|
-
function stubExec(behaviors) {
|
|
16
|
-
// doctor builds its async exec at load time via util.promisify(exec), which
|
|
17
|
-
// binds Node's INTERNAL custom promisify implementation — replacing the plain
|
|
18
|
-
// `exec` property afterwards is invisible to it (measured: stub fired 0-1
|
|
19
|
-
// times while the real cmd.exe child ran). The only patch point that holds
|
|
20
|
-
// across a fresh require is util.promisify itself.
|
|
21
|
-
const util = require('util');
|
|
22
|
-
const originalPromisify = util.promisify;
|
|
23
|
-
const calls = [];
|
|
24
|
-
util.promisify = function (fn) {
|
|
25
|
-
if (fn && fn.name === 'exec') {
|
|
26
|
-
stubWasConsumed = true;
|
|
27
|
-
return (cmd, opts = {}) => {
|
|
28
|
-
const attempt = calls.length;
|
|
29
|
-
calls.push(cmd);
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
behaviors[attempt]((err, stdout, stderr) => {
|
|
32
|
-
if (err) reject(err);
|
|
33
|
-
else resolve({ stdout, stderr });
|
|
34
|
-
}, attempt);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return originalPromisify.call(util, fn);
|
|
39
|
-
};
|
|
40
|
-
return {
|
|
41
|
-
calls,
|
|
42
|
-
restore: () => { util.promisify = originalPromisify; },
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Node couples exec to promisify via a custom symbol; if a future runtime drops
|
|
47
|
-
// that coupling the name-based stub above silently stops intercepting and the
|
|
48
|
-
// real cmd.exe child runs. Each test flips this to true from inside its own
|
|
49
|
-
// stubbed load (never inherited from an earlier test), so afterEach can fail
|
|
50
|
-
// loudly instead of passing vacuously.
|
|
51
|
-
let stubWasConsumed = false;
|
|
52
|
-
|
|
53
|
-
describe('execWithTimeout empty-stream retry (#525 follow-up)', () => {
|
|
54
|
-
let stub = null;
|
|
55
|
-
afterEach(() => {
|
|
56
|
-
if (stub) { stub.restore(); stub = null; }
|
|
57
|
-
// Fail loudly if the fn.name === 'exec' stub never intercepted this test's
|
|
58
|
-
// doctor load — that would mean Node dropped the exec/promisify custom-
|
|
59
|
-
// symbol coupling and the assertions ran against real cmd.exe children.
|
|
60
|
-
expect(stubWasConsumed, `stub did not intercept the doctor load in this test`).toBe(true);
|
|
61
|
-
stubWasConsumed = false;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
function freshDoctor() {
|
|
65
|
-
const doctorPath = require.resolve('../doctor.js');
|
|
66
|
-
delete require.cache[doctorPath];
|
|
67
|
-
return require(doctorPath).execWithTimeout;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Windows-only by construction, as a whole: the RETRY it asserts does not exist
|
|
71
|
-
// off win32. The retry compensates for cmd.exe returning exit 0 with an EMPTY
|
|
72
|
-
// stream; elsewhere the first empty probe is final, so `result` comes back null
|
|
73
|
-
// and there is nothing to retry. Asserting the attempt count alone is not enough
|
|
74
|
-
// — measured under a faked `process.platform = 'linux'`, the count assertion
|
|
75
|
-
// passed while `result` failed with "expected null to deeply equal { stdout:
|
|
76
|
-
// 'v24.19.0' }". The premise of the whole case is win32 (#586).
|
|
77
|
-
it.skipIf(process.platform !== 'win32')(
|
|
78
|
-
'AC-DOCTOR-RETRY-01: retries an exit-0 empty-stdout probe and keeps its own timeout',
|
|
79
|
-
async () => {
|
|
80
|
-
stub = stubExec([
|
|
81
|
-
(cb) => cb(null, '', ''), // the lost-stream failure mode
|
|
82
|
-
(cb) => cb(null, 'v24.19.0\n', ''), // the same probe, stream intact
|
|
83
|
-
]);
|
|
84
|
-
const execWithTimeout = freshDoctor();
|
|
85
|
-
const result = await execWithTimeout('node --version', { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
86
|
-
expect(stub.calls.length).toBe(2);
|
|
87
|
-
expect(result).toEqual({ stdout: 'v24.19.0', stderr: '' });
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
it('AC-DOCTOR-RETRY-01: returns null after exhausting attempts on a persistently empty probe', async () => {
|
|
92
|
-
stub = stubExec([
|
|
93
|
-
(cb) => cb(null, '', ''),
|
|
94
|
-
(cb) => cb(null, '', ''),
|
|
95
|
-
(cb) => cb(null, '', ''),
|
|
96
|
-
(cb) => cb(null, 'unexpected fourth attempt', ''),
|
|
97
|
-
]);
|
|
98
|
-
const execWithTimeout = freshDoctor();
|
|
99
|
-
const result = await execWithTimeout('node --version', {});
|
|
100
|
-
// win32: 3 attempts then null; other platforms: single attempt, still null.
|
|
101
|
-
expect(result).toBeNull();
|
|
102
|
-
expect(stub.calls.length).toBe(process.platform === 'win32' ? 3 : 1);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('AC-DOCTOR-RETRY-01: does not retry when the probe produced output', async () => {
|
|
106
|
-
stub = stubExec([(cb) => cb(null, 'git version 2.54.0\n', '')]);
|
|
107
|
-
const execWithTimeout = freshDoctor();
|
|
108
|
-
const result = await execWithTimeout('git --version', {});
|
|
109
|
-
expect(stub.calls.length).toBe(1);
|
|
110
|
-
expect(result.stdout).toContain('git version');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('AC-DOCTOR-RETRY-01: does not retry a failing command', async () => {
|
|
114
|
-
stub = stubExec([(cb) => cb(Object.assign(new Error('ENOENT'), { code: 'ENOENT' }), '', '')]);
|
|
115
|
-
const execWithTimeout = freshDoctor();
|
|
116
|
-
const result = await execWithTimeout('definitely-not-a-tool --version', {});
|
|
117
|
-
expect(stub.calls.length).toBe(1);
|
|
118
|
-
expect(result).toBeNull();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('AC-DOCTOR-RETRY-01: attempts:1 opts a side-effecting call out of the retry', async () => {
|
|
122
|
-
stub = stubExec([
|
|
123
|
-
(cb) => cb(null, '', ''),
|
|
124
|
-
(cb) => cb(null, 'unexpected second attempt', ''),
|
|
125
|
-
]);
|
|
126
|
-
const execWithTimeout = freshDoctor();
|
|
127
|
-
const result = await execWithTimeout('some-mutating-command', { attempts: 1 });
|
|
128
|
-
expect(stub.calls.length).toBe(1);
|
|
129
|
-
expect(result).toBeNull();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('AC-DOCTOR-RETRY-01: the attempts option is consumed, not forwarded to exec', async () => {
|
|
133
|
-
let forwarded = null;
|
|
134
|
-
stub = stubExec([(cb) => { cb(null, 'ok\n', ''); }]);
|
|
135
|
-
// Capture what doctor hands to the promisified exec by re-stubbing with an
|
|
136
|
-
// options recorder: stubExec's behaviors receive only the callback, so
|
|
137
|
-
// assert forwarding through a second fresh module with a capturing wrapper.
|
|
138
|
-
const util = require('util');
|
|
139
|
-
const originalPromisify = util.promisify;
|
|
140
|
-
const execWithTimeout = (() => {
|
|
141
|
-
util.promisify = function (fn) {
|
|
142
|
-
if (fn && fn.name === 'exec') {
|
|
143
|
-
stubWasConsumed = true;
|
|
144
|
-
return (cmd, opts = {}) => {
|
|
145
|
-
forwarded = opts;
|
|
146
|
-
return Promise.resolve({ stdout: 'ok\n', stderr: '' });
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
return originalPromisify.call(util, fn);
|
|
150
|
-
};
|
|
151
|
-
const doctorPath = require.resolve('../doctor.js');
|
|
152
|
-
delete require.cache[doctorPath];
|
|
153
|
-
const f = require(doctorPath).execWithTimeout;
|
|
154
|
-
util.promisify = originalPromisify;
|
|
155
|
-
return f;
|
|
156
|
-
})();
|
|
157
|
-
const result = await execWithTimeout('git --version', { attempts: 2, timeout: 999 });
|
|
158
|
-
expect(result.stdout).toBe('ok');
|
|
159
|
-
expect(forwarded.attempts).toBeUndefined();
|
|
160
|
-
expect(forwarded.timeout).toBe(999);
|
|
161
|
-
});
|
|
162
|
-
});
|