Repository navigation
feat(environment): apply evidence-gated write effects to the served state - #5600
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The latest change appears safe to merge; no new blocking issue was found. SummaryThe PR serves write tools whose effects later captured reads confirm. The latest change fixes the clock fallback when a capture contains an unusable duration.
Reviews (38) · Last reviewed commit: "fix(environment): start the served clock..." · Reviewed by Greptile |
|
Maintainer thread pass (inventory):
|
…ving selects The gate built a later create's path fields from the recorded request path, while serving fills them from the held collection it selects for that path, so a read showing the other spelling's parent could confirm a create serving cannot reproduce. Rules still learn from the recorded path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ds updates write, and keep later members' types An unmodelled write below an item path names its entity through itemTarget, and one at or above a collection resolves the held collection, as modelled writes do, so an encoded spelling no longer hides the entity it changed. An update's answer counts the fields its rules write, other than increments, as available, so a field only the update writes no longer makes it incomplete-entities. A member a later call first stores keeps that call's JSON type in the body's kinds, which the body check falls back to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er its object A replacement claims only the members it wrote or removed, but it now overwrites every earlier effect under its object, so a merge that wrote the object it replaces loses its confirmation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both sides named unmodelled writes as modelled ones do and dropped volatile fields from members-only checks; this keeps the taint that also resolves collection-level writes through heldCollection, and one volatile filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a date can hold A record timed past the range of a date no longer leaves the served clock without a start, which the store read as zero and stamped writes in 1970; the clock starts after the latest record a date can hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lity Both branches fixed the same two findings. Write descriptions were already quoted and sampled identically; this keeps morluto#5600's wording. For a create's collection, this branch's choice through serving's candidates and order now applies to every create, so morluto#5600's held-only heldCollection is dropped here. The simulated state's serving order moves to its own module to keep the checks under the line limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a tied create's path fields An identifier equal on both sides can name different entities once the probe's mapping gives the live value another environment counterpart, so the comparison now reports it rather than counting it equal. Tests cover a tied create whose parent serving decodes from the collection it selects, which morluto#5600's fix to a create's path fields settles here too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion of unmodelled writes This keeps the read checks under the line limit after morluto#5600's additions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ueries This brings in morluto#5600 at 11e3f01. A list check renders query answers with their totals and, when it fails, reports the members alone accounting for the difference, so it does both. writtenFieldChecks moves to the attribution module to keep the checks under the line limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ueries This brings in morluto#5600 at 90d9022. writtenFieldChecks, which this branch keeps in the attribution module, takes morluto#5600's rule that volatile fields check no write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ueries This brings in morluto#5600 at 3f1f825. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e assigned values Update evidence carries both the type's other entities and the fields the observing view had shown. With morluto#5600's additions the write effects and explanations outgrew the line limit, so the checks a recorded update call must reproduce move to environmentStateWriteCalls.ts, and freshUuid and the generated rule kinds to environmentStateWriteGenerated.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@morluto #5600 is ready for a merge pass: on 4bc6002, CI is green, it merges cleanly, Greptile scores it 5/5, and every review thread is resolved. Codex's review keeps failing on usage limits rather than findings. Could you merge it, or retrigger Codex if you'd like that gate first? #5699, #5787, #5800, #6136, #6138 and #6169 are stacked behind it. |
|
no need to retrigger! lgtm |
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>
…ist lines morluto#5600 landed on main as a squash, so this merge takes 3f1f825, the write-plan commit this branch last merged, as its base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ist queries morluto#5600 landed on main as a squash, so this merge takes 3f1f825, the write-plan commit this branch last merged, as its base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rite assigned values morluto#5600 landed on main as a squash, so this merge takes 3f1f825, the write-plan commit this branch last merged, as its base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iew clock spelling morluto#5600 landed on main as a squash, so this merge takes 3f1f825, the write-plan commit this branch last merged, as its base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rite coverage morluto#5600 landed on main as a squash, so this merge takes 3f1f825, the write-plan commit this branch last merged, as its base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…application (#5699) * chore: restack environment fidelity onto main Keep probe comparison, paging, and tied-create behavior on main after #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> * fix(environment): keep served collection order with the fidelity checks 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> * fix(environment): translate an object's keys only when it is keyed by 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> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Summary
An environment served from its state now also serves the write tools whose effects the capture itself confirms:
Later reads, lists and
data/getshow the change, anddata/resetundoes it.The
environment-stateview decides which write tools are served. It replays the capture's own timeline on the extracted initial state and checks every later read the served state would answer. A write tool is served only when a later read confirms its effect and none contradicts it. Every other write tool stays unserved, with its reason.Refs #4933 (design discussion).
Stacked on #5351 and #5352. Both are merged into this branch at their current heads (5a61853 and b4b7ebc), and main is merged in. Until they land, the diff against main includes them; the new work is in:
docs/specs/agent-environments/state-writes/(spec, plan, tasks, verification).Problem and expected behavior
Serving from the state was read-only, so every task an environment could support was a lookup. For training, agents need to change the environment, and graders need to check the resulting state rather than the agent's reply.
The expected behaviour:
Change and scope
writesholds one plan per state-changing tool,write_clockthe instant the served clock starts from.create,update,delete,documentornoneby the state type or document the path names.entity,identity,emptyorrecorded; the insert position is learned from the recorded list order.nullbody counts as absence;no-state-target,no-call,body-unusable,no-observation,unexplained-change,contradicted,side-effect,unconfirmedorincomplete-entities.data/resetanddata/addrestart them.limit,offset, …) and listed the whole collection backsmembership: "all", and an argument-less list call answers from it. Without this, created entities never appear in many apps' lists.Follow the contribution scope.
Contract and boundary impact
environment-stateview (src/domain/analysisView/environmentStateWrite*.ts,EnvironmentStateWriteSimulation.ts) and the environment serve path (src/application/environment/environmentStateWrite*.ts,environmentToolAnswer.ts, the store).readOnlyHint: false);environment-stateresults gainwritesandwrite_clock;allmembership on paging-only lines;--replay-onlyis unchanged.stateprovenance (create,update,delete,document-write,missing).docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): theinspect_analysis_viewdescription gains one sentence;mcp-catalog:checkpasses.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
Tests.
null; learned insert rules; unmodelled writes; observations from later reads.50 showcase captures (45 HAR inspections, 5 browser scenarios). 31 write tools served in 16 captures (10 creates, 11 updates, 10 deletes). Of the remaining 152 state-changing tools, 102 name no state type and 50 are modelled but not served, each with its reason. For example:
An in-process smoke applied all 31 served tools and read every created or updated entity back from the state.
End to end on a randomly chosen published environment (NetBox). The environment was exported with this branch and run in AgentEnv framework 0.9.1334. Four write tasks were graded by
env_outcome_verifierthroughdata/get, so the grade comes from the state, not the agent's reply:The bundle's 12 retrieval tasks: 12/12 for both models.
Against the live application. NetBox 4.7.3 ran with the capture's own seed, and one scenario ran against the live API and the served environment. 11 of 13 steps were equal, with only
created/last_updatednormalised:The difference is NetBox's 409 when deleting a site that devices reference: the served delete removes the entity alone. The capture never showed that rule, and it is listed as not modelled.
For evidence-bearing changes:
Representative output (NetBox capture, built CLI, MCP client)
Validation performed
At cbb7b61 and again after merging the base branches and main:
Static checks:
npm run build:cached,check:fast,format:check,knip,scan:todos,docs:check,verify:test-discoveryandmcp-catalog:checkpassed.Duplication:
npm run jscpdat 3.44%, under the 3.5% gate.Domain and services:
npx vitest run --project domain --project services: 7442 passed, 5 pre-existing skips.Boundaries:
npm run test:prepare, thennpm run test:focused --the write MCP boundary, the serve MCP, CLI and process boundaries, the export CLI, the analysis-view CLI and MCP and the compact schema boundaries, and the contract description tests: 72 passed.After the latest main merge (only the shared description string conflicted): the contracts, analysis-view and environment tests (857 passed) and those boundaries (53) passed again.
Review round (head df2bded): merged feat(environment)!: serve the environment state by default #5351 at c00fde4, feat(environment): render more read tools from the state and describe responses #5352 at f6c756a and main at 1629266 (trial merge with current main is clean), then fixed the 11 Greptile findings in 82556cd, 138ea4b and 6d21b62 (the batch-limit one was feat(environment)!: serve the environment state by default #5351 code, fixed there in c00fde4).
check:fast,format:check,knip,scan:todos,docs:check,verify:test-discovery,verify:module-boundariesandmcp-catalog:checkpassed;jscpd3.47%; domain and services 7463 passed (5 pre-existing skips); the focused boundary set 75 passed; conformance 279 passed. The pinned replay card digest moved only because feat(environment): render more read tools from the state and describe responses #5352 quotes summary field names (un-quoting reproduces the old digest). The stricter gate left the write verdicts over the 50 showcase captures unchanged plan by plan, and the in-process smoke again applied all 33 served write tools.Review round 2 (head 7056f5f): fixed Greptile's 5 follow-up findings in 2086da6 (checked lines matched as serving matches calls, increments and slugs held for every call, insert rules still learned after an item read, the gate running serving's document body check, decoded parent path values on served creates); each new test fails on df2bded. Gates as above passed again (domain and services 7468, 5 pre-existing skips; boundaries 75; conformance 279;
jscpd3.47%); verdicts over the 50 captures unchanged plan by plan; smoke 33/33.Review round 3 (head db8df45): fixed Greptile's 2 findings on round 2 in db8df45: checked lines keep the path as spelled (replay prefers verbatim spellings), and later slug rules are checked against the values earlier calls recorded. Both new tests fail on 7056f5f. Gates passed again (
check:fast, format, knip, docs, discovery, boundaries, catalog; domain and services 7470 with 5 pre-existing skips; boundaries 75; conformance 279;jscpd3.46%); verdicts over the 50 captures unchanged plan by plan; smoke 33/33.Review round 4 (head 5327e59): a read's checked line is now chosen as replay chooses the line for its call (verbatim or decoded parameters, verbatim first, then recorded order), and a list is compared from that line's collection; the new test fails on db8df45. Gates passed again (domain and services 7471 with 5 pre-existing skips; boundaries 75; conformance 279;
jscpd3.46%); verdicts unchanged plan by plan; smoke 33/33.Review round 5 (head b6c3b16): Greptile's review of feat(environment): compare an environment with probe captures of its application #5699, which builds on this branch, found four more gate and serving gaps, fixed here.
null.data/addrefuses a document whosedata/getform would pass 32 MiB.jscpd3.46%), the verdicts over the 50 captures were unchanged, and the smoke ran 33/33.Follow-up (head f2b9535): a 2xx
nullnow answers a missing entity only for reads, so a write of a missing entity never reports success (Greptile). Its test fails on b6c3b16; domain and services 7476 passed, and the smoke ran 33/33.Review round 6 (head fc403d9): merged the serving branch at 25b6622 and 6b8db19 and the coverage branch at 665112e, which bring main 335c042. The contract text conflicted only where this branch adds its write sentence; in the store this branch's own size check was kept. Gates passed (domain and services 7605, 5 pre-existing skips; boundaries 75; conformance;
jscpd3.45%), the verdicts over the 50 captures are unchanged, and the smoke ran 33/33.Review round 7 (head 1d1c478): fixed Greptile's 4 findings on round 6 in 1d1c478. A read whose body no longer holds the entity or list, or that shows an entity without its required fields, now contradicts the writes it checks. A write whose effect a later write replaces is no longer confirmed by reads of that later state. Sequences skip values the state started with. An emptied collection keeps its spelling for creates. The same commit fixes Greptile's report on feat(environment): compare an environment with probe captures of its application #5699 that the gate confirmed an entity without a field serving requires. All 5 new tests fail on fc403d9. Gates passed (
check:fast, format, knip, todos, docs, discovery, module boundaries, catalog, no oxlint warnings; domain and services 7610, 5 pre-existing skips; boundaries 75; conformance;jscpd3.45%). Over the 50 captures, only Linkding changed: its bundle create and patch are now unconfirmed, because the one list that checked them was taken after the bundle was deleted. That leaves 31 served write tools (10 creates, 11 updates, 10 deletes), and the smoke ran 31/31.Review round 8 (head dc5e2aa): fixed Greptile's 2 findings on round 7.
jscpd3.45%, no oxlint warnings.Review round 9 (head fe8ab58): fixed Greptile's 3 findings on round 8; two were raised on feat(environment): compare an environment with probe captures of its application #5699 against this branch's code.
jscpd3.45%, no oxlint warnings.Review round 10 (head 73c0e9b): fixed Greptile's finding on feat(environment): compare an environment with probe captures of its application #5699 about this branch's store: a create prefers a held collection over an equally fitting Evidence-only spelling. Its test fails on fe8ab58. Gates passed: domain and services 7616, boundaries 75, conformance,
jscpd3.45%, no oxlint warnings. Verdicts are unchanged and the smoke ran 31/31.tests/acceptance/applications/peResources.test.ts), which timed out at 30 s. This branch does not touch it, and it passes on main.Review round 11 (head 6d28aa7): fixed six findings Greptile raised on feat(environment): list every entity on a list's whole lines #5787 against this branch's code, in 9f513d0:
containsDelimitedno longer overflows the stack on wide arrays;environmentStateWriteAttribution.tsand the create's collection choice toenvironmentStateCollections.ts, to stay under the line limit.jscpd3.44%; no oxlint warnings.Review round 12 (head 3580d85): fixed five findings Greptile raised here and one on feat(environment): compare an environment with probe captures of its application #5699 against this branch's code, and merged main d8a9673:
page-exceeded), and the gate checks nothing by it.Review round 13 (head 43d98ea): fixed four findings Greptile raised on feat(environment): list every entity on a list's whole lines #5787 against this branch's code:
Review round 14 (head 325c128): fixed six waves of findings Greptile raised against this branch's code, here and on feat(environment): compare an environment with probe captures of its application #5699, feat(environment): list every entity on a list's whole lines #5787 and feat(environment): answer list filters, search, sorting and paging from the state #5800, in 264ce41, 0ae6440, 466ed8b, 7cef2fb, 45a5c8b and 325c128:
_start–_endrange bounds a page aslimitdoes, and a zero size is no bound by itself only where the line's recording listed items under it, the line's other bounds still applying;data/getwould write past 32 MiB is not served.environmentStatePaging.ts(6257de9) and the document write toenvironmentStateWriteDocument.ts, to keep files under the line limit.check:fast, format, knip, todos, docs, discovery, module boundaries and catalog, with no oxlint warnings in the changed files; domain and services 7748 (5 pre-existing skips); environment boundaries 63; conformance 265;jscpd3.44%.Review round 15 (head 717ac2c): morluto restacked this branch onto main after feat(environment): render more read tools from the state and describe responses #5352 and added fixes through 3b34bbd (5d00ff3). Merged main 8413ec0 in 717ac2c, with no conflict.
check:fast, format, knip, todos, docs, discovery, module boundaries and catalog; domain and services 7827 (5 pre-existing skips); environment boundaries 64;jscpd3.47%.cleanup_incomplete). That test passes locally.Review round 16 (head 3f1f825): fixed the Greptile findings raised against this branch's code on the stacked PRs.
kinds).cleanup_incompleteCI failure. Merged morluto's 53a7866 and 329aeed/756c6312 in 3f1f825; where fixes overlapped, one copy is kept.check:fast, format, knip, todos, docs, discovery, module boundaries and catalog; domain and services 7880 (5 pre-existing skips); environment boundaries 64;jscpd3.41%. The smoke ran 31/31.stateor stampsclosed_at. The only call that closed the issue came after an unmodelled comment delete under it, so that call is no longer learned from (ccdf091).Details, including the per-capture verdict table, are in
docs/specs/agent-environments/state-writes/verification.md.Compatibility, safety, and release
--replay-onlyand the replay fallback are unchanged.writes) first and serving second.Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.🤖 Generated with Claude Code
Current blocker verification
The combined branch retains the author's
7de20bc9efixes for sent-member provenance, negative sequence continuation, deleted-target absence checks and encoded update observations. Target resolution prefers live entities before removed-target fallback, and observation matching uses the same owner. Distinct tests cover encoded collection aliases and the exact resolved raw ID rather than deriving a new identity from the path. The earlier generation-exhaustion refusal remains typed and precedes mutation/write commitment.The additional collection-history fix indexes baseline collection spellings once at restart/load/reset and budgets only newly generated path history. Admission happens before mutation; rejected insertions leave state unchanged. Loaded source collections and sequence facts remain available after deletion/reinsertion. A canonical index removes the prior scan of all baseline entities on every new path. The 1 MiB allowance is deterministic logical accounting for generated history (UTF-8 keys plus explicit bookkeeping allowances), not a total-store or measured OS-memory bound.
The combined source passed 116/116 focused tests,
check:fast,format:checkandgit diff --checkusing Node 24.18.0/npm 11.16.0.docs:checkalso passed on the final tree (README consistency 5/5), and the pre-push fast gate passed. No provider was executed.Independent review covered these owner changes. For the history-index change only, a matched 1,000 insert/delete sample recorded baseline 14.57 ms / 23,867 microseconds CPU versus candidate 9.98 ms / 16,914 microseconds CPU; these are host-specific samples, not a universal speed claim, and the later correctness fixes were not separately benchmarked. Vitest/V8 RSS was noisy; process-family memory and agent-token costs were not measured. The documentation records the limits. This pass is not a new full review of the entire reconstructed PR or a real-provider run. Normal merges preserve the author's intervening branch updates; no history rewrite was used.
Additional owner-boundary verification
Update observations now carry the selected read view's field coverage. A summary that does not cover a required learned clock cannot displace useful partial write-response facts. Facts outside a later view remain available from the response; omission counts as removal only within the read's declared coverage. Missing generated values remain absent in simulation rather than becoming synthetic nulls. This keeps incomplete evidence explicit while preserving the timing and clock-rule checks.
The fix was normally merged with the author's intervening restack, preserving both histories. On exact live head
5d00ff3c, 218 focused simulation, explanation and application tests passed using Node 24.18.0.check:fast,format:check, diff checks and the push gate passed. Regressions cover an abbreviated item view after a richer partial write response, covered removals, and incomplete clock observations. The history-budget and earlier target/provenance fixes remain. No provider execution or new resource measurements were performed.