@openfairygui/backend 0.3.1 → 0.4.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/dist/node.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
2
- import { ProjectValidationReport } from "@openfairygui/core";
3
- import { UamDisplayNodeKind, UamProject, UamResource, UamTransactionOperation } from "@openfairygui/core/uam";
2
+ import { ProjectDiagnosticCode, ProjectValidationReport } from "@openfairygui/core";
3
+ import { UamComponentModel, UamComponentResource, UamComponentSelector, UamControllerModel, UamControllerSelector, UamDisplayNode, UamDisplayNodeKind, UamDisplayNodeSelector, UamGenericAssetResource, UamImageResource, UamMovieClipResource, UamPackageSelector, UamPackageSettings, UamProject, UamResource, UamResourceSelector, UamTransactionOperation, UamTransactionSupportIssueCode, UamTransitionModel, UamTransitionSelector } from "@openfairygui/core/uam";
4
4
 
5
5
  //#region src/path-policy.d.ts
6
6
  interface PathPolicyViolationError {
@@ -12,8 +12,8 @@ interface PathPolicyViolationError {
12
12
  }
13
13
  //#endregion
14
14
  //#region src/contracts.d.ts
15
- declare const BACKEND_CONTRACT_VERSION: "1.1.0-p2";
16
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 3;
15
+ declare const BACKEND_CONTRACT_VERSION: "2.0.0-p2";
16
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 10;
17
17
  declare const BACKEND_COMPATIBILITY_POLICY: {
18
18
  readonly incompatibleChange: "requires contractVersion bump";
19
19
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -24,8 +24,10 @@ interface BackendMessage {
24
24
  code: string;
25
25
  message: string;
26
26
  }
27
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
28
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
27
29
  interface BackendDiagnostic {
28
- code: string;
30
+ code: BackendDiagnosticCode;
29
31
  message: string;
30
32
  severity: 'info' | 'warning' | 'error';
31
33
  path?: string;
@@ -36,6 +38,21 @@ interface BackendDiagnostic {
36
38
  operationKind?: string;
37
39
  opIndex?: number;
38
40
  opId?: string;
41
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
42
+ owner?: BackendDiagnosticOwner;
43
+ docsUri?: string;
44
+ remediation?: BackendDiagnosticRemediation;
45
+ }
46
+ interface BackendDiagnosticRemediation {
47
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
48
+ message: string;
49
+ /** A read-only starting point, never permission to retry or mutate. */
50
+ read?: {
51
+ method: 'getProjectOutline';
52
+ input: {
53
+ sessionId: string;
54
+ };
55
+ };
39
56
  }
40
57
  interface BackendResponseMeta {
41
58
  requestId: string;
@@ -49,7 +66,88 @@ interface BackendResponseMeta {
49
66
  capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
50
67
  }
51
68
  //#endregion
69
+ //#region src/runtime/capabilities.d.ts
70
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
71
+ //#endregion
52
72
  //#region src/runtime/contracts.d.ts
73
+ declare const BACKEND_ENTITY_QUERY_LIMITS: {
74
+ readonly maxBytes: 262144;
75
+ readonly maxDepth: 32;
76
+ readonly maxNodes: 100000;
77
+ };
78
+ declare const BACKEND_TRANSACTION_PREVIEW_LIMITS: {
79
+ readonly maxBytes: 262144;
80
+ readonly maxEntries: 2000;
81
+ };
82
+ /** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
83
+ declare const BACKEND_RESOURCE_QUERY_FIELDS: readonly ["kind", "id", "name", "path", "exported", "favorite", "branch", "branchItemIds", "fileName", "file", "dimensions", "image", "movieClip"];
84
+ type ResourceQueryFields<T> = Pick<T, Extract<keyof T, typeof BACKEND_RESOURCE_QUERY_FIELDS[number]>>;
85
+ type BackendResourceSnapshot = ResourceQueryFields<UamImageResource> | ResourceQueryFields<UamMovieClipResource> | ResourceQueryFields<UamGenericAssetResource> | ResourceQueryFields<UamComponentResource>;
86
+ type BackendComponentSnapshot = Pick<UamComponentModel, 'size' | 'properties' | 'customData'>;
87
+ type BackendProjectSnapshot = Pick<UamProject, 'projectId' | 'settings'>;
88
+ interface BackendPackageSnapshot {
89
+ id: string;
90
+ name: string;
91
+ settings: UamPackageSettings;
92
+ }
93
+ type BackendEntityTarget = {
94
+ kind: 'project';
95
+ } | {
96
+ kind: 'package';
97
+ selector: UamPackageSelector;
98
+ } | {
99
+ kind: 'resource';
100
+ selector: UamResourceSelector;
101
+ } | {
102
+ kind: 'component';
103
+ selector: UamComponentSelector;
104
+ } | {
105
+ kind: 'displayNode';
106
+ selector: UamDisplayNodeSelector;
107
+ } | {
108
+ kind: 'controller';
109
+ selector: UamControllerSelector;
110
+ } | {
111
+ kind: 'transition';
112
+ selector: UamTransitionSelector;
113
+ };
114
+ interface QueryEntityInput {
115
+ sessionId: string;
116
+ target: BackendEntityTarget;
117
+ }
118
+ interface BackendEntitySnapshot {
119
+ sessionId: string;
120
+ revision: number;
121
+ target: BackendEntityTarget;
122
+ entity: {
123
+ kind: 'project';
124
+ properties: BackendProjectSnapshot;
125
+ } | {
126
+ kind: 'package';
127
+ properties: BackendPackageSnapshot;
128
+ } | {
129
+ kind: 'resource';
130
+ properties: BackendResourceSnapshot;
131
+ } | {
132
+ kind: 'component';
133
+ properties: BackendComponentSnapshot;
134
+ } | {
135
+ kind: 'displayNode';
136
+ properties: UamDisplayNode;
137
+ } | {
138
+ kind: 'controller';
139
+ properties: UamControllerModel;
140
+ } | {
141
+ kind: 'transition';
142
+ properties: UamTransitionModel;
143
+ };
144
+ }
145
+ interface EntityQueryError {
146
+ code: 'entity_query_failed';
147
+ message: string;
148
+ sessionId: string;
149
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
150
+ }
53
151
  /** An exclusive lock owned for the lifetime of one backend session. */
54
152
  interface BackendSessionLock {
55
153
  /** Persist optional host metadata without changing lock ownership. */
@@ -128,6 +226,8 @@ interface BackendCapabilityManifest {
128
226
  diagnostics: {
129
227
  stableCodes: true;
130
228
  errorDiagnosticMirror: true;
229
+ recoveryGuides: 'all-formal-codes';
230
+ automaticRepair: false;
131
231
  };
132
232
  }
133
233
  interface BackendCapabilities {
@@ -136,14 +236,26 @@ interface BackendCapabilities {
136
236
  transactionKernelOwner: '@openfairygui/core';
137
237
  appSeamOwner: '@openfairygui/functions';
138
238
  runtimeOwner: '@openfairygui/backend';
139
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'getProjectOutline', 'validateSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
239
+ methods: typeof BACKEND_METHODS;
140
240
  read: {
141
241
  capabilitySnapshot: true;
142
242
  sessionSnapshot: true;
143
243
  projectOutline: true;
244
+ entityQuery: {
245
+ kinds: readonly BackendEntityTarget['kind'][];
246
+ projection: 'properties';
247
+ sourceBytes: false;
248
+ limits: typeof BACKEND_ENTITY_QUERY_LIMITS;
249
+ };
144
250
  projectValidation: true;
145
251
  };
146
252
  authoring: {
253
+ preflightTransaction: {
254
+ mode: 'execute-and-discard';
255
+ reservesRevision: false;
256
+ impact: 'model-diff';
257
+ limits: typeof BACKEND_TRANSACTION_PREVIEW_LIMITS;
258
+ };
147
259
  applyTransaction: true;
148
260
  saveSession: true;
149
261
  resourceKinds: readonly string[];
@@ -476,7 +588,7 @@ interface RefreshCacheInput {
476
588
  sessionId: string;
477
589
  reason?: 'manual' | 'session_open' | 'after_save';
478
590
  }
479
- type BackendError = SessionNotFoundError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
591
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
480
592
  interface ProjectRootNotAllowedError {
481
593
  code: 'project_root_not_allowed';
482
594
  message: string;
@@ -492,6 +604,41 @@ interface ApplySessionTransactionInput {
492
604
  expectedRevision: number;
493
605
  operations: UamTransactionOperation[];
494
606
  }
607
+ interface BackendTransactionPreview {
608
+ sessionId: string;
609
+ baseRevision: number;
610
+ /** Revision after applying this batch at baseRevision, including an empty batch. Not reserved. */
611
+ projectedRevision: number;
612
+ mode: 'execute-and-discard';
613
+ /** Complete, bounded comparison of current and projected UAM, not unsaved changes since last save. */
614
+ impact: {
615
+ entities: BackendTransactionEntityChange[]; /** Project-relative paths from the actual ProjectWriter, including empty directories. Not a disk write plan. */
616
+ files: Array<{
617
+ path: string;
618
+ kind: 'file' | 'directory';
619
+ change: 'added' | 'removed' | 'updated';
620
+ }>;
621
+ };
622
+ persistence: {
623
+ requiredAfterApply: true;
624
+ nextAction: 'saveSession' | 'materializeSession' | 'host-action';
625
+ fileSystemAvailable: boolean;
626
+ uamFidelity: BackendSessionSnapshot['uamFidelity']; /** Preflight never verifies filesystem permissions, materialize destinations or actual disk state. */
627
+ writeVerified: false;
628
+ };
629
+ }
630
+ interface BackendTransactionEntityChange {
631
+ target: BackendEntityTarget;
632
+ change: 'added' | 'removed' | 'updated';
633
+ /** Changed top-level property names; child collections contain identities and preserve their order. */
634
+ fields: string[];
635
+ }
636
+ interface TransactionPreviewError {
637
+ code: 'transaction_preview_failed';
638
+ message: string;
639
+ sessionId: string;
640
+ reason: 'response_budget_exceeded' | 'projection_failed';
641
+ }
495
642
  interface GetProjectOutlineInput {
496
643
  sessionId: string;
497
644
  }
@@ -502,7 +649,9 @@ interface OpenProjectSessionInput {
502
649
  /** Authoritative UAM project. Use BackendRuntime.openSession() when importing an existing project from storage. */
503
650
  project: UamProject;
504
651
  sessionId?: string;
652
+ /** Session identity only; without explicit storage or a per-call filesystem this grants no filesystem access. */
505
653
  canonicalProjectPath?: string;
654
+ /** Host-defined session identity; not a filesystem authorization or an allowed-root override. */
506
655
  canonicalPathKey?: string;
507
656
  /** Optional writeback target for the authoritative UAM project; this is not an import source. */
508
657
  storage?: BackendProjectSessionStorage;
@@ -564,7 +713,9 @@ declare class BackendRuntime {
564
713
  sessionId: string;
565
714
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
566
715
  getProjectOutline(input: GetProjectOutlineInput): BackendResult<BackendProjectOutline, SessionNotFoundError>;
716
+ queryEntity(input: QueryEntityInput): BackendResult<BackendEntitySnapshot, SessionNotFoundError | EntityQueryError>;
567
717
  validateSession(input: ValidateSessionInput): BackendResult<ProjectValidationReport, SessionNotFoundError>;
718
+ preflightTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendTransactionPreview, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError | TransactionPreviewError>>;
568
719
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
569
720
  saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
570
721
  materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
package/dist/node.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { UamDisplayNodeKind, UamProject, UamResource, UamTransactionOperation } from "@openfairygui/core/uam";
1
+ import { UamComponentModel, UamComponentResource, UamComponentSelector, UamControllerModel, UamControllerSelector, UamDisplayNode, UamDisplayNodeKind, UamDisplayNodeSelector, UamGenericAssetResource, UamImageResource, UamMovieClipResource, UamPackageSelector, UamPackageSettings, UamProject, UamResource, UamResourceSelector, UamTransactionOperation, UamTransactionSupportIssueCode, UamTransitionModel, UamTransitionSelector } from "@openfairygui/core/uam";
2
2
  import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
3
- import { ProjectValidationReport } from "@openfairygui/core";
3
+ import { ProjectDiagnosticCode, ProjectValidationReport } from "@openfairygui/core";
4
4
 
5
5
  //#region src/path-policy.d.ts
6
6
  interface PathPolicyViolationError {
@@ -12,8 +12,8 @@ interface PathPolicyViolationError {
12
12
  }
13
13
  //#endregion
14
14
  //#region src/contracts.d.ts
15
- declare const BACKEND_CONTRACT_VERSION: "1.1.0-p2";
16
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 3;
15
+ declare const BACKEND_CONTRACT_VERSION: "2.0.0-p2";
16
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 10;
17
17
  declare const BACKEND_COMPATIBILITY_POLICY: {
18
18
  readonly incompatibleChange: "requires contractVersion bump";
19
19
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -24,8 +24,10 @@ interface BackendMessage {
24
24
  code: string;
25
25
  message: string;
26
26
  }
27
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
28
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
27
29
  interface BackendDiagnostic {
28
- code: string;
30
+ code: BackendDiagnosticCode;
29
31
  message: string;
30
32
  severity: 'info' | 'warning' | 'error';
31
33
  path?: string;
@@ -36,6 +38,21 @@ interface BackendDiagnostic {
36
38
  operationKind?: string;
37
39
  opIndex?: number;
38
40
  opId?: string;
41
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
42
+ owner?: BackendDiagnosticOwner;
43
+ docsUri?: string;
44
+ remediation?: BackendDiagnosticRemediation;
45
+ }
46
+ interface BackendDiagnosticRemediation {
47
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
48
+ message: string;
49
+ /** A read-only starting point, never permission to retry or mutate. */
50
+ read?: {
51
+ method: 'getProjectOutline';
52
+ input: {
53
+ sessionId: string;
54
+ };
55
+ };
39
56
  }
40
57
  interface BackendResponseMeta {
41
58
  requestId: string;
@@ -49,7 +66,88 @@ interface BackendResponseMeta {
49
66
  capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
50
67
  }
51
68
  //#endregion
69
+ //#region src/runtime/capabilities.d.ts
70
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
71
+ //#endregion
52
72
  //#region src/runtime/contracts.d.ts
73
+ declare const BACKEND_ENTITY_QUERY_LIMITS: {
74
+ readonly maxBytes: 262144;
75
+ readonly maxDepth: 32;
76
+ readonly maxNodes: 100000;
77
+ };
78
+ declare const BACKEND_TRANSACTION_PREVIEW_LIMITS: {
79
+ readonly maxBytes: 262144;
80
+ readonly maxEntries: 2000;
81
+ };
82
+ /** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
83
+ declare const BACKEND_RESOURCE_QUERY_FIELDS: readonly ["kind", "id", "name", "path", "exported", "favorite", "branch", "branchItemIds", "fileName", "file", "dimensions", "image", "movieClip"];
84
+ type ResourceQueryFields<T> = Pick<T, Extract<keyof T, typeof BACKEND_RESOURCE_QUERY_FIELDS[number]>>;
85
+ type BackendResourceSnapshot = ResourceQueryFields<UamImageResource> | ResourceQueryFields<UamMovieClipResource> | ResourceQueryFields<UamGenericAssetResource> | ResourceQueryFields<UamComponentResource>;
86
+ type BackendComponentSnapshot = Pick<UamComponentModel, 'size' | 'properties' | 'customData'>;
87
+ type BackendProjectSnapshot = Pick<UamProject, 'projectId' | 'settings'>;
88
+ interface BackendPackageSnapshot {
89
+ id: string;
90
+ name: string;
91
+ settings: UamPackageSettings;
92
+ }
93
+ type BackendEntityTarget = {
94
+ kind: 'project';
95
+ } | {
96
+ kind: 'package';
97
+ selector: UamPackageSelector;
98
+ } | {
99
+ kind: 'resource';
100
+ selector: UamResourceSelector;
101
+ } | {
102
+ kind: 'component';
103
+ selector: UamComponentSelector;
104
+ } | {
105
+ kind: 'displayNode';
106
+ selector: UamDisplayNodeSelector;
107
+ } | {
108
+ kind: 'controller';
109
+ selector: UamControllerSelector;
110
+ } | {
111
+ kind: 'transition';
112
+ selector: UamTransitionSelector;
113
+ };
114
+ interface QueryEntityInput {
115
+ sessionId: string;
116
+ target: BackendEntityTarget;
117
+ }
118
+ interface BackendEntitySnapshot {
119
+ sessionId: string;
120
+ revision: number;
121
+ target: BackendEntityTarget;
122
+ entity: {
123
+ kind: 'project';
124
+ properties: BackendProjectSnapshot;
125
+ } | {
126
+ kind: 'package';
127
+ properties: BackendPackageSnapshot;
128
+ } | {
129
+ kind: 'resource';
130
+ properties: BackendResourceSnapshot;
131
+ } | {
132
+ kind: 'component';
133
+ properties: BackendComponentSnapshot;
134
+ } | {
135
+ kind: 'displayNode';
136
+ properties: UamDisplayNode;
137
+ } | {
138
+ kind: 'controller';
139
+ properties: UamControllerModel;
140
+ } | {
141
+ kind: 'transition';
142
+ properties: UamTransitionModel;
143
+ };
144
+ }
145
+ interface EntityQueryError {
146
+ code: 'entity_query_failed';
147
+ message: string;
148
+ sessionId: string;
149
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
150
+ }
53
151
  /** An exclusive lock owned for the lifetime of one backend session. */
54
152
  interface BackendSessionLock {
55
153
  /** Persist optional host metadata without changing lock ownership. */
@@ -128,6 +226,8 @@ interface BackendCapabilityManifest {
128
226
  diagnostics: {
129
227
  stableCodes: true;
130
228
  errorDiagnosticMirror: true;
229
+ recoveryGuides: 'all-formal-codes';
230
+ automaticRepair: false;
131
231
  };
132
232
  }
133
233
  interface BackendCapabilities {
@@ -136,14 +236,26 @@ interface BackendCapabilities {
136
236
  transactionKernelOwner: '@openfairygui/core';
137
237
  appSeamOwner: '@openfairygui/functions';
138
238
  runtimeOwner: '@openfairygui/backend';
139
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'getProjectOutline', 'validateSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
239
+ methods: typeof BACKEND_METHODS;
140
240
  read: {
141
241
  capabilitySnapshot: true;
142
242
  sessionSnapshot: true;
143
243
  projectOutline: true;
244
+ entityQuery: {
245
+ kinds: readonly BackendEntityTarget['kind'][];
246
+ projection: 'properties';
247
+ sourceBytes: false;
248
+ limits: typeof BACKEND_ENTITY_QUERY_LIMITS;
249
+ };
144
250
  projectValidation: true;
145
251
  };
146
252
  authoring: {
253
+ preflightTransaction: {
254
+ mode: 'execute-and-discard';
255
+ reservesRevision: false;
256
+ impact: 'model-diff';
257
+ limits: typeof BACKEND_TRANSACTION_PREVIEW_LIMITS;
258
+ };
147
259
  applyTransaction: true;
148
260
  saveSession: true;
149
261
  resourceKinds: readonly string[];
@@ -476,7 +588,7 @@ interface RefreshCacheInput {
476
588
  sessionId: string;
477
589
  reason?: 'manual' | 'session_open' | 'after_save';
478
590
  }
479
- type BackendError = SessionNotFoundError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
591
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
480
592
  interface ProjectRootNotAllowedError {
481
593
  code: 'project_root_not_allowed';
482
594
  message: string;
@@ -492,6 +604,41 @@ interface ApplySessionTransactionInput {
492
604
  expectedRevision: number;
493
605
  operations: UamTransactionOperation[];
494
606
  }
607
+ interface BackendTransactionPreview {
608
+ sessionId: string;
609
+ baseRevision: number;
610
+ /** Revision after applying this batch at baseRevision, including an empty batch. Not reserved. */
611
+ projectedRevision: number;
612
+ mode: 'execute-and-discard';
613
+ /** Complete, bounded comparison of current and projected UAM, not unsaved changes since last save. */
614
+ impact: {
615
+ entities: BackendTransactionEntityChange[]; /** Project-relative paths from the actual ProjectWriter, including empty directories. Not a disk write plan. */
616
+ files: Array<{
617
+ path: string;
618
+ kind: 'file' | 'directory';
619
+ change: 'added' | 'removed' | 'updated';
620
+ }>;
621
+ };
622
+ persistence: {
623
+ requiredAfterApply: true;
624
+ nextAction: 'saveSession' | 'materializeSession' | 'host-action';
625
+ fileSystemAvailable: boolean;
626
+ uamFidelity: BackendSessionSnapshot['uamFidelity']; /** Preflight never verifies filesystem permissions, materialize destinations or actual disk state. */
627
+ writeVerified: false;
628
+ };
629
+ }
630
+ interface BackendTransactionEntityChange {
631
+ target: BackendEntityTarget;
632
+ change: 'added' | 'removed' | 'updated';
633
+ /** Changed top-level property names; child collections contain identities and preserve their order. */
634
+ fields: string[];
635
+ }
636
+ interface TransactionPreviewError {
637
+ code: 'transaction_preview_failed';
638
+ message: string;
639
+ sessionId: string;
640
+ reason: 'response_budget_exceeded' | 'projection_failed';
641
+ }
495
642
  interface GetProjectOutlineInput {
496
643
  sessionId: string;
497
644
  }
@@ -502,7 +649,9 @@ interface OpenProjectSessionInput {
502
649
  /** Authoritative UAM project. Use BackendRuntime.openSession() when importing an existing project from storage. */
503
650
  project: UamProject;
504
651
  sessionId?: string;
652
+ /** Session identity only; without explicit storage or a per-call filesystem this grants no filesystem access. */
505
653
  canonicalProjectPath?: string;
654
+ /** Host-defined session identity; not a filesystem authorization or an allowed-root override. */
506
655
  canonicalPathKey?: string;
507
656
  /** Optional writeback target for the authoritative UAM project; this is not an import source. */
508
657
  storage?: BackendProjectSessionStorage;
@@ -564,7 +713,9 @@ declare class BackendRuntime {
564
713
  sessionId: string;
565
714
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
566
715
  getProjectOutline(input: GetProjectOutlineInput): BackendResult<BackendProjectOutline, SessionNotFoundError>;
716
+ queryEntity(input: QueryEntityInput): BackendResult<BackendEntitySnapshot, SessionNotFoundError | EntityQueryError>;
567
717
  validateSession(input: ValidateSessionInput): BackendResult<ProjectValidationReport, SessionNotFoundError>;
718
+ preflightTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendTransactionPreview, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError | TransactionPreviewError>>;
568
719
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
569
720
  saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
570
721
  materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;