arc.bend checks
raw source on the hub · import 0x32ddc3ea4f65841cc2859fb2a86ea04a/arc.bend as Arc
1 import
import Base
Types
type NodeRole source · line 12 · raw
Data
---- vocabulary ---- UserDevice: a user's own device. Server: a machine the project runs. Overlay: the private (overlay) network between them. Outside: someone else's servers.
UserDeviceNodeRole
ServerNodeRole
OverlayNodeRole
OutsideNodeRole
type Node source · line 18 · raw
Data
Node@key:String -> @name:String -> @role:NodeRole -> Node
type ContainerKind source · line 26 · raw
Data
What a container is. The list is closed: something that is none of these is not a container. Client: the app, on the user's device. Network: the private network between client and server. DataApi: answers queries on records and changes them. AgentApi: runs agent threads. ModelApi: answers model calls. Cli: a command a person runs. Worker: has no API of its own; it only moves data between data APIs, so it is the first thing to fold into a data API's own actions.
ClientContainerKind
NetworkContainerKind
DataApiContainerKind
AgentApiContainerKind
ModelApiContainerKind
CliContainerKind
WorkerContainerKind
type Owner source · line 36 · raw
Data
Whether the project builds and runs it, or uses it as it is.
OursOwner
TheirsOwner
type Exposure source · line 41 · raw
Data
Who can reach it: its own machine (127.0.0.1), the local network, the private network, the device it is on, anyone.
LocalExposure
LanExposure
TailnetExposure
DeviceExposure
PublicExposure
type Cap source · line 50 · raw
Data
What a container provides. Hosting is serving the app itself (its HTML and scripts); a data API may also host the app only while it is private (shared_hosting_ok).
HostingCap
PrivateAccessCap
PrivateHostingCap
RealtimeCap
BlobStoreCap
type Lang source · line 57 · raw
Data
BendLang
CLang
RustLang
TypeScriptLang
JavaScriptLang
PythonLang
OpaqueLang
type Container source · line 66 · raw
Data
Container@key:String -> @name:String -> @kind:ContainerKind -> @owner:Owner -> @on:String -> @exposure:Exposure -> @caps:List<&2, Cap> -> Container
type Part source · line 69 · raw
Data
Part@key:String -> @name:String -> @lang:Lang -> @in:String -> Part
type Link source · line 73 · raw
Data
A talks-to edge between two containers or parts, by key.
Link@src:String -> @dst:String -> @label:String -> @live:Bool -> Link
type System source · line 76 · raw
Data
System@nodes:List<&2, Node> -> @containers:List<&2, Container> -> @parts:List<&2, Part> -> @links:List<&2, Link> -> System
Definitions
def nodes source · line 80 · raw
@s:System -> List<&2, Node>
---- access ----
def containers source · line 85 · raw
@s:System -> List<&2, Container>
def parts source · line 90 · raw
@s:System -> List<&2, Part>
def links source · line 95 · raw
@s:System -> List<&2, Link>
def nkey source · line 100 · raw
@n:Node -> String
def ckey source · line 105 · raw
@c:Container -> String
def con source · line 110 · raw
@c:Container -> String
def caps source · line 115 · raw
@c:Container -> List<&2, Cap>
def pkey source · line 120 · raw
@p:Part -> String
def pin source · line 125 · raw
@p:Part -> String
def nkeys source · line 130 · raw
@xs:List<&2, Node> -> List<&2, String>
def ckeys source · line 137 · raw
@xs:List<&2, Container> -> List<&2, String>
def pkeys source · line 144 · raw
@xs:List<&2, Part> -> List<&2, String>
def keys source · line 152 · raw
@+s:System -> List<&2, String>
Keys links may name: containers and parts.
def is_server source · line 156 · raw
@r:NodeRole -> Bool
---- predicates on the vocabulary ----
def is_outside source · line 163 · raw
@r:NodeRole -> Bool
def is_device source · line 170 · raw
@r:NodeRole -> Bool
def is_client source · line 177 · raw
@k:ContainerKind -> Bool
def is_data_api source · line 184 · raw
@k:ContainerKind -> Bool
def is_ours source · line 191 · raw
@o:Owner -> Bool
def is_local source · line 198 · raw
@e:Exposure -> Bool
def is_tailnet source · line 205 · raw
@e:Exposure -> Bool
def is_rust source · line 212 · raw
@l:Lang -> Bool
def str_eq source · line 220 · raw
@a:String -> @b:String -> Bool
---- keys, like foreign keys ----
def has source · line 223 · raw
@+s:String -> @xs:List<&2, String> -> Bool
def pick_str source · line 230 · raw
@c:Bool -> @a:String -> @b:String -> String
def distinct_keys source · line 238 · raw
@xs:List<&2, String> -> Bool
No key names two things.
def all_in source · line 246 · raw
@xs:List<&2, String> -> @+ks:List<&2, String> -> Bool
Every key in xs names something in ks.
def part_ins source · line 253 · raw
@xs:List<&2, Part> -> List<&2, String>
def container_ons source · line 260 · raw
@xs:List<&2, Container> -> List<&2, String>
def link_ends source · line 267 · raw
@xs:List<&2, Link> -> List<&2, String>
def well_formed source · line 278 · raw
@+s:System -> Bool
The system is well formed: node keys and container/part keys are unique, every container is on a node, every part in a container, and every link joins two things that exist.
def part_home source · line 285 · raw
@+k:String -> @xs:List<&2, Part> -> String
---- looking things up ----
def home source · line 293 · raw
@+k:String -> @+s:System -> String
The container a key belongs to: itself, or the one its part sits in.
def none source · line 296 · raw
Container
def pick_c source · line 299 · raw
@hit:Bool -> @c:Container -> @other:Container -> Container
def container source · line 307 · raw
@+k:String -> @xs:List<&2, Container> -> Container
The container with key k (an empty one when k is unknown; well_formed rules that out).
def pick_r source · line 314 · raw
@hit:Bool -> @r:NodeRole -> @other:NodeRole -> NodeRole
def node_role source · line 321 · raw
@+k:String -> @xs:List<&2, Node> -> NodeRole
def node_of source · line 331 · raw
@+k:String -> @+s:System -> String
The node a container or part runs on, and its role.
def role_of source · line 334 · raw
@+k:String -> @+s:System -> NodeRole
def private_ok source · line 339 · raw
@c:Container -> @+ns:List<&2, Node> -> Bool
---- where it runs ---- On a server, everything is reachable only from the server itself or over the private network.
def all_private source · line 344 · raw
@xs:List<&2, Container> -> @+ns:List<&2, Node> -> Bool
def servers_private source · line 351 · raw
@+s:System -> Bool
def devices_via_network.go source · line 355 · raw
@xs:List<&2, Link> -> @+s:System -> Bool
A device reaches a server only through the private network: no link goes straight from one to the other.
def devices_via_network source · line 364 · raw
@+s:System -> Bool
def is_cap source · line 368 · raw
@want:Cap -> @c:Cap -> Bool
---- what it is: minimality, every capability provided exactly once ----
def one_if source · line 383 · raw
@b:Bool -> Nat
def count_in source · line 390 · raw
@+want:Cap -> @cs:List<&2, Cap> -> Nat
def direct source · line 397 · raw
@+want:Cap -> @xs:List<&2, Container> -> Nat
def provided source · line 405 · raw
@want:Cap -> @+s:System -> Nat
How many containers provide want. Hosting plus private access compose into private hosting.
def tailnet_data_apis.go source · line 412 · raw
@xs:List<&2, Container> -> Nat
def tailnet_data_apis source · line 422 · raw
@+s:System -> Nat
The data APIs the private network reaches: the client's data API. Local and outside ones are its sources.
def own_data_apis.go source · line 425 · raw
@xs:List<&2, Container> -> @+ns:List<&2, Node> -> Nat
def own_data_apis source · line 435 · raw
@+s:System -> Nat
The system's own data APIs: those not on someone else's servers. "Exactly one" means one store.
def backend source · line 455 · raw
@c:Container -> Bool
---- a goal: every part of our own non-client containers is Rust ----
def rust_ok source · line 460 · raw
@p:Part -> @+s:System -> Bool
def all_rust.go source · line 465 · raw
@xs:List<&2, Part> -> @+s:System -> Bool
def all_rust source · line 472 · raw
@+s:System -> Bool
def path source · line 476 · raw
@+k:String -> @+s:System -> String
---- the diagram (D2): nodes as boxes, containers inside their node, parts inside their container ----
def node_box source · line 479 · raw
@n:Node -> String
def node_boxes source · line 488 · raw
@xs:List<&2, Node> -> String
def container_box source · line 495 · raw
@c:Container -> String
def container_boxes source · line 500 · raw
@xs:List<&2, Container> -> String
def part_box source · line 507 · raw
@p:Part -> @+s:System -> String
def part_boxes source · line 512 · raw
@xs:List<&2, Part> -> @+s:System -> String
def style source · line 519 · raw
@live:Bool -> String
def edges source · line 526 · raw
@xs:List<&2, Link> -> @+s:System -> String
def d2 source · line 535 · raw
@+s:System -> String