Skip to content

Releases

v1.4.0

Choose a tag to compare

@SMC17 SMC17 released this 28 May 01:50
v1.4.0 — shell-cfunction quota propagation: closes round-5 §6 residua…

v1.3.10 — round-5 production-robustness closures

Choose a tag to compare

@SMC17 SMC17 released this 20 May 01:07

Round 5 explicitly noted: 'rounds 1-4 + fuzz exhausted the privilege-escalation surface; round 5 findings are production-robustness, NOT no-escape claims.' Net-new escalation: zero.

4 of 5 closed; #30 (shell-cfunction quota propagation) named as honest residual with v1.4 implementation path.

  • #30 (RESIDUAL): libc.system / popen swallow EINTR; (os/shell "sleep 9999") blocks for full child lifetime despite quota. v1.4: replace with fork+execv+poll+waitpid bounded by g_alarm_fires.
  • #31 CLOSED: g_alarm_fires TOCTOU — @atomicRmw(.Xchg, 0) atomically reads-and-zeros; post-load fires credited to next dostring.
  • #32 CLOSED: janet_panicf longjmps past Zig defer (structural class rounds 1-4 missed). Doctrine: NO defer in any cfunction reachable by janet_panicf. Closed in cmd_agent_spawn + cmd_agent_run.
  • #33 CLOSED: cmd_agent_wait quota-panic leak — child + fd now SIGTERM'd, closed, reaped before panic.
  • #34 CLOSED: agentDrain 256-iteration cap as defense-in-depth.

Tests: 49/49 + 6/6 quota integration + 25/25 doctest + 5/5 strict + sandbox-fuzz clean + cfunction-audit 0 + 8/10 mutation.

Round-5 explicit prescription for round 6: 'pivot from review to either fuzz harness for the panic-leak class #3 or runtime cap-manifest implementation; a sixth pure-review pass returns mostly noise.' Recursive review has saturated for escalation findings.

v1.3.9 — round-4 adversarial review: bugs in MY OWN v1.3.4-v1.3.8 fix code

Choose a tag to compare

@SMC17 SMC17 released this 20 May 00:54

Round 4 of self-applied hostile review found 2 critical load-bearing bugs in the v1.3.4–v1.3.8 fix code itself + 1 regression + 1 doctrine inconsistency. All closed.

