Skip to content

feat(environment): compare an environment with probe captures of its application - #5699

Merged
morluto merged 4 commits into
morluto:mainfrom
earakely-scale:feat/environment-fidelity
Oct 22, 2026
Merged

morluto merged 4 commits into
morluto:mainfrom
earakely-scale:feat/environment-fidelity

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An environment is only as useful as it is faithful: an agent graded or trained on it should meet the behaviour of the application it was captured from. REA checks an environment only against its own capture, so nothing measured how far it drifts from the application on calls the capture did not make, after writes, or on errors. Every important gap found so far came from ad hoc replays against live applications.

This PR adds rea environment-compare, which measures that. It compares an environment with probe captures: recordings of call sequences made against the live application, each after a reset. It reports how many calls the environment answers as the application did, which tools disagree and how. The command only reads Evidence and makes no network call.

Part of #4933. Stacked on #5600, which carries #5351 and #5352; it is merged in at 5327e598. Until #5600 lands, the diff against main includes it. The new work is:

  • src/application/environment/environmentCompare*.ts and their tests;
  • src/cli/environmentCommands.ts and src/cliCommandNames.ts;
  • tests/boundary/cli/environmentCompareCli.test.ts;
  • the docs and docs/specs/agent-environments/fidelity-compare/.

Problem and expected behavior

rea environment-compare manifest.json --evidence capture.json --probe probe-1.json --probe probe-2.json --json

Each --probe is inspect-web-network-capture or capture-browser-scenario Evidence of one sequence, recorded against the application after a reset. For each probe, the comparison:

  • resets the environment's state;
  • takes the requests in the order they were made;
  • matches each request to the tool of the same method whose path template fits with the most literal segments; a format-rule parameter must fit its format;
  • answers it as the served environment would;
  • compares that answer with the application's.

Id mapping. A re-seeded application holds the same entities under other ids, so the comparison maps them:

  • items in two answers pair by a natural key, a string field unique on each side that both share;
  • identifier fields of paired objects, and of two single answers such as a create's, map the live value to the environment's;
  • objects keyed by ids pair their entries;
  • mapped ids in a request's path, query or body are translated before the request is matched and answered.

Normalisation. After mapping:

  • clocks compare by format only;
  • two values each side generated on its own compare equal;
  • scalar sets in another order differ in order only;
  • bodies over the replay limit compare by status.

The report counts each kind.

Report. Agreement overall, per probe and per tool, plus agreement ignoring order for applications that return sets in no fixed order. Differences are categorised as status, missing-field, extra-field, value, length, order, clock-format, refused, not-served, no-tool and unmapped-id, each with a JSON pointer.

Change and scope

  • Self-contained: the comparison reuses the served environment's own answer path (environmentToolAnswer with a fresh state store per probe), so it measures exactly what an agent meets. Probes load with the capture parser, now exported.
  • Not included:
    • network access, credentials, or resetting the application: probes are recorded outside REA;
    • generating call sequences: a follow-up generates them where the environment disagrees;
    • any change to serving.
  • Scope: an analysis command over existing Evidence, inside the existing boundary; no target execution.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the environment application layer (src/application/environment/) and the CLI.
  • Contribution scope fit and linked maintainer decision: a read-only command over Evidence; not applicable.
  • CLI and MCP/tool-catalog contract: a new CLI command environment-compare with a repeatable --probe; no MCP tool, so the catalog is unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: reads manifest, capture and probe Evidence and authenticates them as environment-serve does; the report cites every Evidence id and is not itself Evidence.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

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.

  • Unit tests (19):
    • matching: literal versus parameter segments, format rules, query and body arguments;
    • the id map and its conflicts;
    • natural-key pairing and its guards;
    • learning from keyed objects;
    • path and value translation;
    • every difference category, plus clocks, generated values, order and oversized bodies.
  • An integration test, run against a probe of the books application re-seeded under other ids:
    • it agrees on all 9 steps, with 3 ids mapped;
    • in a second case, every category appears where expected and the state resets per probe.
  • CLI boundary (2): a successful comparison, and a refusal naming the bad probe.

Executed evidence: six environments against their live applications. The same images were seeded by the same scripts and restored from a snapshot before every sequence (7 to 80 s).

A driver outside REA recorded three kinds of sequence:

  • the capture re-run;
  • a create, read, update and delete scenario per served write type;
  • a read of every seeded entity.

The environments' manifests use prefix-variance, so the comparison ran on a local build with #5664 merged.

Environment Steps Agreement Ignoring order Against its own capture
NetBox 4.7.3 370 99.2% 99.2% 100%
Komga 1.29.1 356 93.8% 93.8% 93.1%
Mealie 3.28.0 301 96.0% 97.0% 97.1%
Shlink 5.1.7 133 89.5% 92.5% 92.4%
n8n 1.123.85 202 74.8% 87.6% 87.5%
Sentry 26.9.0 230 23.9% 46.5% 84.7%

Environment gaps the runs found, which are the next things to fix:

  • withheld writes and the reads after them;
  • n8n's archive-before-delete precondition;
  • lists:
    • a create missing from a list that keeps its recorded members;
    • a filtered list answered without its filter;
    • a replayed search that ignores its body;
  • a domain-scoped short URL served without its domain parameter;
  • Sentry state rendering:
    • a field two recorded views disagree on;
    • an organisation read whose shape depends on a query parameter;
  • event counts that move with the current time while the environment's clock is frozen;
  • a field the capture's scrubbing replaced with "<scrubbed>".

Differences not caused by the environment:

  • The application differing from itself between seedings: Sentry's permission-list order, release first-event times and feature flags, and n8n's executions.
  • The probe observing itself: its own sign-in user agent.
  • Ids the driver never mapped.

The six runs also found six ways the comparison itself was wrong. Each was fixed with a test before the next run:

  • requests are now matched in the environment's terms;
  • outside id fields, only string values are learned as ids;
  • position-only pairs are guarded;
  • objects keyed by ids are mapped;
  • unordered sets are compared as sets, and epoch numbers in arrays as clocks;
  • oversized bodies are compared by status only.

Details are in docs/specs/agent-environments/fidelity-compare/verification.md.

User-visible output. The summary for Komga:

{"probes": 3, "steps": 356, "equal": 334, "agreement": 0.938, "agreement_ignoring_order": 0.938, "unobserved": 0,
 "categories": {"status": 6, "missing-field": 4, "extra-field": 4, "value": 10, "length": 2, "not-served": 8, "unmapped-id": 6, "...": 0},
 "normalised": {"ids": 926, "clocks": 1550, "generated": 17, "large_bodies": 0, "unobserved_bodies": 0}}

Remaining proof gaps:

  • Agreement covers only the calls the probes make.
  • Clocks and generated values compare by form.
  • Id mapping depends on the answers sharing a natural key.
  • The numbers above mix environment fidelity with drift in the application itself between seedings. A live-against-live control would separate the two and is not done here.

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

Run on macOS with Node v22.23.1 at 235b22f (verification commit 20ad661), then again after merging #5600's head into 64b4994.

  • At 235b22f: npm run build:cached, npm run check:fast, npm run format:check, npx knip, npm run scan:todos, npm run docs:check, npm run verify:test-discovery, npm run mcp-catalog:check — passed.

  • npm run jscpd — 3.46% over 3609 files.

  • npx vitest run --project domain --project services — 7487 passed, 5 pre-existing skips.

  • npm run test:prepare, then npm run test:focused -- the environment-compare, export and serve CLI boundaries, the serve MCP boundary and tool schema validity — 5 files, 30 passed.

  • At 64b4994:

    • npm run build:cached, check:fast, format:check, knip, mcp-catalog:check and docs:check passed;
    • jscpd at 3.46%;
    • the environment application tests (168) passed;
    • the compare and serve CLI and MCP boundaries (9) passed.
  • Review round (head 473d03c): fixed the 11 Greptile threads and two findings of my own.

    • feat(environment): apply evidence-gated write effects to the served state #5600's four went in on that branch (b6c3b16) and were merged here (631a712).
    • The comparison fixes are in bbbdea2 and 7832f7e: ids learned only from answers to the call, and also per collection; paging values never translated; calls checked against the served tools' input schemas; browser probes keep their bodies; empty and large binary bodies compare as served; scalar sets compare after mapping; overlapping id-keyed objects pair.
    • Each new test fails on the previous head.
    • Gates passed again: check:fast, format, knip, todos, docs, test discovery, module boundaries and catalog; domain and services 7504 (5 pre-existing skips); focused boundaries 80; conformance; jscpd 3.46%.
    • Re-run on the saved probes, the six environments compare exactly as in the table, step for step, with the same ids mapped.
  • Review round 2 (head c63bcb7): merged feat(environment): apply evidence-gated write effects to the served state #5600's f2b9535 (a write of a missing entity never answers with a 2xx), then fixed Greptile's four follow-ups in 736bf38.

    • Ids are learned from a replay only when the whole recorded line and request body match.
    • An entity's own identity compares within the call's collection.
    • Overlapping keys are read as ids only when they evidently are.
    • A JSON empty string is kept.
    • Each new test fails on de2fc01. Gates passed again (domain and services 7508, boundaries 80, conformance, jscpd 3.46%), and the six environments still compare exactly as in the table.
  • Review round 3 (head 5604d55): entities inside an envelope keep their collection's mapping: the answer's own entities are found at the view's entity or list pointer, or the write's response pointer (8ef9257). Its test fails on c63bcb7; domain and services 7509 passed, boundaries 80, and the six environments are unchanged.

  • Review round 4 (head 7e26d99): no new findings; merged the write-plan branch at 9edbabe and fc403d9 (main 335c042 and the base branches' review fixes). Gates passed (domain and services 7637, 5 pre-existing skips; boundaries 80; conformance; jscpd 3.44%; the environment application tests 189 after the last merge).

  • Review round 5 (head 71a50f0): merged feat(environment): apply evidence-gated write effects to the served state #5600's 1d1c478 in 9622c5d, then fixed Greptile's three findings. The required-field finding was feat(environment): apply evidence-gated write effects to the served state #5600 code, fixed there. The other two are fixed in 71a50f0.

    • Probe records without a usable request line, and requests without a recorded answer, are listed per probe under unobserved with their reason, and left out of agreement.
    • An unrecorded live body compares by status only, counted as unobserved_bodies.
    • A browser probe captured without response bodies is refused.
    • A format-rule path parameter fits by its decoded value.
    • Each new test fails on 7e26d99. Gates passed: check:fast, format, knip, todos, docs, discovery, module boundaries, catalog, no oxlint warnings; domain and services 7647 (5 pre-existing skips); the compare, export, serve and analysis-view boundaries 69; conformance 279; jscpd 3.44%.
    • On the saved probes nothing went unobserved, and five environments compare exactly as before.
    • Komga's collection create and patch are now withheld by feat(environment): apply evidence-gated write effects to the served state #5600's stricter gate, because the only read that could confirm them came after the collection was deleted. Its agreement falls from 96.9% to 93.8% (11 steps: 3 creates, 2 patches, and the 6 reads and deletes that follow), and against its own capture from 96.6% to 93.1%. The table shows the new figures.
  • Review round 6 (head bacafc5): merged feat(environment): apply evidence-gated write effects to the served state #5600's dc5e2aa in 8996fbf. That fixes the two findings Greptile raised on both PRs: derived update changes are weighed, and a reset or load resets collection spellings.

    • A request whose answer the probe lost is now sent to the environment, still uncompared, so a later read sees its effect (bacafc5). Its test fails on 71a50f0.
    • Gates passed: domain and services 7650 (5 pre-existing skips), boundaries 69, conformance 279, jscpd 3.44%, no oxlint warnings.
    • The six environments compare exactly as in the table, probes and self-comparison alike.
  • Review round 7 (head ac3ca8a): Greptile's two findings on round 6 were in feat(environment): apply evidence-gated write effects to the served state #5600's code, fixed there in fe8ab58 and merged here in d58c9ab. Gates passed: domain and services 7653 (5 pre-existing skips), boundaries 69, conformance, jscpd 3.44%. The six environments compare exactly as in the table.

  • Review round 8 (head 779910e): Greptile's finding on round 7 was in feat(environment): apply evidence-gated write effects to the served state #5600's store, fixed there in 73c0e9b and merged here. Gates passed: domain and services 7654, boundaries, jscpd 3.44%. The six environments compare exactly as in the table.

  • Review round 9 (head ce49169): fixed Greptile's two findings on round 8 in 5020a83: a probe with any undated record keeps its recorded order, as state extraction does, and a browser probe that makes POST, PUT or PATCH calls without recorded request bodies is refused. It also merged morluto's a36cdf4 and feat(environment): apply evidence-gated write effects to the served state #5600 at 3580d85 and 43d98ea, whose gate fix settles the finding Greptile raised here about overwritten document writes. Both new tests fail on the previous head, and the six environments compare exactly as before, on the probes and against their own captures.

  • Review round 10 (head 6c13ef7):

    • Fixed Greptile's finding on this branch in b7e50be. A probe request to another origin than its application (the origin with the most JSON-like records, chosen as the manifest chooses its own) is neither made nor compared, and is listed as other-origin. The origin choice moved to environmentManifestOrigin.ts, shared by the manifest and the comparison.
    • Merged feat(environment): apply evidence-gated write effects to the served state #5600 at 264ce41, 0ae6440, 6257de9, 466ed8b, 7cef2fb, 45a5c8b and 325c128 (6a63365, aa33d42, 2431c91, 22fad94, 194493e, 097d379, 6c13ef7). Their fixes settle the nine findings Greptile raised here against that branch's code: pending writes a summary read showed nothing of, encoded update and delete paths, later document replacements, flat entity fields that look like pointers, zero page sizes (twice), partial write responses taken for removals, and interference timed by a tool's call elsewhere or by an overwritten effect. The paging rules, with this branch's isPagingParameter, moved to environmentStatePaging.ts.
    • The new test fails on ce49169. Gates passed on 6c13ef7: check:fast, format, knip, todos, docs, discovery, module boundaries and catalog, with no oxlint warnings in the changed files; domain and services 7789 (5 pre-existing skips); environment boundaries 65; conformance 265; jscpd 3.43%.
    • The six environments compare exactly as before, on the probes and against their own captures, with no unobserved records.
  • Review round 11 (head ea72e29):

  • Review round 12 (head 5a09aae):

  • Review round 13 (head 9549f74): fixed Greptile's finding on 1874b20, the Cursor agent's restack onto main after feat(environment): apply evidence-gated write effects to the served state #5600 landed. Differ.object translates keys only for an object keyed by learned ids, read as learning reads one, so ordinary fields compare by name and a real rename shows. The new test fails on 1874b20.

    • Gates passed: check:fast, format, knip, todos, docs, discovery, module boundaries and catalog; domain and services 7982 (5 pre-existing skips); environment boundaries 67; jscpd 3.39%.
    • The six environments compare byte-identically to round 12, on the probes and against their own captures.

Merge resolution validation

At 462434c03, merged main (293832baf) while preserving its per-line whole-list membership, query-aware list serving, and extracted helper owners alongside this PR's shared encoded-path matching and stable collection ordering. Paging regressions now distinguish learned offset queries from unproved whole lines, use an explicit page size for later-page fixtures, and retain positive-page-base uncertainty. Removed the unreferenced InspectApkSignatureInput type after confirming the Knip finding also on clean main.

  • Environment/application and analysis-view source tests: 46 files, 993 tests passed.
  • Focused CLI/MCP/process boundary tests for environment comparison, serving, export, and shutdown: 7 files, 26 tests passed; runtime and packaged-skill build passed.
  • npm run check — exit 0, including typecheck, lint, formatting, Knip, metadata, module boundaries, and architecture guards.
  • npm run check:fast — exit 0.
  • npm run docs:generate and npm run docs:check — exit 0, including 9 README consistency tests.
  • Full repository suite and the six live-application probe runs were not repeated. Historical live measurements below describe earlier revisions, not this merge resolution.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; a new command.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads local Evidence files only. Probe captures are HARs the caller records; the verification's driver recorded them without headers or cookies.

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

@earakely-scale
earakely-scale marked this pull request as ready for review October 20, 2026 22:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

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-10-20T22:52:49.802648Z
We couldn’t complete this review. Comment @codex review to try again.
64b4994 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.

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge, with non-blocking fixes for a dropped query name and slow ID learning on large lists.

Findings

  1. P2 A query value disappears ▶
  2. P2 Large lists learn IDs slowly ▶
Fix with agent prompt
### Issue 1
src/application/environment/environmentCompareMatch.ts:170-171
A query named `__proto__` disappears because `args` is a plain object. Assigning its string value calls the inherited setter instead of adding an own member. `environmentArguments` then omits it, so replay can choose the first recording instead of the one matching the probe’s query. These query names are allowed and advertised.

Build `args` with `Object.create(null)` or `Object.fromEntries` so the comparison keeps the supplied value.

### Issue 2
src/application/environment/environmentCompareIds.ts:69-74
`#pairScoped` scans every earlier value for each new ID. A 20,000-item list containing only `id` fields fits under the replay body limit but causes about 200 million checks, even when comparing unchanged IDs against their own capture. Large list probes pay this cost each time they run.

Keep a reverse set or map per collection, as the probe-wide `#toLive` map already does.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds offline environment-compare over authenticated Evidence. Each probe gets fresh state, mapped IDs, and a report of answer differences.

  • Environment comparisons now replay application probes against a fresh served state.
  • Environment-state matching and simulated creates now follow serving's path and collection choices.
  • APK signature callers can no longer import the query input type.

Diagram

sequenceDiagram
  participant Input as Evidence files
  participant Compare as Comparison
  participant State as Fresh probe state
  participant IDs as ID map
  participant Report as Report
  Input->>Compare: Authenticate manifest, capture, and probes
  loop Each probe
    Compare->>State: Start from captured state
    loop Each usable request
      Compare->>IDs: Translate known IDs
      Compare->>State: Check arguments and answer
      State-->>Compare: Recorded or state-backed answer
      Compare->>IDs: Learn matching IDs
      Compare->>Report: Compare status and body
    end
  end
Loading

Reviews (29) · Last reviewed commit: "fix(merge): reconcile environment compar..." · Reviewed by Greptile

morluto commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Maintainer thread pass (inventory):

  • Greptile: 38/38 root findings already have @earakely-scale "Fixed in …" replies (this branch or via merged #5600); Greptile confidence is 5/5 on head 6c13ef71.
  • Codex: no inline finding threads. Summary shows code-review Failed (incomplete / usage limits), not concrete unresolved Codex comments — gate "Codex clear" waits on a successful re-review after restack.
  • Resolve: no resolveReviewThread in available cursor-github tools; posting per-thread maintainer acks. UI resolve after #5600 lands and this branch is restacked onto current main.
  • Stack: still after #5352 then #5600. Not launching another rebase agent (parent CloudAgent already handling).

morluto pushed a commit to earakely-scale/rea that referenced this pull request Oct 21, 2026
…application

Add environment-compare against probe captures of the served application,
keeping the rebased write effects and main's state-file ownership.

Squashed rebase of morluto#5699 onto the rebased morluto#5600 tip.
@morluto
morluto force-pushed the feat/environment-fidelity branch from 6c13ef7 to 12d2bc3 Compare October 21, 2026 21:34
@greptile-apps

This comment has been minimized.

cursor Bot pushed a commit to earakely-scale/rea that referenced this pull request Oct 21, 2026
…application

Add environment-compare against probe captures of the served application,
keeping the rebased write effects and main's state-file ownership.

Squashed rebase of morluto#5699 onto the rebased morluto#5600 tip.
@cursor
cursor Bot force-pushed the feat/environment-fidelity branch from 12d2bc3 to b1c6875 Compare October 21, 2026 22:29
cursor Bot pushed a commit to earakely-scale/rea that referenced this pull request Oct 21, 2026
…application

Add environment-compare against probe captures of the served application,
keeping the rebased write effects and main's state-file ownership.

Squashed rebase of morluto#5699 onto the rebased morluto#5600 tip.
@cursor
cursor Bot force-pushed the feat/environment-fidelity branch from b1c6875 to 14b474c Compare October 21, 2026 22:29
@cursor

cursor Bot commented Oct 21, 2026

Copy link
Copy Markdown

Fixed in b8154e9 — a nonzero offset, start, or _start stays on the recorded path. It does not prove membership: "all" (a zero-start line still can). Serving and the write gate list that page's recorded members, so an empty ?offset=1 page does not gain an entity after data/add or a confirmed create, and a later empty page does not contradict the write. Outside-diff P1.

@cursor

cursor Bot commented Oct 21, 2026

Copy link
Copy Markdown

Fixed two open Greptile P1s. Tip ae52ae9ce.

  • 50687af50 fix(environment): share child id scopes across parent spellings. A parent parameter in a collection scope is decoded once, so %32 and 2 share one child id map. A second encoding stays a different parent.
  • ae52ae9ce fix(environment): ignore creates outside a tied collection. A later create in another collection is left unmodelled, so a read of it cannot confirm the plan. A read of the tied collection still can.

cursor Bot pushed a commit to earakely-scale/rea that referenced this pull request Oct 21, 2026
…application

Add environment-compare against probe captures of the served application,
keeping the rebased write effects and main's state-file ownership.

Squashed rebase of morluto#5699 onto the rebased morluto#5600 tip.
@cursor
cursor Bot force-pushed the feat/environment-fidelity branch from ae52ae9 to 98fa616 Compare October 21, 2026 23:19
@cursor

cursor Bot commented Oct 21, 2026

Copy link
Copy Markdown

Restacked onto #5600 tip d7c5c626 (feat/environment-state-writes). New tip 98fa6160a64f56dcc3f22ca0f83e59b0cb121f06.

The five fidelity commits replayed with no conflict files. Offset/page handling, child-id scope decoding, and the tied-collection create guard are still on the branch. Typecheck passed, and 402 focused environment tests passed.

cursoragent and others added 2 commits October 22, 2026 06:23
Keep probe comparison, paging, and tied-create behavior on main after morluto#5600. Capture parsing keeps field-path errors and records whether a probe kept request and response bodies.

Co-authored-by: morluto <morluto@users.noreply.github.com>
The tied-create collection order lives with the checks that match encoded parents. The write simulation reads field checks from that attribution, and taint uses the same segment match.

Co-authored-by: morluto <morluto@users.noreply.github.com>
@cursor
cursor Bot force-pushed the feat/environment-fidelity branch from b1fecee to 1874b20 Compare October 22, 2026 06:25
@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown

Restacked onto main 538017d1 (#5600). New tip 1874b20c53394018d0949624b721b574484df926.

The only content conflict was src/application/environment/environmentSource.ts. The resolution keeps main's field-path capture errors and the fidelity probe fields (purpose, responseBodies, requestBodies). The write checks also needed environmentStateWriteOrder.ts and the attribution export of writtenFieldChecks, which final #5600 no longer had. Typecheck passed, and 460 focused environment tests passed.

earakely-scale and others added 2 commits October 21, 2026 23:56
… learned ids

Differ.object mapped every key through the probe's id map, so a field named
like a learned id was compared with another field, and a real rename could
pass as a mapped key. Keys now translate only for an object keyed by
learned ids as learning reads one: a key both sides share needs every key
evidently an id, and otherwise each entry is an entity or each key evidently
an id. Any other object compares field by field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preserve main's per-line list membership and query-aware serving while retaining shared encoded-path matching and stable collection order. Update paging regressions and docs for the current behavior, and remove the unused APK input type that blocked Knip.

Validation: 993 source tests and 26 CLI/MCP/process boundary tests passed. npm run check and npm run docs:check passed. Live application probes and the full repository suite were not rerun.
@morluto
morluto merged commit edccb43 into morluto:main Oct 22, 2026
11 of 12 checks passed
Comment on lines +170 to +171
else if (!Object.hasOwn(args, name)) {
args[name] = value;

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.

P2 A query value disappears

A query named __proto__ disappears because args is a plain object. Assigning its string value calls the inherited setter instead of adding an own member. environmentArguments then omits it, so replay can choose the first recording instead of the one matching the probe’s query. These query names are allowed and advertised.

Build args with Object.create(null) or Object.fromEntries so the comparison keeps the supplied value.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/environment/environmentCompareMatch.ts
Line: 170-171

Comment:
**A query value disappears**

A query named `__proto__` disappears because `args` is a plain object. Assigning its string value calls the inherited setter instead of adding an own member. `environmentArguments` then omits it, so replay can choose the first recording instead of the one matching the probe’s query. These query names are allowed and advertised.

Build `args` with `Object.create(null)` or `Object.fromEntries` so the comparison keeps the supplied value.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +69 to +74
for (const value of scoped.values()) {
if (String(value) === envKey) {
this.#conflicts += 1;
return false;
}
}

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.

P2 Large lists learn IDs slowly

#pairScoped scans every earlier value for each new ID. A 20,000-item list containing only id fields fits under the replay body limit but causes about 200 million checks, even when comparing unchanged IDs against their own capture. Large list probes pay this cost each time they run.

Keep a reverse set or map per collection, as the probe-wide #toLive map already does.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/environment/environmentCompareIds.ts
Line: 69-74

Comment:
**Large lists learn IDs slowly**

`#pairScoped` scans every earlier value for each new ID. A 20,000-item list containing only `id` fields fits under the replay body limit but causes about 200 million checks, even when comparing unchanged IDs against their own capture. Large list probes pay this cost each time they run.

Keep a reverse set or map per collection, as the probe-wide `#toLive` map already does.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
@morluto morluto added area: runtime Process capture and runtime observation enhancement New feature or request labels Nov 23, 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