Skip to content

Add correctness matrix and property-based tests#11

Merged
intech merged 1 commit intomainfrom
test/correctness-harness
Apr 19, 2026
Merged

Add correctness matrix and property-based tests#11
intech merged 1 commit intomainfrom
test/correctness-harness

Conversation

@intech
Copy link
Copy Markdown

@intech intech commented Apr 19, 2026

Summary

Adds correctness test harness for encode-path optimizations. Split from #6 which was repurposed as benchmark matrix merge.

What's included

  • `correctness-matrix.test.ts` — matrix test across encoders × fixtures (10 fixtures)
  • `round-trip-property.test.ts` — property-based round-trip (seeded mulberry32 PRNG for determinism)
  • `byte-identity.test.ts` — strict byte-identical assertions

Test coverage

54 new tests across 26 suites covering: proto3 defaults, packed/unpacked repeated, oneof variants, map fields (including integer keys), UTF-8 multi-byte, varint boundaries, determinism invariants.

Encoder registry

ENCODERS array tests `toBinary` and `toBinaryFast` (both now on main after #6/#8/#10). Matrix auto-expands to N×N encoder pairs when new encoders added.

Runtime

551ms isolated, contributes ~5s to full suite.

🤖 Generated with Claude Code

Adds a comprehensive correctness test harness for encode-path invariants
so future encoder variants (L0 contiguous-buffer writer, schema plans,
specialized writers) can be validated automatically in CI:

- correctness-matrix.test.ts — matrix across encoders × fixtures covering
  scalars, packed repeated, nested messages, maps, oneofs, and WKTs.
  20 tests across 10 fixtures.
- round-trip-property.test.ts — seeded property-based round-trip tests
  (100 random scalars, 50 packed, 50 nested, oneof variants, map
  ordering, UTF-8, int32/int64 boundaries, deep nesting). 16 tests.
- byte-identity.test.ts — strict byte-identical assertions for
  proto3 default omission, packed vs unpacked repeated, oneof emission,
  UTF-8 multi-byte codepoints, varint boundaries, and determinism.
  18 tests.

The ENCODERS registry in each file currently contains only `toBinary`.
New encoders (`toBinaryFast`, schema-plan variants) will be added to the
registry as they land on main — the matrix will then exercise every
pair automatically.

Total: 54 new test cases, ~1082 LOC added. Runtime <600ms for the three
new files; full protobuf-test suite 2877 tests pass (was 2823).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@intech intech self-assigned this Apr 19, 2026
@intech intech merged commit 785abbd into main Apr 19, 2026
27 of 28 checks passed
@intech intech deleted the test/correctness-harness branch April 19, 2026 22:22
intech added a commit that referenced this pull request Apr 19, 2026
Regenerated after merge of #6 (benchmark matrix), #8 (L0 contiguous
writer), #10 (L1+L2 schema plans + specialized writers), #11
(correctness tests).

Key results (Node 25.8, log-scale chart):
- OTel 100 spans:    525 -> 2,501 ops/s (+376%), 0.80x pbjs (3,110)
- OTel Metrics 50:   891 -> 4,773 ops/s (+435%)
- OTel Logs 100:     880 -> 3,772 ops/s (+329%)
- K8sPodList 20:     712 -> 3,510 ops/s (+393%)
- Stress d=8 w=200:  2,568 -> 14,378 ops/s (+460%)
- SimpleMessage:     1.39M -> 1.81M ops/s (+30%)

Memory allocations per encode reduced proportionally via L0 contiguous
buffer + L1 schema-plan opcode interpreter + L2 specialized field writers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
intech added a commit that referenced this pull request Apr 19, 2026
Regenerated after merge of #6 (benchmark matrix), #8 (L0 contiguous
writer), #10 (L1+L2 schema plans + specialized writers), #11
(correctness tests).

Key results (Node 25.8, log-scale chart):
- OTel 100 spans:    525 -> 2,501 ops/s (+376%), 0.80x pbjs (3,110)
- OTel Metrics 50:   891 -> 4,773 ops/s (+435%)
- OTel Logs 100:     880 -> 3,772 ops/s (+329%)
- K8sPodList 20:     712 -> 3,510 ops/s (+393%)
- Stress d=8 w=200:  2,568 -> 14,378 ops/s (+460%)
- SimpleMessage:     1.39M -> 1.81M ops/s (+30%)

Memory allocations per encode reduced proportionally via L0 contiguous
buffer + L1 schema-plan opcode interpreter + L2 specialized field writers.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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