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): let an unmodelled write explain only the list membe…
…rs that differ

A failed whole-list read now reports which members alone account for the
difference. An unmodelled write excuses the read's writes only when it came
after each such member's last check and pending writes, so an older change
elsewhere no longer hides a newer write the list shows undone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7b6aab9d7191e600051693f2c192afcfc743d083)
  • Loading branch information
earakely-scale and claude committed Oct 22, 2026
commit e923fc735b6d769964fe8e67a41e71568b4145b4
22 changes: 22 additions & 0 deletions src/domain/analysisView/EnvironmentStateWriteSimulation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,28 @@ describe("what an unmodelled write explains", () => {
});
});

it("contradicts by a list a write made after an unmodelled one, though the tool's earlier change elsewhere came before it", () => {
const named = (id: number, name: string) => ({
...book(id, name, bookClock(0)),
id,
});
const rows: TimedCaptureRow[] = [
["GET", "/api/books", [named(1, "A"), named(2, "B")]],
["GET", "/api/books/1", named(1, "A")],
["GET", "/api/books/2", named(2, "B")],
["PATCH", "/api/books/1", named(1, "A2"), 200, { name: "A2" }],
["POST", "/api/exports", { queued: true }, 202, { format: "csv" }],
["PATCH", "/api/books/2", named(2, "B2"), 200, { name: "B2" }],
["GET", "/api/books/2", named(2, "B2")],
// Only book 2 differs, and its patch came after the export.
["GET", "/api/books", [named(1, "A2"), named(2, "B")]],
];
expect(gated(rows, "patch_books_by_id")).toMatchObject({
served: false,
contradicted_by: 7,
});
});

it("contradicts a write made after an unmodelled one, though an earlier pending write came before it", () => {
const summary = (name: string) => [
{ id: 1, name },
Expand Down
30 changes: 14 additions & 16 deletions src/domain/analysisView/EnvironmentStateWriteSimulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
} from "./environmentStateWriteChecks.js";
import {
exercisedBy,
interference,
type WriteHistory,
forgetChecked,
runningAt,
shownFields,
Expand Down Expand Up @@ -92,6 +94,12 @@ export class EnvironmentStateWriteSimulation {
readonly #touchedSince: PendingTargets = new Map();
/** Timeline indexes of writes the gate does not model. */
readonly #unmodelledAt: number[] = [];
readonly #history: WriteHistory = {
touched: this.#touched,
pending: this.#touchedSince,
checked: this.#lastCheck,
unmodelledAt: this.#unmodelledAt,
};
readonly #log: {
readonly index: number;
readonly tool: string;
Expand Down Expand Up @@ -353,8 +361,9 @@ export class EnvironmentStateWriteSimulation {
)
return;
const exercised = exercisedBy(this.#touched, keys, borrowers);
const interferes = interference(this.#history, outcome);
if (borrowers !== undefined) {
if (!outcome.pass) this.#contradictOthers(keys, exercised, record);
if (!outcome.pass) this.#contradictOthers(exercised, record, interferes);
return;
}
const pass =
Expand All @@ -364,14 +373,12 @@ export class EnvironmentStateWriteSimulation {
? this.#confirm(view, record, keys, exercised)
: undefined;
if (!pass) {
const interfered = new Set(
[...exercised].filter((name) => this.#interferedWith(name, keys)),
);
const interfered = new Set([...exercised].filter(interferes));
if (interfered.size === 0)
this.#mismatch({ record, index, keys, exercised, view });
else {
// An unmodelled write after some of these writes may explain the difference: those are checked on their own members only.
this.#contradictOthers(keys, exercised, record);
this.#contradictOthers(exercised, record, interferes);
if (view.shape === "item") this.#checkMembers(view, record, interfered);
else for (const key of keys) this.#taint.fail(key);
}
Expand All @@ -390,12 +397,12 @@ export class EnvironmentStateWriteSimulation {

/** A failed read contradicts the writes it exercised that no unmodelled write came after, as a read a write's effect was learned from still does the others. */
#contradictOthers(
keys: readonly string[],
exercised: ReadonlySet<string>,
record: StateRecordFacts,
interferes: (name: string) => boolean,
): void {
for (const name of exercised)
if (!this.#interferedWith(name, keys))
if (!interferes(name))
this.#drafts.get(name)!.contradictedBy ??= record.ordinal;
}

Expand Down Expand Up @@ -423,15 +430,6 @@ export class EnvironmentStateWriteSimulation {
this.#unmodelledAt.push(index);
}

/** Whether a write the gate does not model came after a tool's latest call on one of these targets where its effect survives, so it may explain what a read shows there. */
#interferedWith(tool: string, keys: readonly string[]): boolean {
return keys.some((key) => {
if (this.#touched.get(key)?.has(tool) !== true) return false;
const at = this.#touchedSince.get(key)?.at.get(tool);
return at !== undefined && this.#unmodelledAt.some((index) => index > at);
});
}

/** Check the writes to an item read's entity on the members they sent, as a resynchronising read does. */
#checkMembers(
view: Extract<StateView, { shape: "item" }>,
Expand Down
37 changes: 37 additions & 0 deletions src/domain/analysisView/environmentStateWriteAttribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,43 @@ export type PendingTargets = Map<
export const overlapsWrite = (until: number, start: number): boolean =>
until > start;

/** What the gate tracks of the writes since each target's last check, and when each unmodelled write ran. */
export interface WriteHistory {
readonly touched: TouchedTargets;
readonly pending: PendingTargets;
readonly checked: ReadonlyMap<string, number>;
readonly unmodelledAt: readonly number[];
}

/** The tools a failed read's difference an unmodelled write may explain: it came after the tool's call on a target where its effect survives, and after every differing target's last check and pending writes. */
export const interference = (
history: WriteHistory,
read: {
readonly targets: readonly string[];
readonly unheld: readonly string[];
readonly differing?: readonly string[];
},
): ((tool: string) => boolean) => {
const keys = [...read.targets, ...read.unheld];
const after = (since: number) =>
history.unmodelledAt.some((index) => index > since);
const explained = (read.differing ?? []).every((key) =>
after(
Math.max(
history.checked.get(key) ?? -1,
...(history.pending.get(key)?.at.values() ?? []),
),
),
);
return (tool) =>
explained &&
keys.some((key) => {
if (history.touched.get(key)?.has(tool) !== true) return false;
const at = history.pending.get(key)?.at.get(tool);
return at !== undefined && after(at);
});
};

/** Whether a modelled write to the target was still running when a read began at `start`, so the read may show either state. */
export const runningAt = (
pending: PendingTargets,
Expand Down
30 changes: 25 additions & 5 deletions src/domain/analysisView/environmentStateWriteChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ export interface CheckOutcome {
readonly targets: readonly string[];
/** Entities the recording, or the served base of a recorded-membership list, lists that the state does not hold, by target. */
readonly unheld: readonly string[];
/** For a failed list read that differs only in some members' fields, those members' targets. */
readonly differing?: readonly string[];
}

/** What a check compares: the read's recorded body and the served base recording it would answer on. */
Expand Down Expand Up @@ -400,21 +402,39 @@ const listCheck = (
view: StateListView,
check: ListBodies,
members: readonly StateEntity[],
): boolean => {
): Pick<CheckOutcome, "pass" | "differing"> => {
if (
members.some(
(entity) =>
missingRequiredFields(entity, view, check.volatile).length > 0,
)
)
return false;
return { pass: false };
const observed = new Map(
check.items.map((item) => [scalarText(item[check.idField]) ?? "", item]),
);
const rendered = members.map((entity) =>
renderStateEntity(entity, view, check.volatile, observed.get(entity.id)),
);
return same(renderStateList(view, check.base, rendered), check.body);
if (same(renderStateList(view, check.base, rendered), check.body))
return { pass: true };
// When the recorded members alone account for the difference, only they differ.
const differs = members.filter((entity, index) => {
const item = observed.get(entity.id);
return item !== undefined && !same(rendered[index], item);
});
const patched = rendered.map(
(item, index) => observed.get(members[index]!.id) ?? item,
);
return differs.length > 0 &&
same(renderStateList(view, check.base, patched), check.body)
? {
pass: false,
differing: differs.map((entity) =>
entityTarget(view.type, check.collection, entity.id),
),
}
: { pass: false };
};

/** A list read of every entity of a collection: membership, order, fields and counters must render from the state. */
Expand All @@ -427,7 +447,7 @@ const checkAllList = (
const members = state.members(view.type, collection);
const held = new Set(members.map((entity) => entity.id));
return {
pass: listCheck(view, check, members),
...listCheck(view, check, members),
targets: [
collectionTarget(view.type, collection),
...members.map((entity) =>
Expand Down Expand Up @@ -460,7 +480,7 @@ const checkRecordedList = (
? unheld
: targets
).push(entityTarget(view.type, collection, id));
return { pass: listCheck(view, check, members), targets, unheld };
return { ...listCheck(view, check, members), targets, unheld };
};

/** A list read on a checked line, compared with the answer the served environment renders on that line's base recording from the collection it names. */
Expand Down