Skip to content

feat(platform): keep test reports, try drafts and run tests by hand - #4808

Merged
yannickmonney merged 2 commits into
mainfrom
feat/automation-test-reports
Oct 11, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
feat/automation-test-reports

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

What

The storage and app routes the editor's Tests panel builds on: a version keeps what its latest test check found, and the app can try a draft and run tests by hand. This is the app half of P5's tests wire. The MCP/REST halves follow the MCP OAuth work; bench runs on the durable stepper (/start with stand-ins, protocol 2) follow the walker.

Storage — 0200_automation_test_reports.sql

  • Adds three nullable columns beside the 0019/0100 verdict, with no backfill (rolling-deploy safe):
    • tests_report jsonb: the trimmed storedTestReportSchema copy, ≤ 64 KB.
    • tests_checked_via: save | deploy | manual, enforced by a CHECK.
    • tests_checked_by: who, in created_by's vocabulary.
  • A save, the deploy gate (passing or refusing) and a run by hand each store the report their verdict came from, which act made it and who.
    • Dispatch hands the report through additive options: SaveOptions.testReport, deploy(…, {testReport}), recordTestVerdict(…, {report, via}).
    • Every save and deploy override passes it on (save, restore, starter, managed configuration).
  • A verdict without a report clears the old one. A reader also shows a report only while its checkedAt matches the verdict's time, so an earlier report never reads as the current one.
  • readTestReport answers a version's last check. History rows fill their tests summary (passed, failed, total, via, by) from SQL.

Routes (Developer and up)

  • POST /:name/try runs a draft or a saved version once, in mock mode: input and stand-ins (runBenchSchema), a 20 s deadline, recorded like a stored run, nothing stored. A refused draft answers AUTOMATION_INVALID with its problems; a stand-in the run cannot take answers BENCH_INVALID.
  • POST /:name/run-tests runs the tests of a draft or a saved version, all or some, each with its run (10 s per test, 60 s per suite). A saved version's whole suite, run to its end, is recorded as its verdict, made by hand (recorded); a subset or a draft records nothing. A document without tests answers an empty report.
  • GET /:name/test-report?version=N answers a saved version's last check. test-report joins the reserved last segments of a new automation's name (AUTO-R49), since the bare GET /:name would otherwise answer a name ending in it as another automation's report.
  • Guards:
    • Charged to a new org bucket automation:bench (120/min, burst 240), a suite by its test count, answering RATE_LIMITED + Retry-After.
    • At most 4 bench runs per process (429, Retry-After: 2).
    • Bodies capped (document 1 MB, bench 512 KB, a stand-in 64 KB → 413 naming the field).
    • The request's abort stops the run.
    • Answers bounded: values past 256 KB are cut for display, a try is capped at 4 MB, and a test's run past 512 KB (or past 8 MB in all) is left out with detailOmitted.

App data layer

  • Contract entries and zod-parsed adapters: tryAutomation, runAutomationTests (refreshes version reads when it records), and getAutomationTestReport (under the automation's keys). The answer schemas live in lib/shared/schemas/automation-tests.ts.
  • Hooks come with the Tests panel that uses them.

Spec

AUTO-R50: a version keeps what its latest test check found, and who made it.

Verification (local)

  • Platform tsc; oxlint; the UI suites (2,479); automations browser tests (93); format, lint:links, lint:manual, knip.
  • The whole server and PII projects: 87,742 of 87,743 pass. The one red, tests/guards/automation-legacy-agent-flow.test.ts ("reuses unchanged historical helpers"), is red on main too: backend/core/node_only/sandbox/turn_budget.ts changed in 6d1e153 without its pinned hash in agent-flow-provenance.json. This branch does not touch either file.
  • The unit tests that pin the store's SQL parameters and dispatch's calls to the store now expect the report, the act and who (store.save-version, store.deploy, dispatch.authoring, dispatch.refusals, routes.authoring, routes.versions), with a new case each for a report kept on save and on deploy.
  • Unit tests:
    • the routes (routes.bench.test.ts, 11): run, record, refusals, 413, 429 for a spent budget and for a busy server, and the verdict recorded only for a whole suite of a saved version. Each real answer also parses with the app's schemas.
    • the bench module (bench.test.ts): concurrency cap, document hash, value cut, a run left out.
    • the adapters (4 new).
  • Real Postgres (integration lanes):
    • checkTestReports (new, 6 checks) passed with checkVersionHistory and checkDeploymentHistory (97/97, migration applied fresh).
    • The save/deploy lanes through dispatch (checkAutomations, checkMcp, checkMcpAuthoringParity, checkManagedAutomationConfiguration, checkRestDoor, checkAutomationTemplates, checkAutomationsSurface): 137 of 138. The one red is checkAutomationsSurface's zip staging (an empty storageId in a filtered run), which fails the same way on a clean main in a filtered run.

A save, the deploy gate and a check made by hand now store the report their tests verdict came from, which act made it and who (migration 0200: tests_report, tests_checked_via, tests_checked_by). A verdict without a report clears the old one, and a reader shows a report only while its checkedAt matches the verdict, so an earlier report never reads as the current one. Version history rows count it; readTestReport answers a version's last check.
POST /:name/try runs a draft or a saved version once in mock mode with an input and stand-ins, recorded like a stored run and never stored. POST /:name/run-tests runs a draft's or a version's tests, all or some, each with its run; a saved version's whole suite is recorded as its verdict, made by hand. GET /:name/test-report answers a version's last check. Runs are charged to a new automation:bench bucket, held to four per process, capped in body and answer, and stopped when the caller leaves. The app gets contract entries and parsed adapters for the three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant