From 83bcc3bb9939458fd3a44093fb6cba0e87b19fc1 Mon Sep 17 00:00:00 2001 From: Shivakumar Date: Mon, 27 Jul 2026 12:21:24 +0530 Subject: [PATCH 1/2] ci: cut the Windows build's redundant pass, Defender scanning, and PDB cost Measured on run 30237145340: Windows 6m10s against Ubuntu's 1m56s, split as rust-cache restore 54s / 12s, cargo build 1m33s / 16s, cargo test 3m16s / 1m18s. Inside the Windows test step, ~91s is spent purely executing the 835-test suite. Three things, each aimed at one of those numbers: The separate cargo build step is gone. cargo test compiles and links the same libs and bins -- it builds every bin target so integration tests can spawn them, which is what crates/flare-git-shim/tests/shim_test.rs relies on -- so building first was a second full pass over the workspace for nothing. Non-test targets stay covered by clippy --all-targets. Windows runners get Defender exclusions for the workspace, the cargo home and TEMP. Real-time protection is on in that image and scans every object file, PDB and executable rustc writes, plus every temp file the tests create -- the likeliest reason the same suite takes 91s there. Best effort: a runner that refuses the exclusion builds slowly rather than failing. CARGO_PROFILE_DEV_DEBUG=line-tables-only workflow-wide. Nothing in CI attaches a debugger, MSVC spends real link time writing PDBs, and those artifacts are what the cache archive restores every run -- which is the 54s against 12s. Panic backtraces stay readable. Workflow-level so build and clippy produce matching artifacts instead of halving the hit rate. Also de-flakes agentflare-artifacts::update_existing_artifact, which failed this way on a windows-latest runner today (1785126773 against 1785126774) and forced a rerun. It asserted created_at == updated_at, true only while both publishes land in the same second -- and passing for that reason rather than because the invariant held: the same assertion still passed with created_at deliberately rewritten on update. It now backdates the stored value first and checks the update carried it forward, which does fail under that mutation. --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++-- crates/agentflare-artifacts/src/lib.rs | 23 ++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75faad53f..dc0c99a34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,16 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name != 'push' }} +env: + # Nothing in CI attaches a debugger, and full debuginfo is expensive twice + # over: MSVC spends real link time writing PDBs, and the artifacts they + # bloat are what the rust-cache archive has to restore on every run (54s on + # Windows against 12s on Linux). `line-tables-only` keeps panic backtraces + # readable, which is the only debug information a failing job actually uses. + # Workflow-level so build and clippy agree — a per-job value would give them + # divergent artifacts and halve the cache hit rate. + CARGO_PROFILE_DEV_DEBUG: line-tables-only + jobs: changes: runs-on: ubuntu-latest @@ -40,6 +50,9 @@ jobs: # A hung test would otherwise pin a runner for GitHub's 6h default and # block the branch's required check indefinitely; fail fast instead. A # cold-cache build+test finishes well under this on every OS. + # + # zizmor: ignore[template-injection] -- github.workspace is a runner path, + # not attacker-controlled input. timeout-minutes: 25 strategy: matrix: @@ -66,8 +79,24 @@ jobs: save-if: ${{ github.ref == 'refs/heads/master' }} - if: needs.changes.result != 'success' || needs.changes.outputs.code == 'true' uses: mozilla-actions/sccache-action@d651010b8da762cde178750d8eda7b5febfe147a # v0.0.9 - - if: needs.changes.result != 'success' || needs.changes.outputs.code == 'true' - run: cargo build --workspace --verbose + # Defender real-time protection is on in the windows-latest image and + # scans every object file, PDB and executable rustc writes -- and every + # temp file the tests create, which is why the same suite that runs in + # ~20s on Linux takes ~90s here. Best-effort: a runner that refuses the + # exclusion should build slowly, not fail. + - if: runner.os == 'Windows' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true') + shell: pwsh + run: | + try { + Add-MpPreference -ExclusionPath "${{ github.workspace }}", "$env:USERPROFILE\.cargo", "$env:TEMP" -ErrorAction Stop + } catch { + Write-Host "Defender exclusions unavailable, continuing: $_" + } + # No separate `cargo build` step: `cargo test` compiles and links the + # same libs and bins (it builds every bin target so integration tests + # can spawn them -- see crates/flare-git-shim/tests/shim_test.rs), so + # building first was a second full pass over the workspace for nothing. + # Non-test targets still get type-checked by `clippy --all-targets`. - if: needs.changes.result != 'success' || needs.changes.outputs.code == 'true' run: cargo test --workspace --verbose diff --git a/crates/agentflare-artifacts/src/lib.rs b/crates/agentflare-artifacts/src/lib.rs index d4ac389c6..f3ab9d0ff 100644 --- a/crates/agentflare-artifacts/src/lib.rs +++ b/crates/agentflare-artifacts/src/lib.rs @@ -74,6 +74,23 @@ mod tests { let resp = store.publish(&req).unwrap(); let id = resp.id.clone(); + // Backdate the stored created_at before updating. Both publishes land + // in the same second, so leaving it alone would make "preserved" and + // "stamped afresh" indistinguishable — the old assertion compared + // created_at to updated_at, which passed for that reason rather than + // because the invariant held, and failed outright whenever the two + // writes straddled a second boundary (seen on a windows-latest + // runner: 1785126773 against 1785126774). + let meta_path = store.base_path().join(&id).join("meta.json"); + let created_before = store.get(&id).unwrap().created_at - 3600; + let meta = std::fs::read_to_string(&meta_path).unwrap(); + let backdated = meta.replace( + &format!("\"created_at\": {}", created_before + 3600), + &format!("\"created_at\": {created_before}"), + ); + assert_ne!(meta, backdated, "created_at not found in {meta_path:?}"); + std::fs::write(&meta_path, backdated).unwrap(); + let update = PublishRequest { name: "updated".into(), artifact_type: ArtifactType::Markdown, @@ -88,8 +105,10 @@ mod tests { let artifact = store.get(&id).unwrap(); assert_eq!(artifact.content, "v2"); assert_eq!(artifact.artifact_type, ArtifactType::Markdown); - // created_at must stay the same on update - assert_eq!(artifact.created_at, artifact.updated_at); // same sec + // An update must carry the stored created_at forward, not stamp a new + // one — the backdating above is what makes the difference visible. + assert_eq!(artifact.created_at, created_before); + assert!(artifact.updated_at >= artifact.created_at); } #[test] From b57e91625f633ce6a696d06cb4681033e52abf14 Mon Sep 17 00:00:00 2001 From: Shivakumar Date: Mon, 27 Jul 2026 12:34:55 +0530 Subject: [PATCH 2/2] test(artifacts): backdate only the artifact's created_at, not its history The artifact's created_at and its first history entry's start out identical, so replacing the timestamp textually moved both -- leaving the fixture describing a version created an hour before the artifact it belongs to. Edit the root JSON field instead. --- crates/agentflare-artifacts/src/lib.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/agentflare-artifacts/src/lib.rs b/crates/agentflare-artifacts/src/lib.rs index f3ab9d0ff..8ddab3e25 100644 --- a/crates/agentflare-artifacts/src/lib.rs +++ b/crates/agentflare-artifacts/src/lib.rs @@ -81,15 +81,19 @@ mod tests { // because the invariant held, and failed outright whenever the two // writes straddled a second boundary (seen on a windows-latest // runner: 1785126773 against 1785126774). + // Edited as JSON rather than by string replacement: the artifact's + // created_at and its first history entry's start out identical, so a + // textual replace would move both and leave the fixture describing a + // version that was created before the artifact it belongs to. let meta_path = store.base_path().join(&id).join("meta.json"); - let created_before = store.get(&id).unwrap().created_at - 3600; - let meta = std::fs::read_to_string(&meta_path).unwrap(); - let backdated = meta.replace( - &format!("\"created_at\": {}", created_before + 3600), - &format!("\"created_at\": {created_before}"), - ); - assert_ne!(meta, backdated, "created_at not found in {meta_path:?}"); - std::fs::write(&meta_path, backdated).unwrap(); + let mut meta: serde_json::Value = + serde_json::from_str(&std::fs::read_to_string(&meta_path).unwrap()).unwrap(); + let created_before = meta["created_at"] + .as_u64() + .unwrap_or_else(|| panic!("no created_at in {meta_path:?}")) + - 3600; + meta["created_at"] = created_before.into(); + std::fs::write(&meta_path, serde_json::to_string_pretty(&meta).unwrap()).unwrap(); let update = PublishRequest { name: "updated".into(),