Skip to content

feat(environment): discriminate multiplexed POST RPC operations in manifest and replay - #9204

Open
saariuslystoned wants to merge 20 commits into
morluto:mainfrom
saariuslystoned:feat/multiplexed-post-rpc-agentenv
Open

saariuslystoned wants to merge 20 commits into
morluto:mainfrom
saariuslystoned:feat/multiplexed-post-rpc-agentenv

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Discriminate multiplexed single-path HTTP POST RPC operations—GraphQL (operationName), JSON-RPC 2.0 / MCP (method), and Google batchexecute (f.req / single rpcids with XSSI-guarded )]}' JSON responses)—across AgentEnv manifest accumulation, state partitioning, replay tool matching, and live/recorded environment comparison.

Previously, EnvironmentManifestAccumulator, EnvironmentStateAccumulator, environmentReplay, and environmentCompare grouped HTTP exchanges solely by (method, pathTemplate) and required raw isJsonLike response bodies, collapsing distinct RPC operations on a shared POST endpoint into a single tool and replay bucket while excluding XSSI-prefixed batchexecute responses served as text/plain or application/x-javascript. No existing upstream issue is linked; this addresses a concrete capture-to-AgentEnv fidelity gap on multiplexed RPC endpoints.

Problem and expected behavior

Modern web applications frequently multiplex unrelated read and write operations onto one POST path:

  1. GraphQL over HTTP (POST /graphql or POST /api/.../graphql with JSON body {"operationName":"GetViewer","query":"..."}).
  2. JSON-RPC 2.0 / MCP over HTTP (POST /rpc or POST /mcp with JSON body {"jsonrpc":"2.0","method":"tools/list","id":1}).
  3. Google batchexecute RPCs (POST /_/.../data/batchexecute with application/x-www-form-urlencoded f.req=[[["RpcMethodId","...",null,"generic"]]] or single rpcids=RpcMethodId, returning )]}'\n-prefixed or length-framed JSON payloads).

Expected observable behavior:

  • When two or more distinct groups share an equal or overlapping POST path_template, unambiguous RPC operations produce distinct manifest tools with deterministic snake_case names (appending tokenized operation words before _by_<params>), carry optional rpc_operation: { kind, name } metadata on each discriminated tool, keep query-identified batchexecute operations separated even when include_query_parameter_names is false, and still participate in path-segment templating ({param}) within the same RPC operation; non-overlapping single-operation (POST, pathTemplate) routes keep their pre-existing tool name and omit rpc_operation while still participating in read-only RPC state classification and advertising string-or-object body inputs for batchexecute form payloads.
  • Read-like vs. mutation-like RPC operations partition into separate EnvironmentStateAccumulator buckets (state.views with reason: "query-body" vs. state.writes) instead of colliding on one route key, including single-operation read-only RPC routes and multi-operation / fragment-bearing GraphQL documents where operationName selects either a query or mutation definition.
  • XSSI-prefixed ()]}'\n / )]}',\n) JSON (including guarded null) and length-framed batchexecute responses within the 64 KiB UTF-8 XSSI limit on non-JSON-like JavaScript/empty media types (and up to 256 KiB on JSON-like media types) are retained and parsed consistently across manifest eligibility, state extraction, replay, and probe origin/body comparison.
  • Incoming POST requests in matchReplayTool / environmentCompare evaluate selectRpcOperationFromText against the same bounded 64 KiB raw UTF-8 wire bodyText as manifest accumulation across fitting POST templates (breaking specificity ties by literal segment count) and dispatch only to the matching rpc_operation tool on multiplexed paths (refusing unrecorded operations on discriminated endpoints rather than cross-dispatching), while ordinary REST POST routes, single-operation POST routes, anonymous GraphQL queries, malformed payloads, >64 KiB raw wire bodies (even when compact JSON would be smaller), and mixed multi-operation batches (including percent-encoded f%2Ereq form fields) preserve existing (method, pathTemplate) behavior.
  • Saved bundles built before rpc_operation existed preserve state derivation and confirmed REST writes via non-discriminated fallback in deriveEnvironmentState.

Change and scope

Follow the contribution scope.
Not applicable for a maintainer scope decision: this change operates strictly on already-captured network exchange data and local AgentEnv manifest/state/replay projection within existing boundaries, introducing no new provider, process execution, injection, target mutation, or protection recovery.

Chosen approach:

  • Added a pure, bounded domain helper src/domain/analysisView/rpcOperationSelector.ts (zero regex backtracking, strict 1..128 char operation name limit, 64 KiB UTF-8 request body and non-JSON-like XSSI response cap, 8 KiB query string cap, URLSearchParams decoding for percent-encoded f.req / rpcids fields) plus XSSI guard detection and bounded JSON/frame parsing.
  • Threaded optional rpcOperation (rpc_operation in environmentManifestSchema.ts) through EnvironmentManifestAccumulator (reading raw query strings for /batchexecute independently of include_query_parameter_names), environmentManifestRules.ts (ToolGroup merging and sibling-variance/pair rebucketing keys), and environmentManifestNames.ts (deterministic tool naming and sort order).
  • Threaded rpc_operation, bounded XSSI body parsing, and pre-RPC manifest compatibility (discriminateRpc = false fallback in deriveEnvironmentState alongside writes/origin checks in stateMismatch) through EnvironmentStateAccumulator, environmentState.ts, environmentStateRules.ts, and environmentStateQueryCalls.ts (linear lexical scanning of top-level GraphQL query vs. mutation/subscription definitions skipping fragment headers).
  • Added matchReplayTool in src/application/environment/environmentReplay.ts and wired environmentCompareMatch.ts, environmentCompareProbe.ts, environmentSource.ts, and environmentTools.ts (toolDescription RPC annotation and { oneOf: [{ type: "string" }, { type: "object" }] } body input schema for batchexecute form-urlencoded tools), and updated owning docs in docs/guides/web/web-network-captures.md and docs/agent-environments.md.
  • Intentionally out of scope: splitting heterogeneous multi-operation JSON-RPC batch arrays or multi-ID batchexecute envelopes into synthetic sub-exchanges (ambiguous batches safely fall back to undefined).

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/analysisView/rpcOperationSelector.ts owns bounded RPC operation discrimination and XSSI JSON parsing; EnvironmentManifestAccumulator and EnvironmentStateAccumulator are the earliest changed domain stages, consumed by environmentSource, environmentState, environmentReplay, environmentTools, and environmentCompare.
  • Contribution scope fit and linked maintainer decision: not applicable (existing network-capture analysis-view and AgentEnv replay boundary).
  • CLI and MCP/tool-catalog contract: additive optional rpc_operation?: { kind: "graphql" | "json-rpc" | "batchexecute"; name: string } field on environment-manifest tool entries; generated AgentEnv MCP tool descriptions include (graphql "<name>") / (json-rpc "<name>") / (batchexecute "<name>"), and batchexecute tools accept string or object body inputs. Owning documentation in docs/guides/web/web-network-captures.md and docs/agent-environments.md is updated accordingly. Top-level REA CLI commands and static MCP tool catalog entries are unchanged (npm run mcp-catalog:check and npm run docs:check pass).
  • Provider, bridge, target-format, or platform compatibility: none; operates on standard HAR / web network capture records across all platforms.
  • Evidence, artifact, provenance, or reconstruction contract: preserves record_ordinals, evidenceId, status codes, excluded exchange accounting, and replay provenance; pre-existing saved manifests without rpc_operation continue to derive state, confirm REST writes, and replay identically to main.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none (npm run metadata:check, npm run mcp-catalog:check, and npm run docs:check pass with zero generated catalog drift).

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

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

