Repository navigation
feat(desktop): check apps whose files REA can't read, through the app's own headless mode or a screen judge - #9217
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[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
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.SummaryAdds task readers for binary app files and model-based checks of screenshots.
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
Reviews (17) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
# 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
| } catch (cause: unknown) { | ||
| if (!signal.aborted) { | ||
| pending.uncertain = cause; | ||
| delete pending.command; |
There was a problem hiding this comment.
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.| 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 |
There was a problem hiding this 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.
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.| ...(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.`, | ||
| ]), |
There was a problem hiding this comment.
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!
| 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; |
There was a problem hiding this 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)
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!
| const { stdoutBytes: bytes } = | ||
| timeoutS + 60 <= 3600 | ||
| ? await runRea(computer, argv, options) | ||
| : await longRuns.run(argv, { ...options, work: WORK }); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
| 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!
| 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 |
There was a problem hiding this 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)
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!
| { | ||
| operation: "check_build_task", | ||
| cause, | ||
| ...(completed === undefined ? { cleanupPrimary: original } : {}), |
There was a problem hiding this comment.
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!
| const found = await stat(path).catch(() => undefined); | ||
| if (found?.isFile() !== true) return undefined; | ||
| return found.size > SCREEN_EXAMPLE_MAX_BYTES ? "too-large" : readFile(path); |
There was a problem hiding this 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)
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.
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
.xcfor 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:
unreadable_viewforposter.xcfandscene.blendand suggested no checks;no_changeandno_document.After this change:
screen_judgecheck, and the bundle ships a judge calibrated on the build's own seed and end screenshots.Change and scope
Readers (
060c8514c):readers, each{id, file, argv, stdin?, output, timeout_s?, display?}.outputisjson(forvalue_equals,value_absentandmember_count) orlines(forlines_present,lines_absentandline_count).readerand gives the reader's file as itsfile.{file}, an unknown or unused reader, and a kind its output doesn't serve.PYTHON_READER_RUNNER, which the export, the witness and the verifier all run.{file}naming the copy.HOMEandXDG_folders in that folder.XDG_RUNTIME_DIRor anyAGENTENV_variable, so it never holds the control token.timeout_s(60 s by default, 300 at most), and may print at most 1 MiB.REAmake the view; everything else, such as banners and warnings, is dropped.computer-exec/v1once the app's files settle.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.verify.pybyte for byte as on the base, and a test pins its SHA-256.gimp-console-2.10), Blender (blender -b --factory-startupwith bpy) and LibreOffice--convert-to.Screen judge (the second commit):
{id?, kind: "screen_judge", question}. A task with one holds only screen judges and no readers.screensfolder. The export ships the seed's as the "no" example and the end's as the "yes" example.computer_screenshot, and asks each question 3 times. Two yes votes pass the check. Each vote gets up to 3 attempts.[model.roles] judge, else[model] default, elseanthropic/claude-sonnet-5-5, through agentenv's own model config.agent-env run --judge-modeldoesn't reach it, and the README says so.verify.py judge <check> <screenshot>with the runner's Python. REA calls no model itself.The design note's seven decisions were all taken as option a.
Not included:
Contract and boundary impact
export_build_environmentandcheck_build_tasktake the wider task schema, withreadersandscreen_judge.rea export-desktop-applicationgains--screens.mark_build_checkpointnow also saves a screenshot in the computer.computer-exec/v1andcomputer_screenshotfrom agentenv 0.9.1431, which the build computer already uses.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.
Evidence and regression coverage
Tests added or updated:
python3ascomputer-execruns 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;computer-exec/v1, with TS and Python agreeing on every result and description;screens/seed.jpgandscreens/end.jpg;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,
seedandend, 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.evaluate_with_readers.User-visible CLI/MCP output (if applicable):
check_build_taskon 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:
--convert-torecipe has not been run live.For evidence-bearing changes:
Validation performed
npx oxfmt --check .: passed.DesktopBuildComputers.tsmax-lines grew from 529 to 536.npm run typecheck: no errors outside the API-contract files, which fail only on a dependency missing locally.src/domain/desktop,src/application/desktop,src/desktop,tests/boundary/providers,tests/boundary/mcp/build*and the advertised-pattern test: 3,391 passed.DatabaseSync.limits, and the IDA, Ghidra, Kuna and ADB tests need local tools.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
verify.pyas before.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)
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.c7e6e90b0keepsverify.py judge CHECK SCREENSHOTon 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:checkandgit diff --checkpassed. This includes the updated parent stack and main through25d3c7237f. 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.Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.🤖 Generated with Claude Code