Skip to content

proposals/execute: name the cause of each not_executable refusal - #98

Open
ayushsingh82 wants to merge 1 commit into
MultiAgency:mainfrom
ayushsingh82:feat/97-not-executable-causes
Open

ayushsingh82 wants to merge 1 commit into
MultiAgency:mainfrom
ayushsingh82:feat/97-not-executable-causes

Conversation

@ayushsingh82

Copy link
Copy Markdown

Closes #97

What changed

A not_executable refusal from proposals/execute now carries causes beside error and code: one { cause, retry } per problem, in the order the message gives them. retry says what happens next without parsing text:

  • now: a race; trying again may pass at once.
  • later: may clear without the owner (prices, quotes, the provider).
  • owner: needs an owner action outside this proposal.
  • never: this proposal can't pass; read it again, or propose anew.

All 17 causes in the issue table are implemented (src/planning/causes.ts). code, error and the HTTP status are unchanged.

  • checkPlan, feasibility and quoteChosen classify each problem. The string-returning checkPlan and feasibility keep their signatures; checkPlanCaused and feasibilityCaused are the structured forms.
  • The proposal's pre-claim checks (beforeClaim) return their own causes: no_grant, cash_floor, policy_not_in_force, approval_mismatch, record_changed, claimed.
  • The plan stream's rejected event gets an optional causes, set only when every problem has one, so it lines up with the message.
  • The owner client's refused failure gets causes?: RefusalCause[] (REFUSAL_CAUSES, refusalCause). Only causes it can validate are passed on. A host older than this change sends none.
  • Docs: the treasury-app skill and docs/sdk-changes.md (new 0.6.1 heading, package-version.ts moved to 0.6.1 as a patch, per the rule in that file: an optional field is an addition).

Decisions for review

  1. cost_limit retry class. The issue says never "once the limit, not the quote, binds" without defining it. I used: never when the quote's slippage margin alone (worst-case cost minus expected cost) is over the limit, so no quote can meet it; otherwise later. Both numbers are carried (worstCostBps, maxCostBps). The 97 bps vs 50 bps case in the issue is never under this rule.
  2. "No fresh quote for swap N" has no row in the issue table; it is provider_warning.
  3. strategy_changed before a claim is now, as in the table, though executeProposal invalidates a proposal whose strategy changed on the next call, so the next answer is a read of the invalidated proposal.
  4. Two existing assertions (plan-recovery.test.ts, planning-valuation.test.ts) compared the whole rejected event, which now includes causes; updated.

What I ran

Node 24.22.0, pnpm 12.16.1 (the pinned 12.15.0 was not usable in my cache):

  • pnpm typecheck: passes.
  • pnpm test (offline): 1,539 pass, 0 fail, including new tests for floor, provider_warning, no_grant, cash_floor and both cost_limit classes.
  • pnpm evidence:check: passes.

Not run: pnpm test:e2e, verify-skills (the skill text changed), the browser suites, and anything live. The sdk-changes.md heading says "unreleased"; the release commit still dates it. Treasury needs no change to keep working; showing the causes in its UI is a follow-up.

A not_executable refusal now carries `causes`, one { cause, retry } per
problem in the order the message gives them, next to the existing `error`
and `code`. `retry` is now, later, owner or never, so an app can say what
happens next without parsing text. A cost_limit also carries worstCostBps
and maxCostBps, and is `never` once the quote's own slippage margin is over
the limit.

The checks (checkPlan, feasibility, quoteChosen, the proposal's pre-claim
checks) classify each problem; the plan stream's `rejected` event and the
owner client's `refused` failure carry the optional `causes`. Hosts older
than this change send none. SDK 0.6.1 (patch: an optional field).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposals/execute: a structured cause on not_executable refusals

1 participant