feat(repl): configurable grant for torb repl --sandbox #246
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/49-repl-sandbox-grant"
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 #49
What
torb repl --sandboxtakes the rest of SCRIPTS.md section 4's grant as flags, each with its value as the next argument and only together with--sandbox:--steps <n>,--time <ms>,--memory <bytes>: the limits of every entry, a fresh budget per entry as before (SandboxSettings,replGrantOfincompiler/src/repl/session.trb).--environment <pattern>(repeatable): a name, a prefix followed by one*, or*; passed to the runtime as the grant'svariablelines.--modules <module>(repeatable): a package ofstd, or one module ofstd/os. The entry'suselines are held against it before anything of the entry runs (refusedImport), for typed entries,:loadand:type; relative imports and workspace packages are not narrowed. A modulestddoes not have endstorb replbefore the session starts (unknownModuleOf).Flag parsing is
sandboxSettingsOfincompiler/src/cli/repl.trb. A flag without--sandbox, a missing value, a limit that is not a positive whole number, a bad pattern or module, and an unknown flag exit with code 2 and one line.:resetkeeps all of them. Plaintorb replandtorb repl --sandboxbehave as before.Why
REPL.md section 7 and 13 left the limits, the environment pattern and the module lock unconfigurable. The interface follows the decision comment on #49: the words of SCRIPTS.md's grant, no "unlimited" spelling (unlimited is plain
torb repl), and the module lock as an opt-in first lock only.Two commits: limits and environment first, modules second. Docs:
docs/tooling/torb-repl.md, REPL.md sections 7, 10, 12 and 13, usage text, regeneratedskills/. SCRIPTS.md unchanged. Does not touch the seed.Test
compiler/tests/repl.test.trbfor the flag parsing, the module spelling,unknownModuleOfandrefusedImport.tests/replsessions:sandbox-steps-default(a loop of 1,000,000 rounds stops at the default 1,000,000 steps),sandbox-limits(the same loop completes with--steps 100000000, a memory hog stops at--memory,:resetkeeps the limits),sandbox-steps(--steps 1000stops a short loop with the default limit'serror:line),sandbox-environment,sandbox-environment-prefix,sandbox-flags,sandbox-modules(refused import with bindings intact,:load,:type, a workspace package'susenot narrowed,:reset),sandbox-modules-unknown. The existingsandboxsession is unchanged.torb format --checkon the touched files (clean) andtorb docs skill docs skills; the gates run in forge CI (ciworkflow onpull_request: bootstrap, gates incl.sh tools/repl.sh,torb test compiler/tests,docs skill --check,format --check, tier A/B): green on807b5b34.8fb6580e77999da70d81999da70d810f745af2a30f745af2a3fb6605e3a1fb6605e3a1807b5b341aChecklist (head
807b5b3):unknownModuleOf,refusedImport; seven newtests/replsessions; CI gates green on this head.--sandbox(exit 2); module lock is checked before anything of the entry runs, for entries,:loadand:type;:resetkeeps the settings.torb repland--sandboxunchanged; SCRIPTS.md and seed untouched.docs/tooling/torb-repl.md, REPL.md sections 7/10/12/13, usage text, regeneratedskills/; pdisc green.Non-blocking:
CI_RESULTin the Test section.--sandbox#49--sandbox#49