Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions biome-plugins/README.md

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions biome-plugins/__fixtures__/no-inline-tolerance-class.fixture.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Fixture for `no-inline-tolerance-class.grit`.
*
* Pairs 8 positive cases (a bridge normalization-class value
* written inline as a string literal — plugin MUST fire) with negative cases
* (the four universal text-encoding classes used as legitimate inline literals,
* a class name appearing only as a SUBSTRING of test-title / docName prose, a
* comment mention, a concatenation, and a non-catalog literal — plugin must NOT
* fire). The fixture-file test asserts the diagnostic count with exact equality
* (`toBe(8)`) so both a weakened pattern (drops below 8) and a widened pattern
* that catches a negative (rises above 8) fail the gate.
*
* The universal-encoding negatives (`crlf`, `bom`, `trailing-whitespace`,
* `trailing-newline`) are the load-bearing precision boundary: they are real
* `BRIDGE_TOLERANCE_CLASSES` members, yet they are deliberately NOT flagged
* because the public floor telemetry runtime surfaces them and public tests
* legitimately assert that behavior. Flagging them would redden those floor
* tests; the fixture pins that they stay silent.
*
* Deliberately NOT linted by the main `bun run lint` pass (biome-plugins/ is
* outside the lint paths); only the scoped override in biome.jsonc reaches it,
* via the fixture-file test.
*/

declare const expect: (v: unknown) => { toBe: (v: unknown) => void };
declare const applied: string;
declare const cls: string;

function positives() {
// P1: a single distinctive fidelity class written inline.
const single = 'emphasis-around-code';
// P2-P5: four class labels written inline as an array.
const reencoded = [
'doc-start-thematic',
'block-separator-collapse',
'table-align-row-spacing',
'row-no-trailing-pipe',
];
// P6: asserting an observed class against an exact fidelity literal.
expect(applied).toBe('jsx-container-boundary-blank');
// P7: an equality comparison against an exact fidelity literal.
const isCanonical = cls === 'list-indent-canonical';
// P8: a fidelity class as an object property value.
const record = { className: 'ordered-list-marker-number' };
return { single, reencoded, isCanonical, record };
}

function negatives() {
// N1-N4: the four universal text-encoding classes are real catalog members but
// are deliberately not flagged — the public floor telemetry runtime emits
// them and public tests assert that behavior. They must stay silent.
const isCrlf = cls === 'crlf';
const isBom = cls === 'bom';
const fired = ['trailing-whitespace', 'trailing-newline'];
// N5: a class name appearing only as a SUBSTRING of a test-title sentence —
// the rule keys on the literal's whole value, not a substring.
const title = 'watchdog tolerates a doc-start-thematic divergence at column 1';
// N6: a class name embedded as a substring of a docName carrying a prefix.
const docName = 'fr34-doc-start-thematic';
// N7: a class name mentioned in a comment (emphasis-around-code) is trivia,
// not a string-literal node; this assignment is an ordinary literal.
const mode = 'replace';
// N8: split across a concatenation — neither operand is the whole value.
const split = `doc-start-${'thematic'}`;
return { isCrlf, isBom, fired, title, docName, mode, split };
}

export { negatives, positives };
50 changes: 0 additions & 50 deletions biome-plugins/__fixtures__/playwright-topass-budget.fixture.tsx

This file was deleted.

60 changes: 60 additions & 0 deletions biome-plugins/no-inline-tolerance-class.grit
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// no-inline-tolerance-class — forbid an inline bridge normalization-class value in a public test.
//
// `BRIDGE_TOLERANCE_CLASSES` (packages/core/src/bridge/normalize.ts) is the
// bridge normalizer's catalog of byte-difference equivalence classes it tolerates.
// A public test should assert OBSERVABLE behavior — that two inputs reduce to the
// same `normalizeBridge` output — rather than hard-coding one of those class
// labels as an inline string literal: the label is an internal classification
// detail, and pinning it inline both couples the test to that detail and
// re-declares the catalog outside the modules that own it. `check-mirror-test-policy`
// Check B blocks a public test from IMPORTING the catalog symbol; this rule closes
// the complementary gap where a test re-encodes a class value as an inline string
// literal, past the import check.
//
// NOT matched, by design: the four universal text-encoding classes — `bom`,
// `crlf`, `trailing-whitespace`, `trailing-newline`. Those are normalizations
// every text tool performs, and the public floor telemetry runtime
// (packages/core/src/bridge/tolerance-telemetry.ts) surfaces them; public tests
// legitimately assert that runtime emits `class: 'crlf'` for a CRLF input.
// Matching them would redden those floor tests. The fixture test's drift canary
// pins this partition: every catalog member is either a matched arm here or one
// of those four universal classes, so a class added to the catalog reddens until
// it is classified.
//
// IDENTITY, not substring: the `or {}` matches a string-literal node whose value
// IS exactly a catalog member. A class name that appears only as a substring of a
// larger string — a test-title sentence (`'... (doc-start-thematic class)'`), a
// docName (`'fr34-doc-start-thematic'`), or a label — has a different node value
// and does not fire. The match is quote-style independent (a single-quoted
// pattern matches the double-quoted form Biome emits).
//
// Does NOT catch (documented honestly):
// - A class name built by concatenation (`'doc-start-' + 'thematic'`) or
// interpolation — neither operand is the whole value.
// - A class name in a template literal or a comment — GritQL matches the
// string-literal node, not template content or trivia.
//
// Suppress a legitimate inline use (none expected on the public surface) with:
// // biome-ignore lint/plugin/no-inline-tolerance-class: <reason>

