feat(repo): add quoter-signer deterministic policy checks - #178
feat(repo): add quoter-signer deterministic policy checks#178julien-devatom wants to merge 7 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- pin offer tick to uint256 and maxAssets to uint128 per the Midnight struct - require an alias-qualified quoter-signer Lambda ARN (no version/unqualified) - clear foreign signer sources for CLI middleware overrides in both directions - report the fail-closed middleware identity as a sanitized signer observation Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Third TIB-2026-08-12 increment: the middleware now parses a strict QUOTER_SIGNER_POLICY deployment document (surface/mode/chain/maker pins, market allowlist with tick and fee ceilings, offer time windows, routine and protected fee ceilings with the emergency-bump reserve, remediation variants) and denies out-of-policy intents with a typed violation naming the violated check. Still fail-closed: no KMS access, nothing signed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…-f85533 # Conflicts: # docs/decisions/TIB-2026-08-12-quoter-bot-kms-signing-middleware.md # pnpm-lock.yaml # services/quoter-signer/README.md # services/quoter-signer/package.json # services/quoter-signer/src/index.ts # services/quoter-signer/src/intent.utils.ts # services/quoter-signer/test/index.test.ts
|
@codex review |
|
@prd-carapulse[bot] can you review and approve if all good |
|
Approved PR #178. • No blocking correctness or security findings. |
There was a problem hiding this comment.
Reviewed the policy parser/check stage and the added tests. No blocking correctness or security findings.
Local verification: 186 quoter-signer tests passed; quoter-signer typecheck passed. The PR Test check is red before test execution because the Foundry installer failed with /home/runner/.foundry/bin/foundryup: cannot execute binary file; contract, unit, and browser suites were skipped.
The pinned v1 SHA runs the downloaded foundryup via bash, which broke repo-wide (main included) when upstream foundryup became a binary: 'cannot execute binary file' before any test executes. v1.9.1 downloads the pinned foundryup-init.sh installer and executes foundryup directly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@codex review |
- viem-first bytes32 identity: market/group keys via hexToBigInt instead of toLowerCase in the policy parser, the check stage, and the intent parser's market count - refuse to serve a setup-remediation deployment with an empty remediation manifest (empty policy) instead of denying per intent - README create-function command now passes the policy via --environment file://environment.json Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…-f85533 Takes main's SHA-256-pinned direct Foundry download (PR #174) for the checks workflow, superseding this branch's foundry-toolchain v1.9.1 bump for the same binary-foundryup breakage.
What
Third increment of TIB-2026-08-12 (quoter-bot KMS signing middleware): the deterministic deployment-policy checks, still entirely fail-closed — the image holds no KMS access, implements no signing surface, and denies every intent.
src/policy.utils.ts): the newQUOTER_SIGNER_POLICYenv var carries one strictly-parsed JSON document — signing-surface pin (quote / ratify / routine-revoke / break-glass-revoke / setup-remediation), ratifier mode, chain/maker/ratifier pins, offer time windows, per-market allowlist (maturity, tick bounds ≤ protocolMAX_TICK, continuous-fee ceiling ≤MAX_CONTINUOUS_FEE, lend-exposure cap), maker-wide cap, routine+protected fee ceilings, remediation variants. Parse-time deployment validation enforces quote↔Ecrecover / ratify↔Setter coherence and the TIB's emergency-bump reserve (protected ≥ max(floor(routine×1125/1000), routine+1),protected.gas ≥ routine.gas). Missing/invalid policy refuses to serve (PolicyNotConfiguredError).src/policy-check.utils.ts): surface/intent-kind, chain and maker pins, per-kind fee ceilings (protected only on the break-glass surface, per-variant for remediation),cancel-root/unratify-rootmode coherence, remediation allowlist; and for quote/ratify offer sets: market allowlist, tick bounds, field pins (configured ratifier; no callback surface; zero receiver on buys, maker on sells), reduce-only side pins, fee-cap ceilings, time windows (start < expiry, unexpired,expiry ≤ min(maturity, now+freshness), start-age), group coherence, and static lend-exposure caps charged once per consumption domain(market, group, side, cap)so per-book rungs sharing a group count once. Violations deny withIntentPolicyViolationError; themiddleware.intent_deniedlog line now carries the violated check id (TIB Observability).src/index.ts): parse → policy load → checks →SigningNotImplementedError, each stage mapping unexpected faults to its own typed denial; the handler still never throws.@morpho-org/midnight-sdk(+@morpho-org/morpho-tspeer) added for the protocol constants, mirroring quoter-bot.Why
The TIB's caller-to-surface scoping, parameter pins, and bounds must be enforceable before any signing surface exists — this lands every check decidable from deployment parameters and the middleware clock alone, so later increments (independent reads, reservation ledger, KMS) only add stages to an already fail-closed pipeline. Nothing policy-relevant comes from the request.
Reviewer notes
onBehalf). It materializes here as the static group-coherence rule (one group id binds one market/side/cap inside an intent) with canonical re-derivation deferred to the encoding increment — recorded in TIB Addendum C, which also carries the sequencing note: today's builders pinexpiry = maturity, so the §3 builder change is a prerequisite of the increment that enables quote/ratify signing.intent.utils.tsrather than sharing a module (each fail-closed parser independently auditable; noted in a comment).reviewerandprotocol-engineeragent passes ran pre-PR; all findings applied (fail-closed market-lookup branch, per-offer helper extraction, env-stub in tests) or documented (README operator guidance on tick-band drift,maxContinuousFeeCapdefaulting to the protocol max, start-age sizing).pnpm lint0 warnings,pnpm format, typecheck clean, esbuild bundle smoke-tested end to end (no-policy / in-policy / out-of-policy denials). Fullpnpm test: only the fork/e2e suites requiringRPC_URL_8453fail, identically tomain(env-gated). knip: known worktree false positives only.🤖 Generated with Claude Code
CI rider (superseded)
This branch briefly carried a
foundry-toolchainv1.9.1 bump for the repo-wide binary-foundryup CI breakage; main merged its own hardened fix (SHA-256-pinned direct Foundry download, PR #174), which this branch now uses via merge — the final diff no longer touches the workflows.