On this page

Architecture atlas

Crate and module ledger

An ownership ledger for every workspace crate, its internal modules, dependency direction, and intended reasons to change it.

Status
22 workspace crates
For
Contributors choosing a change boundary
On this page
  1. Workspace ledger
  2. Module atlas
    1. Syntax and representation
    2. Values and generic operations
    3. Evaluation
    4. Execution and policy
    5. Kernel and agent bridge
    6. Reef, adapters, and configuration
  3. Complete source-module routing index
    1. Entrypoints are adapters
  4. Public boundaries versus implementation modules
  5. Workspace-level maintenance signals

The workspace contains 22 crates. The table below is a routing contract: start a change in the crate that owns the invariant, then let hosts adapt to it. Do not begin in a composition root merely because that is where a symptom appears.

Workspace ledger🔗

CrateOwnsInternal Shoal dependenciesChange it when…
shoal-astspans and the serializable language treethe language can represent a new form
shoal-syntaxmode-aware lexer, parser, parse status, canonical formatter, builtin registryastsource maps to a different AST or formatting rule
shoal-valueruntime value algebra, environments, methods, streams, tasks, rendering, stdin conversionasta value or generic value operation changes
shoal-evaltree-walk semantics, command dispatch, builtins, plans, ports, modules, Reef integrationadapters, ast, exec, journal, leash, picker, reef, secret, syntax, valueAST meaning or language-owned runtime behavior changes
shoal-execprocess spawning, capture, process groups, PTY modes, cancellation, OS sandbox applicationleashthe child-process/terminal boundary changes
shoal-leasheffects, content-addressed plans, policy verdicts, sandbox loweringauthority, approval, or containment semantics change
shoal-journalSQLite schema/query, transcript rows, CAS, spill, undo, GCdurable execution history or bytes change
shoal-reefscoped manifests, constraints, providers, locks, hash cache, executable views, runner selectionreproducible tool/script resolution changes
shoal-adaptersdeclarative command specifications, typed binding, output parsers, bundled adapter loadingast, valuean external CLI gains a structured Shoal surface
shoal-configlayered core config schema and provenanceCLI configuration loading or validation changes
shoal-promptpure prompt context and formatting, prompt-specific config/themes/modulesprompt display or prompt config changes
shoal-authbearer-token hashing, expiry, revocation, and persisted token storekernel identity proof changes
shoal-secretencrypted local secret map and permissionssecret-at-rest storage changes
shoal-protonewline-framed JSON-RPC, wire values/refs, RPC error codes, request/response typesthe kernel wire contract changes
shoal-kernelUnix-socket server, sessions, RPC routing, tasks, PTYs, plans, events, transcript refsast, auth, eval, exec, journal, leash, proto, syntax, valueremote/session semantics change
shoal-mcpMCP stdio facade, kernel client, tools, resources, resource subscriptionsnone normallythe agent-facing MCP projection changes
shoal-lsplexical editor service: diagnostics, formatting, completion, hoversyntaxeditor protocol behavior changes
shoal-historysmall journal inspection CLI/libraryjournalnon-interactive journal inspection changes
shoal-doctorinstallation/state diagnosticsadapters, journal, leasha user-visible health check changes
shoal-pickeralternate-screen fuzzy pickervalueinteractive selection UI changes
shoal-wasmcomponent validation, manifest checks, resource limits, ambient-import rejectionthe future WASM isolation boundary changes
shoalCLI actions, REPL host, editor integration, configuration assembly, prompt snapshotsadapters, ast, config, doctor, eval, journal, leash, prompt, syntax, valuethe human-facing composition root changes

Module atlas🔗

Syntax and representation🔗

flowchart LR
accTitle: Syntax and representation
accDescr: Shows the components and relationships described in Syntax and representation.
  Span["shoal-ast/span.rs\nbyte-offset spans"] --> AST["shoal-ast/ast.rs\nProgram, Stmt, Expr, Pattern"]
  Lexer["shoal-syntax/lexer.rs\nEXPR and CMD modes"] --> Parser["parser.rs + stmt/expr/command/pattern"]
  Parser --> AST
  AST --> Formatter["shoal-syntax/format.rs\ncanonical source"]
  Registry["shoal-syntax/commands.rs\ncanonical builtin names"] --> Parser

