Skip to content

feat(desktop): check apps whose files REA can't read, through the app's own headless mode or a screen judge - #9217

Merged
morluto merged 744 commits into
morluto:mainfrom
earakely-scale:feat/desktop-file-readers
Nov 9, 2026
Merged

morluto merged 744 commits into
morluto:mainfrom
earakely-scale:feat/desktop-file-readers

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #9185 and #9199. This branch contains their merge, 6a381f8d1 (latest). Review 060c8514c (readers) first, then c11e2e36a (screen judge). Once the earlier PRs merge, the diff is about 1,690 hand-written source lines, 1,590 of tests and 610 of docs. It is one PR per outcome, by the owner's choice. It splits cleanly in two: readers first, then the screen judge.

Summary

A task can now check app state that REA can't read from a file. A reader runs the app's own headless command on a binary file, such as GIMP's .xcf or Blender's .blend. A screen judge asks a model a yes-or-no question about a screenshot, for state that no file holds, such as a calculator's result. Both run inside the computer at witness time and at grading time.

Problem and expected behavior

About 45 desktop environments have been built so far. Each needed a file REA could read: XML, JSON, text, key files, SQLite, zip or gzip. Two kinds of app were out of reach:

  • apps that save a binary format. The draft noted unreadable_view for poster.xcf and scene.blend and suggested no checks;
  • apps that keep the change only on screen. GNOME Calculator's draft noted no_change and no_document.

After this change:

  • the build agent adds a reader to the task, and the export, the witness and the verifier all run it on the file;
  • the build agent writes a screen_judge check, and the bundle ships a judge calibrated on the build's own seed and end screenshots.

Change and scope

Readers (060c8514c):

  • Schema: a task may hold 1 to 8 readers, each {id, file, argv, stdin?, output, timeout_s?, display?}.
    • output is json (for value_equals, value_absent and member_count) or lines (for lines_present, lines_absent and line_count).
    • A check names a reader in reader and gives the reader's file as its file.
    • The parser refuses a reader without {file}, an unknown or unused reader, and a kind its output doesn't serve.
  • One runner: a Python program, PYTHON_READER_RUNNER, which the export, the witness and the verifier all run.
    • It copies the file into a new temporary folder and runs the command there, with {file} naming the copy.
    • The command gets a fresh HOME and XDG_ folders in that folder.
    • It never gets the session bus, XDG_RUNTIME_DIR or any AGENTENV_ variable, so it never holds the control token.
    • It gets the display only when the reader asks for it.
    • It is killed with its whole session after timeout_s (60 s by default, 300 at most), and may print at most 1 MiB.
    • Lines starting with REA make the view; everything else, such as banners and warnings, is dropped.
    • A reader that fails gives an error view with the end of its stderr. Every check on that view then fails as undecided.
  • Export: it runs each reader in the build computer, on the seed's bytes as the bundle ships them and on the end's retained bytes. A refusal shows what the reader printed.
  • Witness: it runs the readers through computer-exec/v1 once the app's files settle.
  • Verifier: it runs the same runner through computer-exec/v1, with a fresh request id and the reader's timeout plus 30 s. It raises when the route is missing or the runner doesn't answer.
  • No change for existing tasks: reader code is rendered only for a task with readers. A task without readers renders verify.py byte for byte as on the base, and a test pins its SHA-256.
  • Skill: recipes for GIMP Script-Fu (gimp-console-2.10), Blender (blender -b --factory-startup with bpy) and LibreOffice --convert-to.

Screen judge (the second commit):

  • Schema: {id?, kind: "screen_judge", question}. A task with one holds only screen judges and no readers.
  • Where allowed: the export refuses a screen-judged task when an owned file changed in a way a check could read. It names the files.
  • Labelled examples: at each checkpoint, the build computer saves a JPEG screenshot under the capture's screens folder. The export ships the seed's as the "no" example and the end's as the "yes" example.
  • Votes: the verifier waits 1 s, takes a screenshot through computer_screenshot, and asks each question 3 times. Two yes votes pass the check. Each vote gets up to 3 attempts.
  • Model: [model.roles] judge, else [model] default, else anthropic/claude-sonnet-5-5, through agentenv's own model config. agent-env run --judge-model doesn't reach it, and the README says so.
  • Missing endpoint: the verifier raises, so the run fails rather than scoring the agent.
  • Witness: REA runs the bundle's own verify.py judge <check> <screenshot> with the runner's Python. REA calls no model itself.
  • Reset: an app that owns no files gets a reset that only relaunches it, and only when its task judges the screen.
  • Doctor: the informational endpoint check now says screen-judged tasks need an endpoint.

The design note's seven decisions were all taken as option a.

