Repository navigation
feat(environment): build environments from browser scenario captures - #5182
Merged
gensokyo-dev merged 111 commits intoOct 19, 2026
Merged
gensokyo-dev merged 111 commits into
gensokyo-dev merged 111 commits into
Conversation
Add rea mcp --http [--host] [--port]: the same server rea speaks over stdio, served over MCP Streamable HTTP on a loopback listener by default, using the SDK's web-standard transport already in the pinned @modelcontextprotocol/server behind a small node:http bridge. One client and one session at a time; DELETE ends the session without running provider teardown, a new client's initialize replaces a session left open, foreign Host headers are refused on loopback binds, and shutdown is signals-only. Stdio stays the default and registered transport; server.json and client registrations are unchanged. Refs morluto#4933 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…nd shutdown Addresses the automated review findings on the PR: refuse requests once the session slot is closed and join an arming initialize during shutdown; retry failed close stages instead of replaying the rejection; classify loopback binds by address class and add the bind's own hostname to the Host and Origin allowlist; let only a POST with the streamable headers replace an open session; announce the bound URL at every log level; route `mcp -h --http` to the HTTP entry. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…server Addresses the second automated review round: a sessionless POST replaces a session only when its media type proper is application/json, and the server instance is created after the listener binds so a bind failure leaves nothing to clean up and a factory failure releases the listener. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ailures out of onerror Addresses the third automated review round: loopback is classified from the address the listener bound with the configured name added to the Host and Origin allowlist; scoped IPv6 literals are refused before binding and a URL that cannot be formed closes the listener; listener errors reach onerror only after a successful bind; the MCP runtime keeps its factory owner as the single owner of instance cleanup through `closeInstance: false`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…wn failed Addresses the fourth automated review round: a sessionless POST replaces a session only when its Accept header lists application/json and text/event-stream as exact media ranges, and a session whose transport shutdown rejected stays owned so the next close retries it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Replaces a comma expression left by the previous commit with plain statements and moves the port release into a small function, so the listener body stays within the lint limits without changing behaviour. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…and keep every Set-Cookie Addresses the fifth automated review round: the instance's shutdown hook runs exactly once even when the listener closes without a live session; the initialize probe no longer awaits cancelling its cloned body, which would wait for the original request to drain; and the node:http bridge passes repeated Set-Cookie values through as an array. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…cleanup Addresses the sixth automated review finding: SIGINT and SIGTERM are recorded from the moment the HTTP entry starts, the lifecycle owner acts on a recorded signal as soon as it registers, and a second signal during startup exits at once. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…mal return Addresses the follow-on finding on the signal latch: the HTTP entry now owns its exit status, so a 0 returned by startup after a recorded signal keeps the signal's 130 or 143 while a real failure still wins; a process test sends the signal as the listening line appears. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… read Addresses the eighth automated review finding: a refused Host or Origin, an unknown route or the startup 503 answered a POST while its body stayed unread on the paused bridged stream; such replies now carry Connection: close so an unread upload cannot keep a socket open. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…d body Addresses the ninth automated review round: a method Fetch refuses, such as TRACE, is answered with 405 instead of escaping the request guard; the unread-body decision now comes from the incoming message's own body declaration, so a GET or HEAD carrying a body closes too; and the regression uses a keep-alive client and checks that the socket actually closes. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Picks up upstream's test-runner configuration and the command-finalization test fixes so the fork lane stops failing on unrelated flaky shards. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…d keep failed hooks retryable Addresses the tenth automated review round: the bridge joins an origin-form request target onto the listener's origin so a network-path target stays a path and absolute-form targets are refused; only a lone initialize can replace an open session; and the shutdown hook records completion only after it returns, so a hook that threw stays eligible for the next close. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Addresses the eleventh automated review finding: dot segments such as `/public/../mcp` were canonicalized to `/mcp` before routing. The bridge now refuses any target whose path differs after parsing, so routing sees exactly the path the client sent. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…regression The previous commit added a second successful route call to the regression but left the single-observation assertion in place. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…to its end Addresses the twelfth automated review finding: bodyUsed only means a body was disturbed, so a route that read one chunk of an upload left the rest paused on a keep-alive socket. The close decision now follows the incoming message's end of stream. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…uard Addresses a thirteenth automated review finding: `application/json;q=0` explicitly refuses JSON, so it no longer counts toward the exact Accept ranges a session takeover requires. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eners A browser on the listener's own page sends Origin with the scheme and the bound port. The SDK validator parses the Origin and compares its hostname with the loopback allowlist, so the port never takes part; this test keeps that true for the MCP endpoint and for composed routes, under 127.0.0.1 and localhost. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the merged environment manifest view so this branch is tested against current main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
closeAllConnections() ran before close(), so a connection accepted in between missed the forced-close pass and close() could wait for its request timeout. close() now starts first and closeAllConnections() follows immediately, as Node documents. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A route answering HEAD with a body, such as a reused event stream, was piped until EOF although Node discards the bytes, so an endless stream held the request open. A HEAD reply now ends after the headers and cancels whatever body the route attached. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… takeover A comma or semicolon inside a quoted parameter is not a separator, so a header such as application/json;note=", text/event-stream;x=1" holds a single range. The takeover guard split on every comma and found a text/event-stream range the client never sent. Ranges and their parameters are now split outside quoted strings, and q is read from the parsed parameters. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cancelling one branch of a teed body settles only after its sibling is consumed or cancelled, so a HEAD route answering with a clone of a live cached stream left the request handler pending indefinitely. The reply ends after the headers and the cancellation is started, not awaited. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing body cancellation Readable.fromWeb destroys its source on a client disconnect and waits for the body's cancel(), which for one branch of a teed body settles only when the sibling is consumed or cancelled, so the pipeline never returned. The body is now copied chunk by chunk with backpressure; when the reply closes the copy returns and the cancellation is started, not awaited. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sed before the route resolved The copy raced every read against one pending close promise, which piled up reactions on long streams, and it only noticed a close that happened after it started, so a route resolving after its client left waited forever on an idle body. One close listener now cancels the reader, which also ends a pending read; a reply that is already destroyed cancels at once; drain waits remove their listeners. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… session takeover Media types are case-insensitive in HTTP, so the takeover guard compared them lower-cased, but the SDK's transport matches Accept as a case-sensitive substring. A header such as Application/JSON passed the guard, closed the live session, and then got 406 from the SDK. The guard now also requires the SDK's Accept substrings and uses its exported isJsonContentType, so it only replaces a session the SDK will accept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ment bundle Add rea environment-export <manifest.json> --evidence <capture.json> <dir> [--package-tarball <path>] [--name <override>]: it reads and authenticates the manifest and capture pair once and writes an agent environment bundle folder (README with provenance and a rights note, envs/<name> with a Dockerfile that pins this exact rea version or installs a given tarball, the manifest and the Evidence as byte-identical copies, a Python verifier that checks replay through the MCP endpoint, and a smoke task) that the agentenv framework runs with agent-env run. Refuses a non-empty directory and a mismatched pair before writing. Adds the real-agentenv hosted lane, which packs the checkout, exports a bundle from the source-owned capture fixture and runs it on the runner's Docker with a pinned agentenv-framework, wired into the CI planner and its guard tests. Refs morluto#4933 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…f counting it as a leak The first hosted run of the real-agentenv lane failed only on the cleanup check: agent-env's local image store starts a registry:2 helper (`agentenv-registry[-<port>]`) on first use and keeps it running across runs, so a fresh runner ends the run with one more container than it started with. The verifier now lists containers with their names, reports that helper under `image_store_helpers` and asserts that nothing else was added. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Add rea environment-serve <manifest.json> --evidence <capture.json> [--host] [--port]: it loads an environment-manifest view and the capture Evidence it was projected from, refuses a manifest whose parent evidence id does not match the capture, builds one MCP tool per manifest tool and serves them over streamable HTTP beside an environment card at /.well-known/agent-env.json and a data plane at /agentenv that refuses every method. Each tool call replays the retained record whose path and query values best match the arguments, cites the record ordinal and evidence id, marks replayed content as untrusted target content, and truncates bodies over 256 KiB with a flag. Nothing executes the captured application. Refs morluto#4933 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…erifier's run The pattern was a `const` below the top-level try block, so the leak filter reached it in the temporal dead zone the first time a run actually created the helper; locally no container was new, so the filter never ran. Reproduced the fresh-host path by removing the local `agentenv-registry` before a run. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Merged
11 tasks done
# Conflicts: # docs/agent-environments.md # docs/cli.md # docs/specs/agent-environments/environment-serve/spec.md # src/application/environment/environmentReplay.test.ts # src/application/environment/environmentReplay.ts # src/application/environment/environmentSource.ts # src/application/environment/environmentTools.test.ts # src/application/environment/environmentTools.ts # src/cli/environmentCommands.ts # src/cliCommandNames.ts # src/server/environment/serveEnvironment.test.ts # src/server/environment/serveEnvironment.ts # tests/boundary/cli/cliStartupImports.test.ts # tests/boundary/cli/environmentServeCli.test.ts # tests/boundary/process/environmentServeShutdown.test.ts # tests/fixtures/environmentServe.ts
…t export The serve change now loads environmentSource lazily so CLI startup never imports it; the export command does the same, and the unused static import is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ows device names Export's headroom check reserved one native parse per input, while the raw parse, its authenticated Evidence copy and the schema copy of its result are live together while the pair loads; it now reserves all three, so a file near the heap limit is refused as a resource constraint rather than exhausting the heap. A bundle name that Windows reserves as a device name (con, prn, aux, nul, com1-com9, lpt1-lpt9) is refused while planning, before any file is written, since the env folder could not be created there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…ehave A response body that redaction emptied, because a declared secret could not be cut out, was replayed as an empty reply; it is now treated as not retained. Bodies that kept redaction markers are counted in a manifest limitation, since their tools replay the redacted bytes. The no-body limitation counted transactions no tool can cite and said their tools replay status and content type, which a failed request does not have; it now counts records with a usable request line and says either value may be absent. The tool contract and capture docs now say a scenario parent relies on capture-time redaction instead of the sensitive-values refusal, the MCP contract page lists scenario parents for environment-manifest, and a scenario parent asked for another view is told the one it supports. The browser scenario example raised max_network_body_bytes alone, but the allocation budgets drop a body far below 256 KiB; it now raises them and says how body and event budgets differ. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 tasks done
kangyishuai
pushed a commit
to kangyishuai/rea
that referenced
this pull request
Oct 19, 2026
…ansition-view Main's morluto#5182 builds environment manifests from capture_browser_scenario parents. Keep both view paths: environment-manifest views still route to main's projector first, and this branch's projector serves summary and browser-scenario views for the same parents. The tool description keeps both sides' text, and the projector's refusal now names all three supported views. Main's "supports only the environment-manifest view" fallback can no longer be reached, so the generic message stays. Make main's hand-built scenario fixture match what the recorder emits, so it passes this branch's capture invariants. Step 0 is the implicit start navigation. Step 1 is the declared wait_for_timeout and receives every event. Content events exist only for selected body facets. The recorded scenario declares the capture's event, network and artifact selection. Main's refusal test now expects the summary view to succeed and checks that an unsupported view names the supported ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 of 22 tasks
earakely-scale
added a commit
to earakely-scale/rea
that referenced
this pull request
Oct 19, 2026
Brings in the environment export (morluto#4999) and scenario capture (morluto#5182) merges. The one conflict, the inspect_analysis_view contract text, keeps both insertions: main's sentence on scenario parents and this branch's evidence-file source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
29 tasks
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.
Change
environment-manifest,environment-serveandenvironment-exportacceptcapture_browser_scenarioEvidence alongside HAR Evidence. A browser session captured directly by REA becomes a replay environment through the existing commands. Transactions keep request-order ordinals and source pointers; redacted URLs and ambiguous links remain unrepresented. Refs #4933.This original PR includes main after #4955/#4975/#4999 and the author’s subsequent redaction/body-budget corrections. Followups reserve copied/transformed text before validation or decoding, omit request text from replay projection, preserve exact response bytes and cleanup ownership, normalize portable Windows test inventories, select dependent CI lanes, and count body coverage over represented requests. Marker-bearing bodies replay their redacted bytes; bodies emptied by redaction remain unavailable. No new action/tool/dependency. Default MCP remains stdio; environment HTTP is explicit.
Validation
Final head
cbd45eb72, Linux x64, Node 24.18.0 / npm 11.16.0:docs/specs/agent-environments/scenario-capture/verification.md.resource_constraintbefore decoding. No OOM induced; the existing 96 MiB projection budget remains.agent-env 0.9.1334, ran that actual scenario bundle, passed its three-tool smoke task, tore down the sandbox, and reported no new containers or supervised descendants: 131.648 s / 80.938 s CPU / 375.98 MiB. Framework infrastructure/base-image layers were prepared.Heavy tasks run serially on one CPU/worker; standalone Docker build/runtime limits are 4/2 GiB. Final static gate: 321.822 s / 308.573 s CPU / 4529.34 MiB family RSS. RSS sums sampled descendants and may double-count shared pages; Docker daemon/container CPU and peaks and agent tokens are unmeasured. Matched source projection samples preserve the result digest and do not establish a general speed/memory improvement.
Scope: historical response replay without application-state reconstruction. The checkout package was tested; the published package, Windows/macOS execution and the author’s five-application/model runs are not claimed as this followup’s verification. Initial probe/setup failures and missing-body observations are explicitly recorded in the verification document. Original initial readiness is preserved below.
Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.🤖 Generated with Claude Code