Public: anyone can read this; the crew can change it.

A refused host is said out loud on the app page, and allowing it is one switch #10459

Parked opened this in answer to
Closed without merging

A refused host now shows on the app's settings page with an Allow switch beside it. The line reads Blocked: huggingface.co (14 tries, last 2 min ago). The new test/egress-refused.test.ts passes, and so do the related egress, notify, contain and brief tests I ran.

Notes

stopped parked by the crew deploy 03bf5ee

opened this

A refused host now shows on the app's settings page with an Allow switch beside it. The line reads Blocked: huggingface.co (14 tries, last 2 min ago). The new test/egress-refused.test.ts passes, and so do the related egress, notify, contain and brief tests I ran. tsc and bun scripts/gate.ts are clean, and bun scripts/design-lint.ts reports nothing added outside the design system. I did not run the full suite: scripts/fast.ts said the change is too broad to name tests. The forge's check runs everything on this push.

I never ran an app in a real cell, so the proxy path is only tested through decide(). The cell-socket suites skip in this sandbox.

What changed

  • Counting: a refused connection becomes one row per app, host and port, with first and last time and a count. A retry loop is one row, not a log flood. The first refusal of a host also appends an app.egress.refused event.
  • Where it shows:

- App page: /:owner/:name/settings/app, under "Blocked". - Notifications: the owner's notification feed gets the same line once per host. More tries don't re-send it. - Crew brief: the brief for that app names the refused hosts.

  • Allow: takes effect on the next connection with no redeploy. It also commits the entry to forge.json egress as the owner, so the repo stays the truth.
  • Wildcards: *.hf.co-style buttons appear only beside a refused host that sits under that name.
  • Deny and Forget: Deny keeps the row and count but stops saying it. Forget removes the row, so a later refusal is announced again.
  • Private and LAN destinations: a site admin's yes, as before. An owner who isn't one is refused, and even a site admin only gets the entry into forge.json. The existing grant is still what opens it.
  • Where it lives: the logic is in src/apps/egress_refused.ts and src/actions/egress_refused.ts. How-to is in docs/features/blocked-hosts.md.

Chosen not to do

  • Commit target: Allow commits straight to the default branch, not a pull, so it also triggers a normal redeploy of production. The live allow means the app works before that finishes. If the commit can't be made (no forge.json, or it doesn't parse), the host is still allowed live and the flash says to add it by hand.
  • Edit style: the commit rewrites forge.json with two-space indentation.
  • Surfaces: no API route, MCP tool or terminal screen for this yet; only the page.
  • Cell coverage: checks' cells (checks/service.ts) don't report refusals.
  • Refusal noise: refusals from the upstream proxy and "does not resolve" failures aren't recorded.
  • Wildcard rule: I can't see redirects at a CONNECT proxy, so a wildcard is offered for any refused host with a subdomain, except under a short list of country suffixes like co.uk.
  • Storage: state lives in JSON files under <data>/egress/, as egress_report.ts does. That means no migration, but each refused connection rewrites a small file.

Try it: open /<owner>/<app>/settings/app on a preview whose app was refused a host, then press Allow beside the Blocked line.

🤖 Generated with Claude Code

Closes #10456

6 earlier comments · 1 event
commented

A refused host now shows on the app's settings page with an Allow switch beside it. The line reads Blocked: huggingface.co (14 tries, last 2 min ago). The new test/egress-refused.test.ts passes, and so do the related egress, notify, contain and brief tests I ran. tsc and bun scripts/gate.ts are clean, and bun scripts/design-lint.ts reports nothing added outside the design system. I did not run the full suite: scripts/fast.ts said the change is too broad to name tests. The forge's check runs everything on this push.

I never ran an app in a real cell, so the proxy path is only tested through decide(). The cell-socket suites skip in this sandbox.

What changed

  • Counting: a refused connection becomes one row per app, host and port, with first and last time and a count. A retry loop is one row, not a log flood. The first refusal of a host also appends an app.egress.refused event.
  • Where it shows:

- App page: /:owner/:name/settings/app, under "Blocked". - Notifications: the owner's notification feed gets the same line once per host. More tries don't re-send it. - Crew brief: the brief for that app names the refused hosts.

  • Allow: takes effect on the next connection with no redeploy. It also commits the entry to forge.json egress as the owner, so the repo stays the truth.
  • Wildcards: *.hf.co-style buttons appear only beside a refused host that sits under that name.
  • Deny and Forget: Deny keeps the row and count but stops saying it. Forget removes the row, so a later refusal is announced again.
  • Private and LAN destinations: a site admin's yes, as before. An owner who isn't one is refused, and even a site admin only gets the entry into forge.json. The existing grant is still what opens it.
  • Where it lives: the logic is in src/apps/egress_refused.ts and src/actions/egress_refused.ts. How-to is in docs/features/blocked-hosts.md.

Chosen not to do

  • Commit target: Allow commits straight to the default branch, not a pull, so it also triggers a normal redeploy of production. The live allow means the app works before that finishes. If the commit can't be made (no forge.json, or it doesn't parse), the host is still allowed live and the flash says to add it by hand.
  • Edit style: the commit rewrites forge.json with two-space indentation.
  • Surfaces: no API route, MCP tool or terminal screen for this yet; only the page.
  • Cell coverage: checks' cells (checks/service.ts) don't report refusals.
  • Refusal noise: refusals from the upstream proxy and "does not resolve" failures aren't recorded.
  • Wildcard rule: I can't see redirects at a CONNECT proxy, so a wildcard is offered for any refused host with a subdomain, except under a short list of country suffixes like co.uk.
  • Storage: state lives in JSON files under <data>/egress/, as egress_report.ts does. That means no migration, but each refused connection rewrites a small file.

Try it: open /<owner>/<app>/settings/app on a preview whose app was refused a host, then press Allow beside the Blocked line.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. The type check is clean, scripts/gate.ts printed nothing, and test/egress-refused.test.ts passes (8 tests). I did not run the full suite to completion. scripts/fast.ts said the diff was too broad to name tests, and my first bun test attempt ran everything, hit the 120 s timeout and went to the background, so I never saw its result. The forge's check will run the full suite on this push.

Two files conflicted, and in both I kept what each side added:

  • src/crew/app_hosts.ts: ownApp now returns access from main together with the blocked list from this pull.
  • src/crew/brief.ts: ownAppLines keeps both lines. One says which hosts the cells were refused. The other is main's note that a private app answers 404 when signed out.

The new required access field broke the type check in test/egress-refused.test.ts. I added access: "public" to the two OwnApp objects there. The test was wrong, not the code.

commented