Not included:

  • Drafting checks from a reader's output. The build agent writes the checks, and the export's refusals show what the reader printed.
  • Judging the screen in the export. The witness is where questions are first checked.
  • Mixing screen judges with file checks in one task.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the desktop task schema; the export's task admission; the witness; the exported verifier.
  • Contribution scope fit and linked maintainer decision: same approved desktop-environments work as feat(desktop): capture a Linux desktop application in use #8874.
  • CLI and MCP/tool-catalog contract:
    • export_build_environment and check_build_task take the wider task schema, with readers and screen_judge.
    • rea export-desktop-application gains --screens.
    • mark_build_checkpoint now also saves a screenshot in the computer.
  • Provider, bridge, target-format, or platform compatibility: needs computer-exec/v1 and computer_screenshot from agentenv 0.9.1431, which the build computer already uses.
  • Evidence, artifact, provenance, or reconstruction contract: the witness record gains reader and judge results in its existing per-check fields.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable):
    • readers run as the computer's user, on a private copy, and their folder is deleted afterwards;
    • the judge sends three images per vote to the configured model endpoint.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: one new CLI option.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:

    • parser refusals for readers and screen judges, and both evaluators reading a reader's view;
    • the runner, run with python3 as computer-exec runs it. Tests cover isolation (no token, display, bus or real home), the private copy, marker lines, a timeout that also kills child processes, and each error;
    • the verifier calling computer-exec/v1, with TS and Python agreeing on every result and description;
    • the screen verifier with stand-in MCP, litellm and config modules: majority, model choice, retries, a missing endpoint and the script entry;
    • the export: readers on the seed and the end, refusals with the reader's output, and screen tasks with and without screenshots;
    • the witness MCP flow, with a reader and with a screen judge;
    • the capture saving screens/seed.jpg and screens/end.jpg;
    • the relaunch-only reset;
    • the doctor wording;
    • the reader-less verifier's pinned digest.

    Every new test failed before its change. The digest pin is the exception: it guards the base rendering, so it passes there. It failed on an earlier draft of this branch.

  • Base reproduction or other evidence: real builds on an arm64 Ubuntu 24.04 host, each through the full MCP flow. Each app went through capture, seed and end, the draft and the export. Then came a four-stage witness in a fresh computer, and solves with Claude Code on Claude Sonnet 5.5.

    App Task Check Export Witness, each stage Solves
    GIMP 2.10.36 rename a layer to Summer Sale reader, 2.3 to 2.5 s 6.6 s held, about 5.6 s 4 of 4, $2.93
    Blender 4.0.2 move the Crate to x = 2 m reader, 1.1 to 1.4 s 4.3 s held, about 4.4 s 3 of 3, $2.31
    GNOME Calculator 46.3 18% of 47.60, left showing screen judge, 3 votes 1.8 s held, 9.7 to 10.7 s 3 of 3, $1.72
    • The near misses were "Summer Sail", x = 2.5 and 17% (8.092). Each failed its check.
    • The judge answered 3 of 3 at every Calculator stage and in every solve.
    • GIMP was built twice, once on each commit. Both witnesses held, and the solve on the final code passed through evaluate_with_readers.
  • User-visible CLI/MCP output (if applicable): check_build_task on the Calculator seed returns "the judge (anthropic/claude-sonnet-5-5) said no in 3 of 3 votes: The calculator display is empty, with no result shown. …"

  • Remaining proof gaps:

    • The LibreOffice --convert-to recipe has not been run live.
    • On the Calculator near miss, the history line still showed the earlier 8.568. The judge read the current result and said no 3 of 3, but a less clear screen could mislead it.
    • The checkpoint screenshot is best effort. When it fails, the export refuses the screen task as missing a screenshot.
    • One judge grade costs about $0.02, besides the solve.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx oxfmt --check .: passed.
  • oxlint on the changed files: no errors. The one warning predates this PR: DesktopBuildComputers.ts max-lines grew from 529 to 536.
  • npm run typecheck: no errors outside the API-contract files, which fail only on a dependency missing locally.
  • vitest over src/domain/desktop, src/application/desktop, src/desktop, tests/boundary/providers, tests/boundary/mcp/build* and the advertised-pattern test: 3,391 passed.
    • 41 failed, in the same 10 files that fail on the base. Node 22.23.1 lacks SQLite's DatabaseSync.limits, and the IDA, Ghidra, Kuna and ADB tests need local tools.
    • After a last refactor moving the home-file reads and writes out of AgentEnvComputer.ts, the 371 affected tests passed again.
  • npx knip: only the 2 unresolved worker imports the base also has.
  • npm run verify:module-boundaries: passed.
  • npm run docs:check: passed on the Linux host.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. A task without readers or screen judges renders the same verify.py as before.
  • Real Hopper/Ghidra, browser, or OS coverage: arm64 Ubuntu 24.04 with agentenv 0.9.1431, for GIMP, Blender and GNOME Calculator.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review:
    • a reader never sees the computer's control token and changes only its private copy;
    • a reader's command ships in the bundle and is listed in its README;
    • the judge sends screenshots of the computer to the configured model endpoint, and nothing else.