language js

or {
`'commonmark-escape'` as $lit,
`'emphasis-around-code'` as $lit,
`'leading-newline'` as $lit,
`'doc-start-thematic'` as $lit,
`'block-separator-collapse'` as $lit,
`'table-align-row-spacing'` as $lit,
`'row-no-trailing-pipe'` as $lit,
`'list-indent-canonical'` as $lit,
`'ordered-list-marker-number'` as $lit,
`'paragraph-continuation-indent'` as $lit,
`'jsx-container-boundary-blank'` as $lit,
`'blank-line-collapse'` as $lit
} where {
register_diagnostic(
span = $lit,
message = "Inline bridge normalization-class value in a public test. Assert observable `normalizeBridge` equivalence between inputs instead of hard-coding a BRIDGE_TOLERANCE_CLASSES label as a string literal. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-inline-tolerance-classgrit"
)
}
16 changes: 8 additions & 8 deletions biome-plugins/no-roundtrip-identity-oracle.grit
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// Asserting that re-serializing a freshly-parsed document yields back the
// SAME input bytes — `serialize(parse(x))` (or the MarkdownManager method
// equivalent `m.serialize(m.parse(x))`) compared equal to that same `x` — is
// the engine's byte-identity correctness oracle. That oracle is the private
// quality-bar IP and lives in the private engine fidelity suite; it must not
// ship on the public mirror. This rule flags the inline assertion shape so a
// new public test can't reintroduce it.
// the engine's byte-identity correctness oracle. This general round-trip-identity
// check is exercised by the engine's own fidelity suite; a public test should pin
// a specific expected output instead. This rule flags the inline assertion shape
// so a new public test can't reintroduce the general oracle.
//
// IDENTITY, not contract: the rule only fires when the parse input and the
// expected value are the SAME expression (metavariable reuse `$x` ... `$x`
Expand All @@ -22,8 +22,8 @@
// - Round-trip identity through a helper (`mdRoundTrip(x)`, `normalize(...)`)
// or via an intermediate variable (`const out = serialize(parse(x)); ...`)
// — GritQL matches the inline call shape, not helper bodies or cross-
// statement data flow. Those forms live in the private fidelity suite,
// which is path-excluded from the mirror, so they are covered there.
// statement data flow. Those forms live in the engine's fidelity suite and
// are covered there.
// - Matchers other than `toBe` / `toEqual` / `toStrictEqual` and operators
// other than `===` (e.g. a custom `assertByteIdentical` helper).
//
Expand All @@ -46,7 +46,7 @@ or {
},
register_diagnostic(
span = $assertion,
message = "Byte-fidelity round-trip oracle in a public test: `serialize(parse(x))` asserted equal to the same input `x` exposes the engine's byte-identity correctness oracle on the public mirror. Keep round-trip-identity assertions in the private engine fidelity suite (packages/app/tests/fidelity or packages/core/src/markdown), or assert against a fixed expected literal for a public contract test. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-roundtrip-identity-oraclegrit"
message = "Byte-fidelity round-trip oracle in a public test: `serialize(parse(x))` asserted equal to the same input `x`. This general round-trip-identity check belongs to the engine's fidelity suite (packages/app/tests/fidelity or packages/core/src/markdown); a public test should assert a fixed expected literal for a specific contract instead. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-roundtrip-identity-oraclegrit"
)
},
// serialize(parse($x)) === $x in either operand order (covers `assert(...)`,
Expand All @@ -71,7 +71,7 @@ or {
},
register_diagnostic(
span = $cmp,
message = "Byte-fidelity round-trip oracle in a public test: `serialize(parse(x))` asserted equal to the same input `x` exposes the engine's byte-identity correctness oracle on the public mirror. Keep round-trip-identity assertions in the private engine fidelity suite (packages/app/tests/fidelity or packages/core/src/markdown), or assert against a fixed expected literal for a public contract test. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-roundtrip-identity-oraclegrit"
message = "Byte-fidelity round-trip oracle in a public test: `serialize(parse(x))` asserted equal to the same input `x`. This general round-trip-identity check belongs to the engine's fidelity suite (packages/app/tests/fidelity or packages/core/src/markdown); a public test should assert a fixed expected literal for a specific contract instead. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-roundtrip-identity-oraclegrit"
)
}
}
48 changes: 0 additions & 48 deletions biome-plugins/playwright-topass-budget.grit

