@astrale-os/kernel-client 0.6.0-beta.88 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/client/index.d.ts +1 -1
  2. package/dist/client/request.d.ts +1 -0
  3. package/dist/client/request.js +17 -0
  4. package/dist/client/result.d.ts +4 -1
  5. package/dist/client/result.js +10 -4
  6. package/dist/errors/index.d.ts +1 -0
  7. package/dist/errors/index.js +1 -0
  8. package/dist/errors/refusal.d.ts +12 -0
  9. package/dist/errors/refusal.js +40 -0
  10. package/dist/graph/domain/binding.js +4 -0
  11. package/dist/graph/page-contract.d.ts +6 -0
  12. package/dist/graph/query.js +10 -2
  13. package/dist/pacer/index.d.ts +1 -1
  14. package/dist/pacer/index.js +1 -1
  15. package/dist/pacer/retry/index.d.ts +1 -0
  16. package/dist/pacer/retry/index.js +1 -0
  17. package/dist/pacer/retry/refusals.d.ts +7 -0
  18. package/dist/pacer/retry/refusals.js +10 -0
  19. package/dist/pacer/retry/retry.d.ts +2 -0
  20. package/dist/pacer/retry/retry.js +33 -1
  21. package/dist/schema/admission.d.ts +1 -1
  22. package/dist/schema/admission.js +2 -2
  23. package/dist/schema/contracts.d.ts +95 -2
  24. package/dist/schema/index.d.ts +2 -1
  25. package/dist/schema/installation.d.ts +104 -0
  26. package/dist/schema/installation.js +144 -0
  27. package/dist/schema/schema.d.ts +18 -3
  28. package/dist/schema/schema.js +31 -35
  29. package/dist/session/bound.js +42 -0
  30. package/dist/session/credential/{provider.d.ts → credentials.d.ts} +21 -12
  31. package/dist/session/credential/{provider.js → credentials.js} +75 -15
  32. package/dist/session/credential/index.d.ts +1 -1
  33. package/dist/session/credential/index.js +1 -1
  34. package/dist/session/credential/limits.d.ts +2 -0
  35. package/dist/session/credential/limits.js +2 -0
  36. package/dist/session/exchange/presentation.js +7 -7
  37. package/dist/session/execution.d.ts +24 -1
  38. package/dist/session/index.d.ts +2 -2
  39. package/dist/session/index.js +1 -1
  40. package/dist/session/reference.d.ts +8 -4
  41. package/dist/session/reference.js +7 -2
  42. package/dist/session/routing/dispatch.js +2 -0
  43. package/dist/session/routing/request.d.ts +4 -0
  44. package/dist/session/routing/request.js +11 -1
  45. package/dist/session/routing/result.d.ts +1 -1
  46. package/dist/session/routing/result.js +5 -1
  47. package/dist/session/session.d.ts +1 -1
  48. package/dist/session/session.js +11 -8
  49. package/dist/session/session.typecheck.js +12 -9
  50. package/dist/store/memory.js +20 -1
  51. package/dist/transport/http/admission.js +3 -0
  52. package/dist/transport/transport.d.ts +10 -0
  53. package/dist/transport/websocket/exchange.js +8 -0
  54. package/package.json +5 -5
@@ -1,4 +1,5 @@
1
1
  import type { NodeId } from '@astrale-os/kernel-core/graph/node';
2
+ import type { SystemExecutionDetail } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
2
3
  import type { Value } from '@astrale-os/kernel-dsl/value';
3
4
  import type { CallableReference } from './reference.js';
4
5
  declare const EXECUTION_OUTPUT: unique symbol;
@@ -25,14 +26,36 @@ export type ExecutionOutcome<Output = unknown> = {
25
26
  readonly kind: 'cancelled';
26
27
  };
27
28
  export type ExecutionState = 'pending' | 'running' | 'waiting' | 'paused' | 'completed' | 'failed' | 'cancelled' | 'expired';
28
- export interface ExecutionStatus<Output = unknown> {
29
+ /**
30
+ * The status of an Execution: its node's, or what Root reads of a system execution whose node was
31
+ * deleted.
32
+ */
33
+ export type ExecutionStatus<Output = unknown> = ExecutionNodeStatus<Output> | DeletedExecutionStatus<Output>;
34
+ /** The status of an Execution whose node exists, with the engine state of its run. */
35
+ export interface ExecutionNodeStatus<Output = unknown> {
29
36
  readonly id: NodeId;
30
37
  readonly function: NodeId;
31
38
  readonly version: `sha256:${string}`;
32
39
  readonly state: ExecutionState;
33
40
  readonly createdAt: string;
41
+ /** A system execution's step, progress and session state, as Core shapes it. */
42
+ readonly detail?: SystemExecutionDetail;
34
43
  readonly outcome?: ExecutionOutcome<Output>;
35
44
  }
45
+ /**
46
+ * What Root alone reads of a system execution whose node was deleted: the outcome its lifecycle
47
+ * record keeps, under the explicit state `deleted`, never a live state.
48
+ */
49
+ export interface DeletedExecutionStatus<Output = unknown> {
50
+ readonly id: NodeId;
51
+ readonly state: 'deleted';
52
+ readonly outcome: ExecutionOutcome<Output>;
53
+ /** Absent: the node that recorded them is deleted. */
54
+ readonly function?: never;
55
+ readonly version?: never;
56
+ readonly createdAt?: never;
57
+ readonly detail?: never;
58
+ }
36
59
  type Empty = Readonly<Record<string, never>>;
37
60
  type ExecutionLike<Output> = ExecutionRef<Output> | NodeId;
38
61
  /**
@@ -1,7 +1,7 @@
1
1
  export type { SessionControlOptions, SessionPolicy } from './context/index.js';
2
2
  export type { ContentApi, ContentDownload, ContentLocation, ContentRejection, ContentUploadOptions, ContentUploadResult, } from './content/index.js';
3
3
  export { bindSession, type BoundClientSession, type BoundSessionControls, type BoundSessionSource, } from './bound.js';
4
- export { createSessionCredentialProvider, type SessionCredential, type SessionCredentialProvider, type SessionCredentialProviderOptions, type SessionCredentialState, } from './credential/index.js';
4
+ export { credentials, type Credentials, type CredentialsMint, type CredentialsOptions, type CredentialsState, type SessionCredential, } from './credential/index.js';
5
5
  export type { IntrinsicRelease, SessionSnapshot } from './discovery/index.js';
6
6
  export type { SessionExchangeOptions, SessionExchangeRequest } from './exchange/index.js';
7
7
  export type { Auth, PersistedRoute, SessionRouteArtifact, SessionRouteStore, SessionAuth, SessionEnvelopeTransport, SessionRequestOptions, SessionRequestOptionsWithBody, } from './routing/index.js';
@@ -9,6 +9,6 @@ export type { ClientSessionOptions } from './options.js';
9
9
  export { ClientSession, connect, type ConnectOptions } from './session.js';
10
10
  export type { CallableReference, InputOfReference, InputModeOfReference, InstanceCallableReference, OutputOfReference, } from './reference.js';
11
11
  export { reference } from './reference.js';
12
- export { execution, type ExecutionOutcome, type ExecutionRef, type ExecutionState, type ExecutionStatus, } from './execution.js';
12
+ export { execution, type ExecutionOutcome, type ExecutionRef, type DeletedExecutionStatus, type ExecutionNodeStatus, type ExecutionState, type ExecutionStatus, } from './execution.js';
13
13
  export type { ResolvedView, ViewCatalog } from './views/index.js';
14
14
  export type { DomainBinding } from '../graph/domain/index.js';
@@ -1,5 +1,5 @@
1
1
  export { bindSession, } from './bound.js';
2
- export { createSessionCredentialProvider, } from './credential/index.js';
2
+ export { credentials, } from './credential/index.js';
3
3
  export { ClientSession, connect } from './session.js';
4
4
  export { reference } from './reference.js';
5
5
  export { execution, } from './execution.js';
@@ -1,10 +1,12 @@
1
1
  import type { Path as PathValue, PathLike } from '@astrale-os/kernel-core/path';
2
- import type { CallableInputOf, CallableInputModeOf, CallableOutputOf, CallableResultOf, Domain, ResolvedFunction, ExecutableMethod } from '@astrale-os/kernel-dsl/v1';
2
+ import type { CallableInputOf, CallableInputModeOf, CallableOutputOf, CallableResultOf, Domain, ResolvedFunction, ExecutableMethod, ResolvedMethod } from '@astrale-os/kernel-dsl/v1';
3
3
  import type { MethodAddress } from '@astrale-os/kernel-dsl/v1/addressing';
4
4
  import type { MeaningFingerprint } from '@astrale-os/kernel-dsl/v1/schema/fingerprint';
5
5
  import { type Key as KeyType } from '@astrale-os/kernel-dsl/v1/addressing';
6
- import type { Binary, Input } from '../client/index.js';
6
+ import type { Binary, Input, Result } from '../client/index.js';
7
7
  import type { ExecutionRef } from './execution.js';
8
+ /** Result kind a reference expects: a durable callable answers with its Execution. */
9
+ type OutputMode = Exclude<Result['kind'], 'redirect'>;
8
10
  declare const REFERENCE_INPUT: unique symbol;
9
11
  declare const REFERENCE_INPUT_MODE: unique symbol;
10
12
  declare const REFERENCE_OUTPUT: unique symbol;
@@ -14,7 +16,7 @@ export interface CallableReference<InputValue = Input, Output = unknown, InputMo
14
16
  readonly fingerprint?: MeaningFingerprint;
15
17
  readonly callable: KeyType.Callable;
16
18
  readonly target: PathValue;
17
- readonly outputMode: 'value' | 'stream' | 'binary';
19
+ readonly outputMode: OutputMode;
18
20
  readonly [REFERENCE_INPUT]?: InputValue;
19
21
  readonly [REFERENCE_INPUT_MODE]?: InputMode;
20
22
  readonly [REFERENCE_OUTPUT]?: Output;
@@ -24,7 +26,7 @@ export interface InstanceCallableReference<InputValue = Input, Output = unknown>
24
26
  readonly origin: KeyType.Origin;
25
27
  readonly fingerprint?: MeaningFingerprint;
26
28
  readonly callable: KeyType.Callable;
27
- readonly outputMode: 'value' | 'stream' | 'binary';
29
+ readonly outputMode: OutputMode;
28
30
  }