Review follow-up (75f3163)

JSON task drafts now suggest count checks and guards for top-level arrays. Focused draft and generated Python evaluator tests passed (23 tests), and typecheck passed. The dependent stack and other outstanding review findings remain separate.

Seed validation follow-up (bf0f148)

Task checks now read the seed files the bundle actually ships, adapting the upstream fix in 572edf1623. The task-export suite passed all 27 tests, including the previously failing omitted-log regression; typecheck passed.

Judge cleanup follow-up (1e23d51)

The screen judge and its screenshot now share an owned lifecycle; computer close retries unconfirmed cleanup. Cleanup errors retain completed answers and earlier checks. Ten focused lifecycle and witness tests, typecheck, and the 25-test MCP witness suite passed. The MCP suite used simulated computer and model services; no real desktop provider or model endpoint was exercised. Stacked conflicts remain open.

Screen admission follow-up (9bc4d28)

File checks use the shipped seed, while screen-judge admission compares captured seed and end views. The 29 task-export tests passed, including unchanged and changed omitted-log cases; typecheck and targeted lint passed. No real desktop or model was exercised.

Reader cleanup follow-up (75ffe72)

Unconfirmed reader processes and their working folders remain owned across requests and are retried before later reader work and at one-shot CLI teardown. Errors retain cancellation, completed reader views and distinct capture-file cleanup. The source suites passed 33 tests; process-registry suites passed 9; compiled CLI and reader-runner boundary suites passed 23. Typecheck passed. Failure and retry coverage uses controlled faults; cancellation also uses a real subprocess. An injected cleanup failure was not exercised through the compiled CLI, and no real desktop provider was used.

Judge lifecycle follow-up (9801c7a)

Judge and computer teardown are attempted independently; retries retain only unfinished resources. New judge calls retry retained cleanup first. Eight focused source tests and typecheck passed on the final follow-up; the MCP computer and witness suites passed 50 simulated-service tests before the final cleanup-reporting refactor. No real desktop or model provider was exercised.

Live cleanup attribution (1ef6a1a)

Reader and judge cleanup now share an owner whose resource list follows partial retries. Fifteen lifecycle tests, 40 compiled reader-runner and MCP witness tests, and typecheck passed. Folder-permission failure cases ran on macOS and skip Windows or root; MCP services were simulated.

Merge with the stack's latest (6a381f8)

  • Root-array counts: the stack now has its own version of the 75f3163 fix (feat(desktop): name a record by a nested field or a child's attribute #9185's eea99c7c7), so the merge keeps the stack's code. This PR keeps its draft-guard test and its Python root-array test, which the stack lacks.
  • Seed check views: the stack also has its own version of the bf0f148 fix. The merge keeps the stack's code, plus this PR's integration test "checks the seed the bundle ships, without the app's log it leaves out", which passes on it.
  • Kept from this PR: screen tasks keep their own verifier and the captured-versus-shipped views split.
  • Readers: a verifier without readers is byte-identical to the stack's.
  • Validation: oxfmt is clean; typecheck shows only the API-contract dependency missing locally. vitest over the desktop folders and the Python parity tests: 1,060 passed, 21 skipped (Linux-only). The build witness and capture MCP tests: 49 of 49. The branch merges cleanly into main.
  • Docs: c7e6e90b0 keeps verify.py judge CHECK SCREENSHOT on one line.

Maintainer follow-up

Integrated parent repairs for nested alias restoration, process-family ownership during packing/setup, and declared selector formats. Nested aliases restore in either input order; setup command failure/output survives cancellation during cleanup. Retained source reader/screen checks and controlled witness MCP coverage. This does not qualify real headless apps or a real screen judge. Screen-task change detection uses existing value equality, and reader JSON numbers share the exported verifier exact-number policy. The outer export budget accounts for both reader passes. Actual outer-timeout cleanup and remote reader cleanup remain unresolved; those threads stay open and auto-merge remains disabled. Reader input transport splits the serialized request into bounded UTF-8 arguments and rejoins once, preserving maximum-length Unicode input; Linux-specific E2BIG was not reproduced on macOS and aggregate OS argument/environment limits remain. Doctor obtains model configuration from the pinned agentenv owner rather than treating a model table as an endpoint. Missing, unknown and configured remain distinct; subprocess queries use existing cancellation/deadline ownership. Additional checks passed: npm run docs:check.

At head 83e5e15371, the affected tests below completed with 193 passed (193); npm run check:fast, npm run format:check and git diff --check passed. This includes the updated parent stack and main through 25d3c7237f. Checks use source/domain and controlled boundary fixtures; no real desktop provider qualification was performed. Current-head CI and review remain required before auto-merge.

