Skip to content

refactor(core): share canonical JSON serializer with eval and storage #4927

Description

@seekskyworld

Problem

The headless package now has one canonical JSON implementation, but packages/eval/src/experiment-directory.ts and packages/storage/src/session-bundle-manifest.ts still carry separate serializers. They encode the same sorted-object/JSON primitive rules independently, so changes to canonicalization can silently produce different experiment identities and bundle bytes.

Scope

  • Expose the existing strict canonical JSON authority from @maka/core through a neutral module name.
  • Replace the eval and session-bundle copies with that authority.
  • Preserve the manifest's stable SessionBundleFileError for invalid values and the eval newline/file format.
  • Leave runtime-host serializers for a separately coordinated change because their undefined policies are distinct and their files are under active PRs.

Acceptance criteria

  • Equivalent key order produces identical bytes in both consumers.
  • Manifest encoding still rejects non-finite/unsupported values with its existing public error code.
  • Experiment directory creation and collision checks retain their current output and newline behavior.
  • Focused core, eval, and storage tests cover deterministic ordering, nested arrays/objects, and invalid values.

This is a child slice of the canonicalization audit in #1404.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions