feat: add first-class assert action#20
Merged
Merged
Conversation
Today, asserting an on-chain invariant in a job requires a hacky "assertion template" — a template whose body is empty and whose skip_condition is the invariant, relying on the engine's post-execution check to throw. It's indirect, verbose, and the error can't even say which invariant failed. A first-class assert action fixes this: it evaluates a condition and throws a clear error if it doesn't hold. API: type: assert with fields: - to (AddressValue) + signature (string) + optional values (array) → ACTUAL = result of eth_call (call value resolver) - actual (Value) → ACTUAL = that value resolved - Exactly one comparator key: eq, neq, gt, lt, gte, lte → EXPECTED - Optional message (string) for the error Semantics: resolve ACTUAL and EXPECTED, compare ACTUAL <comparator> EXPECTED via basic-arithmetic (composing existing resolvers). If FALSE, throw. If TRUE, succeed (no broadcast). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bring in the provenance, get-storage-at, and skip_if features now on master, then clean-rebuild the canonical dist/ so it reflects the full merged source. Also force-adds the compiled assert-action spec, which the original change omitted (dist/ is gitignored, so new build outputs must be added explicitly). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a first-class
assertprimitive action. Today, asserting an on-chain invariant requires a hacky "assertion template" — an empty-body template whoseskip_conditionis the invariant, relying on the engine's post-execution check to throw. It's indirect, verbose, and the error can't say which invariant failed.The
assertaction evaluates a comparison and throws a clear error if it doesn't hold (no broadcast, ever).API
type: assertwitharguments:to(+signature, optionalvalues) →eth_call, oractual→ any value resolvereq,neq,gt,lt,gte,lte→ the EXPECTED valuemessageincluded in the error outputComparison composes the existing
callandbasic-arithmeticresolvers. On failure it throwsassert failed[: message]: <describe> (actual=…, expected=…, op=…).Changes
src/lib/types/actions.ts—AssertActiontype, registered as a primitivesrc/lib/core/engine.ts— execution logic; enforces exactly one comparator (rejects zero or multiple)src/lib/core/__tests__/assert-action.spec.ts— 25 testsREADME.md— docs sectiondist/— rebuilt canonical artifactsTesting
🤖 Generated with Claude Code