@sentropic/cluster-mesh 0.23.5 → 0.25.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.
Files changed (240) hide show
  1. package/README.md +5 -0
  2. package/assets/storage/engram-memory/C6-FREEZE.md +63 -0
  3. package/assets/storage/engram-memory/contract-manifest.json +6 -4
  4. package/assets/storage/engram-memory/equivalence.json +1 -1
  5. package/assets/storage/engram-memory/neutral-asset-inventory.json +53 -0
  6. package/assets/storage/engram-memory/neutral-equivalence.json +44 -0
  7. package/assets/storage/postgres/007-consumed-counters.sql +17 -0
  8. package/assets/storage/postgres/008-instance-ownership.sql +35 -0
  9. package/assets/storage/postgres/engram-memory/001-projections.sql +14 -0
  10. package/assets/storage/postgres/engram-memory/002-host-ledger.sql +14 -0
  11. package/assets/storage/postgres/engram-memory/manifest.json +29 -0
  12. package/assets/storage/postgres/manifest.json +26 -0
  13. package/contracts/engram-memory-neutral-contract-v1.d.ts +367 -0
  14. package/dist/comments/postgres.d.ts +1 -0
  15. package/dist/comments/postgres.d.ts.map +1 -1
  16. package/dist/engram-memory/binding.d.ts +115 -0
  17. package/dist/engram-memory/binding.d.ts.map +1 -0
  18. package/dist/engram-memory/binding.js +239 -0
  19. package/dist/engram-memory/binding.js.map +1 -0
  20. package/dist/engram-memory/commit-result-recovery.d.ts +12 -0
  21. package/dist/engram-memory/commit-result-recovery.d.ts.map +1 -0
  22. package/dist/engram-memory/commit-result-recovery.js +14 -0
  23. package/dist/engram-memory/commit-result-recovery.js.map +1 -0
  24. package/dist/engram-memory/contract.d.ts +7 -1
  25. package/dist/engram-memory/contract.d.ts.map +1 -1
  26. package/dist/engram-memory/contract.js +7 -1
  27. package/dist/engram-memory/contract.js.map +1 -1
  28. package/dist/engram-memory/host-maintenance.d.ts +40 -0
  29. package/dist/engram-memory/host-maintenance.d.ts.map +1 -0
  30. package/dist/engram-memory/host-maintenance.js +44 -0
  31. package/dist/engram-memory/host-maintenance.js.map +1 -0
  32. package/dist/engram-memory/ledger.d.ts +75 -0
  33. package/dist/engram-memory/ledger.d.ts.map +1 -0
  34. package/dist/engram-memory/ledger.js +286 -0
  35. package/dist/engram-memory/ledger.js.map +1 -0
  36. package/dist/engram-memory/manifest.d.ts +1 -1
  37. package/dist/engram-memory/manifest.d.ts.map +1 -1
  38. package/dist/engram-memory/manifest.js +2 -1
  39. package/dist/engram-memory/manifest.js.map +1 -1
  40. package/dist/engram-memory/neutral-contract.d.ts +368 -0
  41. package/dist/engram-memory/neutral-contract.d.ts.map +1 -0
  42. package/dist/engram-memory/neutral-contract.js +39 -0
  43. package/dist/engram-memory/neutral-contract.js.map +1 -0
  44. package/dist/engram-memory/neutral-handle.d.ts +62 -0
  45. package/dist/engram-memory/neutral-handle.d.ts.map +1 -0
  46. package/dist/engram-memory/neutral-handle.js +131 -0
  47. package/dist/engram-memory/neutral-handle.js.map +1 -0
  48. package/dist/engram-memory/postgres-queries.d.ts +1 -1
  49. package/dist/engram-memory/postgres-queries.d.ts.map +1 -1
  50. package/dist/engram-memory/postgres-queries.js +111 -21
  51. package/dist/engram-memory/postgres-queries.js.map +1 -1
  52. package/dist/engram-memory/postgres.d.ts +51 -10
  53. package/dist/engram-memory/postgres.d.ts.map +1 -1
  54. package/dist/engram-memory/postgres.js +118 -17
  55. package/dist/engram-memory/postgres.js.map +1 -1
  56. package/dist/engram-memory/projection.d.ts +12 -0
  57. package/dist/engram-memory/projection.d.ts.map +1 -0
  58. package/dist/engram-memory/projection.js +123 -0
  59. package/dist/engram-memory/projection.js.map +1 -0
  60. package/dist/engram-memory/wire-adaptation.d.ts +61 -0
  61. package/dist/engram-memory/wire-adaptation.d.ts.map +1 -0
  62. package/dist/engram-memory/wire-adaptation.js +239 -0
  63. package/dist/engram-memory/wire-adaptation.js.map +1 -0
  64. package/dist/identity-contracts/access.d.ts +54 -0
  65. package/dist/identity-contracts/access.d.ts.map +1 -0
  66. package/dist/identity-contracts/access.js +168 -0
  67. package/dist/identity-contracts/access.js.map +1 -0
  68. package/dist/identity-contracts/accounts.d.ts +44 -0
  69. package/dist/identity-contracts/accounts.d.ts.map +1 -0
  70. package/dist/identity-contracts/accounts.js +149 -0
  71. package/dist/identity-contracts/accounts.js.map +1 -0
  72. package/dist/identity-contracts/descriptors.d.ts +12 -0
  73. package/dist/identity-contracts/descriptors.d.ts.map +1 -0
  74. package/dist/identity-contracts/descriptors.js +57 -0
  75. package/dist/identity-contracts/descriptors.js.map +1 -0
  76. package/dist/identity-contracts/doubles.d.ts +115 -0
  77. package/dist/identity-contracts/doubles.d.ts.map +1 -0
  78. package/dist/identity-contracts/doubles.js +340 -0
  79. package/dist/identity-contracts/doubles.js.map +1 -0
  80. package/dist/identity-contracts/enforcement.d.ts +27 -0
  81. package/dist/identity-contracts/enforcement.d.ts.map +1 -0
  82. package/dist/identity-contracts/enforcement.js +155 -0
  83. package/dist/identity-contracts/enforcement.js.map +1 -0
  84. package/dist/identity-contracts/errors.d.ts +71 -0
  85. package/dist/identity-contracts/errors.d.ts.map +1 -0
  86. package/dist/identity-contracts/errors.js +129 -0
  87. package/dist/identity-contracts/errors.js.map +1 -0
  88. package/dist/identity-contracts/index.d.ts +12 -0
  89. package/dist/identity-contracts/index.d.ts.map +1 -0
  90. package/dist/identity-contracts/index.js +13 -0
  91. package/dist/identity-contracts/index.js.map +1 -0
  92. package/dist/identity-contracts/ports.d.ts +116 -0
  93. package/dist/identity-contracts/ports.d.ts.map +1 -0
  94. package/dist/identity-contracts/ports.js +7 -0
  95. package/dist/identity-contracts/ports.js.map +1 -0
  96. package/dist/identity-contracts/resolution.d.ts +56 -0
  97. package/dist/identity-contracts/resolution.d.ts.map +1 -0
  98. package/dist/identity-contracts/resolution.js +87 -0
  99. package/dist/identity-contracts/resolution.js.map +1 -0
  100. package/dist/identity-contracts/tenancy.d.ts +52 -0
  101. package/dist/identity-contracts/tenancy.d.ts.map +1 -0
  102. package/dist/identity-contracts/tenancy.js +171 -0
  103. package/dist/identity-contracts/tenancy.js.map +1 -0
  104. package/dist/identity-contracts/types.d.ts +253 -0
  105. package/dist/identity-contracts/types.d.ts.map +1 -0
  106. package/dist/identity-contracts/types.js +7 -0
  107. package/dist/identity-contracts/types.js.map +1 -0
  108. package/dist/identity-contracts/workspaces.d.ts +37 -0
  109. package/dist/identity-contracts/workspaces.d.ts.map +1 -0
  110. package/dist/identity-contracts/workspaces.js +118 -0
  111. package/dist/identity-contracts/workspaces.js.map +1 -0
  112. package/dist/index.d.ts +1 -0
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +1 -0
  115. package/dist/index.js.map +1 -1
  116. package/dist/integrations/mcp/memory-compose.d.ts +11 -0
  117. package/dist/integrations/mcp/memory-compose.d.ts.map +1 -0
  118. package/dist/integrations/mcp/memory-compose.js +79 -0
  119. package/dist/integrations/mcp/memory-compose.js.map +1 -0
  120. package/dist/integrations/mcp/memory-definition.d.ts +28 -0
  121. package/dist/integrations/mcp/memory-definition.d.ts.map +1 -0
  122. package/dist/integrations/mcp/memory-definition.js +2 -0
  123. package/dist/integrations/mcp/memory-definition.js.map +1 -0
  124. package/dist/integrations/mcp/memory-manifest.d.ts +4 -0
  125. package/dist/integrations/mcp/memory-manifest.d.ts.map +1 -0
  126. package/dist/integrations/mcp/memory-manifest.js +9 -0
  127. package/dist/integrations/mcp/memory-manifest.js.map +1 -0
  128. package/dist/integrations/mcp/memory-transport.d.ts +21 -0
  129. package/dist/integrations/mcp/memory-transport.d.ts.map +1 -0
  130. package/dist/integrations/mcp/memory-transport.js +47 -0
  131. package/dist/integrations/mcp/memory-transport.js.map +1 -0
  132. package/dist/integrations/mcp/memory.d.ts +19 -0
  133. package/dist/integrations/mcp/memory.d.ts.map +1 -0
  134. package/dist/integrations/mcp/memory.js +40 -0
  135. package/dist/integrations/mcp/memory.js.map +1 -0
  136. package/dist/loaders/mcp/index.d.ts +1 -0
  137. package/dist/loaders/mcp/index.d.ts.map +1 -1
  138. package/dist/loaders/mcp/index.js +1 -0
  139. package/dist/loaders/mcp/index.js.map +1 -1
  140. package/dist/loaders/mcp/memory.d.ts +6 -0
  141. package/dist/loaders/mcp/memory.d.ts.map +1 -0
  142. package/dist/loaders/mcp/memory.js +9 -0
  143. package/dist/loaders/mcp/memory.js.map +1 -0
  144. package/dist/modules/catalog.d.ts +2 -0
  145. package/dist/modules/catalog.d.ts.map +1 -1
  146. package/dist/modules/catalog.js +15 -1
  147. package/dist/modules/catalog.js.map +1 -1
  148. package/dist/modules/contracts.d.ts +1 -1
  149. package/dist/modules/contracts.d.ts.map +1 -1
  150. package/dist/modules/contracts.js +2 -0
  151. package/dist/modules/contracts.js.map +1 -1
  152. package/dist/storage/atomic.d.ts +66 -1
  153. package/dist/storage/atomic.d.ts.map +1 -1
  154. package/dist/storage/atomic.js +173 -1
  155. package/dist/storage/atomic.js.map +1 -1
  156. package/dist/storage/backend.d.ts +3 -0
  157. package/dist/storage/backend.d.ts.map +1 -1
  158. package/dist/storage/backend.js +8 -0
  159. package/dist/storage/backend.js.map +1 -1
  160. package/dist/storage/contracts.d.ts +13 -0
  161. package/dist/storage/contracts.d.ts.map +1 -1
  162. package/dist/storage/contracts.js +12 -0
  163. package/dist/storage/contracts.js.map +1 -1
  164. package/dist/storage/instance-ownership.d.ts.map +1 -1
  165. package/dist/storage/instance-ownership.js +25 -7
  166. package/dist/storage/instance-ownership.js.map +1 -1
  167. package/dist/storage/postgres/codec.d.ts +1 -0
  168. package/dist/storage/postgres/codec.d.ts.map +1 -1
  169. package/dist/storage/postgres/codec.js +19 -0
  170. package/dist/storage/postgres/codec.js.map +1 -1
  171. package/dist/storage/postgres/commit-results.d.ts +6 -0
  172. package/dist/storage/postgres/commit-results.d.ts.map +1 -0
  173. package/dist/storage/postgres/commit-results.js +28 -0
  174. package/dist/storage/postgres/commit-results.js.map +1 -0
  175. package/dist/storage/postgres/core.d.ts +3 -1
  176. package/dist/storage/postgres/core.d.ts.map +1 -1
  177. package/dist/storage/postgres/core.js +99 -36
  178. package/dist/storage/postgres/core.js.map +1 -1
  179. package/dist/storage/postgres/effects.d.ts +1 -1
  180. package/dist/storage/postgres/effects.d.ts.map +1 -1
  181. package/dist/storage/postgres/effects.js +31 -6
  182. package/dist/storage/postgres/effects.js.map +1 -1
  183. package/dist/storage/postgres/errors.d.ts.map +1 -1
  184. package/dist/storage/postgres/errors.js +13 -0
  185. package/dist/storage/postgres/errors.js.map +1 -1
  186. package/dist/storage/postgres/index.d.ts +1 -0
  187. package/dist/storage/postgres/index.d.ts.map +1 -1
  188. package/dist/storage/postgres/index.js +1 -0
  189. package/dist/storage/postgres/index.js.map +1 -1
  190. package/dist/storage/postgres/instance-guard.d.ts +48 -0
  191. package/dist/storage/postgres/instance-guard.d.ts.map +1 -0
  192. package/dist/storage/postgres/instance-guard.js +147 -0
  193. package/dist/storage/postgres/instance-guard.js.map +1 -0
  194. package/dist/storage/postgres/instance-ownership.d.ts +22 -0
  195. package/dist/storage/postgres/instance-ownership.d.ts.map +1 -0
  196. package/dist/storage/postgres/instance-ownership.js +165 -0
  197. package/dist/storage/postgres/instance-ownership.js.map +1 -0
  198. package/dist/storage/postgres/journal.d.ts +24 -8
  199. package/dist/storage/postgres/journal.d.ts.map +1 -1
  200. package/dist/storage/postgres/journal.js +43 -32
  201. package/dist/storage/postgres/journal.js.map +1 -1
  202. package/dist/storage/postgres/migrations.d.ts +2 -1
  203. package/dist/storage/postgres/migrations.d.ts.map +1 -1
  204. package/dist/storage/postgres/migrations.js +14 -4
  205. package/dist/storage/postgres/migrations.js.map +1 -1
  206. package/dist/storage/postgres/ordinary-transactions.d.ts.map +1 -1
  207. package/dist/storage/postgres/ordinary-transactions.js +3 -2
  208. package/dist/storage/postgres/ordinary-transactions.js.map +1 -1
  209. package/dist/storage/postgres/profiles.d.ts +15 -8
  210. package/dist/storage/postgres/profiles.d.ts.map +1 -1
  211. package/dist/storage/postgres/protocol.d.ts +14 -0
  212. package/dist/storage/postgres/protocol.d.ts.map +1 -1
  213. package/dist/storage/postgres/protocol.js.map +1 -1
  214. package/dist/storage/postgres/queries.js +5 -5
  215. package/dist/storage/postgres/queries.js.map +1 -1
  216. package/dist/storage/postgres/readers.js +2 -2
  217. package/dist/storage/postgres/readers.js.map +1 -1
  218. package/dist/storage/postgres/roots.d.ts.map +1 -1
  219. package/dist/storage/postgres/roots.js +10 -6
  220. package/dist/storage/postgres/roots.js.map +1 -1
  221. package/dist/storage/postgres/scope.d.ts +17 -8
  222. package/dist/storage/postgres/scope.d.ts.map +1 -1
  223. package/dist/storage/postgres/scope.js +4 -0
  224. package/dist/storage/postgres/scope.js.map +1 -1
  225. package/dist/storage/postgres/snapshots.d.ts +2 -2
  226. package/dist/storage/postgres/snapshots.d.ts.map +1 -1
  227. package/dist/storage/postgres/snapshots.js +7 -4
  228. package/dist/storage/postgres/snapshots.js.map +1 -1
  229. package/dist/storage/postgres/transactions.d.ts +11 -0
  230. package/dist/storage/postgres/transactions.d.ts.map +1 -1
  231. package/dist/storage/postgres/transactions.js +21 -0
  232. package/dist/storage/postgres/transactions.js.map +1 -1
  233. package/dist/storage/u64.d.ts +18 -0
  234. package/dist/storage/u64.d.ts.map +1 -0
  235. package/dist/storage/u64.js +54 -0
  236. package/dist/storage/u64.js.map +1 -0
  237. package/docs/memory-mcp-candidate.md +46 -0
  238. package/docs/memory-mcp.md +98 -0
  239. package/examples/memory-mcp-stdio.mjs +42 -0
  240. package/package.json +12 -2
@@ -0,0 +1,123 @@
1
+ import { quotePgIdentifier } from '../storage/postgres/protocol.js';
2
+ import { decodePgJson, decodePgText, decodePgUtf8 } from '../storage/postgres/codec.js';
3
+ import { pgScopeKey } from '../storage/postgres/roots.js';
4
+ import { chainRecordKey } from '../storage/postgres/effects.js';
5
+ import { StorageIdempotencyConflictError, StorageInvalidCommandError, StorageUnavailableError } from '../storage/errors.js';
6
+ import { isCanonicalU64 } from './codec.js';
7
+ import { validateMemoryEffects } from './postgres.js';
8
+ import { validateCommitReplay } from './replay-policy.js';
9
+ export const memoryPgScope = (context) => {
10
+ if (context.stream.moduleId !== 'engram-memory' || context.grant.moduleId !== 'engram-memory')
11
+ throw new StorageInvalidCommandError('memory projection requires the memory module');
12
+ return pgScopeKey('engram-memory', context.grant.scope);
13
+ };
14
+ export const memoryPgSchema = (context) => {
15
+ memoryPgScope(context);
16
+ const schema = context.layout.projectionSchemas['engram-memory'];
17
+ if (!schema)
18
+ throw new StorageInvalidCommandError('memory projection schema is required');
19
+ return quotePgIdentifier(schema);
20
+ };
21
+ export const decodeMemoryValue = (encoded) => {
22
+ try {
23
+ const value = JSON.parse(encoded.format === 'base64'
24
+ ? Buffer.from(encoded.data, 'base64').toString('utf8') : encoded.data);
25
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
26
+ throw new Error();
27
+ return value;
28
+ }
29
+ catch {
30
+ throw new StorageInvalidCommandError('memory projection requires JSON object bytes');
31
+ }
32
+ };
33
+ export const memoryPgMap = async (context, root, kind, key) => {
34
+ const data = quotePgIdentifier(context.layout.dataSchema);
35
+ const row = (await context.session.execute({ text: `SELECT ${data}.map_get($1::bigint,$2) AS value`,
36
+ values: [root, JSON.stringify([kind, key])],
37
+ })).rows[0];
38
+ return row?.value == null ? null : decodePgJson(decodePgUtf8(row.value));
39
+ };
40
+ export const readMemoryPgPayload = async (context, payload) => {
41
+ const data = quotePgIdentifier(context.layout.dataSchema);
42
+ const row = (await context.session.execute({ text: `SELECT bytes,erased FROM ${data}.payloads WHERE scope_key=$1 AND id=$2`,
43
+ values: [memoryPgScope(context), payload],
44
+ })).rows[0];
45
+ if (!row || row.erased === true || row.bytes === null)
46
+ throw new StorageUnavailableError('memory payload is unavailable');
47
+ return decodePgJson(decodePgUtf8(row.bytes));
48
+ };
49
+ // Validation and projection share the kernel session. Earlier contributions
50
+ // are visible here, and any refusal poisons/rolls back the entire transaction.
51
+ export const validateMemoryPgEffects = async (effects, context) => {
52
+ const schema = memoryPgSchema(context);
53
+ const proposed = new Map();
54
+ const current = async (key) => {
55
+ if (proposed.has(key))
56
+ return proposed.get(key);
57
+ const row = (await context.session.execute({
58
+ text: `SELECT payload_id FROM ${schema}.memory_entries WHERE scope_key=$1 AND map_kind='aggregate' AND entry_key=$2
59
+ ORDER BY ordinal DESC LIMIT 1`, values: [memoryPgScope(context), key],
60
+ })).rows[0];
61
+ return row ? decodeMemoryValue(await readMemoryPgPayload(context, decodePgText(row.payload_id))) : undefined;
62
+ };
63
+ await validateMemoryEffects(effects);
64
+ for (const update of effects.updates) {
65
+ await validateMemoryEffects({ ...effects, updates: [update] }, current);
66
+ proposed.set(update.key, decodeMemoryValue(update.value));
67
+ }
68
+ const events = new Set();
69
+ for (const append of effects.appends) {
70
+ if (append.chainId !== 'memory-journal')
71
+ throw new StorageInvalidCommandError('unknown memory chain');
72
+ const event = decodeMemoryValue({ format: 'utf8', data: append.record.bytes });
73
+ if (event.event_id !== append.record.id || !isCanonicalU64(event.cursor) || typeof event.intent_hash !== 'string')
74
+ throw new StorageInvalidCommandError('memory journal identity is invalid');
75
+ if (events.has(append.record.id))
76
+ throw new StorageIdempotencyConflictError('memory event repeats within one unit');
77
+ events.add(append.record.id);
78
+ const row = (await context.session.execute({ text: `SELECT intent_hash FROM ${schema}.memory_entries
79
+ WHERE scope_key=$1 AND event_id=$2`, values: [memoryPgScope(context), append.record.id],
80
+ })).rows[0];
81
+ if (row) {
82
+ const validation = validateCommitReplay({ [append.record.id]: decodePgText(row.intent_hash) }, { eventId: append.record.id, intentHash: event.intent_hash });
83
+ throw new StorageIdempotencyConflictError(validation.ok ? 'memory event requires original commit replay' : validation.errors.join('; '));
84
+ }
85
+ }
86
+ };
87
+ export const projectMemoryPgEffects = async (effects, context) => {
88
+ const schema = memoryPgSchema(context);
89
+ const save = async (kind, key, ordinal, value, eventId = null) => {
90
+ if (!isCanonicalU64(ordinal))
91
+ throw new StorageInvalidCommandError('memory projection ordinal must be u64');
92
+ const ref = await memoryPgMap(context, context.root, kind, key);
93
+ if (!ref)
94
+ throw new StorageUnavailableError('memory projection has no canonical membership');
95
+ await context.session.execute({
96
+ text: `INSERT INTO ${schema}.memory_entries(scope_key,map_kind,entry_key,payload_id,ordinal,event_id,intent_hash,scope_ref,state)
97
+ VALUES($1,$2,$3,$4,$5::numeric,$6,$7,$8,$9) ON CONFLICT DO NOTHING`,
98
+ values: [memoryPgScope(context), kind, key, ref.payload, ordinal, eventId,
99
+ eventId ? String(value.intent_hash) : null, typeof value.scope_ref === 'string' ? value.scope_ref : null,
100
+ typeof value.state === 'string' ? value.state : null],
101
+ });
102
+ };
103
+ for (const record of effects.records) {
104
+ const key = JSON.parse(record.key);
105
+ if (!Array.isArray(key) || !['memory-record-v1', 'memory-outbox-v1'].includes(String(key[0])))
106
+ throw new StorageInvalidCommandError('unknown memory record key');
107
+ const value = decodeMemoryValue(record.bytes);
108
+ await save('record', record.key, key[0] === 'memory-outbox-v1' ? String(key[1]) : '0', value);
109
+ }
110
+ for (const update of effects.updates)
111
+ await save('aggregate', update.key, String(update.version), decodeMemoryValue(update.value));
112
+ for (const append of effects.appends) {
113
+ const head = await memoryPgMap(context, context.root, 'chain', append.chainId);
114
+ if (!head)
115
+ throw new StorageUnavailableError('memory journal head is unavailable');
116
+ const event = decodeMemoryValue({ format: 'utf8', data: append.record.bytes });
117
+ // The immutable map sequence is physical; the event cursor remains exact u64.
118
+ const index = head.count - effects.appends.filter((item) => item.chainId === append.chainId).length
119
+ + effects.appends.indexOf(append);
120
+ await save('chain-record', chainRecordKey(append.chainId, index), String(event.cursor), event, append.record.id);
121
+ }
122
+ };
123
+ //# sourceMappingURL=projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.js","sourceRoot":"","sources":["../../src/engram-memory/projection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAA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WAAW,CAAoB,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAClG,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,uBAAuB,CAAC,oCAAoC,CAAC,CAAC;QACnF,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/E,8EAA8E;QAC9E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM;cAC/F,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnH,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { type MemoryEncodedValue } from './codec.js';
2
+ import type { U64AtomicUnit } from '../storage/atomic.js';
3
+ import type { EncodedValue } from '../storage/contracts.js';
4
+ import type { NeutralAggregateUpdate, NeutralAtomicUnit, NeutralModuleTransaction } from './neutral-contract.js';
5
+ export declare const memoryNeutralFailure: (error: unknown) => never;
6
+ export declare const memoryCommitIndexKey: (identity: string) => string;
7
+ export declare const isMemoryCaptureKey: (key: string) => boolean;
8
+ export declare const isMemoryOutcomeKey: (key: string) => boolean;
9
+ export declare const requireMemoryUtf8: (value: EncodedValue) => MemoryEncodedValue;
10
+ /** K7 write direction: snake-case substrate proof to camel-case kernel proof. */
11
+ export declare const captureProofToKernel: (entry: Record<string, unknown>) => Record<string, unknown>;
12
+ /** K7 read direction: camel-case kernel proof back to snake-case wire proof. */
13
+ export declare const captureProofToWire: (stored: Record<string, unknown>) => Record<string, unknown>;
14
+ export declare const translateMemoryUpdateWrite: (row: NeutralAggregateUpdate) => NeutralAggregateUpdate;
15
+ export declare const translateMemoryAggregateRead: (key: string, storedValue: EncodedValue) => MemoryEncodedValue;
16
+ /** Journal append bytes: carry the intent hash in stored bytes only. */
17
+ export declare const journalBytesWithIntentHash: (valueData: string, fallbackHash: string) => string;
18
+ /** Journal read bytes: the intent hash never leaves the stored form. */
19
+ export declare const stripJournalIntentHash: (data: string) => string;
20
+ export declare const neutralUnitToPg: (unit: NeutralAtomicUnit, lexicalIdentities?: ReadonlyMap<string, string>) => U64AtomicUnit;
21
+ /** Structural kernel transaction port consumed by the neutral transaction. */
22
+ export interface MemoryKernelTransactionPort {
23
+ readAggregate(key: string): Promise<{
24
+ readonly version: number;
25
+ readonly value: EncodedValue;
26
+ } | null>;
27
+ readRecords(keys: readonly string[], limits: {
28
+ readonly maxRecords: number;
29
+ readonly maxEncodedBytes: number;
30
+ }): Promise<readonly {
31
+ readonly key: string;
32
+ readonly bytes: EncodedValue;
33
+ readonly contentHash: string;
34
+ }[]>;
35
+ readChain(input: {
36
+ readonly chainId: string;
37
+ readonly limit: number;
38
+ readonly cursor?: unknown;
39
+ readonly maxEncodedBytes: number;
40
+ }): Promise<{
41
+ readonly records: readonly {
42
+ readonly id: string;
43
+ readonly hash: string;
44
+ readonly bytes: string;
45
+ }[];
46
+ readonly nextCursor?: unknown;
47
+ }>;
48
+ findIdempotency(selector: {
49
+ readonly key: string;
50
+ }): Promise<{
51
+ readonly digest: string;
52
+ readonly resultHash: string | null;
53
+ } | null>;
54
+ apply(unit: U64AtomicUnit): Promise<void>;
55
+ }
56
+ export declare const createMemoryNeutralTransaction: (tx: MemoryKernelTransactionPort, options?: {
57
+ readonly units?: NeutralAtomicUnit[];
58
+ readonly identity?: string;
59
+ }) => NeutralModuleTransaction;
60
+ export declare const neutralQueryResult: (name: string, records: readonly unknown[]) => MemoryEncodedValue;
61
+ //# sourceMappingURL=wire-adaptation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-adaptation.d.ts","sourceRoot":"","sources":["../../src/engram-memory/wire-adaptation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAiF,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGpI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EACV,sBAAsB,EAAE,iBAAiB,EAAE,wBAAwB,EACpE,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,oBAAoB,UAAW,OAAO,KAAG,KAUrD,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAAc,MAAM,KAAG,MACH,CAAC;AACtD,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,OACI,CAAC;AACtD,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,OACE,CAAC;AAepD,eAAO,MAAM,iBAAiB,UAAW,YAAY,KAAG,kBAGvD,CAAC;AAgBF,iFAAiF;AACjF,eAAO,MAAM,oBAAoB,UAAW,OAAO,MAAM,EAAE,OAAO,CAAC,KAAG,OAAO,MAAM,EAAE,OAAO,CAW3F,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,WAAY,OAAO,MAAM,EAAE,OAAO,CAAC,KAAG,OAAO,MAAM,EAAE,OAAO,CAI1F,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAS,sBAAsB,KAAG,sBAWxE,CAAC;AAEF,eAAO,MAAM,4BAA4B,QAClC,MAAM,eAAe,YAAY,KACrC,kBAYF,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,cAAe,MAAM,gBAAgB,MAAM,KAAG,MAIpF,CAAC;AAEF,wEAAwE;AACxE,eAAO,M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AG,EAAE,MAAM,CAAA;KAAE,GAChD,OAAO,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAClF,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,8BAA8B,OACrC,2BAA2B,YACtB;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5E,wBA2DD,CAAC;AAEH,eAAO,MAAM,kBAAkB,SAAU,MAAM,WAAW,SAAS,OAAO,EAAE,KAAG,kBAiB9E,CAAC"}
@@ -0,0 +1,239 @@
1
+ // engram-memory K7/K8 wire adaptation (E10a): the frozen Engram substrate
2
+ // persists proofs and journal events in snake-case wire form while the
3
+ // installed kernel validator checks the camel-case proof model. These pure
4
+ // helpers translate both ways at the neutral-handle boundary; validation,
5
+ // allocation, durability and authority remain in the real kernel.
6
+ import { isCanonicalU64, isMemoryLexicalTombstone, MemoryCanonicalJsonError, memoryJcs } from './codec.js';
7
+ import { isMemoryAdmissionOutcome, isMemoryCaptureProof } from './validation.js';
8
+ import { StorageInvalidCommandError } from '../storage/errors.js';
9
+ export const memoryNeutralFailure = (error) => {
10
+ const source = error instanceof MemoryCanonicalJsonError
11
+ ? { code: 'invalid-schema', message: error.message }
12
+ : (error ?? {});
13
+ const codes = {
14
+ denied: 'unauthorized', 'invalid-command': 'invalid-schema', unavailable: 'store-unavailable',
15
+ 'capacity-exceeded': 'limit-exceeded', 'idempotency-conflict': 'digest-conflict',
16
+ 'instance-busy': 'fence-conflict', 'stale-epoch': 'fence-lost', 'terminal-loss': 'fence-lost',
17
+ };
18
+ throw Object.assign(new Error(source.message ?? String(error)), { code: codes[source.code ?? ''] ?? source.code });
19
+ };
20
+ export const memoryCommitIndexKey = (identity) => JSON.stringify(['memory-host-commit-v1', identity]);
21
+ export const isMemoryCaptureKey = (key) => key.startsWith('["memory-capture-idempotency-v1",');
22
+ export const isMemoryOutcomeKey = (key) => key.startsWith('["memory-admission-outcome-v1",');
23
+ const parseStored = (data) => {
24
+ try {
25
+ const parsed = JSON.parse(data);
26
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
27
+ throw new StorageInvalidCommandError('memory wire value must be a JSON object');
28
+ }
29
+ return parsed;
30
+ }
31
+ catch (error) {
32
+ if (error instanceof StorageInvalidCommandError)
33
+ throw error;
34
+ throw new StorageInvalidCommandError('memory wire value must be JSON bytes');
35
+ }
36
+ };
37
+ export const requireMemoryUtf8 = (value) => {
38
+ if (value.format !== 'utf8')
39
+ throw new StorageInvalidCommandError('memory wire value must be UTF-8');
40
+ return { format: 'utf8', data: value.data };
41
+ };
42
+ const requireWire = (ok, what) => {
43
+ if (!ok)
44
+ throw new StorageInvalidCommandError(`memory wire proof is malformed: ${what}`);
45
+ };
46
+ const requireSnake = (entry, capture) => {
47
+ requireWire(typeof entry['candidate_id'] === 'string' && entry['candidate_id'] !== '', 'candidate_id');
48
+ if (!capture) {
49
+ requireWire('status' in entry, 'admission outcome');
50
+ return;
51
+ }
52
+ requireWire(typeof entry['cursor'] === 'string', 'cursor');
53
+ requireWire('content' in entry, 'content');
54
+ requireWire(entry['record_digest'] === undefined || typeof entry['record_digest'] === 'string', 'record_digest');
55
+ };
56
+ const requireKernel = (entry, capture) => {
57
+ requireWire(capture ? isMemoryCaptureProof(entry) : isMemoryAdmissionOutcome(entry), 'stored proof');
58
+ };
59
+ /** K7 write direction: snake-case substrate proof to camel-case kernel proof. */
60
+ export const captureProofToKernel = (entry) => {
61
+ requireSnake(entry, true);
62
+ // Only the completion field is mutable; keep every other producer field.
63
+ const { record_digest: recordDigest, ...proof } = entry;
64
+ return {
65
+ candidateId: entry['candidate_id'],
66
+ revision: recordDigest !== undefined ? 2 : 1,
67
+ recordDigest: recordDigest ?? null,
68
+ createdCursor: entry['cursor'],
69
+ proof,
70
+ };
71
+ };
72
+ /** K7 read direction: camel-case kernel proof back to snake-case wire proof. */
73
+ export const captureProofToWire = (stored) => {
74
+ requireKernel(stored, true);
75
+ const proof = (stored['proof'] ?? {});
76
+ return { ...proof, ...(stored['recordDigest'] !== null ? { record_digest: stored['recordDigest'] } : {}) };
77
+ };
78
+ export const translateMemoryUpdateWrite = (row) => {
79
+ if (!isMemoryCaptureKey(row.key) && !isMemoryOutcomeKey(row.key))
80
+ return row;
81
+ const entry = parseStored(row.value.data);
82
+ if (typeof entry['candidateId'] === 'string') {
83
+ requireKernel(entry, isMemoryCaptureKey(row.key));
84
+ return row;
85
+ }
86
+ requireSnake(entry, isMemoryCaptureKey(row.key));
87
+ if (isMemoryCaptureKey(row.key)) {
88
+ return { ...row, value: memoryJcs(captureProofToKernel(entry)) };
89
+ }
90
+ return { ...row, value: memoryJcs({ candidateId: entry['candidate_id'], outcome: entry['status'], proof: entry }) };
91
+ };
92
+ export const translateMemoryAggregateRead = (key, storedValue) => {
93
+ const value = requireMemoryUtf8(storedValue);
94
+ if (!isMemoryCaptureKey(key) && !isMemoryOutcomeKey(key))
95
+ return value;
96
+ const parsed = parseStored(value.data);
97
+ if (typeof parsed['candidate_id'] === 'string') {
98
+ requireSnake(parsed, isMemoryCaptureKey(key));
99
+ return value;
100
+ }
101
+ requireKernel(parsed, isMemoryCaptureKey(key));
102
+ if (isMemoryCaptureKey(key)) {
103
+ return memoryJcs(captureProofToWire(parsed));
104
+ }
105
+ return memoryJcs(parsed['proof']);
106
+ };
107
+ /** Journal append bytes: carry the intent hash in stored bytes only. */
108
+ export const journalBytesWithIntentHash = (valueData, fallbackHash) => {
109
+ const event = parseStored(valueData);
110
+ if (typeof event['intent_hash'] === 'string')
111
+ return valueData;
112
+ return memoryJcs({ ...event, intent_hash: event['event_digest'] ?? fallbackHash }).data;
113
+ };
114
+ /** Journal read bytes: the intent hash never leaves the stored form. */
115
+ export const stripJournalIntentHash = (data) => {
116
+ const event = parseStored(data);
117
+ if (!('intent_hash' in event))
118
+ return data;
119
+ const { intent_hash: _intentHash, ...rest } = event;
120
+ return memoryJcs(rest).data;
121
+ };
122
+ export const neutralUnitToPg = (unit, lexicalIdentities = new Map()) => {
123
+ if (unit.relationships.length || unit.barriers.length || unit.purgeIntents.length) {
124
+ throw Object.assign(new Error('unsupported memory effects'), { code: 'invalid-schema' });
125
+ }
126
+ return {
127
+ guards: unit.guards.map((guard) => guard.kind === 'aggregate-version'
128
+ ? { kind: 'aggregate-version', key: guard.aggregateKey, version: guard.version }
129
+ : guard.kind === 'chain-head' ? { kind: 'head', chainId: guard.chain, hash: guard.hash }
130
+ : { kind: 'absent', chainId: guard.chain }),
131
+ records: unit.records.map((row) => ({ key: row.key, bytes: row.value, contentHash: row.contentHash })),
132
+ appends: unit.appends.map((row) => ({
133
+ chainId: row.chain,
134
+ record: { id: row.id, hash: row.hash, bytes: journalBytesWithIntentHash(row.value.data, row.hash) },
135
+ expectation: row.expectation,
136
+ })),
137
+ updates: unit.updates.map((row) => {
138
+ const translated = translateMemoryUpdateWrite(row);
139
+ return { key: translated.key, version: translated.version, value: translated.value };
140
+ }),
141
+ indexWrites: unit.indexWrites.map((row) => {
142
+ const lexical = row.index === 'memory-accepted-lexical';
143
+ const value = lexical && isMemoryLexicalTombstone(row.value) ? null : parseStored(row.value.data);
144
+ const identity = lexicalIdentities.get(row.key);
145
+ if (value === null && identity === undefined) {
146
+ throw new StorageInvalidCommandError('lexical removal requires the existing index identity');
147
+ }
148
+ return { key: row.key,
149
+ // Removing a mutable projection retains the admitted record's immutable
150
+ // identity; only the current index result changes to the canonical null.
151
+ digest: value === null ? identity : value['record_digest'] ?? row.value.data,
152
+ resultIds: [], resultHash: lexical ? row.value.data : null };
153
+ }),
154
+ relationships: [], barriers: [], purgeIntents: [], moduleResult: unit.moduleResult,
155
+ };
156
+ };
157
+ export const createMemoryNeutralTransaction = (tx, options = {}) => ({
158
+ readAggregate: async (kind, key) => {
159
+ const found = await tx.readAggregate(key);
160
+ if (found === null)
161
+ return null;
162
+ const value = translateMemoryAggregateRead(key, found.value);
163
+ return { kind, key, version: String(found.version), value };
164
+ },
165
+ readRecords: async (kind, keys) => (await tx.readRecords(keys, { maxRecords: 2000, maxEncodedBytes: 1048576 }))
166
+ .map((row) => ({ kind, key: row.key, value: requireMemoryUtf8(row.bytes), contentHash: row.contentHash })),
167
+ readChain: async ({ chain, afterAllocation = '0', limit }) => {
168
+ if (!isCanonicalU64(afterAllocation) || !Number.isSafeInteger(limit) || limit <= 0 || limit > 2000) {
169
+ throw new StorageInvalidCommandError('memory chain requires a canonical allocation and limit from 1 to 2000');
170
+ }
171
+ const after = BigInt(afterAllocation);
172
+ const records = [];
173
+ let cursor;
174
+ for (;;) {
175
+ const page = await tx.readChain({ chainId: chain, limit: Math.min(500, limit - records.length),
176
+ cursor, maxEncodedBytes: 1048576 });
177
+ for (const row of page.records) {
178
+ const data = stripJournalIntentHash(row.bytes);
179
+ const allocation = parseStored(data)['cursor'];
180
+ if (!isCanonicalU64(allocation)) {
181
+ throw new StorageInvalidCommandError('memory chain record requires a canonical cursor');
182
+ }
183
+ if (BigInt(allocation) > after) {
184
+ records.push({ id: row.id, hash: row.hash, value: { format: 'utf8', data } });
185
+ if (records.length === limit)
186
+ return { chain, records };
187
+ }
188
+ }
189
+ if (!page.nextCursor || page.records.length === 0)
190
+ break;
191
+ cursor = page.nextCursor;
192
+ }
193
+ return { chain, records };
194
+ },
195
+ findIdempotency: async ({ commitIdentity }) => {
196
+ const row = await tx.findIdempotency({ key: memoryCommitIndexKey(commitIdentity) });
197
+ return row
198
+ ? { key: commitIdentity, intentHash: row.digest,
199
+ moduleResult: JSON.parse(row.resultHash ?? 'null') }
200
+ : null;
201
+ },
202
+ apply: async (unit) => {
203
+ const lexicalIdentities = new Map();
204
+ for (const row of unit.indexWrites) {
205
+ if (row.index === 'memory-accepted-lexical' && isMemoryLexicalTombstone(row.value)) {
206
+ const previous = await tx.findIdempotency({ key: row.key });
207
+ if (previous)
208
+ lexicalIdentities.set(row.key, previous.digest);
209
+ }
210
+ }
211
+ const translated = neutralUnitToPg(unit, lexicalIdentities);
212
+ const commitIndex = options.identity ? [{
213
+ key: memoryCommitIndexKey(options.identity),
214
+ digest: unit.intentHash,
215
+ resultIds: [], resultHash: JSON.stringify(unit.moduleResult ?? memoryJcs(null)),
216
+ }] : [];
217
+ await tx.apply({ ...translated, indexWrites: [...translated.indexWrites, ...commitIndex] });
218
+ options.units?.push(structuredClone(unit));
219
+ },
220
+ });
221
+ export const neutralQueryResult = (name, records) => {
222
+ if (name === 'scope-chain-index') {
223
+ const row = records[0];
224
+ return memoryJcs(row ? { chain: row.chainId, head: row.headHash, allocation: row.allocation }
225
+ : { chain: 'memory-journal', head: `sha256:${'0'.repeat(64)}`, allocation: '0' });
226
+ }
227
+ if (name === 'memory-journal-page') {
228
+ return memoryJcs(records.map((event) => {
229
+ const stored = event;
230
+ const { intent_hash: _intentHash, ...rest } = stored;
231
+ return { id: stored.event_id, hash: stored.event_hash, value: memoryJcs(rest) };
232
+ }));
233
+ }
234
+ if (name === 'memory-record-by-id') {
235
+ return memoryJcs(records.length ? { found: true, value: memoryJcs(records[0]) } : { found: false });
236
+ }
237
+ return memoryJcs(records);
238
+ };
239
+ //# sourceMappingURL=wire-adaptation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-adaptation.js","sourceRoot":"","sources":["../../src/engram-memory/wire-adaptation.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uEAAuE;AACvE,2EAA2E;AAC3E,0EAA0E;AAC1E,kEAAkE;AAElE,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,SAAS,EAA2B,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,0BAA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C;IACD,IAAI,IAAI,KAAK,qBAAqB,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,KAA2E,CAAC;YAC3F,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;YACrD,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAClF,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IACD,IAAI,IAAI,KAAK,qBAAqB,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACtG,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC"}
@@ -0,0 +1,54 @@
1
+ import type { DeviceCodeStore, IdentityAuditPort, InvitationStore, InvitationTokenPort, LoginSessionStore, UserAccountStore } from './ports.js';
2
+ import { type ConsumeInvitationResult, type DeviceCodeIssuance, type DeviceCodeRecord, type DeviceCodePollOutcome, type IdentityClock, type InvitationInput, type InvitationRecord, type LoginSession, type LoginSessionInput } from './types.js';
3
+ export interface InvitationDomain {
4
+ issueInvitation(input: InvitationInput, actorId: string): Promise<InvitationRecord>;
5
+ consumeInvitation(token: string, now: string): Promise<ConsumeInvitationResult>;
6
+ revokeInvitation(invitationId: string, actorId: string): Promise<InvitationRecord>;
7
+ }
8
+ export declare function createInvitations(input: {
9
+ readonly invitations: InvitationStore;
10
+ readonly tokens: InvitationTokenPort;
11
+ readonly audit: IdentityAuditPort;
12
+ readonly clock?: IdentityClock;
13
+ }): InvitationDomain;
14
+ /** F04 device-code triplet: the device polls with the device code; the user
15
+ approves with the user code. Approval binds the enrolment to an active
16
+ account; the codes are opaque values from the injected token port. */
17
+ export interface DeviceEnrolmentDomain {
18
+ issueDeviceCode(device: {
19
+ readonly deviceName?: string | null;
20
+ }, options: {
21
+ readonly now: string;
22
+ readonly ttlSeconds: number;
23
+ readonly intervalSec?: number;
24
+ }): Promise<DeviceCodeIssuance>;
25
+ pollDeviceCode(deviceCode: string, now: string): Promise<DeviceCodePollOutcome>;
26
+ approveDeviceCode(userCode: string, approval: {
27
+ readonly userId: string;
28
+ }, now: string): Promise<DeviceCodeRecord>;
29
+ }
30
+ export declare function createDeviceEnrolment(input: {
31
+ readonly deviceCodes: DeviceCodeStore;
32
+ readonly accounts: UserAccountStore;
33
+ readonly tokens: InvitationTokenPort;
34
+ readonly audit: IdentityAuditPort;
35
+ }): DeviceEnrolmentDomain;
36
+ export interface LoginSessionDomain {
37
+ createSession(input: LoginSessionInput, options: {
38
+ readonly now: string;
39
+ readonly ttlSeconds: number;
40
+ }): Promise<LoginSession>;
41
+ validateSession(sessionId: string, now: string): Promise<LoginSession>;
42
+ refreshSession(sessionId: string, options: {
43
+ readonly now: string;
44
+ readonly ttlSeconds: number;
45
+ }): Promise<LoginSession>;
46
+ revokeSession(sessionId: string, actorId: string): Promise<LoginSession>;
47
+ revokeAllSessionsForUser(userId: string, actorId: string): Promise<number>;
48
+ listSessionsForUser(userId: string): Promise<readonly LoginSession[]>;
49
+ }
50
+ export declare function createLoginSessions(input: {
51
+ readonly sessions: LoginSessionStore;
52
+ readonly clock?: IdentityClock;
53
+ }): LoginSessionDomain;
54
+ //# sourceMappingURL=access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/access.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,eAAe,E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