@openfairygui/backend 0.3.1 → 0.5.0-alpha.1

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,7 @@
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 * as _$_openfairygui_core0 from "@openfairygui/core";
3
+ import { ProjectDiagnosticCode, ProjectValidationReport } from "@openfairygui/core";
4
+ import { UamComponentModel, UamComponentResource, UamComponentSelector, UamControllerModel, UamControllerSelector, UamDisplayNode, UamDisplayNodeKind, UamDisplayNodeSelector, UamGenericAssetResource, UamImageResource, UamMovieClipResource, UamPackage, UamPackageSelector, UamPackageSettings, UamProject, UamResource, UamResourceSelector, UamTransactionOperation, UamTransactionSupportIssueCode, UamTransitionModel, UamTransitionSelector } from "@openfairygui/core/uam";
4
5
 
5
6
  //#region src/path-policy.d.ts
6
7
  interface PathPolicyViolationError {
@@ -12,8 +13,8 @@ interface PathPolicyViolationError {
12
13
  }
13
14
  //#endregion
14
15
  //#region src/contracts.d.ts
15
- declare const BACKEND_CONTRACT_VERSION: "1.1.0-p2";
16
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 3;
16
+ declare const BACKEND_CONTRACT_VERSION: "2.0.0-p2";
17
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 11;
17
18
  declare const BACKEND_COMPATIBILITY_POLICY: {
18
19
  readonly incompatibleChange: "requires contractVersion bump";
19
20
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -24,8 +25,10 @@ interface BackendMessage {
24
25
  code: string;
25
26
  message: string;
26
27
  }
28
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
29
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
27
30
  interface BackendDiagnostic {
28
- code: string;
31
+ code: BackendDiagnosticCode;
29
32
  message: string;
30
33
  severity: 'info' | 'warning' | 'error';
31
34
  path?: string;
@@ -36,6 +39,21 @@ interface BackendDiagnostic {
36
39
  operationKind?: string;
37
40
  opIndex?: number;
38
41
  opId?: string;
42
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
43
+ owner?: BackendDiagnosticOwner;
44
+ docsUri?: string;
45
+ remediation?: BackendDiagnosticRemediation;
46
+ }
47
+ interface BackendDiagnosticRemediation {
48
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
49
+ message: string;
50
+ /** A read-only starting point, never permission to retry or mutate. */
51
+ read?: {
52
+ method: 'getProjectOutline';
53
+ input: {
54
+ sessionId: string;
55
+ };
56
+ };
39
57
  }
40
58
  interface BackendResponseMeta {
41
59
  requestId: string;
@@ -49,7 +67,139 @@ interface BackendResponseMeta {
49
67
  capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
50
68
  }
51
69
  //#endregion
70
+ //#region src/runtime/capabilities.d.ts
71
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "readSessionState", "readResourceBytes", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
72
+ //#endregion
52
73
  //#region src/runtime/contracts.d.ts
74
+ declare const BACKEND_ENTITY_QUERY_LIMITS: {
75
+ readonly maxBytes: 262144;
76
+ readonly maxDepth: 32;
77
+ readonly maxNodes: 100000;
78
+ };
79
+ declare const BACKEND_SESSION_READ_LIMITS: {
80
+ readonly model: {
81
+ readonly maxBytes: 4194304;
82
+ readonly maxDepth: 64;
83
+ readonly maxNodes: 500000;
84
+ };
85
+ readonly resourceBytes: 1048576;
86
+ };
87
+ /** The public UAM model, excluding only each asset resource's primary sourceBytes. */
88
+ type BackendSessionResourceModel = UamComponentResource | Omit<UamImageResource, 'sourceBytes'> | Omit<UamMovieClipResource, 'sourceBytes'> | Omit<UamGenericAssetResource, 'sourceBytes'>;
89
+ interface BackendSessionPackageModel extends Omit<UamPackage, 'resources'> {
90
+ resources: BackendSessionResourceModel[];
91
+ }
92
+ interface BackendSessionProjectModel extends Omit<UamProject, 'packages'> {
93
+ packages: BackendSessionPackageModel[];
94
+ }
95
+ interface ReadSessionStateInput {
96
+ sessionId: string;
97
+ expectedRevision?: number;
98
+ }
99
+ interface ReadResourceBytesInput {
100
+ sessionId: string;
101
+ expectedRevision: number;
102
+ selector: UamResourceSelector;
103
+ }
104
+ interface BackendSessionStateSnapshot extends Pick<BackendSessionSnapshot, 'sessionId' | 'revision' | 'lastSavedRevision' | 'dirty' | 'uamFidelity'> {
105
+ project: BackendSessionProjectModel;
106
+ readDiagnostics: _$_openfairygui_core0.ProjectDiagnostic[];
107
+ /** Source-read completeness, not a guarantee of resource bytes or downstream usability. */
108
+ readComplete: boolean;
109
+ }
110
+ interface BackendResourceBytesSnapshot {
111
+ sessionId: string;
112
+ revision: number;
113
+ selector: UamResourceSelector;
114
+ /** Only primary bytes already held in this session; no filesystem hydration. */
115
+ sourceBytes: Uint8Array;
116
+ }
117
+ interface SessionReadError {
118
+ code: 'session_read_failed';
119
+ message: string;
120
+ sessionId: string;
121
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'unsupported_resource' | 'bytes_unavailable' | 'response_budget_exceeded' | 'non_json_value';
122
+ }
123
+ interface SessionStaleReadError {
124
+ code: 'stale_read';
125
+ message: string;
126
+ sessionId: string;
127
+ expectedRevision: number;
128
+ actualRevision: number;
129
+ }
130
+ declare const BACKEND_TRANSACTION_PREVIEW_LIMITS: {
131
+ readonly maxBytes: 262144;
132
+ readonly maxEntries: 2000;
133
+ };
134
+ /** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
135
+ declare const BACKEND_RESOURCE_QUERY_FIELDS: readonly ["kind", "id", "name", "path", "exported", "favorite", "branch", "branchItemIds", "fileName", "file", "dimensions", "image", "movieClip"];
136
+ type ResourceQueryFields<T> = Pick<T, Extract<keyof T, typeof BACKEND_RESOURCE_QUERY_FIELDS[number]>>;
137
+ type BackendResourceSnapshot = ResourceQueryFields<UamImageResource> | ResourceQueryFields<UamMovieClipResource> | ResourceQueryFields<UamGenericAssetResource> | ResourceQueryFields<UamComponentResource>;
138
+ type BackendComponentSnapshot = Pick<UamComponentModel, 'size' | 'properties' | 'customData'>;
139
+ type BackendProjectSnapshot = Pick<UamProject, 'projectId' | 'settings'>;
140
+ interface BackendPackageSnapshot {
141
+ id: string;
142
+ name: string;
143
+ settings: UamPackageSettings;
144
+ }
145
+ type BackendEntityTarget = {
146
+ kind: 'project';
147
+ } | {
148
+ kind: 'package';
149
+ selector: UamPackageSelector;
150
+ } | {
151
+ kind: 'resource';
152
+ selector: UamResourceSelector;
153
+ } | {
154
+ kind: 'component';
155
+ selector: UamComponentSelector;
156
+ } | {
157
+ kind: 'displayNode';
158
+ selector: UamDisplayNodeSelector;
159
+ } | {
160
+ kind: 'controller';
161
+ selector: UamControllerSelector;
162
+ } | {
163
+ kind: 'transition';
164
+ selector: UamTransitionSelector;
165
+ };
166
+ interface QueryEntityInput {
167
+ sessionId: string;
168
+ target: BackendEntityTarget;
169
+ }
170
+ interface BackendEntitySnapshot {
171
+ sessionId: string;
172
+ revision: number;
173
+ target: BackendEntityTarget;
174
+ entity: {
175
+ kind: 'project';
176
+ properties: BackendProjectSnapshot;
177
+ } | {
178
+ kind: 'package';
179
+ properties: BackendPackageSnapshot;
180
+ } | {
181
+ kind: 'resource';
182
+ properties: BackendResourceSnapshot;
183
+ } | {
184
+ kind: 'component';
185
+ properties: BackendComponentSnapshot;
186
+ } | {
187
+ kind: 'displayNode';
188
+ properties: UamDisplayNode;
189
+ } | {
190
+ kind: 'controller';
191
+ properties: UamControllerModel;
192
+ } | {
193
+ kind: 'transition';
194
+ properties: UamTransitionModel;
195
+ };
196
+ }
197
+ interface EntityQueryError {
198
+ code: 'entity_query_failed';
199
+ message: string;
200
+ sessionId: string;
201
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
202
+ }
53
203
  /** An exclusive lock owned for the lifetime of one backend session. */
54
204
  interface BackendSessionLock {
55
205
  /** Persist optional host metadata without changing lock ownership. */
@@ -128,6 +278,8 @@ interface BackendCapabilityManifest {
128
278
  diagnostics: {
129
279
  stableCodes: true;
130
280
  errorDiagnosticMirror: true;
281
+ recoveryGuides: 'all-formal-codes';
282
+ automaticRepair: false;
131
283
  };
132
284
  }
133
285
  interface BackendCapabilities {
@@ -136,14 +288,35 @@ interface BackendCapabilities {
136
288
  transactionKernelOwner: '@openfairygui/core';
137
289
  appSeamOwner: '@openfairygui/functions';
138
290
  runtimeOwner: '@openfairygui/backend';
139
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'getProjectOutline', 'validateSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
291
+ methods: typeof BACKEND_METHODS;
140
292
  read: {
141
293
  capabilitySnapshot: true;
142
294
  sessionSnapshot: true;
143
295
  projectOutline: true;
296
+ entityQuery: {
297
+ kinds: readonly BackendEntityTarget['kind'][];
298
+ projection: 'properties';
299
+ sourceBytes: false;
300
+ limits: typeof BACKEND_ENTITY_QUERY_LIMITS;
301
+ };
302
+ sessionState: {
303
+ sourceBytes: false;
304
+ limits: typeof BACKEND_SESSION_READ_LIMITS.model;
305
+ };
306
+ resourceBytes: {
307
+ expectedRevisionRequired: true;
308
+ hydration: false;
309
+ maxBytes: typeof BACKEND_SESSION_READ_LIMITS.resourceBytes;
310
+ };
144
311
  projectValidation: true;
145
312
  };
146
313
  authoring: {
314
+ preflightTransaction: {
315
+ mode: 'execute-and-discard';
316
+ reservesRevision: false;
317
+ impact: 'model-diff';
318
+ limits: typeof BACKEND_TRANSACTION_PREVIEW_LIMITS;
319
+ };
147
320
  applyTransaction: true;
148
321
  saveSession: true;
149
322
  resourceKinds: readonly string[];
@@ -476,7 +649,7 @@ interface RefreshCacheInput {
476
649
  sessionId: string;
477
650
  reason?: 'manual' | 'session_open' | 'after_save';
478
651
  }
479
- type BackendError = SessionNotFoundError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
652
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionReadError | SessionStaleReadError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
480
653
  interface ProjectRootNotAllowedError {
481
654
  code: 'project_root_not_allowed';
482
655
  message: string;
@@ -492,6 +665,41 @@ interface ApplySessionTransactionInput {
492
665
  expectedRevision: number;
493
666
  operations: UamTransactionOperation[];
494
667
  }
668
+ interface BackendTransactionPreview {
669
+ sessionId: string;
670
+ baseRevision: number;
671
+ /** Revision after applying this batch at baseRevision, including an empty batch. Not reserved. */
672
+ projectedRevision: number;
673
+ mode: 'execute-and-discard';
674
+ /** Complete, bounded comparison of current and projected UAM, not unsaved changes since last save. */
675
+ impact: {
676
+ entities: BackendTransactionEntityChange[]; /** Project-relative paths from the actual ProjectWriter, including empty directories. Not a disk write plan. */
677
+ files: Array<{
678
+ path: string;
679
+ kind: 'file' | 'directory';
680
+ change: 'added' | 'removed' | 'updated';
681
+ }>;
682
+ };
683
+ persistence: {
684
+ requiredAfterApply: true;
685
+ nextAction: 'saveSession' | 'materializeSession' | 'host-action';
686
+ fileSystemAvailable: boolean;
687
+ uamFidelity: BackendSessionSnapshot['uamFidelity']; /** Preflight never verifies filesystem permissions, materialize destinations or actual disk state. */
688
+ writeVerified: false;
689
+ };
690
+ }
691
+ interface BackendTransactionEntityChange {
692
+ target: BackendEntityTarget;
693
+ change: 'added' | 'removed' | 'updated';
694
+ /** Changed top-level property names; child collections contain identities and preserve their order. */
695
+ fields: string[];
696
+ }
697
+ interface TransactionPreviewError {
698
+ code: 'transaction_preview_failed';
699
+ message: string;
700
+ sessionId: string;
701
+ reason: 'response_budget_exceeded' | 'projection_failed';
702
+ }
495
703
  interface GetProjectOutlineInput {
496
704
  sessionId: string;
497
705
  }
@@ -502,7 +710,9 @@ interface OpenProjectSessionInput {
502
710
  /** Authoritative UAM project. Use BackendRuntime.openSession() when importing an existing project from storage. */
503
711
  project: UamProject;
504
712
  sessionId?: string;
713
+ /** Session identity only; without explicit storage or a per-call filesystem this grants no filesystem access. */
505
714
  canonicalProjectPath?: string;
715
+ /** Host-defined session identity; not a filesystem authorization or an allowed-root override. */
506
716
  canonicalPathKey?: string;
507
717
  /** Optional writeback target for the authoritative UAM project; this is not an import source. */
508
718
  storage?: BackendProjectSessionStorage;
@@ -564,7 +774,11 @@ declare class BackendRuntime {
564
774
  sessionId: string;
565
775
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
566
776
  getProjectOutline(input: GetProjectOutlineInput): BackendResult<BackendProjectOutline, SessionNotFoundError>;
777
+ queryEntity(input: QueryEntityInput): BackendResult<BackendEntitySnapshot, SessionNotFoundError | EntityQueryError>;
778
+ readSessionState(input: ReadSessionStateInput): BackendResult<BackendSessionStateSnapshot, SessionNotFoundError | SessionReadError | SessionStaleReadError>;
779
+ readResourceBytes(input: ReadResourceBytesInput): BackendResult<BackendResourceBytesSnapshot, SessionNotFoundError | SessionReadError | SessionStaleReadError>;
567
780
  validateSession(input: ValidateSessionInput): BackendResult<ProjectValidationReport, SessionNotFoundError>;
781
+ preflightTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendTransactionPreview, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError | TransactionPreviewError>>;
568
782
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
569
783
  saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
570
784
  materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
package/dist/node.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import { UamDisplayNodeKind, UamProject, UamResource, UamTransactionOperation } from "@openfairygui/core/uam";
1
+ import { UamComponentModel, UamComponentResource, UamComponentSelector, UamControllerModel, UamControllerSelector, UamDisplayNode, UamDisplayNodeKind, UamDisplayNodeSelector, UamGenericAssetResource, UamImageResource, UamMovieClipResource, UamPackage, 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 * as _$_openfairygui_core0 from "@openfairygui/core";
4
+ import { ProjectDiagnosticCode, ProjectValidationReport } from "@openfairygui/core";
4
5
 
5
6
  //#region src/path-policy.d.ts
6
7
  interface PathPolicyViolationError {
@@ -12,8 +13,8 @@ interface PathPolicyViolationError {
12
13
  }
13
14
  //#endregion
14
15
  //#region src/contracts.d.ts
15
- declare const BACKEND_CONTRACT_VERSION: "1.1.0-p2";
16
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 3;
16
+ declare const BACKEND_CONTRACT_VERSION: "2.0.0-p2";
17
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 11;
17
18
  declare const BACKEND_COMPATIBILITY_POLICY: {
18
19
  readonly incompatibleChange: "requires contractVersion bump";
19
20
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -24,8 +25,10 @@ interface BackendMessage {
24
25
  code: string;
25
26
  message: string;
26
27
  }
28
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
29
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
27
30
  interface BackendDiagnostic {
28
- code: string;
31
+ code: BackendDiagnosticCode;
29
32
  message: string;
30
33
  severity: 'info' | 'warning' | 'error';
31
34
  path?: string;
@@ -36,6 +39,21 @@ interface BackendDiagnostic {
36
39
  operationKind?: string;
37
40
  opIndex?: number;
38
41
  opId?: string;
42
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
43
+ owner?: BackendDiagnosticOwner;
44
+ docsUri?: string;
45
+ remediation?: BackendDiagnosticRemediation;
46
+ }
47
+ interface BackendDiagnosticRemediation {
48
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
49
+ message: string;
50
+ /** A read-only starting point, never permission to retry or mutate. */
51
+ read?: {
52
+ method: 'getProjectOutline';
53
+ input: {
54
+ sessionId: string;
55
+ };
56
+ };
39
57
  }
40
58
  interface BackendResponseMeta {
41
59
  requestId: string;
@@ -49,7 +67,139 @@ interface BackendResponseMeta {
49
67
  capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
50
68
  }
51
69
  //#endregion
70
+ //#region src/runtime/capabilities.d.ts
71
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "readSessionState", "readResourceBytes", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
72
+ //#endregion
52
73
  //#region src/runtime/contracts.d.ts
74
+ declare const BACKEND_ENTITY_QUERY_LIMITS: {
75
+ readonly maxBytes: 262144;
76
+ readonly maxDepth: 32;
77
+ readonly maxNodes: 100000;
78
+ };
79
+ declare const BACKEND_SESSION_READ_LIMITS: {
80
+ readonly model: {
81
+ readonly maxBytes: 4194304;
82
+ readonly maxDepth: 64;
83
+ readonly maxNodes: 500000;
84
+ };
85
+ readonly resourceBytes: 1048576;
86
+ };
87
+ /** The public UAM model, excluding only each asset resource's primary sourceBytes. */
88
+ type BackendSessionResourceModel = UamComponentResource | Omit<UamImageResource, 'sourceBytes'> | Omit<UamMovieClipResource, 'sourceBytes'> | Omit<UamGenericAssetResource, 'sourceBytes'>;
89
+ interface BackendSessionPackageModel extends Omit<UamPackage, 'resources'> {
90
+ resources: BackendSessionResourceModel[];
91
+ }
92
+ interface BackendSessionProjectModel extends Omit<UamProject, 'packages'> {
93
+ packages: BackendSessionPackageModel[];
94
+ }
95
+ interface ReadSessionStateInput {
96
+ sessionId: string;
97
+ expectedRevision?: number;
98
+ }
99
+ interface ReadResourceBytesInput {
100
+ sessionId: string;
101
+ expectedRevision: number;
102
+ selector: UamResourceSelector;
103
+ }
104
+ interface BackendSessionStateSnapshot extends Pick<BackendSessionSnapshot, 'sessionId' | 'revision' | 'lastSavedRevision' | 'dirty' | 'uamFidelity'> {
105
+ project: BackendSessionProjectModel;
106
+ readDiagnostics: _$_openfairygui_core0.ProjectDiagnostic[];
107
+ /** Source-read completeness, not a guarantee of resource bytes or downstream usability. */
108
+ readComplete: boolean;
109
+ }
110
+ interface BackendResourceBytesSnapshot {
111
+ sessionId: string;
112
+ revision: number;
113
+ selector: UamResourceSelector;
114
+ /** Only primary bytes already held in this session; no filesystem hydration. */
115
+ sourceBytes: Uint8Array;
116
+ }
117
+ interface SessionReadError {
118
+ code: 'session_read_failed';
119
+ message: string;
120
+ sessionId: string;
121
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'unsupported_resource' | 'bytes_unavailable' | 'response_budget_exceeded' | 'non_json_value';
122
+ }
123
+ interface SessionStaleReadError {
124
+ code: 'stale_read';
125
+ message: string;
126
+ sessionId: string;
127
+ expectedRevision: number;
128
+ actualRevision: number;
129
+ }
130
+ declare const BACKEND_TRANSACTION_PREVIEW_LIMITS: {
131
+ readonly maxBytes: 262144;
132
+ readonly maxEntries: 2000;
133
+ };
134
+ /** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
135
+ declare const BACKEND_RESOURCE_QUERY_FIELDS: readonly ["kind", "id", "name", "path", "exported", "favorite", "branch", "branchItemIds", "fileName", "file", "dimensions", "image", "movieClip"];
136
+ type ResourceQueryFields<T> = Pick<T, Extract<keyof T, typeof BACKEND_RESOURCE_QUERY_FIELDS[number]>>;
137
+ type BackendResourceSnapshot = ResourceQueryFields<UamImageResource> | ResourceQueryFields<UamMovieClipResource> | ResourceQueryFields<UamGenericAssetResource> | ResourceQueryFields<UamComponentResource>;
138
+ type BackendComponentSnapshot = Pick<UamComponentModel, 'size' | 'properties' | 'customData'>;
139
+ type BackendProjectSnapshot = Pick<UamProject, 'projectId' | 'settings'>;
140
+ interface BackendPackageSnapshot {
141
+ id: string;
142
+ name: string;
143
+ settings: UamPackageSettings;
144
+ }
145
+ type BackendEntityTarget = {
146
+ kind: 'project';
147
+ } | {
148
+ kind: 'package';
149
+ selector: UamPackageSelector;
150
+ } | {
151
+ kind: 'resource';
152
+ selector: UamResourceSelector;
153
+ } | {
154
+ kind: 'component';
155
+ selector: UamComponentSelector;
156
+ } | {
157
+ kind: 'displayNode';
158
+ selector: UamDisplayNodeSelector;
159
+ } | {
160
+ kind: 'controller';
161
+ selector: UamControllerSelector;
162
+ } | {
163
+ kind: 'transition';
164
+ selector: UamTransitionSelector;
165
+ };
166
+ interface QueryEntityInput {
167
+ sessionId: string;
168
+ target: BackendEntityTarget;
169
+ }
170
+ interface BackendEntitySnapshot {
171
+ sessionId: string;
172
+ revision: number;
173
+ target: BackendEntityTarget;
174
+ entity: {
175
+ kind: 'project';
176
+ properties: BackendProjectSnapshot;
177
+ } | {
178
+ kind: 'package';
179
+ properties: BackendPackageSnapshot;
180
+ } | {
181
+ kind: 'resource';
182
+ properties: BackendResourceSnapshot;
183
+ } | {
184
+ kind: 'component';
185
+ properties: BackendComponentSnapshot;
186
+ } | {
187
+ kind: 'displayNode';
188
+ properties: UamDisplayNode;
189
+ } | {
190
+ kind: 'controller';
191
+ properties: UamControllerModel;
192
+ } | {
193
+ kind: 'transition';
194
+ properties: UamTransitionModel;
195
+ };
196
+ }
197
+ interface EntityQueryError {
198
+ code: 'entity_query_failed';
199
+ message: string;
200
+ sessionId: string;
201
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
202
+ }
53
203
  /** An exclusive lock owned for the lifetime of one backend session. */
54
204
  interface BackendSessionLock {
55
205
  /** Persist optional host metadata without changing lock ownership. */
@@ -128,6 +278,8 @@ interface BackendCapabilityManifest {
128
278
  diagnostics: {
129
279
  stableCodes: true;
130
280
  errorDiagnosticMirror: true;
281
+ recoveryGuides: 'all-formal-codes';
282
+ automaticRepair: false;
131
283
  };
132
284
  }
133
285
  interface BackendCapabilities {
@@ -136,14 +288,35 @@ interface BackendCapabilities {
136
288
  transactionKernelOwner: '@openfairygui/core';
137
289
  appSeamOwner: '@openfairygui/functions';
138
290
  runtimeOwner: '@openfairygui/backend';
139
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'getProjectOutline', 'validateSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
291
+ methods: typeof BACKEND_METHODS;
140
292
  read: {
141
293
  capabilitySnapshot: true;
142
294
  sessionSnapshot: true;
143
295
  projectOutline: true;
296
+ entityQuery: {
297
+ kinds: readonly BackendEntityTarget['kind'][];
298
+ projection: 'properties';
299
+ sourceBytes: false;
300
+ limits: typeof BACKEND_ENTITY_QUERY_LIMITS;
301
+ };
302
+ sessionState: {
303
+ sourceBytes: false;
304
+ limits: typeof BACKEND_SESSION_READ_LIMITS.model;
305
+ };
306
+ resourceBytes: {
307
+ expectedRevisionRequired: true;
308
+ hydration: false;
309
+ maxBytes: typeof BACKEND_SESSION_READ_LIMITS.resourceBytes;
310
+ };
144
311
  projectValidation: true;
145
312
  };
146
313
  authoring: {
314
+ preflightTransaction: {
315
+ mode: 'execute-and-discard';
316
+ reservesRevision: false;
317
+ impact: 'model-diff';
318
+ limits: typeof BACKEND_TRANSACTION_PREVIEW_LIMITS;
319
+ };
147
320
  applyTransaction: true;
148
321
  saveSession: true;
149
322
  resourceKinds: readonly string[];
@@ -476,7 +649,7 @@ interface RefreshCacheInput {
476
649
  sessionId: string;
477
650
  reason?: 'manual' | 'session_open' | 'after_save';
478
651
  }
479
- type BackendError = SessionNotFoundError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
652
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionReadError | SessionStaleReadError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
480
653
  interface ProjectRootNotAllowedError {
481
654
  code: 'project_root_not_allowed';
482
655
  message: string;
@@ -492,6 +665,41 @@ interface ApplySessionTransactionInput {
492
665
  expectedRevision: number;
493
666
  operations: UamTransactionOperation[];
494
667
  }
668
+ interface BackendTransactionPreview {
669
+ sessionId: string;
670
+ baseRevision: number;
671
+ /** Revision after applying this batch at baseRevision, including an empty batch. Not reserved. */
672
+ projectedRevision: number;
673
+ mode: 'execute-and-discard';
674
+ /** Complete, bounded comparison of current and projected UAM, not unsaved changes since last save. */
675
+ impact: {
676
+ entities: BackendTransactionEntityChange[]; /** Project-relative paths from the actual ProjectWriter, including empty directories. Not a disk write plan. */
677
+ files: Array<{
678
+ path: string;
679
+ kind: 'file' | 'directory';
680
+ change: 'added' | 'removed' | 'updated';
681
+ }>;
682
+ };
683
+ persistence: {
684
+ requiredAfterApply: true;
685
+ nextAction: 'saveSession' | 'materializeSession' | 'host-action';
686
+ fileSystemAvailable: boolean;
687
+ uamFidelity: BackendSessionSnapshot['uamFidelity']; /** Preflight never verifies filesystem permissions, materialize destinations or actual disk state. */
688
+ writeVerified: false;
689
+ };
690
+ }
691
+ interface BackendTransactionEntityChange {
692
+ target: BackendEntityTarget;
693
+ change: 'added' | 'removed' | 'updated';
694
+ /** Changed top-level property names; child collections contain identities and preserve their order. */
695
+ fields: string[];
696
+ }
697
+ interface TransactionPreviewError {
698
+ code: 'transaction_preview_failed';
699
+ message: string;
700
+ sessionId: string;
701
+ reason: 'response_budget_exceeded' | 'projection_failed';
702
+ }
495
703
  interface GetProjectOutlineInput {
496
704
  sessionId: string;
497
705
  }
@@ -502,7 +710,9 @@ interface OpenProjectSessionInput {
502
710
  /** Authoritative UAM project. Use BackendRuntime.openSession() when importing an existing project from storage. */
503
711
  project: UamProject;
504
712
  sessionId?: string;
713
+ /** Session identity only; without explicit storage or a per-call filesystem this grants no filesystem access. */
505
714
  canonicalProjectPath?: string;
715
+ /** Host-defined session identity; not a filesystem authorization or an allowed-root override. */
506
716
  canonicalPathKey?: string;
507
717
  /** Optional writeback target for the authoritative UAM project; this is not an import source. */
508
718
  storage?: BackendProjectSessionStorage;
@@ -564,7 +774,11 @@ declare class BackendRuntime {
564
774
  sessionId: string;
565
775
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
566
776
  getProjectOutline(input: GetProjectOutlineInput): BackendResult<BackendProjectOutline, SessionNotFoundError>;
777
+ queryEntity(input: QueryEntityInput): BackendResult<BackendEntitySnapshot, SessionNotFoundError | EntityQueryError>;
778
+ readSessionState(input: ReadSessionStateInput): BackendResult<BackendSessionStateSnapshot, SessionNotFoundError | SessionReadError | SessionStaleReadError>;
779
+ readResourceBytes(input: ReadResourceBytesInput): BackendResult<BackendResourceBytesSnapshot, SessionNotFoundError | SessionReadError | SessionStaleReadError>;
567
780
  validateSession(input: ValidateSessionInput): BackendResult<ProjectValidationReport, SessionNotFoundError>;
781
+ preflightTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendTransactionPreview, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError | TransactionPreviewError>>;
568
782
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
569
783
  saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
570
784
  materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;