EnergyVenom's picture
Astra: regression catalogue, runner robustness, idempotent Agent Studio contract, key-screen design (2182ef729b22)
152e0c1 verified
|
Raw History Blame Contribute Delete
16.1 kB

Historical record. This page describes the product as it was when it was written, under an earlier name, and is not kept up to date. For the current system (Astra) read ARCHITECTURE.md, DEPLOYMENT.md, RUNBOOK.md, REMOTE_RUNNER.md and SECURITY.md.

Patchwise: production audit

Branch production-hardening, started from trio-apple-ui at 1c7e8c0 on 3 Nov 2026. Every finding below comes from reading the code at that commit or from a command run against it; file references are path:line at that commit. Status: Fixed means fixed on this branch with a test; Open means still to do (see the roadmap).

1. What the product is

Patchwise is a digital co-worker that tests Oracle Fusion Cloud business processes after the monthly and quarterly patches. AI agents (a LangGraph workflow) read the patch notes and the test environment, choose test scenarios, wait for a consultant to approve them, run them in a real browser (Playwright) against an Oracle Fusion test pod (or a built-in practice app), classify failures, ask a QA approver to judge real defects, and produce a go/no-go report that is signed off in the app.

2. Architecture

Part Where Stack Size (files / lines)
API and workflow coworker/ Python 3.13, FastAPI 0.143, LangGraph, pydantic 2, SQLite, httpx 124 / 19,260
Web app web/ React 18, Mantine 7, TanStack Query, Vite, TypeScript 92 / 16,381
Test executor automation/ Playwright 1.64 (TypeScript) 294 / 9,236
Practice pod mock-app/ Node/Express mock of Fusion screens and REST 44 / 6,250
QA rule and triage reports/generate_report.py, qa/audit.py, triage/ Python 14 / 4,012

