Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 19 additions & 7 deletions tests/control_plane_ts/authority_source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,33 @@ test("registry witness captures primitive values across awaited request mutation
});

const wires = [
{invoke: createLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_create_request", legacy: [0], current: 1},
{invoke: claimLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_claim_request", legacy: [0], current: 1},
{invoke: terminalLifecycleLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_terminal_lifecycle_request", legacy: [0], current: 1},
{invoke: updateLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_update_request", legacy: [0, 1], current: 2},
{invoke: pollLocalCoordinationMonitor, prefix: "loopx_coordination_monitor_poll_request", legacy: [0, 1], current: 2},
{invoke: createLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_create_request",
legacy: [0], current: 1, currentFields: {},
legacyReason: /registry_source|admission and revision fields/u},
{invoke: claimLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_claim_request",
legacy: [0], current: 1, currentFields: {},
legacyReason: /registry_source|admission and revision fields/u},
{invoke: terminalLifecycleLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_terminal_lifecycle_request",
legacy: [0, 1, 2], current: 3, currentFields: {command: "supersede",
operation_identity: {kind: "explicit", operation_id: "source-wire"},
requested_completion_turn_key: null},
legacyReason: /schema mismatch; regenerate with the current runtime/u},
{invoke: updateLocalCoordinationTodo, prefix: "loopx_local_coordination_todo_update_request",
legacy: [0, 1], current: 2, currentFields: {},
legacyReason: /registry_source|admission and revision fields/u},
{invoke: pollLocalCoordinationMonitor, prefix: "loopx_coordination_monitor_poll_request",
legacy: [0, 1], current: 2, currentFields: {},
legacyReason: /registry_source|admission and revision fields/u},
];
for (const wire of wires) test(`${wire.prefix}: source obligation cannot silently cross wire versions`, async () => {
for (const version of wire.legacy) for (const source of [null, {path: "/unused", sha256: "0".repeat(64)}]) {
const result = await wire.invoke({schema_version: `${wire.prefix}_v${version}`, registry_source: source});
assert.equal(result.status, "failed");
assert.match(String(result.reason), /registry_source|admission and revision fields/u);
assert.match(String(result.reason), wire.legacyReason);
}
for (const source of [undefined, {}, {path: "relative", sha256: "0".repeat(64)}, {path: "/unused", sha256: "invalid"}]) {
const result = await wire.invoke({schema_version: `${wire.prefix}_v${wire.current}`, registry_source: source,
lifecycle_grants: []});
lifecycle_grants: [], ...wire.currentFields});
assert.equal(result.status, "failed");
assert.match(String(result.reason), /registry_source/u);
}
Expand Down
19 changes: 15 additions & 4 deletions tests/control_plane_ts/deferred_hard_lease_lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {JsonObject} from "../../loopx/control_plane/effect_program.ts";
import {FileAuthorityStore} from "../../loopx/control_plane/coordination/file_authority_store.ts";
import {SqliteAuthorityStore} from "../../loopx/control_plane/coordination/sqlite_authority_store.ts";
import {canonicalAuthoritySha256} from "../../loopx/control_plane/coordination/authority_store_codec.ts";
import {sqliteAuthorityRuntime} from "../../loopx/control_plane/coordination/sqlite_runtime.ts";
import {TODO_DOMAIN_ITEM_SCHEMA, TODO_DOMAIN_READ_RECORD_SCHEMA, TODO_DOMAIN_RECORD_CONTRACT} from
"../../loopx/control_plane/coordination/coordination_state_contract.ts";
import {executeCoordinationTodoUpdate, type CoordinationTodoUpdateInput} from
Expand All @@ -22,6 +23,12 @@ const TODO = "todo_task";
const OWNER = "agent-a";
const AGENTS = [OWNER, "agent-b"];

function sqliteSkipReason(): string | undefined {
try { sqliteAuthorityRuntime(); return undefined; }
catch { return "requires a WAL-fixed SQLite runtime with finalized statements"; }
}
const sqliteSkip = sqliteSkipReason();

async function seeded(provider: "file" | "sqlite", overrides: JsonObject = {}, lease?: JsonObject) {
const root = await mkdtemp(join(tmpdir(), `loopx-deferred-${provider}-`));
const path = join(root, "authority");
Expand Down Expand Up @@ -72,7 +79,9 @@ function oldLease(status: "active" | "released", expires_at: string): JsonObject
}

for (const provider of ["file", "sqlite"] as const) {
test(`${provider}: deferred resume is one CAS transition and never grants execution`, async () => {
const skip = provider === "sqlite" ? sqliteSkip : undefined;

test(`${provider}: deferred resume is one CAS transition and never grants execution`, {skip}, async () => {
const store = await seeded(provider);
const before = await read(store);
assert.equal(leaseOwnerRejection({status: "deferred", claimed_by: OWNER, excluded_agents: []}, OWNER, AGENTS),
Expand All @@ -99,7 +108,8 @@ for (const provider of ["file", "sqlite"] as const) {
"coordination_operation_identity_mismatch");
});

test(`${provider}: expired lease is retired atomically, while live execution and foreign edits fail closed`, async () => {
test(`${provider}: expired lease is retired atomically, while live execution and foreign edits fail closed`,
{skip}, async () => {
const expired = await seeded(provider, {}, oldLease("active", "2026-09-05T22:30:00Z"));
const resumed = await executeCoordinationTodoUpdate(expired, resume("retire-expired"));
assert.equal(resumed.status, "applied", JSON.stringify(resumed));
Expand All @@ -123,7 +133,8 @@ for (const provider of ["file", "sqlite"] as const) {
}
});

test(`${provider}: an unclaimed deferred Todo stays unclaimed; excluded actors cannot reopen it`, async () => {
test(`${provider}: an unclaimed deferred Todo stays unclaimed; excluded actors cannot reopen it`,
{skip}, async () => {
const unclaimed = await seeded(provider, {claimed_by: null});
const applied = await executeCoordinationTodoUpdate(unclaimed, resume("unclaimed-resume"));
assert.equal(applied.status, "applied", JSON.stringify(applied));
Expand All @@ -138,7 +149,7 @@ for (const provider of ["file", "sqlite"] as const) {
assert.deepEqual(await read(excluded), before);
});

test(`${provider}: deferred supersede closes one Todo and retires expired lease lineage`, async () => {
test(`${provider}: deferred supersede closes one Todo and retires expired lease lineage`, {skip}, async () => {
const store = await seeded(provider, {}, oldLease("active", "2026-09-05T22:30:00Z"));
const input = supersede("supersede-once");
const before = await read(store);
Expand Down
Loading