Skip to content

feat(environment): spell a written clock as each view spells it - #6138

Merged
gensokyo-dev merged 136 commits into
morluto:mainfrom
earakely-scale:feat/environment-view-clock-spelling
Oct 22, 2026
Merged

gensokyo-dev merged 136 commits into
morluto:mainfrom
earakely-scale:feat/environment-view-clock-spelling

Conversation

@earakely-scale

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

Copy link
Copy Markdown
Contributor

Summary

Refs #4933. Preserve each view's recorded clock spelling for newly written local state. Item/list analysis and serving use the same renderer; existing recorded per-view values are unchanged. Adds optional clock_formats with at most nine fraction digits. No target execution or remote application writes.

Initially integrated onto main 7ec9b6e; refreshed onto 5bda0a7, preserving the author's concurrent heap-floor fix, preserving the merged list-query, whole-proof, omission and projection behavior. Fixed all three existing review findings at their owners: the clock parser retains exact sub-millisecond facts; one per-field learner replaces growing format histories with a single format/mixed marker; and retained maps, keys, formats and returned members are charged before retention. Preliminary query probes do not learn clock state. Rendering reuses parsed precision instead of reparsing source text. No speculative cache or second adapter implementation.

Executed validation

  • 755 related source tests passed, including exact micro/nanosecond inequality, equivalent offsets/trailing zeros, learner/output tight-budget checks and constant retained state at 4 versus 1024 incompatible formats. The original precision and budget guards failed before the fixes; positive controls passed.
  • 67 real compiled CLI/MCP boundary tests passed: serving/export/compare, retained Evidence, named advertised output contracts, JSON Schema validity and compact schemas.
  • check:fast (typecheck/lint), formatting, metadata and architecture guards passed. An initial full check stopped on a duplicate export also reproduced on unmodified main 7ec9b6e. Main subsequently fixed it independently; after syncing, the complete full check passed (all six tasks plus architecture guards), as did ten latest-main focused serving/gate tests. Docs check and discovery of all 2053 tests passed. One push hook accidentally used system Node 20; rerun with pinned Node 24 is recorded separately, not counted as a code failure.
  • Independent local Codex CLI source review found no definite new defects in the integrated/fixed boundaries. This is automated review, not a human attestation.
  • Five pinned public capture Evidence datasets (Directus/Homebox/Mealie/Keycloak/Shlink) ran through compiled CLI and stdio MCP with named output schema validation, exact adapter fact/Evidence-ID parity and source-byte SHA-256 checks. Only Mealie's state changes versus main: its recipe list learns three +00:00 clock formats; every served-write verdict is unchanged. No live applications were executed.
  • Complete fresh-process five-capture task under concurrent host load: main 48.10 s wall / 70.53 s CPU / 1158 MiB sampled process-family RSS; candidate 47.11 s / 69.33 s / 1151 MiB, no surviving child processes. One pair, 500 ms RSS sampling, filesystem caches not cleared: no exact-peak, cold-cache, speedup or model-token reduction claim. The format learner's retained state is bounded per field, not per distinct format.

Limitations

Public captures qualify retained-data analysis, not live application persistence, the author's full historical 50-capture census, or real native-provider/Windows behavior. Full author experiments remain in docs/specs/agent-environments/view-clock-spelling/verification.md and were not independently rerun in full. Existing epoch rendering semantics remain unchanged; exact ISO fraction preservation is verified through nanoseconds.

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.

earakely-scale and others added 30 commits October 19, 2026 17:29
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 <[email protected]>
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 <[email protected]>
… 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 <[email protected]>
…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 <[email protected]>
… 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 <[email protected]>
… 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 <[email protected]>
… 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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
# 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 <[email protected]>
… 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 <[email protected]>
…-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 <[email protected]>
…-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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
…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 <[email protected]>
… 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 <[email protected]>
… 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 <[email protected]>
earakely-scale and others added 12 commits October 21, 2026 21:17
…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 <[email protected]>
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]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
earakely-scale and others added 2 commits October 21, 2026 23:17
…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 <[email protected]>
@earakely-scale
earakely-scale marked this pull request as ready for review October 22, 2026 14:57
@chatgpt-codex-connector

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-22T14:57:20.382071Z
We couldn’t complete this review. Comment @codex review to try again.
5e4a31d 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no actionable issues remain in the reviewed changes.

Summary

Adds per-view clock formats for newly written local state while preserving recorded values.

  • Item and list views spell new entity clocks like their recordings.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Recorded clock values] --> B[Compare exact instants]
  B --> C[Learn one consistent format per field]
  C --> D[View clock_formats]
  E[Local write] --> F[Stored entity fields]
  D --> G[Shared renderer]
  F --> G
  H[Recorded per-view values] --> G
  G --> I[Write checks]
  G --> J[Served reads]
Loading

Reviews (2) · Last reviewed commit: "chore: refresh clock spellings with late..." · Reviewed by Greptile

gensokyo-dev and others added 4 commits October 22, 2026 16:00
# Conflicts:
#	src/application/environment/environmentStateWriteAnswer.test.ts
#	src/domain/analysisView/environmentStateGate.ts
#	src/domain/analysisView/environmentStateWriteValues.test.ts
#	src/domain/analysisView/environmentStateWrites.test.ts
#	tests/fixtures/environmentStateWrites.ts
Keep exact sub-millisecond facts at the parser, use bounded per-field format states, charge retained output, and preserve current list-query proof semantics.

Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
Remove the redundant exported minimum alias that Knip reports as a duplicate export. Preserve the decoder floor, validation, launch flags, and diagnostics.

Validated alongside the author's clock fixes: 1088 source tests, 18 focused tests, npm run check, and npm run docs:check passed.
@gensokyo-dev
gensokyo-dev merged commit 957bcfa into morluto:main Oct 22, 2026
1 of 3 checks passed
@gensokyo-dev

Copy link
Copy Markdown
Collaborator

Merged as 957bcfa, preserving the author concurrent heap-floor fix and latest main. Actual merge commit rebuilt: all 10 selected gate/CLI/MCP tests passed again. Before merge: 755 related source tests, 67 boundary tests, full static check after latest-main sync, docs and discovery passed. Five pinned public captures passed real CLI/MCP named-schema and Evidence parity; only Mealie clock formats changed, no write verdict changed. Workload comparison: baseline 48.10 s / 70.53 s CPU / 1158 MiB sampled family RSS; candidate 47.11 s / 69.33 s / 1151 MiB. Host load/warmth uncontrolled; no speedup/token claim. All three original review threads addressed; independent local Codex source review found no new definite defect. Used authorized bypass while new-head GitHub CI/review remained unfinished, not counted as passed. No coauthor trailer; no live application or native-provider qualification.

@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: setup Setup, packaging, upgrade, install, Doctor, and client registration labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants