Repository navigation
Conversation
The server now uses the library for consumer reads, sync, publish and delete, and keeps v1.5.4's claims-based authorization on top of it. The library stays claims-free: claims are written through a new generic `postgres.EntryWriteHook` that runs inside the library's write transaction, and the consumer list filters by claims through an optional caller on the shared list query, set only through a module-internal context key. Consumer routes are served by `httpapi.ConsumerRouter` over a claims-aware reader. It applies v1.5.4's registry gate and filters entries with `claims_visible()` (migration 28) before choosing each name's winning source, so an entry a caller cannot see falls through to the next source. A shared case table pins the SQL function to the Go rule in `internal/claims`. Consumer reads keep v1.5.4's response shapes and audit events. Sync runs on the library's leased jobs and runtime; Kubernetes `authz-claims` annotations are recorded during a fetch and applied at commit. The `/v1` admin handlers are unchanged, and publish, delete and source changes go through the library. The old consumer handlers, sync coordinator and manager, source fetchers, Kubernetes controller and service read paths are removed. User-visible changes: consumer reads always take the highest-priority source (v1.5.4 lists used the lowest version string) and exact versions no longer fall through to lower sources; skills and plugins compete per namespace; publish validates payloads against the upstream schema; sync failure messages are categories; server icons are returned; restarts no longer reset per-entry claims on managed entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## registry-library #961 +/- ##
====================================================
+ Coverage 68.78% 71.94% +3.16%
====================================================
Files 173 165 -8
Lines 17217 14435 -2782
====================================================
- Hits 11842 10385 -1457
+ Misses 5375 4050 -1325 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Regenerate the OpenAPI spec with the current `swag`, which places schema descriptions on property references rather than on the referenced types, matching what `task gen` produces in CI. Remove a blank line left in `internal/sources/types.go` after its unused mock directive was dropped, which `gci` rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The API server ends every watch after its request timeout, and the runner returns `operator.ErrWatch` when one does. The standalone runtime treated that as fatal, so 30-60 minutes after startup it stopped sync for every source while readiness stayed green. `OperatorWorker` now runs the runner again with backoff, and once a source has synced it also retries any other non-ownership failure, which the restarted runner would otherwise report as a startup error. `AnnotationClaims` recorded annotations per kind only, so in a multi-namespace source the last namespace's list replaced the others and their entries fell back to the source's claims. It now records them per namespace and kind, forgets a source's scopes when its worker is rebuilt, and ignores resources the fetcher does not export. An annotation-only change left the snapshot hash unchanged, so the sync completed without committing and the claims hook never wrote the new claims. `annotationJobs` stores a digest of the written annotation claims with the sync result and forces a full commit when it differs. The digest is kept in storage, so every replica compares against what was written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`standalone.Runtime` validated every stored definition and stopped sync for every source when one failed, while readiness stayed green. One admin call could trigger it: an inline source created with a `syncPolicy` is accepted, as in v1.5.4, but its stored schedule failed validation. The library now drops such settings when it loads a definition; the runtime also logs and skips any definition that is still invalid, once per version, so the other sources keep syncing. Kubernetes `authz-claims` annotations were recorded only with `auth.authz`, so without it annotated entries were stored with their source's claims. v1.5.4 recorded them whenever claims were stored; the builder now always does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two consumer and admin responses changed by accident in the move to the library. A consumer read of a registry that does not exist answered "not found" instead of v1.5.4's "registry not found"; the consumer error mapper now maps the library's `ErrViewNotFound` to that message on every consumer route. A managed source from the config file had no `syncStatus` on a fresh install, because v1.5.4 wrote its initial `registry_sync` row at startup and the library never syncs a managed source. The claims-mode startup step now records v1.5.4's completed "Non-synced source (type: managed)" row with `InitializeSourceSync`, leaving an existing row alone so restarts and replicas do not overwrite it. Improves on #946 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`docs/registry-sync.md` still described v1.5.4's two-minute coordinator and called Kubernetes sources non-synced. Rewrite it for the leased-job runtime: how polled, inline, Kubernetes and managed sources sync, the two-minute failure retry, leases across replicas, and the visible differences from v1.5.4 (Kubernetes reports its real sync status, API-created inline sources are synced, sources are fetched on their own interval). Correct the Kubernetes section of `docs/configuration.md`: entries without an `authz-claims` annotation get the source's claims, as both v1.5.4 and this branch do, not no claims. Note that network packages get `transport.url` from the `registry-url` annotation, and how `syncPolicy` applies to each source type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server stopped using Kubernetes leader election when sync moved to the library's database leases, which fence every source including Kubernetes ones. `config.LeaderElectionID` was still read from `THV_REGISTRY_LEADER_ELECTION_ID` but never used, and the chart still set that variable and created a Role and RoleBinding granting configmaps, leases and events that nothing needs. Remove the field, the chart's env entry and the leader-election Role and RoleBinding; the chart writes `env:` only when it has content. A deployment that still sets the variable is unaffected. The DNS-name rule for sources stays, but its rationale is now an API contract rather than lease naming. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second of three PRs ((a) #960 → (b) → (c) Cedar mode). This PR moves the server onto the
pkg/registrylibrary while keeping v1.5.4's claims-based authorization. Stacked on #960: the base isregistry-library, so the diff shows only this PR. Retarget it tomainonce #960 merges.The library stays claims-free. The server keeps claims in step through two small, generic seams.
Writes. The library gains a public
postgres.WithEntryWriteHookoption. The hook'sBeforeEntryWriteandAfterEntryWriterun inside the library's serializable write transaction for every snapshot, publish and delete. The server'sClaimsHookuses them to:Claims commit or roll back together with the entries.
Reads. The shared list query takes an optional
caller. When a caller is set, it appliesclaims_visible()(migration 28) before choosing each name's winning source. Only the server can set the caller, through a module-internal context key, so external embedders can never turn the filter on.What changed
Consumer API.
httpapi.ConsumerRouternow serves the consumer routes, mounted at/registry, over a claims-awarecatalog.Reader(internal/claims.Reader).server.list,skill.read, …).internal/api/consumer_compat.gokeeps v1.5.4's response shapes:_metaalways present on servers;repository: {}on managed skills and plugins.internal/api/openapi_consumer.gokeeps the routes in/openapi.json.Sync. It runs on the library's leased jobs (
reconcile,ingest,operator), supervised byinternal/sync/standalone(ported from #946).authz-claimsannotations are recorded during a fetch and applied at commit.Admin API. The
/v1handlers and their responses are unchanged.Definitions.Reconcile, and their claims are stored afterwards.Removed.
internal/api/registry/v01,internal/api/x/*).Library changes (still experimental):
ValidateSnapshotaccepts servers without$schema, as registry files allow;RequiredSchemaVersionis 28.Rules and docs.
.claude/rules/data-model.md§7 now names the one sanctioned SQL claims check.auth.md,api.md,sync.mdandlayering.mdare updated.Compatibility with v1.5.4
I restored a v1.5.4 database dump and ran v1.5.4 and this branch against the same data. That's 1,090 consumer and admin GETs across 5 identities, plus 30 write scenarios.
/v1response is identical.Changes users will notice
…/versions/latest. An exact version that only a lower-priority source has now returns 404.POST /v1/entriesvalidates payloads against the upstream schema; for example, a server needs a description of 1–100 characters. Invalid payloads return 400. v1.5.4 accepted them.api.*instead ofskills.*andplugins.*. The paths are unchanged.For reviewers: one rule mismatch
.claude/rules/sync.mdused to say that Kubernetes entries without an annotation get no claims. v1.5.4's code gives them the source's claims. This PR keeps the code's behaviour and rewrites the rule. If the old rule was the intent, changing it would be a user-visible change.Testing
go test -race ./...passes (42 packages).task deadcodeis clean.Not covered: Kubernetes sources end to end (unit-tested only, not run under envtest); git and api sources end to end (the comparison used file and inline sources); running a library host and the server against the same database, which is documented as unsupported.
🤖 Generated with Claude Code