Skip to content

fix(cli): make single-tx publish receipts unrepresentable-if-contradictory (#1578) - #1589

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/agitated-yalow-8b0d6a
Aug 4, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/agitated-yalow-8b0d6a

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Fixes #1578.

Problem

NamespaceOutcome and RevokeOutcome in crates/cli/src/commands/publish.rs each carried four loosely-coupled fields — dry_run: bool, in_flight: bool, tx: Option<B256>, plus a decoded Option — admitting 16 combinations for a domain with only five mutually-exclusive states. single_tx_status was a precedence chain that masked contradictions instead of detecting them:

if dry_run { "dry_run" } else if in_flight { "unknown" } else if tx.is_some() { confirmed } else { "failed" }

So a dry_run: true + tx: Some literal printed status=dry_run tx=0x…, while JSON derived submitted independently from tx.is_some() — emitting "submitted": true next 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(), and namespace_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, a created with no hash) are now unrepresentable.

  • Deleted single_tx_status.
  • namespace_failure_context / revoke_failure_context became total matches over the status, deleting the landed local that duplicated part of the state machine.
  • submitted is now status.tx().is_some(), so it can never disagree with status.

AssignOutcome is left as-is — its dry_run: bool is 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_*_outcome emits the same keys/shape (status, submitted, tx, namespace_id, revoked_operator) for every reachable state. The e2e consumers in crates/e2e/tests/cli_publish.rs and crates/e2e/tests/g_origin_01_publish.rs switch on status / read namespace_id exactly as before.

Tests

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

…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]>
Copilot AI lite review requested due to automatic review settings August 4, 2026 12:10
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 95ec4c77-4c5f-4f7a-832f-dd7359b987de

📥 Commits

Reviewing files that changed from the base of the PR and between c310d85 and be14a1b.

📒 Files selected for processing (1)
  • crates/cli/src/commands/publish.rs

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

Copilot AI 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.

🟢 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 NamespaceStatus and RevokeStatus enums and refactored NamespaceOutcome / RevokeOutcome to carry a single status value.
  • Removed single_tx_status and 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.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Coverage report

Total: 80.32% (was 80.30%, ▲ +0.02%) — 56639/70517 lines

File Coverage Lines Δ
crates/cli/src/commands/publish.rs 75.36% 792/1051 ▲ +1.75%
History
Commit Total Δ vs base
be14a1b (HEAD) 80.32% ▲ +0.02%

@alpergundogdu
alpergundogdu merged commit 85a5ebe into main Aug 4, 2026
48 of 50 checks passed
@alpergundogdu
alpergundogdu deleted the claude/agitated-yalow-8b0d6a branch August 4, 2026 12:54
alpergundogdu added a commit that referenced this pull request Aug 4, 2026
#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]>
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.

cli: single-tx outcome structs can represent contradictory receipts (status=dry_run beside submitted: true)

2 participants