Skip to content

feat(remediate): shipper yank --plan executes a saved plan (#98 PR 5)#139

Merged
EffortlessSteven merged 1 commit into
mainfrom
feat/98-yank-from-plan
Apr 18, 2026
Merged

feat(remediate): shipper yank --plan executes a saved plan (#98 PR 5)#139
EffortlessSteven merged 1 commit into
mainfrom
feat/98-yank-from-plan

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

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

  • `YankEntry` / `YankPlan` derive `Deserialize`. `filter` field moves from `&'static str` to `Cow<'static, str>` to allow owned strings from disk without breaking the construction path.
  • `plan_yank::load_plan_from_path` — thin helper mirroring `load_receipt_from_path`.
  • CLI: `shipper yank --plan `. Mutually exclusive with `--crate` / `--version` / `--reason` (clap `conflicts_with`).
  • Handler: iterates entries in order, emits `PackageYanked` event per invocation, halts on first non-zero cargo exit.

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:

  • Execute yank plans end-to-end.
  • Events-as-truth: PackageYanked event per invocation, including failures with real exit codes.

Does not:

  • Resume interrupted plan runs — re-run is idempotent, operator discipline covers it.
  • `fix-forward --plan` execution — needs Cargo.toml edit tooling; deserves its own PR.

Tests

3 new unit tests (8 total in `plan_yank::tests`):

  • YankPlan JSON round-trips: entries + order + per-entry reason preserved
  • `load_plan_from_path` errors cleanly on missing file
  • `load_plan_from_path` errors cleanly on malformed JSON

`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

  • `cargo test -p shipper --lib plan_yank` — 8/8 pass
  • `cargo clippy --workspace --all-targets --all-features -- -D warnings` clean
  • `cargo fmt --all --check` clean
  • CI multi-OS green

@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 27 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3eba60ae-d491-43d7-8487-4926f618f5b9

📥 Commits

Reviewing files that changed from the base of the PR and between 3a9b491 and 3a520fc.

⛔ Files ignored due to path filters (1)
  • crates/shipper-cli/tests/snapshots/e2e_expanded__help_yank.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • crates/shipper/src/cli/mod.rs
  • crates/shipper/src/engine/plan_yank.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/98-yank-from-plan

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist 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.

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.

Comment on lines +758 to +764
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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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());

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment on lines +760 to +764
let registry_name = opts
.registries
.first()
.map(|r| r.name.clone())
.unwrap_or_else(|| yank_plan.registry.clone());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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

codecov Bot commented Apr 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 26.24113% with 104 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/shipper/src/cli/mod.rs 0.00% 101 Missing ⚠️
crates/shipper/src/engine/plan_yank.rs 92.50% 3 Missing ⚠️

📢 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.
@EffortlessSteven EffortlessSteven merged commit f744091 into main Apr 18, 2026
36 of 38 checks passed
@EffortlessSteven EffortlessSteven deleted the feat/98-yank-from-plan branch April 18, 2026 09:24
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.

Receipt-driven yank planning and fix-forward for compromised releases

1 participant