Skip to content

1.8: generator PoC tools/aimux-codegen: ToolCall -> TS + Go, --check (on #42) - #43

Open
cunninghamcard-bit wants to merge 1 commit into
exp/u1.7-descriptor-schemafrom
exp/u1.8-codegen-poc
Open

cunninghamcard-bit wants to merge 1 commit into
exp/u1.7-descriptor-schemafrom
exp/u1.8-codegen-poc

Conversation

@cunninghamcard-bit

Copy link
Copy Markdown
Owner

Phase 1 unit 1.8: a generator proof of concept (arcships#200:1509; RFC-0042 T5). Stacked on #42 (1.7, exp/u1.7-descriptor-schema @ b8d8261); the PR base is that branch.

Added: tools/aimux-codegen (new workspace member)

  • Input: spec/ToolCall.json, a data-only type spec giving the name, docs, and for each field its wire name, type and whether it's optional. Unknown keys are rejected.
  • Library: render_ts, render_go, generate, write, check.
  • Binary: aimux-codegen writes generated/. aimux-codegen --check regenerates in memory and exits non-zero if any committed file is missing or differs.
  • Committed outputs:
    • generated/ts/ToolCall.ts
    • generated/go/tool_call.go (package aimuxgen, encoding/json tags, gofmt-clean)
  • There is no build.rs and no second copy of the spec (docs: full-chain AI SDK alignment design and impact map arcships/aimux#200 §6.5). Nothing is wired into the bindings yet; ts-rs is unchanged.

Acceptance (tools/aimux-codegen/tests/codegen_test.rs, 8 tests)

  • Wire matches the current binding: typescript_matches_the_current_binding_type. The generated TS equals bindings/node/src/types/ToolCall.ts line for line below the one-line header: same fields, optionality, types, imports and docs.
  • Go wire: go_struct_round_trips_core_tool_call_json.
    • Four samples are serialized by aimux_core::tool::ToolCall (static, dynamic + providerExecuted, providerMetadata, invalid + error).
    • The generated Go struct decodes and re-encodes each one, and the result must be the same JSON value (go test in a temp module, stdlib only).
    • The test also asserts the Go file is gofmt-clean.
    • It ran here with go 1.24.4. Without go on PATH it prints SKIPPED.
  • --check catches tampering:
    • check_rejects_tampered_typescript: changing dynamic?: to dynamic: fails.
    • check_rejects_tampered_go: changing the toolName tag fails.
    • Both go through both the library and the binary (non-zero exit, "out of date").
    • check_rejects_a_missing_file covers a deleted output.
    • check_passes_on_an_untouched_copy exits 0, and committed_outputs_are_up_to_date checks the committed files.
  • spec_rejects_unknown_fields.

Fixture and cassette diff: zero.

Results (local linux x64)

1.7 (#42) 1.8
cargo test --workspace 2875 / 0 / 7 2883 / 0 / 7 (+8)
fmt / clippy -D warnings ok ok
boundary script 0 0
gen_ts_types --check ok ok
Node ava (node 22) 87 / 1 baseline fail 87 passed, same 1 failure

Python was not run (no venv). This is a PoC for one type. Unions or discriminators, and the other six languages, are not covered.

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.

1 participant