This file was deleted.

57 changes: 31 additions & 26 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,6 @@
],
"plugins": ["./biome-plugins/class-proof-registration-discipline.grit"]
},
{
// Apple-Event / IPC roundtrip toPass budget enforcement is scoped to
// the desktop-smoke files (and the plugin's own fixture for testing).
// packages/app's *.e2e.ts files drive Chromium in-process, NOT macOS
// `open(1)` Apple-Event dispatch, so their sub-15s toPass budgets are
// legitimate (fast in-process roundtrip, no Launch Services latency).
// Pairs with `tests/smoke/calibration.test.ts` Invariant B, which is
// scoped to the same surface via `TOPASS_BUDGET_FILES`.
"includes": [
"packages/desktop/tests/smoke/deep-link.e2e.ts",
"packages/desktop/tests/smoke/external-link.e2e.ts",
"biome-plugins/__fixtures__/playwright-topass-budget.fixture.tsx"
],
"plugins": ["./biome-plugins/playwright-topass-budget.grit"]
},
{
// One-shot `expect(await locator.count())` reads never retry and are
// the canonical hidden-flake assertion shape (2026-06 e2e audit).
Expand Down Expand Up @@ -219,11 +204,11 @@
// Byte-fidelity round-trip oracle ban, scoped to the public-mirrored test
// surface. `serialize(parse(x))` (or the MarkdownManager method form)
// asserted equal to the same `x` is the engine's byte-identity correctness
// oracle — private quality-bar IP. It legitimately lives in the engine
// fidelity suite (packages/app/tests/fidelity), the markdown + bridge
// precision suites, and the enumerated byte-oracle tests; those are
// excluded from the public mirror, and are excluded here too so the oracle
// stays allowed there but forbidden on the public surface.
// oracle. It legitimately lives in the engine fidelity suite
// (packages/app/tests/fidelity), the markdown + bridge precision suites, and
// the enumerated byte-oracle tests; those are excluded from this override's
// scope so the oracle stays allowed there but forbidden on the public
// surface.
// packages/md-conformance is the private conformance estate
// (also mirror-excluded). The fixture is in scope so its planted oracle
// drives the fixture-file test; the Bridge-invariant comparator
Expand All @@ -237,15 +222,35 @@
"!packages/app/tests/fidelity/**",
"!packages/core/src/markdown/**/*.test.ts",
"!packages/core/src/bridge/**/*.test.ts",
"!packages/server/src/prd-6654-multi-client-repro.test.ts",
"!packages/app/tests/integration/source-mode-byte-preservation.test.ts",
"!packages/app/tests/integration/init-load-byte-stable.test.ts",
"!packages/app/tests/integration/init-load-byte-stable-corpus-coverage.test.ts",
"!packages/app/tests/stress/init-load-byte-stable.e2e.ts",
"!packages/app/tests/stress/single-file-ephemeral.e2e.ts",
"!**/*.private.*",
"biome-plugins/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx"
],
"plugins": ["./biome-plugins/no-roundtrip-identity-oracle.grit"]
},
{
// Inline bridge normalization-class value ban, scoped to the
// public-mirrored test surface. BRIDGE_TOLERANCE_CLASSES
// (packages/core/src/bridge/normalize.ts) is the bridge normalizer's class
// catalog; importing it into a public test is blocked by
// check-mirror-test-policy Check B, and this rule blocks the complementary
// inline re-encoding. The catalog legitimately lives in the bridge tests,
// the markdown precision suite, the fidelity suite, and the byte-oracle
// one-offs — excluded from this override's scope (as they are from the
// plugin pass) so the catalog stays allowed there but the inline form is
// forbidden on the public surface. The fixture is in scope so its planted
// literals drive the fixture-file test.
"includes": [
"packages/**/*.test.ts",
"packages/**/*.test.tsx",
"packages/**/*.e2e.ts",
"!packages/md-conformance/**",
"!packages/app/tests/fidelity/**",
"!packages/core/src/markdown/**/*.test.ts",
"!packages/core/src/bridge/**/*.test.ts",
"!**/*.private.*",
"biome-plugins/__fixtures__/no-inline-tolerance-class.fixture.tsx"
],
"plugins": ["./biome-plugins/no-inline-tolerance-class.grit"]
}
],
"files": {
Expand Down
Loading