103 HTTP routes (coworker/api/routes/*.py), 10 SQL migrations (coworker/platform/migrations/).

flowchart LR
  U[Consultant / QA approver / admin<br/>browser] -->|HTTPS, session cookie + CSRF| API
  subgraph Container [Docker image, non-root, tini]
    API[FastAPI app<br/>coworker/api] --> RM[Run manager<br/>runner.py + run_jobs queue]
    RM --> G[LangGraph workflow<br/>coworker/graph: scout, research, design,<br/>approval gate, data, execute, triage,<br/>human review gate, report]
    G --> PW[Playwright executor<br/>automation/ via adapters/playwright.py]
    G --> RR[QA rule C1-C6<br/>reports/generate_report.py]
    API --> DB[(SQLite fpt.sqlite<br/>runs, events, users, sessions,<br/>pods, schedules, audit chain)]
    API --> V[(Vault<br/>secrets/vault.json + FPT_SECRET_*)]
    SCH[Scheduler<br/>platform/scheduler.py] --> RM
    MOCK[Practice pod<br/>mock-app :3100]
  end
  G -->|EgressGate only| LLM[NVIDIA / frontier model<br/>coworker/llm/router.py]
  G -->|EgressGate: GET, seed/cleanup POST| FUS[Oracle Fusion test pod REST]
  PW -->|browser| FUS
  PW --> MOCK
  API -->|EgressGate| SB[Supabase<br/>identity + encrypted state archive]
  API -->|EgressGate, optional| H[Hermes assistant Space]

Outbound traffic goes through one module, coworker/platform/egress.py (the only importer of httpx outside the tests), which checks the kill switch, writes audit records and pins each request to its configured host. Run state is kept in SQLite plus LangGraph checkpoints; on hosts without a persistent disk (the Hugging Face Space) the whole data folder is saved encrypted to Supabase Storage every 60 s (coworker/platform/statesync.py) and restored at boot.

Deployments today: a Hugging Face Docker Space (public URL, cpu-basic), and a Render blueprint (render.yaml). CI: .github/workflows/image.yml builds the image on pushes to main and smoke-tests it (sign-in, practice pod, self-tests).

3. What was run (3 Nov 2026)

Check Result
npm run build in web/ (tsc + eslint --max-warnings=0 + vite) passes
vitest (web) 86 / 86 pass (one slow whole-app test needed a 30 s limit on this laptop)
Backend tests pytest coworker/tests 275 / 275 pass (8 min 28 s)
Web e2e (Playwright, web/e2e) 5 / 5 on 24 Oct; to be rerun in Phase 5
Real end to end on Oracle Fusion (eiiv-dev2, 31 Oct) connection test signs in; 6 / 6 Payables scenarios passed in the browser; NVIDIA model used for research, test design and summary
pip-audit (coworker + architecture requirements) no known vulnerabilities
npm audit --omit=dev web 2 moderate: react-router 6.x (fixed in 7.17.1)
npm audit --omit=dev mock-app 1 high: body-parser < 1.20.9; 1 moderate: qs
npm audit --omit=dev automation none
Python lint no linter configured (ruff not installed); no pre-commit hooks

4. Gap analysis

Ratings: Critical (exploitable or loses data now), High, Medium, Low.

4.1 Security

# Rating Finding Evidence Status
S1 Critical Anyone who registered on the public URL became consultant: could start runs on the client's Fusion pod, read evidence, approve gates, spend the model key Dockerfile FPT_REGISTER_ROLE=consultant; probe registered a stranger and got 202 on POST /api/runs Fixed 2480dc4: viewer by default
S2 High Sign-in limits keyed on the proxy IP: 5 bad logins locked a real account for everyone; sign-up limits shared coworker/__main__.py proxy_headers=False; routes/auth.py _client() Fixed 2480dc4 (FPT_TRUST_PROXY)
S3 High Password reset did not end existing sessions routes/auth.py reset Fixed 2480dc4
S4 High Child processes (Playwright, practice pod, screen capture) inherited every secret, and run AI-written specs adapters/playwright.py {**os.environ} Fixed 2480dc4 (procs.child_env)
S5 Medium Admin list granted admin to an unconfirmed address routes/auth.py _role_for Fixed (needs Supabase "Confirm email" on)
S6 Medium Reset link built from the request's Host / X-Forwarded-Host routes/auth.py _public_base Fixed (FPT_PUBLIC_URL)
S7 Medium Argon2 (64 MiB per hash) with no global concurrency cap: unauthenticated login floods can exhaust memory platform/users.py:33,49 Fixed 793bb54 (FPT_HASH_CONCURRENCY)
S8 Medium Backup archive key falls back to the Supabase service key when FPT_STATE_KEY is unset platform/statesync.py:38-45 Open: needs a key rotation decision
S9 Medium Playwright traces are recorded after sign-in and can contain Fusion session cookies; any consultant can download them automation/playwright.fusion.config.ts:31 Fixed 34ca925 (traces only on failure)
S10 Medium Dev CORS origins allowed with credentials in production config.py:31 Fixed for the Space (FPT_CORS_ORIGINS=[]); default stays dev for local work (documented)
S11 Low GET /api/pod/profile?refresh=true changes state; login has no CSRF token routes/runs.py:256-268 Open
S12 Low Public endpoints reveal internals: /api/ready (orchestrator, backup status), /api/docs, /api/openapi.json; no HSTS behind the proxy routes/admin.py, middleware.py:195 Fixed ec5996b (anonymous ready trimmed, HSTS, docs switchable); /api/health stays public by design
S13 Low npm advisories: body-parser (high) in the practice app, react-router (moderate) in the web app npm audit Practice app fixed dafaf3e; react-router 6 accepted (needs 7.x major; open redirect not reachable, sign-in return path checked)
S14 Low Supply chain: only top-level Python pins, base images not digest-pinned, Node installed by `curl bash` Dockerfile, requirements.txt

Sound today (checked): argon2id password hashes; server-side sessions with httpOnly cookies and a double-submit CSRF token checked on every unsafe cookie request; RBAC via require(perm) on routes; pydantic Strict input models; report and evidence downloads confined to their folders; tar restore filtered; 500s return only the exception class; CSP, frame, nosniff, referrer and permissions headers set (middleware.py:61-78); passwords kept out of traces and audit records; the egress gate refuses any host but the configured one.

4.2 Reliability and data integrity

# Rating Finding Evidence Status
R1 Critical A double click on Approve could answer the later QA gate: the run completed without QA review api/runner.py:155-162; reproduced 5 of 10 trials Fixed 3ea7129 (atomic claim, gate name carried)
R2 Critical One failing schedule stopped the scheduler and retried every 30 s (Fusion sign-ins could lock the test user) platform/scheduler.py:115-126 Fixed e790d7e
R3 High A storage HTTP 400 at boot was read as "no backup": the app started empty and overwrote the backup platform/supabase.py:132 Fixed 2480dc4
R4 High Fusion test invoices left behind when a run was cancelled, killed or restarted automation/src/fusion/fixtures.ts:21-33 Fixed 4b8d10b (recorded, swept over REST; untested on a real pod)
R5 High Saved-state archive grows without bound (checkpoints, run folders); over 45 MB every save fails platform/statesync.py:117, no checkpoint pruning Fixed 4b8d10b (retention + visible failure)
R6 High Fusion connection test never signed in; wrong address or password failed minutes into a run platform/pods.py Fixed 55af40b
R7 High Step-runner results credited to the helper file, so a fully passing Fusion run came out NO-GO triage/classifier.py, qa/audit.py Fixed 7c780f2
R8 Medium Duplicate starts and double sign-offs runner.py:146, routes/consultant.py:156 Fixed 3ea7129
R9 Medium Queued gate answers lost on restart in-memory queue Fixed 3ea7129 (run_jobs)
R10 Medium Browser crashes and Playwright top-level errors not surfaced; raw exceptions shown to users graph/nodes/execute.py, runner.py:259 Fixed 3ea7129
R11 Medium Resuming an interrupted live Fusion run re-executes the attempt (possible duplicate transactions) runner.py recover/resume Open (mitigated by R4 cleanup)
R12 Low No health-based restart on the Space (Docker HEALTHCHECK ignored by Hugging Face) Dockerfile Open: external monitor

4.3 Architecture and code quality

# Rating Finding Status
A1 Medium No Python linter or formatter; no pre-commit hooks Fixed 31526b9 (ruff, pre-commit, CI)
A2 Medium No .env.example; list settings crashed the app (FPT_FUSION_MODULES=AP) Fixed 3558b56
A3 Low Legacy names (fpt_*, patch-coworker) kept deliberately for deployment compatibility Documented, keep
A4 Low Old generated run folders committed under architecture/out/runs/ and var/demo-live/ duplicate qa/audit.py Open

4.4 Observability

Present: JSON logs with request ids (middleware.py), an append-only hash-chained audit log with /api/audit/verify, /api/health and /api/ready. Missing: error tracking (no Sentry-compatible hook), a metrics endpoint, log rotation (api.jsonl and the practice-pod log grow forever), alerting on failed backups. Rating: Medium. Fixed: /api/metrics, optional Sentry hook (a4b441a), log rotation (acfd2fb), backup status in Settings (960e45c); alerting is the operator's monitor (docs/DEPLOYMENT.md).

4.5 Performance

List endpoints for runs are paginated (routes/runs.py:51); others (tickets, scenarios, audit) partly. The web bundle is one 926 kB chunk (280 kB gzip): no route-level code splitting. The LLM router kept every call record in memory (fixed). Rating: Medium for bundle splitting. Partly fixed 87c484d: less-used pages load on demand (926 kB to 853 kB); the main bundle is still one chunk (Mantine and React Query dominate).

4.6 Testing

Backend: 275+ unittest-style tests including API, gates, races, scheduler, cleanup, Supabase auth (with a fake), the QA rule. Web: 86 vitest tests and 5 Playwright e2e journeys. Gaps: no coverage report; e2e does not cover sign-up, reset, Test environments or schedules; no load test. Rating: Medium. Coverage now measured in CI (see FINAL_REPORT); e2e for sign-up/reset/environments still open.

4.7 DevOps

Present: multi-stage-ish Dockerfile (web build stage + runtime), non-root user, tini, migrations at start, encrypted off-site state backup, CI image build and smoke test on main. Missing: CI on pull requests and other branches, test and lint jobs in CI, dependency scan in CI, image digest pinning, a documented rollback (today: re-upload a previous Space revision, done once on 24 Oct), staging vs production separation (one Space). Rating: High for CI gaps. Fixed: ci.yml on every push/PR (31526b9); rollback and environments documented (docs/DEPLOYMENT.md). Digest pinning still open.

4.8 UI/UX and accessibility

The review on 1 Nov found 15 issues; all are fixed on this branch (commits 50d13c8..472368a, 1c7e8c0): plain error messages with next steps, confirmation before cancelling, failure review blocked until decided, only the gates your role can answer counted as waiting, real Defects and Scenario detail pages, a report toolbar, one live stream, consistent wording. Still open: route-level code splitting, 404/403/500 pages audit, sign-in page details from the Phase 3 brief (caps-lock hint, remember me), unsaved-changes protection on long forms, WCAG pass with a screen reader. Since fixed: sign-in page (c919a4f), 404 and crash-recovery pages (87c484d). Still open: unsaved-changes guard (the long forms are short sheets today), a screen-reader pass.

4.9 Missing product features

Open, in priority order: an admin storage and health panel (data endpoint exists: GET /api/storage); user profile page (change own password, sessions list, sign out everywhere); notifications (in-app and e-mail/Telegram when a run waits); export of runs and results (CSV); feature toggles for risky features (live view, AI scenarios, browser runs, registration) in Settings; a real "new patch available" watch for Fusion pods (today only the practice pod). Since added: account page with sessions (0989440), feature switches and storage panel (960e45c), CSV export (8d281c4), metrics (a4b441a). Not added, with reasons: e-mail/Telegram notifications (needs a mail provider or the Hermes Telegram secrets, owner's decision); data import (scenarios are imported through the library in git, tests/cases, which is the reviewed path); Fusion patch watch (needs Oracle's release feed per pod, larger work).

5. Roadmap

Order Work Effort
1 Phase 2 leftovers: S7 Argon2 cap, S9 trace cookies, S11/S12 surface reduction, HSTS, .env.example with startup validation, log rotation, dependency fixes (S13) 1 day
2 Phase 3: sign-in polish, error pages, code splitting, unsaved-changes guard, accessibility pass 1-2 days
3 Phase 4: profile and sessions, admin storage/health panel, notifications, CSV export, feature toggles 2 days
4 Phase 5: ruff + pre-commit, coverage report, e2e for auth and environments 1 day
5 Phase 6: CI on PRs with lint, tests, scans; digest pins; rollback and backup runbook; Sentry-compatible hook; metrics 1 day
6 Phase 7: README, ARCHITECTURE, SECURITY, DEPLOYMENT, RUNBOOK, CONTRIBUTING, CHANGELOG, FINAL_REPORT 0.5 day

Decisions needed from the owner

  1. Backup key (S8). Setting FPT_STATE_KEY changes the archive key: the current backup must be re-saved under the new key in one controlled step. Recommended, but only with you present.
  2. Supabase "Confirm email" must stay on for the administrator list to be safe (S5).
  3. Registration on the public URL: keep open (viewer by default) or switch off (FPT_REGISTRATION=0) for client use.