lore-forge/.ai/designs/lore-integration.md

16 KiB

Lore integration

Status: phase 1 integration verified end to end. Last updated 2026-11-25.

Facts here were checked against Lore's main at commit 6b12f00 (2026-11-25), workspace version 0.14.1-nightly, and the release-specific facts against the v0.14.0 release, which lore.lock pins. Lore is pre-1.0, so re-check before relying on them.

Minimum Lore version

v0.14.0 (12 November 2026).

  • v0.11.0 added OIDC login through the device grant and the per-repository token exchange.
  • v0.12.0 added token refresh and logout revocation.
  • v0.14.0 fixed verification of tokens from a token-exchange issuer.

How Lore handles authentication

Verified in docs/reference/lore-server-config.md and docs/proposals/2026-08-20-oidc-oauth2-authentication.md.

  • loreserver has no user database. With [server.auth] configured it verifies a bearer JWT on every request, locally, against keys it fetched from the issuer. It makes no call to the issuer per request.
  • It advertises the issuer to clients, which then log in at the issuer directly.
  • Lore defines two modes:
    • Tier 1: actions are read from a role claim in the login token and apply to every repository on the server.
    • Tier 2: the client exchanges its login token for a short-lived token scoped to one repository, and the server reads permissions from that token's resources claim.
  • lore-forge uses Tier 2.

What the issuer must provide

Lore calls this the capability profile. lore-forge implements all of it; details are in token-issuer.md.

Requirement Standard Used for
Discovery document and JWKS OIDC Discovery Server and client find endpoints and keys
JWT access tokens with a stable sub RFC 9068 (at+jwt) Local verification
Device authorization grant RFC 8628 lore auth login
Refresh token grant RFC 6749 Keeping CLI logins alive
Client credentials grant RFC 6749 CI logins
Fixed audience Server rejects tokens minted for other services
Token exchange with a resource indicator RFC 8693, RFC 8707 Per-repository tokens
Revocation RFC 7009 lore auth logout

Server configuration lore-forge generates

lore-forge loreserver-config writes the whole loreserver configuration. The trust settings are below. With --store, --tls-cert/--tls-key, --port and --http-port, it also places the stores, gives both public endpoints (QUIC and gRPC) the certificate, moves the ports, and always binds the plaintext HTTP endpoint to 127.0.0.1. The deployment that uses this is in deployment.md. Field names are from the config reference; the values are examples.

[server.auth]
jwt_issuer = "https://forge.example.com"
jwt_audience = ["https://lore.example.com"]
jwt_typ = "at+jwt"
resource_claim = "resources"          # enables per-repository authorization

[server.auth.oidc]
client_id = "lore-cli"
scopes = ["openid", "offline_access"]
resource_template = "https://lore.example.com/partitions/{id}"
# token_exchange_issuer defaults to jwt_issuer, which is what we want:
# lore-forge is both the login issuer and the exchange issuer.

[environment.endpoint]
user_url = "https://forge.example.com"   # registry and name lookup

Defaults worth knowing: resource_id_template is urc-{id} and resource_wildcard is urc-*, so a resource entry for a repository is named urc-<repository id>.

Start order: loreserver fetches the issuer's keys at startup and refuses to start if it cannot. lore-forge must be up first.

