Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
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
717ac2c
chore: merge main (8413ec08) into environment state writes
earakely-scale Oct 21, 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
11e3f01
refactor(environment): keep the observing view helpers with the obser…
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
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
4bc6002
fix(environment): start the served clock from the records whose times…
earakely-scale 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): confirm no write through volatile fields or overwri…
…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 <noreply@anthropic.com>
  • Loading branch information
earakely-scale and claude committed Oct 22, 2026
commit 329aeedca860295c8d722cd9d493dfc0c85a17b2
54 changes: 54 additions & 0 deletions src/domain/analysisView/EnvironmentStateWriteSimulation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,35 @@ describe("what a read shows of a write", () => {
});
});

it("confirms no document replacement a later merge overwrote", () => {
const rows: TimedCaptureRow[] = [
["GET", "/api/settings", { theme: "light", lang: "en" }],
[
"PUT",
"/api/settings",
{ theme: "dark", lang: "fr" },
200,
{ theme: "dark", lang: "fr" },
],
[
"PATCH",
"/api/settings",
{ theme: "blue", lang: "de" },
200,
{ theme: "blue", lang: "de" },
],
["GET", "/api/settings", { theme: "blue", lang: "de" }],
];
expect(gated(rows, "put_settings")).toMatchObject({
served: false,
checked_record_ordinals: [],
});
expect(gated(rows, "patch_settings")).toMatchObject({
served: true,
checked_record_ordinals: [3],
});
});

it("confirms no document write a later replacement overwrote", () => {
const rows: TimedCaptureRow[] = [
["GET", "/api/settings", { theme: "light", lang: "en" }],
Expand Down Expand Up @@ -1654,6 +1683,31 @@ describe("what an unmodelled write explains", () => {
});
});

describe("volatile fields", () => {
it("confirms no write through a volatile field a read renders from itself", () => {
const seen = (id: number, name: string, at: string) => ({
id,
name,
seen: at,
});
const rows: TimedCaptureRow[] = [
["GET", "/api/books", [seen(1, "A", "t1"), seen(2, "B", "t1")]],
["GET", "/api/books/1", seen(1, "A", "t1")],
// A repeated read with no write between shows `seen` changing on its own, so it is volatile.
["GET", "/api/books/1", seen(1, "A", "t2")],
["GET", "/api/books/2", seen(2, "B", "t1")],
["PATCH", "/api/books/1", seen(1, "A", "t3"), 200, { seen: "t3" }],
["POST", "/api/exports", { queued: true }, 202, { format: "csv" }],
// The export may explain the new name, and `seen` renders from the read, so nothing shows the patch.
["GET", "/api/books/1", seen(1, "Z", "t9")],
];
expect(gated(rows, "patch_books_by_id")).toMatchObject({
served: false,
checked_record_ordinals: [],
});
});
});

describe("an unmodelled write under another collection spelling", () => {
it("keeps a confirmed update when the write spells the held collection plainly", () => {
const acme = (name: string, status: string) => ({
Expand Down
5 changes: 4 additions & 1 deletion src/domain/analysisView/environmentStateWriteChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,11 @@ export const writtenFieldChecks = (
const shown = renderStateEntity(entity, view, check.volatile, observed);
const outcomes = new Map<string, boolean>();
for (const [tool, fields] of check.writes) {
// A volatile field renders from the read itself, so it shows nothing of a write.
const compared = (fields ?? []).filter(
(field) => Object.hasOwn(observed, field) || Object.hasOwn(shown, field),
(field) =>
!check.volatile.has(field) &&
(Object.hasOwn(observed, field) || Object.hasOwn(shown, field)),
);
if (fields === null || compared.length === 0) continue;
outcomes.set(
Expand Down
22 changes: 19 additions & 3 deletions src/domain/analysisView/environmentStateWriteDocument.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { JsonValue } from "../jsonValue.js";
import {
at as valueAt,
decodedSegment,
isObject,
pointerTo,
same,
segmentsOf,
Expand Down Expand Up @@ -49,15 +51,26 @@ const writePointer = (
? draft.plan.observation?.pointer
: documentPointerOf(value, body);

/** The fields a document write changed, as pointers: a merge the members it sent at its object, a replacement all under it (undefined: the whole document). */
/**
* The fields a document write changed, as pointers: a merge the members it sent at its object, a replacement every
* member it wrote or removed there, so later writes can overwrite its effect (undefined: the whole document).
*/
const writtenPointers = (
draft: WriteDraft,
body: JsonObject,
values: { readonly before: JsonValue; readonly after: JsonValue },
): readonly string[] | undefined => {
const at = draft.plan.observation?.pointer ?? "";
if (draft.plan.merge === "merge")
return Object.keys(body).map((member) => `${at}${pointerTo(member)}`);
return at === "" ? undefined : [at];
const members = new Set(
[values.before, values.after].flatMap((value) => {
const object = valueAt(value, at);
return isObject(object) ? Object.keys(object) : [];
}),
);
if (members.size === 0) return at === "" ? undefined : [at];
return [...members].map((member) => `${at}${pointerTo(member)}`);
Comment thread
earakely-scale marked this conversation as resolved.
Resolved
};

/** Build a document plan from its exemplar: its object, merge or replacement by method, and the members it sent. */
Expand Down Expand Up @@ -130,7 +143,10 @@ export const applyDocument = (
}));
context.io.retain(64 + JSON.stringify(written.value).length * 2);
context.state.setDocument(tool, written.value);
const fields = writtenPointers(draft, body!);
const fields = writtenPointers(draft, body!, {
before: value!,
after: written.value,
});
return {
kind: "applied",
targets: [documentTarget(tool)],
Expand Down
16 changes: 16 additions & 0 deletions src/domain/analysisView/environmentStateWrites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ describe("served write plans", () => {
});
});

it("starts no clock when a recorded time lies past the range of a date", () => {
const state = stateOf([
["GET", "/api/books", [FIRST_BOOK]],
["GET", "/api/books/1", FIRST_BOOK],
[
"PATCH",
"/api/books/1",
RENAMED_AT_3,
200,
{ name: "Renamed Book" },
9_000_000_000_000_000,
],
]);
expect(state.write_clock).toBeNull();
});

it("starts no clock on a record-order timeline, where no value is generated by a clock", () => {
const state = environmentStateViewOf(
rawCaptureEvidence(
Expand Down
7 changes: 4 additions & 3 deletions src/domain/analysisView/environmentStateWrites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const clockStart = (
(latest, record) => Math.max(latest, record.end),
Number.NEGATIVE_INFINITY,
);
return Number.isFinite(end)
? new Date(Math.ceil(end / 1000) * 1000).toISOString()
: null;
if (!Number.isFinite(end)) return null;
const start = new Date(Math.ceil(end / 1000) * 1000);
// A recorded time past the range a date can hold gives no served clock.
return Number.isNaN(start.getTime()) ? null : start.toISOString();
Comment thread
earakely-scale marked this conversation as resolved.
Resolved
};

/** The write plans a capture's own timeline confirms against an extracted state, and the served clock's start. */
Expand Down
Loading