dsh-kingdom 0.8.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ASSETS_NOTICE.md +22 -0
- package/LICENSE +661 -29
- package/NOTICE +9 -0
- package/README.md +93 -94
- package/THIRD_PARTY_NOTICES.md +92 -0
- package/cordis.patch.yml +6 -6
- package/docs/V2.0-RELEASE-NOTES.md +30 -0
- package/docs/V2.0-USER-GUIDE.md +74 -0
- package/lib/adapter/dsh-backend.js +327 -24
- package/lib/adapter/dsh-backend.js.map +1 -1
- package/lib/adapter/dsh-cost.js +68 -0
- package/lib/adapter/dsh-cost.js.map +1 -0
- package/lib/adapter/dsh-session-events.js +86 -0
- package/lib/adapter/dsh-session-events.js.map +1 -0
- package/lib/adapter/dsh-usage.js +159 -0
- package/lib/adapter/dsh-usage.js.map +1 -0
- package/lib/capability/admin.js +72 -0
- package/lib/capability/admin.js.map +1 -0
- package/lib/capability/dsh-enforcement.js +143 -34
- package/lib/capability/dsh-enforcement.js.map +1 -1
- package/lib/capability/resolver.js +21 -8
- package/lib/capability/resolver.js.map +1 -1
- package/lib/capability/service.js +169 -26
- package/lib/capability/service.js.map +1 -1
- package/lib/capability/tool-disclosure.js +144 -0
- package/lib/capability/tool-disclosure.js.map +1 -0
- package/lib/core/binding.js +52 -34
- package/lib/core/binding.js.map +1 -1
- package/lib/core/budget.js +304 -0
- package/lib/core/budget.js.map +1 -0
- package/lib/core/collaboration.js +422 -0
- package/lib/core/collaboration.js.map +1 -0
- package/lib/core/cost.js +212 -0
- package/lib/core/cost.js.map +1 -0
- package/lib/core/db.js +197 -4
- package/lib/core/db.js.map +1 -1
- package/lib/core/execution.js +2 -2
- package/lib/core/execution.js.map +1 -1
- package/lib/core/governed-claim.js +46 -0
- package/lib/core/governed-claim.js.map +1 -0
- package/lib/core/governed.js +891 -98
- package/lib/core/governed.js.map +1 -1
- package/lib/core/kingdom.js +78 -70
- package/lib/core/kingdom.js.map +1 -1
- package/lib/core/owner-binding-intent.js +732 -0
- package/lib/core/owner-binding-intent.js.map +1 -0
- package/lib/core/owner-control.js +86 -0
- package/lib/core/owner-control.js.map +1 -0
- package/lib/core/owner-window.js +822 -0
- package/lib/core/owner-window.js.map +1 -0
- package/lib/core/task-service.js +296 -133
- package/lib/core/task-service.js.map +1 -1
- package/lib/core/territory.js +44 -14
- package/lib/core/territory.js.map +1 -1
- package/lib/core/usage.js +39 -0
- package/lib/core/usage.js.map +1 -0
- package/lib/core/workspace-admission.js +225 -0
- package/lib/core/workspace-admission.js.map +1 -0
- package/lib/dispatch/evidence.js +5 -2
- package/lib/dispatch/evidence.js.map +1 -1
- package/lib/dispatch/reconcile.js +3 -9
- package/lib/dispatch/reconcile.js.map +1 -1
- package/lib/dispatch/service.js +464 -64
- package/lib/dispatch/service.js.map +1 -1
- package/lib/gui/assets/characters/chancellor-idle.svg +67 -0
- package/lib/gui/assets/characters/chancellor-sleeping.svg +67 -0
- package/lib/gui/assets/characters/chancellor-thinking.svg +67 -0
- package/lib/gui/assets/characters/chancellor-working.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-idle.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-sleeping.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-thinking.svg +67 -0
- package/lib/gui/assets/characters/knight-redraw-r1-working.svg +67 -0
- package/lib/gui/assets/characters/supervisor-idle.svg +67 -0
- package/lib/gui/assets/characters/supervisor-sleeping.svg +67 -0
- package/lib/gui/assets/characters/supervisor-thinking.svg +67 -0
- package/lib/gui/assets/characters/supervisor-working.svg +67 -0
- package/lib/gui/console-app.js +2330 -0
- package/lib/gui/console-app.js.map +1 -0
- package/lib/gui/contract.js +5 -5
- package/lib/gui/contract.js.map +1 -1
- package/lib/gui/control-contract.js +232 -0
- package/lib/gui/control-contract.js.map +1 -0
- package/lib/gui/local-control.js +423 -0
- package/lib/gui/local-control.js.map +1 -0
- package/lib/gui/owner-control.js +310 -0
- package/lib/gui/owner-control.js.map +1 -0
- package/lib/gui/owner-ui.js +191 -0
- package/lib/gui/owner-ui.js.map +1 -0
- package/lib/gui/server.js +445 -35
- package/lib/gui/server.js.map +1 -1
- package/lib/gui/snapshot.js +1346 -67
- package/lib/gui/snapshot.js.map +1 -1
- package/lib/gui/visual-assets.js +56 -0
- package/lib/gui/visual-assets.js.map +1 -0
- package/lib/gui/visual-system.js +272 -0
- package/lib/gui/visual-system.js.map +1 -0
- package/lib/gui/workbench-ui.js +358 -0
- package/lib/gui/workbench-ui.js.map +1 -0
- package/lib/gui/workbench.js +163 -0
- package/lib/gui/workbench.js.map +1 -0
- package/lib/index.js +1384 -361
- package/lib/index.js.map +1 -1
- package/lib/runner-context-broker.js +1134 -0
- package/lib/runner-context-broker.js.map +1 -0
- package/lib/runtime-cost-observer.js +145 -0
- package/lib/runtime-cost-observer.js.map +1 -0
- package/lib/types/adapter/contract.d.ts +61 -1
- package/lib/types/adapter/dsh-backend.d.ts +32 -13
- package/lib/types/adapter/dsh-cost.d.ts +13 -0
- package/lib/types/adapter/dsh-session-events.d.ts +16 -0
- package/lib/types/adapter/dsh-usage.d.ts +36 -0
- package/lib/types/capability/admin.d.ts +13 -0
- package/lib/types/capability/dsh-enforcement.d.ts +11 -7
- package/lib/types/capability/service.d.ts +10 -3
- package/lib/types/capability/tool-disclosure.d.ts +36 -0
- package/lib/types/core/binding.d.ts +19 -10
- package/lib/types/core/budget.d.ts +81 -0
- package/lib/types/core/collaboration.d.ts +110 -0
- package/lib/types/core/cost.d.ts +99 -0
- package/lib/types/core/db.d.ts +44 -4
- package/lib/types/core/execution.d.ts +1 -1
- package/lib/types/core/governed-claim.d.ts +7 -0
- package/lib/types/core/governed.d.ts +182 -1
- package/lib/types/core/kingdom.d.ts +3 -0
- package/lib/types/core/owner-binding-intent.d.ts +176 -0
- package/lib/types/core/owner-control.d.ts +53 -0
- package/lib/types/core/owner-window.d.ts +226 -0
- package/lib/types/core/task-service.d.ts +60 -13
- package/lib/types/core/territory.d.ts +9 -2
- package/lib/types/core/usage.d.ts +26 -0
- package/lib/types/core/workspace-admission.d.ts +43 -0
- package/lib/types/dispatch/evidence.d.ts +2 -5
- package/lib/types/dispatch/service.d.ts +62 -4
- package/lib/types/gui/console-app.d.ts +137 -0
- package/lib/types/gui/contract.d.ts +396 -16
- package/lib/types/gui/control-contract.d.ts +111 -0
- package/lib/types/gui/local-control.d.ts +120 -0
- package/lib/types/gui/owner-control.d.ts +45 -0
- package/lib/types/gui/owner-ui.d.ts +2 -0
- package/lib/types/gui/server.d.ts +17 -3
- package/lib/types/gui/snapshot.d.ts +33 -11
- package/lib/types/gui/visual-assets.d.ts +27 -0
- package/lib/types/gui/visual-system.d.ts +2 -0
- package/lib/types/gui/workbench-ui.d.ts +5 -0
- package/lib/types/gui/workbench.d.ts +33 -0
- package/lib/types/index.d.ts +157 -6
- package/lib/types/runner-context-broker.d.ts +119 -0
- package/lib/types/runtime-cost-observer.d.ts +22 -0
- package/lib/types/worker/collaboration.d.ts +35 -0
- package/lib/types/worker/dsh-subagent.d.ts +4 -4
- package/lib/types/worker/executor-factory.d.ts +2 -1
- package/lib/types/worker/executor.d.ts +8 -3
- package/lib/types/worker/governed-executor.d.ts +8 -1
- package/lib/worker/collaboration.js +172 -0
- package/lib/worker/collaboration.js.map +1 -0
- package/lib/worker/dsh-subagent.js +4 -4
- package/lib/worker/executor-factory.js.map +1 -1
- package/lib/worker/executor.js +7 -2
- package/lib/worker/executor.js.map +1 -1
- package/lib/worker/governed-executor.js +295 -84
- package/lib/worker/governed-executor.js.map +1 -1
- package/package.json +23 -8
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { KingdomStore, type AffinityRow, type LeaseRow, type CapabilityDecisionRow, type DispatchRecordRow, type ExecutionRow, StaleStateError } from './db.js';
|
|
1
|
+
import { KingdomStore, type AffinityRow, type LeaseRow, type CapabilityDecisionRow, type DispatchRecordRow, type ExecutionRow, type EventRow, StaleStateError } from './db.js';
|
|
2
|
+
import { type BudgetAdmissionHandle } from './budget.js';
|
|
3
|
+
import { type WorkspaceAdmissionHandle } from './workspace-admission.js';
|
|
4
|
+
import { type CollaborationReadiness } from './collaboration.js';
|
|
2
5
|
/** 完整 Runtime Session identity(M3-S1 冻结:(runtime_type, runtime_instance_ref, session_ref))。 */
|
|
3
6
|
export interface SessionIdentity {
|
|
4
7
|
runtimeType: string;
|
|
@@ -13,6 +16,109 @@ export declare class GovernedApiError extends Error {
|
|
|
13
16
|
export declare class SchemaV4NotMigratedError extends GovernedApiError {
|
|
14
17
|
constructor();
|
|
15
18
|
}
|
|
19
|
+
export type RunnerContextPhase = 'OPEN' | 'ACQUIRED' | 'BOUND' | 'TERMINAL' | 'RECOVERING' | 'RECOVERY_TERMINAL' | 'RELEASED' | 'INVALID';
|
|
20
|
+
export type RunnerContextErrorCode = 'RELATION_MISSING' | 'RELATION_MISMATCH' | 'INVALID_HANDLE' | 'INVALID_VERSION' | 'STALE_VERSION' | 'INVALID_ORDER' | 'RECOVERING' | 'RELEASED';
|
|
21
|
+
export declare class RunnerContextError extends GovernedApiError {
|
|
22
|
+
readonly code: RunnerContextErrorCode;
|
|
23
|
+
constructor(code: RunnerContextErrorCode, message: string);
|
|
24
|
+
}
|
|
25
|
+
/** Opaque, module-minted identity. The constructor rejects arbitrary keys. */
|
|
26
|
+
export declare class RunnerContextHandle {
|
|
27
|
+
#private;
|
|
28
|
+
/** @internal The module-private secret is the only accepted constructor key. */
|
|
29
|
+
constructor(key: symbol);
|
|
30
|
+
}
|
|
31
|
+
/** Opaque monotonic token. The public sequence is diagnostic only. */
|
|
32
|
+
export declare class RunnerContextVersion {
|
|
33
|
+
#private;
|
|
34
|
+
/** @internal The module-private secret is the only accepted constructor key. */
|
|
35
|
+
constructor(key: symbol, sequence: number);
|
|
36
|
+
/**
|
|
37
|
+
* This value is intentionally only a diagnostic projection. The product
|
|
38
|
+
* never reads it to mint the next token; the authoritative sequence lives in
|
|
39
|
+
* the module-private WeakMap record below.
|
|
40
|
+
*/
|
|
41
|
+
get sequence(): number;
|
|
42
|
+
}
|
|
43
|
+
export interface RunnerContextView {
|
|
44
|
+
readonly phase: RunnerContextPhase;
|
|
45
|
+
readonly kingdomId: string;
|
|
46
|
+
readonly taskId: string;
|
|
47
|
+
readonly attemptNo: number;
|
|
48
|
+
readonly executionId: string;
|
|
49
|
+
readonly leaseId: string;
|
|
50
|
+
readonly dispatchId: string;
|
|
51
|
+
readonly workerBindingId: string;
|
|
52
|
+
readonly sessionRef: string;
|
|
53
|
+
readonly dispatchState: string;
|
|
54
|
+
readonly executionState: string;
|
|
55
|
+
readonly leaseState: string;
|
|
56
|
+
readonly version: RunnerContextVersion;
|
|
57
|
+
}
|
|
58
|
+
export interface RunnerContextActionContext {
|
|
59
|
+
readonly handle: RunnerContextHandle;
|
|
60
|
+
readonly version: RunnerContextVersion;
|
|
61
|
+
readonly view: RunnerContextView;
|
|
62
|
+
readonly runtimeDispatchRef?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface RunnerContextMutationResult<T> {
|
|
65
|
+
readonly value: T;
|
|
66
|
+
readonly view: RunnerContextView;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Product-side canonical Runner context. It is intentionally not a DB handle
|
|
70
|
+
* and exposes only bounded identifiers/state views to a Runner.
|
|
71
|
+
*/
|
|
72
|
+
export declare class RunnerContextPort {
|
|
73
|
+
/** @internal The module-private secret is the only accepted constructor key. */
|
|
74
|
+
constructor(key: symbol);
|
|
75
|
+
get handle(): RunnerContextHandle;
|
|
76
|
+
get initialVersion(): RunnerContextVersion;
|
|
77
|
+
/** Product-internal phase probe used by the child broker lifecycle. */
|
|
78
|
+
get currentPhase(): RunnerContextPhase;
|
|
79
|
+
private state;
|
|
80
|
+
private consume;
|
|
81
|
+
private advance;
|
|
82
|
+
read(handle: RunnerContextHandle, version: RunnerContextVersion): RunnerContextView;
|
|
83
|
+
/**
|
|
84
|
+
* Non-mutating Product-child snapshot. A broker read may observe the
|
|
85
|
+
* bounded view without consuming the version that the Product uses for its
|
|
86
|
+
* next receipt/correlation/terminal/settlement mutation.
|
|
87
|
+
*/
|
|
88
|
+
brokerSnapshot(): RunnerContextView;
|
|
89
|
+
acquire(handle: RunnerContextHandle, version: RunnerContextVersion): RunnerContextView;
|
|
90
|
+
private mutate;
|
|
91
|
+
bindRuntimeReceipt<T>(handle: RunnerContextHandle, version: RunnerContextVersion, runtimeDispatchRef: string, action: (context: RunnerContextActionContext) => T): RunnerContextMutationResult<T>;
|
|
92
|
+
/**
|
|
93
|
+
* RECEIVED → CORRELATED plus Execution STARTING → RUNNING under the same
|
|
94
|
+
* opaque port/version. The dispatch service supplies the Core write as the
|
|
95
|
+
* in-port action; callers cannot correlate by using the legacy standalone
|
|
96
|
+
* function outside this seam.
|
|
97
|
+
*/
|
|
98
|
+
correlateRuntimeExecution<T>(handle: RunnerContextHandle, version: RunnerContextVersion, runtimeExecutionRef: string, action: (context: RunnerContextActionContext) => T): RunnerContextMutationResult<T>;
|
|
99
|
+
observeTerminal<T>(handle: RunnerContextHandle, version: RunnerContextVersion, action: (context: RunnerContextActionContext) => T): RunnerContextMutationResult<T>;
|
|
100
|
+
/** Observation timeout retains this original capability; the factory still rejects RECOVERING. */
|
|
101
|
+
deferRecovery(handle: RunnerContextHandle, version: RunnerContextVersion): RunnerContextMutationResult<ReturnType<typeof markGovernedDispatchRecovering>>;
|
|
102
|
+
/** Only the original deferred port can consume late evidence; no recovered factory or new Runner. */
|
|
103
|
+
checkRecovery(handle: RunnerContextHandle, version: RunnerContextVersion): RunnerContextView;
|
|
104
|
+
recoverTerminal(handle: RunnerContextHandle, version: RunnerContextVersion, input: TerminalEvidenceInput & {
|
|
105
|
+
runtimeExecutionRef: string;
|
|
106
|
+
}): RunnerContextMutationResult<{
|
|
107
|
+
dispatch: DispatchRecordRow;
|
|
108
|
+
execution: ExecutionRow;
|
|
109
|
+
lease: LeaseRow;
|
|
110
|
+
}>;
|
|
111
|
+
settleRecovery<T>(handle: RunnerContextHandle, version: RunnerContextVersion, action: (context: RunnerContextActionContext) => T): RunnerContextMutationResult<T>;
|
|
112
|
+
settle<T>(handle: RunnerContextHandle, version: RunnerContextVersion, action: (context: RunnerContextActionContext) => T): RunnerContextMutationResult<T>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Mint a Runner context only after the DB has committed a canonical Dispatch
|
|
116
|
+
* relation. The factory never accepts caller-supplied Task/Lease/Session IDs
|
|
117
|
+
* as authority; it derives all relation fields from the exact Dispatch row.
|
|
118
|
+
*/
|
|
119
|
+
export declare function createRunnerContextPort(store: KingdomStore, input: string | {
|
|
120
|
+
readonly dispatchId: string;
|
|
121
|
+
}): RunnerContextPort;
|
|
16
122
|
/** 期望旧态与当前库态不一致(CAS 失败)。 */
|
|
17
123
|
export declare class StaleLeaseError extends StaleStateError {
|
|
18
124
|
}
|
|
@@ -118,6 +224,37 @@ export interface CreateDispatchIntentInput {
|
|
|
118
224
|
* 调用方在本函数返回(事务已提交)**之后**才允许调用 RuntimeAdapter.dispatch()。
|
|
119
225
|
*/
|
|
120
226
|
export declare function createDispatchIntent(store: KingdomStore, input: CreateDispatchIntentInput): DispatchRecordRow;
|
|
227
|
+
export interface PrepareGovernedDispatchInput {
|
|
228
|
+
kingdomId: string;
|
|
229
|
+
taskId: string;
|
|
230
|
+
attemptNo: number;
|
|
231
|
+
workerBindingId: string;
|
|
232
|
+
leaseId: string;
|
|
233
|
+
capabilityDecisionId: string;
|
|
234
|
+
session: SessionIdentity;
|
|
235
|
+
requestSnapshot: string;
|
|
236
|
+
inputRefJson: string;
|
|
237
|
+
payloadHash: string;
|
|
238
|
+
executionId?: string;
|
|
239
|
+
dispatchId?: string;
|
|
240
|
+
preparedAt?: string;
|
|
241
|
+
detail?: string | null;
|
|
242
|
+
budgetAdmission?: BudgetAdmissionHandle;
|
|
243
|
+
workspaceAdmission?: WorkspaceAdmissionHandle;
|
|
244
|
+
collaboration?: CollaborationReadiness | null;
|
|
245
|
+
}
|
|
246
|
+
export interface PreparedGovernedDispatchRows {
|
|
247
|
+
execution: ExecutionRow;
|
|
248
|
+
decision: CapabilityDecisionRow;
|
|
249
|
+
intent: DispatchRecordRow;
|
|
250
|
+
lease: LeaseRow;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* TX-3 COMMIT POINT:在一个真实事务内同时准备 Execution、Decision binding、
|
|
254
|
+
* Dispatch Intent 与 EXECUTING Lease。这里仅调用无事务的 Store primitive,
|
|
255
|
+
* 不能嵌套现有 create/advance public helper。
|
|
256
|
+
*/
|
|
257
|
+
export declare function prepareGovernedDispatch(store: KingdomStore, input: PrepareGovernedDispatchInput): PreparedGovernedDispatchRows;
|
|
121
258
|
export interface ReceiptInput {
|
|
122
259
|
runtimeDispatchRef: string;
|
|
123
260
|
receiptJson: string;
|
|
@@ -156,6 +293,50 @@ export declare function advanceDispatchState(store: KingdomStore, dispatchId: st
|
|
|
156
293
|
receiptAt?: string | null;
|
|
157
294
|
terminalAt?: string | null;
|
|
158
295
|
}): DispatchRecordRow;
|
|
296
|
+
export type GovernedRecoveryReasonCode = 'RECONCILE_UNKNOWN' | 'RECONCILE_UNTRUSTED' | 'DISPATCH_EXCEPTION' | 'TERMINAL_POLL_EXHAUSTED';
|
|
297
|
+
export interface GovernedRecoveryRows {
|
|
298
|
+
dispatch: DispatchRecordRow;
|
|
299
|
+
lease: LeaseRow;
|
|
300
|
+
execution: ExecutionRow;
|
|
301
|
+
}
|
|
302
|
+
/** Bounded, non-runtime-specific reasons for a post-TX-4 integrity incident. */
|
|
303
|
+
export type TerminalIntegrityReasonCode = 'TRUST_FENCE_MISSING' | 'TRUST_FENCE_EXPECTATION_MISMATCH' | 'TRUST_FENCE_CHECK_FAILED' | 'TRUST_FENCE_RELEASE_FAILED';
|
|
304
|
+
export type TerminalIntegrityPhase = 'settlement' | 'release';
|
|
305
|
+
export interface DispatchTerminalIntegrityIncidentInput {
|
|
306
|
+
dispatchId: string;
|
|
307
|
+
reasonCode: TerminalIntegrityReasonCode;
|
|
308
|
+
phase: TerminalIntegrityPhase;
|
|
309
|
+
}
|
|
310
|
+
export interface DispatchTerminalIntegrityIncidentRows {
|
|
311
|
+
dispatch: DispatchRecordRow;
|
|
312
|
+
lease: LeaseRow;
|
|
313
|
+
execution: ExecutionRow;
|
|
314
|
+
incident: EventRow;
|
|
315
|
+
incidentCreated: boolean;
|
|
316
|
+
/** RELEASED is deliberately not rolled back; it requires escalation. */
|
|
317
|
+
escalated: boolean;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* TX-4 post-terminal integrity seam.
|
|
321
|
+
*
|
|
322
|
+
* This is intentionally separate from markGovernedDispatchRecovering:
|
|
323
|
+
* Dispatch and Execution are already terminal and must remain terminal. The
|
|
324
|
+
* exact Dispatch/Task/attempt relation is re-read inside one IMMEDIATE
|
|
325
|
+
* transaction, then only a still-recoverable Lease is moved to RECOVERING and
|
|
326
|
+
* one bounded incident event is appended. Replays are a zero-event readback.
|
|
327
|
+
*/
|
|
328
|
+
export declare function recordDispatchTerminalIntegrityIncident(store: KingdomStore, input: DispatchTerminalIntegrityIncidentInput): DispatchTerminalIntegrityIncidentRows;
|
|
329
|
+
/**
|
|
330
|
+
* Atomically move one governed Dispatch, its Lease, and its Execution into
|
|
331
|
+
* RECOVERING. This is shared by reconciliation and terminal-poll timeout.
|
|
332
|
+
*
|
|
333
|
+
* All related rows are re-read and validated before the first write. The
|
|
334
|
+
* low-level CAS updates and recovery events share one transaction; the
|
|
335
|
+
* independently transactional mark* helpers below must not be nested here.
|
|
336
|
+
* Repeating the call after all three rows are RECOVERING is a zero-event,
|
|
337
|
+
* zero-write idempotent readback.
|
|
338
|
+
*/
|
|
339
|
+
export declare function markGovernedDispatchRecovering(store: KingdomStore, dispatchId: string, reasonCode: GovernedRecoveryReasonCode): GovernedRecoveryRows;
|
|
159
340
|
/** Lease 进 RECOVERING(RECOVERING 不改 Task 治理状态;仅重建证据)。 */
|
|
160
341
|
export declare function markLeaseRecovering(store: KingdomStore, leaseId: string): LeaseRow;
|
|
161
342
|
/** Dispatch 进 RECOVERING(Intent 已存在但证据链断裂;禁盲目重发)。 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { KingdomStore } from './db.js';
|
|
2
|
+
import { type OwnerEventSource } from './owner-control.js';
|
|
2
3
|
export interface InitResult {
|
|
3
4
|
action: 'initialized' | 'attached';
|
|
4
5
|
kingdomId: string;
|
|
@@ -38,3 +39,5 @@ export declare class KingdomManager {
|
|
|
38
39
|
rescan(): InitResult;
|
|
39
40
|
close(): void;
|
|
40
41
|
}
|
|
42
|
+
/** Synchronous fact writer shared by direct init and the Owner receipt transaction. */
|
|
43
|
+
export declare function initializeKingdomFacts(store: KingdomStore, kingdomName: string, ownerName: string, source?: OwnerEventSource): InitResult;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure natural-language -> Owner binding intent Draft.
|
|
3
|
+
*
|
|
4
|
+
* This module deliberately has no KingdomStore, filesystem, event, runtime, or
|
|
5
|
+
* capability dependency. A caller may provide an exact target_session_ref,
|
|
6
|
+
* but that value is only a target reference; it never becomes Owner authority.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DIRECT_SLASH_CONFIRM_REQUIRED: "DIRECT_SLASH_CONFIRM_REQUIRED";
|
|
9
|
+
export type IntentRoleType = 'CHANCELLOR' | 'SUPERVISOR' | 'WORKER';
|
|
10
|
+
export type ParsedRoleType = IntentRoleType | 'OWNER';
|
|
11
|
+
export type TargetSessionClassification = 'ACTIVE' | 'FOREIGN' | 'EXPIRED' | 'ABORTED' | 'MULTIPLE' | 'ABSENT' | 'UNKNOWN';
|
|
12
|
+
/** @deprecated Use TargetSessionClassification for the explicit seam. */
|
|
13
|
+
export type TargetSessionState = TargetSessionClassification | 'MISSING';
|
|
14
|
+
export type RejectedOwnerBindingOperation = 'kingdom_bind_role' | 'kingdom_bind_session' | 'role.bind' | 'role.session';
|
|
15
|
+
export interface StructuredOwnerBindingRejection {
|
|
16
|
+
code: string;
|
|
17
|
+
operation: RejectedOwnerBindingOperation;
|
|
18
|
+
request?: {
|
|
19
|
+
role_type?: string | null;
|
|
20
|
+
role_name?: string | null;
|
|
21
|
+
session_id?: string | null;
|
|
22
|
+
binding_id?: string | null;
|
|
23
|
+
territory_id?: string | null;
|
|
24
|
+
};
|
|
25
|
+
context?: OwnerBindingIntentContext;
|
|
26
|
+
}
|
|
27
|
+
export interface OwnerBindingStepPolicy {
|
|
28
|
+
failure: 'STOP_NO_AGENT_RETRY_OR_COMPENSATION';
|
|
29
|
+
}
|
|
30
|
+
export interface RoleBindDraftStep {
|
|
31
|
+
step_id: 'ROLE_BIND';
|
|
32
|
+
kind: 'role.bind';
|
|
33
|
+
args: RoleBindDraftOperation['args'];
|
|
34
|
+
canonical_direct_slash: string;
|
|
35
|
+
canonical_direct_slash_template: null;
|
|
36
|
+
depends_on: readonly [];
|
|
37
|
+
confirmation: typeof DIRECT_SLASH_CONFIRM_REQUIRED;
|
|
38
|
+
policy: OwnerBindingStepPolicy;
|
|
39
|
+
}
|
|
40
|
+
export interface RoleSessionDraftStep {
|
|
41
|
+
step_id: 'ROLE_SESSION';
|
|
42
|
+
kind: 'role.session';
|
|
43
|
+
args: RoleSessionDraftOperation['args'];
|
|
44
|
+
canonical_direct_slash: string;
|
|
45
|
+
canonical_direct_slash_template: null;
|
|
46
|
+
depends_on: readonly [];
|
|
47
|
+
confirmation: typeof DIRECT_SLASH_CONFIRM_REQUIRED;
|
|
48
|
+
policy: OwnerBindingStepPolicy;
|
|
49
|
+
}
|
|
50
|
+
export interface TerritorySupervisorDraftStep {
|
|
51
|
+
step_id: 'TERRITORY_SUPERVISOR';
|
|
52
|
+
kind: 'territory.supervisor';
|
|
53
|
+
args: {
|
|
54
|
+
territory_id: string;
|
|
55
|
+
supervisor_binding_id_ref: string;
|
|
56
|
+
};
|
|
57
|
+
canonical_direct_slash: string | null;
|
|
58
|
+
canonical_direct_slash_template: string | null;
|
|
59
|
+
depends_on: readonly string[];
|
|
60
|
+
confirmation: typeof DIRECT_SLASH_CONFIRM_REQUIRED;
|
|
61
|
+
policy: OwnerBindingStepPolicy;
|
|
62
|
+
}
|
|
63
|
+
export type CanonicalDraftStep = RoleBindDraftStep | RoleSessionDraftStep | TerritorySupervisorDraftStep;
|
|
64
|
+
export interface TargetSessionCandidate {
|
|
65
|
+
session_ref: string;
|
|
66
|
+
status?: TargetSessionState;
|
|
67
|
+
kingdom_id?: string | null;
|
|
68
|
+
}
|
|
69
|
+
export interface BindingSnapshot {
|
|
70
|
+
binding_id: string;
|
|
71
|
+
role_type: string;
|
|
72
|
+
role_name?: string | null;
|
|
73
|
+
session_id?: string | null;
|
|
74
|
+
status?: 'ACTIVE' | 'RETIRED' | 'DELETED' | 'EXPIRED' | string;
|
|
75
|
+
kingdom_id?: string | null;
|
|
76
|
+
}
|
|
77
|
+
export interface TerritorySnapshot {
|
|
78
|
+
territory_id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
aliases?: readonly string[];
|
|
81
|
+
status?: 'ACTIVE' | 'DELETED' | 'EXPIRED' | string;
|
|
82
|
+
kingdom_id?: string | null;
|
|
83
|
+
supervisor_binding_id?: string | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The only session input accepted for “当前会话/这个会话/该会话” is the
|
|
87
|
+
* exact target_session_ref supplied by the invocation context. The optional
|
|
88
|
+
* resolution fields let an adapter report foreign, expired, or multi-match
|
|
89
|
+
* context without making this pure module inspect a runtime or database.
|
|
90
|
+
*/
|
|
91
|
+
export interface OwnerBindingIntentContext {
|
|
92
|
+
target_session_ref?: string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Trusted adapter proof seam. ACTIVE is valid only after the adapter proves
|
|
95
|
+
* current initiator + agents.get/session.get object identity + matching ids
|
|
96
|
+
* + running + non-aborted signal; absent or failed proof never becomes ACTIVE.
|
|
97
|
+
*/
|
|
98
|
+
target_session_classification?: TargetSessionClassification;
|
|
99
|
+
/**
|
|
100
|
+
* Legacy compatibility hint only. It is intentionally not an authority or
|
|
101
|
+
* liveness proof; callers must migrate to target_session_classification.
|
|
102
|
+
*/
|
|
103
|
+
target_session_state?: TargetSessionState;
|
|
104
|
+
target_session_matches?: readonly string[];
|
|
105
|
+
target_session_candidates?: readonly TargetSessionCandidate[];
|
|
106
|
+
kingdom_id?: string | null;
|
|
107
|
+
role_bindings?: readonly BindingSnapshot[];
|
|
108
|
+
territories?: readonly TerritorySnapshot[];
|
|
109
|
+
}
|
|
110
|
+
export interface OwnerBindingIntentInput {
|
|
111
|
+
text: string;
|
|
112
|
+
context?: OwnerBindingIntentContext;
|
|
113
|
+
}
|
|
114
|
+
export type IntentAmbiguityCode = 'UNSUPPORTED_INPUT' | 'REJECTION_UNSUPPORTED' | 'OWNER_ROLE_DIRECT_ONLY' | 'SESSION_MISSING' | 'SESSION_FOREIGN' | 'SESSION_EXPIRED' | 'SESSION_MULTIPLE' | 'SESSION_UNRESOLVED' | 'ROLE_MULTIPLE' | 'ROLE_FOREIGN' | 'ROLE_BINDING_UNSAFE' | 'TERRITORY_REQUIRED' | 'TERRITORY_NOT_FOUND' | 'TERRITORY_FOREIGN' | 'TERRITORY_UNAVAILABLE' | 'TERRITORY_MULTIPLE' | 'TERRITORY_UNRESOLVED';
|
|
115
|
+
export interface DraftAmbiguity {
|
|
116
|
+
code: IntentAmbiguityCode;
|
|
117
|
+
question: string;
|
|
118
|
+
}
|
|
119
|
+
export interface DraftIntent {
|
|
120
|
+
role_type: ParsedRoleType | null;
|
|
121
|
+
role_alias: string | null;
|
|
122
|
+
target: 'CALL_CONTEXT_TARGET_SESSION' | null;
|
|
123
|
+
target_session_ref: string | null;
|
|
124
|
+
territory: {
|
|
125
|
+
territory_id: string;
|
|
126
|
+
name: string;
|
|
127
|
+
} | null;
|
|
128
|
+
}
|
|
129
|
+
export interface RoleBindDraftOperation {
|
|
130
|
+
kind: 'role.bind';
|
|
131
|
+
args: {
|
|
132
|
+
role_type: IntentRoleType;
|
|
133
|
+
role_name: string;
|
|
134
|
+
session_id: string;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export interface RoleSessionDraftOperation {
|
|
138
|
+
kind: 'role.session';
|
|
139
|
+
args: {
|
|
140
|
+
binding_id: string;
|
|
141
|
+
session_id: string;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
export type DraftOperation = RoleBindDraftOperation | RoleSessionDraftOperation;
|
|
145
|
+
export interface OwnerBindingIntentDraft {
|
|
146
|
+
kind: 'OWNER_BINDING_INTENT_DRAFT';
|
|
147
|
+
status: 'DRAFT_READY' | 'AMBIGUOUS';
|
|
148
|
+
/** Natural language never supplies an Owner principal or capability. */
|
|
149
|
+
authority_source: 'NONE';
|
|
150
|
+
owner_authority: false;
|
|
151
|
+
write_effect: 'ZERO_WRITE';
|
|
152
|
+
normalized_input: string;
|
|
153
|
+
intent: DraftIntent;
|
|
154
|
+
operation: DraftOperation | null;
|
|
155
|
+
steps: readonly CanonicalDraftStep[];
|
|
156
|
+
/** Alias kept for integrations that name the collection explicitly. */
|
|
157
|
+
canonical_steps: readonly CanonicalDraftStep[];
|
|
158
|
+
policy: OwnerBindingStepPolicy;
|
|
159
|
+
canonical_direct_slash: string | null;
|
|
160
|
+
confirmation: typeof DIRECT_SLASH_CONFIRM_REQUIRED | null;
|
|
161
|
+
ambiguity: DraftAmbiguity | null;
|
|
162
|
+
}
|
|
163
|
+
/** Pure materializer for the second direct Slash once role.bind returned its ID. */
|
|
164
|
+
export declare function canonicalTerritorySupervisorSlash(territoryId: string, supervisorBindingId: string): string | null;
|
|
165
|
+
/** Parse one bounded natural-language intent without performing any write. */
|
|
166
|
+
export declare function draftOwnerBindingIntent(input: OwnerBindingIntentInput): OwnerBindingIntentDraft;
|
|
167
|
+
/**
|
|
168
|
+
* Convert a structured OWNER_CONTROL_REQUIRED rejection into the same pure
|
|
169
|
+
* Draft contract. The rejection is data, not authority; target session still
|
|
170
|
+
* comes only from the explicitly classified invocation context.
|
|
171
|
+
*/
|
|
172
|
+
export declare function draftOwnerBindingIntentFromRejectedWrite(input: StructuredOwnerBindingRejection): OwnerBindingIntentDraft;
|
|
173
|
+
/** Compatibility-friendly name for callers that prefer a parse verb. */
|
|
174
|
+
export declare const parseOwnerBindingIntent: typeof draftOwnerBindingIntent;
|
|
175
|
+
/** Stable, JSON-safe rendering for UI/Agent echo and deterministic tests. */
|
|
176
|
+
export declare function serializeOwnerBindingIntentDraft(draft: OwnerBindingIntentDraft): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trusted-local Owner Control Plane.
|
|
3
|
+
*
|
|
4
|
+
* The capability below is deliberately opaque to runtime callers. Only the
|
|
5
|
+
* canonical direct `/kingdom` command handler may mint one; Agent Tools,
|
|
6
|
+
* GUI/HTTP handlers, arguments, and DSH session attribution never receive a
|
|
7
|
+
* path to construct or forward it.
|
|
8
|
+
*/
|
|
9
|
+
import type { KingdomStore, RoleBindingRow } from './db.js';
|
|
10
|
+
import type { AdminAuth } from './binding.js';
|
|
11
|
+
declare const OWNER_CONTROL_MARKER: unique symbol;
|
|
12
|
+
export interface OwnerEventSource {
|
|
13
|
+
source_channel: 'LOCAL_DIRECT_SLASH' | 'LOCAL_OWNER_GUI';
|
|
14
|
+
authorization_source?: 'LOCAL_DIRECT_SLASH';
|
|
15
|
+
decision_id?: string;
|
|
16
|
+
operation_id?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface OwnerOperationMatch {
|
|
19
|
+
operation: string;
|
|
20
|
+
input: unknown;
|
|
21
|
+
}
|
|
22
|
+
/** Stable JSON for exact, immutable operation matching. Undefined follows JSON semantics. */
|
|
23
|
+
export declare function ownerInputHash(input: unknown): string;
|
|
24
|
+
export interface OwnerControlCapability {
|
|
25
|
+
readonly [OWNER_CONTROL_MARKER]: true;
|
|
26
|
+
}
|
|
27
|
+
/** Mint a capability for the direct local Slash handler only. */
|
|
28
|
+
export declare function issueOwnerControlCapability(): OwnerControlCapability;
|
|
29
|
+
export declare function isOwnerControlCapability(value: unknown): value is OwnerControlCapability;
|
|
30
|
+
/** Internal controller seam; requires the original direct capability, never HTTP data. */
|
|
31
|
+
export declare function issueOwnerOperationCapability(authority: OwnerControlCapability, store: KingdomStore, kingdomId: string, match: OwnerOperationMatch, source: OwnerEventSource): OwnerControlCapability;
|
|
32
|
+
export declare function revokeOwnerOperationCapability(capability: OwnerControlCapability): void;
|
|
33
|
+
export interface OwnerControlCheck {
|
|
34
|
+
ok: true;
|
|
35
|
+
owner: RoleBindingRow | null;
|
|
36
|
+
ownerId: string;
|
|
37
|
+
sourceChannel: 'LOCAL_DIRECT_SLASH' | 'LOCAL_OWNER_GUI';
|
|
38
|
+
eventSource: OwnerEventSource;
|
|
39
|
+
}
|
|
40
|
+
export interface OwnerControlFailure {
|
|
41
|
+
ok: false;
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The single Core gate for Owner-only writes. It intentionally ignores
|
|
46
|
+
* OWNER.session_id and all caller/session fields; the only authority input is
|
|
47
|
+
* the opaque capability minted by the direct Slash adapter.
|
|
48
|
+
*/
|
|
49
|
+
export declare function requireOwnerControl(store: KingdomStore, kingdomId: string, capability: unknown, match?: OwnerOperationMatch): OwnerControlCheck | OwnerControlFailure;
|
|
50
|
+
/** Convert the direct capability into the shared Core admin input. */
|
|
51
|
+
export declare function ownerControlAuth(capability: OwnerControlCapability): AdminAuth;
|
|
52
|
+
export declare function ownerEventPayload(operation: string, fields?: Record<string, unknown>, source?: OwnerEventSource): Record<string, unknown>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type { KingdomStore } from './db.js';
|
|
2
|
+
import { type ExecutionProfileV1 } from './binding.js';
|
|
3
|
+
import { type OwnerControlCapability } from './owner-control.js';
|
|
4
|
+
import { type BudgetPolicyParameters } from './budget.js';
|
|
5
|
+
import { type PlanAdoptionParameters, type CollaborationPlanView } from './collaboration.js';
|
|
6
|
+
export declare const OWNER_MUTATION_ACTIONS: readonly ["init", "territory.create", "territory.update", "territory.supervisor", "role.bind", "role.session", "ceiling", "execution-profile", "budget.policy", "plan.adopt"];
|
|
7
|
+
export type OwnerMutationAction = typeof OWNER_MUTATION_ACTIONS[number];
|
|
8
|
+
export type OwnerManagedRole = 'CHANCELLOR' | 'SUPERVISOR' | 'WORKER';
|
|
9
|
+
export interface OwnerDecisionScope {
|
|
10
|
+
kingdomWide: boolean;
|
|
11
|
+
territoryIds: string[];
|
|
12
|
+
bindingIds: string[];
|
|
13
|
+
roleTypes: OwnerManagedRole[];
|
|
14
|
+
targetSessionIds: string[];
|
|
15
|
+
workspaceRoots: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface OwnerDecisionInput {
|
|
18
|
+
kingdomId: string | null;
|
|
19
|
+
actions: OwnerMutationAction[];
|
|
20
|
+
scope: OwnerDecisionScope;
|
|
21
|
+
ttlMs: number;
|
|
22
|
+
}
|
|
23
|
+
declare const OWNER_DECISION_HANDLE: unique symbol;
|
|
24
|
+
export interface OwnerDecisionHandle {
|
|
25
|
+
readonly [OWNER_DECISION_HANDLE]: true;
|
|
26
|
+
}
|
|
27
|
+
export interface OwnerDecisionView {
|
|
28
|
+
decisionId: string;
|
|
29
|
+
kingdomId: string | null;
|
|
30
|
+
ownerId: string | null;
|
|
31
|
+
actions: OwnerMutationAction[];
|
|
32
|
+
scope: OwnerDecisionScope;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
expiresAt: string;
|
|
35
|
+
state: 'ACTIVE' | 'EXPIRED' | 'REVOKED' | 'CONSUMED';
|
|
36
|
+
}
|
|
37
|
+
export interface OwnerValidationFailure {
|
|
38
|
+
ok: false;
|
|
39
|
+
code: string;
|
|
40
|
+
message: string;
|
|
41
|
+
}
|
|
42
|
+
export type OwnerValidationResult = {
|
|
43
|
+
ok: true;
|
|
44
|
+
} | OwnerValidationFailure;
|
|
45
|
+
export interface OwnerSessionValidationInput {
|
|
46
|
+
kingdomId: string;
|
|
47
|
+
roleType: 'CHANCELLOR' | 'SUPERVISOR';
|
|
48
|
+
bindingId: string | null;
|
|
49
|
+
sessionId: string;
|
|
50
|
+
signal: AbortSignal;
|
|
51
|
+
}
|
|
52
|
+
export interface OwnerProfileValidationInput {
|
|
53
|
+
kingdomId: string;
|
|
54
|
+
bindingId: string;
|
|
55
|
+
roleType: OwnerManagedRole;
|
|
56
|
+
profile: Readonly<ExecutionProfileV1> | null;
|
|
57
|
+
signal: AbortSignal;
|
|
58
|
+
}
|
|
59
|
+
export interface OwnerRuntimeSessionChoice {
|
|
60
|
+
id: string;
|
|
61
|
+
label: string;
|
|
62
|
+
}
|
|
63
|
+
export interface OwnerDecisionControllerOptions {
|
|
64
|
+
now?: () => number;
|
|
65
|
+
validationTimeoutMs?: number;
|
|
66
|
+
validateTargetSession: (input: OwnerSessionValidationInput) => Promise<OwnerValidationResult>;
|
|
67
|
+
validateExecutionProfile: (input: OwnerProfileValidationInput) => Promise<OwnerValidationResult>;
|
|
68
|
+
listTargetSessions: (input: {
|
|
69
|
+
sessionIds: readonly string[];
|
|
70
|
+
signal: AbortSignal;
|
|
71
|
+
}) => Promise<readonly OwnerRuntimeSessionChoice[]>;
|
|
72
|
+
}
|
|
73
|
+
export interface OwnerOperationCatalog {
|
|
74
|
+
plans?: CollaborationPlanView[];
|
|
75
|
+
territories: {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
}[];
|
|
79
|
+
bindings: {
|
|
80
|
+
id: string;
|
|
81
|
+
roleType: string;
|
|
82
|
+
roleName: string;
|
|
83
|
+
}[];
|
|
84
|
+
runtimeSessions: OwnerRuntimeSessionChoice[];
|
|
85
|
+
workspaceRoots: string[];
|
|
86
|
+
}
|
|
87
|
+
export type OwnerOperationInput = {
|
|
88
|
+
action: 'init';
|
|
89
|
+
parameters: {
|
|
90
|
+
kingdom_name: string;
|
|
91
|
+
owner_name: string;
|
|
92
|
+
};
|
|
93
|
+
} | {
|
|
94
|
+
action: 'territory.create';
|
|
95
|
+
parameters: {
|
|
96
|
+
name: string;
|
|
97
|
+
workspace_path: string;
|
|
98
|
+
summary?: string | null;
|
|
99
|
+
};
|
|
100
|
+
} | {
|
|
101
|
+
action: 'territory.update';
|
|
102
|
+
parameters: {
|
|
103
|
+
territory_id: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
summary?: string | null;
|
|
106
|
+
};
|
|
107
|
+
} | {
|
|
108
|
+
action: 'territory.supervisor';
|
|
109
|
+
parameters: {
|
|
110
|
+
territory_id: string;
|
|
111
|
+
supervisor_binding_id: string;
|
|
112
|
+
};
|
|
113
|
+
} | {
|
|
114
|
+
action: 'role.bind';
|
|
115
|
+
parameters: {
|
|
116
|
+
role_type: OwnerManagedRole;
|
|
117
|
+
role_name: string;
|
|
118
|
+
session_id?: string | null;
|
|
119
|
+
};
|
|
120
|
+
} | {
|
|
121
|
+
action: 'role.session';
|
|
122
|
+
parameters: {
|
|
123
|
+
binding_id: string;
|
|
124
|
+
session_id: string;
|
|
125
|
+
};
|
|
126
|
+
} | {
|
|
127
|
+
action: 'ceiling';
|
|
128
|
+
parameters: {
|
|
129
|
+
ceiling: Record<string, boolean>;
|
|
130
|
+
};
|
|
131
|
+
} | {
|
|
132
|
+
action: 'execution-profile';
|
|
133
|
+
parameters: {
|
|
134
|
+
binding_id: string;
|
|
135
|
+
profile: ExecutionProfileV1 | null;
|
|
136
|
+
};
|
|
137
|
+
} | {
|
|
138
|
+
action: 'budget.policy';
|
|
139
|
+
parameters: BudgetPolicyParameters;
|
|
140
|
+
} | {
|
|
141
|
+
action: 'plan.adopt';
|
|
142
|
+
parameters: PlanAdoptionParameters;
|
|
143
|
+
};
|
|
144
|
+
export interface OwnerOperationPreview {
|
|
145
|
+
prepareId: string;
|
|
146
|
+
operationId: string;
|
|
147
|
+
decisionId: string;
|
|
148
|
+
action: OwnerMutationAction;
|
|
149
|
+
summary: string;
|
|
150
|
+
changes: {
|
|
151
|
+
label: string;
|
|
152
|
+
before: string | null;
|
|
153
|
+
after: string | null;
|
|
154
|
+
}[];
|
|
155
|
+
affected: {
|
|
156
|
+
territoryIds: string[];
|
|
157
|
+
bindingIds: string[];
|
|
158
|
+
};
|
|
159
|
+
createdAt: string;
|
|
160
|
+
expiresAt: string;
|
|
161
|
+
}
|
|
162
|
+
export interface OwnerOperationReceipt {
|
|
163
|
+
type: 'KingdomOwnerOperationReceipt/v1';
|
|
164
|
+
operationId: string;
|
|
165
|
+
prepareId: string;
|
|
166
|
+
decisionId: string;
|
|
167
|
+
kingdomId: string;
|
|
168
|
+
ownerId: string;
|
|
169
|
+
action: OwnerMutationAction;
|
|
170
|
+
inputHash: string;
|
|
171
|
+
status: 'APPLIED';
|
|
172
|
+
target: {
|
|
173
|
+
type: 'kingdom' | 'territory' | 'binding' | 'collaboration-plan';
|
|
174
|
+
id: string;
|
|
175
|
+
};
|
|
176
|
+
receiptSeq: number;
|
|
177
|
+
appliedAt: string;
|
|
178
|
+
message: string;
|
|
179
|
+
}
|
|
180
|
+
export declare class OwnerOperationError extends Error {
|
|
181
|
+
readonly code: string;
|
|
182
|
+
constructor(code: string, message: string);
|
|
183
|
+
}
|
|
184
|
+
/** Trusted-local decision registry. Public IDs and JSON views never confer authority. */
|
|
185
|
+
export declare class OwnerDecisionController {
|
|
186
|
+
private readonly store;
|
|
187
|
+
private readonly options;
|
|
188
|
+
private readonly decisions;
|
|
189
|
+
private readonly now;
|
|
190
|
+
private readonly timeout;
|
|
191
|
+
private disposed;
|
|
192
|
+
constructor(store: KingdomStore, options: OwnerDecisionControllerOptions);
|
|
193
|
+
activate(capability: OwnerControlCapability, input: OwnerDecisionInput): {
|
|
194
|
+
handle: OwnerDecisionHandle;
|
|
195
|
+
decision: OwnerDecisionView;
|
|
196
|
+
};
|
|
197
|
+
inspect(handle: OwnerDecisionHandle): OwnerDecisionView | null;
|
|
198
|
+
catalog(handle: OwnerDecisionHandle): Promise<OwnerOperationCatalog>;
|
|
199
|
+
prepare(handle: OwnerDecisionHandle, raw: OwnerOperationInput, options?: {
|
|
200
|
+
signal?: AbortSignal;
|
|
201
|
+
}): Promise<OwnerOperationPreview>;
|
|
202
|
+
commit(handle: OwnerDecisionHandle, input: {
|
|
203
|
+
prepareId: string;
|
|
204
|
+
operationId: string;
|
|
205
|
+
}, options?: {
|
|
206
|
+
signal?: AbortSignal;
|
|
207
|
+
}): Promise<OwnerOperationReceipt>;
|
|
208
|
+
receipt(handle: OwnerDecisionHandle, operationId: string): OwnerOperationReceipt | null;
|
|
209
|
+
revoke(handle: OwnerDecisionHandle): OwnerDecisionView;
|
|
210
|
+
dispose(): void;
|
|
211
|
+
private expire;
|
|
212
|
+
private invalidate;
|
|
213
|
+
private active;
|
|
214
|
+
private assertActive;
|
|
215
|
+
private observe;
|
|
216
|
+
private validate;
|
|
217
|
+
private context;
|
|
218
|
+
private guardUnsettled;
|
|
219
|
+
private changes;
|
|
220
|
+
private apply;
|
|
221
|
+
/** Synchronous closed dispatcher: no callback or transport receives an administration capability. */
|
|
222
|
+
private mutate;
|
|
223
|
+
private event;
|
|
224
|
+
private receiptEventId;
|
|
225
|
+
}
|
|
226
|
+
export {};
|