Skip to content

feat(desktop): capture, draft, export and witness a task inside a build computer - #9045

Merged
morluto merged 20 commits into
morluto:mainfrom
earakely-scale:feat/desktop-build-witness
Nov 7, 2026
Merged

morluto merged 20 commits into
morluto:mainfrom
earakely-scale:feat/desktop-build-witness

Conversation

@earakely-scale

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

Copy link
Copy Markdown
Contributor

Builds on main, which now holds #9037 and #9041. Review its own commits: 137572d1c (the feature, which also carries what the earlier merges adapted: the file splits for the lint limits and the bounded action log), then the review and validation fixes 8d04d4d22, f6e9decf7, 0b6e6c46d, 4158a3691, c1e47c8c4, ec5719026, aeae4efc3, 8f84c1f77 and fcb40ceaa (a reset stays applied when the screenshot asked after it fails). About 7,400 added lines with tests and docs, kept as one PR on purpose.

Summary

With this PR, Claude Code builds and proves a computer-app environment inside an agentenv computer through REA's MCP tools: it captures the app as Claude uses it, drafts and exports the task, then witnesses that task in a fresh computer. It is the third of four PRs for "a bundle from a request". The fourth is the skill that walks Claude through the flow.

Problem and expected behavior

#9041 lets Claude drive a computer, but nothing turned that into an environment. After this change:

  1. start_build_capture starts REA's capture of the app inside the computer, after a user-space apt-get update so package sources are found.

  2. Claude makes the starting document in the app and calls mark_build_checkpoint seed. Then it makes the edit and calls mark_build_checkpoint end. Each call returns only once the capture confirms the checkpoint was taken, with its counts.

  3. stop_build_capture returns the package and the draft between seed and end: the changed files and suggested checks.

  4. export_build_environment exports with the task Claude wrote, inside the computer, and fetches the bundle to a local folder.

  5. In a fresh computer of that bundle, check_build_task grades the app's data/get with REA's evaluator through the stages seed, after_edit, near_miss and after_reset. act_on_build_computer gains reset.

    The witness holds only if:

    • a check fails on the seed;
    • all pass after the edit;
    • one fails after a near miss;
    • one fails again after data/reset.

    It writes witness.json Evidence (rea.desktop-build-witness) with the action log and the screen recording.

Change and scope

  • Capture acknowledgement: capture's progress lines carry window_open, checkpoint (with counts, after the checkpoint is taken) and checkpoint_refused events.
  • In-computer controller: bridge/agentenv/capture.py, run through computer-exec/v1.
    • It runs start (apt lists under APT_CONFIG, then the capture detached on a FIFO), mark, stop, run (draft and export) and list.
    • Its own folder stays out of the capture.
    • It drops AGENTENV_*.
  • Adapter:
    • AgentEnvComputer gains exec (bounded, token redacted), homeFiles (bounded data/get batches checked against the listing), appData and waitUntilReady.
    • BuildComputerController.ts runs the controller.
  • Application:
    • DesktopBuildCapture.ts, DesktopBuildExport.ts and DesktopBuildCommands.ts cover capture, draft and export.
    • DesktopBuildWitness.ts and DesktopBuildWitnessRecord.ts cover grading, the stages and the record.
    • DesktopBuildSteps.ts holds the step tools.
    • DesktopOutputTree.ts, the export's safe output-tree writer, moves out so the build export and the witness share it.
  • Domain: buildWitness.ts holds the stage order and rules. An applied input action is required before after_edit and near_miss, and the reset must be the last change before after_reset. buildCapture.ts holds the checkpoint name rules.
  • Gaps closed from feat(desktop): keep an agentenv computer up and drive it through REA's MCP tools #9041's real run:
    • npm run pack:build-computer-runtime -- <out.tar.xz> builds the REA archive.
    • Exported and build apps start in the home, so Save As no longer opens on build files.
    • Long tools send a progress notification every 5 s.
  • Review fixes (8d04d4d22):
    • Retryable steps:
      • a capture whose start answer is lost is stopped and kept until the stop is confirmed;
      • a lost checkpoint answer is recovered from the capture's own log;
      • stop can be repeated to resume its result;
      • a witness can retry a failed seed read and a failed save.
    • Witness integrity: after_edit and near_miss count only click, drag, scroll, type and key, so a reset can't stand in for the near-miss edit.
    • .deb builds: they keep their package file for capture and pass its URL to export.
    • Bounded downloads: each checked file is written before the next is fetched.
    • Errors and progress: apt failures report their exit code and log, and reset sends progress.
  • Second review fixes (4158a3691):
    • One queue per computer: actions, capture steps and witness checks run one at a time, so overlapping checks can't file a stage twice and skip the near miss; close cancels running and queued calls, and different computers still run concurrently.
    • Recording id: one request id per computer, so a seed retried after a lost reply recovers the recording.
    • Undecided checks: a check that couldn't read its file is undecided, not a failure, so a temporary read error can't prove a stage; the stage is refused and can be checked again.
    • Large listings: the export's file listing goes through a file read in bounded batches, not exec's 1 MiB output.
  • Validation fixes (f6e9decf7), from a blind Inkscape rebuild with the build skill:
    • Trash: files in the desktop Trash are no longer owned or seeded; the export names them in a limitation.
    • Bundle folder: starting a computer from a bundle folder no longer writes __pycache__ into it.
    • First screenshot: the first screenshot waits, bounded, until the desktop has drawn.
    • .deb exports: a .deb that apt also offers exports from apt.
  • Docs: a new docs/desktop-build-witness.md, updates to the capture, export and build-computer guides, and a build-witness spec folder.