Transport security (verified in v0.14.0's lore-server-config.md and lore-cli-config.md, and by scripts/e2e-lore.sh, which runs over TLS by default):

  • [server.grpc] serves TLS only with its own certificate block. Without one it is plaintext, and the CLI's gRPC calls carry tokens in the clear.
  • [server.http] cannot serve TLS. Lore's clients do not use it.
  • lores:// validates the certificate and is the default scheme. lore:// accepts any QUIC certificate and sends gRPC without TLS.
  • Clients trust the system's roots, or the file SSL_CERT_FILE names. loreserver reads P-256 keys in SEC1 form.
  • Readiness: loreserver logs no "listening" line by default; GET /health_check on the HTTP port answers once it is up.
  • The local lock store is in memory, so a loreserver restart releases every lock.

Surfaces lore-forge uses

Need Lore surface Verified
Browse trees, history, diffs lore.thin_client.v1.ThinClientService: RevisionTree, RevisionInfo, RevisionDiff; RevisionService.BranchList, RevisionList; RepositoryService.RepositoryGet; HTTP content Verified end to end; see "Reading repositories"
Download file content HTTP /v1/repository/{id}/content/{address}, plus presigned URLs Routes read
Activity, webhooks, CI triggers NotificationService.Subscribe. Events: branch created, pushed, deleted; resource locked, unlocked; obliterate Proto read; [notification] mode = "local" is the default
Locks LockService: Lock, Query, Status, Unlock, AdminLock Proto read
Repository and branch admin lore.repository.v1.RepositoryService, lore.revision.v1.RevisionService Proto read
Landing a change RevisionService.BranchPush with fast_forward_merge Proto read

Landing

BranchPushRequest takes the signature of a revision that is already on the server, and a fast_forward_merge flag: when the new tip does not descend from the current one, the server attempts the merge itself. So lore-forge can land a reviewed branch with one call and needs no working copy or Lore library.

Hooks are not used

Lore's server hooks (lore-server/src/hooks/) are Rust traits compiled into the server. There are no out-of-process hooks. lore-forge does not rely on them; review gating is done through token permissions instead (see forge-features.md).

Services lore-forge provides to Lore

Both are defined in lore-proto/proto/lore/user/v1/user.proto and reached through user_url.

Verified in docs/reference/lore-server-config.md, lore-server/src/authnz/auth.rs and lore-transport/src/auth/ucs_auth.rs:

  • Both services are served at the same user_url.
  • They are gRPC. loreserver dials user_url with tonic; accepted schemes are ucs-auth, https and http, with TLS used for https. So lore-forge must serve gRPC (HTTP/2) as well as its web pages, and a reverse proxy in front of it must pass gRPC through.
  • Lore clients call UserService at user_url too, not only loreserver, so it must be reachable from wherever the CLI runs. Without user_url, clients show raw user IDs as names.

RepositoryRegistryService

  • RepositoryRegister(id, name) — loreserver calls this before storing a new repository, forwarding the caller's login token, and refuses the create if the registry refuses. The registry may reject the name, deny permission, or report a missing prerequisite. This is how lore-forge enforces namespaces; see namespaces-and-access.md.
  • RepositoryUnregister(id) — called before a delete, which is refused if the registry refuses. The forwarded token may be repository-scoped or the login token.
  • RepositoryList — streams the repositories the caller has permissions on, with those permissions. Backs lore repository list.

UserService

  • UserGet, UserFind — resolve user IDs to display names and back. Lore records only an identifier in revision history, so this is how the CLI shows names for revision authors and lock holders.

Repositories on one server

  • One loreserver hosts many repositories. Each has an ID, a name, branches and metadata. Lore also calls a repository a "partition".
  • Names are /-separated segments of ASCII alphanumerics, -, _ and .; no segment is empty or starts with .. So studio/game is a valid name.
  • Repositories are addressed as lore://host:port/<name>.
  • Listing fails past 100,000 repositories, which indicates the intended scale.

Token details that affect lore-forge

  • Signing algorithm: the server takes the algorithm from each key's declared alg in the JWKS and verifies with the jsonwebtoken crate; RS256 is assumed only when alg is absent. lore-forge will use ES256 and always declare alg.
  • Identity: the server reads the caller's identity from the identity claim, or the alias https://lore.org/claims/identity, falling back to sub. That value is recorded as the creator and committer of revisions.
  • Where a token may be sent: the client refuses to send a token to a host the token does not name. It reads allowed hosts from a root_domains claim (or its namespaced alias), and otherwise from aud entries that are https URLs or domains. The audience must therefore cover the loreserver host.
  • Actions: read, write, owner, admin, migrate, push-protected, set-protected, obliterate, presign. Any grant on a repository implies read.
  • Exchanged token lifetime: at most five minutes in Lore's sample service. The client keeps an exchanged token until it expires, so a permission change takes effect within that window.

Not relied upon

  • Lore's Rust crates. They are unpublished (publish = false) and pre-1.0. lore-forge talks to Lore over its network protocols. Only forge-lore uses Lore's protocol definitions, pinned to a git revision.
  • Forks. Lore's roadmap lists forks as "later, exploring", so change requests are branch-based.

Verified end to end

scripts/e2e-lore.sh runs an unmodified loreserver and lore CLI against lore-forge, using the configuration lore-forge loreserver-config generates. By default it uses the official release pinned in lore.lock. As of 2026-11-25 it passes against the v0.14.0 release. An earlier version of the test, which read claims with --with-claims, passed against a source build of 6b12f00. Whether main still has --with-access-token is unchecked. Together these verify:

  • loreserver starts against lore-forge's discovery document and ES256 JWKS.
  • lore auth login completes the device grant through lore-forge's approval page, over plain http on localhost (the client allows loopback http).
  • lore repository create, commit, push and clone work with exchanged repository-scoped tokens, and the token Lore stores carries the resources claim.
  • lore repository list is answered by the registry's RepositoryList.
  • lore auth info resolves the user's display name through UserService. --with-access-token prints the stored repository token, whose payload the test checks. (--with-claims exists on main but not in v0.14.0.)
  • A second user is refused create in another's namespace, clone and listing.
  • lore auth login --token-type api-key (token from LORE_TOKEN) logs in through token exchange with a lore-forge API token; the CLI sends the type api-key verbatim.
  • lore auth login --client-id <service account> (secret from LORE_CLIENT_SECRET) logs in with the client credentials grant. A service account without a grant is refused clone; after a grant it clones.
  • lore auth logout reaches the revocation endpoint.
  • loreserver's ports can be moved with [server.quic], [server.grpc] and [server.http] port settings; the test uses this (LORE_PORT) to run beside a deployment from run/.
  • How refusals surface: the registry's INVALID_ARGUMENT message reaches the CLI verbatim; NOT_FOUND is reported by loreserver as FAILED_PRECONDITION "A required Auth entity was not found"; PERMISSION_DENIED and an exchange invalid_target both show as "Not authorized to access repository".

Release binaries

Verified against the v0.14.0 GitHub release:

  • Each release publishes lore-<version>-<target>.tar.gz, loreserver-<version>-<target>.tar.gz and liblore-<version>-<target>.tar.gz (the C library and lore.h; a zip on Windows) for aarch64-apple-darwin, x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu, plus Windows and -debug variants. There is no Intel macOS build.
  • GitHub records a SHA-256 for every asset, which scripts/fetch-lore.sh --pin copies into lore.lock.
  • Binaries sit at the archive root. The loreserver archive also holds sample configuration in config/, which the fetch script keeps as config-examples/.
  • loreserver has its defaults compiled in. A config directory holding only the generated forge.toml is enough. The public QUIC endpoint listens on 0.0.0.0:41337. Without [server.quic.certificate], it generates a self-signed certificate on every start.
  • On macOS the lore CLI stores the key for its token store in the keychain (tokenstore_encryption_key). Each process asks for access until "Always Allow" is chosen. LORE_AUTH_STORE=fallback keeps the key in a file beside the store (LORE_AUTH_PATH) instead, which is how scripts/e2e-lore.sh runs without prompts. Programs linking liblore read those two variables but not the CLI's [auth] config.
  • liblore and the CLI share logins through that store. A login made through liblore's auth_login_interactive goes through the same device flow as lore auth login. What the desktop client found about liblore is in desktop-client.md.
  • v0.14.0's user.proto differs from 6b12f00 only in comments, so the vendored proto matches.

Reading repositories

Read in Lore's source at 6b12f00 (the protos are identical in v0.14.0 apart from comments) and confirmed by scripts/e2e-lore.sh against the v0.14.0 release:

  • The public gRPC endpoint ([server.grpc], port 41337 over TCP) is plaintext HTTP/2 when it has no certificate; there is no self-signed fallback as for QUIC. The CLI uses gRPC for revision calls whatever the URL scheme.
  • Partition-scoped calls (RevisionService, ThinClientService, StorageService) need authorization: Bearer <token> and the repository ID as 16 raw bytes under lore-partition-bin and urc-repository-id-bin (the CLI sends both). The token must be repository-scoped: a login token matches no resources entry and is refused. Every read call needs only read.
  • RepositoryGet returns the default branch, fixed at creation (main is only the default name).
  • BranchList streams branches; latest is the tip's signature.
  • RevisionList returns at most 100 revisions newest first, following first parents, with paging signatures. Its items carry no message, author or parents; RevisionInfo does.
  • RevisionTree takes a path prefix and a depth and can attribute each entry to the revision that last changed it. RevisionDiff streams changes between two signatures.
  • ContentDiff is unimplemented: it answers UNIMPLEMENTED.
  • File content is served decoded on the HTTP port (41339) at GET /v1/repository/<id hex>/content/<hash hex>[-<context hex>] with the same bearer token, and honours Range. The HTTP endpoint is plaintext.
  • lore branch merge <branch> commits the merge itself, with no message.
  • Timestamps in Revision are milliseconds.

Unverified

  • How BranchPush with fast_forward_merge reports a conflict.
  • Whether a repository can be renamed, which decides whether namespaces can be renamed.
  • Whether identical content is deduplicated across repositories or only within one.
  • Whether NotificationService.Subscribe is reachable by an external subscriber in the default local mode, and what permission it needs.
  • What loreserver itself checks on repository create beyond asking the registry, other than the error mapping above.
  • How stable ThinClientService is between releases.
  • Whether a TreeNode in a linked repository can be read with a token for the parent repository, or needs one for the linked repository.
  • Paging RevisionList with signature_backward; the browser does not page yet.
  • Whether a push loreserver has acknowledged survives a crash within the local stores' 10-second flush interval. A clean SIGTERM stop keeps it (shown by the e2e backup check).

Upstream files worth reading

  • docs/proposals/2026-08-20-oidc-oauth2-authentication.md — the authentication design.
  • docs/reference/lore-server-config.md, section "Authentication" — every setting.
  • contrib/oidc/README.md and contrib/oidc/exchange/ — runnable demos and the sample token exchange service, which is the contract lore-forge's issuer follows.
  • lore-proto/proto/ — all gRPC definitions.
  • docs/roadmap.md — what Epic plans, including its own web client.