Skip to main content
TypeScript spells each method and field in camelCase (preNetwork, ctx.bytesSent).

How it applies

pre_network runs before each connection carries a byte, whoever opens it: curl, git, a CLI, a mount’s VFS, a runtime or an SDK. The workspace’s network lists judge it first, and a connection they refuse reaches no policy. The URL is not there: under HTTPS only the program and the server see it. post_network runs once the connection is over, for each policy that let it through, and only observes.

Example: refuse a large clone

ctx.words holds the URL a git clone names, so a policy can look the repository up before a byte of the clone moves, and refuse one past 96 MB:
GitHub reports strukto-ai/mirage at 151 MB, so its clone is refused before it starts:
The reason is on the result’s decision: strukto-ai/mirage is over 96 MB. A lookup that fails raises, and a policy that raises refuses, so a rate-limited lookup never lets a clone through.

Example: a byte budget

Together the two hold a workspace to a byte budget:

Machines and browsers

  • A program on a machine connects from that machine, and no policy sees its connections. A host machine would connect around the gateway, so it refuses to run while a policy listens.
  • In a browser, fetch is judged by host name with an empty address. A request whose size the page cannot know (a form, a stream), a redirect and a WebSocket are refused while a policy listens.