fix(cron): fix test failures and regenerate protocol files

- Add forceReload option to ensureLoaded to avoid stat I/O in normal
  paths while still detecting cross-service writes in the timer path
- Post isolated job summary back to main session (restores the old
  isolation.postToMainPrefix behavior via delivery model)
- Update legacy migration tests to check delivery.channel instead of
  payload.channel (normalization now moves delivery fields to top-level)
- Remove legacy deliver/channel/to/bestEffortDeliver from payload schema
- Update protocol conformance test for delivery modes
- Regenerate GatewayModels.swift (isolation -> delivery)
This commit is contained in:
Tyler Yust
2026-02-03 20:35:47 -08:00
committed by Peter Steinberger
parent 6fb8d8850e
commit f8d2534062
9 changed files with 83 additions and 88 deletions

View File

@@ -42,10 +42,6 @@ export const CronPayloadSchema = Type.Union([
model: Type.Optional(Type.String()),
thinking: Type.Optional(Type.String()),
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 1 })),
deliver: Type.Optional(Type.Boolean()),
channel: Type.Optional(Type.Union([Type.Literal("last"), NonEmptyString])),
to: Type.Optional(Type.String()),
bestEffortDeliver: Type.Optional(Type.Boolean()),
},
{ additionalProperties: false },
),
@@ -66,10 +62,6 @@ export const CronPayloadPatchSchema = Type.Union([
model: Type.Optional(Type.String()),
thinking: Type.Optional(Type.String()),
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 1 })),
deliver: Type.Optional(Type.Boolean()),
channel: Type.Optional(Type.Union([Type.Literal("last"), NonEmptyString])),
to: Type.Optional(Type.String()),
bestEffortDeliver: Type.Optional(Type.Boolean()),
},
{ additionalProperties: false },
),

View File

@@ -164,28 +164,22 @@ describe("gateway server cron", () => {
const mergeUpdateRes = await rpcReq(ws, "cron.update", {
id: mergeJobId,
patch: {
payload: { kind: "agentTurn", deliver: true, channel: "telegram", to: "19098680" },
delivery: { mode: "announce", channel: "telegram", to: "19098680" },
},
});
expect(mergeUpdateRes.ok).toBe(true);
const merged = mergeUpdateRes.payload as
| {
payload?: {
kind?: unknown;
message?: unknown;
model?: unknown;
deliver?: unknown;
channel?: unknown;
to?: unknown;
};
payload?: { kind?: unknown; message?: unknown; model?: unknown };
delivery?: { mode?: unknown; channel?: unknown; to?: unknown };
}
| undefined;
expect(merged?.payload?.kind).toBe("agentTurn");
expect(merged?.payload?.message).toBe("hello");
expect(merged?.payload?.model).toBe("opus");
expect(merged?.payload?.deliver).toBe(true);
expect(merged?.payload?.channel).toBe("telegram");
expect(merged?.payload?.to).toBe("19098680");
expect(merged?.delivery?.mode).toBe("announce");
expect(merged?.delivery?.channel).toBe("telegram");
expect(merged?.delivery?.to).toBe("19098680");
const rejectRes = await rpcReq(ws, "cron.add", {
name: "patch reject",
@@ -203,7 +197,7 @@ describe("gateway server cron", () => {
const rejectUpdateRes = await rpcReq(ws, "cron.update", {
id: rejectJobId,
patch: {
payload: { kind: "agentTurn", deliver: true },
payload: { kind: "agentTurn", message: "nope" },
},
});
expect(rejectUpdateRes.ok).toBe(false);