Repository navigation
feat(environment): render more read tools from the state and describe responses - #5352
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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no new blocking issue was found. SummaryExpands
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Recorded reads] --> B{Entity plan passes checks?}
B -->|Yes| C[Item or list view]
B -->|No| D{One usable initial request line?}
D -->|No| E[Recorded replay]
D -->|Yes| F{Changed across a write or too large?}
F -->|Yes| E
F -->|No| G[Document view]
A --> H[Bounded response summary]
H --> I[Tool catalog with MCP hints]
Reviews (11) · Last reviewed commit: "test(environment): pin the replay card t..." · Reviewed by Greptile |
… responses Keep main's environment serving and fold in coverage for non-entity reads, response summaries, and MCP tool annotations. Squashed rebase of morluto#5352 onto main.
67b94b1 to
95c8c9d
Compare
…tate Serve write tools whose later reads confirm the effect, and keep main's state-file ownership and part-wise reply measurement. Squashed rebase of morluto#5600 onto the rebased morluto#5352 tip.
…heir budgets A recorded body of exponential numbers can render past 256 KiB and turn a working read into a state size error, so that document stays a recorded replay. Description samples are measured after JSON quoting, and the replay-fallback catalog check uses a tool count the longer response descriptions still separate. Co-authored-by: morluto <[email protected]>
… responses Keep main's environment serving and fold in coverage for non-entity reads, response summaries, and MCP tool annotations. Squashed rebase of morluto#5352 onto main.
…tate Serve write tools whose later reads confirm the effect, and keep main's state-file ownership and part-wise reply measurement. Squashed rebase of morluto#5600 onto the rebased morluto#5352 tip.
… responses Keep main's environment serving and fold in coverage for non-entity reads, response summaries, and MCP tool annotations. Squashed rebase of morluto#5352 onto main.
…tate Serve write tools whose later reads confirm the effect, and keep main's state-file ownership and part-wise reply measurement. Squashed rebase of morluto#5600 onto the rebased morluto#5352 tip.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The replay-only card test pinned main's 11,131-byte card. This branch's descriptions name each tool's recorded responses, so the card it serves is 12,818 bytes; the pin and its name follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep served write plans and the Greptile fixes, and keep morluto#5352's response summaries, replay-card pin, and squash note. Restore the SAZ zero-byte member note and the state-file close notes the write squash had dropped from main. Co-authored-by: morluto <[email protected]>
…tate (#5600) * feat(environment): render more read tools from the state and describe responses Keep main's environment serving and fold in coverage for non-entity reads, response summaries, and MCP tool annotations. Squashed rebase of #5352 onto main. * fix(environment): keep rendered documents and quoted samples inside their budgets A recorded body of exponential numbers can render past 256 KiB and turn a working read into a state size error, so that document stays a recorded replay. Description samples are measured after JSON quoting, and the replay-fallback catalog check uses a tool count the longer response descriptions still separate. Co-authored-by: morluto <[email protected]> * feat(environment): apply evidence-gated write effects to the served state Serve write tools whose later reads confirm the effect, and keep main's state-file ownership and part-wise reply measurement. Squashed rebase of #5600 onto the rebased #5352 tip. * fix(environment): bound and validate write state history * feat(environment): render more read tools from the state and describe responses Keep main's environment serving and fold in coverage for non-entity reads, response summaries, and MCP tool annotations. Squashed rebase of #5352 onto main. * fix(environment): keep rendered documents and quoted samples inside their budgets A recorded body of exponential numbers can render past 256 KiB and turn a working read into a state size error, so that document stays a recorded replay. Description samples are measured after JSON quoting, and the replay-fallback catalog check uses a tool count the longer response descriptions still separate. Co-authored-by: morluto <[email protected]> * feat(environment): apply evidence-gated write effects to the served state Serve write tools whose later reads confirm the effect, and keep main's state-file ownership and part-wise reply measurement. Squashed rebase of #5600 onto the rebased #5352 tip. * fix(environment): bound and validate write state history * fix(environment): bound additional collection history * fix(environment): credit sent fields, negative sequences, and encoded targets A later overwrite copied surviving derived fields into the sent-member claim, so a members-only check rejected an update whose sent field still matched. Serving floored sequences at zero and stored missing history as zero, so a collection sequence learned from negative ranks skipped the next value. An absence after a delete forgot the resolved collection, and an encoded read could not observe an update spelled with another collection encoding. Regression tests cover each case. Co-authored-by: morluto <[email protected]> * test(environment): cover resolved encoded update identities * fix: validate timed update observations * fix(environment): share write overlap and check clocks on earlier calls Observation search skips a read begun before the write ended. That comparison now uses the same overlap as the check path. A clock learned on a later call was not checked against earlier calls that kept the field. Serving would stamp those calls too, so the plan stays unserved. A clock learned earlier is still refused when a later call does not advance it. Regression tests cover an overlapping empty update and a published_at clock that one recorded call leaves unchanged. Co-authored-by: morluto <[email protected]> * fix: preserve partial update evidence * fix(environment): let an unmodelled write explain only the list members that differ A failed whole-list read now reports which members alone account for the difference. An unmodelled write excuses the read's writes only when it came after each such member's last check and pending writes, so an older change elsewhere no longer hides a newer write the list shows undone. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 7b6aab9d7191e600051693f2c192afcfc743d083) * fix(environment): explain added fields, tie creates to serving's collection, and bound write descriptions An update explains a field the entity lacked before when the observing view had shown the entity, so a server-filled field is not dropped. A create is tied to the held collection serving picks for its path. Write descriptions and body refusals quote member names and sample them within a byte bound. The request body is indexed once per explanation, so copied and slugged fields no longer rescan it. Replays 07aca54e onto the restacked branch. Its rule that a read begun before a write ended teaches nothing is already here (fb6785d), so only its test is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(environment): state how list reads weigh unmodelled writes, added update fields and quoted members Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(environment): keep the observing view helpers with the observations shownBefore and the item-or-list fields check move to the observe module, keeping the write effects within the line limit. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(environment): resolve unmodelled writes onto the held collection An unmodelled path kept the request's collection spelling. An archive under the plain spelling of a collection held encoded marked only that plain collection unknown, so a later update was blamed for the archive's fields and dropped. Name that entity the way a modelled write does. Co-authored-by: morluto <[email protected]> * fix(environment): confirm no write through volatile fields or overwritten replacements, and bound the served clock A members-only check no longer compares volatile fields, which render from the read itself. A document replacement credits the members it wrote or removed at its object, so a later merge that overwrites them takes its confirmation away. A recorded time past the range of a date gives no served clock instead of throwing. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(environment): leave unknown entities unchecked by failed reads, volatile fields and unchecked calls A failed item read that is no absence leaves an unknown entity unknown, so a later usable read still checks its writes. A read showing an unknown entity again checks no write on a volatile field. An update of an unknown entity takes its recorded outcome and adds nothing to a built plan. A later update that does not answer with its entity is observed only by a read whose view shows every learned clock; without one it is unmodelled. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(environment): fill a create's path fields from the collection serving 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 <[email protected]> * fix(environment): name unmodelled writes as modelled ones, count fields 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 <[email protected]> * fix(environment): let a document replacement overwrite everything under 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 <[email protected]> * fix(environment): start the served clock from the records whose times 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 <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: morluto <[email protected]> Co-authored-by: morluto <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Raises how much of an environment the
environment-stateview (#5319) renders from its state, and makes served tools say what they return. Read-only documents hold every non-entityGETread with one initial request line, identity can come from an...Id/..._idfield when no fixed name identifies the items (proved by two distinct items), single entities wrapped in a one-element array ({"posts":[{...}]}) are located, served tool descriptions summarise each tool's recorded response, and served tools carry MCP annotations. On 44 recorded captures, 1,011 of 1,277 read tools render from the state, against 625 without this change.Refs #4933 (design discussion; scope decision requested there).
Builds on #5319, now merged; the diff against main is this change only.
Problem and expected behavior
Half of the read tools still replayed recordings: settings, configuration and other singleton reads had no place in the state unless the capture wrote them, lists keyed by
orgId-style fields had no identity, Ghost-style detail responses wrap their entity in an array, and agents saw only a method and path per tool. The expected outcome is a state that covers those reads and tool descriptions an agent can choose from.Change and scope
EnvironmentStateExtraction.ts: documents for every non-entityGETread with one initial request line, written or not;not-entityis retired andpath-variesnames a read under more than one path. Identity inference still requires listed items, as feat(environment): extract the initial state a capture's reads observed #5319 does.environmentStateRules.ts: suffix identity candidates afterIDENTITY_NAMES, accepted only when two items in one recording show them distinct; pointers/0and/<member>/0for a one-element array.environmentTools.ts: a response summary per tool from its first JSON-like recorded exchange (fields of an object, an array of objects, or an envelope's list), plus the manifest's statuses, charged to the catalog reservation.serveEnvironment.ts:readOnlyHint,destructiveHint,idempotentHintandopenWorldHint: falseper tool; the card is unchanged.Follow the contribution scope.
Contract and boundary impact
inspect_analysis_viewenvironment-state results gain document views and thepath-variesreason, losenot-entity; served tool descriptions and MCP annotations change; no new tooldocs/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): the generated catalog picks up the updated view description; no package or installation changeExpected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
no-identity216 to 32,not-entity310 to none.For evidence-bearing changes:
Validation performed
npm run check:fast,npm run format:check,npx knip,npm run scan:todos,npm run docs:check: passed.npm run jscpd: 3.39% duplicated lines over 3362 files (gate 3.5%).npx vitest run --project domain --project services: 344 files, 5914 tests passed, 5 pre-existing skips.npm run build:cached, thennpm run test:focused --serve and tool-definition adapters, serve MCP and CLI boundaries, export CLI, analysis-view MCP and CLI boundaries, compact input-schema budget and two contract tests: 10 files, 98 tests passed.npm run check:fastpassed;npx vitest run src/domain/analysisView src/application src/server/environment src/contracts: 137 files, 1801 tests passed, 5 pre-existing skips.GET /api/mearoundPOST /api/orders) is recorded asfields-differinstead of publishing the post-write value, matching entities; the RFC 9110 safe methods (GET,HEAD,OPTIONS,TRACE) are nowreadOnlyHintandidempotentHint, so a CORS preflight tool no longer falls to the destructive default. Two new tests. tsc, module boundaries, test discovery, knip and docs:check clean; vitest over src/domain, src/application, src/contracts, src/server and src/cli: 7256 passed, 5 skipped; after test:prepare, analysis-view and environment serve/export CLI/MCP and CLI-startup boundary files (55 tests) and tests/conformance (279) passed; mcp-catalog:check passed./0item pointers and the new tests found nothing else; the branch still merges cleanly with main. vitest over src/domain, src/application, src/contracts, src/server and src/cli: 7256 passed, 5 skipped; module boundaries clean."x; recorded statuses 500"no longer makes a description claim a status the tool never recorded (new test). The CI failures on b4b7ebc (tests/boundary/cli/doctorCancellation.test.ts, kuna SIGINT/SIGTERM, arunIdthat is not a UUID) are main's: main's own CI run on eb7acc7 fails the same two tests, and this PR touches no doctor or Kuna code. vitest over src/domain, src/application, src/contracts, src/server and src/cli: 7270 passed, 5 skipped; after test:prepare, analysis-view and environment serve/export CLI/MCP and CLI-startup boundary files (55 tests) and tests/conformance (279) passed; mcp-catalog:check and docs:check passed.check:fast, format, knip, todos, docs, test discovery, module boundaries and catalog passed; domain and services 7262 (5 pre-existing skips); focused boundaries 66; conformance;jscpd3.49%.rendered-oversize), kept description samples within budget after JSON quoting, and refitted the two tests the squash left failing.check:fast, format, knip, todos, docs, discovery, module boundaries and catalog, andjscpd(3.49%). The environment, analysis-view and contract tests across the boundary, MCP, CLI, process, acceptance and conformance projects pass: 37 files.npm run test:fastpasses apart from unrelated tests.JavaScriptRuntimeScope.cancellation"stops Inspector target authorization after the current stat settles" fails the same way on main here (macOS). The rest are timeouts in heavy domain, adapter and composition tests, which pass when rerun alone; one worker test fails on alternate runs.Compatibility, safety, and release
path-variesadded,not-entityremoved.Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.🤖 Generated with Claude Code