Skip to content

feat(resolver): decode self-describing argument values#343

Merged
scarmuega merged 1 commit into
mainfrom
feat/resolver-decode-encoded-args
Jun 22, 2026
Merged

feat(resolver): decode self-describing argument values#343
scarmuega merged 1 commit into
mainfrom
feat/resolver-decode-encoded-args

Conversation

@scarmuega

Copy link
Copy Markdown
Contributor

What

Makes an argument of an aggregate type (record, List, Map, Tuple) resolve, instead of failing with target type not supported. Server half of the client-side-encoding approach: the TIR stays untyped, and the resolver decodes the deterministic, self-describing wire form the client builds from the .tii.

interop::from_json becomes one path:

  • A tagged value (a single-key { "int" | … | "struct": … }) is self-describing and decodes from its tags via the new recursive decode_encoded, no schema, whatever its kind.
  • A bare value carries no tag and is coerced via the param's flat TIR Type — the legacy form a top-level scalar may still take.

There is no scalar-vs-aggregate fork: the kind is not a branch in the road, only "tagged or bare."

decode_encoded maps the tagged wire form to ArgValue (scalar leaves reuse the existing value_to_* coercions; struct carries its constructor index + positional fields; map is an array of [key, value] pairs). Precise errors replace the blanket unsupported case: unknown tag, malformed struct / map-pair, untagged nested value.

Downstream ArgValue sweep

The new tx3-tir variants break the crate's exhaustive ArgValue matches; fixed here:

  • arg_to_json round-trips aggregates through the tagged form (via a new encoded_arg_to_json).
  • The hand-rolled partial_eq test helper is removed now that ArgValue derives PartialEq.

Adopts

tx3-tir 0.19.0 (the ArgValue aggregate variants — tx3-lang/tir#4).

Tests

  • Vector-driven decode for each kind incl. the nested struct { list[int], int } of the 05-invoke fixture, plus reject cases (unknown tag, malformed struct/map-pair, untagged nested, bare aggregate). All existing scalar from_json_* tests stay green.
  • cargo test --workspace green (184 + 96 + …); builds clean against the published tx3-tir 0.19.0 (no [patch.crates-io]).

The crate version bump + publish is a separate release step.

🤖 Generated with Claude Code

@scarmuega scarmuega force-pushed the feat/resolver-decode-encoded-args branch from 2729eb8 to 37cdc94 Compare June 22, 2026 11:29
Bind arguments through one path in `interop::from_json`: a tagged value
is self-describing and decodes from its tags via `decode_tagged`
(recursively, no schema) whatever its kind, while a bare value carries
no tag and is coerced via the param's flat TIR `Type` — the legacy form
a top-level scalar may still take. This replaces the old
`TargetTypeNotSupported` catch-all for `List`/`Map`/`Tuple`/`Custom`
params, so an argument of an aggregate type (record, list, tuple, map)
now resolves.

`decode_tagged` turns the tagged wire form into the matching `ArgValue`
(scalar leaves reuse the existing per-scalar coercions; `struct` carries
its constructor index and positional fields), with precise errors for
unknown tags, malformed structs/map-pairs, and untagged nested values.

Also sweeps the new `ArgValue` variants through the crate's exhaustive
matches: `arg_to_json` round-trips aggregates through the tagged form,
and the hand-rolled `partial_eq` test helper is dropped now that
`ArgValue` derives `PartialEq`.

Adopts `tx3-tir` 0.19.0 (the `ArgValue` aggregate variants).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@scarmuega scarmuega force-pushed the feat/resolver-decode-encoded-args branch from 37cdc94 to 437f4a0 Compare June 22, 2026 11:37
@scarmuega scarmuega merged commit 29fc423 into main Jun 22, 2026
6 checks passed
@scarmuega scarmuega deleted the feat/resolver-decode-encoded-args branch June 22, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant