Repository navigation
feat(cli): operator terms display + acceptance at registration (#1077) - #1079
Conversation
Implements the operator-facing half of ADR 019 § Terms Acceptance (the on-chain enforcement shipped in #1078). - New `commands::terms`: embeds the canonical TERMS.md (`include_str!`), so the displayed text is the exact preimage of the recorded hash. `decide` is the pure acceptance policy; `ensure_accepted` is the IO wrapper. - `decdn node register` / `decdn setup` read the network's `currentTermsHash`, then gate registration on acceptance: - Terminal: print the terms + version + hash, prompt `[y/N]` (default no). - Headless/automation: require `--accept-terms` (errors clearly without it) — keeps scripted provisioning working while keeping consent explicit. - Stale client: if the embedded terms hash != the network's currentTermsHash, refuse — never sign terms the operator wasn't shown (ADR 019 § 281). - `--accept-terms` added to both commands (setup keeps it separate from `--yes`, which only skips the bond confirmation). - Terms display + prompt go to stderr so `--json` stdout stays clean. Tests: pure `decide` matrix, real `ensure_accepted` branches (headless/flag/ stale), and a lock on `keccak256(TERMS.md)` so a terms edit is a gated event paired with a governance setCurrentTermsHash bump. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughAdds a ChangesOperator terms acceptance for node registration
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request implements operator-terms acceptance at registration (ADR 019) by embedding the canonical terms in the binary, verifying their hash against the network's current terms, and prompting the operator for acceptance (or accepting via a new --accept-terms CLI flag). Feedback on the changes suggests checking both stdin and stderr terminal status to prevent potential silent hangs when stderr is redirected.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR implements the CLI-side operator terms acceptance flow required by ADR 019 during node registration, ensuring the registration signature commits to the network’s currentTermsHash and that operators explicitly accept the displayed terms (or pass --accept-terms in headless automation).
Changes:
- Add a new
commands::termsmodule that embedsTERMS.md, computeskeccak256hash, and enforces acceptance via a prompt/flag policy with tests. - Add
--accept-termsto bothdecdn setupanddecdn node register, and gate registration on acceptance + on-chaincurrentTermsHash. - Thread
terms_hashinto the registration submission/signature path.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/common/src/cli/setup.rs | Adds --accept-terms flag to setup CLI args. |
| crates/common/src/cli/node.rs | Adds --accept-terms flag to node registration CLI args. |
| crates/cli/src/commands/terms.rs | New module embedding terms text, hashing, acceptance policy, prompting, and tests. |
| crates/cli/src/commands/setup.rs | Reads currentTermsHash and enforces acceptance before registration in setup flow. |
| crates/cli/src/commands/register.rs | Reads currentTermsHash, enforces acceptance (but currently skipped on --dry-run), and passes terms_hash into signing/submission. |
| crates/cli/src/commands/mod.rs | Exposes the new terms command module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…for terms Gemini review on #1079: if stderr is redirected but stdin is a TTY, the terms + prompt print to the invisible stderr and the process blocks on stdin — a silent hang. Gate the interactive path on both streams being terminals; otherwise fall back to requiring --accept-terms. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/cli/src/commands/setup.rs`:
- Around line 335-345: The terms acceptance check in setup happens too late,
allowing bond::execute to commit before refusal or stale terms can abort the
flow. Move the currentTermsHash/ensure_accepted logic in setup.rs to run before
calling bond::execute, and gate it on !already_registered so registration/bond
submission only proceeds after acceptance. Use the existing setup path around
bond::execute, currentTermsHash, and terms::ensure_accepted to keep the
acceptance gate ahead of any transaction side effects.
In `@crates/cli/src/commands/terms.rs`:
- Around line 81-125: The interactive prompt path in ensure_accepted blocks a
tokio worker thread because it performs synchronous stderr/stdin I/O when called
from async handlers like setup::run and register::run. Move only the prompt
branch off the runtime thread by wrapping the print_terms and prompt_yes_no flow
in spawn_blocking, or convert the prompt to async stdin handling, while keeping
the non-interactive Decision branches unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 81d63f3f-34a9-408a-9c8a-31ac64c98507
📒 Files selected for processing (6)
crates/cli/src/commands/mod.rscrates/cli/src/commands/register.rscrates/cli/src/commands/setup.rscrates/cli/src/commands/terms.rscrates/common/src/cli/node.rscrates/common/src/cli/setup.rs
Review round on #1079 (Copilot + CodeRabbit): - register --dry-run now also enforces terms acceptance: a dry run still emits a real, submit-able signature committing to termsHash, so it must not be produced over unseen/stale terms. (Copilot) - setup accepts terms BEFORE bond::execute (gated on !already_registered) so a refusal / stale-client aborts before the bond is spent, not after. Extracted `accept_terms_if_registering` helper (keeps setup::run under the cognitive- complexity limit). (CodeRabbit) - New `terms::ensure_accepted_async` runs the blocking prompt via spawn_blocking so it never parks a tokio worker; call sites use it. (CodeRabbit) - (stderr-redirect interactive check already landed in the prior commit.) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 81.99% (was 82.06%, ▼ 0.07%) — 42468/51797 lines
History
|
Closes #1077. Implements the operator-facing half of ADR 019 § Terms Acceptance — the on-chain enforcement + governor-swappable
currentTermsHashshipped in #1078.Behaviour
decdn node register/decdn setupread the network'scurrentTermsHash, then gate registration on acceptance:Accept these operator terms? [y/N](default no)--accept-terms; error clearly without it — scripted provisioning keeps working, consent stays explicitcurrentTermsHash, refuse — never sign terms the operator wasn't shown (ADR 019 §281)commands::terms: embeds the canonicalTERMS.mdviainclude_str!, so the displayed text is the exact preimage of the recorded hash (no external document to fetch/substitute).decideis the pure policy;ensure_acceptedis the thin IO wrapper.--accept-termsadded to both commands. Insetupit's separate from--yes(which only skips the bond-amount confirmation) — terms acceptance is always its own explicit act.--jsonstdout stays machine-parseable.Design choice
Prompt-with-flag-fallback (chosen over interactive-only / flag-only): interactive operators get your y/N flow; headless operator provisioning (
decdn setupin CI/scripts) uses--accept-termsinstead of hanging on a prompt.Tests
decidematrix (stale precedence, flag, TTY, headless).ensure_acceptedbranches (the test harness has no TTY, so headless/flag/stale run for real against the actual embedded hash).keccak256(TERMS.md)pinned to0x7da33feb…(==cast keccakof the raw file), so a terms edit is a deliberate, test-gated event that must be paired with a governancesetCurrentTermsHashbump + newCURRENT_TERMS_HASHdeploy value.Local:
cargo fmt/clippyclean, 622 cli/common tests pass, binary--helpshows the flag in both commands.🤖 Generated with Claude Code
Summary by CodeRabbit
--accept-termsoption for setup and node registration.--accept-terms.