Evidence and regression coverage

  • Tests added or updated (executed with synthetic fixtures):
    • src/domain/analysisView/rpcOperationSelector.test.ts: unit coverage for GraphQL (operationName with query, persisted-query extensions, and /graphql paths), JSON-RPC 2.0 method discrimination, Google batchexecute f.req (including percent-encoded f%2Ereq mixed-batch non-fallback) and single-rpcids extraction, fallback cases, raw-wire >64 KiB UTF-8 byte limits, and XSSI )]}' direct (null, objects, arrays) + length-framed response parsing and 64 KiB eligibility bounds.
    • src/domain/analysisView/EnvironmentManifestAccumulator.test.ts & src/domain/analysisView/environmentStateQueryCalls.test.ts: verifies distinct manifest tools and rpc_operation metadata when 2+ groups share an equal or overlapping POST path_template (e.g., /api/orgs/org-1/graphql vs. /api/orgs/{org_id}/graphql), unchanged pre-existing tool names (rpc_operation: undefined) on non-overlapping single-operation POST routes, query-only batchexecute separation when include_query_parameter_names is false, {org_id} sibling-variance path templating within an RPC operation, XSSI response retention, and read vs. write partitioning in EnvironmentStateAccumulator (including single-operation read-only RPC routes, persisted GraphQL GetViewer vs. UpdateProfile / Viewer classification when body.query is absent, and shared multi-operation / keyword-named fragment GraphQL documents).
    • src/application/environment/environmentState.test.ts, src/application/environment/environmentTools.test.ts, & src/application/environment/environmentReplay.test.ts: verifies saved pre-RPC manifest state compatibility (preserving derived state and confirmed REST writes even when the capture also contains XSSI endpoints), single-operation batchexecute string-or-object body schema generation, end-to-end manifest projection -> environmentServeSource -> matchReplayTool + replayEnvironmentTool across equal and overlapping GraphQL templates, unrecorded operation rejection, pretty-printed >64 KiB wire-body fallback parity, JSON-RPC tools/list vs. tools/call, XSSI-framed batchexecute, and unchanged ordinary REST / single-operation POST routes.
    • src/application/environment/environmentCompare.test.ts: verifies compareEnvironment matches live GraphQL (including overlapping literal + {org_id} templates), JSON-RPC 2.0 (including pretty-printed >64 KiB raw-wire request parity), single-operation RPC routes (including single-operation batchexecute form payloads), and XSSI batchexecute probes (including >64 KiB XSSI origin-selection parity) without cross-tool or cross-origin mismatches.
  • Base reproduction or other evidence: on main, feeding multiple GraphQL operationName calls on /graphql or JSON-RPC methods on /rpc into EnvironmentManifestAccumulator produces a single post_graphql / post_rpc tool, and batchexecute application/x-javascript )]}'\n responses are excluded as non-json.
  • User-visible CLI/MCP output (if applicable): AgentEnv environment-manifest tools emit name values such as post_graphql_get_viewer, post_rpc_tools_list, and post_appui_data_batchexecute_get_items alongside rpc_operation: { kind, name }.
  • Remaining proof gaps: validated on macOS arm64 across synthetic HAR/capture fixtures and a live Google Chrome 156.0.8078.80 capture_browser_scenario -> export_environment_bundle -> rea environment-serve (stateful and --replay-only) round-trip; Linux/Windows CI matrix runners execute on push.

For evidence-bearing changes:

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

