@sixb/core 0.1.4 → 0.1.6

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 (118) hide show
  1. package/dist/actions/index.d.ts +2 -2
  2. package/dist/actions/index.d.ts.map +1 -1
  3. package/dist/actions/index.js +8 -8
  4. package/dist/actions/read-facade.d.ts +10 -2
  5. package/dist/actions/read-facade.d.ts.map +1 -1
  6. package/dist/actions/types/context.d.ts +45 -2
  7. package/dist/actions/types/context.d.ts.map +1 -1
  8. package/dist/actions/types/definitions.d.ts +8 -2
  9. package/dist/actions/types/definitions.d.ts.map +1 -1
  10. package/dist/agents/index.js +13 -13
  11. package/dist/agents/types.d.ts +2 -0
  12. package/dist/agents/types.d.ts.map +1 -1
  13. package/dist/agents/validation.d.ts.map +1 -1
  14. package/dist/auth/index.d.ts +1 -1
  15. package/dist/auth/index.d.ts.map +1 -1
  16. package/dist/auth/index.js +1 -1
  17. package/dist/auth/runtime.d.ts.map +1 -1
  18. package/dist/auth/strategy.d.ts +1 -1
  19. package/dist/auth/strategy.d.ts.map +1 -1
  20. package/dist/auth/types.d.ts +13 -0
  21. package/dist/auth/types.d.ts.map +1 -1
  22. package/dist/bootstrap/index.js +17 -17
  23. package/dist/{chunk-tycbzedm.js → chunk-0hc5j867.js} +68 -3
  24. package/dist/chunk-0hc5j867.js.map +15 -0
  25. package/dist/{chunk-tkdscva6.js → chunk-1e8m6yn3.js} +6 -1
  26. package/dist/{chunk-tkdscva6.js.map → chunk-1e8m6yn3.js.map} +4 -4
  27. package/dist/{chunk-xdf9yswn.js → chunk-1g8negke.js} +1 -1
  28. package/dist/{chunk-s31d0qmq.js → chunk-5gynx4xn.js} +11 -11
  29. package/dist/{chunk-s31d0qmq.js.map → chunk-5gynx4xn.js.map} +1 -1
  30. package/dist/{chunk-pn8n8sba.js → chunk-5sxb1168.js} +7 -11
  31. package/dist/{chunk-pn8n8sba.js.map → chunk-5sxb1168.js.map} +3 -4
  32. package/dist/chunk-72q2y8hn.js.map +3 -3
  33. package/dist/{chunk-cbkm2vam.js → chunk-8gv5z0zm.js} +1 -1
  34. package/dist/{chunk-tek1qwgm.js → chunk-a44d5zgd.js} +8 -3
  35. package/dist/{chunk-tek1qwgm.js.map → chunk-a44d5zgd.js.map} +4 -3
  36. package/dist/{chunk-1yz3x65y.js → chunk-dy311asx.js} +7 -9
  37. package/dist/{chunk-1yz3x65y.js.map → chunk-dy311asx.js.map} +2 -2
  38. package/dist/{chunk-rs1wbvy6.js → chunk-e42bc6m3.js} +1 -1
  39. package/dist/{chunk-a09jx26t.js → chunk-fe5ev6mr.js} +1 -1
  40. package/dist/{chunk-nzw7sm3b.js → chunk-hceck7dq.js} +1 -1
  41. package/dist/{chunk-7gw7mepb.js → chunk-md8k0r54.js} +1 -1
  42. package/dist/{chunk-hbeh8j9w.js → chunk-n4spznws.js} +2 -2
  43. package/dist/{chunk-afjpa2hs.js → chunk-nkbfrt0c.js} +1 -1
  44. package/dist/{chunk-c43qr6s0.js → chunk-nva1xkjz.js} +16 -12
  45. package/dist/{chunk-c43qr6s0.js.map → chunk-nva1xkjz.js.map} +4 -4
  46. package/dist/{chunk-1wk20wn3.js → chunk-t624af60.js} +37 -35
  47. package/dist/{chunk-1wk20wn3.js.map → chunk-t624af60.js.map} +4 -4
  48. package/dist/{chunk-g13869yf.js → chunk-tg5mee00.js} +1 -1
  49. package/dist/{chunk-sxwk41qa.js → chunk-znagycq7.js} +1 -1
  50. package/dist/execution/agent.js +13 -13
  51. package/dist/execution/primitive.js +13 -13
  52. package/dist/execution/request.js +13 -13
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +21 -21
  56. package/dist/index.js.map +1 -1
  57. package/dist/materializer/index.js +6 -6
  58. package/dist/objects/index.js +9 -9
  59. package/dist/objects/query/index.js +6 -6
  60. package/dist/ontology/internal.d.ts +1 -1
  61. package/dist/ontology/internal.d.ts.map +1 -1
  62. package/dist/ontology/internal.js +14 -6
  63. package/dist/ontology/internal.js.map +3 -3
  64. package/dist/ontology/json-schema.d.ts +10 -0
  65. package/dist/ontology/json-schema.d.ts.map +1 -1
  66. package/dist/pipelines/index.js +7 -7
  67. package/dist/projections/internal.js +5 -5
  68. package/dist/storage/agents/provider.js +3 -3
  69. package/dist/storage/index.d.ts +1 -1
  70. package/dist/storage/index.d.ts.map +1 -1
  71. package/dist/storage/index.js +5 -5
  72. package/dist/storage/ontology/in-memory/materializations.d.ts +4 -3
  73. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  74. package/dist/storage/ontology/index.d.ts +1 -1
  75. package/dist/storage/ontology/index.d.ts.map +1 -1
  76. package/dist/storage/ontology/materializations.d.ts +7 -3
  77. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  78. package/dist/storage/ontology/provider.d.ts +2 -2
  79. package/dist/storage/ontology/provider.d.ts.map +1 -1
  80. package/dist/storage/workflow-runs/provider.js +3 -3
  81. package/dist/syncs/index.js +7 -7
  82. package/dist/testing/index.js +159 -21
  83. package/dist/testing/index.js.map +3 -3
  84. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  85. package/dist/webhooks/internal.js +5 -5
  86. package/dist/workflows/index.js +14 -14
  87. package/package.json +1 -1
  88. package/src/actions/index.ts +10 -1
  89. package/src/actions/read-facade.ts +125 -3
  90. package/src/actions/types/context.ts +69 -2
  91. package/src/actions/types/definitions.ts +24 -2
  92. package/src/agents/types.ts +2 -0
  93. package/src/agents/validation.ts +4 -0
  94. package/src/auth/index.ts +1 -0
  95. package/src/auth/runtime.ts +8 -0
  96. package/src/auth/strategy.ts +1 -0
  97. package/src/auth/types.ts +14 -0
  98. package/src/index.ts +5 -0
  99. package/src/ontology/internal.ts +1 -1
  100. package/src/ontology/json-schema.ts +27 -5
  101. package/src/storage/index.ts +1 -0
  102. package/src/storage/ontology/in-memory/materializations.ts +34 -22
  103. package/src/storage/ontology/index.ts +1 -0
  104. package/src/storage/ontology/materializations.ts +8 -3
  105. package/src/storage/ontology/provider.ts +2 -2
  106. package/src/storage/timeseries/store.ts +6 -6
  107. package/src/testing/materializer-storage-contract.ts +170 -2
  108. package/dist/chunk-tycbzedm.js.map +0 -15
  109. /package/dist/{chunk-xdf9yswn.js.map → chunk-1g8negke.js.map} +0 -0
  110. /package/dist/{chunk-cbkm2vam.js.map → chunk-8gv5z0zm.js.map} +0 -0
  111. /package/dist/{chunk-rs1wbvy6.js.map → chunk-e42bc6m3.js.map} +0 -0
  112. /package/dist/{chunk-a09jx26t.js.map → chunk-fe5ev6mr.js.map} +0 -0
  113. /package/dist/{chunk-nzw7sm3b.js.map → chunk-hceck7dq.js.map} +0 -0
  114. /package/dist/{chunk-7gw7mepb.js.map → chunk-md8k0r54.js.map} +0 -0
  115. /package/dist/{chunk-hbeh8j9w.js.map → chunk-n4spznws.js.map} +0 -0
  116. /package/dist/{chunk-afjpa2hs.js.map → chunk-nkbfrt0c.js.map} +0 -0
  117. /package/dist/{chunk-g13869yf.js.map → chunk-tg5mee00.js.map} +0 -0
  118. /package/dist/{chunk-sxwk41qa.js.map → chunk-znagycq7.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-x2yw73hy.js";
5
5
  import {
6
6
  SixbHost
7
- } from "../chunk-s31d0qmq.js";
7
+ } from "../chunk-5gynx4xn.js";
8
8
  import"../chunk-9t8f5xfx.js";
