Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/actions/setup-windows-code-layout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Set up Windows native code layout toolchain
description: Install the pinned MSVC Rust host toolchain, configure MSVC build tools, and locate lld-link.
inputs:
target:
description: Native Rust target triple (x86_64-pc-windows-msvc or aarch64-pc-windows-msvc)
required: true
runs:
using: composite
steps:
- name: Select native MSVC Rust toolchain
shell: powershell
env:
DIM_LAYOUT_TARGET: ${{ inputs.target }}
run: |
$channel = python -c "import tomllib; print(tomllib.load(open('rust-toolchain.toml', 'rb'))['toolchain']['channel'])"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$toolchain = "$channel-$env:DIM_LAYOUT_TARGET"
rustup toolchain install $toolchain --profile minimal
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
"RUSTUP_TOOLCHAIN=$toolchain" >> $env:GITHUB_ENV
- name: Configure Windows C/C++ toolchain
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ runner.arch == 'ARM64' && 'arm64' || 'amd64' }}
- name: Locate lld-link
shell: powershell
run: |
$linker = Get-Command lld-link -ErrorAction SilentlyContinue
if (!$linker) {
$linker = Get-ChildItem -Recurse -Filter lld-link.exe -ErrorAction SilentlyContinue `
-Path "$env:ProgramFiles\LLVM\bin", "$env:ProgramFiles\Microsoft Visual Studio\2022\*\VC\Tools\Llvm\*\bin" |
Select-Object -First 1
}
if ($linker) {
$path = if ($linker -is [System.Management.Automation.ApplicationInfo]) { $linker.Source } else { $linker.FullName }
Split-Path $path >> $env:GITHUB_PATH
Write-Output "Using $path"
} else {
Write-Output 'lld-link is not on PATH; the build will use the Rust toolchain rust-lld'
}
80 changes: 71 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
timeout-minutes: 15
env:
CARGO_INCREMENTAL: "0"
CARGO_TARGET_DIR: ${{ github.workspace }}/../.dim-windows-cli-target
RUSTC_WRAPPER: ""
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
Expand All @@ -111,6 +112,34 @@ jobs:
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: amd64
- name: Reuse bounded Windows CLI target directory
shell: powershell
env:
CACHE_STAMP: ${{ hashFiles('rust-toolchain.toml') }}-${{ env.CARGO_PROFILE_DEV_DEBUG }}
run: |
$targetDir = [System.IO.Path]::GetFullPath($env:CARGO_TARGET_DIR)
$stampFile = Join-Path $targetDir '.cache-stamp'
$maxBytes = 6GB
$reset = $false
if (Test-Path $targetDir) {
$current = if (Test-Path $stampFile) { (Get-Content -Raw $stampFile).Trim() } else { '' }
if ($current -ne $env:CACHE_STAMP) {
Write-Output 'Resetting Windows CLI target cache (toolchain or profile stamp changed).'
$reset = $true
} else {
$bytes = (Get-ChildItem -LiteralPath $targetDir -Recurse -File -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum
if ($bytes -gt $maxBytes) {
Write-Output "Resetting Windows CLI target cache ($([math]::Round($bytes / 1GB, 2)) GiB exceeded 6 GiB budget)."
$reset = $true
}
}
}
if ($reset) {
Remove-Item -LiteralPath $targetDir -Recurse -Force
}
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
- name: Verify native Windows CLI boundaries
run: cargo test --locked -p dim-cli --lib
web:
Expand Down Expand Up @@ -198,8 +227,9 @@ jobs:
run: |
echo "CPUs: $(nproc)"
grep -E 'MemTotal|MemAvailable' /proc/meminfo
# Without a working bubblewrap the confined process tests return without running.
bwrap --ro-bind / / true
# The confined tests create a user namespace and a private /proc, so
# check the sandbox they use instead of a plain read-only bind.
bwrap --unshare-user --unshare-pid --proc /proc --dev /dev --ro-bind / / true
- name: Build and lint the Rust workspace
if: needs.changes.outputs.rust == 'true'
shell: bash
Expand All @@ -223,10 +253,38 @@ jobs:
target/debug/xtask check
- name: Run compiled workspace tests
if: needs.changes.outputs.rust == 'true'
shell: bash
env:
DIM_TEST_TIMEOUT_MS: "900000"
run: |
node scripts/run-rust-test.mjs target/test-artifacts.jsonl --workspace --test-threads=3
set -euo pipefail
if [[ "$RUNNER_OS" == Linux ]]; then
cpus=$(nproc)
# Runner hosts may share their physical cores between instances and
# report SMT siblings as CPUs; scale by the cores this job can use.
if command -v lscpu >/dev/null; then
cores=$(lscpu -p=Core,Socket | grep -v '^#' | sort -u | wc -l)

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.

Problem: this probe runs under set -euo pipefail, which is also GitHub's default bash shell, so a present but failing lscpu aborts the step before any fallback. cores=$(lscpu -p=Core,Socket | grep -v '^#' | sort -u | wc -l) returns the pipeline status; when lscpu exits nonzero or prints only comment lines, grep exits 1 and pipefail fails the assignment. The logical= assignment on the next line behaves the same, and the (( cores > 0 )) || cores=1 guard is never reached in these cases.

Failure scenario: on a runner image with util-linux installed but /sys/devices/system/cpu masked or unreadable (a container or hardened image), the verify test step exits 1 immediately, prints no Workspace tests: line, and runs no tests.

Evidence: I ran the exact block from ci.yml:260-286 with fake nproc and lscpu binaries. lscpu exiting 1 with valid rows, exiting 1 with no rows, and printing only headers all exit 1 at the cores assignment. With lscpu absent the fallback runs. The normal 8-core/16-thread case gives DIM_TEST_JOBS=3 --test-threads=2, and head run 44876257722 echoed the same.

Fix: guard the probe, for example if ! cores=$(...); then physical=$cpus; else ... fi (and likewise for logical), or append || true to both assignments and treat a zero cores or logical as the fallback. A command -v lscpu check is not enough because this failure is at runtime.

logical=$(lscpu -p=CPU | grep -vc '^#')
(( cores > 0 )) || cores=1
smt=$(( logical / cores ))
(( smt < 1 )) && smt=1
physical=$(( cpus / smt ))
else
physical=$cpus
fi
(( physical < 1 )) && physical=1
test_jobs=$(( physical / 3 ))
(( test_jobs < 3 )) && test_jobs=3
(( test_jobs > 8 )) && test_jobs=8
test_threads=$(( physical / 4 ))
(( test_threads < 2 )) && test_threads=2
(( test_threads > 6 )) && test_threads=6
else
test_jobs=3
test_threads=3
fi
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"

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.

Problem: this line is the new 6-thread setting, and the only full verify run at the head commit (job 136319155891) failed in it: cli_flow exited 101 after 666244ms with four terminal wait timeouts. The goal, model reselection and subagent policy tests are the known #1957 transcript-order bug fixed by #1958; the paste rejection test is not covered by #1958 and passed in the 3-thread run cited by #1957. Failure: the required check is red and the new concurrency has no green verify run. Fix: land #1958 first and rerun green; if the paste timeout repeats at 6 threads, keep cli_flow at 3 threads or fix that flow.

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.

Partially fixed. The three transcript-order failures are gone: the branch now includes #1958, and goal, repicking and models-picker pass. The required check is still red at the new settings. At 3a1696f job 136671263956 failed on startup::a_first_prompt_is_submitted_once_and_the_interface_stays: the fake daemon's Wire::hold replies after the CLI closed and panics (cli_flow.rs:350-372 and :496-519). The run used 5 jobs and 4 threads on a 16 CPU runner, not 6 threads. The head run 44849116801 is still in progress. Still open until verify is green at these settings or cli_flow stays at 3 threads.

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 1a81f00 and the required check is green. The workspace step now derives SMT width from lscpu and scales the job's CPU count: the 16 CPU dim-verify runner computed Workspace tests: DIM_TEST_JOBS=3 --test-threads=2 (previously 5 by 4), a dedicated 16-core host keeps 5 by 4, and macOS stays at 3 by 3. Head run 44876257722 passed verify (linux) in 18m43s (job 136761584454): the workspace step passed in 6m29s including cli_flow and integration_flow/prompt_lifecycle, the CLI profile step passed including hooks::project_hooks_start_disabled_and_the_user_enables_them, the Node bindings passed, and ci-ok job 136766073868 passed. For comparison, the four verify attempts at 923aa33 all failed (jobs 136676107409, 136687140864, 136702807647 and 136706510187) with the prompt_lifecycle timeout, several unrelated flow failures, and the hooks assertion. This thread can be resolved.

cargo test --workspace --doc --locked ${{ needs.changes.outputs.eval == 'true' && '--features xtask/eval-tests' || '' }}
- name: Verify wall-clock background handoff
if: needs.changes.outputs.execution == 'true'
Expand All @@ -253,6 +311,8 @@ jobs:
# (docs/architecture/tui-e2e.md); the remaining TUI cases still run
# under the ordinary selection, so this step names the production
# and line-mode flows it keeps.
cli_threads=2
if [[ "$RUNNER_OS" == Linux ]]; then cli_threads=4; fi
node scripts/run-rust-test.mjs target/test-artifacts.jsonl cli_flow \
accounts::login_reaches_the_codex_account_of_the_production_daemon \
acp::acp_stdio_temporary_mcp_calls_tools_and_settles_the_child_on_eof \
Expand All @@ -266,7 +326,7 @@ jobs:
project_mcp_entries_start_disabled_and_the_user_enables_them \
real_daemon_profile_conflicts_preserve_the_running_daemon_and_endpoint \
workflow::workflow_commands_write_and_enable_against_the_real_owner \
--ignored --test-threads=2
--ignored --test-threads="$cli_threads"
- name: Verify public Node bindings
if: needs.changes.outputs.node == 'true'
shell: bash
Expand All @@ -283,12 +343,14 @@ jobs:
export DIM_TEST_NODE="$(command -v node)"
export DIM_TEST_JS_RUNTIME="$PWD/runtime/node_modules/@arcships/rutis-runtime"
export DIM_TEST_RUTIS_SDK="$PWD/runtime/node_modules/@arcships/rutis/src/index.mjs"
node scripts/run-rust-test.mjs target/test-artifacts.jsonl transport_flow node_ --ignored --test-threads=2
node scripts/run-rust-test.mjs target/test-artifacts.jsonl app_server_flow mcp_http_flow::node_ --ignored --test-threads=2
node scripts/run-rust-test.mjs target/test-artifacts.jsonl migration_flow node_ --ignored --test-threads=2
node scripts/run-rust-test.mjs target/test-artifacts.jsonl hub_flow node_ --ignored --test-threads=2
node_threads=2
if [[ "$RUNNER_OS" == Linux ]]; then node_threads=4; fi
node scripts/run-rust-test.mjs target/test-artifacts.jsonl transport_flow node_ --ignored --test-threads="$node_threads"
node scripts/run-rust-test.mjs target/test-artifacts.jsonl app_server_flow mcp_http_flow::node_ --ignored --test-threads="$node_threads"
node scripts/run-rust-test.mjs target/test-artifacts.jsonl migration_flow node_ --ignored --test-threads="$node_threads"
node scripts/run-rust-test.mjs target/test-artifacts.jsonl hub_flow node_ --ignored --test-threads="$node_threads"
if [[ '${{ needs.changes.outputs.eval }}' == true ]]; then
node scripts/run-rust-test.mjs target/test-artifacts.jsonl xtask node_ --ignored --test-threads=2
node scripts/run-rust-test.mjs target/test-artifacts.jsonl xtask node_ --ignored --test-threads="$node_threads"
fi
- name: Verify Python plugins
if: needs.changes.outputs.node == 'true' && vars.DIM_CI_PYTHON_PLUGINS == 'true'
Expand Down
67 changes: 7 additions & 60 deletions .github/workflows/code-layout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- scripts/code-layout/**
- scripts/code-layout*.test.mjs
- .github/workflows/code-layout.yml
- .github/actions/setup-windows-code-layout/**
- rust-toolchain.toml
- .node-version
workflow_dispatch:
Expand Down Expand Up @@ -71,38 +72,11 @@ jobs:
with:
python-version: '3.13'
architecture: ${{ runner.arch == 'ARM64' && 'arm64' || 'x64' }}
- name: Select native MSVC Rust toolchain
- name: Set up Windows native code layout toolchain
if: runner.os == 'Windows'
shell: powershell
run: |
$channel = python -c "import tomllib; print(tomllib.load(open('rust-toolchain.toml', 'rb'))['toolchain']['channel'])"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$toolchain = "$channel-${{ matrix.target }}"
rustup toolchain install $toolchain --profile minimal
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
"RUSTUP_TOOLCHAIN=$toolchain" >> $env:GITHUB_ENV
- name: Configure Windows C/C++ toolchain
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
uses: ./.github/actions/setup-windows-code-layout
with:
arch: ${{ runner.arch == 'ARM64' && 'arm64' || 'amd64' }}
- name: Locate lld-link
if: runner.os == 'Windows'
shell: powershell
run: |
$linker = Get-Command lld-link -ErrorAction SilentlyContinue
if (!$linker) {
$linker = Get-ChildItem -Recurse -Filter lld-link.exe -ErrorAction SilentlyContinue `
-Path "$env:ProgramFiles\LLVM\bin", "$env:ProgramFiles\Microsoft Visual Studio\2022\*\VC\Tools\Llvm\*\bin" |
Select-Object -First 1
}
if ($linker) {
$path = if ($linker -is [System.Management.Automation.ApplicationInfo]) { $linker.Source } else { $linker.FullName }
Split-Path $path >> $env:GITHUB_PATH
Write-Output "Using $path"
} else {
Write-Output 'lld-link is not on PATH; the build will use the Rust toolchain rust-lld'
}
target: ${{ matrix.target }}
- run: rustup show
- run: node --test ${{ matrix.test }} scripts/code-layout-replay.test.mjs
env:
Expand Down Expand Up @@ -160,38 +134,11 @@ jobs:
with:
python-version: '3.13'
architecture: ${{ runner.arch == 'ARM64' && 'arm64' || 'x64' }}
- name: Select native MSVC Rust toolchain
- name: Set up Windows native code layout toolchain
if: runner.os == 'Windows'
shell: powershell
run: |
$channel = python -c "import tomllib; print(tomllib.load(open('rust-toolchain.toml', 'rb'))['toolchain']['channel'])"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$toolchain = "$channel-${{ matrix.target }}"
rustup toolchain install $toolchain --profile minimal
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
"RUSTUP_TOOLCHAIN=$toolchain" >> $env:GITHUB_ENV
- name: Configure Windows C/C++ toolchain
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
uses: ./.github/actions/setup-windows-code-layout
with:
arch: ${{ runner.arch == 'ARM64' && 'arm64' || 'amd64' }}
- name: Locate lld-link
if: runner.os == 'Windows'
shell: powershell
run: |
$linker = Get-Command lld-link -ErrorAction SilentlyContinue
if (!$linker) {
$linker = Get-ChildItem -Recurse -Filter lld-link.exe -ErrorAction SilentlyContinue `
-Path "$env:ProgramFiles\LLVM\bin", "$env:ProgramFiles\Microsoft Visual Studio\2022\*\VC\Tools\Llvm\*\bin" |
Select-Object -First 1
}
if ($linker) {
$path = if ($linker -is [System.Management.Automation.ApplicationInfo]) { $linker.Source } else { $linker.FullName }
Split-Path $path >> $env:GITHUB_PATH
Write-Output "Using $path"
} else {
Write-Output 'lld-link is not on PATH; the build will use the Rust toolchain rust-lld'
}
target: ${{ matrix.target }}
- run: rustup show
- name: Provision Windows native build dependencies
if: runner.os == 'Windows'
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ jobs:
run: |
set -euo pipefail
if [[ "$STAMP" == true ]]; then node scripts/alpha-version.mjs "$RELEASE_VERSION"; fi
cargo install cargo-about --version 0.9.3 --features cli --locked
cargo_about_archive="cargo-about-0.9.3-x86_64-unknown-linux-musl.tar.gz"
curl -fsSL -o "$RUNNER_TEMP/$cargo_about_archive" \
"https://github.com/EmbarkStudios/cargo-about/releases/download/0.9.3/$cargo_about_archive"
echo "3ad1e94ea1e63d69d1961f4fb15ccbbe9575d906111f96d2cb4dce6df48f71b4 $RUNNER_TEMP/$cargo_about_archive" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/$cargo_about_archive" -C "$RUNNER_TEMP" cargo-about-0.9.3-x86_64-unknown-linux-musl/cargo-about
export PATH="$RUNNER_TEMP/cargo-about-0.9.3-x86_64-unknown-linux-musl:$PATH"
cargo fetch --locked
mkdir -p staging
node scripts/rust-notices.mjs staging/rust-notices.txt
Expand Down
19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ jiff = { version = "0.2.46", features = ["serde", "tzdb-bundle-always"] }
[profile.dev]
debug = "line-tables-only"

[profile.dev.package]
adler2 = { opt-level = 2 }
aho-corasick = { opt-level = 2 }
crc32fast = { opt-level = 2 }
fdeflate = { opt-level = 2 }
flate2 = { opt-level = 2 }
image = { opt-level = 2 }
image-webp = { opt-level = 2 }
memchr = { opt-level = 2 }
miniz_oxide = { opt-level = 2 }
png = { opt-level = 2 }
regex = { opt-level = 2 }
regex-automata = { opt-level = 2 }
regex-syntax = { opt-level = 2 }
serde_json = { opt-level = 2 }
sha2 = { opt-level = 2 }
simd-adler32 = { opt-level = 2 }
zune-jpeg = { opt-level = 2 }

[profile.release]
lto = "fat"
codegen-units = 1
Expand Down
8 changes: 6 additions & 2 deletions crates/dim-app-server/src/model_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ fn bundled_model(bytes: &[u8]) -> ModelEntry {
}

fn bundled_record<T: serde::de::DeserializeOwned>(bytes: &[u8]) -> T {
serde_json::from_reader(flate2::read::GzDecoder::new(bytes))
.expect("checked-in bundled catalog records deserialize")
use std::io::Read as _;
let mut decoded = Vec::with_capacity(bytes.len().saturating_mul(3));
flate2::read::GzDecoder::new(bytes)
.read_to_end(&mut decoded)
.expect("checked-in bundled catalog records decompress");
serde_json::from_slice(&decoded).expect("checked-in bundled catalog records deserialize")
}
const REASONING_OFF: &str = include_str!("../resources/reasoning-off-overrides.json");

Expand Down
Loading