@opengsd/gsd-core 1.13.0 → 1.14.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/agents/gsd-advisor-researcher.compact.md +85 -0
- package/agents/gsd-ai-researcher.compact.md +96 -0
- package/agents/gsd-assumptions-analyzer.compact.md +81 -0
- package/agents/gsd-code-fixer.compact.md +458 -0
- package/agents/gsd-code-fixer.md +5 -5
- package/agents/gsd-code-reviewer.compact.md +269 -0
- package/agents/gsd-code-reviewer.md +15 -3
- package/agents/gsd-codebase-mapper.compact.md +760 -0
- package/agents/gsd-debug-session-manager.compact.md +345 -0
- package/agents/gsd-doc-classifier.compact.md +192 -0
- package/agents/gsd-doc-synthesizer.compact.md +200 -0
- package/agents/gsd-doc-verifier.compact.md +143 -0
- package/agents/gsd-doc-writer.compact.md +440 -0
- package/agents/gsd-dom-verifier.compact.md +138 -0
- package/agents/gsd-domain-researcher.compact.md +141 -0
- package/agents/gsd-eval-auditor.compact.md +160 -0
- package/agents/gsd-eval-planner.compact.md +137 -0
- package/agents/gsd-framework-selector.compact.md +82 -0
- package/agents/gsd-integration-checker.compact.md +245 -0
- package/agents/gsd-intel-updater.compact.md +226 -0
- package/agents/gsd-mempalace-curator.compact.md +45 -0
- package/agents/gsd-nyquist-auditor.compact.md +179 -0
- package/agents/gsd-pattern-mapper.compact.md +275 -0
- package/agents/gsd-project-researcher.compact.md +587 -0
- package/agents/gsd-research-synthesizer.compact.md +212 -0
- package/agents/gsd-roadmapper.compact.md +454 -0
- package/agents/gsd-roadmapper.md +13 -0
- package/agents/gsd-security-auditor.compact.md +162 -0
- package/agents/gsd-ui-auditor.compact.md +404 -0
- package/agents/gsd-ui-checker.compact.md +277 -0
- package/agents/gsd-ui-researcher.compact.md +282 -0
- package/agents/gsd-user-profiler.compact.md +108 -0
- package/bin/install.js +206 -68
- package/commands/gsd/cleanup.md +1 -0
- package/commands/gsd/code-review.md +2 -1
- package/commands/gsd/complete-milestone.md +1 -0
- package/commands/gsd/config.md +1 -0
- package/commands/gsd/debug.md +1 -0
- package/commands/gsd/graphify.md +1 -0
- package/commands/gsd/health.md +1 -0
- package/commands/gsd/mempalace-capture.md +1 -0
- package/commands/gsd/mempalace-recall.md +1 -0
- package/commands/gsd/new-milestone.md +1 -0
- package/commands/gsd/new-project.md +1 -0
- package/commands/gsd/next.md +1 -0
- package/commands/gsd/pause-work.md +1 -0
- package/commands/gsd/phase.md +1 -0
- package/commands/gsd/pr-branch.md +1 -0
- package/commands/gsd/resume-work.md +1 -0
- package/commands/gsd/review-backlog.md +1 -0
- package/commands/gsd/settings.md +2 -1
- package/commands/gsd/stats.md +1 -0
- package/commands/gsd/thread.md +1 -0
- package/commands/gsd/workspace.md +1 -0
- package/commands/gsd/workstreams.md +1 -0
- package/gsd-core/bin/check-latest-version.cjs +8 -3
- package/gsd-core/bin/gsd-tools.cjs +338 -125
- package/gsd-core/bin/lib/adr-parser.cjs +1 -1
- package/gsd-core/bin/lib/artifacts.cjs +2 -1
- package/gsd-core/bin/lib/audit.cjs +39 -22
- package/gsd-core/bin/lib/broken-windows.cjs +168 -49
- package/gsd-core/bin/lib/capability-lifecycle.cjs +10 -6
- package/gsd-core/bin/lib/capability-loader.cjs +135 -1
- package/gsd-core/bin/lib/capability-registry.cjs +79 -67
- package/gsd-core/bin/lib/capability-source.cjs +19 -2
- package/gsd-core/bin/lib/capability-validator.cjs +14 -1
- package/gsd-core/bin/lib/check-command-router.cjs +113 -36
- package/gsd-core/bin/lib/code-review-depth.cjs +2 -2
- package/gsd-core/bin/lib/commands.cjs +650 -72
- package/gsd-core/bin/lib/config-loader.cjs +1 -0
- package/gsd-core/bin/lib/config.cjs +153 -38
- package/gsd-core/bin/lib/coverage.cjs +1 -1
- package/gsd-core/bin/lib/decisions.cjs +137 -34
- package/gsd-core/bin/lib/external-descriptor-trust.cjs +29 -14
- package/gsd-core/bin/lib/gsd2-import.cjs +1 -2
- package/gsd-core/bin/lib/health-diagnostic-rules/state-consistency.cjs +12 -1
- package/gsd-core/bin/lib/health-diagnostic-rules/worktree-health.cjs +1 -1
- package/gsd-core/bin/lib/init.cjs +409 -47
- package/gsd-core/bin/lib/install-engine.cjs +16 -3
- package/gsd-core/bin/lib/install-profiles.cjs +14 -0
- package/gsd-core/bin/lib/installer-migrations.cjs +33 -4
- package/gsd-core/bin/lib/loop-resolver.cjs +50 -31
- package/gsd-core/bin/lib/mcp-catalog.cjs +2 -2
- package/gsd-core/bin/lib/milestone.cjs +19 -8
- package/gsd-core/bin/lib/model-resolver.cjs +101 -10
- package/gsd-core/bin/lib/phase-command-router.cjs +7 -1
- package/gsd-core/bin/lib/phase-id.cjs +161 -22
- package/gsd-core/bin/lib/phase-lifecycle.cjs +61 -0
- package/gsd-core/bin/lib/phase.cjs +167 -63
- package/gsd-core/bin/lib/planning-inspect.cjs +34 -18
- package/gsd-core/bin/lib/planning-snapshot.cjs +61 -12
- package/gsd-core/bin/lib/planning-workspace.cjs +50 -1
- package/gsd-core/bin/lib/pristine-baseline.cjs +182 -0
- package/gsd-core/bin/lib/prohibition-enforcement.cjs +91 -4
- package/gsd-core/bin/lib/quick-batch.cjs +1 -1
- package/gsd-core/bin/lib/refactor-trigger-command-router.cjs +61 -2
- package/gsd-core/bin/lib/research-store.cjs +11 -12
- package/gsd-core/bin/lib/review-lane-invocation.cjs +23 -0
- package/gsd-core/bin/lib/reviewer-step-dispatch.cjs +337 -0
- package/gsd-core/bin/lib/roadmap-parser.cjs +56 -15
- package/gsd-core/bin/lib/roadmap.cjs +108 -14
- package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +27 -10
- package/gsd-core/bin/lib/runtime-artifact-install-plan.cjs +12 -3
- package/gsd-core/bin/lib/runtime-artifact-layout.cjs +13 -5
- package/gsd-core/bin/lib/runtime-hooks-surface.cjs +193 -4
- package/gsd-core/bin/lib/security.cjs +126 -7
- package/gsd-core/bin/lib/state-document.cjs +130 -28
- package/gsd-core/bin/lib/state-md-schema.cjs +21 -14
- package/gsd-core/bin/lib/state-transition.cjs +142 -28
- package/gsd-core/bin/lib/state.cjs +223 -27
- package/gsd-core/bin/lib/surface.cjs +60 -2
- package/gsd-core/bin/lib/task-command-router.cjs +12 -6
- package/gsd-core/bin/lib/uat.cjs +1 -1
- package/gsd-core/bin/lib/update-context.cjs +30 -24
- package/gsd-core/bin/lib/vendor/js-yaml.cjs +11 -3
- package/gsd-core/bin/lib/verification.cjs +47 -15
- package/gsd-core/bin/lib/verify-command-grounding.cjs +1 -1
- package/gsd-core/bin/lib/verify.cjs +188 -23
- package/gsd-core/bin/lib/workstream-inventory.cjs +1 -0
- package/gsd-core/bin/lib/worktree-safety.cjs +13 -7
- package/gsd-core/bin/shared/config-defaults.manifest.json +1 -0
- package/gsd-core/bin/shared/config-schema.manifest.json +5 -0
- package/gsd-core/bin/verify-reapply-patches.cjs +439 -80
- package/gsd-core/references/compact-content-gate.md +66 -0
- package/gsd-core/references/loop-hook-dispatch.md +18 -0
- package/gsd-core/references/model-profiles.md +12 -3
- package/gsd-core/references/planning-config.md +3 -0
- package/gsd-core/references/tdd.md +5 -2
- package/gsd-core/references/thinking-models-planning.md +18 -2
- package/gsd-core/references/verification-patterns.md +17 -4
- package/gsd-core/references/worktree-path-safety.md +112 -2
- package/gsd-core/templates/README.md +7 -1
- package/gsd-core/templates/state.md +6 -3
- package/gsd-core/templates/summary.compact.md +212 -0
- package/gsd-core/templates/user-setup.compact.md +199 -0
- package/gsd-core/templates/user-setup.md +0 -9
- package/gsd-core/workflows/add-todo.md +3 -2
- package/gsd-core/workflows/autonomous.md +13 -10
- package/gsd-core/workflows/check-todos.md +4 -2
- package/gsd-core/workflows/cleanup.md +3 -1
- package/gsd-core/workflows/code-review/steps/structural-pre-pass.md +7 -0
- package/gsd-core/workflows/code-review-fix.md +3 -3
- package/gsd-core/workflows/code-review.md +156 -30
- package/gsd-core/workflows/complete-milestone/detail/elaboration.md +274 -0
- package/gsd-core/workflows/complete-milestone.md +39 -262
- package/gsd-core/workflows/docs-update/detail/elaboration.md +179 -0
- package/gsd-core/workflows/docs-update.md +14 -155
- package/gsd-core/workflows/execute-phase/detail/elaboration.md +124 -0
- package/gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md +18 -3
- package/gsd-core/workflows/execute-phase/steps/completion-reconciliation.md +56 -0
- package/gsd-core/workflows/execute-phase/steps/executor-isolation-dispatch.md +7 -2
- package/gsd-core/workflows/execute-phase/steps/executor-progress-policy.md +43 -0
- package/gsd-core/workflows/execute-phase/steps/sequential-root-pin.md +35 -0
- package/gsd-core/workflows/execute-phase.md +53 -152
- package/gsd-core/workflows/execute-plan.md +20 -7
- package/gsd-core/workflows/help/modes/full.compact.md +398 -0
- package/gsd-core/workflows/help.md +1 -1
- package/gsd-core/workflows/map-codebase.md +50 -3
- package/gsd-core/workflows/new-milestone.md +54 -12
- package/gsd-core/workflows/new-project/detail/elaboration.md +216 -0
- package/gsd-core/workflows/new-project.md +32 -202
- package/gsd-core/workflows/plan-phase/detail/elaboration.md +209 -0
- package/gsd-core/workflows/plan-phase.md +22 -181
- package/gsd-core/workflows/pr-branch.md +19 -7
- package/gsd-core/workflows/quick.md +8 -1
- package/gsd-core/workflows/reapply-patches.md +77 -3
- package/gsd-core/workflows/settings.md +18 -5
- package/gsd-core/workflows/update.md +7 -5
- package/gsd-core/workflows/verify-work/detail/elaboration.md +230 -0
- package/gsd-core/workflows/verify-work.md +20 -180
- package/hooks/dist/gsd-agent-isolation-guard.js +42 -16
- package/hooks/dist/gsd-context-monitor.js +88 -15
- package/hooks/dist/gsd-cursor-subagent-start.js +34 -14
- package/hooks/dist/gsd-secret-read-guard.js +44 -18
- package/hooks/dist/gsd-statusline.js +11 -7
- package/hooks/dist/gsd-validate-commit.sh +34 -4
- package/hooks/dist/gsd-worktree-path-guard.js +25 -14
- package/hooks/dist/gsd-write-guard.js +46 -1
- package/hooks/dist/lib/dispatch-identity.js +187 -0
- package/hooks/dist/lib/filename-classification.js +64 -0
- package/hooks/dist/lib/isolation-deny-reason.js +53 -1
- package/hooks/dist/lib/isolation-sentinel.js +58 -19
- package/hooks/gsd-agent-isolation-guard.js +42 -16
- package/hooks/gsd-context-monitor.js +88 -15
- package/hooks/gsd-cursor-subagent-start.js +34 -14
- package/hooks/gsd-secret-read-guard.js +44 -18
- package/hooks/gsd-statusline.js +11 -7
- package/hooks/gsd-validate-commit.sh +34 -4
- package/hooks/gsd-worktree-path-guard.js +25 -14
- package/hooks/gsd-write-guard.js +46 -1
- package/hooks/lib/dispatch-identity.js +187 -0
- package/hooks/lib/filename-classification.js +64 -0
- package/hooks/lib/isolation-deny-reason.js +53 -1
- package/hooks/lib/isolation-sentinel.js +58 -19
- package/package.json +10 -6
- package/scripts/benchmark-compact-content-variants.cjs +298 -0
- package/scripts/benchmark-compact-content.cjs +368 -0
- package/scripts/check-contract-drift.cjs +4 -1
- package/scripts/check-env.cjs +36 -8
- package/scripts/check-glossary-refs.cjs +25 -21
- package/scripts/ci-next-health.cjs +271 -0
- package/scripts/ci-prepare-test-scope.cjs +7 -7
- package/scripts/ci-test-scope.cjs +126 -20
- package/scripts/ci-timeout-report.cjs +1 -1
- package/scripts/diff-touches-shipped-paths.cjs +1 -1
- package/scripts/docs-guard-registry.cjs +7 -2
- package/scripts/gen-adr-index.cjs +8 -2
- package/scripts/gen-inventory-manifest.cjs +12 -0
- package/scripts/gen-platform-conformance-tier.cjs +557 -0
- package/scripts/lib/drift-scan.cjs +1 -1
- package/scripts/lib/macos-conformance-tier.generated.cjs +210 -0
- package/scripts/lib/npm-version-check-diagnosis.cjs +59 -0
- package/scripts/lib/platform-conformance-tier.generated.cjs +276 -0
- package/scripts/lib/suite-detection.cjs +32 -0
- package/scripts/lint-allowed-tools-parity.cjs +221 -0
- package/scripts/lint-docs-guard-registration.exempt-baseline.cjs +19 -2
- package/scripts/lint-phase-id-drift.cjs +338 -13
- package/scripts/lint-response-language-coverage.cjs +9 -3
- package/scripts/lint-source-test-name-collision.cjs +1 -1
- package/scripts/lint-test-file-count.allowlist.json +1 -0
- package/scripts/lint-vendored-deps.cjs +128 -17
- package/scripts/lint-workflow-shellcheck-baseline.json +85 -0
- package/scripts/prompt-injection-scan.sh +14 -0
- package/scripts/workflow-size.cjs +139 -0
- package/skills/gsd-cleanup/SKILL.md +1 -0
- package/skills/gsd-code-review/SKILL.md +2 -1
- package/skills/gsd-complete-milestone/SKILL.md +1 -0
- package/skills/gsd-config/SKILL.md +1 -0
- package/skills/gsd-debug/SKILL.md +1 -0
- package/skills/gsd-graphify/SKILL.md +1 -0
- package/skills/gsd-health/SKILL.md +1 -0
- package/skills/gsd-mempalace-capture/SKILL.md +1 -0
- package/skills/gsd-mempalace-recall/SKILL.md +1 -0
- package/skills/gsd-new-milestone/SKILL.md +1 -0
- package/skills/gsd-new-project/SKILL.md +1 -0
- package/skills/gsd-next/SKILL.md +1 -0
- package/skills/gsd-pause-work/SKILL.md +1 -0
- package/skills/gsd-phase/SKILL.md +1 -0
- package/skills/gsd-pr-branch/SKILL.md +1 -0
- package/skills/gsd-resume-work/SKILL.md +1 -0
- package/skills/gsd-review-backlog/SKILL.md +1 -0
- package/skills/gsd-settings/SKILL.md +2 -1
- package/skills/gsd-stats/SKILL.md +1 -0
- package/skills/gsd-thread/SKILL.md +1 -0
- package/skills/gsd-workspace/SKILL.md +1 -0
- package/skills/gsd-workstreams/SKILL.md +1 -0
- package/vscode/package.json +1 -1
- package/gsd-core/templates/claude-md.md +0 -145
- package/gsd-core/templates/codebase/concerns.md +0 -310
- package/gsd-core/templates/codebase/conventions.md +0 -307
- package/gsd-core/templates/codebase/integrations.md +0 -280
- package/gsd-core/templates/codebase/structure.md +0 -285
- package/gsd-core/templates/codebase/testing.md +0 -480
- package/gsd-core/templates/debug-subagent-prompt.md +0 -91
- package/gsd-core/templates/discovery.md +0 -146
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generates scripts/lib/platform-conformance-tier.generated.cjs — the list of
|
|
6
|
+
* test files under tests/**\/*.test.cjs whose CONTENT signals they exercise
|
|
7
|
+
* platform-specific behavior (Windows/macOS path quirks, raw child_process
|
|
8
|
+
* usage, chmod mode bits, etc.) and therefore need REAL-OS coverage rather
|
|
9
|
+
* than a Linux-only conformance lane (#4591).
|
|
10
|
+
*
|
|
11
|
+
* Only `unit`-suite test files (no suite suffix, per `scripts/run-tests.cjs`'s
|
|
12
|
+
* `suiteOf()`) are considered for the conformance tier. `install`-,
|
|
13
|
+
* `security`-, `slow`-, `integration`-, and `qa`-suffixed files are excluded
|
|
14
|
+
* entirely — never merely deprioritized — for three independent reasons: (1)
|
|
15
|
+
* `install`/`slow` are explicitly PR-excluded suites
|
|
16
|
+
* (`scripts/affected-tests-lib.cjs`'s `PR_EXCLUDED_SUITES`; "PRs must never
|
|
17
|
+
* select or run these"), and this generator's output feeds a `pull_request`-
|
|
18
|
+
* triggered job; (2) `integration`/`security` already run via their own
|
|
19
|
+
* separate, dedicated, unsharded, shard-1-only steps in the `test` job
|
|
20
|
+
* (.github/workflows/test.yml) — folding any of them into
|
|
21
|
+
* this job's generic `--files-from` + `--shard` invocation is unproven and,
|
|
22
|
+
* per the incident below, unsafe. (3) `qa` (loop-walk-suite files) already
|
|
23
|
+
* runs via its own separate, dedicated `qa-loop-walk` job
|
|
24
|
+
* (.github/workflows/test.yml) — the same rationale as (2): a purpose-built
|
|
25
|
+
* home already exists, so folding it into this job's generic invocation
|
|
26
|
+
* duplicates coverage without benefit. Real incident that surfaced this: a live
|
|
27
|
+
* CI run's `conformance test (windows-latest, shard 2/3)` job was killed with
|
|
28
|
+
* 11 tests in flight — including `tests/release-tarball-smoke.install.test.cjs`
|
|
29
|
+
* — because this generator had (wrongly) placed an `install`-suite file into
|
|
30
|
+
* the Linux-conformance candidate pool with no suite filtering at all.
|
|
31
|
+
*
|
|
32
|
+
* `classifyContent(content)` is the pure, exported classifier: it favors
|
|
33
|
+
* simple, auditable substring/regex matching over AST parsing, mirroring
|
|
34
|
+
* eslint-rules/lib/portability-vocab.cjs's own design stance (over-inclusion
|
|
35
|
+
* is the safe direction — a false positive costs one extra test running on a
|
|
36
|
+
* real OS; a false negative silently drops real-OS coverage).
|
|
37
|
+
*
|
|
38
|
+
* That stance is a correct per-file tiebreak, but proved wrong in aggregate
|
|
39
|
+
* (#4641): applied to two categories that matched the house test idiom
|
|
40
|
+
* rather than a genuine platform signal, it produced a Windows "tier" of
|
|
41
|
+
* 547 of 931 eligible unit-suite files (58.8%, measured 2026-09-11) — most
|
|
42
|
+
* of the suite. Measured per-category UNIQUE (sole-signal, i.e. the file
|
|
43
|
+
* would have been excluded without it) contribution as of that same
|
|
44
|
+
* measurement: `process-seam-subprocess` 118 files, `hardcoded-path-vs-
|
|
45
|
+
* path-call` 108 files, every other category 41 files COMBINED. Both were
|
|
46
|
+
* removed outright from CATEGORIES; the same-tree, same-day recount put
|
|
47
|
+
* the tier at 255 of 931 (27.4%) — exactly 292 entries removed from the
|
|
48
|
+
* committed list, none added. The macOS tier was unaffected by this change
|
|
49
|
+
* (a diff of macos-conformance-tier.generated.cjs across the same removal
|
|
50
|
+
* showed zero changed lines). None of these counts is asserted as a
|
|
51
|
+
* literal anywhere in the test suite: the ceilings this generator enforces
|
|
52
|
+
* are ratios against a live denominator (the current eligible-file count),
|
|
53
|
+
* and the committed lists are pinned by comparing against a fresh
|
|
54
|
+
* classification of the live tree, not against a hardcoded number —
|
|
55
|
+
* deliberately, since a hardcoded count in a test is a failure scheduled
|
|
56
|
+
* for the next time the suite grows. See
|
|
57
|
+
* docs/adr/4641-windows-selector-consolidation.md for the full rationale.
|
|
58
|
+
*
|
|
59
|
+
* KNOWN LIMIT, disclosed deliberately: this is a STATIC content classifier,
|
|
60
|
+
* not a real per-file, per-OS behavioral diff. Epic #4589's issue #4591 asked
|
|
61
|
+
* for the cutover to be validated by "running the existing full matrix one
|
|
62
|
+
* more time as a parity baseline, diffing pass/fail per file between the
|
|
63
|
+
* real-OS runs and the Linux run" before moving any file into the Linux-only
|
|
64
|
+
* bulk. That literal per-file diff was NOT performed — no historical
|
|
65
|
+
* per-file, per-OS pass/fail dataset exists to diff against (GitHub Actions
|
|
66
|
+
* publishes coverage/QA artifacts from CI runs, not per-file JUnit results).
|
|
67
|
+
* What stands in for it: (1) the most recent push-triggered run on `next`
|
|
68
|
+
* (unconditionally full-matrix) is green on every OS for every file in this
|
|
69
|
+
* classification, confirmed before this classifier was built; (2) the
|
|
70
|
+
* legacy full-matrix job ran the WHOLE suite on real Windows/macOS as a
|
|
71
|
+
* non-gating safety net for one release cycle (.github/workflows/test.yml)
|
|
72
|
+
* before it was retired (#4603) — a classifier miss during that cycle would
|
|
73
|
+
* have surfaced as a visible warning there, not a silent gap. This is the same
|
|
74
|
+
* static-analysis-substitutes-for-real-OS-execution stance ADR-1703's whole
|
|
75
|
+
* rule catalog already takes; it is a real, disclosed limit, not a silent
|
|
76
|
+
* substitution.
|
|
77
|
+
*
|
|
78
|
+
* Usage:
|
|
79
|
+
* node scripts/gen-platform-conformance-tier.cjs # print summary to stdout
|
|
80
|
+
* node scripts/gen-platform-conformance-tier.cjs --write # write the generated file
|
|
81
|
+
* node scripts/gen-platform-conformance-tier.cjs --check # exit 1 if the committed file is stale
|
|
82
|
+
* node scripts/gen-platform-conformance-tier.cjs --target macos ... # same three modes, macOS-specific list (#4593)
|
|
83
|
+
* node scripts/gen-platform-conformance-tier.cjs --tests-dir <path> # override the tests/ root (tests only)
|
|
84
|
+
* node scripts/gen-platform-conformance-tier.cjs --out <path> # override the generated-file path (tests only)
|
|
85
|
+
*
|
|
86
|
+
* `--target` selects which of the two independent generated outputs this
|
|
87
|
+
* invocation targets: `windows` (default, the original #4591 behavior —
|
|
88
|
+
* omitting the flag is unchanged) or `macos` (#4593's narrower, macOS-
|
|
89
|
+
* specific list). Both write into the SAME committed-file conventions
|
|
90
|
+
* (`scripts/lib/platform-conformance-tier.generated.cjs` /
|
|
91
|
+
* `scripts/lib/macos-conformance-tier.generated.cjs`), so `package.json`'s
|
|
92
|
+
* `lint:generated-sync`/`regen:derived` chains invoke this script twice, once
|
|
93
|
+
* per target, rather than needing a second script file.
|
|
94
|
+
*
|
|
95
|
+
* `--tests-dir`/`--out` (or the TESTS_DIR/OUT_PATH env vars, flag takes
|
|
96
|
+
* precedence) exist solely so tests/platform-conformance-tier.test.cjs can
|
|
97
|
+
* point the CLI at a small temp fixture tree instead of this repo's real,
|
|
98
|
+
* 900+-file tests/ tree. Production usage (package.json's lint:generated-sync
|
|
99
|
+
* / regen:derived chains) passes no flags and gets the real repo paths.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
const fs = require('node:fs');
|
|
103
|
+
const path = require('node:path');
|
|
104
|
+
|
|
105
|
+
const { ExitError, runMain } = require('./lib/cli-exit.cjs');
|
|
106
|
+
const { suiteOf } = require('./lib/suite-detection.cjs');
|
|
107
|
+
|
|
108
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
109
|
+
const DEFAULT_TESTS_DIR = path.join(ROOT, 'tests');
|
|
110
|
+
const DEFAULT_OUT_PATH = path.join(ROOT, 'scripts', 'lib', 'platform-conformance-tier.generated.cjs');
|
|
111
|
+
const DEFAULT_MACOS_OUT_PATH = path.join(ROOT, 'scripts', 'lib', 'macos-conformance-tier.generated.cjs');
|
|
112
|
+
|
|
113
|
+
const GENERATED_HEADER =
|
|
114
|
+
'// GENERATED FILE — do not hand-edit. Run `node scripts/gen-platform-conformance-tier.cjs --write` to regenerate.\n';
|
|
115
|
+
|
|
116
|
+
const MACOS_GENERATED_HEADER =
|
|
117
|
+
'// GENERATED FILE — do not hand-edit. Run `node scripts/gen-platform-conformance-tier.cjs --target macos --write` to regenerate.\n' +
|
|
118
|
+
'// macOS-specific conformance tier (#4593), separate from and narrower than the general/\n' +
|
|
119
|
+
'// Windows-oriented tier in platform-conformance-tier.generated.cjs — see\n' +
|
|
120
|
+
'// docs/adr/4593-macos-conformance-tier-architecture.md for the full rationale.\n';
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Detection categories (#4591 design doc). Each entry's `test` receives the
|
|
124
|
+
* raw file content string and returns true when that category's signal is
|
|
125
|
+
* present. Order matches the design doc's enumeration; `signals` in
|
|
126
|
+
* `classifyContent`'s return value preserves this order.
|
|
127
|
+
*/
|
|
128
|
+
const CATEGORIES = [
|
|
129
|
+
{
|
|
130
|
+
name: 'process-platform',
|
|
131
|
+
test: (content) => /process\.platform/.test(content),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'os-platform',
|
|
135
|
+
test: (content) => /os\.platform\(\)/.test(content),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'win32-darwin-literal',
|
|
139
|
+
test: (content) => /\bwin32\b/.test(content) || /\bdarwin\b/.test(content),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'chmod-mode-bit',
|
|
143
|
+
test: (content) => /chmodSync|chmod\(/.test(content) || /0o[0-7]{3,4}\b/.test(content),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'windows-shell-token',
|
|
147
|
+
test: (content) => /cmd\.exe|powershell|pwsh|ComSpec/i.test(content),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'windows-env-var',
|
|
151
|
+
test: (content) => /\bPATHEXT\b|\bUSERPROFILE\b|\bHOMEDRIVE\b|\bHOMEPATH\b/.test(content),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'raw-child-process',
|
|
155
|
+
// Requires BOTH the child_process import/reference token AND one of the
|
|
156
|
+
// three call names in the same file — this is what keeps a same-named
|
|
157
|
+
// local identifier (e.g. a variable called `spawnResult`) from false-
|
|
158
|
+
// positiving: `spawnResult` never forms the substring `spawnSync(`.
|
|
159
|
+
test: (content) => {
|
|
160
|
+
if (/require\((['"])(?:node:)?child_process\1\)/.test(content)) return true;
|
|
161
|
+
if (!content.includes('child_process')) return false;
|
|
162
|
+
return /\bspawnSync\(|\bexecSync\(|\bexecFileSync\(/.test(content);
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'shell-interpreter-spawn',
|
|
167
|
+
// Added after an adversarial review (#4641) caught a REAL false negative
|
|
168
|
+
// introduced by removing 'process-seam-subprocess' above: that removal
|
|
169
|
+
// also dropped the only coverage for tests/execute-phase-worktree-guard.
|
|
170
|
+
// test.cjs, which calls tests/helpers/process-seam.cjs's `runHook(...,
|
|
171
|
+
// { interpreter: 'bash', ... })`. `runHook` spawns `options.interpreter`
|
|
172
|
+
// via a real `spawnSync`, so `interpreter: 'bash'` is a genuine real-shell
|
|
173
|
+
// invocation — bash availability, quoting, and git output parsing all
|
|
174
|
+
// differ across OSes. This is deliberately narrower than (and does not
|
|
175
|
+
// reintroduce) 'process-seam-subprocess': the rationale that going
|
|
176
|
+
// through the injected-`platform`-parameter seam in
|
|
177
|
+
// src/shell-command-projection.cts is NOT a platform signal (because the
|
|
178
|
+
// caller supplies `platform` itself) holds for THAT seam only — it does
|
|
179
|
+
// not hold for `runHook`'s `interpreter` option, which spawns a real
|
|
180
|
+
// interpreter binary rather than taking platform as injected data.
|
|
181
|
+
// Measured 2026-09-11: 33 eligible files match this pattern; 9 of them
|
|
182
|
+
// were outside the committed Windows tier and are added back by this
|
|
183
|
+
// change, taking the tier from 255 to 264 of 931 eligible files (27.4% ->
|
|
184
|
+
// 28.4%), still under the 33% ceiling. All 9 additions were verified by
|
|
185
|
+
// reading the matching source line: 0 false positives, every match is a
|
|
186
|
+
// live `interpreter:` option on a real `runHook`/`runHookSeam` call. As
|
|
187
|
+
// with all counts in this file, these are dated point-in-time
|
|
188
|
+
// measurements, not standing facts.
|
|
189
|
+
test: (content) => /interpreter:\s*['"`](bash|sh|zsh|dash|pwsh|powershell|cmd)['"`]/.test(content),
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'symlink-keyword',
|
|
193
|
+
// A leading `\b` with no trailing one, case-insensitive: this is
|
|
194
|
+
// deliberately NOT `/\bsymlink\b|\bSymlink\b/` (that literal pair would
|
|
195
|
+
// never match the dominant real-world call shape `symlinkSync(` /
|
|
196
|
+
// `readlinkSync(` — no word boundary exists between "symlink" and the
|
|
197
|
+
// immediately-following "Sync", both \w characters). The leading `\b`
|
|
198
|
+
// alone still excludes a mid-word embedding like "presymlink".
|
|
199
|
+
test: (content) => /\bsymlink/i.test(content),
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
|
|
203
|
+
// A CATEGORIES entry precise enough for TEST-file classification (this
|
|
204
|
+
// module's own purpose) but too broad for SOURCE-file reachability
|
|
205
|
+
// (scripts/ci-test-scope.cjs's #4592 use). This set used to hold a second
|
|
206
|
+
// member, 'hardcoded-path-vs-path-call', alongside 'symlink-keyword'; that
|
|
207
|
+
// category was removed outright from CATEGORIES (#4641 — measured to be the
|
|
208
|
+
// single largest driver of Windows-tier over-inclusion, a universal Node
|
|
209
|
+
// test-suite idiom rather than a platform signal), not merely exempted here,
|
|
210
|
+
// because it was over-broad for BOTH consumers (this module's own Windows
|
|
211
|
+
// tier AND source reachability), not source-reachability alone. Only
|
|
212
|
+
// 'symlink-keyword' remains: still precise enough for test-file
|
|
213
|
+
// classification but, per the same empirical pass described above, too noisy
|
|
214
|
+
// for source reachability.
|
|
215
|
+
const NOISY_FOR_SOURCE_REACHABILITY = new Set(['symlink-keyword']);
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Escape hatch, WINDOWS TIER ONLY (union'd into `classifyTree`, never into
|
|
219
|
+
* `classifyMacosTree`/`MACOS_CATEGORIES` — those stay untouched by this map).
|
|
220
|
+
*
|
|
221
|
+
* `classifyContent` above is a STATIC CONTENT classifier: it can only see
|
|
222
|
+
* text in the test file itself. Some files need real-OS coverage for a
|
|
223
|
+
* reason that lives in the CODE UNDER TEST, not in the test's own text — no
|
|
224
|
+
* regex over the test file can ever detect that, because the signal simply
|
|
225
|
+
* isn't there to find. Rather than chase that gap with ever-more-specific
|
|
226
|
+
* content heuristics (the exact failure mode #4641 measured and rolled
|
|
227
|
+
* back — see the header comment above), this map is the single, centrally-
|
|
228
|
+
* enumerated source of truth for those cases, matching ADR-1703's
|
|
229
|
+
* `portability-vocab.cjs` stance and epic #4589 Phase 2's explicit
|
|
230
|
+
* requirement that such overrides be "centrally-enumerated, not a naming
|
|
231
|
+
* convention". It is deliberately NOT a heuristic: it is a `Map` (path ->
|
|
232
|
+
* reason) precisely so every entry is forced to carry a recorded,
|
|
233
|
+
* human-reviewed reason at the call site — an entry without one is
|
|
234
|
+
* impossible by construction (there is no positional/array form that would
|
|
235
|
+
* let a path be added without a paired reason string).
|
|
236
|
+
*
|
|
237
|
+
* Adding an entry requires a recorded reason and should be rare: prefer
|
|
238
|
+
* fixing the classifier (a new CATEGORIES signal) when the real-OS need IS
|
|
239
|
+
* expressible as content; reach for this map only when it structurally is
|
|
240
|
+
* not.
|
|
241
|
+
*
|
|
242
|
+
* Current entries:
|
|
243
|
+
* - tests/external-descriptor-confinement.test.cjs: exercises `isPathConfined`
|
|
244
|
+
* (src/external-descriptor-trust.cts:41-49), which calls the AMBIENT
|
|
245
|
+
* `path` module directly — `path.resolve(root, target)` and `path.sep` —
|
|
246
|
+
* with no platform/path injection seam. Its win32 semantics (drive
|
|
247
|
+
* letters, UNC paths, `\` separator) are therefore only reachable by
|
|
248
|
+
* actually running on Windows; the win32 branch is unreachable on Linux.
|
|
249
|
+
* This is a security-relevant write-confinement gate, so a silent gap
|
|
250
|
+
* here is a security regression, not a coverage nit (#4641).
|
|
251
|
+
*/
|
|
252
|
+
const ALWAYS_REAL_OS = new Map([
|
|
253
|
+
[
|
|
254
|
+
'tests/external-descriptor-confinement.test.cjs',
|
|
255
|
+
'Exercises isPathConfined (src/external-descriptor-trust.cts:41-49), which uses the ambient ' +
|
|
256
|
+
'path module (path.resolve/path.sep) with no platform injection; its win32 branch (drive ' +
|
|
257
|
+
'letters, UNC paths, \\ separator) is unreachable on Linux. Security-relevant write-confinement gate.',
|
|
258
|
+
],
|
|
259
|
+
]);
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* macOS-specific detection categories (#4593, design doc
|
|
263
|
+
* .gsd/phase/chore-4593-macos-conformance-tier/40-design.md). Built new,
|
|
264
|
+
* rather than reusing CATEGORIES above minus its Windows-specific entries,
|
|
265
|
+
* because that naive exclusion barely narrows anything (measured: 546 -> 424
|
|
266
|
+
* files, 78%) — most files match multiple general-tier signals simultaneously
|
|
267
|
+
* and only need ONE surviving signal to stay in. `chmod-mode-bit` and
|
|
268
|
+
* `symlink-keyword` ARE deliberately duplicated verbatim from CATEGORIES:
|
|
269
|
+
* both are genuinely Unix-relevant (chmod bits and symlink semantics differ
|
|
270
|
+
* materially on macOS), not Windows-motivated the way the rest of CATEGORIES
|
|
271
|
+
* is. A standalone CRLF/`autocrlf` signal was considered and rejected: even
|
|
272
|
+
* narrowed to `/\bCRLF\b|autocrlf/i` it still hit 143/930 files (15%) — CRLF
|
|
273
|
+
* is primarily a Windows checkout concern in this codebase (ADR-1703's
|
|
274
|
+
* `no-crlf-fragile-split` files it under DEFECT.WINDOWS-TEST-PORTABILITY),
|
|
275
|
+
* so a CRLF signal pulls in Windows-relevant files already covered by the
|
|
276
|
+
* general tier, not a macOS-narrowing one.
|
|
277
|
+
*/
|
|
278
|
+
const MACOS_CATEGORIES = [
|
|
279
|
+
{ name: 'darwin-literal', test: (content) => /\bdarwin\b/.test(content) },
|
|
280
|
+
{ name: 'zsh-dispatch', test: (content) => /\bzsh\b/i.test(content) },
|
|
281
|
+
{ name: 'case-sensitivity', test: (content) => /case.?insensitiv|case.?sensitiv/i.test(content) },
|
|
282
|
+
{ name: 'chmod-mode-bit', test: (content) => /chmodSync|chmod\(/.test(content) || /0o[0-7]{3,4}\b/.test(content) },
|
|
283
|
+
{ name: 'symlink-keyword', test: (content) => /\bsymlink/i.test(content) },
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Pure classifier: given a test file's raw string content, returns which
|
|
288
|
+
* platform-conformance categories matched and whether the file needs real-OS
|
|
289
|
+
* coverage (true iff at least one category matched).
|
|
290
|
+
*
|
|
291
|
+
* @param {string} content
|
|
292
|
+
* @returns {{needsRealOs: boolean, signals: string[]}}
|
|
293
|
+
*/
|
|
294
|
+
function classifyContent(content) {
|
|
295
|
+
const text = typeof content === 'string' ? content : '';
|
|
296
|
+
const signals = [];
|
|
297
|
+
for (const category of CATEGORIES) {
|
|
298
|
+
if (category.test(text)) signals.push(category.name);
|
|
299
|
+
}
|
|
300
|
+
return { needsRealOs: signals.length > 0, signals };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Pure classifier, macOS-specific signal set (#4593). Same shape as
|
|
305
|
+
* classifyContent, against MACOS_CATEGORIES instead of CATEGORIES.
|
|
306
|
+
*
|
|
307
|
+
* @param {string} content
|
|
308
|
+
* @returns {{needsRealOs: boolean, signals: string[]}}
|
|
309
|
+
*/
|
|
310
|
+
function classifyMacosContent(content) {
|
|
311
|
+
const text = typeof content === 'string' ? content : '';
|
|
312
|
+
const signals = [];
|
|
313
|
+
for (const category of MACOS_CATEGORIES) {
|
|
314
|
+
if (category.test(text)) signals.push(category.name);
|
|
315
|
+
}
|
|
316
|
+
return { needsRealOs: signals.length > 0, signals };
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Recursively collect every `*.test.cjs` file beneath `dir`.
|
|
321
|
+
* @param {string} dir
|
|
322
|
+
* @returns {string[]} absolute paths
|
|
323
|
+
*/
|
|
324
|
+
function walkTestFiles(dir) {
|
|
325
|
+
const out = [];
|
|
326
|
+
let entries;
|
|
327
|
+
try {
|
|
328
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
329
|
+
} catch {
|
|
330
|
+
return out;
|
|
331
|
+
}
|
|
332
|
+
for (const entry of entries) {
|
|
333
|
+
const full = path.join(dir, entry.name);
|
|
334
|
+
if (entry.isDirectory()) {
|
|
335
|
+
out.push(...walkTestFiles(full));
|
|
336
|
+
} else if (entry.isFile() && entry.name.endsWith('.test.cjs')) {
|
|
337
|
+
out.push(full);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return out;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Classify every test file under `testsDir`, returning `{ total, files }`
|
|
345
|
+
* where `files` is the SORTED array of `tests/<...>.test.cjs`-relative paths
|
|
346
|
+
* (POSIX-normalized, per RULESET.CONTENT-PATH-NORMALIZATION) whose content
|
|
347
|
+
* needs real-OS coverage.
|
|
348
|
+
*
|
|
349
|
+
* @param {string} testsDir
|
|
350
|
+
* @returns {{ total: number, files: string[] }}
|
|
351
|
+
*/
|
|
352
|
+
function classifyTree(testsDir) {
|
|
353
|
+
const absoluteFiles = walkTestFiles(testsDir);
|
|
354
|
+
// Only unit-suite files (no suite suffix) are eligible for the conformance
|
|
355
|
+
// tier — see the header doc-comment for why suite-tagged files are excluded
|
|
356
|
+
// entirely rather than merely deprioritized.
|
|
357
|
+
const unitFiles = absoluteFiles.filter((absPath) => suiteOf(absPath) === null);
|
|
358
|
+
const flagged = [];
|
|
359
|
+
for (const absPath of unitFiles) {
|
|
360
|
+
const rel = 'tests/' + path.relative(testsDir, absPath).replace(/\\/g, '/');
|
|
361
|
+
const content = fs.readFileSync(absPath, 'utf8');
|
|
362
|
+
const { needsRealOs } = classifyContent(content);
|
|
363
|
+
// The ALWAYS_REAL_OS escape hatch (Windows tier only — see its doc
|
|
364
|
+
// comment) is unioned in HERE, keyed off a file that this walk actually
|
|
365
|
+
// found, rather than blindly appended regardless of `testsDir` — that
|
|
366
|
+
// keeps the escape hatch from leaking a real-repo path into an unrelated
|
|
367
|
+
// temp-fixture-tree classification (e.g. this module's own tests).
|
|
368
|
+
if (needsRealOs || ALWAYS_REAL_OS.has(rel)) {
|
|
369
|
+
flagged.push(rel);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
const result = [...new Set(flagged)].sort();
|
|
373
|
+
return { total: absoluteFiles.length, files: result };
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Same walk/eligibility as classifyTree, classified with the macOS-specific
|
|
378
|
+
* signal set (#4593).
|
|
379
|
+
*
|
|
380
|
+
* @param {string} testsDir
|
|
381
|
+
* @returns {{ total: number, files: string[] }}
|
|
382
|
+
*/
|
|
383
|
+
function classifyMacosTree(testsDir) {
|
|
384
|
+
const absoluteFiles = walkTestFiles(testsDir);
|
|
385
|
+
const unitFiles = absoluteFiles.filter((absPath) => suiteOf(absPath) === null);
|
|
386
|
+
const flagged = [];
|
|
387
|
+
for (const absPath of unitFiles) {
|
|
388
|
+
const content = fs.readFileSync(absPath, 'utf8');
|
|
389
|
+
const { needsRealOs } = classifyMacosContent(content);
|
|
390
|
+
if (needsRealOs) {
|
|
391
|
+
const rel = path.relative(testsDir, absPath).replace(/\\/g, '/');
|
|
392
|
+
flagged.push('tests/' + rel);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
flagged.sort();
|
|
396
|
+
return { total: absoluteFiles.length, files: flagged };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Render the generated `.cjs` module body — one array entry per line for a
|
|
401
|
+
* readable diff, matching scripts/lib/portability-vocab.cjs's array-literal
|
|
402
|
+
* style.
|
|
403
|
+
*
|
|
404
|
+
* @param {string[]} files - already sorted.
|
|
405
|
+
* @returns {string}
|
|
406
|
+
*/
|
|
407
|
+
function renderGeneratedFile(files) {
|
|
408
|
+
const lines = files.map((f) => ` ${JSON.stringify(f)},`).join('\n');
|
|
409
|
+
return (
|
|
410
|
+
GENERATED_HEADER +
|
|
411
|
+
"'use strict';\n\n" +
|
|
412
|
+
'module.exports = {\n' +
|
|
413
|
+
' CONFORMANCE_TIER_FILES: [\n' +
|
|
414
|
+
(lines.length > 0 ? lines + '\n' : '') +
|
|
415
|
+
' ],\n' +
|
|
416
|
+
'};\n'
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Render scripts/lib/macos-conformance-tier.generated.cjs's module body,
|
|
422
|
+
* mirroring renderGeneratedFile exactly against the macOS export name.
|
|
423
|
+
*
|
|
424
|
+
* @param {string[]} files - already sorted.
|
|
425
|
+
* @returns {string}
|
|
426
|
+
*/
|
|
427
|
+
function renderMacosGeneratedFile(files) {
|
|
428
|
+
const lines = files.map((f) => ` ${JSON.stringify(f)},`).join('\n');
|
|
429
|
+
return (
|
|
430
|
+
MACOS_GENERATED_HEADER +
|
|
431
|
+
"'use strict';\n\n" +
|
|
432
|
+
'module.exports = {\n' +
|
|
433
|
+
' MACOS_CONFORMANCE_TIER_FILES: [\n' +
|
|
434
|
+
(lines.length > 0 ? lines + '\n' : '') +
|
|
435
|
+
' ],\n' +
|
|
436
|
+
'};\n'
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Resolve the effective target/tests-dir/out-path from argv/env, flag beats env. */
|
|
441
|
+
function resolveOverrides(argv) {
|
|
442
|
+
let target = 'windows';
|
|
443
|
+
for (let i = 0; i < argv.length; i++) {
|
|
444
|
+
if (argv[i] === '--target') {
|
|
445
|
+
const value = argv[i + 1];
|
|
446
|
+
if (value !== 'windows' && value !== 'macos') {
|
|
447
|
+
throw new ExitError(1, 'gen-platform-conformance-tier: --target requires "windows" or "macos"');
|
|
448
|
+
}
|
|
449
|
+
target = value;
|
|
450
|
+
i++;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const defaultOutPath = target === 'macos' ? DEFAULT_MACOS_OUT_PATH : DEFAULT_OUT_PATH;
|
|
455
|
+
let testsDir = process.env.TESTS_DIR || DEFAULT_TESTS_DIR;
|
|
456
|
+
let outPath = process.env.OUT_PATH || defaultOutPath;
|
|
457
|
+
|
|
458
|
+
for (let i = 0; i < argv.length; i++) {
|
|
459
|
+
if (argv[i] === '--tests-dir') {
|
|
460
|
+
const value = argv[i + 1];
|
|
461
|
+
if (!value || value.startsWith('--')) {
|
|
462
|
+
throw new ExitError(1, 'gen-platform-conformance-tier: --tests-dir requires a path value');
|
|
463
|
+
}
|
|
464
|
+
testsDir = path.resolve(value);
|
|
465
|
+
i++;
|
|
466
|
+
} else if (argv[i] === '--out') {
|
|
467
|
+
const value = argv[i + 1];
|
|
468
|
+
if (!value || value.startsWith('--')) {
|
|
469
|
+
throw new ExitError(1, 'gen-platform-conformance-tier: --out requires a path value');
|
|
470
|
+
}
|
|
471
|
+
outPath = path.resolve(value);
|
|
472
|
+
i++;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return { target, testsDir: path.resolve(testsDir), outPath: path.resolve(outPath) };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function main() {
|
|
480
|
+
const argv = process.argv.slice(2);
|
|
481
|
+
const { target, testsDir, outPath } = resolveOverrides(argv);
|
|
482
|
+
const mode = argv.includes('--check') ? 'check' : argv.includes('--write') ? 'write' : 'print';
|
|
483
|
+
|
|
484
|
+
const isMacos = target === 'macos';
|
|
485
|
+
const label = isMacos ? 'gen-platform-conformance-tier --target macos' : 'gen-platform-conformance-tier';
|
|
486
|
+
const exportKey = isMacos ? 'MACOS_CONFORMANCE_TIER_FILES' : 'CONFORMANCE_TIER_FILES';
|
|
487
|
+
const { total, files } = isMacos ? classifyMacosTree(testsDir) : classifyTree(testsDir);
|
|
488
|
+
|
|
489
|
+
if (mode === 'write') {
|
|
490
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
491
|
+
fs.writeFileSync(outPath, isMacos ? renderMacosGeneratedFile(files) : renderGeneratedFile(files));
|
|
492
|
+
process.stdout.write(`Wrote ${outPath} (${files.length} conformance-tier file(s))\n`);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (mode === 'check') {
|
|
497
|
+
// Never trust a stale require cache — the committed file may have been
|
|
498
|
+
// rewritten (by --write, or by hand) since this process started.
|
|
499
|
+
let committed;
|
|
500
|
+
try {
|
|
501
|
+
const resolved = require.resolve(outPath);
|
|
502
|
+
delete require.cache[resolved];
|
|
503
|
+
committed = require(resolved);
|
|
504
|
+
} catch (err) {
|
|
505
|
+
throw new ExitError(
|
|
506
|
+
1,
|
|
507
|
+
`${label}: could not load ${outPath} — run ` +
|
|
508
|
+
`\`node scripts/gen-platform-conformance-tier.cjs${isMacos ? ' --target macos' : ''} --write\` first ` +
|
|
509
|
+
`(${err && err.message ? err.message : err})`,
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
const committedFiles = Array.isArray(committed[exportKey]) ? committed[exportKey] : [];
|
|
513
|
+
const committedSet = new Set(committedFiles);
|
|
514
|
+
const liveSet = new Set(files);
|
|
515
|
+
|
|
516
|
+
const added = files.filter((f) => !committedSet.has(f));
|
|
517
|
+
const removed = committedFiles.filter((f) => !liveSet.has(f));
|
|
518
|
+
|
|
519
|
+
if (added.length > 0 || removed.length > 0) {
|
|
520
|
+
process.stderr.write(
|
|
521
|
+
`${path.relative(ROOT, outPath).replace(/\\/g, '/')} is stale. Run:\n` +
|
|
522
|
+
` node scripts/gen-platform-conformance-tier.cjs${isMacos ? ' --target macos' : ''} --write\n\n`,
|
|
523
|
+
);
|
|
524
|
+
for (const f of added) process.stderr.write(' + ' + f + '\n');
|
|
525
|
+
for (const f of removed) process.stderr.write(' - ' + f + '\n');
|
|
526
|
+
throw new ExitError(1);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
process.stdout.write(`ok ${label}: ${files.length} conformance-tier files, list matches\n`);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// No flag: print a classification summary, write nothing.
|
|
534
|
+
process.stdout.write(
|
|
535
|
+
`${label}: ${total} file(s) scanned, ` +
|
|
536
|
+
`${files.length} need real OS, ${total - files.length} excluded (Linux-only conformance tier eligible)\n`,
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/* c8 ignore next 3 -- CLI entry guard; this repo measures coverage with c8, which does not honor istanbul pragmas */
|
|
541
|
+
if (require.main === module) {
|
|
542
|
+
runMain(main);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
module.exports = {
|
|
546
|
+
classifyContent,
|
|
547
|
+
CATEGORIES,
|
|
548
|
+
NOISY_FOR_SOURCE_REACHABILITY,
|
|
549
|
+
ALWAYS_REAL_OS,
|
|
550
|
+
walkTestFiles,
|
|
551
|
+
classifyTree,
|
|
552
|
+
renderGeneratedFile,
|
|
553
|
+
classifyMacosContent,
|
|
554
|
+
MACOS_CATEGORIES,
|
|
555
|
+
classifyMacosTree,
|
|
556
|
+
renderMacosGeneratedFile,
|
|
557
|
+
};
|
|
@@ -162,7 +162,7 @@ function readRegexLiteralAt(line, start) {
|
|
|
162
162
|
// root + separator — a plain `startsWith(root)` would also accept a sibling
|
|
163
163
|
// directory whose name merely starts with the root's name (`/repo-evil`).
|
|
164
164
|
function isInsideRoot(realPath, realRoot) {
|
|
165
|
-
return realPath === realRoot || realPath.startsWith(realRoot + path.sep);
|
|
165
|
+
return realPath === realRoot || realPath.startsWith(realRoot + path.sep); // allow-handrolled-containment: lint:ci guard; runs before build:lib, compiled security.cjs may not exist
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// True when `realPath` (already confirmed inside `realRoot` by `isInsideRoot`)
|