Repository navigation
feat(environment): list every entity on a list's whole lines - #5787
Conversation
Add the environment-state analysis view. From the parents the environment manifest accepts, it extracts the data the capture's reads observed before the first related write: entity types with an identity field (proved by a path parameter or inferred from an identity name), entities with their recorded values and provenance, documents for written non-entity paths, and a render plan per read tool that is kept only when it reproduces the tool's latest initial recordings from the state; every other read tool is a recorded view with the reason. The Evidence is always inferred. Response-body decoding moves to a domain owner shared with replay, exact JSON parsing moves to the owner of the exact-number policy, the manifest and state views share parent admission and record grouping, and projectAnalysisView takes its accumulators as one object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the IL2CPP metadata view's edits to the shared refusal message and the inspect_analysis_view description alongside the environment-state view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… from items A scenario write whose URL was redacted has no request line, so it was dropped and reads after it counted as initial state. Such a successful write now joins the timeline with an empty path, whose root relates to every type, so it ends every type's state; a limitation counts them. A list whose recordings were all empty passed the "every listed item carries it" check vacuously and published an identity field nothing showed; it now needs at least one item, else the view stays recorded as no-identity. A value that differed between two request lines of one item tool, such as a query variant, was called volatile, and the gate then substituted each recording's own value; only repeats of one request line now show volatility, so differing lines go through fields-differ. List membership is compared only while a list can still be the whole collection, and merged entities are indexed by type and collection once, so paged captures no longer cost pages times entities (8,000 pages of 40,000 entities: 5.7 s to 0.23 s). Docs and the tool contract say scenario state keeps the capture's redaction markers and how redacted writes bound it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ield unions Entities took the order of the first plan observed, and item plans run before list plans, so a complete list read before its detail reads came out reordered and lost "all" membership; each entity now keeps its earliest recorded sighting. A list plan reused the first recording's pointer for later recordings, so a later response that was itself an entity wrapping a list was read as that list; every recording must now locate the same list. The field union scanned its ordered list for every key, quadratic in an object's width; a set now answers membership. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… initial state A value that changed between repeats of one request line was named volatile whenever no write under the type's own root lay between, so a write under another root (for example POST /api/dashboards/db before a second GET /api/search) left its effect in the initial state. Any recorded write between the two observations now leaves every tool of the type recorded with reason fields-differ instead. A list was published with membership "all" even when a total or count envelope member exceeded the number it listed. Such a counter now makes the membership "recorded". Also drop a stale doc comment on ObservedEntity.order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… documents State documents are held only for list-shaped paths a POST, PUT or PATCH tool writes. Reads of item-shaped written paths and of paths that are only deleted stay recorded views; the guide now says so and the spec defers them to a later increment of morluto#4933. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reads The volatility check compared write start positions with the two reads, so a write already in flight when the earlier read started was missed and its effect was named volatile. A write now counts when its interval overlaps the span from the earlier read's start to the later read's end. The check also ran once per changed field and scanned every write. It now runs once per pair of observations, answered by a binary search over the writes in timeline order and the latest end among each prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the inspect_analysis_view description conflict with morluto#3634 by keeping main's inventory wording and adding the environment-state sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The inspect_analysis_view contract text conflicted: main's Godot PCK and inventory wording and this branch's environment-state sentence touch separate parts of it and are both kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tem totals A value that changed across a write was caught only between repeats of one tool's request line, so a list read before a write and an item read after it put the post-write value into the initial state. Changes are now classified per entity in timeline order after observation: across any recorded write, a change between repeats of a line or between two lines of the type rewrites the type (every tool recorded as fields-differ); with no write between, a repeat's change is volatile. The classification lives in environmentStateMerge.ts. Any numeric member whose name contained "total" or "count" counted as an item total, so total_pages, account_id or page_count made complete lists partial. Item totals are now members whose name tokens include total or count and none of page, pages or per; a string of digits counts as a number; and a set has_more, next or next-page token member also marks the list partial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolved against both sides' intent: the shared templateRulesSchema keeps main's description naming sibling-pair-variance; scenario admission keeps main's derived-text reservation and this branch's response-body requirement for the state view; the MCP test keeps the state test and main's renamed file-source manifest test; the contract text keeps both insertions. main's new scenario admission test passes the view kind the state view added to admitScenarioCaptureParent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/contracts/analysisViewToolContracts.ts # src/domain/analysisView/scenarioCaptureRecords.ts # tests/boundary/mcp/analysisViewMcp.test.ts
`environment-serve --state <state.json>` serves an environment from the initial state an environment-state view extracted. Read tools whose views are state-backed answer from a live state store: item views render the held entity into the recorded envelope, list views render the collection or the recorded members, and document views return the held value; a missing entity or one lacking a required field is refused, and requests the state cannot answer fall back to their recordings with the reason. The /agentenv data plane implements data/reset, data/add (a rea-state/v1 document as a data part, base64 bytes, a file:// path or an https URL, validated and replaced atomically) and data/get, and the card advertises those operations and an intake declaration. Stage 1 is read-only: write tools are not served in state mode. Without --state nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… responses
The environment-state view now holds every non-entity GET read with one
initial request line as a read-only document, infers identity from an
`...Id`/`..._id` field every listed item carries distinctly when no fixed
identity name does, and locates single entities wrapped in a one-element
array (`{"posts":[{...}]}`). Served tool descriptions say what each tool
returns, from its own recorded exchanges, and tools carry MCP annotations
(read-only, destructive, idempotent, closed world). On 44 recorded captures
the state renders 1,016 of 1,258 read tools, up from 710.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-state-serve Keep the state view's redacted-write bound beside the serve path's shared body-usability rule, and restore the test imports both sides use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-state-coverage Keep the view's rewritten-type refusal, one-list rule and earliest-sighting order beside the read-only document and suffix-identity rules: identity is still inferred only from listed items, and a read that is no list becomes a document. The two view tests about such reads now expect documents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… review fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… review fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t-state-coverage morluto#5319 is on main as one squashed commit with the same content as the branch this work was stacked on, so the branch's side of each overlapping hunk is kept; morluto#5349's analysis-view changes merge as they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t-state-serve morluto#5319 is on main as one squashed commit with the same content as the branch this work was stacked on, so the branch's side of each overlapping hunk is kept; morluto#5349's analysis-view changes merge as they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed value identifies built every value before checking, so a wide first item followed by many sparse items cost a full scan per suffix-named field. It now returns at the first missing or repeated value; a regression test counts reads over a 2,000-field item and 5,000 empty ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
environment-serve derives the environment state at startup by running the environment-state view in-process on the capture with the manifest's template rules, so an environment comes with its state and a user supplies nothing extra. The derived Evidence is the same one inspect-analysis-view produces by hand. --state is removed; --replay-only serves exactly the stateless replay of main. When the state cannot be derived, or its catalog does not fit the discovery budget, the server starts in replay mode, logs the reason and reports it in the stop summary's `state`. Exported bundles serve the state by default too: export derives it the same way, so the verifier's tool count and checked answer match what is served, and the README describes the served mode. BREAKING CHANGE: environment-serve answers read tools from the derived state and does not serve write tools unless --replay-only is given; the stop summary reports `state` instead of `state_evidence_id`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…intake on stop - One /agentenv response is held to 64 MiB: replies are measured as they are produced and one past the budget becomes a -32000 error stating it. - Every message of a batch enters the arrival-order queue on arrival, so another request's reset never lands between them. - Stopping the server, or a caller leaving, cancels the active download and answers queued calls `cancelled` without running them. - file:// URIs name only this host: another host or a network share is refused before anything is opened. - A loaded view value may not give an entity another identity. - List answers refuse a member lacking a field every recording carried, as item answers do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the state A recorded body at the JSON depth limit was accepted by extraction, then nested a few levels deeper as a document or entity value, so sealing the state Evidence threw and environment-serve and environment-export stopped instead of falling back. stateBodyJson, the one rule extraction and serving share, now treats a body nesting deeper than the limit minus 16 levels as unusable, so its tool stays a recorded view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… into feat/environment-state-coverage Keep main's tool description and change only its environment-state documents clause to this branch's rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rs 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 <noreply@anthropic.com> (cherry picked from commit 7b6aab9d7191e600051693f2c192afcfc743d083)
…ection, 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 <noreply@anthropic.com>
…d update fields and quoted members Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… lines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vations 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 <noreply@anthropic.com>
… lines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <morluto@users.noreply.github.com>
…tten 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 <noreply@anthropic.com>
…olatile 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 <noreply@anthropic.com>
…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>
… lines 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>
…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>
… lines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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>
…st main Keep the shared path decoder while integrating per-line membership. Admit whole-list lines only when paging establishes the collection's beginning; retain later or ambiguous pages as recorded membership after data/add. Cover first/later pages, aliases, malformed positions and repeated values with a fail-before serving regression and producer-boundary checks. Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
Maintainer verification of
|
| Completed task | Wall s | CPU s | Sampled family RSS MiB |
|---|---|---|---|
| Main public workflow | 20.46 | 28.73 | 505.76 |
| Candidate public workflow | 18.09 | 25.89 | 490.87 |
| Candidate workflow plus actual Codex investigation; grader exit 1 | 27.40 | 19.51 | 1011.16 |
| 392 adjacent source tests | 5.57 | 11.60 | 1191.79 |
| Latest-main integration public workflow | 10.09 | 15.79 | 496.78 |
| Actual merged revision public workflow | 10.04 | 15.90 | 494.59 |
935-byte environment catalog unchanged. Whole reply grows 12,570→12,869 bytes to include the missing entity. Warm three-read totals: main 40.20 ms, candidate 46.36 ms. Fresh runtime processes, uncontrolled OS/dependency caches and host load; one pair does not establish a speedup or token reduction. RSS sampled every 500 ms with PID/start-time identity; not a hard bound or kernel peak. CPU excludes sampler overhead. No observed descendants remained; cloud-CI resource costs and initial unprofiled commands were not measured.
Actual agent outcome and retained failed grader
Codex CLI 0.161.0 / gpt-6.1-sol made one get_repos_morluto_rea_labels({per_page:"100"}) call, no shell/other action. It correctly reported 45 labels, marker ID 12798270926, all-membership, exact source Evidence ev_02596d441ff827a9b2d665db8687eb2694b72fdd51e9575e91ea966ffb015299, and no GitHub modification. Its source wording explicitly distinguished local state, original capture provenance and uninspected live GitHub.
The outer runner exited 1 because the prompt did not specify an enum but the grader required the exact source string state. Original trace/exit/metrics were retained; no model rerun concealed it. The same trace's facts and exact source sentence were separately verified against the original observations and tool payload. A first regrading-script attempt also failed because Codex JSONL uses structured_content, not the direct SDK's camelCase; that script was corrected, not the trace. The failed agent runner closed its listener before its reset stage; reset passed in the separate non-agent public run.
Actual session usage: 78,736 input tokens, including 51,200 cached, 217 output. Includes the complete Codex session context; baseline agent usage was not measured. Small catalog bytes do not establish small overall model context.
Review / integration status
Merged normally, without bypass, by gensokyo-dev at 10:34:56 UTC, as 4043e71f6cb9c708b07f3f27e15dfc42663e73f3. Primary author earakely-scale retained; no Co-authored-by. Complete technical CI 39761493093 passed, including all eight shards and selected Windows/Apple/native-package/real-environment lanes. Readiness/title checks passed. Greptile completed the exact head with a successful check but confidence 1/5 due to the out-of-scope native-export finding described below; this is not claimed to be a 5/5 review. All attributable findings were addressed and no review threads remain unresolved.
The initial readiness job failed on an empty owner placeholder; the existing contributor checkboxes were left unchanged and factual owner @earakely-scale filled in. Subsequent checks and the corrected-job rerun passed; no new human-review attestation was made.
Main advanced to 932fbb7d8 with two unrelated commits, no overlap with the feature. An isolated no-conflict integration with reviewed 36571c494 produced tree f9adc9a9dae1f7f771965e48f77ad61aaad5a65e; its build and the same real retained-data public workflow passed again (row above). This is an executed integration-tree check, not a claim that the PR head changed or was already merged.
The actual merge's entire tree equals that tested integration tree. Rebuilt actual merge and reran all 491 related source tests plus the complete real retained-data public workflow; all passed, including local loaded-fact provenance, partial pages and exact reset. Profiled actual-merge task appears in the last table row.
GitHub's PR metadata had remained pinned to old base 538017d1, displaying 332 files and causing a review of intervening main code. Reapplying base=main refreshed the PR to 932fbb7d8 and the actual 18-file delta without changing head. Greptile's native-export allocation finding concerns a file byte-identical to already-merged main and absent from this PR; it is separately recorded in #6262 as source-derived, with no runtime OOM reproduction or repair claim. Its attribution thread was resolved after fixing the stale base metadata, not as a repaired parser bug.
Pre-existing ignored write-query modes, encoded create-observation matching and fallback-absence ordering are tracked separately in #6262 and not claimed fixed here. Review agreed the latter two are not introduced by this PR; all three attribution threads were resolved as independent baseline issues with explicit explanations, not as repaired bugs. No live application-write fidelity, full published-capture census, zero-/one-based page inference, or exhaustive scale qualification is claimed.
…gned values Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
A list view serves either every entity of the collection (
membership: "all") or only the entities each recording listed (recorded). It wasallonly when every checked line of the tool listed the whole collection. One filtered line (?library_id=…,?name=…) therefore kept all of the tool's lines to their recorded members. An entity a task loaded withdata/add, or a served write created, then never appeared in that tool's lists, even on the unfiltered line where the application had shown it lists everything.This PR decides that per line. It also stops a whole list from confirming a create whose entity a read has already shown gone.
Part of #4933. Stacked on #5600, merged in at
dc5e2aad; until #5600 lands, the diff against main includes it. The new work is:environmentStateGate.ts,environmentStateRules.ts,environmentStateView.ts: per-line membership and the counter names;environmentStateWriteChecks.ts,EnvironmentStateWriteSimulation.ts: per-line checks and insert retries, and dropping a write from its collection on an observed absence;environmentStateAnswer.ts: per-line serving;docs/specs/agent-environments/list-lines/.Problem and expected behavior
all_record_ordinals, each checked line that meets the conditionsallasks of every line:allview. An argument-less call may answer on any whole line. Other lines keep their recorded members.numberOfElementsand similar number-of-items names count the listed entities, so Komga-style envelopes follow the state.Change and scope
Contract and boundary impact
src/domain/analysisView/), then serving (src/application/environment/).inspect_analysis_viewoutput gains an optionalall_record_ordinalson list views.numberOfElementscounter, changes and so gets a new Evidence id. A state supplied toenvironment-servekeeps loading, since the member is optional.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.
Evidence and regression coverage
Tests added.
environmentStateWrites, 3):numberOfElementsandtotalElements, and a create the whole line lists is confirmed;environmentStateWriteAnswer, 1): after a served create, the whole line lists the created book with its counters, and the filtered line keeps its recorded member.Executed evidence.
data/addloads and served writes change. Three of them back a type with a served write (Airbyte tags, BookStack books, Linkding tags).environment-compare, probes from feat(environment): compare an environment with probe captures of its application #5699 plus held-out sessions):Details are in
docs/specs/agent-environments/list-lines/verification.md.Remaining proof gaps:
For evidence-bearing changes:
Validation performed
Run on macOS with Node v22.23.1 at 4080063 (the last code change; the next commit is the verification record).
npm run build:cached,npm run check:fast(typecheck and lint),npm run format:check,npx knip,npm run scan:todos,npm run docs:check,npm run verify:test-discoveryandnpm run mcp-catalog:check: passed.npm run jscpd: 3.45% duplicated lines over 3646 files, under the 3.5% gate.npx vitest run --project domain --project services: 7616 passed, 5 pre-existing skips.npm run test:prepare, thennpm run test:focused --the environment serve and export CLI boundaries, the serve and served-writes MCP boundaries, the analysis-view CLI and MCP boundaries, the compact input schema boundary and tool schema validity: 8 files, 78 passed.check:fast, format, knip, todos, docs, discovery, module boundaries and catalog, with no oxlint warnings. Domain and services 7717 (5 pre-existing skips); boundaries 83; conformance 279;jscpd3.43%.totalto BookStack's pages andcountto Linkding's tags, and served write tools stay at 31. The six environments compare exactly as before._start–_endrange escaping the page cap, fields an update removed, entities named by a double decode, later creates' generated formats, an initial state too large to load back, zero page sizes erasing positive bounds, and interference timed by a tool's call on another collection.pageBound, and#retryInsertreads its line's collection directly to stay 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 7754 (5 pre-existing skips); environment boundaries 63; conformance 265;jscpd3.43%.check:fast, format, knip, todos, docs, discovery, module boundaries and catalog; domain and services 7835 (5 pre-existing skips); environment boundaries 63;jscpd3.47%.environmentStateAnswer.ts,environmentStateGate.ts,environmentStateWriteChecks.tsand two docs tables.writtenFieldChecksinto the attribution module, keeping the checks under the line limit.check:fast, format, knip, todos, docs, discovery, module boundaries and catalog; domain and services 7886 (5 pre-existing skips); environment boundaries 64;jscpd3.41%. On an earlier run of this round, two heavy domain tests (the keyed-archive traversal and the 125,000-dependent graph) timed out under load; they passed when rerun and on the final run.Compatibility, safety, and release
Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.🤖 Generated with Claude Code
Maintainer integration — 2026-10-22 (
36571c494)3a42a9e35, retaining its shared path decoder. No CI configuration changes and no Co-authored-by trailer.npm run check;npm run docs:checkincluding 9 README tests; pre-pushcheck:fast.62db6a3c0f0cd6be433f358fd5c3e13eaa058059a5b669bf557490527c3e23cf. Both CLI/MCP views agree exactly. Public environment serving returns all 45 local-state labels after adding a synthetic local-only label, keeps the one-item page unchanged, preserves the new entity’s empty record citations, and resets exactly. Baseline main incorrectly leaves the whole line at 44. No GitHub writes or live application-write fidelity claim.