Compare commits

...

13 Commits

Author SHA1 Message Date
Quixos Subtree Publisher 446fd4e36e Publish camino-package-runtime from 8e42108f9ac903cca5f613fefbff3c147c775b81 2026-09-18 02:55:23 +00:00
Timothy J. Aveni dac9c48856 Publish final aggregation diagnostics and select toolchain pins 2026-09-17 19:55:23 -07:00
Timothy J. Aveni d0dca13ff9 Enforce aggregation contract budgets and expose residual timing 2026-09-17 19:52:55 -07:00
Quixos Subtree Publisher f42d70a4fe Publish camino-package-runtime from 460335e4e892a682e68b10f25abd81e65829538f 2026-09-18 02:47:38 +00:00
Timothy J. Aveni 424ebec92e Publish aggregation toolchain and update scaffold pins 2026-09-17 19:47:38 -07:00
Timothy J. Aveni b86dbe2dfa Implement checked aggregation plans, native SQL, and bounded RPC capture 2026-09-17 19:43:46 -07:00
Quixos Subtree Publisher 1982c6fff1 Publish camino-package-runtime from cbf03106e69d3e2867d7f96859741991e04402b7 2026-09-17 23:51:19 +00:00
Timothy J. Aveni 13d2d0b1ee Pin package SDK to the checked-query protocol release 2026-09-17 16:51:19 -07:00
Timothy J. Aveni c1330ae8e3 Implement query execution, scoped RPC enrichment, live collections, and scaffold integration 2026-09-17 16:49:44 -07:00
Timothy J. Aveni 7e69e675ba Add exact runtime conformance lookup and agent-visible language limits
Add authorized exact-contract lookup, revision-fenced views, generated typed package/browser descriptors, and lifecycle-safe React discovery. Preserve closed generic contracts without competing-conformance policies or new authority grants. Document supported workarounds and privacy boundaries for agent feedback. Publish matching protocol/SDK exports and update scaffold/starter pins; leave the deployed template unchanged.
2026-09-17 12:04:06 -07:00
Quixos Subtree Publisher 99101ad206 Publish camino-package-runtime from db6d7990a4ffec273258ac313b7d2aeac57b261a 2026-09-17 18:54:46 +00:00
Timothy J. Aveni 169c0cdc37 Add exact runtime conformance lookup and agent-visible language limits 2026-09-17 11:54:46 -07:00
Timothy J. Aveni 47efd9659d Release updated TODO template dependencies 2026-09-16 18:17:35 -07:00
33 changed files with 4825 additions and 200 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"version": 1,
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos",
"sourceCommit": "29c36195235aeb4b60042e7ec4df0b0d2bcfff33",
"sourceCommit": "8e42108f9ac903cca5f613fefbff3c147c775b81",
"sourcePath": "quixos-instance/packages/camino-package-runtime",
"exportName": "camino-package-runtime",
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git"
+19
View File
@@ -25,6 +25,17 @@ export type QxContextLifecycle<C> = {
signal?: AbortSignal;
openSession?: () => Promise<QxSession<C>>;
};
declare const contractView: unique symbol;
/** Generated exact closed contract. A descriptor is type evidence, never authority. */
export type QxInterfaceContract<View> = {
readonly interfaceRevisionId: string;
readonly operations: Record<string, QxOperationSpec>;
readonly [contractView]: (value: View) => View;
};
export declare const defineQxInterfaceContract: <View>(interfaceRevisionId: string, operations: Record<string, QxOperationSpec>) => QxInterfaceContract<View>;
export type QxConformer = {
tryConform<View>(object: import("./references.js").QxObjectRef, contract: QxInterfaceContract<View>): Promise<View | undefined>;
};
export declare const qxDerived: <C, O>(get: QxHandler<C, O>) => QxDerived<C, O>;
/** Versioned binding ABI. This mirrors the language-neutral value IR. */
export type QxValueType = {
@@ -52,6 +63,13 @@ export type QxOperationSpec = {
outputType: QxValueType;
};
export type QxPortSpec = {
kind: "query";
id: string;
definitionDigest: string;
variables: QxValueType;
output: QxValueType;
watch: boolean;
} | {
kind: "state";
id: string;
valueType: QxValueType;
@@ -63,6 +81,7 @@ export type QxPortSpec = {
} | {
kind: "interface";
id: string;
interfaceRevisionId: string;
operations: Record<string, QxOperationSpec>;
} | {
kind: "constructor";
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAGL,SAAS,EAGT,KAAK,cAAc,EACnB,KAAK,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Aa,SAAU,WAAW,SAAS,KAAK,GAAG,SAAS,YAAY,UAAU,KAAG,GAyCjG,CAAC;AAOF,eAAO,MAAM,aAAa,SAAU,WAAW,SAAS,GAAG,YAAY,UAAU,KAAG,KA8BnF,CAAC;AAmBF,uFAAuF;AACvF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,QAC1B,aAAa,WACV,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,YAChC,UAAU,KACnB,cAAc,GAAG,cAgInB,CAAC"}
+52 -10
View File
@@ -2,7 +2,21 @@ import { create } from "@bufbuild/protobuf";
import { ValueSchema, ObjectValueSchema } from "./camino/api_pb.js";
import { derived, jsToProtoValue, liveValue, protoValueToJs, } from "./index.js";
import { assertReferenceFree, referenceToWire } from "./references.js";
import { decodeQuerySnapshot } from "./queries.js";
export const defineQxInterfaceContract = (interfaceRevisionId, operations) => Object.freeze({ interfaceRevisionId, operations });
export const qxDerived = (get) => ({ kind: "derived", get });
const bindInterfaceView = (target, contract, messages) => ({
objectId: target.objectId,
contract,
live: Object.fromEntries(Object.entries(contract.operations).map(([name, operation]) => [
name,
(input) => target.live(operation.id, inputFields(operation.inputType, input, messages)),
])),
...Object.fromEntries(Object.entries(contract.operations).map(([name, operation]) => [
name,
async (input) => decodeQxValue(operation.outputType, (await target.live(operation.id, inputFields(operation.inputType, input, messages))).$quixosValue, messages),
])),
});
// Conversion belongs at the binding boundary. It does not add orchestrator validation.
export const decodeQxValue = (type, value, messages) => {
if (type.kind === "builtin" && type.name === "unit")
@@ -152,19 +166,39 @@ export const bindQxHandler = (spec, handler, messages) => {
}
case "interface": {
const target = raw.interface(port.id);
return [
name,
bindInterfaceView(target, defineQxInterfaceContract(port.interfaceRevisionId, port.operations), messages),
];
}
case "query": {
const query = raw.query(port.id);
const variablesToWire = (variables) => {
const value = encodeQxValue(port.variables, variables, messages);
if (value.kind.case !== "objectValue")
throw new Error("QUERY_VARIABLE_INVALID");
return value.kind.value.fields;
};
return [
name,
{
objectId: target.objectId,
live: Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [
name,
(input) => target.live(operation.id, inputFields(operation.inputType, input, messages)),
])),
...Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [
name,
async (input) => decodeQxValue(operation.outputType, (await target.live(operation.id, inputFields(operation.inputType, input, messages)))
.$quixosValue, messages),
])),
async execute(variables) {
const response = await query.execute(variablesToWire(variables), port.definitionDigest);
if (response.pending.length || response.errors.length)
throw new Error("QUERY_INCOMPLETE");
return decodeQxValue(port.output, response.value, messages);
},
...(port.watch
? {
async *watch(variables, signal) {
for await (const event of query.watch(variablesToWire(variables), signal, port.definitionDigest)) {
if (!event.snapshot)
throw new Error("QUERY_SNAPSHOT_MISSING");
yield decodeQuerySnapshot(event.snapshot, port.output, event.runId, event.sequence);
}
},
}
: {}),
},
];
}
@@ -178,6 +212,14 @@ export const bindQxHandler = (spec, handler, messages) => {
}
}));
return {
conform: {
async tryConform(object, contract) {
const target = await raw.tryConform(object, contract.interfaceRevisionId);
return target
? bindInterfaceView(target, contract, messages)
: undefined;
},
},
...(spec.receiver === "none" ? {} : { objectId: raw.objectId }),
signal: raw.signal,
...(spec.receiver !== "none" && raw.openSession
+504 -1
View File
@@ -1,5 +1,5 @@
import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
import type { PersistencePlan } from "./schema_pb.js";
import type { PersistencePlan, QueryRelationalPlan, QuerySelection } from "./schema_pb.js";
import type { Message } from "@bufbuild/protobuf";
/**
* Describes the file camino/api.proto.
@@ -826,10 +826,513 @@ export type CaminoOp = Message<"camino.CaminoOp"> & {
* Use `create(CaminoOpSchema)` to create a new message.
*/
export declare const CaminoOpSchema: GenMessage<CaminoOp>;
/**
* @generated from message camino.QueryRequest
*/
export type QueryRequest = Message<"camino.QueryRequest"> & {
/**
* @generated from field: string query_id = 1;
*/
queryId: string;
/**
* @generated from field: string object_id = 2;
*/
objectId: string;
/**
* @generated from field: map<string, camino.Value> variables = 3;
*/
variables: {
[key: string]: Value;
};
/**
* Typed callers require this exact checked definition. Administrative/raw
* callers may omit it to explicitly select the currently installed definition.
*
* @generated from field: string expected_definition_digest = 4;
*/
expectedDefinitionDigest: string;
};
/**
* Describes the message camino.QueryRequest.
* Use `create(QueryRequestSchema)` to create a new message.
*/
export declare const QueryRequestSchema: GenMessage<QueryRequest>;
/**
* @generated from message camino.QueryPathPart
*/
export type QueryPathPart = Message<"camino.QueryPathPart"> & {
/**
* @generated from oneof camino.QueryPathPart.part
*/
part: {
/**
* @generated from field: string field = 1;
*/
value: string;
case: "field";
} | {
/**
* @generated from field: uint32 index = 2;
*/
value: number;
case: "index";
} | {
case: undefined;
value?: undefined;
};
};
/**
* Describes the message camino.QueryPathPart.
* Use `create(QueryPathPartSchema)` to create a new message.
*/
export declare const QueryPathPartSchema: GenMessage<QueryPathPart>;
/**
* @generated from message camino.QueryPendingField
*/
export type QueryPendingField = Message<"camino.QueryPendingField"> & {
/**
* @generated from field: repeated camino.QueryPathPart path = 1;
*/
path: QueryPathPart[];
/**
* @generated from field: string object_id = 2;
*/
objectId: string;
/**
* @generated from field: string interface_revision_id = 3;
*/
interfaceRevisionId: string;
/**
* @generated from field: string member_id = 4;
*/
memberId: string;
/**
* @generated from field: string operation_id = 5;
*/
operationId: string;
/**
* @generated from field: string value_type_json = 6;
*/
valueTypeJson: string;
/**
* Internal residual facts are separate from the authored result projection.
*
* @generated from field: optional uint32 residual_window = 7;
*/
residualWindow?: number | undefined;
/**
* @generated from field: uint32 residual_row = 8;
*/
residualRow: number;
/**
* @generated from field: string residual_field = 9;
*/
residualField: string;
/**
* @generated from field: optional uint32 relational_capture = 10;
*/
relationalCapture?: number | undefined;
/**
* @generated from field: uint32 captured_object = 11;
*/
capturedObject: number;
};
/**
* Describes the message camino.QueryPendingField.
* Use `create(QueryPendingFieldSchema)` to create a new message.
*/
export declare const QueryPendingFieldSchema: GenMessage<QueryPendingField>;
/**
* @generated from message camino.QueryStats
*/
export type QueryStats = Message<"camino.QueryStats"> & {
/**
* @generated from field: uint32 sql_count = 1;
*/
sqlCount: number;
/**
* @generated from field: double sql_ms = 2;
*/
sqlMs: number;
/**
* @generated from field: uint32 rpc_count = 3;
*/
rpcCount: number;
/**
* @generated from field: double rpc_ms = 4;
*/
rpcMs: number;
/**
* @generated from field: uint32 result_bytes = 5;
*/
resultBytes: number;
/**
* @generated from field: double preparation_ms = 6;
*/
preparationMs: number;
/**
* @generated from field: double total_ms = 7;
*/
totalMs: number;
/**
* @generated from field: uint32 relational_stages = 8;
*/
relationalStages: number;
/**
* @generated from field: uint32 captured_candidates = 9;
*/
capturedCandidates: number;
/**
* @generated from field: double relational_ms = 10;
*/
relationalMs: number;
/**
* @generated from field: double residual_ms = 11;
*/
residualMs: number;
};
/**
* Describes the message camino.QueryStats.
* Use `create(QueryStatsSchema)` to create a new message.
*/
export declare const QueryStatsSchema: GenMessage<QueryStats>;
/**
* @generated from message camino.QueryResponse
*/
export type QueryResponse = Message<"camino.QueryResponse"> & {
/**
* @generated from field: camino.Value value = 1;
*/
value?: Value | undefined;
/**
* @generated from field: string data_version = 2;
*/
dataVersion: string;
/**
* @generated from field: string binding_digest = 3;
*/
bindingDigest: string;
/**
* @generated from field: repeated camino.QueryPendingField pending = 4;
*/
pending: QueryPendingField[];
/**
* @generated from field: camino.QueryStats stats = 5;
*/
stats?: QueryStats | undefined;
/**
* Redeemable only through the host's private control socket, not an RPC grant.
*
* @generated from field: string preparation_token = 6;
*/
preparationToken: string;
/**
* @generated from field: repeated camino.QueryFieldFailure errors = 7;
*/
errors: QueryFieldFailure[];
/**
* @generated from field: repeated camino.QueryResidualWindow residual_windows = 8;
*/
residualWindows: QueryResidualWindow[];
/**
* Native reads share one database snapshot; package enrichment does not.
*
* native-snapshot | mixed
*
* @generated from field: string consistency = 9;
*/
consistency: string;
/**
* @generated from field: repeated camino.QueryRelationalCapture relational_captures = 10;
*/
relationalCaptures: QueryRelationalCapture[];
};
/**
* Describes the message camino.QueryResponse.
* Use `create(QueryResponseSchema)` to create a new message.
*/
export declare const QueryResponseSchema: GenMessage<QueryResponse>;
/**
* Private coordinator input, removed before publishing a result. Memberships
* and native facts share one snapshot; package reads are sampled afterwards.
*
* @generated from message camino.QueryCapturedMember
*/
export type QueryCapturedMember = Message<"camino.QueryCapturedMember"> & {
/**
* @generated from field: string object_id = 1;
*/
objectId: string;
/**
* @generated from field: string entry_id = 2;
*/
entryId: string;
/**
* @generated from field: camino.Value map_key = 3;
*/
mapKey?: Value | undefined;
};
/**
* Describes the message camino.QueryCapturedMember.
* Use `create(QueryCapturedMemberSchema)` to create a new message.
*/
export declare const QueryCapturedMemberSchema: GenMessage<QueryCapturedMember>;
/**
* @generated from message camino.QueryCapturedMembers
*/
export type QueryCapturedMembers = Message<"camino.QueryCapturedMembers"> & {
/**
* @generated from field: repeated camino.QueryCapturedMember entries = 1;
*/
entries: QueryCapturedMember[];
};
/**
* Describes the message camino.QueryCapturedMembers.
* Use `create(QueryCapturedMembersSchema)` to create a new message.
*/
export declare const QueryCapturedMembersSchema: GenMessage<QueryCapturedMembers>;
/**
* @generated from message camino.QueryCapturedObject
*/
export type QueryCapturedObject = Message<"camino.QueryCapturedObject"> & {
/**
* @generated from field: string object_id = 1;
*/
objectId: string;
/**
* @generated from field: map<string, camino.Value> fields = 2;
*/
fields: {
[key: string]: Value;
};
/**
* @generated from field: map<string, string> field_types = 3;
*/
fieldTypes: {
[key: string]: string;
};
/**
* @generated from field: map<string, camino.QueryCapturedMembers> relationships = 4;
*/
relationships: {
[key: string]: QueryCapturedMembers;
};
};
/**
* Describes the message camino.QueryCapturedObject.
* Use `create(QueryCapturedObjectSchema)` to create a new message.
*/
export declare const QueryCapturedObjectSchema: GenMessage<QueryCapturedObject>;
/**
* @generated from message camino.QueryRelationalCapture
*/
export type QueryRelationalCapture = Message<"camino.QueryRelationalCapture"> & {
/**
* @generated from field: repeated camino.QueryPathPart path = 1;
*/
path: QueryPathPart[];
/**
* @generated from field: camino.QueryRelationalPlan plan = 2;
*/
plan?: QueryRelationalPlan | undefined;
/**
* @generated from field: string root_object_id = 3;
*/
rootObjectId: string;
/**
* @generated from field: repeated camino.QueryCapturedObject objects = 4;
*/
objects: QueryCapturedObject[];
/**
* @generated from field: string variables_json = 5;
*/
variablesJson: string;
/**
* @generated from field: uint32 row_limit = 6;
*/
rowLimit: number;
/**
* @generated from field: uint32 candidate_limit = 7;
*/
candidateLimit: number;
/**
* @generated from field: optional uint32 residual_window = 8;
*/
residualWindow?: number | undefined;
/**
* @generated from field: repeated string result_path = 9;
*/
resultPath: string[];
};
/**
* Describes the message camino.QueryRelationalCapture.
* Use `create(QueryRelationalCaptureSchema)` to create a new message.
*/
export declare const QueryRelationalCaptureSchema: GenMessage<QueryRelationalCapture>;
/**
* @generated from message camino.QueryResidualRow
*/
export type QueryResidualRow = Message<"camino.QueryResidualRow"> & {
/**
* @generated from field: string entry_id = 1;
*/
entryId: string;
/**
* @generated from field: map<string, camino.Value> fields = 2;
*/
fields: {
[key: string]: Value;
};
};
/**
* Describes the message camino.QueryResidualRow.
* Use `create(QueryResidualRowSchema)` to create a new message.
*/
export declare const QueryResidualRowSchema: GenMessage<QueryResidualRow>;
/**
* @generated from message camino.QueryResidualOrder
*/
export type QueryResidualOrder = Message<"camino.QueryResidualOrder"> & {
/**
* @generated from field: string field = 1;
*/
field: string;
/**
* @generated from field: bool descending = 2;
*/
descending: boolean;
};
/**
* Describes the message camino.QueryResidualOrder.
* Use `create(QueryResidualOrderSchema)` to create a new message.
*/
export declare const QueryResidualOrderSchema: GenMessage<QueryResidualOrder>;
/**
* @generated from message camino.QueryResidualWindow
*/
export type QueryResidualWindow = Message<"camino.QueryResidualWindow"> & {
/**
* @generated from field: repeated camino.QueryPathPart path = 1;
*/
path: QueryPathPart[];
/**
* @generated from field: repeated camino.QueryResidualRow rows = 2;
*/
rows: QueryResidualRow[];
/**
* @generated from field: string predicate_json = 3;
*/
predicateJson: string;
/**
* @generated from field: repeated camino.QueryResidualOrder order = 4;
*/
order: QueryResidualOrder[];
/**
* @generated from field: uint32 limit = 5;
*/
limit: number;
/**
* @generated from field: bool bounded_all = 6;
*/
boundedAll: boolean;
/**
* @generated from field: repeated camino.QuerySelection selection = 7;
*/
selection: QuerySelection[];
/**
* @generated from field: map<string, string> field_types = 8;
*/
fieldTypes: {
[key: string]: string;
};
/**
* @generated from field: bool relational = 9;
*/
relational: boolean;
/**
* @generated from field: repeated string matched_entries = 10;
*/
matchedEntries: string[];
};
/**
* Describes the message camino.QueryResidualWindow.
* Use `create(QueryResidualWindowSchema)` to create a new message.
*/
export declare const QueryResidualWindowSchema: GenMessage<QueryResidualWindow>;
/**
* @generated from message camino.QueryFieldFailure
*/
export type QueryFieldFailure = Message<"camino.QueryFieldFailure"> & {
/**
* @generated from field: repeated camino.QueryPathPart path = 1;
*/
path: QueryPathPart[];
/**
* @generated from field: string error = 2;
*/
error: string;
};
/**
* Describes the message camino.QueryFieldFailure.
* Use `create(QueryFieldFailureSchema)` to create a new message.
*/
export declare const QueryFieldFailureSchema: GenMessage<QueryFieldFailure>;
/**
* @generated from message camino.QueryChangesRequest
*/
export type QueryChangesRequest = Message<"camino.QueryChangesRequest"> & {
/**
* @generated from field: string query_id = 1;
*/
queryId: string;
/**
* @generated from field: string object_id = 2;
*/
objectId: string;
/**
* @generated from field: string data_version = 3;
*/
dataVersion: string;
};
/**
* Describes the message camino.QueryChangesRequest.
* Use `create(QueryChangesRequestSchema)` to create a new message.
*/
export declare const QueryChangesRequestSchema: GenMessage<QueryChangesRequest>;
/**
* @generated from message camino.QueryChangesResponse
*/
export type QueryChangesResponse = Message<"camino.QueryChangesResponse"> & {
/**
* @generated from field: bool changed = 1;
*/
changed: boolean;
};
/**
* Describes the message camino.QueryChangesResponse.
* Use `create(QueryChangesResponseSchema)` to create a new message.
*/
export declare const QueryChangesResponseSchema: GenMessage<QueryChangesResponse>;
/**
* @generated from service camino.CaminoService
*/
export declare const CaminoService: GenService<{
/**
* @generated from rpc camino.CaminoService.ExecuteQuery
*/
executeQuery: {
methodKind: "unary";
input: typeof QueryRequestSchema;
output: typeof QueryResponseSchema;
};
/**
* @generated from rpc camino.CaminoService.QueryChanges
*/
queryChanges: {
methodKind: "unary";
input: typeof QueryChangesRequestSchema;
output: typeof QueryChangesResponseSchema;
};
/**
* @generated from rpc camino.CaminoService.InstallPersistencePlan
*/
+1 -1
View File
File diff suppressed because one or more lines are too long
+76 -1
View File
File diff suppressed because one or more lines are too long
+1044
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+261 -1
View File
File diff suppressed because one or more lines are too long
+10 -2
View File
@@ -1,10 +1,11 @@
import http from "node:http";
import { type QxObjectRef } from "./references.js";
export * from "./bindings.js";
export * from "./queries.js";
export { relationshipMap, relationshipList, relationshipSet } from "./relationships.js";
export { createMigrationContext, migrationObjectId, serveMigration, type MigrationContext, type MigrationInput, type MigrationOutput, type MigrationEdge, } from "./migration.js";
import { type Client, type ConnectRouter } from "@connectrpc/connect";
import { CaminoService, type Value } from "./camino/api_pb.js";
import { CaminoService, type Value, type QueryResponse } from "./camino/api_pb.js";
import { OrchestratorRuntime } from "./quixos/orch_pb.js";
export type CaminoClient = Client<typeof CaminoService>;
export type OrchClient = Client<typeof OrchestratorRuntime>;
@@ -61,8 +62,14 @@ export type ConstructorPort = {
atomId: string;
construct(input?: Record<string, unknown>): Promise<QxObjectRef>;
};
export type RuntimePort = StatePort | EdgePort | InterfacePort | ConstructorPort;
export type QueryPort = {
queryId: string;
execute(variables: Record<string, Value>, expectedDefinitionDigest?: string): Promise<QueryResponse>;
watch(variables: Record<string, Value>, signal: AbortSignal, expectedDefinitionDigest?: string): AsyncIterable<import("./quixos/orch_pb.js").QueryEvent>;
};
export type RuntimePort = StatePort | EdgePort | InterfacePort | ConstructorPort | QueryPort;
export type RuntimeContext = {
tryConform(object: QxObjectRef, interfaceRevisionId: string): Promise<InterfacePort | undefined>;
/** Cooperative cancellation. Completion is acknowledged only after the handler returns. */
signal?: AbortSignal;
openSession?: () => Promise<RuntimeSession>;
@@ -74,6 +81,7 @@ export type RuntimeContext = {
edge(portId: string): EdgePort;
interface(portId: string): InterfacePort;
constructor(portId: string): ConstructorPort;
query(portId: string): QueryPort;
};
export type RuntimeSession = {
id: string;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGxF,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAoC,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAExG,OAAO,EACL,aAAa,EAOb,KAAK,KAAK,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAU1D,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;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F;IAChF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AACF,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,YAAY,OAAO,EAAE,MAAM,EAI1B;CACF;AAOD,eAAO,MAAM,oBAAoB,WACvB,YAAY,QACd,UAAU,WACP,cAAc,KACtB,cAqMF,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACrF,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,cAAc,CAAA;CAAE,CAAC;AACtE,eAAO,MAAM,OAAO,QAAS,cAAc,KAAG,cAA4C,CAAC;AA0B3F,eAAO,MAAM,0BAA0B,WAAY;IACjD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,cAwJiB,aAAa,kBAgN9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAY;IAC1C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;CAC1D,yEAaA,CAAC;AACF,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7B,YAAY,EAAE,OAAO,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;CAClE,CAAC"}
+48 -41
View File
@@ -3,6 +3,7 @@ import { readFileSync } from "node:fs";
import { createInvocationRegistry } from "./invocations.js";
import { isObjectReference, referenceFromWire, referenceToWire, assertReferenceFree, } from "./references.js";
export * from "./bindings.js";
export * from "./queries.js";
export { relationshipMap, relationshipList, relationshipSet } from "./relationships.js";
import { AsyncLocalStorage } from "node:async_hooks";
import { createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -123,9 +124,47 @@ export class RuntimeAuthorityError extends Error {
}
const targetForEdge = (edge, projectionId) => (edge.firstProjectionId === projectionId ? edge.secondObjectId : edge.firstObjectId);
export const createRuntimeContext = (camino, orch, request) => {
const acquiredPort = (objectId, interfaceRevisionId, conformance) => {
const invoke = async (operationId, input = {}) => {
const response = await orch.invokeCapability({
objectId,
capability: create(CapabilityRefSchema, { interfaceRevisionId, operationId, conformance }),
input: Object.fromEntries(Object.entries(input).map(([key, value]) => [key, jsToProtoValue(value)])),
});
if (!response.ok)
throw new Error(response.error || "Capability invocation failed");
for (const dependency of response.dependencies) {
if (dependency.kind === "state" || dependency.kind === "edge")
await recordDependency({
kind: dependency.kind,
objectId: dependency.objectId,
attachmentId: dependency.attachmentId,
...(dependency.kind === "edge" ? { projectionId: dependency.projectionId } : {}),
});
}
if (!response.result)
throw new Error("Capability returned no value");
return response.result;
};
return {
objectId: referenceFromWire(objectId),
interfaceRevisionId,
invoke: async (operation, input) => protoValueToJs(await invoke(operation, input)),
live: async (operation, input) => liveValue(await invoke(operation, input)),
};
};
const ports = new Map();
for (const dependency of request.dependencies) {
switch (dependency.binding.case) {
case "queryId": {
const queryId = dependency.binding.value, objectId = dependency.objectId || request.objectId;
ports.set(dependency.portId, {
queryId,
execute: (variables, expectedDefinitionDigest) => orch.executeQuery({ queryId, objectId, variables, expectedDefinitionDigest }),
watch: (variables, signal, expectedDefinitionDigest) => orch.watchQuery({ queryId, objectId, variables, expectedDefinitionDigest }, { signal }),
});
break;
}
case "stateSlotId": {
const slotId = dependency.binding.value;
const dependencyObjectId = dependency.objectId || request.objectId;
@@ -224,47 +263,7 @@ export const createRuntimeContext = (camino, orch, request) => {
case "interfaceRevisionId": {
const interfaceRevisionId = dependency.binding.value;
const dependencyObjectId = dependency.objectId || request.objectId;
const invoke = async (operationId, input) => {
const response = await orch.invokeCapability({
capability: create(CapabilityRefSchema, { interfaceRevisionId, operationId }),
objectId: dependencyObjectId,
input: Object.fromEntries(Object.entries(input).map(([key, value]) => [key, jsToProtoValue(value)])),
});
if (!response.ok)
throw new Error(response.error || `Capability ${operationId} failed`);
for (const dependency of response.dependencies) {
if (dependency.kind === "state") {
await recordDependency({
kind: "state",
objectId: dependency.objectId,
attachmentId: dependency.attachmentId,
});
}
else if (dependency.kind === "edge") {
await recordDependency({
kind: "edge",
objectId: dependency.objectId,
attachmentId: dependency.attachmentId,
projectionId: dependency.projectionId,
});
}
}
return response.result;
};
const capability = {
objectId: referenceFromWire(dependencyObjectId),
interfaceRevisionId,
async invoke(operationId, input = {}) {
return protoValueToJs(await invoke(operationId, input));
},
async live(operationId, input = {}) {
const value = await invoke(operationId, input);
if (!value)
throw new Error(`Capability ${operationId} returned no value`);
return liveValue(value);
},
};
ports.set(dependency.portId, capability);
ports.set(dependency.portId, acquiredPort(dependencyObjectId, interfaceRevisionId));
break;
}
case "constructorAtomId": {
@@ -292,6 +291,13 @@ export const createRuntimeContext = (camino, orch, request) => {
return port;
};
return {
async tryConform(object, interfaceRevisionId) {
const objectId = referenceToWire(object);
const { conformance } = await orch.tryConform({ objectId, interfaceRevisionId });
if (conformance && (conformance.objectId !== objectId || conformance.interfaceRevisionId !== interfaceRevisionId))
throw new Error("Conformance response does not match the requested view");
return conformance ? acquiredPort(objectId, interfaceRevisionId, conformance) : undefined;
},
get objectId() {
return referenceFromWire(request.objectId);
},
@@ -302,6 +308,7 @@ export const createRuntimeContext = (camino, orch, request) => {
edge: (portId) => requirePort(portId, "edgeTypeId"),
interface: (portId) => requirePort(portId, "interfaceRevisionId"),
constructor: (portId) => requirePort(portId, "atomId"),
query: (portId) => requirePort(portId, "queryId"),
};
};
export const derived = (get) => ({ kind: "derived", get });
+38
View File
@@ -0,0 +1,38 @@
import { type QxValueType } from "./bindings.js";
import type { QueryResponse } from "./camino/api_pb.js";
import type { QxObjectRef } from "./references.js";
export type QxQueryPartial<T> = T extends QxObjectRef ? T : T extends readonly (infer Item)[] ? QxQueryPartial<Item>[] : T extends object ? {
[Key in keyof T]?: QxQueryPartial<T[Key]>;
} : T;
export type QxQuerySnapshot<T> = {
runId: string;
sequence: bigint;
dataVersion: string;
bindingDigest: string;
consistency: string;
fields: {
path: readonly (string | number)[];
status: "pending" | "error";
error?: string;
}[];
} & ({
status: "ready";
data: T;
} | {
status: "partial";
data: QxQueryPartial<T>;
});
declare const queryTypes: unique symbol;
/** Generated shape evidence, not permission to run a query. */
export interface QxQueryDescriptor<Variables, Result, Root extends string = string> {
readonly id: string;
readonly definitionDigest: string;
readonly rootInterfaceRevisionId: Root;
readonly variables: QxValueType;
readonly output: QxValueType;
readonly watch: boolean;
readonly [queryTypes]?: (variables: Variables, result: Result) => [Variables, Result];
}
export declare function decodeQuerySnapshot<T>(response: QueryResponse, output: QxValueType, runId: string, sequence: bigint): QxQuerySnapshot<T>;
export {};
//# sourceMappingURL=queries.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,WAAW,GACjD,CAAC,GACD,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GAC/B,cAAc,CAAC,IAAI,CAAC,EAAE,GACtB,CAAC,SAAS,MAAM,GACd;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GAC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,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,eAAe,CAAC,CAAC,CAAC,CA6CpB"}
+57
View File
@@ -0,0 +1,57 @@
import { decodeQxValue } from "./bindings.js";
export function decodeQuerySnapshot(response, output, runId, sequence) {
if (response.preparationToken || response.residualWindows.length || response.relationalCaptures.length)
throw new Error("QUERY_RESULT_UNFINISHED: private preparation is not a query result");
const fields = [
...response.pending.map((field) => ({ path: field.path, status: "pending" })),
...response.errors.map((field) => ({ path: field.path, status: "error", error: field.error })),
].map((field) => ({
...field,
path: field.path.map((part) => {
if (part.part.case !== "field" && part.part.case !== "index")
throw new Error("QUERY_PATCH_INVALID");
return part.part.value;
}),
}));
// Pending/error values are absent, not successful nulls of a scalar type.
const shape = structuredClone(output);
for (const field of fields) {
let cursor = shape;
for (const [index, part] of field.path.entries()) {
while (cursor.kind === "optional")
cursor = cursor.value;
const last = index === field.path.length - 1;
if (typeof part === "string" && cursor.kind === "record" && cursor.fields[part]) {
if (last)
cursor.fields[part] = { kind: "optional", value: cursor.fields[part] };
else
cursor = cursor.fields[part];
}
else if (typeof part === "number" && cursor.kind === "list")
cursor = cursor.value;
else
throw new Error("QUERY_PATCH_INVALID");
}
}
const data = decodeQxValue(shape, response.value, {});
for (const field of fields) {
let cursor = data;
for (const [index, part] of field.path.entries()) {
if (!cursor || typeof cursor !== "object")
throw new Error("QUERY_PATCH_INVALID");
if (index === field.path.length - 1)
delete cursor[part];
else
cursor = cursor[part];
}
}
return {
runId,
sequence,
dataVersion: response.dataVersion,
bindingDigest: response.bindingDigest,
consistency: response.consistency,
fields,
...(fields.length ? { status: "partial", data } : { status: "ready", data }),
};
}
+155 -2
View File
@@ -1,13 +1,88 @@
import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
import type { CaminoObject, CrdtValue, Value } from "../camino/api_pb.js";
import type { CaminoObject, CrdtValue, QueryPathPart, QueryRequestSchema, QueryResponse, QueryResponseSchema, Value } from "../camino/api_pb.js";
import type { InstalledQuery } from "../camino/schema_pb.js";
import type { PackageDescriptor } from "./package_pb.js";
import type { CapabilityRef, PackageExportRef } from "./refs_pb.js";
import type { CapabilityRef, ConformanceWitness, PackageExportRef } from "./refs_pb.js";
import type { DerivedDependency } from "./runtime_pb.js";
import type { Message } from "@bufbuild/protobuf";
/**
* Describes the file quixos/orch.proto.
*/
export declare const file_quixos_orch: GenFile;
/**
* @generated from message quixos.orch.QueryEvent
*/
export type QueryEvent = Message<"quixos.orch.QueryEvent"> & {
/**
* @generated from field: string run_id = 1;
*/
runId: string;
/**
* @generated from field: uint64 sequence = 2;
*/
sequence: bigint;
/**
* @generated from field: string kind = 3;
*/
kind: string;
/**
* @generated from field: camino.QueryResponse snapshot = 4;
*/
snapshot?: QueryResponse | undefined;
/**
* @generated from field: repeated camino.QueryPathPart path = 5;
*/
path: QueryPathPart[];
/**
* @generated from field: camino.Value value = 6;
*/
value?: Value | undefined;
/**
* @generated from field: string error = 7;
*/
error: string;
};
/**
* Describes the message quixos.orch.QueryEvent.
* Use `create(QueryEventSchema)` to create a new message.
*/
export declare const QueryEventSchema: GenMessage<QueryEvent>;
/**
* Exact closed interface lookup; no policy selection or competing conformances.
*
* @generated from message quixos.orch.TryConformRequest
*/
export type TryConformRequest = Message<"quixos.orch.TryConformRequest"> & {
/**
* @generated from field: string object_id = 1;
*/
objectId: string;
/**
* @generated from field: string interface_revision_id = 2;
*/
interfaceRevisionId: string;
};
/**
* Describes the message quixos.orch.TryConformRequest.
* Use `create(TryConformRequestSchema)` to create a new message.
*/
export declare const TryConformRequestSchema: GenMessage<TryConformRequest>;
/**
* @generated from message quixos.orch.TryConformResponse
*/
export type TryConformResponse = Message<"quixos.orch.TryConformResponse"> & {
/**
* Absent only when this object lacks a known contract. Other failures are errors.
*
* @generated from field: quixos.ConformanceWitness conformance = 1;
*/
conformance?: ConformanceWitness | undefined;
};
/**
* Describes the message quixos.orch.TryConformResponse.
* Use `create(TryConformResponseSchema)` to create a new message.
*/
export declare const TryConformResponseSchema: GenMessage<TryConformResponse>;
/**
* @generated from message quixos.orch.ConstructObjectRequest
*/
@@ -315,6 +390,10 @@ export type GetWorkspaceRequest = Message<"quixos.orch.GetWorkspaceRequest"> & {
* @generated from field: bool include_interface_contracts = 1;
*/
includeInterfaceContracts: boolean;
/**
* @generated from field: bool include_query_contracts = 2;
*/
includeQueryContracts: boolean;
};
/**
* Describes the message quixos.orch.GetWorkspaceRequest.
@@ -362,12 +441,62 @@ export type GetWorkspaceResponse = Message<"quixos.orch.GetWorkspaceResponse"> &
* @generated from field: repeated quixos.orch.ClassCapability class_capabilities = 8;
*/
classCapabilities: ClassCapability[];
/**
* @generated from field: repeated quixos.orch.QueryDescription queries = 9;
*/
queries: QueryDescription[];
/**
* @generated from field: uint32 active_query_executions = 10;
*/
activeQueryExecutions: number;
};
/**
* Describes the message quixos.orch.GetWorkspaceResponse.
* Use `create(GetWorkspaceResponseSchema)` to create a new message.
*/
export declare const GetWorkspaceResponseSchema: GenMessage<GetWorkspaceResponse>;
/**
* @generated from message quixos.orch.QueryDescription
*/
export type QueryDescription = Message<"quixos.orch.QueryDescription"> & {
/**
* @generated from field: string id = 1;
*/
id: string;
/**
* @generated from field: string name = 2;
*/
name: string;
/**
* @generated from field: string package_revision_id = 3;
*/
packageRevisionId: string;
/**
* @generated from field: string document = 4;
*/
document: string;
/**
* @generated from field: string schema = 5;
*/
schema: string;
/**
* @generated from field: repeated string source_files = 6;
*/
sourceFiles: string[];
/**
* @generated from field: string effects_json = 7;
*/
effectsJson: string;
/**
* @generated from field: camino.InstalledQuery plan = 8;
*/
plan?: InstalledQuery | undefined;
};
/**
* Describes the message quixos.orch.QueryDescription.
* Use `create(QueryDescriptionSchema)` to create a new message.
*/
export declare const QueryDescriptionSchema: GenMessage<QueryDescription>;
/**
* @generated from message quixos.orch.ClassCapability
*/
@@ -659,6 +788,30 @@ export declare const PackageRuntimeStatusSchema: GenMessage<PackageRuntimeStatus
* @generated from service quixos.orch.OrchestratorRuntime
*/
export declare const OrchestratorRuntime: GenService<{
/**
* @generated from rpc quixos.orch.OrchestratorRuntime.ExecuteQuery
*/
executeQuery: {
methodKind: "unary";
input: typeof QueryRequestSchema;
output: typeof QueryResponseSchema;
};
/**
* @generated from rpc quixos.orch.OrchestratorRuntime.WatchQuery
*/
watchQuery: {
methodKind: "server_streaming";
input: typeof QueryRequestSchema;
output: typeof QueryEventSchema;
};
/**
* @generated from rpc quixos.orch.OrchestratorRuntime.TryConform
*/
tryConform: {
methodKind: "unary";
input: typeof TryConformRequestSchema;
output: typeof TryConformResponseSchema;
};
/**
* @generated from rpc quixos.orch.OrchestratorRuntime.InvokeCapability
*/
+1 -1
View File
File diff suppressed because one or more lines are too long
+48 -27
View File
File diff suppressed because one or more lines are too long
+42
View File
@@ -16,12 +16,48 @@ export type CapabilityRef = Message<"quixos.CapabilityRef"> & {
* @generated from field: string operation_id = 2;
*/
operationId: string;
/**
* Optional fence for a view acquired through TryConform. Not an authority grant.
*
* @generated from field: quixos.ConformanceWitness conformance = 3;
*/
conformance?: ConformanceWitness | undefined;
};
/**
* Describes the message quixos.CapabilityRef.
* Use `create(CapabilityRefSchema)` to create a new message.
*/
export declare const CapabilityRefSchema: GenMessage<CapabilityRef>;
/**
* @generated from message quixos.ConformanceWitness
*/
export type ConformanceWitness = Message<"quixos.ConformanceWitness"> & {
/**
* @generated from field: string object_id = 1;
*/
objectId: string;
/**
* @generated from field: string interface_revision_id = 2;
*/
interfaceRevisionId: string;
/**
* @generated from field: string conformance_id = 3;
*/
conformanceId: string;
/**
* @generated from field: string workspace_revision_id = 4;
*/
workspaceRevisionId: string;
/**
* @generated from field: string workspace_epoch = 5;
*/
workspaceEpoch: string;
};
/**
* Describes the message quixos.ConformanceWitness.
* Use `create(ConformanceWitnessSchema)` to create a new message.
*/
export declare const ConformanceWitnessSchema: GenMessage<ConformanceWitness>;
/**
* @generated from message quixos.PackageExportRef
*/
@@ -75,6 +111,12 @@ export type InjectedDependency = Message<"quixos.InjectedDependency"> & {
*/
value: string;
case: "constructorAtomId";
} | {
/**
* @generated from field: string query_id = 7;
*/
value: string;
case: "queryId";
} | {
case: undefined;
value?: undefined;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"refs_pb.d.ts","sourceRoot":"","sources":["../../src/quixos/refs_pb.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,OACmjB,CAAC;AAEnlB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG;IAC5D;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAU,CAAC,aAAa,CACxB,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC,GAAG;IAClE;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,UAAU,CAAC,gBAAgB,CAC9B,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC,GAAG;IACtE;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE;QACP;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,aAAa,CAAC;KACrB,GAAG;QACF;;WAEG;QACH,KAAK,EAAE,cAAc,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG;QACF;;WAEG;QACH,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C,EAAE,SAAS,CAAA;KAAE,CAAC;IAE3C;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,UAAU,CAAC,kBAAkB,CAClC,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC,GAAG;IAC9D;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,UAAU,CAAC,cAAc,CAC1B,CAAC"}
+9 -4
View File
@@ -5,24 +5,29 @@ import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
/**
* Describes the file quixos/refs.proto.
*/
export const file_quixos_refs = /*@__PURE__*/ fileDesc("ChFxdWl4b3MvcmVmcy5wcm90bxIGcXVpeG9zIkQKDUNhcGFiaWxpdHlSZWYSHQoVaW50ZXJmYWNlX3JldmlzaW9uX2lkGAEgASgJEhQKDG9wZXJhdGlvbl9pZBgCIAEoCSJCChBQYWNrYWdlRXhwb3J0UmVmEhsKE3BhY2thZ2VfcmV2aXNpb25faWQYASABKAkSEQoJZXhwb3J0X2lkGAIgASgJIsQBChJJbmplY3RlZERlcGVuZGVuY3kSDwoHcG9ydF9pZBgBIAEoCRIXCg1zdGF0ZV9zbG90X2lkGAIgASgJSAASJgoEZWRnZRgDIAEoCzIWLnF1aXhvcy5FZGdlRGVwZW5kZW5jeUgAEh8KFWludGVyZmFjZV9yZXZpc2lvbl9pZBgEIAEoCUgAEh0KE2NvbnN0cnVjdG9yX2F0b21faWQYBSABKAlIABIRCglvYmplY3RfaWQYBiABKAlCCQoHYmluZGluZyI9Cg5FZGdlRGVwZW5kZW5jeRIUCgxlZGdlX3R5cGVfaWQYASABKAkSFQoNcHJvamVjdGlvbl9pZBgCIAEoCWIGcHJvdG8z");
export const file_quixos_refs = /*@__PURE__*/ fileDesc("ChFxdWl4b3MvcmVmcy5wcm90bxIGcXVpeG9zInUKDUNhcGFiaWxpdHlSZWYSHQoVaW50ZXJmYWNlX3JldmlzaW9uX2lkGAEgASgJEhQKDG9wZXJhdGlvbl9pZBgCIAEoCRIvCgtjb25mb3JtYW5jZRgDIAEoCzIaLnF1aXhvcy5Db25mb3JtYW5jZVdpdG5lc3MilgEKEkNvbmZvcm1hbmNlV2l0bmVzcxIRCglvYmplY3RfaWQYASABKAkSHQoVaW50ZXJmYWNlX3JldmlzaW9uX2lkGAIgASgJEhYKDmNvbmZvcm1hbmNlX2lkGAMgASgJEh0KFXdvcmtzcGFjZV9yZXZpc2lvbl9pZBgEIAEoCRIXCg93b3Jrc3BhY2VfZXBvY2gYBSABKAkiQgoQUGFja2FnZUV4cG9ydFJlZhIbChNwYWNrYWdlX3JldmlzaW9uX2lkGAEgASgJEhEKCWV4cG9ydF9pZBgCIAEoCSLYAQoSSW5qZWN0ZWREZXBlbmRlbmN5Eg8KB3BvcnRfaWQYASABKAkSFwoNc3RhdGVfc2xvdF9pZBgCIAEoCUgAEiYKBGVkZ2UYAyABKAsyFi5xdWl4b3MuRWRnZURlcGVuZGVuY3lIABIfChVpbnRlcmZhY2VfcmV2aXNpb25faWQYBCABKAlIABIdChNjb25zdHJ1Y3Rvcl9hdG9tX2lkGAUgASgJSAASEgoIcXVlcnlfaWQYByABKAlIABIRCglvYmplY3RfaWQYBiABKAlCCQoHYmluZGluZyI9Cg5FZGdlRGVwZW5kZW5jeRIUCgxlZGdlX3R5cGVfaWQYASABKAkSFQoNcHJvamVjdGlvbl9pZBgCIAEoCWIGcHJvdG8z");
/**
* Describes the message quixos.CapabilityRef.
* Use `create(CapabilityRefSchema)` to create a new message.
*/
export const CapabilityRefSchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 0);
/**
* Describes the message quixos.ConformanceWitness.
* Use `create(ConformanceWitnessSchema)` to create a new message.
*/
export const ConformanceWitnessSchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 1);
/**
* Describes the message quixos.PackageExportRef.
* Use `create(PackageExportRefSchema)` to create a new message.
*/
export const PackageExportRefSchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 1);
export const PackageExportRefSchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 2);
/**
* Describes the message quixos.InjectedDependency.
* Use `create(InjectedDependencySchema)` to create a new message.
*/
export const InjectedDependencySchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 2);
export const InjectedDependencySchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 3);
/**
* Describes the message quixos.EdgeDependency.
* Use `create(EdgeDependencySchema)` to create a new message.
*/
export const EdgeDependencySchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 3);
export const EdgeDependencySchema = /*@__PURE__*/ messageDesc(file_quixos_refs, 4);
Generated
+7 -7
View File
@@ -74,17 +74,17 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1789602549,
"narHash": "sha256-/riIaX4zEud3wPtGqI5pGm+SbHCrsqVTLZOacfOdYM4=",
"ref": "refs/tags/quixos-reachability/499b65b274f07d151c61e7710929a6323b6549a7",
"rev": "499b65b274f07d151c61e7710929a6323b6549a7",
"revCount": 74,
"lastModified": 1789699975,
"narHash": "sha256-OG2ebD1FAzPPXjgFcH0Bd+DR/pS2YL3zlaIQ9XUCpJg=",
"ref": "refs/tags/quixos-reachability/93c8cae1e651fa6a98ab5aa26e9ed2696c0bfd05",
"rev": "93c8cae1e651fa6a98ab5aa26e9ed2696c0bfd05",
"revCount": 88,
"type": "git",
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
},
"original": {
"ref": "refs/tags/quixos-reachability/499b65b274f07d151c61e7710929a6323b6549a7",
"rev": "499b65b274f07d151c61e7710929a6323b6549a7",
"ref": "refs/tags/quixos-reachability/93c8cae1e651fa6a98ab5aa26e9ed2696c0bfd05",
"rev": "93c8cae1e651fa6a98ab5aa26e9ed2696c0bfd05",
"type": "git",
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
}
+1 -1
View File
@@ -4,7 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
quixos-protocol.url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git?ref=refs/tags/quixos-reachability/499b65b274f07d151c61e7710929a6323b6549a7&rev=499b65b274f07d151c61e7710929a6323b6549a7";
quixos-protocol.url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git?ref=refs/tags/quixos-reachability/93c8cae1e651fa6a98ab5aa26e9ed2696c0bfd05&rev=93c8cae1e651fa6a98ab5aa26e9ed2696c0bfd05";
quixosNixHelpers = {
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/7177130c0365f2fa58ea4877366e1c5d17db4c01&rev=7177130c0365f2fa58ea4877366e1c5d17db4c01";
flake = false;
+85 -20
View File
@@ -12,6 +12,7 @@ import {
export type { QxObjectRef } from "./references.js";
import { assertReferenceFree, referenceToWire } from "./references.js";
import { decodeQuerySnapshot } from "./queries.js";
declare const watchBrand: unique symbol;
export type QxWatchHandle = string & { readonly [watchBrand]: true };
export type MessageBinding<T> = { encode(value: T): Value; decode(value: Value): T };
@@ -21,6 +22,23 @@ export type QxHandler<C, O> = (context: C) => O | Promise<O>;
export type QxDerived<C, O> = { kind: "derived"; get: QxHandler<C, O> };
export type QxSession<C> = { id: string; run<T>(work: (context: C) => Promise<T>): Promise<T>; close(): Promise<void> };
export type QxContextLifecycle<C> = { signal?: AbortSignal; openSession?: () => Promise<QxSession<C>> };
declare const contractView: unique symbol;
/** Generated exact closed contract. A descriptor is type evidence, never authority. */
export type QxInterfaceContract<View> = {
readonly interfaceRevisionId: string;
readonly operations: Record<string, QxOperationSpec>;
readonly [contractView]: (value: View) => View;
};
export const defineQxInterfaceContract = <View>(
interfaceRevisionId: string,
operations: Record<string, QxOperationSpec>,
): QxInterfaceContract<View> => Object.freeze({ interfaceRevisionId, operations }) as QxInterfaceContract<View>;
export type QxConformer = {
tryConform<View>(
object: import("./references.js").QxObjectRef,
contract: QxInterfaceContract<View>,
): Promise<View | undefined>;
};
export const qxDerived = <C, O>(get: QxHandler<C, O>): QxDerived<C, O> => ({ kind: "derived", get });
/** Versioned binding ABI. This mirrors the language-neutral value IR. */
@@ -33,9 +51,10 @@ export type QxValueType =
| { kind: "optional" | "list"; value: QxValueType };
export type QxOperationSpec = { id: string; inputType: QxValueType; outputType: QxValueType };
export type QxPortSpec =
| { kind: "query"; id: string; definitionDigest: string; variables: QxValueType; output: QxValueType; watch: boolean }
| { kind: "state"; id: string; valueType: QxValueType; primitives: string[] }
| { kind: "edge"; id: string; primitives: string[] }
| { kind: "interface"; id: string; operations: Record<string, QxOperationSpec> }
| { kind: "interface"; id: string; interfaceRevisionId: string; operations: Record<string, QxOperationSpec> }
| { kind: "constructor"; id: string; inputType: QxValueType };
export type QxHandlerSpec = {
receiver?: "none";
@@ -46,6 +65,32 @@ export type QxHandlerSpec = {
};
export type QxMessages = Record<string, MessageBinding<any>>;
const bindInterfaceView = (
target: import("./index.js").InterfacePort,
contract: QxInterfaceContract<unknown>,
messages: QxMessages,
) => ({
objectId: target.objectId,
contract,
live: Object.fromEntries(
Object.entries(contract.operations).map(([name, operation]) => [
name,
(input: unknown) => target.live(operation.id, inputFields(operation.inputType, input, messages)),
]),
),
...Object.fromEntries(
Object.entries(contract.operations).map(([name, operation]) => [
name,
async (input: unknown) =>
decodeQxValue(
operation.outputType,
(await target.live(operation.id, inputFields(operation.inputType, input, messages))).$quixosValue,
messages,
),
]),
),
});
// Conversion belongs at the binding boundary. It does not add orchestrator validation.
export const decodeQxValue = (type: QxValueType, value: Value | undefined, messages: QxMessages): any => {
if (type.kind === "builtin" && type.name === "unit") return null;
@@ -196,28 +241,40 @@ export const bindQxHandler = <C, O>(
}
case "interface": {
const target = raw.interface(port.id);
return [
name,
bindInterfaceView(target, defineQxInterfaceContract(port.interfaceRevisionId, port.operations), messages),
];
}
case "query": {
const query = raw.query(port.id);
const variablesToWire = (variables: unknown) => {
const value = encodeQxValue(port.variables, variables, messages);
if (value.kind.case !== "objectValue") throw new Error("QUERY_VARIABLE_INVALID");
return value.kind.value.fields;
};
return [
name,
{
objectId: target.objectId,
live: Object.fromEntries(
Object.entries(port.operations).map(([name, operation]) => [
name,
(input: unknown) => target.live(operation.id, inputFields(operation.inputType, input, messages)),
]),
),
...Object.fromEntries(
Object.entries(port.operations).map(([name, operation]) => [
name,
async (input: unknown) =>
decodeQxValue(
operation.outputType,
(await target.live(operation.id, inputFields(operation.inputType, input, messages)))
.$quixosValue,
messages,
),
]),
),
async execute(variables: unknown) {
const response = await query.execute(variablesToWire(variables), port.definitionDigest);
if (response.pending.length || response.errors.length) throw new Error("QUERY_INCOMPLETE");
return decodeQxValue(port.output, response.value, messages);
},
...(port.watch
? {
async *watch(variables: unknown, signal: AbortSignal) {
for await (const event of query.watch(
variablesToWire(variables),
signal,
port.definitionDigest,
)) {
if (!event.snapshot) throw new Error("QUERY_SNAPSHOT_MISSING");
yield decodeQuerySnapshot(event.snapshot, port.output, event.runId, event.sequence);
}
},
}
: {}),
},
];
}
@@ -233,6 +290,14 @@ export const bindQxHandler = <C, O>(
}),
);
return {
conform: {
async tryConform<View>(object: import("./references.js").QxObjectRef, contract: QxInterfaceContract<View>) {
const target = await raw.tryConform(object, contract.interfaceRevisionId);
return target
? (bindInterfaceView(target, contract as QxInterfaceContract<unknown>, messages) as View)
: undefined;
},
} satisfies QxConformer,
...(spec.receiver === "none" ? {} : { objectId: raw.objectId }),
signal: raw.signal,
...(spec.receiver !== "none" && raw.openSession
+594 -2
View File
File diff suppressed because one or more lines are too long
+1217 -1
View File
File diff suppressed because one or more lines are too long
+67 -40
View File
@@ -9,6 +9,7 @@ import {
type QxObjectRef,
} from "./references.js";
export * from "./bindings.js";
export * from "./queries.js";
export { relationshipMap, relationshipList, relationshipSet } from "./relationships.js";
import { AsyncLocalStorage } from "node:async_hooks";
import { createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -33,6 +34,7 @@ import {
RefValueSchema,
ValueSchema,
type Value,
type QueryResponse,
} from "./camino/api_pb.js";
import { OrchestratorRuntime } from "./quixos/orch_pb.js";
import {
@@ -42,7 +44,7 @@ import {
PackageRuntime,
WatchEventSchema,
} from "./quixos/runtime_pb.js";
import { CapabilityRefSchema } from "./quixos/refs_pb.js";
import { CapabilityRefSchema, type ConformanceWitness } from "./quixos/refs_pb.js";
export type CaminoClient = Client<typeof CaminoService>;
export type OrchClient = Client<typeof OrchestratorRuntime>;
@@ -197,9 +199,19 @@ export type ConstructorPort = {
atomId: string;
construct(input?: Record<string, unknown>): Promise<QxObjectRef>;
};
export type RuntimePort = StatePort | EdgePort | InterfacePort | ConstructorPort;
export type QueryPort = {
queryId: string;
execute(variables: Record<string, Value>, expectedDefinitionDigest?: string): Promise<QueryResponse>;
watch(
variables: Record<string, Value>,
signal: AbortSignal,
expectedDefinitionDigest?: string,
): AsyncIterable<import("./quixos/orch_pb.js").QueryEvent>;
};
export type RuntimePort = StatePort | EdgePort | InterfacePort | ConstructorPort | QueryPort;
export type RuntimeContext = {
tryConform(object: QxObjectRef, interfaceRevisionId: string): Promise<InterfacePort | undefined>;
/** Cooperative cancellation. Completion is acknowledged only after the handler returns. */
signal?: AbortSignal;
openSession?: () => Promise<RuntimeSession>;
@@ -211,6 +223,7 @@ export type RuntimeContext = {
edge(portId: string): EdgePort;
interface(portId: string): InterfacePort;
constructor(portId: string): ConstructorPort;
query(portId: string): QueryPort;
};
export type RuntimeSession = {
@@ -238,9 +251,52 @@ export const createRuntimeContext = (
orch: OrchClient,
request: RuntimeRequest,
): RuntimeContext => {
const acquiredPort = (
objectId: string,
interfaceRevisionId: string,
conformance?: ConformanceWitness,
): InterfacePort => {
const invoke = async (operationId: string, input: Record<string, unknown> = {}) => {
const response = await orch.invokeCapability({
objectId,
capability: create(CapabilityRefSchema, { interfaceRevisionId, operationId, conformance }),
input: Object.fromEntries(Object.entries(input).map(([key, value]) => [key, jsToProtoValue(value)])),
});
if (!response.ok) throw new Error(response.error || "Capability invocation failed");
for (const dependency of response.dependencies) {
if (dependency.kind === "state" || dependency.kind === "edge")
await recordDependency({
kind: dependency.kind,
objectId: dependency.objectId,
attachmentId: dependency.attachmentId,
...(dependency.kind === "edge" ? { projectionId: dependency.projectionId } : {}),
} as RuntimeDependency);
}
if (!response.result) throw new Error("Capability returned no value");
return response.result;
};
return {
objectId: referenceFromWire(objectId),
interfaceRevisionId,
invoke: async (operation, input) => protoValueToJs(await invoke(operation, input)),
live: async (operation, input) => liveValue(await invoke(operation, input)),
};
};
const ports = new Map<string, RuntimePort>();
for (const dependency of request.dependencies) {
switch (dependency.binding.case) {
case "queryId": {
const queryId = dependency.binding.value,
objectId = dependency.objectId || request.objectId;
ports.set(dependency.portId, {
queryId,
execute: (variables, expectedDefinitionDigest) =>
orch.executeQuery({ queryId, objectId, variables, expectedDefinitionDigest }),
watch: (variables, signal, expectedDefinitionDigest) =>
orch.watchQuery({ queryId, objectId, variables, expectedDefinitionDigest }, { signal }),
});
break;
}
case "stateSlotId": {
const slotId = dependency.binding.value;
const dependencyObjectId = dependency.objectId || request.objectId;
@@ -346,44 +402,7 @@ export const createRuntimeContext = (
case "interfaceRevisionId": {
const interfaceRevisionId = dependency.binding.value;
const dependencyObjectId = dependency.objectId || request.objectId;
const invoke = async (operationId: string, input: Record<string, unknown>) => {
const response = await orch.invokeCapability({
capability: create(CapabilityRefSchema, { interfaceRevisionId, operationId }),
objectId: dependencyObjectId,
input: Object.fromEntries(Object.entries(input).map(([key, value]) => [key, jsToProtoValue(value)])),
});
if (!response.ok) throw new Error(response.error || `Capability ${operationId} failed`);
for (const dependency of response.dependencies) {
if (dependency.kind === "state") {
await recordDependency({
kind: "state",
objectId: dependency.objectId,
attachmentId: dependency.attachmentId,
});
} else if (dependency.kind === "edge") {
await recordDependency({
kind: "edge",
objectId: dependency.objectId,
attachmentId: dependency.attachmentId,
projectionId: dependency.projectionId,
});
}
}
return response.result;
};
const capability: InterfacePort = {
objectId: referenceFromWire(dependencyObjectId),
interfaceRevisionId,
async invoke(operationId, input = {}) {
return protoValueToJs(await invoke(operationId, input));
},
async live(operationId, input = {}) {
const value = await invoke(operationId, input);
if (!value) throw new Error(`Capability ${operationId} returned no value`);
return liveValue(value);
},
};
ports.set(dependency.portId, capability);
ports.set(dependency.portId, acquiredPort(dependencyObjectId, interfaceRevisionId));
break;
}
case "constructorAtomId": {
@@ -409,6 +428,13 @@ export const createRuntimeContext = (
return port as T;
};
return {
async tryConform(object, interfaceRevisionId) {
const objectId = referenceToWire(object);
const { conformance } = await orch.tryConform({ objectId, interfaceRevisionId });
if (conformance && (conformance.objectId !== objectId || conformance.interfaceRevisionId !== interfaceRevisionId))
throw new Error("Conformance response does not match the requested view");
return conformance ? acquiredPort(objectId, interfaceRevisionId, conformance) : undefined;
},
get objectId() {
return referenceFromWire(request.objectId);
},
@@ -419,6 +445,7 @@ export const createRuntimeContext = (
edge: (portId: string) => requirePort<EdgePort>(portId, "edgeTypeId"),
interface: (portId: string) => requirePort<InterfacePort>(portId, "interfaceRevisionId"),
constructor: (portId: string) => requirePort<ConstructorPort>(portId, "atomId"),
query: (portId: string) => requirePort<QueryPort>(portId, "queryId"),
};
};
+82
View File
@@ -0,0 +1,82 @@
import { decodeQxValue, type QxValueType } from "./bindings.js";
import type { QueryResponse } from "./camino/api_pb.js";
import type { QxObjectRef } from "./references.js";
export type QxQueryPartial<T> = T extends QxObjectRef
? T
: T extends readonly (infer Item)[]
? QxQueryPartial<Item>[]
: T extends object
? { [Key in keyof T]?: QxQueryPartial<T[Key]> }
: T;
export type QxQuerySnapshot<T> = {
runId: string;
sequence: bigint;
dataVersion: string;
bindingDigest: string;
consistency: string;
fields: { path: readonly (string | number)[]; status: "pending" | "error"; error?: string }[];
} & ({ status: "ready"; data: T } | { status: "partial"; data: QxQueryPartial<T> });
declare const queryTypes: unique symbol;
/** Generated shape evidence, not permission to run a query. */
export interface QxQueryDescriptor<Variables, Result, Root extends string = string> {
readonly id: string;
readonly definitionDigest: string;
readonly rootInterfaceRevisionId: Root;
readonly variables: QxValueType;
readonly output: QxValueType;
readonly watch: boolean;
readonly [queryTypes]?: (variables: Variables, result: Result) => [Variables, Result];
}
export function decodeQuerySnapshot<T>(
response: QueryResponse,
output: QxValueType,
runId: string,
sequence: bigint,
): QxQuerySnapshot<T> {
if (response.preparationToken || response.residualWindows.length || response.relationalCaptures.length)
throw new Error("QUERY_RESULT_UNFINISHED: private preparation is not a query result");
const fields = [
...response.pending.map((field) => ({ path: field.path, status: "pending" as const })),
...response.errors.map((field) => ({ path: field.path, status: "error" as const, error: field.error })),
].map((field) => ({
...field,
path: field.path.map((part) => {
if (part.part.case !== "field" && part.part.case !== "index") throw new Error("QUERY_PATCH_INVALID");
return part.part.value;
}),
}));
// Pending/error values are absent, not successful nulls of a scalar type.
const shape = structuredClone(output);
for (const field of fields) {
let cursor = shape;
for (const [index, part] of field.path.entries()) {
while (cursor.kind === "optional") cursor = cursor.value;
const last = index === field.path.length - 1;
if (typeof part === "string" && cursor.kind === "record" && cursor.fields[part]) {
if (last) cursor.fields[part] = { kind: "optional", value: cursor.fields[part]! };
else cursor = cursor.fields[part]!;
} else if (typeof part === "number" && cursor.kind === "list") cursor = cursor.value;
else throw new Error("QUERY_PATCH_INVALID");
}
}
const data = decodeQxValue(shape, response.value, {}) as Record<string, unknown>;
for (const field of fields) {
let cursor: unknown = data;
for (const [index, part] of field.path.entries()) {
if (!cursor || typeof cursor !== "object") throw new Error("QUERY_PATCH_INVALID");
if (index === field.path.length - 1) delete (cursor as Record<string | number, unknown>)[part];
else cursor = (cursor as Record<string | number, unknown>)[part];
}
}
return {
runId,
sequence,
dataVersion: response.dataVersion,
bindingDigest: response.bindingDigest,
consistency: response.consistency,
fields,
...(fields.length ? { status: "partial", data } : { status: "ready", data }),
} as QxQuerySnapshot<T>;
}
+212 -29
View File
File diff suppressed because one or more lines are too long
+54 -4
View File
@@ -10,7 +10,7 @@ import type { Message } from "@bufbuild/protobuf";
* Describes the file quixos/refs.proto.
*/
export const file_quixos_refs: GenFile = /*@__PURE__*/
fileDesc("ChFxdWl4b3MvcmVmcy5wcm90bxIGcXVpeG9zIkQKDUNhcGFiaWxpdHlSZWYSHQoVaW50ZXJmYWNlX3JldmlzaW9uX2lkGAEgASgJEhQKDG9wZXJhdGlvbl9pZBgCIAEoCSJCChBQYWNrYWdlRXhwb3J0UmVmEhsKE3BhY2thZ2VfcmV2aXNpb25faWQYASABKAkSEQoJZXhwb3J0X2lkGAIgASgJIsQBChJJbmplY3RlZERlcGVuZGVuY3kSDwoHcG9ydF9pZBgBIAEoCRIXCg1zdGF0ZV9zbG90X2lkGAIgASgJSAASJgoEZWRnZRgDIAEoCzIWLnF1aXhvcy5FZGdlRGVwZW5kZW5jeUgAEh8KFWludGVyZmFjZV9yZXZpc2lvbl9pZBgEIAEoCUgAEh0KE2NvbnN0cnVjdG9yX2F0b21faWQYBSABKAlIABIRCglvYmplY3RfaWQYBiABKAlCCQoHYmluZGluZyI9Cg5FZGdlRGVwZW5kZW5jeRIUCgxlZGdlX3R5cGVfaWQYASABKAkSFQoNcHJvamVjdGlvbl9pZBgCIAEoCWIGcHJvdG8z");
fileDesc("ChFxdWl4b3MvcmVmcy5wcm90bxIGcXVpeG9zInUKDUNhcGFiaWxpdHlSZWYSHQoVaW50ZXJmYWNlX3JldmlzaW9uX2lkGAEgASgJEhQKDG9wZXJhdGlvbl9pZBgCIAEoCRIvCgtjb25mb3JtYW5jZRgDIAEoCzIaLnF1aXhvcy5Db25mb3JtYW5jZVdpdG5lc3MilgEKEkNvbmZvcm1hbmNlV2l0bmVzcxIRCglvYmplY3RfaWQYASABKAkSHQoVaW50ZXJmYWNlX3JldmlzaW9uX2lkGAIgASgJEhYKDmNvbmZvcm1hbmNlX2lkGAMgASgJEh0KFXdvcmtzcGFjZV9yZXZpc2lvbl9pZBgEIAEoCRIXCg93b3Jrc3BhY2VfZXBvY2gYBSABKAkiQgoQUGFja2FnZUV4cG9ydFJlZhIbChNwYWNrYWdlX3JldmlzaW9uX2lkGAEgASgJEhEKCWV4cG9ydF9pZBgCIAEoCSLYAQoSSW5qZWN0ZWREZXBlbmRlbmN5Eg8KB3BvcnRfaWQYASABKAkSFwoNc3RhdGVfc2xvdF9pZBgCIAEoCUgAEiYKBGVkZ2UYAyABKAsyFi5xdWl4b3MuRWRnZURlcGVuZGVuY3lIABIfChVpbnRlcmZhY2VfcmV2aXNpb25faWQYBCABKAlIABIdChNjb25zdHJ1Y3Rvcl9hdG9tX2lkGAUgASgJSAASEgoIcXVlcnlfaWQYByABKAlIABIRCglvYmplY3RfaWQYBiABKAlCCQoHYmluZGluZyI9Cg5FZGdlRGVwZW5kZW5jeRIUCgxlZGdlX3R5cGVfaWQYASABKAkSFQoNcHJvamVjdGlvbl9pZBgCIAEoCWIGcHJvdG8z");
/**
* @generated from message quixos.CapabilityRef
@@ -25,6 +25,13 @@ export type CapabilityRef = Message<"quixos.CapabilityRef"> & {
* @generated from field: string operation_id = 2;
*/
operationId: string;
/**
* Optional fence for a view acquired through TryConform. Not an authority grant.
*
* @generated from field: quixos.ConformanceWitness conformance = 3;
*/
conformance?: ConformanceWitness | undefined;
};
/**
@@ -34,6 +41,43 @@ export type CapabilityRef = Message<"quixos.CapabilityRef"> & {
export const CapabilityRefSchema: GenMessage<CapabilityRef> = /*@__PURE__*/
messageDesc(file_quixos_refs, 0);
/**
* @generated from message quixos.ConformanceWitness
*/
export type ConformanceWitness = Message<"quixos.ConformanceWitness"> & {
/**
* @generated from field: string object_id = 1;
*/
objectId: string;
/**
* @generated from field: string interface_revision_id = 2;
*/
interfaceRevisionId: string;
/**
* @generated from field: string conformance_id = 3;
*/
conformanceId: string;
/**
* @generated from field: string workspace_revision_id = 4;
*/
workspaceRevisionId: string;
/**
* @generated from field: string workspace_epoch = 5;
*/
workspaceEpoch: string;
};
/**
* Describes the message quixos.ConformanceWitness.
* Use `create(ConformanceWitnessSchema)` to create a new message.
*/
export const ConformanceWitnessSchema: GenMessage<ConformanceWitness> = /*@__PURE__*/
messageDesc(file_quixos_refs, 1);
/**
* @generated from message quixos.PackageExportRef
*/
@@ -54,7 +98,7 @@ export type PackageExportRef = Message<"quixos.PackageExportRef"> & {
* Use `create(PackageExportRefSchema)` to create a new message.
*/
export const PackageExportRefSchema: GenMessage<PackageExportRef> = /*@__PURE__*/
messageDesc(file_quixos_refs, 1);
messageDesc(file_quixos_refs, 2);
/**
* @generated from message quixos.InjectedDependency
@@ -92,6 +136,12 @@ export type InjectedDependency = Message<"quixos.InjectedDependency"> & {
*/
value: string;
case: "constructorAtomId";
} | {
/**
* @generated from field: string query_id = 7;
*/
value: string;
case: "queryId";
} | { case: undefined; value?: undefined };
/**
@@ -108,7 +158,7 @@ export type InjectedDependency = Message<"quixos.InjectedDependency"> & {
* Use `create(InjectedDependencySchema)` to create a new message.
*/
export const InjectedDependencySchema: GenMessage<InjectedDependency> = /*@__PURE__*/
messageDesc(file_quixos_refs, 2);
messageDesc(file_quixos_refs, 3);
/**
* @generated from message quixos.EdgeDependency
@@ -130,5 +180,5 @@ export type EdgeDependency = Message<"quixos.EdgeDependency"> & {
* Use `create(EdgeDependencySchema)` to create a new message.
*/
export const EdgeDependencySchema: GenMessage<EdgeDependency> = /*@__PURE__*/
messageDesc(file_quixos_refs, 3);
messageDesc(file_quixos_refs, 4);
+72
View File
@@ -0,0 +1,72 @@
import assert from "node:assert/strict";
import test from "node:test";
import { bindQxHandler, createRuntimeContext, defineQxInterfaceContract, jsToProtoValue } from "../dist/index.js";
import { referenceFromWire } from "../dist/references.js";
const unit = { kind: "builtin", name: "unit" };
test("generated conformance views use checked codecs and retain their fence on invocation", async () => {
const contract = defineQxInterfaceContract("Named", {
"name.get": { id: "get", inputType: unit, outputType: { kind: "scalar", name: "string" } },
});
const object = referenceFromWire("object");
const witness = {
objectId: "object",
interfaceRevisionId: "Named",
workspaceEpoch: "1",
workspaceRevisionId: "w",
conformanceId: "named",
};
const requests = [];
const raw = createRuntimeContext(
{},
{
async tryConform(request) {
requests.push(request);
return { conformance: witness };
},
async invokeCapability(request) {
for (const key of Object.keys(witness)) assert.equal(request.capability.conformance[key], witness[key]);
assert.deepEqual(request.input, {});
return { ok: true, result: jsToProtoValue("Hello"), dependencies: [] };
},
},
{ objectId: "object", input: {}, dependencies: [] },
);
const handler = bindQxHandler(
{ inputType: unit, outputType: unit, ports: {} },
async (context) => {
const view = await context.conform.tryConform(object, contract);
assert.ok(view.objectId.equals(object));
assert.equal(view.contract, contract);
assert.equal(await view["name.get"](), "Hello");
},
{},
);
await handler(raw);
assert.deepEqual(requests, [{ objectId: "object", interfaceRevisionId: "Named" }]);
});
test("package discovery preserves absence and denied errors and refuses raw IDs", async () => {
const request = { objectId: "object", input: {}, dependencies: [] };
const raw = createRuntimeContext(
{},
{
async tryConform() {
return {};
},
},
request,
);
assert.equal(await raw.tryConform(referenceFromWire("object"), "Missing"), undefined);
await assert.rejects(raw.tryConform("object", "Named"), /opaque object reference/);
const denied = createRuntimeContext(
{},
{
async tryConform() {
throw Error("permission denied");
},
},
request,
);
await assert.rejects(denied.tryConform(referenceFromWire("object"), "Named"), /permission denied/);
});
+63
View File
@@ -0,0 +1,63 @@
import assert from "node:assert/strict";
import test from "node:test";
import { create } from "@bufbuild/protobuf";
import { QueryResponseSchema } from "../dist/camino/api_pb.js";
import { InjectedDependencySchema } from "../dist/quixos/refs_pb.js";
import { createRuntimeContext, decodeQuerySnapshot, jsToProtoValue, protoValueToJs } from "../dist/index.js";
test("private relational captures cannot be decoded as a completed public query", () => {
const response = create(QueryResponseSchema, { relationalCaptures: [{ rootObjectId: "obj:private" }] });
assert.throws(
() => decodeQuerySnapshot(response, { kind: "record", fields: {} }, "run", 1n),
/QUERY_RESULT_UNFINISHED/,
);
});
test("query ports carry only an injected query identity and root", async () => {
let seen;
const context = createRuntimeContext(
{},
{
executeQuery: async (request) => {
seen = request;
return create(QueryResponseSchema);
},
},
{
objectId: "obj:receiver",
input: {},
dependencies: [
create(InjectedDependencySchema, {
portId: "list",
objectId: "obj:collection",
binding: { case: "queryId", value: "pkg@1:upcoming" },
}),
],
},
);
await context.query("list").execute({ first: jsToProtoValue(30) }, "checked-definition");
assert.equal(seen.expectedDefinitionDigest, "checked-definition");
assert.equal(seen.objectId, "obj:collection");
assert.equal(seen.queryId, "pkg@1:upcoming");
assert.equal(protoValueToJs(seen.variables.first), 30);
assert.throws(() => context.query("not-injected"), /Missing/);
});
test("query snapshots distinguish an unavailable scalar from a successful null", () => {
const output = {
kind: "record",
fields: { title: { kind: "scalar", name: "string" }, score: { kind: "scalar", name: "int64" } },
};
const response = create(QueryResponseSchema, {
value: jsToProtoValue({ title: "Native title", score: null }),
pending: [{ path: [{ part: { case: "field", value: "score" } }] }],
});
const snapshot = decodeQuerySnapshot(response, output, "run1", 1n);
assert.equal(snapshot.status, "partial");
assert.deepEqual(snapshot.data, { title: "Native title" });
assert.deepEqual(snapshot.fields, [{ path: ["score"], status: "pending" }]);
assert.equal(output.fields.score.kind, "scalar");
response.pending = [];
response.value = jsToProtoValue({ title: "Native title", score: 9007199254740993n });
assert.equal(decodeQuerySnapshot(response, output, "run1", 2n).data.score, 9007199254740993n);
});