feat(sandbox): Sandbox.read loads a script from a path known at run time #577
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/576-sandbox-read"
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?
Closes #576
Step 1 of the resources epic #138 (RESOURCES.md slices 5 and 6):
Sandbox.read<Value>(path: Path, capabilities), the third verb of RESOURCES.md section 5, for a script whose path is only known while the program runs.What
std/sandboxdeclaresread. It behaves asloaddoes for a path no literal named: the file is read relative to the working directory, checked againstValueand lowered when the program asks, with the same grants, limits andSandboxErrortexts. It never consults the table of the program's scripts (the VM path callsloadScript, the native path passes no compiled-in script name tohostLoadScript), and the checker has noreadspecial case, so areadof a file that is not there leavestorb checkclean. No new native, no seed change,loaduntouched.tests/conformance/vm-only/sandbox-runtime-path.trbnow callsreadwith aPath; newvm-only/sandbox-read-literal.trb(a literal-looking path that is not there when the program is built, then a mistyped and a valid script);compiler/tests/receivers.test.trbshows thatreadof the same path names no script whileloadstill does.sandbox.mddeclaration block listsread,the-sandbox.md, SCRIPTS.md slice 7 nameread, RESOURCES.md status header, section 10 row 5 and probe 4 (now marked historical);skills/regenerated.One deviation from the issue
The issue asks for the
.expectedofsandbox-runtime-pathto stay byte for byte. One line cannot: aPathis normalized (Path.from("./generated/nowhere.trb").show()isgenerated/nowhere.trb), and the missing-file error names the path asshowspells it, so the line is nownot loaded: There is no script `generated/nowhere.trb`. The other six lines are unchanged. (compiler/tests/sandbox.test.trbhas no run-time-path case: all its loads are literals, so it needs no change.)Test
Local quick checks only (nightly
torb, std of this branch):torb format --checkon every touched.trb;torb run --vmofsandbox-runtime-path.trb(diff against.expectedis only the line above) and ofsandbox-read-literal.trb;torb test compiler/tests/receivers.test.trb --filter "Sandbox.load makes a file part of the project"(9 passed);torb docs check docs(no problems),torb docs declarations docs --check,torb docs skill docs skills --check. Gates a (and b is not expected: nothing reachescompiler/src/ir,compiler/src/backendorruntime/) run in the forge CI of this PR. The nativereadpath (hostLoadScriptwith an empty compiled-in name) is not run by any vm-only program;sandbox-crossing.trbkeeps coveringloadthere.Tracking: orion/tasks#97
Sandbox.readfor a script path known at run time (step 1 of #138) #576Checklist (head
9965efd):vm-only/sandbox-read-literal.trb, migratedsandbox-runtime-path.trb, and areceivers.test.trbcase showingreadnames no script whileloadstill does. CI combined status success for this head (tier A, tier B, gates).Sandbox.readmirrors the run-time-path branch ofload(VM:loadScript; native:hostLoadScriptwith empty compiled-in name), same grants, limits andSandboxErrortexts; the malformed-pattern check is kept..expectedline change is explained (Path normalization) and is correct.loaduntouched; no data or format change.skills/updated; pdisc green.Sandboxgains a verb already specified in RESOURCES.md section 5).Non-blocking: the native
readpath is not exercised by any program (the PR body says so); worth a native conformance case in a later step.