Case Blueprint — Building & Testing a New Module¶
End-to-end developer blueprint. You'll build a new Acumen module with Claude Code as your pair, then prove the module works by writing a Probe spec and running it against the live screen. The worked example throughout is Accounts Receivable (AR).
This doc has two halves:
- Part 1 — Build the module with AI. Annotated transcript of the
actual AR session, phase by phase, mapped to
MODULE_BUILD_PROTOCOL.md. Currently a placeholder — fills in after Fabio's AR session lands. - Part 2 — Test it with Probe. Hand-author a ProbeSpec, push it to the runtime, trigger a run, read the result, iterate. Complete now.
If you're here today (2026-04-29) to test an in-progress module, jump straight to Part 2.
Prerequisites¶
- Acumen development environment running locally (
docker compose up acumen-api+ frontend on:3001). - Claude Code with these MCP servers enabled:
canonical,oracle,architect,codebuilder,legacy-db,gitworkflow. ANTHROPIC_API_KEYinproject_root/.env(used by Lensmith).AI_API_KEY+AI_BASE_URLinproject_root/.env(used by Probe — DeepSeek by default).- You can authenticate against
http://localhost:8000and reach/probein the UI.
What you'll build¶
A complete AR module: discovery report, DDL, models, schemas, services with FSM + permission envelope, routes, lens artefacts, page YAMLs, tests — and one or more ProbeSpecs that drive a real browser through the new screens and assert they behave correctly. The Probe spec becomes your regression net: re-run after every significant change to catch UI breakage immediately.
Part 1 — Build the module with AI¶
Part 1 lands after the AR session (2026-04-30)
This half of the blueprint will be filled in from Fabio's real Claude-Code-Opus-4.7 session as he builds AR tomorrow. For now, follow MODULE_BUILD_PROTOCOL.md directly with Claude Code as your pair, then come back here once the transcript has been folded in.
The shape this section will take, mirroring the protocol's phase numbering so cross-reference stays trivial:
| Protocol phase | What the transcript will show |
|---|---|
| Phase 0 — Safety | Branch + tag setup. Two-line pre-flight before any code touches the working tree. |
| Phase 1 — Discovery | Legacy MSSQL queries via the legacy-db MCP → acumen/ar/AR_DISCOVERY_REPORT.md. Decisions about which fields defer to Phase 2. |
| Phase 1b — ADR-040 audit | Only fires if any AR service already exists. The audit checklist in protocol §1b run interactively. |
| Phase 2 — Database | Raw DDL written by hand (the autogenerate chain is broken — protocol §2.1 explains). Manual alembic_version update. |
| Phase 3 — Backend | SQLAlchemy model → Pydantic schemas → service inheriting BaseService with get_permission_envelope() → FSM transitions.py. |
| Phase 4 — Routes | List endpoint plain, detail endpoint enveloped, one POST per FSM action. Router registered in main.py. |
| Phase 5 — Module artefacts | Rulebook entry → python scripts/generate_lenses.py → page YAML patched with lens: key: block. |
| Phase 6 — Tests | The pytest matrix from protocol §6: create / list / detail-envelope / update / delete / per-FSM-action / per-business-rule. |
Each phase will show: the prompt Fabio gave Claude, the salient response, any course-correction, and the file diff that landed.
Part 2 — Test it with Probe¶
This part is complete now. Use it to verify your module while you build it — don't wait until the end.
2.1 Why hand-author a spec for a new module¶
Probe's UI auto-generates ProbeSpecs in one situation only: when you customise an existing screen with Lenser, the Lensmith assistant generates a verifying spec alongside the override (see Probe User Guide → Where ProbeSpecs come from).
A new base module like AR has no Lenser project — it's not a customisation, it's the base behaviour itself. So no auto-spec. The standalone spec authoring UI on /probe is on the Phase 2 roadmap (§6.5 🟡). Until it lands, the supported workflow is:
- Author the spec YAML on disk under git
- Push it to the runtime via
POST /api/probe/specs - Trigger a run from
/probeor viaPOST /api/probe/run - Iterate
That's what this section teaches.
2.2 Atlas attributes — what your module must emit¶
Probe drives the page through HTML attributes the renderer emits. Every field container needs a data-lens-path, every validation message a data-lens-error, every action button a data-acumen-action. See the Atlas attribute contract for the full table.
Coverage by renderer (as of 2026-04-29):
| Renderer | What it renders | Coverage |
|---|---|---|
LensRenderer |
Lens-keyed screens (/lens/<key>) |
✅ Probe-ready |
RecordToolbar |
Acumatica-style icon strip on form/list pages | ✅ Probe-ready |
YamlPageRenderer |
Plain YAML pages (e.g. ap-vendor-class-form) |
✅ Probe-ready (audit 3b8b9497) |
FinancialDocumentPage |
Bills, invoices, cash entries, payments, orders | ✅ Probe-ready (audit 3b8b9497) |
Path scheme depends on the renderer:
| Renderer | Path format | Example |
|---|---|---|
LensRenderer |
<section_id>.<field_key> |
fs_license_details.license_number |
YamlPageRenderer |
<section.id \| section.section \| section.title \| 'form'>.<field_key> |
FISCAL YEAR.year_code |
FinancialDocumentPage |
header.<key> | <tab_id>.<key> | line.<key> |
header.business_account_id |
| Toolbar / action button | toolbar.<action> (resolves to [data-acumen-action="<action>"]) |
toolbar.save |
Verify what your screen actually emits before authoring assertions. The fastest check is to drive a headless Chromium against your screen and dump every [data-lens-path]. From inside the acumen-fastapi container:
# Save as /tmp/check-attrs.py inside the container, then
# `docker exec acumen-fastapi python3 /tmp/check-attrs.py`
from playwright.sync_api import sync_playwright
import json, httpx
with httpx.Client(timeout=10.0) as c:
auth = c.post(
"http://localhost:8000/api/auth/login",
json={"email": "admin@restrat.co.za", "password": "D@wn.1net"},
).json()
with sync_playwright() as pw:
browser = pw.chromium.launch(headless=True)
ctx = browser.new_context()
ctx.add_init_script(f"""
window.localStorage.setItem('token', {json.dumps(auth['access_token'])});
window.localStorage.setItem('user', {json.dumps(json.dumps({
'id': auth['user']['user_id'],
'username': auth['user']['email'],
'email': auth['user']['email'],
}))});
window.localStorage.setItem('modules', {json.dumps(json.dumps(auth.get('accessible_modules') or []))});
""")
page = ctx.new_page()
page.goto("http://host.docker.internal:3001/#/receivables/invoices/new",
wait_until="networkidle", timeout=20000)
page.wait_for_timeout(2500)
paths = page.evaluate(
'Array.from(document.querySelectorAll("[data-lens-path]"))'
'.map(el => el.getAttribute("data-lens-path"))'
)
actions = page.evaluate(
'Array.from(document.querySelectorAll("[data-acumen-action]"))'
'.map(el => el.getAttribute("data-acumen-action"))'
)
print("paths:", paths)
print("actions:", actions)
browser.close()
If the output is empty for the screen you just built, your module's renderer isn't emitting attributes — fix that before authoring the spec. The attribute names you see here are the strings you use as field: values in your spec.
If you're hitting a header field or lookup popup
renderHeaderField and renderSearchLookup in YamlPageRenderer are intentionally not instrumented by the audit (header-bar fields are rare Probe targets and have no consistent section context). If you need to assert against one, file a follow-up against MODULE_BUILD_ORDER.md §6.5 or extend the renderer locally.
2.3 Author the spec on disk¶
Convention: place it under git at project_root/docs/architecture/tools/probe_specs/<module>_<thing>_smoke.probe.yaml. The on-disk file is the source of truth; the DB row is the runtime instance.
Use the AR Invoice spec we shipped today (081cffbf) as the starting template. The full file:
id: ar_invoice_smoke
name: AR Invoice — form smoke
screen_id: ar.invoice.form
description: >
Regression smoke for the AR Invoice form. Asserts the new-record form
loads with every header field that consultants and downstream
integrations rely on. Designed as a safety net while iterating on the
AR module — re-run after each significant change.
tags: [smoke, ar, invoice]
scenarios:
- id: new_form_renders_required_fields
name: New AR Invoice form renders required Customer + Date fields
steps:
- action: navigate
screen: ar.invoice.form
mode: new
route: /receivables/invoices/new
assert:
- field: header.business_account_id
state: visible
- field: header.document_date
state: visible
- id: new_form_renders_full_header
name: New AR Invoice header shows the canonical 9-field set
steps:
- action: navigate
screen: ar.invoice.form
mode: new
route: /receivables/invoices/new
assert:
- field: header.document_type
state: visible
- field: header.invoice_number
state: visible
- field: header.business_account_id
state: visible
- field: header.location_id
state: visible
- field: header.currency_id
state: visible
- field: header.document_date
state: visible
- field: header.payment_terms_id
state: visible
- field: header.financial_period
state: visible
- field: header.description
state: visible
- id: new_form_action_bar_present
name: Save / Discard / Delete / Release / Void buttons rendered
steps:
- action: navigate
screen: ar.invoice.form
mode: new
route: /receivables/invoices/new
assert:
- field: toolbar.save
state: visible
- field: toolbar.discard
state: visible
- field: toolbar.delete
state: visible
- field: toolbar.release
state: visible
- field: toolbar.void
state: visible
Walking through it block by block:
id— unique slug, matches the filename stem. The DB also stores this asprobe_spec.slug.screen_id— symbolic Acumen screen identifier (ar.invoice.form). Doesn't have to match a real route; it's a label the runner reports against.scenarios[]— each one is an isolated user journey. Independent steps + assertions.steps[].action: navigate— for non-Lens screens you must include theroute:override. Without it the runner builds/#/lens/<screen_id>and the SPA bounces to the dashboard. Theroute:value is the SPA hash-route path:/receivables/invoices/newhere.{id}placeholders get substituted fromrecord_idif you pass one.assert[].field— thedata-lens-pathvalue (ortoolbar.<action>for action buttons). Exact string match against what the renderer emits. Section 2.2 tells you how to enumerate them.assert[].state: visible— closed set. Other allowed states:enabled,disabled,hidden. See the YAML grammar reference for the full vocabulary.
The full grammar — every action, every assertion, scenario setup / teardown, conditional waits — is in ProbeSpec YAML grammar. This blueprint only shows what AR Invoice needs.
2.4 Push the spec into the runtime¶
There's no on-disk-to-DB sync. After creating or editing the file, you push it via the API. Get a token first:
TOKEN=$(curl -s -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"admin@restrat.co.za","password":"D@wn.1net"}' \
| python3 -c "import sys,json;print(json.load(sys.stdin)['access_token'])")
Create (first time):
YAML=$(python3 -c "import json;print(json.dumps(open(\
'project_root/docs/architecture/tools/probe_specs/ar_invoice_smoke.probe.yaml'\
).read()))")
curl -s -X POST http://localhost:8000/api/probe/specs \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"slug\": \"ar_invoice_smoke\",
\"name\": \"AR Invoice form smoke\",
\"screen_id\": \"ar.invoice.form\",
\"yaml_content\": $YAML,
\"tags\": [\"smoke\",\"ar\"]
}"
The response includes the id (a UUID) — keep it; you'll need it to trigger runs.
Update (every time you edit the file):
curl -s -X PATCH "http://localhost:8000/api/probe/specs/<spec_id>" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"yaml_content\": $YAML}"
PATCH is idempotent. The git file remains the source of truth — the DB row is just the materialised runtime copy.
2.5 Trigger a run¶
Two paths.
From the UI — fastest for ad-hoc smoke:
- Navigate to
/probe(top-level sidebar, peer of Lenser). - Find your spec by slug, click the row.
- Open the Run now tab in the right drawer.
- Click Start run. The page auto-jumps to Run history and you can watch the new pending run go to
runningthenpassed/failed.
From the CLI — what you'll wire into a CI hook later:
TENANT_ID=<your-organisation-uuid> # e.g. 7aa495bc-70aa-4419-867e-c5e867177a69
curl -s -X POST http://localhost:8000/api/probe/run \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"spec_id\": \"<spec_id>\", \"tenant_id\": \"$TENANT_ID\"}"
A run typically takes 30–90 seconds. Status transitions: pending → running → passed | failed | error. Poll GET /api/probe/runs/{run_id} or just refresh the UI.
2.6 Read the result¶
When a run finishes, every assertion is recorded with expected / actual values plus a screenshot on failure.
- In the UI —
/proberow → drawer → Run history → click the run. You get a per-scenario tree with ✓/✗ icons and the LLM transcript collapsible at the bottom. - From the API —
GET /api/probe/runs/{run_id}returns the full report includingassertion_results[]andcc_reasoning_log. - Screenshots — written to
/tmp/probe-screenshots/<run_id>/<NNN>_<label>.pnginside theacumen-fastapicontainer. Copy them out withdocker exec acumen-fastapi cat /tmp/.../foo.png > local.pngif you want to look at them in your image viewer.
Common failure modes when you're testing a brand-new module:
| Symptom | Most likely cause |
|---|---|
actual: not-found on every field assertion |
Screen isn't emitting data-lens-path. Re-run the §2.2 attribute dump and confirm. |
Browser ends up on /#/ instead of your screen |
route: override missing or wrong. The default is a Lens URL, which won't resolve for a base module. |
toolbar.save not found but the button is visible |
Action button missing data-acumen-action. RecordToolbar and FinancialDocumentPage action bar both emit it; if you wrote a custom action bar, it must too. |
Save fires but assert_record_saved says 0 successes |
Browser save did succeed but the response listener missed it. Almost always a timing issue — increase the wait step before the assertion. |
For the deeper "why did this assertion really fail" workflow — screenshots, LLM transcript reading, common React/MUI gotchas — see Probe User Guide → Reading a failed run.
2.7 Iterate the spec — fixtures.reset_sql¶
The AR Invoice smoke above is read-only on purpose. The moment you add an edit-and-save scenario, the spec stops being idempotent: the first run mutates the DB to your target state, the second run sees no diff (isDirty = false), Save stays disabled, and the scenario fails.
The fix is a fixtures.reset_sql block at the top level of the spec — it runs before every scenario and restores the seed to its canonical state. From fs_license_smoke.probe.yaml:
fixtures:
reset_sql:
- >
UPDATE fs_license
SET description = 'Probe Tier 1 acceptance test license',
never_expires = TRUE
WHERE id = '019e0001-0000-7000-8000-000000000001'
Rules:
- The value can be a single string or a list of strings — each is run in order.
DROP,TRUNCATE,ALTERare refused by the runner. Soft guard against accidental destruction; if you need DDL inside a spec, you're doing it wrong.- The block runs before the headless browser launches, so you can rely on it for fresh state in every assertion.
For AR, you'd typically seed a known invoice with fixed UUID, then the edit-and-save scenario edits the description, hits Save, asserts a 2xx — and the next run starts from the same baseline.
2.8 Hand off to publishing¶
When you eventually customise this AR screen with a Lenser project, the spec becomes a publish gate:
- Specs with
lenser_project_idset are run synchronously when someone clicks Publish on that project. - Any failed spec returns HTTP 409 with a structured blocker payload, and the Lenser publish panel renders a red banner + override box (record a reason → Publish with override).
For pure base-module specs (no Lenser linkage), the spec is just an on-demand smoke. Phase 2 will wire CI hooks; until then, run after every significant change to the module.
2.9 Worked example summary¶
- Spec slug:
ar_invoice_smoke. On-disk:project_root/docs/architecture/tools/probe_specs/ar_invoice_smoke.probe.yaml. - Coverage: 3 scenarios, 16 assertions — required fields, full 9-field header set, 5-button action bar.
- Last green run: 2026-04-29 (this is what shipped today as commit
081cffbf). - Re-runnable from
/probeafter every AR change. ~30 seconds per run.
If you've followed Part 2 with your own module, you should now have:
- The on-disk YAML under git
- A registered spec in the DB
- At least one green run in
/probehistory - Confidence that the next change you push will surface UI breakage immediately
That's the loop. Keep it tight.
Quick reference¶
| You want to… | Do this |
|---|---|
| Verify your screen emits Atlas attributes | Run the Playwright dump from §2.2 |
| Author a spec | Drop YAML at project_root/docs/architecture/tools/probe_specs/<slug>.probe.yaml |
| Push to runtime (first time) | POST /api/probe/specs (curl in §2.4) |
| Re-push after edits | PATCH /api/probe/specs/{id} (same body shape) |
| Trigger a run | /probe → row → Run now → Start, or POST /api/probe/run |
| Re-run idempotently | Add fixtures.reset_sql: block (§2.7) |
| Read a failure | /probe row → run history → expand the LLM transcript |
| Override a blocked publish | Lenser project → Publication card → reason + Publish with override |
Last updated 2026-04-29. Part 1 (AI-build transcript) lands after the AR build session.