Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
95c8c9d
feat(environment): render more read tools from the state and describe…
cursoragent Oct 21, 2026
ad8f674
feat(environment): apply evidence-gated write effects to the served s…
cursoragent Oct 21, 2026
733833e
feat(environment): model bodiless writes, omitted fields, projected r…
earakely-scale Oct 21, 2026
6f67a11
feat(environment): test and document wider write coverage
earakely-scale Oct 21, 2026
e44adb5
docs(environment): record the write-coverage checks on the current wr…
earakely-scale Oct 21, 2026
a4c4a23
docs(environment): record the re-recorded and end-to-end write-covera…
earakely-scale Oct 21, 2026
6c8f4f7
feat(environment): render more read tools from the state and describe…
cursoragent Oct 21, 2026
378a109
fix(environment): keep rendered documents and quoted samples inside t…
cursoragent Oct 21, 2026
cfb42dd
feat(environment): apply evidence-gated write effects to the served s…
cursoragent Oct 21, 2026
5d0e096
fix(environment): bound and validate write state history
morluto Oct 21, 2026
5b42469
feat(environment): render more read tools from the state and describe…
cursoragent Oct 21, 2026
54c8934
fix(environment): keep rendered documents and quoted samples inside t…
cursoragent Oct 21, 2026
19b50ea
feat(environment): apply evidence-gated write effects to the served s…
cursoragent Oct 21, 2026
a057ea9
fix(environment): bound and validate write state history
morluto Oct 21, 2026
f79f1e1
fix(environment): bound additional collection history
morluto Oct 21, 2026
4a678f1
Merge remote-tracking branch 'live-5600/feat/environment-state-writes…
morluto Oct 21, 2026
7de20bc
fix(environment): credit sent fields, negative sequences, and encoded…
cursoragent Oct 21, 2026
a1076ca
Merge live environment write verification fixes
morluto Oct 21, 2026
d3015d2
test(environment): cover resolved encoded update identities
morluto Oct 21, 2026
cddd3e6
fix: validate timed update observations
morluto Oct 21, 2026
fb6785d
fix(environment): share write overlap and check clocks on earlier calls
cursoragent Oct 21, 2026
d7c5c62
merge: restack environment state writes onto main after #5352
cursoragent Oct 21, 2026
3b34bbd
fix: preserve partial update evidence
morluto Oct 21, 2026
5d00ff3
Merge remote-tracking branch 'live-5600/feat/environment-state-writes…
morluto Oct 21, 2026
067f0fa
fix(environment): keep projected and partial reads out of the write g…
earakely-scale Oct 21, 2026
717ac2c
chore: merge main (8413ec08) into environment state writes
earakely-scale Oct 21, 2026
1074355
chore: merge environment state writes (717ac2c4) into environment wri…
earakely-scale Oct 22, 2026
0061234
chore: merge main (2451e187) into environment write coverage
earakely-scale Oct 22, 2026
70249b3
fix(environment): check the absence a projected read answers, and rea…
earakely-scale Oct 22, 2026
e923fc7
fix(environment): let an unmodelled write explain only the list membe…
earakely-scale Oct 21, 2026
75d7bb0
fix(environment): explain added fields, tie creates to serving's coll…
earakely-scale Oct 21, 2026
cd26a76
docs(environment): state how list reads weigh unmodelled writes, adde…
earakely-scale Oct 22, 2026
2a125b7
chore: merge main (4a4bbab3) into environment state writes
earakely-scale Oct 22, 2026
9517260
chore: merge environment state writes (2a125b71) into environment wri…
earakely-scale Oct 22, 2026
11e3f01
refactor(environment): keep the observing view helpers with the obser…
earakely-scale Oct 22, 2026
cfc43a7
chore: merge environment state writes (11e3f016) into environment wri…
earakely-scale Oct 22, 2026
53a7866
fix(environment): resolve unmodelled writes onto the held collection
cursoragent Oct 22, 2026
329aeed
fix(environment): confirm no write through volatile fields or overwri…
earakely-scale Oct 22, 2026
ccdf091
fix(environment): leave unknown entities unchecked by failed reads, v…
earakely-scale Oct 22, 2026
1c97933
fix(environment): fill a create's path fields from the collection ser…
earakely-scale Oct 22, 2026
90d9022
fix(environment): name unmodelled writes as modelled ones, count fiel…
earakely-scale Oct 22, 2026
54f7d85
fix(environment): note omitted fields only from reads the gate checks
earakely-scale Oct 22, 2026
3ac1136
chore: merge environment state writes (90d90227) into environment wri…
earakely-scale Oct 22, 2026
756c631
fix(environment): let a document replacement overwrite everything und…
earakely-scale Oct 22, 2026
3f1f825
chore: merge the published environment state writes (756c6312)
earakely-scale Oct 22, 2026
caf2acf
chore: merge environment state writes (3f1f825e) into environment wri…
earakely-scale Oct 22, 2026
613048a
chore: merge main (b8c1b453) into environment write coverage
earakely-scale Oct 22, 2026
e21f6c5
chore: merge main (538017d1, #5600 squashed) into environment write c…
earakely-scale Oct 22, 2026
06ec0d4
fix(merge): preserve write coverage with query-aware validation
morluto Oct 22, 2026
f5162bb
fix(environment): align write inference with resolved state facts
morluto Oct 22, 2026
17c5a44
chore: integrate write coverage with current main
gensokyo-dev Oct 22, 2026
8b6e35b
chore: sync write coverage with latest main
N0zoM1z0 Oct 22, 2026
6f726ef
fix(environment): preserve projection and omission evidence across wr…
gensokyo-dev Oct 22, 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): check the absence a projected read answers, and rea…
…d counts past their mask

A read that asked for some fields and answered 400, 404 or 410 was taken
for a partial entity and skipped, so a delete it confirmed went unserved.
Only a successful answer can be a partial entity now.

A held sequence value whose digits outgrew its mask (`100-00` after
`99-99`) was not read as a count, so after `data/add` cleared the counter
serving numbered the next create `100-00` again. Such a value now counts
when it is the exemplar's spelling of its number, in serving and in the
gate's sequence checks; dates still never match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
earakely-scale and claude committed Oct 22, 2026
commit 70249b31c5a11cee8eba2611265af92eecd1ade1
6 changes: 4 additions & 2 deletions docs/specs/agent-environments/write-coverage/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ what the writes did:
is left out of the identity proof and the view's checks. The view lists it in `projected_record_ordinals`, and serving
replays a call to that tool naming such a parameter, for an entity the state holds, with the reason `projection`;
the replay shows the recording, not served writes. The write gate neither checks nor learns a write's effect from a
read that names such a parameter and leaves out a field its view requires.
successful read that names such a parameter and leaves out a field its view requires; a 400, 404 or 410 such a read
answers is still the absence it checks.
- **Sequences.** A sequence value may be `-`-separated digit groups of one width of at least two digits, not a date,
version or address. The next value keeps the exemplar's groups and zero padding; digits that outgrow them lead. A
later create must record its value spelled that way.
later create must record its value spelled that way. A held value whose digits outgrew the mask (`100-00` after
`99-99`) counts only when it is the exemplar's spelling of its number, so a reloaded state numbers on from it.

## Acceptance

Expand Down
28 changes: 28 additions & 0 deletions src/application/environment/environmentStateWriteAnswer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,34 @@ describe("wider write coverage", () => {
});

describe("write coverage limits", () => {
it("numbers past a mask's width again after the state is saved and loaded", () => {
const books = servedFrom([
[
"GET",
"/api/books",
[assetBook(FIRST_BOOK, "99-97"), assetBook(SECOND_BOOK, "99-98")],
],
["GET", "/api/books/1", assetBook(FIRST_BOOK, "99-97")],
["GET", "/api/books/2", assetBook(SECOND_BOOK, "99-98")],
[
"POST",
"/api/books",
assetBook(THIRD_BOOK, "99-99"),
201,
{ name: "Third Book" },
],
["GET", "/api/books/3", assetBook(THIRD_BOOK, "99-99")],
]);
const create = (name: string) =>
books.answer("post_books", { body: { name } }).body;
expect(create("Fifth Book")).toMatchObject({ asset: "99-99" });
expect(create("Sixth Book")).toMatchObject({ asset: "100-00" });
// Loading what data/get wrote clears the sequence counter, so the held numbers alone carry it on.
const { rea_state } = books.store.snapshot();
expect(books.store.replace({ rea_state }).ok).toBe(true);
expect(create("Seventh Book")).toMatchObject({ asset: "100-01" });
});

it("replays a call naming a projection parameter, even an empty one", () => {
expect(
servedFrom(PROJECTED_ROWS).answer("get_books_by_id", {
Expand Down
16 changes: 13 additions & 3 deletions src/application/environment/environmentStateWriteAnswer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,16 @@ const observedEntity = (
return isObject(object) ? object : undefined;
};

/** One past the largest integer these entities hold in the field, or undefined when none holds one. */
const nextHeld = (entities: readonly StateEntity[], field: string) =>
/** One past the largest integer these entities hold in the field, read as the exemplar spells it, or undefined when none holds one. */
const nextHeld = (
entities: readonly StateEntity[],
field: string,
exemplar: JsonValue,
) =>
nextInteger(
entities.map((entity) => entity.fields),
field,
exemplar,
);

/**
Expand Down Expand Up @@ -197,6 +202,7 @@ const generator = (
? [...target.collection, ...startedIn]
: [...ofType, ...started],
rule.field,
exemplar,
),
),
),
Expand All @@ -212,7 +218,11 @@ const generator = (
exemplar,
sequence(
`${request.plan.target ?? ""} ${rule.field} ${target.name}`,
nextHeld([...target.collection, ...startedIn], rule.field),
nextHeld(
[...target.collection, ...startedIn],
rule.field,
exemplar,
),
),
),
);
Expand Down
7 changes: 5 additions & 2 deletions src/domain/analysisView/environmentStateWriteCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const followsSequences = (
rule.scope === "type" || entity.collection === created.collection,
);
const next = nextSequence(
nextInteger(fieldsOf(scope), rule.field),
nextInteger(fieldsOf(scope), rule.field, draft.observed?.[rule.field]),
draft.sequences.get(key),
);
return (
Expand Down Expand Up @@ -226,7 +226,10 @@ const takeSequences = (
created: Pick<StateEntity, "collection" | "fields">,
): void => {
for (const { rule, key } of sequencesOf(draft, created.collection)) {
const value = sequenceNumber(created.fields[rule.field]);
const value = sequenceNumber(
created.fields[rule.field],
draft.observed?.[rule.field],
);
if (value !== undefined) draft.sequences.set(key, value);
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/domain/analysisView/environmentStateWriteExplain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ const isClockNear = (
export const nextInteger = (
members: readonly JsonObject[],
field: string,
exemplar?: JsonValue,
): number | undefined => {
let largest: number | undefined;
for (const member of members) {
const value = sequenceNumber(member[field]);
const value = sequenceNumber(member[field], exemplar);
if (value !== undefined && (largest === undefined || value > largest))
largest = value;
}
Expand Down
2 changes: 2 additions & 0 deletions src/domain/analysisView/environmentStateWriteObserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export const projectedRead = (
return false;
if (view.shape === "item" && view.projected_record_ordinals !== undefined)
return true;
// An absence or error holds no entity, so it is never a partial one.
if (!succeeded(record)) return false;
return io.withBody(record.ordinal, (body) => {
const objects =
body === undefined || body === null
Expand Down
9 changes: 9 additions & 0 deletions src/domain/analysisView/environmentStateWriteValues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@ it("reads a sequence written as digit groups of one width, but not a date, versi
expect(sequenceNumber("000-")).toBeUndefined();
});

it("reads a count that outgrew its mask only as the exemplar's spelling of it", () => {
expect(sequenceNumber("100-00", "99-99")).toBe(10_000);
expect(sequenceNumber("1000-000", "000-005")).toBe(1_000_000);
expect(sequenceNumber("100-00")).toBeUndefined();
for (const other of ["2026-10-21", "20261-02", "100-0"])
expect(sequenceNumber(other, "000-005")).toBeUndefined();
expect(sequenceNumber("100-00", "2026-10")).toBeUndefined();
});

it("spells a sequence value in the recorded value's digit groups, the overflow leading", () => {
expect(spelledLike("000-005", 6)).toBe("000-006");
expect(spelledLike("000-999", 1000)).toBe("001-000");
Expand Down
19 changes: 17 additions & 2 deletions src/domain/analysisView/environmentStateWriteValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,25 @@ const maskedCount = (value: JsonValue | undefined): number | undefined => {
return digits.length <= 15 ? Number(digits) : undefined;
};

/** A sequence's number: an integer, or digit groups that count. */
/** A count that outgrew the exemplar's mask, read only when it is spelled as serving spells it, so dates never match. */
const outgrownMask = (
value: JsonValue | undefined,
exemplar: JsonValue | undefined,
): number | undefined => {
if (typeof value !== "string" || maskedCount(exemplar) === undefined)
return undefined;
const digits = value.replaceAll("-", "");
if (!/^\d{1,15}$/u.test(digits)) return undefined;
const count = Number(digits);
return fillMask(exemplar as string, count) === value ? count : undefined;
};

/** A sequence's number: an integer, digit groups that count, or with the sequence's exemplar a count that outgrew its mask. */
export const sequenceNumber = (
value: JsonValue | undefined,
): number | undefined => integerOf(value) ?? maskedCount(value);
exemplar?: JsonValue,
): number | undefined =>
integerOf(value) ?? maskedCount(value) ?? outgrownMask(value, exemplar);

/** A number written into a mask's digit positions, zero-padded; digits that outgrow the mask lead it. */
const fillMask = (mask: string, value: number): string => {
Expand Down
44 changes: 44 additions & 0 deletions src/domain/analysisView/environmentStateWrites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
RENAMED_BOOK,
SECOND_BOOK,
THIRD_BOOK,
assetBook,
book,
bookClock,
environmentStateViewOf,
Expand Down Expand Up @@ -274,6 +275,49 @@ describe("write coverage limits", () => {
});
});

it("confirms a delete from a read that asked for some fields and found no book", () => {
const rows: TimedCaptureRow[] = [
...BOOK_INIT_ROWS,
["DELETE", "/api/books/2", "", 204],
["GET", "/api/books/2?fields=id,name", BOOK_NOT_FOUND, 404],
];
expect(planOf(stateOf(rows), "delete_books_by_id")).toMatchObject({
served: true,
checked_record_ordinals: [4],
});
});

it("follows a sequence past its mask's width, as serving spells it", () => {
const numbered = (id: number, asset: string): Book =>
assetBook(book(id, `Book ${String(id)}`, bookClock(id + 2)), asset);
const rows: TimedCaptureRow[] = [
["GET", "/api/books", [numbered(1, "99-97"), numbered(2, "99-98")]],
["GET", "/api/books/1", numbered(1, "99-97")],
["GET", "/api/books/2", numbered(2, "99-98")],
];
for (const [id, asset] of [
[3, "99-99"],
[4, "100-00"],
[5, "100-01"],
] as const)
rows.push(
[
"POST",
"/api/books",
numbered(id, asset),
201,
{ name: `Book ${String(id)}` },
],
["GET", `/api/books/${String(id)}`, numbered(id, asset)],
);
expect(planOf(stateOf(rows), "post_books")).toMatchObject({
served: true,
rules: expect.arrayContaining([
{ field: "asset", rule: "sequence", scope: "collection" },
]),
});
});

it("withholds creates whose later call spells its sequence otherwise than serving would", () => {
const spelled = (asset: JsonValue): TimedCaptureRow[] => {
const fourth = { ...book(4, "Fourth Book", bookClock(5)), asset };
Expand Down
Loading