9
9
  import"../chunk-819wnjz8.js";
10
10
  import {
@@ -20,10 +20,10 @@ import"../chunk-ghteq96b.js";
20
20
  import"../chunk-z3zp0bj1.js";
21
21
  import"../chunk-zqqz8052.js";
22
22
  import"../chunk-f2rt4vkh.js";
23
- import"../chunk-1yz3x65y.js";
24
- import"../chunk-sxwk41qa.js";
25
- import"../chunk-hbeh8j9w.js";
26
- import"../chunk-rs1wbvy6.js";
23
+ import"../chunk-dy311asx.js";
24
+ import"../chunk-znagycq7.js";
25
+ import"../chunk-n4spznws.js";
26
+ import"../chunk-e42bc6m3.js";
27
27
  import"../chunk-5sz8ta9r.js";
28
28
  import"../chunk-979ww6b3.js";
29
29
  import"../chunk-2ab72m2h.js";
@@ -39,10 +39,10 @@ import {
39
39
  } from "../chunk-wtmzkcht.js";
40
40
  import {
41
41
  isBoundSixb
42
- } from "../chunk-c43qr6s0.js";
43
- import"../chunk-g13869yf.js";
44
- import"../chunk-cbkm2vam.js";
45
- import"../chunk-pn8n8sba.js";
42
+ } from "../chunk-nva1xkjz.js";
43
+ import"../chunk-tg5mee00.js";
44
+ import"../chunk-8gv5z0zm.js";
45
+ import"../chunk-5sxb1168.js";
46
46
  import"../chunk-4rh2m6zg.js";
