Skip to content

feat(cache): warm the compile cache's base lane from every default-branch head - #241

Merged
debuggingfuture merged 1 commit into
mainfrom
gate/warm-base-cache
Oct 23, 2026
Merged

debuggingfuture merged 1 commit into
mainfrom
gate/warm-base-cache

Conversation

@debuggingfuture

Copy link
Copy Markdown
Member

Every default-branch push of contextful now fills the compile cache's base lane, so a pull request's first gate reads compiled crates instead of compiling cold.

Problem & Insight

  • base is written only by default-branch executions, and the only one was the heavy tier, which runs only when gate.lightLabels:<repo> is set. With it unset, base stays empty and each PR warms only its own pr-<n> lane from its second push on.
  • sccache keys an entry on the compile's arguments, working directory and CARGO_* environment. A warm that runs its own cargo invocation, or launches the gate tool through cargo run, writes entries no part reads. The warm has to run the gate part's exact command.

Take

  • New run contextful-cache-warm (runs/contextful-cache-warm.ts), triggered on default-branch pushes with no opt-in key. It uses one container: checkout with install, the gate's prebuilt contextful-ci, then workspace.compile (cargo test --workspace --no-run) through stageCommand and compileCacheCommand, with a base token. It spawns no child and posts no part check-run.
  • Cache-poisoning boundary: before checkout, the run reads the branch head and skips unless it equals the run's sha. It also skips when the head can't be read.
  • Supersession group per repo and branch, ranked by the head commit's timestamp. The idempotency key is the head, so an equal head warms once.
  • It skips before checkout when the deploy injects no cache access, or when the heavy tier already compiles workspace.compile on that push.
  • A failed compile concludes green with its exit code. The gate gives the verdict.
  • The decision is recorded in ADR-0007 § Base-lane warm, with a pointer from ADR-0009 § Two-tier gate.

Follow-ups

  • features.* and other parts compile under other features or target directories, so the warm doesn't cover them. Warming them needs a compile-only mode per part in the consumer's contextful-ci.

…anch head

Every push to contextful's default branch starts contextful-cache-warm,
independent of the two-tier gate's gate.lightLabels opt-in. One container
checks out the head, builds the gate's prebuilt contextful-ci and runs the
gate's workspace.compile part (cargo test --workspace --no-run) under the
compile-cache wrapper with a base-lane token. The command, checkout path and
environment equal a gate part's, since sccache keys entries on arguments,
working directory and CARGO_* variables.

Only a default-branch head writes base: the run reads the branch head before
checkout and skips unless it equals the run's head, or when the head is
unreadable. A newer head supersedes the older warm, ranked by the head
commit's timestamp; the idempotency key is the head. The warm skips when the
deploy injects no cache access and when the heavy tier already compiles
workspace.compile on the push. A failed compile concludes green with its exit
code. Pull-request gates keep reading pr-<n> then base and writing pr-<n>.

Spec: specs/adr/0007-cost-efficient-execution.md
@debuggingfuture
debuggingfuture marked this pull request as ready for review October 23, 2026 13:07
@debuggingfuture
debuggingfuture merged commit 43f0ad9 into main Oct 23, 2026
2 checks passed

@flaredispatch-fractalboxdev flaredispatch-fractalboxdev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AI code review — 💬 Comment

Risk tier: full · 0 critical · 1 warnings · 0 suggestions

Reviewers: security ⚠️ · performance 1 · code-quality 0 · documentation ⚠️ · release-management ⚠️ · compliance 0 · agents-md ⚠️

1. ⚠️ Warning — Timestamp ranking can allow duplicate long-running warms

📍 runs/contextful-cache-warm.ts:87

The supersession order relies only on 'head_commit.timestamp', which is not guaranteed to increase across pushes and can be equal for multiple commits. A newer default-branch head can therefore fail to supersede an older warm, leaving multiple potentially 5400-second containers compiling and uploading the same base lane. Use a monotonic push/event sequence or otherwise enforce latest-head ordering so stale warms are cancelled before consuming the compile budget.

📋 View full logs & reviewed diff ↗

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.

1 participant