Contract and boundary impact

  • Semantic owner and earliest changed stage: new MCP-only session tools in the application family, plus capture's progress events.
  • 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: five new MCP tools and a reset action. capture-desktop-application progress lines gain an event field.
  • Provider, bridge, target-format, or platform compatibility: a new Python controller run inside the computer. Exported apps now cd to the captured working directory before launch.
  • Evidence, artifact, provenance, or reconstruction contract: new rea.desktop-build-witness Evidence.
  • Target selection, authority, upstream behavior, and cleanup details:
    • runs REA inside the computer through agentenv's exec route;
    • the controller's files stay under ~/.rea-build, which the capture leaves out.
  • Generated metadata: the MCP catalog.

Expected effects:

  • 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

  • New tests, each failing on the base:

    • buildWitness.test.ts;
    • the reset action;
    • three launchCommand cases;
    • the demand launch;
    • buildCaptureMcp.test.ts and buildWitnessMcp.test.ts, run against an extended fake computer with exec, data/get paths and data/reset;
    • on Linux, the capture acknowledgement test, which timed out on the base.
  • Real end-to-end run on an Ubuntu 24.04 amd64 VM (agentenv-framework 0.9.1431), through REA's real MCP tools, with Claude as the building agent:

    Step Result
    Mousepad build computer 80 s cold with 14 progress notifications; 22.5 s warm
    start_build_capture 7.3 s; Save As opened on the home
    Seed two lines saved; seed marked in 0.45 s and confirmed; a second seed refused
    Edit a third line saved; end marked; stop_build_capture drafted exactly that line
    Export 9 files, failing_on_seed covering the new line's checks; the launch line has cd "$HOME"
    Witness in a fresh computer held
    • Witness stages:
      • seed: the new-line checks fail;
      • after_edit: all pass;
      • near_miss ("call the dentists"): the line check fails;
      • after_reset: they fail again, with the reset ready in 0.8 s.
    • Record: 15 actions, and a recording of 5 segments over 69 s.
    • Cleanup: every computer closed in about 0.5 s, and Docker was left clean.
  • After the merge with feat(desktop): keep an agentenv computer up and drive it through REA's MCP tools #9041's fixes, a real start, capture, checkpoint, stop and close round passed on the VM. The start took 22.7 s and returned a JPEG screenshot.

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

  • These passed with no new lint diagnostics in this PR's files: npm run typecheck, format:check, build:cached then knip, jscpd, docs:check, docs:build, verify:test-discovery, verify:architecture-guards, verify:module-boundaries and mcp-catalog:check. lint fails only on main's tests/acceptance/webSourceLocationCli.test.ts.
  • Touched-area tests: 1,739 passed and 31 skipped on macOS with the review fixes, covering the desktop code, contracts, process supervision, schema, family and CLI-parity tests, and the build and Python parity tests.
  • VM: the desktop and build tests passed, 478 of 478.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Capture progress lines gain an optional field.
  • Real Hopper/Ghidra, browser, or OS coverage: a real Ubuntu 24.04 amd64 agentenv computer; Mousepad.
  • Package or release metadata impact: bridge/agentenv/capture.py is added to the package's files; there is a new pack:build-computer-runtime script.
  • Security, privacy, process, or containment review:
    • the control token never leaves REA's process, and exec output is redacted;
    • every read from the computer is bounded.

Known gaps:

  • The witness acts were made by the building agent from the task prompt, and the grading used REA's evaluator. The exported verify.py and a separate solving agent run in the milestone's validation, not here.
  • Proven on Mousepad on the local provider on amd64 only.
  • REA's skill does not mention these tools yet; the next PR adds the skill.

Final review round

