Define the spawn-time handoff a job process consumes before any application code runs: two inherited descriptors named by SWACTOR_ARENA_FD and SWACTOR_WAKE_FD, and a fixed 48-byte little-endian header at arena offset 0 naming one control-ring region. - Canonical header layout, shared parser, and a host writer that leases the header region and control ring disjointly under the arena's own placement law, zeroes the ring, stamps its generation, and returns the handoff (env map, inheritable arena and wake descriptors, host wake eventfd) only after every write completes. - Python binding gains swactor.run(main): map the arena read-only, take ground truth from fstat, validate through the shared parser, arm FD_CLOEXEC on the wake descriptor, close the arena descriptor after mapping, and drive main on asyncio with Context.data carrying the resolved state. Fail-fast BootstrapError before main on any defect. - Rewrite jobs/tiny_linear_inference.py against the approved path API and record the slice, invariants, and remaining bridge work in the handoff doc. Verified with 12 new data-plane bootstrap guarantee tests (parser defect table, fuzzed pages, writer round-trip), 29 binding tests across in-process and exec boundaries, and full data-plane and iroh-driver suites with no regressions.
42 lines
1.1 KiB
Python
Executable file
42 lines
1.1 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""L3 probe for the bootstrap slice.
|
|
|
|
Runs under ``swactor.run`` and reports facts observable without any
|
|
data-plane primitives: context shape, wake readability, and descriptor
|
|
hygiene across an exec boundary.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import select
|
|
import subprocess
|
|
import sys
|
|
|
|
import swactor
|
|
|
|
_CHILD_CHECK = (
|
|
"import os, sys; "
|
|
"sys.exit(0 if sys.argv[1] not in os.listdir('/proc/self/fd') else 3)"
|
|
)
|
|
|
|
|
|
async def main(ctx: swactor.Context) -> None:
|
|
facts = [f"HAS_DATA={int(isinstance(ctx.data, swactor.DataPlane))}"]
|
|
|
|
wake = int(os.environ["SWACTOR_WAKE_FD"])
|
|
readable = bool(select.select([wake], [], [], 0)[0])
|
|
facts.append(f"WAKE_READABLE={int(readable)}")
|
|
|
|
# B5: a close_fds=False child must not see the CLOEXEC-armed wake fd.
|
|
child = subprocess.Popen(
|
|
[sys.executable, "-c", _CHILD_CHECK, str(wake)],
|
|
close_fds=False,
|
|
)
|
|
child.wait()
|
|
facts.append(f"WAKE_LEAKED={int(child.returncode == 3)}")
|
|
print(" ".join(facts))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
swactor.run(main)
|