Preserve bigint precision in native Stop receipt checks

This commit is contained in:
Dotta committed 2026-11-03 17:46:38 -06:00
1 parent 7051e27d4b
commit 36c62b5abc
3 files changed
+31 -7

No files matched your search

+2 -2
View File
@@ -150,7 +150,7 @@ for (const pair of pairs) for (const arm of ["baseline", "candidate"] as const)
assert.equal(row.agent_id, local.controlAgentId, "Stop did not use its separate local control agent");
assert.equal(row.provider, "local", "Stop requires its normal local lease");
assert.equal(row.provider_lease_id, null); assert.equal(row.checkpoint_part, null, "Local Stop must retain host-file authority without a database header");
assert.ok(Number.isSafeInteger(row.process_identity_seq) && row.process_identity_seq > 0);
assert.ok(BigInt(String(row.process_identity_seq)) > 0n);
assert.equal(row.process_identity_source_event_id, null, "Local identity must be server-authored");
assert.equal(row.process_identity?.targetKind, "local");
assert.equal(row.process_identity?.processPid, row.process_pid);
@@ -199,7 +199,7 @@ for (const pair of pairs) for (const arm of ["baseline", "candidate"] as const)
"admitted_execution_workspace_id", "process_identity_seq", "process_identity_source_event_id"]) assert.equal(after?.[field], row[field], "Local stopped database identity mismatch");
assert.equal(after.status, "cancelled"); assert.equal(after.cancellation_dispatch_state, "acknowledged");
if (!after.process_pid && !after.process_group_id) {
assert.ok(after.process_stopped_seq > row.process_identity_seq, "Cleared local process identity needs its server stop receipt");
assert.ok(BigInt(String(after.process_stopped_seq)) > BigInt(String(row.process_identity_seq)), "Cleared local process identity needs its server stop receipt");
assert.equal(after.process_stopped_source_event_id, null);
assert.equal(after.process_stopped?.processPid, before.runnerPid);
assert.equal(after.process_stopped?.processGroupId, before.processGroupId);
@@ -110,7 +110,7 @@ function browserReport(revision, latency) {
checkpoint_part: stop ? null : "header", checkpoint_header_bytes: stop ? null : 256,
runner_instance_id: id(6, caseIndex, index), native_session_id: id(7, caseIndex, index), admitted_execution_workspace_id: id(8, caseIndex, index),
...(stop ? { process_pid: pid - 1, process_group_id: pid - 1, process_started_at: "2026-11-03T00:00:00.000Z",
process_identity_seq: 1, process_identity_source_event_id: null,
process_identity_seq: "9", process_identity_source_event_id: null,
process_identity: { targetKind: "local", hostname: "fixture-host", processPid: pid - 1, processGroupId: pid - 1,
processStartedAt: "2026-11-03T00:00:00.000Z" } } : {}),
}));
@@ -131,7 +131,7 @@ function browserReport(revision, latency) {
processes: { ...localProcesses, runnerAbsent: true, groupAbsent: true, providerAbsent: true },
database: { ...snapshot, checkedBeforeMeasuredEpoch: false, checkedAtMs: 1000 + latency, connectionClosedAtMs: 1000 + latency,
rows: [{ ...rows[0], process_pid: null, process_group_id: null, process_started_at: null, status: "cancelled", cancellation_dispatch_state: "acknowledged",
process_stopped_seq: 2, process_stopped_source_event_id: null, process_stopped: { processPid: pid - 1, processGroupId: pid - 1, processStartedAt: rows[0].process_started_at } }] } } }
process_stopped_seq: "64", process_stopped_source_event_id: null, process_stopped: { processPid: pid - 1, processGroupId: pid - 1, processStartedAt: rows[0].process_started_at } }] } } }
: { remoteLeases: rows.map(row => ({ id: row.lease_id, runId: row.run_id, companyId, environmentId, provider: "fake-plugin", providerLeaseId: row.provider_lease_id,
status: "released", cleanupStatus: "success", releasedAt: "2026-11-03T00:00:00.000Z" })) }),
visible: Array(stop ? 3 : workload.events).fill({}), matchedVisibleClocks: stop ? 3 : workload.events,
@@ -172,6 +172,13 @@ test("browser CLI rejects the three-pairs-above-noise counterexample and ineligi
assert.ok(result.gates.filter(gate => gate.improvementRequired).every(gate => gate.noiseExceedingPairedWins === 3));
const good = run([`--pairs=${await manifest("four-wins", [0.30, 0.25, 0.20, 0.15, 0.01])}`, `--noise-report=${noise}`, "--require-acceptance"]);
assert.equal(good.status, 0, good.stderr);
const wide = run([`--pairs=${await manifest("int64-ordered-receipt", Array(5).fill(0.30), false, report => {
const stop = report.cases[5];
stop.controllerAuthority.rows[0].process_identity_seq = "9223372036854775806";
stop.localStopProof.database.rows[0].process_identity_seq = "9223372036854775806";
stop.localStopProof.database.rows[0].process_stopped_seq = "9223372036854775807";
})}`, `--noise-report=${noise}`, "--require-acceptance"]);
assert.equal(wide.status, 0, wide.stderr);
for (const [name, change, message] of [
["smoke", report => { report.qualificationOnly = true; }, /Smoke cannot qualify/],
["source", report => { report.serverArtifact = "source-qualification"; }, /compiled server/],
@@ -228,7 +235,12 @@ test("browser CLI rejects the three-pairs-above-noise counterexample and ineligi
["local-provider-still-alive", report => { report.cases[5].localStopProof.processes.providerAbsent = false; }, /remains alive/],
["local-group-still-alive", report => { report.cases[5].localStopProof.processes.groupAbsent = false; }, /false.*true|false !== true/],
["local-database-ack-missing", report => { report.cases[5].localStopProof.database.rows[0].cancellation_dispatch_state = "pending"; }, /acknowledged/],
["local-cleared-identity-no-receipt", report => { delete report.cases[5].localStopProof.database.rows[0].process_stopped_seq; }, /server stop receipt/],
["local-cleared-identity-no-receipt", report => { delete report.cases[5].localStopProof.database.rows[0].process_stopped_seq; }, /BigInt/],
["local-bigint-lexicographic-false-pass", report => {
report.cases[5].controllerAuthority.rows[0].process_identity_seq = "90071992547409920";
report.cases[5].localStopProof.database.rows[0].process_identity_seq = "90071992547409920";
report.cases[5].localStopProof.database.rows[0].process_stopped_seq = "9007199254740993";
}, /server stop receipt/],
["local-provider-stop-receipt", report => { report.cases[5].localStopProof.database.rows[0].process_stopped_source_event_id = "provider"; }, /null/],
["local-lease-cleanup-failed", report => { report.cases[5].localStopProof.lease.cleanupStatus = "failed"; }, /Local Stop lease cleanup/],
["local-lease-wrong-binding", report => { report.cases[5].localStopProof.lease.heartbeatRunId = "other"; }, /other/],
@@ -251,6 +263,18 @@ test("browser CLI rejects the three-pairs-above-noise counterexample and ineligi
const rejected = run([`--pairs=${await manifest(name, Array(5).fill(0.30), false, change)}`, `--noise-report=${noise}`, "--require-acceptance"]);
assert.notEqual(rejected.status, 0); assert.match(rejected.stderr, message);
}
for (const [label, value] of [["null", null], ["missing", undefined], ["invalid", "not-a-sequence"], ["fractional", 1.5]]) {
for (const field of ["identity", "stopped"]) {
const rejected = run([`--pairs=${await manifest(`bigint-${field}-${label}`, Array(5).fill(0.30), false, report => {
const stop = report.cases[5];
if (field === "identity") {
stop.controllerAuthority.rows[0].process_identity_seq = value;
stop.localStopProof.database.rows[0].process_identity_seq = value;
} else stop.localStopProof.database.rows[0].process_stopped_seq = value;
})}`, `--noise-report=${noise}`, "--require-acceptance"]);
assert.notEqual(rejected.status, 0); assert.match(rejected.stderr, /BigInt/);
}
}
for (const [name, change, message] of [
["old-noise-protocol", report => { report.protocolVersion = "v2-compact-markers-original-clock-stream"; }, /different mixed protocol/],
["local-noise-transport", report => { report.transport = "local"; }, /different transport/],
+2 -2
View File
@@ -94,7 +94,7 @@ async function runtimeAuthority(input: {
expect(row.checkpoint_part, "Local raw transport keeps its existing host-file journal authority").toBeNull();
expect(row.process_identity?.targetKind).toBe("local"); expect(row.process_identity?.hostname).toBe(hostname());
expect(row.process_identity_source_event_id).toBeNull();
expect(Number(row.process_identity_seq)).toBeGreaterThan(0);
expect(BigInt(String(row.process_identity_seq))).toBeGreaterThan(0n);
expect(row.admitted_execution_workspace_id).toMatch(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i);
if (row.process_started_at) expect(row.process_identity.processStartedAt).toBe(new Date(row.process_started_at).toISOString());
}
@@ -550,7 +550,7 @@ test("native ingestion reaches the shipped UI promptly and survives reload", asy
const row = database.rows[0];
expect(row.status).toBe("cancelled"); expect(row.cancellation_dispatch_state).toBe("acknowledged");
if (!row.process_pid && !row.process_group_id) {
expect(row.process_stopped_seq).toBeGreaterThan(row.process_identity_seq);
expect(BigInt(String(row.process_stopped_seq))).toBeGreaterThan(BigInt(String(row.process_identity_seq)));
expect(row.process_stopped?.processPid).toBe(processIdentity.runnerPid);
expect(row.process_stopped?.processGroupId).toBe(processIdentity.processGroupId);
}