Validation performed

  • npx vitest run src/domain/analysisView/ src/application/environment/ src/application/analysisView/ src/server/environment/ tests/boundary/cli/environmentCompareCli.test.ts tests/boundary/mcp/environmentServeWritesMcp.test.ts — passed (116 test files passed, 2345 tests passed).
  • npx oxfmt --check . — passed (7120 files checked, all formatted).
  • npm run check:fast — passed (typecheck and lint: 2 successful tasks, 0 errors).
  • npm run verify:architecture-guards — passed (2520 source files checked).
  • npm run verify:test-discovery — passed (3158 test files discovered once).
  • npm run scan:todos — passed (No tech-debt markers found).
  • npm run jscpd — passed (5803 files checked, within threshold).
  • npm run knip — passed (Knip found no issues).
  • npm run knip:production — passed (0 errors; 0 advisory candidates in touched files).
  • npm run lint:typed — passed (6587 files, 0 errors).
  • npm run metadata:check — passed (exit 0).
  • npm run mcp-catalog:check — passed (4 successful tasks, exit 0).
  • npm run docs:check — passed (6 successful tasks + tests/conformance/readmeConsistency.test.ts 9/9 passed).
  • Trial merge with main (08637b0c2) + multi-Node matrix (v22.23.4, v24.22.2, v26.13.0): clean merge (0 conflicts), npm run check:fast passed, and all 7 changed test files (200/200 tests) passed across Node v22.23.4, v24.22.2, and v26.13.0; mutation probe on rpcCallReadsOnly (case "absent") failed the 2 persisted-GraphQL tests in environmentStateQueryCalls.test.ts as expected before restore.
  • Live Google Chrome 156.0.8078.80 capture_browser_scenario -> export_environment_bundle -> rea environment-serve HTTP MCP verification (v24.22.2): exported 9 manifest tools across REST, declared GraphQL query/mutation, persisted GraphQL query (without body.query), JSON-RPC 2.0 read/write, single-ID XSSI batchexecute, and unsplit multi-ID XSSI batchexecute; verified all 6/6 read-only tools in stateful mode and all 9/9 tools in --replay-only mode (isError: false, )]}' XSSI prefix stripped to structured JSON).

Compatibility, safety, and release

  • Breaking changes or migration steps: none. rpc_operation is exactOptional() in environmentManifestSchema; pre-existing saved manifests without rpc_operation continue to load, derive state, serve confirmed writes, and match unchanged, single-operation POST routes keep their existing tool names and schemas on rebuild, and captures recording multiple distinct RPC operations on a shared POST route now emit one operation-qualified tool per operation instead of collapsing them onto a single conflicting route bucket.
  • Real Hopper/Ghidra, browser, or OS coverage: verified on macOS arm64 across Node v22.23.4, v24.22.2, and v26.13.0, including live Google Chrome 156.0.8078.80 capture_browser_scenario -> export_environment_bundle -> rea environment-serve HTTP MCP replay. Hopper/Ghidra providers are not touched.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: request body and non-JSON-like XSSI response inspection are strictly capped at 64 KiB UTF-8, query inspection at 8 KiB, operation names at 128 ASCII characters, XSSI multi-frame parsing is bounded by input slice indices and accumulator byte budgets, and character-code scanners avoid backtracking regular expressions.

Author readiness

Human owner: @saariuslystoned

  • 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.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new blocking issue was established.

Summary

Adds operation-aware tools for multiplexed POST endpoints and shared support for bounded XSSI responses.

  • Shared POST paths now keep RPC operations and replies separate.
  • Environment state keeps read-like RPC calls apart from writes.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Capture["Recorded exchanges"] --> Parse["Bounded RPC and XSSI parsing"]
  Parse --> Manifest["Manifest tools and operation identity"]
  Manifest --> State["Read views and write plans"]
  Manifest --> Match["Match probe path and operation"]
  State --> Answer["State or recorded answer"]
  Match --> Answer
  Answer --> Compare["Compare with the captured live answer"]
Loading

Reviews (17) · Last reviewed commit: "chore: sync with upstream main" · Reviewed by Greptile

Comment thread docs/web-network-captures.md Resolved
@saariuslystoned
saariuslystoned marked this pull request as ready for review November 7, 2026 01:04
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T01:04:23.615079Z
We couldn’t complete this review. Comment @codex review to try again.
7e664f7 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.

@greptile-apps

greptile-apps Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@CassieFox23 CassieFox23 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR: This is a code read. I ran nothing from the PR, and CI has not run on this head yet. The Greptile fixes I checked are in. One change isn't in the body. A rebuild renames tools, even on a path with just one GraphQL or JSON-RPC call.

Edit (7 Nov): I ran this PR at head ddd7229 in a VM, and the results are here.

