Skip to content

Feat/serialize package - #1

Merged
Thanga-Ganapathy merged 6 commits into
mainfrom
feat/serialize-package
Nov 4, 2026
Merged

Thanga-Ganapathy merged 6 commits into
mainfrom
feat/serialize-package

Conversation

@Thanga-Ganapathy

Copy link
Copy Markdown
Contributor

No description provided.

…rom obj-diff

Extract obj-diff's stringify/parse codec into a standalone, dependency-free
package with an unchanged wire format, plus low-level encode/decode for
embedding encoded values in other JSON shapes.

Hardening for untrusted input:
- "__proto__" keys are defined as own properties; prototypes never change
- optional maxLength / maxDepth limits on parse (maxDepth on stringify too)
- a clear INVALID_ENVELOPE error for input missing the {v, $refs} wrapper
- every failure is a SerializeError with a machine-readable code
- type tags and Error names can no longer reach Object.prototype members
- self-referencing Map/Set input throws CIRCULAR_REF instead of overflowing
- payloads are shape-checked instead of building broken values

Tooling: esdev (test, build, typecheck), pnpm (TypeScript 7, Biome), tsr tasks.
- benchmarks/: fidelity, malformed-input, wire-size and speed comparison
  against superjson, devalue, seroval and @ungap/structured-clone on esdev
  bench; writes benchmarks/results.json
- benchmarks/readme.ts renders the results into README's Measured section
  (tsr bench:readme)
- README rewritten in the Open Tech Foundation style, with a feature
  comparison and the AFW / obj-diff context
- Any value reachable by more than one edge is written once in $refs and
  referenced by token; Map, Set and Error claim their id before their
  children, and the decoder registers their empty shells first, so cycles
  through them round-trip and every shared value keeps its identity.
- Array holes encode as tokens for one shared {"_t":"hole"} entry; a hole
  anywhere but an array element is rejected as INVALID_PAYLOAD.
- Output for values without shared specials or holes is unchanged, byte for
  byte, from obj-diff 0.18; CIRCULAR_REF now only flags forged leaf entries.
- Fidelity benchmark: 28/28; README regenerated.
- .github/workflows/ci.yml: pnpm install, esdev and tsr, then `tsr ci`.
- CHANGELOG.md with an [Unreleased] section for the curated strategy.
- release.toml: drop the [discovery] entry that matched no package, build
  with esdev before publishing (a [[setup]] step installs it), and enable
  provenance so the workflow gets id-token: write; release.yml regenerated
  with `release upgrade --force`. `release doctor` reports no issues.
@Thanga-Ganapathy
Thanga-Ganapathy merged commit dda4b89 into main Nov 4, 2026
1 check passed
@Thanga-Ganapathy
Thanga-Ganapathy deleted the feat/serialize-package branch November 4, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant