feat(remediate): shipper yank --plan executes a saved plan (#98 PR 5)#139
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 27 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ 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 |
There was a problem hiding this comment.
Code Review
This pull request introduces a plan execution mode for the yank command, enabling batch yank operations from a JSON plan file. It updates the CLI to support a --plan argument that is mutually exclusive with individual crate details and implements the orchestration logic to process plan entries sequentially. Feedback was provided to optimize workspace root retrieval and ensure registry resolution correctly prioritizes CLI overrides.
| let workspace_root = std::env::current_dir() | ||
| .context("failed to resolve current dir for plan execution")?; | ||
| let registry_name = opts | ||
| .registries | ||
| .first() | ||
| .map(|r| r.name.clone()) | ||
| .unwrap_or_else(|| yank_plan.registry.clone()); |
There was a problem hiding this comment.
The workspace_root can be retrieved directly from the already resolved planned workspace instead of calling std::env::current_dir(). Additionally, the registry resolution logic should respect the singular --registry CLI flag as an override before falling back to the plan's registry.
| let workspace_root = std::env::current_dir() | |
| .context("failed to resolve current dir for plan execution")?; | |
| let registry_name = opts | |
| .registries | |
| .first() | |
| .map(|r| r.name.clone()) | |
| .unwrap_or_else(|| yank_plan.registry.clone()); | |
| let workspace_root = &planned.workspace_root; | |
| let registry_name = opts | |
| .registries | |
| .first() | |
| .map(|r| r.name.clone()) | |
| .or_else(|| cli.registry.clone()) | |
| .unwrap_or_else(|| yank_plan.registry.clone()); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb52a1992f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let registry_name = opts | ||
| .registries | ||
| .first() | ||
| .map(|r| r.name.clone()) | ||
| .unwrap_or_else(|| yank_plan.registry.clone()); |
There was a problem hiding this comment.
Use plan registry when executing yank plans
In yank --plan mode, registry selection currently prefers opts.registries.first() over the registry embedded in the saved plan, so passing global multi-registry flags (for example --registries or --all-registries) can execute every yank against a different registry than the reviewed plan. This is especially risky because the preceding log line reports yank_plan.registry, so operators may believe they are yanking one registry while actually mutating another.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Closes the remaining plan-execution gap in #98. \`shipper plan-yank --format json\` emits a YankPlan; \`shipper yank --plan <PATH>\` walks that plan and invokes \`cargo yank\` per entry. - \`YankEntry\` / \`YankPlan\` now derive \`Deserialize\` so plans round-trip via \`--format json\` → file → \`--plan\`. The \`filter\` field moves from \`&'static str\` to \`Cow<'static, str>\` so owned strings coming off disk don't require allocation in the construction path. - \`plan_yank::load_plan_from_path\` — thin helper mirroring \`load_receipt_from_path\`. - CLI: \`shipper yank --plan <PATH>\`. Mutually exclusive with \`--crate\` / \`--version\` / \`--reason\` (clap \`conflicts_with\`); those become optional in plan mode. - Handler: iterates entries in order, emits \`PackageYanked\` event per invocation, halts on first non-zero cargo exit (reverse-topo plan means every downstream entry would be failing to yank a dependent of a crate we just failed on — continuing is damage). **Does:** - Execute yank plans end-to-end. - Correct halt-on-failure semantics. - Events-as-truth: every invocation writes a PackageYanked event (with real exit code) to events.jsonl, including failures. **Does not:** - Resume interrupted plan runs. First yank is destructive on the registry; re-running the plan with the same reason is idempotent (cargo yank of an already-yanked version is a no-op), so the simplest fix is to just re-run the plan, and operator discipline picks up the rest. - Add a \`fix-forward\` executor. That requires Cargo.toml version bumps which are workspace-edit territory — deserves its own PR with --dry-run / --apply / git-cleanliness guards. 3 new unit tests (8 total in \`plan_yank::tests\`): - YankPlan JSON round-trips: serialize, write, load → entries + order preserved, per-entry reason preserved. - \`load_plan_from_path\` errors cleanly on missing file. - \`load_plan_from_path\` errors cleanly on malformed JSON. Regenerated \`yank --help\` snapshot. With PR #138 (starting-crate) and this one, #98's acceptance checklist is fulfilled: - [x] Receipt fields (compromised_at/compromised_by/superseded_by) — PR #132 - [x] plan-yank --from-receipt + --starting-crate + --reason — PR #132 + #138 - [x] shipper yank executes a plan — **this PR** - [ ] shipper fix-forward --plan executes a plan — follow-on (needs Cargo.toml edit tooling) - [x] Docs distinguish yank semantics — PR #134 The fix-forward executor is the last remaining #98 piece. It's cleanly deferred because it adds workspace-edit scope; this PR keeps the execution story for yank self-contained.
fb52a19 to
3a520fc
Compare
Summary
Closes the plan-execution gap in #98. `shipper plan-yank --format json` emits a `YankPlan`; `shipper yank --plan ` walks that plan and invokes `cargo yank` per entry. Round-trip-safe via JSON.
What's new
Why halt-on-failure
The plan is reverse-topological. If yank N fails, yank N+1 targets a dependent of a crate we just failed to yank — continuing is just more damage. Operator reviews the stderr, fixes the underlying issue, re-runs the plan (cargo yank is idempotent for already-yanked versions).
Scope
Does:
Does not:
Tests
3 new unit tests (8 total in `plan_yank::tests`):
`yank --help` snapshot regenerated.
Closes most of #98
With #138 (starting-crate) and this one, #98's acceptance is:
Ready to close #98 with a comment pointing at this chain, leaving fix-forward execution as a scoped follow-on.
Test plan