Repository navigation
Description
Found during review of #1568. Not a live bug — every state is currently unreachable — but the encoding is what makes it unreachable, and that guarantee is one dropped struct field wide.
Problem
NamespaceOutcome, VettingOutcome and RevokeOutcome in crates/cli/src/commands/publish.rs each carry four loosely-coupled fields — dry_run: bool, in_flight: bool, tx: Option<B256>, plus a decoded Option (namespace_id / ready_at). The domain has five mutually exclusive states; the fields admit 16 combinations.
single_tx_status is a precedence chain, so it masks contradictions instead of detecting them:
if dry_run { "dry_run" } else if in_flight { "unknown" } else if tx.is_some() { confirmed } else { "failed" }Concretely, for NamespaceOutcome:
dry_run: true+tx: Some→ text printsstatus=dry_run tx=0x…, and JSON is worse:submittedis derived independently fromtx.is_some(), so the object carries"submitted": truenext to"status": "dry_run"— two keys of the same receipt contradicting each other.dry_run: true+in_flight: true→dry_runwins, so a broadcast transaction reports as a dry run. That is the precise inversion of what cli: post-receipt failures inpublish namespace creatediscard a recorded tx hash and the new namespace id #1549 fixed.in_flight: true+tx: None→status=unknown submitted=false: anunknownwith no hash is the one state an operator cannot act on at all, and is exactly whatsend_for_receipt's out-param exists to prevent.
All are well-formed struct literals. None is a compile error. Each renders as confident, plausible output.
The distance from correct to wrong is one field in a struct-update literal — and that shape is already live in the file: namespace_dry_run_and_submitted_formats builds its done case with ..base where base.dry_run == true, carrying an explicit dry_run: false line for exactly this reason. Delete that line and it still compiles, printing status=dry_run tx=0x5555.
The invariants are enforced today by a single assignment (outcome.in_flight = outcome.tx.is_some()) in each command's Err arm, plus a landed function local that no type relates to in_flight.
Direction
SeatOutcome (same file) is already the right shape — Seated(B256) | InFlight(B256) | Failed | NotAttempted with tx() and label() derived from the variant. Give the single-tx commands the same treatment:
enum NamespaceStatus {
DryRun,
Failed,
InFlight(B256),
Created { tx: B256, id: Option<u64> },
}This also lets namespace_failure_context / vetting_failure_context / revoke_failure_context become total matches over the same value the renderer matches on, deleting the landed local that currently duplicates part of the state machine.
Scope
Must convert all three at once and delete single_tx_status — converting one leaves three different outcome shapes in one file, which is worse for a reader than the current two and destroys the cross-command symmetry established by #1548. AssignOutcome stays as-is: its dry_run: bool is genuinely orthogonal (per-command, whereas seats are per-operator), as its own doc comment explains.
The JSON contract is unaffected — these structs are private to the module, so they mirror the schema rather than being it. write_*_outcome keeps emitting the same keys, which is what crates/e2e/tests/cli_publish.rs and crates/e2e/tests/g_origin_01_publish.rs consume. submitted should become status.tx().is_some() so it can no longer disagree with status.
Explicit non-goal: do not add debug_assert!s to single_tx_status as a half-measure — it adds a panic path to a CLI, against the workspace anti-panic policy.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fix(cli): make the namespace-create recovery path one that actually w…
fix(cli): print the namespace-create receipt before a post-receipt fa…
fix(cli): make single-tx publish receipts unrepresentable-if-contradi…
Merge main into #1550/#1577 fix, reconciling with #1578