node node_modules/vitest/vitest.mjs run src/application/desktop/DesktopTaskReaders.test.ts src/application/desktop/DesktopTaskExport.test.ts src/domain/desktop/appTaskReaders.test.ts src/domain/desktop/appTaskScreen.test.ts src/desktop/ScreenJudgeProcess.test.ts tests/boundary/mcp/buildWitnessMcp.test.ts tests/boundary/providers/desktopExportPython.test.ts src/domain/desktop/appTaskDraftJson.test.ts src/application/desktop/DesktopBuildExport.test.ts src/desktop/DesktopBuildDoctorFacts.test.ts src/application/DesktopBuildDoctor.test.ts src/application/desktop/DesktopTaskDraftNotes.test.ts src/domain/desktop/stateRoles.test.ts

Author readiness

Human owner: @earakely-scale

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T01:53:40.172299Z
We couldn’t complete this review. Comment @codex review to try again.
c11e2e3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5 · Do not merge yet: lost reader replies can prevent shutdown, and shorter export retries can bypass unfinished cleanup.RetriggerView in GreptileConfidence Score: 3/5 Tier: plus

[Medium impact] The new checks affect only desktop tasks that opt into a reader or a screen judge.

Do not merge yet: lost reader replies can prevent shutdown, and shorter export retries can bypass unfinished cleanup.

Findings

  1. P1 Lost replies prevent shutdown ▶
  2. P1 Shorter retries skip cleanup ▶
  3. P2 Cancellation loses its cause ▶
  4. P2 Screenshot reads lack ownership ▶
  5. P2 Task reference omits new features ▶
  6. P2 Export notes repeat ▶
  7. P2 Cancellation gets lost during cleanup ▶
  8. P2 README claims unrun checks ▶
  9. P2 Earlier reader answers disappear ▶
Fix with agent prompt
### Issue 1
src/application/desktop/DesktopRemoteTaskReaders.ts:107-110
When a reader reply is lost, this catch deletes `pending.command`. Every later `release()` then throws the saved error without contacting the computer again. `DesktopBuildComputers` skips `computer.close()` while that cleanup remains unfinished. Even after the connection recovers and the reader finishes, neither another check nor closing the computer can recover.

The exported verifier has the same problem: it repeatedly awaits the already-failed task. Retain a way to confirm the original request's outcome, or safely release the owned computer.

### Issue 2
src/application/desktop/DesktopBuildExport.ts:184-187
After a long export fails with unfinished cleanup, retrying with fewer or shorter readers takes `runRea` instead of `longRuns.run`. Only `longRuns.run` retries the retained job, so the shorter export can start while the earlier export is still running.

`AGENTS.md` requires retrying retained cleanup before new work and blocking new work while cleanup remains unresolved. Put both export paths behind the same cleanup gate.

### Issue 3
src/desktop/ScreenJudgeProcess.ts:221
When the judge has returned a complete answer but process cleanup fails, `#retainProcessFailure` drops `cleanupPrimary`. That also drops typed cancellation when `OwnedCommandFailure` records an abort. An abort during process cleanup can have `reason: "process"` with a separate `cancellation` record, which this wrapper and the local reader's `primaryFailure` ignore. Callers then see a provider failure instead of cancellation, even after cleanup succeeds.

Preserve the recorded cancellation and typed primary alongside the completed answer. `AGENTS.md` requires carrying the caller's cancellation through cleanup wrapping. This repository requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 4
src/application/desktop/DesktopExportReaders.ts:51-53
`screenAt` opens screenshots with `readFile` instead of the repository's owned file reader. It cannot retain the exact file handle if close fails. Its size check also applies to an earlier `stat`, not the file it reads, so a replaced or enlarged screenshot can bypass the intended limit.

`AGENTS.md` requires following the lifecycle guide: give file reads an owner before opening them and retain failed closes. Use the existing owned, bounded read path here. This repository requirement must be satisfied before merging.

### Issue 5
docs/desktop-build-witness.md:225-230
Both new links point to missing sections. `desktop-application-tasks.md` documents neither readers nor screen judges and still says REA runs no agent-written code. Users following these links cannot find the new task contracts and get an incorrect description of what runs.

Add both contracts to that owning guide and update its execution description.

### Issue 6
src/domain/desktop/appExportInstallLimitations.ts:81-85
This adds a third identical `extraPackages` note. Every export with extra packages now repeats the same sentence three times in `limitations`, which is copied directly into the export result. Keep one branch so users and agents get one clear note instead of repeated text.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 7
src/desktop/ScreenJudgeProcess.ts:151-154
After `runOwnedCommand` returns an answer, cancelling while `#removeScreen` waits for `rm` still returns `outcome`. A `check_build_task` call without `stage` forwards that normal grade without another cancellation check.

