Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ad439bd
feat(environment): extract the initial state a capture's reads observed
earakely-scale Oct 20, 2026
7a668b7
Merge main into feat/environment-state-view
earakely-scale Oct 20, 2026
f2c9a2e
fix(environment): bound state at redacted writes; infer identity only…
earakely-scale Oct 20, 2026
2999128
fix(environment): keep first sightings, one list pointer and linear f…
earakely-scale Oct 20, 2026
a5c7b92
fix(environment): keep post-write values and partial lists out of the…
kaoru0822-kitauji Oct 20, 2026
4e93547
docs(environment): scope item-shaped and deleted written paths out of…
kaoru0822-kitauji Oct 20, 2026
aba9cb1
fix(environment): count writes in flight when a value changes between…
kaoru0822-kitauji Oct 20, 2026
856c8c0
Merge main into feat/environment-state-view
kaoru0822-kitauji Oct 20, 2026
55480bd
chore: merge main (5fa4defc) into environment state view
earakely-scale Oct 20, 2026
9fee36d
fix(environment): catch cross-tool changes across writes; read only i…
earakely-scale Oct 20, 2026
3c64cbe
chore: merge the branch's own main merge (856c8c0b), identical to 554…
earakely-scale Oct 20, 2026
47f8a27
chore: merge main (f93a0335, rich captures) into environment state view
earakely-scale Oct 20, 2026
32fbaa5
chore: merge main into environment state view
gensokyo-dev Oct 20, 2026
04e2c56
fix(environment): keep post-write observations out of initial state
gensokyo-dev Oct 20, 2026
3daeebb
chore: retain author main integration in environment state view
gensokyo-dev Oct 20, 2026
25923c3
chore: sync environment state view with latest main
gensokyo-dev Oct 20, 2026
6ad63bc
fix(environment): retain field provenance and bound state inference work
gensokyo-dev Oct 20, 2026
2bd0b3c
feat(environment): serve tool calls from the environment state
earakely-scale Oct 20, 2026
9f60e54
Merge the environment state view's review fixes into feat/environment…
earakely-scale Oct 20, 2026
cb04dcd
docs(environment): record verification after merging the state view's…
earakely-scale Oct 20, 2026
e96484b
Merge main (#5319 squashed, #5349) into feat/environment-state-serve
earakely-scale Oct 20, 2026
6676582
feat(environment)!: serve the environment state by default
earakely-scale Oct 20, 2026
83fcc73
fix(environment): bound data-plane replies, keep batch order, cancel …
earakely-scale Oct 20, 2026
d9c0357
fix(environment): keep bodies too deep for the state's nesting out of…
earakely-scale Oct 20, 2026
57b1168
fix(environment): measure data-plane replies before building them
earakely-scale Oct 20, 2026
5956e00
chore: merge main (d2a3269d) into environment state serve
earakely-scale Oct 20, 2026
5a61853
fix(environment): release batch replies as they are encoded; judge ex…
earakely-scale Oct 20, 2026
c00fde4
fix(environment): keep room for refusals and framing in the reply budget
earakely-scale Oct 20, 2026
25b6622
chore: merge main (335c042d) into environment state serve
earakely-scale Oct 21, 2026
6b8db19
fix(environment): refuse a loaded state that data/get would write pas…
earakely-scale Oct 21, 2026
31a618e
chore: merge main (d9767eb4) into environment state serve
cursoragent Oct 21, 2026
96ce6c6
fix(environment): keep merged export checks on the shared test graph
cursoragent Oct 21, 2026
bfe9d4b
chore: merge main into environment state serve
morluto Oct 21, 2026
0da8e23
fix(environment): keep a state file whose close failed owned until it…
earakely-scale Oct 21, 2026
98a7511
fix(environment): attempt all state cleanup on close
morluto Oct 21, 2026
d681bfd
fix(environment): bound wide state JSON traversal
morluto Oct 21, 2026
e4a0fc6
chore: merge current main into state server fixes
morluto Oct 21, 2026
467828e
fix(environment): scope cached state reply sizes to requests
morluto Oct 21, 2026
05deae3
fix(domain): preserve JSON depth diagnostic guidance
morluto Oct 21, 2026
7c3d0e9
chore: merge current main into state server fixes
morluto Oct 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(environment): release batch replies as they are encoded; judge ex…
…act numbers by value

answerBatch kept every settled reply in its pending array until the
batch ended, so a batch alternating data/add and data/get held each
loaded state alive; each reply now leaves the queue as it is encoded.

The exact-number policy judged a number by its recorded spelling, so a
state loaded with 1e20 came back from data/get as
100000000000000000000, which data/add refused, breaking the promise
that data/get output loads back unchanged. A number is exact only when
both its recorded spelling and the one serialization writes are safe,
so integers from 2^53 below 1e21 are refused in any spelling; replay
keeps such bodies as recorded text. A domain test checks that every
accepted number is accepted again once written back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
earakely-scale and claude committed Oct 20, 2026
commit 5a61853a697a742153c9c3f797e7d58dc7e4ee5f
4 changes: 3 additions & 1 deletion docs/agent-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ calls find entities under the checked line's recorded path. Each document
names a `document` view once, at its initial document's `path`. The `version`,
and the `state_evidence_id` and `types` that `data/get` reports, must match
the served state, so a `data/get` result loads back unchanged. A number without
an exact native value or a `__proto__` member is refused rather than altered.
an exact native value, or whose serialized spelling would not be read as exact
(an integer from 2^53 below 1e21, such as `1e20`, in any spelling), or a
`__proto__` member is refused rather than altered.
An invalid document is `-32602` naming the first problem by JSON pointer, as in
`/rea_state/entities/3/collection` (also in `error.data.path`); a problem
inside caller data (`fields`, `value`, `types`) is located at that member, so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("replay JSON value fidelity", () => {
'{"id":9007199254740993}',
'{"id":9007199254740993.0}',
'{"id":9.007199254740993e15}',
'{"id":1e20}',
'[{"id":18446744073709551615}]',
'{"value":0.100000000000000005}',
'{"value":1e-1000}',
Expand Down
33 changes: 33 additions & 0 deletions src/domain/exactJsonNumber.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect, it } from "vitest";

import { isExactJsonNumber } from "./exactJsonNumber.js";

const spellings = [
"0",
"42",
"-7",
"1.5",
"0.1",
"1e3",
"1e-7",
"9007199254740991",
"9007199254740992",
"9.007199254740992e15",
"1e20",
"100000000000000000000",
"1e21",
"1.7976931348623157e308",
];

it("judges a number alike in every spelling, so an accepted number is accepted again once written back", () => {
for (const spelling of spellings) {
const value = Number(spelling);
if (isExactJsonNumber(value, spelling))
expect(isExactJsonNumber(value, String(value)), spelling).toBe(true);
}
expect(isExactJsonNumber(1e20, "1e20")).toBe(false);
expect(isExactJsonNumber(1e20, "100000000000000000000")).toBe(false);
expect(isExactJsonNumber(1e21, "1e21")).toBe(true);
expect(isExactJsonNumber(9007199254740991, "9007199254740991")).toBe(true);
expect(isExactJsonNumber(-0, "-0")).toBe(false);
});
11 changes: 9 additions & 2 deletions src/domain/exactJsonNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import { isSafeNumber } from "lossless-json";
import { jsonValueSchema, type JsonValue } from "./jsonValue.js";
import { safeParseJson } from "./safeJson.js";

/** Whether native JSON conversion and serialization preserve the recorded number. */
/**
* Whether native JSON conversion and serialization preserve the recorded number. Both the recorded
* spelling and the one serialization writes must be safe, so `1e20` and `100000000000000000000`
* are judged alike and anything accepted is accepted again once written back.
*/
export const isExactJsonNumber = (
value: number,
source: string | undefined,
): boolean =>
source !== undefined && isSafeNumber(source) && !Object.is(value, -0);
source !== undefined &&
isSafeNumber(source) &&
isSafeNumber(String(value)) &&
!Object.is(value, -0);

/** Parse JSON text whose every number survives native conversion exactly; undefined otherwise. */
export const parseExactJson = (text: string): JsonValue | undefined => {
Expand Down
3 changes: 2 additions & 1 deletion src/server/environment/serveEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ const answerBatch = async (
for (const reply of pending) void reply.catch(() => undefined);
const encode = replyEncoder();
const texts: string[] = [];
for (const next of pending) {
// Taking each settled reply off the queue releases it, and any state it holds, once encoded.
for (let next = pending.shift(); next !== undefined; next = pending.shift()) {
const reply = await next;
if (reply !== undefined) texts.push(encode(reply));
}
Expand Down
2 changes: 2 additions & 0 deletions src/server/environment/serveEnvironmentState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ describe("state data plane", () => {
});
for (const altered of [
'"login":9007199254740993',
// Exact in this spelling, but data/get would write it as digits it could not load again.
'"login":1e20',
'"__proto__":{"polluted":true},"login":"renamed"',
]) {
const reply = await plane.post(
Expand Down
Loading