I read the PR head e4d6b9d against its merge base 48f5f30. Main is now 99db80a, and none of main's new commits touch these files.

Worth a look

  1. Single-operation paths get new tool names. The group key always carries the operation kind and name when one is found (EnvironmentManifestAccumulator.ts lines 275 to 282). That happens even when a path has just one operation. Discrimination is on by default (line 213), and toolName adds the operation words (line 554). Say a capture has one POST /graphql call named GetViewer. A rebuild with this PR adds the words from GetViewer to that tool's name (environmentManifestNames.ts lines 120 to 127). The same goes for any JSON-RPC 2.0 endpoint. An agent or config that knows the old name would miss the tool after a rebuild. The body calls the contract change an additive optional field. Two fixes would work. Split a path only when two or more calls share it, or list the rename under breaking changes.

Nit

  • The 64 KiB check measures two different things. The manifest checks the raw request text, spaces included (rpcOperationSelector.ts lines 110 to 111 and 255). The replay value path measures compact JSON instead (lines 114 to 140, called from environmentReplay.ts line 109). A pretty-printed body just over 64 KiB is left undispatched in the manifest. At replay the same body can fit and get an operation. If the path also has discriminated tools, replay then refuses it (environmentReplay.ts lines 117 to 127). It's rare, but one shared measure would keep the two sides in step.

Looks good

  • Encoded batch names. The f.req check now uses URLSearchParams(bodyText).getAll("f.req") (rpcOperationSelector.ts line 265), so percent-encoded names are caught.
  • Comparison origin. isProbeJsonLike now uses the same hasBoundedXssiJsonResponse check as the manifest (environmentCompareProbe.ts line 144).
  • Old saved manifests still parse. rpc_operation is exactOptional (environmentManifestSchema.ts lines 49 and 50). Replay against an old manifest falls back to tools without an operation (environmentReplay.ts line 129).
  • Batches stay whole. A JSON array body is not a plain object, so GraphQL and JSON-RPC batches are left undispatched (rpcOperationSelector.ts lines 261 and 293).
  • Request bodies are bounded. The raw text is checked against 64 KiB before any JSON or form parsing (line 255).

Not run

  • No build, no typecheck, no tests. Each point comes from reading the code.
  • I did not check how persisted GraphQL queries are sorted into reads and writes. Only their name is known.
  • I did not trace the derived-state path for an old saved bundle that has an XSSI endpoint and no RPC tools.

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@CassieFox23

CassieFox23 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I ran this PR at head ddd7229 in a VM, and the 7 changed test files pass on Node 22.23.4, 24.22.1 and 26.12.1. A capture with one operation on a path keeps its plain tool name again. CI has not run on this head. I tested the head alone, without merging main.

Edit (7 Nov): I ran this PR again at head 83fc5eb in a VM, with a check of the XSSI item I left open here, and the results are here.

What passed

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
7 changed test files, 194 tests pass pass pass

My first point: one-operation paths keep their names

A build from a capture with one operation on a path, by commit:

Capture base 48f5f30 e4d6b9d (my review above) head ddd7229
GraphQL GetViewer on POST /graphql post_graphql post_graphql_get_viewer post_graphql
JSON-RPC 2.0 users.get on POST /rpc post_rpc post_rpc_users_get post_rpc
batchexecute GetItems post_appui_data_batchexecute post_appui_data_batchexecute_get_items post_appui_data_batchexecute
GraphQL GetViewer seen twice post_graphql post_graphql_get_viewer post_graphql
two GraphQL operations on one path post_graphql (one tool for both) post_graphql_get_viewer and post_graphql_get_orders post_graphql_get_viewer and post_graphql_get_orders

So the rename I found at e4d6b9d is gone at ddd7229. A path with two operations still splits into two tools, as the PR intends.

One thing to know. A bundle built from a one-operation capture holds post_graphql. A rebuild from a capture that adds a second operation on that path holds post_graphql_get_viewer and post_graphql_get_orders. That is the split the PR sets out to make. That split means a tool name depends on what the capture holds.

