Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
b49177e
fix(environment): keep read-only POSTs out of the write list
earakely-scale Oct 22, 2026
d5a1fa9
fix(environment): take an entity an unplanned write made when a read …
earakely-scale Oct 22, 2026
004b064
fix(environment): plan a create into the type its returned id is read…
earakely-scale Oct 22, 2026
d8f9c05
fix(environment): end a type's initial reads at the write its reads d…
earakely-scale Oct 22, 2026
64e472a
fix(environment): replay request lines that show entities in another …
earakely-scale Oct 22, 2026
28c3ae9
docs(environment): specify and record the state-target changes
earakely-scale Oct 22, 2026
48d7fae
fix(environment): keep a read-only POST a write when its evidence is …
earakely-scale Oct 22, 2026
5d48df7
fix(environment): answer a field selection only when the state shows …
earakely-scale Oct 22, 2026
ce2301d
fix(environment): hold adopted entities and linked creates to what th…
earakely-scale Oct 22, 2026
48106e1
Merge remote-tracking branch 'origin/main' into feat/environment-stat…
earakely-scale Oct 22, 2026
6656816
docs(environment): record the review fixes' measurements
earakely-scale Oct 22, 2026
22e27b1
fix(environment): release a discarded planning pass before planning a…
earakely-scale Oct 22, 2026
5702983
fix(environment): link no create whose id an earlier read showed, and…
earakely-scale Oct 22, 2026
0cf3b27
fix(environment): let the gate skip exactly the reads serving replays
earakely-scale Oct 22, 2026
096b1ca
Merge remote-tracking branch 'origin/main' into feat/environment-stat…
earakely-scale Oct 22, 2026
197b1a3
docs(environment): record the second review round's checks
earakely-scale Oct 22, 2026
5e2e84c
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 23, 2026
0ed9e8c
fix(environment): read writes, links and creation cuts only from evid…
earakely-scale Oct 23, 2026
ed78be2
docs(environment): record the third review round's checks
earakely-scale Oct 23, 2026
c983edf
fix(environment): tie linked creates to their returned ids and order …
earakely-scale Oct 23, 2026
fa9f69c
docs(environment): record the fourth review round's checks
earakely-scale Oct 23, 2026
b8c164e
Merge commit '5d6b8a0ab' into st
earakely-scale Oct 23, 2026
f044816
Merge commit 3c5c887a2 into st
earakely-scale Oct 23, 2026
a6adf12
Merge commit '5f702dd6c^' into st
earakely-scale Oct 23, 2026
92f88a9
Merge commit 5f702dd6c into st
earakely-scale Oct 23, 2026
d04ba9d
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 23, 2026
294fa3c
fix(environment): keep foreign keys, stale reads and double decoding …
earakely-scale Oct 23, 2026
ce9a153
docs(environment): record the fifth review round's checks
earakely-scale Oct 23, 2026
169842b
fix(environment): compare linked sources by position, decode path fie…
earakely-scale Oct 23, 2026
e3c5b23
docs(environment): record the sixth review round's checks
earakely-scale Oct 23, 2026
a3dbf79
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 23, 2026
ca3eead
fix(environment): replay late and variant-only items, fill linked pat…
earakely-scale Oct 23, 2026
eb9344b
docs(environment): record the seventh review round's checks
earakely-scale Oct 23, 2026
94b8c55
fix(environment): blame a failed read on the writes whose fields it d…
earakely-scale Oct 23, 2026
fcf8d1a
fix(environment): explain unsent update changes and nested clocks by …
earakely-scale Oct 23, 2026
b1ca254
fix(environment): order collections by whole lines and sort only arra…
earakely-scale Oct 23, 2026
59439f5
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 23, 2026
189152d
feat(environment): serve bulk writes at a collection and target item …
earakely-scale Oct 23, 2026
147ff45
fix(environment): decide late item lines against the lines left, char…
earakely-scale Oct 23, 2026
8876143
docs(environment): record the eighth review round's checks
earakely-scale Oct 23, 2026
6037875
fix(environment): set aside response members a path mints anew on eve…
earakely-scale Oct 23, 2026
342933e
fix(environment): count only reads finished before a linked create be…
earakely-scale Oct 23, 2026
0caf400
Merge #6385 head 342933ea into feat/environment-write-rules
earakely-scale Oct 23, 2026
cfa8310
fix(environment): count a list total nested in a paging object
earakely-scale Oct 23, 2026
65ba035
fix(environment): take a created entity's nested clocks from its read…
earakely-scale Oct 23, 2026
9d0dc27
fix(environment): import the compare tool definition as a type
earakely-scale Oct 23, 2026
c567281
docs(environment): describe the new write rules and trim repeated par…
earakely-scale Oct 23, 2026
7ef08a3
fix(environment): confirm no update whose clocks or fields the eviden…
earakely-scale Oct 23, 2026
434db04
fix(environment): show pinned query and body values in the served cat…
earakely-scale Oct 23, 2026
08c2532
docs(environment): specify and record the write-rule changes
earakely-scale Oct 23, 2026
456cfdf
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 23, 2026
e08f003
fix(environment): keep served creates' items missing, check same-type…
earakely-scale Oct 23, 2026
e4c4940
docs(environment): record the ninth review round's checks
earakely-scale Oct 23, 2026
fd67f4f
Merge commit '0bbd635ab^' into wr2
earakely-scale Oct 23, 2026
d447349
Merge commit 0bbd635ab into wr2
earakely-scale Oct 23, 2026
391fe2c
Merge commit 'e4c494087' into wr2
earakely-scale Oct 23, 2026
1c8588a
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 23, 2026
6ee9703
fix(environment): link creates past empty item reads, sweep repeated …
earakely-scale Oct 23, 2026
88ee22e
docs(environment): record the tenth review round's checks
earakely-scale Oct 23, 2026
72f0442
Merge commit '88ee22e2d' into wr2
earakely-scale Oct 23, 2026
d3828d5
fix(environment): take bulk ids literally, check each recorded call's…
earakely-scale Oct 23, 2026
364891b
docs(environment): record the review fixes' checks
earakely-scale Oct 23, 2026
2c0e7bd
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 23, 2026
12e4df7
Merge remote-tracking branch 'origin/main' into wr2
earakely-scale Oct 24, 2026
5d612dc
Merge commit '2c0e7bdde' into wr2
earakely-scale Oct 24, 2026
c166a69
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 24, 2026
4e622bb
Merge commit 'c166a694e6abd7e9c3c16ae4f938d0ef9f0d8fb6' into wr2
earakely-scale Oct 24, 2026
9614465
perf(environment): compare variant lines through shared entities and …
earakely-scale Oct 24, 2026
53b2966
docs(environment): record the eleventh review round's checks
earakely-scale Oct 24, 2026
715c578
Merge commit '53b2966c5' into wr2
earakely-scale Oct 24, 2026
f151988
Merge remote-tracking branch 'origin/main' into feat/environment-stat…
kaoru0822-kitauji Oct 24, 2026
b82e276
Merge remote-tracking branch 'origin/main' into feat/environment-writ…
kaoru0822-kitauji Oct 24, 2026
3dd85f2
perf(environment): list a type's collections only when the path's own…
earakely-scale Oct 24, 2026
f55c731
Merge remote-tracking branch 'origin/main' into st
earakely-scale Oct 24, 2026
6273d9b
Merge commit 'f55c73151' into wr2
earakely-scale Oct 24, 2026
dee4dd7
docs(environment): record the twelfth review round's checks and the s…
earakely-scale Oct 24, 2026
751af03
Merge commit 'dee4dd757a5a55f920f32c956f951ab4509c07f0' into wr2
earakely-scale Oct 24, 2026
f01215d
docs(environment): record the 50-capture sweep's wall, CPU and peak m…
earakely-scale Oct 24, 2026
3608c5a
Merge remote-tracking branch 'fork/feat/environment-state-targets' in…
earakely-scale Oct 24, 2026
5a6b4f1
Merge commit '3608c5aa2c2bd5aaa4c9786bdb9855996134e11b' into wr2
earakely-scale Oct 24, 2026
7584387
Merge remote-tracking branch 'fork/feat/environment-write-rules' into…
earakely-scale Oct 24, 2026
192db6c
chore: integrate latest main into environment write rules
gensokyo-dev Oct 24, 2026
3b66ee2
fix(environment): remove duplicate schema after main integration
gensokyo-dev Oct 24, 2026
f501e23
fix(environment): honor recorded bulk identity kinds
gensokyo-dev Oct 24, 2026
2c62bb9
fix(environment): retain scoped evidence and honor write defaults
gensokyo-dev Oct 24, 2026
352c027
test(environment): keep SDK regressions independently scoped
gensokyo-dev Oct 24, 2026
de4035a
docs(environment): record scoped write verification and measured costs
gensokyo-dev Oct 24, 2026
9942863
Merge remote-tracking branch 'origin/main' into integrate/6897-write-…
gensokyo-dev Oct 24, 2026
b3d706f
chore: merge main into environment write rules
morluto Oct 24, 2026
41aff3d
fix(environment): serve bulk writes whose response lists each entity …
earakely-scale Oct 24, 2026
a319ba1
docs(environment): measure the 50 captures at the scoped-envelope head
earakely-scale Oct 24, 2026
3fe3b0a
fix(environment): classify bulk responses and release verifier transf…
morluto Oct 24, 2026
f4bc513
fix(environment): classify and verify complete bulk responses
gensokyo-dev Oct 24, 2026
390541e
fix(javascript): retain capture context along covered mutation paths
morluto Oct 24, 2026
72ce7d6
merge: retain author bulk regressions with shared response verification
gensokyo-dev Oct 24, 2026
5ae634f
test(environment): verify bulk responses through the real MCP SDK
gensokyo-dev Oct 24, 2026
585d71c
test(environment): separate bulk response proof regressions
gensokyo-dev Oct 24, 2026
e73355e
chore: retain concurrent bulk response verification
morluto Oct 24, 2026
3e1b023
fix(environment): preserve request absence and generated value relati…
gensokyo-dev Oct 24, 2026
ac5f217
Merge commit 'e73355e1326aeaf4558d5a913596de627ae35bb2' into integrat…
gensokyo-dev Oct 24, 2026
034eed4
merge: sync main and keep its canonical JavaScript mutation analysis
gensokyo-dev Oct 24, 2026
75817ba
fix(environment): verify complete nested clocks on creates
gensokyo-dev Oct 24, 2026
5b91c99
fix(javascript): erase inline type imports before binding values
morluto Oct 24, 2026
ea64ca4
chore: sync main and retain canonical JavaScript binding fixes
morluto Oct 24, 2026
130121f
fix(environment): share complete generated value verification
gensokyo-dev Oct 24, 2026
7f01865
fix(verifiers): load the Windows source graph only when needed
gensokyo-dev Oct 24, 2026
7360127
fix(environment): validate write responses before stored clock restamps
gensokyo-dev Oct 24, 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): show pinned query and body values in the served cat…
…alog and apply bulk writes atomically

A pinned query parameter is required with its recorded value as the only choice, and a
call that leaves it out takes that value. A fixed body member shows its recorded value,
and an enveloped body its wrapping, in the schema, the description and the refusal.
Bulk writes go through the same query pin and update or remove their entities at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
earakely-scale and claude committed Oct 23, 2026
commit 434db0429adec27d600fc5f9e7f385103f4c3e22
26 changes: 20 additions & 6 deletions docs/specs/agent-environments/state-writes/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ the exemplar.
`body.envelope`: serving takes only a body wrapped that way.
- **Query.** Serving takes only the query parameters the exemplar sent, with
its values, since they may change what the body does (Ghost reads `html`
only with `?source=html`); a call with others is refused. The gate treats a
later recorded call sent with another query, or wrapped otherwise, as a
write its plan does not explain: it brings the entity to what the call
recorded, without attribution.
only with `?source=html`): a parameter a call leaves out takes the recorded
value, as the recording sent it, and a call with another value or parameter
is refused, a bulk call included. The gate treats a later recorded call sent
with another query, or wrapped otherwise, as a write its plan does not
explain: it brings the entity to what the call recorded, without
attribution, and a bulk call leaves the entities it names unmodelled.
- **The written entity.** The entity is observed in the exemplar's response,
located by its identity value at the root, in one member, or in a
one-element array, as item views locate it. When the response does not carry
Expand Down Expand Up @@ -551,7 +553,18 @@ served. Their descriptions say the tool:
- applies its effect to the served state;
- names its target type;
- lists its required and accepted body members, quoted and sampled within the
description budget as response fields are.
description budget as response fields are, the members it accepts only with
their recorded value, with that value when its JSON text is 120 characters
or less, and the envelope a body wraps its object in;
- names the query its recording sent.

