Repository navigation
feat(cli): make commands safe to rerun with --request-id - #426
Open
PiquelChips wants to merge 1 commit into
Open
PiquelChips wants to merge 1 commit into
PiquelChips wants to merge 1 commit into
Conversation
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 35 minutes. View limit details
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. |
PiquelChips
marked this pull request as ready for review
November 10, 2026 18:50
PiquelChips
force-pushed
the
feat/cli-request-id
branch
3 times, most recently
from
November 12, 2026 21:33
dccd233 to
50acdda
Compare
- A global --request-id ID, else PIQUELD_REQUEST_ID, else a new UUID, is sent as the command's Idempotency-Key. Changes to applications, environments and previews honor it; secret, notification, account, token and sign-in commands, and preview prune, don't. - The daemon's replay fingerprint leaves out the preconditions a caller inspects beforehand (expected generation, expected application ID), so a rerun with the same ID returns the original receipt instead of request_id_conflict, and never repeats the change. Different content or force under the same ID still conflicts. - Local snapshot commits are dated like HEAD, so a rerun of preview deploy --local makes the same commit and replays. - One is_request_id rule, 1 to 128 of [A-Za-z0-9-_.:], is shared by the daemon and the CLI.
PiquelChips
force-pushed
the
feat/cli-request-id
branch
from
November 13, 2026 13:05
50acdda to
392d745
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a command lost its connection mid-way, there was no safe way to run it again: each run made up a fresh idempotency key, so a rerun could repeat a change the daemon had already accepted. Reusing a key didn't help either, because the daemon's replay fingerprint included the preconditions the CLI inspects, which the first run had just changed, so a rerun got 409
request_id_conflict.--request-id ID(CLI-10, D9 as revised), a global flag withPIQUELD_REQUEST_IDas fallback, names the command, and the CLI sends it as is asIdempotency-Key. Without either, the CLI uses a new UUID as before. No command sends more than one keyed mutation, so there is no per-mutation numbering.True replay in the daemon: the receipt fingerprint now leaves out the preconditions a caller inspects beforehand (
expected_generation, a save'sexpected_application_id) and keeps the mutation itself andforce. A rerun with the same ID returns the original receipt and never repeats the change. The same ID with different content, or with--forceadded, still fails withrequest_id_conflict. Fingerprints keep their[mutation, null, force]shape, so receipts of requests sent without preconditions still match. Receipts last 24 hours, and those stored by an older daemon with a precondition conflict on a rerun across the upgrade instead of replaying: a safe failure, never a duplicate.Scope: only changes to applications, environments and previews honor the key. Secret, notification, account, token and sign-in commands, and
preview prune, ignore it and make their change again when rerun; the help andcli.mdsay so.preview deploy --localreplays too: its snapshot commit is now dated likeHEAD, so the same worktree makes the same commit.IDs may be 1 to 128 characters, like the daemon accepts, through one shared
is_request_idinpiqueld-core.cli.md,api.mdand the flag help describe the behaviour.Proof: a new daemon contract test reruns
apply_and_deploywith the same ID and re-inspected preconditions after acceptance, and gets the original operation without a second change; a changed manifest under that ID conflicts. The store's legacy-receipt test now checks that another generation replays whileforceconflicts. The CLI retry test checks that--request-id agent-run-7is sent as is on both attempts, and a snapshot test that an unchanged worktree snapshots to the same commit. The daemon'sapi_contractsuite (100), its receipt, promotion and restore tests,cargo nextest run -p piquelctl -p piqueld-client -p piqueld-core(342),just lintand fmt pass.Note
Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 (via T3 Code)
🤖 Generated with Claude Code