47
47
  import"../chunk-xhy826cz.js";
48
48
  import {
@@ -53,7 +53,7 @@ import {
53
53
  existsObjects,
54
54
  facetObjects,
55
55
  validateObjectQuery
56
- } from "../chunk-7gw7mepb.js";
56
+ } from "../chunk-md8k0r54.js";
57
57
  import {
58
58
  ObjectQueryPlanningError,
59
59
  normalizeObjectQuery
@@ -65,12 +65,13 @@ import {
65
65
  import"../chunk-51fjndv0.js";
66
66
  import"../chunk-8m5ejdpn.js";
67
67
  import"../chunk-nf4r78r4.js";
68
- import"../chunk-tycbzedm.js";
69
- import"../chunk-tek1qwgm.js";
68
+ import"../chunk-0hc5j867.js";
69
+ import"../chunk-a44d5zgd.js";
70
70
  import {
71
71
  ProjectionRegistry,
72
+ createLinkScopeFingerprint,
72
73
  createOntologyMaterializer
73
- } from "../chunk-afjpa2hs.js";
74
+ } from "../chunk-nkbfrt0c.js";
74
75
  import"../chunk-96swp2wd.js";
75
76
  import {
76
77
  restoreTrustedPrimitiveExecutionScope
@@ -81,7 +82,7 @@ import {
81
82
  linkBatchKey,
82
83
  objectBatchKey,
83
84
  objectLinkCursor
84
- } from "../chunk-1wk20wn3.js";
85
+ } from "../chunk-t624af60.js";
85
86
  import {
86
87
  createEventId
87
88
  } from "../chunk-72q2y8hn.js";
@@ -90,15 +91,15 @@ import"../chunk-cy0n5dms.js";
90
91
  import"../chunk-dysw7nsm.js";
91
92
  import"../chunk-62c7t4jc.js";
92
93
  import"../chunk-ezake7g1.js";
93
- import"../chunk-a09jx26t.js";
94
+ import"../chunk-fe5ev6mr.js";
94
95
  import"../chunk-htq0qh7z.js";
95
96
  import"../chunk-xkthy56g.js";
96
97
  import {
97
98
  AgentStorageError
98
- } from "../chunk-xdf9yswn.js";
99
+ } from "../chunk-1g8negke.js";
99
100
  import {
100
101
  agentServiceAccountId
101
- } from "../chunk-nzw7sm3b.js";
102
+ } from "../chunk-hceck7dq.js";
102
103
  import"../chunk-t9xghkva.js";
103
104
  import {
104
105
  AiUsageStorageError
@@ -126,7 +127,7 @@ import"../chunk-dm72y8wt.js";
126
127
  import"../chunk-t0jjkep3.js";
127
128
  import {
128
129
  AuthStorageError
129
- } from "../chunk-tkdscva6.js";
130
+ } from "../chunk-1e8m6yn3.js";
130
131
  import"../chunk-rhrbz7d4.js";
131
132
  import"../chunk-xwnf87e1.js";
132
133
  import {
@@ -6783,7 +6784,7 @@ var Device2 = defineObjectType({
6783
6784
  prop("name", "string", { required: true }),
6784
6785
  prop("temperature", "double", { mode: "telemetry" })
6785
6786
  ],
6786
- links: [link.self("parent", { cardinality: "one" })]
6787
+ links: [link.self("parent", { cardinality: "one" }), link.self("peers", { cardinality: "many" })]
6787
6788
  });
