Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
TypeScript
browse can keep untrusted pages off local and private network addresses (#4812) (#4888)
Garry Tanfb4474ec6c9a
diff --git a/BROWSER.md b/BROWSER.mdindex 9cdf2f31e..b275f0b82 100644--- a/BROWSER.md+++ b/BROWSER.md@@ -312,7 +312,7 @@ $B connect # headed Chromium + Side Panel extension5. [Snapshot system + ref-based selection](#snapshot-system)6. [Browser-skills runtime](#browser-skills-runtime)7. [Domain-skills (per-site agent notes)](#domain-skills)-8. [Real-browser mode (`$B connect`)](#real-browser-mode) — including [`--headed` + `--proxy` + `--navigate` (v1.28.0.0)](#headed-mode--proxy--browser-native-downloads-v12800) and [Aside and third-party drives (v1.72.0.0+)](#aside-and-third-party-drives-v17200)+8. [Real-browser mode (`$B connect`)](#real-browser-mode) — including [`--headed` + `--proxy` + `--navigate` (v1.28.0.0)](#headed-mode--proxy--browser-native-downloads-v12800), [Aside and third-party drives (v1.72.0.0+)](#aside-and-third-party-drives-v17200) and [Public-only mode](#public-only-mode)9. [Side Panel + sidebar agent](#side-panel--sidebar-agent)10. [Pair-agent — remote agents over an ngrok tunnel](#pair-agent)11. [Authentication + tokens](#authentication)@@ -1126,6 +1126,73 @@ startup with a redacted error after 3 retries (5s budget). Mid-streamupstream drop — bridge kills the affected client connection only; notransport retries that could corrupt browser traffic.+### Public-only mode++Turn this on when an agent reads pages you don't trust (social posts, vendor+sites, search results) and those pages must not reach the machine browse runs+on or the network around it:++```bash+$B --public-only goto https://example.com+# or, for every command in a session or harness:+export BROWSE_PUBLIC_ONLY=1+```++It is off by default, and with it off nothing changes: `localhost:3000` and+RFC 1918 dev servers work exactly as before. `BROWSE_PUBLIC_ONLY` takes `1`,+`true` or `on` (and `0`, `false`, `off` or empty for off); any other value+stops the command with exit code 2, so a typo never leaves the guard off.+Like `--proxy`, it is daemon-startup config: a public-only command never reuses+a daemon started without it (and the reverse), and says so; run+`$B disconnect` to switch.++**What it does.** browse starts a small SOCKS5 guard on 127.0.0.1 and makes it+Chromium's only proxy, with no bypass list, so every connection Chromium makes+goes through it: navigations, redirects, popups, frames, images and scripts,+`fetch`, WebSockets, workers, downloads, and browse's own `download` and+`scrape` fetches. For each connection the guard refuses the destination when+the address, or any address its name resolves to, is not a public internet+address: loopback (`127.0.0.0/8`, `::1`, `localhost`, `*.localhost`),+private (`10/8`, `172.16/12`, `192.168/16`, `fc00::/7`), carrier-grade NAT+(`100.64/10`), link-local and cloud metadata (`169.254/16`, `fe80::/10`), and+every other range IANA marks as not globally reachable, plus anything on this+machine's own networks (each interface address with its prefix). It refuses+when DNS fails. An allowed name is connected to the exact address that was+checked, so a DNS answer that changes between the check and the connection+(DNS rebinding) cannot redirect it. WebRTC may not send UDP outside the proxy.+Before every launch browse checks that the guard is still the only proxy, that+no bypass list is set, and that `PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK`+is unset; otherwise Chromium does not start.++**What you see.** A refused navigation, download or redirect fails with+`public-only refused <host:port> (<reason>) [PUBLIC_ONLY_REFUSED]` and the fix.+Refused subresources fail inside the page. The daemon log has one+`[browse] [public-only] refused ...` line per destination a minute, and+`/health` reports `publicOnly.refused`, the number refused so far.++**Upstream proxies.** A `socks5://` upstream (from `--proxy` or the+environment) is chained behind the guard, which hands it the checked address,+never the name; so a name is resolved on this machine, not by the upstream.+An HTTP(S) upstream is refused, because browse can't see what goes through it,+unless you set `BROWSE_PUBLIC_ONLY_UPSTREAM=trusted` to say that proxy blocks+private addresses itself. Then nothing skips the proxy (loopback included),+the CLI prints that the proxy is doing the blocking, and browse's own checks on+navigations and downloads are a second line, not a guarantee. Those checks+still look names up on this machine and refuse a name it cannot resolve, so on+a network where only the proxy can resolve outside names, every navigation is+refused.++**Not covered.** `--headed`, `$B connect` and `handoff` are refused in+public-only mode for now, because the sidebar talks to local ports pages must+not reach, and `pair-agent` keeps the headless browser. A frame that loads a+refused address fails inside the page; the tab is not reset. Skills that drive+the Aside browser first skip it unless `BROWSE_PUBLIC_ONLY` is unset, empty, 0,+false or off, and use browse's own browser, because Aside is not guarded. A page can still make+this machine look a name up in DNS (it can't connect to the answer). `file://`+URLs follow browse's usual path rules. Chromium's sandbox is unchanged; on a+root container with `--no-sandbox`, add an egress firewall as well. A public+server that forwards to its own internal network is outside browse's reach.+---## Side Panel + sidebar agent@@ -1785,6 +1852,8 @@ the global `~/.gstack/browser-skills/foo/` only inside project-a.| `BROWSE_CDP_URL` | (none) | Set to `channel:chrome` for real-browser mode || `BROWSE_CDP_PORT` | 0 | CDP port (used internally) || `BROWSE_HEADLESS_SKIP` | 0 | Skip Chromium launch entirely (test harness only) |+| `BROWSE_PUBLIC_ONLY` | unset | `1`, `true` or `on`: refuse loopback, private and other non-public addresses for every page load ([Public-only mode](#public-only-mode)) |+| `BROWSE_PUBLIC_ONLY_UPSTREAM` | unset | `trusted`: allow public-only behind an HTTP(S) proxy that blocks private addresses itself || `BROWSE_TUNNEL` | 0 | Activate the dual-listener tunnel architecture (requires `NGROK_AUTHTOKEN`) || `BROWSE_TUNNEL_LOCAL_ONLY` | 0 | Test-only — bind both listeners locally without ngrok || `BROWSE_SESSION` | unset (agent harness calls get `agent-<pid>`) | CLI side: this caller's session name; empty or `off` turns sessions off |@@ -1815,6 +1884,9 @@ browse/│ ├── socks-bridge.ts # Local 127.0.0.1 SOCKS5 bridge that handles auth handshakes Chromium can't speak│ ├── proxy-config.ts # --proxy URL parsing + cred resolution (URL vs env, fail-fast on both); direct:// launch switch + proxy-mode log line│ ├── proxy-redact.ts # Cred-redaction helper for any proxy URL surfaced to logs/errors+│ ├── public-only.ts # Public-only mode: BROWSE_PUBLIC_ONLY switch, destination check, refusal messages, launch invariant+│ ├── public-only-proxy.ts # Public-only daemon startup: guard (or trusted upstream) as Chromium's only proxy+│ ├── address-guard.ts # Public-only SOCKS5 guard on 127.0.0.1: refuses non-public destinations, connects to the checked address│ ├── xvfb.ts # Xvfb auto-spawn + orphan cleanup with PID + start-time validation│ ├── stealth.ts # Layer C: webdriver mask + window.chrome.* + Notification/Permissions + per-install hardware + toString proxy + automation-global sweep; buildGStackLaunchArgs (GSTACK_* cmdline switches); GSTACK_STEALTH=extended opt-in│ ├── browse-client.ts # Canonical SDK — what skills import as _lib/browse-client.ts@@ -1844,7 +1916,7 @@ browse/│ ├── pty-session-cookie.ts # Separate scope: live Claude PTY auth│ ├── tunnel-denial-log.ts # ~/.gstack/security/attempts.jsonl writer (salted)│ ├── path-security.ts # validateOutputPath / validateReadPath / validateTempPath-│ ├── url-validation.ts # URL safety checks for goto+│ ├── url-validation.ts # URL safety checks for goto (plus the non-public address ranges public-only mode refuses)│ ├── content-security.ts # L1-L3: datamarking, hidden strip, ARIA, URL blocklist, envelopes│ ├── security.ts # L5 canary + L6 verdict combiner + thresholds│ ├── security-classifier.ts # L4 ML classifier (TestSavantAI, runs in the security sidecar)diff --git a/benchmark/SKILL.md b/benchmark/SKILL.mdindex 1b3d19cfd..324ca0ef0 100644--- a/benchmark/SKILL.md+++ b/benchmark/SKILL.md@@ -167,6 +167,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/browse/SKILL.md b/browse/SKILL.mdindex ff72c3a60..84f5eefc2 100644--- a/browse/SKILL.md+++ b/browse/SKILL.md@@ -175,6 +175,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/browse/src/address-guard.ts b/browse/src/address-guard.tsnew file mode 100644index 000000000..6610d930d--- /dev/null+++ b/browse/src/address-guard.ts@@ -0,0 +1,60 @@+/**+ * The public-only guard (#4812): a no-auth SOCKS5 listener on 127.0.0.1 that+ * Chromium gets as its only proxy, with no bypass list, when public-only mode+ * is on. Chromium hands SOCKS5 the host name (remote DNS), so every connection+ * arrives here: navigations, redirects, subresources, fetch, WebSocket,+ * workers, downloads, and Playwright's page.request.+ *+ * For each CONNECT the guard checks the destination (public-only.ts+ * checkDestination: the literal and every DNS answer must be public and off+ * this machine's own networks) and then connects to one of the addresses it+ * checked, never to the name, so a DNS answer that changes between the check+ * and the connection (DNS rebinding) cannot redirect it. With a SOCKS5+ * upstream the checked address, not the name, goes to the upstream.+ */++import * as net from 'node:net';+import { SocksClient } from 'socks';+import { buildUpstream, serveSocks5, SocksRefusal, REPLY_NOT_ALLOWED, UPSTREAM_CONNECT_TIMEOUT_MS, type BridgeHandle, type UpstreamConfig } from './socks-bridge';+import { checkDestination, recordRefusal, type CheckOptions } from './public-only';++export interface GuardOptions extends CheckOptions {+ /** Chain allowed connections through this SOCKS5 upstream instead of connecting directly. */+ upstream?: UpstreamConfig;+ port?: number;+ /** Per-address connect timeout. */+ connectTimeoutMs?: number;+}++function connectDirect(host: string, port: number, timeoutMs: number): Promise<net.Socket> {+ return new Promise((resolve, reject) => {+ const socket = net.connect({ host, port });+ const timer = setTimeout(() => { socket.destroy(); reject(new Error('connect timeout')); }, timeoutMs);+ socket.once('connect', () => { clearTimeout(timer); resolve(socket); });+ socket.once('error', (err) => { clearTimeout(timer); reject(err); });+ });+}++export async function startAddressGuard(opts: GuardOptions = {}): Promise<BridgeHandle> {+ const upstream = opts.upstream ? buildUpstream(opts.upstream) : null;+ const timeoutMs = opts.connectTimeoutMs ?? (upstream ? UPSTREAM_CONNECT_TIMEOUT_MS : 10_000);+ return serveSocks5(async ({ host, port }) => {+ const checked = await checkDestination(host, port, opts);+ const target = host.includes(':') ? `[${host}]:${port}` : `${host}:${port}`;+ if ('reason' in checked) {+ recordRefusal(target, checked.reason);+ throw new SocksRefusal(REPLY_NOT_ALLOWED, checked.reason);+ }+ let lastError: unknown;+ for (const address of checked.addresses) {+ try {+ if (!upstream) return await connectDirect(address, port, timeoutMs);+ const result = await SocksClient.createConnection({ proxy: upstream, command: 'connect', destination: { host: address, port }, timeout: timeoutMs });+ return result.socket;+ } catch (err) {+ lastError = err;+ }+ }+ throw lastError;+ }, opts.port ?? 0);+}diff --git a/browse/src/browser-manager.ts b/browse/src/browser-manager.tsindex d35366fa2..e86592de1 100644--- a/browse/src/browser-manager.ts+++ b/browse/src/browser-manager.ts@@ -28,6 +28,7 @@ import { ensureProjectProfile } from './chromium-profiles';import { launchWithXProtectHeal } from './xprotect-heal';import { explainSandboxFailure, sandboxBlockedByHost, shouldEnableChromiumSandbox } from './chromium-sandbox';import { DIRECT_PROXY_ARG, forcesDirect } from './proxy-config';+import { assertPublicOnlyLaunch, WEBRTC_PROXIED_ONLY_ARG } from './public-only';import { readPidStartTime, shouldSpawnXvfb, spawnFreeXvfb, xvfbInstallHint, type XvfbHandle } from './xvfb';import { withCdpSession } from './cdp-bridge';import { applyDevice } from './device-emulation';@@ -345,6 +346,10 @@ export class BrowserManager {// points this at the local bridge (socks5://127.0.0.1:<bridgePort>); for// HTTP/HTTPS or unauth SOCKS5, it's the upstream URL directly.private proxyConfig: { server: string; bypass?: string; username?: string; password?: string } | null = null;+ /** Public-only mode (#4812): the guard's (or trusted upstream's) proxy server, or null when off. */+ private publicOnlyServer: string | null = null;+ /** Public-only with the guard as Chromium's proxy (a SOCKS5 server there is always the guard), not a trusted HTTP(S) upstream. */+ private publicOnlyGuarded = false;private pages: Map<number, Page> = new Map();private tabSessions: Map<number, TabSession> = new Map();private activeTabId: number = 0;@@ -607,6 +612,19 @@ export class BrowserManager {this.proxyConfig = cfg;}+ /**+ * Public-only mode (#4812): pin the proxy server.ts just set as the only+ * one every later launch may use (proxyLaunchArgs checks it).+ */+ setPublicOnly(): void {+ this.publicOnlyServer = this.proxyConfig?.server ?? null;+ this.publicOnlyGuarded = this.publicOnlyServer?.startsWith('socks5://') ?? false;+ }++ isPublicOnly(): boolean {+ return this.publicOnlyServer !== null;+ }+/*** Playwright passes a configured proxy explicitly as --proxy-server, so only* a session browse resolved to direct was exposed: `BROWSE_PROXY_URL=direct`@@ -616,6 +634,10 @@ export class BrowserManager {* would otherwise pick a proxy browse did not resolve (forcesDirect).*/private proxyLaunchArgs(): string[] {+ if (this.publicOnlyServer !== null) {+ assertPublicOnlyLaunch(this.proxyConfig, this.publicOnlyServer);+ return [WEBRTC_PROXIED_ONLY_ARG];+ }return !this.proxyConfig && forcesDirect(process.env) ? [DIRECT_PROXY_ARG] : [];}@@ -2161,6 +2183,7 @@ export class BrowserManager {* If step 2 fails → return error, headless browser untouched*/async handoff(message: string): Promise<string> {+ if (this.publicOnlyServer !== null) throw new Error("public-only mode cannot hand off to the headed browser yet. fix: run 'browse disconnect' and start browse without --public-only or BROWSE_PUBLIC_ONLY to hand off");if (this.handoffPending) return this.handoffPending;this.handoffPending = this.promoteToHeaded(message);try { return await this.handoffPending; }@@ -2372,7 +2395,7 @@ export class BrowserManager {}getFailureHint(): string | null {- if (this.consecutiveFailures >= 3 && !this.isHeaded) {+ if (this.consecutiveFailures >= 3 && !this.isHeaded && this.publicOnlyServer === null) {return `HINT: ${this.consecutiveFailures} consecutive failures. Consider using 'handoff' to let the user help.`;}return null;@@ -2406,6 +2429,7 @@ export class BrowserManager {this.navigationGuards.set(page, guard);page.on('request', (req) => {if (!req.isNavigationRequest()) return;+ if (this.publicOnlyGuarded && req.frame() !== page.mainFrame()) return; // #4812: the guard refuses a frame's connection; blanking the tab would let any page hide itselfconst check: Promise<void> = blockedNavigationReason(req.url()).then(async (reason) => {if (!reason || page.isClosed()) return;guard.blocked = reason;diff --git a/browse/src/cli.ts b/browse/src/cli.tsindex 66bc8ad48..b4851ac2d 100644--- a/browse/src/cli.ts+++ b/browse/src/cli.ts@@ -17,6 +17,7 @@ import { readPidStartTime, readPidCmdline } from './xvfb';import { writeSecureFile, mkdirSecure } from './file-permissions';import { resolveConfig, ensureStateDir, readVersionHash, isPairAgentEnabled, resolveChromiumProfile } from './config';import { resolveProxy, computeConfigHash, explicitDirect, ProxyConfigError, PROXY_TROUBLESHOOTING } from './proxy-config';+import { publicOnlyFromEnv, PublicOnlyConfigError } from './public-only';import { redactProxyUrl } from './proxy-redact';import { spawnTerminalAgent, bunChildFlags } from './terminal-agent-control';import { profileOwner, ensureProjectProfile, runProfilesCommand } from './chromium-profiles';@@ -197,6 +198,8 @@ interface ServerState {proxyBypass?: string;/** #3440: started with BROWSE_PROXY_URL=direct where that bypasses the system proxy settings. */proxyDirect?: boolean;+ /** #4812: started in public-only mode. */+ publicOnly?: boolean;/** Xvfb child PID for cleanup on disconnect. */xvfbPid?: number;xvfbStartTime?: string;@@ -527,9 +530,11 @@ export function proxyMismatchLines(flags: GlobalFlags, state: ServerState, env:* BROWSE_PROXY_USER/PASS, so those are blanked for the daemon, which inherits* this environment and would otherwise see the creds twice (#3457).*/-function proxyServerEnv(flags: Partial<Pick<GlobalFlags, 'proxyUrl' | 'proxySource' | 'proxyBypass' | 'explicitDirect'>> | null | undefined): Record<string, string> {- if (!flags?.proxyUrl) return flags?.explicitDirect ? { BROWSE_PROXY_URL: 'direct' } : {};+function proxyServerEnv(flags: Partial<Pick<GlobalFlags, 'proxyUrl' | 'proxySource' | 'proxyBypass' | 'explicitDirect' | 'publicOnly' | 'trustedUpstream'>> | null | undefined): Record<string, string> {+ const publicOnly = flags?.publicOnly ? { BROWSE_PUBLIC_ONLY: '1', ...(flags.trustedUpstream ? { BROWSE_PUBLIC_ONLY_UPSTREAM: 'trusted' } : {}) } : {};+ if (!flags?.proxyUrl) return { ...(flags?.explicitDirect ? { BROWSE_PROXY_URL: 'direct' } : {}), ...publicOnly };return {+ ...publicOnly,BROWSE_PROXY_URL: flags.proxyUrl,BROWSE_PROXY_USER: '',BROWSE_PROXY_PASS: '',@@ -564,7 +569,7 @@ export function buildRestartEnv(* the same port, watchdog setting, proxy and config hash. Pure + exported for tests.*/export function buildHeadedServerEnv(- globalFlags: Pick<GlobalFlags, 'proxyUrl' | 'configHash' | 'explicitDirect'> & Partial<Pick<GlobalFlags, 'proxySource' | 'proxyBypass'>>,+ globalFlags: Pick<GlobalFlags, 'proxyUrl' | 'configHash' | 'explicitDirect'> & Partial<Pick<GlobalFlags, 'proxySource' | 'proxyBypass' | 'publicOnly' | 'trustedUpstream'>>,): Record<string, string> {return {BROWSE_HEADED: '1',@@ -938,6 +943,7 @@ async function ensureServer(flags?: GlobalFlags): Promise<ServerState> {// hint. No silent restart — that would drop tab state, cookies, and// logged-in sessions without warning.if (desiredHash && state.configHash && state.configHash !== desiredHash) {+ refusePublicOnlyMismatch(state, flags);const proxyLines = flags && proxyMismatchLines(flags, state);if (proxyLines) {for (const line of proxyLines) console.error(`[browse] ${line}`);@@ -955,7 +961,8 @@ async function ensureServer(flags?: GlobalFlags): Promise<ServerState> {// Same path: existing daemon is plain (no flags) but caller passes// --proxy/--headed. Refuse for the same reason — apply explicitly via// disconnect+reconnect.- if (desiredHash && !state.configHash && (flags?.proxyUrl || flags?.headed || flags?.explicitDirect)) {+ if (desiredHash && !state.configHash && (flags?.proxyUrl || flags?.headed || flags?.explicitDirect || flags?.publicOnly)) {+ refusePublicOnlyMismatch(state, flags);console.error(`[browse] existing daemon was started without --proxy/--headed${flags?.explicitDirect ? ' or BROWSE_PROXY_URL=direct' : ''}.`);console.error(`[browse] run 'browse disconnect' first to apply new flags.`);process.exit(1);@@ -1012,7 +1019,10 @@ async function ensureServer(flags?: GlobalFlags): Promise<ServerState> {const start = Date.now();while (Date.now() - start < MAX_START_WAIT) {const freshState = readState();- if (freshState && await isServerHealthy(freshState.port)) return freshState;+ if (freshState && await isServerHealthy(freshState.port)) {+ if (desiredHash) refusePublicOnlyMismatch(freshState, flags);+ return freshState;+ }await Bun.sleep(200);}throw new Error('Timed out waiting for another instance to start the server');@@ -1022,6 +1032,7 @@ async function ensureServer(flags?: GlobalFlags): Promise<ServerState> {// Re-read state under lock in case another process just started the serverconst freshState = readState();if (freshState && await isServerHealthy(freshState.port)) {+ if (desiredHash) refusePublicOnlyMismatch(freshState, flags);return freshState;}@@ -1037,6 +1048,11 @@ async function ensureServer(flags?: GlobalFlags): Promise<ServerState> {} else {console.error('[browse] Starting server...');}+ if (flags?.publicOnly) {+ console.error(flags.trustedUpstream+ ? `[browse] public-only: on, trusting the HTTP(S) proxy ${flags.redactedProxyUrl} to block private addresses for page traffic (BROWSE_PUBLIC_ONLY_UPSTREAM=trusted)`+ : '[browse] public-only: on (loopback, private and other non-public addresses are refused)');+ }return await startServer(extraEnv);} finally {releaseLock();@@ -1092,7 +1108,20 @@ export async function commandTimeoutReport(state: { pid: number; port: number }}// ─── Command Dispatch ──────────────────────────────────────────+/**+ * #4812: a command never runs on a daemon in the other public-only mode,+ * whichever path found that daemon (first read, a concurrent start, a+ * restart or an auth retry). stop clears configHash and is exempt.+ */+function refusePublicOnlyMismatch(state: ServerState, flags: Partial<Pick<GlobalFlags, 'publicOnly'>> | null | undefined): void {+ if (!!state.publicOnly === !!flags?.publicOnly) return;+ console.error(`[browse] the running browse daemon was started ${state.publicOnly ? 'in' : 'without'} public-only mode, so it was not reused.`);+ console.error(`[browse] fix: run 'browse disconnect', then run this command again.`);+ process.exit(1);+}+export async function sendCommand(state: ServerState, command: string, args: string[], retries = 0): Promise<void> {+ if (_globalFlags?.configHash && command !== 'stop') refusePublicOnlyMismatch(state, _globalFlags);// Precedence: CLI --tab-id flag > BROWSE_TAB env var > --session > BROWSE_SESSION > agent harness.// make-pdf always passes --tab-id; human users typically rely on BROWSE_TAB// or the active tab.@@ -1373,6 +1402,10 @@ export interface GlobalFlags {explicitDirect: boolean;/** Whether --headed was passed. */headed: boolean;+ /** Public-only mode (#4812): --public-only or BROWSE_PUBLIC_ONLY. */+ publicOnly: boolean;+ /** BROWSE_PUBLIC_ONLY_UPSTREAM=trusted with public-only on. */+ trustedUpstream: boolean;/** Hash of (proxy + headed + explicit direct) for daemon-mismatch check. */configHash: string;/** Redacted form of proxyUrl, safe for logs. */@@ -1393,6 +1426,7 @@ export function extractGlobalFlags(rawArgs: string[], env: NodeJS.ProcessEnv, plconst out: string[] = [];let proxyUrl: string | null = null;let headed = false;+ let publicOnlyFlag = false;let forceRestart = false;const leadingSession: string[] = [];@@ -1420,6 +1454,7 @@ export function extractGlobalFlags(rawArgs: string[], env: NodeJS.ProcessEnv, plcontinue;}if (arg === '--headed') { headed = true; continue; }+ if (arg === '--public-only') { publicOnlyFlag = true; continue; }out.push(arg);}out.splice(1, 0, ...leadingSession);@@ -1427,8 +1462,18 @@ export function extractGlobalFlags(rawArgs: string[], env: NodeJS.ProcessEnv, pl// Resolve --proxy, BROWSE_PROXY_URL or the standard proxy variables, with// creds embedded (server reads BROWSE_PROXY_URL from env, which passes to// the child without ps-aux exposure).- const proxy = resolveProxy(proxyUrl, env);+ const publicOnly = publicOnlyFromEnv(env, publicOnlyFlag);+ const proxy = resolveProxy(proxyUrl, env, publicOnly.on);const direct = !proxy.url && explicitDirect(env, platform);+ if (publicOnly.on && headed) {+ throw new PublicOnlyConfigError('drop --headed, or run without --public-only and BROWSE_PUBLIC_ONLY', '--public-only cannot be combined with --headed yet');+ }+ if (publicOnly.on && proxy.url && /^https?:/.test(proxy.url) && !publicOnly.trustedUpstream) {+ throw new PublicOnlyConfigError(+ `use a socks5:// proxy, unset ${proxy.source}, or set BROWSE_PUBLIC_ONLY_UPSTREAM=trusted if that proxy blocks private addresses itself`,+ `public-only mode cannot guard page traffic through the HTTP(S) proxy from ${proxy.source}`,+ );+ }return {args: out,@@ -1438,7 +1483,9 @@ export function extractGlobalFlags(rawArgs: string[], env: NodeJS.ProcessEnv, plproxyWarning: proxy.warning,explicitDirect: direct,headed,- configHash: computeConfigHash({ proxyUrl: proxy.url, headed, noProxyRules: proxy.noProxyRules, explicitDirect: direct }),+ publicOnly: publicOnly.on,+ trustedUpstream: publicOnly.trustedUpstream,+ configHash: computeConfigHash({ proxyUrl: proxy.url, headed, noProxyRules: proxy.noProxyRules, explicitDirect: direct, publicOnly: publicOnly.on, trustedUpstream: publicOnly.trustedUpstream }),redactedProxyUrl: redactProxyUrl(proxy.url),forceRestart,};@@ -1843,7 +1890,7 @@ async function main() {if (err instanceof ProxyConfigError) {console.error(`[browse] error: ${err.message}`);console.error(`[browse] hint: ${err.hint}`);- process.exit(1);+ process.exit(err instanceof PublicOnlyConfigError ? 2 : 1);}throw err;}@@ -1909,6 +1956,11 @@ Refs: After 'snapshot', use @e1, @e2... as selectors:// connect must be handled BEFORE ensureServer() because it needs// to restart the server in headed mode with the Chrome extension.if (command === 'connect') {+ if (globalFlags.publicOnly) {+ console.error('[browse] error: public-only mode cannot drive the headed browser (connect) yet');+ console.error('[browse] hint: run connect without --public-only and BROWSE_PUBLIC_ONLY, or use headless browse commands');+ process.exit(2);+ }// Check if already in headed mode and healthyconst existingState = readState();if (existingState && existingState.mode === 'headed' && isProcessAlive(existingState.pid)) {@@ -2253,7 +2305,9 @@ Refs: After 'snapshot', use @e1, @e2... as selectors:if (command === 'pair-agent') {// Ensure headed mode — the user should see the browser window// when sharing it with another agent. Feels safer, more impressive.- if (state.mode !== 'headed' && !hasFlag(commandArgs, '--headless')) {+ if (globalFlags.publicOnly) {+ console.log('[browse] public-only: pairing keeps the headless guarded browser (headed mode is not available in public-only mode yet).');+ } else if (state.mode !== 'headed' && !hasFlag(commandArgs, '--headless')) {if (pairAgentPreexistingDaemonAlive && !globalFlags.forceRestart) {// #2219 IRON RULE: only an explicit --force-restart may kill a live// daemon. The headed switch is nice-to-have; the user's open tabs,diff --git a/browse/src/proxy-config.ts b/browse/src/proxy-config.tsindex 101892072..8f64925ec 100644--- a/browse/src/proxy-config.ts+++ b/browse/src/proxy-config.ts@@ -176,6 +176,9 @@ export function computeConfigHash(opts: {noProxyRules?: string | null;/** explicitDirect(): BROWSE_PROXY_URL=direct where it bypasses the system proxy settings. */explicitDirect?: boolean;+ /** Public-only mode (#4812) and its trusted HTTP(S) upstream; hashed only when on, so other hashes are unchanged. */+ publicOnly?: boolean;+ trustedUpstream?: boolean;}): string {const proxyKey = canonicalizeProxyUrl(opts.proxyUrl);const input = JSON.stringify({@@ -183,6 +186,7 @@ export function computeConfigHash(opts: {headed: opts.headed,...(proxyKey && opts.noProxyRules ? { noProxy: opts.noProxyRules } : {}),...(!proxyKey && opts.explicitDirect ? { direct: true } : {}),+ ...(opts.publicOnly ? { publicOnly: opts.trustedUpstream ? 'trusted-upstream' : true } : {}),});return createHash('sha256').update(input).digest('hex').slice(0, 16);}@@ -353,7 +357,7 @@ const LEADING_SCHEME_RE = /^(?:https?|socks5h?):/i;* --proxy and BROWSE_PROXY_URL are explicit browse settings and still fail* closed, scheme required.*/-export function resolveProxy(flagUrl: string | null, env: NodeJS.ProcessEnv): ResolvedProxy {+export function resolveProxy(flagUrl: string | null, env: NodeJS.ProcessEnv, publicOnly = false): ResolvedProxy {const direct = (warning: string | null = null): ResolvedProxy => ({ url: null, source: null, noProxyRules: null, bypass: null, warning });let source: string;let raw: string;@@ -380,6 +384,8 @@ export function resolveProxy(flagUrl: string | null, env: NodeJS.ProcessEnv): Reif (url.protocol === 'socks5h:') url.protocol = 'socks5:';url.username = parsed.userId ? encodeURIComponent(parsed.userId) : '';url.password = parsed.password ? encodeURIComponent(parsed.password) : '';+ // Public-only (#4812): nothing may skip the proxy, so NO_PROXY and loopback stay off the bypass list.+ if (publicOnly) return { url: url.toString(), source, noProxyRules: null, bypass: null, warning: null };const rules = noProxyToChromiumRules(env.NO_PROXY || env.no_proxy);return {url: url.toString(),diff --git a/browse/src/public-only-proxy.ts b/browse/src/public-only-proxy.tsnew file mode 100644index 000000000..e221a981f--- /dev/null+++ b/browse/src/public-only-proxy.ts@@ -0,0 +1,83 @@+/**+ * Daemon startup for public-only mode (#4812): read the setting, then give+ * Chromium its only proxy, either the guard (direct, or chained to a SOCKS5+ * upstream) or an HTTP(S) upstream the user marked trusted, with no bypass+ * list; pin it for the launch invariant and install the navigation check.+ * Kept out of server.ts so the default proxy path there stays as it was.+ */++import { startAddressGuard } from './address-guard';+import { parseProxyConfig, toUpstreamConfig, ProxyConfigError } from './proxy-config';+import { redactProxyUrl } from './proxy-redact';+import { checkDestination, publicOnlyFromEnv, refusalMessage, type PublicOnlySetting } from './public-only';+import { testUpstream, type BridgeHandle } from './socks-bridge';+import { setPublicOnlyCheck } from './url-validation';++function exitWith(message: string): never {+ console.error(`[browse] error: ${message}`);+ process.exit(1);+}++/** The daemon's public-only setting; a value that does not parse, or public-only with headed mode, stops the daemon. */+export function readPublicOnlySetting(env: NodeJS.ProcessEnv): PublicOnlySetting {+ let setting: PublicOnlySetting;+ try {+ setting = publicOnlyFromEnv(env);+ } catch (err) {+ if (err instanceof ProxyConfigError) exitWith(`${err.message} (${err.hint})`);+ throw err;+ }+ if (setting.on && env.BROWSE_HEADED === '1') exitWith('public-only mode cannot drive the headed browser yet (run without BROWSE_PUBLIC_ONLY)');+ return setting;+}++export async function startPublicOnlyProxy(+ browserManager: { setProxyConfig(cfg: { server: string; username?: string; password?: string }): void; setPublicOnly(): void },+ setting: PublicOnlySetting,+ proxyUrl: string | undefined,+ proxySource: string,+ env: NodeJS.ProcessEnv = process.env,+): Promise<BridgeHandle | null> {+ let guard: BridgeHandle | null = null;+ let parsed: ReturnType<typeof parseProxyConfig> | null = null;+ if (proxyUrl) {+ try {+ parsed = parseProxyConfig({ proxyUrl, envUser: env.BROWSE_PROXY_USER, envPass: env.BROWSE_PROXY_PASS, source: proxySource });+ } catch (err) {+ if (err instanceof ProxyConfigError) exitWith(`${err.message} (${err.hint})`);+ throw err;+ }+ }+ if (parsed && parsed.scheme !== 'socks5') {+ if (!setting.trustedUpstream) {+ exitWith(`public-only mode cannot guard page traffic through the HTTP(S) proxy from ${proxySource} (use a socks5:// proxy, or set BROWSE_PUBLIC_ONLY_UPSTREAM=trusted if that proxy blocks private addresses itself)`);+ }+ browserManager.setProxyConfig({+ server: `${parsed.scheme}://${parsed.host}:${parsed.port}`,+ ...(parsed.userId ? { username: parsed.userId } : {}),+ ...(parsed.password ? { password: parsed.password } : {}),+ });+ console.log(`[browse] [public-only] on: the trusted HTTP(S) proxy ${redactProxyUrl(proxyUrl!)} from ${proxySource} blocks private addresses for page traffic; browse checks navigations, downloads and redirects`);+ } else {+ if (parsed) {+ try {+ const test = await testUpstream({ upstream: toUpstreamConfig(parsed), budgetMs: 5000, retries: 3, backoffMs: 500 });+ console.log(`[browse] [proxy] upstream test ok in ${test.ms}ms`);+ } catch (err) {+ exitWith(`[proxy] upstream ${redactProxyUrl(proxyUrl!)}: ${err instanceof Error ? err.message : String(err)}`);+ }+ }+ guard = await startAddressGuard(parsed ? { upstream: toUpstreamConfig(parsed) } : {});+ browserManager.setProxyConfig({ server: `socks5://127.0.0.1:${guard.port}` });+ const handle = guard;+ process.on('exit', () => { handle.close().catch(() => { /* shutting down anyway */ }); });+ console.log(`[browse] [public-only] on: every Chromium connection goes through the guard on 127.0.0.1:${guard.port}${parsed ? `, then ${redactProxyUrl(proxyUrl!)}` : ''}; loopback, private and other non-public addresses are refused`);+ }+ browserManager.setPublicOnly();+ setPublicOnlyCheck(async (url) => {+ const port = Number(url.port) || (url.protocol === 'https:' ? 443 : 80);+ const checked = await checkDestination(url.hostname, port);+ return 'reason' in checked ? refusalMessage(url.host, checked.reason) : null;+ });+ return guard;+}diff --git a/browse/src/public-only.ts b/browse/src/public-only.tsnew file mode 100644index 000000000..b45942fb8--- /dev/null+++ b/browse/src/public-only.ts@@ -0,0 +1,218 @@+/**+ * Public-only mode (#4812): an opt-in daemon mode for reading untrusted pages.+ * Every connection Chromium makes goes through the guard (address-guard.ts),+ * which refuses any destination that is not a public internet address.+ *+ * This module holds the parts the CLI, the daemon, the guard and navigation+ * share: the environment switch, the destination check (one resolver for the+ * guard and the navigation pre-check), the recent-refusal ring the daemon+ * turns into a clear command error, and the launch invariant.+ *+ * Threat model and what stays out of scope: BROWSER.md, "Public-only mode".+ */++import * as net from 'node:net';+import * as os from 'node:os';+import { lookup } from 'node:dns/promises';+import { ProxyConfigError } from './proxy-config';+import { ipBytes, nonPublicAddressReason } from './url-validation';++export const PUBLIC_ONLY_DOCS = 'https://github.com/garrytan/gstack/blob/main/BROWSER.md#public-only-mode';+export const PUBLIC_ONLY_CODE = 'PUBLIC_ONLY_REFUSED';+/** WebRTC may not send UDP outside the proxy, so ICE/STUN cannot reach private addresses directly. */+export const WEBRTC_PROXIED_ONLY_ARG = '--force-webrtc-ip-handling-policy=disable_non_proxied_udp';+/** Playwright's escape hatch that drops the <-loopback> rule, which would let loopback go direct. */+export const PLAYWRIGHT_LOOPBACK_ESCAPE = 'PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK';++/** A public-only setting that does not parse: the CLI exits 2, the daemon refuses to start. */+export class PublicOnlyConfigError extends ProxyConfigError {+ constructor(hint: string, message: string) {+ super(hint, message);+ this.name = 'PublicOnlyConfigError';+ }+}++export interface PublicOnlySetting {+ on: boolean;+ /** BROWSE_PUBLIC_ONLY_UPSTREAM=trusted: the user's HTTP(S) proxy enforces public-only on its own. */+ trustedUpstream: boolean;+}++/**+ * Read BROWSE_PUBLIC_ONLY (1, true or on; unset, empty, 0, false or off) and+ * BROWSE_PUBLIC_ONLY_UPSTREAM (unset, empty or trusted). Any other value+ * throws, so a typo never silently leaves the guard off.+ */+export function publicOnlyFromEnv(env: NodeJS.ProcessEnv, flag = false): PublicOnlySetting {+ const value = env.BROWSE_PUBLIC_ONLY ?? '';+ if (!['', '0', 'false', 'off', '1', 'true', 'on'].includes(value)) {+ throw new PublicOnlyConfigError('set BROWSE_PUBLIC_ONLY=1 to turn public-only mode on, or unset it', 'BROWSE_PUBLIC_ONLY must be 1, true or on (or 0, false, off or empty)');+ }+ const upstream = env.BROWSE_PUBLIC_ONLY_UPSTREAM ?? '';+ if (upstream !== '' && upstream !== 'trusted') {+ throw new PublicOnlyConfigError('set BROWSE_PUBLIC_ONLY_UPSTREAM=trusted only if your HTTP(S) proxy blocks private addresses itself, or unset it', 'BROWSE_PUBLIC_ONLY_UPSTREAM must be trusted or empty');+ }+ const on = flag || ['1', 'true', 'on'].includes(value);+ return { on, trustedUpstream: on && upstream === 'trusted' };+}++/** The refusal message every public-only path uses, with its code and fix. */+export function refusalMessage(target: string, reason: string): string {+ return `public-only refused ${target} (${reason}) [${PUBLIC_ONLY_CODE}]. fix: this session loads only public internet addresses; to reach local or private ones, run 'browse disconnect' and start browse without --public-only or BROWSE_PUBLIC_ONLY. see ${PUBLIC_ONLY_DOCS}`;+}++function inPrefix(address: number[], network: number[], bits: number): boolean {+ if (address.length !== network.length) return false;+ for (let i = 0; i < address.length && bits > 0; i++, bits -= 8) {+ const mask = bits >= 8 ? 0xff : (0xff << (8 - bits)) & 0xff;+ if ((address[i] & mask) !== (network[i] & mask)) return false;+ }+ return true;+}++export interface LocalNetwork { bytes: number[]; bits: number; cidr: string }++let interfaceCache: { at: number; nets: LocalNetwork[] } | null = null;++/** This machine's own networks (each interface address with its on-link prefix), cached briefly. */+function localNetworks(): LocalNetwork[] {+ if (interfaceCache && Date.now() - interfaceCache.at < 30_000) return interfaceCache.nets;+ const nets: LocalNetwork[] = [];+ for (const entries of Object.values(os.networkInterfaces())) {+ for (const entry of entries ?? []) {+ const bytes = ipBytes(entry.address);+ const bits = Number(entry.cidr?.split('/')[1]);+ if (bytes && Number.isInteger(bits)) nets.push({ bytes, bits, cidr: entry.cidr! });+ }+ }+ interfaceCache = { at: Date.now(), nets };+ return nets;+}++/** Why an address is refused in public-only mode, or null when it is a public address outside this machine's own networks. */+export function addressRefusalReason(address: string, networks: LocalNetwork[] = localNetworks()): string | null {+ const reason = nonPublicAddressReason(address);+ if (reason) return reason;+ const raw = ipBytes(address);+ if (!raw) return 'not an IP address';+ const mapped = raw.length === 16 && raw.slice(0, 10).every(b => b === 0) && raw[10] === 0xff && raw[11] === 0xff;+ const bytes = mapped ? raw.slice(12) : raw;+ const own = networks.find(n => inPrefix(bytes, n.bytes, n.bits));+ return own ? `address on this machine's own network (${own.cidr})` : null;+}++export type Resolver = (host: string) => Promise<string[]>;++const systemResolver: Resolver = async (host) => (await lookup(host, { all: true, verbatim: true })).map(a => a.address);+const answerCache = new Map<string, { at: number; answer: Promise<string[]> }>();++/** The OS resolver (hosts file included), with a 30 s cache that also shares in-flight lookups. */+export function cachedResolver(resolve: Resolver = systemResolver): Resolver {+ return (host) => {+ const hit = answerCache.get(host);+ if (hit && Date.now() - hit.at < 30_000) return hit.answer;+ if (answerCache.size > 500) answerCache.clear();+ const answer = resolve(host);+ answerCache.set(host, { at: Date.now(), answer });+ answer.catch(() => answerCache.delete(host));+ return answer;+ };+}++export interface CheckOptions {+ resolver?: Resolver;+ /** Refusal reason for one address; defaults to addressRefusalReason. Tests key fixtures by port. */+ reason?: (address: string, port: number) => string | null;+}++/**+ * Check one destination: refuse localhost names without DNS, refuse when the+ * literal or ANY resolved address is refused, refuse when DNS fails. On+ * success, the checked addresses are the only ones a caller may connect to.+ */+export async function checkDestination(host: string, port: number, opts: CheckOptions = {}): Promise<{ addresses: string[] } | { reason: string }> {+ const name = host.toLowerCase().replace(/^\[|\]$/g, '').replace(/\.$/, '');+ if (name === 'localhost' || name.endsWith('.localhost')) return { reason: 'loopback name' };+ const reasonFor = opts.reason ?? ((address: string) => addressRefusalReason(address));+ if (net.isIP(name)) {+ const reason = reasonFor(name, port);+ return reason ? { reason } : { addresses: [name] };+ }+ let addresses: string[];+ try {+ addresses = await (opts.resolver ?? cachedResolver())(name);+ } catch {+ return { reason: 'DNS lookup failed' };+ }+ if (addresses.length === 0) return { reason: 'DNS lookup returned no address' };+ for (const address of addresses) {+ const reason = reasonFor(address, port);+ if (reason) return { reason: `resolves to ${address}, a ${reason}` };+ }+ return { addresses };+}++export interface Refusal { target: string; reason: string; at: number }++const recent: Refusal[] = [];+let refusedTotal = 0;+const loggedTargets = new Map<string, number>();++/** Record a guard refusal: kept for the command error, counted for /health, logged at most once a minute per target. */+export function recordRefusal(target: string, reason: string): void {+ const at = Date.now();+ recent.push({ target, reason, at });+ if (recent.length > 50) recent.shift();+ refusedTotal++;+ if (at - (loggedTargets.get(target) ?? 0) < 60_000) return;+ if (loggedTargets.size > 500) loggedTargets.clear();+ loggedTargets.set(target, at);+ console.warn(`[browse] [public-only] refused ${target} (${reason})`);+}++export function refusalsSince(at: number): Refusal[] {+ return recent.filter(r => r.at >= at);+}++export function refusalCount(): number {+ return refusedTotal;+}++/**+ * A command error that names a host the guard refused while the command ran+ * leads with that refusal, so the agent sees what was refused and the fix+ * instead of a bare ERR_SOCKS_CONNECTION_FAILED. A refusal of some other host+ * (another session's, or a page's tracker) is left out. Refusals exist only in+ * public-only mode.+ */+export function withRefusal(message: string, since: number): string {+ if (message.includes(PUBLIC_ONLY_CODE)) return message;+ const names = (r: Refusal) => {+ const host = r.target.replace(/:\d+$/, '');+ for (let i = message.indexOf(host); i !== -1; i = message.indexOf(host, i + 1)) {+ if (!/[\w.-]/.test(message[i - 1] ?? '') && !/[\w-]/.test(message[i + host.length] ?? '')) return true;+ }+ return false;+ };+ const refusal = refusalsSince(since).find(names);+ return refusal ? `${refusalMessage(refusal.target, refusal.reason)}\n(${message})` : message;+}++/**+ * The launch invariant (#4812): in public-only mode Chromium's only proxy is+ * the guard (or the trusted upstream), with no bypass list from any source,+ * and Playwright's switch that drops <-loopback> is not set. Throws with a+ * fix line otherwise; every launch path calls this before chromium.launch.+ */+export function assertPublicOnlyLaunch(+ proxy: { server: string; bypass?: string } | null,+ expectedServer: string,+ env: NodeJS.ProcessEnv = process.env,+): void {+ const fail = (what: string, fix: string) => {+ throw new Error(`public-only: refusing to launch Chromium because ${what}. fix: ${fix}. see ${PUBLIC_ONLY_DOCS}`);+ };+ if (!proxy || proxy.server !== expectedServer) fail(`its proxy is ${proxy?.server ?? 'none'}, not the public-only guard`, "run 'browse disconnect' and start again");+ if (proxy!.bypass) fail(`its proxy bypass list is set (${proxy!.bypass})`, "unset BROWSE_PROXY_BYPASS");+ if (env[PLAYWRIGHT_LOOPBACK_ESCAPE]) fail(`${PLAYWRIGHT_LOOPBACK_ESCAPE} is set, which would let loopback skip the guard`, `unset ${PLAYWRIGHT_LOOPBACK_ESCAPE}`);+}diff --git a/browse/src/routes/core.ts b/browse/src/routes/core.tsindex 611448594..67ac5df98 100644--- a/browse/src/routes/core.ts+++ b/browse/src/routes/core.ts@@ -8,6 +8,7 @@ import * as fs from 'fs';import * as path from 'path';import { resolveStateRoot } from '../../../lib/state-root';import { json, type RouteEntry } from './table';+import { refusalCount } from '../public-only';import { handleCookiePickerRoute } from '../cookie-picker-routes';import { sanitizeReplacer } from '../sanitize';@@ -93,6 +94,8 @@ export const coreRoutes: RouteEntry[] = [mode: browserManager.getConnectionMode(),uptime: Math.floor((Date.now() - ctx.startTime) / 1000),tabs: browserManager.getTabCount(),+ // Public-only mode (#4812): how many connections the guard refused.+ ...(browserManager.isPublicOnly() ? { publicOnly: { refused: refusalCount() } } : {}),// No `security` field (#2557): the live defenses report through// their own call sites, not through /health.// Terminal-agent discovery. ONLY a port number — never a token.diff --git a/browse/src/server.ts b/browse/src/server.tsindex ad4588ec2..3cb9c8b51 100644--- a/browse/src/server.ts+++ b/browse/src/server.ts@@ -50,6 +50,8 @@ import { isProcessAlive } from './error-handling';import { allowedExtensionOrigin } from './extension-id';import { sanitizeBody, stripLoneSurrogates } from './sanitize';import { startSocksBridge, testUpstream, type BridgeHandle } from './socks-bridge';+import { withRefusal } from './public-only';+import { readPublicOnlySetting, startPublicOnlyProxy } from './public-only-proxy';import { parseProxyConfig, toUpstreamConfig, ProxyConfigError, serverProxyEnv, directProxyLogLine } from './proxy-config';import { writeReceipt } from '../../lib/egress-receipt';import { redactProxyUrl } from './proxy-redact';@@ -1305,7 +1307,7 @@ async function handleCommandInternalImpl(});browserManager.incrementFailures();- let errorMsg = wrapError(err);+ let errorMsg = withRefusal(wrapError(err), startTime);const hint = browserManager.getFailureHint();if (hint) errorMsg += '\n' + hint;return { status: 500, result: JSON.stringify({ error: errorMsg }), json: true };@@ -1868,7 +1870,9 @@ export async function start() {// SOCKS5 auth itself); HTTP/HTTPS or unauthenticated SOCKS5 pass through.let proxyBridge: BridgeHandle | null = null;const { url: proxyUrl, source: proxySource, bypass: proxyBypass, direct: proxyDirect } = serverProxyEnv(process.env);- if (proxyUrl) {+ const publicOnly = readPublicOnlySetting(process.env); // #4812: BROWSER.md, "Public-only mode"+ if (publicOnly.on) proxyBridge = await startPublicOnlyProxy(browserManager, publicOnly, proxyUrl, proxySource);+ else if (proxyUrl) {let parsed;try {parsed = parseProxyConfig({@@ -2003,7 +2007,8 @@ export async function start() {// D2 daemon-mismatch detection: CLI computes the same hash from its// resolved flags and refuses if it differs from this stored value....(process.env.BROWSE_CONFIG_HASH ? { configHash: process.env.BROWSE_CONFIG_HASH } : {}),- ...(proxyUrl ? { proxy: redactProxyUrl(proxyUrl), proxySource, proxyBypass } : proxyDirect ? { proxyDirect } : {}), // #915/#3440 refusal detail+ ...(proxyUrl ? { proxy: redactProxyUrl(proxyUrl), proxySource, ...(publicOnly.on ? {} : { proxyBypass }) } : proxyDirect ? { proxyDirect } : {}), // #915/#3440 refusal detail+ ...(publicOnly.on ? { publicOnly: true } : {}),// Xvfb child PID + start-time + display so disconnect (or a future// daemon launch on this state file) can validate-then-cleanup orphans// without clobbering a recycled PID.diff --git a/browse/src/socks-bridge.ts b/browse/src/socks-bridge.tsindex 16a1ad44b..32fa37fcc 100644--- a/browse/src/socks-bridge.ts+++ b/browse/src/socks-bridge.ts@@ -45,10 +45,12 @@ const ATYP_DOMAINNAME = 0x03;const ATYP_IPV6 = 0x04;const REPLY_SUCCESS = 0x00;const REPLY_GENERAL_FAILURE = 0x01;+/** SOCKS5 reply 0x02: connection not allowed by ruleset (public-only refusals, #4812). */+export const REPLY_NOT_ALLOWED = 0x02;const REPLY_HOST_UNREACHABLE = 0x04;-const UPSTREAM_CONNECT_TIMEOUT_MS = 15000;+export const UPSTREAM_CONNECT_TIMEOUT_MS = 15000;-function buildUpstream(upstream: UpstreamConfig): SocksProxy {+export function buildUpstream(upstream: UpstreamConfig): SocksProxy {return {host: upstream.host,port: upstream.port,@@ -106,7 +108,32 @@ export async function startSocksBridge(opts: {port?: number;}): Promise<BridgeHandle> {const upstreamProxy = buildUpstream(opts.upstream);- const requestedPort = opts.port ?? 0;+ return serveSocks5((dest) => SocksClient.createConnection({+ proxy: upstreamProxy,+ command: 'connect',+ destination: { host: dest.host, port: dest.port },+ timeout: UPSTREAM_CONNECT_TIMEOUT_MS,+ }).then((result) => result.socket), opts.port);+}++/** A connect callback's refusal: the bridge replies with this SOCKS5 code. */+export class SocksRefusal extends Error {+ constructor(public readonly reply: number, message: string) {+ super(message);+ this.name = 'SocksRefusal';+ }+}++/**+ * The no-auth SOCKS5 listener on 127.0.0.1 behind startSocksBridge and the+ * public-only guard (address-guard.ts). connect opens the outbound socket for+ * each CONNECT; a SocksRefusal rejection picks the reply code, any other+ * rejection replies host unreachable.+ */+export async function serveSocks5(+ connect: (dest: { host: string; port: number }) => Promise<net.Socket>,+ requestedPort = 0,+): Promise<BridgeHandle> {const inFlight = new Set<net.Socket>();// Frame-size predicates for the two SOCKS5 messages we read from the@@ -149,7 +176,10 @@ export async function startSocksBridge(opts: {killBoth('handshake timeout');}}, 30000);- clientSocket.once('close', () => clearTimeout(handshakeTimeout));+ clientSocket.once('close', () => {+ clearTimeout(handshakeTimeout);+ if (state !== 'piped') killBoth('client closed');+ });const onData = (chunk: Buffer) => {if (state === 'closed' || state === 'piped') return;@@ -182,17 +212,12 @@ export async function startSocksBridge(opts: {// Pause client reads so any post-handshake bytes don't get dropped.// We replay `remainder` after upstream is established.clientSocket.pause();- SocksClient.createConnection({- proxy: upstreamProxy,- command: 'connect',- destination: { host: dest.host, port: dest.port },- timeout: UPSTREAM_CONNECT_TIMEOUT_MS,- }).then((result) => {+ connect(dest).then((socket) => {if (state === 'closed') {- try { result.socket.destroy(); } catch { /* shutdown */ }+ try { socket.destroy(); } catch { /* shutdown */ }return;}- upstreamSocket = result.socket;+ upstreamSocket = socket;writeReply(clientSocket, REPLY_SUCCESS);// Replay any pre-buffered post-handshake bytes BEFORE we pipe.if (remainder.length > 0) {@@ -206,8 +231,8 @@ export async function startSocksBridge(opts: {upstreamSocket.pipe(clientSocket);clientSocket.resume();state = 'piped';- }).catch(() => {- writeReply(clientSocket, REPLY_HOST_UNREACHABLE);+ }).catch((err) => {+ writeReply(clientSocket, err instanceof SocksRefusal ? err.reply : REPLY_HOST_UNREACHABLE);killBoth('upstream connect failed');});return;diff --git a/browse/src/url-validation.ts b/browse/src/url-validation.tsindex 717de6de0..cf7088cd4 100644--- a/browse/src/url-validation.ts+++ b/browse/src/url-validation.ts@@ -69,6 +69,91 @@ function expandIpv6(addr: string): number[] | null {return groups.every(g => Number.isInteger(g) && g >= 0 && g <= 0xffff) ? groups : null;}+/** IPv4 ranges that are not public internet addresses (IANA special-purpose registry, not globally reachable), #4812. */+const NON_PUBLIC_V4: Array<[number, number, number, number, number, string]> = [+ [0, 0, 0, 0, 8, '"this network" address'],+ [10, 0, 0, 0, 8, 'private address'],+ [100, 64, 0, 0, 10, 'carrier-grade NAT address'],+ [127, 0, 0, 0, 8, 'loopback address'],+ [169, 254, 0, 0, 16, 'link-local or cloud metadata address'],+ [172, 16, 0, 0, 12, 'private address'],+ [192, 0, 0, 0, 24, 'IETF special-purpose address'],+ [192, 0, 2, 0, 24, 'documentation address'],+ [192, 88, 99, 0, 24, '6to4 relay address'],+ [192, 168, 0, 0, 16, 'private address'],+ [198, 18, 0, 0, 15, 'benchmarking address'],+ [198, 51, 100, 0, 24, 'documentation address'],+ [203, 0, 113, 0, 24, 'documentation address'],+ [224, 0, 0, 0, 4, 'multicast address'],+ [240, 0, 0, 0, 4, 'reserved address'],+];++function v4Reason(octets: number[]): string | null {+ const value = ((octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | octets[3]) >>> 0;+ for (const [a, b, c, d, bits, label] of NON_PUBLIC_V4) {+ const base = ((a << 24) | (b << 16) | (c << 8) | d) >>> 0;+ const mask = bits === 0 ? 0 : (0xffffffff << (32 - bits)) >>> 0;+ if (((value & mask) >>> 0) === base) return label;+ }+ return null;+}++/**+ * The bytes of an IP literal (4 for IPv4, 16 for IPv6), after the same+ * canonicalization classifyAddress applies; null when the host is not one.+ */+export function ipBytes(host: string): number[] | null {+ let h = host.trim().toLowerCase().replace(/^\[|\]$/g, '').replace(/\.$/, '');+ if (!h) return null;+ if (h.includes(':')) {+ try { h = new URL(`http://[${h}]/`).hostname.slice(1, -1); } catch { return null; }+ const groups = expandIpv6(h);+ return groups ? groups.flatMap(g => [g >> 8, g & 255]) : null;+ }+ try { h = new URL(`http://${h}/`).hostname; } catch { return null; }+ const m = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(h);+ return m ? m.slice(1).map(Number) : null;+}++/**+ * Why an IP literal is not a public internet address, or null when it is one+ * (or is not an IP literal). Public-only mode (#4812) refuses every address+ * this names. IPv6 is public only inside 2000::/3, minus the special ranges;+ * IPv4 embedded in mapped (::ffff:0:0/96), NAT64 (64:ff9b::/96) and 6to4+ * (2002::/16) addresses is judged by the embedded address.+ */+export function nonPublicAddressReason(host: string): string | null {+ const bytes = ipBytes(host);+ if (!bytes) return null;+ if (bytes.length === 4) return v4Reason(bytes);+ const g = Array.from({ length: 8 }, (_, i) => (bytes[2 * i] << 8) | bytes[2 * i + 1]);+ const zeros = (n: number) => g.slice(0, n).every(x => x === 0);+ if (zeros(5) && g[5] === 0xffff) return v4Reason(bytes.slice(12));+ if (g[0] === 0x64 && g[1] === 0xff9b && g[2] === 0 && g[3] === 0 && g[4] === 0 && g[5] === 0) return v4Reason(bytes.slice(12));+ if (g[0] === 0x2002) return v4Reason(bytes.slice(2, 6));+ if (zeros(7)) return g[7] === 1 ? 'loopback address' : g[7] === 0 ? 'unspecified address' : 'IPv4-compatible (deprecated) address';+ if (zeros(6)) return 'IPv4-compatible (deprecated) address';+ if ((g[0] & 0xfe00) === 0xfc00) return 'unique local (private) address';+ if ((g[0] & 0xffc0) === 0xfe80) return 'link-local address';+ if ((g[0] & 0xffc0) === 0xfec0) return 'site-local address';+ if ((g[0] & 0xff00) === 0xff00) return 'multicast address';+ if ((g[0] & 0xe000) !== 0x2000) return 'reserved address';+ if (g[0] === 0x2001 && g[1] === 0x0db8) return 'documentation address';+ if (g[0] === 0x2001 && g[1] < 0x0200) return 'IETF special-purpose address (Teredo, benchmarking, ORCHID)';+ if ((g[0] & 0xfff0) === 0x3ff0) return 'documentation address';+ return null;+}++/**+ * The public-only check (#4812), installed by the daemon when the mode is on;+ * null otherwise, so default navigation keeps exactly today's rules. It gets+ * the parsed http(s) URL and returns the refusal message or null.+ */+let publicOnlyCheck: ((url: URL) => Promise<string | null>) | null = null;+export function setPublicOnlyCheck(check: ((url: URL) => Promise<string | null>) | null): void {+ publicOnlyCheck = check;+}+/*** Resolve a hostname and report whether any A or AAAA answer is blocked.* Each family is tried independently; a missing family is not a risk. DNS@@ -104,6 +189,10 @@ export async function blockedNavigationReason(url: string): Promise<string | nulif (kind === 'blocked' || BLOCKED_METADATA_HOSTNAMES.has(hostname)) {return `Blocked: ${parsed.hostname} is a cloud metadata or link-local address. Access is denied for security.`;}+ if (publicOnlyCheck) {+ const refused = await publicOnlyCheck(parsed);+ if (refused) return refused;+ }if (kind !== null || hostname === 'localhost') return null;if (await resolvesToBlockedIp(hostname)) {return `Blocked: ${parsed.hostname} resolves to a cloud metadata or link-local address. Possible DNS rebinding attack.`;diff --git a/browse/test/address-guard.test.ts b/browse/test/address-guard.test.tsnew file mode 100644index 000000000..2e46c1f20--- /dev/null+++ b/browse/test/address-guard.test.ts@@ -0,0 +1,124 @@+/**+ * #4812 public-only guard: the SOCKS5 listener Chromium gets as its only proxy.+ * Loopback echo servers stand in for destinations; the guard's reason hook+ * counts one fixture port as public, so an allowed connection can complete+ * without the internet while every other loopback port stays refused.+ *+ * Value: protects=the guard refuses non-public destinations before any byte reaches them, replies "not allowed", records the refusal, connects only to the address it checked (no second lookup, so DNS rebinding cannot swap it), falls back across checked addresses, and sends the checked address, not the name, to a SOCKS5 upstream;+ * fails_when=the guard connects to the name instead of the checked address, resolves twice, stops recording refusals, or hands a SOCKS5 upstream the host name;+ * why_new=socks-bridge.test.ts covers the authenticated bridge only, and the guard is new;+ * seam=the reason hook allows one fixture port and a stub resolver supplies DNS answers; no_claim=Chromium's own traffic through the guard is public-only-e2e.test.ts+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import * as net from 'node:net';+import { SocksClient } from 'socks';+import { startAddressGuard } from '../src/address-guard';+import { addressRefusalReason, refusalsSince } from '../src/public-only';+import type { BridgeHandle } from '../src/socks-bridge';++interface Fixture { port: number; hits: number; close: () => Promise<void> }++async function echoServer(): Promise<Fixture> {+ const fixture = { port: 0, hits: 0, close: async () => {} };+ const server = net.createServer((sock) => { fixture.hits++; sock.on('data', (d) => sock.write(d)); sock.on('error', () => {}); });+ await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));+ fixture.port = (server.address() as net.AddressInfo).port;+ fixture.close = () => new Promise<void>((resolve) => server.close(() => resolve()));+ return fixture;+}++/** A no-auth SOCKS5 upstream that records each CONNECT destination and relays it. */+async function recordingUpstream(): Promise<{ port: number; destinations: string[]; close: () => Promise<void> }> {+ const destinations: string[] = [];+ const server = net.createServer((sock) => {+ sock.on('error', () => {});+ sock.once('data', () => {+ sock.write(Buffer.from([0x05, 0x00]));+ sock.once('data', (req: Buffer) => {+ const atyp = req[3];+ const host = atyp === 0x01 ? [...req.subarray(4, 8)].join('.') : req.subarray(5, 5 + req[4]).toString();+ const port = req.readUInt16BE(req.length - 2);+ destinations.push(`${atyp === 0x01 ? 'ip' : 'name'}:${host}:${port}`);+ const out = net.connect({ host: atyp === 0x01 ? host : '127.0.0.1', port }, () => {+ sock.write(Buffer.from([0x05, 0x00, 0x00, 0x01, 0, 0, 0, 0, 0, 0]));+ sock.pipe(out); out.pipe(sock);+ });+ out.on('error', () => sock.destroy());+ });+ });+ });+ await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));+ return { port: (server.address() as net.AddressInfo).port, destinations, close: () => new Promise<void>((resolve) => server.close(() => resolve())) };+}++async function through(guard: BridgeHandle, host: string, port: number): Promise<string> {+ const { socket } = await SocksClient.createConnection({ proxy: { host: '127.0.0.1', port: guard.port, type: 5 }, command: 'connect', destination: { host, port }, timeout: 5000 });+ socket.write('ping');+ const reply = await new Promise<string>((resolve) => socket.once('data', (d) => resolve(d.toString())));+ socket.destroy();+ return reply;+}++let publicFixture: Fixture;+let privateFixture: Fixture;+const lookups: string[] = [];+const answers: Record<string, string[]> = {};+const opts = () => ({+ resolver: async (host: string) => { lookups.push(host); if (!answers[host]) throw new Error('ENOTFOUND'); return answers[host]; },+ reason: (address: string, port: number) => (port === publicFixture.port && address === '127.0.0.1' ? null : addressRefusalReason(address)),+});++beforeAll(async () => { publicFixture = await echoServer(); privateFixture = await echoServer(); });+afterAll(async () => { await publicFixture.close(); await privateFixture.close(); });++describe('startAddressGuard', () => {+ test('relays an allowed destination and refuses a non-public one before it is reached', async () => {+ const guard = await startAddressGuard(opts());+ try {+ expect(await through(guard, '127.0.0.1', publicFixture.port)).toBe('ping');+ const since = Date.now();+ await expect(through(guard, '127.0.0.1', privateFixture.port)).rejects.toThrow(/not allowed|ruleset|Socks5 proxy rejected/i);+ await expect(through(guard, 'localhost', privateFixture.port)).rejects.toThrow();+ expect(privateFixture.hits).toBe(0);+ expect(refusalsSince(since).map(r => r.target)).toEqual([`127.0.0.1:${privateFixture.port}`, `localhost:${privateFixture.port}`]);+ } finally { await guard.close(); }+ });++ test('connects to the checked address with one lookup, so a changed DNS answer cannot redirect it', async () => {+ const guard = await startAddressGuard(opts());+ try {+ answers['pinned.test'] = ['127.0.0.1'];+ lookups.length = 0;+ expect(await through(guard, 'pinned.test', publicFixture.port)).toBe('ping');+ expect(lookups).toEqual(['pinned.test']);+ answers['mixed.test'] = ['127.0.0.1', '10.0.0.5'];+ await expect(through(guard, 'mixed.test', publicFixture.port)).rejects.toThrow();+ await expect(through(guard, 'nxdomain.test', publicFixture.port)).rejects.toThrow();+ } finally { await guard.close(); }+ });++ test('tries each checked address in turn', async () => {+ const guard = await startAddressGuard({ ...opts(), reason: () => null, connectTimeoutMs: 2000 });+ try {+ answers['fallback.test'] = ['127.0.0.2', '127.0.0.1'];+ const closed = await echoServer();+ const port = closed.port;+ await closed.close();+ answers['dead.test'] = ['127.0.0.1'];+ await expect(through(guard, 'dead.test', port)).rejects.toThrow();+ expect(await through(guard, 'fallback.test', publicFixture.port)).toBe('ping');+ } finally { await guard.close(); }+ });++ test('a SOCKS5 upstream receives the checked address, never the name', async () => {+ const upstream = await recordingUpstream();+ const guard = await startAddressGuard({ ...opts(), upstream: { host: '127.0.0.1', port: upstream.port } });+ try {+ answers['chained.test'] = ['127.0.0.1'];+ expect(await through(guard, 'chained.test', publicFixture.port)).toBe('ping');+ expect(upstream.destinations).toEqual([`ip:127.0.0.1:${publicFixture.port}`]);+ await expect(through(guard, '127.0.0.1', privateFixture.port)).rejects.toThrow();+ expect(upstream.destinations).toHaveLength(1);+ } finally { await guard.close(); await upstream.close(); }+ });+});diff --git a/browse/test/daemon-mismatch-refuse.test.ts b/browse/test/daemon-mismatch-refuse.test.tsindex b36ab64e3..f00a80f04 100644--- a/browse/test/daemon-mismatch-refuse.test.ts+++ b/browse/test/daemon-mismatch-refuse.test.ts@@ -176,3 +176,68 @@ describe('D2 daemon-mismatch refuse (CLI integration)', () => {}}, 15000);});++describe('#4812 public-only daemon mismatch (CLI integration)', () => {+ async function runAgainstFakeDaemon(state: Record<string, unknown>, args: string[]) {+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'browse-mismatch-public-only-'));+ const stateFile = path.join(tmpDir, 'browse.json');+ const fakeServer = await startFakeHealthServer('fake-token');+ fs.writeFileSync(stateFile, JSON.stringify({+ pid: process.pid,+ port: fakeServer.port,+ token: 'fake-token',+ startedAt: new Date().toISOString(),+ serverPath: '',+ mode: 'launched',+ ...state,+ }, null, 2));+ const cliEnv: Record<string, string> = {};+ for (const [k, v] of Object.entries(process.env)) {+ if (v !== undefined && !k.startsWith('BROWSE_PUBLIC_ONLY')) cliEnv[k] = v;+ }+ cliEnv.BROWSE_STATE_FILE = stateFile;+ try {+ return await runCli(args, cliEnv);+ } finally {+ await fakeServer.close();+ fs.rmSync(tmpDir, { recursive: true, force: true });+ }+ }++ test('a public-only command refuses a running daemon started without the guard', async () => {+ const { computeConfigHash } = await import('../src/proxy-config');+ const plainHash = computeConfigHash({ proxyUrl: null, headed: false });+ const result = await runAgainstFakeDaemon({ configHash: plainHash }, ['--public-only', 'status']);+ expect(result.code).toBe(1);+ expect(result.stderr).toContain('started without public-only mode, so it was not reused');+ expect(result.stderr).toContain("run 'browse disconnect'");+ }, 15000);++ test('a public-only command refuses an older daemon that recorded no config hash', async () => {+ const result = await runAgainstFakeDaemon({}, ['--public-only', 'status']);+ expect(result.code).toBe(1);+ expect(result.stderr).toContain('started without public-only mode, so it was not reused');+ }, 15000);++ test('a plain command refuses a running public-only daemon with the same hint', async () => {+ const { computeConfigHash } = await import('../src/proxy-config');+ const guardedHash = computeConfigHash({ proxyUrl: null, headed: false, publicOnly: true });+ const result = await runAgainstFakeDaemon({ configHash: guardedHash, publicOnly: true }, ['status']);+ expect(result.code).toBe(1);+ expect(result.stderr).toContain('started in public-only mode, so it was not reused');+ expect(result.stderr).toContain("run 'browse disconnect'");+ }, 15000);+ test('a daemon found with a matching hash but in the other mode is still refused before dispatch', async () => {+ const { computeConfigHash } = await import('../src/proxy-config');+ const guardedHash = computeConfigHash({ proxyUrl: null, headed: false, publicOnly: true });+ const result = await runAgainstFakeDaemon({ configHash: guardedHash }, ['--public-only', 'status']);+ expect(result.code).toBe(1);+ expect(result.stderr).toContain('started without public-only mode, so it was not reused');+ }, 15000);+ test('plain stop still stops a public-only daemon', async () => {+ const { computeConfigHash } = await import('../src/proxy-config');+ const guardedHash = computeConfigHash({ proxyUrl: null, headed: false, publicOnly: true });+ const result = await runAgainstFakeDaemon({ publicOnly: true, configHash: guardedHash }, ['stop']);+ expect(result.stderr).not.toContain('so it was not reused');+ }, 15000);+});diff --git a/browse/test/public-only-e2e.test.ts b/browse/test/public-only-e2e.test.tsnew file mode 100644index 000000000..be0bbc3a2--- /dev/null+++ b/browse/test/public-only-e2e.test.ts@@ -0,0 +1,224 @@+/**+ * #4812 public-only mode against a real Chromium. One loopback HTTP fixture+ * plays the public site (the guard's reason hook allows exactly its port);+ * another plays a private service and counts every TCP connection it gets.+ * The public page aims images, fetch, a WebSocket, an iframe, a form POST and+ * a redirect at the private service by 127.0.0.1 and by localhost. With the+ * guard as Chromium's only proxy the private service must see no connection;+ * the same page without the guard reaches it (negative control). Then the+ * daemon itself: a public-only goto to loopback is refused with the code and+ * fix (goto and download), the CLI refuses an unguardable setup and a mismatched+ * daemon, and BrowserManager's own launch carries the public-only switches.+ *+ * Value: protects=no Chromium connection (subresource, fetch, WebSocket, frame, form, redirect, page.request) reaches a non-public address in public-only mode, loopback included, and the daemon wires the mode end to end;+ * fails_when=Chromium gets a bypass list or loses the WebRTC switch, Playwright stops proxying loopback, the guard lets a loopback port through, page.request skips the proxy, the daemon starts without the guard, or the CLI reuses a daemon in the other mode;+ * why_new=address-guard.test.ts drives the guard with a SOCKS client, which cannot show what Chromium routes around a proxy;+ * seam=the guard's reason hook counts one fixture port as public; no_claim=service workers, WebRTC traffic and real DNS rebinding are not exercised here (the WebRTC switch is checked on the command line; the single lookup is unit-tested); Windows is skipped+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import * as fs from 'node:fs';+import * as http from 'node:http';+import * as net from 'node:net';+import * as os from 'node:os';+import * as path from 'node:path';+import { chromium } from 'playwright';+import { startAddressGuard } from '../src/address-guard';+import { addressRefusalReason, WEBRTC_PROXIED_ONLY_ARG } from '../src/public-only';+import { BrowserManager } from '../src/browser-manager';+import { readPidCmdline } from '../src/xvfb';++let publicServer: http.Server;+let publicPort = 0;+let privateServer: net.Server;+let privatePort = 0;+let privateHits = 0;+const privateSockets = new Set<net.Socket>();++beforeAll(async () => {+ privateServer = net.createServer((sock) => {+ privateHits++;+ privateSockets.add(sock);+ sock.on('close', () => privateSockets.delete(sock));+ sock.on('error', () => {});+ sock.end('HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 2\r\nConnection: close\r\n\r\nok');+ });+ await new Promise<void>((resolve) => privateServer.listen(0, '127.0.0.1', resolve));+ privatePort = (privateServer.address() as net.AddressInfo).port;+ publicServer = http.createServer((req, res) => {+ if (req.url === '/redirect') { res.writeHead(302, { Location: `http://127.0.0.1:${privatePort}/redirected` }); res.end(); return; }+ const priv = `http://127.0.0.1:${privatePort}`;+ const named = `http://localhost:${privatePort}`;+ res.writeHead(200, { 'Content-Type': 'text/html' });+ res.end(`<!doctype html><title>public</title>+ <img src="${priv}/img"><img src="${named}/img"><img src="/redirect">+ <iframe src="${priv}/frame"></iframe><iframe name="sink"></iframe>+ <form id="f" method="post" action="${priv}/form" target="sink"><input name="a" value="1"></form>+ <script>+ fetch('${priv}/fetch', { mode: 'no-cors' }).catch(() => {});+ fetch('${named}/fetch', { mode: 'no-cors' }).catch(() => {});+ try { new WebSocket('ws://127.0.0.1:${privatePort}/ws'); } catch {}+ document.getElementById('f').submit();+ </script>`);+ });+ await new Promise<void>((resolve) => publicServer.listen(0, '127.0.0.1', resolve));+ publicPort = (publicServer.address() as net.AddressInfo).port;+});++afterAll(async () => {+ publicServer.closeAllConnections();+ await new Promise<void>((resolve) => publicServer.close(() => resolve()));+ for (const sock of privateSockets) sock.destroy();+ await new Promise<void>((resolve) => privateServer.close(() => resolve()));+});++const reason = (address: string, port: number) => (port === publicPort && address === '127.0.0.1' ? null : addressRefusalReason(address));++async function loadPublicPage(proxy: { server: string } | undefined): Promise<{ title: string; requestError: string | null }> {+ const browser = await chromium.launch({ headless: true, ...(proxy ? { proxy } : {}), args: proxy ? [WEBRTC_PROXIED_ONLY_ARG] : [] });+ try {+ const page = await browser.newPage();+ await page.goto(`http://127.0.0.1:${publicPort}/`, { waitUntil: 'load', timeout: 20_000 });+ await page.waitForTimeout(1_500);+ const requestError = await page.request.fetch(`http://127.0.0.1:${privatePort}/api`, { timeout: 5_000 }).then(() => null, (err: Error) => err.message);+ await page.request.fetch(`http://127.0.0.1:${publicPort}/redirect`, { timeout: 5_000 }).catch(() => null);+ return { title: await page.title(), requestError };+ } finally {+ await browser.close();+ }+}++describe.skipIf(process.platform === 'win32')('#4812 public-only: Chromium through the guard', () => {+ test('negative control: without the guard the public page reaches the private service', async () => {+ privateHits = 0;+ const r = await loadPublicPage(undefined);+ expect(r.title).toBe('public');+ expect(privateHits).toBeGreaterThan(0);+ }, 60_000);++ test('with the guard as the only proxy, the page loads and the private service sees no connection', async () => {+ const guard = await startAddressGuard({ reason });+ try {+ privateHits = 0;+ const r = await loadPublicPage({ server: `socks5://127.0.0.1:${guard.port}` });+ expect(r.title).toBe('public');+ expect(r.requestError).not.toBeNull();+ expect(privateHits).toBe(0);+ } finally {+ await guard.close();+ }+ }, 60_000);+});++describe.skipIf(process.platform === 'win32')('#4812 public-only: the Chromium command line BrowserManager launches', () => {+ let saved: string | undefined;+ let dir = '';+ beforeAll(() => {+ saved = process.env.BROWSE_STATE_FILE;+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'browse-public-only-args-'));+ process.env.BROWSE_STATE_FILE = path.join(dir, 'state', 'browse.json');+ });+ afterAll(() => {+ if (saved === undefined) delete process.env.BROWSE_STATE_FILE;+ else process.env.BROWSE_STATE_FILE = saved;+ fs.rmSync(dir, { recursive: true, force: true });+ });++ async function switchesOf(manager: BrowserManager): Promise<string[]> {+ try {+ await manager.launch();+ const info = manager.getChromiumProcInfo();+ if (!info) throw new Error('BrowserManager recorded no Chromium pid');+ return readPidCmdline(info.pid).split(' ').filter(arg => arg.startsWith('--'));+ } finally {+ await Promise.race([manager.close(), new Promise(resolve => setTimeout(resolve, 5000))]).catch(() => {});+ }+ }++ test('public-only adds the WebRTC switch and keeps the guard as the only proxy with Playwright\'s <-loopback> rule; default mode has no WebRTC switch', async () => {+ const guard = await startAddressGuard({ reason });+ try {+ const guarded = new BrowserManager();+ guarded.setProxyConfig({ server: `socks5://127.0.0.1:${guard.port}` });+ guarded.setPublicOnly();+ const on = await switchesOf(guarded);+ expect(on).toContain(WEBRTC_PROXIED_ONLY_ARG);+ expect(on).toContain(`--proxy-server=socks5://127.0.0.1:${guard.port}`);+ expect(on.filter(arg => arg.startsWith('--proxy-bypass-list='))).toEqual(['--proxy-bypass-list=<-loopback>']);+ } finally {+ await guard.close();+ }+ expect(await switchesOf(new BrowserManager())).not.toContain(WEBRTC_PROXIED_ONLY_ARG);+ }, 90_000);++ test('a bypass list refuses the launch before Chromium starts', async () => {+ const manager = new BrowserManager();+ manager.setProxyConfig({ server: 'socks5://127.0.0.1:9', bypass: 'localhost' });+ manager.setPublicOnly();+ await expect(manager.launch()).rejects.toThrow('its proxy bypass list is set');+ expect(manager.getChromiumProcInfo()).toBeNull();+ }, 30_000);+});++const CLI = path.resolve(import.meta.dir, '../src/cli.ts');+let scratch = '';+let stateFile = '';++async function browse(args: string[], extraEnv: Record<string, string>) {+ const env: Record<string, string> = {};+ for (const [key, value] of Object.entries(process.env)) {+ if (value !== undefined && !/^(BROWSE_|GSTACK_|NO_PROXY$|no_proxy$|HTTPS?_PROXY$|https?_proxy$|ALL_PROXY$|all_proxy$|PLAYWRIGHT_DISABLE_)/.test(key)) env[key] = value;+ }+ Object.assign(env, {+ HOME: scratch,+ GSTACK_HOME: path.join(scratch, '.gstack'),+ PLAYWRIGHT_BROWSERS_PATH: process.env.PLAYWRIGHT_BROWSERS_PATH || path.join(os.homedir(), ...(process.platform === 'darwin' ? ['Library', 'Caches'] : ['.cache']), 'ms-playwright'),+ BROWSE_STATE_FILE: stateFile,+ BROWSE_PARENT_PID: '0',+ }, extraEnv);+ const cli = Bun.spawn([process.execPath, CLI, ...args], { cwd: scratch, env, stdin: 'ignore', stdout: 'pipe', stderr: 'pipe' });+ const timer = setTimeout(() => cli.kill('SIGKILL'), 60_000);+ const [code, stdout, stderr] = await Promise.all([cli.exited, new Response(cli.stdout).text(), new Response(cli.stderr).text()]);+ clearTimeout(timer);+ return { code, out: stdout + stderr };+}++describe.skipIf(process.platform === 'win32')('#4812 public-only: the daemon and CLI', () => {+ beforeAll(() => {+ scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'browse-public-only-'));+ stateFile = path.join(scratch, 'state', 'browse.json');+ });+ afterAll(() => {+ if (fs.existsSync(stateFile)) {+ try { process.kill(JSON.parse(fs.readFileSync(stateFile, 'utf8')).pid, 'SIGKILL'); } catch {}+ }+ fs.rmSync(scratch, { recursive: true, force: true });+ });++ test('goto a loopback service is refused with the code and fix, and the daemon records the mode', async () => {+ privateHits = 0;+ const r = await browse(['--public-only', 'goto', `http://127.0.0.1:${privatePort}/`], {});+ expect(r.code).not.toBe(0);+ expect(r.out).toContain('public-only: on');+ expect(r.out).toContain('[PUBLIC_ONLY_REFUSED]');+ expect(r.out).toContain("run 'browse disconnect'");+ expect(privateHits).toBe(0);+ expect(JSON.parse(fs.readFileSync(stateFile, 'utf8')).publicOnly).toBe(true);+ const download = await browse(['--public-only', 'download', `http://127.0.0.1:${privatePort}/x`, path.join(scratch, 'x.bin')], {});+ expect(download.code).not.toBe(0);+ expect(download.out).toContain('[PUBLIC_ONLY_REFUSED]');+ expect(privateHits).toBe(0);+ const plain = await browse(['url'], {});+ expect(plain.code).toBe(1);+ expect(plain.out).toContain('started in public-only mode, so it was not reused');+ expect((await browse(['--public-only', 'stop'], {})).code).toBe(0);+ }, 120_000);++ test('the CLI refuses an HTTP(S) upstream, --headed and a typo with exit 2, before starting anything', async () => {+ const proxied = await browse(['goto', 'https://example.com'], { BROWSE_PUBLIC_ONLY: '1', HTTPS_PROXY: 'http://proxy.invalid:3128' });+ expect(proxied.code).toBe(2);+ expect(proxied.out).toContain('BROWSE_PUBLIC_ONLY_UPSTREAM=trusted');+ expect((await browse(['--headed', 'goto', 'https://example.com'], { BROWSE_PUBLIC_ONLY: '1' })).code).toBe(2);+ expect((await browse(['goto', 'https://example.com'], { BROWSE_PUBLIC_ONLY: 'yes' })).code).toBe(2);+ expect(fs.existsSync(stateFile)).toBe(false);+ }, 60_000);+});diff --git a/browse/test/public-only.test.ts b/browse/test/public-only.test.tsnew file mode 100644index 000000000..08acca524--- /dev/null+++ b/browse/test/public-only.test.ts@@ -0,0 +1,207 @@+/**+ * #4812 public-only mode, the pure parts: which addresses count as public,+ * the environment switch, the destination check the guard and navigation+ * share, the launch invariant, the refusal message a failed command carries,+ * and the CLI's flag parsing, refusals and daemon env.+ *+ * Value: protects=public-only refuses every non-public range and this machine's own networks, fails closed on DNS errors and mixed answers, never starts with an HTTP(S) upstream it cannot guard, with --headed, or with a bypass list or Playwright's loopback escape, and leaves the default proxy settings and config hash unchanged;+ * fails_when=a range drops out of nonPublicAddressReason, checkDestination accepts a mixed or failed DNS answer, publicOnlyFromEnv reads a typo as off, assertPublicOnlyLaunch lets a bypass or the escape variable through, or extractGlobalFlags stops refusing an unguarded combination;+ * why_new=the mode is new: no existing test covers public-only classification, parsing or refusals;+ * seam=checkDestination takes a stub resolver and addressRefusalReason a stub interface list, so no DNS or network is touched; no_claim=connections through the guard are address-guard.test.ts and Chromium's traffic is public-only-e2e.test.ts+ */+import { describe, expect, test } from 'bun:test';+import { ipBytes, nonPublicAddressReason } from '../src/url-validation';+import {+ PLAYWRIGHT_LOOPBACK_ESCAPE, PUBLIC_ONLY_CODE, PublicOnlyConfigError, addressRefusalReason, assertPublicOnlyLaunch,+ checkDestination, publicOnlyFromEnv, recordRefusal, withRefusal,+} from '../src/public-only';+import { computeConfigHash, resolveProxy } from '../src/proxy-config';+import { buildRestartEnv, extractGlobalFlags } from '../src/cli';+import { isCdpMethodAllowed } from '../src/cdp-allowlist';+import * as os from 'node:os';+import * as path from 'node:path';+import { BrowserManager } from '../src/browser-manager';++describe('nonPublicAddressReason', () => {+ const refused = [+ '0.0.0.0', '0.255.255.255', '10.0.0.1', '10.255.255.255', '100.64.0.1', '100.127.255.255', '127.0.0.1', '127.1.2.3',+ '169.254.169.254', '172.16.0.1', '172.31.255.255', '192.0.0.8', '192.0.2.1', '192.88.99.1', '192.168.1.1',+ '198.18.0.1', '198.19.255.255', '198.51.100.7', '203.0.113.9', '224.0.0.1', '239.255.255.250', '240.0.0.1', '255.255.255.255',+ '100.100.100.200', '2852039166', '0x7f000001', '017700000001',+ '::', '::1', '[::1]', 'fe80::1', 'febf::1', 'fec0::1', 'fc00::1', 'fd00:ec2::254', 'ff02::1', '::ffff:127.0.0.1',+ '::ffff:10.1.2.3', '::ffff:7f00:1', '::127.0.0.1', '64:ff9b::a9fe:a9fe', '64:ff9b:1::1', '2002:7f00:1::1', '2002:c0a8:101::1',+ '2001::1', '2001:0:4136:e378:8000:63bf:3fff:fdd2', '2001:2::1', '2001:db8::1', '3fff::1', '100::1', '5f00::1', '4000::1',+ ];+ for (const address of refused) {+ test(`refuses ${address}`, () => { expect(nonPublicAddressReason(address)).not.toBeNull(); });+ }+ const allowed = ['8.8.8.8', '1.1.1.1', '9.255.255.255', '11.0.0.0', '100.63.255.255', '100.128.0.0', '172.15.255.255', '172.32.0.0',+ '192.167.255.255', '192.169.0.0', '198.17.255.255', '198.20.0.0', '223.255.255.255', '2606:4700::1111', '2a00:1450::1',+ '::ffff:8.8.8.8', '64:ff9b::808:808', '2002:808:808::1', '2001:200::1'];+ for (const address of allowed) {+ test(`allows ${address}`, () => { expect(nonPublicAddressReason(address)).toBeNull(); });+ }+ test('names the kind of address', () => {+ expect(nonPublicAddressReason('127.0.0.1')).toBe('loopback address');+ expect(nonPublicAddressReason('10.0.0.1')).toBe('private address');+ expect(nonPublicAddressReason('169.254.169.254')).toBe('link-local or cloud metadata address');+ expect(nonPublicAddressReason('fd00::1')).toBe('unique local (private) address');+ });+ test('a host name is not an IP literal', () => { expect(nonPublicAddressReason('example.com')).toBeNull(); });+});++describe('addressRefusalReason', () => {+ const nets = [{ bytes: ipBytes('34.1.2.3')!, bits: 20, cidr: '34.1.2.3/20' }, { bytes: ipBytes('2600:1f18::5')!, bits: 64, cidr: '2600:1f18::5/64' }];+ test("refuses public addresses on this machine's own networks", () => {+ expect(addressRefusalReason('34.1.15.200', nets)).toBe("address on this machine's own network (34.1.2.3/20)");+ expect(addressRefusalReason('2600:1f18::99', nets)).toContain("this machine's own network");+ expect(addressRefusalReason('34.1.16.1', nets)).toBeNull();+ expect(addressRefusalReason('2600:1f18:0:1::1', nets)).toBeNull();+ });+ test('non-public reasons come first and a name is never an address', () => {+ expect(addressRefusalReason('10.0.0.1', [])).toBe('private address');+ expect(addressRefusalReason('example.com', [])).toBe('not an IP address');+ });+});++describe('publicOnlyFromEnv', () => {+ test('on and off spellings', () => {+ for (const v of ['1', 'true', 'on']) expect(publicOnlyFromEnv({ BROWSE_PUBLIC_ONLY: v }).on).toBe(true);+ for (const v of ['', '0', 'false', 'off']) expect(publicOnlyFromEnv({ BROWSE_PUBLIC_ONLY: v }).on).toBe(false);+ expect(publicOnlyFromEnv({}).on).toBe(false);+ expect(publicOnlyFromEnv({}, true).on).toBe(true);+ });+ test('any other value throws instead of silently meaning off', () => {+ for (const v of ['yes', 'TRUE', 'On', '2', ' 1']) expect(() => publicOnlyFromEnv({ BROWSE_PUBLIC_ONLY: v })).toThrow(PublicOnlyConfigError);+ expect(() => publicOnlyFromEnv({ BROWSE_PUBLIC_ONLY: '1', BROWSE_PUBLIC_ONLY_UPSTREAM: 'yes' })).toThrow(PublicOnlyConfigError);+ });+ test('the trusted upstream counts only with public-only on', () => {+ expect(publicOnlyFromEnv({ BROWSE_PUBLIC_ONLY: '1', BROWSE_PUBLIC_ONLY_UPSTREAM: 'trusted' }).trustedUpstream).toBe(true);+ expect(publicOnlyFromEnv({ BROWSE_PUBLIC_ONLY_UPSTREAM: 'trusted' }).trustedUpstream).toBe(false);+ });+});++describe('checkDestination', () => {+ const resolver = (answers: Record<string, string[]>) => async (host: string) => {+ if (!(host in answers)) throw new Error('ENOTFOUND');+ return answers[host];+ };+ const dns = resolver({ 'public.test': ['8.8.8.8', '2606:4700::1111'], 'mixed.test': ['8.8.8.8', '10.0.0.5'], 'rebind.test': ['127.0.0.1'], 'empty.test': [] });+ test('a public name passes with the addresses it was checked against', async () => {+ expect(await checkDestination('public.test', 443, { resolver: dns })).toEqual({ addresses: ['8.8.8.8', '2606:4700::1111'] });+ expect(await checkDestination('8.8.8.8', 80, { resolver: dns })).toEqual({ addresses: ['8.8.8.8'] });+ });+ test('refuses when any answer is non-public, when DNS fails or answers nothing, and loopback names without DNS', async () => {+ expect(await checkDestination('mixed.test', 443, { resolver: dns })).toEqual({ reason: 'resolves to 10.0.0.5, a private address' });+ expect(await checkDestination('rebind.test', 443, { resolver: dns })).toEqual({ reason: 'resolves to 127.0.0.1, a loopback address' });+ expect(await checkDestination('missing.test', 443, { resolver: dns })).toEqual({ reason: 'DNS lookup failed' });+ expect(await checkDestination('empty.test', 443, { resolver: dns })).toEqual({ reason: 'DNS lookup returned no address' });+ for (const host of ['localhost', 'LOCALHOST.', 'app.localhost']) {+ expect(await checkDestination(host, 3000, { resolver: async () => ['8.8.8.8'] })).toEqual({ reason: 'loopback name' });+ }+ expect(await checkDestination('127.0.0.1', 80, { resolver: dns })).toEqual({ reason: 'loopback address' });+ expect(await checkDestination('[::1]', 80, { resolver: dns })).toEqual({ reason: 'loopback address' });+ });+});++describe('assertPublicOnlyLaunch', () => {+ const guard = 'socks5://127.0.0.1:4000';+ test('passes only for the pinned guard with no bypass and no loopback escape', () => {+ expect(() => assertPublicOnlyLaunch({ server: guard }, guard, {})).not.toThrow();+ expect(() => assertPublicOnlyLaunch(null, guard, {})).toThrow(/its proxy is none/);+ expect(() => assertPublicOnlyLaunch({ server: 'socks5://127.0.0.1:4001' }, guard, {})).toThrow(/not the public-only guard/);+ expect(() => assertPublicOnlyLaunch({ server: guard, bypass: 'localhost' }, guard, {})).toThrow(/bypass list is set/);+ expect(() => assertPublicOnlyLaunch({ server: guard }, guard, { [PLAYWRIGHT_LOOPBACK_ESCAPE]: '1' })).toThrow(new RegExp(PLAYWRIGHT_LOOPBACK_ESCAPE));+ });+});++describe('refusal errors', () => {+ test('a command error names the refusal recorded while it ran, with the code and fix', () => {+ const before = Date.now();+ expect(withRefusal('net::ERR_SOCKS_CONNECTION_FAILED', before)).toBe('net::ERR_SOCKS_CONNECTION_FAILED');+ recordRefusal('10.0.0.5:80', 'private address');+ expect(withRefusal('net::ERR_SOCKS_CONNECTION_FAILED at http://203.0.114.1/', before)).toBe('net::ERR_SOCKS_CONNECTION_FAILED at http://203.0.114.1/');+ expect(withRefusal('locator.click: Timeout 5000ms exceeded', before)).toBe('locator.click: Timeout 5000ms exceeded');+ const message = withRefusal('net::ERR_SOCKS_CONNECTION_FAILED at http://10.0.0.5/', before);+ expect(message).toStartWith(`public-only refused 10.0.0.5:80 (private address) [${PUBLIC_ONLY_CODE}]. fix:`);+ expect(message).toContain("run 'browse disconnect'");+ expect(message).toContain('BROWSER.md#public-only-mode');+ expect(message).toEndWith('(net::ERR_SOCKS_CONNECTION_FAILED at http://10.0.0.5/)');+ expect(withRefusal('net::ERR_FAILED', Date.now() + 1000)).toBe('net::ERR_FAILED');+ });+});++describe('proxy settings in public-only mode', () => {+ test('nothing skips the proxy: NO_PROXY and loopback leave the bypass list', () => {+ const env = { HTTPS_PROXY: 'socks5://proxy.example:1080', NO_PROXY: 'corp.example' };+ expect(resolveProxy(null, env).bypass).toContain('localhost');+ expect(resolveProxy(null, env, true)).toMatchObject({ url: 'socks5://proxy.example:1080', bypass: null, noProxyRules: null });+ });+ test('the config hash changes only when public-only is on', () => {+ const base = { proxyUrl: null, headed: false };+ expect(computeConfigHash({ ...base, publicOnly: false })).toBe(computeConfigHash(base));+ expect(computeConfigHash({ ...base, publicOnly: true })).not.toBe(computeConfigHash(base));+ expect(computeConfigHash({ ...base, publicOnly: true, trustedUpstream: true })).not.toBe(computeConfigHash({ ...base, publicOnly: true }));+ });+});++describe('CLI flags', () => {+ test('--public-only is stripped, hashed and forwarded to the daemon', () => {+ const flags = extractGlobalFlags(['goto', '--public-only', 'https://example.com'], {}, 'linux');+ expect(flags).toMatchObject({ args: ['goto', 'https://example.com'], publicOnly: true, trustedUpstream: false });+ expect(flags.configHash).not.toBe(extractGlobalFlags(['goto', 'https://example.com'], {}, 'linux').configHash);+ expect(buildRestartEnv(flags, null)).toMatchObject({ BROWSE_PUBLIC_ONLY: '1' });+ const plain = extractGlobalFlags(['goto', 'https://example.com'], {}, 'linux');+ expect(plain.publicOnly).toBe(false);+ expect(buildRestartEnv(plain, null).BROWSE_PUBLIC_ONLY).toBeUndefined();+ });+ test('refuses --headed, an unguardable HTTP(S) upstream and a typo, with exit-2 errors', () => {+ expect(() => extractGlobalFlags(['goto', 'x'], { BROWSE_PUBLIC_ONLY: 'yes' }, 'linux')).toThrow(PublicOnlyConfigError);+ expect(() => extractGlobalFlags(['--headed', 'goto', 'x'], { BROWSE_PUBLIC_ONLY: '1' }, 'linux')).toThrow(/--headed/);+ expect(() => extractGlobalFlags(['goto', 'x'], { BROWSE_PUBLIC_ONLY: '1', HTTPS_PROXY: 'http://proxy.corp:3128' }, 'linux')).toThrow(/HTTP\(S\) proxy from HTTPS_PROXY/);+ expect(() => extractGlobalFlags(['--public-only', '--proxy', 'https://proxy.corp:3128', 'goto', 'x'], {}, 'linux')).toThrow(PublicOnlyConfigError);+ });+ test('a SOCKS5 upstream is guarded, and a trusted HTTP(S) upstream is allowed with nothing bypassing it', () => {+ expect(extractGlobalFlags(['goto', 'x'], { BROWSE_PUBLIC_ONLY: '1', ALL_PROXY: 'socks5://sock.example:1080' }, 'linux')).toMatchObject({ publicOnly: true, proxyBypass: null });+ const trusted = extractGlobalFlags(['goto', 'x'], { BROWSE_PUBLIC_ONLY: '1', BROWSE_PUBLIC_ONLY_UPSTREAM: 'trusted', HTTPS_PROXY: 'http://proxy.corp:3128' }, 'linux');+ expect(trusted).toMatchObject({ publicOnly: true, trustedUpstream: true, proxyBypass: null });+ expect(buildRestartEnv(trusted, null)).toMatchObject({ BROWSE_PUBLIC_ONLY: '1', BROWSE_PUBLIC_ONLY_UPSTREAM: 'trusted' });+ expect(buildRestartEnv(trusted, null).BROWSE_PROXY_BYPASS).toBeUndefined();+ });+});++test('raw CDP cannot create a browser context with its own proxy', () => {+ expect(isCdpMethodAllowed('Target.createBrowserContext')).toBe(false);+});++describe('#4812 review fixes', () => {+ test("a mapped IPv6 address is judged against this machine's IPv4 networks", () => {+ const nets = [{ bytes: [8, 8, 8, 0], bits: 24, cidr: '8.8.8.0/24' }];+ expect(addressRefusalReason('::ffff:8.8.8.8', nets)).toBe("address on this machine's own network (8.8.8.0/24)");+ expect(addressRefusalReason('::ffff:8.8.4.4', nets)).toBeNull();+ });++ test('a refusal leads only an error that names its exact host', () => {+ const before = Date.now();+ recordRefusal('a.example:443', 'DNS lookup failed');+ expect(withRefusal('net::ERR_FAILED at https://data.a.example/', before)).not.toContain(PUBLIC_ONLY_CODE);+ expect(withRefusal('net::ERR_FAILED at https://xa.example/', before)).not.toContain(PUBLIC_ONLY_CODE);+ expect(withRefusal('net::ERR_FAILED at https://a.example/x', before)).toContain(PUBLIC_ONLY_CODE);+ });++ test('handoff is refused, and never suggested, in public-only mode', async () => {+ const saved = process.env.BROWSE_STATE_FILE;+ process.env.BROWSE_STATE_FILE = path.join(os.tmpdir(), 'browse-public-only-handoff', 'browse.json');+ try {+ const bm = new BrowserManager();+ bm.setProxyConfig({ server: 'socks5://127.0.0.1:9' });+ bm.setPublicOnly();+ await expect(bm.handoff('help')).rejects.toThrow('public-only mode cannot hand off');+ for (let i = 0; i < 3; i++) bm.incrementFailures();+ expect(bm.getFailureHint()).toBeNull();+ } finally {+ if (saved === undefined) delete process.env.BROWSE_STATE_FILE;+ else process.env.BROWSE_STATE_FILE = saved;+ }+ });+});diff --git a/browse/test/terminal-agent.test.ts b/browse/test/terminal-agent.test.tsindex c5b247ac1..b9c1861fc 100644--- a/browse/test/terminal-agent.test.ts+++ b/browse/test/terminal-agent.test.ts@@ -96,7 +96,7 @@ describe('/health does NOT surface ptyToken', () => {const ctx = stubRouteContext({browserManager: {isHealthy: () => true, probeActiveTab: async () => ({ id: 1, responsive: true }),- getConnectionMode: () => 'launched', getTabCount: () => 1,+ getConnectionMode: () => 'launched', getTabCount: () => 1, isPublicOnly: () => false,} as any,terminal: { readPort: () => 4242, grantToken: async () => true, restartSession: async () => true },});diff --git a/canary/SKILL.md b/canary/SKILL.mdindex e3b23d95c..a89221293 100644--- a/canary/SKILL.md+++ b/canary/SKILL.md@@ -112,6 +112,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/changelog.d/capy-browse-public-only.md b/changelog.d/capy-browse-public-only.mdnew file mode 100644index 000000000..e4d170207--- /dev/null+++ b/changelog.d/capy-browse-public-only.md@@ -0,0 +1 @@+**browse can now keep untrusted pages off your machine and private network.** Run `browse --public-only` or set `BROWSE_PUBLIC_ONLY=1`, and every connection the browser makes (pages, redirects, images, fetches, WebSockets, downloads) is refused when it points at this machine, a private network, or a cloud metadata address, and DNS tricks can't get around it. With the switch off nothing changes, so `localhost:3000` keeps working. See BROWSER.md, "Public-only mode". (#4812)diff --git a/design-consultation/SKILL.md b/design-consultation/SKILL.mdindex 38ea8c0e6..61bad23b4 100644--- a/design-consultation/SKILL.md+++ b/design-consultation/SKILL.md@@ -234,6 +234,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/design-review/SKILL.md b/design-review/SKILL.mdindex 21701ec35..f263f0858 100644--- a/design-review/SKILL.md+++ b/design-review/SKILL.md@@ -201,6 +201,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/devex-review/SKILL.md b/devex-review/SKILL.mdindex 68a1e5d8d..799aa68d2 100644--- a/devex-review/SKILL.md+++ b/devex-review/SKILL.md@@ -183,6 +183,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/docs/REMOTE_BROWSER_ACCESS.md b/docs/REMOTE_BROWSER_ACCESS.mdindex 688fba031..c2c5ae18e 100644--- a/docs/REMOTE_BROWSER_ACCESS.md+++ b/docs/REMOTE_BROWSER_ACCESS.md@@ -184,7 +184,7 @@ Each agent owns the tabs it creates. Rules:- Tokens can be revoked instantly: `$B tunnel revoke agent-name` deletes the session plus any pending setup keys and verifies against the live agent list. `$B tunnel agents` shows who's paired (pending setup keys included). `$B stop` clears everything — tokens never survive the daemon.- **SSE auth** uses a 30-minute HttpOnly SameSite=Strict cookie, stream-scope only (never valid against `/command`).- **Path traversal guarded** on `/welcome` — `GSTACK_SLUG` must match `^[a-z0-9_-]+$` or falls back to the built-in template.-- **SSRF guards** on `goto`, `download`, and scrape paths — validates URL target against a localhost/private-range blocklist.+- **SSRF guards** on `goto`, `download`, and scrape paths — refuse cloud metadata and link-local addresses (`169.254.0.0/16`, `fe80::/10`, `fc00::/7` and the metadata host names). Localhost and private ranges stay reachable for local dev servers unless the daemon runs in [public-only mode](../BROWSER.md#public-only-mode), which refuses them for every connection the browser makes.- **Tunnel surface denial logging.** Every rejection on the tunnel listener (`path_not_on_tunnel`, `root_token_on_tunnel`, `missing_scoped_token`, `disallowed_command:*`) is appended to `~/.gstack/security/attempts.jsonl` with timestamp, source IP, path, method. Rate-capped at 60 writes/min.- **Egress receipt on tunnel start (v1.63+).** Every tunnel session open writes a hash-chained receipt (sink `browse-tunnel`) to `~/.gstack/security/egress.jsonl` BEFORE ngrok forwards anything. Fail-closed: if the receipt can't be written, the tunnel refuses to start. Audit with `bin/gstack-egress list` / `bin/gstack-egress verify`.- All agent activity is logged with attribution (clientId).diff --git a/land-and-deploy/sections/canary.md b/land-and-deploy/sections/canary.mdindex 8c891c2b1..bef6bcea6 100644--- a/land-and-deploy/sections/canary.md+++ b/land-and-deploy/sections/canary.md@@ -12,6 +12,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" in@@ -46,6 +47,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/office-hours/SKILL.md b/office-hours/SKILL.mdindex cc2369aa1..88317b15c 100644--- a/office-hours/SKILL.md+++ b/office-hours/SKILL.md@@ -191,6 +191,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" in@@ -422,6 +423,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/plan-ceo-review/SKILL.md b/plan-ceo-review/SKILL.mdindex 8c8024a2d..77ddfe6db 100644--- a/plan-ceo-review/SKILL.md+++ b/plan-ceo-review/SKILL.md@@ -269,6 +269,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/plan-devex-review/SKILL.md b/plan-devex-review/SKILL.mdindex f8aaef84a..dd4b65643 100644--- a/plan-devex-review/SKILL.md+++ b/plan-devex-review/SKILL.md@@ -425,6 +425,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/plan-eng-review/SKILL.md b/plan-eng-review/SKILL.mdindex 766783272..5230fab32 100644--- a/plan-eng-review/SKILL.md+++ b/plan-eng-review/SKILL.md@@ -362,6 +362,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/qa/sections/browser-setup.md b/qa/sections/browser-setup.mdindex 5bc682966..4f34d2a5f 100644--- a/qa/sections/browser-setup.md+++ b/qa/sections/browser-setup.md@@ -32,6 +32,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/review/SKILL.md b/review/SKILL.mdindex 8371a7eec..2e1890fdf 100644--- a/review/SKILL.md+++ b/review/SKILL.md@@ -434,6 +434,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/scrape/SKILL.md b/scrape/SKILL.mdindex e9ef82cd8..473019b6d 100644--- a/scrape/SKILL.md+++ b/scrape/SKILL.md@@ -167,6 +167,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/scripts/lib/windows-curation.ts b/scripts/lib/windows-curation.tsindex 437f76385..7ddd8e790 100644--- a/scripts/lib/windows-curation.ts+++ b/scripts/lib/windows-curation.ts@@ -517,6 +517,10 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }>file: 'test/review-pass-voice-failures.test.ts',reason: 'split from test/review-pass.test.ts, which Windows never ran (its POSIX mode-bit check): runs bin/gstack-review-dispatch (a shebang) and bash git fixtures through test/helpers/review-pass-harness.ts',},+ {+ file: 'browse/test/address-guard.test.ts',+ reason: 'Bun crashes on windows-latest (bun.report, KERNEL32) while the public-only guard relays its SOCKS5 test connections (PR #4888 windows-scoped-shard, run 46198225599); public-only mode targets Linux and macOS like its e2e file, which skips Windows',+ },];// Force-include overrides: files a WINDOWS_FRAGILE_PATTERNS regex excludes fordiff --git a/scripts/resolvers/aside.ts b/scripts/resolvers/aside.tsindex 74eb8bafc..40d4d7dfd 100644--- a/scripts/resolvers/aside.ts+++ b/scripts/resolvers/aside.ts@@ -107,6 +107,7 @@ elif command -v perl >/dev/null; then perl -e 'alarm(shift);exec(@ARGV)' 30 "$@"_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "\${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: \${GSTACK_PLATFORM:-$(uname)}"+elif case \${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/setup-deploy/SKILL.md b/setup-deploy/SKILL.mdindex f23ddfea9..a0f60252d 100644--- a/setup-deploy/SKILL.md+++ b/setup-deploy/SKILL.md@@ -116,6 +116,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/ship/SKILL.md b/ship/SKILL.mdindex 5534912e0..5c82d052a 100644--- a/ship/SKILL.md+++ b/ship/SKILL.md@@ -148,6 +148,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/spec/SKILL.md b/spec/SKILL.mdindex 92e9eddf3..323065ae9 100644--- a/spec/SKILL.md+++ b/spec/SKILL.md@@ -147,6 +147,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/test/aside-probe-shell.test.ts b/test/aside-probe-shell.test.tsindex ec9799e77..5fd6e08e5 100644--- a/test/aside-probe-shell.test.ts+++ b/test/aside-probe-shell.test.ts@@ -15,7 +15,7 @@ const launchers = {perl: Bun.which('perl'),};-function run(shell: string, arm: keyof typeof launchers | 'none', mode = 'ready', skip = false, platform = 'Darwin') {+function run(shell: string, arm: keyof typeof launchers | 'none', mode = 'ready', skip = false, platform = 'Darwin', extraEnv: Record<string, string> = {}) {const root = mkdtempSync(join(tmpdir(), 'aside-probe-'));const bin = join(root, 'bin');mkdirSync(bin);@@ -42,7 +42,7 @@ esacconst script = mode === 'hang' ? probe.replaceAll('30 "$@"', '1 "$@"') : probe;const result = spawnSync(executable, ['-c', script], {encoding: 'utf8', timeout: 5000,- env: { HOME: root, PATH: bin, MODE: mode, CALLS: join(root, 'calls'), GSTACK_SKIP_ASIDE: skip ? '1' : '', ...(platform ? { GSTACK_PLATFORM: platform } : {}) },+ env: { HOME: root, PATH: bin, MODE: mode, CALLS: join(root, 'calls'), GSTACK_SKIP_ASIDE: skip ? '1' : '', ...(platform ? { GSTACK_PLATFORM: platform } : {}), ...extraEnv },});let calls = '';try { calls = readFileSync(join(root, 'calls'), 'utf8'); } catch {}@@ -113,3 +113,19 @@ describe('emitted Aside readiness probe', () => {}}});++describe('the Aside probe under BROWSE_PUBLIC_ONLY (#4812)', () => {+ for (const shell of shells) {+ const shellTest = Bun.which(shell) && launchers.timeout ? test : test.skip;+ shellTest(`${shell}: on, or any value browse rejects, skips Aside without calling it; off and unset keep the probe`, () => {+ for (const value of ['1', 'true', 'on', 'TRUE', 'yes', ' 1']) {+ const r = run(shell, 'timeout', 'ready', false, 'Darwin', { BROWSE_PUBLIC_ONLY: value });+ expect(r.output).toBe('ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY\n');+ expect(r.calls).toBe('');+ }+ for (const value of ['', '0', 'false', 'off']) {+ expect(run(shell, 'timeout', 'ready', false, 'Darwin', { BROWSE_PUBLIC_ONLY: value }).output).toStartWith('READY: ');+ }+ });+ }+});diff --git a/test/fixtures/golden/agy-ship-SKILL.md b/test/fixtures/golden/agy-ship-SKILL.mdindex d02a28779..21069dbb7 100644--- a/test/fixtures/golden/agy-ship-SKILL.md+++ b/test/fixtures/golden/agy-ship-SKILL.md@@ -143,6 +143,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/test/fixtures/golden/claude-ship-SKILL.md b/test/fixtures/golden/claude-ship-SKILL.mdindex 5534912e0..5c82d052a 100644--- a/test/fixtures/golden/claude-ship-SKILL.md+++ b/test/fixtures/golden/claude-ship-SKILL.md@@ -148,6 +148,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/test/fixtures/golden/codex-ship-SKILL.md b/test/fixtures/golden/codex-ship-SKILL.mdindex 241501ec7..fe3202c4c 100644--- a/test/fixtures/golden/codex-ship-SKILL.md+++ b/test/fixtures/golden/codex-ship-SKILL.md@@ -141,6 +141,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/test/fixtures/golden/factory-ship-SKILL.md b/test/fixtures/golden/factory-ship-SKILL.mdindex ad29fcc69..88c304712 100644--- a/test/fixtures/golden/factory-ship-SKILL.md+++ b/test/fixtures/golden/factory-ship-SKILL.md@@ -143,6 +143,7 @@ Some steps require action on a site the user controls: registering an API key, c_A=aside; command -v aside >/dev/null || _A=$(command -v ~/.local/bin/aside)if [ "${GSTACK_SKIP_ASIDE:-}" = "1" ] || [ -z "$_A" ]; thenecho "NEEDS_ASIDE: ${GSTACK_PLATFORM:-$(uname)}"+ elif case ${BROWSE_PUBLIC_ONLY-} in ''|0|false|off) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"else_rc=0; _o=$(_gs_d "$_A" repl 'console.log("ASIDE_READY " + pwd)' 2>&1) || _rc=$?case "$_rc" indiff --git a/test/fixtures/skill-md-size-allowlist.json b/test/fixtures/skill-md-size-allowlist.jsonindex 7bb5ef8a8..eabae8056 100644--- a/test/fixtures/skill-md-size-allowlist.json+++ b/test/fixtures/skill-md-size-allowlist.json@@ -4,54 +4,54 @@"pins": {"agy/gstack-autoplan": 109163,"agy/gstack-plan-design-review": 109100,- "agy/gstack-plan-devex-review": 115130,- "agy/gstack-plan-eng-review": 143742,- "agy/gstack-review": 102773,+ "agy/gstack-plan-devex-review": 115242,+ "agy/gstack-plan-eng-review": 143854,+ "agy/gstack-review": 102885,"codex/gstack-autoplan": 107431,"codex/gstack-plan-design-review": 110375,- "codex/gstack-plan-devex-review": 114416,- "codex/gstack-plan-eng-review": 142685,- "codex/gstack-review": 104147,+ "codex/gstack-plan-devex-review": 114528,+ "codex/gstack-plan-eng-review": 142797,+ "codex/gstack-review": 104259,"copilot/gstack-autoplan": 108606,"copilot/gstack-plan-design-review": 109366,- "copilot/gstack-plan-devex-review": 114592,- "copilot/gstack-plan-eng-review": 143907,- "copilot/gstack-review": 102338,+ "copilot/gstack-plan-devex-review": 114704,+ "copilot/gstack-plan-eng-review": 144019,+ "copilot/gstack-review": 102450,"cursor/gstack-autoplan": 107838,"cursor/gstack-plan-design-review": 107908,- "cursor/gstack-plan-devex-review": 113862,- "cursor/gstack-plan-eng-review": 142497,- "cursor/gstack-review": 121041,+ "cursor/gstack-plan-devex-review": 113974,+ "cursor/gstack-plan-eng-review": 142609,+ "cursor/gstack-review": 121153,"factory/gstack-autoplan": 110116,"factory/gstack-plan-design-review": 111006,- "factory/gstack-plan-devex-review": 117225,- "factory/gstack-plan-eng-review": 145605,- "factory/gstack-review": 124810,+ "factory/gstack-plan-devex-review": 117337,+ "factory/gstack-plan-eng-review": 145717,+ "factory/gstack-review": 124922,"gbrain/gstack-autoplan": 108245,- "gbrain/gstack-plan-eng-review": 125054,+ "gbrain/gstack-plan-eng-review": 125166,"gemini/gstack-autoplan": 108396,"gemini/gstack-plan-design-review": 109194,- "gemini/gstack-plan-devex-review": 114420,- "gemini/gstack-plan-eng-review": 143740,- "gemini/gstack-review": 102164,+ "gemini/gstack-plan-devex-review": 114532,+ "gemini/gstack-plan-eng-review": 143852,+ "gemini/gstack-review": 102276,"hermes/gstack-autoplan": 108250,- "hermes/gstack-plan-eng-review": 125007,+ "hermes/gstack-plan-eng-review": 125119,"kiro/gstack-autoplan": 107612,"kiro/gstack-plan-design-review": 107754,- "kiro/gstack-plan-devex-review": 113714,- "kiro/gstack-plan-eng-review": 142359,- "kiro/gstack-review": 120873,+ "kiro/gstack-plan-devex-review": 113826,+ "kiro/gstack-plan-eng-review": 142471,+ "kiro/gstack-review": 120985,"openclaw/gstack-autoplan": 108068,- "openclaw/gstack-plan-eng-review": 123553,+ "openclaw/gstack-plan-eng-review": 123665,"opencode/gstack-autoplan": 108587,"opencode/gstack-plan-design-review": 109222,- "opencode/gstack-plan-devex-review": 114470,- "opencode/gstack-plan-eng-review": 143766,- "opencode/gstack-review": 121655,+ "opencode/gstack-plan-devex-review": 114582,+ "opencode/gstack-plan-eng-review": 143878,+ "opencode/gstack-review": 121767,"slate/gstack-autoplan": 107725,"slate/gstack-plan-design-review": 107831,- "slate/gstack-plan-devex-review": 113788,- "slate/gstack-plan-eng-review": 142428,- "slate/gstack-review": 120957+ "slate/gstack-plan-devex-review": 113900,+ "slate/gstack-plan-eng-review": 142540,+ "slate/gstack-review": 121069}}diff --git a/test/helpers/carve-guards.ts b/test/helpers/carve-guards.tsindex 2db26b6a6..31095c7d8 100644--- a/test/helpers/carve-guards.ts+++ b/test/helpers/carve-guards.ts@@ -160,7 +160,7 @@ export const CARVE_GUARDS: Record<string, CarveGuard> = {},behavioral: 'external',externalTest: 'test/skill-e2e-ship-section-loading.test.ts',- maxSkeletonBytes: 61_949, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 61_936. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 61_844. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 61_467. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is), and /ship's list drops "deploy this", which belongs to /land-and-deploy; measured 61,467 (before: 61,438 on a141e94). Before that: GST-2726 (2026-11-15, Garry: bring /plan-eng-review back): Step 1's DIFF hint and the no-Eng-Review line name /plan-eng-review again, the wording GST-1698 removed; measured 61,438 (before: 61,417 on 81fb900). Before that: GSTA-152 token cap (2026-10-29, Garry's "Do it" on plan v3): the skeleton's Budget paragraph (the --token-cap, --resume and --continue flags, start/check/close, the budget-handoff pointer) and the section index's budget-handoff line; measured 61,420 (before: 60,958 on edf4c2e). Before that: GSTA-131 token efficiency (2026-10-27, Garry's D1): Step 1's delta carry (dry run, pregate at HEAD, then carry --pregate) and Step 11.5's fix-check and planned-skip binding, +60 bytes after tightening Step 1 and the Review policy paragraph; measured 60,960 (before: 60,900 on 10b77de4). Before that: GSTA-96 hoist merged with GSTA-92 phase 2 (2026-10-26): the hoisted skeleton (59,706) plus this PR's growth, keeping the hoist's 65-byte headroom; measured 60,848. Before: + v2.0 {{ASIDE_RESEARCH}} (Aside first, WebSearch fallback); measured 78_275. + gate integrity (HONEST_WORK_GATE_INTEGRITY W3): Step 16 stage 4 ZERO-RUN/unknown receipt rows, stage 5 honesty inventory, Step 17 open-gate ready-PR gate; measured 80,540 (2026-10-10). + rule 22 / GBRA-108 (2026-10-25): Step 22's terminal line (gstack-ship-receipt result, the GSTACK_RESULT line a parent greps) and Step 18's unattended routing (an open PR at HEAD gets its body updated, else handoff), offset in part by tightening Steps 14, 16, 18 and 20 prose after the 2026-10-14 tightening left 2 bytes of headroom; measured 81,535. + harness lane E (2026-10-26, issue row 3: four Captains re-ran /ship on identical product code): Step 1's carry check (gstack-ship-receipt carry binds an earlier receipt to HEAD when the product patch-id is unchanged); measured 82,165. + the Review policy paragraph (the blocking floor, pass structure and cap, NO FINDINGS, the review_loop receipt counters, the review_scope knob), stated in the skeleton because gstack is the canonical holder of its review policy (docs/review-policy.md); measured 82,645.+ maxSkeletonBytes: 62_028, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 61_949. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 61_936. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 61_844. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 61_467. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is), and /ship's list drops "deploy this", which belongs to /land-and-deploy; measured 61,467 (before: 61,438 on a141e94). Before that: GST-2726 (2026-11-15, Garry: bring /plan-eng-review back): Step 1's DIFF hint and the no-Eng-Review line name /plan-eng-review again, the wording GST-1698 removed; measured 61,438 (before: 61,417 on 81fb900). Before that: GSTA-152 token cap (2026-10-29, Garry's "Do it" on plan v3): the skeleton's Budget paragraph (the --token-cap, --resume and --continue flags, start/check/close, the budget-handoff pointer) and the section index's budget-handoff line; measured 61,420 (before: 60,958 on edf4c2e). Before that: GSTA-131 token efficiency (2026-10-27, Garry's D1): Step 1's delta carry (dry run, pregate at HEAD, then carry --pregate) and Step 11.5's fix-check and planned-skip binding, +60 bytes after tightening Step 1 and the Review policy paragraph; measured 60,960 (before: 60,900 on 10b77de4). Before that: GSTA-96 hoist merged with GSTA-92 phase 2 (2026-10-26): the hoisted skeleton (59,706) plus this PR's growth, keeping the hoist's 65-byte headroom; measured 60,848. Before: + v2.0 {{ASIDE_RESEARCH}} (Aside first, WebSearch fallback); measured 78_275. + gate integrity (HONEST_WORK_GATE_INTEGRITY W3): Step 16 stage 4 ZERO-RUN/unknown receipt rows, stage 5 honesty inventory, Step 17 open-gate ready-PR gate; measured 80,540 (2026-10-10). + rule 22 / GBRA-108 (2026-10-25): Step 22's terminal line (gstack-ship-receipt result, the GSTACK_RESULT line a parent greps) and Step 18's unattended routing (an open PR at HEAD gets its body updated, else handoff), offset in part by tightening Steps 14, 16, 18 and 20 prose after the 2026-10-14 tightening left 2 bytes of headroom; measured 81,535. + harness lane E (2026-10-26, issue row 3: four Captains re-ran /ship on identical product code): Step 1's carry check (gstack-ship-receipt carry binds an earlier receipt to HEAD when the product patch-id is unchanged); measured 82,165. + the Review policy paragraph (the blocking floor, pass structure and cap, NO FINDINGS, the review_loop receipt counters, the review_scope knob), stated in the skeleton because gstack is the canonical holder of its review policy (docs/review-policy.md); measured 82,645.minUnionBytes: 181_000, // token-reduction Phases 1-2 (v1.69.x branch); measured union 201,464mustContain: ['VERSION', 'CHANGELOG', 'review', 'merge', 'PR'],// v1.58.5.0: pre-push-guard install (#2077) stacks on the shared first-run-guidance preamble.@@ -191,12 +191,12 @@ export const CARVE_GUARDS: Record<string, CarveGuard> = {// v1.65 merge: provisional larger-of-both-waves budget; re-measured below.// Fork port wave 2 (#703): the repo-doc-preference block in the design// check grew every plan-review skeleton ~0.7KB. Measured values noted.- maxSkeletonBytes: 61_146, // GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 61_056. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 60_712. GSTA-96 hoist (2026-10-26): lowered from 81_000 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 273 bytes; measured 60,439. Before: + depth-specific output and 0H/0I feasibility boundary clarity + the Aside probe's failure reason; measured 80,111. + W1 guarded state-root resolution (`eval gstack-paths; : "${GSTACK_STATE_ROOT:?…}"`) in the Context Recovery preamble, the eureka log and each state-writing bash block; measured 80,649 (2026-09-30); + the same guard in the CEO spec-review metrics block; measured 80,812 (2026-09-30). + Oct 10 multi-agent wave PR D1 (reality rows): the 0A/0B reality-rows block (bin command, tier 1 row ids, the REALITY: line grammar, the unattended rule); measured skeleton 80,916 (2026-10-10).+ maxSkeletonBytes: 61_239, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 61_146. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 61_056. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 60_712. GSTA-96 hoist (2026-10-26): lowered from 81_000 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 273 bytes; measured 60,439. Before: + depth-specific output and 0H/0I feasibility boundary clarity + the Aside probe's failure reason; measured 80,111. + W1 guarded state-root resolution (`eval gstack-paths; : "${GSTACK_STATE_ROOT:?…}"`) in the Context Recovery preamble, the eureka log and each state-writing bash block; measured 80,649 (2026-09-30); + the same guard in the CEO spec-review metrics block; measured 80,812 (2026-09-30). + Oct 10 multi-agent wave PR D1 (reality rows): the 0A/0B reality-rows block (bin command, tier 1 row ids, the REALITY: line grammar, the unattended rule); measured skeleton 80,916 (2026-10-10).minUnionBytes: 123_600, // token-reduction Phases 1-2 (v1.69.x branch): preamble bash -> bin/gstack-skill-start, onboarding -> gated emission; measured union 137,346mustContain: ['SCOPE EXPANSION', 'SELECTIVE EXPANSION', 'HOLD SCOPE', 'SCOPE REDUCTION'],// Default-on Codex outside-voice (codexPreflight block + CODEX_MODE branch// prose replacing the smaller opt-in question) lands this ~5.2% over baseline.- maxSizeRatio: 1.1020, // GSTA-812 (2026-11-22, Captain GStack Minder ruling A, extended to every skill carrying the shared boundary): #3924, the shared second-model boundary reads the repo agents/ folder, +90 bytes; was 1.1014. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.1008. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.1006. + the Aside probe's failure reason; measured 1.0803 + Oct 10 multi-agent wave PR D1 (reality rows): 0A/0B block in the skeleton, the Reality rows required output, the Completion Summary row and the checklist row; measured 165,042 / 151,747 = 1.0876 (2026-10-10). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 166,899 / 151,747 = 1.0999 (2026-10-25). + GSTA-96 completeness rewording (#3425, Garry 2026-10-25: "1/ yes fix this") merged into the hoist (#3434): the COMPLETENESS IS COVERAGE bullet replaces COMPLETENESS IS CHEAP, +106 bytes under the same "do it" (parity caps to measured size); measured 167,012 / 151,747 = 1.1006 (2026-10-26). Before: 1.088.+ maxSizeRatio: 1.1026, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 1.1020. Before that: GSTA-812 (2026-11-22, Captain GStack Minder ruling A, extended to every skill carrying the shared boundary): #3924, the shared second-model boundary reads the repo agents/ folder, +90 bytes; was 1.1014. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.1008. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.1006. + the Aside probe's failure reason; measured 1.0803 + Oct 10 multi-agent wave PR D1 (reality rows): 0A/0B block in the skeleton, the Reality rows required output, the Completion Summary row and the checklist row; measured 165,042 / 151,747 = 1.0876 (2026-10-10). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 166,899 / 151,747 = 1.0999 (2026-10-25). + GSTA-96 completeness rewording (#3425, Garry 2026-10-25: "1/ yes fix this") merged into the hoist (#3434): the COMPLETENESS IS COVERAGE bullet replaces COMPLETENESS IS CHEAP, +106 bytes under the same "do it" (parity caps to measured size); measured 167,012 / 151,747 = 1.1006 (2026-10-26). Before: 1.088.},'plan-eng-review': {skill: 'plan-eng-review',@@ -279,7 +279,7 @@ export const CARVE_GUARDS: Record<string, CarveGuard> = {mustContain: ['developer experience', 'Getting Started'],// Default-on Codex outside-voice (codexPreflight block + CODEX_MODE branch// prose replacing the smaller opt-in question) lands this ~5.7% over baseline.- maxSizeRatio: 1.0913, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.0912. Before that: GSTA-812 (2026-11-22, Captain GStack Minder ruling A, extended to every skill carrying the shared boundary): #3924, the shared second-model boundary reads the repo agents/ folder, +90 bytes; was 1.0911. Before that: + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 136,646 / 125,243 = 1.0910 (2026-10-25). Before: 1.08.+ maxSizeRatio: 1.0922, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 1.0913. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.0912. Before that: GSTA-812 (2026-11-22, Captain GStack Minder ruling A, extended to every skill carrying the shared boundary): #3924, the shared second-model boundary reads the repo agents/ folder, +90 bytes; was 1.0911. Before that: + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 136,646 / 125,243 = 1.0910 (2026-10-25). Before: 1.08.},'office-hours': {skill: 'office-hours',@@ -357,10 +357,10 @@ do not launch the downstream skill or open a browser.`,// the #538 opt-out + D1 evidence directive — ratio 1.104 measured.// #2499 project-scope MCP jq in the brain-sync block grew every tier-2+// skeleton ~1.5KB (entry resolution emitted once per SKILL.md).- maxSkeletonBytes: 44_452, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 44_445. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 44_326. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 43_937. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 43,937 (before: 43,885 on a141e94). Before that: GSTA-134 skill diet (2026-10-28): lowered from 80_533 to the measured skeleton after the second opinion and visual design moved to sections, 43,885. Before: GSTA-96 hoist (2026-10-26): lowered from 95_900 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 952 bytes; measured 79,581. Before: Office-hours + sketch outside voices include host guards and completion checks. + v1.91.19.0 wave: Q<N> open-question prose form (#2729, approved Q3), DESIGN_READY --version probe (B4), Aside ~/.local/bin fallback (E7), verdict-form outside voice (INV-1), plus v1.91.17.0's round accounting (#3022) merged in; measured 89,684 (2026-10-03). + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); skeleton measured 92,590 (2026-10-06). + Oct 7 wave B3: the Codex probe runs as a command (select-model capture lines, check-sandbox/probe-model/run-with-timeout subcommands) instead of being sourced; skeleton measured 92,869 (2026-10-07). + Oct 7 wave CEO-28/DX-11: review prompts ask for a severity per finding and design proposals use the proposal gate; skeleton measured 92,930 (2026-10-07). + Oct 7 wave guard (CEO-20): conditional `run_in_background` request plus the background-run recovery at each foreground dispatch site; skeleton measured 92,756 (2026-10-07). Merged with the guard area: measured skeleton 93,099 (2026-10-07). + fix wave PR D: the Phase 4.5 builder-profile read before the session log (#2801) and the pre-telemetry design-doc check (#1049); measured skeleton 94,877 (2026-10-07). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10).+ maxSkeletonBytes: 44_681, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 44_452. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 44_445. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 44_326. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 43_937. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 43,937 (before: 43,885 on a141e94). Before that: GSTA-134 skill diet (2026-10-28): lowered from 80_533 to the measured skeleton after the second opinion and visual design moved to sections, 43,885. Before: GSTA-96 hoist (2026-10-26): lowered from 95_900 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 952 bytes; measured 79,581. Before: Office-hours + sketch outside voices include host guards and completion checks. + v1.91.19.0 wave: Q<N> open-question prose form (#2729, approved Q3), DESIGN_READY --version probe (B4), Aside ~/.local/bin fallback (E7), verdict-form outside voice (INV-1), plus v1.91.17.0's round accounting (#3022) merged in; measured 89,684 (2026-10-03). + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); skeleton measured 92,590 (2026-10-06). + Oct 7 wave B3: the Codex probe runs as a command (select-model capture lines, check-sandbox/probe-model/run-with-timeout subcommands) instead of being sourced; skeleton measured 92,869 (2026-10-07). + Oct 7 wave CEO-28/DX-11: review prompts ask for a severity per finding and design proposals use the proposal gate; skeleton measured 92,930 (2026-10-07). + Oct 7 wave guard (CEO-20): conditional `run_in_background` request plus the background-run recovery at each foreground dispatch site; skeleton measured 92,756 (2026-10-07). Merged with the guard area: measured skeleton 93,099 (2026-10-07). + fix wave PR D: the Phase 4.5 builder-profile read before the session log (#2801) and the pre-telemetry design-doc check (#1049); measured skeleton 94,877 (2026-10-07). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10).minUnionBytes: 115_800, // Phase 4 wave 4; measured union 118,175mustContain: ['design doc', 'problem statement'],- maxSizeRatio: 1.2166, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.2164. Before that: GSTA-812 (2026-11-22, Captain GStack Minder ruling A, extended to every skill carrying the shared boundary): #3924, the shared second-model boundary reads the repo agents/ folder, +90 bytes; was 1.2157. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.2149. Before that: GST-3024 (2026-11-17, Garry's "do it" to U1 via GStack Minder GSTA-36): /office-hours reality check, memo route, pivot and discovery section, kill-date follow-up after #4463 moved 8,590 bytes of founder resources out; measured 159,274 bytes against the 157,240-byte cap, 159,274 / 131,110 = 1.21481, rounded up (before: 1.1993). Before that: GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 157,236 / 131,110 = 1.19927, rounded up (before: 1.1990). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.1990 (before: 1.1968). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.1968 (before: 1.1922). Before that: GST-2726 (2026-11-15, Garry: bring /plan-eng-review back): the handoff menu, its default and the design-doc line name /plan-eng-review again, +42 B union; measured 156,298 / 131,110 = 1.19211, rounded up (before: 156,256 = 1.19179 on 81fb900). Before that: GSTA-134 (2026-10-28, raised from 1.1796 by GStack Minder as merge-queue owner): +1,662 B union: second-opinion question moved into the main file while CODEX_SECOND_OPINION keeps its copy; per-run load 73,248→43,885 B; measured 156,286 / 131,110 = 1.19202, rounded up. Before: + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); measured 149,758 / 131,110 = 1.1422 (2026-10-06). + Oct 7 wave B3: the Codex probe runs as a command (select-model capture lines, check-sandbox/probe-model/run-with-timeout subcommands) instead of being sourced; measured 150,037 / 131,110 = 1.1444 (2026-10-07). + Oct 7 wave CEO-28/DX-11: review prompts ask for a severity per finding and design proposals use the proposal gate; measured 150,098 / 131,110 = 1.1448 (2026-10-07). + Oct 7 wave guard (CEO-20): conditional `run_in_background` request plus the background-run recovery at each foreground dispatch site; measured 150,011 / 131,110 = 1.1442 (2026-10-07). Merged with the guard area: measured 150,354 / 131,110 = 1.1468 (2026-10-07). + fix wave PR D: builder-profile read before the session log with Phase 6 using the carried values (#2801), the inline design doc before approval (#879) and the pre-telemetry design-doc check (#1049); measured 153,206 / 131,110 = 1.1685 (2026-10-07). + empty LAST_ASSIGNMENT/LAST_PROJECT guards in the welcome_back and regular greetings (backfilled profiles); measured 153,469 / 131,110 = 1.1705 (2026-10-08). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file and its own copies of shared sections; measured 160,989 / 131,110 = 1.2279 (2026-10-25). Before: 1.18. - GSTA-96 dedupe: the Q<N> open-question form is office-hours' own appended subsection, so its copies of the shared Format and fallback subsections go; measured 154,653 / 131,110 = 1.1796 (2026-10-26), 154,624 = 1.1793 after the main merge. Before: 1.2279.+ maxSizeRatio: 1.2183, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 1.2166. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.2164. Before that: GSTA-812 (2026-11-22, Captain GStack Minder ruling A, extended to every skill carrying the shared boundary): #3924, the shared second-model boundary reads the repo agents/ folder, +90 bytes; was 1.2157. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.2149. Before that: GST-3024 (2026-11-17, Garry's "do it" to U1 via GStack Minder GSTA-36): /office-hours reality check, memo route, pivot and discovery section, kill-date follow-up after #4463 moved 8,590 bytes of founder resources out; measured 159,274 bytes against the 157,240-byte cap, 159,274 / 131,110 = 1.21481, rounded up (before: 1.1993). Before that: GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 157,236 / 131,110 = 1.19927, rounded up (before: 1.1990). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.1990 (before: 1.1968). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.1968 (before: 1.1922). Before that: GST-2726 (2026-11-15, Garry: bring /plan-eng-review back): the handoff menu, its default and the design-doc line name /plan-eng-review again, +42 B union; measured 156,298 / 131,110 = 1.19211, rounded up (before: 156,256 = 1.19179 on 81fb900). Before that: GSTA-134 (2026-10-28, raised from 1.1796 by GStack Minder as merge-queue owner): +1,662 B union: second-opinion question moved into the main file while CODEX_SECOND_OPINION keeps its copy; per-run load 73,248→43,885 B; measured 156,286 / 131,110 = 1.19202, rounded up. Before: + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); measured 149,758 / 131,110 = 1.1422 (2026-10-06). + Oct 7 wave B3: the Codex probe runs as a command (select-model capture lines, check-sandbox/probe-model/run-with-timeout subcommands) instead of being sourced; measured 150,037 / 131,110 = 1.1444 (2026-10-07). + Oct 7 wave CEO-28/DX-11: review prompts ask for a severity per finding and design proposals use the proposal gate; measured 150,098 / 131,110 = 1.1448 (2026-10-07). + Oct 7 wave guard (CEO-20): conditional `run_in_background` request plus the background-run recovery at each foreground dispatch site; measured 150,011 / 131,110 = 1.1442 (2026-10-07). Merged with the guard area: measured 150,354 / 131,110 = 1.1468 (2026-10-07). + fix wave PR D: builder-profile read before the session log with Phase 6 using the carried values (#2801), the inline design doc before approval (#879) and the pre-telemetry design-doc check (#1049); measured 153,206 / 131,110 = 1.1685 (2026-10-07). + empty LAST_ASSIGNMENT/LAST_PROJECT guards in the welcome_back and regular greetings (backfilled profiles); measured 153,469 / 131,110 = 1.1705 (2026-10-08). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file and its own copies of shared sections; measured 160,989 / 131,110 = 1.2279 (2026-10-25). Before: 1.18. - GSTA-96 dedupe: the Q<N> open-question form is office-hours' own appended subsection, so its copies of the shared Format and fallback subsections go; measured 154,653 / 131,110 = 1.1796 (2026-10-26), 154,624 = 1.1793 after the main merge. Before: 1.2279.},'document-release': {skill: 'document-release',@@ -420,7 +420,7 @@ do not launch the downstream skill or open a browser.`,// eureka log, the office-hours lookup and the taste-profile read; measured// 1.0834 (2026-09-30). + named design-direction defaults to avoid in the native// subagent prompt (s02 H4a); measured 1.0911 (2026-10-02).- maxSizeRatio: 1.1776, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.1774. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.1763. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.1719. GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.1719 (before: 1.1688). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.1688 (before: 1.1623). Before that: + v1.91.19.0 wave: design --version probe (B4), taste-profile load (F3), verdict-form outside voice (INV-1), plus v1.91.17.0's round accounting and board/approval blocks (#3022) merged in; measured 100,446 / 90,375 = 1.1114 (2026-10-03). + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); measured 103,384 / 90,375 = 1.1439 (2026-10-06). + Oct 7 wave B6: Aside rules 1, 4, 6 and 7 (offer a target-origin tab before openTab, a second sign-in wall means a tab- or URL-bound session, no early-return hint, fast [ok without the sentinel is an abort); measured 103,576 / 90,375 = 1.1461 (2026-10-07). + Oct 7 wave B3: the Codex probe runs as a command (select-model capture lines, check-sandbox/probe-model/run-with-timeout subcommands) instead of being sourced; measured 103,522 / 90,375 = 1.1455 (2026-10-07). Both merged: measured 103,726 / 90,375 = 1.1477 (2026-10-07). + Oct 7 wave guard (CEO-20): conditional `run_in_background` request plus the background-run recovery at each foreground dispatch site; measured 103,466 / 90,375 = 1.1449 (2026-10-07). Merged with the guard area: measured 103,804 / 90,375 = 1.1486 (2026-10-07). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 105,039 / 90,375 = 1.1623 (2026-10-25). Before: 1.16.+ maxSizeRatio: 1.1781, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 1.1776. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.1774. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.1763. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.1719. GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.1719 (before: 1.1688). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.1688 (before: 1.1623). Before that: + v1.91.19.0 wave: design --version probe (B4), taste-profile load (F3), verdict-form outside voice (INV-1), plus v1.91.17.0's round accounting and board/approval blocks (#3022) merged in; measured 100,446 / 90,375 = 1.1114 (2026-10-03). + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); measured 103,384 / 90,375 = 1.1439 (2026-10-06). + Oct 7 wave B6: Aside rules 1, 4, 6 and 7 (offer a target-origin tab before openTab, a second sign-in wall means a tab- or URL-bound session, no early-return hint, fast [ok without the sentinel is an abort); measured 103,576 / 90,375 = 1.1461 (2026-10-07). + Oct 7 wave B3: the Codex probe runs as a command (select-model capture lines, check-sandbox/probe-model/run-with-timeout subcommands) instead of being sourced; measured 103,522 / 90,375 = 1.1455 (2026-10-07). Both merged: measured 103,726 / 90,375 = 1.1477 (2026-10-07). + Oct 7 wave guard (CEO-20): conditional `run_in_background` request plus the background-run recovery at each foreground dispatch site; measured 103,466 / 90,375 = 1.1449 (2026-10-07). Merged with the guard area: measured 103,804 / 90,375 = 1.1486 (2026-10-07). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 105,039 / 90,375 = 1.1623 (2026-10-25). Before: 1.16.},// ── Token-reduction Phase 4 wave 1 (v1.69.x branch) ──────────────────────review: {@@ -450,7 +450,7 @@ do not launch the downstream skill or open a browser.`,gateAfterStop: undefined, // operational multi-STOP skill, like ship},behavioral: 'plan',- maxSkeletonBytes: 60_679, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 60_644. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 60_558. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 60_176. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 60,176 (before: 60,070 on a141e94). Before that: GST-1088 lane B follow-up (raised from 60,014 to measured, no headroom): the Done-means check/waive commands run through the host-resolved bin path (~/.claude/skills/gstack/bin/gstack-skill-contract) instead of a bare gstack-skill-contract that a standard install doesn't put on PATH (fix-check finding on #3909 at 58aeee7), +56 bytes; measured 60,070. Before: GST-1088 lane B (#3909, raised from 59,774 to measured, no headroom; owner ruling via GStack Minder 2026-11-03): CONTRACT_CHECKER_SHIPPED=true now that bin/gstack-skill-contract ships (#3912) renders the gstack-skill-contract check/waive sentence under the Done means list (renders/GSTA-256/plan-v3.md line 74, r2-d6 "Done-means list"), +240 bytes; lane C's diet is expected to bring /review back under 59,073; measured 60,014. Before: GST-1088 lane B (raised from 59,073 to measured, no headroom): the contract: frontmatter block and the F1 "Done means" list rendered from it at the top of the body, plus widened triggers; F1 is a gate-rev-2 recommendation on the plan Garry approved with "do it" on gate rev 1 (2026-11-03), contingent on his gate-rev-2 answer, and lane C's diet is expected to bring /review back under 59,073; measured 59,774. Before: GSTA-96 hoist (2026-10-26): lowered from 80_900 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 319 bytes; measured 58,754. Before: Shared-code identity/skip/action rules + critical-severity validation; measured 74,493 (2026-09-17). + v1.91.12.0 merge of #2999 (review clarity repairs: await reads, research alongside dispatch, /review deadline and setup authority, findings sources) with #3002 (guarded state-root lines, plan-check checkpoints); each fit alone; measured 74,881 (2026-10-01). + Oct 8 wave: shared voice directive bans "load-bearing" and adds the reply-language rule, offset by tightening the bounded closer (net +17 bytes per tier-2+ skill); measured 74,884 (2026-10-08). + gate integrity (HONEST_WORK_GATE_INTEGRITY W2): Step 3.5 Diff scans with the shared GATE_SCAN_BLOCK, the Step 4 carry, the four-option `review-gate-disposition` question in 5c, gate record fields in 5.8 and the Gate edits report line; measured 80,054 (2026-10-10). + Oct 10 multi-agent wave PR D2 (sideways review): Step 4's enum-only paragraph becomes the sideways sweep with the forced-CRITICAL list, plus the flake-fix number sentence in the Gate Integrity paragraph; measured skeleton 80,812 (2026-10-10).+ maxSkeletonBytes: 60_789, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 60_679. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 60_644. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 60_558. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 60_176. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 60,176 (before: 60,070 on a141e94). Before that: GST-1088 lane B follow-up (raised from 60,014 to measured, no headroom): the Done-means check/waive commands run through the host-resolved bin path (~/.claude/skills/gstack/bin/gstack-skill-contract) instead of a bare gstack-skill-contract that a standard install doesn't put on PATH (fix-check finding on #3909 at 58aeee7), +56 bytes; measured 60,070. Before: GST-1088 lane B (#3909, raised from 59,774 to measured, no headroom; owner ruling via GStack Minder 2026-11-03): CONTRACT_CHECKER_SHIPPED=true now that bin/gstack-skill-contract ships (#3912) renders the gstack-skill-contract check/waive sentence under the Done means list (renders/GSTA-256/plan-v3.md line 74, r2-d6 "Done-means list"), +240 bytes; lane C's diet is expected to bring /review back under 59,073; measured 60,014. Before: GST-1088 lane B (raised from 59,073 to measured, no headroom): the contract: frontmatter block and the F1 "Done means" list rendered from it at the top of the body, plus widened triggers; F1 is a gate-rev-2 recommendation on the plan Garry approved with "do it" on gate rev 1 (2026-11-03), contingent on his gate-rev-2 answer, and lane C's diet is expected to bring /review back under 59,073; measured 59,774. Before: GSTA-96 hoist (2026-10-26): lowered from 80_900 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 319 bytes; measured 58,754. Before: Shared-code identity/skip/action rules + critical-severity validation; measured 74,493 (2026-09-17). + v1.91.12.0 merge of #2999 (review clarity repairs: await reads, research alongside dispatch, /review deadline and setup authority, findings sources) with #3002 (guarded state-root lines, plan-check checkpoints); each fit alone; measured 74,881 (2026-10-01). + Oct 8 wave: shared voice directive bans "load-bearing" and adds the reply-language rule, offset by tightening the bounded closer (net +17 bytes per tier-2+ skill); measured 74,884 (2026-10-08). + gate integrity (HONEST_WORK_GATE_INTEGRITY W2): Step 3.5 Diff scans with the shared GATE_SCAN_BLOCK, the Step 4 carry, the four-option `review-gate-disposition` question in 5c, gate record fields in 5.8 and the Gate edits report line; measured 80,054 (2026-10-10). + Oct 10 multi-agent wave PR D2 (sideways review): Step 4's enum-only paragraph becomes the sideways sweep with the forced-CRITICAL list, plus the flake-fix number sentence in the Gate Integrity paragraph; measured skeleton 80,812 (2026-10-10).minUnionBytes: 89_000, // Phase 4 wave 1; measured union 93,357mustContain: ['confidence', 'P1', 'P2', 'Review Army', 'adversarial'],maxSizeRatio: 1.3434, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.3429. Before that: GSTA-812 (2026-11-22, Captain GStack Minder ruling A): #3924, the shared second-model boundary reads the repo agents/ folder, +90 bytes in sections/adversarial.md; was 1.3421. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.3413. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.3378. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 145,176 / 108,523 = 1.33774, rounded up (before: 1.3369). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.3369 (before: 1.3343). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.3343 (before: 1.3288). Before that: + GST-1088 lane B follow-up (raised from 1.3283 to measured, no headroom): the Done-means check/waive commands run through the host-resolved bin path instead of a bare gstack-skill-contract that isn't on PATH (fix-check finding on #3909 at 58aeee7), +56 bytes; measured 144,203 / 108,523 = 1.328778, rounded up. Before: + GST-1088 lane B (#3909, raised from 1.3261 to measured, no headroom; owner ruling via GStack Minder 2026-11-03): the gstack-skill-contract check/waive sentence that CONTRACT_CHECKER_SHIPPED=true renders (renders/GSTA-256/plan-v3.md line 74, r2-d6 "Done-means list"), +240 bytes; lane C's diet is expected to bring /review back under 1.3180; measured 144,147 / 108,523 = 1.32826, rounded up. Before: + GST-1088 lane B (raised from 1.3180 to measured, no headroom): the contract: frontmatter block and the F1 "Done means" list, contingent on Garry's gate-rev-2 answer; lane C's diet is expected to bring /review back under 1.3180; measured 143,907 / 108,523 = 1.3261. Before: + GSTA-167 variant G part 1 (plan approved by Garry 2026-10-30, autoplan-20261030161754 "Do it", which names about +0.3k prompt tokens per voice): the native adversarial and outside-voice prompts carry the blocking floor and the Severity and Blocks lines, +537 bytes; measured 1.3180 (2026-10-30). Before: 1.3136. GSTA-96 hoist merged with GSTA-92 phase 2 (2026-10-26): both owner-approved raises together, measured 142,550 / 108,523 = 1.3135. Before: Shared-code feature + critical-severity validation: 128,042 union bytes / 108,523 baseline = 1.1799; preserves content floors. + v1.91.12.0 merge of #2999 (above, plus plan-completion fallback intent and specialist checklist-by-path) with #3002; measured 1.1843 (2026-10-01). + v1.91.19.0 wave: verdict-form Codex callers with sandbox preflight (INV-1/B1), P0/P1 structured gate (B1b), bound-plan discovery and data-not-instructions guard (F1/D3), visible LEARNINGS failures (B5); measured 129,941 / 108,523 = 1.1974 (2026-10-03). + v1.91.18.0 (#3023) merged into the v1.91.19.0 wave; measured 130,025 / 108,523 = 1.1981 (2026-10-04). + Oct 6 fix wave: quota_exhausted preflight branch (#3051); measured 130,359 / 108,523 = 1.2012 (2026-10-06). + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); measured 131,314 / 108,523 = 1.2100 (2026-10-06). Combined Oct 6 wave head (A and B): measured 131,966 / 108,523 = 1.2160 (2026-10-06). + Oct 7 wave B3: the Codex probe runs as a command (select-model capture lines, check-sandbox/probe-model/run-with-timeout subcommands) instead of being sourced; measured 132,199 / 108,523 = 1.2182 (2026-10-07). + Oct 7 wave CEO-28/DX-11: review prompts ask for a severity per finding and design proposals use the proposal gate; measured 132,258 / 108,523 = 1.2187 (2026-10-07). + Oct 7 wave guard (CEO-20): conditional `run_in_background` request plus the background-run recovery at each foreground dispatch site; measured 132,233 / 108,523 = 1.2185 (2026-10-07). Merged with the guard area: measured 132,522 / 108,523 = 1.2211 (2026-10-07). + Oct 8 wave: the defensive-security framing and fixture summary mode reach the security specialist and the Red Team (stated once in the dispatch, referenced by the Red Team); measured 133,902 / 108,523 = 1.2339 (2026-10-08). + gate integrity W2 (above); measured 1.282 (2026-10-10). + Oct 10 multi-agent wave PR D2 (sideways review): sideways sweep and flake-fix number in Step 4; `Diff read` and `Undeclared behavior changes` in the review-mode Scope Check (plan-completion section); measured 140,497 / 108,523 = 1.2946 (2026-10-10). + harness lane E (2026-10-26): the lead-judgment stage in the finding merge and the `cause` anchor in the specialist prompts, shared with /ship through scripts/resolvers/review-army.ts; measured 141,949 / 108,523 = 1.3080.@@ -572,7 +572,7 @@ do not launch the downstream skill or open a browser.`,behavioral: 'prompt',maxSkeletonBytes: 36_571, // GSTA-96 hoist (2026-10-26): lowered from 58_400 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 1,606 bytes; measured 34,965. Before: + v2.0 {{ASIDE_RESEARCH}} (Aside first, WebSearch fallback); measured 57_356minUnionBytes: 64_500, // measured union 67,430- maxSizeRatio: 1.0943, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.0934. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.0907. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.0860. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 88,590 / 81,577 = 1.08597, rounded up (before: 1.0853). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.0853 (before: 1.0819). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.0819 (before: 1.0746). Before that: Oct 10 multi-agent wave PR E2: the lazy gate-and-file section renders {{COORDINATOR_CONTRACT}} (the block every spawned lane inherits word for word; `gstack-autoplan contract` prints the same bytes) before the --execute spawn pipe; measured 86,614 / 81,577 = 1.0617 after the contract became a fail-closed `CONTRACT=$(…)` capture (2026-10-10). The skeleton is unchanged (57,107). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 87,656 / 81,577 = 1.0745 (2026-10-25). Before: 1.07.+ maxSizeRatio: 1.0956, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 1.0943. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.0934. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.0907. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.0860. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 88,590 / 81,577 = 1.08597, rounded up (before: 1.0853). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.0853 (before: 1.0819). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.0819 (before: 1.0746). Before that: Oct 10 multi-agent wave PR E2: the lazy gate-and-file section renders {{COORDINATOR_CONTRACT}} (the block every spawned lane inherits word for word; `gstack-autoplan contract` prints the same bytes) before the --execute spawn pipe; measured 86,614 / 81,577 = 1.0617 after the contract became a fail-closed `CONTRACT=$(…)` capture (2026-10-10). The skeleton is unchanged (57,107). + GSTA-96 shared-preamble hoist (owner-approved raise, Garry 2026-10-25: "do it"): the union now holds sections/preamble.md, so a fresh invocation reads the pointer plus the shared file; measured 87,656 / 81,577 = 1.0745 (2026-10-25). Before: 1.07.mustContain: ['HARD GATE', 'dedupe', 'quality gate', 'acceptance criteria', 'archive'],},'setup-gbrain': {@@ -637,7 +637,7 @@ do not launch the downstream skill or open a browser.`,},behavioral: 'prompt',maxSkeletonBytes: 41_669, // GSTA-96 hoist (2026-10-26): lowered from 63_500 by the shared preamble that moved to sections/preamble.md, keeping the pre-hoist headroom of 12,415 bytes; measured 29,254. Before: + v2.0 {{ASIDE_SETUP}}/{{BROWSE_FALLBACK}} (replaces the browse setup block); measured 61_253- maxSizeRatio: 1.1598, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.1588. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.1577. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.1533. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 96,928 / 84,049 = 1.15323, rounded up (before: 1.1526). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.1526 (before: 1.1493). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.1493 (before: 1.1420). Before that: + v1.81 Aside contract + gstack-browser fallback block (1.080 on v1.91.7.0) + the shared test value bar at 8a.5 ({{TEST_VALUE_BAR:qa}}); measured 1.094 + W1 guarded state-root resolution (`eval gstack-paths; : "${GSTACK_STATE_ROOT:?…}"`) in the Context Recovery preamble, the eureka log and each state-writing bash block; measured 1.101 (2026-09-30) + v1.91.12.0 merge of #2999 (await scope/method Reads, capture --after checkpoints, browser-only empty evidence list) with #3002; measured 1.1028 (2026-10-01). + both untrusted-content marker formats in the browser fallback (W7f); measured 1.1035 (2026-10-02). Re-measured 1.1038 after the W8 probe-loop renames (2026-10-03); the cap already matches. + the annotate-every-capture and superseded rule before materialize (a ship-exploratory-late-input run published evidence that omitted older-snapshot captures); measured 1.1064 (2026-10-03). + v1.91.18.0 (#3023) merged into the v1.91.19.0 wave; measured 93,282 / 84,049 = 1.1099 (2026-10-04). + reliability follow-ups C2 (judge-named gaps after trimming the added wording: feasible 180 s Browser Quick, PROBE_DIR's source line, stop goes to the §4 report, written JSON keeps full card values; lane S's {user}/timing fields); measured 93,311 / 84,049 = 1.11020 (2026-10-04). + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); measured 94,486 / 84,049 = 1.1242 (2026-10-06). + Oct 7 wave B6: Aside rules 1, 4, 6 and 7 (offer a target-origin tab before openTab, a second sign-in wall means a tab- or URL-bound session, no early-return hint, fast [ok without the sentinel is an abort); measured 94,681 / 84,049 = 1.1265 (2026-10-07). + Oct 8 wave: shared voice directive bans "load-bearing" and adds the reply-language rule, offset by tightening the bounded closer (net +17 bytes per tier-2+ skill); measured 94,736 / 84,049 = 1.12715 (2026-10-08). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10).+ maxSizeRatio: 1.1604, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 1.1598. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.1588. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.1577. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.1533. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 96,928 / 84,049 = 1.15323, rounded up (before: 1.1526). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.1526 (before: 1.1493). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.1493 (before: 1.1420). Before that: + v1.81 Aside contract + gstack-browser fallback block (1.080 on v1.91.7.0) + the shared test value bar at 8a.5 ({{TEST_VALUE_BAR:qa}}); measured 1.094 + W1 guarded state-root resolution (`eval gstack-paths; : "${GSTACK_STATE_ROOT:?…}"`) in the Context Recovery preamble, the eureka log and each state-writing bash block; measured 1.101 (2026-09-30) + v1.91.12.0 merge of #2999 (await scope/method Reads, capture --after checkpoints, browser-only empty evidence list) with #3002; measured 1.1028 (2026-10-01). + both untrusted-content marker formats in the browser fallback (W7f); measured 1.1035 (2026-10-02). Re-measured 1.1038 after the W8 probe-loop renames (2026-10-03); the cap already matches. + the annotate-every-capture and superseded rule before materialize (a ship-exploratory-late-input run published evidence that omitted older-snapshot captures); measured 1.1064 (2026-10-03). + v1.91.18.0 (#3023) merged into the v1.91.19.0 wave; measured 93,282 / 84,049 = 1.1099 (2026-10-04). + reliability follow-ups C2 (judge-named gaps after trimming the added wording: feasible 180 s Browser Quick, PROBE_DIR's source line, stop goes to the §4 report, written JSON keeps full card values; lane S's {user}/timing fields); measured 93,311 / 84,049 = 1.11020 (2026-10-04). + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); measured 94,486 / 84,049 = 1.1242 (2026-10-06). + Oct 7 wave B6: Aside rules 1, 4, 6 and 7 (offer a target-origin tab before openTab, a second sign-in wall means a tab- or URL-bound session, no early-return hint, fast [ok without the sentinel is an abort); measured 94,681 / 84,049 = 1.1265 (2026-10-07). + Oct 8 wave: shared voice directive bans "load-bearing" and adds the reply-language rule, offset by tightening the bounded closer (net +17 bytes per tier-2+ skill); measured 94,736 / 84,049 = 1.12715 (2026-10-08). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10).minUnionBytes: 69_500, // measured union 70,385// 'aside repl' pins the Aside contract; '$B goto' pins the fallback block in the always-loaded skeleton.mustContain: ['bug', 'aside repl', '$B goto', 'fix', 'Health Score Rubric', 'regression'],@@ -674,7 +674,7 @@ do not launch the downstream skill or open a browser.`,gateAfterStop: undefined,},behavioral: 'prompt',- maxSkeletonBytes: 35_980, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 35_959. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 35_867. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 35_635. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 35,635 (before: 35,574 on a141e94). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 35,574 (before: 35_298). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 35,298 (before: 34_700). Before that: + v2.0 {{ASIDE_SETUP}}/{{BROWSE_FALLBACK}} skeleton + the STOP-Read pointer; measured 29_986 + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); skeleton measured 32,532 (2026-10-06). + Oct 7 wave B6: Aside rules 1, 4, 6 and 7 (offer a target-origin tab before openTab, a second sign-in wall means a tab- or URL-bound session, no early-return hint, fast [ok without the sentinel is an abort), and the cookbook's silent-failure list and signed-in-tab recipe (the rule details live here, not in every browsing skill); skeleton measured 34,047 (2026-10-07). + Oct 8 wave: the tier-1 voice directive bans "load-bearing" and adds the reply-language rule (tier 1 has no closer to tighten: +158 bytes); skeleton measured 34,209 (2026-10-08). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10).+ maxSkeletonBytes: 36_001, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 35_980. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 35_959. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 35_867. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 35_635. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 35,635 (before: 35,574 on a141e94). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 35,574 (before: 35_298). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 35,298 (before: 34_700). Before that: + v2.0 {{ASIDE_SETUP}}/{{BROWSE_FALLBACK}} skeleton + the STOP-Read pointer; measured 29_986 + Oct 6 fix wave A3/CEO-12: free text reaches commands only through agent-written mktemp files (mktemp block, write rule, path rebuild and refusal at each posting, prompt and brief site); skeleton measured 32,532 (2026-10-06). + Oct 7 wave B6: Aside rules 1, 4, 6 and 7 (offer a target-origin tab before openTab, a second sign-in wall means a tab- or URL-bound session, no early-return hint, fast [ok without the sentinel is an abort), and the cookbook's silent-failure list and signed-in-tab recipe (the rule details live here, not in every browsing skill); skeleton measured 34,047 (2026-10-07). + Oct 8 wave: the tier-1 voice directive bans "load-bearing" and adds the reply-language rule (tier 1 has no closer to tighten: +158 bytes); skeleton measured 34,209 (2026-10-08). + Honest Work wave merged (W2/W3 gate integrity in review/ship, W4 kernel + DONE line in every tier-2+ skill, W5/W7 in spec/ship): re-measured on the integrated tree (2026-10-10).minUnionBytes: 36_000, // skeleton + command-list section (14,240); measured union ~38.5 KB// 'BEGIN/END UNTRUSTED EXTERNAL' pins the untrusted-content warning in the// command reference; 'aside repl' pins the Aside contract in the skeleton.@@ -720,7 +720,7 @@ do not launch the downstream skill or open a browser.`,maxSkeletonBytes: 85_709, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 85_702. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 85_618. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 85_222. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 85,222 (before: 85,182 on a141e94). Before that: /design-review --build (GST-1741 PR 2, 2026-11-07, grant: GStack Minder, 2026-11-07): --build routing, stop pointer, index row, description clause and trigger: +443 B, trimmed 130; the build-loop section is mode-loaded; measured 85,182. Before: GSTA-134 skill diet (2026-10-28): lowered from 115_947 to the measured skeleton after the outside voices and test bootstrap moved to sections, 84,869. Before: GSTA-96 hoist merged with v1.91.274.0 (#3507, 2026-10-27): the hoisted skeleton plus main's headroom of 0 bytes; measured 115,947 on the merged tree. Before: measured 137735 on the merged tree with main f27a760 (2026-10-27, #3507); 137767 (2026-10-26; 137773 on 2026-10-25 before the shorter craft-audit trigger): the Section index the external-host carve test requires, its craft-audit row, and the STOP pointer (GSTA-92; Garry 2026-10-25 'Do it' (GSTA-92)).minUnionBytes: 136_100, // GSTA-134 skill diet (2026-10-28): measured union 137,602 (lowered from 143_300); before: measured union 144802 on the merged tree with main f27a760 (2026-10-27, #3507); 145037 (2026-10-26)mustContain: ['AI Slop Detection', 'Fix Loop', 'gstack-design-lint', 'Proof beside each claim', 'holds session data'],- maxSizeRatio: 1.3704, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.3702. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.3695. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.3657. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 144,546 / 105,842 = 1.36568, rounded up (before: 1.3654). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.3654 (before: 1.3628). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.3628 (before: 1.357). Before that: /design-review --build (GST-1741 PR 2, 2026-11-07, grant: GStack Minder, 2026-11-07): --build routing, stop pointer, index row, description clause and trigger: +443 B, trimmed 130; the build-loop section is mode-loaded; measured 143,620 / 105,842 = 1.35693. Before: 1.3001, GSTA-134 skill diet (2026-10-28): measured 137,602 / 105,842 = 1.30007, rounded up (lowered from 1.3739). Before: GSTA-96 hoist merged with v1.91.274.0 (#3507, 2026-10-27): the union now holds sections/preamble.md (the hoist's owner-approved raise, decision A) on top of main's 1.3681; measured 145,410 / 105,842 = 1.3739 on the merged tree. Before: first parity guard for design-review: measured 144802 / 105,842 = 1.3681 on the merged tree with main f27a760 (2026-10-27, #3507: the design lint swap); before that 145082 / 105,842 = 1.3708 (2026-10-25; 145077 after the /ship review fixes, 145068 = 1.3707 after the line-13 reword, 145049 = 1.3705 after the post-merge /ship review, 145037 = 1.3704 after its second pass, 2026-10-26), the skeleton's growth since v1.64.1.0 plus the craft audit (Garry 2026-10-25 'Do it' (GSTA-92)).+ maxSizeRatio: 1.3708, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 1.3704. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 1.3702. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 1.3695. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 1.3657. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 144,546 / 105,842 = 1.36568, rounded up (before: 1.3654). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 1.3654 (before: 1.3628). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 1.3628 (before: 1.357). Before that: /design-review --build (GST-1741 PR 2, 2026-11-07, grant: GStack Minder, 2026-11-07): --build routing, stop pointer, index row, description clause and trigger: +443 B, trimmed 130; the build-loop section is mode-loaded; measured 143,620 / 105,842 = 1.35693. Before: 1.3001, GSTA-134 skill diet (2026-10-28): measured 137,602 / 105,842 = 1.30007, rounded up (lowered from 1.3739). Before: GSTA-96 hoist merged with v1.91.274.0 (#3507, 2026-10-27): the union now holds sections/preamble.md (the hoist's owner-approved raise, decision A) on top of main's 1.3681; measured 145,410 / 105,842 = 1.3739 on the merged tree. Before: first parity guard for design-review: measured 144802 / 105,842 = 1.3681 on the merged tree with main f27a760 (2026-10-27, #3507: the design lint swap); before that 145082 / 105,842 = 1.3708 (2026-10-25; 145077 after the /ship review fixes, 145068 = 1.3707 after the line-13 reword, 145049 = 1.3705 after the post-merge /ship review, 145037 = 1.3704 after its second pass, 2026-10-26), the skeleton's growth since v1.64.1.0 plus the craft audit (Garry 2026-10-25 'Do it' (GSTA-92)).},// ── Token-reduction Phase 4 wave 4 (v1.69.x branch): design doctrine carve ──@@ -861,7 +861,7 @@ do not launch the downstream skill or open a browser.`,gateAfterStop: undefined, // operational skill, no plan-mode gate},behavioral: 'prompt',- maxSkeletonBytes: 32_577, // GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 32_556. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 32_460. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 32_225. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 32,225 (before: 32,169 on a141e94). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 32,169 (before: 31_893). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 31,893 (before: 31_300). Before that: first carve: Section index, one STOP pointer and the vet rule on the 29.9k monolith; measured 30,781 (2026-10-26)+ maxSkeletonBytes: 32_641, // GSTA-902 (2026-11-28, Garry "do it" on GST-4130 B via GStack Minder): public-only mode (#4812) makes the shared Aside probe skip Aside when BROWSE_PUBLIC_ONLY is on, because Aside is not guarded; measured on the tree; was 32_577. Before that: GST-3654 (2026-11-24, Garry "Do it" on B1): /ship installs as /gstack-ship because Claude Code keeps the name ship for its own built-in (#4775), so each line that names it grows by 7 bytes; was 32_556. Before that: GSTA-803 (2026-11-22, Captain GStack Minder ruling D1): user-reported fix #4366, the Aside probe reports a closed app; #3924 changes only the /codex skill; was 32_460. Before that: GST-3157 (2026-11-19, Garry "Do it" on I1): Claude Code skills load the shared preamble and the start output at load time; was 32_225. GST-2774 (2026-11-14): the Claude catalog description keeps a when-to-use clause (GSTA-558: Opus 5.5 skipped /review and the planning skills when the listing said only what a skill is); measured 32,225 (before: 32,169 on a141e94). Before that: GST-2756 (2026-11-15, Garry's "Do it" to the ask-once and open-every-file habits): two Ground Rules lines (ask each question once and carry it as one waiting line; open every handed-over file and remove placeholders), +276 bytes; measured 32,169 (before: 31_893). Before that: GST-2753 (2026-11-15, Garry's "Do it" to moving the never-print-secrets rule into gstack): the shared Ground Rules preamble section (never print a whole environment, git config or process table; wait on CI with one gstack-pr-wait call), +614 bytes; measured 31,893 (before: 31_300). Before that: first carve: Section index, one STOP pointer and the vet rule on the 29.9k monolith; measured 30,781 (2026-10-26)minUnionBytes: 33_000, // skeleton + vet-the-number section; measured union 34,527 (2026-10-26)mustContain: ['performance.getEntries()', 'REGRESSION', 'Name the limiter', 'run-to-run variation', 'inconclusive'],// The v1.64.1.0 baseline measured the 37.2k monolith; the carved union is below it.diff --git a/test/qa-browser-deadline-evidence.test.ts b/test/qa-browser-deadline-evidence.test.tsindex e482d53c5..1b53ce4c2 100644--- a/test/qa-browser-deadline-evidence.test.ts+++ b/test/qa-browser-deadline-evidence.test.ts@@ -237,7 +237,10 @@ test.each(['extra-option', 'suffix-option', 'operator', 'newline', 'foreign-cwd'// "unsupported outer shell composition" after joining reads with an exact bookkeeping call, as in// `ls -la; git -C <fixture> branch --show-current`. Every non-guard Bash command from those three// attempts and from the eight passing attempts beside them replays inside a real guarded attempt.-const bookkeepingReplay = (f: ReturnType<typeof fixture>, command: string) => command+const currentReadiness = fs.readFileSync(path.join(ROOT, 'qa/sections/browser-setup.md'), 'utf8').match(/```bash\n(_gs_d\(\)[\s\S]*?)\n```/)![1];+const publicOnlySkip = /^elif case \$\{BROWSE_PUBLIC_ONLY-\} in ''\|0\|false\|off\) false;; esac; then echo "ASIDE_SKIPPED: BROWSE_PUBLIC_ONLY"\n/m;+const recordedReadiness = currentReadiness.replace(publicOnlySkip, '');+const bookkeepingReplay = (f: ReturnType<typeof fixture>, command: string) => (command === recordedReadiness ? currentReadiness : command).replaceAll('__QA_FIXTURE__', f.directory).replaceAll('__QA_GUARD__', guard).replaceAll('__QA_BROWSE__', browse);test.each(capturedBookkeeping.attempts.map(attempt => [attempt.source, attempt.passed, attempt.commands] as const))('captured non-guard Bash commands replay as bookkeeping: %s (passed %p)', (_, __, commands) => {@@ -249,6 +252,13 @@ test.each(capturedBookkeeping.attempts.map(attempt => [attempt.source, attempt.pexpect(f.check()).toEqual({ launchedRuns: 1, completedRuns: 1, refusedRuns: 0, timedOutRuns: 0 });});+test('captured readiness blocks differ from the current block only by the public-only skip line', () => {+ expect(recordedReadiness).not.toBe(currentReadiness);+ const recorded = capturedBookkeeping.attempts.flatMap(attempt => attempt.commands.filter(command => command.startsWith('_gs_d()')));+ expect(recorded.length).toBe(capturedBookkeeping.attempts.length);+ expect([...new Set(recorded)]).toEqual([recordedReadiness]);+});+test('the captured joins are the three failing attempts\' only unaccepted commands', () => {const failing = capturedBookkeeping.attempts.filter(attempt => !attempt.passed);expect(failing.map(attempt => attempt.source.split(' ')[1])).toEqual(['39313931713', '39332134395', '39336730429']);diff --git a/test/size-ledger/ship/capy-browse-public-only.json b/test/size-ledger/ship/capy-browse-public-only.jsonnew file mode 100644index 000000000..b95999061--- /dev/null+++ b/test/size-ledger/ship/capy-browse-public-only.json@@ -0,0 +1,4 @@+{+ "bytes": 115,+ "why": "GSTA-902 public-only mode (#4812): the shared Aside probe skips Aside unless BROWSE_PUBLIC_ONLY is off or unset"+}