Skip to content

CI: gate the emitted parser against createParser (run emit-parser-verify) #7

Closed

Description

@johnsoncodehk

test/emit-parser-verify.ts checks that the emitted parser (emitParser, PR #4) is byte-identical to createParser (the oracle) across the tests/cases corpus — but it is not run in CI. So a future change to gen-parser.ts, emit-parser.ts, gen-lexer.ts, or a grammar could silently make the emitted parser diverge from the oracle.

Add it to the CI test job over a stride-sample (a few hundred to a few thousand files, for runtime), so emitted == createParser is enforced on every push.

Optionally: emit the parser from cli.ts and add the emitted artifact to the npm run gen "must be in sync" check, so the committed emitted parser can't drift from the grammar either.

Activity

  1. johnsoncodehk commented on Jun 20, 2026

    @johnsoncodehk
    OwnerAuthor

    Done — the core ask is resolved by PR #53.

    emit-parser-verify (plus emit-reject-messages and emit-lexer-verify) now run two ways:

    • in npm run check (the CI test job, every push) on a corpus-free in-repo corpus (test/emit-corpus.ts), so emitted == createParser is enforced without needing the external corpus; and
    • in a dedicated path-gated emit-parity CI job that pinned-clones the full TS tests/cases and runs all three over the whole corpus for breadth.

    So a change to gen-parser.ts / emit-parser.ts / gen-lexer.ts / a grammar can no longer silently diverge — the gate re-emits and compares to the oracle on every push. (It already earned its keep: wiring it to the full corpus surfaced a pre-existing farthest-hint divergence, handled in #53.)

    The optional second part — emit the parser from cli.ts as a committed artifact and add it to the npm run gen in-sync check — is deferred, not done. emitParser currently has no consumer outside the tests (it's generated on the fly), so committing it would add multiple MB of generated JS that nothing reads, and the parity gate above already enforces grammar→emitted correctness on every push. Worth revisiting only if/when the emitted parser becomes a distributed/inspectable product artifact (the URL-import direction); the in-sync mechanism is the same one npm run gen already applies to the other artifacts.

    Closing as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions