Repository navigation
feat(cli): say what a described change would do on a terminal - #98
Conversation
tee8z
left a comment
There was a problem hiding this comment.
Requesting changes on 00bae89 (base #96 9296da7). The summary is well placed:
- It runs only for human formats, and
report_errorhandles the machine formats first, so--jsonand NDJSON are unchanged. - Exit code 6 is kept, and no request is sent.
- The summary uses the same body that the description shows, so private and secret fields stay out unless
--show-secretsis given. - Amounts keep their own currency.
Two fixes are needed.
P2: the summary can name a different wallet or webhook than the one the request targets. facts (src/dry_run.rs:174) labels the target with described.resource_id, which is body_id.or(invocation.resource_id) (src/input.rs). The request path, though, uses invocation.resource_id, and a raw --data body's id is accepted on any operation. Try voltage wallets update 1111… --org ORG --data @b.json --output table with {"id":"2222…","name":"x"} in b.json. The summary shows wallet_id 2222…, while the URL acts on 1111…. People read this summary to decide whether to add --execute, so it must name the target that the request hits. Use invocation.resource_id for the target fact, and add this case to facts_name_the_target_and_the_shown_values_only.
P2 (AGENTS.md: test every new early return): only the decorated terminal path and piped stderr are tested. Please also cover these:
--quiethides the summary but keeps› Send it.--jsonor--output ndjsonwith stderr on a terminal prints no summary and a JSON error (output.rs:320).
Nonblocking:
- The
Send itline hard-codesVOLTAGE_EXECUTE=1, whileapi.rsuses theEXECUTE_VARIABLEconstant. - The description's "Try it" pipes stdout with
2>&1 | cat. A piped stdout selects JSON, so stderr gets the JSON error, noterror: Described…. It needs--output table. - Arrays in the summary, such as webhook
events, are shown as raw JSON.
Validation on this head, in nix develop: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata, cargo test --locked (147 unit, 125 integration) and python3 scripts/check-coverage.py passed. CRAP: 678 measured functions, none at or above 20, highest endpoint at 18.00; 180 functions were unmeasured. CI is green.
00bae89 to
243fe63
Compare
A change without --execute now starts, on a terminal with table output, with "! Not sent: this would ..." and the target and values the description shows, and ends with "Send it: add --execute, or set VOLTAGE_EXECUTE=1" instead of an error line. The full description and exit code 6 are unchanged, and redirected stderr keeps the error line.
243fe63 to
b17d0ca
Compare
|
Review-body notes, in b17d0ca:
|
tee8z
left a comment
There was a problem hiding this comment.
Approved b17d0ca against feat/cli-look-03-login (#96 f9a1096). My findings are fixed:
- The summary's target comes from
invocation.resource_id, the path's target, so a raw--databody with anotheridno longer changes it, and a unit test covers that case. - New terminal tests cover
--json, which prints only the JSON error with no summary and noSend itline, and--quiet, which hides the summary and keepsSend it. - The
Send itline now usesEXECUTE_VARIABLE.
Validation on this head, in nix develop: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata, cargo test --locked (159 unit, 132 integration) and python3 scripts/check-coverage.py passed. CRAP: 708 measured functions, none at or above 20, highest wait_for_payment at 17.05. CRAP passed on its second run, after three pseudo-terminal login tests timed out in the instrumented suite on the first, the flakiness that #104 addresses. CI is green.
Stack position: 4 of 13 in the look-and-feel stack. Base:
feat/cli-look-03-login(#96).Problem
Since #54, a change without
--executeprints a description of its request and exits with code 6. On a terminal, that description is a debug-style field dump (run.reconcile,values_omitted, …) followed by a rederror: Described this change without sending it…. It does not say plainly what would happen, and a normal preview looks like a failure.Behavior
On a terminal with table output:
payments sendandreceivesay "send a payment" and "receive a payment". Other changes use the API's operation summary, lowercased, without a trailing period or " as a user" ("delete a wallet", "request a currency conversion quote").idgenerated only for the description are left out. A send'sdatafields are listed as its own (amount, notdata.amount). They use the samefield valuerenderer as tables, so amounts read1000000 msats.› Send it: …replaces theerror:line on a terminal. Exit code 6 is unchanged.error: Described this change…;--jsonand NDJSON are unchanged;--quiethides the summary but not the› Send itline.There's no prompt:
--executeis still the only approval, as #54 decided. The plan's "y/N" confirmation was written before #54 and was dropped.Try it on staging
Setup: Try a pull request on staging (added by #97). These commands send nothing, so any wallet works; find a wallet ID with
voltage wallets list --account me.Expect:
! Not sent: this would delete a wallet, thenwallet_id WALLET_ID, a blank line, the full description, and› Send it: add --execute, or set VOLTAGE_EXECUTE=1. Exit code 6 (echo $?).Expect: "this would receive a payment" with
amount 1000000 msats,payment_kind bolt11, andwallet_id. Then "this would create a new webhook", where the URL and name are not shown because the description omits them.Expect: piped, the old
error: Described this change without sending it…line and no summary. With--json, the JSON description and the JSON error, unchanged. With-q, no summary, but the› Send itline stays.Validation
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo machete --with-metadata,cargo test --locked(147 unit and 125 integration tests), andpython3 scripts/check-coverage.pyall pass.data, omitted and null values dropped, a generatediddropped, and a chosen--idkept.wallets deletewithout--executeon a terminal shows the summary block exactly, the details on stdout, the bold yellow!, a closing› Send itline, and noerror:; exit code 6; no request sent. Piped stderr keepserror: Described this changeand no summary.src/cli.rsendpoint, untouched);api::executeis 15.00.Docs
docs/concepts/safety-model.mdandCHANGELOG.md.