Skip to content

id-store: versioned namespace registry state + authorization seam (#10257) - #12867

Merged
dezren39 merged 1 commit into
mainfrom
archer/10257-namespace-registry-state
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
archer/10257-namespace-registry-state

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Implements slice A9116-registry-state for #10257 (parent #9116; design part-a-addressing/versioned-design.md A-9116.1, S4.2–S4.10, S4.18). Native blockers verified closed before implementation: #9083, #10160 (9110-02), #10243 (A9116-registry-record).

What

  • pkgs/id/crates/id-store/src/namespace_registry.rs (new) — RegistryState: a LocalRegistry (record layer, id-core) plus a generation counter and an audit log.
    • Mutations create/update/revoke go through one transition: authorize → expected-generation check → apply. Authorization uses the injected seam — a MutationContext (principal + tenant/authorization scopes, the port envelope's scopes under the design(pm-stack): tenancy architecture — per-user Turso databases + central tenancy DB, served by Workers and Durable Objects #9083 contract) judged by a RegistryAuthorizer; shipped judge is AdminScopeAuthorizer. This slice defines no tenancy.
    • A failed mutation changes nothing (definitions, generation, audit). Success increments the generation by exactly one and appends an audit entry (generation, mutation, namespace, context).
    • Concurrent writers: a stale expected generation is a typed GenerationConflict, never a silent overwrite.
    • Updates cannot move a namespace to the other core (CoreChange) — handlers cannot change core identity.
    • Persistence: canonical-CBOR state (version 1, strict known fields, definitions re-validated through the record layer on decode); rollback = resolve through the last verified generation. Iroh namespace registries are untouched and coexist.
  • pkgs/id/crates/id-store/tests/namespace_registry_model.rs (new) — the recorded model oracle: generated operation sequences (3 seeds × 300 ops mixing authorized/unauthorized contexts, stale/future generations, duplicate creates, unknown-name updates/revokes, core-changing updates) run against an independent reference model; every resulting state and error compared. Plus targeted tests: exactly-one-generation increments, unauthorized-changes-nothing (authorization precedes the generation check), conflict-changes-nothing, core-change refusal, byte-exact persistence round-trip, decode rejection of unknown fields/other versions, two-registry coexistence, authorizer substitutability.
  • pkgs/id/crates/id-store/src/lib.rs — one line: pub mod namespace_registry; (the crate-root export the manifest assigned to 9110-02, which closed as the port-contracts slice before this module existed).

Verification

cargo test -p id-store --test namespace_registry_model (nix develop, pkgs/id, laptop worktree off origin/main):

running 9 tests
test state_round_trips_through_canonical_bytes ... ok
test each_successful_mutation_increments_exactly_one_generation ... ok
test unauthorized_mutation_changes_nothing ... ok
test decode_rejects_unknown_fields_and_other_versions ... ok
test authorizer_is_a_seam_not_a_singleton ... ok
test registries_coexist_with_independent_state ... ok
test update_cannot_change_core ... ok
test generation_conflict_changes_nothing ... ok
test generated_operations_match_the_model ... ok
test result: ok. 9 passed; 0 failed

cargo fmt -p id-store -- --check clean. No production rollout — library state machine + tests only, per the packet.


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…0257)

Slice A9116-registry-state: RegistryState wraps the record layer LocalRegistry with a generation counter and an audit log. Mutations (create/update/revoke) authorize through the injected RegistryAuthorizer + MutationContext seam first, then check the expected generation (concurrent-writer conflict), then apply through the record layer; success increments exactly one generation and appends an audit entry. Updates cannot change a namespace core. State persists as canonical CBOR (versioned, strict fields) and round-trips byte-for-byte. Model test generates operation sequences against an independent reference model and compares every resulting state and error.
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 04:05
@dezren39
dezren39 merged commit 641657a into main Nov 23, 2026
1 check passed
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5519ca03-22e5-4707-893b-b7c75d41a5d6
Commits

Reviewing files that changed from the base of the PR and between 8c69c49 and 150f480.

Files selected for processing: 3

  • pkgs/id/crates/id-store/src/lib.rs
  • pkgs/id/crates/id-store/src/namespace_registry.rs
  • pkgs/id/crates/id-store/tests/namespace_registry_model.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 deleted the archer/10257-namespace-registry-state branch November 23, 2026 04:05
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