Skip to content

Registry integrity - #30

Merged
handrews merged 3 commits into
mainfrom
registry-integrity
Sep 23, 2026
Merged

handrews merged 3 commits into
mainfrom
registry-integrity

Conversation

@handrews

Copy link
Copy Markdown
Owner

No description provided.

handrews and others added 3 commits September 23, 2026 11:18
P12 refused two schemas claiming one resource URI but left three ways a
URI could still be shadowed silently:

- An `$id` equal to another document's retrieval URI registered, and was
  unreachable: lookups prefer the alias.
- A retrieval URI reused for a different document silently repointed
  its alias.
- Claiming a bundled metaschema's URI with different content succeeded
  on a fresh engine and failed once the metaschema had been used.

All three are `DuplicateResourceError` now. The first two follow the
TypeScript engine's ADR 0005. For the third, the owner ruled that bundled
URIs are reserved for content equal to the bundled document, checked
against `_bundled` before lazy registration so the answer no longer
depends on order. A custom metaschema goes under its own URI.

Resolves DESIGN.md §7 "P12 has three gaps where an identifier still
shadows silently".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Groundwork for `unregister`, matching the TypeScript engine's ADR 0005:

- `_owned_resources` maps a document root to every resource its last
  registration claimed -- exactly P12's claim set, so nothing new is
  collected. `_resource_locations` stays the truth for who owns a resource
  now.
- When an equal embedded copy takes over a resource that was a document
  of its own, that document stops being one and loses its ownership
  record and range lookup.
- The journal gains `_pop`, a removal recorded like a write so undo puts
  it back. Only `_documents` promises an order, and nothing removes from
  it mid-registration.

A re-registration without a range lookup now drops the old one: equal
JSON can come from differently formatted text, and a caller who
re-registers without positions has said there are none. Resolves
DESIGN.md §7 "A stale range lookup survives a re-registration".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
P12 made a modified re-registration a `DuplicateResourceError`, and
nothing could undo a registration, so an edit-and-re-register loop needed
a fresh engine. `SchemaRegistry.unregister(uri)` and
`Engine.unregister_schema(uri)` take the shape the TypeScript engine's
ADR 0005 decided: no `replace=`, so remove then register is the
replacement path.

`uri` must name a document root, directly or by retrieval URI. Anything
else is `UnresolvableReferenceError`, naming the owning document for an
embedded resource. Removal drops what the document still owns -- a
resource an equal copy in a later document has taken over stays with that
document -- plus the document's range lookup and every alias pointing at
it. The produced/consumed unions and the pending queue are left alone.
Snapshots, and so compiled artifacts, keep everything.

It is refused on a snapshot, from caller code inside a registration
(whose rollback would undo it), and for a bundled metaschema, whose URI
is reserved.

Resolves DESIGN.md §7 "No way to replace a registered document".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@handrews
handrews merged commit e1cb4d3 into main Sep 23, 2026
6 checks passed
@handrews
handrews deleted the registry-integrity branch September 24, 2026 19:36
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