The input schema says the same: each query parameter the recording sent is
required, with its value as the only `enum` member; a body that wraps its
object requires that member, an array of one object; and a member accepted
only with its recorded value carries that value as `const` when it is short
and no boolean (some clients reject boolean literals), else a description
saying it must equal the recorded value. A refused member's message names the
recorded value the same way.

The discovery budget charges them. `--replay-only` and the replay fallback are
unchanged.
Expand Down Expand Up @@ -643,7 +656,8 @@ included, and `environment-compare` sends a probe's body to it; every id must
name an entity the state holds, else the call is refused and the state is
unchanged. A bulk
update with a `unique` or `renewed` rule writes one entity per call, since one
call draws those values once. A served item action's path names its entity
call draws those values once. A bulk write changes or removes its entities in
one step, so a call the state cannot hold changes none of them. A served item action's path names its entity
before the action segment.

**Data plane and export.**
Expand Down
3 changes: 2 additions & 1 deletion docs/web-network-captures.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ stores nowhere, or for an item action a `set` of a scalar to the value it
showed, or the plan is `unexplained-change`; an increment, slug, stamp, derived
value or set must hold for every call of the tool, and an action is served
only once a call found what it sets already set. A write is served only
with the query its first call sent. Every member the first call sent is required, except by `PATCH` and
with the query its first call sent, which serving applies to a call that
leaves a parameter out and the catalog advertises as required. Every member the first call sent is required, except by `PATCH` and
`POST` updates.

