Repository navigation
feat(environment): build agent environments from a prompt - #6946
Merged
Merged
Conversation
…ent-coverage view A new inspect_analysis_view kind over capture Evidence. It projects the state an environment derives with the given template rules and reports each tool as answered from state, replayed with its view reason, a served write, or a withheld write with its reason, the records behind it and a hint about what to record next. The hints cover every write reason, so a new reason without one fails to compile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rea environment-build <capture> [directory] inspects a HAR (or reads capture Evidence), projects the environment manifest from the in-memory Evidence, authenticates the pair, prepares the state and writes the bundle environment-export writes. Every bundle file is byte-identical to the three-step path for the same capture and options. The report adds the capture and manifest identities, the coverage summary, warnings (a loopback capture named after its file, credential-named body members by pointer) and the next command. --dry-run writes nothing. The default template rules are the four the published environments use. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Domain tests check the hint table against the state view's reasons, the summary, and the view against the environment-state view it summarizes. Service tests build the fixture capture and compare every file with the three-step path, a dry run, loopback naming and the refusals. A CLI test compares a HAR built in one step with the three CLI steps byte for byte, and an MCP test projects the view from every source kind. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ment-build The lane now runs the command users run: it builds the Grafana-shaped HAR with environment-build and the packed checkout, checks the report, then runs the bundle with agent-env as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The agent environments guide opens with the one-step build: the report, the hint for each withheld write reason, and what a bundle ships. The CLI guide, the capture guide and the skill reference name the command and the environment-coverage view. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The credential scan walks with its own stack, so a deeply nested body cannot crash the build, and it also reports credential-named header names, query names, form body members and string arrays. - The build checks SIGINT between stages: cancelled before the bundle stage it writes nothing, during the write it names the written bundle. - A dry run opens the package tarball, so it refuses what a build refuses. - Repeated template rules are refused, a HAR saved as .json gets a hint, file-derived names follow the bundle name rules, `localhost.` counts as a loopback origin, and the next command is shell-quoted. - --capture-timeout-ms passes through to the HAR inspection, and a missing directory is refused before inspection. - The no-observation hint covers updates and deletes of entities the state never held; the coverage view states that it does not apply the serve-time admission checks; the inspect_analysis_view description names the view. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cation The guides now state when the one-step bundle equals the three-step one, which headers inspection excludes, what the credential warning scans, how cancellation behaves, and that the coverage view does not apply the serve-time admission checks. The spec folder records the census, the end to end runs, the gates and the review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e check The manifest, state and coverage stages run synchronously, so a SIGINT that arrived during them was only dispatched once the bundle write had begun. Each check now yields first, so an interrupt before the bundle stage cancels the build with nothing written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The export file read returns permission refusals through Result under the calling operation's name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uest step A capture_browser_scenario step `request` sends one declared HTTP request through the page's own fetch, with its cookies and session, the way the application's frontend would, and reads the whole response so the capture records the transaction like any other. The path must resolve to the start URL's origin, and the page must be on that origin when the step runs. Query values and header values may be literals or declared secrets, and a header may read its value from a cookie or a local storage entry, which is then redacted from later records like a declared secret. `expected_status` fails the step on any other status. Scenarios without a request step are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ilt environment verify:browser:request records a write session against a fixture item API that refuses writes without its CSRF cookie header and stored bearer token. It checks that every request lands in its own step, that the page values authenticated each write and appear in no record, header or body, that an unexpected status fails the step and cancels the rest, and that environment-build serves the recorded create, update and delete. Co-Authored-By: Claude Opus 5.5 <[email protected]>
export_environment_bundle writes the bundle environment-build writes, from capture Evidence retained in the session or one capture Evidence file, into an absolute output directory that must not exist and whose parent must exist, as extract_firmware and export_web_scripts require; it never creates the parent or reuses a directory. It returns the same report, whose schema now lives in the domain so the CLI and the tool share it, and dry_run reports without writing. A loopback capture without a file needs a name. The build's refusal messages no longer name CLI flags. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and serialize Evidence once A browser scenario's retained header values and the query parameters of its recorded URLs are scanned for credential names as a HAR's are, through a review projection of its records. A dry run admits and releases the package tarball through the export's regular-file scope, so a close it cannot confirm keeps its owner, and checks for cancellation after that last await. Evidence is written into one exactly sized buffer instead of chunks joined by a copy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s and the bundle tool Add the environments reference to the skill and install it with setup: record against a disposable instance, sign in through the UI, write with request steps and read each write back, check coverage, re-record by withheld reason and export the bundle. Route it from SKILL.md, name agent environments in the skill description, and document the request step, the export tool and recording writes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…smaller functions Co-Authored-By: Claude Opus 5.5 <[email protected]>
Scenario records keep main's response-body retention map beside the review projection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Coverage of a capture whose records are not all timed, which includes every browser scenario capture, now states that the state learns no clock, so an update stamped with a server-set modification time stays unexplained-change however often it is recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Agents guessed the scenario schema field by field and two hung on steps without timeout_ms. The reference now starts from a complete scenario with a timeout on every step, and says a scenario capture cannot serve updates the application stamps with a modification time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s redacted - Follow no redirects: a redirect fails the step and nothing reaches the location it names (checked in real Chrome), and check the page's origin again in the page as the request is sent. - Send nothing once the step's time has run out or it was cancelled while header values were read; the in-page deadline is what remains of the step's. - Keep every page value redacted under a repeated or colliding label, keep a value's first marker when it is read again, and leave values shorter than 8 characters unredacted rather than rewriting ids, ports and hosts. - Refuse a header name given twice, User-Agent (Chrome drops it) and line breaks in literal values and prefixes; fail before sending when a secret or page value holds them. - Append query entries after the path's literal query without re-encoding it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…als for both surfaces Document redirects, timeouts, page value redaction, HttpOnly cookie sources and header refusals for request steps. Refusals shared by environment-build and export_environment_bundle no longer name CLI flags, and the retained loopback refusal no longer prints an empty file name. The skill reference asks for read-backs after each write, shows the coverage view's source, names package_tarball for unreleased builds and the browser path a scenario ships. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…odies The build's credential scan collapsed form bodies with Object.fromEntries, so a repeated field kept only its last occurrence: `api_key=secret&api_key=` warned about nothing although the Evidence ships the value, and repeated values were undercounted. Form fields are now scanned as ordered name/value pairs, as headers and query strings already are. The review projection of a capture_browser_scenario dropped a request body recorded without a media type, so the scan never saw it. Review keeps such a body's text with an empty media type; the manifest projection still reads only bodies it can classify. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Append query entries correctly after a path ending in "?", "&" or "#". - Refuse 3xx expected statuses, which an unfollowed redirect can never report, and say a redirected write may already have been applied. - Redact a page value also as fetch sends it, without surrounding spaces and tabs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dry runs Document that reading a page value shrinks the bodies a capture keeps under the default allocation limit, that redirected writes may have landed, that the MCP dry_run still checks its output directory and which refusals name the tool, and keep the .har hint in the HAR-as-JSON refusal for both surfaces. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Gates, the real-browser lanes, five environments built from prompts by an agent on disposable VMs and evaluated with two models, and the two reviews. Co-Authored-By: Claude Opus 5.5 <[email protected]>
earakely-scale
marked this pull request as ready for review
October 24, 2026 05:34
Codex Review SummaryThis 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. |
…and scan SaveHar null-text forms The inspected HAR's Evidence and the projected manifest are checked against live heap headroom before they are serialized, with the same check the file route uses, so a capture too large to parse and seal is refused as resource_constraint before anything is written. A request whose postData text is SaveHar's null is scanned by its structured params. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # scripts/verify-agentenv-environment.mjs # src/application/environment/environmentBuildReport.ts
A body counts against the 4 MiB limit by its UTF-8 length, not its UTF-16 code units, so multibyte text over the limit is reported as unscanned instead of parsed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…page reads on the start origin The page receives the step's absolute deadline and a one-second start window, so a busy page that runs the request late, or after the step is cancelled, sends nothing; local storage is read only on the start origin; the response is drained without keeping its body; an unparseable path is a field issue; retained Evidence is refused for heap headroom before it is serialized; and the skill says how to reach server-assigned ids. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…owner The browser request lane runs each CLI call through createPackageVerifierCommands on a private runtime root, so a timeout, output overflow or failure stops the CLI and the browser it launched before the root is removed, and a failed stop is reported with the root retained. The verification record states the lane's current counts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…heir media type A browser scenario's credential scan reads every retained network-content event, including a response attached mid-flight and a transaction no record represents, with event pointers, and each transaction URL's query once; the review record projection it replaces is removed. A body is parsed as a form or as JSON by its recorded media type, falling back to its shape, so valid forms such as `password=x&` are scanned and sentences are not read as forms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Windows owned command keeps main's lazy verifier source import. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
@morluto this is ready for review: CI is green at |
12 of 22 tasks
15 of 22 tasks
3 tasks done
This was referenced Oct 25, 2026
5 of 22 tasks
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An agent asked to build an agent environment of a running web application cannot finish the job through REA's MCP
server today. A browser scenario reaches an application's API only through the UI or a
gotoGET, so recording thewrites an environment serves means scripting every form. No MCP tool writes a bundle, and nothing tells the agent how to
record a session the state can learn writes from, or when to stop. This PR adds:
requestscenario action: one same-origin HTTP request sent through the page's ownfetch, so a scenario cansign in through the UI and then call the application's API, writes included. Header values can be declared secrets
or values the page holds (a CSRF cookie, a stored bearer token), and those are redacted from later records.
export_environment_bundleMCP tool: the bundlerea environment-buildwrites, from retained captureEvidence or an Evidence file, into an absent absolute directory, with the same report.
references/environments.md: how to go from a prompt to a bundle. Map the app, record with atimeout on every step, read every write back, check coverage, re-record or stop by the withheld reason, export and
hand off.
With that, Claude Code built and exported five environments from one-paragraph prompts. Each took about 2–7 minutes.
All five bundles start and answer retrieval tasks; 3 of the 5 also serve writes, and their write tasks pass with two
models.
Stacked on #6929 (
feat/environment-build): the commits aftereeab0bdaare this PR's(compare). Part of
#4933.
Problem and expected behavior
session's cookies and the headers the frontend sends. It must stay confined to the start URL's origin, and keep the
values it reads out of the Evidence.
It must never touch data the user did not offer, nor loop on gaps that re-recording cannot close.
Change and scope
requestaction (src/domain/browserScenarioValues.ts,browserScenario.ts,src/browser/PlaywrightScenarioRequest.ts):GET/HEAD/POST/PUT/PATCH/DELETE, a path that must resolve to the start origin, queryentries, headers and a JSON body.
with an optional prefix.
expected_statusfails the step on any other status; 3xx statuses are refused.fetchcannot set,User-Agent, a repeated header name, and line breaks.sent. A value read again keeps its first marker. Values shorter than 8 characters are not redacted, so ids and ports
survive.
src/contracts/environmentToolContracts.ts,src/domain/environmentBundleExport.ts,src/application/environment/environmentBundleTool.ts):--format jsonwrites it, so the bundle is byte-identical toenvironment-build's;environment-buildfor CLI parity and registered in the product catalog.scenario capture is untimed, so an update the application stamps with a modification time is withheld however often
it is recorded.
references/environments.mdis installed by setup and routed from SKILL.md;docs/browser-scenario-contract.md), recording writes and the MCP tool(
docs/agent-environments.md), and the spec folderdocs/specs/agent-environments/environment-prompt/.npm run verify:browser:requestdrives a real Chrome through a CSRF-and-bearer item API, builds theenvironment, and checks redaction, failure on an unexpected status, and redirect confinement.
Not included:
today);
Scope decision pending:
requestlets a scenario change application state without a user gesture. CONTRIBUTING asksfor a maintainer decision on target mutation, and the scenario-capture spec named a fetch action as a non-goal needing
one. The step is confined to the start origin, the docs and skill require a disposable instance, and the skill asks
before any scenario that writes.
Size: about 2,500 lines (870 source, 1,200 tests and the lane, 460 docs). It splits cleanly if preferred: the
requestaction with its lane and contract docs, then the MCP tool, coverage line and skill.Contract and boundary impact
src/domain,src/browser);src/application/environment);boundary. The
requestaction needs the maintainer decision above (pending).capture_browser_scenarioandcapture-browser-scenarioaccept therequestaction;export_environment_bundle, the CLI alias ofenvironment-build;capture_browser_scenariodescription names the action.the request runs in the user's page.
requeststeps and their events;[REDACTED:page:<step>.<header>];start origin with the session's cookies, and write methods change the application's data. Cleanup is unchanged.
version 47 (
src/generatedPackageMetadata.ts).Expected effects:
Evidence and regression coverage
Environments from a prompt. Five applications were seeded fresh on disposable Ubuntu VMs, loopback only. Claude Code
2.1.310 (
claude-sonnet-5-5) had this branch's packed CLI, registered withrea setup --client claude_code. Each run gotone prompt: build an agent environment of the app at this URL covering these entities; the instance is disposable, but
leave the seeded data; the user, the password variable, the Chromium path and the output folder. The prompt did not
mention the skill. Bash and web tools were disabled.
Each bundle was then rebuilt from its own
evidence.jsonwith this branch's tarball;manifest.jsonandevidence.jsonwere byte-identical to the agent's. It then ran its smoke task, a retrieval eval generated from the bundle, and the
application's recorded write eval with
fireworks_ai/gpt-oss-120bandfireworks_ai/glm-5p3-flash, one run per task.* The Directus eval's count check expects exactly the 2 provisions the scripted recording read. The agent read all 5,
so the raw eval is 0/2 even though every field check passes. With counts relative to the state, it is 2/2.
read more (11–39 state-backed reads) and serve 7, 3, 2, 2 and 0 writes. The prompted ones serve 0, 6, 0, 5 and 1.
Linkding's scripted HAR serves the same PATCH with a clock rule.
timeout_ms. The skill now starts from a whole scenario with a timeout onevery step.
Reviews. Two independent reviews tried to refute the change; everything below is now fixed and tested.
Round 1 found:
User-Agentdropped silently;Round 2 confirmed those fixes and found:
?or#, 3xx statuses that cannot match, and padded values escaping redaction(fixed);
Tests added or updated:
verify:browser:request.Base reproduction or other evidence: see above. The redirect case is checked against the server, which never
receives the cross-origin request.
User-visible CLI/MCP output:
{"step_id": "create-1", "action": "request", "method": "POST", "path": "/api/objects/products", "json": {...}, "expected_status": [200], "timeout_ms": 15000};environment-build's (status,coverage.reads,coverage.writes.served/withheldwithhints,
warnings,next).Remaining proof gaps:
[email protected]has noenvironment-serve, so a bundle exported from an unreleased build needspackage_tarballuntil the next release (pre-existing).For evidence-bearing changes:
Validation performed
Run on macOS with Node v24.22.1 at
c67f57f8(the merge ofeeab0bdaplus this PR).npm run -s typecheck,lint,format:check,docs:check,mcp-catalog:check,verify:test-discoveryandnpx knip: passed.npx vitest run --project domain --project services --project adapters: 16,347 passed, 1 failed ("stops Inspectortarget authorization after the current stat settles"). It fails the same way on the base
fce1aba8here (16,326passed, 2 failed).
passed;
npm run -s verify:browser:requestandnpm run -s verify:browser:network: passed in real Chrome.npm run -s verify:browserstops at "Real Chrome stable capture identities did not reconcile" (aninspect_web_pagecomparison) identically on the base.
After merging #6929 at
53a03c06(maind87e73f2) intoac4d88aa, with no conflicts, on macOS with Node v24.22.1 and main's locked dependencies:npm run jscpd: 3.58%);npx vitest run --project domain --project services: 9793 passed, 6 skipped, none failed; the environment boundary projects: 107 passed.src/browser/PlaywrightScenarioRequest.test.ts: 16 passed.npm run verify:browser:requestwith Chrome: 22 request steps, 7 authenticated writes, 3 served writes (delete_items_by_id,post_items,put_items_by_id), verified.CI on
ac4d88aafound two regressions from this branch, fixed ate80e89ef:b1e6652a: the environments reference makes the packaged skill eight files, sosetupSkillPublication.test.tsderives its rollback counts fromMANAGED_SKILL_FILESinstead of fixing them at six and seven.e80e89ef: an earlier merge's lint autofix had unescaped the hyphens injavaFloatValuePattern(src/domain/adb/adbDeviceAnalysis.ts), which no v-mode JS regex accepts, failingadvertisedPatternsVMode; the file now matches main. No other file differs from main through a merge alone.npm run -s check:fast,format:check,docs:check,mcp-catalog:checkandnpx knippassed; the MCP boundary project: 1386 passed; the skill boundaries: 30 passed.At
2718c6e1: CI one80e89effound one more regression, fixed ina53d320e: the request step example indocs/browser-scenario-contract.mdstood alone, but every JSON example there must parse as a wholecapture_browser_scenarioinput, so it now sits in a launch scenario. #6929 at74f7ad28is merged with no conflicts and no file changed by the merge alone.npm run -s check:fastpasses;src/application/environment,src/domain/analysisViewand the request step tests: 1273 passed. Run locally against maind87e73f2, the boundary, CLI-boundary, process-boundary and acceptance projects fail no test main passes, except two release tests that readnode_modulesthrough this worktree's symlink and one worker-order timing test.At
6fa1635e(#6929 at98fe6deamerged): seven review findings fixed in814ffa94with #6929's headroom check: the page sends a request step only before its absolute deadline and within a one-second start window, so a busy page that starts it after cancellation sends nothing; local storage is read only on the start origin; the response is drained without keeping its body; an unparseable path is a field issue; retained Evidence is refused for heap headroom before serialization; and the skill says how to reach server-assigned ids. Each new test failed before the fix. Static checks (includingmcp-catalog:check) pass;npx vitest run --project domain --project services(excludingjavascriptSemanticAnalysis.reference_lifetimes.test.ts, whose worker crashes on main too): 9923 passed; the bundle MCP, product catalog, tool schema, v-mode pattern, skill and build boundaries pass;npm run verify:browser:requestwith Chrome verifies 22 request steps and 3 served writes. A request the page starts within that second of the hand-over can still be sent after cancellation; closing that needs network-level interception.At
558ff76f(morluto's0ad86117, then main2250e67b): three review findings fixed.ffe82bbfruns the browser request lane under the shared verifier command owner, so a failed or timed-out run stops the CLI and the browser it launched before its private root is removed.558ff76fscans a browser scenario's credentials by event, including a response attached mid-flight and an unattributable transaction (pointers now readevent N …), and picks the form or JSON parser by the recorded media type, so valid forms such aspassword=x&are scanned and sentences are not. Each new test failed before its fix. On macOS with Node v24.22.1: the static checks pass, includingmcp-catalog:check;npx vitest run --project domain --project servicespasses (9940, excludingjavascriptSemanticAnalysis.reference_lifetimes.test.ts, whose worker crashes on main too); the bundle MCP, catalog, schema, v-mode, skill, build, export, headroom and verifier-ownership boundaries pass (74);verify:browser:requestwith Chrome verifies; and all 54 bundles stay byte-identical to the three-step path's, with unchanged warnings. CI's failing tests arepackedBridgeVerification.test.ts, which mainbe2811e4fails the same way.At
378a7177, after merging maind361c53c(which carries #6897; one conflict,scripts/lib/windows-owned-command.mjs, takes main's lazy verifier source import, and no other file differs from main except this branch's own):runnerCancellation.test.ts, which failed on558ff76f's CI and locally, passes with main's fix;npm run -s check:fast, format, knip, docs,mcp-catalog:checkand test discovery pass; the environment, analysis-view, browser and CLI tests pass (2560) and the focused boundaries pass (75);verify:browser:requestverifies; and all 54 bundles stay byte-identical to the three-step path's (78 served writes with main's write rules).Compatibility, safety, and release
(end to end).
Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.🤖 Generated with Claude Code