The probe is my own script, not PR code. It feeds hand-made POST records to the PR's manifest builder (EnvironmentManifestAccumulator). It is not the full bundle export, which needs a live capture.

My second point: the 64 KiB budget

I did not write a separate test for this. The PR has two tests for it, and both files passed on all three Node versions. I read both. Each one builds a GraphQL body that is over 64 KiB with its spaces, but under 256 bytes without them. That is my case:

  • measures raw wire UTF-8 bytes including formatting whitespace against the 64 KiB limit in rpcOperationSelector.test.ts expects no operation to be picked.
  • uses raw wire bodyText for the 64 KiB check so pretty-printed oversized GraphQL bodies route to the fallback tool in environmentReplay.test.ts builds the manifest, then matches the replay request.

I read the setup of both and did not run either one alone.

Still not run

  • The full bundle export and replay from a real capture.
  • The two 64 KiB tests on their own, and a probe of mine with a body of that size.
  • A merge of this head with main.
  • Two items I left open in my review above. One is the read and write split for persisted GraphQL. The other is derived state for an old bundle with an XSSI endpoint.

Thanks, saariuslystoned, for both of the fixes you made.

Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, kernel 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: ddd7229 / 48f5f30
  • Install: npm ci --offline on Node 24.22.1, then npm run prepare and npm run test:prepare
  • CI: CI, CodeQL and PR title are waiting for a maintainer. None ran on this head.
Commands

The 7 files are the test files in git diff --name-only 48f5f30fd5 ddd722998a. None calls doctor.

npm --prefix ~/pr-9204/src ci --offline
npm --prefix ~/pr-9204/src run prepare
npm --prefix ~/pr-9204/src run test:prepare
npm --prefix ~/pr-9204/src run test:focused -- \
  src/application/environment/environmentCompare.test.ts \
  src/application/environment/environmentReplay.test.ts \
  src/application/environment/environmentState.test.ts \
  src/application/environment/environmentTools.test.ts \
  src/domain/analysisView/EnvironmentManifestAccumulator.test.ts \
  src/domain/analysisView/environmentStateQueryCalls.test.ts \
  src/domain/analysisView/rpcOperationSelector.test.ts

All exited 0. The test command ran once per Node version: 7 files and 194 tests each time.

The probe ran with node_modules/.bin/tsx probe-names.mts <tree> on Node 24.22.1 for each of three trees: a git archive of 48f5f30, a git archive of e4d6b9d, and the head. Each tree uses the head's node_modules by symlink. The script, in short:

const acc = new EnvironmentManifestAccumulator(1024 * 1024);
for (const spec of specs) acc.add(record(spec)); // hand-made POST records
const out = acc.finish();
console.log(out.value.tools.map((t) => t.name + (t.rpc_operation ? ` [rpc_operation ${t.rpc_operation.kind}:${t.rpc_operation.name}]` : "")));

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@CassieFox23

CassieFox23 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I ran this PR at head 83fc5eb in a VM, and the 7 changed test files pass on Node 22.23.4, 24.22.1 and 26.12.1. Then I took the old XSSI fallback out of deriveEnvironmentState in the VM copy. Both new XSSI tests failed (one only in its second half). So the tests do need it. No test workflow has run on this head.

Edit (24 Nov): I ran the new head, 48f2191, in a VM, and the results are here.

What passed

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
7 changed test files, 200 tests pass pass pass

The count is 200, up from the 194 in my earlier comment at ddd7229. The six extra tests are two XSSI tests in environmentState.test.ts, three GraphQL tests in environmentStateQueryCalls.test.ts and one in rpcOperationSelector.test.ts.

I reran the tool-name probe from my earlier comment, on Node 24.22.1 only. It gives the same five lines at 83fc5eb as at ddd7229. A one-operation path keeps its plain name, and two operations on one path still split.

Old bundle with an XSSI endpoint (open item in my review above)

