feat(core): replace instruction checkpoints with value-delta sync (#36254)

This commit is contained in:
Kit Langton
2026-07-10 13:26:25 -04:00
committed by GitHub
parent 768a69bbbd
commit 96a9731947
57 changed files with 2091 additions and 1316 deletions
@@ -5,8 +5,8 @@ import { SessionEvent } from "./session-event.js"
import { SessionV1 } from "./session-v1.js"
export const SessionDurable = {
definitions: Event.durableMap(SessionEvent.Definitions),
definitions: Event.durableMap(SessionEvent.DurableDefinitions),
schema: SessionEvent.Durable,
} as const
export const Durable = Event.durableMap([...SessionV1.Event.Definitions, ...SessionEvent.Definitions])
export const Durable = Event.durableMap([...SessionV1.Event.Definitions, ...SessionEvent.DurableDefinitions])
+12
View File
@@ -18,3 +18,15 @@ export const Info = Schema.Struct({
value: Schema.Json.annotate({ description: "JSON value attached to the session's instructions" }),
}).annotate({ identifier: "InstructionEntry.Info" })
export interface Info extends Schema.Schema.Type<typeof Info> {}
export const MaxValueBytes = 8 * 1024
export class ValueTooLargeError extends Schema.TaggedErrorClass<ValueTooLargeError>()(
"InstructionEntryValueTooLargeError",
{
actualBytes: Schema.Int,
maxBytes: Schema.Int,
message: Schema.String,
},
{ httpApiStatus: 413 },
) {}
+21
View File
@@ -0,0 +1,21 @@
export * as Instruction from "./instruction.js"
import { Schema } from "effect"
export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/)).pipe(
Schema.brand("Instruction.Key"),
)
export type Key = typeof Key.Type
export const Hash = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/)).pipe(Schema.brand("Instruction.Hash"))
export type Hash = typeof Hash.Type
export const Values = Schema.Record(Key, Hash)
export type Values = Readonly<Record<string, Hash>>
export const Removed = Schema.Literal("removed")
export type Removed = typeof Removed.Type
export const removed = Removed.make("removed")
export const Delta = Schema.Record(Schema.String, Schema.Union([Hash, Removed]))
export type Delta = typeof Delta.Type
+11 -3
View File
@@ -14,6 +14,7 @@ import { SessionMessage } from "./session-message.js"
import { Revert } from "./session-revert.js"
import { Shell as ShellSchema } from "./shell.js"
import { SessionError } from "./session-error.js"
import { Instruction } from "./instruction.js"
import { Agent } from "./agent.js"
import { Skill as SkillSchema } from "./skill.js"
import { Money } from "./money.js"
@@ -105,10 +106,14 @@ export type Deleted = typeof Deleted.Type
export const Forked = Event.durable({
type: "session.forked",
...options,
durable: {
aggregate: "sessionID",
version: 2,
},
schema: {
...Base,
parentID: SessionID,
parentSeq: Schema.Int.check(Schema.isGreaterThanOrEqualTo(-1)),
from: SessionMessage.ID.pipe(optional),
},
})
@@ -159,10 +164,13 @@ export namespace Execution {
export const InstructionsUpdated = Event.durable({
type: "session.instructions.updated",
...options,
durable: {
aggregate: "sessionID",
version: 2,
},
schema: {
...Base,
text: Schema.String,
delta: Instruction.Delta,
},
})
export type InstructionsUpdated = typeof InstructionsUpdated.Type
+2 -2
View File
@@ -104,14 +104,14 @@ describe("public event manifest", () => {
"session.model.selected.1",
"session.moved.1",
"session.renamed.1",
"session.forked.1",
"session.forked.2",
"session.input.promoted.1",
"session.input.admitted.1",
"session.execution.started.1",
"session.execution.succeeded.1",
"session.execution.failed.1",
"session.execution.interrupted.1",
"session.instructions.updated.1",
"session.instructions.updated.2",
"session.synthetic.1",
"session.skill.activated.1",
"session.shell.started.1",