shoal-syntax is divided by grammar concern: lexer, parser, stmt, expr, command, pattern, block, string, and number. format walks the resulting AST. commands is the shared builtin-name registry used by evaluator and editor-facing classification.

Values and generic operations🔗

flowchart TB
accTitle: Values and generic operations
accDescr: Shows the components and relationships described in Values and generic operations.
  Value["lib.rs\nValue algebra + feed_bytes"]
  Env["env.rs\nlexical bindings"]
  Methods["methods/*\ntype-directed methods"]
  Stream["stream/*\npull protocol + lazy operators"]
  Task["task.rs\ncompletion and control hooks"]
  Render["render.rs\nhuman rendering"]
  JSON["json.rs\nstructured conversion"]
  Ports["ports.rs\nvalue-side IO traits"]
  Outcome["outcome.rs\nprocess/builtin result"]

  Value --> Env
  Value --> Methods
  Value --> Stream
  Value --> Task
  Value --> Render
  Value --> JSON
  Value --> Outcome
  Methods --> Ports

The methods directory separates list, record, string, numeric, path, outcome, task, and stream families. Stream operators live under stream/ because they own pull state, timeout propagation, single-consumption, and tee buffering rather than only method name dispatch.

Evaluation🔗

flowchart TB
accTitle: Evaluation
accDescr: Shows the components and relationships described in Evaluation.
  Entry["lib.rs\nEvaluator state + program loop"]
  Stmt["stmt.rs"] --> Expr["expr.rs / expr_access / expr_binop"]
  Expr --> Call["call.rs"]
  Expr --> Command["command.rs\ncommand dispatch"]
  Command --> Args["args.rs / coerce.rs"]
  Command --> Builtins["builtins.rs"]
  Command --> Host["host.rs\noutcome wrapping"]
  Command --> Script["script.rs"]
  Command --> Reef["reef*.rs"]
  Command --> Ports["ports.rs\nFs, Exec, Clock, Opener…"]
  Entry --> Modules["modules.rs / namespaces.rs"]
  Entry --> Journal["journal.rs"]
  Entry --> Plans["plan.rs / plan_derive.rs / plan_effects.rs"]
  Entry --> Streams["streams.rs / channels.rs"]

This is a tree-walk evaluator. lib.rs holds session state and the top-level evaluation loop; semantic cases are split by AST kind. command.rs is intentionally a high-fan-out dispatch point, so additions there deserve parity tests across callable, builtin, adapter, script, Reef, and external-command cases.

Execution and policy🔗

shoal-exec separates capture from pty and pty_session; cancel, watcher, and status normalize lifecycle behavior; which locates executables; sandbox selects the OS implementation. OS-specific enforcement is in Leash’s enforce and seatbelt modules. This is where the workspace’s unsafe and Unix-specific code should remain concentrated and reviewable.

flowchart LR
accTitle: Execution and policy
accDescr: Shows the components and relationships described in Execution and policy.
  Effects["leash/effects.rs"] --> Policy["leash/policy.rs"]
  Policy --> Lower["leash/enforce.rs"]
  Lower --> Request["exec/lib.rs\nExecSpec"]
  Request --> Capture["capture.rs"]
  Request --> Pty["pty.rs / pty_session.rs"]
  Capture --> Status["status.rs"]
  Pty --> Status
  Cancel["cancel.rs"] --> Capture
  Cancel --> Pty

Kernel and agent bridge🔗

The kernel’s dispatch.rs is a thin method router. Handler modules own session, execution/plan, value/event, task, and PTY families. session.rs owns shared evaluator/transcript state; wire.rs does bounded Value conversion; eventbus.rs owns rings, durable replay integration, and subscriber queues. lib.rs owns connection lifecycle and shared maps.

