resources: Sandbox.read for a script path known at run time (step 1 of #138) #576
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Step 1 of the epic #138 (RESOURCES slices 5 and 6).
Goal
std/sandboxgets the member for a script whose path is decided while the program runs:Sandbox.read<Value>(path: Path, capabilities). It is the third verb of RESOURCES.md section 5:readtakes aPath, the compiler has never seen the file, nothing is checked at build time, everything at run time. Today'sSandbox.load(path: String)does exactly that for every path the program computes, so this step gives that behaviour its final name and moves every run-time caller to it.loadandembeddedchange their parameter types toResource/EmbeddedTextin later steps of the epic; this step leavesloadas it is.Design record
Sandbox, which needs all three": "Today'sSandbox.loadbecomesSandbox.read"), section 10 slice 5, and URI.md gap table row forSandbox.embedded/load/read.main(4b59fae): the dependency of the epic ("Sandboxruns on both implementations") holds.tests/conformance/sandbox-crossing.trbprints the same in the VM and in a native binary,tests/conformance/vm-only/sandbox-*.trbandcompiler/tests/sandbox.test.trbexercise the VM,Sandbox.loadTextexists. RESOURCES.md probe 4 ("runs on neither implementation") and the "Blocked" cells of slices 5 and 6 are stale.Acceptance criteria
std/sandboxdeclaresstatic fn read<Value>(path: Path, capabilities: (var self: SandboxCapabilities) => Void = {}): Result<Script<Value>, SandboxError>. It behaves asloaddoes today for a path that 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 (a missing file isThere is no script ...). It never consults the table of scripts the program was compiled with, and the checker does not treat areadcall as a receiver-script load (areadof a file that does not exist leavestorb checkclean).tests/conformance/vm-only/sandbox-runtime-path.trband the run-time-path cases oftests/conformance/vm-only/sandbox-*.trbandcompiler/tests/sandbox.test.trbcallreadwith aPathand keep their.expectedbyte for byte; a new case shows thatreadof a literal-lookingPathis not checked at build time whileloadof a literal still is.sandbox-crossing.trband the literalSandbox.loadcases stay green and unchanged (tier A; tier B only if the change reachescompiler/src/ir,compiler/src/backendorruntime/, which it should not).docs/standard-library/sandbox.mddeclaration block listsread(thetorb:declarationblock stays in sync),docs/language/configuration/the-sandbox.mdand SCRIPTS.md slice 7 namereadfor a path known at run time; RESOURCES.md status header and section 10 row 5 say that slice 5 is in progress and that probe 4 is historical;build/release/torb.exe docs skill docs skillsregenerated.Seed
Does not touch the seed: no syntax change, no new native (
readshares the existingloadScript/hostLoadScriptnatives withload), no driver flag. The compiler recognizesSandbox.loadby its shape (compiler/src/semantics/scripts.trb); it looks up no nameread, andcompiler/srcdoes not callSandboxitself. The seed question comes with the later step that changesload's parameter type.Size
One PR, one Conventional Commit:
feat(sandbox): Sandbox.read loads a script from a path known at run time. Worker: sonnet/medium (std/, tests, docs).Keep out of
compiler/src/semantics/{graph,scripts}.trb,checker/receiver.trb,ir/lower/script.trb: the script-receivers epic #518 (#513) reworks them, and this step needs none of them. Doc files that #517 migrates (sandbox.md,the-sandbox.md) conflict only textually; rebase.[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T14:35Z
[loop:torbscript] implement: PR #577 open, review requested from argus, forge CI queued on the runners (commit messages, change scope and pdisc green; gates, bootstrap and tiers pending after 29 min of waiting, run https://git.torb.dev/torbscript/language/actions/runs/2209), next: waiting (forge CI and merge gate). One deviation from the acceptance criteria, explained in the PR: a
Pathis normalized, so the missing-file line ofsandbox-runtime-path.expectednow namesgenerated/nowhere.trbinstead of./generated/nowhere.trb; every other line is byte for byte.compiler/tests/sandbox.test.trbhas no run-time-path case, so it is unchanged. Worker usage: about 120k tokens (estimate, sonnet).[loop:torbscript] claim fix by session:loop-torbscript-20261029 until 2026-10-29T15:58Z