Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD across contents and paths, upstream package/repo coordinates -> @golem15/msd-core and golem15com/msd-core. Deep links into upstream history, sibling upstream packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is. Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line, package/plugin identity, regenerated lockfile, install-tree fixtures, derived registries and benchmark baseline; migration checksum baseline re-locked (MSD keeps its own install state, so no install had applied the old sums); sort-order and regex-escaped expectations in tests adjusted.
20 KiB
ADR-1244 — Capability Ecosystem: third-party authoring, versioned manifests, and URL import/upgrade/remove
- Status: Accepted — ratified 2026-07-17 (originally Proposed 2026-06-14); see "Ratification" below
- Date: 2026-06-14
- Amended by: ADR-2782 (Reviewer Lane capability surface) — D5 gains a fourth executable-surface disclosure class, the reviewer lane, which is the first disclosed surface that receives data rather than only executing: a lane is piped plan text, requirements, research findings, and
CONTEXT.mddecisions. D9's capability matrix gains a reviewer-lane column. - Amended by: ADR-2363 (Capability instruction surfaces) — D5 gains a fifth disclosure class, and the first that is not executable: the instruction surface. D5's binary of "executable surfaces get consent, everything else is non-executable and gets a lighter note" is replaced by three classes, because that binary grouped an agent-invocable
SKILL.mdbody with an inert asset on the strength of a property ("does not execute code") that is true and not the relevant one — the agent is the interpreter. Capability skill bodies are recorded as trusted and unscanned, and content scanning is explicitly rejected rather than deferred.
Relationship to other ADRs. This ADR amends and extends ADR-857 Decisions 7 and 8 — it does not reverse them. ADR-857 D7 deferred third-party code-loading "to its own ADR"; D8 deferred third-party CLI support "to an external loader + trust/validation gate, no rework because runtimes are already descriptors." This is that ADR, and it delivers that gate. It builds on ADR-894 (capability declaration format), ADR-1016 (runtime capability descriptor), and ADR-58 (InstallPlan seam). Tracked by #1244. Target release: 1.6.0.
Ratification (2026-07-17): Proposed → Accepted
Ratified by explicit maintainer directive; the Status field sat at Proposed for 33 days after the owning issue and all six phase sub-issues had already closed as shipped.
Evidence the decision shipped:
- Issue #1244 and all six phase sub-issues (#1430–#1435, Phase 1 through Phase 6) are CLOSED /
stateReason: COMPLETED. - D1 (versioned manifest):
capabilities/*/capability.jsoncarryversion+engines(confirmed inai-integration,antigravity,claude-orchestration). - D2 (runtime overlay):
src/capability-loader.cts:486exportsloadRegistry({ includeInstalled }). - D3 (source resolver):
src/capability-source.cts:1080exportsresolveCapabilitySource, backed by the four adaptersresolveLocal(861),resolveGit(892),resolveNpm(944),resolveTarball(1017). - D4 (ledger):
src/capability-ledger.cts(42.4K) exists withtests/capability-ledger.test.cjs(111.0K) covering it. - D5 (trust model):
src/capability-trust.ctsandsrc/capability-consent.ctsexist;strictKnownRegistriesis threaded throughsrc/capability-lifecycle.ctsat lines 171, 881, 956, and 1079, each backed bytests/capability-trust.test.cjsandtests/capability-consent.test.cjs. - D6 (upgrade/compat):
src/capability-lifecycle.cts:1078implementsupgradeCapabilityunder the documented atomic stage-then-swap (comment header at line 1056);compatVersionsdowngrade handling is present at lines 126, 920, and 1111. - D9 (capability matrix):
docs/reference/capability-matrix.md(9.4K) exists and is generated from the registry.
Governance: owning issue #1244, stateReason: COMPLETED, closed 2026-07-07.
Known gaps at ratification: the D8 cross-reference promised back into ADR-857 ("D7 and D8... extended by ADR-1244") was never written — docs/adr/857-capability-system.md has no mention of ADR-1244. And epic #1900 (ADR-1244 edge hardening: MCP arg/cwd confinement, tarball/registry SSRF denylist, duplicated injection patterns) remains OPEN with all three of its filed children (#1901, #1902, #1903) closed NOT_PLANNED — the epic's own text scopes this as post-ship hardening on an already fail-closed pipeline, not a reversal of any D1–D9 decision, but the hardening itself is not yet scheduled.
Context
ADR-857 turned the five-step loop into a host with 12 Loop Extension Points and made every feature a Capability — a folder capabilities/<id>/capability.json declaring owned skills/agents, lifecycle hooks, a federated config slice, and loop-extension registrations (step / contribution / gate). 32 capabilities ship today (20 role:feature, 12 role:runtime). The architecture is in place; the ecosystem is not.
Three structural facts make third-party capabilities impossible today:
-
The registry is a build-time artifact.
scripts/gen-capability-registry.cjsreadscapabilities/*/capability.jsonat build time and emitsmsd-core/bin/lib/capability-registry.cjs, which is committed and shipped read-only. Every runtime consumer (config-loader.cjs,surface.cjs,capability-state.cjs, command dispatch inmsd-tools.cjs)require()s that generated file. Nothing readscapability.jsonat runtime. A capability that is not in the shipped package literally cannot be seen by config federation, surface, state resolution, or dispatch. There is no build step on a user's machine. -
Capabilities are unversioned.
capability.jsoncarries noversion. Version lives only at the registry schema level (SCHEMA_VERSION = '1') and on the package manifests (package.json,.claude-plugin/plugin.json,gemini-extension.json, stamped byscripts/sync-manifest-versions.cjs). "Is there a newer version of this capability?" and "does this capability work with my MSD version?" are both undefined. -
There is no per-capability install/upgrade/remove. The only uninstall surface is whole-product (
bin/install.js --uninstall), which deletes everything matching themsd-*prefix with no record of what an install wrote. Upgrade of one capability, and clean removal of one capability, are impossible.
The maintainer has decided the 1.6.0 scope: full ecosystem (the live loader ships in 1.6.0, not just docs) and full first-party parity for third-party capabilities (they may ship the same executable surfaces MSD ships — hooks, MCP servers, command modules), mediated by a trust/integrity/consent gate. This raises the security stakes and makes the trust model load-bearing.
The crux for every decision below: close the build-time/runtime gap with a runtime overlay, and make every executable surface pass through one consent + integrity seam.
Decisions
D1 — Versioned capability manifest
capability.json gains:
version— semver, required. The registry rejects a capability without one; a parity test fails the build if any native manifest lacks a version.engines.msd— a semver range expressing host compatibility (e.g.">=1.6.0 <3.0.0"). Modelled on VS Code'sengines.vscode. A hard gate at install and at load.compatVersions(optional) — a capability-version → min-msd-version table for graceful downgrade. Modelled on Obsidian'sversions.json. Only meaningful for sources that enumerate versions (git tags, registry, npm).integrity(optional) —sha512-<base64>of the capability bundle, populated by a registry or recorded at install.provenance(optional) —{ sourceRepo, commit }; SHOULD be emitted in CI for first-party and curated capabilities.
The build-time validator in gen-capability-registry.cjs is extended to enforce these fields. Native capabilities are stamped at release (D6). Rationale: versioning is the data substrate every other decision depends on — upgrade, compatibility, integrity, and the matrix all key off it.
D2 — Runtime Capability Registry overlay
Promote the registry from a frozen data file to a module with an interface:
loadRegistry({ includeInstalled }) → composed registry
It composes first-party (shipped, frozen) ∪ installed overlay — third-party manifests read at runtime from a per-scope install root (global: ~/.msd/capabilities/<id>/; project: .msd/capabilities/<id>/). The conformance validator (today build-time-only) is extracted to a runtime-callable validateCapability() / validateCrossCapability() and run at install time over the merged set, not just the new manifest.
Invariants enforced at install (over first-party ∪ ledger ∪ new):
- First-party always wins. An overlay whose
idcollides with a first-party id, or that claims a skill/agent stem already owned, is rejected. - Cross-capability invariants from ADR-894 (owner-uniqueness, config-key exclusivity, artifact-production-uniqueness per point,
requiresacyclic + tier-monotone) re-checked over the merged set.
Load-time re-gate (default-resilient): the host can change under an installed overlay (a MSD upgrade renames a loop point, or engines.msd no longer matches). At load, an invalid or incompatible overlay is skipped with a warning and flagged in the ledger as needing update — it never crashes the loop. This mirrors the existing defensive skip in capability-state.cjs.
Rationale: this is the load-bearing unlock. Without a runtime overlay seam, the loader, ledger, and dispatch have nowhere to land. Deletion test: remove the overlay and the third-party-install complexity reappears in every consumer.
D3 — Capability source resolver (the URL importer)
One seam, resolveCapabilitySource(spec), with one adapter per source kind:
| Spec form | Adapter |
|---|---|
<name>@<registry> |
registry |
https://…/repo.git#<tag> / #sha:<40-hex> |
git |
npm:@org/pkg@<range> |
npm |
https://…/cap-x.y.z.tgz |
tarball |
./local/path |
local |
Every adapter follows the same pipeline: fetch → verify integrity/SHA → check engines.msd → return a staged, validated bundle. Git/npm sources shell out through the existing shell-command-projection seam with bounded timeouts; tarball/registry fetch uses Node's https + crypto. The trust gate (D5) lives at this single seam. Rationale: multiple real adapters = a real seam (not hypothetical); adding a source kind = adding an adapter, not editing the loader.
D4 — Capability ledger
A per-runtime install manifest, e.g. ~/.claude/.msd-capabilities.json, recording per installed capability:
{
"<id>": {
"version": "1.2.0",
"source": "https://github.com/org/cap.git#sha:…",
"integrity": "sha512-…",
"files": ["skills/…", "agents/…"], // owned files written
"sharedEdits": [{ "file": "settings.json", "marker": "<id>" }]
}
}
The ledger is the commit point for installs/upgrades (atomic write, like surface.cjs writeSurface) and the basis for precise removal. It records not only owned files but fragments written into shared files (settings.json hooks, mcpServers) so removal can strip exactly those entries without deleting shared files. A reconciliation sweep on next run resolves crash orphans (files not in the ledger; ledger entries with missing files). Rationale: "remove by msd-* prefix" has whole-product blast radius and no record of ownership; the ledger gives selective, reversible, crash-safe install.
D5 — Trust model: artifact parity is full, trust posture is tiered
Third-party capabilities may ship the same artifacts first-party ships (full parity, per the maintainer's scope), but trust is not symmetric:
- First-party is implicitly trusted — it is the shipped package.
- Third-party requires explicit, informed, revocable consent + SHA-pinned integrity.
Hard rules (MUST):
- Install never executes capability code. Staging is copy-only; no
postinstall-equivalent. (npm--ignore-scriptslesson.) - Executable surfaces are disclosed and consented at install.
hooks,mcpServers, and command modules activate on the next tool call — there is no "first use" gate for a hook — so consent must be at install, naming every executable surface. The disclosure includes each MCP server'senvandcwd(#1459), because an environment variable (e.g.NODE_OPTIONS=--require evil.js) can change what a command does without touching the command or argv; the disclosure signature folds env/cwd in as stable sorted JSON so any add/change forces re-consent. Declining aborts cleanly. - Integrity is verified before extraction when an
integrity/SHA is available; mismatch aborts. (npm registry-signature lesson.) - Auto-update is OFF by default for third-party; enabling it still re-prompts when the executable set changes between versions. (VS Code stolen-PAT + silent-auto-update lesson.)
- Modules are
require()'d only from the capability's own install root — parent-directory traversal in declared paths is rejected. msd-*(andmsd-core-*,anthropic-*) ids/prefixes are reserved — third-party cannot impersonate first-party.strictKnownRegistries(managed/project config) can lock installs to an allowlist;[]means no external installs.- The consent signal for a project-scope capability is a user-owned consent store, NOT the in-repo ledger (#1459). The store lives at
${MSD_HOME||homedir()}/.msd/consent.json— outside any repository — keyed by(realpath(projectRoot), id)and bound to the bundle integrity + disclosure signature. Before activating a project-scope overlay (its declarative loop surfaces and its command dispatch) the loader requires a matching record on this machine; without it the capability is discovered-but-inactive. This retracts the prior limitation that a project-scope ledger living inside the repository was itself the consent — a forged/cloned project ledger could otherwise activate executable + declarative surfaces with no user decision. Global-scope installs (under the user's own home) need no per-project record.msd capability trust list/revokeaudit and revoke project consents.
Stated honestly: there is no sandbox. Node-level sandboxing is impractical and would defeat full parity. Consent + integrity + reversibility are the barrier. (Obsidian's honest acknowledgment.) Rationale: a one-time trust prompt does not make running arbitrary code safe; separating artifact parity from trust posture is what makes full parity defensible.
D6 — Upgrade and compatibility
- Atomic stage-then-swap. Upgrade fully stages (fetch + verify + validate) before swapping; the ledger write is the commit point; a reconciliation sweep handles crash orphans. A mid-upgrade crash leaves either the old or the new version fully intact — never a half-state.
- Two-layer compatibility.
engines.msdis a hard gate (block with a clear message at install and load);compatVersionsprovides graceful downgrade to the newest compatible version — but only for sources that enumerate versions (git tags, registry, npm). A bare tarball URL has one version and simply blocks. - Native version stamping.
scripts/sync-manifest-versions.cjs(or a parallel capability sweep) stampsversioninto nativecapabilities/*/capability.jsonat release; the existing version-sync regression guard is extended to cover them. - "Update available?" is a per-source matrix (git: fetch tags/manifest; registry: catalog; npm: dist-tags; tarball: not auto-detectable → manual only) — documented, not silently partial.
D7 — Registry-driven dispatch (sequenced last, behind the gate)
Fulfil ADR-857 D7's deferred "registry over hardcoded switch": msd-tools.cjs / command-routing-hub.cjs consult the (overlay-aware) registry's commands: [{ family, module, router }] and dispatch via dynamic require(module)[router](). This is where third-party code executes, so it is gated by the same consent (D5) and confined to the capability's install root. First-party in-tree modules (graphify, intel, audit) collapse onto the same seam (dogfooding). Sequenced last because it carries the highest risk.
D8 — Relationship to ADR-857 (amend, not reverse)
ADR-857 D7/D8 did not forbid third-party code — they deferred it pending (a) its own ADR and (b) a trust/validation gate. This ADR satisfies both. ADR-857 is updated to mark D7 and D8 "extended by ADR-1244." The only substantive change is moving third-party from "deferred" to "delivered, gated." The runtime overlay (D2) is consistent with 857's own direction ("each loop step authored as if it could become a Capability"; "registry over hardcoded switch").
D9 — The capability matrix
A generated-from-registry catalog at docs/reference/capability-matrix.md, mapping every capability to id, version, tier, extension points, hook kinds, and engines.msd — kept honest by a drift guard (like docs/INVENTORY.md). It includes a documented section where third-party authors register their capability. Whether MSD operates/advertises a central community registry is left TBD/TBA (see the PRD); the documentation mechanic ships regardless of that decision.
Consequences
Positive
- MSD becomes an actual platform: authors ship capabilities independently; users install/upgrade/remove them without forking or maintainer PRs.
- Versioned manifests give native capabilities a real version surface and make compatibility explicit.
- The overlay + ledger make install reversible and crash-safe; whole-product
--uninstallis no longer the only removal path. - The trust gate is concentrated at one seam (D3/D5) — auditable, testable, and the single place the security posture is enforced.
- D7 retires a long-standing hardcoded-switch debt and dogfoods first-party modules onto the same dispatch seam.
Negative / costs
- New permanent attack surface. URL import + third-party code execution at full parity is the highest-maintenance, highest-risk part of MSD. The trust/integrity/consent model is a forever responsibility.
- Runtime overlay couples the runtime validator to the ADR-894/1016 schema — a generative-parity assertion is required so build-time and runtime validators cannot drift.
- Per-runtime ledger × 16 runtimes multiplies the install/remove test surface (cross-platform fault injection required).
- Documentation breadth (COMMANDS / FEATURES / USER-GUIDE / CONFIGURATION / ARCHITECTURE / AGENTS + the generated matrix).
Risks & mitigations
- Malicious capability via auto-update → auto-update OFF by default; re-consent on executable-set change; SHA pin.
- Overlay drift / contract change under an installed capability → load-time re-gate, skip-with-warning, ledger flag.
- Half-state install/upgrade → ledger-as-commit-point + reconciliation sweep.
- Impersonation → reserved namespace;
strictKnownRegistriesallowlist. - Validator drift → shared validator module + generative-parity test.
Implementation phases (dependency-ordered)
- Versioned manifest (D1) + native stamping (D6) — the data substrate; the "documentation-release" piece.
- Runtime registry overlay (D2) — the structural unlock.
- Source resolver (D3) + ledger (D4) — additive, testable in isolation.
- Trust gate (D5) + upgrade/compat (D6).
- Registry-driven dispatch (D7) — last, behind the gate.
- Capability matrix (D9) + full diataxis documentation set.
Each phase ships as its own PR with a changeset and full gate compliance (per CONTRIBUTING: one concern per PR; docs-required for Added/Changed fragments).
Alternatives considered
- Stay build-time only (third parties fork or upstream-PR). Rejected — no ecosystem; every community capability becomes maintainer burden. This is the status quo 857 D7/D8 flagged.
- Declarative-only third-party (no hooks/MCP/code). Safer (matches 857 D7), but the maintainer chose full parity so authors ship the same power MSD ships — accepting the heavier trust model rather than a capped one.
- Centralized-registry-only (no URL import). Rejected for launch — gates every capability behind maintainer review (the Obsidian one-PR-per-version pitfall). URL/git import keeps distribution decentralized; a registry can layer on top later.
- Regenerate the committed registry on the user's machine at install. Rejected — requires the full build toolchain on every machine and mutates a shipped file; the overlay achieves the same without a build step.