Tangled lexicons #
This package contains the generated Go representations of the Tangled record
lexicons that tg consumes. It is deliberately internal:
tangled/ remains the handwritten Bobbin client and turns these generated
types into the CLI's stable application types.
lock.json pins the upstream Tangled Core commit used for the checked-in
schemas. schemas.txt is the explicit allowlist of upstream lexicons that tg
depends on. Keeping both means an upstream schema addition cannot silently
become part of tg's wire contract.
Updating #
Choose a reviewed, full 40-character Tangled Core commit and run:
cd internal/tangledlex
./update-schemas.sh <tangled-core-commit>
The script fetches only that commit, replaces exactly the paths listed in
schemas.txt, updates lock.json, and regenerates the Go and CBOR code.
Review the resulting schema and generated-code diff, then run nix fmt and
nix build path:.#tg from the repository root.
To add support for a new lexicon, add its path (relative to Tangled Core's
lexicons/) to schemas.txt. Add any new map types needed by the generated unions to the CBOR generator's list in cborgen/main.go; then run the update
script.
Bobbin's handwritten response types follow the registered handlers in the
pinned checkout. Some list lexicons still describe legacy records or filters.
Contract tests cover those differences. generate-lexicons.sh creates temporary
CBOR stubs so union codecs can compile, then replaces them with real generated
map codecs and restores the type registry.
Compatibility review #
The current pin, 358b13fc7ed6c120217cb904ebc329cfd363c7d3, is reviewed against
the registered handlers as well as the lexicons. All 18 vendored schemas remain
semantically unchanged, and regeneration produces the same Go code. Knot now
accepts assignees and empty ticket bodies and rejects the old mentions and
references fields. Tg preserves assignees when editing tickets. Same-repository
PRs require a published source branch containing their head; tg already verifies
the published tip before submitting a patch.
The review covers tg's existing commands and its MCP tools:
| Area | Contracts checked |
|---|---|
| Identity and Git | Owner declarations, repository manifests, DID services, SSH and HTTPS remotes, push audiences, and explicit ports |
| Repository writes | Creation, forks, metadata, contribution policy, default branch, deletion, declaration CAS, and recovery after rejection |
| Tickets and comments | Structured and historical titles, original authors, issue and PR states, filters, pagination, strong references, and foster read routing |
| Pull requests | Published source commits, fork source DIDs, immutable rounds, streamed patches, checkout, merge results, and partial completion |
| Personal records | SSH keys, string blobs, MIME and size limits, listing, viewing, and deletion |
| CI | Repository-scoped reads and logs, manual event payloads, blocked workflows, approval, retry, cancellation, schedules, and Spindle identity audiences |
| Frontends | CLI JSON fields, Pydantic models, tool annotations, help, man pages, and completions |
The knot's getRecord serializes byte fields as { "$bytes": "..." } with
unpadded base64. In particular, org.tangled.git.refs/self is not a plain base64
string. Historical tickets can contain string titles; reads accept these and
edits send the current inline-markup shape.
Repository search sends nsid=org.tangled.repo.manifest before applying the
result limit. The handwritten patch-list and merge calls follow actual served
routes even where a lexicon is missing or retains a different name.
Actor profile views include the optional avatarCid field. The current Spindle
webhook routes use org.tangled.webhook.*; tg does not call those routes. Its
existing CI routes are still served. event.notifyEvent now returns optional
ci.pipelines and ci.message fields. Tg preserves every ID and the message,
while accepting the previous top-level single-pipeline response during upgrades.
Pipeline and workflow schemas moved under org.tangled.ci.defs; their JSON fields
remain compatible with tg's handwritten decoders. repo.reserveKey renamed
repoDid to repo; tg does not call that method. Knot fixes for empty imports and missing
LFS objects preserve the repository creation contract used by tg.
Validation uses HTTP contract fixtures, unit and race tests, MCP model checks,
and the Nix package and website builds. The opt-in integration tests ran against
Core 358b13fc7ed6c120217cb904ebc329cfd363c7d3, using real local PDS, PLC, Knot,
Hydrant, Bobbin, Knotmirror, and Spindle services. They cover repository metadata
and policy, issue lifecycle and stale versions, assignee preservation, strings
and blobs, SSH-key records, HTTPS pushes, PR rounds and checkout, forks and
cloning, merge completion, and attestation delivery. The optional Spindle checks
also verify manual triggers, retries, pipeline listings, PR trigger metadata,
archived log content, and step outcomes. See
the integration test instructions.
Spindle log completion has an upstream defect at this pin. In
spindle/xrpc/ci_pipeline_subscribe_logs.go, handleSubscribeLogs drains its
writer and calls conn.Close() without sending a WebSocket close frame or a
terminal event. Clients receive code 1006 even after reading an archived log.
Tg preserves the received events and reports that completion is unconfirmed,
because a truncated stream produces the same error. The integration test checks
the expected log content and step outcome, records this limitation, and continues
with the remaining API checks. It does not claim complete delivery.
Knot defaults new repositories to SHA-256. The live Git fixture uses that
format; a pre-existing SHA-1 repository cannot push into a fresh SHA-256
repository. The create API has no object-format parameter. Forks inherit the
source format. This remains a constraint for repo create --push.
The local tests use password sessions. Browser OAuth, SSH transport, production Spindle engines, and the legacy PDS-to-foster-to-upgraded-Knot handover remain outside this live verification. Spindle's dummy engine checks the API and workflow lifecycle without executing shell commands. The migrated native write path passing does not establish that the legacy bridge works.