@abloatai/humans 0.48.0 → 0.50.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 (106) hide show
  1. package/dist/client.d.ts +6 -0
  2. package/dist/humans.d.ts +1 -1
  3. package/dist/local/RuntimeContext.d.ts +1 -1
  4. package/dist/local/SyncClient.d.ts +1 -1
  5. package/dist/local/SyncClient.js +3 -3
  6. package/dist/local/client/createModelProxy.d.ts +7 -1
  7. package/dist/local/client/createModelProxy.js +146 -39
  8. package/dist/local/client/options.d.ts +1 -1
  9. package/dist/local/client/reactiveEngine.js +69 -7
  10. package/dist/local/client/resourceTypes.d.ts +1 -1
  11. package/dist/local/client/resourceTypes.js +1 -1
  12. package/dist/local/client/storeCluster.d.ts +3 -0
  13. package/dist/local/client/storeCluster.js +4 -2
  14. package/dist/local/client/storeLifecycle.d.ts +2 -0
  15. package/dist/local/client/storeLifecycle.js +1 -0
  16. package/dist/local/client/wsMutationExecutor.d.ts +4 -1
  17. package/dist/local/client/wsMutationExecutor.js +26 -2
  18. package/dist/local/context.js +5 -1
  19. package/dist/local/interfaces/index.d.ts +3 -1
  20. package/dist/local/mutators/UndoManager.d.ts +1 -1
  21. package/dist/local/mutators/UndoManager.js +1 -1
  22. package/dist/local/query/client.js +15 -0
  23. package/dist/local/query/types.d.ts +14 -0
  24. package/dist/local/stores/syncAction.d.ts +1 -1
  25. package/dist/local/stores/syncAction.js +1 -1
  26. package/dist/local/sync/ConnectionManager.d.ts +1 -1
  27. package/dist/local/sync/ConnectionManager.js +1 -1
  28. package/dist/local/sync/OnDemandLoader.d.ts +3 -0
  29. package/dist/local/sync/OnDemandLoader.js +15 -2
  30. package/dist/local/sync/SyncWebSocket.d.ts +1 -1
  31. package/dist/local/sync/SyncWebSocket.js +1 -1
  32. package/dist/local/sync/commitFrames.d.ts +1 -1
  33. package/dist/local/sync/commitFrames.js +1 -1
  34. package/dist/local/sync/contextPorts.d.ts +1 -1
  35. package/dist/local/sync/contextPorts.js +1 -1
  36. package/dist/local/sync/credentialLifecycle.d.ts +1 -1
  37. package/dist/local/sync/credentialLifecycle.js +1 -1
  38. package/dist/local/sync/wsFrameHandlers.d.ts +1 -1
  39. package/dist/local/sync/wsFrameHandlers.js +1 -1
  40. package/dist/local/transactions/databaseCommitOutbox.d.ts +1 -1
  41. package/dist/local/transactions/localMutation.d.ts +1 -1
  42. package/dist/local/transactions/localMutation.js +1 -1
  43. package/dist/local/transactions/mutations/MutationQueue.d.ts +2 -2
  44. package/dist/local/transactions/mutations/MutationQueue.js +4 -4
  45. package/dist/local/transactions/mutations/batchProcessing.d.ts +1 -1
  46. package/dist/local/transactions/mutations/commitApi.d.ts +1 -1
  47. package/dist/local/transactions/mutations/commitLane.d.ts +1 -1
  48. package/dist/local/transactions/mutations/commitPayload.d.ts +2 -1
  49. package/dist/local/transactions/mutations/commitPayload.js +8 -0
  50. package/dist/local/transactions/mutations/commitTransport.d.ts +1 -1
  51. package/dist/local/transactions/mutations/commitTransport.js +1 -1
  52. package/dist/local/transactions/mutations/durableCommitRestore.d.ts +1 -1
  53. package/dist/local/transactions/mutations/durableCommitRestore.js +1 -1
  54. package/dist/local/transactions/mutations/durableWriteStore.d.ts +4 -4
  55. package/dist/local/transactions/mutations/durableWriteStore.js +3 -3
  56. package/dist/local/transactions/mutations/localMutation.d.ts +1 -1
  57. package/dist/local/transactions/mutations/mutationPersistence.d.ts +1 -1
  58. package/dist/local/transactions/mutations/pendingDrain.d.ts +2 -2
  59. package/dist/local/transactions/mutations/pendingDrain.js +1 -1
  60. package/dist/local/transactions/mutations/replayValidation.d.ts +13 -1
  61. package/dist/local/transactions/mutations/replayValidation.js +3 -2
  62. package/dist/local/transactions/reconnectDrain.d.ts +1 -1
  63. package/dist/react/useSyncStatus.d.ts +1 -1
  64. package/dist/react/useSyncStatus.js +1 -1
  65. package/package.json +2 -2
  66. package/src/Ablo.ts +1 -1
  67. package/src/client.ts +7 -0
  68. package/src/humans.ts +1 -1
  69. package/src/local/RuntimeContext.ts +1 -1
  70. package/src/local/SyncClient.ts +3 -3
  71. package/src/local/client/createModelProxy.ts +236 -55
  72. package/src/local/client/options.ts +1 -1
  73. package/src/local/client/reactiveEngine.ts +81 -4
  74. package/src/local/client/resourceTypes.ts +1 -1
  75. package/src/local/client/storeCluster.ts +12 -2
  76. package/src/local/client/storeLifecycle.ts +3 -0
  77. package/src/local/client/wsMutationExecutor.ts +43 -1
  78. package/src/local/context.ts +5 -1
  79. package/src/local/interfaces/index.ts +7 -5
  80. package/src/local/mutators/UndoManager.ts +1 -1
  81. package/src/local/query/client.ts +17 -0
  82. package/src/local/query/types.ts +16 -1
  83. package/src/local/stores/syncAction.ts +1 -1
  84. package/src/local/sync/ConnectionManager.ts +1 -1
  85. package/src/local/sync/OnDemandLoader.ts +20 -3
  86. package/src/local/sync/SyncWebSocket.ts +1 -1
  87. package/src/local/sync/commitFrames.ts +1 -1
  88. package/src/local/sync/contextPorts.ts +1 -1
  89. package/src/local/sync/credentialLifecycle.ts +1 -1
  90. package/src/local/sync/wsFrameHandlers.ts +1 -1
  91. package/src/local/transactions/databaseCommitOutbox.ts +1 -1
  92. package/src/local/transactions/localMutation.ts +1 -1
  93. package/src/local/transactions/mutations/MutationQueue.ts +4 -4
  94. package/src/local/transactions/mutations/batchProcessing.ts +1 -1
  95. package/src/local/transactions/mutations/commitApi.ts +1 -1
  96. package/src/local/transactions/mutations/commitLane.ts +1 -1
  97. package/src/local/transactions/mutations/commitPayload.ts +10 -1
  98. package/src/local/transactions/mutations/commitTransport.ts +1 -1
  99. package/src/local/transactions/mutations/durableCommitRestore.ts +2 -2
  100. package/src/local/transactions/mutations/durableWriteStore.ts +4 -4
  101. package/src/local/transactions/mutations/localMutation.ts +1 -1
  102. package/src/local/transactions/mutations/mutationPersistence.ts +1 -1
  103. package/src/local/transactions/mutations/pendingDrain.ts +2 -2
  104. package/src/local/transactions/mutations/replayValidation.ts +3 -2
  105. package/src/local/transactions/reconnectDrain.ts +1 -1
  106. package/src/react/useSyncStatus.ts +1 -1
@@ -1,12 +1,12 @@
1
1
  /**
2
- * The durable-write port moved to the settlement core (ADR 0016): it is a
2
+ * The durable-write port moved to the confirmation core (ADR 0016): it is a
3
3
  * contract over commit envelopes and holds no local rows. Re-exported here so
4
4
  * the existing `transactions/mutations/durableWriteStore` import path keeps
5
5
  * resolving for the queue, the outbox, and the client options.
6
6
  *
7
7
  * The port and its config live in the core's `durableWrites` module (a behavior
8
8
  * contract, not a persisted shape); the records that cross it are owned by
9
- * `transactions/settlement/pendingWrite`.
9
+ * `transactions/confirmation/pendingWrite`.
10
10
  */
11
11
  export { durableWriteStoreSchema, durableWritesConfigSchema, } from '@abloatai/transaction/durableWrites';
12
- export { pendingWriteSchema } from '@abloatai/transaction/transactions/settlement/pendingWrite';
12
+ export { pendingWriteSchema } from '@abloatai/transaction/transactions/confirmation/pendingWrite';
@@ -26,7 +26,7 @@ export interface OptimisticUpdateEntry {
26
26
  export interface OptimisticEmitter {
27
27
  emit(event: string, payload: unknown): void;
28
28
  }
29
- /** Materializer capability consumed by settlement; implementation belongs to the local layer. */
29
+ /** Materializer capability consumed by confirmation; implementation belongs to the local layer. */
30
30
  export interface LocalMutationPort {
31
31
  readonly updates: Map<string, OptimisticUpdateEntry>;
32
32
  applyCreate(model: Model, transaction: QueuedMutation): void;
@@ -1,7 +1,7 @@
1
1
  import type { RuntimeContext } from '../../RuntimeContext.js';
2
2
  import type { MutationPersistencePort } from '../../mutationPersistence.js';
3
3
  import type { MutationQueueConfig } from './MutationQueue.js';
4
- import type { CommitOutboxScope } from '@abloatai/transaction/transactions/settlement/commitEnvelope';
4
+ import type { CommitOutboxScope } from '@abloatai/transaction/transactions/confirmation/commitEnvelope';
5
5
  import type { QueuedMutation } from './commitPayload.js';
6
6
  import { MutationStore } from './MutationStore.js';
7
7
  import { deserializePersistedTransaction } from './replayValidation.js';
@@ -3,7 +3,7 @@ import type { QueuedMutation } from './commitPayload.js';
3
3
  import type { MutationStore } from './MutationStore.js';
4
4
  import type { OptimisticUpdateEntry } from './localMutation.js';
5
5
  import type { MutationCommitResult } from '@abloatai/transaction/wire/commit';
6
- import type { DurableCommitEnvelope } from '@abloatai/transaction/transactions/settlement/commitEnvelope';
6
+ import type { DurableCommitEnvelope } from '@abloatai/transaction/transactions/confirmation/commitEnvelope';
7
7
  export interface PendingDrainContext {
8
8
  readonly runtime: RuntimeContext;
9
9
  readonly config: {
@@ -30,4 +30,4 @@ export interface PendingDrainContext {
30
30
  readonly recentDeltaCorrelations: Map<string, number>;
31
31
  readonly emit: (event: string, payload: object) => boolean;
32
32
  }
33
- export declare function drainPendingSettlements(ctx: PendingDrainContext): Promise<void>;
33
+ export declare function drainPendingConfirmations(ctx: PendingDrainContext): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { applyWriteOptions, TX_TYPE_TO_MUTATION_OP } from './commitPayload.js';
2
- export async function drainPendingSettlements(ctx) {
2
+ export async function drainPendingConfirmations(ctx) {
3
3
  ctx.assertDurableReplayOpen();
4
4
  // Kick the commit lane too: atomic envelopes from `commits.create()` may
5
5
  // have been left at the head of the lane while the connection was down.
@@ -4,7 +4,7 @@
4
4
  * Rows read back from the on-disk transaction store may have been written by an
5
5
  * earlier run — possibly by an older version of this package, possibly
6
6
  * corrupted. Rather than trust them, the schemas here validate exactly the
7
- * fields the settlement queue and the local journal restore read during
7
+ * fields the confirmation queue and the local journal restore read during
8
8
  * replay. A row that fails to parse is dropped and reported, never replayed as
9
9
  * a malformed commit.
10
10
  *
@@ -64,6 +64,9 @@ export declare const persistedTransactionSchema: z.ZodObject<{
64
64
  idempotencyKey: z.ZodOptional<z.ZodString>;
65
65
  label: z.ZodOptional<z.ZodString>;
66
66
  fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
67
+ claimRef: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
68
+ id: z.ZodString;
69
+ }, z.core.$strip>]>>>;
67
70
  }, z.core.$loose>>;
68
71
  localOnly: z.ZodOptional<z.ZodBoolean>;
69
72
  }, z.core.$loose>;
@@ -107,6 +110,9 @@ export declare const persistedMutationSchema: z.ZodObject<{
107
110
  idempotencyKey: z.ZodOptional<z.ZodString>;
108
111
  label: z.ZodOptional<z.ZodString>;
109
112
  fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
113
+ claimRef: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
114
+ id: z.ZodString;
115
+ }, z.core.$strip>]>>>;
110
116
  }, z.core.$loose>>;
111
117
  }, z.core.$loose>;
