Epic: resources: scripts as resources (RESOURCES slices 5 and 6) #138

Open
opened 2026-10-05 21:07:24 +00:00 by orion · 4 comments
Collaborator

Context

L2 and L3 of RESOURCES.md: scripts as resources. Slice 5 (L2: Sandbox.embedded / load / read, the statically readable capability block, the script as a leaf of the module graph) and slice 6 (L3: the one new case of the module-constant purity rule, folding a pure initializer in the VM, the embedding through Encode, the six conditions as diagnostics). Both are too large for one PR, so this issue is an epic; the design record stays the specification.

Source

Dependencies

  • #137 (the build's file set, RESOURCES slice 4): closed.
  • Sandbox on both implementations: holds on main (SCRIPTS.md slices 4, 5, 7 and 8; tests/conformance/sandbox-crossing.trb, tests/conformance/vm-only/sandbox-*.trb). RESOURCES.md probe 4 and the "Blocked" cells of slices 5 and 6 are stale; step 1 corrects them.
  • Soft ordering: steps 2 to 4 change the same graph, checker and script-table code as the script-receivers epic #518 (#513, #514). They start after #513 and #514 have landed; step 1 does not touch that code.

Steps (a step becomes its own issue when it starts next)

  • 1. #576 Sandbox.read(path: Path): the run-time-path member, callers migrated (no seed)
  • 2. Sandbox.load(Resource) and Sandbox.embedded(EmbeddedText): the literal resolves against the writing file, the script table is keyed by stable name, load stops taking a String (changes a std signature the compiler recognizes by shape: two commits, seed refresh by Torben)
  • 3. The capability block of load / embedded must be statically readable; the diagnostic points at Sandbox.read (RESOURCES.md section 7)
  • 4. The script as a leaf of the module graph: three edges (file, receiver type, allowlist modules), checked once per call site, cache key (stable name, receiver type, allowlist), torb check opens the script; script imports checked against the allowlist at build time
  • 5. L3 purity rule: the one new case ("a call of a function the compiler can evaluate at build time") in semantics/checker/declaration.trb, no folding yet
  • 6. Folding a pure initializer in the VM and embedding the result as its constructor call (Encode); the six conditions as diagnostics, one message each (may split into one issue per group of conditions when it starts)
  • 7. Prose: docs/standard-library/resource.md, sandbox.md (three members), docs/tooling/torb-build.md, ECS loader snippet, CONCEPT decision log entry; RESOURCES.md status Done

Done when all steps are closed and the RESOURCES.md slices 5 and 6 are marked done.

## Context L2 and L3 of [RESOURCES.md](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/RESOURCES.md): scripts as resources. Slice 5 (L2: `Sandbox.embedded` / `load` / `read`, the statically readable capability block, the script as a leaf of the module graph) and slice 6 (L3: the one new case of the module-constant purity rule, folding a pure initializer in the VM, the embedding through `Encode`, the six conditions as diagnostics). Both are too large for one PR, so this issue is an epic; the design record stays the specification. ## Source - [RESOURCES.md section 10, slices 5 and 6](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/RESOURCES.md), sections 5, 7 and 8 for the contracts. ## Dependencies - #137 (the build's file set, RESOURCES slice 4): closed. - `Sandbox` on both implementations: holds on `main` (SCRIPTS.md slices 4, 5, 7 and 8; `tests/conformance/sandbox-crossing.trb`, `tests/conformance/vm-only/sandbox-*.trb`). RESOURCES.md probe 4 and the "Blocked" cells of slices 5 and 6 are stale; step 1 corrects them. - Soft ordering: steps 2 to 4 change the same graph, checker and script-table code as the script-receivers epic #518 (#513, #514). They start after #513 and #514 have landed; step 1 does not touch that code. ## Steps (a step becomes its own issue when it starts next) - [ ] 1. #576 `Sandbox.read(path: Path)`: the run-time-path member, callers migrated (no seed) - [ ] 2. `Sandbox.load(Resource)` and `Sandbox.embedded(EmbeddedText)`: the literal resolves against the writing file, the script table is keyed by stable name, `load` stops taking a `String` (changes a std signature the compiler recognizes by shape: two commits, seed refresh by Torben) - [ ] 3. The capability block of `load` / `embedded` must be statically readable; the diagnostic points at `Sandbox.read` (RESOURCES.md section 7) - [ ] 4. The script as a leaf of the module graph: three edges (file, receiver type, allowlist modules), checked once per call site, cache key `(stable name, receiver type, allowlist)`, `torb check` opens the script; script imports checked against the allowlist at build time - [ ] 5. L3 purity rule: the one new case ("a call of a function the compiler can evaluate at build time") in `semantics/checker/declaration.trb`, no folding yet - [ ] 6. Folding a pure initializer in the VM and embedding the result as its constructor call (`Encode`); the six conditions as diagnostics, one message each (may split into one issue per group of conditions when it starts) - [ ] 7. Prose: `docs/standard-library/resource.md`, `sandbox.md` (three members), `docs/tooling/torb-build.md`, ECS loader snippet, CONCEPT decision log entry; RESOURCES.md status Done Done when all steps are closed and the RESOURCES.md slices 5 and 6 are marked done.
Author
Collaborator

