Skip to content

Rewrite the five libraries as a minimal core - #32

Merged
samternent merged 24 commits into
mainfrom
minimal-core
Nov 30, 2026
Merged

samternent merged 24 commits into
mainfrom
minimal-core

Conversation

@samternent

@samternent samternent commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

A fresh rewrite of Identity, Seal, Armour, Ledger and Concord with no backwards compatibility. Each package is now one source file with a small interface, its own saved vectors, and a README, llms.txt and CLAUDE.md. Library source goes from about 7,300 lines to about 1,410.

Packages

  • Identity (e2d18a0): createIdentity, restoreIdentity, createMnemonicIdentity, recoverIdentity, verify and validatePublicIdentity. Uses Noble and Scure for every primitive. The v2 backup format and the derivation path are unchanged.
  • Seal (4e6c509, d42afba): createSealHash, createSealProof and verifySealProof for a seal v1 detached proof. The CLI, artifacts, manifests and public-key files are removed.
  • Armour (5db3bbb): encrypt and decrypt over bytes, for public identities, native X25519 group keys and passphrases. Output is binary age.
  • Ledger (9db76b8): createLedger, openLedger and createWriter. The v2 format has a Seal proof per commit, and import accepts canonical bytes only. A history is immutable and only Ledger can create one. maxBytes is the single limit. Projections and subscriptions are removed.
  • Concord (d751f3d and the later Concord commits): createDocument, openDocument and defineModel.
    • A model is events and one pure reducer, staged and committed per group. There is no rebase or squash: applications re-stage their events on another copy and combine their own events.
    • Groups are independent, with member and admin roles. Membership, roles and key epochs are public signed entries, so anyone with the file can check every change was authorised; only event types and data are encrypted. Removing a member rotates the group key, and a new member receives the group's whole history.
    • Events entries name their group and epoch. A wrapped key counts only if it derives the epoch's public recipient, and no two epochs may share a recipient, so a forged, malformed or relabelled key never becomes a group's key. Each forgery has a test. Any member can still hand a key to someone outside the group.
    • Each group records its model ID and version; only an admin's commit can raise the version, and readers on an older model refuse the group.
    • Commits that break a group's rules stay in the history with no effect.
    • Trust model: outsiders and ordinary members can't forge history, write to a group they aren't in, or read a group they were never given keys for. Admins are trusted to distribute keys honestly.

Repository

  • Release sealing is removed from CI and the release workflow, along with the publisher's Seal check and the retained verifier tools (365f3c8, d42afba).
  • The packed-consumer check now runs one consumer across all five libraries and their saved vectors, an import-isolation check per package, a typed consumer and a browser proof (99afc60).
  • AGENTS.md, CONTEXT.md, the README and llms.txt describe the new design.
  • The packed-consumer check no longer runs a Vue page or checks CSS and 404s, and no longer probes that the toolchain's lint, format and test failures propagate. It still checks the tarballs, installs them from a temporary registry, and runs a Node consumer, an import-isolation check per package, a typed consumer and a browser proof.
  • CONTRIBUTING.md and .changeset/README.md lose their links to the removed docs.
  • Each package's CHANGELOG.md, and the SPEC.md in Armour and Concord, are removed. Changesets starts new changelogs at the next release.
  • renovate.json drops its ignores for the deleted packages and the Vue plugin entries; the toolchain group is renamed "Vite+ toolchain". Ledger stays ignored.
  • packages/ui, packages/workspace and docs/ are removed, along with an unused Vite library config, a stale tsconfig and the browser consumer's Vue app (75fcf34). The published @ternent/ui@0.6.0 and @ternent/workspace@0.1.0 stay on npm.

Not in this PR

  • www, the create-ternent-app templates and workspace still use the old APIs.
  • The separate workspace demo links packages/workspace by local path, so it needs repointing to the published package.
  • No Changesets entry yet for these breaking changes.
  • The SEAL_RELEASE_PUBLIC_KEY variable and SEAL_RELEASE_IDENTITY_B64 secret are unused and can be deleted in repository settings.

🤖 Generated with Claude Code

samternent and others added 24 commits November 27, 2026 23:12
Replace the serialized and capability APIs with six functions: createIdentity,
restoreIdentity, createMnemonicIdentity, recoverIdentity, verify and
validatePublicIdentity. An Identity exports its v2 backup, signs exact bytes and
lends a scoped X25519 secret.

Use Scure for encodings and Noble's strict verification instead of handwritten
equivalents. Keep the v2 backup format, the m/101010'/25519'/0' derivation and
all existing vectors. Consumers are not yet adapted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the proof, artifact, manifest, public-key and error APIs with
createSealHash, createSealProof and verifySealProof. A seal v1 proof signs
"ternent-seal/v1" || 0x00 || canonical JSON of its fields with an Identity, and
verification reports signature and hash results separately.

The CLI keeps sign and verify, reading the signer from SEAL_IDENTITY_FILE.
Armour is no longer a dependency. Test vectors live in the package.
Consumers are not yet adapted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ages

Remove the changelogs, agent guides and Seal's CLAUDE.md, which described the
retired APIs, and a stray Vite timestamp file. Each README now carries the
package's interface. Identity's test vectors move into the package so its tests
no longer read the docs folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each package ships an llms.txt for developers whose agents use it, linked from
its README and the root guide. A CLAUDE.md for each package records what it
owns and the rules that keep it small.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the text, file, codec, capability and error APIs with two functions.
encrypt takes public identities and native X25519 age recipients, or a
passphrase; decrypt takes an Identity, a native age secret key, or a
passphrase. Both return binary age through one age Encrypter or Decrypter.

Saved native-age vectors move into the package, and the tests check interop
with the age CLI in both directions and scrypt work-factor rejection.
Consumers are not yet adapted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the stateful log, projections, subscriptions and protocol subpath with
createLedger, openLedger and createWriter. A history is immutable and issued
only by Ledger; a writer stages validated entries and advances on a
successful commit. Each commit carries a Seal v1 proof over its body.

openLedger accepts only canonical v2 bytes and verifies every proof, linkage
and entry rule. maxBytes is the single size limit. The v2 vector lives in the
package. Consumers are not yet adapted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the Seal Action, the test and release signing identities and the
proof verification from CI and the release workflow, along with the release
CLI commands and the mandatory Seal hook in the publisher that served them.
prepare-release still records the workflow origin and checks it on resume.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seal is now its three library functions. Remove bin/seal, the CLI and its
tests, the release flow's retained verifier tools, the Seal consumer, type
and isolation checks, the browser check's Seal block, the old Seal format
docs and vectors, and the CLI and release-sealing mentions in the root docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace commands, system profiles, capability sets, authoring modes, inspection
handles, locked views and the /protocol, /system and /testing subpaths with
createDocument, openDocument and defineModel. A model is events and one pure
reducer; a document stages and commits events per group.

Every entry is one age ciphertext with no group label. Membership, roles and
key epochs live in encrypted group records; a key gains authority only through
an accepted record. Each group replays independently, rejected commits stay as
evidence with no effect, and rebase reapplies unpublished local commits onto
another copy. A saved vector fixes the format. Consumers are not yet adapted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…libraries

Replace eleven consumer and type checks written against the old APIs with one
consumer covering all five libraries and their saved vectors, a per-package
import-isolation check and one typed consumer, and rewrite the browser proof.
Update AGENTS.md, CONTEXT.md, the README and the agent guide to the current
design, and mark docs/ as history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…don't need

Delete packages/ui and packages/workspace (published versions remain on npm),
the docs folder, an unused Vite library config and a tsconfig for a removed
app. The browser consumer drops its Vue counter and CSS check, and the
consumer check drops probes of the toolchain's own lint, format and test
failures. Renovate no longer ignores Ledger, and guides lose their links to
the removed docs. Vue stays as a root dependency because Vite+'s type
declarations need it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Key discovery kept only the last key wrapped for each group epoch, so a member
could wrap a fake key for an epoch another member already held, displace the
real key in that reader's copy, and replay a forged creation record. Keep
every candidate key per epoch, and accept events and role changes only when
they decrypt with the epoch key an accepted record established.

Also restore Renovate's Ledger ignore, and replace comments that restated
code with the reasons behind it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… nothing

A wrap's group label is the sender's claim. A member of two groups could wrap
one group's key to another member labelled as the other group's, and that
reader's replay filed the real group's records under the wrong group and lost
access to it. Every record now names its group inside the ciphertext, and a
key only opens records of the group it was wrapped for. The saved vector is
regenerated for the new record format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bership checks

setMember no longer repeats the role, no-op and last-admin checks that
replay makes on the same record; replay's rejection is the error. Add tests
for replay rules no test covered: group creation for someone else or at a
later epoch, two records for one group in a commit, records for an unknown
group, a non-member holding the current key, a no-op role change, removals
that skip the epoch, name the wrong epoch or name a non-member, and
malformed records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wraps carried group and epoch labels, and replay used them to decide what a
key meant. A label is only the sender's claim, and three forgeries abused it:
a fake key for a held epoch, another group's key, and the current key under
an older epoch. Wraps now carry unlabelled keys. An accepted creation or
removal record establishes the key that opened it; every other record counts
only if the key that opened it is established as its group's current epoch.
Removal records drop their epoch field. This replaces the per-epoch candidate
lists and label checks; the saved vector is regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Membership, roles and key epochs become public, signed entries: anyone with
the file can check that every accepted change was authorised. Each epoch's
public recipient is recorded, and a wrapped key is used only if it derives
that recipient, so forged, mislabelled and multi-recipient keys change
nothing. Events entries name their group and epoch in the clear and are
decrypted with that epoch's key, so trial decryption and label handling go.
Only event types and data stay encrypted. The saved vector is regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k commits

Anyone can send a wrap, and a wrapped string that isn't a key made opening
throw, which let any signer break a member's copy or block removals; such a
secret is now skipped. A group created or rotated onto a recipient another
epoch already uses is rejected, so a relabelled wrap can't open a copycat
group. A commit whose first entry isn't a record is rejected instead of
ignored. CONTEXT.md and the README now describe public membership exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…adable per epoch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A group whose model or version this reader doesn't support skipped its events
before the no-key count, so a reader without the key under-counted
`unreadable`. Count first, then skip for readers who hold the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Concord keeps the shortest useful flow: create or open, stage and commit
events, read state, export, and manage groups. Rebase and the model squash
hook go; an application re-stages its events on another copy and combines its
own events before staging. The README, guides and AGENTS.md state that admins
are trusted to distribute keys honestly, and what follows if they don't.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A member could commit events claiming a model version no app will reach and
make the group unreadable for everyone, admins included. The creation record
now states the group's version, a commit may raise it only if an admin signed
it, and readers on an older model refuse the group as before. openDocument
calls replay directly now that nothing else opens a document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samternent
samternent marked this pull request as ready for review November 30, 2026 17:01
@samternent
samternent merged commit 008e6d0 into main Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant