EnergyVenom's picture
Patchwise Agent Studio: Oracle AI Agent Studio cycles
af1bee9 verified
|
Raw History Blame Contribute Delete
6.85 kB
# P2P patch-test loop: LangGraph skeleton (AI Architect)
> **Superseded by `coworker/`** (17-node design in `design/DESIGN.md`, web app + desktop app). This folder is the legacy skeleton, kept as is.
> **Stub by default.** There is no Oracle Fusion pod and there are no credentials (BRIEF.md). In the default `PLAYWRIGHT_MODE=stub`,
> Playwright results are synthetic, and every report gets a red "STUB RUN" banner plus `run_mode` in `run-summary.json`.
> `PLAYWRIGHT_MODE=live` runs the Automation team's specs against `mock-app/`, which is still **not** Fusion.
## Pilot decisions implemented (Chief of Staff, 2026-10-09)
| # | Decision | Where in code |
|---|---|---|
| 1 | **The graph owns the retry. Playwright always runs with `--retries=0`.** | `playwright_command()` always passes `--retries=0` (and `PW_RETRIES=0` in the env). `after_execute` loops `execute` once, for failed cases only. `merge_attempts()` stitches the two attempts into one Playwright-shaped report (`results=[try0, try1]`, `status=flaky/unexpected`), so triage and QA see the retry exactly as Playwright would. Do **not** set `retries` in `playwright.config.ts` or pass `PW_RETRIES>0` when running under the graph, or a failure gets re-run twice. |
| 2 | **Go/no-go = QA's rule in `reports/generate_report.py`.** | The `report` node calls `generate_report.write_reports(tri, run_dir, root=..., review=...)` and copies `decision`, `criteria` (C1–C6) and `gaps` verbatim. The graph has no rule of its own (selftest checks this). |
| 3 | **Match tests keep real amounts. Triage stays local. Only redacted counts go to the frontier model.** | `route_model()`: frontier only for task `summary` with a payload of allowlisted count names mapped to `int`. Anything else (triage, text, amounts, floats) stays local. Triage itself is `triage/classifier.py` (deterministic). See `model-routing.md`. |
| 4 | **No rented cloud GPU with client data.** | Docs only (`cost-estimate.md`). `LOCAL_MODEL` targets Ollama on a local or client-hosted GPU. |
| 5 | **Tiered scope: P1 must run, P2 if time allows, P3 deferred.** | `select_scope()` in `load_cases`. P1 always, P2 only with `--include-p2` / `include_p2=True`, P3/P4 always deferred. Deferred and rejected cases are listed in `run-summary.json`. The tier vocabulary is `generate_report.tier()`, so the graph and the go/no-go rule agree. |
**Removed from the skeleton (accepted simplifications):** LLM test design, research swarm, script builder, self-heal (the retry
is a plain re-run), Jira/ticket node, LLM reporter and learner. Also removed: the LLM in `plan_data`, which is now a deterministic
recipe lookup. Kept: SQLite checkpoints, env-var config, human interrupts.
```
START -> load_cases(P1 / +P2 filter) -> approval_gate[HUMAN] -> plan_data -> execute(--retries=0)
execute --failures, no retry yet--> execute (failed cases only) # exactly one retry
execute --otherwise--> triage (triage/classifier.py)
triage --low-conf or real-defect verdict, or flaky needs owner--> human_review[HUMAN] -> report
triage --else--> report (reports/generate_report.py decides GO / NO-GO) -> END
```
## Typed state, checkpoints, gates
- `P2PState` (TypedDict): patch_id, include_p2, test_cases, deferred, approvals, data_refs, attempt_files, failures, retry_count,
triage_path, report_root, review_items, review, report_path, decision, counts, and `llm_calls` (append-only audit).
- `SqliteSaver` at `out/checkpoints.sqlite`, so a paused or crashed run resumes in a new process.
- Gate 1 `approve_cases`: cases whose `approval_status` is not `approved…` (or `new_or_changed: true`). Rejected cases are deferred.
- Gate 2 `human_review`: the answer is passed straight to generate_report in its format:
`{"<case id>": {"confirmed": "real_defect"|"not_defect", "waiver": "...", "owner": "..."}}`.
## Web interface: superseded
`web_ui.py` (the stdlib UI) was deleted on 10 Oct 2026. It is superseded by the **co-worker** (`coworker/` backend, `web/`
React app, `desktop/` Electron shell); see `coworker/README.md`. This skeleton (`p2p_graph.py`, `selftest.py`) is kept
unchanged as the legacy pilot and still passes 27/27. The co-worker reuses its helpers only through `coworker/adapters/legacy.py`.
```bat
fpt.cmd setup & rem venv deps, npm installs, var/, vault, DB, library.git
fpt.cmd create-user --username admin --role admin
fpt.cmd up & rem mock (3100) + API serving the web app on http://127.0.0.1:8800
```
## Run
```bash
cd /workspace/fusion-patch-testing/architecture
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
.venv/bin/python selftest.py # 27 checks, stub mode, real classifier + report generator
.venv/bin/python p2p_graph.py run --thread t1 [--include-p2] # pauses at approval_gate
.venv/bin/python p2p_graph.py resume --thread t1 --approve # resumes from SQLite
STUB_FAIL=P2P-INV-001 .venv/bin/python p2p_graph.py demo --thread t2 # auto-answers gates (demo only)
PLAYWRIGHT_MODE=live .venv/bin/python p2p_graph.py run --thread live1 # real specs vs mock-app (see "Waiting on")
```
Outputs go to `out/runs/<thread>/`: `attempt-N.json`, `merged-results.json`, `triage.json`, `go-no-go.{md,html}` (from generate_report)
and `run-summary.json`. In stub mode generate_report evaluates a throwaway `stub-root/` that holds only the in-scope cases and a placeholder spec, so
QA's C1/C5 checks are meaningful. Live mode uses the real project root.
Env knobs: `PLAYWRIGHT_MODE` (stub|live), `P2P_CASES_DIR` (default `../tests/cases`; falls back to 6 labelled SAMPLE cases if empty),
`STUB_FAIL` / `STUB_DEFECT` / `STUB_UI` / `STUB_FLAKY` (comma-separated ids), `LOCAL_TRIAGE_HINTS=1` (optional local-LLM note on
review items), `FRONTIER_SUMMARY=1` (optional counts-only summary), and `LOCAL_MODEL` / `FRONTIER_MODEL`. Leave `LLM_MODE` as `stub`: live LLM calls are not wired.
## Adapters to other teams (status 2026-10-09 ~16:36 IST)
| Adapter | Team code | Status |
|---|---|---|
| `classifier()` → `triage/classifier.py` (`triage`, `parse_report`, `load_report`) | Triage | **Wired**, used in selftest |
| `report_generator()` → `reports/generate_report.py` (`write_reports`, `summarize`, `tier`) | Triage/QA | **Wired**. It implements QA's C1–C6 rule (updated 16:33) |
| `load_cases_from_disk()` → `tests/cases/*.yaml` | Test Designer | **Wired**: 65 cases found, all P1 so far. Reads `priority`, `approval_status`, `data_recipes` |
| `run_playwright()` live → `npx playwright test --retries=0 --reporter=json --grep <ids>` in `automation/` | Automation | **Adapter ready, not run.** The specs present (`tests/starter/P2P-AUTO-0xx`) are titled with `P2P-AUTO-*` ids, not designed case ids, so `--grep` would select nothing. |