Repository navigation
fix(cli): make single-tx publish receipts unrepresentable-if-contradictory (#1578) - #1589
Conversation
…1578) NamespaceOutcome and RevokeOutcome carried four loosely-coupled fields (dry_run, in_flight, tx, plus a decoded Option) that admitted 16 combinations for a domain with five states. single_tx_status was a precedence chain that masked contradictions instead of detecting them: a dry_run + tx:Some literal printed `status=dry_run tx=0x…` while JSON derived `submitted` from tx.is_some(), so the receipt carried `"submitted": true` next to `"status": "dry_run"`. Replace the field soup with a status enum per command (NamespaceStatus, RevokeStatus), modeled on SeatOutcome, so text and JSON rendering derive tx/label/id from one source of truth and illegal combinations are unrepresentable. Delete single_tx_status; namespace_failure_context and revoke_failure_context become total matches over the status, deleting the `landed` local that duplicated part of the state machine. AssignOutcome is unchanged (its dry_run is genuinely orthogonal). JSON keys and shape for every reachable state are preserved, so --json consumers are unaffected. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
🟢 Ready to approve
The refactor removes representable contradictory states while preserving the receipt output contract, and the updated tests explicitly cover the previously possible inconsistency.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR refactors the decdn CLI publish command’s single-transaction receipts to make contradictory receipt states unrepresentable, fixing the invariant gap described in #1578. It replaces loosely-coupled “field soup” (dry-run / in-flight / optional hash / optional decoded payload) with per-command status enums so both text and JSON rendering derive from a single source of truth.
Changes:
- Introduced
NamespaceStatusandRevokeStatusenums and refactoredNamespaceOutcome/RevokeOutcometo carry a single status value. - Removed
single_tx_statusand updated rendering + failure-context helpers to match exhaustively on the new status enums. - Updated and expanded tests to pin the original contradictory dry-run/submitted defect and to cover per-variant label/hash derivation.
File summaries
| File | Description |
|---|---|
| crates/cli/src/commands/publish.rs | Replaces single-tx outcome field combinations with status enums for consistent, non-contradictory receipt rendering; updates failure-context logic and tests accordingly. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Coverage reportTotal: 80.32% (was 80.30%, ▲ +0.02%) — 56639/70517 lines
History
|
#1589 landed #1578 on main, reshaping the single-tx publish receipts into per-command status enums (`NamespaceStatus`, `RevokeStatus`) and extending `SeatOutcome`, replacing the `dry_run`/`in_flight`/`tx` field soup this branch had also been editing. Only `crates/cli/src/commands/publish.rs` conflicted. Resolved by adopting main's enum shape as the base and re-applying the #1550/#1577 semantics onto it: - Extend `NamespaceStatus`, `RevokeStatus`, and `SeatOutcome` with `Reverted` (mined, keeps its hash — #1550) and `MaybeBroadcast` (transport failure, no hash, may still mine — #1577), each with matching `label()`/`tx()`. - Add a `submitted()` method to the single-tx status enums returning `Option<bool>`, so `submitted` serializes to `true`/`false`/`null` (null for `MaybeBroadcast`) and text prints `submitted=unknown` there. - Thread `SendOutcome` from `send_for_receipt` into the three commands, mapping each variant to the reshaped status; `SeatOutcome::from_send` derives seats. - Extend the failure-context helpers and the assign guidance note for the two new states; add tests for `reverted`/`maybe_broadcast` on top of main's. `tx.rs` (the `SendOutcome` type and send-error classifier) did not conflict. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Fixes #1578.
Problem
NamespaceOutcomeandRevokeOutcomeincrates/cli/src/commands/publish.rseach carried four loosely-coupled fields —dry_run: bool,in_flight: bool,tx: Option<B256>, plus a decodedOption— admitting 16 combinations for a domain with only five mutually-exclusive states.single_tx_statuswas a precedence chain that masked contradictions instead of detecting them:So a
dry_run: true+tx: Someliteral printedstatus=dry_run tx=0x…, while JSON derivedsubmittedindependently fromtx.is_some()— emitting"submitted": truenext to"status": "dry_run", two keys of one receipt contradicting each other. Every contradictory state is currently unreachable, but the guarantee was one dropped struct field wide.Fix — one source of truth per command
Replaced the field soup with a status enum per command, modeled on the existing
SeatOutcome:NamespaceStatus=DryRun | Failed | InFlight(B256) | Created { tx: B256, id: Option<u64> }RevokeStatus=DryRun | Failed | InFlight(B256) | Revoked(B256)tx(),label(), andnamespace_id()derive from the variant, so text and JSON rendering read from one value and can no longer disagree. Illegal combinations (a hash on a dry run, acreatedwith no hash) are now unrepresentable.single_tx_status.namespace_failure_context/revoke_failure_contextbecame total matches over the status, deleting thelandedlocal that duplicated part of the state machine.submittedis nowstatus.tx().is_some(), so it can never disagree withstatus.AssignOutcomeis left as-is — itsdry_run: boolis genuinely orthogonal (per-command, not per-operator), as the issue scope specifies.Compatibility
The JSON contract is unaffected: these structs are private to the module, and
write_*_outcomeemits the same keys/shape (status,submitted,tx,namespace_id,revoked_operator) for every reachable state. The e2e consumers incrates/e2e/tests/cli_publish.rsandcrates/e2e/tests/g_origin_01_publish.rsswitch onstatus/ readnamespace_idexactly as before.Tests
namespace_dry_run_carries_no_tx_and_is_not_submittedpinning the exact cli: single-tx outcome structs can represent contradictory receipts (status=dry_runbesidesubmitted: true) #1578 defect (dry run carries no hash and is notsubmitted, in both text and JSON).namespace_created_with_id_emits_the_idand per-enum*_status_labels_and_hashes_match_their_statestests covering the rendering / derivation of every state.Verification
cargo build -p decdn-cli✓cargo clippy -p decdn-cli✓ (clean; anti-panic policy respected — no unwrap/expect/panic/indexing in non-test code)cargo fmt -p decdn-cli -- --check✓cargo nextest run -p decdn-cli✓ (409 passed, 0 failed)🤖 Generated with Claude Code