A read on a line `query` answers is checked against the query evaluated over
Expand Down
11 changes: 9 additions & 2 deletions src/application/environment/environmentState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { initialStateBytes } from "./environmentStateStore.js";
import {
describeWrite,
writeBody,
writeQuery,
} from "./environmentStateWriteDescription.js";
import {
environmentToolDefinitions,
Expand Down Expand Up @@ -105,8 +106,14 @@ export const servedCatalog = (
...(state === undefined
? {}
: {
describe: (tool) => describeWrite(state.writes.get(tool.name)),
body: (tool) => writeBody(state.writes.get(tool.name)),
describe: (tool) =>
describeWrite(
state.writes.get(tool.name),
writeQuery(state.writes.get(tool.name), source),
),
body: (tool, recorded) =>
writeBody(state.writes.get(tool.name), recorded),
query: (tool) => writeQuery(state.writes.get(tool.name), source),
}),
},
);
Expand Down
46 changes: 46 additions & 0 deletions src/application/environment/environmentStateBulkAnswer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
BOOK_NOT_FOUND,
FIRST_BOOK,
SECOND_BOOK,
renamedBook,
type Book,
} from "../../../tests/fixtures/environmentStateWrites.js";
import { servedCatalog } from "./environmentState.js";
Expand All @@ -18,6 +19,16 @@ const BULK_DELETE_ROWS: readonly TimedCaptureRow[] = [
["GET", "/api/books", [FIRST_BOOK]],
];

const RENAMED_AT_3 = renamedBook(FIRST_BOOK, "Renamed Book", 3);

/** A bulk rename of the books an id array names, which the list after it confirms. */
const BULK_RENAME_ROWS: readonly TimedCaptureRow[] = [
...BOOK_INIT_ROWS,
["PATCH", "/api/books", "", 204, { ids: [1], name: "Renamed Book" }],
["GET", "/api/books/1", RENAMED_AT_3],
["GET", "/api/books", [RENAMED_AT_3, SECOND_BOOK]],
];

/** A book with an `archived` flag, which an item action sets. */
const shelved = (entity: Book, archived: boolean) => ({ ...entity, archived });

Expand Down Expand Up @@ -64,6 +75,41 @@ describe("served bulk writes", () => {
});
});

describe("served bulk write queries and capacity", () => {
it("applies a bulk delete's recorded query when a call leaves it out, and refuses another", () => {
const books = servedFrom([
...BOOK_INIT_ROWS,
["DELETE", "/api/books?force=true", [{ id: 2 }], 200, [{ id: 2 }]],
["GET", "/api/books/2", BOOK_NOT_FOUND, 404],
["GET", "/api/books", [FIRST_BOOK]],
]);
const before = books.snapshot();
expect(
books.refusal("delete_books", { force: "false", body: [{ id: 1 }] })
.message,
).toContain("takes only the query its recording sent (force=true)");
expect(books.snapshot()).toBe(before);
expect(books.answer("delete_books", { body: [{ id: 1 }] })).toMatchObject({
status: 200,
body: [{ id: 1 }],
});
expect(books.store.ofType("/api/books").map((book) => book.id)).toEqual([
"2",
]);
});

it("refuses a bulk update the state cannot hold, leaving every entity as it was", () => {
const books = servedFrom(BULK_RENAME_ROWS);
const before = books.snapshot();
// Each renamed book grows by twice the name, slug included; two of them pass the intake limit, one does not.
const name = "x".repeat(9 * 1024 * 1024);
expect(
books.refusal("patch_books", { body: { ids: [1, 2], name } }),
).toMatchObject({ code: "resource_constraint" });
expect(books.snapshot()).toBe(before);
});
});

