Skip to content

refactor(core-types): consolidate CoreValue dispatch, harden decoder pool, unify Date wire format (#58) - #66

Closed
ofriw wants to merge 36 commits into
mainfrom
refactor/corevalue-jsonserializer
Closed

ofriw wants to merge 36 commits into
mainfrom
refactor/corevalue-jsonserializer

Conversation

@ofriw

@ofriw ofriw commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Note: This PR was generated by an AI agent. If you'd like to talk with other humans, drop by our Discord!


CoreValue & JSON Serializer Refactor (issue #58)

Why this work matters

CoreType knowledge lived in three separate switch statements. Each new type needed three edits, and one missed edit failed silently. The JSON decoder pool leaked on error paths. Legacy isRef and rich-text machinery stayed after its removal and misled readers. Dates had two wire forms, and the checksum could not tell a date from a number.

This PR makes one table the single source of truth, closes the leaks, deletes the dead code, and unifies the Date form.

Changes at a glance

Added

  • + base/core-types/type-ops.ts — one frozen kTypeOps table. A missing type is now a compile error.
  • + base/core-types/encoding/encoded-ref.ts — dependency-free leaf for the ref guard.
  • + cfds/richtext/legacy-ref.ts — rejects legacy ref shapes at every ingress.
  • + db/storage-epoch.ts — refuses incompatible stores at open.
  • + Characterization suites, benchmarks, and CI type-check plus runtime-floor probes.

Removed

  • − Duplicate CoreType switches in clone.ts, equals.ts, and base-encoder.ts.
  • − Dead ref/GC plumbing: isRef, fillRefs, rewriteRefs, needGC, gc, getRefOperation, and cfds/base/types/utils.ts.
  • − Five zero-import rich-text files (composer, shortcuts, doc-state, utils, markdown ref case) and the commented blocks around them.

Changed

  • ~ Decoder pool: Symbol.dispose plus OwnedDecoder. Acquire/finalize is idempotent and generation-tracked. Eight production leak sites and decodedDataChanges are fixed.
  • ~ Date wires only as { "__t": "D", "__v": … }. The bare-number form is rejected.
  • ~ The checksum tags Date in all positions. The unknown-value path is unchanged.
  • ~ Clone keeps shared aliases across array and set siblings.
  • ~ Options and hash names are unified. coreValueHash becomes encodableValueHash.

Also on this branch (separate feature, #55)

  • ~ Idle repository and query auto-close, plus lazy query loading (db.ts, repo/, base/emitter.ts).

Breaking changes

  • Old stores are refused at open with "delete and re-sync". Mixed-version fleets are unsupported.
  • Legacy rich-text refs and bare-number dates throw instead of decoding. Reject, never strip — silent truncation cannot happen.
  • A lone { "__rId": <n> } outside __r/__d throws.
  • A non-typeSafe string can still collide with a tagged Date. Use typeSafe for untrusted input.
  • The version becomes 0.7.0. kTypeOps stays internal, not public API.

Value

One place defines a type. Missing coverage fails the build. Leaks become testable. Incompatible data fails loud and clear, not as scattered corruption. Goldens pin the stored bytes.


Attached is an agent-optimized description of the changes in this PR: AGENT_REVIEW.md

ofriw added 30 commits October 15, 2026 19:44
…rations table, drop isRef/gc/fillRefs methods
@ofriw

ofriw commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by the reviewed, fully verified replacement stack: https://github.com/goatplatform/goatdb/stack/92

Each complete replacement tip passed full Deno + Node + browser suites on current Deno2.9.1 and actual floor2.3.3, with Node24.14.1 and Playwright1.64.1. Exact tip hashes, scope, dependencies, gates and breaking/data notices are in the new PR bodies. Final tip9e9a759f has 0 failures on all six full runs; the 49-source-commit content audit and independent review passed. Remote Actions status is separate from these measured local gates.

Review bottom-up. This replaces the old split, not just its last diff. No PR was merged, no issue was edited, and original remote branches are retained.

@ofriw ofriw closed this Oct 29, 2026
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