Documentation menu

Connectors, ingest and publishing

How an org-os-kms instance pulls knowledge from other sources (ingest) and publishes its own (publish). Statements here were checked against the source in packages/org-os-kms/src/ and packages/toolkit-framework/src/ and the package tests, and the commands were run against a scratch instance; where something is a convention rather than code, it says so. For what the instance is and its other commands, see KMS; for the canon, the public plane and the publication gate, KMS-PLANES.

Run the CLI as node packages/org-os-kms/src/cli.mjs <verb> … (the commands below are written with the shorter org-os-kms, the name of the package’s bin). It has no --help; an unknown verb prints {"error": …} and exits 1.

1. Verbs

org-os-kms ingest  [--connector <name>] [--dry] [--dir <instance>]
org-os-kms publish [--apply] [--dry]            [--dir <instance>]
org-os-kms claims reconcile [--dry]             [--dir <instance>]
org-os-kms certified draft                      [--dir <instance>]
  • ingest pulls the connectors declared in kms.yaml under connectors: (each entry: name, config, and optionally a seed cursor; see “Cursor write-back” in section 10). It is a CLI verb only: it is not bound to close (or initialize), so nothing runs it automatically.
    • Fail-soft per connector. A connector that throws is reported as status: 'failed' (with error) and counted in report.failed; the others still run and the op still returns ok: true. A connector whose pull is not implemented is reported as status: 'not-implemented'. The CLI exits 1 when the report is ok: false (an operator error such as an unusable --connector, see below) and for unknown verbs/subcommands, but per-connector failures are still fail-soft (ok: true, exit 0), so the exit code does not signal them. Scripts must check all of: report.failed, any non-empty connectors[].errors, and any non-empty connectors[].invalid / connectors[].collided. The errors check matters because the atproto connector catches a per-peer failure inside itself: that peer is listed in connectors[].errors while the connector’s status stays 'ok' and report.failed stays 0, so a run where every peer failed still looks successful if you only read failed. invalid and collided list candidates that were dropped (see section 10). The report is not persisted anywhere; capture the JSON the command prints.
    • --connector <name> runs only that declared connector. If no declared connector has that name the run does nothing and returns report.warning: 'no declared connector named <name>'.
    • A --connector with no usable name (bare --connector, --connector --dry, or an empty value) is an operator-input error, not a connector failure: nothing runs, kms.yaml is not touched, and the result is ok: false with report.error: '--connector needs a name (usage: --connector <name>)'. It never falls back to running every connector. Note the CLI’s flag parser only understands --connector <name> (space-separated); --connector=<name> is not parsed as that flag, so use the space form. Omitting --connector entirely means all declared connectors.
    • --dry runs every pull and mapping and reports what would happen (candidates, invalid, collided) but stores nothing, writes no source-system card, applies no retractions, and writes no cursor (data/kms-cursors.json is not touched). Note that a dry run still performs the network pulls.
  • publish is described in section 2.

The ingest report, per connector: name, status, dry, pulled, candidates, stored, updated, unchanged, collisions, collided, invalid, retractions, errors. Top level: connectors, failed, and, only when set, warning (unknown --connector name), or error (unusable --connector value, or an unreadable data/kms-cursors.json; nothing runs in either case).

Exit codes. publish, ingest and validate exit 1 when the result is ok: false: operator errors, a failed publish (failed login/apply, failed static surface, partial PDS failures) and the refused mass delete (section 2). Every other verb keeps fail-soft behaviour (exit 1 only for { error } results such as an unknown verb or subcommand; e.g. render returns fail-soft ok: false deliberately and still exits 0). ingest’s per-connector failures are the exception described above: ok: true, exit 0, read failed/errors.

2. What close does (and does not) do

lifecycle close (declared in bind.mjs) ends with publish then sync.push; run from the CLI it currently stops at its bridge step, which reads a config that only lifecycle initialize loads (errors: ["bridge: Cannot read properties of undefined (reading 'adapter')"]), so run the verbs one at a time. The rest of this section describes what the publish verb does, which works on its own. publish runs in plan mode unless kms.yaml has publish.apply: true: it makes no PDS writes and writes no manifest. Plan mode is not read-only. When not --dry it still:

  • mints id (and grc20Id, see section 9) into the source yaml for objects that pass the gate, but only when a publication target exists: atproto.did, atproto.pds and atproto.nsid_authority are all set, or publish.static is not false. An instance with neither (a pull-only instance with publish.static: false) gets no yaml rewritten; the report’s minted count is then only a preview; and
  • regenerates the static surface (<publish.static_dir>, default public/) unless publish.static: false.

publish --dry is the fully read-only mode: no ids minted, no static files written, no PDS calls, no manifest. Real PDS writes need --apply (or publish.apply: true), atproto.did, atproto.pds, atproto.nsid_authority, and ATPROTO_APP_PASSWORD in the environment; if any is missing the atproto part reports not-configured (or planned when only apply is missing). Publish is a write op inside close, so a failed static surface (for example a missing publish.base_url) or failed PDS writes stop the lifecycle before sync.push. A failed login or a network error during apply is reported as atproto.status: 'failed' with an error message (never the credential) and ok: false, not thrown; in that case no manifest is written (nothing trustworthy came back) while the static surface step still runs from the last persisted manifest.

Mass-delete refusal. The plan deletes every manifest entry that is no longer selected. If an apply would run with no publishable items selected while the manifest still lists published records (an empty or misconfigured selection: check publish.gate, types_opt_in/types_opt_out, target and public_use), publish refuses: no login, no PDS call, atproto.status: 'failed', reason: 'refusing to delete every published record: ...', wouldDelete: <n>, deleted: 0, ok: false. Plan mode (no apply) is unchanged and just reports the counts. There is deliberately no other threshold: deleting some records is normal.

Nothing wires lifecycle close into the agent’s /close command today (the .claude/commands/close.md flow does not call org-os-kms). Run org-os-kms lifecycle close or org-os-kms publish explicitly.

3. The projection (what never leaves the instance)

publicView() (toolkit-framework/src/publishable.mjs) is applied to everything outbound (PDS records and static entries) and to inbound atproto records. It drops these fields:

notes, work_order, reviewed_by, review_needs, interpretation, uncertainty, tensions, risks_of_flattening, high_risk, consent_note, salvaged_from, legacy_status, additional_provenance

and provenance.surfaced_by. That list is the PRIVATE_FIELDS constant; read it there rather than trusting this copy if the framework version differs.

This is the framework floor, and it is all that plain publish applies besides the optional instance gate and, in a canon-shaped instance, the canon gate: it does not look at maturity (beyond held) or at source_lineage, so a draft with a publishable public_use publishes. The stricter canon publication gate runs in export and validate (KMS-PLANES), and in publish only where an instance with no plane role holds canon control data; there a draft is not published. The floor: only these types publish by default (claim-evidence, concept-lineage, encyclopedia-entry, implementation-record, option-entry, organization, relationship-record, resource, signal, track), source-system and public-use-boundary are opt-in via publish.types_opt_in (and publish.types_opt_out removes a type), person is never publishable, and an object needs public_use of ok-with-caveat, source-linked-unreviewed, reviewed-for-explanation or reviewed-for-guidance, and its maturity must not be held (no other maturity is part of the floor). An optional instance gate (publish.gate) can only narrow this. In an instance with no plane role whose knowledge base is canon-shaped, publish also runs the canon publication gate, which can only narrow it too (see Two planes, below: Each plane knows what it is).

Matching-only: a floor that no gate widens, and the egress audit

A type of a visibility-gated pack (org-os-needs-offers) is published only when its object holds every publish_requires value (visibility: public); an object without the field is refused. The floor is applied four times: the publish op withholds (report.withheld.visibility), planPublish fails closed (visibility floor: …) whatever called it, the registry bridge skips the object, and the export verb (selectForPublication) rejects it before anything is written to the commons. An instance gate runs after the floor and can only narrow it. A published record is cut to public_fields (and, in a shared lexicon, to that lexicon’s properties). The test is test/matching-only-egress.test.mjs: a sentinel in title, text and contact_route of a matching-only need must appear only in the private canon.

The closed audit list (read in this build, 2026-11-20):

