Skip to content

feat(acts): assertion DSL and variable substitution - #61

Merged
JakubWorek merged 1 commit into
jakubworek/acts-transport-adaptersfrom
jakubworek/acts-assertions
Sep 9, 2026
Merged

JakubWorek merged 1 commit into
jakubworek/acts-transport-adaptersfrom
jakubworek/acts-assertions

Conversation

@JakubWorek

Copy link
Copy Markdown
Member

Stacked on #60. Base is jakubworek/acts-transport-adapters, so this diff shows only the assertion work. Retargeting to main once #60 lands.

Summary

Adds the two pure layers the runner sits on: assertions.py evaluates the DSL against a response, variables.py resolves {{...}}, reads dot-paths and holds a test's captures. Neither performs I/O.

The interesting part is telling an operator map from a path descent. Spec §5.2 makes expect.body mirror the response by nesting while §5.4 puts operators in a map, so {status: {state: FOO}} and {type: array, count_gte: 1} have the same syntax. The rule that works is that a key is an operator when it is a known name and its argument is well-formed for that operator. Both halves are load-bearing: {type: array, count_gte: 1, items: [...]} mixes operators with a third key, and REST-PD-001 asserts on an RFC 9457 body whose members really are named type, title and status. Over the whole corpus this classifies 203 operator keys and 397 field keys, with exactly one - that type - resolving to a field despite an operator's name.

One ambiguity survives and cannot be resolved: a field named type expected to equal the string "string". Nothing in A2A hits it and the format offers no escape, so it is documented rather than handled.

items is implemented as the single extension operator. §5.1 has no way to say "an array of at least one element whose elements look like X", because one YAML node cannot be both the map operators need and the list §5.2 requires; the corpus needs it anyway and invents items at five sites with JSON Schema semantics. Unlike the compat.py defects this one has no spec-legal target to rewrite to, so it lives in the evaluator.

Notes

Three choices the spec does not make, all resolved the same way - an assertion must never report success having compared nothing:

  • A quantifier over an empty match set fails for any and all, and passes for none, which is genuinely satisfied by having no elements.
  • AssertionResult.checks counts real comparisons, so a caller can tell "passed" from "asserted nothing".
  • A capture whose path reads nothing raises rather than binding a null, which would turn one unmet expectation into a cascade downstream.

MISSING is a distinct sentinel rather than None because JSON has null: {exists: true} passes for a present null and {absent: true} fails for it, and only those two operators tolerate an absent value at all.

Substitution distinguishes a whole-string reference, which yields the value with its type, from an embedded one, which interpolates - a captured integer has to stay an integer for an exact match.

201 tests. Failure.as_detail() emits §13.3's failure-detail directly; the runner supplies step_id, the one field this layer cannot know.

@JakubWorek
JakubWorek force-pushed the jakubworek/acts-assertions branch from 37dcf1d to 3a54d9c Compare September 7, 2026 07:53
@JakubWorek
JakubWorek merged commit 89f4560 into main Sep 9, 2026
2 checks passed
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.

2 participants