shoal-mcp is divided into a socket client, MCP tools, URI-backed resources, and the stdio server in lib. It deliberately consumes the public kernel contract rather than reaching into kernel memory.

Reef, adapters, and configuration🔗

flowchart TB
accTitle: Reef, adapters, and configuration
accDescr: Shows the components and relationships described in Reef, adapters, and configuration.
  Scope["reef/scope.rs\nnearest-first discovery"] --> Manifest["manifest.rs"]
  Manifest --> Resolve["resolve.rs"]
  Resolve --> Providers["npm / venv / mise / cargo / system"]
  Resolve --> Lock["lock.rs"]
  Lock --> Hash["hashcache.rs"]
  Resolve --> View["view.rs\ncontent-addressed PATH view"]
  Runner["runner.rs\nextension + shebang"] --> Resolve

  ConfigLoad["config/load.rs"] --> ConfigSchema["config/schema.rs"]
  AdapterLoad["adapters/lib.rs\nTOML specs"] --> Bind["typed argv binding"]
  Bind --> Parse["JSON / lines / CSV / records…"]

Core config and prompt config are separate systems. shoal-config loads the shell’s core schema; shoal-prompt has its own config and formatting modules. Reef manifests are also parsed through their own discovery path. Treating all three as one configuration object will miss real behavior.

Complete source-module routing index🔗

This index names every current Rust source module, including binary entrypoints and nested modules. It is intentionally mechanical: a newly added module should appear here in the same change so future maintainers can tell whether the architecture gained a boundary or only an implementation split.

CrateModules and responsibility
shoal-adapterslib — TOML model, catalog loading, argument binding, output parsers, bundled-spec access
shoal-astlib — exports/version surface; ast — nodes; span — byte spans
shoal-authlib — token store/verification; main — token-management CLI
shoal-configlib — typed config/public API; load — discovery/merge/env overrides; schema — shape validation and suggestions; error — located failures
shoal-doctorlib — diagnostic checks/results; main — standalone diagnostic CLI
shoal-evallib — evaluator state/program loop; stmt, expr, expr_access, expr_binop, pattern — tree-walk semantics; call, args, coerce, helpers — calls/signatures/coercion; command, builtins, host — ordered dispatch and outcome wrapping; ports — host capabilities; journal — statement lifecycle/undo hooks; modules, namespaces — imports and namespace values; plan, plan_derive, plan_effects — plan verbs/static effects; reef, reef_builtins, reef_resolve, script — tool and script resolution; streams, channels — language producers/event bridge; frecency — jump store integration
shoal-execlibExecSpec/ExecResult and orchestration; capture — pipe capture/spill; pty — foreground PTY tee and parked jobs; pty_session — long-lived terminal emulator; cancel — cancellation token/escalation; status — wait status normalization; watcher — child lifecycle polling; sandbox — pre-exec enforcement selection; which — executable lookup; main — standalone harness/entrypoint
shoal-historylib — journal lookup/render API; main — history CLI
shoal-journallib — journal API and entry/output records; schema — SQLite schema/version; query — filters; cas — compressed content store; gc — orphan/LRU/TTL collection; undo — inverse records and safe apply; transcript — durable transcript events; tests — crate-internal integration-style tests
shoal-kernelmain — daemon args/socket startup; lib — shared maps, server/connection lifecycle and types; dispatch — method router; session — attachment/session creation; handlers_session — parse/complete/explain/session views; handlers_exec — exec/plan/apply; handlers_value — value/blob/journal/event handlers; handlers_task — task/plan capability lifecycle; handlers_pty — PTY lifecycle; wire — navigation/encoding/elision/render bounds; eventbus — rings, durable replay, subscriber backpressure
shoal-leashlib — exported authority/enforcement API; effectsEffect/Plan; policy — TOML grants and verdicts; enforce — sandbox representation, Landlock, hashing/status; seatbelt — macOS profile generation; main — policy/enforcement CLI
shoal-lsplib — LSP service; main — stdio server entrypoint
shoal-mcpmain — stdio entrypoint/config; lib — MCP router/autostart/framing; client — attached kernel client and event forwarder; tools — tool schemas/mapping/bounds; resources — URI parser/list/read/subscribe
shoal-pickerlib — alternate-screen fuzzy picker and terminal lifecycle
shoal-promptlib — renderer API; context — immutable gathered facts; config/mod, config/schema, config/module_config — prompt loading/validation/module settings; format — template parsing; fmt — value formatting helpers; style — ANSI style model; themes — built-ins; render/mod, render/helpers, render/modules — pure rendering and module implementations
shoal-protolib — complete JSON-RPC frame/types/error/ref/wire-path contract
shoal-reeflib — public resolver model; manifest — native manifest; scope — native/foreign discovery; resolve — constraint/provider/lock policy; lock — lockfile; hashcache — executable identity cache; view — content-addressed PATH view; runner — extension/shebang runner table; version — constraints/order; timestamp — portable metadata time; report — resolution explanation; error — typed failures; provider/mod — provider trait/order; provider/npm, provider/venv, provider/mise, provider/cargo, provider/system — concrete candidate sources
shoal-secretlib — encrypted store and permission checks; main — secret CLI
shoal-syntaxlib — parse/format/status exports; commands — canonical builtin registry; format — AST formatter; lexer with lexer/number, lexer/string — mode-aware tokenization; parser with parser/stmt, parser/expr, parser/command, parser/pattern, parser/block — grammar implementation
shoal-valuelibValue, equality and stdin conversion; env — lexical chain; value_types — domain scalar types; outcome — command result; task — task state/hooks; ops — generic operators; json — JSON conversion; render — human output; ports — value-side callback traits; methods/mod, methods/list, methods/num, methods/outcome, methods/path, methods/record, methods/stream, methods/strops, methods/task — method families; methods/suggest — did-you-mean; stream/mod, stream/ops, stream/tee — pull state, lazy operators, fan-out
shoal-wasmlib — component/manifest validation, resource limits, ambient-import policy
shoalmain — CLI dispatch and non-interactive host; args — action parsing; repl — Reedline/evaluator session; adapters — bundled/extra catalog host loading; completer — context candidates/cache/ranking; highlight — editor coloring; keybindings — config-to-Reedline mapping; prompt — host fact gathering/snapshot adapter

Entrypoints are adapters🔗

Every main.rs should remain thin: parse process arguments/environment, construct the owning library, choose exit behavior, and report errors. Business rules placed only in a binary cannot be reused by the shoal companion launcher or exercised through library integration tests.

Public boundaries versus implementation modules🔗

Changing a private module is not automatically a local change. These cross-crate concepts are the effective public architecture:

ConceptCanonical ownerMain consumers
AST shape and AST_VERSION compatibilityast + protosyntax, eval, kernel clients
builtin namessyntax commandsparser, eval, completion, highlighter, LSP
Value kinds and equality/feed semanticsvalueeval, adapters, picker, kernel wire
effect and plan serializationleasheval, exec, kernel, agents
journal entry/output schemajournaleval, kernel, history, doctor
JSON-RPC codes and wire refsprotokernel and external clients
adapter TOML schemaadaptersbundled specs, config directories, evaluator
Reef manifest/lock formatreefevaluator, projects, reef commands

Workspace-level maintenance signals🔗

The root Cargo.toml declares a workspace lint policy, but member manifests do not currently opt in with [lints] workspace = true. CI still runs Clippy with warnings denied, so today the executable quality gate is the CI command rather than inherited manifest metadata. If lint inheritance is enabled, do it across the workspace and expect latent warnings rather than assuming the table is already active.

Workspace package metadata now uses the same alliecatowo/shoal repository as the checked-out remote and documentation links. Keep this as one workspace-level value rather than overriding it in individual crates.

Type to search every guide navigate open esc close
Diagram