repl: configurable limits and environment for --sandbox #49
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?
Goal
torb repl --sandboxruns every entry under SCRIPTS.md's grant withGrant's fixed defaults (1,000,000 steps, 64 MB, 2000 ms, no environment variable) and does not narrow whichstdpackages an entry mayuse. Make the limits, the environment pattern and thestdpackages of that grant configurable with flags oftorb repl, so a session can be given exactly the room it needs. Plaintorb replandtorb repl --sandboxwithout further flags behave exactly as today.Specification
--sandboxdoes not narrow", "Neither the limits nor the environment pattern are configurable yet") and the closing paragraph of section 13 that leaves both for later. The grant words and defaults are SCRIPTS.md section 4 (steps,time,memory,environment,modules); the import lock follows its "first lock" wording.runRepland--sandboxincompiler/src/main.trbandcompiler/src/cli/repl.trb,newSessionandreplGrantOfincompiler/src/repl/session.trb(the sandbox'sGrantandgrantTextincompiler/src/vm/sandbox.trbalready carrysteps,memory,millisecondsandenvironment), usage text incompiler/src/cli/usage.trb.Interface (decided by the loop, see the comment below)
Every flag below takes its value as the next argument and is accepted only together with
--sandbox(otherwise exit code 2 with`--steps` needs `--sandbox`, so an unrestricted session never looks limited by accident).--steps <n>--time <ms>--memory <bytes>--environment <pattern>*; repeatable;"*"is all--modules <module>stdmodule an entry mayuse; repeatable; a package covers its modules, insidestd/osone module at a timestdpackage, as todayNumbers are positive integers (0, negative or non-numeric values: exit code 2 with a message naming the flag).
:resetkeeps all of them for the session it makes, as it keeps--sandbox.Acceptance criteria
--steps,--timeand--memoryset the limits of every entry (fresh budget per entry as today). Shown bytests/replsessions: a loop that stops at the default limit completes with a larger--steps, and--steps 1000stops a short loop with the sameerror:line the default limit produces today.--environment <pattern>(repeatable) letsEnvironment.getread the matching variables and only those; a variable no pattern matches reads as unset (tests/replsession:PATHreadable with--environment PATH,Nonewith--environment NOPE_*).--modules(repeatable): an entry whoseusenames astdmodule outside the list is refused before anything of the entry runs, with a message in SCRIPTS.md's style that names the module and the flag (The entry may not import `std/fs`: grant it with `--modules std/fs`) and the session survives with its bindings intact. Relative imports and the workspace's own packages are not narrowed (REPL.md section 10).:loadand:typefollow the same rule. Not given: nothing narrowed.--sandbox, a missing or invalid value, and an unknown module name (not astdpackage or module) exit with code 2 and a one-line message;torb repl --help/usage text lists the flags.:resetkeeps limits, environment pattern and modules (atests/replsession after:reset).docs/tooling/torb-repl.md(flag table, the--sandboxparagraph), REPL.md sections 7 and 13 (the "not yet configurable" and "does not narrow" sentences become what is built), theusage.trbtext, and the regeneratedskills/(torb docs skill docs skills --checkclean). SCRIPTS.md stays as is.compiler/tests/repl.test.trbor besidecli/repl.trb) for the flag parsing and the module check; existingtests/repl/sandboxsession unchanged and green.Seed
Does not touch the seed: no syntax change, no new native (the runtime already reads
memory,environmentand the limits fromgrantText), no new flag of the seed's driver (the flags aretorb's own, parsed by source inmain.trb), nostdname the compiler looks up by string. No seed refresh and no two-step migration.Size and dependencies
One PR, two Conventional Commits:
feat(repl): configurable limits and environment for --sandbox---steps,--time,--memory,--environment, flag parsing and errors, tests, docs.feat(repl): narrow the std modules of --sandbox---modulesand the import check, tests, docs.No dependency on the VM/IR follow-ups (#164),
tools/registry(#18) or the documentation module (#32); the only overlap is the regeneratedskills/anddocs/tooling/torb-repl.md, resolved by rebasing.Moved from the planning lists of the docs; the design record stays the specification.
[loop:torbscript] intake: in scope (author orion, label loop). REPL.md section 13 names the gap; how limits, the environment pattern and a package allow-list are configured for
torb repl --sandboxis new CLI andGrantsurface, so refine will likely need an owner decision. No duplicate found. next: refine (ready buffer is 6, so not before it drops below 2).[loop:torbscript] decided by the loop: interface of the configurable grant. (1) Flags of
torb repl, each with its value as the next argument and only valid together with--sandbox:--steps,--time(ms),--memory(bytes),--environment(repeatable),--modules(repeatable). Why: names follow SCRIPTS.md section 4's grant words (steps,time,memory,environment,modules) andGrant's fields; the value-as-next-argument form follows--project <directory>and--channel; refusing them without--sandboxkeeps an unrestricted session from looking limited. (2) Values are positive integers, no "unlimited" spelling: unlimited is plaintorb repl, andmemory 0(no limit in the runtime) is therefore not reachable by accident. (3)--modulesis a first lock only (import check before the entry runs), as the REPL has no second runtime lock for modules to mirror; it narrowsstdpackages only, relative and workspace imports stay as REPL.md section 10 says. REPL.md section 7 reasoned that the module lock has nothing to check for a person at their own prompt; the issue asks for it anyway as an opt-in for demos and teaching, so the default stays unnarrowed and the design record gets updated, not contradicted. (4) Additive CLI surface, defaults unchanged, so no published contract breaks and no owner question applies. (5) Size: two commits in one PR (limits and environment first, modules second), no seed involvement.[loop:torbscript] refine: rewrote the issue to goal, interface, seven testable criteria, design record points (REPL.md sections 7, 10, 13; SCRIPTS.md section 4), seed statement (does not touch the seed) and size (one PR, two commits); decisions in the comment above; no overlap with the live VM/IR (#164), registry (#18) or documentation (#32) work beyond a rebase of regenerated docs; next: implement
[loop:torbscript] claim implement by session:loop-torbscript-20261009 until 2026-10-09T08:58Z
Buffer<Item>as the heap storage primitive #54[loop:torbscript] implement: PR #246 open, CI green (
807b5b34), worker usage ~120k tokens, next: review (waiting on the merge gate argus)[loop:torbscript] close: landed via PR #246 as
83f49f01andcf14b601; main CI is green on the later headcf14b601(success). Issue closed.