`AGENTS.md` requires following the lifecycle rule to check cancellation after the last cleanup step and retain completed observations in the cancellation error. Recheck `signal` after screenshot deletion and preserve `outcome` when reporting cancellation.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 8
src/application/desktop/DesktopTaskExport.ts:undefined-382
Every newly exported screen task says “REA's witness ran this judge,” but this README is written before the witness runs. The witness may never happen, so an unwitnessed bundle claims completed checks.

`AGENTS.md` requires distinguishing observations from unverified claims. Say the witness must run the judge instead. This repository requirement must be satisfied before merging.

```suggestion
scoring the agent. The export judged no screen; run REA's witness to check this judge on a fresh screenshot at each stage.
```

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 9
src/domain/desktop/appTaskReaders.ts:410-413
If a later reader call fails or verification is cancelled while it runs, this branch rethrows with only the request and folder names. Earlier answers remain only in the local `views` map, so the failure loses those completed results. The cleanup-error branches preserve them, but this branch does not.

Preserve completed views and known absences on every failure path. `AGENTS.md` requires keeping completed observations before awaiting the next stage. This repository requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds task readers for binary app files and model-based checks of screenshots.

  • Desktop tasks can check binary files through an app’s own reader command.
  • Desktop tasks can grade screen-only changes with yes-or-no model checks.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Task["Task checks"] --> Kind{"Check source"}
  Kind --> Reader["App's headless reader"]
  Kind --> Screen["Screenshot judge"]
  Reader --> View["JSON or lines"]
  View --> Evaluate["Existing check evaluator"]
  Screen --> Examples["Seed and end examples"]
  Examples --> Votes["Three model votes"]
  Evaluate --> Result["Per-check results"]
  Votes --> Result
Loading