PathVerdict
registry-bridge.mjsUpserted every bound object into data/needs.yaml / data/offers.yaml, tracked files that generators read. Changed: a gated type is skipped unless it clears its floor, and a row carries only public_fields. Applied to every instance, because the per-instance answers (tracked? remote? read by a generator?) for Brasil Regenerativo and refi-dao-os were not read in this build; the stricter default is safe for all.
render.site (renderSiteData)Writes the index (counts by type and maturity, no titles or fields) to the site data path. Changed: a gated type is counted only when the object passes the floor, so a node moving between matching-only and private moves no count; the private canon’s own data/kb/index.json is unchanged.
static/surface.mjs, pages/Take only the selected items; gated types are cut to public_fields before them (a public need’s contact_route does not reach api/need.json or a page).
planes/export-commons.mjs, planes/select-for-publication.mjsWrites data/kb/<type>.yaml into the commons, the public plane. Changed: selectForPublication applies the visibility floor after the commons’ policy registers the pack rules; a failing object is listed in floorRejected, never written. Test: the export case in test/matching-only-egress.test.mjs.
any field of a public record that names a non-public objectClosed (spec 6.3), by value. scrubUnpublishedRefs (src/visibility.mjs) no longer reads a closed list of field names: toRecord passes every non-private key and the pages print every extra field, so superseded_by, supersedes, parent, see_also, related or a field nobody listed can all carry a ref. For each selected item, at any depth (nested objects and arrays), a string that exactly equals the slug, id or type:slug of a local object that is not in the selected set (matching-only, private, undeclared, gate-rejected) is removed from its array, or its key is dropped when it is a scalar. It keeps at:// URIs, strings that resolve to nothing local, and refs to a selected object; an ambiguous bare slug is dropped. Exempt: the keys id, slug, type and title, and their values only while they equal the slug the item is filed under or its type (slug: priv-offer on a public resource is a ref and goes), and a top-level field its schema declares an enum or an axis for, but only while its value IS in that list (link_status: active survives a private slug active; link_status: m-need, maturity: m-need and lifecycle_state: <a private id> are not in their lists, so they are scrubbed like any value; a required field dropped this way is refused loudly by the record validation in planPublish, never published without it). Round 4: both sides of the comparison are trimmed and lower-cased (' m-need ', 'm-need\n', 'M-NEED' all match), an object key equal to a non-public slug is dropped with its value at every depth, and the drop is counted, never named: each item that lost something carries scrubbed: <n>, the publish report carries report.scrubbed = { total, items: [{ ref, count }], note }, so an author learns that an ordinary word collided with a private slug. render.site scrubs the items it tallies (deriveIndex counts maturity, public_use and lifecycle_state, which had published a private slug as a count key in src/data/kms-index.json); the private canon’s own data/kb/index.json stays an honest tally. Round 4 probe (2026-11-20): link_status, maturity, lifecycle_state outside their lists, ' m-need ', 'm-need\n', 'M-NEED', a top-level m-need key and nested x-need / M-NEED keys left the slugs and the private id only in the canon, after publish apply, the static api, the pages (publish.pages: true), render.site, index.rebuild, the bridge, the map and the export verb (test/matching-only-egress.test.mjs, test/visibility.test.mjs). Still open, named: a non-gated pack’s render.site copies the canon index unchanged. Not scrubbed: free text. Only exact equality is removed, so notes: 'see m-need' is left as the author wrote it; an author who names a private object in prose has published it. It runs in publish right after the cut to public_fields (so the putRecord payload, public/api/*.json, public/k/** pages and render.site all read scrubbed items), again in planPublish (fail closed), in the registry bridge for the rows of data/*.yaml, and in selectForPublication (the commons already drops related; the test keeps it so). Probe, 2026-11-20 (round 3): a public resource with an unlisted field probe_unlisted_field: m-need, superseded_by: m-need and a nested deep.a[].b: need:m-need left m-need in the canon only after publish apply, the static api, the pages, render.site, the bridge, the map and the export verb; the old name-list scrub leaked it into the putRecord payload, public/api/* and data/resources.yaml (test/matching-only-egress.test.mjs, test/visibility.test.mjs). Polish (2026-11-20): a YAML-number id (id: 424242) is indexed as its string and number-typed entries are matched; a typed ref whose prefix names no object (Need:Priv-Offer for a private offer) is looked up again as the bare slug after its first colon; and when the scrub removes a required field, planPublish says missing required field: text (removed: matched a non-public object), never the value. What the scrub does not catch (each is a decision for the operator, not fixed here): a private object’s title used as a value (the scrub matches slugs and ids, not titles); look-alike characters (zero-width characters, a non-breaking hyphen, fullwidth letters) that make a string differ from the slug by bytes while a reader sees the same word; a slug inside a URL, a path or prose (only exact equality is removed); and the count-only N8: render.site’s index counts items of ungated non-public types, so a count (not a name) of what the canon holds that is not public can reach src/data/kms-index.json.
render pages --preview (pages/write.mjs)Writes the whole canon, internal titles included, under renders/preview/, which an instance must gitignore and never publish. Probe: the sentinel title appears in renders/preview/index.html, k/need/index.html and k/need/<slug>.html, and nowhere else outside the canon.
bridge report (registry-bridge.mjs)The report’s withheld list carries each withheld object’s title (a matching-only need’s too), and the CLI prints the report to stdout. Do not run bridge into a shared log or CI output. The rows written to data/needs.yaml carry no withheld title.
federate.contributeReads the peer card only; records come from the caller, and the result is a draft, never applied.
frontier.mjs, map.mjs, render-map-html.mjsRead federation.yaml, peer snapshots, data/source-systems.yaml and the index counts; no object fields.
A target instance’s own generators over data/*.yamlNot read here (outside this build). Before a target adopts the pack: git -C <instance> ls-files data/needs.yaml, git remote -v, and grep its generators for reads of data/.

Claims: publishing on a node’s behalf, and stepping aside (off by default)

A claim is an ordinary object with claim fields (claim_for, claim_status, claim_node_did, claim_checked_on, consent_atproto, superseded_by), published from the instance’s own account so a node appears before it has one. Nothing is published about a node without its yes by name:

  • The floor (src/claims.mjs, claimFloor). A claim publishes only if publish.claims is exactly true, claim_status is claimed, claim_for is set, consent_atproto is a real date, and publish.claim_publisher names who publishes (for example ReFi DAO). It is applied four times, none of them widenable by an instance gate: the publish op withholds (report.withheld.claims), planPublish fails closed (claim floor: …; its publishClaims defaults to off), and export (selectForPublication) rejects it before anything is written to a public plane (floorRejected).
  • The record carries claim_for (the subject: the node), claim_status, claim_node_did, claim_checked_on and publisher (the configured publisher). consent_atproto and superseded_by stay home. Refs are still scrubbed by value, so a claim that names a private object does not carry it. A claim of a pack type whose lexicon is shared is cut by that lexicon, so the marks are only present where the lexicon has the properties.
  • Supersede (claims reconcile [--dry], a CLI verb bound to no lifecycle event). When an ingested record of the same schema is the node’s own (its sourceUri DID is the claim’s claim_node_did, or its url is the claim’s claim_for, normalised: lowercase host, no www., no trailing slash), every claim of that schema for that node is set claim_status: superseded, maturity: held, superseded_by: <the node's record>. The node’s record is never written; a record retracted at origin (held) does not count. Idempotent. The next publish removes the claim through the manifest delete, from the collection the manifest recorded (the shared one for a shared type).
  • The mass-delete guard still applies (section 2): superseding the last published claim refuses the apply, and the report says that the record it would delete is a superseded claim. There is no bypass; the operator withdraws the last record by hand.

A node’s update into the Certified feed, as a draft file (off by default)

certified draft (a CLI verb bound to no lifecycle event; needs publish.certified_drafts: true) builds, for each of the instance’s own signal objects of type implementation, the exact org.hypercerts.context.attachment record (contentType: update, a Leaflet body, subjects a strongRef) and writes it as renders/certified-updates/<slug>.json for the node’s own session to put into its own repository. The bundle never holds a node’s credentials: the command takes no client, never logs in, and puts nothing anywhere. The file says what is still missing (needs: ['certified_subject_cid'] when the signal carries no certified_subject_cid).

  • The text is signal.update_text, never notes: notes is private and is where ingested Certified text is kept, so an ingested record is never exported (it has a sourceUri; it is counted under report.ignored.ingested).
  • Eligible: public_use publishable and not held, certified_subject an AT-URI of the node’s activity, collection or profile, update_text set, and either the node’s consent_atproto date or the node’s own authorship (publisher: node, not a claim). Anything else is listed under report.skipped with the reason.
  • The record is built from named fields only (title, text, subject, languages), so no other field of the signal can reach the file. Test: test/certified-update.test.mjs, with the shape of a real public post as the golden fixture.

4. .well-known allowlist

Only these files are written under <static_dir>/.well-known/: dao.json (copied from the instance root .well-known/ if present) and knowledge.json (generated: the root file if any is merged with did, geo, exchange.published_domains/subscribed_domains and source cards). Of geo only the public pointers network, space and parent_space are written (GEO_PUBLIC in src/static/surface.mjs); author_space, space_kind, property and type ids and vocabularies are apply-only config and stay out. exchange.subscribed_domains is empty unless publish.disclose_subscriptions: true in kms.yaml: listing the peer DIDs and static-json base URLs discloses who this instance reads, so it is opt-in. meetings.json, members.json, activities.json and any other root .well-known file are never copied. An instance whose kms.yaml declares extensions also gets extensions.yaml (§13): its merged Layer-B entity set (type names, maps_to_core and each entity’s description — no instance data), which is the file a peer hands to federate check. An instance without packs does not get it. When standard.site is on (§14) and the publication exists, site.standard.publication is written there too.

5. Static surface facts

  • <static_dir>/api/** is generated and wiped: the whole <static_dir>/api subtree is deleted and rewritten on every publish that writes the surface (non-dry, publish.static not false). Do not hand-author files there. In instances that publish, commit it.
  • publish.base_url is required when the surface is on (without it the surface step fails). @context and index endpoint paths are absolute URLs built from it.
  • Source-system cards appear in knowledge.json sources only when source-system is opted in (publish.types_opt_in) and the card’s public_use is publishable. Cards written by connectors are stored internal-only, so they stay out until an operator reviews and changes them.
  • publish.static_dir must be a relative path inside the instance.

6. Install

Vendor both packages/toolkit-framework and packages/org-os-kms into the instance, unedited and pinned to a tag, as siblings. node_modules/@org-os/kms does not work: src/framework.mjs re-exports the framework through relative sibling paths (../../toolkit-framework/src/...), so the two directories must sit side by side. js-yaml is the runtime dependency. Do not edit vendored files in place; upstream changes and re-vendor.

Extension packs (§13) are vendored the same way: as further siblings, unedited and pinned.

7. Pulling from AT Proto peers (atproto connector)

connectors:
  - name: atproto
    config: { peers: [did:plc:...] }   # peers are DIDs
    cursor: null
  • A puller needs atproto.pds set in kms.yaml even while atproto.did is null (the did is only needed to publish, and to ignore your own records when pulling).
  • The connector uses one PDS for all listed peers. Resolving each peer’s own PDS via DID documents, or reading from a relay, is not implemented; peers must be reachable on the configured PDS.
  • atproto.did (as self), atproto.nsid_authority and atproto.pds are merged under each connector’s own config (the connector’s own keys win).
  • Cursor: { <did>: { rev, seen } }. A peer whose commit rev is unchanged is skipped. A peer’s full record list is compared to seen to detect retractions. A per-peer failure goes into the connector’s errors and the other peers continue.
  • Inbound records are treated as untrusted: they are passed through the same projection (private fields dropped), the peer’s id is not kept, records claiming your own DID as origin are ignored, and a record that claims another listed peer as its origin is ignored.

8. Static JSON sources (static-json connector)

  - name: static-json
    config: { base_url: 'https://example.org', mapper: openhaven }
    cursor: null
  • The only mapper is openhaven (Open Haven /api/protocols.json becomes resource, /api/affordances.json becomes signal; domains are deliberately unmapped). Optional config: index (default /api/index.json) and collections.
  • Cursor: a sha256 over the index body plus every collection body, in fixed order. If it is unchanged nothing is pulled.
  • The mapper emits a stable https sourceUri per record, so re-pulled records upsert by sourceUri instead of colliding.
  • When the hash changes the whole collection is re-pulled, but runConnector compares each record’s content with what is stored and counts unchanged ones under unchanged without rewriting or re-flagging them (§10).
  • An origin update never overwrites a local maturity, public_use, id or review_needs. If the incoming ai_assisted: true would clash with a locally reviewed object (AI-assisted is not human-reviewed), the incoming ai_assisted is dropped and the local value kept; only if the merged object still violates an invariant is the update reported under invalid.

8a. Pulling from Hypercerts and Certified (hypercerts connector)

connectors:
  - name: hypercerts
    config:
      follows_of: did:plc:...        # the accounts this DID follows on Certified are in scope
      dids: [did:plc:..., did:web:...] # plus these; a DID, never a handle or an AT-URI
      # base: https://api.hypercerts.dev   (the default host; `base` is free config, so point it only at a Hypercerts API you trust)
      # constellation: { enabled: true }   (optional backlink enrichment; OFF unless enabled is exactly true; see below)
  • Every request has a deadline. timeoutMs in the connector config (default 10 000 ms, also constellation.timeoutMs) cuts off a request that never answers. For Hypercerts it is a listing failure like any other (the rules above and below apply); for Constellation it is the silent fallback described below.
  • Read-only, no login. GET requests to the public Hypercerts API (api.hypercerts.dev, GET /xrpc/<NSID>), no PDS, labeler or firehose. The client refuses to send a query parameter the contract does not list (the live server answers an unknown one with a stack trace) and never copies a response body into an error.
  • It refuses to run unscoped. The scope is follows_of’s follows plus dids. With neither, or with a follows_of that follows nobody and no dids, the connector throws (ingest reports it failed) instead of reading the whole directory (about 9,600 candidates on 2026-11-18, almost all unrelated). A commons account that follows nobody on Certified needs dids until it does.
  • What is read, per scoped DID: organizations (app.certified.actor.getOrganizations), activities (org.hypercerts.claim.listActivities, authors), attachments (org.hypercerts.context.listAttachments, authors). The followed accounts come from app.certified.graph.listActorFollowing.
  • What it maps: organization → organization; activity → implementation-record (source_position: self-report); attachment evidence / report / audit → claim-evidence; attachment update → signal (the update text and its languages go in notes). Galleries, photos, audio, comments, funding receipts and anything else are not mapped; no donor or wallet field is ever read.
  • What it skips: organizations and activities with no title or a title naming a test, QA, e2e or demo run; attachments whose own title says so or whose activity is such a test. Certified’s likely-test label is not used: the public API has no label operation (65 operations checked, 2026-11-20) and the labeler is a separate host, so v1 filters on titles only.
  • A title edit can hold a record. The filter reads the title on every run. If the origin later edits a title already pulled so that it names a test or a demo (or blanks it), the record leaves the kept set, counts as vanished, and is set held like a retraction (section 10) even though nothing was retracted at the origin. The review note then says retracted at origin; read the origin before believing it.
  • A failed activity listing holds attachments, it does not guess. Whether an attachment is about a test activity is known only from the activity listing. When that listing fails, an attachment is kept only if every activity it is about was kept by the last good listing (a subject entry with no readable uri, or a plain string, cannot be checked, so it holds too); the others are held for that run (not stored, not retracted, cursor unchanged) and errors carries one attachment entry saying how many.
  • Candidates land raw and not-public-yet like every pulled record (section 10), and a source-system card for the API is stored internal-only.
  • Cursor (data/kms-cursors.json, key hypercerts): { seen: { organization: [AT-URI…], activity: […], attachment: […] } }, the URIs kept by the last good listing of each collection.
  • Retraction (an origin record that vanished sets held, section 10) is worked out per collection, only for a collection that listed successfully, and only over DIDs still in scope. Two cases that must not retract: unfollowing an account (its records stay, its URIs leave seen) and a listing that failed half-way (the cursor for that collection is left as it was and errors names it).
  • Optional enrichment: Constellation backlinks (OFF by default). With constellation: { enabled: true } the pull also asks Constellation (microcosm, constellation.microcosm.blue; constellation.base overrides it) which records elsewhere on the network link to each kept activity and organization: GET /links/all/count?target=<at-uri> (marked deprecated in microcosm’s server, read 2026-11-20; see below), then one getBacklinks page (at most 100) per source that has any. The answer is returned beside the records as enrichment.constellation and nothing in kms stores or acts on it yet. It is enrichment, not a source of record: it is one maintainer’s best-effort service with no full-network backfill, so an empty answer means “no links seen”, never “no links”, and it never feeds retraction, the cursor or a record’s content. Any failure (HTTP error, 429, timeout, bad JSON) stops the lookups and falls back silently to the reads above: errors, records, retracted and the cursor are exactly what a run without the flag returns, and only enrichment.constellation.error says it failed. GET only, the same allowlist discipline as the Hypercerts client, user agent org-os-kms (read-only) (it carries no name, handle or e-mail), at most 50 requests a run. On the deprecated count route: the non-deprecated blue.microcosm.links.getBacklinksCount (lexicon read 2026-11-20 in at-microcosm/microcosm-rs, lexicons/blue.microcosm/links/) needs a source (collection and path) and returns one total; it cannot say which sources link to a target, which is what the all-count answers and the connector needs to choose its getBacklinks calls. No other lexicon in that directory (getBacklinkDids, getBacklinks, getManyToMany, getManyToManyCounts) enumerates sources either, so countLinks stays on /links/all/count. If microcosm removes it, the lookup fails soft (the fallback above) and this section is the place to revisit. Lookups use the form a record wrote: a handle-form at-uri is indexed under the handle, so it will not match a lookup by DID. Calling the public API is not a licence event; self-hosting Constellation (AGPL) is, and is not covered here. Source: knowledge/ecosystem/2026-11-20-microcosm-atproto-indexing.md in lf-work-os.
  • Dry run: org-os-kms ingest --connector hypercerts --dry --dir <instance> stores nothing and writes no cursor. Read failed, errors, invalid and collided, not just the exit code.

9. Ids

  • id (UUIDv4) is the AT Proto record key (rkey) and the key of the publish manifest (data/kms-published.json). It is minted at first non-dry publish, and only for objects that passed every gate, and only when a publication target exists (section 2); never on --dry. The instance-registry bridge (bridge) matches an existing data/<registry>.yaml row by the object’s id or its title slug, so a row bridged before the id was minted migrates from slug to id in place instead of being duplicated. The id is a field on the object in the source yaml, so git holds it.
  • grc20Id is minted only when kms.yaml.geo.space is set.
  • The publish plan compares the content hash of the projected record with the hash stored in the manifest under that id: unchanged is skipped, changed is an update (with a compare-and-swap on the stored cid), and manifest ids no longer present are deleted from the PDS.
  • A stale copy is tracked until it is gone. When an object’s collection changes (a namespace swap), its new record is created and the old one deleted. If that delete fails, the old copy is kept on manifest.orphans ([{ id, collection, rkey }], absent when empty) and its delete is retried on every later run, including after the object is withdrawn; each failed retry is a reported failure (atproto.status: failed), a success removes the entry. An orphan whose collection and rkey a run writes or keeps again is dropped, never deleted.
  • Storing an entry whose slug is already taken: the repo-data adapter treats it as the same object when both have an id and the ids are equal, or, lacking ids, when their content is identical (sameStoredObject in toolkit-framework/src/util.mjs); a different object with the same slug is stored under a hash-suffixed key and reported as a collision, unless store.on_collision: merge (read by the framework’s own store command) is set. Separately, the connector layer never overwrites a local object with a new candidate that has the same slug (section 10).

10. Ingest semantics (runConnector, toolkit-framework/src/connector.mjs)

Order per connector: describe, pull, map, validate, upsert/store, write the source-system card, apply retractions.

  • Every candidate is validated as it will be stored: maturity: raw, public_use: not-public-yet, ai_assisted: true unless the mapper says otherwise, plus work_order: connector:<name>:<time>, source_lineage and provenance.origin. Whatever maturity or public use the origin claims is ignored.
  • Upsert is by sourceUri. An existing local object with the same sourceUri is updated (its local id, maturity, public_use and review_needs are excluded from the origin patch, so origin cannot change them; afterwards review_needs is explicitly set to updated at origin, replacing any earlier value). An unchanged record is skipped, not rewritten: if applying the origin’s fields would leave the stored object identical (ignoring key order, the per-pull work_order stamp and review_needs), it is counted under unchanged, not updated, and nothing is written, so a peer whose commit rev moves does not re-flag its whole corpus for review and a reviewer’s own review_needs note survives. If several candidates in one pull share a sourceUri, only the last one is applied.
  • Collisions are skipped, never overwritten. A new candidate whose slug is already taken by a local object (or by an earlier candidate in the same pull) is skipped and reported as collided ({ schema, title }, counted in collisions).
  • Invalid candidates are reported, not stored. They appear under invalid ({ title, errors }).
  • The cursor still advances past invalid and collided records. They are not retried until the peer’s data changes (a new rev, or a different body hash). Read invalid and collided in the ingest report; that is the only place they are surfaced.
  • Retractions never delete. A record that disappeared at the origin sets maturity: held and review_needs: 'retracted at origin <sourceUri>'. Matching is by sourceUri; for atproto that is the peer’s record AT-URI, so a stored record that carries its own different sourceUri claim is not matched by a retraction.
  • held unpublishes. The publication floor (section 3) refuses maturity: held. If a reviewer already promoted an ingested object to a publishable public_use and it is later retracted at the origin, the next publish drops it: deleted from the PDS when applying, removed from the static surface. The same holds for an object an operator sets to held to withhold it. Only held is special: every other maturity is left to your instance gate (publish.gate), which can only narrow the floor.
  • Cursor write-back. After a successful (non-dry) pull the new cursor is written to the sidecar data/kms-cursors.json ({ "version": 1, "cursors": { "<key>": <cursor> } }), never to kms.yaml, which is not rewritten (its comments survive). The key is the connector’s name; a repeated name gets #2, #3, … in declaration order. A write happens only if some cursor actually changed (an empty {} counts as null, so a peerless atproto connector causes no write), and it merges into a fresh read of the sidecar (a cursor another run wrote during the slow pulls survives) and lands atomically (tmp + rename). A cursor: in kms.yaml is only the seed: a connector with no sidecar entry starts from it, and once the sidecar has an entry the sidecar wins, so an older config keeps working and a stale seed is harmless. To re-pull a peer from scratch, delete its key from the sidecar (and clear the seed). If the sidecar is not valid JSON, ingest fails with ok: false before pulling anything and leaves the file alone. Failed and not-implemented connectors leave their cursor as it was.

Ingested objects and bridge (read before running close)

Ingested objects land not-public-yet, so they are outside the publication floor (section 3). bridge is bound earlier than publish in close and is not the publish path, so know what it does with them:

  • Registry rows are still copied. Every object of a bound schema is upserted into the org-os registries (data/resources.yaml, data/source-systems.yaml, data/signals.yaml, …), whatever its maturity or public_use. Those are internal instance state, not a publication surface, and are not gated. If your site or .well-known generators read those registries, that is where a pulled object can surface.
  • encyclopedia-entry pages are gated. They are written to the site’s src/content/docs/kb/<slug>.md, which is the public site. An entry whose public_use is not-public-yet or internal-only, or whose maturity is held, gets no page; it is listed under report.withheld ({ schema, title, reason }). An entry with no public_use at all is written as before.
  • Existing pages are never deleted. If an entry was bridged while publishable and later turns held or internal-only, its old page stays until you remove it; bridge only stops rewriting it.
  • Pages for publishable entries are still unprojected. Frontmatter is every field of the object, including notes, reviewed_by, consent_note, id, sourceUri and viaUri. Only the publication plane (publish) applies publicView(); bridge does not. Keep private material out of publishable entries’ fields, or keep the kb/ pages out of the built site.

11. Identity setup for a publisher

  1. Choose or run a PDS.
  2. Create the account on it.
  3. Obtain the account’s did:plc and an app password (not the account password).
  4. Fill kms.yaml atproto: with did, handle, pds, nsid_authority, and put ATPROTO_APP_PASSWORD in .env (environment only, never a tracked file; publish reads process.env).
  5. Publish the lexicon DNS record so the NSIDs resolve: a TXT record at _lexicon.<nsid authority, labels reversed> with value did=<your did> (AT Protocol lexicon resolution; the code does not check it). Collections are <nsid_authority>.<camelCaseSchema>, e.g. <authority>.claimEvidence.
  6. Any dev/test identity must be wiped (its records deleted and the manifest reset) before the first real publish, otherwise the manifest would describe records that live on the wrong account.

12. This plan

An instance that only pulls (publish.apply off, atproto.did unset, publish.static: false) uses ingest and never runs publish --apply. Nothing in the code requires an instance to do both.

13. Extension packs

See also KMS-EXTENSION-PACKS and TERRITORY-PACK.

A pack is a sibling package of org-os-kms that adds typed schemas, Layer-B entities, connectors and registry bindings without editing the framework. An instance opts in:

extensions: [org-os-territory]

No extensions key, no code path: such an instance behaves exactly as before.

packages/<pack>/
  pack.yaml                 # name (= directory), version, requires: { framework: ">=x.y.z", kms: ">=x.y.z" }, types: [...]
  schemas/*.yaml            # object schemas, `extends: frontmatter`
  extension-entities.yaml   # { entities: { <type>: { maps_to_core } } }
  connectors/index.mjs      # optional: export const CONNECTORS = { <name>: <connector> }
  profile/profile.yaml      # optional: registry_bindings: { <schema>: data/<file>.yaml }
  # a visibility-gated pack (visibility_gated: true in pack.yaml) also DECLARES, per type, as data that core enforces:
  #   publish_requires: { <type>: { <field>: <value> } }   # the floor, src/visibility.mjs
  #   public_fields:    { <type>: [<field>, …] }           # the only keys that may leave the instance
  #   shared_lexicon:   { <type>: lexicons/<nsid>.json }   # publish in a shared lexicon, mapped by src/shared-map.mjs
  • Loaded at config load, before any op (loadKmsConfig → loadExtensions). A pack that is missing, fails its requires, or collides with anything throws with the pack named; no op runs against a half-loaded instance. (The failure is raised from loadKmsConfig, so the lifecycle stops and the CLI exits 1; packs registered before the failing one remain in the process registry until resetPacks().)
  • Core wins. A pack schema, entity, connector or registry binding named like a core one (or like an earlier pack’s) is a load error, never a shadow.
  • Entities must map to a real Layer-A type (isForkCompatible), or the pack refuses to load.
  • types are publish-eligible, not published. They join the opt-in set, so an instance must still list them in publish.types_opt_in. Installing a pack never widens what an instance publishes. The projection (publicView) and the floor apply to pack types exactly as to core ones.
  • Lexicons for pack types are generated under the instance’s own nsid_authority (<authority>.territorialUnit).
  • The atproto connector lists pack collections once a pack is loaded, so two instances with the same pack exchange its records through the usual untrusted path. A peer without the pack never requests those collections; downgrading an unknown type to its maps_to_core on ingest is not implemented.
  • Visibility-gated packs (kms >= 0.2.0, opt-in per pack). A pack with visibility_gated: true in pack.yaml must declare, per type, publish_requires and public_fields. Until it does, publish withholds the type (report.withheld.undeclared) and planPublish refuses it. When declared, the object is cut to public_fields before it becomes a record, because the projection alone keeps every key it does not know. A pack that does not set the key is unchanged. A pack that needs these keys states requires: { kms: ">=0.2.0" }, and an older kms refuses to load it.
  • What a pack can supply is only what the loader reads (src/extensions.mjs): pack.yaml, schemas/, extension-entities.yaml, profile/profile.yaml registry_bindings, and connectors/index.mjs; a visibility-gated pack’s pack.yaml also declares publish_requires, public_fields and shared_lexicon, and shared_lexicon runs the pack’s src/shared-map.mjs (src/pack-publish.mjs), executed like a connector. There is no hook for invariants, gates or the private-field list (the visibility floor lives in core, src/visibility.mjs), and a pack schema named like a core one is a load error.
  • Pack registration is per-process state. The CLI runs one instance per process; a host that walks several instances in one process should call resetPacks() and resetRegistryBindings() between them.
  • A pack’s connectors/index.mjs is executed. ingest dynamically imports the entry module of every declared pack, whether or not a connector from it is configured. Everything else a pack ships (pack.yaml, extension-entities.yaml, profile/profile.yaml) is read as data. Vendor packs with the same care as org-os-kms itself.

14. standard.site documents (atproto.standard_site)

See also KMS-PUBLISHING.

Opt-in. When enabled, every entry publish writes to the PDS is also written as a standard.site document, the shared long-form lexicon that Bluesky renders in timelines. Without the block (or with enabled: false) no code path runs and publish behaves exactly as before.

atproto:
  did: did:plc:...
  handle: ...
  pds: https://...
  nsid_authority: xyz.example.kb
  standard_site:
    enabled: true
    title: Example Commons               # required: the publication's name
    description: Comum de conhecimento…   # optional
    url: https://example.org             # site base URL; falls back to publish.base_url. Required one way or the other.
    language: pt-BR                       # optional BCP-47 default for documents. Never assumed: no language, no `langs`.
    language_field: idioma                # optional: an object field that carries a BCP-47 tag and wins over `language`
    paths:                                # URL pattern per schema; {slug} {id} {schema}; must start with "/"
      default: /kb/{slug}
      resource: /recursos/{slug}
    tag_fields: [domain, function]        # optional; this is the default
    fields:                               # optional: override/add the description and body fields of a schema (e.g. a pack type)
      territorial-unit: { description: summary, body: [summary] }
    publication_rkey: 3abc...             # optional: adopt an existing publication record (a TID) instead of the derived one
    show_in_discover: true                # optional → preferences.showInDiscover

The record relationship

RecordCollectionRecord keyRole
the entry<nsid_authority>.<camelCaseSchema>the object id (UUIDv4)Is the entry. What peers pull. Its shape is not changed by this feature.
its documentsite.standard.documenta TID derived from the object idThe readable rendering. Points back to the entry and to the publication.
the publicationsite.standard.publicationa TID derived from the DID (or publication_rkey)One per commons.

Both standard.site lexicons declare key: tid, so the UUID cannot be the document’s record key. The key is a syntactically valid TID computed from a hash of the object id (tidFor): stable across republishes, but its embedded timestamp is not a real time (it is pinned to a past range).

A document record:

{
  "$type": "site.standard.document",
  "site": "at://<did>/site.standard.publication/<tid>",
  "title": "Agrofloresta sintrópica",
  "path": "/kb/agrofloresta-sintropica",
  "description": "…",
  "textContent": "…",
  "tags": ["agroecologia"],
  "langs": ["pt-BR"],
  "content": { "$type": "<nsid_authority>.entryRef", "entry": { "uri": "at://<did>/<nsid_authority>.encyclopediaEntry/<id>", "cid": "…" }, "schema": "encyclopedia-entry" },
  "publishedAt": "…",
  "updatedAt": "…"
}
  • Back-pointer. content is the lexicon’s open union; its value here is <nsid_authority>.entryRef, whose entry is a strongRef (uri + cid) to the entry record. In a plan the cid is absent (the entry may not exist yet); it is stamped at apply from the manifest. The web URL is the standard one: the publication’s url + the document’s path.
  • Field mapping (FIELD_MAP in src/atproto/standard-site.mjs, applied after publicView(), so private fields never reach a document): title ← title; description ← summary (encyclopedia-entry), short_description (concept-lineage), claim, use_cases, context, starting_context, what_it_curates; textContent ← the schema’s prose fields joined as plain paragraphs, with no labels (a label would have to be in some language); tags ← domain, function (leading # removed). Schemas with no prose fields (resource, organization, signal, pack types without a fields mapping) still get a document: title, tags, path and the back-pointer.
  • Withheld. An entry with no title (a relationship-record, a public-use-boundary) gets no document; it is listed under standard_site.withheld with the reason. Its entry record is published as usual.
  • Language. The document lexicon has no language field. langs (an array of BCP-47 tags, the app.bsky.feed.post convention, also written by pckt) is emitted only when language_field or language gives one. Nothing reads it yet as far as we could verify.
  • Dates. publishedAt (required by the lexicon) is the time of the document’s first publication, kept across updates; updatedAt is set on each later rewrite. The framework’s schemas carry no publication date to use instead.
  • Limits enforced at plan time: title 500 graphemes / 5000 bytes (error), description 3000 graphemes / 30000 bytes (cut on a grapheme boundary, … appended), each tag 128 graphemes (error), record 1 MB (error). Text is never re-normalised.

Plan, apply, idempotency

  • Plan-first like the rest: report.standard_site is { status: 'planned', publication: 'create'|'update'|'skip', created, updated, deleted, skipped, withheld, warnings }. With --apply it becomes status: 'applied' (or 'failed', with failures).
  • Order at apply: entries, then the publication (only when new or changed), then documents. A document is written only for an entry that is actually on the PDS. If the publication write fails, no document is written.
  • State lives in the same manifest, data/kms-published.json, under standardSite: { publication, documents: { <id>: { rkey, atUri, cid, hash, entryCid, publishedAt } } }. Unchanged documents are skipped; a document is rewritten (compare-and-swap on its cid) when its rendering changed or its entry got a new version (so the strongRef stays current); a document whose entry left the selection is deleted, exactly as the entry is. The mass-delete refusal (section 2) covers both.
  • Validation never throws and never blocks the entries. A bad standard_site block or an over-long title gives standard_site: { status: 'invalid', errors }, ok: false (exit 1), the entries are still published, and nothing standard.site is written (all-or-nothing, like the entry plan).
  • A warnings entry no path pattern for <schema> means that document has no path, so it has no web URL and cannot be verified or rendered as a card.
  • Turning enabled off later leaves the already-written documents, the publication and the manifest section untouched. There is no retract-all switch; delete the records by hand if needed.

Site-side verification (operator step, required)

A reader only trusts these records if the website points back at them (standard.site/docs/verification). Bluesky will not render the enhanced card without it (atproto discussion #4978).

  1. Publication: https://<url>/.well-known/site.standard.publication must return the publication’s AT-URI as the response body (for a publication under a path: /.well-known/site.standard.publication/<path>). publish writes exactly this file into the static surface (<static_dir>/.well-known/site.standard.publication) once the publication exists. That only helps if the static surface is served at the root of url; otherwise copy the value (standardSite.publication.atUri in the manifest) to wherever the site serves .well-known.

  2. Each entry page (the page at url + path) must contain, in the server-rendered <head> (crawlers do not run JavaScript):

    <link rel="site.standard.document" href="at://<did>/site.standard.document/<tid>" />
    <link rel="site.standard.publication" href="at://<did>/site.standard.publication/<tid>" />

    The document AT-URI for an entry is standardSite.documents[<object id>].atUri in data/kms-published.json. Nothing in this package edits the site’s HTML: the site generator has to read the manifest and emit the tags.

  3. The page URL must really be url + path: set paths to match the site’s routes (the bridge writes encyclopedia entries to src/content/docs/kb/<slug>.md).

Not done here: a cover image (coverImage) or publication icon (blobs are not uploaded), a rich content rendering (Leaflet, pckt and Offprint each use their own block types; there is no shared one in the lexicon), and posting to Bluesky. A card appears in a timeline only when a post embeds the page URL with associatedRefs to the document and publication; this package creates no posts.

Two planes: a private canon and a public plane (export, validate)

This section is a summary; KMS-PLANES has the gate’s refusal reasons, the field allowlist and the full sequence.

An instance may keep everything it knows in a private canon and publish only what passes a gate into a separate public plane, another instance in another repository. The canon names its public plane in its own kms.yaml:

planes:
  public:
    instance: my-commons-public      # the `instance:` the plane's kms.yaml must carry
    dir: repos/my-commons-public     # optional; this is the default
  • org-os-kms export [--dir <canon>] lints the canon’s source cards and boundaries, runs every object through the publication gate (src/planes/publication-gate.mjs) and the framework floor, mints ids in the canon for what passes, and writes only allowlisted fields into <plane>/data/kb/. It refuses to write into the canon, into a directory whose kms.yaml is not the named instance, or through a symlink or hard link. A refused export leaves the canon byte-identical.
  • org-os-kms validate [--dir <canon>] re-gates what is published against the live canon: an entry with no canon counterpart, one that no longer passes, a divergence, an unallowlisted canon field or a leaked private field is an error (exit 1).

What the gate requires. An object is refused for any of: a boundary or source-card shape, high_risk, a blocked public_use; no source_lineage, or one that is not a canonically written corpus path (repos/<Repo>/…, never a URL); a lineage (including provenance.origin and additional_provenance) under a held prefix, on a consent boundary, or not claimed by any registered source card; a claiming card that is internal, high-risk, malformed or without a public_use. What is left passes if maturity: reviewed or the object carries publish: true. It never throws: an error is a refusal.

What is the public plane’s to decide, in its own kms.yaml:

extensions: [org-os-territory]
publish:
  types_opt_in: [territorial-unit]   # pack types that may publish
  public_fields:                     # fields added to the framework's allowlist
    "*": [summary_es]                #   on every schema
    resource: [bioma]                #   on one schema
  nested_fields:
    contato: [rede]                  # the public keys of an object-valued field

A field not on the allowlist is dropped, and validate reports it until its visibility is decided. An instance can only add fields; naming a private one (notes, surfaced_by, reviewed_by, …) is refused. The plane’s own data/kb/source-system.yaml holds one card, the commons itself, and is published as it stands.

Each plane knows what it is (src/planes/role.mjs). A canon is the instance whose kms.yaml names a public plane; the public plane carries planes: { role: public } (the clone also writes canon: <instance>, which no code reads).

  • In a canon, publish is refused in every mode, before anything is listed, minted or written (refused: canon). So is the publish step of lifecycle close, which stops there.
  • In a public plane, publish first re-gates the plane against its canon (the same check as validate). A failure is refused in every mode (refused: regate). The canon is looked for two levels up (<canon>/repos/<plane>) or at planes.canon_dir, and only counts if it names this plane. A plane that cannot find its canon will plan but not apply; planes.regate: false is the explicit way to publish from a plane on its own, and it is reported as regate: disabled.
  • In a public plane, ingest is refused (refused: public-plane): the plane receives only what its canon exports.
  • An instance with no planes key has no role. If its knowledge base holds no canon control data, publish behaves as before and reports canonGate: { status: 'not-applied', reason }. If it does — a source card that claims or holds corpus paths (origin_prefixes, held_prefixes, container_role, or a GitHub url), or any public-use-boundary record — publish also runs the canon publication gate (src/planes/canon-gate.mjs, the same gate and the same lint as export), in every mode. It runs in selectPublic (src/gate.mjs), after the framework, visibility and claims floors and before the instance gate, so it only narrows, before any id is minted, and the steward’s preview and kms-admin see the same selection. publish reports canonGate: { status: 'applied', passed, rejected, by_reason }; a maturity: draft entry is not published. Malformed cards or boundaries refuse the publish before anything is minted or written (refused: 'canon-control-data', with the errors), and selectPublic throws for the preview and kms-admin, so nothing is called public until they are fixed. A card that claims nothing, such as a peer’s card brought in by ingest or a garden’s own self card, does not count. The cards and boundaries are read from the adapter’s listing, the one publish judges, whatever the adapter.

A store whose file name is the type (what export writes) carries no type on its objects; publish supplies it on the record without rewriting the file.

Readable pages (publish.pages, render.fonts, render.labels)

By default publish writes only the JSON API under public/. Set publish.pages: true in kms.yaml and it also writes the commons as pages people can read: index.html (the commons by kind, with search), k/<kind>/index.html (one page per kind), k/<kind>/<id>.html (one page per entry), and _kms/ (the search file and the fonts). Only this instance’s own published entries get a page; an entry that came from a peer shows as a row that links out to its source. An entry that is not published has no page and its title appears nowhere under public/. The public pages carry no link to the federation map.

kms owns index.html, k/ and _kms/ in the output folder while this is on: each run removes and rewrites them, so a page for an entry you stopped publishing goes away. A marker file, _kms/.kms-pages, records that kms wrote them. Turn publish.pages off (or remove it) and the next publish removes them, but only if the marker is there; an index.html from another tool is never touched. If the output folder already holds one of those three paths and no marker, publish refuses to write pages rather than overwrite it.

  • render.fonts: house (default) copies the three house fonts to _kms/fonts/ and the pages load them from there; system writes no fonts and the pages use the reader’s own. Pages never ask any other site for a font.
  • render.labels: a map of field name to the words shown for it on the pages, for example render.labels: { steward: "Looked after by" }. It wins over a pack’s labels and the built-in words.
publish:
  pages: true
render:
  fonts: house
  labels:
    steward: Looked after by