Skip to content

Sonjoo automation, CI gates, and Rust embedding

View as Markdown

Sonjoo exposes the same audit engine through several interfaces. Use the CLI for shell and CI jobs, the authenticated local HTTP API for a separate process with live progress, stdio MCP for tool-calling agents, or a Cargo dependency when the audit must run in your Rust process.

Pin the Sonjoo release, use an authorized target, commit the non-sensitive audit configuration, and budget the crawl. Write a fresh export to keep findings even when the gate fails.

Terminal window
sonjoo audit 'https://example.com/' --crawl --max-pages 10 --max-duration 120 \
--fail-under 80 --min-coverage 90 --no-save --format json --output audit.json
Gate What causes a failure Where to configure it
Minimum audit score Overall Sonjoo score falls below the threshold. --fail-under or [ci].fail_under. The built-in threshold is 70; a score equal to the threshold meets the score gate.
Minimum crawl coverage The percentage of measured pages among attempted pages, rounded down to a whole percent, falls below an active threshold. --min-coverage with --crawl, or [ci].min_coverage. Check that a measured/attempted page count is available.
Required rule The selected rule fails or a required check is unevaluated in a way that prevents the gate from being assessed. [rules.override], for example core-title-present = { fail_ci = true }. Sonjoo rejects configurations that disable a required rule or exclude its category.
Required custom search A search marked fail_ci has failing results, it checked zero pages, or the regex time limit stopped it on at least one page. [custom] search entries. Custom search and extraction
Saved-audit regression Comparable saved reports show a score drop or a rule regression. sonjoo compare DOMAIN --fail-on-regression. Inspect comparable and runDifferences when coverage or options differ.

Inspect the exit code and report together. Exit 0 means the command succeeded and active audit gates passed; findings can still appear. Exit 1 from an audit or analysis can accompany a valid JSON report with a failing gate. Exit 2 indicates an input, configuration, or execution error. Exit 130 indicates interruption for a CLI audit, analysis, or crawl. Keep the report as a job artifact, including on gate failure, and preserve Sonjoo’s own exit status. Gate examples · Exit code reference

If an audit is part of deployment verification, run the same rule selection, page scope, and browser profile before and after the change. Provision Chromium when the checks depend on it. Keep secrets out of reports and retain only artifacts your team can share. Report coverage · Local privacy and exports

Integration Use it for Start here
CLI Reproducible audit files, gates, and snapshot workflows in shell scripts. CLI features
Local HTTP Start and cancel audits, stream progress, consume JSON, or download crawl exports from the same machine. Local HTTP API features
Stdio MCP Let a compatible local client call named tools with structured arguments. MCP tools and agent skills
Rust library Reuse engine, configuration, catalog, and report functions directly in a Rust program. Runnable Rust embedding example

Add Sonjoo as a Cargo path dependency from a chosen checkout and pin the revision you build against. Use engine::AuditOptions to select the target, mode, categories, and budgets. engine::audit uses engine defaults, and engine::audit_configured accepts a configuration value. Start from config::default_config() before applying overrides. The audit returns a JSON value as its report.

The audit functions block. In an async application, call them on a worker that can block. Provide a progress callback and share the Arc<AtomicBool> cancellation flag with your controller. Your application decides whether and where to store the returned report. For evidence, read categoryResults or use reports::findings_json; reports::render can produce display formats such as HTML, Markdown, JSON and AI-readable text.

Use engine::registry() and engine::categories() to build rule selectors or look up stable IDs. Choose built-in rule settings or custom search and extraction for project-specific checks without changing the engine. The built-in rule set is defined in the repository; adding a built-in rule requires a source change and a matching validation scenario. Sonjoo rule catalog · Rule validation

Lower-level modules expose HTML contexts (context::Context), crawl snapshots (crawl_store), local audit persistence (storage::Store), and configuration validation (config). Prefer the documented engine and report entry points for embedding, and integration-test any lower-level calls against the Sonjoo revision you ship. Rust module declarations