Skip to content

feat(ts): cross-impl golden tests against fixtures.toml (rebased from #68)#69

Merged
TSavo merged 1 commit into
mainfrom
feat/rust-ts-byte-equality-golden-rebased
May 2, 2026
Merged

feat(ts): cross-impl golden tests against fixtures.toml (rebased from #68)#69
TSavo merged 1 commit into
mainfrom
feat/rust-ts-byte-equality-golden-rebased

Conversation

@TSavo
Copy link
Copy Markdown
Owner

@TSavo TSavo commented May 2, 2026

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

  • `pnpm test` runs cross-impl-golden.test.ts and all fixtures pass

Summary by CodeRabbit

  • Tests
    • Added cross-implementation golden test suite to validate canonicalization consistency and hash correctness between implementations.
    • Tests verify serialized canonical output bytes and derived hash values against conformance fixtures, ensuring reliable validation across TypeScript and Rust implementations.

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>
Copilot AI review requested due to automatic review settings May 2, 2026 21:43
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8fcf5557-738f-4b4e-9a03-af84f3326beb

📥 Commits

Reviewing files that changed from the base of the PR and between 8399b4d and 2afd2cf.

📒 Files selected for processing (1)
  • implementations/typescript/src/canonicalizer/cross-impl-golden.test.ts

Walkthrough

This 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.

Changes

Cross-Implementation Golden Test

Layer / File(s) Summary
TOML Fixture Loader
implementations/typescript/src/canonicalizer/cross-impl-golden.test.ts (lines 1–115)
Parses conformance/fixtures.toml line-by-line, detects [[fixture]] blocks, collects key-value pairs with support for single-quoted multi-line jcs literals, strips inline comments, and returns structured fixture objects.
Test Setup & Filtering
implementations/typescript/src/canonicalizer/cross-impl-golden.test.ts (lines 121–207)
Loads fixture file from disk, defines IR term/sort constructors (Int, String, constTerm, varTerm, ctorTerm), implements buildFormulaFor() to return IR for eq_atomic and pattern1_bounded_loop fixtures, and partitions fixtures into formula and non-formula sets.
Test Assertions
implementations/typescript/src/canonicalizer/cross-impl-golden.test.ts (lines 208–239)
Runs Vitest suite with conditionally skipped non-formula fixtures and paired assertions per formula fixture: (1) serialized canonical AST matches expected JCS string, (2) computed CID matches expected hash.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A golden test hops into view,
Rust and TypeScript, comparing anew,
Each formula checked, each hash verified true,
Cross-impl conformance—a rabbit's debut!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rust-ts-byte-equality-golden-rebased

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@TSavo TSavo merged commit edd733f into main May 2, 2026
1 of 5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts under 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.

Comment on lines +63 to +70
if (inJcs) {
if (line.endsWith("'")) {
jcsBuffer += line.slice(0, -1);
current.jcs = jcsBuffer;
inJcs = false;
jcsBuffer = "";
} else {
jcsBuffer += line;
Comment on lines +219 to +225
const ast = formulaToCanonicalAst(formula);
const bytes = serializeCanonicalAst(ast);
const actualJcs = bytes.toString("utf8");

expect(actualJcs, `JCS byte mismatch for "${fixture.name}"`).toBe(
fixture.jcs,
);
Comment on lines +205 to +212
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
Comment on lines +81 to +84
// Remove optional trailing comment after value
const commentIdx = value.indexOf("#");
if (commentIdx !== -1) {
value = value.slice(0, commentIdx).trim();
TSavo added a commit that referenced this pull request May 12, 2026
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>
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.

2 participants