Skip to content

Data Contracts

github-actions[bot] edited this page Nov 27, 2026 · 5 revisions

Data contracts

Role. The files that pass between the modules, and between Omnisnap and its consumers (the wrappers, the Action, merge, anyone scripting it). Module bundle-schema. Everything else on this wiki reads or writes these.

Rule. The JSON Schemas in schema/ are the source of truth. The Go types in internal/schema are checked against them in tests; a consumer never needs the Go code to read a result.

The schemas

Schema File Go type Written by
job job.schema.json Job the user, or the CLI from a URL and flags; the wrappers write it for run()
capture capture.schema.json Capture capture, one per engine and run
host host.schema.json Host the CLI, once per bundle
summary summary.schema.json Summary the CLI and merge
progress progress.schema.json progress.go the CLI with --json, one event per line

Every document carries its schema's $id in $schema: https://omnisnap.org/schema/<name>/<major>.json, built by schema.ID with the major version 1 (schema.go). The site at omnisnap.org is built from these files by tools/site/build.py and served by the Worker in src/worker.js. It is deployed with each release, so a schema change on main is published with the next release (Website).

job.json

Pages (each a url and an optional slug), engines (absent = every discovered engine), baseline, viewport, runs, probes, fontParity, neutral, timeouts (navigationMs, scriptMs) and output. resolve fills the defaults: it rejects a page that is not an http(s) URL, derives a slug from the URL when none is given, and makes duplicate slugs unique with -2, -3 (options.go). probes and fontParity default to on, neutral to off (options.go).

The bundle

What one omnisnap run writes, here for a page captured in Chrome (the baseline), Firefox and WPE WebKit:

<output>/
  summary.json                        every result (summary schema)
  report.html                         the viewer
  host.json                           OS, architecture, the engines with versions and profile kinds
  <slug>/page.json                    url, slug, capturedAt
  <slug>/findings.json                full evidence of every cause, per engine pair
  <slug>/<engine>-<run>.json          capture file (geometry tree + metadata)
  <slug>/<engine>-<run>.png           full-page screenshot
  <slug>/<engine>-<run>.probes.json.gz   the four probe captures (lh, font, controls, all)
  <slug>/<engine>-<run>.error.txt     only when that capture failed or was skipped
  <slug>/failed.json                  only when the page was unreachable

Files are written atomically (to a temporary name, then renamed: internal/fsutil), so an interrupted run never leaves a half-written capture. That is what lets --resume trust what it finds.

Capture file

<engine>-<run>.json has two keys, meta and root.

  • meta: the URL, title, user agent, viewport (vw, vh), client width, device pixel ratio, document size (docW, docH), node count and whether the node cap truncated the tree, fonts loaded and failed, post (did the page change during capture), the probes' metadata, the screenshot size, stabilization details, failed and blocked requests, the capture time, and the engine and version (Meta).
  • root: the element tree. Each Node has short keys to keep captures small:
Key Meaning
t, id, tid, role, c, n, u tag, id, test id, role, classes, name, the href/src key: the identity tokens matching uses
nt position among the same-tag siblings in the DOM, hidden ones included, as :nth-of-type counts; only when the tag repeats, and on every child of a shadow host (its shadow and light lists share one k). Selectors use it (Layout-Diff); older captures have none
sr 1 on each child of an open shadow root; a selector names its shadow host instead, since document.querySelector cannot reach into a shadow tree. Older captures have none
b border box [x, y, w, h] in document pixels
d, p computed display and position
hid not visible
o, of pixels of content beyond the box, and the overflow values
tr text is truncated (ellipsis or line clamp)
ia interactive
mut, mutp changed by a mutation (ground-truth captures only)
k children
text fields for an element with its own text (Text): the first 60 characters, a hash of the full text, line count ln, text width tw, text inset ti, line tops lt, line height lh, font size, family and weight, white-space

Flags are written as 1 and omitted when unset.

summary.json

The one file a consumer reads. Top level: $schema, tool (name and version), generated, the resolved job, hosts, skipped (engines left out, with the reason), pages and results (summary.go).

One result per page and compared engine (Result): host, page, baseline, engine (with family, version and profile), status (ok, diverged, failed, unreachable), warnings, stats (report and info counts, matchRate, ms), screenshot references, the path of the page's findings.json, causes, intent violations, blocked hosts and dynamic regions per side, and the DOM audit of both captures.

A cause (Cause), as written for a planted overflow page:

{
  "id": "127.0.0.1-8099-03-overflow.html@firefox|width|table#target",
  "tier": "report",
  "title": "Width differs",
  "kinds": ["width"],
  "consequences": ["protrusion", "structural"],
  "selector": "table#target",
  "boxes": {"baseline": [122, 243.9, 1036, 445], "engine": [122, 243.9, 1600, 445]},
  "delta": {"dw": 564, "dh": 0, "dx": 0, "dy": 0, "dln": 0},
  "kb": null,
  "evidence": {"mechanism": "layout", "consensus": "engine-odd", "perception": 2,
               "ink": 0.58, "intent": [], "calibration": {"explained": false, "by": []}},
  "score": 0.9343,
  "count": 1,
  "instances": ["table#target"]
}

The summary carries compact evidence (Evidence). The full evidence of every cause, the symptoms, and the model's feature vector go to <slug>/findings.json (slug, url, and one entry per engine pair), which the viewer reads (internal/pipeline/findings.go). The split keeps summary.json small enough for the PR comment and the wrappers.

Progress events

With --json, stdout is NDJSON: one object per line with ts and type. The types (progress.go):

Type When
job the plan is made: page count, engine ids, output directory
engine an engine is discovered, launched or failed (with the error; a lost engine is reported this way too)
page-start a page begins
capture one capture finished: engine, run, ms, node count, or its error
page-done a page finished, with its status
diff defined in the schema, never sent (see below)
done the job finished: the path of summary.json
error a fatal error ended the run

A consumer must skip types it does not know: new types are additive (ErrUnknownEvent). A run on one page in three engines sends, in order: engine ×3 (discovered), job, engine ×3 (launched), page-start, capture ×6, page-done, done.

Versioning

Additive fields are a minor change: consumers ignore unknown fields. A removal or a change of meaning is a new major version, with a new $id.

Tests

Where the code differs from the spec

  • The diff event is never sent. The spec lists diff (page, engine, report, info) among the progress events, and the schema and NewDiffEvent define it, but no code emits it. The counts are in summary.json when the job is done.

Spec

specs/SPEC-bundle-schema.md.

Source files

Clone this wiki locally