refactor(store/memory): split adapter by domain and document helpers#57
Merged
Conversation
Break the 782-line store.go into per-domain files (principal, role, provisioning, identity, oidc) plus clone.go and validation.go, while keeping the package surface frozen at NewStore/*Store. Test files mirror the new layout with per-domain TestStoreSatisfiesXContracts compile-time assertions and helpers_test.go for the shared createPrincipal/constants. Every unexported helper gains a one-line godoc; ProvisionIdentity, CreateRegistration, and UpdateCredentialAfterLogin now carry inline comments naming the write-lock and credential-binding security invariants. Co-Authored-By: Claude Opus 4.7 (1M context) <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
store/memory/store.go(782 lines, 5 fused domains) into per-domain files:principal.go,role.go,provisioning.go,identity.go,oidc.go, plusclone.go(defensive-copy helpers) andvalidation.go(shared validators). Existingtoken.goandpasskey.goare kept but gain godocs on previously-undocumented unexported helpers.helpers_test.gocarries the sharedcreatePrincipalhelper and package test constants; each domain has a matching*_test.gowith aTestStoreSatisfiesXContractscompile-time port-assertion bundle plus that domain's existing local unit tests. The legacy monolithicstore_test.gois deleted (its content is fully redistributed).LinkIdentityandCreateRegistration, the credential-binding immutability inUpdateCredentialAfterLogin, and the write-lock-for-whole-operation reasoning inProvisionIdentity.go doc ./store/memorystill shows exactlytype Store struct{ ... }andfunc NewStore() *Store. Behavior unchanged.This is PR B of a three-PR storage refactor; PR A (
internal/storetestsub-suite split, #56) landed first. PR C will mirror the same shape forstore/postgresplus extractwithTx/codec/error/clone helpers.Test plan
moon run root:check --summary minimal(vet, lint, build, unit tests)moon run root:integration(postgres Testcontainers suite)go doc ./store/memorymatchesmastergit diff --check(no whitespace damage)store.goitself now 88 lines🤖 Generated with Claude Code