Skip to content

feature: run2 builtin with structured response record#499

Merged
danieljohnmorris merged 6 commits into
mainfrom
feature/run-structured-response
May 21, 2026
Merged

feature: run2 builtin with structured response record#499
danieljohnmorris merged 6 commits into
mainfrom
feature/run-structured-response

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

  • Adds run2 cmd:t args:L t > R RunResult t - a structured process spawn that returns a typed Record{stdout:t; stderr:t; exit:n} instead of the loose M t t map that run returns
  • exit is a number (n), not text, so =0 r.exit, <0 r.exit work without string conversion
  • Same no-shell-no-glob security model, same concurrent capture + 10 MiB cap as run; Err only on spawn failure
  • run unchanged for compatibility

Repro before/after

Before: accessing exit code required mget m "code" then num code then comparing as number. Loose Map meant no dot-access ergonomics.

After:

r=run2!! "git" ["status" "--short"]
r.stdout   -- text
r.exit     -- 0 or non-zero, already a number
?{=0 r.exit : "clean" ; "dirty"}

What's in the diff

  1. add Run2 builtin variant, tree-bridge, and on-wire tag - enum, from_name, name, ALL slice (appended, tag stable), tree-bridge eligible + tree_bridge_returns_result
  2. implement run2 interpreter: run_spawn_structured returns typed Record - run_spawn_structured non-wasm + wasm stub, interpreter dispatch, argv validation
  3. add run2 verifier: signature table entry and type-check case - BUILTIN_SIGS, type inference match arm, ILO-T013 hints
  4. add examples/run-structured.ilo with run:/out: annotations - echo stdout, false exit, true exit, numeric pattern match, nonexistent Err
  5. docs: sync run2 to SPEC.md, ai.txt, skill, and CHANGELOG - SPEC Process spawn section updated, skill subsection added, ai.txt regenerated

Test plan

  • 6 new unit tests covering: RunResult record shape, stdout text, false exit (1.0), true exit (0.0), stderr capture, exit as Number not Text, nonexistent command returns Err
  • examples/run-structured.ilo runs clean in examples_engines harness
  • Full suite: 3265 passed, 7 failed (pre-existing AOT worktree-isolation failures, not related to this change)
  • cargo fmt --check passes

Follow-ups

  • Signal-killed exit is -1.0; could expose the signal number in a future run3 with 4-field record
  • stdin pipe arg (run2 cmd args stdin:t) deferred to a follow-up per spec comment in run

@danieljohnmorris danieljohnmorris force-pushed the feature/run-structured-response branch from eb9603c to 2d92713 Compare May 20, 2026 20:02
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4928 1 4927 0
View the full list of 1 ❄️ flaky test(s)
ilo::regression_calendar_arithmetic::add_mo_result_out_of_calendar_range

Flake rate in main: 100.00% (Passed 0 times, Failed 1 times)

Stack Traces | 0.01s run time
thread 'main' (44184) panicked at src/interpreter/mod.rs:1891:21:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@danieljohnmorris danieljohnmorris force-pushed the feature/run-structured-response branch 5 times, most recently from f69d077 to 714a31d Compare May 21, 2026 13:54
Adds Builtin::Run2 to the enum, from_name/name mappings, the ALL
stable-tag slice, the vm tree-bridge eligible table, and the
tree_bridge_returns_result set. On-wire tag is appended last so all
existing tags are stable.
Adds run_spawn_structured (non-wasm + wasm stubs) that captures
stdout/stderr with the same 10 MiB cap and concurrent drain as
run_spawn, then returns Ok(Record{stdout:t; stderr:t; exit:n}) where
exit is f64 (-1.0 for signal-killed). Interpreter dispatch added
alongside existing run handler; argv validation is identical.
Adds ("run2", &["t", "L t"], "R RunResult t") to BUILTIN_SIGS and a
"run2" match arm in the builtin type-inference function. Emits
ILO-T013 with contextual hints when cmd or args types mismatch,
mirroring the existing run case. Return type is R RunResult t.
Covers echo (stdout populated), false (exit 1 as number), true (exit 0),
numeric exit pattern match, and nonexistent command returning Err.
Exercises all shapes the examples_engines harness runs across tree and VM.
Updates the I/O builtins table in SPEC.md, expands the Process spawn
section to document both run and run2 with examples, updates the
ilo-builtins-io.md skill with a Process spawn subsection, and adds the
CHANGELOG entry. ai.txt regenerated from SPEC.md via build.rs.
@danieljohnmorris danieljohnmorris force-pushed the feature/run-structured-response branch from 714a31d to 3cd12f9 Compare May 21, 2026 14:14
@danieljohnmorris danieljohnmorris merged commit bf5981a into main May 21, 2026
1 of 4 checks passed
@danieljohnmorris danieljohnmorris deleted the feature/run-structured-response branch May 21, 2026 14:14
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