refactor(storage): centralize safe persisted identifier validation - #4931
refactor(storage): centralize safe persisted identifier validation#4931seekskyworld wants to merge 1 commit into
Conversation
Signed-off-by: seekskyworld <djh1813553759@gmail.com>
267f1a9 to
e666677
Compare
Astro-Han
left a comment
There was a problem hiding this comment.
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.tsalready combined atypeofcheck with the pattern; the guard folds both into one call with identical outcomes.session-copy-cleanup.tskeeps its caller-specific trim-then-validate order.goal-authority.tskeeps its caller-specificTypeErrormessage;session-bundle-policy.tskeeps itsSessionBundleExportErrorcontract.- 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.
Fixes #4926
Summary
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