I removed the fallback in the VM copy only, by adding return loaded; before it in environmentState.ts, and ran environmentState.test.ts on Node 24.22.1. Then I put the file back (same md5 before and after).

Test Without the fallback
falls back cleanly without stateMismatch when a saved pre-PR bundle excluded non-/api/ XSSI endpoints fails at the derived.ok check (line 1020)
derives state without stateMismatch when a saved pre-PR bundle recorded text/plain and /api/ XSSI reads and POST XSSI writes fails at the second half (line 1095); the first half, with no excluded XSSI endpoint, passes
preserves derived state and confirmed REST writes when serving a saved manifest without rpc_operation (older test) fails at line 865
  • Result: 3 failed, 35 passed. The other 35 tests in the file are unaffected.
  • All three failures print the same refusal, "The state names a tool the manifest does not have". That is the stateMismatch check in environmentState.ts, so a mismatch does fail these tests, through derived.ok or report.served.
  • The test that pins get_notes as recorded (line 1097) looks right to me. The same capture derives get_notes as list on the direct path (line 1077), and as recorded on the fallback path. The docs say the fallback uses the old extraction, from before RPC and XSSI calls were split. I read main at 887b998. Its environment state code has no XSSI handling. So main did not parse a guarded text/plain body either. I read that and did not run main.

Persisted GraphQL sorting (open item in my review above)

The head adds classifies persisted GraphQL requests without body.query by operation name and repeated-read evidence and two unreadable-body tests in environmentStateQueryCalls.test.ts. They ran inside that file, 26 tests, and passed on all three Node versions. I did not run them alone, because the runner takes whole files. I did not check that they fail when the code they cover is removed.

Still not run

  • The full bundle export and replay from a real capture.
  • The two 64 KiB tests on their own, and a probe of mine with a body of that size.
  • The persisted GraphQL tests alone, and the same remove-the-code check I did for XSSI.
  • A merge of this head with current main. GitHub now shows the head as mergeable. Main is now 5 commits past 015a02d, the main commit this head carries.
  • test:fast, test:built and the browser lanes.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, kernel 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / merge base: 83fc5eb / 015a02d (main was 887b998 when I tested)
  • Install: npm ci --offline on Node 24.22.1, then npm run prepare and npm run test:prepare
  • CI: only Greptile Review and Validate author declaration ran on this head. No test workflow ran.
Commands

The 7 files are the test files this PR changes. None calls doctor.

npm --prefix ~/pr-9204/src ci --offline
npm --prefix ~/pr-9204/src run prepare
npm --prefix ~/pr-9204/src run test:prepare
npm --prefix ~/pr-9204/src run test:focused -- \
  src/application/environment/environmentCompare.test.ts \
  src/application/environment/environmentReplay.test.ts \
  src/application/environment/environmentState.test.ts \
  src/application/environment/environmentTools.test.ts \
  src/domain/analysisView/EnvironmentManifestAccumulator.test.ts \
  src/domain/analysisView/environmentStateQueryCalls.test.ts \
  src/domain/analysisView/rpcOperationSelector.test.ts

All exited 0. The test command ran once per Node version: 7 files and 200 tests each time.

The probe is the same script as before (node_modules/.bin/tsx probe-names.mts <tree>, Node 24.22.1, exit 0). It is my script, not PR code.

The removal of the fallback, in the VM copy only:

sed -i '261i\  return loaded;' ~/pr-9204/src/src/application/environment/environmentState.ts
npm --prefix ~/pr-9204/src run test:focused -- src/application/environment/environmentState.test.ts

That run exited 1 with 3 failed and 35 passed. A second and third run added one console.error line before the return to print the refusal, and failed the same way. I put the original file back each time.

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto
morluto enabled auto-merge (squash) November 8, 2026 19:08
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@CassieFox23 thanks for the review.

