Skip to content

refactor(storage): centralize safe persisted identifier validation - #4931

Open
seekskyworld wants to merge 1 commit into
apache:mainfrom
seekskyworld:refactor/4926-storage-safe-id
Open

refactor(storage): centralize safe persisted identifier validation#4931
seekskyworld wants to merge 1 commit into
apache:mainfrom
seekskyworld:refactor/4926-storage-safe-id

Conversation

@seekskyworld

Copy link
Copy Markdown
Contributor

Fixes #4926

Summary

  • add a storage-local safe persisted identifier predicate and asserter
  • migrate runtime event, interaction, session bundle, session copy, and Goal authority boundaries
  • preserve caller-specific trimming, errors, and owner-id semantics
  • add 1/128 boundary and invalid-value regression coverage

Motivation

The same persisted identifier grammar was implemented in several storage authorities. Centralizing the grammar prevents future policy changes from leaving one persistence boundary weaker or accepting a different set of values.

Validation

  • npm --workspace @maka/core run build
  • npm --workspace @maka/storage run build
  • node --test packages/storage/dist/tests/storage-id.test.js packages/storage/dist/tests/session-bundle-policy.test.js packages/storage/dist/tests/session-copy-cleanup.test.js packages/storage/dist/tests/goal-authority.test.js packages/storage/dist/tests/client-capability-session-grant-store.test.js packages/storage/dist/tests/sqlite-core-execution-store.test.js (40/40)
  • npx biome check on changed storage sources and tests

@github-actions github-actions Bot added the effort/S Under 100 readable lines label Sep 6, 2026
Signed-off-by: seekskyworld <djh1813553759@gmail.com>
@seekskyworld
seekskyworld force-pushed the refactor/4926-storage-safe-id branch from 267f1a9 to e666677 Compare September 6, 2026 19:24

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR at head e666677f (7 files, +92/−8) against base 2310035a.

What the change does: adds one storage-local safe persisted-identifier module (storage-id.ts) with an isSafeStorageId type guard (unknown → string) and an assertSafeStorageId assertion over the shared /^[A-Za-z0-9_-]{1,128}$/ grammar, and migrates the five boundaries that previously implemented the same rule independently: runtime-event-invariants.ts, interaction-store.ts, session-bundle-policy.ts, session-copy-cleanup.ts, and goal-authority.ts.

Behavior equivalence (checked per call site):

  • interaction-store.ts already combined a typeof check with the pattern; the guard folds both into one call with identical outcomes.
  • session-copy-cleanup.ts keeps its caller-specific trim-then-validate order.
  • goal-authority.ts keeps its caller-specific TypeError message; session-bundle-policy.ts keeps its SessionBundleExportError contract.
  • The test covers both length boundaries (1 and 128), the charset, and rejections for empty, overlong, whitespace, path, punctuation, and non-string values, plus the assertion message.

Scope: #4926 explicitly leaves provider-specific external session identifiers and the independently evolving agent-run-store / message-admission-store paths out of this change, so the partial consolidation is by design, not a gap. One recorded P3: those remaining storage paths may still hold their own identifier checks; they should be folded in when the broader #1404 consolidation lands.

Gates: CI on this exact head is green (including the epoch guard and architecture checks); no protocol or epoch files are touched; no review is bound to the current head.

Not verified: I did not run the suites locally (CI on the exact head covers the storage suite; the author reports 40/40 passing).

No P0–P2 findings. This is a refactor; I am not approving — the merge decision belongs to humans.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/S Under 100 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(storage): centralize safe persisted identifier validation

2 participants