The auto_suspend leak (#1) is the most important shipment of the day — pre-fix, ONE quota timeout broke every subsequent eval for the rest of the process. quota_integration.sh missed it because the test piped one expression then EOFed; v1.3.9 ships a regression test that catches it.

Findings closed:

  1. SIGALRM quota leaked auto_suspend (CRITICAL). janet_interpreter_interrupt(vm) does atomic-inc on vm->auto_suspend; the matching janet_interpreter_interrupt_handled was never called. Fix: g_alarm_fires atomic counter drained by janet_dostring_quota after each eval.
  2. Wall-clock quota only bounded Janet bytecode, not blocking cfunctions (CRITICAL). agent/wait's poll loop retried on EINTR. Fix: snapshot g_alarm_fires at entry, check between poll iterations, panic on fire.
  3. Regression of round-2 #3 — new-buffer + save-as echo printed raw parsed.args[0]. Fix: use sanitized buffer.
  4. Sanitizer doctrine inconsistency — agent/spawn stripped UTF-8 while sanitizeNameInto preserved. Fix: converge on the UTF-8-preserving policy.

Tests: 49/49 + 6/6 quota integration (was 5/5; +1 regression test) + 25/25 doctest + 5/5 strict-mode + sandbox-fuzz clean.

Round 4 report shipped in repo: research/2026-05-19-adversarial-review-round4.md.

v1.3.8 — init.janet truncation warning + selective os/* closures

Choose a tag to compare

@SMC17 SMC17 released this 20 May 00:37

Two round-2 honest residuals closed:

init.janet 64KB truncation now WARNS instead of silently truncating. fstat the file first; if size > 65535, print warning + write init-janet-truncated to audit log.

3 selective os/* closures out of the 17 surviving metadata bindings round-2 enumerated:

  • os/cwd — $HOME-path info leak
  • os/setlocale — process-wide state mutation
  • os/which — program-discovery info leak

The other 14 (os/time, os/date, os/strftime, os/clock, os/cryptorand, os/isatty, os/arch, os/compiler, os/cpu-count, os/perm-string, os/perm-int, os/mktime, os/sleep, os/getpid) intentionally retained as pure-metadata or bounded-by-quota or already-low-risk.

REMOVED_BINDINGS 70 → 73. Sandbox-fuzz: 0 violations.

v1.3.7 — round-3 sandbox fuzz harness + 2 missed FFI symbols

Choose a tag to compare

@SMC17 SMC17 released this 20 May 00:34

Round 2 prescribed a fuzz harness that walks (all-bindings root-env) post-applyDefaultDeny, calls each cfunction with no args, and FAILS if any dangerous-looking symbol returned a value without panic. v1.3.7 ships it as tools/sandbox-fuzz.{janet,sh} and wires it into zig build test.

First run caught 2 missed FFI symbols that source-reading rounds 1+2 didn't enumerate:

  • ffi/calling-conventions
  • ffi/trampoline

Both added to REMOVED_BINDINGS. List grows 68 → 70.

Post-fix fuzz report:

=== mast sandbox-fuzz (round-3 prescribed) ===
  host=16 returned=45 panicked-mast=71 panicked-arity=242 panicked-other=
PASS: no dangerous cfunction returned a value from default-deny env.

The fuzz now runs on every zig build test — catches transitive re-exposures via module/find / require that source-reading reviews would miss. Round-3 prescription is alive as a continuous check.

Known limitation: 242 PANICKED-ARITY entries are functions that need arguments; fuzz calls with zero args, so Janet's validation fires before our gate. v0.4 could extend with per-function default-argv shapes.

v1.3.6 — round-2 adversarial review closures (ev/thread + CLOEXEC + sanitize-at-write + audit bounds)

Choose a tag to compare

@SMC17 SMC17 released this 20 May 00:30

mast v1.3.6 — round-2 adversarial review closures

A second self-applied hostile-reviewer pass against the post-v1.3.4 + v1.3.5 state found four more net-new gaps + 1 doctrine update. All addressed in this release. Round-2 report: research/2026-05-19-adversarial-review-round2.md.

The headline finding: ev/thread re-instantiates a fresh Janet VM that bypasses applyDefaultDeny entirely. The thread spawned by ev/thread calls janet_init() in a new OS thread, creating a VM with the FULL stdlib — every removed binding (os/shell, slurp, ffi/*, unmarshal, asm) was fully reachable from the spawned thread, even under MAST_SANDBOX_STRICT=1. Closed in v1.3.6.

What ships

Finding #1 — ev/thread fresh-VM bypass (CRITICAL)

ev/thread, ev/thread-chan, ev/spawn-thread removed via panic stubs under new DenyCategory.threading. REMOVED_BINDINGS grows 65 → 68.

ev/go is single-thread and inherits the gated env — intentionally NOT removed. The threat model now distinguishes "fresh-VM threading" (removed) from "fiber-on-current-VM" (allowed).

Finding #2 — O_CLOEXEC audit-fd leak

Without O_CLOEXEC, children of agent/spawn, agent/run, and os/shell inherited the JSONL audit-log fd. A child could discover the fd via /proc/self/fd/<n> and write raw bytes to the log, completely bypassing writeJsonString (the v1.3.4 fix for finding #3 — round 1).

Fix: O_CLOEXEC on every libc.open/libc.pipe site:

  • audit.zig::init (the log itself)
  • main.zig::load_init_janet (init.janet read fd)
  • cmd_agent_spawn pipe-read end via fcntl(F_SETFD, FD_CLOEXEC)

Finding #3 — list-buffers print path bypassed sanitize_into

v1.3.4 added sanitize_into only inside tui.render_to_buf. The line-REPL list-buffers and M-x display paths still printed buf.name unsanitized. PoC:

M-x new-buffer "$(printf 'a\x1b]52;c;cm0gLXJmIH4=\x07')"
M-x list-buffers

On OSC-52-respecting terminals, rm -rf ~ lands in the clipboard.

Fix: new sanitizeNameInto helper canonicalizes buffer names at the WRITE site (MAST_NEWBUFFER_SENTINEL + MAST_SAVEAS_SENTINEL). Doctrine: sanitize at the trust boundary, not scattered across render sites.

Finding #4 — audit.zig::write bare-array overflow

audit.zig::write had bare buf[written] = X writes with no bounds check. writeJsonString could succeed at exactly out.len == 4096, then the next buf[4096] = '}' was one byte past the 4096-byte stack array (UB on the adjacent stack slot, which on Linux x86_64 is the rc: c_int local).

Fix: new appendByte(buf, &written, b) bounded helper. Every bare-array-write site converted to try appendByte(...). Long inputs (eg. M-x save-as <~4000-char path>) now surface as error.NoSpaceLeft instead of corrupting stack.

Finding #5 — §7 manifest doctrine (doc-only)

The v2 capability-manifest paragraph previously read as if (use-capabilities :exec :fs_read) parsed from source was sufficient. Round 2 confirms: with compile + parser/produce retained (intentional per residual #19), a script can construct code at runtime that never appears as a literal. Manifest must be a runtime grant against an empty default-deny env, NOT a source scan. Threat model §6 #25 updated.

Tests

Suite Result
In-source unit 49/49 (12 buffer + 21 tui + 4 audit + 12 sandbox)
Strict-mode integration 5/5 pass
Doctest 25/25 pass
Quota integration 5/5 pass
cfunction-audit 0/16 violations
Mutation harness 8/10 killed (2 documented equivalent)

REMOVED_BINDINGS static list + drift-proof property test now iterates 68 entries × 9 probe categories × 200 random cap sets = 122,400 Janet invocations confirming the panic invariant under every cap configuration.

Numbers — cumulative across today's two adversarial-review rounds

round-1 baseline round-2 baseline Δ
REMOVED_BINDINGS entries 31 68 +37 over the day
DenyCategory variants 10 14 +4 (ffi, process_control, bytecode, threading)
Documented threat-model findings 12 25 +13 in §6 numbered list
Adversarial-review reports 0 2 round 1 + round 2, self-applied

What's left

  • G3 — soak time. Out of session scope.
  • G4 — independent external review. Two rounds of self-applied internal review documented; not a replacement for external eyes.
  • G5 — Zig 1.0. Out of repo control.
  • Memory + fd quotas. Wall-clock quota shipped in v1.3.5; memory/fd extensions deferred.
  • Per-row TUI emit path. Diff helper shipped in v1.3.3; actual row-granular emit deferred to v0.4.
  • pidfd_open / kqueue for agent/wait. 500ms backstop adequate for handfuls of concurrent agents.
  • Residual #19 — compile/signal/debug/* retained intentionally. Cannot be removed without breaking the language; informs §7 doctrine.
  • 17 surviving os/ metadata bindings* (sleep/cwd/getpid/setlocale/cryptorand/isatty/perm-/which/arch/compiler/cpu-count/mtime/date/strftime/clock). Round-2 named these as low-severity but un-enumerated. v0.4 §3 cleanup.
  • 64KB init.janet silent truncation. Round-2 confirmed; low-severity (host-trusted).

Upgrade

git pull && zig build test --summary all

API-additive (new sanitizeNameInto, appendByte helpers); no removals from the Zig public API. The Janet-script surface lost 3 more symbols (ev/thread/thread-chan/spawn-thread).

Round 3?

Round 2 prescribed a fuzz harness that walks (all-bindings root-env) post-applyDefaultDeny and diffs against REMOVED_BINDINGS. That's the next escalation — it would catch transitive re-exposures via module/find / require that source-reading rounds 1 and 2 might both miss.

v1.3.5 — resource quota: wall-clock budget per eval

Choose a tag to compare

@SMC17 SMC17 released this 20 May 00:22

mast v1.3.5 — resource quota via SIGALRM + janet_interpreter_interrupt

Closes the long-standing v1.3.0 §honest-residuals "no resource quotas" item. The primitive (janet_interpreter_interrupt + janet_local_vm) was identified in v1.3.3 (vendored/janet/janet.h lines 2066–2072); v1.3.5 wires it into the production paths.

What ships

Wall-clock quota on every Janet eval. SIGALRM handler calls janet_interpreter_interrupt(janet_local_vm()) which cancels the running fiber at the next bytecode-op boundary. janet_dostring_quota wraps:

  • run_repl — every M-x verb the user types
  • cmd_agent_run — the synchronous agent invocation path (the spawn itself, not the spawned child)
  • load_init_janet — startup script

Each wrapper arms libc.alarm(N) before the call and disarms with libc.alarm(0) after. The cancelled fiber returns non-zero status; mast surfaces this as a normal mx-error audit event. The editor recovers — it does not die.

Configurable via MAST_EVAL_TIMEOUT_SEC env var. Default 30 seconds. Cap 3600 seconds (1 hour) as a sanity backstop.

Smoke test (live confirmation)

$ printf '(while true 1)' | MAST_EVAL_TIMEOUT_SEC=3 ./zig-out/bin/mast
M-x interrupted:
  in thunk [mx] on line 1, column 1
  (error: status=1)
M-x

Pre-v1.3.5 this would freeze mast until the user hit external Ctrl-C. Post-v1.3.5 the editor cleanly interrupts after the configured budget, prints the standard Janet panic, and presents the next prompt.

Threat model impact

§6 #8 flips: ~~No resource quotas~~ → CLOSED 2026-05-19 (v1.3.5).

What remains: only wall-clock quota is implemented in v1.3.5. Memory quota (heap-exhaustion via (repeat 1e9 ...)) and fd quota (file-descriptor exhaustion) extend through the same primitive (each would need a separate observer + alarm category) but are deferred to v0.4.

Verification

git tag -v v1.3.5
# gpg: Good signature from "stax release signer ..."

Tests (unchanged)

Suite Result
In-source unit 49/49 (12 buffer + 21 tui + 4 audit + 12 sandbox)
Strict-mode integration 5/5 pass
Doctest 25/25 pass
cfunction-audit 0/16 violations
Mutation harness 8/10 killed (2 documented equivalent)

The v1.3.5 change is in main.zig; it does not introduce new in-source tests because the quota path is integration-tested via the live smoke above (no test module currently links the full main.zig Janet env to exercise SIGALRM).

v1.3.4 — adversarial-review-driven security closures

Choose a tag to compare

@SMC17 SMC17 released this 20 May 00:18

mast v1.3.4 — adversarial-review-driven security closures

Substantive security release. A self-applied hostile-reviewer pass against the post-v1.3.3 threat model found seven net-new gaps the prior audit missed. All seven are addressed in this release (six closed mechanically, one documented as intentional residual). The full review report ships in the repo at research/2026-05-19-adversarial-review.md.

The headline finding is a real file-I/O sandbox bypass: the prior v0.2 "file I/O CLOSED" claim was half-true. os/open + the file/* methods (file/read/write/close/seek/tell/flush/lines) remained live, so under MAST_SANDBOX_STRICT=1 a Janet script could do (file/read (os/open "/etc/shadow" :r) :all) and the gate would not fire. That gap is now closed.

What ships

Finding #1 — fs-I/O sandbox completion

9 new symbols added to REMOVED_BINDINGS: os/open, os/pipe, file/read, file/write, file/close, file/seek, file/tell, file/flush, file/lines. The threat model §6 #2 "file I/O CLOSED" claim was half-true — file/open/slurp/spit were removed in v0.2 but os/open + the method surface survived.

Finding #2 — FFI surface (15 symbols)

ffi/native, ffi/lookup, ffi/call, ffi/signature, ffi/jitfn, ffi/malloc, ffi/free, ffi/read, ffi/write, ffi/pointer-cfunction, ffi/pointer-buffer, ffi/struct, ffi/size, ffi/align, ffi/context all removed under new DenyCategory.ffi. The §3 ffi row previously claimed the vendored Janet build did not compile FFI — false. vendored/janet/janet.h:269 defines JANET_FFI unconditionally. ffi/jitfn alone is strictly stronger than the removed native — mmap + execute arbitrary bytecode.

Finding #3 — audit-log JSON injection

src/audit.zig::write previously formatted payload string fields as raw JSON via bufPrint("\"{s}\":\"{s}\"") with no escape, so a hostile M-x verb / save-as path / buffer name could forge log lines. PoC: a verb containing ","verb":"sandbox-grant","x":" would forge a sandbox-grant event downstream.

Fix: new writeJsonString helper escapes ", \, control bytes (\u00XX for 0x00–0x1f and 0x7f). Every user-controllable string field now routes through it. 4 in-source tests cover trivial ASCII, quote/backslash/newline, control-bytes, and the published PoC neutralization.

Finding #4 — TUI ANSI escape injection

src/tui.zig emitted buf.name (settable via M-x save-as) and buf.contents (carrying agent-spawn stdout) raw to stdout. PoC:

(agent/spawn "printf '\\x1b]52;c;cm0gLXJmIH4=\\x07'")

On OSC-52-respecting terminals (kitty, iTerm) this puts rm -rf ~ into the system clipboard for the user's next paste-into-shell.

Fix: sanitize_into helper replaces ESC (0x1b), BEL (0x07), DEL (0x7f), and other C0 control bytes (except \t/\n/\r) with ? in the render path. 3 in-source tests cover the OSC 52 PoC + UTF-8 passthrough + DEL handling.

Finding #5 — process-control survivors

8 symbols added to REMOVED_BINDINGS under new DenyCategory.process_control: os/cd, os/umask, os/link, os/proc-kill (arbitrary-pid signal — strictly worse than the gated agent/kill), os/proc-wait, os/proc-close, os/sigaction (could make mast un-killable by SIGTERM), os/posix-chroot.

Finding #6 — bytecode constructors

2 symbols added under new DenyCategory.bytecode: asm (constructs Janet functions from a runtime dictionary — pure-Janet bytecode builder) and marshal (paired serializer to the already-removed unmarshal).

Honest residual #19: compile, signal, debug/* are intentionally NOT removed. compile underpins every (eval …); signal is the primitive try/catch raises through; debug/* is the only Janet introspection surface. Removing them would break the language. The v2 capability-manifest plan must not assume source-level review is sound — the manifest must be a runtime grant, not a code scan. This is the doctrine consequence of the bytecode residual.

Finding #7 — agent/wait DoS under strict mode

agent/wait + poll + count + alive? previously were not gated on exec. PoC: user runs M-x agent-run "sleep 9999" under default policy; later, any strict-mode script calling (agent/wait 0) freezes mast for the full hour even though the script itself has no exec cap.

Fix: every agent/* operation now gated on exec, matching the capability domain that created the handle.

Tests

Suite Result
In-source unit (Zig) 12 buffer + 21 tui + 4 audit + 12 sandbox (= 49 unique tests; total counted differs because tui transitively imports buffer)
Strict-mode integration (bash) 5/5 pass
Doctest 25/25 pass
cfunction-audit (bash) 0 violations across 16 cfunctions
Mutation harness (bash) 8/10 killed (2 documented equivalent)

The property test (REMOVED_BINDINGS panic-invariance under random cap sets) now iterates 65 entries × 9 probe categories × 200 random cap sets = 117,000 Janet invocations confirming every removed binding panics regardless of grants.

Numbers

v1.3.0 v1.3.4 Δ
REMOVED_BINDINGS entries 16 65 +49
DenyCategory variants 10 13 +3 (ffi, process_control, bytecode)
cfunction-audit.sh cfunctions 15 16 +1
Doctest checks 25 25 —
In-source tests (unique) 22 49 +27

What's left open

  • G3 — soak time. Not yet started.
  • G4 — independent security review. This v1.3.4 release IS a self-applied hostile-reviewer pass acting on its own findings; not a substitute for external eyes.
  • G5 — Zig 1.0. Out of repo control.
  • Resource quotas. janet_interpreter_interrupt() primitive identified in v1.3.3; implementation pending.
  • Residual #19 — compile/signal/debug/* retained. Manifest plan must be runtime-grant-based, not source-scan-based.
  • Per-row TUI damage tracker actual EMIT path. v1.3.3 ships the pure diff helper; row-granular emission (cursor + clear-line per changed row) is v0.4.
  • pidfd_open / kqueue for agent/wait. v1.3.x ships poll(2) on stdout_fd with 500ms backstop.

Upgrade

git pull && zig build test --summary all

API-additive (new tui.frame_changed, tui.diff_rows, tui.sanitize_into, audit.writeJsonString); no removals from the public Zig API. The Janet-script surface lost 34 symbols (all dangerous bindings that should not have been reachable). The MAST_SANDBOX_STRICT=1 posture is now closer to honest.

Verification

git tag -v v1.3.4
# gpg: Good signature from "stax release signer ..."

v1.3.2 — agent/kill + TUI damage tracker

Choose a tag to compare

@SMC17 SMC17 released this 19 May 19:39

mast v1.3.2 — agent/kill + TUI damage tracker

Patch release on top of v1.3.1. Two more honest-residuals from the v1.3.0 release notes now closed.

Post-release amendment (commit 88ead92): the v1.3.2 FrameState test as originally published called emit_with_damage which writes to stdout via write_str; under the Zig test runner's --listen=- transport this can deadlock the test when the runner's stdout-capture pipe fills under load. The fix splits the diff logic into a pure tui.frame_changed() helper (no side-effect) that the test now uses. Production code path is unchanged. Tests now pass 36/36 under host load 35+ (12 buffer + 15 tui-with-transitive-buffer + 9 sandbox).

What ships

(agent/kill handle) — in-session cancellation

The "no agent/kill handle for in-session cancellation (process exit reaps, but no per-handle SIGTERM verb today)" residual named in v1.3.1 is closed.

(def h (agent/spawn "sleep 30"))
(agent/alive? h)   # -> true
(agent/kill h)     # -> true (signaled)
(agent/wait h)     # -> 0 (reaped)
(agent/alive? h)   # -> false
  • Signals SIGTERM via libc.kill(pid, SIGTERM)
  • Returns boolean: true if signal was sent, false if handle is invalid or already closed
  • Audits the kill as agent-kill event in the session log
  • Gated on exec (signaling a child you started is the same capability as starting it)
  • Reaping is still via (agent/wait handle) — kill just signals; the caller collects the exit status

TUI damage tracker — frame-level diff

The "TUI is full-redraw per keystroke" residual named in v1.3.0 is closed in the common case (any unchanged frame).

  • tui.render_to_buf(out, allocator, ...) writes into a caller-supplied byte buffer instead of stdout
  • tui.FrameState + tui.frame_changed(state, allocator, current) (pure: diff + cache-update, no side-effect)
  • tui.emit_with_damage(state, allocator, current) (frame_changed + write_str when changed)
  • tui.invalidate(state) forces full redraw on the next emit (use after window resize, after exiting/entering alt-screen, after any out-of-band stdout write)
  • run_tui() in main.zig now runs through the damage-tracked path

What this fixes: repeated no-op keystrokes (unbound keys, scrolling past EOF on a short buffer, holding a key) no longer cost a screen-rewrite per keystroke. The TUI feels snappier under bursty input. Full-redraw still happens on every state-changing keystroke (any j/k/n/p/g/G/: input).

Not fixed in v1.3.2: row-level damage tracking (frame-level diff still emits the whole frame when ANY byte differs). Row-level would only emit changed rows on large terminals; v0.4 work.

What's left on the residual list

After v1.3.2, the remaining open items from the v1.3.0 honest-residuals are:

  • G3 — soak time. Out of single-session scope.
  • G4 — independent security review. Internal substitute documented; not a replacement.
  • G5 — Zig 1.0. Out of repo control.
  • Resource quotas. Needs a Janet fiber-level interrupt primitive not yet designed.
  • Per-row TUI damage tracking. v0.4 incremental work.
  • pidfd_open / kqueue for agent/wait. v1.3.x ships poll(2) on stdout_fd with 500ms backstop. True OS-level child-exit notification would eliminate the 500ms wake. v0.4 work.

Tests (post-88ead92 fix)

Suite Result
In-source unit (Zig) 36/36 pass (12 buffer + 15 tui-with-transitive-buffer + 9 sandbox)
Strict-mode integration (bash) 5/5 pass
Doctest 25/25 pass
cfunction-audit (bash) 0 violations across 16 cfunctions
Mutation harness (bash) 8/10 killed (2 documented equivalent)

Upgrade

git pull && zig build test --summary all

No source-API changes for callers; v1.3.2 additions are purely additive on the agent/* and tui.* surfaces. The new tui.frame_changed helper is exposed for any caller that wants to make their own emit decision.

Verification

git tag -v v1.3.2
# gpg: Good signature from "stax release signer ..."

GPG public key fingerprint: 079261B06444C6A410B3BE363CFCB60243028886.

v1.3.1 — residual closures + tooling

Choose a tag to compare

@SMC17 SMC17 released this 19 May 19:20

mast v1.3.1 — residual closures + tooling

Patch release on top of v1.3.0. Four residuals named in the v1.3.0 release notes are now closed, the documentation drift discipline is meaningfully tighter, and the host-cfunction regression surface gets a first-class static check.

What ships

Residual #9 — sandbox-deny audit routing (CLOSED)

Previously, every removed-binding panic and every exec-gated deny went only to stderr via janet_panicf. The host had no first-class hook to route deny events into SessionAudit. v1.3.1 introduces:

  • sandbox.DenyCategory enum: exec_gated | subprocess | file_io | net | native | unmarshal | exit | dofile | env | fs_ancillary
  • sandbox.g_deny_observer callback hook
  • Every panic stub + both exec-gated wrappers call observe(category) before janet_panicf, so even unrecoverable denies leave a trace in the audit log before Janet's stacktrace hits stderr
  • main.zig::onSandboxDeny routes events → SessionAudit.write("sandbox-deny", { category })
  • One new in-source test exercises 5 categories from a single Janet VM

Residual #8 — agent/wait poll(2) (CLOSED)

v1.3.0 shipped agent/wait as a 10ms usleep loop. v1.3.1 replaces that with poll(2) on the stdout_fd + a 500ms backstop timeout:

  • poll wakes immediately on stdout activity OR pipe EOF (child closed the write end, almost always == process exit)
  • 500ms backstop covers the rare "child exits without closing stdout" case (eg. a grandchild still holding it)
  • Lower CPU under many concurrent agents; faster wake-up under bursty output

Residual #10 — host-cfunction regression discipline (CLOSED)

tools/cfunction-audit.sh enumerates every janet_def-registered cfunction and FAILS if any touches a dangerous syscall (libc.system / popen / exec* / fork) without consulting sandbox.g_sandbox.has(...) or delegating to a sandbox.gated_* function. Escape hatch: // cfunction-audit-ok: <reason> marker.

Wired into zig build test so the discipline runs on every test invocation. Available standalone as zig build cfunction-audit.

Initial scan: 15 cfunctions, 3 gated, 12 benign, 0 violations.

TUI minibuffer sentinel handling (CLOSED)

The v1.3.0 TUI prototype punted on sentinel verbs (save/append/save-as/new-buffer). v1.3.1 wires them through execute_mx_line() directly so the TUI minibuffer can drive mutation-bearing verbs. Display-only sentinels (help/display/list-buffers) deliberately stay punted — the TUI renders that state inline.

Documentation drift discipline (tightened)

tools/doctest.sh extended from 13 → 25 checks. New coverage:

  • Multi-buffer ring lifecycle (empty → new-buffer × 2 → list shows count → switch-buffer 0 → cycle to next)
  • (agent/run cmd) returns new buffer index AND captures stdout into the :agent buffer
  • (agent/spawn cmd) → handle int; (agent/wait h) → exit status int; (agent/alive? h) → false after exit
  • mast --tui <file> exits cleanly on 'q' AND emits ANSI alt-screen-enter (1049h)
  • (slurp "/etc/hostname") and (os/getenv "HOME") panic with the documented REMOVED marker (G2 closure visible from user-script)

Mutation test re-run

8/10 killed, 80% score unchanged. No new survivors emerged from the v1.3.x sandbox extensions. The 2 survivors (M08 fd-zero, M10 mark-clamp no-op) are documented equivalent mutants per the v1.1.0 CHANGELOG.

Tests

Suite Result
In-source unit (Zig) 22/22 pass (was 21 in v1.3.0; +1 deny-observer test)
Strict-mode integration (bash) 5/5 pass
Doctest 25/25 pass (was 13 in v1.3.0; +12 new checks)
cfunction-audit (bash) 0 violations across 15 cfunctions
Mutation harness (bash) 8/10 killed (2 documented equivalent)

Honest residuals (still present in v1.3.1)

These remain open and are named for honesty:

  • G3 — soak time. ≥30 days of daily-driver use; not yet started.
  • G4 — independent security review. Internal substitute (threat-model + mutation + cfunction-audit + 25/25 doctest) is the strongest current surrogate but is not a replacement for external eyes.
  • G5 — Zig 1.0. Out of repo control.
  • Resource quotas. A pathological Janet script can spin (while true) or fill the heap. v0.3+; requires a Janet fiber-level interrupt primitive not yet designed.
  • TUI damage tracker. Full-redraw per keystroke today; adequate on small terminals, suboptimal on 200×80+. v1.3.x will add a damage tracker.
  • agent/kill handle verb. Process exit reaps any still-running agents via SIGTERM + waitpid, but there is no per-handle in-session cancellation verb.

Upgrade

git pull && zig build test --summary all
# 22/22 unit + 25/25 doctest + 5/5 strict + 0 cfunction-audit violations

No source-API changes; the v1.3.x additions are purely additive.

Build matrix

Linux x86_64 + macOS arm64 on Zig 0.16.0, both verified in CI. Single binary, vendored Janet (3.3 MB amalgamated source compiled in-tree), no external make, no system Janet, no Zig dependency graph (no build.zig.zon).