Single-operation tool names stay plain. selectGroupsWithOverlappingRpcPeers adds rpc_operation and the operation tokens only when two or more operations share method, origin, and template. A path with one operation stays post_graphql, post_rpc, or post_appui_data_batchexecute. A later capture that adds a second operation on that path splits the names; that split is the contract.

The 64 KiB check runs on the raw body before JSON.parse. selectRpcOperationFactsFromText / selectRpcOperationFromText reject via withinBodyByteLimit on both JavaScript length and UTF-8 bytes. Replay uses request.bodyText when it is set, then a string body, and only then JSON.stringify(request.body). A pretty-printed wire body over 64 KiB stays undispatched on both sides when bodyText is the wire text.

The persisted-GraphQL / legacy XSSI fallback in derive and environment state is still required. Removing it fails with "The state names a tool the manifest does not have". Persisted GraphQL classification tests passed in the post-merge focused run (environmentStateQueryCalls, 26 tests, 199 overall). A full bundle export from a live capture was not run.

☁️

Adopt main's prepare/commit split in the manifest accumulator: RPC
operation and XSSI facts are admitted in prepare, and the operation map,
JSON-like count and group fields are written only in the commit closure.
Pass the manifest name to environmentToolDefinitions in the new test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
auto-merge was automatically disabled November 13, 2026 18:20

Head branch was pushed to by a user without write access

Comment thread docs/guides/web/web-network-captures.md Resolved
saariuslystoned and others added 2 commits November 13, 2026 13:43
With operations in separate POST buckets, a mutation whose response
repeated the latest GET of /graphql passed the repeated-read check and
became a query-body view. Reject declared mutations and subscriptions
before any response- or path-based read inference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@saariuslystoned thanks for the PR — there is 1 open review thread here:

Could you address or reply to this? Once it's resolved and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@saariuslystoned also, this branch has merge conflicts with main — please resolve those along with the open threads.

Merge 42bbf33 while preserving the lazy per-call RPC facts repair. Retain normalized media ownership, shared JSON helpers, and upstream environment admission fixes.

Use the shared record predicate in the RPC selector to satisfy current architecture checks. Dependency-free regression and source checks pass; full dependency-backed validation remains with the coordinator.
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: On the new head, 48f2191, the seven changed test files pass on three Node versions: 205 of 205 tests. The last open review thread asked that a POST body not be parsed when the saved RPC facts already answer. A new test checks that, and it passes.

My last comment tested head 83fc5eb on 8 November, with 200 tests in the same files. Thanks, saariuslystoned, for the answers on tool names and the 64 KiB check.

Results

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Test files (7) exit 0, 7 passed exit 0, 7 passed exit 0, 7 passed
Tests (205) 205 passed 205 passed 205 passed
  • That thread is on environmentStateQueryCalls.ts:486, and it is now marked resolved. Commit 49854d7 adds reuses saved RPC facts without reading a request body for the fallback to environmentStateQueryCalls.test.ts. That file passed, 33 of 33.
  • Commit 05007b2 adds keeps a named mutation a write even when its response repeats the latest read, in the same file.
  • The PR adds 1 source file, so I did not run the tests with the source put back to the merge base.
  • CI on this head is green: CI and PR title are completed/success, with 16 checks passing, among them CI required, Portable tests and the three test shards. GitHub shows mergeable true, state clean.
  • This head includes main up to e896f60.

Not run

  • The tool-name probe from my earlier comments.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB, Linux 7.2.11) on my Nobara 44 PC
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 48f2191 / e896f60 (merge base with main)
  • Install: npm ci --offline and npm run test:prepare
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/application/environment/environmentCompare.test.ts src/application/environment/environmentReplay.test.ts src/application/environment/environmentState.test.ts src/application/environment/environmentTools.test.ts src/domain/analysisView/EnvironmentManifestAccumulator.test.ts src/domain/analysisView/environmentStateQueryCalls.test.ts src/domain/analysisView/rpcOperationSelector.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto morluto added the area: setup Setup, packaging, upgrade, install, Doctor, and client registration label Nov 26, 2026

This branch has not been deployed

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

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants