diff --git a/pkgs/fleet/docs/verbs.md b/pkgs/fleet/docs/verbs.md new file mode 100644 index 0000000000..7c0c7918ec --- /dev/null +++ b/pkgs/fleet/docs/verbs.md @@ -0,0 +1,75 @@ +# fleet verb reference + +Contract for each verb of the `fleet` multicall binary. The code is the +source of truth: the dispatch in `crates/fleet/src/main.rs` and the domain +handlers. The `subcommands` arrays in `crates/fleet-registry/src/lib.rs` are +stale (the queue domain lists about 16 verbs, the code dispatches 31); do not +generate docs from them until they are fixed. + +Invocation: `fleet [args]`, or the domain's alias as argv0 +(`repo-queue`, `queue-broker`, `secrets-broker`, `laptop-agent-broker`, +`atlas-search`, `laptop-agent`). + +## Root + +| Verb | Contract | +|------|----------| +| `init` | Initialise fleet configuration. | +| `version`, `--version`, `-V` | Print the version. | +| `capabilities` | List available domains and their state. | +| `help [domain]` | Print help for the binary or one domain. | + +Exit codes: `0` success; `2` usage error; `69` (`EX_UNAVAILABLE`) when a +domain is unavailable (capability stub). + +## queue + +Client for the repo-queue broker (`crates/fleet-queue/src/client.rs`). + +| Verb | Contract | +|------|----------| +| `validate` | Validate a packet without writing it. | +| `enqueue` | Add a packet to the queue. | +| `list` | List items, with filters. | +| `claim` | Claim the highest-priority eligible item for a worker and lane. | +| `release` | Release a claim (requires `--reason`). | +| `lane` | Inspect or set lane state. | +| `bind` | Bind an item to a task reference. | +| `heartbeat` | Extend a claim's lease. | +| `checkpoint` | Record progress and the next action on a claimed item. | +| `park` | Park an item until its delay or a wake. | +| `wake` | Return a parked item to eligible. | +| `block`, `unblock` | Mark an item blocked with a reason class, or clear it. | +| `dep-recheck` | Re-evaluate dependency edges. | +| `quarantine-recheck` | Re-evaluate quarantined items. | +| `cancel` | Cancel an item. | +| `revive` | Reopen a failed or cancelled item. | +| `fail` | Mark a claimed item failed, with a reason class. | +| `complete` | Mark a claimed item done with a structured result. | +| `verify-disposition` | Verify a recorded disposition. | +| `timeline`, `history` | Event timeline for one item (same handler). | +| `models` | Model catalog and pool information. | +| `health` | Broker health and per-queue counts. | +| `signal` | Send a signal to a worker or item. | +| `fallback` | `scan`, `status`, `claim`, `heartbeat`, `release` (fallback mode). | +| `dispatch` | `status`, `launch`, `enqueue` (`placement.rs`). | +| `session` | Placement session commands. | +| `surfaces` | Print the placement surface registry (`pkgs/fleet/fleet-surfaces.json`) as JSON. Read-only; takes `[--registry PATH]`. | +| `outbox` | Creation outbox group. | +| `stack` | Stack group. | + +## Other domains + +| Domain and verb | Contract | +|-----------------|----------| +| `serve` | Serve role (`fleet-serve`). | +| `proxy serve`, `connect`, `init`, `ssh`, `splice`, `get`, `put` | Proxy leaves. `connect` takes connection flags; `put` takes mode and no-resume flags. | +| `dispatch status`, `launch`, `enqueue` | Dispatch status, launch a run, enqueue work (`crates/fleet-dispatch`). | +| `dispatch-test scan`, `submit`, `status` | Test-dispatch scan, submit and status (`crates/fleet-dispatch-test`). | +| `secrets get`, `list` | Secret lookup and listing. | +| `gh `, `tiers`, `cache-serve`, `cache-status`, `--raw` | Pass-through to `gh`; tier information; cache serve and status. | +| `search search`, `get-chunk` | Search the index and fetch a chunk. The `serve` alias is also accepted. | +| `laptop-agent health`, `jobs`, `kill`, `exec`, `run`, `poll`, `fetch` | Laptop-agent broker operations. | + +Note: `scripts/fleet` is a directory of helper scripts, not the multicall +binary. diff --git a/pkgs/id/ARCHITECTURE.md b/pkgs/id/ARCHITECTURE.md index a2f1f73e13..5ab749d0a9 100644 --- a/pkgs/id/ARCHITECTURE.md +++ b/pkgs/id/ARCHITECTURE.md @@ -31,6 +31,28 @@ System architecture for the `id` peer-to-peer file sharing CLI. └──────────────────────────────────────────────────────────────────┘ ``` +## Public API and Crate Surface + +Crates in `pkgs/id/crates/` and the root `id` package, classified by +dependents (checked against `Cargo.toml` and a repo-wide grep; no `id-*` +crate is consumed outside `pkgs/id/`). + +| Crate | Classification | Notes | +|-------|----------------|-------| +| `id` (root, `src/`) | Public surface | The only crate whose `lib.rs` re-exports the API; the CLI and binaries build on it. | +| `id-core` | Public surface (shared core) | Depended on by 10 crates. The root re-exports a subset (`abuse`, `access`, `connectivity`, `discovery`, `frames`, `holders`, `membership`, `rejection`, `residency`, `sync_method`, `tuple`, `waiting`, plus `KEY_FILE`, `CLIENT_KEY_FILE`, `SERVE_LOCK`, `is_node_id`). Modules not re-exported by `id` are internal to the workspace. | +| `id-caps`, `id-store`, `id-events`, `id-groups`, `id-sync`, `id-worlds`, `id-directory`, `id-web` | Internal | Used only by sibling crates and the root. | +| `id-cli` | Internal (binary) | Only the root depends on it. | +| `id-native-shell` | Internal (app) | Not a default workspace member. | +| `id-currency-registry`, `id-render` | Internal, no dependents | Candidates for removal or for documenting as unused. | + +Standalone examples and benchmarks (`examples/`, `benchmarks`) are not +public API. Vendored crates (`vendor/p2panda-sync`, `vendor/p2panda-encryption`) +are third-party code. + +Rustdoc coverage on public items is about 99% in `id-core` and the root +crate. `missing_docs = "warn"` is set in both `Cargo.toml` files. + ## Core Modules ### Entry Point (`main.rs`, `lib.rs`) diff --git a/pkgs/id/crates/id-core/src/membership/mod.rs b/pkgs/id/crates/id-core/src/membership/mod.rs index a13b24fcda..1476aebba2 100644 --- a/pkgs/id/crates/id-core/src/membership/mod.rs +++ b/pkgs/id/crates/id-core/src/membership/mod.rs @@ -39,6 +39,7 @@ pub use layer::{CausalEvent, Membership, MembershipError, Outcome, Refusal, Role #[derive( Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, std::hash::Hash, Serialize, Deserialize, )] +/// The identity an author is recorded under. pub enum AuthId { /// An author's Ed25519 verifying key. Key([u8; 32]), diff --git a/pkgs/id/crates/id-core/src/residency.rs b/pkgs/id/crates/id-core/src/residency.rs index f6180e2eea..cd872f6c2c 100644 --- a/pkgs/id/crates/id-core/src/residency.rs +++ b/pkgs/id/crates/id-core/src/residency.rs @@ -195,6 +195,7 @@ pub enum DenyReason { OutOfPolicy(Plane), } +/// The outcome of a residency check: allowed, or refused. #[derive(Clone, Debug, PartialEq, Eq)] pub enum Decision { /// Every required plane and hop was allowed. diff --git a/pkgs/id/src/backup.rs b/pkgs/id/src/backup.rs index 934200e7b1..7fb8bccd3e 100644 --- a/pkgs/id/src/backup.rs +++ b/pkgs/id/src/backup.rs @@ -81,8 +81,11 @@ const MAX_LANES: u32 = 4; /// Per-identity download budget from the #5033 decision: 10 per hour, /// 50 per day, per `H(pub)`. pub const DOWNLOAD_HOUR_LIMIT: u64 = 10; +/// Length of the hourly backup-download window, in milliseconds. pub const DOWNLOAD_HOUR_WINDOW_MS: u64 = 3_600_000; +/// Maximum backup downloads allowed per day window. pub const DOWNLOAD_DAY_LIMIT: u64 = 50; +/// Length of the daily backup-download window, in milliseconds. pub const DOWNLOAD_DAY_WINDOW_MS: u64 = 86_400_000; /// `H(pub)`: SHA-256 of the identity public key. The only identity a diff --git a/pkgs/id/src/currency/gateway.rs b/pkgs/id/src/currency/gateway.rs index c862c9888b..4ae3b3d305 100644 --- a/pkgs/id/src/currency/gateway.rs +++ b/pkgs/id/src/currency/gateway.rs @@ -189,6 +189,7 @@ pub enum GatewayError { rename_all = "snake_case", deny_unknown_fields )] +/// A currency operation a caller can submit through the gateway. pub enum CurrencyOp { /// Register a new currency under the caller's account. RegisterCurrency(RegisterCurrency), diff --git a/pkgs/mcpx/docs/SUMMARY.md b/pkgs/mcpx/docs/SUMMARY.md index e67ecd91ab..733eb76f34 100644 --- a/pkgs/mcpx/docs/SUMMARY.md +++ b/pkgs/mcpx/docs/SUMMARY.md @@ -44,6 +44,7 @@ - [Research and incidental findings](research-and-findings.md) - [Script runtimes, permission profiles and presets](runtimes.md) - [Schema validation (`internal/schemaval`)](schema-validation.md) +- [MCP tool reference](tool-reference.md) - [Scripts](scripts.md) - [mcpx](story.md) - [mcpx Development Strategies & Lessons Learned](work-strategies.md) diff --git a/pkgs/mcpx/docs/compendium.manifest.json b/pkgs/mcpx/docs/compendium.manifest.json index 2ab0068617..2cb89ace07 100644 --- a/pkgs/mcpx/docs/compendium.manifest.json +++ b/pkgs/mcpx/docs/compendium.manifest.json @@ -515,6 +515,13 @@ "lines": 227, "note": "reference (#144) and L2 (#146); generated, and linked from the book" }, + { + "path": "docs/tool-reference.md", + "chapter": null, + "role": "included", + "lines": 87, + "note": "API-level MCP tool reference (#6380 slice 3, #11190); linked from SUMMARY" + }, { "path": "docs/plugin-discovery.md", "chapter": "designs", diff --git a/pkgs/mcpx/docs/tool-reference.md b/pkgs/mcpx/docs/tool-reference.md new file mode 100644 index 0000000000..e3f9c5c56b --- /dev/null +++ b/pkgs/mcpx/docs/tool-reference.md @@ -0,0 +1,87 @@ +# MCP tool reference + +API-level reference for the tools mcpx exposes to MCP clients. For the +route and CLI mapping of every operation, see [Parity](parity.md). For the +protocol, see [MCP](mcp.md). + +This page describes the surface as implemented in +`internal/mcpserver/server.go` (hand-written tools) and +`internal/mcpserver/ops.go` (generated tools). It documents behaviour; it +does not change it. + +## Surfaces + +| Surface | Tools | Source | +|---------|-------|--------| +| Hand-written | 12 | `internal/mcpserver/server.go`, `Tools()` | +| Generated | one `mcpx_` per operation | `internal/mcpserver/ops.go`, `OpTools` | +| Dynamic | adapter, OpenAPI, recipe, reactive, passthrough, raw | `internal/cli/serve.go` | + +Dynamic tools exist only when their upstream or configuration is present. +Their names are derived from the upstream: `_`, OpenAPI +`operationId` (with `_2`-style suffixes for collisions), `recipe_`, +and `_` on the raw surface (`?codemode=false`). + +## Hand-written tools + +| Tool | Parameters | Purpose | +|------|------------|---------| +| `mcpx_namespaces` | none | List configured namespaces. | +| `mcpx_catalog` | `budget`, `bias` | Catalog of available tools, sized to a budget. | +| `mcpx_types` | `namespaces` | TypeScript signatures for namespaces. | +| `mcpx_search` | `query`, `limit` | Search tools by name or description. | +| `mcpx_call` | `namespace`, `tool`, `arguments` | Call one upstream tool. | +| `mcpx_exec` | `source`, `timeoutSec` | Run a Code Mode script. | +| `mcpx_log` | `since`, `level`, `event`, `limit` | Read daemon log entries. | +| `mcpx_stats` | `dimension` (enum) | Usage and timing statistics. | +| `mcpx_registry` | `query`, `limit` | Search the server registry. | +| `mcpx_status` | none | Daemon status. | +| `mcpx_batch` | `calls`, `stopOnError`, `parallel` | Run several calls in one request. | +| `batch_call` | as `mcpx_batch` | Alias of `mcpx_batch`. The reactive-surface version has a different schema. | + +## Generated tools + +Each operation in `internal/api/ops.go` `Ops()` produces one +`mcpx_` tool, except: + +- operations covered by a hand-written tool (`status`, `namespaces`, + `search`, `types`, `catalog`, `call`, `call_path`, `batch`, `exec`); +- streaming operations (`events`); +- operations marked `NoTool` (`secrets_set`). + +Input schemas come from each operation's `Params` through `InputSchema()`. +Annotations are derived from the operation: + +| Annotation | Value | +|------------|-------| +| `readOnlyHint` | `!Mutating` | +| `idempotentHint` | `!Mutating \|\| Idempotent` | +| `destructiveHint` | from the operation | +| `openWorldHint` | `true` | + +The per-operation name, method, path and CLI mapping is in +[Parity](parity.md). Because that table is generated from `Ops()`, prefer +it over any hand-maintained list. + +## Return values + +- Operation tools return pretty-printed JSON text, or raw text when the + operation sets `Text`. +- An empty upstream body returns `(the daemon answered with an empty body)`. +- Tool failures return a result with `isError: true` and the error text. + Text the tool produced before failing is kept ahead of the error. + +## Errors + +| Condition | Result | +|-----------|--------| +| Invalid parameters | JSON-RPC error `-32602`. | +| Upstream JSON-RPC error | Relayed as `UpstreamError`. | +| Unknown name on the raw surface | `no tool named "" on the raw surface (codemode=false)`. | + +## Known gaps + +- Tool inputs and outputs are not yet validated against their JSON Schemas + (see [Protocol](protocol.md), known gaps). +- Operation counts in [interfaces](interfaces.md) and [HTTP API](http-api.md) + predate the current operation set; the live count comes from `Ops()`. diff --git a/planning/architecture/README.md b/planning/architecture/README.md index 45f29d0cf6..022dd7f6f4 100644 --- a/planning/architecture/README.md +++ b/planning/architecture/README.md @@ -91,7 +91,10 @@ records. ## Package architecture docs (living, with the code) -- [id — architecture](../../pkgs/id/ARCHITECTURE.md) +- [id — architecture](../../pkgs/id/ARCHITECTURE.md) (includes the public-vs-internal crate section) +- [mcpx — MCP tool reference](../../pkgs/mcpx/docs/tool-reference.md) +- [fleet — verb reference](../../pkgs/fleet/docs/verbs.md) +- [pm-stack — aggregator routes](../../pm-stack/docs/routes.md) - Package docs folders: `pkgs/id/docs/`, `pkgs/mcpx/docs/` (see the documentation map in [`doc/README.md`](../../doc/README.md)). diff --git a/pm-stack/docs/routes.md b/pm-stack/docs/routes.md new file mode 100644 index 0000000000..8b673efbaa --- /dev/null +++ b/pm-stack/docs/routes.md @@ -0,0 +1,80 @@ +# pm-stack aggregator routes + +HTTP routes served by the aggregator (`pm-stack/aggregator/src/server.ts`). +Routing is a single handler: each path is a branch in sequence, and unknown +paths return the not-found response. The page list is in +`pm-stack/aggregator/src/pages.ts` (`PAGES`); derive any table from it rather +than maintaining one by hand. + +Method rule: a route marked GET answers GET as its contract. Other methods +on GET-only routes are unsupported. Some routes are not method-guarded in the +code, so do not rely on them rejecting other methods. + +## GET JSON (machine surface) + +Each HTML page has a JSON twin, plus a few JSON-only endpoints: + +- `/api/overview.json`, `/api/today.json`, `/api/digest.json`, + `/api/digests.json`, `/api/attention.json`, `/api/needs-drew.json` +- `/api/queue.json`, `/api/orchestration.json`, `/api/board.json`, + `/api/roadmap.json`, `/api/releases.json` +- `/api/quota.json`, `/api/quota/service.json`, `/api/quota-analytics.json`, + `/api/flow-analytics.json`, `/api/forecasts.json` +- `/api/dns.json`, `/api/aa.json`, `/api/search.json`, `/api/registry.json`, + `/api/conflicts.json`, `/api/projects.json`, `/api/program.json`, + `/api/program-project.json` +- `/api/events.json`, `/api/activity.json`, `/api/views.json`, + `/api/actions.json`, `/api/comments.json`, `/api/comments/queue.json`, + `/api/coverage.json`, `/api/alerts.json`, `/api/alerts/preferences.json`, + `/api/notifications.json`, `/api/freshness-events.json` +- `/api/health`, `/api/author-identities` +- `/api/item/.json` + +## GET HTML pages + +`/`, `/board`, `/today`, `/digest`, `/queue`, `/roadmap`, `/quota`, +`/quota/service/`, `/attention`, `/decisions`, `/decisions/`, +`/answer/`, `/dns`, `/aa`, `/sessions`, `/search`, `/events`, +`/projects` (redirects to `/program`), `/conflicts`, `/program`, +`/program/`, `/health`, `/pages`, `/comments`, `/alerts`, +`/alerts/preferences`, `/notifications`, `/item/`, `/discuss/`. + +Fragments for live updates: `/frag/overview`, `/frag/board`, `/frag/today`, +`/frag/queue`, `/frag/attention/header`, `/frag/attention/queues`, +`/frag/attention/sessions`. + +Stream: `GET /freshness/stream` (server-sent events). + +## Writes (POST unless noted) + +| Route | Methods | Purpose | +|-------|---------|---------| +| `/api/roadmap/annotations`, `/api/roadmap/annotations/alias` | POST | Roadmap annotations. | +| `/api/comments`, `/api/comments/triage`, `/api/comments/github-result` | POST | Comment submission, triage and result. | +| `/api/actions`, `/api/actions/batch`, `/api/actions/result` | POST | Action submission and results. | +| `/quota/refresh`, `/api/quota/refresh` | POST | Refresh quota data. | +| `/api/alerts` | POST | Create an alert. | +| `/api/alerts//ack`, `/api/alerts//close` | POST | Acknowledge or close an alert. | +| `/api/decision-sets`, `/api/decision-sets/submit` | POST | Create and submit decision sets. | +| `/api/decision-sets//events` | GET, POST | Decision-set events. | +| `/api/decisions//submit`, `/defer`, `/request-info` | POST | Decision actions. | +| `/api/decisions//drafts` | GET, POST | Decision drafts. | +| `/api/decisions//events` | GET, POST | Decision events. | +| `/api/needs-drew//answer` | POST | Answer a needs-Drew item. | +| `/api/sw-probe` | POST records; GET summarises | Service-worker probe. | +| `/api/push/subscriptions` | POST (create), DELETE (remove) | Push subscriptions; other methods return 405. | +| `/api/push/test`, `/api/push/test-class` | POST | Push test sends. | +| `/api/admin/identity-registry` | GET, POST, DELETE | Identity registry administration. | + +## Static and PWA assets + +`/sw.js`, `/manifest.webmanifest`, `/icons/icon-192.png`, +`/icons/icon-512.png`, `/icons/icon-maskable-512.png`, +`/icons/apple-touch-icon.png`, `/assets/app.css`, `/assets/datastar.js`, +`/assets/aa-explorer-computations.js`, `/assets/push-client.js`, +`/assets/freshness-client.js`. + +## Other listeners + +`freshness-ipc.ts` exposes `POST /publish` on its own listener, separate +from the dashboard handler.