@enbox/agent 0.7.7 → 0.7.9

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.
Files changed (77) hide show
  1. package/dist/browser.mjs +9 -9
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/dwn-api.js +3 -2
  4. package/dist/esm/dwn-api.js.map +1 -1
  5. package/dist/esm/enbox-connect-protocol.js +5 -5
  6. package/dist/esm/enbox-connect-protocol.js.map +1 -1
  7. package/dist/esm/index.js +1 -1
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/esm/permissions-api.js +7 -34
  10. package/dist/esm/permissions-api.js.map +1 -1
  11. package/dist/esm/sync-closure-resolver.js +229 -110
  12. package/dist/esm/sync-closure-resolver.js.map +1 -1
  13. package/dist/esm/sync-closure-types.js +39 -7
  14. package/dist/esm/sync-closure-types.js.map +1 -1
  15. package/dist/esm/sync-engine-level.js +2242 -797
  16. package/dist/esm/sync-engine-level.js.map +1 -1
  17. package/dist/esm/sync-link-id.js +4 -13
  18. package/dist/esm/sync-link-id.js.map +1 -1
  19. package/dist/esm/sync-link-reconciler.js +26 -8
  20. package/dist/esm/sync-link-reconciler.js.map +1 -1
  21. package/dist/esm/sync-messages.js +218 -154
  22. package/dist/esm/sync-messages.js.map +1 -1
  23. package/dist/esm/sync-permission-grants.js +208 -0
  24. package/dist/esm/sync-permission-grants.js.map +1 -0
  25. package/dist/esm/sync-replication-ledger.js +23 -40
  26. package/dist/esm/sync-replication-ledger.js.map +1 -1
  27. package/dist/esm/sync-scope-acceptance.js +126 -0
  28. package/dist/esm/sync-scope-acceptance.js.map +1 -0
  29. package/dist/esm/sync-topological-sort.js +57 -15
  30. package/dist/esm/sync-topological-sort.js.map +1 -1
  31. package/dist/esm/types/sync.js +130 -22
  32. package/dist/esm/types/sync.js.map +1 -1
  33. package/dist/types/dwn-api.d.ts.map +1 -1
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/permissions-api.d.ts +1 -2
  37. package/dist/types/permissions-api.d.ts.map +1 -1
  38. package/dist/types/sync-closure-resolver.d.ts.map +1 -1
  39. package/dist/types/sync-closure-types.d.ts +14 -3
  40. package/dist/types/sync-closure-types.d.ts.map +1 -1
  41. package/dist/types/sync-engine-level.d.ts +144 -31
  42. package/dist/types/sync-engine-level.d.ts.map +1 -1
  43. package/dist/types/sync-link-id.d.ts +3 -9
  44. package/dist/types/sync-link-id.d.ts.map +1 -1
  45. package/dist/types/sync-link-reconciler.d.ts +12 -2
  46. package/dist/types/sync-link-reconciler.d.ts.map +1 -1
  47. package/dist/types/sync-messages.d.ts +16 -13
  48. package/dist/types/sync-messages.d.ts.map +1 -1
  49. package/dist/types/sync-permission-grants.d.ts +52 -0
  50. package/dist/types/sync-permission-grants.d.ts.map +1 -0
  51. package/dist/types/sync-replication-ledger.d.ts +5 -13
  52. package/dist/types/sync-replication-ledger.d.ts.map +1 -1
  53. package/dist/types/sync-scope-acceptance.d.ts +28 -0
  54. package/dist/types/sync-scope-acceptance.d.ts.map +1 -0
  55. package/dist/types/sync-topological-sort.d.ts +2 -1
  56. package/dist/types/sync-topological-sort.d.ts.map +1 -1
  57. package/dist/types/types/permissions.d.ts +2 -0
  58. package/dist/types/types/permissions.d.ts.map +1 -1
  59. package/dist/types/types/sync.d.ts +137 -75
  60. package/dist/types/types/sync.d.ts.map +1 -1
  61. package/package.json +3 -3
  62. package/src/dwn-api.ts +3 -2
  63. package/src/enbox-connect-protocol.ts +5 -5
  64. package/src/index.ts +10 -1
  65. package/src/permissions-api.ts +11 -42
  66. package/src/sync-closure-resolver.ts +306 -126
  67. package/src/sync-closure-types.ts +54 -9
  68. package/src/sync-engine-level.ts +3051 -967
  69. package/src/sync-link-id.ts +9 -14
  70. package/src/sync-link-reconciler.ts +43 -10
  71. package/src/sync-messages.ts +263 -159
  72. package/src/sync-permission-grants.ts +297 -0
  73. package/src/sync-replication-ledger.ts +55 -50
  74. package/src/sync-scope-acceptance.ts +186 -0
  75. package/src/sync-topological-sort.ts +89 -21
  76. package/src/types/permissions.ts +2 -0
  77. package/src/types/sync.ts +235 -62
@@ -1 +1 @@
1
- {"version":3,"file":"sync-replication-ledger.d.ts","sourceRoot":"","sources":["../../src/sync-replication-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOxG;;;;;;;;;;GAUG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA8C;IACjE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAEd,EAAE,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IAS3D,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ;IAYvB;;;OAGG;IACU,eAAe,CAAC,MAAM,EAAE;QACnC,SAAS,EAAG,MAAM,CAAC;QACnB,cAAc,EAAG,MAAM,CAAC;QACxB,KAAK,EAAG,SAAS,CAAC;QAClB,WAAW,CAAC,EAAG,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAG,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqCjC,2CAA2C;IAC9B,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhE,qBAAqB;IACR,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlG,mCAAmC;IACtB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAWlF,sBAA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,KAAK,EAAE,aAAa,GAAG,OAAO;IAMjG;;;;OAIG;WACW,gBAAgB,CAAC,UAAU,EAAE,mBAAmB,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAS3F;;;;OAIG;WACW,qBAAqB,CAAC,UAAU,EAAE,mBAAmB,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAYhG;;;OAGG;WACW,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI;IAS3F;;;OAGG;IACU,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5F;;OAEG;IACU,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5E"}
@@ -0,0 +1,28 @@
1
+ import type { GenericMessage, MessageEvent, RecordsWriteMessage } from '@enbox/dwn-sdk-js';
2
+ import type { SyncScope } from './types/sync.js';
3
+ /** Result of testing whether an inbound sync message belongs to a link scope. */
4
+ export type SyncScopeClassification = 'in-scope' | 'out-of-scope' | 'unknown';
5
+ type SyncMessageScopeClassificationParams = {
6
+ message: GenericMessage;
7
+ initialWrite?: RecordsWriteMessage;
8
+ scope: SyncScope;
9
+ };
10
+ /**
11
+ * Classifies whether a live event belongs to the link's current sync scope.
12
+ *
13
+ * Full links accept every message. Protocol-set links accept records for a
14
+ * covered protocol, ProtocolsConfigure messages that install a covered
15
+ * protocol, and permission records tagged for a covered protocol. RecordsDelete
16
+ * messages carry no protocol in their descriptor, so they must be classified
17
+ * from the event's initial write metadata.
18
+ */
19
+ export declare function classifySyncEventScope(event: MessageEvent, scope: SyncScope): SyncScopeClassification;
20
+ /**
21
+ * Classifies whether a DWN message belongs to a sync scope before local apply.
22
+ *
23
+ * If a RecordsDelete cannot be tied to its initial write, the result is
24
+ * `unknown` so callers fail closed instead of applying an unclassified delete.
25
+ */
26
+ export declare function classifySyncMessageScope({ message, initialWrite, scope, }: SyncMessageScopeClassificationParams): SyncScopeClassification;
27
+ export {};
28
+ //# sourceMappingURL=sync-scope-acceptance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-scope-acceptance.d.ts","sourceRoot":"","sources":["../../src/sync-scope-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAiB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI1G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,iFAAiF;AACjF,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,CAAC;AAE9E,KAAK,oCAAoC,GAAG;IAC1C,OAAO,EAAE,cAAc,CAAC;IACxB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAKF;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,GAAG,uBAAuB,CAMrG;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,YAAY,EACZ,KAAK,GACN,EAAE,oCAAoC,GAAG,uBAAuB,CAOhE"}
@@ -5,9 +5,10 @@ import type { GenericMessage } from '@enbox/dwn-sdk-js';
5
5
  *
6
6
  * Dependencies:
7
7
  * - ProtocolsConfigure must come before any RecordsWrite using that protocol
8
+ * - Composed ProtocolsConfigure must come after ProtocolsConfigure messages for protocols in `uses`
8
9
  * - Parent record must come before child record (via parentId)
9
10
  * - Initial write must come before update writes (same recordId, not initial)
10
- * - Permission grant must come before records using that permissionGrantId
11
+ * - Permission grants must come before messages that invoke them
11
12
  */
12
13
  export declare function topologicalSort<T extends {
13
14
  message: GenericMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"sync-topological-sort.d.ts","sourceRoot":"","sources":["../../src/sync-topological-sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAiBxD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,EACnE,QAAQ,EAAE,CAAC,EAAE,GACZ,CAAC,EAAE,CAyIL"}
1
+ {"version":3,"file":"sync-topological-sort.d.ts","sourceRoot":"","sources":["../../src/sync-topological-sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,mBAAmB,CAAC;AA0E5E;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,EACnE,QAAQ,EAAE,CAAC,EAAE,GACZ,CAAC,EAAE,CAmJL"}
@@ -69,6 +69,8 @@ export type GetPermissionParams = {
69
69
  delegateDid: string;
70
70
  messageType: DwnInterface;
71
71
  protocol?: string;
72
+ protocolPath?: string;
73
+ contextId?: string;
72
74
  cached?: boolean;
73
75
  delegate?: boolean;
74
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/types/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9I,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAA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CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,uBAAuB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAExF;;OAEG;IACH,WAAW,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAEjF;;OAEG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,4BAA4B,KAAK,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC;IAE3F;;MAEE;IACF,cAAc,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpE;;OAEG;IACH,WAAW,EAAC,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEzE;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAE5E;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAErF;;OAEG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B"}
@@ -1,5 +1,7 @@
1
- import type { ProgressToken } from '@enbox/dwn-sdk-js';
1
+ import type { NormalizedRecordsProjectionScope, ProgressToken, RecordsProjectionScope } from '@enbox/dwn-sdk-js';
2
2
  import type { EnboxPlatformAgent } from './agent.js';
3
+ /** Deterministic bytewise string comparator for hash inputs and canonical IDs. */
4
+ export declare function lexicographicalCompare(a: string, b: string): number;
3
5
  /**
4
6
  * The SyncEngine is responsible for syncing messages between the agent and the platform.
5
7
  */
@@ -12,6 +14,10 @@ export type SyncIdentityOptions = {
12
14
  * The protocols that should be synced for this identity.
13
15
  * - `'all'` — sync all protocols (full replica).
14
16
  * - `string[]` — sync only the listed protocol URIs.
17
+ *
18
+ * Composed protocols are not expanded automatically. If a protocol definition
19
+ * declares `uses`, include every referenced protocol that the local DWN must
20
+ * install or use while applying that projection.
15
21
  */
16
22
  protocols: 'all' | [string, ...string[]];
17
23
  };
@@ -25,34 +31,102 @@ export type SyncConnectivityState = 'online' | 'offline' | 'unknown';
25
31
  */
26
32
  export type SyncMode = 'poll' | 'live';
27
33
  /**
28
- * Describes what a replication link syncs. Currently whole-tenant only
29
- * (`kind: 'full'`). Scoped subset sync (`kind: 'protocol'` with
30
- * `protocolPathPrefixes` / `contextIdPrefixes`) is deferred to Phase 3.
34
+ * Projection-root algorithm used by StateIndex full/protocol sync scopes.
35
+ *
36
+ * Sync compares either the existing full-tenant StateIndex root or existing
37
+ * per-protocol StateIndex roots. Records-primary projection scopes use the
38
+ * DWN SDK's `RECORDS_PROJECTION_ROOT_VERSION` instead.
39
+ */
40
+ export declare const SYNC_PROJECTION_ROOT_VERSION = "state-index-full-protocol-root-v1";
41
+ /**
42
+ * Authorization-epoch algorithm used by delegated Messages.Read sync links.
43
+ *
44
+ * The authorization epoch is separate from the projection ID: re-granting the
45
+ * same scope or changing delegate grants must invalidate in-flight work without
46
+ * changing the primary CID set being compared.
47
+ */
48
+ export declare const SYNC_AUTHORIZATION_EPOCH_VERSION = "messages-read-grants-v1";
49
+ /** A non-empty, sorted, duplicate-free string list. */
50
+ export type NonEmptyStringArray = [string, ...string[]];
51
+ /** A non-empty, sorted, duplicate-free, subsumption-reduced Records projection scope union. */
52
+ export type NonEmptyRecordsProjectionScopes = [NormalizedRecordsProjectionScope, ...NormalizedRecordsProjectionScope[]];
53
+ /**
54
+ * Describes the primary CID set a replication link syncs.
55
+ *
56
+ * Full and protocol-set sync use the existing StateIndex roots. Records
57
+ * projections use the `records-primary-scope-root-v1` root over latest Records
58
+ * primary messages selected by protocol, exact protocolPath, or context
59
+ * subtree. For composed protocols, the scope must include the composed protocol
60
+ * and any `uses` targets required for local protocol installation and closure
61
+ * evaluation.
31
62
  */
32
63
  export type SyncScope = {
33
- /** Scope kind. Only `'full'` is implemented in Phase 1. */
64
+ /** Full-tenant projection. Valid only for owner sync or unscoped delegated grants. */
34
65
  kind: 'full';
35
66
  } | {
36
- /**
37
- * Protocol-scoped sync. Deferred to Phase 3 — included here for type
38
- * forward-compatibility only.
39
- */
40
- kind: 'protocol';
41
- protocol: string;
42
- protocolPathPrefixes?: string[];
43
- contextIdPrefixes?: string[];
67
+ /** Protocol-set projection over one or more protocol roots. */
68
+ kind: 'protocolSet';
69
+ protocols: NonEmptyStringArray;
70
+ } | {
71
+ /** Records-primary projected root over protocol/path/context scope entries. */
72
+ kind: 'recordsProjection';
73
+ scopes: NonEmptyRecordsProjectionScopes;
44
74
  };
45
75
  /**
46
- * Computes a deterministic, collision-resistant identifier for a {@link SyncScope}.
76
+ * Authorization context for a link. Owner links do not invoke grants. Delegate
77
+ * links carry the active Messages.Read grants that authorize the scope union.
78
+ */
79
+ export type SyncAuthorization = {
80
+ kind: 'owner';
81
+ } | {
82
+ kind: 'delegate';
83
+ delegateDid: string;
84
+ permissionGrantIds: NonEmptyStringArray;
85
+ };
86
+ /** Grant metadata that participates in delegated authorization-epoch hashing. */
87
+ export type SyncAuthorizationGrant = {
88
+ id: string;
89
+ dateExpires: string;
90
+ dateGranted?: string;
91
+ };
92
+ /**
93
+ * Normalizes a protocol list into canonical scope-union order.
94
+ */
95
+ export declare function normalizeSyncProtocols(protocols: [string, ...string[]] | string[]): NonEmptyStringArray;
96
+ /** Converts persisted identity options into the canonical sync scope. */
97
+ export declare function syncScopeFromProtocols(protocols: SyncIdentityOptions['protocols']): SyncScope;
98
+ /** Converts Records projection scopes into the canonical sync scope shape. */
99
+ export declare function syncScopeFromRecordsProjectionScopes(scopes: readonly [RecordsProjectionScope, ...RecordsProjectionScope[]]): Extract<SyncScope, {
100
+ kind: 'recordsProjection';
101
+ }>;
102
+ /** Returns the protocol list covered by a scope, or `undefined` for full scope. */
103
+ export declare function protocolsForSyncScope(scope: SyncScope): NonEmptyStringArray | undefined;
104
+ /** Returns the single protocol root covered by a protocol-set scope, if any. */
105
+ export declare function singleProtocolForSyncScope(scope: SyncScope): string | undefined;
106
+ /** Returns a canonical JSON-ready representation of a sync scope. */
107
+ export declare function canonicalizeSyncScope(scope: SyncScope): SyncScope;
108
+ /**
109
+ * Computes a deterministic, collision-resistant projection ID.
47
110
  *
48
- * The ID is `base64url(SHA-256(canonicalJSON))` where `canonicalJSON` is the
49
- * scope object with keys sorted alphabetically and array values sorted
50
- * lexicographically.
111
+ * The projection ID is derived from tenant DID, normalized scope, and the
112
+ * projection-root algorithm version. It intentionally excludes endpoint,
113
+ * grant IDs, authorization epoch, and remote diff contents.
114
+ */
115
+ export declare function computeProjectionId(tenantDid: string, scope: SyncScope): Promise<string>;
116
+ /**
117
+ * Computes the authorization epoch for a link.
51
118
  *
52
- * Used as part of the LevelDB key for the replication ledger:
53
- * `{tenantDid}^{remoteEndpoint}^{scopeId}`.
119
+ * Owner epochs are stable for the owner projection. Delegate epochs are derived
120
+ * from the delegate DID plus the active grant IDs and expiry metadata. A changed
121
+ * grant set creates a new link key even when the projection ID is unchanged.
54
122
  */
55
- export declare function computeScopeId(scope: SyncScope): Promise<string>;
123
+ export declare function computeAuthorizationEpoch(input: {
124
+ kind: 'owner';
125
+ } | {
126
+ kind: 'delegate';
127
+ delegateDid: string;
128
+ grants: [SyncAuthorizationGrant, ...SyncAuthorizationGrant[]];
129
+ }): Promise<string>;
56
130
  /**
57
131
  * Maximum number of in-flight deliveries (runtime ordinals) a link may
58
132
  * accumulate before transitioning to `repairing`. This is the overflow
@@ -91,25 +165,31 @@ export type DirectionCheckpoint = {
91
165
  *
92
166
  * - `initializing` — link created, no subscriptions open yet.
93
167
  * - `live` — actively receiving events via subscription.
168
+ * - `polling` — current link is reconciled by periodic SMT sync; live subscription is not supported for its scope.
94
169
  * - `repairing` — gap detected or pending overflow; running SMT reconciliation.
95
170
  * - `degraded_poll` — subscription failed; polling at reduced frequency.
171
+ * - `terminal_incomplete` — closure failed with a terminal dependency error; requires a new scope/authorization epoch.
96
172
  * - `paused` — explicitly paused by the application.
97
173
  */
98
- export type LinkStatus = 'initializing' | 'live' | 'repairing' | 'degraded_poll' | 'paused';
174
+ export type LinkStatus = 'initializing' | 'live' | 'polling' | 'repairing' | 'degraded_poll' | 'terminal_incomplete' | 'paused';
99
175
  /**
100
176
  * Durable state of a single replication link. Persisted to LevelDB and
101
177
  * loaded on startup. Each link is identified by the tuple
102
- * `(tenantDid, remoteEndpoint, scopeId)`.
178
+ * `(tenantDid, remoteEndpoint, projectionId, authorizationEpoch)`.
103
179
  */
104
180
  export type ReplicationLinkState = {
105
181
  /** The tenant DID this link syncs for. */
106
182
  tenantDid: string;
107
183
  /** The remote DWN endpoint URL. */
108
184
  remoteEndpoint: string;
109
- /** Deterministic hash of the {@link SyncScope}. See {@link computeScopeId}. */
110
- scopeId: string;
185
+ /** Deterministic hash of tenant DID, normalized scope, and root algorithm version. */
186
+ projectionId: string;
187
+ /** Deterministic hash of owner/delegate grant context for this link. */
188
+ authorizationEpoch: string;
111
189
  /** The scope definition this link covers. */
112
190
  scope: SyncScope;
191
+ /** Owner/delegate authorization context used to sign sync messages. */
192
+ authorization: SyncAuthorization;
113
193
  /** Current link status. */
114
194
  status: LinkStatus;
115
195
  /** Pull-direction replication checkpoint (remote → local). */
@@ -125,14 +205,6 @@ export type ReplicationLinkState = {
125
205
  connectivity: SyncConnectivityState;
126
206
  /** Delegate DID used to sign sync messages, if any. */
127
207
  delegateDid?: string;
128
- /**
129
- * Protocol filter for this link, if any. Duplicates the protocol in `scope`
130
- * for operational convenience — used by permission lookups and cursor key
131
- * building. The scope is the source of truth for what to sync; this field
132
- * is the source of truth for how to authenticate. To be consolidated in
133
- * Phase 3 when scope resolution is more complex.
134
- */
135
- protocol?: string;
136
208
  /** ISO-8601 timestamp of last successful sync activity. */
137
209
  lastActivityAt?: string;
138
210
  };
@@ -166,7 +238,7 @@ export type StartSyncParams = {
166
238
  * push. Falls back to SMT reconciliation on cold start or long disconnect.
167
239
  * An infrequent SMT integrity check still runs at `interval`.
168
240
  *
169
- * - `'poll'`: Legacy mode. Performs a full SMT set-reconciliation sync on a
241
+ * - `'poll'`: Performs a full SMT set-reconciliation sync on a
170
242
  * fixed interval. No WebSocket subscriptions are used.
171
243
  */
172
244
  mode?: SyncMode;
@@ -181,76 +253,57 @@ export type StartSyncParams = {
181
253
  */
182
254
  interval?: string;
183
255
  };
256
+ /** Sync scope metadata attached to observability events. */
257
+ export type SyncEventScope = {
258
+ /** Present only when the event belongs to a single-protocol link. */
259
+ protocol?: string;
260
+ /** Present when the event belongs to a protocol-set link. */
261
+ protocols?: NonEmptyStringArray;
262
+ };
263
+ type SyncEventBase = {
264
+ tenantDid: string;
265
+ remoteEndpoint: string;
266
+ } & SyncEventScope;
184
267
  /**
185
268
  * Events emitted by the sync engine at key state transitions.
186
269
  * Consumers subscribe via `SyncEngine.on('event', handler)` and can
187
270
  * hook these into metrics, logging, or UI state.
188
271
  */
189
- export type SyncEvent = {
272
+ export type SyncEvent = SyncEventBase & {
190
273
  type: 'link:status-change';
191
- tenantDid: string;
192
- remoteEndpoint: string;
193
- protocol?: string;
194
274
  from: LinkStatus;
195
275
  to: LinkStatus;
196
- } | {
276
+ } | SyncEventBase & {
197
277
  type: 'link:connectivity-change';
198
- tenantDid: string;
199
- remoteEndpoint: string;
200
- protocol?: string;
201
278
  from: SyncConnectivityState;
202
279
  to: SyncConnectivityState;
203
- } | {
280
+ } | SyncEventBase & {
204
281
  type: 'checkpoint:pull-advance';
205
- tenantDid: string;
206
- remoteEndpoint: string;
207
- protocol?: string;
208
282
  position: string;
209
283
  messageCid: string;
210
- } | {
284
+ } | SyncEventBase & {
211
285
  type: 'reconcile:needed';
212
- tenantDid: string;
213
- remoteEndpoint: string;
214
- protocol?: string;
215
286
  reason: string;
216
- } | {
287
+ } | SyncEventBase & {
217
288
  type: 'reconcile:completed';
218
- tenantDid: string;
219
- remoteEndpoint: string;
220
- protocol?: string;
221
- } | {
289
+ } | SyncEventBase & {
222
290
  type: 'repair:started';
223
- tenantDid: string;
224
- remoteEndpoint: string;
225
- protocol?: string;
226
291
  attempt: number;
227
- } | {
292
+ } | SyncEventBase & {
228
293
  type: 'repair:completed';
229
- tenantDid: string;
230
- remoteEndpoint: string;
231
- protocol?: string;
232
- } | {
294
+ } | SyncEventBase & {
233
295
  type: 'repair:failed';
234
- tenantDid: string;
235
- remoteEndpoint: string;
236
- protocol?: string;
237
296
  attempt: number;
238
297
  error: string;
239
- } | {
298
+ } | SyncEventBase & {
240
299
  type: 'degraded-poll:entered';
241
- tenantDid: string;
242
- remoteEndpoint: string;
243
- protocol?: string;
244
- } | {
300
+ } | SyncEventBase & {
245
301
  type: 'gap:detected';
246
- tenantDid: string;
247
- remoteEndpoint: string;
248
- protocol?: string;
249
302
  reason: string;
250
303
  };
251
304
  export type SyncEventListener = (event: SyncEvent) => void;
252
305
  /** Category of sync failure for dead letter entries. */
253
- export type DeadLetterCategory = 'push-permanent' | 'push-exhausted' | 'pull-processing' | 'closure';
306
+ export type DeadLetterCategory = 'push-permanent' | 'push-exhausted' | 'pull-processing' | 'pull-scope-rejected' | 'closure';
254
307
  /** A message that permanently failed to sync. */
255
308
  export type DeadLetterEntry = {
256
309
  /** The message CID that failed. */
@@ -285,8 +338,16 @@ export type SyncHealthSummary = {
285
338
  * the engine self-heals — entries are auto-cleared on later success.
286
339
  */
287
340
  failedMessageCount: number;
288
- /** Number of links currently in 'repairing' or 'degraded_poll' status. */
341
+ /**
342
+ * Number of current closure failures. A link can have matching sync roots
343
+ * while still being unusable because required dependencies are missing; this
344
+ * count keeps that state visible to callers.
345
+ */
346
+ closureFailureCount: number;
347
+ /** Number of current sync links in 'repairing', 'degraded_poll', or terminal-incomplete status. */
289
348
  degradedLinkCount: number;
349
+ /** True only when there are no failed messages and no degraded links. */
350
+ syncHealthy: boolean;
290
351
  };
291
352
  export interface SyncEngine {
292
353
  /**
@@ -401,4 +462,5 @@ export interface SyncEngine {
401
462
  */
402
463
  getSyncHealth(): Promise<SyncHealthSummary>;
403
464
  }
465
+ export {};
404
466
  //# sourceMappingURL=sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/types/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,SAAS,EAAE,KAAK,GAAG,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAErE;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAMvC;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;CACd,GAAG;IACF;;;OAGG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CA4BtE;AAMD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;;OAMG;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AEG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;IAC1E;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F;;;;;OAKG;IACH,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,EAAE,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAAC;IAE5C;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAMvB;;;;;OAKG;IACH,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAElE;;;;;OAKG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAElF;;OAEG;IACH,sBAAsB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/agent",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
4
4
  "type": "module",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -72,8 +72,8 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@scure/bip39": "1.2.2",
75
- "@enbox/dwn-clients": "0.4.2",
76
- "@enbox/dwn-sdk-js": "0.3.7",
75
+ "@enbox/dwn-clients": "0.4.3",
76
+ "@enbox/dwn-sdk-js": "0.3.8",
77
77
  "@enbox/common": "0.1.1",
78
78
  "@enbox/crypto": "0.1.1",
79
79
  "@enbox/dids": "0.1.1",
package/src/dwn-api.ts CHANGED
@@ -1242,8 +1242,8 @@ export class AgentDwnApi {
1242
1242
  throw new Error('AgentDwnApi: messageParams must be provided when rawMessage is not given.');
1243
1243
  }
1244
1244
 
1245
- // If we need to sign as an author delegate or with permissions we need to get the grantee's signer
1246
- // The messageParams should include either a permissionGrantId, or a delegatedGrant message
1245
+ // If we need to sign as an author delegate or with permissions we need to get the grantee's signer.
1246
+ // The messageParams should include either a permission grant invocation or a delegatedGrant message.
1247
1247
  const signer = request.granteeDid ?
1248
1248
  await this.getSigner(request.granteeDid) :
1249
1249
  await this.getSigner(request.author);
@@ -1311,6 +1311,7 @@ export class AgentDwnApi {
1311
1311
  private hasGrantParams<T extends DwnInterface>(params?: DwnMessageParams[T]): boolean {
1312
1312
  return params !== undefined &&
1313
1313
  (('permissionGrantId' in params && params.permissionGrantId !== undefined) ||
1314
+ ('permissionGrantIds' in params && params.permissionGrantIds !== undefined) ||
1314
1315
  ('delegatedGrant' in params && params.delegatedGrant !== undefined));
1315
1316
  }
1316
1317
 
@@ -1482,7 +1482,7 @@ async function submitConnectResponse(
1482
1482
  // below, but we must NOT iterate over them (they are meta-grants, not session grants).
1483
1483
  sessionGrantCount = delegateGrants.length;
1484
1484
 
1485
- // Phase 1: create all revocation grants locally with bounded concurrency.
1485
+ // Create all revocation grants locally with bounded concurrency.
1486
1486
  // createGrant is local-only (storage + signing) so it's cheap, but we still
1487
1487
  // cap parallelism to avoid head-of-line blocking when sessionGrantCount is
1488
1488
  // large (e.g. dapp requesting many scopes at once).
@@ -1508,10 +1508,10 @@ async function submitConnectResponse(
1508
1508
  ),
1509
1509
  );
1510
1510
 
1511
- // Phase 2: fan out every revocation grant to every owner DWN endpoint with
1512
- // a single global concurrency cap so that (grants × endpoints) cannot blow
1513
- // up. This is best-effort (sync delivers eventually) so individual failures
1514
- // are tolerated by `mapConcurrentSettled`.
1511
+ // Fan out every revocation grant to every owner DWN endpoint with a single
1512
+ // global concurrency cap so that (grants × endpoints) cannot blow up. This
1513
+ // is best-effort (sync delivers eventually) so individual failures are
1514
+ // tolerated by `mapConcurrentSettled`.
1515
1515
  const revSendTasks = revGrantResults.flatMap(({ grantMessage, revGrant }) => {
1516
1516
  sessionRevocations.push({
1517
1517
  grantId : grantMessage.recordId,
package/src/index.ts CHANGED
@@ -5,7 +5,16 @@ export type * from './types/identity-vault.js';
5
5
  export type * from './types/key-manager.js';
6
6
  export type * from './types/permissions.js';
7
7
  export type * from './types/sync.js';
8
- export { computeScopeId, MAX_PENDING_TOKENS } from './types/sync.js';
8
+ export {
9
+ computeAuthorizationEpoch,
10
+ computeProjectionId,
11
+ MAX_PENDING_TOKENS,
12
+ normalizeSyncProtocols,
13
+ protocolsForSyncScope,
14
+ singleProtocolForSyncScope,
15
+ syncScopeFromRecordsProjectionScopes,
16
+ syncScopeFromProtocols,
17
+ } from './types/sync.js';
9
18
  export { ReplicationLedger } from './sync-replication-ledger.js';
10
19
  export { ClosureFailureCode, createClosureContext } from './sync-closure-types.js';
11
20
  export type { ClosureDependencyEdge, ClosureEvaluationContext, ClosureResult } from './sync-closure-types.js';
@@ -1,12 +1,12 @@
1
1
  import type { EnboxAgent } from './types/agent.js';
2
2
  import type { CreateGrantParams, CreateRequestParams, CreateRevocationParams, FetchPermissionRequestParams, FetchPermissionsParams, GetPermissionParams, IsGrantRevokedParams, PermissionGrantEntry, PermissionRequestEntry, PermissionRevocationEntry, PermissionsApi } from './types/permissions.js';
3
- import type { DwnDataEncodedRecordsWriteMessage, DwnMessageParams, DwnPermissionScope, DwnRecordsPermissionScope, ProcessDwnRequest } from './types/dwn.js';
3
+ import type { DwnDataEncodedRecordsWriteMessage, DwnMessageParams, DwnRecordsPermissionScope, ProcessDwnRequest } from './types/dwn.js';
4
4
  import type { PermissionGrant, PermissionGrantData, PermissionRequestData, PermissionRevocationData } from '@enbox/dwn-sdk-js';
5
5
 
6
6
  import { isRecordsType } from './dwn-api.js';
7
- import { PermissionsProtocol } from '@enbox/dwn-sdk-js';
8
7
  import { Convert, TtlCache } from '@enbox/common';
9
8
  import { DwnInterface, DwnPermissionGrant, DwnPermissionRequest } from './types/dwn.js';
9
+ import { PermissionScopeMatcher, PermissionsProtocol } from '@enbox/dwn-sdk-js';
10
10
 
11
11
  export class AgentPermissionsApi implements PermissionsApi {
12
12
 
@@ -36,11 +36,11 @@ export class AgentPermissionsApi implements PermissionsApi {
36
36
  delegate,
37
37
  messageType,
38
38
  protocol,
39
+ protocolPath,
40
+ contextId,
39
41
  cached = false
40
42
  }: GetPermissionParams): Promise<PermissionGrantEntry> {
41
- // Currently we only support finding grants based on protocols
42
- // A different approach may be necessary when we introduce `protocolPath` and `contextId` specific impersonation
43
- const cacheKey = [ connectedDid, delegateDid, messageType, protocol ].join('~');
43
+ const cacheKey = JSON.stringify([ connectedDid, delegateDid, messageType, protocol, protocolPath, contextId ]);
44
44
  const cachedGrant = cached ? this._cachedPermissions.get(cacheKey) : undefined;
45
45
  if (cachedGrant) {
46
46
  return cachedGrant;
@@ -57,13 +57,13 @@ export class AgentPermissionsApi implements PermissionsApi {
57
57
  const grant = await AgentPermissionsApi.matchGrantFromArray(
58
58
  connectedDid,
59
59
  delegateDid,
60
- { messageType, protocol },
60
+ { messageType, protocol, protocolPath, contextId },
61
61
  permissionGrants,
62
62
  delegate
63
63
  );
64
64
 
65
65
  if (!grant) {
66
- throw new Error(`CachedPermissions: No permissions found for ${messageType}: ${protocol}`);
66
+ throw new Error(`CachedPermissions: No permissions found for ${messageType}: ${[protocol, protocolPath, contextId].filter(Boolean).join('/') || undefined}`);
67
67
  }
68
68
 
69
69
  this._cachedPermissions.set(cacheKey, grant);
@@ -437,7 +437,7 @@ export class AgentPermissionsApi implements PermissionsApi {
437
437
  protocolPath?: string,
438
438
  contextId?: string
439
439
  ): boolean {
440
- // Check if the grant matches the provided parameters
440
+ // Check if the grant matches the provided parameters
441
441
  if (grant.grantee !== grantee || grant.grantor !== grantor) {
442
442
  return false;
443
443
  }
@@ -458,44 +458,13 @@ export class AgentPermissionsApi implements PermissionsApi {
458
458
  if (isMessagesScopeMatch) {
459
459
  if (isRecordsType(messageType)) {
460
460
  const recordScope = scope as DwnRecordsPermissionScope;
461
- if (recordScope.protocol !== protocol) {
462
- return false;
463
- }
464
-
465
- // If the grant scope is not restricted to a specific context or protocol path, it is unrestricted and can be used
466
- if (this.isUnrestrictedProtocolScope(recordScope)) {
467
- return true;
468
- }
469
-
470
- // protocolPath and contextId are mutually exclusive
471
- // If the permission is scoped to a protocolPath and the permissionParams matches that path, this grant can be used
472
- if (recordScope.protocolPath !== undefined && recordScope.protocolPath === protocolPath) {
473
- return true;
474
- }
475
-
476
- // If the permission is scoped to a contextId and the permissionParams starts with that contextId, this grant can be used
477
- if (recordScope.contextId !== undefined && contextId?.startsWith(recordScope.contextId)) {
478
- return true;
479
- }
461
+ return PermissionScopeMatcher.matches(recordScope, { protocol, protocolPath, contextId });
480
462
  } else {
481
463
  const messagesScope = scope;
482
- // Checks for unrestricted protocol scope, if no protocol is defined in the scope it is unrestricted
483
- if (messagesScope.protocol === undefined) {
484
- return true;
485
- }
486
-
487
- if (messagesScope.protocol !== protocol) {
488
- return false;
489
- }
490
-
491
- return this.isUnrestrictedProtocolScope(messagesScope);
464
+ return PermissionScopeMatcher.matches(messagesScope, { protocol, protocolPath, contextId });
492
465
  }
493
466
  }
494
467
 
495
468
  return false;
496
469
  }
497
-
498
- private static isUnrestrictedProtocolScope(scope: DwnPermissionScope & { contextId?: string, protocolPath?: string }): boolean {
499
- return scope.contextId === undefined && scope.protocolPath === undefined;
500
- }
501
- }
470
+ }