nawabari 0.8.0 → 0.9.2
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/README.md +35 -0
- package/dist/cli-command-registry.d.ts +6 -0
- package/dist/cli-command-registry.js +26 -5
- package/dist/cli-command-registry.js.map +1 -1
- package/dist/cli.js +70 -8
- package/dist/cli.js.map +1 -1
- package/dist/contract.js +35 -0
- package/dist/contract.js.map +1 -1
- package/dist/domain/doctor.js +44 -0
- package/dist/domain/doctor.js.map +1 -1
- package/dist/domain/session-backend.d.ts +2 -1
- package/dist/domain/session-backend.js +119 -18
- package/dist/domain/session-backend.js.map +1 -1
- package/dist/domain/session.d.ts +100 -19
- package/dist/domain/session.js.map +1 -1
- package/dist/product-state-manifest.d.ts +152 -0
- package/dist/product-state-manifest.js +240 -0
- package/dist/product-state-manifest.js.map +1 -0
- package/dist/public-contract.d.ts +25 -0
- package/dist/public-contract.js +29 -0
- package/dist/public-contract.js.map +1 -0
- package/dist/public-state.d.ts +75 -0
- package/dist/public-state.js +60 -0
- package/dist/public-state.js.map +1 -0
- package/dist/session-lifecycle-actions.d.ts +4 -3
- package/dist/session-lifecycle-actions.js +14 -5
- package/dist/session-lifecycle-actions.js.map +1 -1
- package/dist/session-lifecycle-classification.d.ts +55 -2
- package/dist/session-lifecycle-classification.js +39 -306
- package/dist/session-lifecycle-classification.js.map +1 -1
- package/dist/session-registry.d.ts +83 -1
- package/dist/session-registry.js +440 -21
- package/dist/session-registry.js.map +1 -1
- package/dist/state/index.d.ts +5 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/session/actors.d.ts +71 -0
- package/dist/state/session/actors.js +259 -0
- package/dist/state/session/actors.js.map +1 -0
- package/dist/state/session/guards.d.ts +25 -0
- package/dist/state/session/guards.js +108 -0
- package/dist/state/session/guards.js.map +1 -0
- package/dist/state/session/index.d.ts +6 -0
- package/dist/state/session/index.js +5 -0
- package/dist/state/session/index.js.map +1 -0
- package/dist/state/session/machine.d.ts +185 -0
- package/dist/state/session/machine.js +408 -0
- package/dist/state/session/machine.js.map +1 -0
- package/dist/state/session/types.d.ts +94 -0
- package/dist/state/session/types.js +14 -0
- package/dist/state/session/types.js.map +1 -0
- package/package.json +26 -6
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-neutral Nawabari Product State Manifest projection.
|
|
3
|
+
*
|
|
4
|
+
* The manifest is an output of the existing public state and machine-contract
|
|
5
|
+
* projections. It is not a lifecycle authority: it does not create a machine,
|
|
6
|
+
* accept an event, observe a repository, or execute a command. In particular,
|
|
7
|
+
* internal XState event names, state-node ids, context, and snapshots are not
|
|
8
|
+
* part of this module's public shape.
|
|
9
|
+
*/
|
|
10
|
+
import { MACHINE_CONTRACT_ID, MACHINE_CONTRACT_SCHEMA_VERSION, NAWABARI_CONTRACT_API_SCHEMA_VERSION } from "./public-contract.js";
|
|
11
|
+
import type { NawabariCommand, NawabariLifecycleState, NawabariTransitionDecision, NawabariTransitionDecisionProjection } from "./public-state.js";
|
|
12
|
+
export declare const NAWABARI_PRODUCT_STATE_MANIFEST_SCHEMA_VERSION: 1;
|
|
13
|
+
export declare const NAWABARI_PRODUCT_STATE_MANIFEST_ID: "nawabari.product-state-manifest.v1";
|
|
14
|
+
export declare const NAWABARI_PRODUCT_ID: "nawabari";
|
|
15
|
+
export declare const NAWABARI_SESSION_ACTOR_ID: "nawabari.session";
|
|
16
|
+
export declare const NAWABARI_SESSION_LIFECYCLE_SCHEMA_ID: "nawabari.session-lifecycle.v1";
|
|
17
|
+
export declare const NAWABARI_SESSION_COMMAND_SCHEMA_ID: "nawabari.session-command.v1";
|
|
18
|
+
export type NawabariManifestVersionedIdentity = {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly version: number;
|
|
21
|
+
};
|
|
22
|
+
type NawabariManifestReason = NawabariTransitionDecision["reason"];
|
|
23
|
+
export type NawabariManifestAuthoritySource = {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly kind: "executable" | "public-projection" | "contract-projection";
|
|
26
|
+
readonly module: string;
|
|
27
|
+
};
|
|
28
|
+
export type NawabariManifestParticipant = {
|
|
29
|
+
readonly product_id: string;
|
|
30
|
+
readonly actor_id: string;
|
|
31
|
+
readonly role: "producer" | "consumer";
|
|
32
|
+
/** Null means the independent caller has not supplied a contract identity. */
|
|
33
|
+
readonly contract: NawabariManifestVersionedIdentity | null;
|
|
34
|
+
};
|
|
35
|
+
export type NawabariManifestCorrelation = {
|
|
36
|
+
readonly mode: "session-scoped" | "not-applicable";
|
|
37
|
+
readonly field: "session_id" | null;
|
|
38
|
+
readonly required: boolean;
|
|
39
|
+
readonly authority: string;
|
|
40
|
+
};
|
|
41
|
+
export type NawabariManifestIdempotency = {
|
|
42
|
+
readonly mode: "not-declared" | "not-applicable";
|
|
43
|
+
readonly key: string | null;
|
|
44
|
+
readonly required: boolean;
|
|
45
|
+
readonly authority: string;
|
|
46
|
+
};
|
|
47
|
+
export type NawabariManifestUnconditionalTransition = {
|
|
48
|
+
readonly source_state: NawabariLifecycleState;
|
|
49
|
+
readonly command: NawabariCommand;
|
|
50
|
+
readonly guarded: false;
|
|
51
|
+
readonly allowed: boolean;
|
|
52
|
+
readonly target: NawabariLifecycleState | null;
|
|
53
|
+
readonly requires_explicit_intent: boolean;
|
|
54
|
+
readonly authority: NawabariTransitionDecisionProjection["authority"];
|
|
55
|
+
readonly reason: NawabariManifestReason;
|
|
56
|
+
};
|
|
57
|
+
export type NawabariManifestGuardedTransition = {
|
|
58
|
+
readonly source_state: NawabariLifecycleState;
|
|
59
|
+
readonly command: NawabariCommand;
|
|
60
|
+
readonly guarded: true;
|
|
61
|
+
readonly requires_explicit_intent: boolean;
|
|
62
|
+
readonly authority: NawabariTransitionDecisionProjection["authority"];
|
|
63
|
+
readonly when_guard_accepts: {
|
|
64
|
+
readonly allowed: true;
|
|
65
|
+
readonly target: NawabariLifecycleState;
|
|
66
|
+
readonly reason: NawabariManifestReason;
|
|
67
|
+
};
|
|
68
|
+
readonly when_guard_rejects: {
|
|
69
|
+
readonly allowed: false;
|
|
70
|
+
readonly target: null;
|
|
71
|
+
readonly reason: NawabariManifestReason;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export type NawabariManifestTransition = NawabariManifestUnconditionalTransition | NawabariManifestGuardedTransition;
|
|
75
|
+
export type NawabariManifestAcceptedCommand = {
|
|
76
|
+
readonly id: NawabariCommand;
|
|
77
|
+
/** Public-state vocabulary; deliberately not a raw XState event name. */
|
|
78
|
+
readonly public_name: NawabariCommand;
|
|
79
|
+
readonly kind: "command";
|
|
80
|
+
readonly schema: NawabariManifestVersionedIdentity;
|
|
81
|
+
readonly producers: readonly NawabariManifestParticipant[];
|
|
82
|
+
readonly consumers: readonly NawabariManifestParticipant[];
|
|
83
|
+
readonly correlation: NawabariManifestCorrelation;
|
|
84
|
+
readonly idempotency: NawabariManifestIdempotency;
|
|
85
|
+
};
|
|
86
|
+
export type NawabariManifestEmittedEvent = {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly schema: NawabariManifestVersionedIdentity;
|
|
89
|
+
readonly producers: readonly NawabariManifestParticipant[];
|
|
90
|
+
readonly consumers: readonly NawabariManifestParticipant[];
|
|
91
|
+
readonly correlation: NawabariManifestCorrelation;
|
|
92
|
+
readonly idempotency: NawabariManifestIdempotency;
|
|
93
|
+
};
|
|
94
|
+
export type NawabariManifestEmittedEvents = {
|
|
95
|
+
/** No emitted cross-product event is currently exposed by Nawabari. */
|
|
96
|
+
readonly status: "not-exposed";
|
|
97
|
+
readonly schema: NawabariManifestVersionedIdentity | null;
|
|
98
|
+
readonly events: readonly NawabariManifestEmittedEvent[];
|
|
99
|
+
readonly producers: readonly NawabariManifestParticipant[];
|
|
100
|
+
readonly consumers: readonly NawabariManifestParticipant[];
|
|
101
|
+
};
|
|
102
|
+
export type NawabariManifestActor = {
|
|
103
|
+
readonly id: typeof NAWABARI_SESSION_ACTOR_ID;
|
|
104
|
+
readonly product_id: typeof NAWABARI_PRODUCT_ID;
|
|
105
|
+
readonly kind: "session";
|
|
106
|
+
readonly state: {
|
|
107
|
+
readonly schema: NawabariManifestVersionedIdentity;
|
|
108
|
+
readonly states: readonly NawabariLifecycleState[];
|
|
109
|
+
readonly transitions: readonly NawabariManifestTransition[];
|
|
110
|
+
readonly authority: "public-state-projection";
|
|
111
|
+
};
|
|
112
|
+
readonly accepted_commands: readonly NawabariManifestAcceptedCommand[];
|
|
113
|
+
readonly emitted_events: NawabariManifestEmittedEvents;
|
|
114
|
+
};
|
|
115
|
+
export interface NawabariProductStateManifest {
|
|
116
|
+
readonly manifest_id: typeof NAWABARI_PRODUCT_STATE_MANIFEST_ID;
|
|
117
|
+
readonly schema_version: typeof NAWABARI_PRODUCT_STATE_MANIFEST_SCHEMA_VERSION;
|
|
118
|
+
readonly product: {
|
|
119
|
+
readonly id: typeof NAWABARI_PRODUCT_ID;
|
|
120
|
+
readonly name: "Nawabari";
|
|
121
|
+
readonly package_name: "nawabari";
|
|
122
|
+
readonly package_version: string;
|
|
123
|
+
};
|
|
124
|
+
readonly public_contract: {
|
|
125
|
+
readonly contract_id: typeof MACHINE_CONTRACT_ID;
|
|
126
|
+
readonly schema_version: typeof MACHINE_CONTRACT_SCHEMA_VERSION;
|
|
127
|
+
readonly api_schema_version: typeof NAWABARI_CONTRACT_API_SCHEMA_VERSION;
|
|
128
|
+
};
|
|
129
|
+
readonly authority: {
|
|
130
|
+
readonly model: "projection";
|
|
131
|
+
readonly source_of_truth: readonly NawabariManifestAuthoritySource[];
|
|
132
|
+
readonly output_role: "generated-artifact";
|
|
133
|
+
};
|
|
134
|
+
readonly composition: {
|
|
135
|
+
readonly participant_schema: NawabariManifestVersionedIdentity;
|
|
136
|
+
readonly connection_model: "independent-product-actors";
|
|
137
|
+
readonly transport: "adapter-owned";
|
|
138
|
+
};
|
|
139
|
+
readonly actors: readonly NawabariManifestActor[];
|
|
140
|
+
}
|
|
141
|
+
/** Generate the deterministic public manifest for the installed package version. */
|
|
142
|
+
export declare function generateNawabariProductStateManifest(packageVersion?: string): NawabariProductStateManifest;
|
|
143
|
+
/** Naming parallel to `nawabariMachineContract`; both return the same projection. */
|
|
144
|
+
export declare const nawabariProductStateManifest: typeof generateNawabariProductStateManifest;
|
|
145
|
+
/** Stable byte representation for checked-in/generated artifacts. */
|
|
146
|
+
export declare function serializeNawabariProductStateManifest(manifest?: NawabariProductStateManifest): string;
|
|
147
|
+
/**
|
|
148
|
+
* Render a deterministic Mermaid state diagram from manifest data. The
|
|
149
|
+
* manifest is the input boundary; this renderer contains no lifecycle graph.
|
|
150
|
+
*/
|
|
151
|
+
export declare function renderNawabariSessionLifecycleDiagram(manifest?: NawabariProductStateManifest): string;
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-neutral Nawabari Product State Manifest projection.
|
|
3
|
+
*
|
|
4
|
+
* The manifest is an output of the existing public state and machine-contract
|
|
5
|
+
* projections. It is not a lifecycle authority: it does not create a machine,
|
|
6
|
+
* accept an event, observe a repository, or execute a command. In particular,
|
|
7
|
+
* internal XState event names, state-node ids, context, and snapshots are not
|
|
8
|
+
* part of this module's public shape.
|
|
9
|
+
*/
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
|
+
import { MACHINE_CONTRACT_ID, MACHINE_CONTRACT_SCHEMA_VERSION, NAWABARI_CONTRACT_API_SCHEMA_VERSION, nawabariMachineContract, } from "./public-contract.js";
|
|
12
|
+
import { NAWABARI_LIFECYCLE_STATES, NAWABARI_STATE_API_SCHEMA_VERSION, NAWABARI_TRANSITION_TABLE, } from "./public-state.js";
|
|
13
|
+
import { SESSION_LIFECYCLE_CLASSIFICATION_SCHEMA_VERSION } from "./session-lifecycle-classification.js";
|
|
14
|
+
const installedPackageMetadata = createRequire(import.meta.url)("../package.json");
|
|
15
|
+
export const NAWABARI_PRODUCT_STATE_MANIFEST_SCHEMA_VERSION = 1;
|
|
16
|
+
export const NAWABARI_PRODUCT_STATE_MANIFEST_ID = "nawabari.product-state-manifest.v1";
|
|
17
|
+
export const NAWABARI_PRODUCT_ID = "nawabari";
|
|
18
|
+
export const NAWABARI_SESSION_ACTOR_ID = "nawabari.session";
|
|
19
|
+
export const NAWABARI_SESSION_LIFECYCLE_SCHEMA_ID = "nawabari.session-lifecycle.v1";
|
|
20
|
+
export const NAWABARI_SESSION_COMMAND_SCHEMA_ID = "nawabari.session-command.v1";
|
|
21
|
+
const SOURCE_OF_TRUTH = Object.freeze([
|
|
22
|
+
Object.freeze({
|
|
23
|
+
id: "session-lifecycle-machine",
|
|
24
|
+
kind: "executable",
|
|
25
|
+
module: "src/state/session/machine.ts",
|
|
26
|
+
}),
|
|
27
|
+
Object.freeze({
|
|
28
|
+
id: "public-state-lifecycle-projection",
|
|
29
|
+
kind: "public-projection",
|
|
30
|
+
module: "src/public-state.ts",
|
|
31
|
+
}),
|
|
32
|
+
Object.freeze({
|
|
33
|
+
id: "machine-contract-projection",
|
|
34
|
+
kind: "contract-projection",
|
|
35
|
+
module: "src/contract.ts",
|
|
36
|
+
}),
|
|
37
|
+
Object.freeze({
|
|
38
|
+
id: "public-contract-package-boundary",
|
|
39
|
+
kind: "public-projection",
|
|
40
|
+
module: "src/public-contract.ts",
|
|
41
|
+
}),
|
|
42
|
+
]);
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45
|
+
}
|
|
46
|
+
function lifecycleCapability(contract) {
|
|
47
|
+
if (!Array.isArray(contract.capabilities)) {
|
|
48
|
+
throw new Error("Nawabari machine contract has no capability inventory");
|
|
49
|
+
}
|
|
50
|
+
const capability = contract.capabilities.find((candidate) => isRecord(candidate) && candidate.id === "session-diagnostics");
|
|
51
|
+
if (!isRecord(capability) || !isRecord(capability.lifecycle)) {
|
|
52
|
+
throw new Error("Nawabari machine contract has no session lifecycle projection");
|
|
53
|
+
}
|
|
54
|
+
return capability.lifecycle;
|
|
55
|
+
}
|
|
56
|
+
function assertContractProjectionParity(contract) {
|
|
57
|
+
const lifecycle = lifecycleCapability(contract);
|
|
58
|
+
const publicStates = [...NAWABARI_LIFECYCLE_STATES];
|
|
59
|
+
const publicTransitions = NAWABARI_TRANSITION_TABLE;
|
|
60
|
+
if (JSON.stringify(lifecycle.states) !== JSON.stringify(publicStates)) {
|
|
61
|
+
throw new Error("Nawabari Product State Manifest source projections disagree on lifecycle states");
|
|
62
|
+
}
|
|
63
|
+
if (JSON.stringify(lifecycle.transition_table) !== JSON.stringify(publicTransitions)) {
|
|
64
|
+
throw new Error("Nawabari Product State Manifest source projections disagree on lifecycle transitions");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function projectTransition(sourceState, transition) {
|
|
68
|
+
if (transition.guarded) {
|
|
69
|
+
return Object.freeze({
|
|
70
|
+
source_state: sourceState,
|
|
71
|
+
command: transition.operation,
|
|
72
|
+
guarded: true,
|
|
73
|
+
requires_explicit_intent: transition.requiresExplicitIntent,
|
|
74
|
+
authority: transition.authority,
|
|
75
|
+
when_guard_accepts: Object.freeze({
|
|
76
|
+
allowed: true,
|
|
77
|
+
target: transition.whenGuardAccepts.target,
|
|
78
|
+
reason: transition.whenGuardAccepts.reason,
|
|
79
|
+
}),
|
|
80
|
+
when_guard_rejects: Object.freeze({
|
|
81
|
+
allowed: false,
|
|
82
|
+
target: null,
|
|
83
|
+
reason: transition.whenGuardRejects.reason,
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return Object.freeze({
|
|
88
|
+
source_state: sourceState,
|
|
89
|
+
command: transition.operation,
|
|
90
|
+
guarded: false,
|
|
91
|
+
allowed: transition.allowed,
|
|
92
|
+
target: transition.target,
|
|
93
|
+
requires_explicit_intent: transition.requiresExplicitIntent,
|
|
94
|
+
authority: transition.authority,
|
|
95
|
+
reason: transition.reason,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function projectTransitions() {
|
|
99
|
+
return Object.freeze(NAWABARI_LIFECYCLE_STATES.flatMap((state) => NAWABARI_TRANSITION_TABLE[state].map((transition) => projectTransition(state, transition))));
|
|
100
|
+
}
|
|
101
|
+
function uniqueCommands(transitions) {
|
|
102
|
+
const commands = [];
|
|
103
|
+
for (const transition of transitions) {
|
|
104
|
+
if (!commands.includes(transition.command))
|
|
105
|
+
commands.push(transition.command);
|
|
106
|
+
}
|
|
107
|
+
return Object.freeze(commands);
|
|
108
|
+
}
|
|
109
|
+
function participant(productId, actorId, role, contract) {
|
|
110
|
+
return Object.freeze({
|
|
111
|
+
product_id: productId,
|
|
112
|
+
actor_id: actorId,
|
|
113
|
+
role,
|
|
114
|
+
contract: contract === null ? null : Object.freeze({ ...contract }),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function acceptedCommand(command) {
|
|
118
|
+
return Object.freeze({
|
|
119
|
+
id: command,
|
|
120
|
+
public_name: command,
|
|
121
|
+
kind: "command",
|
|
122
|
+
schema: Object.freeze({ id: NAWABARI_SESSION_COMMAND_SCHEMA_ID, version: NAWABARI_STATE_API_SCHEMA_VERSION }),
|
|
123
|
+
producers: Object.freeze([participant("external", "caller", "producer", null)]),
|
|
124
|
+
consumers: Object.freeze([
|
|
125
|
+
participant("nawabari", NAWABARI_SESSION_ACTOR_ID, "consumer", {
|
|
126
|
+
id: MACHINE_CONTRACT_ID,
|
|
127
|
+
version: MACHINE_CONTRACT_SCHEMA_VERSION,
|
|
128
|
+
}),
|
|
129
|
+
]),
|
|
130
|
+
correlation: Object.freeze({
|
|
131
|
+
mode: "session-scoped",
|
|
132
|
+
field: "session_id",
|
|
133
|
+
required: false,
|
|
134
|
+
authority: "public-state observation boundary",
|
|
135
|
+
}),
|
|
136
|
+
idempotency: Object.freeze({
|
|
137
|
+
mode: "not-declared",
|
|
138
|
+
key: null,
|
|
139
|
+
required: false,
|
|
140
|
+
authority: "existing command/runtime contract",
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function emittedEvents() {
|
|
145
|
+
return Object.freeze({
|
|
146
|
+
status: "not-exposed",
|
|
147
|
+
schema: null,
|
|
148
|
+
events: Object.freeze([]),
|
|
149
|
+
producers: Object.freeze([]),
|
|
150
|
+
consumers: Object.freeze([]),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** Generate the deterministic public manifest for the installed package version. */
|
|
154
|
+
export function generateNawabariProductStateManifest(packageVersion = installedPackageMetadata.version) {
|
|
155
|
+
const contract = nawabariMachineContract(packageVersion);
|
|
156
|
+
assertContractProjectionParity(contract);
|
|
157
|
+
const transitions = projectTransitions();
|
|
158
|
+
const commands = uniqueCommands(transitions);
|
|
159
|
+
const actor = Object.freeze({
|
|
160
|
+
id: NAWABARI_SESSION_ACTOR_ID,
|
|
161
|
+
product_id: NAWABARI_PRODUCT_ID,
|
|
162
|
+
kind: "session",
|
|
163
|
+
state: Object.freeze({
|
|
164
|
+
schema: Object.freeze({
|
|
165
|
+
id: NAWABARI_SESSION_LIFECYCLE_SCHEMA_ID,
|
|
166
|
+
version: SESSION_LIFECYCLE_CLASSIFICATION_SCHEMA_VERSION,
|
|
167
|
+
}),
|
|
168
|
+
states: Object.freeze([...NAWABARI_LIFECYCLE_STATES]),
|
|
169
|
+
transitions,
|
|
170
|
+
authority: "public-state-projection",
|
|
171
|
+
}),
|
|
172
|
+
accepted_commands: Object.freeze(commands.map(acceptedCommand)),
|
|
173
|
+
emitted_events: emittedEvents(),
|
|
174
|
+
});
|
|
175
|
+
return Object.freeze({
|
|
176
|
+
manifest_id: NAWABARI_PRODUCT_STATE_MANIFEST_ID,
|
|
177
|
+
schema_version: NAWABARI_PRODUCT_STATE_MANIFEST_SCHEMA_VERSION,
|
|
178
|
+
product: Object.freeze({
|
|
179
|
+
id: NAWABARI_PRODUCT_ID,
|
|
180
|
+
name: "Nawabari",
|
|
181
|
+
package_name: "nawabari",
|
|
182
|
+
package_version: packageVersion,
|
|
183
|
+
}),
|
|
184
|
+
public_contract: Object.freeze({
|
|
185
|
+
contract_id: MACHINE_CONTRACT_ID,
|
|
186
|
+
schema_version: MACHINE_CONTRACT_SCHEMA_VERSION,
|
|
187
|
+
api_schema_version: NAWABARI_CONTRACT_API_SCHEMA_VERSION,
|
|
188
|
+
}),
|
|
189
|
+
authority: Object.freeze({
|
|
190
|
+
model: "projection",
|
|
191
|
+
source_of_truth: SOURCE_OF_TRUTH,
|
|
192
|
+
output_role: "generated-artifact",
|
|
193
|
+
}),
|
|
194
|
+
composition: Object.freeze({
|
|
195
|
+
participant_schema: Object.freeze({ id: "nawabari.product-participant.v1", version: 1 }),
|
|
196
|
+
connection_model: "independent-product-actors",
|
|
197
|
+
transport: "adapter-owned",
|
|
198
|
+
}),
|
|
199
|
+
actors: Object.freeze([actor]),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/** Naming parallel to `nawabariMachineContract`; both return the same projection. */
|
|
203
|
+
export const nawabariProductStateManifest = generateNawabariProductStateManifest;
|
|
204
|
+
/** Stable byte representation for checked-in/generated artifacts. */
|
|
205
|
+
export function serializeNawabariProductStateManifest(manifest = generateNawabariProductStateManifest()) {
|
|
206
|
+
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
207
|
+
}
|
|
208
|
+
function diagramStateId(state) {
|
|
209
|
+
return state.replace(/[^A-Za-z0-9_]/gu, "_");
|
|
210
|
+
}
|
|
211
|
+
function diagramTransitionLines(transition) {
|
|
212
|
+
const source = diagramStateId(transition.source_state);
|
|
213
|
+
if (transition.guarded) {
|
|
214
|
+
return [
|
|
215
|
+
` ${source} --> ${diagramStateId(transition.when_guard_accepts.target)} : ${transition.command} [guard accepts]`,
|
|
216
|
+
` %% ${transition.source_state} -- ${transition.command} [guard rejects] --> no public transition (${transition.when_guard_rejects.reason})`,
|
|
217
|
+
];
|
|
218
|
+
}
|
|
219
|
+
if (!transition.allowed || transition.target === null) {
|
|
220
|
+
return [` %% ${transition.source_state} -- ${transition.command} --> no public transition (${transition.reason})`];
|
|
221
|
+
}
|
|
222
|
+
return [` ${source} --> ${diagramStateId(transition.target)} : ${transition.command}`];
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Render a deterministic Mermaid state diagram from manifest data. The
|
|
226
|
+
* manifest is the input boundary; this renderer contains no lifecycle graph.
|
|
227
|
+
*/
|
|
228
|
+
export function renderNawabariSessionLifecycleDiagram(manifest = generateNawabariProductStateManifest()) {
|
|
229
|
+
const actor = manifest.actors.find((candidate) => candidate.id === NAWABARI_SESSION_ACTOR_ID);
|
|
230
|
+
if (actor === undefined)
|
|
231
|
+
throw new Error(`Manifest is missing actor ${NAWABARI_SESSION_ACTOR_ID}`);
|
|
232
|
+
const lines = ["%% Generated from Nawabari Product State Manifest; do not edit.", "stateDiagram-v2"];
|
|
233
|
+
for (const state of actor.state.states) {
|
|
234
|
+
lines.push(` state "${state}" as ${diagramStateId(state)}`);
|
|
235
|
+
}
|
|
236
|
+
for (const transition of actor.state.transitions)
|
|
237
|
+
lines.push(...diagramTransitionLines(transition));
|
|
238
|
+
return `${lines.join("\n")}\n`;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=product-state-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-state-manifest.js","sourceRoot":"","sources":["../src/product-state-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAC/B,oCAAoC,EACpC,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,+CAA+C,EAAE,MAAM,uCAAuC,CAAC;AAExG,MAAM,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,i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AAU,CAAC,CAAC,CAAC;IACpG,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, transport-neutral package boundary for Nawabari machine-contract
|
|
3
|
+
* discovery (#257; see docs/architecture/xstate-state-architecture.md,
|
|
4
|
+
* "Public library boundary").
|
|
5
|
+
*
|
|
6
|
+
* This module lets a cross-product caller discover the installed package's
|
|
7
|
+
* versioned capability inventory, result-schema mappings, failure-code
|
|
8
|
+
* vocabulary, and public session-lifecycle projection (#256) without
|
|
9
|
+
* spawning the CLI's `capabilities --json` command and parsing its output.
|
|
10
|
+
* It is a thin, version-defaulted wrapper over the existing `contract.ts`
|
|
11
|
+
* projection; it introduces no independent contract authority.
|
|
12
|
+
*/
|
|
13
|
+
import type { JsonObject } from "./domain/errors.js";
|
|
14
|
+
import { machineContract, MACHINE_CONTRACT_ID, MACHINE_CONTRACT_SCHEMA_VERSION, REGISTRY_LOCK_RECOVERY_CONTRACT_ID, REGISTRY_LOCK_RECOVERY_CONTRACT_VERSION, RESOURCE_CLAIM_MACHINE_CONTRACT_ID, RESOURCE_CLAIM_MACHINE_CONTRACT_VERSION, RESOURCE_CLAIM_RECOVERY_SCHEMA, RESOURCE_CLAIM_RESULT_SCHEMA, RESOURCE_CLAIM_TRANSITION_MATRIX_ID } from "./contract.js";
|
|
15
|
+
export { machineContract, MACHINE_CONTRACT_ID, MACHINE_CONTRACT_SCHEMA_VERSION, REGISTRY_LOCK_RECOVERY_CONTRACT_ID, REGISTRY_LOCK_RECOVERY_CONTRACT_VERSION, RESOURCE_CLAIM_MACHINE_CONTRACT_ID, RESOURCE_CLAIM_MACHINE_CONTRACT_VERSION, RESOURCE_CLAIM_RECOVERY_SCHEMA, RESOURCE_CLAIM_RESULT_SCHEMA, RESOURCE_CLAIM_TRANSITION_MATRIX_ID, };
|
|
16
|
+
/** Schema generation for this public contract-discovery API module itself. */
|
|
17
|
+
export declare const NAWABARI_CONTRACT_API_SCHEMA_VERSION: 1;
|
|
18
|
+
/**
|
|
19
|
+
* Discover the installed Nawabari package's machine contract: capability
|
|
20
|
+
* inventory, result-schema mappings, failure-code vocabulary, and the
|
|
21
|
+
* XState-derived public session-lifecycle projection. Defaults to the
|
|
22
|
+
* installed package's own version; pass an explicit version only to
|
|
23
|
+
* describe a different generation of this same contract shape.
|
|
24
|
+
*/
|
|
25
|
+
export declare function nawabariMachineContract(packageVersion?: string): JsonObject;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, transport-neutral package boundary for Nawabari machine-contract
|
|
3
|
+
* discovery (#257; see docs/architecture/xstate-state-architecture.md,
|
|
4
|
+
* "Public library boundary").
|
|
5
|
+
*
|
|
6
|
+
* This module lets a cross-product caller discover the installed package's
|
|
7
|
+
* versioned capability inventory, result-schema mappings, failure-code
|
|
8
|
+
* vocabulary, and public session-lifecycle projection (#256) without
|
|
9
|
+
* spawning the CLI's `capabilities --json` command and parsing its output.
|
|
10
|
+
* It is a thin, version-defaulted wrapper over the existing `contract.ts`
|
|
11
|
+
* projection; it introduces no independent contract authority.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { machineContract, MACHINE_CONTRACT_ID, MACHINE_CONTRACT_SCHEMA_VERSION, REGISTRY_LOCK_RECOVERY_CONTRACT_ID, REGISTRY_LOCK_RECOVERY_CONTRACT_VERSION, RESOURCE_CLAIM_MACHINE_CONTRACT_ID, RESOURCE_CLAIM_MACHINE_CONTRACT_VERSION, RESOURCE_CLAIM_RECOVERY_SCHEMA, RESOURCE_CLAIM_RESULT_SCHEMA, RESOURCE_CLAIM_TRANSITION_MATRIX_ID, } from "./contract.js";
|
|
15
|
+
export { machineContract, MACHINE_CONTRACT_ID, MACHINE_CONTRACT_SCHEMA_VERSION, REGISTRY_LOCK_RECOVERY_CONTRACT_ID, REGISTRY_LOCK_RECOVERY_CONTRACT_VERSION, RESOURCE_CLAIM_MACHINE_CONTRACT_ID, RESOURCE_CLAIM_MACHINE_CONTRACT_VERSION, RESOURCE_CLAIM_RECOVERY_SCHEMA, RESOURCE_CLAIM_RESULT_SCHEMA, RESOURCE_CLAIM_TRANSITION_MATRIX_ID, };
|
|
16
|
+
/** Schema generation for this public contract-discovery API module itself. */
|
|
17
|
+
export const NAWABARI_CONTRACT_API_SCHEMA_VERSION = 1;
|
|
18
|
+
const installedPackageMetadata = createRequire(import.meta.url)("../package.json");
|
|
19
|
+
/**
|
|
20
|
+
* Discover the installed Nawabari package's machine contract: capability
|
|
21
|
+
* inventory, result-schema mappings, failure-code vocabulary, and the
|
|
22
|
+
* XState-derived public session-lifecycle projection. Defaults to the
|
|
23
|
+
* installed package's own version; pass an explicit version only to
|
|
24
|
+
* describe a different generation of this same contract shape.
|
|
25
|
+
*/
|
|
26
|
+
export function nawabariMachineContract(packageVersion = installedPackageMetadata.version) {
|
|
27
|
+
return machineContract(packageVersion);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=public-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-contract.js","sourceRoot":"","sources":["../src/public-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,+BAA+B,EAC/B,kCAAkC,EAClC,uCAAuC,EACvC,kCAAkC,EAClC,uCAAuC,EACvC,8BAA8B,EAC9B,4BAA4B,EAC5B,mCAAmC,GACpC,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,+BAA+B,EAC/B,kCAAkC,EAClC,uCAAuC,EACvC,kCAAkC,EAClC,uCAAuC,EACvC,8BAA8B,EAC9B,4BAA4B,EAC5B,mCAAmC,GACpC,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAU,CAAC;AAE/D,MAAM,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAwB,CAAC;AAE1G;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,iBAAyB,wBAAwB,CAAC,OAAO;IAC/F,OAAO,eAAe,CAAC,cAAc,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, transport-neutral package boundary for Nawabari state/contract
|
|
3
|
+
* integration (#257; see docs/architecture/xstate-state-architecture.md,
|
|
4
|
+
* "Public library boundary").
|
|
5
|
+
*
|
|
6
|
+
* This module is the supported way for a cross-product caller (a future
|
|
7
|
+
* Mottainai/Inari adapter, or any other Node consumer) to obtain a public
|
|
8
|
+
* lifecycle observation/snapshot and transition-decision data without
|
|
9
|
+
* spawning the CLI and parsing its output, and without reaching into XState
|
|
10
|
+
* machine/actor internals. Every exported type and function here is a
|
|
11
|
+
* projection of the existing Core/#256 lifecycle authority
|
|
12
|
+
* (`session-lifecycle-classification.ts` and `SessionRegistry`); this module
|
|
13
|
+
* introduces no independent state or transition authority.
|
|
14
|
+
*
|
|
15
|
+
* Raw XState machine definitions, actor refs, internal state-node ids, and
|
|
16
|
+
* private machine context are never exported here. Mutating a session
|
|
17
|
+
* (close/discard/claim/commit/push/...) still requires the existing
|
|
18
|
+
* `SessionRegistry` Git/filesystem/registry authority; nothing in this
|
|
19
|
+
* module lets a caller manufacture or bypass that authorization by
|
|
20
|
+
* constructing an observation or transition decision by hand.
|
|
21
|
+
*/
|
|
22
|
+
import type { SessionLifecycleBlocker, SessionLifecycleClassification, SessionLifecycleCloseReadiness, SessionLifecycleGuardedTransition, SessionLifecycleObservation, SessionLifecycleOperation, SessionLifecyclePhase, SessionLifecycleState, SessionLifecycleTransition, SessionLifecycleTransitionProjection, SessionLifecycleUnconditionalTransition } from "./session-lifecycle-classification.js";
|
|
23
|
+
/** Schema generation for this public state-API module itself. */
|
|
24
|
+
export declare const NAWABARI_STATE_API_SCHEMA_VERSION: 1;
|
|
25
|
+
/** Public lifecycle command/event vocabulary. Never a raw XState event type. */
|
|
26
|
+
export type NawabariCommand = SessionLifecycleOperation;
|
|
27
|
+
/** Caller-supplied observation input. Structural, not tied to a live session. */
|
|
28
|
+
export type NawabariObservation = SessionLifecycleObservation;
|
|
29
|
+
export type NawabariObservationBlocker = SessionLifecycleBlocker;
|
|
30
|
+
export type NawabariObservationPhase = SessionLifecyclePhase;
|
|
31
|
+
export type NawabariCloseReadiness = SessionLifecycleCloseReadiness;
|
|
32
|
+
/** Public lifecycle state name. Never an internal XState state-node id. */
|
|
33
|
+
export type NawabariLifecycleState = SessionLifecycleState;
|
|
34
|
+
export declare const NAWABARI_LIFECYCLE_STATES: readonly NawabariLifecycleState[];
|
|
35
|
+
/**
|
|
36
|
+
* Public projection of one classified session: its lifecycle state plus
|
|
37
|
+
* every per-command transition decision. This is a public projection, not a
|
|
38
|
+
* raw XState snapshot.
|
|
39
|
+
*/
|
|
40
|
+
export type NawabariStateSnapshot = SessionLifecycleClassification;
|
|
41
|
+
/** One command's transition decision: whether/where it would move the state, and why. */
|
|
42
|
+
export type NawabariTransitionDecision = SessionLifecycleTransition;
|
|
43
|
+
export type NawabariUnconditionalTransitionDecision = SessionLifecycleUnconditionalTransition;
|
|
44
|
+
export type NawabariGuardedTransitionDecision = SessionLifecycleGuardedTransition;
|
|
45
|
+
export type NawabariTransitionDecisionProjection = SessionLifecycleTransitionProjection;
|
|
46
|
+
/** The complete static state/command transition-decision table, for discovery. */
|
|
47
|
+
export declare const NAWABARI_TRANSITION_TABLE: Readonly<Record<NawabariLifecycleState, readonly NawabariTransitionDecisionProjection[]>>;
|
|
48
|
+
/**
|
|
49
|
+
* Classify an already-observed session into its public state snapshot and
|
|
50
|
+
* per-command transition decisions. Pure and transport-neutral: it performs
|
|
51
|
+
* no Git/filesystem/registry observation of its own.
|
|
52
|
+
*/
|
|
53
|
+
export declare function classifyNawabariState(observation: NawabariObservation): NawabariStateSnapshot;
|
|
54
|
+
/** Return one command's transition decision from an already-classified snapshot. */
|
|
55
|
+
export declare function nawabariTransitionDecision(snapshot: NawabariStateSnapshot, command: NawabariCommand): NawabariTransitionDecision;
|
|
56
|
+
/** Commands the canonical machine currently admits for an already-classified snapshot. */
|
|
57
|
+
export declare function availableNawabariCommands(snapshot: NawabariStateSnapshot): readonly NawabariCommand[];
|
|
58
|
+
export interface NawabariSessionSnapshotOptions {
|
|
59
|
+
/** Repository/worktree to resolve the session registry from. Defaults to `process.cwd()`. */
|
|
60
|
+
readonly cwd?: string;
|
|
61
|
+
/** Defaults to the session owning `cwd` when omitted. */
|
|
62
|
+
readonly sessionId?: string;
|
|
63
|
+
/** Caller-supplied integration revision, independently re-verified before it affects close readiness. */
|
|
64
|
+
readonly integratedRevision?: string;
|
|
65
|
+
/** `current` reports ownership as it exists; `termination` projects close readiness. Defaults to `current`. */
|
|
66
|
+
readonly phase?: NawabariObservationPhase;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Observe one real, already-provisioned Nawabari session and return its
|
|
70
|
+
* public state snapshot. This reuses the existing `SessionRegistry`
|
|
71
|
+
* Git/filesystem/session-registry authority — the same authority `session
|
|
72
|
+
* inspect` uses — without spawning or parsing CLI output. It never mutates a
|
|
73
|
+
* session, claim, branch, or worktree.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getNawabariSessionStateSnapshot(options?: NawabariSessionSnapshotOptions): NawabariStateSnapshot;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, transport-neutral package boundary for Nawabari state/contract
|
|
3
|
+
* integration (#257; see docs/architecture/xstate-state-architecture.md,
|
|
4
|
+
* "Public library boundary").
|
|
5
|
+
*
|
|
6
|
+
* This module is the supported way for a cross-product caller (a future
|
|
7
|
+
* Mottainai/Inari adapter, or any other Node consumer) to obtain a public
|
|
8
|
+
* lifecycle observation/snapshot and transition-decision data without
|
|
9
|
+
* spawning the CLI and parsing its output, and without reaching into XState
|
|
10
|
+
* machine/actor internals. Every exported type and function here is a
|
|
11
|
+
* projection of the existing Core/#256 lifecycle authority
|
|
12
|
+
* (`session-lifecycle-classification.ts` and `SessionRegistry`); this module
|
|
13
|
+
* introduces no independent state or transition authority.
|
|
14
|
+
*
|
|
15
|
+
* Raw XState machine definitions, actor refs, internal state-node ids, and
|
|
16
|
+
* private machine context are never exported here. Mutating a session
|
|
17
|
+
* (close/discard/claim/commit/push/...) still requires the existing
|
|
18
|
+
* `SessionRegistry` Git/filesystem/registry authority; nothing in this
|
|
19
|
+
* module lets a caller manufacture or bypass that authorization by
|
|
20
|
+
* constructing an observation or transition decision by hand.
|
|
21
|
+
*/
|
|
22
|
+
import { SessionRegistry } from "./session-registry.js";
|
|
23
|
+
import { availableLifecycleOperations, classifySessionLifecycle, lifecycleTransition, SESSION_LIFECYCLE_STATES, SESSION_LIFECYCLE_TRANSITION_TABLE, } from "./session-lifecycle-classification.js";
|
|
24
|
+
/** Schema generation for this public state-API module itself. */
|
|
25
|
+
export const NAWABARI_STATE_API_SCHEMA_VERSION = 1;
|
|
26
|
+
export const NAWABARI_LIFECYCLE_STATES = SESSION_LIFECYCLE_STATES;
|
|
27
|
+
/** The complete static state/command transition-decision table, for discovery. */
|
|
28
|
+
export const NAWABARI_TRANSITION_TABLE = SESSION_LIFECYCLE_TRANSITION_TABLE;
|
|
29
|
+
/**
|
|
30
|
+
* Classify an already-observed session into its public state snapshot and
|
|
31
|
+
* per-command transition decisions. Pure and transport-neutral: it performs
|
|
32
|
+
* no Git/filesystem/registry observation of its own.
|
|
33
|
+
*/
|
|
34
|
+
export function classifyNawabariState(observation) {
|
|
35
|
+
return classifySessionLifecycle(observation);
|
|
36
|
+
}
|
|
37
|
+
/** Return one command's transition decision from an already-classified snapshot. */
|
|
38
|
+
export function nawabariTransitionDecision(snapshot, command) {
|
|
39
|
+
return lifecycleTransition(snapshot, command);
|
|
40
|
+
}
|
|
41
|
+
/** Commands the canonical machine currently admits for an already-classified snapshot. */
|
|
42
|
+
export function availableNawabariCommands(snapshot) {
|
|
43
|
+
return availableLifecycleOperations(snapshot);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Observe one real, already-provisioned Nawabari session and return its
|
|
47
|
+
* public state snapshot. This reuses the existing `SessionRegistry`
|
|
48
|
+
* Git/filesystem/session-registry authority — the same authority `session
|
|
49
|
+
* inspect` uses — without spawning or parsing CLI output. It never mutates a
|
|
50
|
+
* session, claim, branch, or worktree.
|
|
51
|
+
*/
|
|
52
|
+
export function getNawabariSessionStateSnapshot(options = {}) {
|
|
53
|
+
const registry = new SessionRegistry(options.cwd === undefined ? undefined : { cwd: options.cwd });
|
|
54
|
+
return registry.classifyLifecycle({
|
|
55
|
+
sessionId: options.sessionId ?? null,
|
|
56
|
+
integratedRevision: options.integratedRevision ?? null,
|
|
57
|
+
phase: options.phase,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=public-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-state.js","sourceRoot":"","sources":["../src/public-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,uCAAuC,CAAC;AAe/C,iEAAiE;AACjE,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAU,CAAC;AAa5D,MAAM,CAAC,MAAM,yBAAyB,GAAsC,wBAAwB,CAAC;AAerG,kFAAkF;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAElC,kCAAkC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAgC;IACpE,OAAO,wBAAwB,CAAC,WAAW,CAAC,CAAC;AAC/C,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,0BAA0B,CACxC,QAA+B,EAC/B,OAAwB;IAExB,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,yBAAyB,CAAC,QAA+B;IACvE,OAAO,4BAA4B,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC;AAaD;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAAC,UAA0C,EAAE;IAC1F,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACnG,OAAO,QAAQ,CAAC,iBAAiB,CAAC;QAChC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;QACpC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,IAAI;QACtD,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SessionLifecycleClassification } from "./session-lifecycle-classification.js";
|
|
2
2
|
/**
|
|
3
3
|
* The small, public vocabulary for lifecycle recovery. These values are
|
|
4
4
|
* descriptions of an available caller action; none of them grants mutation
|
|
@@ -54,8 +54,9 @@ export type SessionLifecycleActionProjectionInput = {
|
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
56
|
* Project one canonical lifecycle observation into bounded typed caller
|
|
57
|
-
* actions.
|
|
58
|
-
* function only consumes
|
|
57
|
+
* actions. Lifecycle state and admissibility arrive through the canonical
|
|
58
|
+
* classification projection; this function only consumes that result and
|
|
59
|
+
* already-authoritative blocker facts.
|
|
59
60
|
*/
|
|
60
61
|
export declare function projectSessionLifecycleActions(input: SessionLifecycleActionProjectionInput): readonly SessionLifecycleAction[];
|
|
61
62
|
export declare function primarySessionLifecycleAction(input: SessionLifecycleActionProjectionInput): SessionLifecycleAction | undefined;
|