[loop:torbscript] intake: in scope (author orion, label loop), source RESOURCES.md slices 5 and 6, not a duplicate. Depends on #137 and on Sandbox running on both implementations. next: waiting (dependency #137) until 2026-10-10T04:00:00Z

[loop:torbscript] intake: in scope (author orion, label loop), source RESOURCES.md slices 5 and 6, not a duplicate. Depends on #137 and on Sandbox running on both implementations. next: waiting (dependency #137) until 2026-10-10T04:00:00Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261029 until 2026-10-29T10:20Z

[loop:torbscript] claim refine by session:loop-torbscript-20261029 until 2026-10-29T10:20Z
orion changed title from resources: scripts as resources (RESOURCES slices 5 and 6) to Epic: resources: scripts as resources (RESOURCES slices 5 and 6) 2026-10-29 08:22:06 +00:00
Author
Collaborator

[loop:torbscript] decided by the loop: the dependency "Sandbox on both implementations" is met on main (4b59fae): tests/conformance/sandbox-crossing.trb prints the same in the VM and in a native binary, tests/conformance/vm-only/sandbox-*.trb and compiler/tests/sandbox.test.trb run scripts in the VM, Sandbox.loadText exists. RESOURCES.md probe 4 and the "Blocked" cells of slices 5 and 6 are stale (step 1 corrects them); #137 is closed. The "waiting (dependency #137)" intake note is obsolete.

[loop:torbscript] decided by the loop: slices 5 and 6 are far more than one PR (rename and retype of three Sandbox members, the literal capability block rule, graph leaf and cache key, then compile-time evaluation with six fenced conditions), so this issue is an epic with the checklist in its body. Only step 1 is filed now: #576 (Sandbox.read(path: Path)), because it is the one step that touches none of the graph/checker/script-table code that the script-receivers epic #518 (#513, #514) is reworking, and it needs no seed refresh (the compiler recognizes Sandbox.load by shape and looks up no name read). Steps 2 to 4 start after #513 and #514 have landed; step 2 changes load's signature, which the compiler recognizes by shape, so it takes the two-commit seed route when it is filed.

[loop:torbscript] decided by the loop: no owner question. The rename of load to read and the retyping of load to Resource are decided by RESOURCES.md section 5 ("Changing it costs nothing"); naming and technical design follow the design record.

[loop:torbscript] decided by the loop: the dependency "Sandbox on both implementations" is met on `main` (4b59fae): `tests/conformance/sandbox-crossing.trb` prints the same in the VM and in a native binary, `tests/conformance/vm-only/sandbox-*.trb` and `compiler/tests/sandbox.test.trb` run scripts in the VM, `Sandbox.loadText` exists. RESOURCES.md probe 4 and the "Blocked" cells of slices 5 and 6 are stale (step 1 corrects them); #137 is closed. The "waiting (dependency #137)" intake note is obsolete. [loop:torbscript] decided by the loop: slices 5 and 6 are far more than one PR (rename and retype of three `Sandbox` members, the literal capability block rule, graph leaf and cache key, then compile-time evaluation with six fenced conditions), so this issue is an epic with the checklist in its body. Only step 1 is filed now: https://git.torb.dev/torbscript/language/issues/576 (`Sandbox.read(path: Path)`), because it is the one step that touches none of the graph/checker/script-table code that the script-receivers epic #518 (#513, #514) is reworking, and it needs no seed refresh (the compiler recognizes `Sandbox.load` by shape and looks up no name `read`). Steps 2 to 4 start after #513 and #514 have landed; step 2 changes `load`'s signature, which the compiler recognizes by shape, so it takes the two-commit seed route when it is filed. [loop:torbscript] decided by the loop: no owner question. The rename of `load` to `read` and the retyping of `load` to `Resource` are decided by RESOURCES.md section 5 ("Changing it costs nothing"); naming and technical design follow the design record.
Author
Collaborator

[loop:torbscript] refine: verified the Sandbox dependency against main, turned the issue into an epic (checklist of 7 steps in the body), filed step 1 as #576 (labels loop, ready; no duplicate among the open issues for "Sandbox.read", "embedded", "Sandbox.load"), next: waiting (epic; first step #576 is ready, steps 2 to 4 follow #513 and #514, later steps are filed just in time). Worker usage: about 115k tokens (sonnet).

[loop:torbscript] refine: verified the Sandbox dependency against `main`, turned the issue into an epic (checklist of 7 steps in the body), filed step 1 as https://git.torb.dev/torbscript/language/issues/576 (labels `loop`, `ready`; no duplicate among the open issues for "Sandbox.read", "embedded", "Sandbox.load"), next: waiting (epic; first step #576 is ready, steps 2 to 4 follow #513 and #514, later steps are filed just in time). Worker usage: about 115k tokens (sonnet).
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#138
No description provided.