Implement progressive query admission, session boundaries and event-driven Studio observations
This commit is contained in:
@@ -4,6 +4,7 @@ import { portableValueSchema } from "../bindings/portable.js";
|
||||
import { ExecutionPlanError, hexDigest, type ExecutionPlan } from "./plan.js";
|
||||
import type { ValueType } from "../capability-model/types.js";
|
||||
import { compileQueryComposition } from "../query/composition.js";
|
||||
import { queryTreeBlueprint } from "./query-trees.js";
|
||||
|
||||
const lowerTypes = (value: unknown): unknown =>
|
||||
JSON.parse(
|
||||
@@ -59,6 +60,12 @@ export function compileQueryProgram(plan: ExecutionPlan): unknown {
|
||||
codec: "camino-query-program-v1",
|
||||
plan: (compileKernelProgram(plan) as { plan: string }).plan,
|
||||
...(compositions.length ? { compositions } : {}),
|
||||
trees: plan.definition.queries
|
||||
.filter((entry) => entry.query.checked.tree)
|
||||
.map((entry) => ({
|
||||
id: entry.id,
|
||||
...queryTreeBlueprint(entry.query.packageRevisionId, entry.query.checked),
|
||||
})),
|
||||
queries: [
|
||||
...compileInspectionTemplates(plan).queries,
|
||||
...plan.definition.queries.map((entry) => queryProgramEntry(plan, entry)),
|
||||
@@ -85,7 +92,10 @@ export function queryProgramEntry(plan: ExecutionPlan, entry: import("./plan.js"
|
||||
placement: checked.declaration.placement?.kind ?? "remote",
|
||||
source:
|
||||
checked.declaration.placement?.kind === "local"
|
||||
? JSON.stringify([query.packageRevisionId, checked.declaration.placement.sourceQueryId])
|
||||
? JSON.stringify([
|
||||
query.packageRevisionId,
|
||||
checked.treeProjection?.tree ?? checked.declaration.placement.sourceQueryId,
|
||||
])
|
||||
: null,
|
||||
root: checked.declaration.root,
|
||||
atoms: query.rootAtoms,
|
||||
@@ -105,6 +115,19 @@ export function queryProgramEntry(plan: ExecutionPlan, entry: import("./plan.js"
|
||||
operation: JSON.stringify([field.atomId, field.interfaceRevisionId, field.getter]),
|
||||
};
|
||||
}),
|
||||
admittedOperations,
|
||||
admittedOperations: checked.tree
|
||||
? [
|
||||
...new Set([
|
||||
...admittedOperations,
|
||||
...plan.definition.queries
|
||||
.filter(
|
||||
(entry) =>
|
||||
entry.query.packageRevisionId === query.packageRevisionId &&
|
||||
entry.query.checked.treeProjection?.tree === checked.declaration.id,
|
||||
)
|
||||
.flatMap((entry) => entry.operations),
|
||||
]),
|
||||
].sort()
|
||||
: admittedOperations,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user