Skip to content

feat(wallet): safely reuse ClawRouter signer and spend limits - #118

Closed
A1igator wants to merge 6 commits into
agent/hermes-native-integrationfrom
agent/clawrouter-wallet-provider
Closed

feat(wallet): safely reuse ClawRouter signer and spend limits#118
A1igator wants to merge 6 commits into
agent/hermes-native-integrationfrom
agent/clawrouter-wallet-provider

Conversation

@A1igator

@A1igator A1igator commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add explicit tenjin wallet connect clawrouter selection for users who already fund ClawRouter
  • follow ClawRouter's canonical EVM resolution contract: ~/.openclaw/blockrun/wallet.key first, BLOCKRUN_WALLET_KEY only when the file is absent
  • keep ClawRouter's source wallet outside Tenjin's mutation boundary across connect, reconnect, signing, installation, package upgrades, and uninstall
  • pin the connected address and refuse signer drift until an explicit --replace reconnect
  • support SIWX, publishing, and x402 message/typed-data signing while refusing raw transaction signing and therefore tenjin send
  • inherit ClawRouter's configured perRequest, rolling hourly, rolling daily, and session spend limits read-only by default
  • honor any explicit Tenjin read-spend setting as a separate Tenjin policy for Tenjin purchases

The integration contract was checked against BlockRunAI/ClawRouter at ba855b90103cde00b5d39023220e2f5aeab94b75 and the Hermes adapter at dfcc3009a422c539d31e7100a04c72348ae6b225.

Spend-policy contract

  • inherit only when the active provider is ClawRouter and none of maxAutoSpend, sessionBudget, confirm, or allowlistCreators is explicitly set in Tenjin
  • treat any explicit Tenjin read-spend key as selection of the separate Tenjin policy as a whole; never create a surprising inherited/explicit hybrid
  • parse only ClawRouter's standard limit fields from ~/.openclaw/blockrun/spending.json; never import, append to, or rewrite its history
  • round imported USD limits down to six-decimal USDC atomic units so conversion never loosens a limit
  • enforce per-request, rolling hourly, rolling daily, and session ceilings as hard denials before confirmation
  • reserve concurrent spends atomically and store committed event history in Tenjin's owner-only ledger
  • conservatively migrate Tenjin spend-ledger v2 into v3 history without discarding already-recorded spend
  • fall back to confirmation-only when the ClawRouter policy is missing, empty, malformed, unreadable, or unrepresentable
  • show inherited config provenance as clawrouter and disclose the source/limits in stacked install receipts

Tenjin and ClawRouter use separate ledgers. The configured limit values match, but spend across the two applications is not one aggregate budget. These are client-side guardrails, not signer-enforced controls.

Authority and custody model

The ClawRouter key belongs to the user. Tenjin selects it only after an explicit connect command (or the explicit --wallet-provider clawrouter choice in the stacked installer); mere discovery never selects it. The calling harness's configured execution policy decides whether that command prompts, is denied, or runs automatically. Tenjin does not add a second proof-of-humanity/TTY gate.

The key necessarily enters Tenjin process memory to derive the selected address and produce signatures. Tenjin does not copy it into Tenjin storage/configuration, persist it, log it, return it, transmit it, inspect the mnemonic, or request raw-transaction signing. Only provider/address metadata is stored.

If YOLO grants arbitrary shell access as the same OS user that can read the ClawRouter key or edit policy files, no Tenjin application-level prompt can reliably oppose it. Notices and receipts improve visibility but do not prove a human saw them. A meaningful restriction must be enforced outside that authority boundary, such as an OS sandbox, separate user, keychain user-presence check, hardware wallet, or independently constrained signer.

Implemented custody contract

  • give the connector only read/stat capabilities for the external source; it has no write, chmod, rename, archive, overwrite, or delete primitive
  • resolve the signer after acquiring Tenjin's wallet lock so a queued connect cannot pin a pre-lock observation
  • assert source byte/inode/mode/size/mtime stability across connect, idempotent reconnect, signing, rotation, drift refusal, diagnostics, and refused local replacement
  • keep consumer install/uninstall lifecycle scripts absent so package updates/removal cannot implicitly migrate a home-directory wallet
  • preserve/archive an outgoing local Tenjin wallet and passphrase before an explicit provider replacement
  • never silently create another wallet or move funds while connecting

Stack

This is stacked on #113. Merge #113 first. #119 consumes this PR's custody and spend-policy facts; #120 forwards them through the universal installer.

Verification

  • formatting, lint, typecheck, and build pass
  • 243 focused free-read/buy/config/policy/ledger/provider/wallet tests pass on this PR head
  • full stacked suite passes apart from the loopback-restricted eval inside the sandbox; that eval passes outside the sandbox
  • source-protection suite and package lifecycle-script checks pass

A funded Base USDC purchase/publication smoke was not performed.

Priority

Critical (P0). This is the no-second-wallet safety and policy boundary used by the Hermes onboarding follow-up.

@greptile-apps greptile-apps Bot 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.

A1igator has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot 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.

A1igator has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot 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.

A1igator has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@A1igator

Copy link
Copy Markdown
Contributor Author

Merged the current #113 base in 44cb006 and resolved the wallet/passphrase/doctor overlaps while preserving both local and ClawRouter provider behavior. Verification is green: typecheck, lint, build, 309 focused tests, and the full suite (1,736 passed / 10 skipped).

@A1igator A1igator changed the title feat(wallet): connect an existing ClawRouter signer feat(wallet): reuse an explicitly selected ClawRouter signer Aug 10, 2026

@greptile-apps greptile-apps Bot 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.

A1igator has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@A1igator
A1igator force-pushed the agent/clawrouter-wallet-provider branch from 9a170bb to 716289f Compare August 10, 2026 06:31

@greptile-apps greptile-apps Bot 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.

A1igator has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot 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.

A1igator has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot 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.

A1igator has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@A1igator A1igator changed the title feat(wallet): reuse an explicitly selected ClawRouter signer feat(wallet): safely reuse ClawRouter signer and spend limits Aug 10, 2026
@A1igator

Copy link
Copy Markdown
Contributor Author

Closing as deferred. The ClawRouter connector and copied-limit integration are not justified by the current routing economics. The implementation remains in branch history; revisit criteria are tracked in #122.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: high High priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants