Skip to content

feat(environment): serve creates whose answers show less than reads, and whole-object updates - #7080

Merged
morluto merged 4 commits into
morluto:mainfrom
earakely-scale:feat/environment-write-views
Oct 25, 2026
Merged

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

Conversation

@earakely-scale

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

Copy link
Copy Markdown
Contributor

Summary

Agents built environments from a prompt for five applications the prompt flow had never seen: Vikunja, Ghost, EspoCRM,
Paperless-ngx and Miniflux. Most of their creates and edits were withheld, and two write-model gaps accounted for most
of them:

  • A create's answer is another view of the entity than its reads.
    • Paperless answers a tag create without the document_count its item read shows.
    • EspoCRM answers a contact create without nine fields its item read shows.
    • Ghost answers a tag create without the count its list shows.
    • Vikunja answers a label create with clocks to the nanosecond where reads show whole seconds.
    • The state built the new entity from the answer alone, so the read-back contradicted the create.
  • A whole-object update sends back what the application derives.
    • Paperless's UI sends a tag's old slug with its new name, and the application slugs the name anew.
    • Ghost's UI sends the updated_at it read, and the application stamps a new one.
    • The update was withheld as unexplained-change, or its first call's value was pinned so later calls conflicted.

This PR handles both:

  1. Read-backs. A create's observation takes fields from the first read of its entity before the next write
    (observation.read). The read must otherwise agree with the answer.
    • An item read lends the fields the answer lacks, plus its clock spellings, and then observes rather than checks.
    • A list read only adds fields the answer lacks, and still checks the create.
    • Serving merges the same recorded objects.
  2. Re-derived members. A sent update member stored as a fresh clock, after the call sent back the held one, is a
    clock rule. One stored as the slug of another member stored as sent is a slug rule.

Results on the same recordings, against main:

  • The held-out recordings serve 10 of their 20 targeted write tools instead of 8.
  • The held-out write tasks gain EspoCRM's contact create (0/3 to 1/3 with both models) and Paperless's tag rename with
    GLM (1/3 to 2/3).
  • The 69 recorded captures serve the same 132 writes, and no write goes from served to withheld.

Part of #4933 (agent-environment projection, serving and export).

Problem and expected behavior

  • A create whose answer leaves out fields its read-back shows, or spells its clocks to another precision, should be
    served with the fields reads show. It should still be answered in the application's answer shape.
  • A read-back that disagrees with the answer on any other value must still contradict the create.
  • An update that sends back the slug or modification time it read should be served with the application's re-derived
    value, accepting any sent value for that member.
  • Plans that need none of this must not change.

Change and scope

  • Read-backs (environmentStateWriteCreate.ts, environmentStateWriteObserve.ts):
    • withReadBack looks for the first read of the created id before the next write.
    • An item read that disagrees on a value, other than a clock spelled to fewer fraction digits (respelledInstant),
      leaves the observation as it was.
    • Otherwise withRead merges: item reads lend fields and clock spellings, list reads only add fields.
    • Only an item read is marked observed, which keeps a list read checking the create.
  • Plan and schema (environmentStateWriteRules.ts, environmentStateView.ts): observation.read holds the
    ordinal, pointer and shape of the read.
  • Serving (environmentStateWriteAnswer.ts): observedEntity merges the observation and its read with withRead.
  • Sent members (environmentStateWriteChanges.ts):
    • sentRule learns a clock for a member sent back as the held clock and stored as a fresh clock near the call.
    • It learns a slug for a member stored as the slug of another member stored as sent.
    • Both are accepted with any value.
  • Docs and spec: docs/web-network-captures.md, and docs/specs/agent-environments/write-views/.

Not included: these follow-ups surfaced in the same recordings:

  • Paperless list envelopes that list every id (all).
  • Ghost tag lists that leave out created tags.
  • Vikunja's partial created_by in create answers.
  • Strict required members for whole-object PUTs recorded through a UI.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the environment-state view's write plans
    (src/domain/analysisView), and served write answers (src/application/environment).
  • Contribution scope fit and linked maintainer decision: within the existing environment-state write model. It
    reads recorded captures only and adds no new target interaction.
  • CLI and MCP/tool-catalog contract:
    • No tool or argument changes.
    • environment-state write plans may carry observation.read, and update plans may carry clock and slug rules for
      sent members.
  • Provider, bridge, target-format, or platform compatibility: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract:
    • State views and bundles built by this version may hold observation.read. Earlier REA versions refuse it, because
      the schema is strict.
    • Earlier views parse unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • 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

How the held-out recordings were made.

  • Claude Code (claude-sonnet-5-5) built each environment from a one-paragraph prompt on Ubuntu VMs, with REA at main
    475f09d5 (skill v49).
  • Miniflux's first run produced no bundle: its API takes only Basic auth or an API key, which the recorder cannot
    construct. Its second run was given an API key.
  • Every bundle rebuilt byte-identical and passed smoke. Retrieval passed 38/38 with gpt-oss and 27/38 with GLM.

Census, environment-state views on main and on this branch:

Captures Served on main Served here Served to withheld
69 recorded 132 132 none
5 held-out (20 write tools with a target) 8 10 none
  • Now served:
    • EspoCRM's contact create: its read-back adds nine fields the answer lacks.
    • Paperless's tag edit: the stale slug is slugged anew from the name.
  • Past the read-back, withheld by other gaps:
    • Paperless's tag create: its list's all member lists every id, which rendering does not model.
    • Ghost's tag create and edit: the state does not list created tags in Ghost's tag lists.
  • Still contradicted: Vikunja's label create. Its item read-back shows a fully loaded created_by where the answer
    showed a partial one, and that is a disagreement this PR deliberately keeps.

