Skip to content

fix(cli): reject malformed approval grant lifetimes - #133806

Merged
steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/fix-cli-approval-expiry-strictness-20260831
Sep 1, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/fix-cli-approval-expiry-strictness-20260831

Conversation

@qingminglong

@qingminglong qingminglong commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where approvals resolve --expires-in-days silently accepted a numeric prefix: 10junk became 10 days and 1.5 became 1 day. The operator could resolve an approval with a lifetime different from the text supplied.

Why This Change Was Made

The CLI now uses the shared strict positive-integer parser already used by the standing-grant list command. One validation block rejects a present invalid value or a value above the existing 3650-day limit. The parser already establishes positivity and integrality, so their duplicate checks are removed. Omitted lifetimes still defer to the existing Gateway behavior, and valid lifetimes are forwarded as numbers.

User Impact

Malformed, fractional, empty, non-positive, and out-of-range values produce the existing whole-day validation error before approval.resolve. Scripts that relied on numeric-prefix coercion must pass the intended whole-day value explicitly. The existing 1–3650 range, approval decisions, grant ownership, configuration defaults, and Gateway protocol remain unchanged.

Evidence

  • Trusted main 8655892bb20 and stable v2026.8.1 contain the permissive parser. Three new tests failed on the baseline because 10junk, 1.5, and 1e3 unexpectedly reached resolution; the other 25 cases passed.
  • node scripts/run-vitest.mjs src/cli/exec-approvals-cli.pending-resolve.test.ts packages/normalization-core/src/number-coercion.test.ts passed all 58 tests after the fix. The CLI cases cover malformed inputs, the lower and upper bounds, a normal 30-day value, and omission of the override. Existing pending-list, decision, identity, and resolution cases remain covered.
  • Before the fix, the actual built CLI sent 10junk and 1.5 to an isolated loopback Gateway and both pending approvals became allowed. A valid 30 control also resolved successfully.
  • After the fix, the same real CLI rejected both malformed inputs with exit code 1 and --expires-in-days must be a whole number of days between 1 and 3650. Follow-up approval.get and exec.approval.list calls confirmed each approval remained pending and listed. The valid 30 control still resolved successfully.
  • Both runtime builds passed. The live proof used synthetic pending requests with no command consumer or automation source; no command ran and no standing grant was minted. The proof verifies the changed CLI/resolution boundary, while numeric forwarding is asserted in the CLI tests. All temporary Gateway state was removed with zero cleanup errors.
  • Full two-file Codex autoreview completed with no accepted/actionable findings. The complete changed-scope repository check passed, including types, lint, formatting, unused-export and owner-boundary guards. Published-head CI remains required before merge.

Representative command, using only an isolated test Gateway:

node dist/entry.js approvals resolve <synthetic-approval-id> allow-always --expires-in-days 10junk --json --url <loopback-url> --token <redacted>

Owner and Scope

The CLI owns parsing operator text before it calls the unified approval resolver. The Gateway already validates grantExpiresInDays as an integer from 1 through 3650 and retains ownership of approval transitions and frozen grant terms. This change fixes the malformed value at its producer without changing those contracts.

The permissive block was introduced by de12e0a06c1b; the raw parent and patch were checked directly. The sibling grant-list parser already uses the strict helper following #133361.

Production: +4/-8 (net −4). Tests: +68/-0. The latest ClawSweeper suggestion to consolidate redundant validation is applied. No new dependency, option, environment variable, auth policy, protocol, schema, or persistence behavior.

Thanks @qingminglong for the original fix and reproduction.

Maintainer-reviewed head: 374502a71e3c7053834865c2ff5ca90b7d1fa2a2. Contributor credit is preserved.

Exact-head CI exposed five 120-second subprocess timeouts in the existing Vitest worker-artifact transform suite. Investigation is in progress; this PR will remain open until the required gate passes. No timeout has been increased.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Aug 31, 2026
@qingminglong
qingminglong marked this pull request as ready for review August 31, 2026 05:01
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 6:06 AM ET / 10:06 UTC.

ClawSweeper review

What this changes

This PR makes approvals resolve --expires-in-days accept only whole positive day counts within the existing 1–3650 range and adds regression coverage for malformed, boundary, valid, and omitted values.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The focused repair is correct and still necessary: current main retains permissive numeric-prefix parsing, while this branch rejects malformed lifetime text before it can resolve an approval. Keep this PR open until its required exact-head CI gate passes.

Priority: P2
Reviewed head: 374502a71e3c7053834865c2ff5ca90b7d1fa2a2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, contract-aligned, and supported by real boundary evidence; required exact-head CI remains the only merge blocker.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed production owner is the CLI lifetime parser before approval.resolve; the PR body records an isolated real CLI and loopback Gateway before/after run where malformed values now exit before resolution and a valid 30-day control still resolves.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed production owner is the CLI lifetime parser before approval.resolve; the PR body records an isolated real CLI and loopback Gateway before/after run where malformed values now exit before resolution and a valid 30-day control still resolves.
Evidence reviewed 7 items Introduced repair: The PR-introduced hunk replaces Number.parseInt with the shared strict positive-integer parser, rejects absent parse results and values above 3650, and only forwards a validated number.
Current-main behavior: Fetched current main still uses Number.parseInt at this option, so it can accept a numeric prefix and does not already contain the branch repair.
Parser contract: The reused helper accepts only strict safe integer strings and then requires a value greater than zero, rejecting prefixes, fractions, scientific notation, blank input, zero, and negatives.
Findings None None.
Security None None.

