Repository navigation
One detector dialect, read alike by every runtime - #46
Merged
Merged
Conversation
pact check holds every looks-like line to the detector dialect (loader/looks-like-outside-the-dialect); the TypeScript port and shared conformance cases hold Rust, Python and TypeScript to one answer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r-dialect # Conflicts: # CHANGELOG.md # README.md # docs/90-REVIEW.md # site-docs/index.md # site-docs/status/verified.md
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r-dialect # Conflicts: # CHANGELOG.md # README.md # docs/90-REVIEW.md # site-docs/index.md # site-docs/status/verified.md
…r-dialect # Conflicts: # README.md # docs/90-REVIEW.md # site-docs/index.md # site-docs/status/verified.md
jithinAB
marked this pull request as ready for review
November 17, 2026 09:30
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.
What
One detector dialect, read alike by every runtime.
crates/pact-loader/src/dialect.rs: the detector dialect as a reader.outside(pattern)says why a pattern is outside it, and where.pact checkholds everydetectors.<name>.looks-like:line to it, each line on its own and then the lines joined as every runtime joins them, and refuses the rest withloader/looks-like-outside-the-dialect.adapters/typescript/src/detectors.ts: the TypeScript port.translateDetectorPatterntranslates exactly the patterns in the dialect to JavaScript that finds what Python'srefinds, and refuses the rest with the checker's reasons.compileDetectorscompiles a workspace'sdetectors:and holds each to itsexamples:, and the module carries the five built-in recognisers.tests/conformance/detectors.json: 87 patterns over 68 texts. Each case is in or outside the dialect, with its reason, and lists every matchre.finditeryields for the ones in it. It is read bycrates/pact-loader/tests/detector_dialect_cases.rs(the checker's reasons) and byadapters/python/tests/test_every_port_reads_one_detector_dialect.py(the reference's matches throughdetectors.declared_in, the TypeScript port's refusals and matches throughread-detectors.mts, andpact checkrefusing a tree).spec/schema.yaml(detector.looks-like) describes the dialect, and the CHANGELOG and headline counts are updated.Why
looks-like:took any regular expression Python'srecompiled. A runtime in another language reads the patterns with its own engine. Engines disagree on lookaround, back-references,(?<name>...)(refused by Python'sre, a named group to others), flags for the whole pattern,{,m}, nested classes,\bbeside non-ASCII letters,$before a final newline, and where the next search starts after an empty match. So one tree could hide a card number on one runtime and let it through on another. The dialect is the part both Python'sreand the Rustregexcrate read, with Python's meaning. The TypeScript port translates\b,\w,\d,\s,$and(?i:...)to Python's meaning rather than JavaScript's. A pattern that can match an empty value is outside the dialect: it finds something in every text, and Python and JavaScript step past an empty match differently, which was the one disagreement the shared cases found.The TypeScript module is the detector port Bud Meta Harness has run since its PK-3 card, with 10 000 canary values compared against Python's
re. Upstream holds one copy, and BMH re-pins to it instead of keeping its own (plan §3.14).Evidence
On this branch's head (upstream master a52dcdd merged in), the steps of
scripts/test-all.sh:cargo build -p pact-cli, thepact-fill-wasmrelease build,cargo test --no-fail-fast(1727 passed, 0 failed, includingdetector_dialect_cases),cargo clippy --all-targets -D warningsand the wasm clippy: exit 0.tsc --noEmit: exit 0.test_every_port_reads_one_detector_dialect.py(4 passed) andtest_the_headline_test_count_is_the_count.py.scripts/sync-counts.sh: rust=1727 adapter=3618, no document changed.Purpose checklist (§0.2)
examples:are held by the Python and TypeScript ports at compile time. The checker holds syntax, since it carries no regular-expression engine.tests/conformance/detectors.json, read by Rust, Python and TypeScript.pact check, so it is never versioned.detectors.tsor read the cases.