Add Date, ArrayBuffer, and TypedArray support; establish golden test vectors#1
Merged
Conversation
added 9 commits
May 31, 2026 01:27
…rmance docs - format.ts: add Tag.Date(40), Tag.Bytes(41), Tag.TypedArray(42) and ElementType enum, in sync with spec/FORMAT.md §5.3/§5.1/§5.4 - encode.ts: encode Date (svarint ms + 0 nanos), every TypedArray subtype (concrete-before-abstract instanceof order), and ArrayBuffer as Bytes - decode.ts: decode Date / Bytes / TypedArray, error on unknown element type - index.ts: export ElementType - test/roundtrip.ts: +14 cases (Date incl. identity, all TypedArrays, ArrayBuffer, special floats, empty arrays) — 42 passed, 0 failed - scripts/gen-golden.ts: generate spec/golden/*.bin vectors - spec/golden/: 9 golden binary vectors - conformance/README.md: harness contract, vector table, per-language layout
- package.json: drop caret ranges (@types/node, tsx, typescript) → exact pins - pnpm-lock.yaml: update specifier fields to match (lockfile format kept at 6.0) - add js/.npmrc with save-exact=true so future installs pin by default
- package.json: add packageManager "pnpm@11.5.0+sha512..." (Corepack pin) - pnpm-lock.yaml: regenerate with pnpm 11.5.0 (lockfile format 6.0 -> 9.0) Corepack now enforces pnpm 11.5.0 for everyone using this repo.
- devDeps: vitest@4.1.7, tsdown@0.22.1 (exact pins) - migrate test/roundtrip.ts -> test/roundtrip.test.ts (describe/it/expect), all assertions preserved; run via `pnpm test` (vitest run) - vitest.config.ts: include test/**/*.test.ts, node environment - tsdown.config.ts: bundle src/index.ts -> dist (ESM + d.ts), `pnpm build` - package.json: proper ESM exports/main/module/types pointing at dist, files: [dist], scripts: build / test / test:watch / typecheck
- tsdown: outExtensions -> .js / .d.ts (was .mjs / .d.mts); package.json main/module/types/exports realigned to dist/index.js + dist/index.d.ts - devDeps (exact pins): oxlint@1.67.0, oxfmt@0.52.0, fast-check@4.8.0 - scripts: lint, lint:fix, format, format:check - .oxlintrc.json: correctness category; disable unicorn/no-new-array (intentional length-preallocation in encode/decode) - .oxfmtrc.json: defaults; formatted all sources (cosmetic only: trailing commas / wrapping) - test/property.test.ts: fast-check property roundtrips (nested values, Int32Array, Date) - drop unused loss-of-precision literal from roundtrip test Verified: typecheck + lint + format:check clean, 43 tests pass, build ok.
moduleResolution is "bundler" and the lib is bundled by tsdown (run via tsx/vitest), so explicit .js extensions are unnecessary. Extensionless specifiers across src/test/scripts; behavior unchanged. Verified: typecheck + lint + format:check clean, 43 tests pass, build ok, golden vectors byte-identical.
Next session will extend existing modules, so the "完了済み(触らないこと)" prohibition no longer applies. Heading is now just "完了済み".
Runs on push to main and all PRs. Node 22 + Corepack-pinned pnpm 11.5.0, working-directory js/. Steps: install --frozen-lockfile, typecheck, lint, format:check, test, build. Caches the pnpm store keyed on the lockfile.
Add a build matrix over Node 22/24/26 (fail-fast disabled). pnpm store cache key now includes the node version to avoid cross-job collisions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements support for Date, ArrayBuffer, and TypedArray types in the Graft binary format (tasks 1–3 from CLAUDE.md), and establishes the conformance testing infrastructure.
Key Changes
Format & Codec Extensions
format.tsencode.tsanddecode.ts:unix_ms(signed) andsub_ms_nanos(always 0 in JS)Test Infrastructure
test/roundtrip.ts(manual check/fail counters) withtest/roundtrip.test.ts(vitest describe/it)test/property.test.tsfor property-based testing with fast-checkjs/scripts/gen-golden.ts):.binfiles inspec/golden/covering all major typesConformance Documentation
conformance/README.mddefining the testing contract:Build & Package Configuration
package.json:vitest(4.1.7)fast-check(4.8.0)oxlint(1.67.0),oxfmt(0.52.0)tsdown(0.22.1)packageManagerto pnpm 11.5.0vitest.config.ts— test environment setuptsdown.config.ts— ESM build with .d.ts generation.oxlintrc.json— linting rules.oxfmtrc.json— formatting config.npmrc— save-exact pinningpnpm-workspace.yaml— workspace configImport Path Cleanup
.jsextensions from all internal imports (TypeScript module resolution)index.tsto exportElementTypeImplementation Details
.binfile is a complete Graft stream (MAGIC + VERSION + ROOT + COUNT + NODEs) with a single Object rootAll existing 28 tests pass
https://claude.ai/code/session_01AAcPMoZL93BdAkPyYT9yvs