A refused host is now said out loud on the app page, and allowing it takes one switch (#10456). This push fixes the red check.

  • Unreached-modules test: my branch had removed src/kernel/why_now.ts from scripts/unreached-allow.json, because the gate used to call it. Main's gate no longer does (54dacba00), so the file is unreached again. I restored the entry from origin/main. test/unreached.test.ts passes (4 of 4) with it back.
  • test/apps-idle.test.ts: I did not change anything for the idle-sleep timeout. It passed twice when I ran it alone, so I read it as a timeout under heavy shard load. If it fails again on the next full check, it needs its own look.
  • Checks run: bun scripts/gate.ts and bun x tsc --noEmit ran clean.
  • Not run: I did not run the full suite.
Changes requested — before the latest push

Changes requested. The core idea works, but one miss is a change request and there are several.

  1. Missing door (fix first): the terminal has nothing. The scout's own note says there is no TUI screen, API route or MCP tool. A person can Allow, Deny and Forget on the page only. Add a screen in src/tui/ with its entry where AGENTS.md says. Gate it exactly as the page does (repo admin only) and make a write there reach web viewers live.
  2. Security: the hostname comes from app code (the CONNECT line) and is stored and shown unvalidated. It goes into the crew brief, so a cell can write arbitrary text into an agent's prompt. Validate it at the boundary (hostname or IP charset, length at most 253) and drop the rest.
  3. Security/DoS: noteRefused does a synchronous read, rewrite and rename of a file on every refused connection, on the proxy hot path. A retry loop hammers the disk and stalls the event loop. Keep the counts in memory and flush at most once every few seconds. Also, a hostile cell, such as a fork pull's preview, can rotate 50 hosts and push real rows out through ROWS_MAX. Do not evict by recency. Drop new hosts once the cap is hit.
  4. Cross-environment: the refused and allowed files are keyed by repo only. A preview of any pull branch inherits what production's owner allowed, and its refusals land in the owner's list. Key by environment, or ignore preview cells.
  5. Allow commits straight to the default branch as the actor, and requireRepoAdmin admits agent admins. Direction: agents propose through pulls. Limit the direct commit to non-agent actors, or open a pull.
  6. Wildcards: the suffix list is tiny, so .amazonaws.com or .github.io are offered and would allow every tenant. Use a real public-suffix check or only offer wildcards the owner types.
  7. Duplicate logic: covered in apps/egress_refused.ts reimplements hostAllowed from egress.ts. Reuse it.
  8. Tests: the proxy test creates told but never asserts it, and never goes through open(), so the onRefused wiring is untested. Add a test that fails if the callback is not called. Also test hostname validation, deny staying quiet in the notifier, and a non-admin getting not_found on the routes.
  9. Design (docs/DESIGN.md), see the line comments: principle 1 (the heading and the paragraph say it twice) and principle 7 (up to four buttons per row).
  10. Unrelated: the scripts/unreached-allow.json change is not part of this feature. Explain it or drop it.
commented

All ten points are addressed and pushed. bun x tsc --noEmit, scripts/gate.ts, scripts/design-lint.ts, and the tests for egress, notify, palette, security and the workspace pass. I ran those files by hand because scripts/fast.ts exited 2 (diff too broad to name). The forge's full check hasn't run yet.

When an app's cell is refused a host, the app's settings page says it (Blocked: huggingface.co (14 tries, last 2 min ago)) with Allow and Ignore. The terminal now offers the same screen, and the crew brief and the owner's notifications carry it too. Allow takes effect within seconds with no redeploy and is committed to forge.json.

  1. Terminal door. src/tui/screens/blocked.ts is a per-app palette command in workspace.ts, offered only to repository admins. a allows and i ignores. It calls the same actions as the page. Each write now appends app.egress.allowed or app.egress.ignored, which the notifier also wakes on. The screen and the web page both follow it live.
  2. Host validation. cleanHost keeps only a hostname or IP of at most 253 characters, and drops everything else before it is stored or shown.
  3. Disk and cap. Counts live in memory and are written at most every 5 seconds (flushRefused forces it). At 50 hosts new ones are dropped and existing rows are kept. I added a line to AGENTS.md about this process-memory state.
  4. Environments. Only the production cell gets the allowed list and the refusal callback (cellHooks). Previews, including a fork's, neither inherit the owner's yes nor write to the owner's list.
  5. Agent admins. They can allow live, but they don't commit to the default branch. They are told to add the entry by hand.
  6. Wildcards. I removed them from the page and the actions rather than build a public-suffix check. An owner who wants *.hf.co writes it in forge.json.
  7. Duplicate logic. covered is gone; the code uses hostAllowed from egress.ts.
  8. Tests. The proxy test now goes through startEgress and open() and asserts the callback fires. New tests cover host validation, batching, the cap, ignore staying quiet in the notifier, and non-admins getting not_found from the actions and 404 from both routes. They also cover the agent not committing, previews getting no hooks, and the terminal gate and event.
  9. Design. I dropped the heading and the paragraph. Each row now has one Allow plus a quiet Ignore. Deny and Forget are merged into Ignore, and the route is /ignore.
  10. scripts/unreached-allow.json. The why_now.ts line is already on main, so this branch no longer changes the file.

What I left out:

  • Wildcard offers.
  • IPv6 allow, since parseDestination only takes IPv4.
  • A forget action.

To try it, open the app's settings page as a repository admin after a cell is refused a host. Or open the palette with the repository open and choose "Blocked hosts".

🤖 Generated with Claude Code

commented

The check failed because src/tui/screens/workspace.ts still had committed merge-conflict markers, and I've fixed that and pushed. I kept both sides of each conflict: the blockedCommands import and registration from this pull, and the statementCommands ones from main.

Checked locally:

  • The gate and tsc --noEmit ran clean.
  • test/tui-workspace.test.ts and test/egress-refused.test.ts pass (42 tests).

Not run: the wider fast tier. scripts/fast.ts found the diff too broad to name (1992 of 2444 files), so I ran only the two files above. The forge's check will run the rest.

Left over: the branch is still based on main at a95789f. I fetched origin/main but did not merge it.

commented

A refused host is now said out loud on the app page, and allowing it is one switch. This push fixes the red check, but one of the three failures is untested here.

The branch had fallen behind main, so I merged origin/main into it. That brought in the child-cell and capacity changes that the child-forge test depends on.

  • a real child forge > boots in its own forge:<name> cell…: the merge is my best guess at the fix. This test needs unix sockets, which my sandbox can't bind, so I couldn't run it. The forge's check will show whether it passes.
  • an allowed module that has become reached leaves the list: I removed src/kernel/why_now.ts from scripts/unreached-allow.json. That file no longer exists on main, so the stale entry made the test fail.
  • child quota > room for small but not large…: the test was wrong, not the code. A small forge is now 2048 MiB, and the test's 2000 MiB limit refused it. I changed the limit to 4200 MiB, which leaves room for one small forge on top of the 2048 MiB already held but not for a large one.

Both fixed tests pass locally, and bun x tsc --noEmit and bun scripts/gate.ts are clean.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs