Skip to content

ci: move the inline job checks into scripts/ and record measured budgets - #2262

Merged
eric8810 merged 3 commits into
mainfrom
dim/2258-ci-scripts
Nov 27, 2026
Merged

eric8810 merged 3 commits into
mainfrom
dim/2258-ci-scripts

Conversation

@eric8810

Copy link
Copy Markdown
Collaborator

Summary

ci.yml mixed wiring with programs. This PR moves the programs out and leaves the wiring, and corrects the two gate budgets that said they had never been measured (#2258).

  • scripts/ci-windows-target.ps1 — the Windows target directory, its toolchain/profile stamp and the 12 GiB budget. Extracted verbatim from ci.yml; the step keeps CACHE_STAMP and calls the script.
  • scripts/ci-windows-native-tools.ps1 — the pinned portable CMake/NASM provisioning. Extracted verbatim; the step keeps the version and SHA variables.
  • scripts/ci-web-check.ps1 — the Web staging, third-party-notice and generated-declaration check. Extracted verbatim.
  • scripts/ci-test-concurrency.mjs (+ test) — the workspace test plan: DIM_TEST_JOBS = clamp(physical/3, 3, 8), --test-threads = clamp(physical/4, 2, 6), macOS at 3/3. It replaces 25 lines of bash between the build and the test run, and the job reads it from a step output.
  • ci-changes.mjs gains platforms(event), so the job matrix reads fromJSON(needs.changes.outputs.platforms) instead of a boolean chain over github.event_name. It is exported and unit-tested beside classify.
  • docs/architecture/build.md now records what the runs measured: verify (linux) 8m12s–14m18s on four recent runs (the six older ones were 18m17s–30m49s), and windows-cli 2.2–6.8 minutes for the whole job with the native-flows step at 1.1–4.4 minutes across 25 sampled runs.

The three PowerShell bodies were extracted byte for byte (checked against HEAD), so the only new risk is the call line. .github/workflows/ci.yml selects every group, so this PR runs the Windows, Web, macOS and Linux jobs that call them.

Not moved: the Python standalone provisioning (ci.yml, gated by DIM_CI_PYTHON_PLUGINS), which needs a run against the network on Linux and macOS before its extraction can be called verified. It is the one item left on #2258.

Design rule checklist

  • Scope: n/a — CI scripts, no part or lifecycle.
  • Commands and results: n/a.
  • Handover: n/a.
  • Timeline before callbacks: n/a.
  • Infrastructure (Timeline, Dispatcher, event envelope, assembly and lifecycle, Session and branch facades): unchanged.
  • Core mechanisms and consumers gain no plugin-specific handling: n/a.
  • Batch: n/a.
  • Context: n/a.
  • No reading another plugin's internal state or deciding for it: n/a.
  • Cross-language faces: n/a.
  • Business configuration stays out of loader rows; contracts are language-neutral: n/a.
  • Missing mechanism capabilities: none.
  • Timeline holds only facts later decisions use: n/a.

Documentation

  • docs/architecture/build.md budgets match measured runs, with run ids beside them.
  • No accepted ADR is modified or deleted.
  • No other module's design is changed.
  • No delivery status is added to an ADR, index or roadmap.

Verification

  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/ci.yml'))" — valid.
  • node --test scripts/*.test.mjs — 167 tests, 165 passed, 2 skipped.
  • node scripts/ci-test-concurrency.mjs — jobs=5, threads=4 on this 32-CPU/16-core host, matching the bash formula it replaces.
  • The three PowerShell files are byte-identical to the blocks removed from HEAD.
  • Windows and Web job behaviour is verified by this PR's own CI run, which selects every group because it changes the workflow file.

Refs #2258

Three job checks lived as 68 lines of PowerShell inside `ci.yml`: the Windows
target directory and its 12 GiB budget, the portable CMake/NASM provisioning,
and the Web staging check. Each is a script under `scripts/`, called by one
line with the logic unchanged (#2258).

The workspace test concurrency is `scripts/ci-test-concurrency.mjs` with unit
tests instead of 25 lines of bash, and the platforms a full verification runs
on come from `ci-changes.mjs` (`platforms`), so the job matrix no longer
evaluates a chain of string-truthy conditions.

`docs/architecture/build.md` records what the runs measured: `verify (linux)`
8m12s–14m18s on recent runs, and `windows-cli` 2.2–6.8 minutes for the whole
job with the native-flows step at 1.1–4.4 minutes, which retires the two
"not measured yet" notes.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR moves the three inline PowerShell checks and the workspace test-concurrency math into scripts/, takes the verify matrix from a new platforms(event) output, and records measured budgets in docs/architecture/build.md. The three PowerShell bodies are byte-identical to the removed YAML, the new call lines ran in this PR's Windows and Web jobs, the platforms output matches the old boolean chain for every event class, and the four verify run ids resolve to the cited durations within 3 seconds.

P2: the windows-cli budget row still says the native flows were never measured

Problem: docs/architecture/build.md:335 still records native flows: not yet measured, while the paragraph added at docs/architecture/build.md:352 records the native-flows step at 1.1 to 4.4 minutes across 25 sampled runs. The commit message says it retires both "not measured yet" notes, but this row is unchanged.

Failure scenario: a maintainer reads the budget table to judge the windows-cli gate and concludes the native flows have no measurement, so a regression toward the 15-minute timeout has no recorded baseline; the document contradicts itself in the section this PR is meant to correct.

Evidence: docs/architecture/build.md:335, docs/architecture/build.md:352.

Fix: update the row's budget cell to the measured range, for example native flows: 1.1 to 4.4 min across 25 runs; p90 pending, or state the intended budget and its basis.

P3: edits to an extracted PowerShell script no longer run the job that executes it

Problem: the removed bodies lived in .github/workflows/ci.yml, which matches no classifier rule and therefore selects every group. The new files match ^scripts/ (scripts/ci-changes.mjs:51), which selects only the Linux scripts group, and the web and windows-cli jobs are gated on web and windows. A PR that edits only scripts/ci-web-check.ps1, scripts/ci-windows-target.ps1 or scripts/ci-windows-native-tools.ps1 therefore runs none of the jobs that execute it.

Failure scenario: a quoting, path or exit-code fix in scripts/ci-windows-target.ps1 merges after a green PR that never ran it on Windows. The merge push currently catches it because main pushes still select every group, but the PR gate gives no signal and the guard depends on the staged all-groups push behavior.

Evidence: scripts/ci-changes.mjs:51, .github/workflows/ci.yml:125, .github/workflows/ci.yml:144, .github/workflows/ci.yml:164.

Fix: classify the moved scripts for their consumers, for example ['scripts','web'] for ci-web-check.ps1, ['scripts','windows'] for ci-windows-target.ps1, and a windows_native selection for ci-windows-native-tools.ps1, or record the limitation.

P3: the concurrency tests never reach the upper clamps

Problem: scripts/ci-test-concurrency.test.mjs exercises the lower clamps (3 jobs, 2 threads) and macOS, but no case reaches 8 jobs or 6 threads.

Failure scenario: a later edit that changes the caps from 8 to 7 or from 6 to 5 passes every test and silently reduces parallelism on large runners.

Evidence: scripts/ci-test-concurrency.test.mjs:5-17.

Fix: add a case such as assert.deepEqual(plan('linux', 64, 32, 64), {jobs: 8, threads: 6}); (SMT 2, physical 32).

Optional: the verify budget is looser than the runs it cites

Problem: docs/architecture/build.md:337 records at most 30 minutes while the four post-change runs are 8m12s to 14m18s, the 15-minute target it replaces would still fit them, and the paragraph at line 340 says p90 is not recorded. The cited 30m49s run belongs to the pre-settings set, so the cell combines a budget with a measurement above it.

Failure scenario: a regression from about 14 minutes to 28 minutes stays inside the recorded budget and is not treated as a regression under the rule below the table.

Evidence: docs/architecture/build.md:337, docs/architecture/build.md:340.

Fix: keep the 15-minute target now that four runs fit it, or state why 30 minutes is the budget and label it as a target rather than a p90.

Verdict: REQUEST_CHANGES for the stale windows-cli row; the other items are P3 or optional.

The [Web workspace](../design/web-workspace.md) frontend in `web/` is a separate artifact (`scripts/stage-web.mjs` builds it; the CLI finds the installed `dimcode-web` package or a `web/` directory beside the executable or in the product home, or `DIMCODE_WEB_ASSETS` names one), so building `dim-app-server` and `dimcode` needs neither Node nor npm. Only `cargo build --features embedded-web` compiles the frontend in; then `build.rs` runs `npm ci` and `npm run build` when that frontend changed, and a host without npm fails the build. Otherwise Node is only needed for packaging, packaging checks and TypeScript plugin execution/development. `.node-version` pins the Node version bundled into account-enabled releases. The `runtime/package-lock.json` fixes the rutis Node runtime and its transitive dependencies; `npm ci --ignore-scripts --prefix runtime` installs them for local bridge testing.

Pull requests run workspace verification on self-hosted Linux x64 runners labelled `dim-verify`, with eight Cargo build jobs. The job checks that bubblewrap can create the sandbox the confined tests use (a user namespace with a private `/proc`) before running them. The macOS ARM64 runners use four Cargo jobs for the native Rust checks on pull requests and for full workspace verification on `main`. Use `node scripts/test-macos-native.mjs --list` to inspect the Rust selection from the current Cargo targets, Rust platform guards and host-specific test fixtures. On an Apple Silicon Mac, run `node scripts/test-macos-native.mjs` to build those targets and check each selected name against its compiled test binary before execution. Tests marked for manual execution keep their normal ignore status. The [workflow guide](../release/README.md#github-workflows) describes path selection, native packaging checks and manual dispatch. The separate `windows-cli` job runs the `dim-cli` library tests on a self-hosted Windows x64 runner, where its fixture writes to the clipboard. When a pull request changes Windows storage, host-platform, named-pipe or worktree-removal paths, when a push to `main` changes a path that selects the job, and on scheduled sweeps and manual dispatch, the same job also builds and runs the Windows-only boundary flows (`file_storage_flow`'s Windows checks, `host_platform_windows_flow`, `named_pipe_flow` and `worktree_removal_flow`) in that directory; `node scripts/test-windows-native.mjs --list` prints the selection and a run checks every selected name against its compiled test binary. The job keeps its fifteen-minute hard timeout, and the first cold compile of the `dim-app-server` graph that the step adds may not fit it; no run has measured that yet and it cannot be reproduced locally. The layout workflow uses hosted `windows-2022` and `windows-11-arm` runners, with Python 3.13 and the pinned native MSVC Rust host toolchain provisioned explicitly. Release builds use GitHub-hosted VMs matching each target OS and CPU. See the [runner setup and release matrix](../release/README.md#runner-setup).
Pull requests run workspace verification on self-hosted Linux x64 runners labelled `dim-verify`, with eight Cargo build jobs. The job checks that bubblewrap can create the sandbox the confined tests use (a user namespace with a private `/proc`) before running them. The macOS ARM64 runners use four Cargo jobs for the native Rust checks on pull requests and for full workspace verification on `main`. Use `node scripts/test-macos-native.mjs --list` to inspect the Rust selection from the current Cargo targets, Rust platform guards and host-specific test fixtures. On an Apple Silicon Mac, run `node scripts/test-macos-native.mjs` to build those targets and check each selected name against its compiled test binary before execution. Tests marked for manual execution keep their normal ignore status. The [workflow guide](../release/README.md#github-workflows) describes path selection, native packaging checks and manual dispatch. The separate `windows-cli` job runs the `dim-cli` library tests on a self-hosted Windows x64 runner, where its fixture writes to the clipboard. When a pull request changes Windows storage, host-platform, named-pipe or worktree-removal paths, when a push to `main` changes a path that selects the job, and on scheduled sweeps and manual dispatch, the same job also builds and runs the Windows-only boundary flows (`file_storage_flow`'s Windows checks, `host_platform_windows_flow`, `named_pipe_flow` and `worktree_removal_flow`) in that directory; `node scripts/test-windows-native.mjs --list` prints the selection and a run checks every selected name against its compiled test binary. The job keeps its fifteen-minute hard timeout. Across 25 sampled runs the whole job took 2.2–6.8 minutes and the native-flows step 1.1–4.4 minutes, so the compile that the step adds fits the budget. The layout workflow uses hosted `windows-2022` and `windows-11-arm` runners, with Python 3.13 and the pinned native MSVC Rust host toolchain provisioned explicitly. Release builds use GitHub-hosted VMs matching each target OS and CPU. See the [runner setup and release matrix](../release/README.md#runner-setup).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The windows-cli row at docs/architecture/build.md:335 still says native flows: not yet measured, while this paragraph records 1.1 to 4.4 minutes across 25 runs. The budget table now contradicts the measurement it cites, so a reader cannot tell which is the recorded value. Fix: update the row to the measured range, for example native flows: 1.1 to 4.4 min across 25 runs; p90 pending, or state the intended budget and its basis.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed in 54579d5.

Comment thread .github/workflows/ci.yml
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
Set-Content -LiteralPath $stampFile -Value $env:CACHE_STAMP -NoNewline
"CARGO_TARGET_DIR=$targetDir" >> $env:GITHUB_ENV
run: '& "$env:GITHUB_WORKSPACE\scripts\ci-windows-target.ps1"'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Moving this body to scripts/ changes which PRs exercise it. The old location in ci.yml selected every check group; scripts/ci-windows-target.ps1 now matches only the scripts rule (scripts/ci-changes.mjs:51), so a PR that edits only this file runs the Linux scripts job and skips windows-cli. Fix: add classifier rules for the moved scripts, for example ['scripts','windows'] here, ['scripts','web'] for ci-web-check.ps1, and a windows_native selection for ci-windows-native-tools.ps1, or record the gap.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed in 54579d5.


test('the plan holds the macOS settings on other platforms', () => {
assert.deepEqual(plan('darwin', 32, 16, 32), {jobs: 3, threads: 3});
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The tests cover the lower clamps (3 jobs, 2 threads) and macOS, but no case reaches the upper clamps (8 jobs, 6 threads), so a change from 8 to 7 or from 6 to 5 would pass. Fix: add assert.deepEqual(plan('linux', 64, 32, 64), {jobs: 8, threads: 6}); (SMT 2, physical 32).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed in 54579d5.

Review follow-up on #2262. `scripts/ci-web-check.ps1`,
`scripts/ci-windows-target.ps1` and `scripts/ci-windows-native-tools.ps1`
used to live in `ci.yml`, which matches no rule and selects every group. The
classifier gave them only `scripts`, so a pull request editing one of them
never ran the Windows or Web job that executes it. Each now selects its
consumers, with a test case.

The `windows-cli` budget row records the native flows at 1.1–4.4 minutes
across 25 runs instead of "not yet measured", and the `verify (linux)` row
returns to its fifteen-minute target with the four post-change runs beside it,
so a run between 15 and 30 minutes is a regression again.

The concurrency test reaches the upper clamps: 64 CPUs over 32 cores gives
8 jobs and 6 threads.
@eric8810

Copy link
Copy Markdown
Collaborator Author

All three in 54579d5.

  • P2 (stale windows-cli row) — the budget cell now reads native flows: 1.1–4.4 min across 25 runs, p90 pending, so the table and the paragraph agree.
  • P3 (moved scripts lost their consumers) — classifier rules added: ci-web-check.ps1 → ['scripts','web'], ci-windows-target.ps1 → ['scripts','windows'], ci-windows-native-tools.ps1 → ['scripts','windows','windows_native'], each with a test case.
  • P3 (clamps unreached) — plan('linux', 64, 32, 64) now asserts {jobs: 8, threads: 6}.
  • Optional (verify budget looser than its runs) — back to ≤ 15 min target with the four post-change runs (8m12s–14m18s) beside it and p90 still stated as pending, so 15–30 minutes is a regression again.

node --test scripts/*.test.mjs — 166 passed, 2 skipped; the workflow still parses.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All findings from my previous review are fixed or addressed at 54579d5.

Withdrawn:

  • P2, docs/architecture/build.md:335: the windows-cli row now reads native flows: 1.1 to 4.4 min across 25 runs, p90 pending, consistent with the paragraph at docs/architecture/build.md:352. No row in this section still says the native flows are unmeasured; the code-layout row's Not yet recorded is outside this change.
  • P3, .github/workflows/ci.yml:125: scripts/ci-changes.mjs:49-51 now selects ['scripts','web'] for ci-web-check.ps1, ['scripts','windows'] for ci-windows-target.ps1, and ['scripts','windows','windows_native'] for ci-windows-native-tools.ps1. These match the gates at .github/workflows/ci.yml:106, :137 and :152. The test at scripts/ci-changes.test.mjs:233-241 pins each selection, and a direct classify call on each script returns those groups.
  • P3, scripts/ci-test-concurrency.test.mjs:8: the added plan('linux', 64, 32, 64) case reaches both upper clamps, 8 jobs and 6 threads with SMT 2 and 32 physical cores.
  • Optional, docs/architecture/build.md:337: the verify row keeps the 15-minute target, records the four post-change runs at 8m12s to 14m18s, and states that p90 is pending. The four run ids at docs/architecture/build.md:340 resolve to those durations within 3 seconds.

No remaining P0-P2 findings. I reran node --test scripts/ci-changes.test.mjs scripts/ci-test-concurrency.test.mjs (17 pass), rechecked the three extracted PowerShell bodies against the removed YAML (unchanged), and confirmed the platforms output matches the old matrix expression for pull request, push, schedule and manual dispatch. At this head the extracted scripts ran in the windows-cli and web jobs and both passed. CI at this head: changes, dependencies, static-checks, windows-cli, web, scripts and macos-native pass; verify (linux) was still running when I checked.

APPROVE

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The PowerShell jobs now select their moved scripts, and the corrected budget row and upper-clamp assertions look good. One coverage regression remains for the extracted concurrency helper. A PR changing only scripts/ci-test-concurrency.mjs selects the scripts group, not the workspace verify job. The focused tests import plan() without exercising the CLI step's jobs and threads outputs, so an output regression can pass ci-ok and surface only when main runs the workflow. Acceptance: a helper-only PR exercises the output handoff to the workspace test runner, and missing or invalid output fails the PR gate. The original Goal timeout is separate and not attributed here.

A pull request touching only `scripts/ci-test-concurrency.mjs` selected the
`scripts` group, so the `verify` step that runs the helper and hands its
outputs to the test runner never executed. It now selects `rust` too.

The helper's command line gains a test: the step writes exactly `jobs=` and
`threads=`, their values stay inside the ranges the planner can produce, so a
missing or malformed output fails the scripts job instead of surfacing on
`main` (zerob13's review on #2262).
@eric8810

Copy link
Copy Markdown
Collaborator Author

Both in 9e9061d:

  • the helper now selects ['rust','scripts'], so a PR that changes scripts/ci-test-concurrency.mjs runs the verify step that executes it and hands jobs/threads to run-rust-test.mjs; a classifier test pins the selection;
  • a new test runs the command and asserts it writes exactly jobs= and threads= with values in the planner's ranges, so a missing or malformed output fails the scripts job.

node --test scripts/*.test.mjs — 167 passed, 2 skipped.

The failed verify (linux) on the previous head is unrelated: context_flow::product_summary::compaction_chunks_images_as_markers_and_legacy_screenshots_as_text panicked with Storage(\"unknown session …\"), and the Windows/Web jobs this PR touches were green.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR moves the three inline PowerShell checks and the workspace test concurrency math into scripts/, takes the verify matrix from a new platforms(event) output, and records measured budgets in docs/architecture/build.md.

The coverage point from the previous change request is fixed at 9e9061d:

  • scripts/ci-changes.mjs:49 maps scripts/ci-test-concurrency.mjs to ['rust','scripts'], so a helper-only PR selects the verify job (.github/workflows/ci.yml:203), and Derive test concurrency (.github/workflows/ci.yml:259-263) feeds steps.concurrency.outputs.jobs and steps.concurrency.outputs.threads into Run compiled workspace tests (.github/workflows/ci.yml:271-272). A direct classify(['scripts/ci-test-concurrency.mjs']) returns rust and scripts; scripts/ci-changes.test.mjs:234-238 pins it, and the test fails when I remove the rule.
  • Missing or invalid output fails the gate. scripts/run-rust-test.mjs:14-15 asserts that DIM_TEST_JOBS is a positive integer; empty and non-numeric values exit 1 locally. An empty or non-numeric threads reaches libtest as --test-threads= or --test-threads=abc, which exits 101, so the step fails. A helper failure fails the step under set -e.
  • The focused test now exercises the CLI, not only plan(): scripts/ci-test-concurrency.test.mjs:21-34 spawns scripts/ci-test-concurrency.mjs and requires exactly jobs= and threads= with numeric values. It fails when I rename the jobs output.

My earlier points remain fixed and nothing is reinstated: the windows-cli budget row at docs/architecture/build.md:335 agrees with the paragraph at :352, the moved PowerShell scripts select their consumer jobs (scripts/ci-changes.mjs:50-52), and the upper-clamp case is at scripts/ci-test-concurrency.test.mjs:9.

Remaining, optional:
P3, scripts/ci-test-concurrency.test.mjs:30-33. Problem: the CLI test checks the output names and value ranges, not that the values equal plan() for this host. Failure scenario: a helper that calls plan('darwin', ...) on every platform, or prints fixed values, passes the test; Linux verify then runs at the macOS settings and no gate catches it. Evidence: scripts/ci-test-concurrency.test.mjs:30-33, scripts/ci-test-concurrency.mjs:25-30. Fix: compare the printed values with plan(process.platform, availableParallelism(), ...) using the same topology inputs, or record the limitation.

Verification: node --test scripts/ci-changes.test.mjs scripts/ci-test-concurrency.test.mjs passes 18. At this head changes, dependencies, static-checks, windows-cli, web, scripts, macos-native, verify (linux) and ci-ok pass; verify (linux) took 16m37s and its log shows Workspace tests: DIM_TEST_JOBS=3 --test-threads=2, so the real step consumed non-empty outputs. No conflicts with origin/main 7880f6e or the open PRs #2249, #2255, #2263, #2264 and #1881; none of them touch .github/workflows/ci.yml, scripts/ci-* or docs/architecture/build.md.

APPROVE

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The remaining finding is resolved. I verified with an isolated helper-only diff that the classifier selects Linux verify and scripts, and that the CLI-facing assertions reject missing, malformed, empty, and out-of-range outputs. Exact-head CI consumed the helper's values in the workspace test runner; Linux and ci-ok passed. No remaining blockers.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants