In this section
On this page

Scope

This specification defines the semantic foundations, runtime protocol, execution model, and development patterns for CapDAG. It is the authoritative shared contract for every CapDAG implementation.


Document map

Foundations (2–5)

# Document Purpose Dependencies
2 Formal foundations Mathematical foundation, dispatch relation None
3 Tagged URN domain Base domain U, normalization, wildcard truth table 2
4 Predicates Derived predicates (accepts, conforms_to, is_comparable, is_equivalent) 3
5 Specificity Specificity scoring function 3

Dispatch and routing (6–8)

# Document Purpose Dependencies
6 Cap URN structure Cap URN as product C = U × U × U × E 3, 5
7 Dispatch The dispatch predicate 3, 4, 6
8 Ranking Selection among valid candidates 5, 7

Machine notation and data types (9–11)

# Document Purpose Dependencies
9 Machine notation Textual encoding of multi-cap data-flow graphs 4, 6
10 Validation rules Structural validation constraints 3, 6
11 Media URNs Media URN structure and the ext/fmt/enc axes 3

Protocol (12)

# Document Purpose Dependencies
12.1 Architecture System topology, component roles 7, 8
12.2 Frame protocol Wire format, frame types, size limits 12.3, 12.4
12.3 Handshake Connection setup, HELLO exchange, identity verification —
12.4 Streaming Multiplexed streams, chunking, sequence numbering —
12.5 Flow control Credit windows, teardown, overruns, and protocol statistics 12.2, 12.4

Cartridge runtime (13)

# Document Purpose Dependencies
13.1 Cartridge runtime Entry point, handler registration, CLI/cartridge mode 7, 12.3
13.2 Input and output InputStream, OutputStream, stream lookup 13.4, 15.4
13.3 Peer invocation Cross-cartridge capability calls —
13.4 Progress and logging LOG frames, progress mapping, keepalive 15.3

Host and relay (14)

# Document Purpose Dependencies
14.1 Host runtime Cartridge lifecycle, frame routing, health monitoring 12.3
14.2 Relay switch Cap-aware routing multiplexer 7, 8, 15.4
14.3 Relay topology RelaySlave/RelayMaster pairs, Unix socket relay chains —

Execution (15)

# Document Purpose Dependencies
15.1 Orchestrator Machine notation parsing, DAG construction 11
15.2 Execution execute_plan, scheduling, maps, step policy 15.3
15.3 Progress mapping Deterministic progress subdivision —
15.4 Planner Path finding, LiveCapFab, MachinePlan 15.1

Cartridge development (16)

# Document Purpose Dependencies
16.1 Cartridge anatomy Cartridge structure, manifest, cap definitions 12.3
16.2 Handler patterns Op trait, argument extraction, output emission 15.4
16.3 Model cartridges ML cartridges, three-phase architecture 13.4
16.4 Content cartridges Document processing, standard cap patterns 7, 16.2
16.5 Rust vs Swift Implementation differences, module coverage —

Runtime errors (17)

# Document Purpose Dependencies
17.2 Error handling Error type hierarchy, propagation patterns 13.4

The capdag CLI (18)

# Document Purpose Dependencies
18.0 Installing the CapDAG CLI Every way to install it: Homebrew, apt, dnf, winget, or a direct download —
18.1 CapDAG CLI reference Every capdag subcommand, options, fabric binding, output discipline 7, 15.2
18.2 Build and run a cartridge Scaffold, install for development, run, and iterate on a cartridge; the local dev fallback 16.1, 18.1

Reading order

  1. 02 Formal foundations: mathematical foundation (optional, for formal reference)
  2. 03 Tagged URN domain: the base domain
  3. 04 Predicates: the four derived predicates
  4. 05 Specificity: scoring
  5. 06 Cap URN structure: how Cap URNs compose four structural coordinates
  6. 07 Dispatch: the central routing rule
  7. 08 Ranking: selection among valid candidates
  8. 09 Machine notation: wire multiple caps into a data-flow graph
  9. 10 Validation rules: structural constraints
  10. 11 Media URNs: media type details
  11. 12 Protocol: wire format, connection setup, streaming, and flow control
  12. 13 Cartridge runtime: writing handlers
  13. 14 Host and relay: cartridge hosting infrastructure
  14. 15 Execution: DAG orchestration and planning
  15. 16 Cartridge development: building cartridges
  16. 17 Runtime errors: error vocabulary and propagation
  17. 18 The capdag CLI: the command-line tool and the cartridge-development loop

Terminology

Term Definition
Tagged URN A URN with structure prefix:key1=value1;key2=value2;...
Media URN A Tagged URN with prefix media: describing a data type
Cap URN A Tagged URN with prefix cap: describing a capability
Pattern A URN used as a template or constraint
Instance A URN representing a concrete value or request
Candidate A registered capability that can handle requests
Request A capability URN describing what is needed
Dispatch The act of routing a request to a valid candidate
Specificity A numeric score measuring how constrained a URN is
Wildcard A special value (*, ?, !) with matching semantics
Machine An ordered collection of MachineStrands wired into data-flow graphs
MachineStrand A maximal connected component of resolved cap edges with anchors
Machine notation The textual encoding of a Machine (see Machine notation)
Cartridge A standalone binary that provides one or more capabilities
Cap Kind A logical classification of a cap into one of Identity, Source, Sink, Effect, or Transform, derived from (in, out, y, effect). See Cap URN structure: cap kinds.
Top type media:, the universal wildcard for media URNs. Every media URN conforms to it. A side typed media: reads as “any A.”
Unit type media:void, the nullary value. A side typed media:void reads as “()”: no meaningful data flows there. It is distinct from the top type. Atomic: refinements like media:void;text are parse errors.

Notational conventions

Order-theoretic notation

  • a <= b: “a is at least as specific as b” (a refines b)
  • a >= b: “a is at least as general as b” (equivalent to b <= a)

Cap URN components

A Cap URN c is written as a quadruple:

c = (i, o, y, e)

where:

  • i = input media URN (the in tag value)
  • o = output media URN (the out tag value)
  • y = non-direction cap-tags (op, ext, model, and so on; all are arbitrary and none has functional privilege)
  • e = effect on runtime media/type identity

Foundation

This specification builds on the mathematical foundations in Formal foundations, which defines the core dispatch relation:

Dispatch(p, r) <=> i_r <= i_p /\ gives(p, i_r) <= o_r /\ (e_r = ? \/ e_p = e_r) /\ y_p satisfies y_r

A request is a call: it states what it sends (media: sends anything), and asks of what the candidate gives for it — a declared output read complete, or what an effect=none or effect=patch candidate makes of what is sent. The candidate’s own tags are read complete. A search may leave a side unknown.

The numbered documents fill in operational details: wildcard truth tables, normalization rules, specificity scoring, validation constraints, machine notation, protocol, runtime, execution, and development patterns.


Conformance

An implementation conforms to this specification if:

  1. All Tagged URNs normalize identically (per Tagged URN domain)
  2. All predicates compute identically (per Predicates)
  3. Specificity scores match (per Specificity)
  4. Dispatch validity matches (per Dispatch)
  5. All validation rules are enforced (per Validation rules)

Ranking policy (Ranking) may vary by subsystem, but dispatch validity must not.