Skip to content

Extending Omnisnap

github-actions[bot] edited this page Nov 21, 2026 · 2 revisions

Extending Omnisnap

Recipes for the changes people make most often: which files to touch, which tests must pass, and which spec to update. The rules behind them are in CONTRIBUTING.md and specs/CONVENTIONS.md: anything that contradicts a spec changes that spec in the same contribution, and some changes need approval first (the injected scripts, capture discipline constants, thresholds, new dependencies, public flags).

One trap applies to every analysis change. The tree model's input is a fixed list of 82 features (features.go): cause kinds, consequences, KB ids, mechanisms, perceptual events, consensus verdicts, roles and engines. If a change adds a value to one of those lists, the shipped model no longer matches this binary's features. Compatible then refuses it, and every score becomes null, hidden rather than guessed. Either keep the new value out of the feature lists, or retrain the model and regenerate its parity fixture (Ground truth and the model).

A knowledge-base entry

An expected engine difference that should be explained away (or, like K5, named with its fix).

  1. Add the matcher to Match in internal/triage/kb.go: the signature, and a KB{ID, Title, Explanation, Fix, Expected}. Order matters: the first entry that matches wins.
  2. Add a planted kb fixture page that triggers it (below) and expect it to be explained.
  3. Add a unit test next to kb_test.go. Mutation-test the bound if it could explain a real bug away (that is how K4's bound was found).
  4. Decide the feature question: adding the id to FeatureKB means retraining.
  5. Update the table in SPEC-triage.md §1, and the Triage page.

A cause kind

  1. Emit it in Analyze (or in its own pass, like tables.go), with the cause-versus-effect rule that keeps it from repeating on every child.
  2. Give it a consequence in consequences if a person can see it, and decide whether that consequence is hard.
  3. Give it a title in triage and a severity weight in severity.go.
  4. Tests: a hand-built tree in align_test.go; golden parity must still pass (TestGoldenAlignParity); the planted gates must still pass.
  5. The feature question: FeatureKinds.
  6. Update SPEC-layout-diff.md §4, the README's "What it detects", and the Layout diff page.

A DOM-audit check

  1. Write the check as a function of the walker in checks.go, add it to checks in reporting order, and name its threshold in audit.go.
  2. Start it at info; promoting a check to report needs approval and crawl evidence (median findings per page at most 2).
  3. Tests: a unit test in audit_test.go, a planted page it fires on and a control it does not (TestPlantedAuditPages in test/e2e/audit_test.go); TestAuditIsFast must stay under 50 ms.
  4. Add its human name to auditCheckName in the viewer's app.js.
  5. Update SPEC-dom-audit.md and the DOM audit page.

A browser or an engine

A browser of an existing family (another Blink browser, say):

  1. Add it to the catalog with every name it goes by, and to the per-OS sources that should find it (the Windows catalog, the macOS bundle ids).
  2. Add a fixture for each OS source (a reg query dump, an Info.plist) and a test in that OS's discovery test file.
  3. If it blocks requests itself, it is a branded browser: see Branded browsers.
  4. Update SPEC-discovery.md.

A new engine family or protocol is a larger change across five modules:

  • discovery: the family and protocol;
  • process: a Start… with its launch flags, isolation and cleanup tests;
  • drivers: a drivers.Session implementation, honest Capabilities, and a harness in the conformance suite;
  • canDrive and launch in internal/cli/env.go;
  • the lane it belongs to in lanes.

It needs a spec change in each module first.

A planted page

The planted suite is generated from the spike, so the Go fixtures are never edited by hand:

  1. Add the page to spikes/layout-diff/planted/pages.mjs: the base page, its .ff rule that plants exactly one divergence in Firefox, its kind (planted, control, kb, native) and its expected answer (expect, maxFindings, intent).
  2. Export: node spikes/layout-diff/tools/export-planted.mjs writes testdata/planted/<slug>.html and expectations.json (export-planted.mjs). CI runs it with --check and fails if the fixtures drift.
  3. Capture its golden captures with the spike and export them (export-golden.mjs), so the gates and parity tests cover it (testdata/golden/README.md).
  4. Tests that must pass: TestLoadPlantedMatchesTheSuite, TestGoldenPlantedCoversTheSuite, and TestPlantedGates (recall stays at or above 90%; controls stay at 0 Report).
  5. Update the list in SPEC-ground-truth.md §1.

Source files

Clone this wiki locally