112
118
  export type PersistedQueuedMutation = z.infer<typeof persistedMutationSchema>;
@@ -143,6 +149,9 @@ export declare const legacyPendingMutationRecordSchema: z.ZodObject<{
143
149
  idempotencyKey: z.ZodOptional<z.ZodString>;
144
150
  label: z.ZodOptional<z.ZodString>;
145
151
  fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
152
+ claimRef: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
153
+ id: z.ZodString;
154
+ }, z.core.$strip>]>>>;
146
155
  }, z.core.$loose>>;
147
156
  mutationId: z.ZodString;
148
157
  }, z.core.$loose>;
@@ -178,6 +187,9 @@ export declare const pendingMutationRecordSchema: z.ZodObject<{
178
187
  idempotencyKey: z.ZodOptional<z.ZodString>;
179
188
  label: z.ZodOptional<z.ZodString>;
180
189
  fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
190
+ claimRef: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
191
+ id: z.ZodString;
192
+ }, z.core.$strip>]>>>;
181
193
  }, z.core.$loose>>;
182
194
  mutationId: z.ZodString;
183
195
  }, z.core.$loose>;
@@ -4,7 +4,7 @@
4
4
  * Rows read back from the on-disk transaction store may have been written by an
5
5
  * earlier run — possibly by an older version of this package, possibly
