feat(ts): cross-impl golden tests against fixtures.toml (rebased from #68)#69
Conversation
Cherry-picked from PR #68 (closed; stale base would have reverted PR #67's Python pin work + the v1-3-fields-probe Rust binary). The new test loads /Users/tsavo/provekit/conformance/fixtures.toml at test time and asserts the TS canonicalizer produces byte-identical JCS bytes for each fixture. Closes the gap PR #17 noted: "TS golden is TS-vs-TS only — Rust-side byte-equality fixture needs minting". Now TS verifies against the canonical Rust-emitted bytes the conformance harness pins, not against its own derivation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR introduces a new Vitest cross-implementation golden test that loads TOML fixtures, parses fixture blocks with multi-line string support, builds IR formulas for recognized fixture names, and validates that the TypeScript canonicalizer's serialized output matches Rust-emitted expected bytes and hash values. ChangesCross-Implementation Golden Test
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds a new TypeScript conformance test intended to compare the TS canonicalizer against the repository’s shared conformance/fixtures.toml goldens, so the TS implementation can be checked against Rust-emitted fixture bytes and hashes instead of only TS-vs-TS expectations.
Changes:
- Adds
cross-impl-golden.test.tsunder the TS canonicalizer tests. - Loads
conformance/fixtures.toml, parses fixture entries, and builds matching TS-side formulas for supported fixture names. - Asserts serialized JCS bytes and BLAKE3-512 CIDs against the shared golden fixtures, while skipping non-formula fixtures.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (inJcs) { | ||
| if (line.endsWith("'")) { | ||
| jcsBuffer += line.slice(0, -1); | ||
| current.jcs = jcsBuffer; | ||
| inJcs = false; | ||
| jcsBuffer = ""; | ||
| } else { | ||
| jcsBuffer += line; |
| const ast = formulaToCanonicalAst(formula); | ||
| const bytes = serializeCanonicalAst(ast); | ||
| const actualJcs = bytes.toString("utf8"); | ||
|
|
||
| expect(actualJcs, `JCS byte mismatch for "${fixture.name}"`).toBe( | ||
| fixture.jcs, | ||
| ); |
| const formulaFixtures = allFixtures.filter((f) => buildFormulaFor(f.name) !== null); | ||
| const nonFormulaFixtures = allFixtures.filter((f) => buildFormulaFor(f.name) === null); | ||
|
|
||
| describe("cross-impl golden: TS canonicalizer vs Rust-emitted fixtures", () => { | ||
| it.runIf(nonFormulaFixtures.length > 0)( | ||
| `skipped ${nonFormulaFixtures.length} non-formula fixture(s): ${nonFormulaFixtures.map((f) => f.name).join(", ")} (contract/bridge declarations are not formula-level)`, | ||
| () => { | ||
| // informational only |
| // Remove optional trailing comment after value | ||
| const commentIdx = value.indexOf("#"); | ||
| if (commentIdx !== -1) { | ||
| value = value.slice(0, commentIdx).trim(); |
Adversarial audit of the concept-hub library against a broad corpus of programming idioms across the substrate's 10 supported languages. Findings categorized P1/P2/P3 for PEP 1.8.0 planning. Baseline: 45 primitive op + 7 pattern-shape concept:* ops at main 21cd698. Missing concepts identified: 4 P1, 7 P2, 10 P3. Language-signature gaps identified: 19. Audit-only -- no concept ops minted, no transport-gap mementos created. Findings route to 1.8.0 issue planning. Co-authored-by: Claude Code <agentwopr@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Cherry-picked the 239-LOC `cross-impl-golden.test.ts` from PR #68 (closed; stale base would have reverted PR #67's Python pin work + the v1-3-fields-probe Rust binary).
The test loads `/Users/tsavo/provekit/conformance/fixtures.toml` at test time and asserts the TS canonicalizer produces byte-identical JCS bytes for each fixture, plus matching BLAKE3-512 hashes.
Closes the gap PR #17 noted: "TS golden is TS-vs-TS only — Rust-side byte-equality fixture needs minting". Now TS verifies against the canonical Rust-emitted bytes the conformance harness pins, not its own derivation.
Test plan
Summary by CodeRabbit