Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/SANDBOX-NEEDS.md # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / SANDBOX-NEEDS.md` 451 lines ยท 33888 bytes Raw Blame History Rendered 1 # forged sandbox needs 2 3 Baseline: ``c0f108e7fcd854edbda3e64f260af58c47c86d30``. This is a candidate, 4 not a deployment. The wrapper is existing-host shell infrastructure as explicitly 5 requested by L1058. The server remains seeded Omega. No dependency was downloaded. 6 7 ## Source inventory 8 9 | Access | Source | Purpose and policy | 10 | --- | --- | --- | 11 | Executable | `run.sh`, `infra/spark/forged-service.sh` | The selected forged binary only, mounted read-only at `/app/forged`. No source worktree. | 12 | Static assets | `server/pages.om`, `server/route.om` | CSS and page text are embedded in the binary. No asset directory is needed. | 13 | Repository list | `server/repos.om:5` | `~/handoffs/radicle/RIDS.md`, first table. Read-only file inside the dedicated directory export. | 14 | Repository objects, refs, config, packed refs | `server/util.om:101`, `server/repos.om`, `browse/`, `dl/`, `collab/` | Individual public bare repos under `~/.radicle/storage/`. Read-only. Denied repos and unrelated working trees are absent. | 15 | Download caches | `dl/dl.om` | `/archives`, temporary archive files, final archives, hashes, eviction and locks. Writable. | 16 | Collaboration caches | `collab/co8cache.om`, `collab/co4pat.om` | `/collab`, cached COB views and generated diffs, temporary files and locks. Writable. | 17 | Social state | `social/05decl.om`, `social/20crypt.om`, `social/30store.om`, `social/40auth.om` | `/social.key`, `social.log`, `social.head`, `social.head.tmp`, `tmp/` signature verification inputs. Writable. The session key belongs to this service and is necessarily visible to it. | 18 | Reload | `server/main.om` | `/reload` is read and unlinked. RIDS modification time is checked. | 19 | Published review metadata | `collab/co2cob.om:68,1156` | Export copies of `*.verdict.txt` and `*.receipt.txt` files from `~/handoffs/hive/manager/reviews` and `~/handoffs/hive/forge/receipts`. Read-only. Other handoff contents are absent. Synthetic parent directories replace the real home and handoffs directories. | 20 | Node health snapshot | `nodes/stat.om:8` | `~/.local/state/aien-factory/nodes.txt`, read-only individual file if present. No node databases, keys, control sockets or other factory state. | 21 | Logging | `server/main.om`, service wrapper | The server writes its inherited stderr. The supervisor owns `/logs` and `/forged-supervisor.pid`. These are mounted read-only inside the child so it cannot plant symlinks or falsify the pid that the supervisor trusts. The reload writer uses an atomic replacement, not touch on a child-controlled path. | 22 | Programs | `server/util.om:102,560`, `social/20crypt.om`, `dl/dl.om` | `/usr/bin/git`, `/usr/bin/ssh-keygen`. The installed Git compresses tar.gz internally. Only these binaries and the dependencies reported by their local `ldd` are mounted read-only. No shell or gzip executable is mounted. The probe replaces the main executable with dash and reads its script on stdin; it gets the same filesystem profile. | 23 | System data | signature verifier, loader, Git archive | Synthetic one-user `/etc/passwd`; no host account database. Read-only `/etc/localtime` is required for byte-identical ZIP date fields. `/dev/null`, `/dev/urandom`. Private read-only `/proc`, not the host process view. | 24 25 Git may consult its repository's config and attributes. The sandbox hides the host 26 Git configuration, SSH keys, SSH agent, vault, home dotfiles, other repositories 27 and executables. Repository symlinks cannot lead back to a hidden host path. 28 29 `nodes/snap.om` is a separate producer, not a forged child. Its sqlite3, rad, 30 node databases and network access are not needed inside the web server. 31 32 ## Network and processes 33 34 Unsandboxed, `server/main.om` calls `hlisten` on IPv4 loopback, port 18480, then accepts 35 HTTP connections. The private build changes only the port to 19830 and home path 36 constants to its fixture. Runtime tracing is retained by the test runner. 37 The composed server has no outbound connect call or Unix socket dependency: the seed 38 library's `hdial` is compiled in but never called. Git and ssh-keygen are started with 39 explicit arguments and an empty environment, and only read local files. 40 41 Since r5 Part B the sandboxed server has no network (`bwrap --unshare-net`). Its private 42 namespace holds only `lo`, with no listener and no route out. The 127.0.0.1:18480 listener 43 is made outside the sandbox by `infra/spark/forged-listen.om`, a seeded-Omega helper that 44 binds, listens, puts the listener on descriptor 0 without close-on-exec, and execs the next 45 program with a fixed environment. 46 47 Since netns r2 the service supervisor owns the listener for its whole life. `forged-service.sh 48 _loop` takes the port once through forged-listen (exit 3, and no service, when the port is 49 taken), checks that descriptor 0 is the listener on its port, keeps it on a descriptor of its 50 own, and hands it on descriptor 0 to every forged it starts. The port is never unbound while 51 the supervisor runs: connections that arrive during a restart wait in the queue (backlog 64) 52 for the next forged, and no other local process can bind the port in between, provided the child 53 cannot give the listener away (the listener guard below). A restart for 54 a new repository set is a drain: the supervisor writes the flag file `/restart` 55 (atomic replacement, like the reload flag), forged removes it and exits 0 after the connection 56 it is serving, and after 10 s without an exit the supervisor sends TERM. A direct wrapper start 57 with `FORGED_LISTEN_PORT` still makes its own listener through forged-listen. 58 59 With a listening socket on descriptor 0 the wrapper adds `--inherited-listener` in every mode 60 (network cut on or off, sandbox on or off). forged checks that descriptor 0 is the IPv4 61 listener on 127.0.0.1 and its compiled port, moves it to a close-on-exec descriptor, and puts 62 /dev/null on descriptor 0, so git and ssh-keygen never inherit it. Without 63 `--inherited-listener`, forged binds its own listener exactly as before. 64 65 The listener, and every connection forged accepts from it, belongs to the host network 66 namespace, so interface questions asked through them are answered about the host: SIOCGIFCONF, 67 SIOCGIFNAME, SIOCGIFADDR, SIOCGIFHWADDR, SIOCGIFNETMASK, and SO_BINDTOIFINDEX followed by 68 SO_BINDTODEVICE (the review found the first; r2 found the others). No namespace setting changes 69 that, because the namespace belongs to the socket. The socket filter closes it: a classic BPF 70 seccomp program written by the seeded-Omega generator `infra/spark/forged-seccomp.om`, built by 71 `run.sh` into `forged-seccomp.bpf` beside forged and installed by bwrap (`--seccomp`) just 72 before it executes forged. It allows ioctl only for FIOCLEX, FIONCLEX, FIONBIO, FIONREAD, TCGETS 73 and TIOCGWINSZ; socket and socketpair only for AF_UNIX (no netlink, inet or packet socket); 74 setsockopt only for TCP_NODELAY and SO_REUSEADDR, SO_SNDBUF, SO_RCVBUF, SO_KEEPALIVE; it refuses 75 connect, shutdown and io_uring; everything refused fails with EPERM. A system call from any 76 architecture other than AArch64 kills the process. The wrapper refuses a filter that is 77 missing, inside data or export, or not a whole number of 8-byte instructions. 78 `FORGED_SECCOMP` names another location (tests use it for host tools). bwrap installs the filter 79 in its last step, after it has brought up lo in the new namespace (one SIOCGIFINDEX and a netlink 80 socket of bwrap's own, outside the filter), so it covers forged from its first instruction and 81 every process forged starts. The gate makes three traces with process tracking: the server serving 82 the smoke and download routes (forged starts git many times there), and git and ssh-keygen each run 83 directly as the wrapper's program (bwrap starts that program as /app/forged). It requires no EPERM 84 (the filter must not change what forged does) and checks with `infra/test/seccomp-order.py` that 85 each of the three programs starts under the filter (by its arguments: `--inherited-listener`, 86 `log`, `-Y`), that forged's git runs under it, and that no process under the filter opens a 87 netlink or inet socket or gets an answer from an ioctl outside the allowlist. A filter that allows 88 everything must fail that check. The only refusal the work meets is glibc's name-cache lookup in 89 git and ssh-keygen (connect to /var/run/nscd/socket, ENOENT before the listener guard); glibc 90 then reads the files, as before; the gate allows exactly that refusal and counts it. 91 92 **Listener guard** (netns r2 review of `8f6b4a29`, findings 1 and 2). The listener is shared: the 93 supervisor and the child hold the same socket. Three calls on the child's copy give the port 94 away: shutdown (SHUT_RD or SHUT_RDWR) and connect with an AF_UNSPEC address both disconnect a 95 listening socket, after which a local process with SO_REUSEADDR binds 127.0.0.1 on the port and 96 receives the connections (the supervisor's copy is the same disconnected socket); and SO_REUSEPORT 97 lets a local process with SO_REUSEPORT bind the same address and take a share of new connections 98 (6 of 8 in the review). The filter refuses connect, shutdown and SO_REUSEPORT. forged calls none 99 of them (it never connects; the listener is bound outside). Gate steps: `seccomp-table` 100 (`infra/test/seccomp-table.py` runs the filter bytes over a table of 45 calls, without trusting the 101 generator's notes), `netns-poison` (`infra/test/listener-poison.py`, under the real forged-listen: 102 the sandboxed leakprobe makes each call on the inherited listener, a rival with SO_REUSEADDR and 103 SO_REUSEPORT tries the port, the successor forged starts on the held listener, 8 connections show 104 who answers), and controls that must reproduce each case: `seccomp-table-control` and 105 `netns-poison-control` (the `8f6b4a29` filter), `netns-poison-mutants` (this filter with one rule 106 removed each). Measured on the host (not a gate step): listen() again on the same socket, shutdown 107 SHUT_WR, connect to an inet address and sendto with MSG_FASTOPEN do not free the port. A listener 108 made without SO_REUSEADDR would also keep a rival out after a disconnect, but then the next start 109 after a stop cannot bind while the port's TIME_WAIT sockets last (62.5 s measured after three 110 server-closed connections), so the supervisor keeps SO_REUSEADDR and the guard is the filter. 111 112 The only thing inside the sandbox that needs a socket is the listener. Signature checks 113 (ssh-keygen -Y) and git (log, show, cat-file, archive on local storage) need none, and the 114 gate traces both under the private namespace. Connections that remain outside the sandbox: 115 the counts collector (`forged --counts-snapshot` with `rad node routing` and `getent`) and 116 `public-read` run in the supervisor's account, as before. `FORGED_NETNS=off` returns to the 117 shared host network with no socket filter, with a loud warning on every start. 118 119 Abstract Unix sockets belong to the network namespace, so the private namespace also hides 120 the host's abstract sockets. Filesystem Unix sockets were already hidden. 121 122 Descriptors: the wrapper closes every descriptor above 2 that its starter left open, first, 123 on every path (service, direct, `FORGED_NETNS=off`, `FORGED_SANDBOX=off`). Descriptor 0 stays 124 (the listener or /dev/null). The only descriptors opened afterwards are the passwd entry and the 125 socket filter, which bwrap reads and closes itself. The counts collector closes the same way. 126 127 Processes have no_new_privs, no capabilities, a private PID namespace, a private 128 IPC namespace and a new session. Further user namespaces are disabled. With the network cut on, 129 the socket filter above applies. Only FORGE_DATA is a writable host filesystem mount. 130 Its supervisor log directory and pid file are protected read-only submounts. 131 Direct launches must create these real paths first; the supervisor already does. 132 133 ## Dependencies and host prerequisite 134 135 The host's installed bubblewrap is 0.9.0. The unprivileged `bwrap --ro-bind / / true` 136 probe succeeded. The stronger user/PID/IPC/UTS namespace probe also succeeded. 137 `/etc/apparmor.d/bwrap` already grants `userns` to `/usr/bin/bwrap` with 138 `flags=(unconfined)`. No root change is needed here. The wrapper fails closed on 139 setup errors. It never changes AppArmor or silently selects a weaker mechanism. 140 Exact installed package versions and binary hashes belong in the run evidence. 141 142 Host dependencies are Bash, bubblewrap, setpriv, coreutils (including `env`, which starts 143 bubblewrap with an empty environment), awk and ldd for setup, util-linux `prlimit` for the 144 resource limits (r5), and Git, OpenSSH ssh-keygen and their resolved libraries for service 145 execution. The listener helper and the socket filter generator are seeded Omega, built by 146 `run.sh` beside forged as `server/forged-listen` and `server/forged-seccomp.bpf`. The gate's 147 interface-leak probe `infra/test/leakprobe.c` is a test instrument built with the host gcc: 148 seeded Omega has no ioctl word and only six socket options. The long-term Omega replacement is a native namespace/mount launcher 149 and native repository/archive/signature operations. This candidate does not 150 claim to have replaced those host tools. 151 152 ## Public metadata refresh (r2) 153 154 The trusted supervisor owns `FORGED_PUBLIC_DIR`, default `$FORGE_DATA/../forge-public`. 155 It runs `forged-public.sh` before launch and each supervisor pass. The default interval 156 is two seconds (`FORGED_MIRROR_INTERVAL`, whole seconds from 1 to 99). No systemd unit 157 or timer is installed. This is the supervisor loop requested by the r2 brief. 158 159 `public-read.om`, compiled by the pinned compiler, opens each path component with 160 NOFOLLOW, enters directory descriptors, and accepts only regular files. It reads at 161 most the cap plus a detection byte and emits nothing unless the whole file fits. 162 The per-file cap is `1048576` bytes. No Python is in the runtime or build path. 163 The test and timing oracles use Python outside the service. 164 165 The export contains `RIDS.md`, `nodes.txt`, the selected `*.verdict.txt` files from 166 `handoffs/hive/manager/reviews`, and selected `*.receipt.txt` from 167 `handoffs/hive/forge/receipts`. Sources stay untouched. Changed bytes go through a 168 new temporary file inside the export and an atomic rename. Missing, unsafe or 169 over-cap sources revoke the old export. Equal bytes retain their inode and time. 170 The export is mounted read-only at each of the four expected metadata directories. 171 Only synthetic ancestors are visible, never the owner's containing directories. 172 The export must be disjoint from writable data and the source metadata trees. 173 174 Whole-file copying still reveals more than the public page needs: 175 - RIDS includes later tables, source working-directory paths, timestamps and notes. 176 The application parses only the first allow-list table. 177 - The node snapshot includes every repository known to the producer, not only 178 public repositories. `nodes/snap.om` explicitly records this fact. 179 - Verdicts include the whole review, although some consumers show only its verdict. 180 - Receipts include reviewer, author, clone and command/evidence information beyond 181 the public result. The exact excess depends on the producer's file contents. 182 183 Repository binds remain individual and read-only. A digest covers sorted allowed 184 RIDs, resolved directory paths and directory identities. A changed mount set sends 185 TERM to the child, waits for its exit and starts a new child without crash backoff. 186 TERM drops in-flight connections; this is not graceful request draining. One log 187 line names the set change. Content pushed into the existing directory leaves its 188 identity unchanged and needs no restart. RIDS content changes with the same mount 189 set are handled by the application's normal metadata reload. 190 191 `run.sh build` now also builds `public-read` beside the selected forged output. 192 `run.sh deploy` stages and records it with the binary, but deployment is not part 193 of these private checks. The supervisor fails closed if its reader is missing. 194 The wrapper never launches a compiler or downloads a dependency. 195 196 The forward-fit check uses an isolated local clone at the specified integrated 197 head. Its newer counts reader needs two nginx logs and their rotations, 198 `/usr/bin/getent`, `/usr/bin/env`, the Radicle command, and node routing state. 199 These are outside the r2 metadata export. The acceptance test redirects them to 200 controlled fixtures, exercises positive inputs outside the sandbox, and compares 201 the sandbox's result. Missing data must not be silently called compatible. 202 Galaxy files and quiet state already live under service data. The visits program 203 is a separate owner-side reader of the supervisor log, not a forged child. 204 205 The pinned baseline has no `infra/RUNBOOK.md`. The coordinator's later copy at 206 `../wt/infra/RUNBOOK.md` was read as context only. It names `infra/smoke.sh local` 207 as the direct forged check. Its public smoke, nginx edge tests and backup drills 208 do not target a private forged instance. The latter drill is absent at this pin. 209 The candidate makes the existing smoke suite accept `FORGE_TEST_PORT` and runs 210 it unchanged otherwise. The existing download HTTP suite accepts fixture storage 211 and an evidence destination so it does not rewrite historical transcripts. 212 The JSON route at this pin is `/status.json`; newer repository JSON APIs are absent. 213 214 ## Reproduce 215 216 Run `bash infra/test/sandbox.sh` from this checkout. It acquires pool-12-14, 217 pins cores 12,13, creates fixtures under the worktree's parent, compiles with the 218 exact run.sh compiler pin, traces the unrestricted private baseline, compares 219 HTTP bodies with cmp, runs existing smoke/download tests and isolation probes, 220 and challenges the probe with a writable-repository mutation. It tests both a 221 valid and an invalid SSH signature using a throwaway private key outside the 222 sandbox. Every check writes its command, exit status, log and log SHA-256. 223 Evidence is under `../sandbox-evidence`; `latest` names the run directory. 224 225 Rollback is explicit: `FORGED_SANDBOX=off` runs the selected binary directly and 226 prints `OWNER ACCOUNT EXPOSED; SANDBOX DISABLED` to the service log. 227 228 ## Historical r2 forward fit on the integrated head 229 230 The r2 integrated gate is BLOCKED by count parity. Its private run is 231 `../sandbox-evidence/r2-on-one/run.XClz1X`. All original isolation controls, 232 metadata replacement, source refusal controls, live push and five automatic 233 repository-set restarts passed. Quiet pages with a real fixture sign-in, filter 234 writes, `.receipt`, galaxy files and public JSON byte comparisons passed. 235 The existing JSON walker visited 164 pages, covered 22 schemas and reported no 236 failures. The visits suite passed. These facts do not make the full gate pass. 237 238 The positive count fixture has one git fetch, one upload-pack request and three 239 seed announcements outside the sandbox. All become null inside it. Even the 240 service-log count becomes null because its visitor filter needs the unavailable 241 address lookup. `integrated-counts-comparison.json` retains both responses. 242 The installed Radicle command, traced against an empty private home, exits 1 243 and says its profile is missing. No owner identity or node was borrowed. 244 245 Additional inputs in ``3edf9201``, relative to the original sandbox base: 246 247 | Path/program | Use | Present in this profile? | 248 | --- | --- | --- | 249 | `/var/log/nginx/aienos-dl.log` and `.1` | Clone/fetch requests and rotation tail | No | 250 | `/var/log/nginx/aienos.access.log` and `.1` | Upload-pack requests and rotation tail | No | 251 | `/usr/bin/getent hosts www.aienos.com` | Exclude the owner's address from visitor counts | No. Its resolver/configuration dependencies are not granted. | 252 | `/usr/bin/env` and `~/.radicle/bin/rad node routing` | Read routing announcements under an explicit HOME | No | 253 | `~/.radicle/node/node.db-wal` | Trigger routing refresh when node state changes | No | 254 | Radicle profile and routing database | Prerequisites of the command above | No. Empty-home trace stops at the profile requirement. Later prerequisites are not qualified. | 255 | `/counts.log` | Counts and source positions | Writable application data | 256 | `/growth/seeds.log` | Growth history; other growth JSON caches share this directory | Writable application data | 257 | `/quiet/events`, `quiet/subs`, `quiet/out/` | Notification events, filters and digests | Writable application data | 258 | `/galaxy/index.html`, `galaxy.css`, `tokens.css` | Prebuilt galaxy page and styles | Application data. The outside producer is not a child. | 259 | `/owner/visits.html`, `visits.tsv`, styles | Separate owner analytics | Application data, if populated. Its renderer and private HTTP server are outside this profile. | 260 261 No additional socket was used by the successfully exercised forged routes. 262 The galaxy producer's factory stream and the visits owner's private listener are 263 separate processes, not required child sockets. The real routing command beyond 264 its missing-profile refusal was not qualified. This is not a claim of complete 265 network isolation or a working Radicle command inside the sandbox. 266 267 The r2 export contract named only RIDS, node snapshots, verdicts and receipts. 268 Adding raw request logs, owner profile files or a node control socket would widen 269 that contract and the privacy boundary. The r3 brief approved the following change: a 270 public count snapshot written outside the sandbox, with the web reader consuming 271 only that snapshot. Reusing node snapshot copy counts as routing announcements 272 would change the meaning of the result and is not an equivalent fix. 273 274 ## Historical r1 result (superseded by the r2 report) 275 276 The final run is `../sandbox-evidence/run.fGiVwY`. The full gate exits 4, BLOCKED, 277 because the FIFO-synchronized atomic RIDS replacement check exits 1 and reports 278 that the sandbox still reads the old inode. This is an observed failure, not a 279 prediction. Fixing it needs a public input publication layout outside the private 280 handoff directories, plus a mount refresh policy when the allowed repo set changes. 281 Those producers are outside this brief's permitted worktree. They were not changed. 282 283 HTTP body comparisons passed for the root, explore, CSS, project, blob, raw file, 284 ZIP, tar.gz and populated status JSON. The JSON uses an explicitly future-dated 285 fixture to keep its age field stable; it is not a measurement of the real node. 286 The existing smoke and download HTTP suites passed. The private supervisor started 287 the sandbox, accepted HUP and stopped. Its reload operation did not follow a 288 planted symlink; a symlinked log directory was refused before writing. 289 290 The probe could write application data, but could not read the owner SSH keys, 291 Radicle keys, vault, private handoffs or shadow file, or write outside the allowed 292 application state. It could not change the supervisor log directory or pid file. 293 NoNewPrivs was 1 and effective capabilities were zero. Sudo was unavailable inside 294 the profile. Removing a repository's read-only mount made its write control fail, 295 as required. The real SSH verifier accepted a valid signature and rejected a 296 changed message. Explicit sandbox-off rollback printed the required warning. 297 298 The baseline trace records a loopback bind and Git execution. No outbound connect 299 was observed on those requests. Signature verification was exercised separately. 300 Git's read of `/etc/localtime` explained the earlier ZIP byte mismatch; the final 301 comparison passed with that file mounted read-only. Trace, commands, exit codes, 302 compiler/source/binary hashes and log hashes are in the evidence directory. 303 304 Installed versions recorded there: bubblewrap 0.9.0-1ubuntu0.3; util-linux 305 2.39.3-9ubuntu6.6; Bash 5.2.21-2ubuntu4; coreutils 9.4-3ubuntu6.3; mawk 306 1.3.4.`20240123`-1build1; libc6 2.39-0ubuntu8.9; Git 1:2.43.0-1ubuntu7.3; 307 OpenSSH client 1:9.6p1-3ubuntu13.19. Dash and gzip are test-oracle tools only. 308 No shared Omega guide was changed: no language, compiler pin or seed procedure changed. 309 The service-specific reader build is documented here and in run.sh. This candidate was not pushed, merged, published or deployed. 310 311 ## Public aggregate counts (r3) 312 313 The existing forged executable has an owner-side `--counts-snapshot JOURNAL` mode. 314 It calls the existing allow-list loader, journal replay, log readers and Radicle 315 routing reader. It does not listen on a port or load social state in this mode. 316 The journal argument is mandatory and absolute. The supervisor places that 317 journal in `FORGED_COUNTS_STATE`, default `$FORGE_DATA/../forge-counts-state`. 318 That directory must be outside writable application data and the public export. 319 It is not mounted in the child. Preserve this journal across service restarts. 320 At a cutover from an unrestricted count-enabled version, stop the old writer and 321 copy its committed `counts.log` into the owner state directory before collection. 322 This preserves counts whose original log files have already rotated away. 323 324 `forged-counts.sh` starts collection outside the sandbox, pinned to the same cores. 325 It publishes `counts.snapshot` by writing a unique temporary file in the export 326 and renaming it after successful collection. A failed collector removes the old 327 snapshot. Collection runs alongside the supervisor so it does not block HTTP, 328 metadata refresh, restart or stop handling. The supervisor starts it at launch, 329 on an allowed repository set change and every `FORGED_COUNTS_INTERVAL` seconds 330 (default 900, permitted 1 through 1800). Runs never overlap within one supervisor. 331 A collection is stopped after 300 seconds. No scheduler or systemd unit is added. 332 333 The wrapper sets `FORGED_COUNTS_SNAPSHOT=1` in its otherwise cleared environment. 334 Only this mode switches the count reader. Unrestricted behavior is unchanged. 335 The sandbox reads the file at the existing public-export mount under 336 `handoffs/radicle/counts.snapshot` before each project HTML or JSON count response. 337 It opens a regular file without following its final symlink (aarch64 open flags 338 O_CLOEXEC, O_NOFOLLOW `0100000` and O_NONBLOCK, value 559104). Directory mounts 339 make atomic replacements visible immediately, with no restart or cached inode. 340 341 Format is ASCII, version 1. Header: `1 COLLECTION_EPOCH` followed by LF. 342 Each subsequent line is `RID GIT UPLOAD ARCHIVES ASSETS SINCE0 SINCE1 SINCE2 SEEDS STATUS SEED_EPOCH` 343 followed by LF. Fields have exactly one separating space. RID omits `rad:` and 344 contains only ASCII letters and digits. All other fields are unsigned decimal 345 integers. They have at most 20 digits and must fit in an unsigned 64-bit integer. 346 Leading zeroes are accepted. STATUS is 0, 1 or 2; 1 means seeding was measured. 347 SINCE values and SEED_EPOCH are Unix seconds. Zero means unavailable where the 348 existing renderer uses it. Archives plus assets must not overflow. The file 349 contains only public project identifiers, aggregate figures and collection times. 350 It contains no client address, user agent, raw request line or key material. 351 352 Limits: 65536 file bytes, 257 LF-terminated lines including the header, 256 bytes 353 per line excluding LF, 11 row fields, 64 bytes per field, 256 project rows (FAMAX, 354 server/util.om; 16384 bytes, 65 lines and 64 rows before 2026-11-14, when the 355 allow-list table grew for the native store). 356 Duplicate project identifiers, incomplete lines, wrong field counts, invalid 357 numbers, future collection time or source times after collection are rejected. 358 Files older than 3600 seconds are rejected. A missing, rejected or stale snapshot 359 clears all count availability. Existing HTML says `not measured`; JSON uses null. 360 A project absent from an otherwise valid snapshot is also unavailable. Reads 361 are capped with an extra detection byte. Every parsing loop is guarded before 362 its bound, including malformed input. No private source is opened in this mode. 363 364 Additional child permissions: only read access to counts.snapshot in the existing 365 export. No nginx log, resolver, Radicle executable, database, owner profile, key 366 or node socket is added. Additional owner-side utility: installed GNU timeout, 367 used to bound the collection process. Its version is recorded in evidence. The 368 future native Omega supervisor should provide the equivalent process deadline. 369 370 R3 private acceptance ran in `../sandbox-evidence/r3/gate/run.IAtnd2` and exited 0. 371 Positive HTML and JSON count parity passed for git fetches, upload-pack requests, 372 archives, release assets and routing announcements. Exact valid read limits and 373 limit-plus-one/far-beyond refusals passed. Every malformed case left the server 374 answering requests. Removing the freshness guard caused the stale assertion to 375 fail. Fixture addresses and user agents were present in the source log and absent 376 from the producer output. The supervisor changed a published count without a child 377 restart. R1/r2 isolation, mutations, metadata refresh, repository-set restarts, 378 existing-repository push visibility, integrated routes and visits also passed. 379 See the r3 READY report for pinned rebuild hashes and real-log collection cost. 380 381 The owner collection mode persists read positions even for batches with no counted 382 events. This prevents repeated full-log scans across separate collections. The 383 unrestricted in-process reader retains its existing journal behavior. A fixture 384 asserts cursor advancement, unchanged counts and no write on unchanged recollection. 385 386 R4 review fixes. The r3 reader passed 657408, which on aarch64 is O_LARGEFILE, 387 not O_NOFOLLOW, so it followed a symlink named counts.snapshot. Its symlink test 388 pointed outside the export, so it passed only because the target was not mounted. 389 The test now also links to a valid snapshot inside the export. Several refusal 390 cases used all-zero rows, which render as unavailable even when accepted. Every 391 refusal case now has an accepted twin with positive figures that is shown 392 available first. New cases: header version, since or seed time after collection, 393 non-alphanumeric RID, 400 lines under the file cap and a well-formed 16385-byte file. 394 395 ## Clean environment, resource limits, guards and umask (r5) 396 397 **Clean environment.** Bubblewrap stays process 1 inside the sandbox, and the child can read 398 `/proc/1/environ`. The wrapper therefore starts it as 399 `exec env -i /usr/bin/setpriv --no-new-privs /usr/bin/bwrap ...`; setpriv and bwrap read no 400 environment variables. The systemd unit `infra/spark/interplane-forged.service` and, without it, 401 `forged-service.sh start` (tmux) start the supervisor through `env -i HOME=... PATH=/usr/bin:/bin 402 FORGED_...=...`, so the service manager's or tmux server's own environment and the operator's 403 shell never reach the supervisor, its children or the sandbox. Gate steps 404 `env-clean` and `service-env` plant a canary in the starter; `env-mutant` (the r4 final line) 405 and `service-env-old` (the r4 service script) are the controls that must leak it. 406 407 **Resource limits.** `/usr/bin/prlimit` runs inside the sandbox, after bubblewrap has created 408 the user namespace, and execs forged. RLIMIT_NPROC counts every task of the real user id, and the 409 owner runs about 450 processes on the Spark; set before bubblewrap, `--nproc=256` made bwrap fail 410 with "Creating new namespace failed: Resource temporarily unavailable". Inside, the namespace 411 starts with only bwrap's own tasks, so the limit bounds the sandbox. 412 413 | Limit | Value | Measured need | Margin (Wolfram) | 414 |---|---|---|---| 415 | nproc | 256 | forged is one thread; `git pack-objects` uses about 20 threads; with bwrap and children about 30 tasks | 256/30 = 8.5 | 416 | address space | 4 GiB | `git pack-objects` on the largest public repository (159 MB) fails at 1024 MiB ("unable to create thread") and passes at 1280 MiB; live forged VmPeak 56704 kB | 4 GiB / 1280 MiB = 3.2; 4 GiB / 56704 kB = 74 | 417 | file size | 1 GiB | dl caps one archive at 512 MiB (`536870912` bytes); the largest live data file is a 96.5 MB tar.gz | 1 GiB / 96.5 MB = 11.1 | 418 | open files | 1024 | live forged holds 4 descriptors | 1024/4 = 256 | 419 | core | 0 | none | | 420 421 Wolfram: `{N[4*2^30/(1280*2^20)], N[4*2^30/(56704*1024)], N[2^30/(96.5*10^6)], N[256/30]}` 422 -> `{3.2, 73.97, 11.13, 8.53}`. 423 424 The service log is not subject to the file-size limit: the supervisor gives the child a pipe and 425 an unsandboxed `cat` appends to `forged.log`. The live log is `258819608` bytes and grows about 426 94 MB a day; with the file itself as stderr, forged would die with SIGXFSZ after 427 2^30 / 94 MB = 11.4 days (Wolfram `N[2^30/(94*10^6)]` -> 11.42). Gate steps `log-fsize` (this 428 supervisor keeps serving with a 2 GiB log) and `log-fsize-old` (the r4 supervisor's forged dies 429 with exit 153) cover it. 430 431 **Growth of FORGE_DATA.** No quota exists. `/` is ext4 without quota options, with 425 GiB free. 432 The bounds that do exist: the archive cache is capped at 5 GiB by dl (`dlrunf`), one archive at 433 512 MiB, one file at 1 GiB by RLIMIT_FSIZE. The log has no cap: at 94 MB a day, 425 GiB lasts 434 about 4855 days (Wolfram `N[425*2^30/(94*10^6)]` -> 4854.7). The collab, search and visits stores 435 have no cap of their own; FORGE_DATA totals 537 MB today. A per-directory cap needs either a 436 dedicated filesystem (a loop-mounted image of fixed size, root needed) or project quotas; this 437 round adds neither. 438 439 **Omega gap.** The pinned omc has no setrlimit or prlimit64 host word, so util-linux prlimit 440 2.39.3 (sha256 `26600e1c720c29d7b7a87eac6beb13f5bc497925349d6c36a5c03751df879fd1`) stays a 441 recorded host binary. Proposed replacement: a host word `rlimit resource soft hard` (prlimit64 on 442 the calling process) used by a seeded-Omega launcher that sets the limits and then `execprog`s 443 forged. 444 445 **Binary guards.** The wrapper refuses a forged binary that resolves inside the data directory or 446 the export directory. The count collector (`counts_bin_ok`, at init and before every collection) 447 and the public reader (`public_init`) refuse the same, because both run as the owner, unsandboxed. 448 449 **umask.** The wrapper sets `umask 0077`, so every file and directory forged creates in 450 FORGE_DATA is owner-only. The mirror (`public_sync`, run by the owner) and the count producer 451 (run by the owner) read them as the same user.