6
6
  * corrupted. Rather than trust them, the schemas here validate exactly the
7
- * fields the settlement queue and the local journal restore read during
7
+ * fields the confirmation queue and the local journal restore read during
8
8
  * replay. A row that fails to parse is dropped and reported, never replayed as
9
9
  * a malformed commit.
10
10
  *
@@ -17,7 +17,7 @@
17
17
  import { z } from 'zod';
18
18
  import { computePriorityScore, normalizeModelKey } from './commitPayload.js';
19
19
  import { globalRuntime } from '../../context.js';
20
- import { commitEnvelopeMemberSchema, commitOutboxScopeSchema, } from '@abloatai/transaction/transactions/settlement/commitEnvelope';
20
+ import { commitEnvelopeMemberSchema, commitOutboxScopeSchema, } from '@abloatai/transaction/transactions/confirmation/commitEnvelope';
21
21
  import { onStaleModeSchema } from '@abloatai/transaction/coordination/schema';
22
22
  /** The subset of a write's options that is stored with each transaction or queued mutation. */
23
23
  const persistedWriteOptionsSchema = z
@@ -32,6 +32,7 @@ const persistedWriteOptionsSchema = z
32
32
  // write. Declared (not just loose-passthrough) so it is validated as a
33
33
  // number on rehydration.
34
34
  fenceToken: z.number().nullable().optional(),
35
+ claimRef: z.union([z.string().min(1), z.object({ id: z.string().min(1) })]).nullable().optional(),
35
36
  })
36
37
  .loose();
37
38
  /**
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Human-side reconnect adapter.
3
3
  *
4
- * The settlement callback owns ordering and receipts. This adapter owns the
4
+ * The confirmation callback owns ordering and receipts. This adapter owns the
5
5
  * local client's reconnect concurrency: repeated online/connect signals join
6
6
  * the same drain instead of starting competing local recovery passes.
7
7
  */
@@ -15,5 +15,5 @@ export type SyncStatusSnapshot = {
15
15
  } | {
16
16
  readonly name: 'needs-auth';
17
17
  };
18
- /** Reactively exposes the local store's connection and settlement status. */
18
+ /** Reactively exposes the local store's connection and confirmation status. */
19
19
  export declare function useSyncStatus(): SyncStatusSnapshot;
@@ -2,7 +2,7 @@
2
2
  import { useCallback } from 'react';
3
3
  import { useSyncContext, } from './context.js';
4
4
  import { useReactive } from '../useReactive.js';
