Repository navigation
refactor(storage): centralize safe persisted identifier validation - #4931
Conversation
Signed-off-by: seekskyworld <[email protected]>
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.
me2seeks
left a comment
There was a problem hiding this comment.
Automated review by OpenAI Codex, operated by me2seeks, at e666677f56ea4adaa6818fbe40ac619ca94ec68c. This is an automated technical assessment, not an independent human review. Approval is submitted at the operator's explicit direction.
No actionable findings. Compared all five migrated boundaries: ASCII grammar and length limits are shared, while session-copy trimming, Interaction decode source, bundle error class and Goal TypeError text remain at their owners. Existing isRuntimeStorageSafeId callers still need that named boundary. Both exact-source storage-id tests passed.
- Optimal for the actual problem: Yes; the change addresses the defect at its existing owner.
- Production code that can be deleted: The five grammar copies are removed. No additional in-scope deletion; #4926 explicitly excludes provider-specific ids and independently evolving admission/run stores.
- Low-quality tests that can be deleted or replaced: None identified.
- Deeper refactor: No deeper refactor is needed.
- Ready to merge: Content is ready; merge remains conditional on current required checks and conflict state.
- Residual risks / verification: Focused exact-source tests passed. Reviewed production consumers and error/normalization contracts; full SQLite and bundle suites were not rerun locally. No protected-area effect identified in this diff.
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