describe("served item actions", () => {
it("sets what the action changed on the entity the path names", () => {
const books = servedFrom([
Expand Down
54 changes: 15 additions & 39 deletions src/application/environment/environmentStateBulkAnswer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { namedEntities } from "../../domain/analysisView/environmentStateWriteAddress.js";
import {
bulkCollectionOf,
namedEntities,
} from "../../domain/analysisView/environmentStateWriteAddress.js";
import {
updatedEntity,
updatedFields,
Expand All @@ -8,12 +11,9 @@ import type {
FieldRule,
WriteResponse,
} from "../../domain/analysisView/environmentStateWriteRules.js";
import {
isParam,
segmentsOf,
type JsonObject,
type StateEntity,
type SuppliedSegment,
import type {
JsonObject,
StateEntity,
} from "../../domain/analysisView/environmentStateRules.js";
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
import type { JsonValue } from "../../domain/jsonValue.js";
Expand All @@ -37,27 +37,11 @@ import {
writeAnswer,
type WriteRequest,
} from "./environmentStateWriteAnswer.js";
import {
environmentToolArguments,
hasRepeatedQueryArgument,
} from "./environmentTools.js";
import { environmentToolArguments } from "./environmentTools.js";

/** Rules whose generated value is drawn once per call, which one call cannot give several entities. */
const DRAWN_ONCE = new Set<FieldRule["rule"]>(["unique", "renewed"]);

/** The collection a bulk call's path names, with the type's spelling of its last segment, and no delete segment after it. */
const collectionSegments = (
segments: readonly SuppliedSegment[],
target: string,
): SuppliedSegment[] => {
const typed = segmentsOf(target);
const collection = segments.slice(0, typed.length);
const last = typed.at(-1)!;
if (!isParam(last))
collection[typed.length - 1] = { text: last, supplied: false };
return collection;
};

/** A bulk answer from the recorded one: one element per written entity, rendered as the first recorded element shows its entity. */
const bulkResponse = (
response: WriteResponse,
Expand Down Expand Up @@ -110,7 +94,10 @@ const namedTargets = (
const segments = callSegments(tool, args);
if (segments === undefined)
return err(refused(tool, `Tool ${tool.name} needs every path argument.`));
const collection = collectionSegments(segments, type);
const collection = bulkCollectionOf(type, segments, (text) => ({
text,
supplied: false,
}));
const targets = [];
for (const { id, body: members } of named) {
const entity = namedEntity(serving.store, type, {
Expand All @@ -135,13 +122,6 @@ export const answerBulk = (
request: WriteRequest,
): Result<StateAnswer, AnalysisError> => {
const { tool, plan, args } = request;
if (hasRepeatedQueryArgument(tool, args))
return err(
refused(
tool,
"The state write model cannot apply repeated query parameters; the state is unchanged.",
),
);
const targets = namedTargets(serving, request);
if (!targets.ok) return targets;
const update = plan.effect === "update";
Expand Down Expand Up @@ -202,14 +182,10 @@ export const answerBulk = (
},
);
if (!answer.ok) return answer;
for (const entity of written) {
if (!update) {
serving.store.remove(entity);
continue;
}
const updated = serving.store.update(entity);
if (update) {
const updated = serving.store.updateAll(written);
if (!updated.ok) return updated;
}
} else serving.store.removeAll(written);
serving.store.commitWrite(values.taken);
return answer;
};
56 changes: 41 additions & 15 deletions src/application/environment/environmentStateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,31 @@ export class EnvironmentStateStore {

/** Replace a held entity's values in place, unless the state would outgrow what `data/add` loads. */
update(entity: StateEntity): Result<void, AnalysisResourceConstraintError> {
const key = compositeKey([entity.type, entity.collection, entity.id]);
const held = this.#entities.get(key);
if (held === undefined) return ok(undefined);
const bytes = this.#grown(jsonByteLength(entity) - jsonByteLength(held));
return this.updateAll([entity]);
}

/** Replace held entities in one step, unless the state would outgrow what `data/add` loads; a refusal changes nothing. */
updateAll(
entities: readonly StateEntity[],
): Result<void, AnalysisResourceConstraintError> {
const replaced = new Map<StateEntity, StateEntity>();
let delta = 0;
for (const entity of entities) {
const held = this.#entities.get(
compositeKey([entity.type, entity.collection, entity.id]),
);
if (held === undefined) continue;
replaced.set(held, entity);
delta += jsonByteLength(entity) - jsonByteLength(held);
Comment thread
earakely-scale marked this conversation as resolved.
Resolved
}
if (replaced.size === 0) return ok(undefined);
const bytes = this.#grown(delta);
if (!bytes.ok) return bytes;
this.#install(
{
...this.#content,
entities: this.#content.entities.map((candidate) =>
candidate === held ? entity : candidate,
entities: this.#content.entities.map(
(candidate) => replaced.get(candidate) ?? candidate,
),
},
bytes.value,
Expand All @@ -317,17 +332,28 @@ export class EnvironmentStateStore {
}

remove(entity: StateEntity): void {
const held = this.#entities.get(
compositeKey([entity.type, entity.collection, entity.id]),
);
if (held === undefined) return;
const entities = this.#content.entities.filter(
(candidate) => candidate !== held,
this.removeAll([entity]);
}

/** Remove held entities in one step. */
removeAll(entities: readonly StateEntity[]): void {
const held = new Set(
entities.flatMap((entity) => {
const found = this.#entities.get(
compositeKey([entity.type, entity.collection, entity.id]),
);
return found === undefined ? [] : [found];
}),
);
this.#install(
{ ...this.#content, entities },
this.#bytes - jsonByteLength(held) - (entities.length > 0 ? 1 : 0),
if (held.size === 0) return;
const kept = this.#content.entities.filter(
(candidate) => !held.has(candidate),
);
let bytes = this.#bytes;
for (const entity of held) bytes -= jsonByteLength(entity);
// Each removed entity takes its separator, except the last one an emptied list had none for.
bytes -= held.size - (kept.length === 0 ? 1 : 0);
this.#install({ ...this.#content, entities: kept }, bytes);
}

/** Set a held document's value, unless the state would outgrow what `data/add` loads; a value that is not the Evidence's cites no record. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,10 @@ describe("served values an application stamps", () => {
notes.refusal("patch_notes_by_id", edit("2", bookClock(3))).message,
).toContain("derives excerpt");
expect(
notes.refusal("patch_notes_by_id", edit("1", bookClock(3), {})).message,
notes.refusal(
"patch_notes_by_id",
edit("1", bookClock(3), { source: "markdown" }),
).message,
).toContain("takes only the query its recording sent (source=html)");
expect(
notes.refusal("patch_notes_by_id", edit("1", "2026-01-01T00:00:00Z"))
Expand Down
21 changes: 2 additions & 19 deletions src/application/environment/environmentStateWriteAnswer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
import { callRenewal } from "../../domain/analysisView/environmentStateWriteGenerated.js";
import {
nestedClockValue,
queryProblem,
unenveloped,
} from "../../domain/analysisView/environmentStateWriteStamps.js";
import {
Expand Down Expand Up @@ -52,7 +51,7 @@ import {
type ReplayArguments,
} from "./environmentReplay.js";
import type { EnvironmentManifestTool } from "./environmentSource.js";
import { callQuery, callSegments } from "./environmentStateCallLines.js";
import { callSegments } from "./environmentStateCallLines.js";
import {
itemCall,
missingAnswer,
Expand All @@ -70,10 +69,7 @@ import {
unloadableMember,
type HeldDocument,
} from "./environmentStateDocument.js";
import {
environmentToolArguments,
hasRepeatedQueryArgument,
} from "./environmentTools.js";
import { environmentToolArguments } from "./environmentTools.js";

/** Attempts at a generated UUID or token before a collision with held values is refused. */
const GENERATION_ATTEMPTS = 64;
Expand Down Expand Up @@ -649,19 +645,6 @@ export const answerWrite = (
serving: StateServing,
request: WriteRequest,
): Result<StateAnswer, AnalysisError> => {
if (hasRepeatedQueryArgument(request.tool, request.args))
return err(
refused(
request.tool,
"The state write model cannot apply repeated query parameters; the state is unchanged.",
),
);
const query = queryProblem(
serving.source.exchanges.get(request.plan.exemplar_ordinal ?? -1)?.query,
callQuery(request.tool, request.args),
);
if (query !== undefined)
return err(refused(request.tool, `Tool ${request.tool.name} ${query}`));
const body = callBody(request);
if (!body.ok) return body;
const call: WriteCall = {
Expand Down
Loading