5
- /** Reactively exposes the local store's connection and settlement status. */
5
+ /** Reactively exposes the local store's connection and confirmation status. */
6
6
  export function useSyncStatus() {
7
7
  const { store } = useSyncContext();
8
8
  const compute = useCallback(() => deriveStatus(store), [store]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abloatai/humans",
3
- "version": "0.48.0",
3
+ "version": "0.50.0",
4
4
  "description": "The optional human-facing local-state package for Ablo: presence, live queries, and React bindings.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -84,7 +84,7 @@
84
84
  "directory": "packages/humans"
85
85
  },
86
86
  "dependencies": {
87
- "@abloatai/transaction": "^0.48.0",
87
+ "@abloatai/transaction": "^0.50.0",
88
88
  "mobx": "^6.13.7",
89
89
  "uuid": "^11.1.0",
90
90
  "zod": "^4.4.3"
package/src/Ablo.ts CHANGED
@@ -64,7 +64,7 @@ export type {
64
64
  } from './local/client/options.js';
65
65
  export type { AbloReads } from './client.js';
66
66
  // `ModelTarget` (the model/id locator) and `ModelClaim` (the resolved claim
67
- // view) are defined once in the settlement core, derived from a single zod
67
+ // view) are defined once in the confirmation core, derived from a single zod
68
68
  // schema so the typed client, the HTTP client, and the server share one
69
69
  // definition. They reach consumers through `./resourceTypes` with the rest of
70
70
  // the resource surface; re-exported here so `ablo.ModelTarget` and
package/src/client.ts CHANGED
@@ -30,6 +30,7 @@ import type {
30
30
  CreateAgentClientParams,
31
31
  SessionResource,
32
32
  } from '@abloatai/transaction/resources/httpResources';
33
+ import type { EffectiveAuthority } from '@abloatai/transaction/auth';
33
34
  export type { LocalReadOptions } from './local/client/resourceTypes.js';
34
35
 
35
36
  /** The typed sync engine client — one property per model in the schema */
@@ -182,6 +183,12 @@ export type AbloClient<S extends SchemaRecord> = {
182
183
  */
183
184
  readonly organizationId: string | null;
184
185
 
186
+ /**
187
+ * The effective authority of this running participant, confirmed by the
188
+ * server credential exchange/identity endpoint. `null` until `ready()`.
189
+ */
190
+ readonly identity: EffectiveAuthority | null;
191
+
185
192
  /**
186
193
  * Destroy every IndexedDB database owned by this engine. Disconnects
187
194
  * the WebSocket, releases timers, and deletes all `ablo_*` / `ablo-*`
package/src/humans.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Public human-facing local-state capability.
3
3
  *
4
4
  * The plugin and its local-state runtime belong to @abloatai/humans. The
5
- * shared settlement package supplies only the handoff identity and wire
5
+ * shared confirmation package supplies only the handoff identity and wire
6
6
  * contracts.
7
7
  */
8
8
  import type { AbloPlugin, PluginContext, AppliedChange } from './plugin.js';
@@ -48,7 +48,7 @@ export interface RuntimeContext {
48
48
 
49
49
  /**
50
50
  * Model metadata lookup. Injected by the client (it wires this from its
51
- * `ModelRegistry`) so the settlement core can resolve a model's metadata
51
+ * `ModelRegistry`) so the confirmation core can resolve a model's metadata
52
52
  * without importing the registry — the dependency inversion that keeps the
53
53
  * core free of the client's `Model` layer (ADR 0013).
54
54
  */
@@ -1280,7 +1280,7 @@ export class SyncClient extends EventEmitter {
1280
1280
  if (this.pendingStages.size > 0) {
1281
1281
  await Promise.all([...this.pendingStages]);
1282
1282
  }
1283
- await this.drainPendingSettlements();
1283
+ await this.drainPendingConfirmations();
1284
1284
  }
1285
1285
 
1286
1286
  /**
@@ -1511,7 +1511,7 @@ export class SyncClient extends EventEmitter {
1511
1511
  // Browser online state may have marked the client connected before the
1512
1512
  // WebSocket itself was ready. Always kick both durable lanes on the real
1513
1513
  // socket event, even when the high-level state did not change.
1514
- void this.drainPendingSettlements().catch((error: unknown) => {
1514
+ void this.drainPendingConfirmations().catch((error: unknown) => {
1515
1515
  this.runtime.observability.captureMutationFailure({
1516
1516
  context: 'restore-commit-outbox',
1517
1517
  error: error instanceof Error ? error : new Error(String(error)),
@@ -1520,7 +1520,7 @@ export class SyncClient extends EventEmitter {
1520
1520
  void this.processPendingMutations();
1521
1521
  }
1522
1522
 
1523
- private drainPendingSettlements(): Promise<void> {
1523
+ private drainPendingConfirmations(): Promise<void> {
1524
1524
  return this.reconnectDrain.drain(() => this.mutationQueue.drainPending());
1525
1525
  }
1526
1526