6788
6789
  var devices = defineDataset("storage_contract_devices", {
6789
6790
  schema: [
@@ -6795,6 +6796,9 @@ var devices = defineDataset("storage_contract_devices", {
6795
6796
  var readings = defineDataset("storage_contract_readings", {
6796
6797
  schema: [col("device_id", "string"), col("at", "timestamp"), col("value", "float64")]
6797
6798
  });
6799
+ var devicePeers = defineDataset("storage_contract_device_peers", {
6800
+ schema: [col("source_id", "string"), col("target_id", "string")]
6801
+ });
6798
6802
  var ConflictDevice = defineObjectType({
6799
6803
  id: "StorageContractConflictDevice",
6800
6804
  name: "Conflict device",
@@ -6820,14 +6824,21 @@ var deviceProjection = defineProjection("storage_contract_devices", Device2).fro
6820
6824
  }
6821
6825
  });
6822
6826
  var temperatureProjection = defineProjection("storage_contract_temperatures", Device2.p.temperature).fromDataset(readings).points({ objectId: "device_id", at: "at", value: "value" });
6827
+ var devicePeersProjection = defineProjection("storage_contract_device_peers", Device2.l.peers).fromDataset(devicePeers).sourceField("source_id").targetField("target_id");
6823
6828
  var conflictDeviceProjection = defineProjection("storage_contract_conflict_devices", ConflictDevice).fromDataset(conflictDevices).properties({ id: "id", name: "name", state: "state" }).resolveConflicts({ strategy: "mostRecent", sourceTimestamp: "updated_at" });
6824
6829
  var ontology2 = new OntologyRegistry({ sources: [Device2, ConflictDevice] });
6825
6830
  var projections = new ProjectionRegistry({
6826
- projections: [deviceProjection, temperatureProjection, conflictDeviceProjection],
6831
+ projections: [
6832
+ deviceProjection,
6833
+ temperatureProjection,
6834
+ devicePeersProjection,
6835
+ conflictDeviceProjection
6836
+ ],
6827
6837
  ontology: ontology2,
6828
6838
  datasetsById: new Map([
6829
6839
  [devices.id, devices],
6830
6840
  [readings.id, readings],
6841
+ [devicePeers.id, devicePeers],
6831
6842
  [conflictDevices.id, conflictDevices]
6832
6843
  ])
6833
6844
  });
@@ -7218,6 +7229,133 @@ function runMaterializerStorageContractSuite(name, provider) {
7218
7229
  await provider.cleanup?.(createdStorage);
7219
7230
  }
7220
7231
  });
7232
+ test13(`${name} fences projected cardinality-many link scopes by fingerprint`, async () => {
7233
+ const createdStorage = await provider.createStorage();
7234
+ const storage = requireContractStorage(createdStorage);
7235
+ let materializationOrdinal = 0;
7236
+ const materializer = createOntologyMaterializer({
7237
+ projectId: "materializer-storage-contract",
7238
+ ontology: ontology2,
7239
+ projections,
7240
+ storage,
7241
+ dependencies: {
7242
+ batching: { sourceStageRows: 1, statePageRows: 1, planChunkRows: 1 },
7243
+ clock: () => new Date("2026-02-01T12:00:00.000Z"),
7244
+ materializationId: () => `many-scope-contract-candidate-${++materializationOrdinal}`
7245
+ }
7246
+ });
7247
+ const runtimeMaterializer = materializer.withScope(runtimeScope());
7248
+ const source = { objectTypeId: Device2.id, primaryId: "source" };
7249
+ const peer2 = (primaryId) => ({ objectTypeId: Device2.id, primaryId });
7250
+ const linkRef = (targetId) => ({
7251
+ source,
7252
+ linkId: "peers",
7253
+ target: peer2(targetId)
7254
+ });
7255
+ try {
7256
+ await runtimeMaterializer.edits.commit({
7257
+ mode: "atomic",
7258
+ source: { kind: "runtime", requestId: "many-scope-endpoints" },
7259
+ operations: ["source", "peer-a", "peer-b", "peer-c"].map((primaryId) => ({
7260
+ id: `create-${primaryId}`,
7261
+ kind: "object.create",
7262
+ ref: peer2(primaryId),
7263
+ properties: { name: primaryId }
7264
+ })),
7265
+ expectedObjects: [],
7266
+ expectedLinks: [],
7267
+ expectedLinkScopes: []
7268
+ });
7269
+ const datasetVersion = {
7270
+ datasetId: devicePeers.id,
7271
+ versionId: "many-links-v1",
7272
+ createdAt: "2026-02-01T00:00:00.000Z"
7273
+ };
7274
+ const execution2 = await claim(storage, {
7275
+ runId: "many-links-v1",
7276
+ projectionId: devicePeersProjection.id,
7277
+ protocol: "replacement",
7278
+ datasetVersion
7279
+ });
7280
+ const projectedLinks = [linkRef("peer-a"), linkRef("peer-b")];
7281
+ await (await projectionMaterializer(materializer, storage, devicePeersProjection.id, "many-links-v1")).projections.replace({
7282
+ source: { projectionId: devicePeersProjection.id },
7283
+ datasetVersion,
7284
+ execution: execution2,
7285
+ entries: entries(projectedLinks.map((ref) => ({
7286
+ root: { kind: "link", ref },
7287
+ assertions: [{ kind: "link", ref }]
7288
+ })))
7289
+ });
7290
+ const observedLinks = await storage.objects.listLinks({
7291
+ projectId: "materializer-storage-contract",
7292
+ objectTypeId: Device2.id,
7293
+ objectId: source.primaryId,
7294
+ linkId: "peers"
7295
+ });
7296
+ const fingerprint = createLinkScopeFingerprint(observedLinks.map((row) => {
7297
+ if (row.lastCommitId === undefined) {
7298
+ throw new Error("Projected contract link is missing materializer provenance.");
7299
+ }
7300
+ return {
7301
+ ref: linkRef(row.targetId),
7302
+ createdAt: row.createdAt.toISOString(),
7303
+ updatedAt: row.updatedAt.toISOString(),
7304
+ lastCommitId: row.lastCommitId
7305
+ };
7306
+ }));
7307
+ const commitObservation = async (runId, name2) => {
7308
+ await queueTestActionRun(storage, {
7309
+ id: runId,
7310
+ projectId: "materializer-storage-contract",
7311
+ actionId: "observePeers",
7312
+ subject: { kind: "object", objectTypeId: Device2.id, primaryId: source.primaryId },
7313
+ params: {},
7314
+ idempotencyKey: runId
7315
+ });
7316
+ await storage.actionRuns.start({ id: runId, projectId: "materializer-storage-contract" });
7317
+ const actionMaterializer = await primitiveMaterializer(materializer, storage, {
7318
+ kind: "action",
7319
+ id: "observePeers",
7320
+ runId
7321
+ });
7322
+ return actionMaterializer.edits.commit({
7323
+ mode: "atomic",
7324
+ source: { kind: "action", actionId: "observePeers", runId },
7325
+ operations: [
7326
+ {
7327
+ id: `record-${runId}`,
7328
+ kind: "object.patch",
7329
+ ref: source,
7330
+ set: { name: name2 },
7331
+ unset: [],
7332
+ reset: []
7333
+ }
7334
+ ],
7335
+ expectedObjects: [],
7336
+ expectedLinks: [],
7337
+ expectedLinkScopes: [{ source, linkId: "peers", fingerprint }]
7338
+ });
7339
+ };
7340
+ await expect13(commitObservation("many-scope-action", "observed peers")).resolves.toMatchObject({ kind: "edit", created: true });
7341
+ await runtimeMaterializer.edits.commit({
7342
+ mode: "atomic",
7343
+ source: { kind: "runtime", requestId: "many-scope-change" },
7344
+ operations: [{ id: "add-peer", kind: "link.upsert", ref: linkRef("peer-c") }],
7345
+ expectedObjects: [],
7346
+ expectedLinks: [],
7347
+ expectedLinkScopes: []
7348
+ });
7349
+ await expect13(commitObservation("stale-many-scope-action", "must not commit")).rejects.toThrow("Expected link scope changed");
7350
+ expect13(await storage.objects.getByPrimaryId({
7351
+ projectId: "materializer-storage-contract",
7352
+ objectTypeId: Device2.id,
7353
+ primaryId: source.primaryId
7354
+ })).toMatchObject({ properties: { name: "observed peers" } });
7355
+ } finally {
7356
+ await provider.cleanup?.(createdStorage);
7357
+ }
7358
+ });
7221
7359
  }
7222
7360
  function runtimeScope() {
7223
7361
  return createTestingScope({
@@ -10828,4 +10966,4 @@ export {
10828
10966
  claimTestProjectionRun
10829
10967
  };
10830
10968
 
10831
- //# debugId=18CDE018B0AEEC3264756E2164756E21
10969
+ //# debugId=C5E12E146E78554F64756E2164756E21