Repository navigation
Description
Summary
Replace GocciaScript's scattered capability flags with one capability model: an immutable engine-level capability set, a --allow-<cap> / --deny-<cap> grammar, config permissions that apply only through an explicit trust step, and a single runner that has a sandbox filesystem mode. It ships as one hard-breaking release (0.14.0). The design is recorded in ADR 0122.
Why
- Defaults contradict VISION. VISION promises "no ambient file system", yet the default loader can read any file the process can read through
import … with { type: "bytes" }, because host-filesystem module loading is on by default. - Config grants itself capabilities. A discovered
goccia.json, found by walking up from each script, can grantunsafe-ffi,allowed-hosts,allow-node-modulesandunsafe-*. Running a cloned project can therefore enable network or native code with no flag. - Flags have no shared grammar. Current forms include
--allowed-host,--unsafe-ffi,--allow-node-modules[=ceiling],--no-host-filesystemand--fetch-deny-private-ranges. Flag options ignore their value, so--unsafe-ffi=falseenables FFI. - Several binaries silently ignore capability options. The bundler ignores all runtime options, the REPL ignores
--timeoutand--no-host-filesystem, and the sandbox runner ignores--allow-node-modules. - The embedding API is scattered and partly process-wide. It spans
AttachRuntime(hostFileLoading),SetAllowedFetchHosts, the process-globalSetFetchRequestPolicy,AllowNodeModulesand extension installs.
Current behavior
- No-flag loader: host files are readable through imports;
fetchexists with an empty allowlist; FFI,eval, ShadowRealm andnode_modulesare off; theFunctionconstructor throws. - Per-folder configs grant capabilities implicitly. CI's test run depends on this for FFI, fetch, ShadowRealm, AST,
node_modulesand the Function constructor. GocciaSandboxRunneris a separate binary with its own CLI. Its entry is a sandbox path that must be seeded separately, and it has--seed/--seed-config, four--diff*flags,--fs-quota-bytes/--fs-node-limit, and--config-only config.
Expected behavior
Model
- One immutable capability set, owned by the engine and fixed at creation. The CLI, config and embedders only fill it in; nested contexts can only narrow it; there is no process-wide policy.
- With no flags, nothing reaching outside the process is allowed, except statically importing code and data from inside the project (the nearest
goccia.jsondirectory, or the entry's directory). - No interactive prompts.
Grammar
--allow-<cap>[=scope,…]/--deny-<cap>[=scope,…]. Deny always wins, independent of order. There is no--allow-alland no environment-variable form.
Capabilities
read: canonical paths (symlinks resolved), recursive.net:host,host:port,*.domain, IPs and CIDR ranges,private. Private ranges are denied unless named, and every redirect hop is re-checked.ffi: library paths.import:node_modules[=ceiling]and provider hosts such asgithub.
Settings outside the grammar
- Limits become
--max-memory,--max-fetch-bytes,--max-fs-bytes,--max-fs-nodes,--max-instructionsand--max-stack, with unit suffixes.--timeoutaccepts units. --unsafe-*language escapes stay separate but need trust when they come from config.--compat-*,--experimental-*and--deterministicstay settings.
Config and trust
- A config's
permissionsblock, itsunsafe-*keys and itssandboxinputs are requests, not grants. There are no named sets. --trust <path>stores path + SHA-256 of the normalized effective block in a user-level store outside the repo, after showing the change.--untrustand--list-trustedmanage the store.- An untrusted or changed config fails startup with the exact fix.
-Ptrusts the declarations for a single run; CI uses it. - A binary fails on a capability flag it can't honor and warns when the capability comes from config.
Runner
GocciaScriptLoaderbecomesGocciaRunnerand absorbsGocciaSandboxRunneras a sandbox filesystem mode. The mode activates on--copy/--copy-rw, a trustedsandboxconfig section, or--sandbox.- The entry is a host file, auto-copied into the sandbox;
--entrycovers the rare sandbox-only case. --copy <host>[=<sandbox>]copies read-only.--copy-rwmarks an input for write-back, following ADR 0119's rules.--diff[=json|unified]prints the diff;--diff-file=<path>writes it.- In sandbox mode only
netis allowed, andfs,$andrunScriptexist only in this mode.
Surfacing
- Denials raise a catchable
PermissionDenied. Its guest-visible message names the capability and scope, never host paths; the host-side report names the flag or--trustcommand to use. - Audit event kinds are named after capabilities, and every allow and deny is emitted. New
config.permissionsandcapabilities.effectiveevents record trust decisions and the final set. - Provider imports:
--allow-import=githubdownloads at resolve time against a required, hash-verified lockfile, with no default hosts.
Scope notes
Delivery. A hard break with no aliases: old flags and keys fail with an error naming their replacement. It ships as one native PR stack that merges atomically as 0.14.0. Layers exist for reviewability only, so an intermediate layer builds and passes its own tests but does not have to preserve behavior. The boundary is mechanism (engine) versus policy (CLI):
0. ADR 0122 (#1256).
- Engine capabilities. The immutable set and Pascal API;
readenforcement with scopes and the module-graph exemption;netscopes and private ranges;ffipaths;node_modules; the per-engine fetch policy;PermissionDenied; audit events renamed after capabilities, pluscapabilities.effective. Engines created without a set getNone(deny everything); embedders and tests declare what they need. - CLI surface and defaults. The
--allow-*/--deny-*grammar, the hard break,--max-*limits with units, errors for unsupported capabilities, and the user-facing deny-by-default flip. - Config trust.
permissionsblocks, the path+hash trust store,--trust/--untrust/--list-trusted,-P. - One runner.
GocciaScriptLoaderbecomesGocciaRunner, with sandbox mode (--copy,--copy-rw,--diff,--diff-file, host entry) replacingGocciaSandboxRunner. - Provider imports. feat(modules): add gated remote package imports #1054 rebuilt as
--allow-import=github.
Standalone fixes shipped first (security bugs found while designing layer 1, fixed on main independently of this stack):
- A nested
runScriptfrees the thread's fetch manager: the parent loses--fetch-deny-private-ranges/--fetch-max-response-bytes, and fetch-then-runScripthangs or crashes. --no-host-filesystemis bypassed by--modules=<manifest.js>.
Docs. ADR 0122 supersedes the flag decisions in ADRs 0068, 0097 (event names), 0103 (host filesystem default), 0111, 0119 and 0121. A new docs/permissions.md becomes the single reference. VISION's "no ambient file system" becomes literally true.
Test suite. CI adds -P. The fetch tests declare private for 127.0.0.1, and capability-dependent folders declare their needs.
Related. #1054 (provider imports; stays a draft until layer 8); #1254 (single goccia binary; a follow-up, not part of this stack); ADR 0107 (its out-of-process capabilities section should adopt these names).
Activity
frostney commentedon Sep 25, 2026
Design recorded in ADR 0122: #1256.
docs(adr): record the unified allow/deny capability model (#1256)
frostney commentedon Sep 28, 2026
Done. The unified capability model shipped in the #1260 stack:
--allow-*/--deny-*grammar, with everything else denied by defaultGocciaRunnerwith a sandbox mode, replacingGocciaScriptLoaderandGocciaSandboxRunnerRelease follow-ups are #1268–#1271, and the docs sync is #1272. A single
gocciabinary stays in #1254.