Probe — architecture¶
Probe is Acumen's screen-agnostic, AI-driven behavioural testing layer. It uses the Playwright MCP server and Claude Code (cc) to drive a real Chromium browser against a live Acumen instance and verify behaviour, without anyone writing test code by hand.
Probe was built to give Lenser a publish gate, but the infrastructure lives at the Acumen level — every other module can use it the same way.
Phase 1 scope
Phase 1 covers the full pipeline (spec → run → assertion results → screenshots) for Lens-rendered screens. ProbeSuites, base-screen specs, CI integration, and the spec-authoring UI are Phase 2. See MODULE_BUILD_ORDER.md §6.5 in the source repo for the roadmap.
Pipeline¶
ProbeSpec (YAML — plain-language behavioural assertions)
↓
POST /probe/run
↓
ProbeRunner (FastAPI service)
↓ [passes spec to cc]
cc + Playwright MCP (real browser, live Acumen instance)
↓ [exercises screen, evaluates assertions]
ProbeResult (pass/fail per assertion, screenshots on failure)
↓
Stored in DB + returned to caller (Lenser publish panel, CI, or direct API)
Probe does not generate or maintain test code files. cc is the test runner. The ProbeSpec YAML is the test definition. The Playwright MCP server is the browser bridge.
Core concepts¶
| Concept | Description |
|---|---|
| ProbeSpec | A YAML document describing a screen and a set of behavioural assertions. See yaml-spec.md. |
| ProbeAssertion | A single verifiable behavioural claim about a screen (field is disabled, error appears, record saves). |
| ProbeRun | A single execution of a ProbeSpec against a live Acumen instance. |
| ProbeResult | The outcome of a ProbeRun — overall pass/fail, per-assertion results, screenshots, cc reasoning log. |
| ProbeStep | A user action within a test scenario (navigate, fill, click, wait, …). |
| ProbeSuite | A named collection of ProbeSpecs grouped for a module, workflow, or release. |
Data model¶
probe_spec
id UUID (UUIDv7) PK
slug TEXT UNIQUE -- e.g. "fs_licenses__no_indefinite"
name TEXT
screen_id TEXT -- registered Acumen screen
description TEXT
tags JSONB -- string array
lenser_project_id UUID → lenser_project NULL OK
yaml_content TEXT -- raw ProbeSpec YAML
created_by UUID → acumen_user
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ
probe_suite
id UUID (UUIDv7) PK
name TEXT
description TEXT
spec_ids JSONB -- ordered array of probe_spec UUIDs
created_by UUID → acumen_user
created_at TIMESTAMPTZ
probe_run
id UUID (UUIDv7) PK
spec_id UUID → probe_spec
suite_run_id UUID → probe_suite_run NULL OK
triggered_by TEXT -- lenser_publish | ci | manual | api
triggered_by_id UUID -- project ID, user ID, etc.
tenant_id UUID -- which tenant was tested
base_url TEXT -- Acumen instance URL used
status TEXT -- pending | running | passed | failed | error
started_at TIMESTAMPTZ
completed_at TIMESTAMPTZ
cc_reasoning_log TEXT -- full cc reasoning transcript
created_at TIMESTAMPTZ
probe_assertion_result
id UUID (UUIDv7) PK
run_id UUID → probe_run
scenario_id TEXT -- matches scenario.id in ProbeSpec
assertion_index INT
assertion_desc TEXT -- human-readable description
status TEXT -- passed | failed | skipped | error
actual_value TEXT -- what cc observed
expected_value TEXT -- what the spec required
screenshot_path TEXT -- failure screenshot path (file, not blob)
created_at TIMESTAMPTZ
probe_suite_run
id UUID (UUIDv7) PK
suite_id UUID → probe_suite
triggered_by TEXT
status TEXT -- pending | running | passed | failed | error
started_at TIMESTAMPTZ
completed_at TIMESTAMPTZ
created_at TIMESTAMPTZ
All PKs are UUIDv7. Screenshots are stored as files, not blobs — probe_assertion_result.screenshot_path holds the path; serve them via the screenshot endpoint.
How ProbeRunner executes a spec¶
The ProbeRunner service is the bridge between the ProbeSpec YAML and cc + Playwright MCP.
Setup¶
Playwright MCP must be registered in the Acumen project's cc configuration:
This persists in ~/.claude.json under the Acumen project path.
Execution flow¶
When POST /probe/run is called:
- ProbeRunner loads the ProbeSpec from the database.
- Constructs a structured prompt for cc that includes:
- The full ProbeSpec YAML
- The base URL of the target Acumen instance
- Authentication credentials for the test tenant
- The closed set of allowed actions and assertions
- Instructions to return structured JSON results
- Passes the prompt to cc via the Playwright MCP server.
- cc opens a real Chromium browser, executes each scenario step by step, evaluates each assertion, and captures screenshots on failure.
- cc returns a structured
ProbeRunReportJSON. - ProbeRunner persists the results as
probe_assertion_resultrecords. - Updates
probe_run.statustopassedorfailed.
POST /probe/run is asynchronous
The endpoint returns immediately with run_id and status: pending. The actual run executes asynchronously (FastAPI BackgroundTasks). Poll GET /probe/runs/{id} for completion.
cc prompt structure¶
You are executing a Probe test run for the Acumen ERP system.
BASE URL: {base_url}
AUTH: Use the test tenant credentials provided.
PROBSPEC:
{probe_spec_yaml}
INSTRUCTIONS:
- Use Playwright MCP to control the browser.
- Execute each scenario in order.
- For each assertion, record: status (passed/failed), actual observed value, expected value.
- On any failed assertion, capture a screenshot before continuing.
- Do not stop on failure — run all scenarios.
- Return ONLY a JSON object matching the ProbeRunReport schema below.
- Do not add commentary outside the JSON.
PROBERUNREPORT SCHEMA:
{
"overall_status": "passed" | "failed",
"scenarios": [
{
"id": string,
"status": "passed" | "failed" | "error",
"assertions": [
{
"index": number,
"description": string,
"status": "passed" | "failed" | "skipped",
"actual": string,
"expected": string,
"screenshot": string | null
}
],
"error": string | null
}
],
"reasoning": string // cc's plain-English summary of what it observed
}
Authentication strategy¶
Test runs use a dedicated probe_test tenant with seeded reference data. cc authenticates once at the start of a run using stored credentials and reuses the session for all scenarios via Playwright's storageState pattern. This avoids re-authentication per scenario and prevents rate-limit triggers on the auth endpoint.
Credentials come from Acumen's existing secrets management — never hardcoded.
Lenser integration¶
Lenser calls Probe via the standard /probe/run endpoint. No special Lenser-specific Probe code exists — Lenser is just another API consumer.
How Lensmith generates a ProbeSpec¶
When Lensmith proposes a set of LenserOperation[] for a project, it simultaneously generates a corresponding ProbeSpec:
Lensmith proposes:
[Override] form.license.valid_from → enabled: false
[Rule] on_save: expiration_date required unless never_expires
Lensmith also generates:
[ProbeSpec] fs_licenses__no_indefinite.probe.yaml
scenario: valid_from_disabled
scenario: expiration_required_on_save
scenario: never_expires_bypasses_validation
[Accept operations + ProbeSpec] [Accept operations only] [Modify]
The ProbeSpec is saved to probe_spec immediately. It is not executed until the consultant explicitly triggers a run or publication is attempted.
Pre-publication gate¶
When a consultant clicks Publish on a LenserProject:
- Lenser checks whether any
probe_specrecords are linked to this project. - If yes, it calls
POST /probe/runfor each linked spec against the staging tenant. - Publication is blocked if any ProbeRun returns
status: failed. - The publish panel shows the ProbeRun results inline — per-scenario pass/fail, failure screenshots, cc reasoning summary.
- The consultant can override the block (with a recorded reason) or fix the project and retry.
Manual run¶
The Lenser publish panel has a Run Probe button that triggers a run on demand without attempting publication. Results appear inline within 30–90 seconds depending on scenario count.
Beyond Lenser (Phase 2 use cases)¶
The infrastructure is built at the Acumen level so all of these work without changing the core:
| Future use | Description |
|---|---|
| Base screen testing | ProbeSpecs for core Acumen screens (AP, AR, IN, SO, etc.) with no Lenser involvement |
| Cross-module workflow testing | Multi-screen scenarios: raise PO → receive → check AP impact |
| Pre-release regression suite | A ProbeSuite covering all modules, run before every release |
| Tenant acceptance testing | Consultant delivers a passing ProbeSuite to a client as proof of configuration correctness |
| CI/CD gate | POST /probe/suite/run triggered automatically on every PR merge to main |
None of these require any changes to Probe's core infrastructure — only new ProbeSpec YAML files (and optionally new ProbeSuites grouping them).
Naming conventions¶
| Layer | Convention |
|---|---|
| PostgreSQL tables | probe_* |
| SQLAlchemy models | ProbeSpec, ProbeRun, ProbeAssertionResult, … |
| FastAPI router | probe_router in routers/probe.py |
| Service classes | ProbeRunner in services/probe_runner.py, ProbeSpecGenerator in services/probe_spec_generator.py |
| React components | ProbeResultsPanel, ProbeAssertionRow, ProbeManagementScreen |
| TypeScript types | ProbeSpec, ProbeRun, ProbeAssertionResult, ProbeRunReport |
| YAML file extension | .probe.yaml |
| cc prompt role | Referred to as "Probe test run" in all cc prompts |
Constraints¶
- Probe infrastructure lives under
/probe/— no Lenser-specific paths. POST /probe/runreturns immediately; the run executes asynchronously.- cc must be instructed to continue through failures — a single failed assertion must not abort the run.
- Screenshots are server-side files, not DB blobs.
- The
probe_testtenant credentials come from Acumen's secrets management. - Playwright MCP runs headless in CI, headed (visible) in local development.
Where to go next¶
- ProbeSpec YAML grammar — the closed sets of
actionandasserttypes, plus a worked example. - API reference — every endpoint, request body, and response shape.
- Atlas attribute contract — the
data-lens-path,data-lens-error,data-acumen-actionattributes Probe relies on. - Consultant guide — the user-level "how do I publish through this gate" view.