diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e92720d97b..785e22b66e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: node: ${{ steps.groups.outputs.node }} eval: ${{ steps.groups.outputs.eval }} execution: ${{ steps.groups.outputs.execution }} + debug: ${{ steps.groups.outputs.debug }} web: ${{ steps.groups.outputs.web }} scripts: ${{ steps.groups.outputs.scripts }} macos_scripts: ${{ steps.groups.outputs.macos_scripts }} @@ -357,6 +358,19 @@ jobs: echo "Workspace tests: DIM_TEST_JOBS=$test_jobs --test-threads=$test_threads" DIM_TEST_JOBS="$test_jobs" node scripts/run-rust-test.mjs target/test-artifacts.jsonl --workspace "--test-threads=$test_threads" cargo test --workspace --doc --locked ${{ needs.changes.outputs.eval == 'true' && '--features xtask/eval-tests' || '' }} + - name: Verify debug-only CLI tests + if: needs.changes.outputs.debug == 'true' + shell: bash + env: + DIM_TEST_TIMEOUT_MS: "600000" + run: | + set -euo pipefail + cargo clippy --locked -p dimcode --all-targets --features dev-tests -- -D warnings + cargo build --locked -p dimcode --features dev-tests --test cli_daemon_flow --test cli_flow --message-format=json > target/debug-test-artifacts.jsonl + node scripts/run-rust-test.mjs target/debug-test-artifacts.jsonl cli_daemon_flow daemon_startup_progress --test-threads=2 + node scripts/run-rust-test.mjs target/debug-test-artifacts.jsonl cli_daemon_flow daemon_replace::build_identity --test-threads=2 + node scripts/run-rust-test.mjs target/debug-test-artifacts.jsonl cli_flow staged_update::recovery --test-threads=2 + node scripts/run-rust-test.mjs target/debug-test-artifacts.jsonl cli_flow staged_update::tui_update --test-threads=2 - name: Verify wall-clock background handoff if: needs.changes.outputs.execution == 'true' run: node scripts/run-rust-test.mjs target/test-artifacts.jsonl integration_flow local_execution::a_long_foreground_command_moves_to_the_background_after_30_seconds --ignored --exact diff --git a/crates/dimcode/Cargo.toml b/crates/dimcode/Cargo.toml index 400d89bdd7..fc79d08bc7 100644 --- a/crates/dimcode/Cargo.toml +++ b/crates/dimcode/Cargo.toml @@ -39,6 +39,9 @@ path = "tests/ui_leaf.rs" [features] # Compile the Web workspace into the executable (dim-app-server's feature). embedded-web = ["dim-app-server/embedded-web"] +# Debug-build acceptances that a release binary cannot run. CI enables this +# only for the paths that own them; ordinary workspace tests leave them out. +dev-tests = [] [dependencies] dim-cli = { path = "../dim-cli" } diff --git a/crates/dimcode/tests/cli_daemon_flow.rs b/crates/dimcode/tests/cli_daemon_flow.rs index 9515ccf2fe..93d5c41081 100644 --- a/crates/dimcode/tests/cli_daemon_flow.rs +++ b/crates/dimcode/tests/cli_daemon_flow.rs @@ -14,6 +14,7 @@ mod catalog; mod context; #[path = "cli_flow/daemon_replace.rs"] mod daemon_replace; +#[cfg(feature = "dev-tests")] #[path = "cli_flow/daemon_startup_progress.rs"] mod daemon_startup_progress; #[path = "cli_flow/migration.rs"] diff --git a/crates/dimcode/tests/cli_flow/daemon_replace.rs b/crates/dimcode/tests/cli_flow/daemon_replace.rs index e56866729e..a5a0db48d4 100644 --- a/crates/dimcode/tests/cli_flow/daemon_replace.rs +++ b/crates/dimcode/tests/cli_flow/daemon_replace.rs @@ -438,7 +438,7 @@ fn the_daemon_notice_never_reaches_json_stdout() { /// with one notice and no shutdown, whether or not it is idle, and a matching /// stamp says nothing. `DIM_TEST_BUILD_ID` is a debug-build stand-in for the /// stamp a distributable build embeds, so this is a debug-build check. -#[cfg(debug_assertions)] +#[cfg(all(debug_assertions, feature = "dev-tests"))] mod build_identity { use super::*; diff --git a/crates/dimcode/tests/cli_flow/staged_update.rs b/crates/dimcode/tests/cli_flow/staged_update.rs index f50687657b..aa7b0ed55e 100644 --- a/crates/dimcode/tests/cli_flow/staged_update.rs +++ b/crates/dimcode/tests/cli_flow/staged_update.rs @@ -901,7 +901,11 @@ fn an_interrupted_check_ends_every_process_it_started() { ); } -#[cfg(all(debug_assertions, any(target_os = "macos", target_os = "linux")))] +#[cfg(all( + debug_assertions, + feature = "dev-tests", + any(target_os = "macos", target_os = "linux") +))] fn target_platform() -> Option<&'static str> { match (std::env::consts::OS, std::env::consts::ARCH) { ("macos", "aarch64") => Some("darwin-arm64"), @@ -915,7 +919,11 @@ fn target_platform() -> Option<&'static str> { /// Startup recovery when the store format is newer than this daemon. Uses the /// debug-only `DIM_TEST_RELEASE_BUILD=1` override so these flows run against /// the already-compiled debug binary without recompiling the workspace. -#[cfg(all(debug_assertions, any(target_os = "macos", target_os = "linux")))] +#[cfg(all( + debug_assertions, + feature = "dev-tests", + any(target_os = "macos", target_os = "linux") +))] mod recovery { use super::*; @@ -1274,7 +1282,11 @@ mod recovery { /// `Update now` in the terminal UI. Uses the debug-only /// `DIM_TEST_RELEASE_BUILD=1` override so these flows run against the /// already-compiled debug binary without recompiling the workspace. -#[cfg(all(debug_assertions, any(target_os = "macos", target_os = "linux")))] +#[cfg(all( + debug_assertions, + feature = "dev-tests", + any(target_os = "macos", target_os = "linux") +))] mod tui_update { use super::*; diff --git a/docs/architecture/build.md b/docs/architecture/build.md index aecd0e4985..781d14ce9a 100644 --- a/docs/architecture/build.md +++ b/docs/architecture/build.md @@ -363,7 +363,16 @@ Each runner's OS/libc baseline must be recorded and verified before declaring th Public Node provider and MCP interoperability fixtures use development dependencies declared in `runtime/package.json`. Install them with `npm ci --prefix runtime --ignore-scripts`; distribution staging uses `--omit=dev` and does not ship those SDKs. -Evaluation-tool tests are opt-in: `cargo test --locked -p xtask --features eval-tests`. CI enables them for `xtask/` changes, main pushes, scheduled sweeps and manual runs. The real 30-second background handoff is also opt-in locally: `cargo test --locked -p dim-agent-integration-tests --test integration_flow local_execution::a_long_foreground_command_moves_to_the_background_after_30_seconds -- --ignored --exact`; CI runs it for execution-related paths, main pushes, scheduled sweeps and manual runs. Ordinary workspace tests retain execution cancellation, cleanup and recovery flows. +Evaluation-tool tests are opt-in: `cargo test --locked -p xtask --features eval-tests`. CI enables them for `xtask/` changes, main pushes, scheduled sweeps and manual runs. Debug-build CLI acceptances are also opt-in. Run all 39 with: + +```sh +cargo test --locked -p dimcode --features dev-tests --test cli_daemon_flow daemon_startup_progress +cargo test --locked -p dimcode --features dev-tests --test cli_daemon_flow daemon_replace::build_identity +cargo test --locked -p dimcode --features dev-tests --test cli_flow staged_update::recovery +cargo test --locked -p dimcode --features dev-tests --test cli_flow staged_update::tui_update +``` + +Ordinary workspace tests compile without `dev-tests`; CI selects the dedicated step for changes to those owning test files and to the production paths that implement the behaviors they assert: `dim-cli/src/client.rs`, `dim-cli/src/lib.rs`, `dim-cli/src/update.rs`, `dim-cli/src/update/staged.rs`, `dim-cli/src/plugins.rs`, `dim-cli/src/session_host.rs`, `dim-cli/src/ui/`, `dim-agent-capabilities/src/build.rs`, `dim-app-server/src/cli.rs`, `dim-app-server/src/transport.rs`, `dim-app-server/src/storage/sqlite.rs` and `dimcode/src/main.rs`. The owning test files, `dimcode/tests/support/cli_harness.rs`, `dimcode/tests/support/daemon.rs` and `dimcode/Cargo.toml` also select it. The real 30-second background handoff is also opt-in locally: `cargo test --locked -p dim-agent-integration-tests --test integration_flow local_execution::a_long_foreground_command_moves_to_the_background_after_30_seconds -- --ignored --exact`; CI runs it for execution-related paths, main pushes, scheduled sweeps and manual runs. Ordinary workspace tests retain execution cancellation, cleanup and recovery flows. `npm run build --prefix web` type-checks and bundles the frontend. Run its component and projection flows separately with `npm test --prefix web`. diff --git a/docs/architecture/tui-e2e.md b/docs/architecture/tui-e2e.md index 2ced6f0432..0ac4ea1cc6 100644 --- a/docs/architecture/tui-e2e.md +++ b/docs/architecture/tui-e2e.md @@ -429,12 +429,16 @@ component and protocol tests do not already cover. CI keeps: - Ordinary workspace tests: the `dim-cli` component render and keyboard tests, - `dim-app-server` protocol and transport flows, the 422 non-TUI `cli_flow*` - cases (`--no-tui`, `exec`, piped prompts, ACP, `staged_update::recovery::`, - and the scripted daemon flows), and the 287 TUI cases #1810 still tracks - (including the 6 `staged_update::tui_update::` cases, which use the debug-only - `DIM_TEST_RELEASE_BUILD=1` override instead of a separate release-stamped - build step). + `dim-app-server` protocol and transport flows, the 389 non-TUI `cli_flow*` + cases (`--no-tui`, `exec`, piped prompts, ACP, and the scripted daemon flows), + and the 281 TUI cases #1810 still tracks. +- The dedicated `dev-tests` step: the 7 `staged_update::recovery::`, 6 + `staged_update::tui_update::`, 6 `daemon_replace::build_identity::` and 20 + `daemon_startup_progress::` cases. It runs when their owning test files or + the production paths they protect change. The `tui_update` cases use the + debug-only `DIM_TEST_RELEASE_BUILD=1` override instead of a separate + release-stamped build step. When the dedicated step is selected, the two + runs together keep the original 422 non-TUI and 287 TUI `cli_flow*` cases. - The explicit `cli_flow` step that names the 12 `--ignored` production and line-mode flows one by one: the production App Server, the account and permission presets, the real-owner MCP/hooks/workflow writes, and the diff --git a/docs/release/README.md b/docs/release/README.md index 346bac6937..80e1d292d0 100644 --- a/docs/release/README.md +++ b/docs/release/README.md @@ -223,7 +223,7 @@ release packages use the ordinary Cargo executable. `ci.yml` runs on pull requests, pushes to `main`, a daily scheduled full sweep (`0 19 * * *` UTC), and manual dispatch. A pull request runs the groups its changed paths need, as decided by `scripts/ci-changes.mjs`. A push to `main` runs only `changes` and `ci-ok` when its entire push range changes only paths that select no check group (documentation and non-code repository metadata); pushes touching any checked path or whose base cannot be compared keep the full `main` run while the daily scheduled sweep is established (ADR 026 D5). Scheduled sweeps and manual dispatch select every group across both Linux and macOS: if a scheduled sweep fails on a cross-group regression, the maintainers triage it and bisect the `main` commit range since the previous passing sweep back to the regressing merge. Every push to `main` runs its selected jobs to completion: a later push does not cancel them, so each merge has its own result and the `main CI` badge in the [README](../../README.md) reports the latest finished one. -CI builds the workspace, checks formatting and Clippy, runs workspace tests and boundary checks, runs the packaging/development script tests in a dedicated Linux x64 `scripts` job, and exercises the ignored actual CLI profile and public Node-backed flows. `ci-ok` passes when every selected gating job passes, so it is the check to require. CI builds without debug info (`CARGO_PROFILE_DEV_DEBUG=0`). The [build environment](../architecture/build.md) describes test artifact reuse, concurrency limits, and target deadlines. Cargo runs documentation tests with the same features, and ignored CLI and Node flows reuse the recorded binaries without package-scoped recompilation. Web source changes run the lightweight `static-checks` job (`xtask-check`) on Linux x64 without compiling business runtime crates. Plugin pages select the runtime-assembled `xtask` check. From `scripts/`, `scripts/stage-web.mjs` and `scripts/run-rust-test.mjs` select the `web` job (the latter deliberately selects every group), while Rust files read directly by packaging scripts (`crates/dim-app-server/src/protocol.rs`, `crates/dim-app-server/src/storage/sqlite.rs`, and `crates/dim-app-server/resources/`) retain their owning packaging checks. Node-backed checks run for runtime, binding and service-contract paths, and CLI-only changes retain their ordinary and actual-profile flows. Windows client transport and CLI terminal crates (`crates/dim-cli/`, `crates/dim-client/`, `crates/dim-agent-types/`, `vendor/grok-build/`) trigger `windows-cli`. Windows storage, host-platform, named-pipe and worktree-removal paths (`crates/dim-agent-capabilities/src/file_storage*`, `crates/dim-agent-capabilities/src/host_platform*`, `crates/dim-app-server/src/lib.rs`, `transport.rs`, `pipe_client.rs`, `cli.rs`, `worktrees.rs` and the test files that hold those flows, including `worktree_removal_flow.rs`) also run its Windows-native boundary step, which `main` pushes that select the job, scheduled sweeps and manual dispatch execute as well. Evaluation tests use `xtask/eval-tests` for `xtask/` changes, and the wall-clock handoff runs for execution-related changes. PRs run `verify (linux)` for the selected Rust/`xtask` groups. Rust PRs also run `macos-native` on Apple Silicon, and changes affecting native packaging or code layout select its macOS script checks on PRs, `main` pushes, scheduled sweeps and manual runs. All selected jobs feed `ci-ok`. Full `main` pushes run `verify (macos)`, and scheduled sweeps and manual dispatch run full verification on both Linux and macOS. The `web` job runs on self-hosted Windows x64. It stages the frontend package, verifies generated declarations and bundled dependency notices, and runs the Web tests. +CI builds the workspace, checks formatting and Clippy, runs workspace tests and boundary checks, runs the packaging/development script tests in a dedicated Linux x64 `scripts` job, and exercises the ignored actual CLI profile and public Node-backed flows. `ci-ok` passes when every selected gating job passes, so it is the check to require. CI builds without debug info (`CARGO_PROFILE_DEV_DEBUG=0`). The [build environment](../architecture/build.md) describes test artifact reuse, concurrency limits, and target deadlines. Cargo runs documentation tests with the same features, and ignored CLI and Node flows reuse the recorded binaries without package-scoped recompilation. Web source changes run the lightweight `static-checks` job (`xtask-check`) on Linux x64 without compiling business runtime crates. Plugin pages select the runtime-assembled `xtask` check. From `scripts/`, `scripts/stage-web.mjs` and `scripts/run-rust-test.mjs` select the `web` job (the latter deliberately selects every group), while Rust files read directly by packaging scripts (`crates/dim-app-server/src/protocol.rs`, `crates/dim-app-server/src/storage/sqlite.rs`, and `crates/dim-app-server/resources/`) retain their owning packaging checks. Node-backed checks run for runtime, binding and service-contract paths, and CLI-only changes retain their ordinary and actual-profile flows. Windows client transport and CLI terminal crates (`crates/dim-cli/`, `crates/dim-client/`, `crates/dim-agent-types/`, `vendor/grok-build/`) trigger `windows-cli`. Windows storage, host-platform, named-pipe and worktree-removal paths (`crates/dim-agent-capabilities/src/file_storage*`, `crates/dim-agent-capabilities/src/host_platform*`, `crates/dim-app-server/src/lib.rs`, `transport.rs`, `pipe_client.rs`, `cli.rs`, `worktrees.rs` and the test files that hold those flows, including `worktree_removal_flow.rs`) also run its Windows-native boundary step, which `main` pushes that select the job, scheduled sweeps and manual dispatch execute as well. Evaluation tests use `xtask/eval-tests` for `xtask/` changes, debug-build CLI acceptances use `dimcode`'s `dev-tests` feature for their owning test files, and the wall-clock handoff runs for execution-related changes. PRs run `verify (linux)` for the selected Rust/`xtask` groups. Rust PRs also run `macos-native` on Apple Silicon, and changes affecting native packaging or code layout select its macOS script checks on PRs, `main` pushes, scheduled sweeps and manual runs. All selected jobs feed `ci-ok`. Full `main` pushes run `verify (macos)`, and scheduled sweeps and manual dispatch run full verification on both Linux and macOS. The `web` job runs on self-hosted Windows x64. It stages the frontend package, verifies generated declarations and bundled dependency notices, and runs the Web tests. The `Verify Python plugins` step is off by default. When a Python plugin ships, set the repository Actions variable `DIM_CI_PYTHON_PLUGINS` to `true` to run it whenever the Node check group is selected. It prepares CPython for the `python_plugin_` flows and reuses the App Server test binary from the workspace build. See the [App Server verification commands](../../crates/dim-app-server/README.md#verification) to run the suites locally. diff --git a/scripts/ci-changes.mjs b/scripts/ci-changes.mjs index 46f02c89aa..d6b95c4aaf 100644 --- a/scripts/ci-changes.mjs +++ b/scripts/ci-changes.mjs @@ -1,7 +1,7 @@ import {execFileSync,spawnSync} from 'node:child_process'; import {appendFileSync} from 'node:fs'; -export const groups=['rust','windows','windows_native','static','xtask','node','eval','execution','web','scripts','macos_scripts','dependencies']; +export const groups=['rust','windows','windows_native','static','xtask','node','eval','execution','debug','web','scripts','macos_scripts','dependencies']; const everything=Object.fromEntries(groups.map(group=>[group,true])); const documentation=/^docs\/|^[^/]+\.md$/; const cargoManifest=/(?:^|\/)Cargo\.toml$/; @@ -50,12 +50,24 @@ const rules=[ [/^scripts\/(stage-release|pack-release|native-binary|store-formats|release\.test)\.mjs$/,['scripts','macos_scripts']], [/^scripts\//,['scripts']], [/^docker\//,['scripts']], + // The startup, replacement and update paths these acceptances protect. + [/^crates\/dim-cli\/src\/(?:client\.rs|update(?:\.rs|\/))/,['rust','windows','debug']], + [/^crates\/dim-cli\/src\/(?:lib\.rs|plugins\.rs|session_host(?:\.rs|\/)|ui\/)/,['rust','windows','debug']], [/^crates\/dim-cli\//,['rust','windows']], [/^crates\/dim-client\//,['rust','windows','node']], [/^crates\/dim-agent-types\//,['rust','windows','node']], + // Debug-build acceptances (#2218) leave ordinary workspace tests. The owning + // test files and the production paths they protect select the dedicated step. + [/^crates\/dimcode\/tests\/(?:cli_flow|cli_daemon_flow)\.rs$/,['rust','debug']], + [/^crates\/dimcode\/tests\/cli_flow\/(?:daemon_startup_progress|daemon_replace|staged_update)\.rs$/,['rust','debug']], + [/^crates\/dimcode\/tests\/support\/(?:cli_harness|daemon)\.rs$/,['rust','node','debug']], + [/^crates\/dimcode\/(?:Cargo\.toml|src\/main\.rs)$/,['rust','debug']], [/^crates\/dimcode\//,['rust']], + [/^crates\/dim-agent-capabilities\/src\/build\.rs$/,['rust','node','debug']], + [/^crates\/dim-app-server\/src\/transport\.rs$/,['rust','node','debug']], [/^crates\/dim-app-server\/src\/protocol\.rs$/,['rust','node','web','scripts']], - [/^crates\/dim-app-server\/src\/storage\/sqlite\.rs$/,['rust','node','scripts','macos_scripts']], + [/^crates\/dim-app-server\/src\/storage\/sqlite\.rs$/,['rust','node','scripts','macos_scripts','debug']], + [/^crates\/dim-app-server\/src\/cli\.rs$/,['rust','node','debug']], [/^crates\/dim-app-server\/resources\//,['rust','node','scripts']], [/^crates\/dim-agent-capabilities\/src\/(workspace_tools\/(background|exec)|host_platform)/,['rust','node','execution']], [/^tests\/integration\/tests\/(local_execution|local_support|minimal_execution)/,['rust','node','execution']], diff --git a/scripts/ci-changes.test.mjs b/scripts/ci-changes.test.mjs index 79e9062173..8545933208 100644 --- a/scripts/ci-changes.test.mjs +++ b/scripts/ci-changes.test.mjs @@ -68,7 +68,7 @@ test('source areas select their groups',()=>{ assert.deepEqual(classify(['docker/Dockerfile']),only('scripts')); assert.deepEqual(classify(['crates/dim-app-server/src/lib.rs','runtime/fixtures/session-part.json']),only('rust','node','windows_native')); assert.deepEqual(classify(['crates/dim-app-server/src/protocol.rs']),only('rust','node','web','scripts')); - assert.deepEqual(classify(['crates/dim-app-server/src/storage/sqlite.rs']),only('rust','node','scripts','macos_scripts')); + assert.deepEqual(classify(['crates/dim-app-server/src/storage/sqlite.rs']),only('rust','node','scripts','macos_scripts','debug')); assert.deepEqual(classify(['crates/dim-app-server/resources/default-catalog.json']),only('rust','node','scripts')); assert.deepEqual(classify(['crates/dim-cli/src/main.rs']),only('rust','windows')); assert.deepEqual(classify(['crates/dim-client/src/lib.rs']),only('rust','windows','node')); @@ -111,8 +111,36 @@ test('native macOS CI follows its runner, packaging and Mach-O layout sources',( } }); +test('debug-only CLI tests follow their owning modules',()=>{ + for (const file of [ + 'crates/dimcode/tests/cli_flow/daemon_startup_progress.rs', + 'crates/dimcode/tests/cli_flow/daemon_replace.rs', + 'crates/dimcode/tests/cli_flow/staged_update.rs', + ]) assert.deepEqual(classify([file]),only('rust','debug'),file); + assert.deepEqual(classify(['crates/dimcode/tests/cli_daemon_flow.rs']),only('rust','debug')); + assert.deepEqual(classify(['crates/dimcode/tests/cli_flow.rs']),only('rust','debug')); + assert.deepEqual(classify(['crates/dimcode/tests/support/cli_harness.rs']),only('rust','node','debug')); + assert.deepEqual(classify(['crates/dimcode/Cargo.toml']),only('rust','debug','dependencies')); + assert.deepEqual(classify(['crates/dimcode/src/main.rs']),only('rust','debug')); + for (const file of [ + 'crates/dim-cli/src/client.rs', + 'crates/dim-cli/src/update.rs', + 'crates/dim-cli/src/update/staged.rs', + 'crates/dim-cli/src/lib.rs', + 'crates/dim-cli/src/plugins.rs', + 'crates/dim-cli/src/ui/tui.rs', + ]) assert.deepEqual(classify([file]),only('rust','windows','debug'),file); + assert.deepEqual(classify(['crates/dim-app-server/src/storage/sqlite.rs']),only('rust','node','scripts','macos_scripts','debug')); + assert.deepEqual(classify(['crates/dim-app-server/src/cli.rs']),only('rust','node','debug','windows_native')); + assert.deepEqual(classify(['crates/dim-app-server/src/transport.rs']),only('rust','node','debug','windows_native')); + assert.deepEqual(classify(['crates/dim-agent-capabilities/src/build.rs']),only('rust','node','debug')); + assert.deepEqual(classify(['crates/dimcode/src/main.rs']),only('rust','debug')); + assert.deepEqual(classify(['crates/dimcode/tests/support/daemon.rs']),only('rust','node','debug')); + assert.deepEqual(classify(['crates/dim-cli/src/session_host.rs']),only('rust','windows','debug')); +}); + test('bridge, evaluation and wall-clock flows follow their owning paths',()=>{ - assert.deepEqual(classify(['crates/dim-cli/src/ui/tui.rs']),only('rust','windows')); + assert.deepEqual(classify(['crates/dim-cli/src/ui/tui.rs']),only('rust','windows','debug')); assert.deepEqual(classify(['crates/dimcode/tests/cli_flow/models.rs']),only('rust')); assert.deepEqual(classify(['crates/dim-agent-types/src/tool.rs']),only('rust','windows','node')); assert.deepEqual(classify(['xtask/check/src/literal_main.rs']),only('static','xtask'));