Skip to content

CLI and Orchestration

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

CLI and orchestration

Role. The omnisnap command: parse the arguments, build the job, run every runtime module in order, report progress, and map the outcome to an exit code. Module cli, package internal/cli, with the analysis glue in internal/pipeline.

Commands

From the usage text in root.go:

Command Does Code
omnisnap <url> [<url>...] [flags] a job from URLs root.go
omnisnap run <job.json> [flags] a job from a file; flags override it root.go
omnisnap report <bundle-dir> re-render report.html from a bundle's summary.json report.go
omnisnap merge <bundle-dir>... -o <dir> [--rename-hosts] one bundle from several machines merge.go
omnisnap comment <merged-bundle> [--report-url U] [--run-url U] the PR comment as Markdown comment.go
omnisnap browsers [--json] discovery's result browsers.go
omnisnap check-fonts the font-parity table fonts.go
omnisnap warm <browser> warm a branded browser's template warm.go
omnisnap install firefox, uninstall firefox Install install.go
omnisnap version the version root.go

Flags for <url> and run: --engines, --baseline, --out, --runs, --viewport, --timeout, --resume, --retry-failed, --allow-small-pages, --no-audit, --neutral, --json, --quiet, --verbose (options.go).

How a job runs

Main sets up a context that SIGINT, SIGTERM and SIGHUP cancel, runs the sweeper before any command but version and help (Process management), and dispatches. main in cmd/omnisnap only calls os.Exit(cli.Main(...)), so every command is a function from arguments to an exit code, and tests call it directly.

For <url> and run, the job is built (jobFromURLs or readJob, which reads strictly), the flags that were set override it (apply), and runJob runs:

  1. resolve: defaults, URL checks, slugs.
  2. Discovery, then makePlan: the baseline is the job's (which must be an installed Blink browser), else chrome, else the first Blink found. The engines are the job's, or every discovered browser. An engine that is not installed, or whose family has no driver, is skipped with the reason, and listed in summary.json.
  3. Launch the engines in groups of at most --max-browsers live browsers (default 3; options.go), in job order with the baseline first. A failed launch does not count toward the cap. With N engines or fewer there is one group, and the steps below run exactly as without the cap; with more, steps 3 to 5 repeat per group, each group's browsers closed before the next launches. Each browser starts through env.launch (CDP for Blink, from a warmed template for branded ones; BiDi for Gecko; Classic for WebKit), each wrapped in a restartable: NewSession opens a page, Relaunch closes a dead browser and launches a fresh one the same way, which is the capture's crash retry. After every new session, env.oom re-applies the Linux out-of-memory score to the launched trees (Process management). A browser that fails to launch is skipped. If the baseline did not start, exit 2, unless the run was interrupted while it launched. A Ctrl-C between groups, or one that makes the baseline's or a whole group's launches fail, ends the run like any interrupt (exit 4, no summary): those engines are not broken, and a summary would pass the job off as finished.
  4. The font pre-flight for the group's engines, against the baseline's report kept from the first group (its browser is closed by then), and a hint naming omnisnap install firefox when only one engine family is left.
  5. Per page, capture.RunPage (Capture pipeline) with the group's engines. Only the first group carries the baseline and its failure policy; later groups skip the pages it found unreachable. --resume asks capture.ResumeState with the group's engine ids. Each page gets one page-start before its first capture and one page-done after its last: right after the page with one group, after the last group otherwise. The Outcome callback that prints a line or an event per capture, a LOST line for a lost engine, and "(in a fresh browser: the first attempt crashed)" after a successful retry.
  6. writeBundle: the analysis of every page and engine, findings.json, host.json, summary.json, report.html (Architecture).

Progress

The reporter prints either one human line per event, or with --json one NDJSON event per line and nothing else on stdout (Data contracts, progress events). --quiet prints only the report path and errors.

Exit codes

exit.go:

Code Meaning
0 the job completed, with or without findings (report-only)
1 usage error: a bad flag, an unknown command, an invalid job file, nothing to capture
2 no usable browsers: fewer than two engine families, or no baseline
3 every capture of every page failed
4 internal error: a bug; the message asks for a report

Tests

  • run_test.go with a fake environment: usage errors, exit codes 2, 3 and 4, a URL run writing a bundle, a job file's interleaving, flags after the URL, resume, check-fonts, the font pre-flight, install and uninstall, the single-family hint, merge, the neutral profile.
  • root_test.go: TestMainExitCodesAndOutput.
  • crash_test.go: a crashed engine leaves the job with one message and one engine failed event.
  • comment_test.go, report_test.go.
  • TestWalkingSkeleton (browsers tag): a real job end to end.

Where the code differs from the spec

  • --no-probes and --open do not exist. SPEC-cli.md lists both. Probes can be turned off only in the job file ("probes": false). The report is never opened automatically; the CLI prints its path.

Spec

specs/SPEC-cli.md.

Source files

Clone this wiki locally