feat(xtask): add ci plan subcommand (Rust-native PR planner)#3758
feat(xtask): add ci plan subcommand (Rust-native PR planner)#3758EffortlessSteven wants to merge 1 commit intomainfrom
Conversation
Replaces the inline Python planner that previously lived in
.github/workflows/pr-plan.yml. The Rust version is unit-testable with
fixtures and emits a stable ci-plan.json schema for downstream tooling
(budget warnings, label-aware gating, future learned-budget calibration).
cargo run --locked -p xtask -- ci plan \
--base "$BASE_SHA" \
--head "$HEAD_SHA" \
--labels-json '["full-ci"]' \
--json-out ci-plan.json \
--github-summary "$GITHUB_STEP_SUMMARY"
Implementation:
- xtask/src/ci_plan.rs: pure planner (plan_for) + git-diff wrapper
(git_changed_files) + JSON / step-summary entry point (run).
- xtask/src/main.rs: new `Cmd::Ci { command: CiCmd }` subcommand and
`CiCmd::Plan` variant.
- .github/workflows/pr-plan.yml: replace ~120 lines of inline Python
with a single cargo run invocation.
Tests (10/10 passing):
- empty PR → 0 lanes, pennies band
- docs-only PR → guards lane only
- rust crate change → Core / Feature Matrix PR / MSRV / ripr / guards
- GPU kernel change → native compile lane (no Docker without label)
- full-ci label → all label-gated lanes fire
- ripr-eligible PR → advisory lane fires
- test-only Rust diff → ripr advisory does NOT fire
- ripr label on docs-only PR → ripr advisory still fires
- high-LEM full-ci on kernel change → over-hard-ceiling band
- parse_git_output strips blank lines
Schema additions vs the inline Python version:
- lane.blocking: bool (whether this lane blocks merges today)
- lane.stage: "required" | "default" | "label" | "advisory"
These are placeholders for future budget enforcement (PR O) and ripr
promotion rules (PR P).
Out of scope (future PRs):
- Hoist hard-coded LEM estimates into policy/ci-budget.toml,
policy/ci-lanes.toml, policy/ci-risk-packs.toml (PR L).
- actual LEM collection / ci-actuals.json (PR N).
- soft budget warnings + hard ceiling at 125 LEM without full-ci (PR O).
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Replaces the inline Python planner in
.github/workflows/pr-plan.yml(added in #3742) with a Rust-native, unit-testablextask ci plansubcommand. This is PR K in the multi-PR CI roadmap (A–H merged; I, J, K open).Why
The inline Python version was the right first move (#3742 shipped fast and exercised the LEM model end-to-end) but it could not be tested without a CI run. A YAML-embedded planner drifts; a Rust planner can be tested with fixtures and held to the same review bar as the rest of the codebase. This is the foundation for everything that follows: PR L (policy files), PR N (actuals), PR O (budget warnings), and PR P (ripr promotion rules) all consume
ci-plan.json.Implementation
xtask/src/ci_plan.rs— pureplan_for(changed, labels) -> Planfunction +git_changed_files(...)wrapper +run(...)entry point. Same touched-area buckets and lane logic as the Python version, plus the ripr lane (rust_production,riprlabel).xtask/src/main.rs— newCmd::Ci { command: CiCmd }subcommand andCiCmd::Planvariant..github/workflows/pr-plan.yml— drops ~120 lines of inline Python in favor of a singlecargo runinvocation. Adds a small Rust toolchain install +Swatinem/rust-cachefor the xtask compile.Schema
Two additions vs the inline Python version:
lane.blockingboollane.stage"required" | "default" | "label" | "advisory"The rest of the schema (
posture,touched,labels,lanes[].name/lem/reason,estimated_lem,band) is unchanged from #3742.Tests (10/10 passing)
docs-onlySmoke output
Test plan
ci-plan.jsonartifact uploaded with new schema.Out of scope (future PRs)
policy/ci-budget.toml,policy/ci-lanes.toml,policy/ci-risk-packs.toml.ci-actuals.json).full-ci).lane.stagetaxonomy added here.https://claude.ai/code/session_01S2yTnEYJcA3G2CyZn9bY4v
Generated by Claude Code