How this fits together

The approvals CLI converts an operator’s resolution command into a Gateway request for a pending approval. An allow-always resolution may create a standing grant, so the CLI validates the lifetime before the Gateway records the decision.

flowchart LR
  A[Operator CLI command] --> B[Approval resolution CLI]
  B --> C[Validate lifetime text]
  C -->|invalid| D[CLI error]
  C -->|valid or omitted| E[Gateway approval resolver]
  E --> F[Recorded approval decision]
  F --> G[Standing grant terms]
Loading

Before merge

  • Resolve merge risk (P1) - Existing scripts that relied on numeric-prefix coercion will now receive a validation error; this is the intended compatibility change, but it should remain visible at merge.
  • Resolve merge risk (P1) - The exact-head CI gate currently fails with five worker-artifact transform subprocess timeouts. The available evidence does not tie those timeouts to this two-file parser change, but required CI must pass before merge.
  • Complete next step (P2) - The PR already contains the narrow repair and sufficient behavior evidence; the remaining action is to clear the required exact-head CI gate.
Agent review details

Security

None.

PR surface

Source -4, Tests +68. Total +64 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 8 -4
Tests 1 68 0 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 72 8 +64

Review metrics

Metric Value Why it matters
Production versus test delta production +4/-8 (net -4); tests +68/-0 The repair removes duplicated permissive validation while adding focused table-driven coverage for the affected CLI boundary.

Merge-risk options

Maintainer options:

  1. Accept strict CLI validation (recommended)
    Merge after exact-head CI passes, accepting that malformed numeric-prefix lifetime arguments now fail rather than silently creating a different-duration grant.
  2. Pause the behavior change
    Keep the PR open only if maintainers intend to preserve undocumented numeric-prefix coercion for existing scripts.

Technical review

Best possible solution:

Land the strict parser once exact-head CI is green, retaining the Gateway’s existing 1–3650 contract and the supplied real CLI boundary proof.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main’s Number.parseInt call makes the malformed-input path source-reproducible, and the PR body records an isolated before/after CLI-to-Gateway run for that path.

Is this the best way to solve the issue?

Yes. Reusing the canonical strict positive-integer parser at the CLI boundary fixes the producer-side coercion without changing the Gateway protocol, approval ownership, or stored grant terms.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against de64e911270f.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded CLI correctness repair that prevents malformed lifetime text from silently changing a standing grant’s duration.
  • merge-risk: 🚨 compatibility: The stricter CLI parser intentionally changes existing numeric-prefix arguments from successful coercion to a validation error.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed production owner is the CLI lifetime parser before approval.resolve; the PR body records an isolated real CLI and loopback Gateway before/after run where malformed values now exit before resolution and a valid 30-day control still resolves.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the CLI lifetime parser before approval.resolve; the PR body records an isolated real CLI and loopback Gateway before/after run where malformed values now exit before resolution and a valid 30-day control still resolves.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • qingminglong: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve or rerun the failing exact-head CI gate before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-31T05:08:11.188Z sha 00ee28c6b93c7dfca71f87fc4661c406aee34790 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T06:09:06.813Z sha b0fea86 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T07:31:27.702Z sha b0fea86 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T09:48:56.624Z sha 374502a :: needs maintainer review before merge. :: none

@qingminglong
qingminglong force-pushed the codex/fix-cli-approval-expiry-strictness-20260831 branch from 00ee28c to b0fea86 Compare August 31, 2026 06:02
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 31, 2026
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 31, 2026
Reuse the canonical strict parser and consolidate range validation without
changing valid or omitted grant terms. Cover malformed and boundary input.

Co-authored-by: qingminlong <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Maintainer revision and source-bound before/after evidence are now in the PR body. Contributor credit is preserved. The pending CI investigation is disclosed; no merge until the required gate passes.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The unchanged transform suite passed all six cases on Node 24.19 with two-CPU affinity (65.53 seconds), using the exact CI baseline compiler/test sources. Serial execution was slower and was rejected; no test or production changes were made. The isolated host differs from the CI runner, so the timeout cause remains unproven. One retry of the failed jobs on the unchanged head is now running: https://github.com/openclaw/openclaw/actions/runs/33493484114. Required CI must pass before landing.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Required exact-head CI is green for 374502a71e3c7053834865c2ff5ca90b7d1fa2a2: https://github.com/openclaw/openclaw/actions/runs/33493484114.

Attempt 2 passed on the unchanged head. The earlier subprocess timeout and independent unchanged-suite proof remain documented; no test or timeout changes were made.

@steipete
steipete merged commit 90dba1a into openclaw:main Sep 1, 2026
385 of 387 checks passed
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
* fix(cli): reject malformed approval grant lifetimes

* fix(cli): validate whole approval grant lifetimes

Reuse the canonical strict parser and consolidate range validation without
changing valid or omitted grant terms. Cover malformed and boundary input.

Co-authored-by: qingminlong <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: qingminlong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants