feat(11-C3): python3 subprocess + Tier 0 sandbox + boot stub #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/11-phase-c3-spawn-sandbox"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Phase C3 of #11. The whole runtime path:
PythonFlowExecutor::execute(opts)stages the user's flow source to a per-Play workdir, binds the Phase C2 span socket, spawns python3 with Tier 0 sandbox (per hero_logic#14), and awaits both the subprocess exit + listener drain.What lands
PythonFlowExecutor::execute(opts)ExecuteOutcome { exit_code, timed_out, stderr }.BOOT_STUB(Python)globals()for__hero_flow__-stamped functions, decodesHERO_FLOW_INPUT, calls_bootstrap_run. Exits 2 with a diagnostic if no@flowis present.Tier0Sandboxsetrlimiton Linux only (RLIMIT_AS / RLIMIT_CPU / RLIMIT_NOFILE / RLIMIT_NPROC).ExecuteOptionssdk_dir,clients_dir,workdir_root,span_socket_path,python_bin) so tests don't touch the operator's real paths.SpanListener::with_socket_pathExecuteOptions::span_socket_pathis set.Tier 0 details
Per the hero_logic#14 threat model:
time.sleep(60)inside a flow withwall_clock = 2sgets SIGTERMed at 2s, SIGKILLed at 2.5s. ✓PATH,HOME,LANG,PYTHONPATH,PYTHONDONTWRITEBYTECODE,HERO_FLOW_*.~/.hero/var/plays/{play_sid}/workbecomes cwd. flow.py is staged there.Listener drain bound
After subprocess exit, the listener task gets
grace + 2sto finish naturally; if still stuck, abort. macOS doesn't always deliver EOF promptly to a UnixStream whose peer was SIGKILLed. Losing late span events on a killed flow is acceptable; hanging the executor is not.Tests
13 total — 9 unit + 4 integration. Integration tests actually run python3 and skip cleanly if it's not on PATH.
end_to_end_flow_writes_spans—@flow+flow.step→ spans persisted with names + parent linkage +SpanStatus::Okflow_failure_records_failed_root_span—raise flow.Failed("nope")→ root span persists asFailedwith the exception textwall_clock_timeout_kills_runaway_flow—time.sleep(60)killed at 2s; outcome reportstimed_out=truemissing_flow_decoration_exits_with_diagnostic— boot stub exits 2 with "no @flow-decorated function" messageWhat this PR is NOT
play_startrouting bypython_sourcenon-empty (C4)Phase plan (#11)
hero_tracing.pySDK (#16, merged)play_startroutingTest plan
cargo test -p hero_logic --lib python_executor::tests— 9/9 passcargo test -p hero_logic --lib python_executor::integration_tests— 4/4 passcargo test --workspace --lib— 32 total, all greencargo build --workspaceclean🤖 Generated with Claude Code