Served write tasks. The held-out round's write tasks, rebuilt from the same recordings with this branch:

Application Main (gpt-oss, GLM) This branch (gpt-oss, GLM)
EspoCRM contacts: create, update email, delete 0/3, 0/3 1/3, 1/3 (create)
Paperless tags: create, rename, delete 1/3, 1/3 1/3, 2/3 (rename with GLM)
  • gpt-oss's rename did not apply, and the cause is unconfirmed because its trajectory was not kept. A served PUT
    requires every member the recorded call sent (about 14 here); GLM sent them all.

Tests added: each fails on main.

  • View:
    • a create whose item read adds a count and respells its clock;
    • a create whose only read-back is a list adding a count;
    • a rename that sends a stale slug;
    • two edits that send back the modification time they read.
  • Serving:
    • a created tag answers in the application's answer shape and reads with the read-back's count;
    • a created label lists with its count;
    • a rename re-derives the slug from whatever slug is sent;
    • an edit stamps a new modification time rather than storing the sent one.
  • Existing: the tests where a read-back that disagrees on a slug, or on a nested clock, still contradicts or still
    restamps pass unchanged.

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

Review follow-up (dc4db9081, 1cfc598b6)

  • Reconcile compatible slug/echo and clock/held-clock saves in either recording order. Check earlier slug-only calls too: without the source, serving keeps the field, so a recorded change contradicts the rule.
  • Keep item read-back omissions as contradictory evidence; compare clock fractions through nanoseconds at the coarser recorded precision.
  • Preserve create-response clock precision independently of stored read-back precision.
  • macOS, Node 24.22.1, npm 11.16.0: npm run check passed; environment-state source tests passed (38 files, 1,040 tests); compiled served-writes MCP/serve CLI tests passed (2 files, 12 tests). docs:check passed at dc4db9081; documentation is unchanged in the second fix.
  • Seven regression cases failed on the original PR head. The additional changed-slug-only case failed at dc4db9081. MCP SDK coverage verifies incompatible slug-only tools are withheld in either call order; unchanged slug-only saves remain covered as compatible.
  • Greptile reviewed 1cfc598b6 with no remaining findings (5/5). Codex re-review could not run because the integration reported insufficient review credits.
  • Coverage uses synthetic captures and the local CLI/MCP server. The real-application recording census and held-out agent tasks below were not rerun for these fixes.

Original author validation, before the review fixes:

Run on macOS with Node v24.22.1 at 421d2410 (main 8e6a9578 and this branch).

  • npm run check (build, typecheck, format, lint, typed lint, module boundaries, architecture guards) and
    npm run docs:check: passed.
  • npx vitest run --project domain --project services --project adapters: 17,624 passed, 25 skipped, 1 failed ("stops
    Inspector target authorization after the current stat settles"), which fails the same way on main in this environment.
  • npm run test:focused -- the analysis-view, environment build, compare, export and serve CLI boundaries, the
    analysis-view, environment bundle, serve and served-writes MCP boundaries, tool schema validity, output schema profile
    and MCP schema validation: 12 files, 106 passed.
  • The environment domain and application tests: 1,742 passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for callers. Bundles and state views built by this version need it or
    later to serve.
  • Real Hopper/Ghidra, browser, or OS coverage: recordings from real applications on Ubuntu 24.04. Gates ran on
    macOS.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads recorded captures only.

Author readiness

Human owner:

  • 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 and others added 2 commits October 24, 2026 22:49
…pdate members

- A create's observation takes the fields the first read of its entity
  shows that the answer lacks, and an item read's clock spellings, when the
  read agrees with the answer otherwise. The plan records the read
  (observation.read with its shape); an item read then observes rather than
  checks, a list read only adds fields and still checks. Serving merges the
  same recorded objects.
- An update member sent back as the clock the entity held and stored as a
  fresh clock near the call is a clock rule; one stored as the slug of
  another member stored as sent is a slug rule. Both are accepted with any
  value, as whole-object writes send what they read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining slug-only edit finding is addressed.

Summary

This PR lets create plans borrow compatible read-back fields and learn regenerated slugs and clocks from whole-object saves.

  • Create plans combine a write answer with its first useful read-back.
  • Whole-object updates can re-derive echoed slugs and timestamps.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Create answer] --> C[Check compatible read-back]
  B[First read before next write] --> C
  C --> D[Stored entity]
  D --> E[Learn write rules]
  F[Earlier update calls] --> G[Check promoted rules]
  E --> G
  G --> H[Serve confirmed writes]
Loading

Reviews (3) · Last reviewed commit: "fix(environment): reject incompatible sl..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review October 25, 2026 06:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T06:50:28.015963Z
We couldn’t complete this review. Comment @codex review to try again.
1cfc598 Manual request
ℹ️ 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.

@morluto

morluto commented Oct 25, 2026

Copy link
Copy Markdown
Owner

@codex review

@morluto

morluto commented Oct 25, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@morluto
morluto merged commit 113679c into morluto:main Oct 25, 2026
40 of 45 checks passed
@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
@morluto morluto added the enhancement New feature or request label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants