@astrale-os/kernel-client 1.0.0-beta.4 → 1.0.0-beta.5
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.
- package/dist/client/request.d.ts +1 -0
- package/dist/client/request.js +17 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/errors/refusal.d.ts +12 -0
- package/dist/errors/refusal.js +40 -0
- package/dist/graph/domain/binding.js +4 -0
- package/dist/graph/page-contract.d.ts +6 -0
- package/dist/graph/query.js +10 -2
- package/dist/pacer/index.d.ts +1 -1
- package/dist/pacer/index.js +1 -1
- package/dist/pacer/retry/index.d.ts +1 -0
- package/dist/pacer/retry/index.js +1 -0
- package/dist/pacer/retry/refusals.d.ts +7 -0
- package/dist/pacer/retry/refusals.js +10 -0
- package/dist/pacer/retry/retry.d.ts +2 -0
- package/dist/pacer/retry/retry.js +33 -1
- package/dist/schema/admission.d.ts +1 -1
- package/dist/schema/admission.js +2 -2
- package/dist/schema/contracts.d.ts +95 -2
- package/dist/schema/index.d.ts +2 -1
- package/dist/schema/installation.d.ts +104 -0
- package/dist/schema/installation.js +146 -0
- package/dist/schema/schema.d.ts +18 -3
- package/dist/schema/schema.js +31 -35
- package/dist/session/bound.js +42 -0
- package/dist/session/execution.d.ts +24 -1
- package/dist/session/index.d.ts +1 -1
- package/dist/session/routing/dispatch.js +2 -0
- package/dist/session/routing/request.d.ts +4 -0
- package/dist/session/routing/request.js +11 -1
- package/dist/store/memory.js +20 -1
- package/dist/transport/transport.d.ts +10 -0
- package/package.json +4 -4
package/dist/client/request.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface AdmittedRequest {
|
|
|
25
25
|
readonly delegate?: protocol.Delegate;
|
|
26
26
|
readonly routing?: protocol.Routing;
|
|
27
27
|
readonly schema?: protocol.SchemaTarget;
|
|
28
|
+
readonly maintenance?: protocol.Maintenance;
|
|
28
29
|
readonly options: RequestOptions;
|
|
29
30
|
readonly body?: Blob;
|
|
30
31
|
}
|
package/dist/client/request.js
CHANGED
|
@@ -10,11 +10,13 @@ export function admitRequest(input, options, lifecycle) {
|
|
|
10
10
|
const delegate = admitDelegate(options?.delegate);
|
|
11
11
|
const routing = admitRouting(options?.routing);
|
|
12
12
|
const schema = admitSchemaTarget(options?.schema);
|
|
13
|
+
const maintenance = admitMaintenance(options?.maintenance);
|
|
13
14
|
return Object.freeze({
|
|
14
15
|
call,
|
|
15
16
|
...(delegate === undefined ? {} : { delegate }),
|
|
16
17
|
...(routing === undefined ? {} : { routing }),
|
|
17
18
|
...(schema === undefined ? {} : { schema }),
|
|
19
|
+
...(maintenance === undefined ? {} : { maintenance }),
|
|
18
20
|
...(admitted.body === undefined ? {} : { body: admitted.body }),
|
|
19
21
|
options: admittedOptions,
|
|
20
22
|
});
|
|
@@ -28,6 +30,9 @@ export function invocation(request, credential, trace) {
|
|
|
28
30
|
if (request.schema !== undefined) {
|
|
29
31
|
throw new TypeError('Destination Client requests cannot carry a Schema target.');
|
|
30
32
|
}
|
|
33
|
+
if (request.maintenance !== undefined) {
|
|
34
|
+
throw new TypeError('Destination Client requests cannot carry a maintenance guard.');
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
37
|
else if ((credential === undefined) !== (request.delegate === undefined)) {
|
|
33
38
|
throw new TypeError('Source Client credentials and delegation requests must occur together.');
|
|
@@ -38,6 +43,7 @@ export function invocation(request, credential, trace) {
|
|
|
38
43
|
...(request.delegate === undefined ? {} : { delegate: request.delegate }),
|
|
39
44
|
...(request.routing === undefined ? {} : { routing: request.routing }),
|
|
40
45
|
...(request.schema === undefined ? {} : { schema: request.schema }),
|
|
46
|
+
...(request.maintenance === undefined ? {} : { maintenance: request.maintenance }),
|
|
41
47
|
...(admittedTrace === undefined ? {} : { trace: admittedTrace }),
|
|
42
48
|
});
|
|
43
49
|
}
|
|
@@ -54,6 +60,7 @@ function admitRequestOptions(input) {
|
|
|
54
60
|
'delegate',
|
|
55
61
|
'routing',
|
|
56
62
|
'schema',
|
|
63
|
+
'maintenance',
|
|
57
64
|
'body',
|
|
58
65
|
].includes(String(field)))) {
|
|
59
66
|
throw new TypeError('Client request options contain unsupported fields.');
|
|
@@ -118,6 +125,16 @@ function admitSchemaTarget(input) {
|
|
|
118
125
|
throw new TypeError('Client Schema target is invalid.', { cause });
|
|
119
126
|
}
|
|
120
127
|
}
|
|
128
|
+
function admitMaintenance(input) {
|
|
129
|
+
if (input === undefined)
|
|
130
|
+
return undefined;
|
|
131
|
+
try {
|
|
132
|
+
return invocationProtocol.acceptMaintenance(input);
|
|
133
|
+
}
|
|
134
|
+
catch (cause) {
|
|
135
|
+
throw new TypeError('Client maintenance guard is invalid.', { cause });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
121
138
|
function lifecycleOptions(input, lifecycle) {
|
|
122
139
|
const signal = input?.signal === undefined ? lifecycle : AbortSignal.any([input.signal, lifecycle]);
|
|
123
140
|
return Object.freeze({
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './client-error.js';
|
|
|
2
2
|
export * from './exchange-error.js';
|
|
3
3
|
export * from './miss-error.js';
|
|
4
4
|
export * from './protocol-error.js';
|
|
5
|
+
export * from './refusal.js';
|
|
5
6
|
export * from './response-error.js';
|
|
6
7
|
export * from './session-error.js';
|
|
7
8
|
export * from './stale-route-error.js';
|
package/dist/errors/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './client-error.js';
|
|
|
2
2
|
export * from './exchange-error.js';
|
|
3
3
|
export * from './miss-error.js';
|
|
4
4
|
export * from './protocol-error.js';
|
|
5
|
+
export * from './refusal.js';
|
|
5
6
|
export * from './response-error.js';
|
|
6
7
|
export * from './session-error.js';
|
|
7
8
|
export * from './stale-route-error.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResponseError } from './response-error.js';
|
|
2
|
+
/** Return the delay a refused invocation prescribes before it is sent again, and nothing else. */
|
|
3
|
+
export declare function retryAfterOf(error: unknown): number | undefined;
|
|
4
|
+
/** Whether the Instance refused the invocation because a maintenance session admits only root. */
|
|
5
|
+
export declare function isMaintenance(error: unknown): error is ResponseError;
|
|
6
|
+
/**
|
|
7
|
+
* Whether the Kernel refused a request whose maintenance guard names a session that does not own
|
|
8
|
+
* the Instance: it ended, or another one owns it. Nothing ran; resending it unchanged cannot succeed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isMaintenanceSessionStale(error: unknown): error is ResponseError;
|
|
11
|
+
/** Whether a sealed conflict ran nothing because the graph snapshot advanced; resend it at once. */
|
|
12
|
+
export declare function isSnapshotStale(error: unknown): error is ResponseError;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as errors from '@astrale-os/kernel-protocol/errors';
|
|
2
|
+
import { ResponseError } from './response-error.js';
|
|
3
|
+
/** Sealed conflicts whose plan met a checkpoint advanced past its pinned snapshot. */
|
|
4
|
+
const SNAPSHOT_STALE_REASONS = new Set([
|
|
5
|
+
'SNAPSHOT_STALE',
|
|
6
|
+
'QUERY_SNAPSHOT_STALE',
|
|
7
|
+
'MUTATION_SNAPSHOT_STALE',
|
|
8
|
+
]);
|
|
9
|
+
/** Return the delay a refused invocation prescribes before it is sent again, and nothing else. */
|
|
10
|
+
export function retryAfterOf(error) {
|
|
11
|
+
if (!(error instanceof ResponseError))
|
|
12
|
+
return undefined;
|
|
13
|
+
return errors.retryAfterOf({
|
|
14
|
+
code: error.code,
|
|
15
|
+
message: error.message,
|
|
16
|
+
...(error.data === undefined ? {} : { data: error.data }),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** Whether the Instance refused the invocation because a maintenance session admits only root. */
|
|
20
|
+
export function isMaintenance(error) {
|
|
21
|
+
return (error instanceof ResponseError &&
|
|
22
|
+
error.reason?.code === errors.RETRY_REASONS.INSTANCE_MAINTENANCE &&
|
|
23
|
+
retryAfterOf(error) !== undefined);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Whether the Kernel refused a request whose maintenance guard names a session that does not own
|
|
27
|
+
* the Instance: it ended, or another one owns it. Nothing ran; resending it unchanged cannot succeed.
|
|
28
|
+
*/
|
|
29
|
+
export function isMaintenanceSessionStale(error) {
|
|
30
|
+
return (error instanceof ResponseError &&
|
|
31
|
+
error.code === errors.CODES.CONFLICT &&
|
|
32
|
+
error.reason?.code === 'MAINTENANCE_SESSION_STALE');
|
|
33
|
+
}
|
|
34
|
+
/** Whether a sealed conflict ran nothing because the graph snapshot advanced; resend it at once. */
|
|
35
|
+
export function isSnapshotStale(error) {
|
|
36
|
+
return (error instanceof ResponseError &&
|
|
37
|
+
error.code === errors.CODES.CONFLICT &&
|
|
38
|
+
error.reason !== undefined &&
|
|
39
|
+
SNAPSHOT_STALE_REASONS.has(error.reason.code));
|
|
40
|
+
}
|
|
@@ -35,6 +35,10 @@ export function createDomainBinding(domain, graph, call) {
|
|
|
35
35
|
async query(query, options) {
|
|
36
36
|
const selected = selectedSourceClass(domain, query);
|
|
37
37
|
const response = await graph.query(query, { ...options, expected: domain.closure });
|
|
38
|
+
// A repair-session read may hold facts the bound Domain refutes: it is never typed by it.
|
|
39
|
+
if (response.certification === 'uncertified') {
|
|
40
|
+
throw new TypeError('An uncertified Query response cannot be bound to its Domain.');
|
|
41
|
+
}
|
|
38
42
|
const provenance = provenanceOfResponse(response);
|
|
39
43
|
if (provenance === undefined || !sameClosure(provenance.closure, domain.closure)) {
|
|
40
44
|
throw new TypeError('Authenticated query provenance was not retained.');
|
|
@@ -10,4 +10,10 @@ export interface QueryResponse<Result extends QueryResult = QueryResult> {
|
|
|
10
10
|
readonly page: {
|
|
11
11
|
readonly next?: string;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Present only for a repair-session read made without conformance admission: its facts may
|
|
15
|
+
* violate the active schema, so it is raw Core data only. The Store keeps it out of its shared
|
|
16
|
+
* cache and a Domain binding refuses to type it.
|
|
17
|
+
*/
|
|
18
|
+
readonly certification?: 'uncertified';
|
|
13
19
|
}
|
package/dist/graph/query.js
CHANGED
|
@@ -52,9 +52,13 @@ function decodeResponse(input) {
|
|
|
52
52
|
throw new TypeError('Graph query response is invalid.');
|
|
53
53
|
}
|
|
54
54
|
const value = input;
|
|
55
|
-
|
|
55
|
+
const uncertified = value.certification !== undefined;
|
|
56
|
+
if (!hasExactKeys(value, uncertified ? ['result', 'page', 'certification'] : ['result', 'page'])) {
|
|
56
57
|
throw new TypeError('Graph query response is invalid.');
|
|
57
58
|
}
|
|
59
|
+
if (uncertified && value.certification !== 'uncertified') {
|
|
60
|
+
throw new TypeError('Graph query response certification is invalid.');
|
|
61
|
+
}
|
|
58
62
|
const pageInput = value.page;
|
|
59
63
|
if (pageInput === null || typeof pageInput !== 'object' || Array.isArray(pageInput)) {
|
|
60
64
|
throw new TypeError('Graph query response page is invalid.');
|
|
@@ -69,7 +73,11 @@ function decodeResponse(input) {
|
|
|
69
73
|
}
|
|
70
74
|
const result = QueryResult.decode(value.result);
|
|
71
75
|
const page = Object.freeze(pageValue.next === undefined ? {} : { next: pageValue.next });
|
|
72
|
-
return Object.freeze({
|
|
76
|
+
return Object.freeze({
|
|
77
|
+
result,
|
|
78
|
+
page,
|
|
79
|
+
...(uncertified ? { certification: 'uncertified' } : {}),
|
|
80
|
+
});
|
|
73
81
|
}
|
|
74
82
|
function hasExactKeys(input, expected) {
|
|
75
83
|
const keys = Object.keys(input);
|
package/dist/pacer/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { retry, type RetryOptions } from './retry/index.js';
|
|
1
|
+
export { RETRY_REFUSALS, retry, type RetryOptions } from './retry/index.js';
|
|
2
2
|
export { createQueue, type QueueOptions } from './queue/index.js';
|
|
3
3
|
export { createBatcher, type BatchOptions } from './batcher/index.js';
|
|
4
4
|
export { createRateLimiter, type RateLimitOptions } from './limiter/index.js';
|
package/dist/pacer/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RetryOptions } from './retry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Opt-in policy for refusals proven to have run nothing. A back-pressure, draining or maintenance
|
|
4
|
+
* refusal is resent no earlier than its prescribed delay; a stale-snapshot conflict is resent after
|
|
5
|
+
* ordinary backoff. Every other failure ends the retry.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RETRY_REFUSALS: Readonly<Required<Pick<RetryOptions, 'shouldRetry' | 'retryAfter'>>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isSnapshotStale, retryAfterOf } from '../../errors/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Opt-in policy for refusals proven to have run nothing. A back-pressure, draining or maintenance
|
|
4
|
+
* refusal is resent no earlier than its prescribed delay; a stale-snapshot conflict is resent after
|
|
5
|
+
* ordinary backoff. Every other failure ends the retry.
|
|
6
|
+
*/
|
|
7
|
+
export const RETRY_REFUSALS = Object.freeze({
|
|
8
|
+
shouldRetry: (error) => retryAfterOf(error) !== undefined || isSnapshotStale(error),
|
|
9
|
+
retryAfter: (error) => retryAfterOf(error),
|
|
10
|
+
});
|
|
@@ -4,6 +4,8 @@ export interface RetryOptions {
|
|
|
4
4
|
readonly maxWait?: number;
|
|
5
5
|
readonly jitter?: number;
|
|
6
6
|
readonly shouldRetry?: (error: Error, attempt: number) => boolean;
|
|
7
|
+
/** Least delay in milliseconds a failure prescribes before the next attempt; backoff still applies. */
|
|
8
|
+
readonly retryAfter?: (error: Error, attempt: number) => number | undefined;
|
|
7
9
|
}
|
|
8
10
|
/** Retry with bounded exponential backoff and never swallow the final failure. */
|
|
9
11
|
export declare function retry<Result>(operation: () => Promise<Result>, options?: RetryOptions): Promise<Result>;
|
|
@@ -10,6 +10,9 @@ export async function retry(operation, options = {}) {
|
|
|
10
10
|
if (options.shouldRetry !== undefined && typeof options.shouldRetry !== 'function') {
|
|
11
11
|
throw new TypeError('Retry classifier is invalid.');
|
|
12
12
|
}
|
|
13
|
+
if (options.retryAfter !== undefined && typeof options.retryAfter !== 'function') {
|
|
14
|
+
throw new TypeError('Retry delay classifier is invalid.');
|
|
15
|
+
}
|
|
13
16
|
const attempts = positive(options.maxAttempts ?? DEFAULT_RETRY_ATTEMPTS, 'maxAttempts');
|
|
14
17
|
const baseWait = nonNegative(options.baseWait ?? DEFAULT_RETRY_BASE_WAIT_MS, 'baseWait');
|
|
15
18
|
const maxWait = nonNegative(options.maxWait ?? DEFAULT_RETRY_MAX_WAIT_MS, 'maxWait');
|
|
@@ -19,7 +22,11 @@ export async function retry(operation, options = {}) {
|
|
|
19
22
|
}
|
|
20
23
|
let succeeded = false;
|
|
21
24
|
let failure;
|
|
25
|
+
// Earliest instant the last failure allows the next attempt; backoff has already waited part of it.
|
|
26
|
+
let notBefore = 0;
|
|
27
|
+
let invalidDelay;
|
|
22
28
|
const retryer = new AsyncRetryer(async () => {
|
|
29
|
+
await waitUntil(notBefore);
|
|
23
30
|
try {
|
|
24
31
|
const result = await operation();
|
|
25
32
|
succeeded = true;
|
|
@@ -29,6 +36,15 @@ export async function retry(operation, options = {}) {
|
|
|
29
36
|
catch (error) {
|
|
30
37
|
succeeded = false;
|
|
31
38
|
failure = error;
|
|
39
|
+
if (error instanceof Error && options.retryAfter !== undefined) {
|
|
40
|
+
const delay = options.retryAfter(error, retryer.store.state.currentAttempt);
|
|
41
|
+
if (delay !== undefined && (!Number.isFinite(delay) || delay < 0)) {
|
|
42
|
+
invalidDelay = new TypeError('retryAfter must return a finite non-negative number.');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
notBefore = delay === undefined ? 0 : Date.now() + delay;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
32
48
|
throw error;
|
|
33
49
|
}
|
|
34
50
|
}, {
|
|
@@ -39,13 +55,23 @@ export async function retry(operation, options = {}) {
|
|
|
39
55
|
maxAttempts: (current) => {
|
|
40
56
|
const error = current.store.state.lastError;
|
|
41
57
|
const attempt = current.store.state.currentAttempt;
|
|
58
|
+
if (invalidDelay !== undefined)
|
|
59
|
+
return attempt;
|
|
42
60
|
if (error !== undefined && options.shouldRetry?.(error, attempt) === false)
|
|
43
61
|
return attempt;
|
|
44
62
|
return attempts;
|
|
45
63
|
},
|
|
46
64
|
throwOnError: 'last',
|
|
47
65
|
});
|
|
48
|
-
|
|
66
|
+
let result;
|
|
67
|
+
try {
|
|
68
|
+
result = await retryer.execute();
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw invalidDelay ?? error;
|
|
72
|
+
}
|
|
73
|
+
if (invalidDelay !== undefined)
|
|
74
|
+
throw invalidDelay;
|
|
49
75
|
if (!succeeded) {
|
|
50
76
|
if (failure !== undefined)
|
|
51
77
|
throw failure;
|
|
@@ -53,3 +79,9 @@ export async function retry(operation, options = {}) {
|
|
|
53
79
|
}
|
|
54
80
|
return result;
|
|
55
81
|
}
|
|
82
|
+
/** Timers may fire early against the wall clock, so wait again until the instant has passed. */
|
|
83
|
+
async function waitUntil(instant) {
|
|
84
|
+
for (let remaining = instant - Date.now(); remaining > 0; remaining = instant - Date.now()) {
|
|
85
|
+
await new Promise((resolve) => setTimeout(resolve, remaining));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -8,5 +8,5 @@ interface OutputContract {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
/** Admit one value result through its Core-owned syscall contract. */
|
|
11
|
-
export declare function acceptOutput<T>(contract: OutputContract, input: unknown): T;
|
|
11
|
+
export declare function acceptOutput<T>(contract: OutputContract, input: unknown, what?: string): T;
|
|
12
12
|
export {};
|
package/dist/schema/admission.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as portable from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
/** Admit one value result through its Core-owned syscall contract. */
|
|
3
|
-
export function acceptOutput(contract, input) {
|
|
3
|
+
export function acceptOutput(contract, input, what = 'Schema result') {
|
|
4
4
|
const value = portable.accept(input);
|
|
5
5
|
const parsed = contract.safeParse(value);
|
|
6
6
|
if (!parsed.success)
|
|
7
|
-
throw new TypeError(
|
|
7
|
+
throw new TypeError(`Kernel returned an invalid ${what}.`);
|
|
8
8
|
return freeze(parsed.data);
|
|
9
9
|
}
|
|
10
10
|
function freeze(input) {
|
|
@@ -1,12 +1,105 @@
|
|
|
1
|
+
import type { NodeId } from '@astrale-os/kernel-core/graph/node';
|
|
1
2
|
import type { installation } from '@astrale-os/kernel-core/schema';
|
|
2
|
-
import type { DomainRequest as CoreDomainRequest, InstallInput, InstallReceipt as CoreInstallReceipt, UninstallInput, UninstallOutput } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
3
|
+
import type { AttemptReport, DomainRequest as CoreDomainRequest, InstallClass as CoreInstallClass, InstallInput, InstallMode as CoreInstallMode, InstallReceipt as CoreInstallReceipt, SystemExecutionDetail, UninstallInput, UninstallOutput, ValidationOptions } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
4
|
+
import type { Value } from '@astrale-os/kernel-dsl/value';
|
|
5
|
+
import type { schema as protocolSchema } from '@astrale-os/kernel-protocol';
|
|
6
|
+
import type { ExecutionState } from '../session/execution.js';
|
|
3
7
|
export type OperationId = installation.OperationId;
|
|
4
8
|
/** Canonical caller input accepted by the Kernel install syscall. */
|
|
5
9
|
export type DomainRequest = CoreDomainRequest;
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* One install: its Kernel input, plus `wait`, which the Client alone reads: `false` answers at
|
|
12
|
+
* once, otherwise the Client waits for the outcome within the request deadline. It is never sent,
|
|
13
|
+
* so it is no part of the operation's intent.
|
|
14
|
+
*/
|
|
15
|
+
export type InstallRequest = InstallInput & {
|
|
16
|
+
readonly wait?: boolean;
|
|
17
|
+
};
|
|
7
18
|
/** Admitted terminal install receipt returned by the Kernel. */
|
|
8
19
|
export type InstallReceipt = CoreInstallReceipt;
|
|
20
|
+
/** The `K.Execution` an install or uninstall is; a repair session's id is its Execution's. */
|
|
21
|
+
export type InstallExecutionId = NodeId;
|
|
22
|
+
/** What an install does to the stored data: nothing, applied at once, or revalidated first. */
|
|
23
|
+
export type InstallClass = CoreInstallClass;
|
|
24
|
+
export type InstallMode = CoreInstallMode;
|
|
25
|
+
/** The validation options of an install, defaults filled in. */
|
|
26
|
+
export type InstallValidationOptions = ValidationOptions;
|
|
27
|
+
/** The last attempt of a repair session that ended without activating, with its report. */
|
|
28
|
+
export type InstallAttemptReport = AttemptReport;
|
|
29
|
+
/** What an install or session shows beside its engine state, as Core shapes it. */
|
|
30
|
+
export type InstallDetail = SystemExecutionDetail;
|
|
31
|
+
/** The public failure a rejected install ended with, such as `DATA_MIGRATION_REQUIRED`. */
|
|
32
|
+
export interface InstallFailure {
|
|
33
|
+
readonly code: string;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
readonly family?: string;
|
|
36
|
+
readonly details?: Value;
|
|
37
|
+
}
|
|
38
|
+
/** A terminal install: its committed result, its rejection, or its cancellation. */
|
|
39
|
+
export type InstallOutcome = {
|
|
40
|
+
readonly kind: 'completed';
|
|
41
|
+
readonly value: protocolSchema.installation.InstallResult;
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: 'failed';
|
|
44
|
+
readonly error: InstallFailure;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: 'cancelled';
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The status of one install, uninstall or repair session: the engine `state` the CLI decides on,
|
|
50
|
+
* and the Core `detail` (phase, class, progress, the next command index, the running attempt and
|
|
51
|
+
* the last attempt report).
|
|
52
|
+
*/
|
|
53
|
+
export type InstallStatus<Outcome = InstallOutcome> = InstallNodeStatus<Outcome> | DeletedInstallStatus<Outcome>;
|
|
54
|
+
/** The status of an install, uninstall or session whose Execution node exists. */
|
|
55
|
+
export interface InstallNodeStatus<Outcome = InstallOutcome> {
|
|
56
|
+
readonly id: InstallExecutionId;
|
|
57
|
+
readonly function: NodeId;
|
|
58
|
+
readonly version: `sha256:${string}`;
|
|
59
|
+
readonly state: ExecutionState;
|
|
60
|
+
readonly createdAt: string;
|
|
61
|
+
readonly detail?: InstallDetail;
|
|
62
|
+
/** Present exactly once the Execution is terminal. */
|
|
63
|
+
readonly outcome?: Outcome;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* What Root alone reads once the Execution node of an install, uninstall or session was deleted:
|
|
67
|
+
* the outcome its lifecycle record keeps, under the explicit state `deleted`.
|
|
68
|
+
*/
|
|
69
|
+
export interface DeletedInstallStatus<Outcome = InstallOutcome> {
|
|
70
|
+
readonly id: InstallExecutionId;
|
|
71
|
+
readonly state: 'deleted';
|
|
72
|
+
readonly outcome: Outcome;
|
|
73
|
+
/** Absent: the node that recorded them is deleted. */
|
|
74
|
+
readonly function?: never;
|
|
75
|
+
readonly version?: never;
|
|
76
|
+
readonly createdAt?: never;
|
|
77
|
+
readonly detail?: never;
|
|
78
|
+
}
|
|
79
|
+
/** One admitted install answer: its Execution, its status, and its result once completed. */
|
|
80
|
+
export interface Installation {
|
|
81
|
+
readonly execution: InstallExecutionId;
|
|
82
|
+
readonly status: InstallStatus;
|
|
83
|
+
/** The committed result, present exactly when the status is completed. */
|
|
84
|
+
readonly result?: protocolSchema.installation.InstallResult;
|
|
85
|
+
}
|
|
9
86
|
/** Canonical caller input accepted by the Kernel uninstall syscall. */
|
|
10
87
|
export type UninstallRequest = UninstallInput;
|
|
11
88
|
/** Admitted terminal uninstall receipt returned by the Kernel. */
|
|
12
89
|
export type UninstallReceipt = UninstallOutput;
|
|
90
|
+
/** A terminal uninstall: its committed receipt, its rejection, or its cancellation. */
|
|
91
|
+
export type UninstallOutcome = {
|
|
92
|
+
readonly kind: 'completed';
|
|
93
|
+
readonly value: UninstallReceipt;
|
|
94
|
+
} | {
|
|
95
|
+
readonly kind: 'failed';
|
|
96
|
+
readonly error: InstallFailure;
|
|
97
|
+
} | {
|
|
98
|
+
readonly kind: 'cancelled';
|
|
99
|
+
};
|
|
100
|
+
/** One admitted uninstall answer: its Execution, its status, and its receipt once completed. */
|
|
101
|
+
export interface Uninstallation {
|
|
102
|
+
readonly execution: InstallExecutionId;
|
|
103
|
+
readonly status: InstallStatus<UninstallOutcome>;
|
|
104
|
+
readonly result?: UninstallReceipt;
|
|
105
|
+
}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { createSchema, DEFAULT_SCHEMA_LIFECYCLE_TIMEOUT_MS, type SchemaApi, type SchemaCall, type SchemaOptions, type DomainBundle, type DomainDependencies, type DomainInfo, type InstalledPin, type InstalledRelease, type InstallResult, } from './schema.js';
|
|
2
2
|
export { acceptOperationId, createOperationId } from './operation.js';
|
|
3
|
-
export type {
|
|
3
|
+
export type { InstallationApi, UninstallationApi } from './installation.js';
|
|
4
|
+
export type { DomainRequest, InstallAttemptReport, InstallClass, InstallDetail, InstallExecutionId, InstallFailure, InstallMode, InstallOutcome, InstallStatus, InstallNodeStatus, DeletedInstallStatus, InstallValidationOptions, Installation, InstallReceipt, InstallRequest, OperationId, Uninstallation, UninstallOutcome, UninstallReceipt, UninstallRequest, } from './contracts.js';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { PathLike } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import type { InstallValidation } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
3
|
+
import type { RequestOptions } from '../transport/index.js';
|
|
4
|
+
import type { InstallExecutionId, InstallFailure, InstallOutcome, InstallStatus, UninstallOutcome, UninstallReceipt } from './contracts.js';
|
|
5
|
+
import type { SchemaCall } from './schema.js';
|
|
6
|
+
/**
|
|
7
|
+
* The install executions of one Instance, through the `K.Execution` Methods of each. Observing
|
|
8
|
+
* and a cooperative cancel are Root's or the initiator's; signals, a forced cancel, resume and
|
|
9
|
+
* delete are Root's.
|
|
10
|
+
*/
|
|
11
|
+
export interface InstallationApi {
|
|
12
|
+
/** The status of one install or repair session. */
|
|
13
|
+
status(execution: InstallExecutionId, options?: RequestOptions): Promise<InstallStatus>;
|
|
14
|
+
/** The terminal outcome, waiting at most `waitMs`; `EXECUTION_PENDING` once it lapses. */
|
|
15
|
+
result(execution: InstallExecutionId, wait?: {
|
|
16
|
+
readonly waitMs?: number;
|
|
17
|
+
}, options?: RequestOptions): Promise<InstallOutcome>;
|
|
18
|
+
/**
|
|
19
|
+
* A waiting repair session attempts its target: the `command:<index>` signal, `index` being
|
|
20
|
+
* the `detail.command` its status announces. A signal already resolved is refused.
|
|
21
|
+
*/
|
|
22
|
+
apply(execution: InstallExecutionId, command: {
|
|
23
|
+
readonly index: number;
|
|
24
|
+
readonly validation?: InstallValidation;
|
|
25
|
+
}, options?: RequestOptions): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Stop the attempt a repair session runs, `detail.attempt.number`, through its `abort:<attempt>`
|
|
28
|
+
* signal; the session waits again.
|
|
29
|
+
*/
|
|
30
|
+
abort(execution: InstallExecutionId, attempt: number, options?: RequestOptions): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* A cooperative cancel ends an install before its point of no return with nothing changed, and
|
|
33
|
+
* has a repair session attempt its source schema. `force` kills the run; a live session first
|
|
34
|
+
* takes the break-glass exit (the Instance reopens on its source, marked `uncertified`).
|
|
35
|
+
*/
|
|
36
|
+
cancel(execution: InstallExecutionId, input?: {
|
|
37
|
+
readonly force?: boolean;
|
|
38
|
+
}, options?: RequestOptions): Promise<InstallStatus>;
|
|
39
|
+
/** Resume a paused install or session; a running one is unchanged. */
|
|
40
|
+
resume(execution: InstallExecutionId, options?: RequestOptions): Promise<InstallStatus>;
|
|
41
|
+
/** Delete the Execution, then kill and purge its run; a live session exits by break-glass. */
|
|
42
|
+
delete(execution: InstallExecutionId, options?: RequestOptions): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The uninstall executions of one Instance, through the same `K.Execution` Methods: a completed
|
|
46
|
+
* outcome carries the uninstall receipt. An uninstall has no repair session, so no signal.
|
|
47
|
+
*/
|
|
48
|
+
export interface UninstallationApi {
|
|
49
|
+
/** The status of one uninstall. */
|
|
50
|
+
status(execution: InstallExecutionId, options?: RequestOptions): Promise<InstallStatus<UninstallOutcome>>;
|
|
51
|
+
/** The terminal outcome, waiting at most `waitMs`; `EXECUTION_PENDING` once it lapses. */
|
|
52
|
+
result(execution: InstallExecutionId, wait?: {
|
|
53
|
+
readonly waitMs?: number;
|
|
54
|
+
}, options?: RequestOptions): Promise<UninstallOutcome>;
|
|
55
|
+
/** A cooperative cancel ends it before its point of no return; `force` kills the run. */
|
|
56
|
+
cancel(execution: InstallExecutionId, input?: {
|
|
57
|
+
readonly force?: boolean;
|
|
58
|
+
}, options?: RequestOptions): Promise<InstallStatus<UninstallOutcome>>;
|
|
59
|
+
/** Resume a paused uninstall; a running one is unchanged. */
|
|
60
|
+
resume(execution: InstallExecutionId, options?: RequestOptions): Promise<InstallStatus<UninstallOutcome>>;
|
|
61
|
+
/** Delete the Execution, then kill and purge its run. */
|
|
62
|
+
delete(execution: InstallExecutionId, options?: RequestOptions): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/** Admit a completed outcome's value; anything else of the outcome is kept as admitted. */
|
|
65
|
+
export type AcceptValue<Value> = (input: unknown) => Value;
|
|
66
|
+
export type ExecutionOutcomeOf<Value> = {
|
|
67
|
+
readonly kind: 'completed';
|
|
68
|
+
readonly value: Value;
|
|
69
|
+
} | {
|
|
70
|
+
readonly kind: 'failed';
|
|
71
|
+
readonly error: InstallFailure;
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: 'cancelled';
|
|
74
|
+
};
|
|
75
|
+
/** The `K.Execution` Methods of one Execution, over one call capability; package-private. */
|
|
76
|
+
export declare function executionMethods(call: SchemaCall, options: (input: RequestOptions | undefined) => RequestOptions): Readonly<{
|
|
77
|
+
status: <Value>(id: InstallExecutionId, accept: AcceptValue<Value>, request?: RequestOptions) => Promise<InstallStatus<ExecutionOutcomeOf<Value>>>;
|
|
78
|
+
result<Value>(id: InstallExecutionId, accept: AcceptValue<Value>, wait?: {
|
|
79
|
+
readonly waitMs?: number;
|
|
80
|
+
}, request?: RequestOptions): Promise<ExecutionOutcomeOf<Value>>;
|
|
81
|
+
signal(id: InstallExecutionId, name: string, signalled: unknown, request?: RequestOptions): Promise<void>;
|
|
82
|
+
cancel: <Value>(id: InstallExecutionId, accept: AcceptValue<Value>, input: {
|
|
83
|
+
readonly force?: boolean;
|
|
84
|
+
}, request?: RequestOptions) => Promise<InstallStatus<ExecutionOutcomeOf<Value>>>;
|
|
85
|
+
resume: <Value>(id: InstallExecutionId, accept: AcceptValue<Value>, request?: RequestOptions) => Promise<InstallStatus<ExecutionOutcomeOf<Value>>>;
|
|
86
|
+
delete(id: InstallExecutionId, request?: RequestOptions): Promise<void>;
|
|
87
|
+
/** Admit what a durable call answers at once: the Execution it created or recovered. */
|
|
88
|
+
start(path: PathLike, input: unknown, request?: RequestOptions): Promise<InstallExecutionId>;
|
|
89
|
+
/**
|
|
90
|
+
* Wait within the request deadline for the outcome. A wait that lapsed after waiting, while
|
|
91
|
+
* time remains, waits again; a wait a closing process or a gap with no process failed is sent
|
|
92
|
+
* again. Every other end of the wait, or its deadline, leaves the Execution as it is: its
|
|
93
|
+
* status, read next, says where it is, so the caller never loses the Execution.
|
|
94
|
+
*/
|
|
95
|
+
settle(id: InstallExecutionId, request?: RequestOptions): Promise<void>;
|
|
96
|
+
/** The status after a wait, read again as `settle` sends its wait again, within the deadline. */
|
|
97
|
+
observe<Value>(id: InstallExecutionId, accept: AcceptValue<Value>, request?: RequestOptions): Promise<InstallStatus<ExecutionOutcomeOf<Value>>>;
|
|
98
|
+
}>;
|
|
99
|
+
export type ExecutionMethods = ReturnType<typeof executionMethods>;
|
|
100
|
+
/** The install Methods: a completed outcome carries the result its Protocol owner admits. */
|
|
101
|
+
export declare function createInstallation(executions: ExecutionMethods): InstallationApi;
|
|
102
|
+
/** The uninstall Methods: a completed outcome carries the receipt Core's contract admits. */
|
|
103
|
+
export declare function createUninstallation(executions: ExecutionMethods): UninstallationApi;
|
|
104
|
+
export declare function acceptUninstallReceipt(input: unknown): UninstallReceipt;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { NodeId } from '@astrale-os/kernel-core/graph/node';
|
|
2
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
3
|
+
import { abortSignal, commandSignal, executionOutcome, executionRef, executionStatus, uninstallOutput, } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
4
|
+
import { execution as methods } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
5
|
+
import { MethodKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
6
|
+
import * as protocolSchema from '@astrale-os/kernel-protocol/schema';
|
|
7
|
+
import { call as invocation } from '../client/index.js';
|
|
8
|
+
import { ResponseError, TransportError } from '../errors/index.js';
|
|
9
|
+
import { RETRY_REFUSALS, retry } from '../pacer/index.js';
|
|
10
|
+
import { acceptOutput } from './admission.js';
|
|
11
|
+
/** Attempts of one effect-free Execution read; the wait's deadline bounds them too. */
|
|
12
|
+
const READ_ATTEMPTS = 8;
|
|
13
|
+
/** A pending answer sooner than this did not wait: the Kernel answers now, so waiting ends. */
|
|
14
|
+
const LAPSED_WAIT_MS = 1_000;
|
|
15
|
+
/** No wait starts with less time left than this before its deadline. */
|
|
16
|
+
const MINIMUM_WAIT_MS = 1_000;
|
|
17
|
+
/** The `K.Execution` Methods of one Execution, over one call capability; package-private. */
|
|
18
|
+
export function executionMethods(call, options) {
|
|
19
|
+
const value = async (id, method, input, request) => {
|
|
20
|
+
const target = Path.instanceMethod(Path.id(id), MethodKey.of(method.owner, method.name));
|
|
21
|
+
const result = await call(invocation(target, input), options(request));
|
|
22
|
+
if (result.kind !== 'value')
|
|
23
|
+
throw new TypeError('Execution Method returned a non-value result.');
|
|
24
|
+
return result.value;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* An Execution read has no effect: one a process refused with a retry delay, or a gap with no
|
|
28
|
+
* process on the port failed, is sent again through the pacer, each attempt within `deadline`.
|
|
29
|
+
*/
|
|
30
|
+
const read = (deadline, request, work) => retry(() => work({ ...request, timeoutMs: Math.max(1, deadline - Date.now()) }), {
|
|
31
|
+
maxAttempts: READ_ATTEMPTS,
|
|
32
|
+
shouldRetry: (error, attempt) => Date.now() < deadline &&
|
|
33
|
+
(error instanceof TransportError || RETRY_REFUSALS.shouldRetry(error, attempt)),
|
|
34
|
+
retryAfter: RETRY_REFUSALS.retryAfter,
|
|
35
|
+
});
|
|
36
|
+
const status = async (id, accept, answer) => {
|
|
37
|
+
const admitted = acceptOutput(executionStatus, await answer, 'Execution status');
|
|
38
|
+
if (admitted.id !== id)
|
|
39
|
+
throw new TypeError('Kernel returned the status of another Execution.');
|
|
40
|
+
const outcome = admitted.outcome === undefined ? undefined : outcomeOf(admitted.outcome, accept);
|
|
41
|
+
// A deleted Execution carries the outcome its lifecycle record keeps, whatever its kind.
|
|
42
|
+
if (admitted.state !== 'deleted' &&
|
|
43
|
+
(admitted.state === 'completed') !== (outcome?.kind === 'completed')) {
|
|
44
|
+
throw new TypeError('Execution status and outcome disagree.');
|
|
45
|
+
}
|
|
46
|
+
if (admitted.state === 'deleted')
|
|
47
|
+
return Object.freeze({ id, state: 'deleted', outcome: outcome });
|
|
48
|
+
const { outcome: _outcome, ...rest } = admitted;
|
|
49
|
+
return Object.freeze({ ...rest, ...(outcome === undefined ? {} : { outcome }) });
|
|
50
|
+
};
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
status: (id, accept, request) => status(id, accept, value(id, methods.status, {}, request)),
|
|
53
|
+
async result(id, accept, wait = {}, request) {
|
|
54
|
+
const answer = await value(id, methods.result, { ...wait }, request);
|
|
55
|
+
return outcomeOf(acceptOutput(executionOutcome, answer, 'Execution outcome'), accept);
|
|
56
|
+
},
|
|
57
|
+
async signal(id, name, signalled, request) {
|
|
58
|
+
await value(id, methods.signal, { name, value: signalled }, request);
|
|
59
|
+
},
|
|
60
|
+
cancel: (id, accept, input, request) => status(id, accept, value(id, methods.cancel, { ...input }, request)),
|
|
61
|
+
resume: (id, accept, request) => status(id, accept, value(id, methods.resume, {}, request)),
|
|
62
|
+
async delete(id, request) {
|
|
63
|
+
await value(id, methods.delete, {}, request);
|
|
64
|
+
},
|
|
65
|
+
/** Admit what a durable call answers at once: the Execution it created or recovered. */
|
|
66
|
+
async start(path, input, request) {
|
|
67
|
+
const result = await call(invocation(path, input), options(request));
|
|
68
|
+
if (result.kind !== 'value')
|
|
69
|
+
throw new TypeError('Schema syscall returned a non-value result.');
|
|
70
|
+
const ref = acceptOutput(executionRef, result.value, 'Execution reference');
|
|
71
|
+
return NodeId(ref.id);
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* Wait within the request deadline for the outcome. A wait that lapsed after waiting, while
|
|
75
|
+
* time remains, waits again; a wait a closing process or a gap with no process failed is sent
|
|
76
|
+
* again. Every other end of the wait, or its deadline, leaves the Execution as it is: its
|
|
77
|
+
* status, read next, says where it is, so the caller never loses the Execution.
|
|
78
|
+
*/
|
|
79
|
+
async settle(id, request) {
|
|
80
|
+
const deadline = Date.now() + (options(request).timeoutMs ?? 0);
|
|
81
|
+
while (deadline - Date.now() >= MINIMUM_WAIT_MS) {
|
|
82
|
+
const started = Date.now();
|
|
83
|
+
try {
|
|
84
|
+
await read(deadline, request, (attempt) => value(id, methods.result, { waitMs: attempt.timeoutMs }, attempt));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const pending = error instanceof ResponseError && error.reason?.code === 'EXECUTION_PENDING';
|
|
89
|
+
if (!pending || Date.now() - started < LAPSED_WAIT_MS)
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
/** The status after a wait, read again as `settle` sends its wait again, within the deadline. */
|
|
95
|
+
observe(id, accept, request) {
|
|
96
|
+
const deadline = Date.now() + (options(request).timeoutMs ?? 0);
|
|
97
|
+
return read(deadline, request, (attempt) => status(id, accept, value(id, methods.status, {}, attempt)));
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** The install Methods: a completed outcome carries the result its Protocol owner admits. */
|
|
102
|
+
export function createInstallation(executions) {
|
|
103
|
+
const accept = (input) => {
|
|
104
|
+
if (uninstallOutput.safeParse(input).success) {
|
|
105
|
+
throw new TypeError('The Execution is an uninstall: read it through SchemaApi.uninstallation.');
|
|
106
|
+
}
|
|
107
|
+
return protocolSchema.installation.acceptResult(input);
|
|
108
|
+
};
|
|
109
|
+
return Object.freeze({
|
|
110
|
+
status: (execution, request) => executions.status(execution, accept, request),
|
|
111
|
+
result: (execution, wait, request) => executions.result(execution, accept, wait, request),
|
|
112
|
+
apply: async (execution, command, request) => executions.signal(execution, commandSignal(ordinal(command.index)), Object.freeze({
|
|
113
|
+
kind: 'apply',
|
|
114
|
+
...(command.validation === undefined ? {} : { validation: command.validation }),
|
|
115
|
+
}), request),
|
|
116
|
+
abort: async (execution, attempt, request) => executions.signal(execution, abortSignal(ordinal(attempt)), Object.freeze({ kind: 'abort' }), request),
|
|
117
|
+
cancel: (execution, input = {}, request) => executions.cancel(execution, accept, input, request),
|
|
118
|
+
resume: (execution, request) => executions.resume(execution, accept, request),
|
|
119
|
+
delete: (execution, request) => executions.delete(execution, request),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** The uninstall Methods: a completed outcome carries the receipt Core's contract admits. */
|
|
123
|
+
export function createUninstallation(executions) {
|
|
124
|
+
const accept = acceptUninstallReceipt;
|
|
125
|
+
return Object.freeze({
|
|
126
|
+
status: (execution, request) => executions.status(execution, accept, request),
|
|
127
|
+
result: (execution, wait, request) => executions.result(execution, accept, wait, request),
|
|
128
|
+
cancel: (execution, input = {}, request) => executions.cancel(execution, accept, input, request),
|
|
129
|
+
resume: (execution, request) => executions.resume(execution, accept, request),
|
|
130
|
+
delete: (execution, request) => executions.delete(execution, request),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
export function acceptUninstallReceipt(input) {
|
|
134
|
+
return acceptOutput(uninstallOutput, input, 'uninstall receipt');
|
|
135
|
+
}
|
|
136
|
+
function outcomeOf(outcome, accept) {
|
|
137
|
+
if (outcome.kind !== 'completed')
|
|
138
|
+
return outcome;
|
|
139
|
+
return Object.freeze({ kind: 'completed', value: accept(outcome.value) });
|
|
140
|
+
}
|
|
141
|
+
function ordinal(input) {
|
|
142
|
+
if (!Number.isSafeInteger(input) || input < 1) {
|
|
143
|
+
throw new TypeError('A session signal index is a positive integer.');
|
|
144
|
+
}
|
|
145
|
+
return input;
|
|
146
|
+
}
|
package/dist/schema/schema.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { Key } from '@astrale-os/kernel-dsl/v1';
|
|
|
2
2
|
import * as protocolSchema from '@astrale-os/kernel-protocol/schema';
|
|
3
3
|
import type { Call, Result } from '../client/index.js';
|
|
4
4
|
import type { RequestOptions } from '../transport/index.js';
|
|
5
|
-
import type { InstallRequest,
|
|
5
|
+
import type { Installation, InstallRequest, Uninstallation, UninstallRequest } from './contracts.js';
|
|
6
|
+
import { type InstallationApi, type UninstallationApi } from './installation.js';
|
|
6
7
|
export type SchemaCall = (call: Call, options?: RequestOptions) => Promise<Result>;
|
|
7
8
|
export interface SchemaOptions extends protocolSchema.installation.introspection.Limits {
|
|
8
9
|
readonly lifecycleTimeoutMs?: number;
|
|
@@ -14,8 +15,22 @@ export type InstalledRelease = protocolSchema.installation.introspection.Install
|
|
|
14
15
|
export type InstalledPin = protocolSchema.installation.introspection.InstalledPin;
|
|
15
16
|
export type InstallResult = protocolSchema.installation.InstallResult;
|
|
16
17
|
export interface SchemaApi {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Install Domains: start the durable Execution the install is, then, unless `wait` is false or
|
|
20
|
+
* the mode is `maintenance`, wait within the request deadline for its outcome. The answer names
|
|
21
|
+
* the Execution with its status; `result` is present once it completed. A rejected install is a
|
|
22
|
+
* terminal `failed` status, never a failed call.
|
|
23
|
+
*/
|
|
24
|
+
install(request: InstallRequest, options?: RequestOptions): Promise<Installation>;
|
|
25
|
+
/** The install executions and repair sessions, through their `K.Execution` Methods. */
|
|
26
|
+
readonly installation: InstallationApi;
|
|
27
|
+
/**
|
|
28
|
+
* Uninstall Domains: start the durable Execution the uninstall is and wait within the request
|
|
29
|
+
* deadline for its outcome. `result` is the receipt once it completed.
|
|
30
|
+
*/
|
|
31
|
+
uninstall(request: UninstallRequest, options?: RequestOptions): Promise<Uninstallation>;
|
|
32
|
+
/** The uninstall executions, through their `K.Execution` Methods. */
|
|
33
|
+
readonly uninstallation: UninstallationApi;
|
|
19
34
|
inspect(origin: Key.Origin, options?: RequestOptions): Promise<DomainInfo>;
|
|
20
35
|
bundle(origin: Key.Origin, options?: RequestOptions): Promise<DomainBundle>;
|
|
21
36
|
dependencies(origin: Key.Origin, options?: RequestOptions): Promise<DomainDependencies>;
|
package/dist/schema/schema.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
|
-
import { uninstallOutput } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
3
2
|
import { install, uninstall } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
4
3
|
import * as protocolSchema from '@astrale-os/kernel-protocol/schema';
|
|
5
|
-
import {
|
|
6
|
-
import { acceptOutput } from './admission.js';
|
|
4
|
+
import { acceptUninstallReceipt, createInstallation, createUninstallation, executionMethods, } from './installation.js';
|
|
7
5
|
import { introspect } from './introspection.js';
|
|
8
6
|
const INSTALL_PATH = Path.project(install).raw;
|
|
9
7
|
const UNINSTALL_PATH = Path.project(uninstall).raw;
|
|
@@ -13,34 +11,33 @@ export function createSchema(call, limits) {
|
|
|
13
11
|
if (typeof call !== 'function')
|
|
14
12
|
throw new TypeError('Schema call capability is invalid.');
|
|
15
13
|
const admittedLimits = admitLimits(limits);
|
|
14
|
+
const executions = executionMethods(call, (options) => lifecycleOptions(options, admittedLimits.lifecycleTimeoutMs));
|
|
15
|
+
const installation = createInstallation(executions);
|
|
16
|
+
const uninstallation = createUninstallation(executions);
|
|
16
17
|
return Object.freeze({
|
|
17
18
|
async install(request, options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// `wait` is the Client's own: it never reaches the Kernel, so it is no part of the intent.
|
|
20
|
+
const { wait, ...input } = request;
|
|
21
|
+
const execution = await executions.start(INSTALL_PATH, input, options);
|
|
22
|
+
// A maintenance session awaits Root's commands: its outcome is not the call's to wait for.
|
|
23
|
+
if (wait !== false && input.mode !== 'maintenance') {
|
|
24
|
+
await executions.settle(execution, options);
|
|
21
25
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
? protocolSchema.installation.decode
|
|
25
|
-
: undefined;
|
|
26
|
-
if (decode === undefined) {
|
|
27
|
-
throw new TypeError('Schema install returned an unsupported media type.');
|
|
28
|
-
}
|
|
29
|
-
if (!(result.value.body instanceof Uint8Array)) {
|
|
30
|
-
await result.value.body[Symbol.asyncIterator]().return?.();
|
|
31
|
-
throw new TypeError('Schema install returned a streaming binary result.');
|
|
32
|
-
}
|
|
33
|
-
const decoded = await decode(result.value.body, installationResultLimit(admittedLimits.maximumReleaseBytes, request.domains.length));
|
|
34
|
-
proveInstallResult(request, decoded);
|
|
35
|
-
return decoded;
|
|
26
|
+
const status = await executions.observe(execution, protocolSchema.installation.acceptResult, options);
|
|
27
|
+
return admitInstallation(request, execution, status);
|
|
36
28
|
},
|
|
29
|
+
installation,
|
|
37
30
|
async uninstall(request, options) {
|
|
38
31
|
const snapshot = snapshotUninstallRequest(request);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
const execution = await executions.start(UNINSTALL_PATH, snapshot, options);
|
|
33
|
+
await executions.settle(execution, options);
|
|
34
|
+
const status = await executions.observe(execution, acceptUninstallReceipt, options);
|
|
35
|
+
if (status.outcome?.kind !== 'completed')
|
|
36
|
+
return Object.freeze({ execution, status });
|
|
37
|
+
proveUninstallReceipt(snapshot, status.outcome.value);
|
|
38
|
+
return Object.freeze({ execution, status, result: status.outcome.value });
|
|
43
39
|
},
|
|
40
|
+
uninstallation,
|
|
44
41
|
async inspect(origin, options) {
|
|
45
42
|
return introspect(call, admittedLimits, { kind: 'inspect', origin }, options);
|
|
46
43
|
},
|
|
@@ -75,12 +72,16 @@ function proveUninstallReceipt(request, receipt) {
|
|
|
75
72
|
function compare(left, right) {
|
|
76
73
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
77
74
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
/**
|
|
76
|
+
* The answer of one install, proved against its request: a completed status carries the result of
|
|
77
|
+
* exactly this operation, admitted by its Protocol owner.
|
|
78
|
+
*/
|
|
79
|
+
function admitInstallation(request, execution, status) {
|
|
80
|
+
if (status.outcome?.kind !== 'completed')
|
|
81
|
+
return Object.freeze({ execution, status });
|
|
82
|
+
const result = status.outcome.value;
|
|
83
|
+
proveInstallResult(request, result);
|
|
84
|
+
return Object.freeze({ execution, status, result });
|
|
84
85
|
}
|
|
85
86
|
function proveInstallResult(request, result) {
|
|
86
87
|
if (result.changed) {
|
|
@@ -96,11 +97,6 @@ function proveInstallResult(request, result) {
|
|
|
96
97
|
throw new TypeError('Schema unchanged result does not match the requested Domain count.');
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
function value(result) {
|
|
100
|
-
if (result.kind !== 'value')
|
|
101
|
-
throw new TypeError('Schema syscall returned a non-value result.');
|
|
102
|
-
return result.value;
|
|
103
|
-
}
|
|
104
100
|
function admitLimits(input) {
|
|
105
101
|
const lifecycleTimeoutMs = input?.lifecycleTimeoutMs ?? DEFAULT_SCHEMA_LIFECYCLE_TIMEOUT_MS;
|
|
106
102
|
if (input === null ||
|
package/dist/session/bound.js
CHANGED
|
@@ -36,9 +36,29 @@ export function bindSession(source, controls) {
|
|
|
36
36
|
const bundle = (origin, options) => schemaSource.bundle(origin, controlOptions(options, admittedControls));
|
|
37
37
|
const dependencies = (origin, options) => schemaSource.dependencies(origin, controlOptions(options, admittedControls));
|
|
38
38
|
const installed = (options) => schemaSource.installed(controlOptions(options, admittedControls));
|
|
39
|
+
const installs = schemaSource.installation;
|
|
40
|
+
const installation = Object.freeze({
|
|
41
|
+
status: (execution, options) => installs.status(execution, controlOptions(options, admittedControls)),
|
|
42
|
+
result: (execution, wait, options) => installs.result(execution, wait, controlOptions(options, admittedControls)),
|
|
43
|
+
apply: (execution, command, options) => installs.apply(execution, command, controlOptions(options, admittedControls)),
|
|
44
|
+
abort: (execution, attempt, options) => installs.abort(execution, attempt, controlOptions(options, admittedControls)),
|
|
45
|
+
cancel: (execution, input, options) => installs.cancel(execution, input, controlOptions(options, admittedControls)),
|
|
46
|
+
resume: (execution, options) => installs.resume(execution, controlOptions(options, admittedControls)),
|
|
47
|
+
delete: (execution, options) => installs.delete(execution, controlOptions(options, admittedControls)),
|
|
48
|
+
});
|
|
49
|
+
const uninstalls = schemaSource.uninstallation;
|
|
50
|
+
const uninstallation = Object.freeze({
|
|
51
|
+
status: (execution, options) => uninstalls.status(execution, controlOptions(options, admittedControls)),
|
|
52
|
+
result: (execution, wait, options) => uninstalls.result(execution, wait, controlOptions(options, admittedControls)),
|
|
53
|
+
cancel: (execution, input, options) => uninstalls.cancel(execution, input, controlOptions(options, admittedControls)),
|
|
54
|
+
resume: (execution, options) => uninstalls.resume(execution, controlOptions(options, admittedControls)),
|
|
55
|
+
delete: (execution, options) => uninstalls.delete(execution, controlOptions(options, admittedControls)),
|
|
56
|
+
});
|
|
39
57
|
const schema = Object.freeze({
|
|
40
58
|
install,
|
|
59
|
+
installation,
|
|
41
60
|
uninstall,
|
|
61
|
+
uninstallation,
|
|
42
62
|
inspect,
|
|
43
63
|
bundle,
|
|
44
64
|
dependencies,
|
|
@@ -106,9 +126,31 @@ function capture(source, key) {
|
|
|
106
126
|
function captureSchema(input) {
|
|
107
127
|
if (input === null || typeof input !== 'object')
|
|
108
128
|
invalid();
|
|
129
|
+
const installation = input.installation;
|
|
130
|
+
if (installation === null || typeof installation !== 'object')
|
|
131
|
+
invalid();
|
|
132
|
+
const uninstallation = input.uninstallation;
|
|
133
|
+
if (uninstallation === null || typeof uninstallation !== 'object')
|
|
134
|
+
invalid();
|
|
109
135
|
return Object.freeze({
|
|
110
136
|
install: capture(input, 'install'),
|
|
137
|
+
installation: Object.freeze({
|
|
138
|
+
status: capture(installation, 'status'),
|
|
139
|
+
result: capture(installation, 'result'),
|
|
140
|
+
apply: capture(installation, 'apply'),
|
|
141
|
+
abort: capture(installation, 'abort'),
|
|
142
|
+
cancel: capture(installation, 'cancel'),
|
|
143
|
+
resume: capture(installation, 'resume'),
|
|
144
|
+
delete: capture(installation, 'delete'),
|
|
145
|
+
}),
|
|
111
146
|
uninstall: capture(input, 'uninstall'),
|
|
147
|
+
uninstallation: Object.freeze({
|
|
148
|
+
status: capture(uninstallation, 'status'),
|
|
149
|
+
result: capture(uninstallation, 'result'),
|
|
150
|
+
cancel: capture(uninstallation, 'cancel'),
|
|
151
|
+
resume: capture(uninstallation, 'resume'),
|
|
152
|
+
delete: capture(uninstallation, 'delete'),
|
|
153
|
+
}),
|
|
112
154
|
inspect: capture(input, 'inspect'),
|
|
113
155
|
bundle: capture(input, 'bundle'),
|
|
114
156
|
dependencies: capture(input, 'dependencies'),
|
|
@@ -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
|
-
|
|
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
|
/**
|
package/dist/session/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -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.');
|
package/dist/store/memory.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-client",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
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": "1.0.0-beta.
|
|
68
|
+
"@astrale-os/kernel-core": "1.0.0-beta.5",
|
|
69
69
|
"@astrale-os/kernel-dsl": "1.0.0-beta.3",
|
|
70
|
-
"@astrale-os/kernel-protocol": "1.0.0-beta.
|
|
70
|
+
"@astrale-os/kernel-protocol": "1.0.0-beta.5",
|
|
71
71
|
"@tanstack/pacer": "0.20.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@astrale-os/kernel-server": "1.0.0-beta.
|
|
74
|
+
"@astrale-os/kernel-server": "1.0.0-beta.5",
|
|
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",
|