Files
pbakaus_impeccable/crates/core/src/browser/mod.rs
T
Paul BakausandClaude Fable 5.1 0547ed6a63 reorg C: the open Rust runtime joins this repo as one Cargo workspace
The engine no longer lives in a separate repo. `crates/` is a snapshot of the
open crates (foundation, core, common, context, live, hook, skills, comp,
comp-verbs, html, browser, detect, cli) plus `Cargo.lock`, taken as a git
archive of the engine repo at the commit that finished the boundary split.
None of that repo's history comes with it, and none of it should: the closed
half stays private.

The closed half is the rule engine. It ships as a prebuilt native archive per
target, `libimpeccable_detector.a`, published as a `detector-v<X>` GitHub
Release on this repo. `crates/core/build.rs` resolves and links it three ways:
`IMPECCABLE_DETECTOR_LIB=<dir>` for a local detector build, else the
`~/.impeccable/detector/<version>/<target>/` cache, else a download verified
against its `.sha256` sidecar. `crates/core` is a thin shim over a three-symbol
C ABI; nothing above it knows the boundary exists.

What changed versus the engine repo copy:

- Every crate manifest moves from `license-file.workspace` to
  `license.workspace` (this workspace declares Apache-2.0), and the workspace
  gains the `postcard` dependency the boundary encoding needs.
- The launcher contract test reads `skill/scripts/impeccable{,.cmd}` instead of
  a sibling `launcher/` dir, and `engine_binary` downloads from
  `github.com/pbakaus/impeccable/releases/download/engine-v<version>/` instead
  of the retired dist repo. No oracle golden carried the old URL, so no
  re-recording was owed.
- The tests that hunted for a public repo through `IMPECCABLE_PUBLIC_REPO`,
  `../impeccable-second` or a hardcoded home directory now resolve the root as
  `CARGO_MANIFEST_DIR/../..`, because they are in it. The env var stays as an
  override for an out-of-tree checkout.
- The in-page bundle (`detect-antipatterns-browser.js`, 2 MB of generated wasm
  glue) is no longer tracked. `crates/core/build.rs` resolves it beside the
  archive, hands the path to `impeccable_core::browser::IN_PAGE_BUNDLE_JS`, and
  live mode serves that. `scripts/check-detector-release.mjs` now requires it
  and its `.sha256` in a detector release.
- The live crate embeds `skill/scripts/live-browser*.js` and
  `modern-screenshot.umd.js` directly rather than through vendored copies, so
  the binary and the installed skill cannot drift.
- `crates/browser/assets/` (an unused second copy of the bundle) is gone.
- `tests/lib/engine-bin.mjs` also accepts `target/release/impeccable`, so a
  plain `cargo build --release -p impeccable` is enough to run `bun run test`.

Verified with the archive from a local detector build: `cargo test --workspace`
267 pass, oracle 795 pass / 0 fail / 0 missing, `bun run build` clean, the
default suite green, and the launcher's `engine-probe` handshake answering
through `skill/scripts/impeccable`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vau2X53xGTjjTCXWMVBoNY
2026-09-01 15:31:26 -07:00

34 lines
1.5 KiB
Rust

//! The in-page (browser) rule set, as the open runtime sees it.
//!
//! The probe trait, its snapshot implementation, the selector engine, the test
//! fake and the boundary types are open (`impeccable_foundation::browser`) and
//! re-exported here under the paths callers already use. The rules themselves
//! are closed: `driver`, `page_checks`, `element_checks` and `visual` are
//! shims over the C-ABI, and the closed side reaches back into the caller's
//! `&dyn Dom` through the host vtable.
//!
//! `background`, `quality` and `text_collectors` have no open callers and
//! therefore no shim: they run entirely inside the detector, reached through
//! `driver::collect_browser_findings`.
pub use impeccable_foundation::browser::dom;
pub use impeccable_foundation::browser::selector;
#[cfg(any(test, feature = "fake-dom"))]
pub use impeccable_foundation::browser::fake_dom;
pub mod driver;
pub mod element_checks;
pub mod page_checks;
pub mod snapshot;
pub mod visual;
pub use dom::{Dom, ElId, Rect};
pub use impeccable_foundation::browser::{BrowserConfig, BrowserFinding, ElFinding, FindingGroup};
/// The in-page bundle: the same closed rules compiled to wasm, wrapped in the
/// script live mode serves at `/detect.js` (and the extension and the site
/// ship). `crates/core/build.rs` resolves it beside the detector archive, so
/// the generated 2 MB file is not tracked in this repo.
pub const IN_PAGE_BUNDLE_JS: &str = include_str!(env!("IMPECCABLE_DETECTOR_BUNDLE_JS"));