Skip to content

Derive CI planner gate test inputs from package.json scripts - #4479

Open
Rangsh wants to merge 5 commits into
apache:mainfrom
Rangsh:issue-4473-derive-planner-test-inputs-from-gate-scripts
Open

Rangsh wants to merge 5 commits into
apache:mainfrom
Rangsh:issue-4473-derive-planner-test-inputs-from-gate-scripts

Conversation

@Rangsh

@Rangsh Rangsh commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Derive CI planner gate test inputs from package.json scripts

Stop hand-maintaining scripts/*.test.mjs paths in RELEASE_CONTRACT_FILES and ASF_SOURCE_FILES. The planner now reads check:release and check:asf-source (including nested npm run delegations) and treats each named test file as an input to that gate's lane.

Summary

Whether a scripts/*.test.mjs file runs, and whether a change to it schedules the lane that runs it, were previously written in three places: the test file itself, an npm gate script (check:release, check:asf-source) or a CI step, and a literal path list in scripts/ci-test-plan.mjs. Missing the third meant the gate still ran the test, but editing the test alone did not select the lane — so the test could be changed green without CI exercising it.

This PR makes the planner derive those test-file inputs from package.json instead:

  • loadGateTestFiles() reads check:release and check:asf-source
  • collectGateScriptTestFiles() extracts every scripts/*.test.mjs path from each gate script's command text
  • Nested npm run invocations are followed recursively (e.g. check:release → check:asf-npm → scripts/asf-npm-workflow-policy.test.mjs)
  • isReleaseContractPath() and isAsfSourcePath() union the derived sets with the remaining static authority paths

Thirteen hand-written .test.mjs entries are removed from RELEASE_CONTRACT_FILES and ASF_SOURCE_FILES. Static non-test authority paths (workflows, generators, manifests) stay listed as before.

Out of scope (per issue): the ~11 test files named directly in .github/workflows/ci.yml node --test steps are unchanged — most run unconditionally and need no lane selection. App icon drift tests remain driven by the workflow step, not an npm gate script.

Fixes #4473

Verification

node --test scripts/ci-test-plan.test.mjs

Result: 32/32 tests passed.

Spot checks:

node -e "import { planTests } from './scripts/ci-test-plan.mjs'; const p = planTests(['scripts/desktop-nightly-workflow-policy.test.mjs']); console.log(p);"
# releaseContract: true (previously missed by the static list)

node -e "import { planTests } from './scripts/ci-test-plan.mjs'; const p = planTests(['scripts/source-legal-inventory.test.mjs']); console.log(p);"
# releaseContract: true, asfSource: true (shared across both gates)

Not run locally: full npm ci, check:release, check:asf-source, or workflow-policy suites. The change is confined to the install-free planner and its unit tests, which run before npm ci in CI.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope:

Cursor (Auto) — implemented loadGateTestFiles / collectGateScriptTestFiles, removed duplicated static test paths, and updated ci-test-plan.test.mjs guardrails.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Behavior change: editing any scripts/*.test.mjs named by check:release or check:asf-source (including via nested npm run) now selects release_contract or asf_source in the CI test plan. Previously, several release-gate tests (e.g. desktop-nightly-workflow-policy.test.mjs, release-cli-* tests reachable only via derivation) did not select their lane when edited alone. The planner's output now also depends on package.json script text, not only the static tables.

@me2seeks me2seeks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review notice: This comment was posted by an automated review agent operated by me2seeks make. It is not an independent human review and does not replace one.

Summary

Derives the CI planner's releaseContract/asfSource gate-lane test files from package.json scripts instead of a hardcoded list: collectGateScriptTestFiles recursively walks check:release and check:asf-source npm-script chains (npm run x references, cycle-guarded) collecting scripts/*.test.mjs inputs, and planTests merges those sets into the lane predicates. I executed the extraction against the PR head: it finds all 13 previously hardcoded files (zero missing) plus 14 more test files that previously did NOT select the lane (scripts/desktop-nightly*.test.mjs, scripts/release-cli-*.test.mjs, scripts/asf-npm-workflow-policy.test.mjs, etc.) — a strict superset, so no existing lane coverage is lost and genuine gaps are closed. The recursion is cycle-safe via visited.

Findings

  1. [P3] Only label ran on this head — ci-test-plan.test.mjs is the suite that guards this planner, and the planner selects CI lanes for every other PR, so the test lane must run green before merge.

Verdict

merge-ready — verified strict-superset derivation with cycle safety; request CI as housekeeping.

Stop hand-maintaining scripts/*.test.mjs paths in RELEASE_CONTRACT_FILES
and ASF_SOURCE_FILES. The planner now reads check:release and
check:asf-source (including nested npm run delegations) and treats each
named test file as an input to that gate's lane.
@Rangsh
Rangsh force-pushed the issue-4473-derive-planner-test-inputs-from-gate-scripts branch from 93d87ff to 3cf1edf Compare September 28, 2026 14:37
@Rangsh

Rangsh commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

Rebased onto current main to clear the merge conflict in scripts/ci-test-plan.mjs / scripts/ci-test-plan.test.mjs (kept main’s newer non-test authority paths such as .asf.yaml and scripts/workflow-pull-request-paths.mjs; gate scripts/*.test.mjs inputs stay derived from package.json).

node --test scripts/ci-test-plan.test.mjs → 42/42 locally. Requesting the required test lane as housekeeping — it is queued on this head.

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed commit 3cf1edf. The planner now derives release/asf gate-owned scripts/*.test.mjs inputs from the corresponding package.json scripts, including nested npm run calls, rather than maintaining a second static list (scripts/ci-test-plan.mjs:29-68,445-449,561-575). The existing static paths outside those test inputs remain.

I found no substantiated code defect in the changed logic. The 42 planner tests pass locally, and the derived sets include 26 release and 6 ASF test paths. Fresh main 71bc045 merges cleanly and git diff --check passes. However, current-head hosted test is FAILED: Biome rejects the formatting at scripts/ci-test-plan.mjs:574-575. Please fix that gate failure and re-run CI before merge; this review is not merge approval. I did not run the complete CI suite locally or verify future, differently-shaped npm script commands.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

@Rangsh

Rangsh commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@hqhq1025 Thanks for catching the Biome format failure.

Pushed 51a0ab0b8 to put the releaseContract assignment on one line in scripts/ci-test-plan.mjs so biome format is clean. Local biome format scripts/ci-test-plan.mjs passes; CI test should re-run on this head.

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change since the prior reviewed head is Biome formatting of the releaseContract assignment in scripts/ci-test-plan.mjs; the planner logic and test cases are unchanged. The PR still derives the release/ASF gate-test inputs from package scripts, and I found no actionable issue in the reviewed increment. On Node 24, all 42 focused planner tests pass. The current-head hosted test check passes, and the fresh-main merge-tree and diff check are clean. I did not run the complete local workspace suite or package a release. This is not merge approval.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

…e-scripts

Keep gate-script test-file derivation from this PR, take main's
shouldRunAstryxSurfaceInventory rename and Boolean astryx_surface output,
and re-pin compatible protocol declarations to epoch 202 for the merge.

Co-authored-by: Cursor <[email protected]>

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed b840fbe7fa15b325338d7e0dd208a90f0787ce1e (4 files, +98/−47; three commits, the last a merge of main).

1×P3, and no other P0–P3.

P3 — two protocol ledgers were re-dated without anything being re-validated. packages/runtime-host/protocol-compatible-changes/mechanical-candidate-sweep.json and turn-snapshot-optional-fields.json move "epoch": 200 → 202. Those files record the compatibility argument for a specific change, and their epoch is the protocol baseline that argument was made against. Here main still carries 200 in both files, and this PR does not touch RUNTIME_HOST_COMPATIBILITY_EPOCH at all — it reads 202 on main and on this branch alike. So the edit asserts that two unrelated compatibility arguments were re-validated through epoch 202, which this change neither does nor needs to do. It looks like incidental drift picked up while merging main and is better reverted; a CI-planner change has no business re-dating the protocol ledgers.

The planner change itself checks out, including the risk it carries. scripts/ci-test-plan.mjs now derives the release and ASF gate-test inputs from the package.json scripts instead of keeping a second static list: GATE_SCRIPT_LANES maps check:release → releaseContract and check:asf-source → asfSource, and collectGateScriptTestFiles follows nested npm run calls with a visited guard, so a script cycle cannot loop. The derived sets feed the planner at scripts/ci-test-plan.mjs:449 (options.gateTestFiles ?? loadGateTestFiles(...)), so the new module is genuinely wired rather than dead, and the test file drives both the derivation and the lane map.

The thing worth proving was that deleting the static entries loses no coverage, since that failure would be silent. I re-implemented the same derivation against this head's package.json and enumerated the seven scripts/*.test.mjs paths the diff removes:

  • audit-shipped-dependencies, prepare-windows-upgrade-baseline, generate-third-party-notices, product-release, qualify-released-cli-state-root, third-party-closure, verify-linux-harness

All seven are still produced by the derivation, which yields 26 release-lane and 6 ASF-lane test files. The deletions are therefore duplicates of what the scripts already reach, not coverage.

Gate on this head: test is green; the merge state is blocked, i.e. review still pending rather than a verdict.

What I could not judge

  • I did not run the planner's own test file or the release tooling; I verified the derivation's coverage by reproducing its logic independently against package.json.
  • No release packaging or hosted CI beyond the check above.

I did not approve, request changes, or merge.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

A CI planner change should not re-date unrelated compatible-change ledgers;
restore both files to main's epoch 200.

Co-authored-by: Cursor <[email protected]>

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Incremental re-review of exact head d4a06e02. The previous reviewed head was b840fbe7. The merge-base is unchanged (57964425), so the increment is exactly one commit, d4a06e022 ("Revert incidental epoch re-pin of protocol compatibility declarations"). The PR is now +96/-45 across 2 files.

Status of the previous finding

  • P3, two protocol ledgers re-dated from 200 to 202 without re-validation: fixed. packages/runtime-host/protocol-compatible-changes/mechanical-candidate-sweep.json and turn-snapshot-optional-fields.json are back to "epoch": 200, which matches main. The PR no longer touches anything under packages/.

Planner change unchanged. git diff 57964425 b840fbe7 -- scripts and git diff 57964425 d4a06e02 -- scripts are byte-identical, so the earlier analysis still holds. scripts/ci-test-plan.mjs derives the release and ASF gate-test inputs from the check:release / check:asf-source script graph, with a visited guard. The seven static entries it removes are all still produced by that derivation.

Main drift. Main is 22 commits past the merge-base. Neither scripts/ci-test-plan.mjs nor its test changed on main. The only package.json change is the new shots:storybook script, which is not reachable from either gate script and so does not affect the derived sets. I merged current main (7c90bac2) into this head locally, without conflicts, and ran node --test scripts/ci-test-plan.test.mjs: 42/42 pass.

New findings: none at P0-P3.

CI and merge state: test passes on this head. MERGEABLE; BLOCKED only on required review.

Verdict: the only open item from the last round is resolved, and there is nothing further.

@Rangsh

Rangsh commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you so much @Astro-Han for the careful re-review, and for verifying the merge against the latest main as well — really appreciated!

The incidental epoch re-pin has been reverted in d4a06e0, so the PR no longer touches anything under packages/, and the test check is green on this head.

Whenever a maintainer has a moment, I'd be grateful for a final look and approval. Thanks again to everyone for the helpful feedback!

@github-actions github-actions Bot added the stale No qualifying activity within the lifecycle policy window label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

This pull request has had no new commits for 30 days and has been marked stale. It will be closed in 7 days unless a new commit is pushed.

Comments do not reset this timer: only a new commit does. If the pull request is intentionally long-lived, a maintainer can apply the pinned label.

@github-actions github-actions Bot removed the stale No qualifying activity within the lifecycle policy window label Nov 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Derive the planner's test-file inputs from the gate scripts that run them

4 participants