refactor(core): share canonical JSON serializer with eval and storage - #4932
refactor(core): share canonical JSON serializer with eval and storage#4932seekskyworld wants to merge 1 commit into
Conversation
Signed-off-by: seekskyworld <djh1813553759@gmail.com>
88282c4 to
8c1a5e8
Compare
hqhq1025
left a comment
There was a problem hiding this comment.
Reviewed all six changed files at 8c1a5e8. No substantiated P0–P3 finding.
The new core/canonical-json subpath re-exports the existing serializer unchanged. Eval and Storage remove two local serializers; Storage retains schema validation and its stable invalid_manifest error. This is not completely behavior-neutral for Eval: newly written experiment files can have different key order, and invalid JavaScript values such as NaN are rejected rather than coerced. Existing files are parsed and compared canonically without rewriting them. The CLI already validates its JSON input before this call.
Validation: 16 focused exact-source tests and four independent production probes passed. I compared 32 valid Manifest V1 cases with the actual base producer, including Unicode, optional activation provenance and numeric boundaries; all encoded bytes were identical and cross-decoding succeeded. A legacy experiment file with differently ordered numeric/case/accented keys reopened unchanged; changed specs still rejected. Concurrent conflicting writers retained one winner, and invalid input left no partial experiment file. Replacing the shared serializer with ordinary JSON.stringify caused six regression tests to fail across core, Eval and Manifest, confirming the checks exercise the changed consumers.
The local tests used current-head TypeScript through an esbuild source loader, not a full local build/typecheck. Hosted test and audit are successful on this exact head; GitHub reports MERGEABLE/BLOCKED. Refactoring direction remains a human decision, and this automated source review does not grant merge or product acceptance.
Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.
Fixes #4927
Summary
@maka/core/canonical-jsonSessionBundleFileError('invalid_manifest', ...)Motivation
Eval identities and portable bundle bytes were produced by separate serializers. Sharing the strict core authority keeps key ordering and rejection of unsupported JSON values consistent across both persistence boundaries.
Validation