main is merged in (91bd1765a): its Electron launch script now sits beside this branch's package-file copy in the build bundle. An independent review of this PR's diff found five gaps, fixed in 3855a38cd, each with a test that failed first:

  • Commands in the computer answer only when they end, but fetch stops waiting for headers after 300 s, so a slow export, draft or start always failed. A command with its own deadline now waits on node:http, bounded by that deadline.
  • after_reset held whenever some check failed, so a reset that restored nothing passed. Each check must now come out as it did at seed.
  • A failed or partial apt-get update looked complete to the next start. The update is recorded only when it succeeds, and rerun otherwise.
  • At seed, a witness on a bundle computer refuses a task whose steps or checks differ from the bundle's.
  • A task too large for one command argument (96 KiB) is refused before the export runs.

Known gaps: after_reset compares checks' results, so a near miss failing exactly the seed's checks can't show a reset that restored nothing; the witness record does not yet carry the bundle's file digests.

main is merged in again at b128538c7, now with #8982. ff9c13246 escapes the checkpoint name pattern's hyphen so it compiles in every JS regex mode, as main's advertised-pattern test requires.

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

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The latest cleanup refactor appears safe to merge.

Summary

This PR adds capture, task drafting, export, reset, and recorded task checks on build computers. The latest change groups the saved cleanup error with its release function and checks repeated failures.

  • Build computers can capture an app session and export its task bundle.
  • A fresh computer can show whether an exported task holds up.
  • Build computers can reset apps and wait for the desktop to be ready.
  • Task checks and exported app files now reflect what the captured computer can support.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Capture starting state and edit] --> B[Stop capture and draft task]
  B --> C[Export bundle]
  C --> D[Start fresh computer]
  D --> E[Check starting state, edit, near miss, and reset]
  E --> F[Save record and recording]
  F -->|Saved with handles closed| G[Return saved record]
  F -->|Saved with handles still open| H[Keep error and release function together]
  H -->|Close fails: return same error| H
  H -->|Close succeeds| G
Loading

Reviews (21) · Last reviewed commit: "fix(desktop): keep one published witness..." · Reviewed by Greptile

Comment thread src/domain/desktop/buildWitness.ts Resolved
Comment thread src/desktop/BuildComputerController.ts Resolved
Comment thread bridge/agentenv/capture.py Resolved
Comment thread src/desktop/AgentEnvComputer.ts Resolved
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 5, 2026
Comment thread src/domain/desktop/buildWitness.ts Resolved
Comment thread bridge/agentenv/capture.py Resolved
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	src/application/desktop/DesktopTaskExport.ts
Comment thread src/domain/desktop/seedScrub.ts Resolved
Comment thread src/domain/desktop/viewPointer.ts Resolved
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
…kill

Resolves where morluto#9050's DOCTYPE policy and whole-text checks meet the build
stack's syntax-only XML pass and undecided rule: one saxes pass applies the
DOCTYPE policy, checking an external-id-only declaration against XML 1.0's
grammar so it agrees with the DOM parser; a UTF-16 seed with a plain DOCTYPE
reads as XML like a UTF-8 one; and text checks follow the cut-view rule in
both evaluators (a text_contains match on a cut element stays decided, a
miss or a text_equals there is undecided).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
@earakely-scale
earakely-scale marked this pull request as ready for review November 6, 2026 01:26
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-06T01:26:40.160875Z
We couldn’t complete this review. Comment @codex review to try again.
4fc0424 Draft marked ready
ℹ️ 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.

earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
earakely-scale and others added 3 commits November 5, 2026 20:13
…ld computer

- start_build_capture runs REA's capture inside the computer through a
  small controller over computer-exec, after a user-space apt-get update;
  mark_build_checkpoint returns once the capture confirms the checkpoint;
  stop_build_capture returns the draft between seed and end.
- export_build_environment exports with the requester's task inside the
  computer and fetches the bundle through data/get in bounded batches.
- check_build_task grades a computer's data/get with REA's evaluator and,
  through seed, after_edit, near_miss and after_reset stages, records a
  witness with the action log and the screen recording; act_on_build_computer
  gains reset.
- Capture progress lines carry window, checkpoint and refusal events; apps
  start in the home; a pack script builds the runtime archive; long tools
  send progress notifications.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…se the near-miss reset hole

- A capture whose start answer is lost is stopped at once and kept
  unreleased until the stop is confirmed; a lost checkpoint answer is
  recovered from the capture's own log, and draft and export use the
  checkpoints its Evidence records; stop can be repeated to resume
  reading its result.
- A witness can check its seed again after a failed read, and keeps its
  stages in a saving state until the record is written, so a failed save
  can be retried without reading the app again.
- after_edit and near_miss count only click, drag, scroll, type and key,
  so a reset no longer stands in for the near-miss edit.
- A .deb build keeps its package file for capture and passes its URL to
  export; bundle downloads write each checked file before fetching the
  next; an apt-get update failure reports its exit code and log tail;
  reset sends progress while it waits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd first frames drawn

From the blind Inkscape rebuild:
- Paths in ~/.local/share/Trash get a desktop_trash reason and the
  shared_desktop role, so a file trashed before seed is neither owned nor
  seeded; the export names it in a limitation.
- The keep helper runs with PYTHONDONTWRITEBYTECODE=1, so starting a
  computer from a bundle folder no longer writes __pycache__ into it.
- start_build_computer waits, bounded, until the first frame is not one
  colour before returning it.
From review: a .deb that apt also offers exports from apt, since export
passes --package-url only when the capture says the package must come
from its file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
…s nothing, and tie the witness to its bundle

A review found five gaps.

- Commands in the computer answer only when they end, but fetch stops
  waiting for headers after 300 s. So a slow export, draft or start always
  failed. A command with its own deadline now waits on node:http, bounded
  by that deadline.
- after_reset held whenever some check failed, so a reset that changed
  nothing passed on the near-miss state. Each check must now come out as it
  did at the seed.
- A failed or partial apt-get update left lists that looked complete, so a
  second start skipped the update. The update is now recorded only when it
  succeeds, and rerun otherwise.
- A witness on a bundle computer graded whatever task it was given. Its
  seed stage now refuses a task whose steps or checks differ from the
  bundle's.
- A task too large for one command argument (96 KiB) is refused before the
  export runs, instead of failing with E2BIG in the computer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
The witness doc keeps this branch's synthetic-seed and launch-document
sentences beside morluto#9045's 96 KiB task limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
Both sides' new capture tests are kept, the witness doc gains morluto#9045's
96 KiB task limit, and an import morluto#9045's fix left unused is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/domain/desktop/buildWitness.ts Resolved
Comment thread bridge/agentenv/capture.py Resolved
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
morluto#9045's review fixes meet this branch's settle rule. A witness stage
grades settled results. after_reset then compares them with the seed's,
and the record carries settled, read_cut and the optional remediation.
The bundle tie runs when the seed stage opens. The build computer passes
its bundle path and settle timing to the witness.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
The build computers module keeps this branch's extraPackagesOf import and
drops the BuildRequest type morluto#9045's fix no longer uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale and others added 2 commits November 6, 2026 10:40
…ery JS regex mode

main's advertised-pattern test compiles every input schema pattern in v
mode, which refuses an unescaped hyphen in a character class. The
checkpoint name's hyphen is now escaped, and it means the same in u mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale added a commit to earakely-scale/rea that referenced this pull request Nov 6, 2026
@earakely-scale

Copy link
Copy Markdown
Contributor Author

@morluto this one is ready for review. It builds on main, merges cleanly, and all checks pass.

The description's "Final review round" section lists the main merges and the fixes from an independent review of this PR's diff.

cursoragent and others added 2 commits November 7, 2026 04:12
Keep the build-witness spec beside the XML text-check spec, and keep
cut-view failures undecided while accepting main's whole-text checks.

Co-authored-by: morluto <[email protected]>
…t update

A cancel after data/reset no longer drops the restore from the action log,
so a near miss cannot treat the restored seed as an edit. An unreadable
seed check that later passes leaves after_reset undecided instead of
failing the witness. apt-get update is kept only when Error-Mode reports
success and a package list was fetched. The controller reply schema lives
with the controller, and capture progress lines are read by their domain
parser.
cursor Bot pushed a commit to earakely-scale/rea that referenced this pull request Nov 7, 2026
Bring the reset, seed-comparison and apt-list fixes forward, and keep
morluto#9049's rule that a cut element's text stays undecided.
Comment thread src/domain/desktop/buildWitness.ts Resolved
after_reset stays undecided when any check was not read, even if another
check still fails and the unread result's boolean matches the seed. A
text check for a child past a truncated view is undecided in both
evaluators. A reset whose reply is lost blocks a near miss until a later
input or a reset whose reply arrives.
A recording that fails to end or download is not written into the witness
folder, and a manifest already received is fetched again without ending
the recording twice. A folder that is published while its handles fail to
close keeps that record and retries the same cleanup instead of writing
the folder again.
A second failure to close a published witness returns the original error,
so its record and cleanup lease stay bound. A reset the app itself
refuses is an AppDataRefusal; only a reply that is not that refusal stays
unsettled. A missing child of a cut view is undecided with the same
description in both evaluators, and the shared cases cover it.
A published record and its bound cleanup error stay together. A later close failure returns that error, and the unused path that built a fresh adapter error is gone.
@morluto
morluto merged commit c5301e6 into morluto:main Nov 7, 2026
48 checks passed
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: runtime Process capture and runtime observation enhancement New feature or request labels Nov 22, 2026
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.

3 participants