29
31
  export type InputOfReference<Reference extends CallableReference<unknown>> = Reference extends CallableReference<infer InputValue, unknown> ? InputValue : never;
30
32
  export type OutputOfReference<Reference extends CallableReference<unknown>> = Reference extends CallableReference<infer _Input, infer Output> ? Output : never;
@@ -47,6 +49,8 @@ export declare function reference<const Callable extends ExecutableInstanceMetho
47
49
  * addresses every Kernel syscall. Loading the Session therefore never resolves the Kernel Schema.
48
50
  */
49
51
  export declare function kernelReference(method: MethodAddress): InstanceCallableReference<unknown>;
52
+ /** The result kind invoking this callable yields. */
53
+ export declare function outputModeOf(callable: ResolvedFunction | ResolvedMethod): OutputMode;
50
54
  export declare function admitReference(input: CallableReference<unknown>): CallableReference<unknown>;
51
55
  export declare function matchesCallable(target: PathValue, callable: KeyType.Callable): boolean;
52
56
  export {};
@@ -2,6 +2,7 @@ import { Path } from '@astrale-os/kernel-core/path';
2
2
  import { callableAddress, Key, MethodKey, patterns, } from '@astrale-os/kernel-dsl/v1/addressing';
3
3
  import { callableFingerprint } from '@astrale-os/kernel-dsl/v1/schema/fingerprint';
4
4
  const FINGERPRINT_PATTERN = /^sha256:[0-9a-f]{64}$/u;
5
+ const OUTPUT_MODES = ['value', 'stream', 'binary', 'execution'];
5
6
  export function reference(domain, callable) {
6
7
  if (Key.origin(callable.key) !== domain.origin)
7
8
  invalid();
@@ -11,7 +12,7 @@ export function reference(domain, callable) {
11
12
  origin: domain.origin,
12
13
  fingerprint: callableFingerprint(callable),
13
14
  callable: callable.key,
14
- outputMode: callable.output.mode,
15
+ outputMode: outputModeOf(callable),
15
16
  });
16
17
  if ('owner' in callable && !callable.static) {
17
18
  const bind = (receiver) => admitReference({
@@ -39,6 +40,10 @@ export function kernelReference(method) {
39
40
  const bind = (receiver) => admitReference({ ...common, target: Path.instanceMethod(Path.from(receiver), callable) });
40
41
  return Object.assign(bind, common);
41
42
  }
43
+ /** The result kind invoking this callable yields. */
44
+ export function outputModeOf(callable) {
45
+ return callable.execution?.durable === true ? 'execution' : callable.output.mode;
46
+ }
42
47
  export function admitReference(input) {
43
48
  if (input === null || typeof input !== 'object')
44
49
  invalid();
@@ -47,7 +52,7 @@ export function admitReference(input) {
47
52
  typeof input.callable !== 'string' ||
48
53
  !Key.is(input.callable) ||
49
54
  Key.origin(input.callable) !== input.origin ||
50
- !['value', 'stream', 'binary'].includes(input.outputMode) ||
55
+ !OUTPUT_MODES.includes(input.outputMode) ||
51
56
  (input.fingerprint !== undefined &&
52
57
  (typeof input.fingerprint !== 'string' || !FINGERPRINT_PATTERN.test(input.fingerprint))))
53
58
  invalid();
@@ -62,6 +62,8 @@ export class SessionDispatcher {
62
62
  ...transportOptions(operation, options, streaming),
63
63
  ...(state.auth.delegate === undefined ? {} : { delegate: state.auth.delegate }),
64
64
  ...(routing === undefined ? {} : { routing }),
65
+ // The guard is the source Kernel's: a routed destination request never carries it.
66
+ ...(options.maintenance === undefined ? {} : { maintenance: options.maintenance }),
65
67
  }));
66
68
  }
67
69
  async followSource(result, state, options, operation, streaming) {
@@ -3,6 +3,10 @@ import type { SessionControlOptions } from '../context/index.js';
3
3
  export type SessionEnvelopeTransport = 'auto' | 'http' | 'websocket';
4
4
  export interface SessionRequestOptions extends SessionControlOptions {
5
5
  readonly idempotencyKey?: invocation.IdempotencyKey;
6
+ /** Sent to the source Kernel only; a routed destination never receives it. */
7
+ readonly maintenance?: {
8
+ readonly session: string;
9
+ };
6
10
  readonly body?: never;
7
11
  }
8
12
  export type SessionRequestOptionsWithBody = Omit<SessionRequestOptions, 'body' | 'idempotencyKey'> & {
@@ -23,17 +23,27 @@ export function admitRequestOptions(input = {}) {
23
23
  }
24
24
  const control = admitControlOptions(input);
25
25
  const fields = Reflect.ownKeys(input);
26
- if (fields.some((field) => !['signal', 'timeoutMs', 'idempotencyKey'].includes(String(field)))) {
26
+ if (fields.some((field) => !['signal', 'timeoutMs', 'idempotencyKey', 'maintenance'].includes(String(field)))) {
27
27
  throw new TypeError('Session request options contain unsupported fields.');
28
28
  }
29
29
  const idempotencyKey = input.idempotencyKey === undefined
30
30
  ? undefined
31
31
  : invocationProtocol.acceptIdempotencyKey(input.idempotencyKey, 'request.idempotencyKey');
32
+ const maintenance = input.maintenance === undefined ? undefined : admitMaintenance(input.maintenance);
32
33
  return Object.freeze({
33
34
  ...control,
34
35
  ...(idempotencyKey === undefined ? {} : { idempotencyKey }),
36
+ ...(maintenance === undefined ? {} : { maintenance }),
35
37
  });
36
38
  }
39
+ function admitMaintenance(input) {
40
+ try {
41
+ return invocationProtocol.acceptMaintenance(input);
42
+ }
43
+ catch (cause) {
44
+ throw new TypeError('Session maintenance guard is invalid.', { cause });
45
+ }
46
+ }
37
47
  export function admitEnvelopeTransport(input) {
38
48
  if (input !== 'auto' && input !== 'http' && input !== 'websocket') {
39
49
  throw new TypeError('Session envelope transport is invalid.');
@@ -1,5 +1,5 @@
1
1
  import type { Result } from '../../client/index.js';
2
2
  /** Narrow a Result to the kind a sugar requires, releasing a live body before rejecting it. */
3
- export declare function requireResultKind<Kind extends 'value' | 'stream' | 'binary'>(expected: Kind, result: Result): Extract<Result, {
3
+ export declare function requireResultKind<Kind extends Exclude<Result['kind'], 'redirect'>>(expected: Kind, result: Result): Extract<Result, {
4
4
  kind: Kind;
5
5
  }>;
@@ -8,5 +8,9 @@ export function requireResultKind(expected, result) {
8
8
  if (result.kind === 'binary' && !(result.value.body instanceof Uint8Array)) {
9
9
  void result.value.body[Symbol.asyncIterator]().return?.();
10
10
  }
11
- throw new ClientError(`Function returned ${result.kind}; ${expected} was required.`);
11
+ // A started Execution is named so its caller never starts it again.
12
+ const returned = result.kind === 'execution'
13
+ ? `Function started Execution ${result.execution}`
14
+ : `Function returned ${result.kind}`;
15
+ throw new ClientError(`${returned}; ${expected} was required.`);
12
16
  }
@@ -41,7 +41,7 @@ export declare class ClientSession {
41
41
  /**
42
42
  * Delegate this Session's caller to one Domain issuer and exchange that delegation for the
43
43
  * Domain's credential to this Kernel. Nothing is cached: hold the result, for example through
44
- * `createSessionCredentialProvider`, for as long as it covers the calls it carries.
44
+ * `credentials`, for as long as it covers the calls it carries.
45
45
  */
46
46
  exchange(domain: string, options?: SessionExchangeRequest): Promise<SessionCredential>;
47
47
  /**
@@ -12,7 +12,7 @@ import { admitControlOptions, allowEndpoint, createSessionOperation } from './co
12
12
  import { createSessionDiscovery } from './discovery/index.js';
13
13
  import { acquireDomainCredential, admitExchangeRequest, createSessionExchange, } from './exchange/index.js';
14
14
  import { acceptSessionOptions } from './options.js';
15
- import { admitReference } from './reference.js';
15
+ import { admitReference, outputModeOf } from './reference.js';
16
16
  import { admitInvocationOptions, requireResultKind, SessionDispatcher } from './routing/index.js';
17
17
  import { domainViewCatalog, resolveViewsFor } from './views/index.js';
18
18
  const DEFAULT_SESSION_POLICY = Object.freeze({ maximumRouteAgeMs: 60_000 });
@@ -107,7 +107,7 @@ export class ClientSession {
107
107
  /**
108
108
  * Delegate this Session's caller to one Domain issuer and exchange that delegation for the
109
109
  * Domain's credential to this Kernel. Nothing is cached: hold the result, for example through
110
- * `createSessionCredentialProvider`, for as long as it covers the calls it carries.
110
+ * `credentials`, for as long as it covers the calls it carries.
111
111
  */
112
112
  async exchange(domain, options) {
113
113
  const request = admitExchangeRequest(domain, options);
@@ -162,11 +162,14 @@ export class ClientSession {
162
162
  ? this.dispatcher.dispatch(call, admitted.options, operation)
163
163
  : this.dispatcher.dispatchHttp(call, admitted.options, operation, admitted.body));
164
164
  const narrowed = requireResultKind(admittedReference.outputMode, result);
165
- return narrowed.kind === 'value'
166
- ? narrowed.value
167
- : narrowed.kind === 'stream'
168
- ? narrowed.stream
169
- : narrowed.value;
165
+ switch (narrowed.kind) {
166
+ case 'stream':
167
+ return narrowed.stream;
168
+ case 'execution':
169
+ return Object.freeze({ id: narrowed.execution });
170
+ default:
171
+ return narrowed.value;
172
+ }
170
173
  }
171
174
  dispatchWith(call, options, requireHttp = false) {
172
175
  const admitted = admitInvocationOptions(options);
@@ -209,7 +212,7 @@ export class ClientSession {
209
212
  fingerprint: callableFingerprint(method),
210
213
  callable: method.key,
211
214
  target: Path.instanceMethod(Path.id(node.id), method.key),
212
- outputMode: method.output.mode,
215
+ outputMode: outputModeOf(method),
213
216
  }, input);
214
217
  }
215
218
  operation(options) {
@@ -4,7 +4,7 @@ import { K, KernelSchema } from '@astrale-os/kernel-core/schema';
4
4
  import { defineSchema, func, method, nodeClass, schema, valueSchema, } from '@astrale-os/kernel-dsl/v1';
5
5
  import { isBinaryInput } from '@astrale-os/kernel-dsl/v1/language';
6
6
  import { call } from '../client/index.js';
7
- import { ClientSession, createSessionCredentialProvider, execution, reference } from './index.js';
7
+ import { ClientSession, credentials, execution, reference } from './index.js';
8
8
  void new ClientSession(options);
9
9
  void auth;
10
10
  void control;
@@ -29,12 +29,15 @@ void session.auth.admit({ target: Path.parse('/:example.test:function.write'), i
29
29
  { attenuation: { kind: 'identity', self: true } });
30
30
  // @ts-expect-error Admission belongs to Auth, not the top-level Session.
31
31
  void session.admit({ target: Path.parse('/:example.test:function.write'), input: {} });
32
- const credentials = createSessionCredentialProvider({
33
- ttlSeconds: 60,
34
- mint: async () => minted,
35
- });
36
- // A credential provider is a Session authentication resolver; no adapter stands between them.
37
- const credentialAuth = credentials;
32
+ const held = credentials({ ttlSeconds: 60, mint: async () => minted });
33
+ // Credentials is a Session authentication resolver; no adapter stands between them.
34
+ const credentialAuth = held;
35
+ void new ClientSession({ ...options, auth: credentials(minted.credential) });
36
+ void new ClientSession({ ...options, auth: credentials(async () => minted.credential) });
37
+ void new ClientSession({ ...options, auth: credentials(() => minted) });
38
+ void credentials({ initial: minted.credential, onChange: (state) => void state.status });
39
+ // @ts-expect-error A credential that may be missing is refused before any call.
40
+ void credentials(configured);
38
41
  void new ClientSession({ ...options, auth: credentialAuth });
39
42
  void new ClientSession({ ...options, auth: credentialAuth, exchange: { mode: 'auto' } });
40
43
  void new ClientSession({
@@ -53,8 +56,8 @@ void new ClientSession({ ...options, exchange: { mode: 'source', ttlSeconds: 300
53
56
  void new ClientSession({ ...options, exchange: true });
54
57
  // @ts-expect-error Unknown exchange modes are not admitted.
55
58
  void new ClientSession({ ...options, exchange: { mode: 'invalid' } });
56
- // @ts-expect-error A minted credential must carry its own absolute expiry.
57
- void createSessionCredentialProvider({ ttlSeconds: 60, mint: async () => minted.credential });
59
+ // @ts-expect-error A minted credential is a credential string or a credential with its expiry.
60
+ void credentials(async () => ({ credential: minted.credential }));
58
61
  const dynamicReference = reference(dynamicDomain, dynamicMethod)(Path.id(NodeId('dynamic-node')));
59
62
  void session.invoke(dynamicReference, dynamicInput);
60
63
  const dynamicInputIsClientInput = true;
@@ -4,6 +4,10 @@ import { retainDerivedQueryProvenance } from '../graph/provenance.js';
4
4
  import { EntityIndex } from './entity-index.js';
5
5
  import { OptimisticOverlay } from './optimistic.js';
6
6
  import { COLD_SNAPSHOT, QueryShape } from './shape.js';
7
+ const NO_REFERENCES = Object.freeze({
8
+ nodes: Object.freeze([]),
9
+ edges: Object.freeze([]),
10
+ });
7
11
  export class GraphMemory {
8
12
  options;
9
13
  entities = new EntityIndex();
@@ -60,6 +64,17 @@ export class GraphMemory {
60
64
  this.publish(shape, prior === undefined ? 'cold' : this.overlay.hasAny() ? 'optimistic' : 'stale');
61
65
  return result;
62
66
  }
67
+ // An uncertified read may hold facts the active schema refutes: it stays raw on its own
68
+ // shape and never enters, or is derived from, the shared entity cache.
69
+ if (result.certification === 'uncertified') {
70
+ shape.references = NO_REFERENCES;
71
+ shape.confirmed = result;
72
+ shape.response = result;
73
+ shape.refreshedAt = this.options.now();
74
+ this.touch(shape, shape.refreshedAt);
75
+ this.publish(shape, 'ready');
76
+ return shape.response;
77
+ }
63
78
  const integration = this.entities.integrate(result.result);
64
79
  shape.references = integration.references;
65
80
  shape.confirmed = result;
@@ -127,7 +142,7 @@ export class GraphMemory {
127
142
  }
128
143
  optimistic() {
129
144
  for (const shape of this.shapes.values()) {
130
- if (shape.response === undefined)
145
+ if (shape.response === undefined || shape.confirmed?.certification === 'uncertified')
131
146
  continue;
132
147
  shape.response = this.materialize(shape.confirmed, shape.references);
133
148
  this.publish(shape, 'optimistic');
@@ -195,9 +210,13 @@ export class GraphMemory {
195
210
  this.pending.shift()?.reject(error);
196
211
  }
197
212
  materialize(template, references) {
213
+ // Optimistic overlays and cache refreshes never rewrite an uncertified read.
214
+ if (template.certification === 'uncertified')
215
+ return template;
198
216
  const response = Object.freeze({
199
217
  result: this.materializeResult(template.result, references),
200
218
  page: template.page,
219
+ ...(template.certification === undefined ? {} : { certification: template.certification }),
201
220
  });
202
221
  return retainDerivedQueryProvenance(template, response);
203
222
  }
@@ -90,6 +90,9 @@ export async function admitResponse(response, requestId, context) {
90
90
  throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
91
91
  }
92
92
  requireLive(control);
93
+ if ('execution' in envelope) {
94
+ return { kind: 'execution', execution: envelope.execution, invocation: envelope.invocation };
95
+ }
93
96
  return { kind: 'value', value: envelope.result, invocation: envelope.invocation };
94
97
  }
95
98
  function redirectResult(response) {
@@ -4,6 +4,14 @@ export interface RequestOptions {
4
4
  readonly signal?: AbortSignal;
5
5
  readonly timeoutMs?: number;
6
6
  readonly idempotencyKey?: protocol.IdempotencyKey;
7
+ /**
8
+ * The maintenance session a root request expects to act within, by its install execution id. It
9
+ * grants nothing: the Kernel refuses the request `MAINTENANCE_SESSION_STALE` unless that session
10
+ * is the Instance's live one. The Client carries it in the source request, never to a destination.
11
+ */
12
+ readonly maintenance?: {
13
+ readonly session: string;
14
+ };
7
15
  }
8
16
  export interface TransportRequest {
9
17
  readonly call: protocol.Call;
@@ -14,6 +22,8 @@ export interface TransportRequest {
14
22
  readonly routing?: protocol.Routing;
15
23
  /** Source-Kernel Schema Registration precondition; omitted after routing. */
16
24
  readonly schema?: protocol.SchemaTarget;
25
+ /** Source-Kernel maintenance session guard; omitted after routing. */
26
+ readonly maintenance?: protocol.Maintenance;
17
27
  }
18
28
  /** Correlated reserved control decoded independently from application results and errors. */
19
29
  export interface StaleControl {
@@ -153,6 +153,14 @@ export class WebSocketExchange {
153
153
  this.reject(new ResponseError(response.error.code, response.error.message, response.invocation, response.error.data));
154
154
  return;
155
155
  }
156
+ if ('execution' in response) {
157
+ this.complete({
158
+ kind: 'execution',
159
+ execution: response.execution,
160
+ invocation: response.invocation,
161
+ });
162
+ return;
163
+ }
156
164
  this.complete({ kind: 'value', value: response.result, invocation: response.invocation });
157
165
  }
158
166
  receiveStreamFrame(frame) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-client",
3
- "version": "0.6.0-beta.88",
3
+ "version": "0.6.0",
4
4
  "description": "Universal Client — protocol-first, transport-agnostic",
5
5
  "keywords": [
6
6
  "astrale",
@@ -65,13 +65,13 @@
65
65
  "access": "public"
66
66
  },
67
67
  "dependencies": {
68
- "@astrale-os/kernel-core": "0.9.0-beta.67",
69
- "@astrale-os/kernel-dsl": "0.2.0-beta.49",
70
- "@astrale-os/kernel-protocol": "0.5.0-beta.73",
68
+ "@astrale-os/kernel-core": "0.9.0",
69
+ "@astrale-os/kernel-dsl": "0.2.0",
70
+ "@astrale-os/kernel-protocol": "0.5.0",
71
71
  "@tanstack/pacer": "0.20.1"
72
72
  },
73
73
  "devDependencies": {
74
- "@astrale-os/kernel-server": "0.5.0-beta.75",
74
+ "@astrale-os/kernel-server": "0.5.0",
75
75
  "@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
76
76
  "@types/node": "^22.0.0",
77
77
  "typescript": "7.0.2",