Reviews (17) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/desktop/TaskReaderProcess.ts Resolved
Comment thread src/domain/desktop/appTaskReaders.ts Resolved
Comment thread src/domain/desktop/appTaskReaders.ts Resolved
Comment thread src/contracts/toolEffects.ts Resolved
Comment thread src/domain/desktop/appTaskDraftJson.ts Resolved
Comment thread src/desktop/ScreenJudgeProcess.ts Resolved
Comment thread src/desktop/ScreenJudgeProcess.ts Resolved
# Conflicts:
#	src/application/Setup.ts
#	src/composition/capabilityServices.ts
#	src/doctorRuntime.ts
# Conflicts:
#	.agents/skills/reverse-engineer-anything/references/desktop-build.md
#	docs/desktop-application-capture.md
#	docs/desktop-application-export.md
#	docs/desktop-application-state.md
#	docs/desktop-application-tasks.md
#	docs/desktop-build-computer.md
#	docs/desktop-build-witness.md
#	docs/specs/desktop-app-environments/build-witness/spec.md
#	docs/specs/desktop-app-environments/build-witness/verification.md
#	src/application/desktop/DesktopApplicationCapture.ts
#	src/application/desktop/DesktopApplicationExport.test.ts
#	src/application/desktop/DesktopApplicationExport.ts
#	src/application/desktop/DesktopBuildBundle.ts
#	src/application/desktop/DesktopBuildCapture.ts
#	src/application/desktop/DesktopBuildComputers.ts
#	src/application/desktop/DesktopBuildOutputRead.test.ts
#	src/application/desktop/DesktopBuildSummary.ts
#	src/application/desktop/DesktopBuildWitness.test.ts
#	src/application/desktop/DesktopBuildWitness.ts
#	src/application/desktop/DesktopBuildWitnessRecord.ts
#	src/application/desktop/DesktopExportFiles.ts
#	src/application/desktop/DesktopExportLaunch.ts
#	src/application/desktop/DesktopGzipDocument.test.ts
#	src/application/desktop/DesktopTaskDraft.ts
#	src/application/desktop/DesktopTaskDraftNotes.test.ts
#	src/application/desktop/DesktopTaskExport.test.ts
#	src/application/desktop/DesktopTaskExport.ts
#	src/composition/capabilityServices.ts
#	src/contracts/desktopBuildToolContracts.ts
#	src/desktop/AgentEnvComputer.ts
#	src/desktop/BuildComputerController.ts
#	src/desktop/DesktopApplicationSession.test.ts
#	src/domain/desktop/appExport.test.ts
#	src/domain/desktop/appExport.ts
#	src/domain/desktop/appExportPython.ts
#	src/domain/desktop/appExportUnowned.test.ts
#	src/domain/desktop/appExportUnowned.ts
#	src/domain/desktop/appTaskChecks.fixture.ts
#	src/domain/desktop/appTaskChecks.ts
#	src/domain/desktop/appTaskDraft.fixture.ts
#	src/domain/desktop/appTaskDraft.ts
#	src/domain/desktop/appTaskDraftAdded.test.ts
#	src/domain/desktop/appTaskDraftAdded.ts
#	src/domain/desktop/appTaskDraftFileNotes.test.ts
#	src/domain/desktop/appTaskDraftFileNotes.ts
#	src/domain/desktop/appTaskDraftGuards.test.ts
#	src/domain/desktop/appTaskDraftGuards.ts
#	src/domain/desktop/appTaskDraftLineGuards.ts
#	src/domain/desktop/appTaskDraftNamed.ts
#	src/domain/desktop/appTaskDraftNoise.test.ts
#	src/domain/desktop/appTaskDraftNoise.ts
#	src/domain/desktop/appTaskDraftNotes.ts
#	src/domain/desktop/appTaskDraftPositional.test.ts
#	src/domain/desktop/appTaskDraftScalars.ts
#	src/domain/desktop/appTaskDraftText.ts
#	src/domain/desktop/appTaskDraftTextAdded.test.ts
#	src/domain/desktop/appTaskDraftValues.test.ts
#	src/domain/desktop/appTaskDraftValues.ts
#	src/domain/desktop/appTaskPython.ts
#	src/domain/desktop/attributeRank.ts
#	src/domain/desktop/desktopCapture.test.ts
#	src/domain/desktop/desktopCapture.ts
#	src/domain/desktop/positionalKeys.ts
#	src/domain/desktop/runtimeFiles.ts
#	src/domain/desktop/seedDocument.test.ts
#	src/domain/desktop/seedScrub.ts
#	src/domain/desktop/selectorCandidates.ts
#	src/domain/desktop/stateChanges.ts
#	src/domain/desktop/stateFormats.ts
#	src/domain/desktop/stateRoles.test.ts
#	src/domain/desktop/stateRoles.ts
#	src/domain/desktop/viewPointer.test.ts
#	src/domain/desktop/viewPointer.ts
#	tests/boundary/mcp/buildCaptureDraftMcp.test.ts
#	tests/boundary/mcp/buildCaptureMcp.test.ts
#	tests/boundary/mcp/buildCaptureRetryMcp.test.ts
#	tests/boundary/mcp/buildComputerMcp.test.ts
#	tests/boundary/mcp/buildWitnessMcp.test.ts
#	tests/boundary/providers/desktopExportPython.test.ts
#	tests/boundary/providers/desktopTaskPython.test.ts
#	tests/fixtures/buildCaptureFakes.ts
#	tests/fixtures/buildComputerMcp.ts
#	tests/fixtures/fakeAgentEnvComputer.ts
# Conflicts:
#	.agents/skills/reverse-engineer-anything/references/desktop-build.md
#	docs/desktop-application-export.md
#	docs/desktop-application-tasks.md
#	docs/specs/desktop-app-environments/README.md
#	src/application/DesktopBuildDoctor.test.ts
#	src/application/DesktopBuildDoctor.ts
#	src/application/desktop/DesktopApplicationExport.ts
#	src/application/desktop/DesktopBuildCapture.ts
#	src/application/desktop/DesktopBuildExport.ts
#	src/application/desktop/DesktopBuildWitness.ts
#	src/application/desktop/DesktopExportFiles.ts
#	src/application/desktop/DesktopExportInstall.ts
#	src/application/desktop/DesktopTaskExport.test.ts
#	src/application/desktop/DesktopTaskExport.ts
#	src/cli/desktopCaptureCommands.ts
#	src/contracts/desktopBuildToolContracts.ts
#	src/domain/desktop/appBuild.test.ts
#	src/domain/desktop/appBuild.ts
#	src/domain/desktop/appExport.ts
#	src/domain/desktop/appExportInstall.ts
#	src/domain/desktop/appExportPython.ts
#	src/domain/desktop/appTask.ts
#	src/domain/desktop/appTaskDraft.fixture.ts
#	src/domain/desktop/appTaskDraftJson.test.ts
#	src/domain/desktop/appTaskDraftLineGuards.test.ts
#	src/domain/desktop/appTaskDraftLineGuards.ts
#	src/domain/desktop/appTaskDraftModel.test.ts
#	src/domain/desktop/appTaskPython.ts
#	tests/boundary/mcp/buildCaptureRetryMcp.test.ts
#	tests/fixtures/buildCaptureFakes.ts
#	tests/fixtures/buildComputerMcp.ts
Comment on lines +107 to +110
} catch (cause: unknown) {
if (!signal.aborted) {
pending.uncertain = cause;
delete pending.command;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Lost replies prevent shutdown

When a reader reply is lost, this catch deletes pending.command. Every later release() then throws the saved error without contacting the computer again. DesktopBuildComputers skips computer.close() while that cleanup remains unfinished. Even after the connection recovers and the reader finishes, neither another check nor closing the computer can recover.

The exported verifier has the same problem: it repeatedly awaits the already-failed task. Retain a way to confirm the original request's outcome, or safely release the owned computer.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/desktop/DesktopRemoteTaskReaders.ts
Line: 107-110

Comment:
**Lost replies prevent shutdown**

When a reader reply is lost, this catch deletes `pending.command`. Every later `release()` then throws the saved error without contacting the computer again. `DesktopBuildComputers` skips `computer.close()` while that cleanup remains unfinished. Even after the connection recovers and the reader finishes, neither another check nor closing the computer can recover.

The exported verifier has the same problem: it repeatedly awaits the already-failed task. Retain a way to confirm the original request's outcome, or safely release the owned computer.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +225 to +230
check. Once the files settle it runs the task's
[readers](desktop-application-tasks.md#readers) in the computer through
`computer-exec/v1`, as the verifier does, and a check through a reader reads
that reader's view. A task of [screen judges](desktop-application-tasks.md#screen-judges)
reads no files: REA takes a screenshot and runs the bundle's own judge on it
with the agentenv runner's Python and model endpoint. Like the verifier, it grades only once the app's files settle, since an

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Task reference omits new features

Both new links point to missing sections. desktop-application-tasks.md documents neither readers nor screen judges and still says REA runs no agent-written code. Users following these links cannot find the new task contracts and get an incorrect description of what runs.

Add both contracts to that owning guide and update its execution description.

Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/desktop-build-witness.md
Line: 225-230

Comment:
**Task reference omits new features**

Both new links point to missing sections. `desktop-application-tasks.md` documents neither readers nor screen judges and still says REA runs no agent-written code. Users following these links cannot find the new task contracts and get an incorrect description of what runs.

Add both contracts to that owning guide and update its execution description.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +81 to +85
...(install.extraPackages === undefined
? []
: [
`The computer installs ${install.extraPackages.join(", ")} beside the application because the export was asked for them with --extra-package, as a build computer asks for the packages its request named.`,
]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Export notes repeat

This adds a third identical extraPackages note. Every export with extra packages now repeats the same sentence three times in limitations, which is copied directly into the export result. Keep one branch so users and agents get one clear note instead of repeated text.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/desktop/appExportInstallLimitations.ts
Line: 81-85

Comment:
**Export notes repeat**

This adds a third identical `extraPackages` note. Every export with extra packages now repeats the same sentence three times in `limitations`, which is copied directly into the export result. Keep one branch so users and agents get one clear note instead of repeated text.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +151 to +154
if (!retained) await this.#removeScreen(folder, outcome, primary?.cause);
if (primary !== undefined) throw primary.cause;
if (outcome === undefined) throw new Error("Judge produced no outcome.");
return outcome;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Cancellation gets lost during cleanup

After runOwnedCommand returns an answer, cancelling while #removeScreen waits for rm still returns outcome. A check_build_task call without stage forwards that normal grade without another cancellation check.

AGENTS.md requires following the lifecycle rule to check cancellation after the last cleanup step and retain completed observations in the cancellation error. Recheck signal after screenshot deletion and preserve outcome when reporting cancellation.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/desktop/ScreenJudgeProcess.ts
Line: 151-154

Comment:
**Cancellation gets lost during cleanup**

After `runOwnedCommand` returns an answer, cancelling while `#removeScreen` waits for `rm` still returns `outcome`. A `check_build_task` call without `stage` forwards that normal grade without another cancellation check.

`AGENTS.md` requires following the lifecycle rule to check cancellation after the last cleanup step and retain completed observations in the cancellation error. Recheck `signal` after screenshot deletion and preserve `outcome` when reporting cancellation.

**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +184 to +187
const { stdoutBytes: bytes } =
timeoutS + 60 <= 3600
? await runRea(computer, argv, options)
: await longRuns.run(argv, { ...options, work: WORK });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Shorter retries skip cleanup

After a long export fails with unfinished cleanup, retrying with fewer or shorter readers takes runRea instead of longRuns.run. Only longRuns.run retries the retained job, so the shorter export can start while the earlier export is still running.

AGENTS.md requires retrying retained cleanup before new work and blocking new work while cleanup remains unresolved. Put both export paths behind the same cleanup gate.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/desktop/DesktopBuildExport.ts
Line: 184-187

Comment:
**Shorter retries skip cleanup**

After a long export fails with unfinished cleanup, retrying with fewer or shorter readers takes `runRea` instead of `longRuns.run`. Only `longRuns.run` retries the retained job, so the shorter export can start while the earlier export is still running.

`AGENTS.md` requires retrying retained cleanup before new work and blocking new work while cleanup remains unresolved. Put both export paths behind the same cleanup gate.

**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

The judge's model is \`[model.roles] judge\` in the runner's \`.agentenv/config.toml\`, else its \`[model] default\`, else
\`${DEFAULT_JUDGE_MODEL}\`, called through \`LITELLM_BASE_URL\` and \`LITELLM_API_KEY\` or \`[model] base_url\` and \`api_key\`.
\`agent-env run --judge-model\` does not reach it. Without an endpoint the verifier raises, so the run fails rather than
scoring the agent. The export judged no screen; REA's witness ran this judge on a fresh screenshot at each stage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 README claims unrun checks

Every newly exported screen task says “REA's witness ran this judge,” but this README is written before the witness runs. The witness may never happen, so an unwitnessed bundle claims completed checks.

AGENTS.md requires distinguishing observations from unverified claims. Say the witness must run the judge instead. This repository requirement must be satisfied before merging.

Suggested change
scoring the agent. The export judged no screen; REA's witness ran this judge on a fresh screenshot at each stage.
scoring the agent. The export judged no screen; run REA's witness to check this judge on a fresh screenshot at each stage.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/desktop/DesktopTaskExport.ts
Line: 382

Comment:
**README claims unrun checks**

Every newly exported screen task says “REA's witness ran this judge,” but this README is written before the witness runs. The witness may never happen, so an unwitnessed bundle claims completed checks.

`AGENTS.md` requires distinguishing observations from unverified claims. Say the witness must run the judge instead. This repository requirement must be satisfied before merging.

```suggestion
scoring the agent. The export judged no screen; run REA's witness to check this judge on a fresh screenshot at each stage.
```

**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@morluto morluto added the enhancement New feature or request label Nov 22, 2026
Comment on lines +410 to +413
except BaseException as error:
_PENDING_READERS[token]["abandoned"] = True
error.add_note(f"Reader command {params['request_id']} and folder {lease['path']} remain owned for retry.")
raise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Earlier reader answers disappear

If a later reader call fails or verification is cancelled while it runs, this branch rethrows with only the request and folder names. Earlier answers remain only in the local views map, so the failure loses those completed results. The cleanup-error branches preserve them, but this branch does not.

Preserve completed views and known absences on every failure path. AGENTS.md requires keeping completed observations before awaiting the next stage. This repository requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/desktop/appTaskReaders.ts
Line: 410-413

Comment:
**Earlier reader answers disappear**

If a later reader call fails or verification is cancelled while it runs, this branch rethrows with only the request and folder names. Earlier answers remain only in the local `views` map, so the failure loses those completed results. The cleanup-error branches preserve them, but this branch does not.

Preserve completed views and known absences on every failure path. `AGENTS.md` requires keeping completed observations before awaiting the next stage. This repository requirement must be satisfied before merging.

**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@morluto morluto added the area: runtime Process capture and runtime observation label Nov 26, 2026
{
operation: "check_build_task",
cause,
...(completed === undefined ? { cleanupPrimary: original } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Cancellation loses its cause

When the judge has returned a complete answer but process cleanup fails, #retainProcessFailure drops cleanupPrimary. That also drops typed cancellation when OwnedCommandFailure records an abort. An abort during process cleanup can have reason: "process" with a separate cancellation record, which this wrapper and the local reader's primaryFailure ignore. Callers then see a provider failure instead of cancellation, even after cleanup succeeds.

Preserve the recorded cancellation and typed primary alongside the completed answer. AGENTS.md requires carrying the caller's cancellation through cleanup wrapping. This repository requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/desktop/ScreenJudgeProcess.ts
Line: 221

Comment:
**Cancellation loses its cause**

When the judge has returned a complete answer but process cleanup fails, `#retainProcessFailure` drops `cleanupPrimary`. That also drops typed cancellation when `OwnedCommandFailure` records an abort. An abort during process cleanup can have `reason: "process"` with a separate `cancellation` record, which this wrapper and the local reader's `primaryFailure` ignore. Callers then see a provider failure instead of cancellation, even after cleanup succeeds.

Preserve the recorded cancellation and typed primary alongside the completed answer. `AGENTS.md` requires carrying the caller's cancellation through cleanup wrapping. This repository requirement must be satisfied before merging.

**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +51 to +53
const found = await stat(path).catch(() => undefined);
if (found?.isFile() !== true) return undefined;
return found.size > SCREEN_EXAMPLE_MAX_BYTES ? "too-large" : readFile(path);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Screenshot reads lack ownership

screenAt opens screenshots with readFile instead of the repository's owned file reader. It cannot retain the exact file handle if close fails. Its size check also applies to an earlier stat, not the file it reads, so a replaced or enlarged screenshot can bypass the intended limit.

AGENTS.md requires following the lifecycle guide: give file reads an owner before opening them and retain failed closes. Use the existing owned, bounded read path here. This repository requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/desktop/DesktopExportReaders.ts
Line: 51-53

Comment:
**Screenshot reads lack ownership**

`screenAt` opens screenshots with `readFile` instead of the repository's owned file reader. It cannot retain the exact file handle if close fails. Its size check also applies to an earlier `stat`, not the file it reads, so a replaced or enlarged screenshot can bypass the intended limit.

`AGENTS.md` requires following the lifecycle guide: give file reads an owner before opening them and retain failed closes. Use the existing owned, bounded read path here. This repository requirement must be satisfied before merging.

**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants