@adcp/sdk 15.9.0 → 16.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/bin/adcp-identity.js +74 -0
  2. package/bin/adcp.js +2 -0
  3. package/dist/lib/adapters/keyed-account-backend.d.mts +37 -0
  4. package/dist/lib/adapters/keyed-account-backend.d.ts +37 -0
  5. package/dist/lib/adapters/keyed-account-backend.js +121 -0
  6. package/dist/lib/adapters/keyed-account-backend.mjs +94 -0
  7. package/dist/lib/adapters/keyed-account-store.d.mts +28 -0
  8. package/dist/lib/adapters/keyed-account-store.d.ts +28 -0
  9. package/dist/lib/adapters/keyed-account-store.js +227 -0
  10. package/dist/lib/adapters/keyed-account-store.mjs +203 -0
  11. package/dist/lib/core/SingleAgentClient.d.mts +16 -2
  12. package/dist/lib/core/SingleAgentClient.d.ts +16 -2
  13. package/dist/lib/core/SingleAgentClient.js +259 -62
  14. package/dist/lib/core/SingleAgentClient.mjs +261 -57
  15. package/dist/lib/core/TaskExecutor.d.mts +6 -0
  16. package/dist/lib/core/TaskExecutor.d.ts +6 -0
  17. package/dist/lib/core/TaskExecutor.js +66 -5
  18. package/dist/lib/core/TaskExecutor.mjs +71 -5
  19. package/dist/lib/core/postgres-webhook-registration-store.js +32 -5
  20. package/dist/lib/core/postgres-webhook-registration-store.mjs +32 -5
  21. package/dist/lib/core/redis-webhook-registration-store.js +23 -1
  22. package/dist/lib/core/redis-webhook-registration-store.mjs +23 -1
  23. package/dist/lib/core/webhook-registration.d.mts +7 -1
  24. package/dist/lib/core/webhook-registration.d.ts +7 -1
  25. package/dist/lib/core/webhook-registration.js +24 -2
  26. package/dist/lib/core/webhook-registration.mjs +23 -2
  27. package/dist/lib/identity-3.3/index.d.mts +10 -0
  28. package/dist/lib/identity-3.3/index.d.ts +10 -0
  29. package/dist/lib/identity-3.3/index.js +75 -0
  30. package/dist/lib/identity-3.3/index.mjs +46 -0
  31. package/dist/lib/identity-3.3/lifecycle.d.mts +113 -0
  32. package/dist/lib/identity-3.3/lifecycle.d.ts +113 -0
  33. package/dist/lib/identity-3.3/lifecycle.js +267 -0
  34. package/dist/lib/identity-3.3/lifecycle.mjs +240 -0
  35. package/dist/lib/identity-3.3/revocation.d.mts +50 -0
  36. package/dist/lib/identity-3.3/revocation.d.ts +50 -0
  37. package/dist/lib/identity-3.3/revocation.js +238 -0
  38. package/dist/lib/identity-3.3/revocation.mjs +216 -0
  39. package/dist/lib/identity-3.3/schemas.draft.d.mts +2472 -0
  40. package/dist/lib/identity-3.3/schemas.draft.d.ts +2472 -0
  41. package/dist/lib/identity-3.3/schemas.draft.js +1448 -0
  42. package/dist/lib/identity-3.3/schemas.draft.mjs +1428 -0
  43. package/dist/lib/identity-3.3/server.d.mts +34 -0
  44. package/dist/lib/identity-3.3/server.d.ts +34 -0
  45. package/dist/lib/identity-3.3/server.js +219 -0
  46. package/dist/lib/identity-3.3/server.mjs +194 -0
  47. package/dist/lib/identity-3.3/store.d.mts +24 -0
  48. package/dist/lib/identity-3.3/store.d.ts +24 -0
  49. package/dist/lib/identity-3.3/store.js +191 -0
  50. package/dist/lib/identity-3.3/store.mjs +169 -0
  51. package/dist/lib/identity-3.3/trust.d.mts +94 -0
  52. package/dist/lib/identity-3.3/trust.d.ts +94 -0
  53. package/dist/lib/identity-3.3/trust.js +278 -0
  54. package/dist/lib/identity-3.3/trust.mjs +239 -0
  55. package/dist/lib/identity-3.3/types.d.mts +127 -0
  56. package/dist/lib/identity-3.3/types.d.ts +127 -0
  57. package/dist/lib/identity-3.3/types.js +16 -0
  58. package/dist/lib/identity-3.3/types.mjs +0 -0
  59. package/dist/lib/identity-3.3/validation.d.mts +2 -0
  60. package/dist/lib/identity-3.3/validation.d.ts +2 -0
  61. package/dist/lib/identity-3.3/validation.js +125 -0
  62. package/dist/lib/identity-3.3/validation.mjs +91 -0
  63. package/dist/lib/index.d.mts +1 -1
  64. package/dist/lib/index.d.ts +1 -1
  65. package/dist/lib/reporting/azure/index.d.mts +5 -0
  66. package/dist/lib/reporting/azure/index.d.ts +5 -0
  67. package/dist/lib/reporting/azure/index.js +26 -7
  68. package/dist/lib/reporting/azure/index.mjs +26 -7
  69. package/dist/lib/reporting/bigquery/index.d.mts +80 -25
  70. package/dist/lib/reporting/bigquery/index.d.ts +80 -25
  71. package/dist/lib/reporting/bigquery/index.js +184 -81
  72. package/dist/lib/reporting/bigquery/index.mjs +182 -80
  73. package/dist/lib/reporting/gcs/adapter.d.mts +8 -1
  74. package/dist/lib/reporting/gcs/adapter.d.ts +8 -1
  75. package/dist/lib/reporting/gcs/errors.d.mts +6 -0
  76. package/dist/lib/reporting/gcs/errors.d.ts +6 -0
  77. package/dist/lib/reporting/gcs/fence.d.mts +5 -0
  78. package/dist/lib/reporting/gcs/fence.d.ts +5 -0
  79. package/dist/lib/reporting/gcs/index.d.mts +9 -0
  80. package/dist/lib/reporting/gcs/index.d.ts +9 -0
  81. package/dist/lib/reporting/gcs/reader.d.mts +27 -3
  82. package/dist/lib/reporting/gcs/reader.d.ts +27 -3
  83. package/dist/lib/reporting/gcs/row-provider.d.mts +7 -0
  84. package/dist/lib/reporting/gcs/row-provider.d.ts +7 -0
  85. package/dist/lib/reporting/gcs/row-provider.js +34 -14
  86. package/dist/lib/reporting/gcs/row-provider.mjs +34 -14
  87. package/dist/lib/reporting/ledger/change-feed.d.mts +22 -1
  88. package/dist/lib/reporting/ledger/change-feed.d.ts +22 -1
  89. package/dist/lib/reporting/ledger/index.d.mts +11 -0
  90. package/dist/lib/reporting/ledger/index.d.ts +11 -0
  91. package/dist/lib/reporting/ledger/managed-postgres.d.mts +8 -0
  92. package/dist/lib/reporting/ledger/managed-postgres.d.ts +8 -0
  93. package/dist/lib/reporting/ledger/managed-router.d.mts +27 -2
  94. package/dist/lib/reporting/ledger/managed-router.d.ts +27 -2
  95. package/dist/lib/reporting/ledger/managed.d.mts +86 -6
  96. package/dist/lib/reporting/ledger/managed.d.ts +86 -6
  97. package/dist/lib/reporting/ledger/notification-activity.d.mts +65 -3
  98. package/dist/lib/reporting/ledger/notification-activity.d.ts +65 -3
  99. package/dist/lib/reporting/ledger/object-writes.d.mts +64 -5
  100. package/dist/lib/reporting/ledger/object-writes.d.ts +64 -5
  101. package/dist/lib/reporting/ledger/postgres.d.mts +43 -9
  102. package/dist/lib/reporting/ledger/postgres.d.ts +43 -9
  103. package/dist/lib/reporting/ledger/postgres.js +43 -27
  104. package/dist/lib/reporting/ledger/postgres.mjs +43 -27
  105. package/dist/lib/reporting/ledger/row-encoding.d.mts +92 -6
  106. package/dist/lib/reporting/ledger/row-encoding.d.ts +92 -6
  107. package/dist/lib/reporting/ledger/row-encoding.js +8 -4
  108. package/dist/lib/reporting/ledger/row-encoding.mjs +6 -3
  109. package/dist/lib/reporting/ledger/row-storage-errors.d.mts +11 -1
  110. package/dist/lib/reporting/ledger/row-storage-errors.d.ts +11 -1
  111. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +19 -1
  112. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +19 -1
  113. package/dist/lib/reporting/ledger/row-storage-migration.js +133 -18
  114. package/dist/lib/reporting/ledger/row-storage-migration.mjs +133 -18
  115. package/dist/lib/reporting/ledger/row-storage-object.d.mts +103 -12
  116. package/dist/lib/reporting/ledger/row-storage-object.d.ts +103 -12
  117. package/dist/lib/reporting/ledger/row-storage-object.js +106 -31
  118. package/dist/lib/reporting/ledger/row-storage-object.mjs +104 -31
  119. package/dist/lib/reporting/ledger/row-storage.d.mts +87 -20
  120. package/dist/lib/reporting/ledger/row-storage.d.ts +87 -20
  121. package/dist/lib/reporting/ledger/row-storage.js +126 -66
  122. package/dist/lib/reporting/ledger/row-storage.mjs +129 -67
  123. package/dist/lib/reporting/ledger/schedule.d.mts +13 -0
  124. package/dist/lib/reporting/ledger/schedule.d.ts +13 -0
  125. package/dist/lib/reporting/ledger/schedule.js +24 -0
  126. package/dist/lib/reporting/ledger/schedule.mjs +23 -0
  127. package/dist/lib/reporting/ledger/types.d.mts +23 -1
  128. package/dist/lib/reporting/ledger/types.d.ts +23 -1
  129. package/dist/lib/reporting/s3/index.d.mts +5 -0
  130. package/dist/lib/reporting/s3/index.d.ts +5 -0
  131. package/dist/lib/reporting/s3/index.js +37 -14
  132. package/dist/lib/reporting/s3/index.mjs +37 -14
  133. package/dist/lib/reporting/service/index.d.mts +10 -0
  134. package/dist/lib/reporting/service/index.d.ts +10 -0
  135. package/dist/lib/reporting/service/maintenance.d.mts +28 -2
  136. package/dist/lib/reporting/service/maintenance.d.ts +28 -2
  137. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  138. package/dist/lib/server/account-sync-contract.d.mts +14 -0
  139. package/dist/lib/server/account-sync-contract.d.ts +14 -0
  140. package/dist/lib/server/account-sync-contract.js +225 -0
  141. package/dist/lib/server/account-sync-contract.mjs +197 -0
  142. package/dist/lib/server/adcp-server.js +5 -0
  143. package/dist/lib/server/adcp-server.mjs +10 -0
  144. package/dist/lib/server/auth-signature.d.mts +10 -0
  145. package/dist/lib/server/auth-signature.d.ts +10 -0
  146. package/dist/lib/server/auth-signature.js +61 -2
  147. package/dist/lib/server/auth-signature.mjs +65 -2
  148. package/dist/lib/server/auth.d.mts +6 -0
  149. package/dist/lib/server/auth.d.ts +6 -0
  150. package/dist/lib/server/auth.js +6 -0
  151. package/dist/lib/server/auth.mjs +6 -0
  152. package/dist/lib/server/create-adcp-server.d.mts +19 -5
  153. package/dist/lib/server/create-adcp-server.d.ts +19 -5
  154. package/dist/lib/server/create-adcp-server.js +238 -19
  155. package/dist/lib/server/create-adcp-server.mjs +240 -10
  156. package/dist/lib/server/decisioning/account.d.mts +24 -1
  157. package/dist/lib/server/decisioning/account.d.ts +24 -1
  158. package/dist/lib/server/decisioning/index.d.mts +1 -1
  159. package/dist/lib/server/decisioning/index.d.ts +1 -1
  160. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +0 -50
  161. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +0 -50
  162. package/dist/lib/server/decisioning/runtime/from-platform.js +61 -11
  163. package/dist/lib/server/decisioning/runtime/from-platform.mjs +65 -12
  164. package/dist/lib/server/index.d.mts +2 -0
  165. package/dist/lib/server/index.d.ts +2 -0
  166. package/dist/lib/server/index.js +12 -0
  167. package/dist/lib/server/index.mjs +12 -0
  168. package/dist/lib/server/notification-subscriptions/runtime.js +9 -1
  169. package/dist/lib/server/notification-subscriptions/runtime.mjs +9 -1
  170. package/dist/lib/server/notification-subscriptions/types.d.mts +5 -0
  171. package/dist/lib/server/notification-subscriptions/types.d.ts +5 -0
  172. package/dist/lib/server/principal/types.d.mts +1 -1
  173. package/dist/lib/server/principal/types.d.ts +1 -1
  174. package/dist/lib/server/serve.js +5 -0
  175. package/dist/lib/server/serve.mjs +5 -0
  176. package/dist/lib/server/webhook-delivery/recovery.d.mts +1 -0
  177. package/dist/lib/server/webhook-delivery/recovery.d.ts +1 -0
  178. package/dist/lib/server/webhook-delivery/recovery.js +4 -0
  179. package/dist/lib/server/webhook-delivery/recovery.mjs +4 -0
  180. package/dist/lib/server/webhook-emitter.d.mts +10 -0
  181. package/dist/lib/server/webhook-emitter.d.ts +10 -0
  182. package/dist/lib/server/webhook-emitter.js +22 -0
  183. package/dist/lib/server/webhook-emitter.mjs +22 -0
  184. package/dist/lib/signing/agent-context.d.mts +0 -5
  185. package/dist/lib/signing/agent-context.d.ts +0 -5
  186. package/dist/lib/signing/agent-context.js +9 -1
  187. package/dist/lib/signing/agent-context.mjs +9 -1
  188. package/dist/lib/signing/agent-fetch.js +27 -2
  189. package/dist/lib/signing/agent-fetch.mjs +32 -2
  190. package/dist/lib/signing/agent-resolver/canonicalize.d.mts +10 -15
  191. package/dist/lib/signing/agent-resolver/canonicalize.d.ts +10 -15
  192. package/dist/lib/signing/agent-resolver/canonicalize.js +17 -5
  193. package/dist/lib/signing/agent-resolver/canonicalize.mjs +16 -5
  194. package/dist/lib/signing/agent-resolver/index.d.mts +1 -0
  195. package/dist/lib/signing/agent-resolver/index.d.ts +1 -0
  196. package/dist/lib/signing/agent-resolver/index.js +5 -0
  197. package/dist/lib/signing/agent-resolver/index.mjs +3 -0
  198. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +3 -2
  199. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +3 -2
  200. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +30 -3
  201. package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +30 -3
  202. package/dist/lib/signing/agent-resolver/strict-json.d.mts +2 -2
  203. package/dist/lib/signing/agent-resolver/strict-json.d.ts +2 -2
  204. package/dist/lib/signing/agent-resolver/strict-json.js +5 -3
  205. package/dist/lib/signing/agent-resolver/strict-json.mjs +5 -3
  206. package/dist/lib/signing/brand-jwks.d.mts +2 -2
  207. package/dist/lib/signing/brand-jwks.d.ts +2 -2
  208. package/dist/lib/signing/brand-jwks.js +4 -4
  209. package/dist/lib/signing/brand-jwks.mjs +4 -4
  210. package/dist/lib/signing/client.d.mts +1 -0
  211. package/dist/lib/signing/client.d.ts +1 -0
  212. package/dist/lib/signing/client.js +5 -0
  213. package/dist/lib/signing/client.mjs +3 -0
  214. package/dist/lib/signing/jwks-https.d.mts +1 -1
  215. package/dist/lib/signing/jwks-https.d.ts +1 -1
  216. package/dist/lib/signing/jwks-https.js +1 -1
  217. package/dist/lib/signing/jwks-https.mjs +1 -1
  218. package/dist/lib/signing/jwks.d.mts +11 -3
  219. package/dist/lib/signing/jwks.d.ts +11 -3
  220. package/dist/lib/signing/jwks.js +1 -1
  221. package/dist/lib/signing/jwks.mjs +1 -1
  222. package/dist/lib/signing/parser.d.mts +1 -1
  223. package/dist/lib/signing/parser.d.ts +1 -1
  224. package/dist/lib/signing/parser.js +5 -3
  225. package/dist/lib/signing/parser.mjs +6 -4
  226. package/dist/lib/signing/revocation.d.mts +4 -1
  227. package/dist/lib/signing/revocation.d.ts +4 -1
  228. package/dist/lib/signing/revocation.js +33 -3
  229. package/dist/lib/signing/revocation.mjs +31 -2
  230. package/dist/lib/signing/server.d.mts +1 -1
  231. package/dist/lib/signing/server.d.ts +1 -1
  232. package/dist/lib/signing/server.js +4 -0
  233. package/dist/lib/signing/server.mjs +4 -0
  234. package/dist/lib/signing/types.d.mts +3 -0
  235. package/dist/lib/signing/types.d.ts +3 -0
  236. package/dist/lib/signing/web-bot-auth.d.mts +117 -0
  237. package/dist/lib/signing/web-bot-auth.d.ts +117 -0
  238. package/dist/lib/signing/web-bot-auth.js +660 -0
  239. package/dist/lib/signing/web-bot-auth.mjs +624 -0
  240. package/dist/lib/testing/client.d.mts +1 -4
  241. package/dist/lib/testing/client.d.ts +1 -4
  242. package/dist/lib/testing/client.js +141 -20
  243. package/dist/lib/testing/client.mjs +137 -19
  244. package/dist/lib/testing/compliance/comply.js +29 -10
  245. package/dist/lib/testing/compliance/comply.mjs +37 -11
  246. package/dist/lib/testing/storyboard/account-sync-contract.d.mts +3 -0
  247. package/dist/lib/testing/storyboard/account-sync-contract.d.ts +3 -0
  248. package/dist/lib/testing/storyboard/account-sync-contract.js +79 -0
  249. package/dist/lib/testing/storyboard/account-sync-contract.mjs +55 -0
  250. package/dist/lib/testing/storyboard/default-invariants.js +2 -0
  251. package/dist/lib/testing/storyboard/default-invariants.mjs +2 -0
  252. package/dist/lib/testing/storyboard/runner.js +23 -8
  253. package/dist/lib/testing/storyboard/runner.mjs +24 -8
  254. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  255. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  256. package/dist/lib/types/adcp.d.mts +4 -0
  257. package/dist/lib/types/adcp.d.ts +4 -0
  258. package/dist/lib/types/schemas.generated.d.ts +6 -6
  259. package/dist/lib/utils/capabilities.d.mts +1 -0
  260. package/dist/lib/utils/capabilities.d.ts +1 -0
  261. package/dist/lib/utils/capabilities.js +5 -0
  262. package/dist/lib/utils/capabilities.mjs +5 -0
  263. package/dist/lib/v2/projection/creative-delivery.d.mts +3 -1
  264. package/dist/lib/v2/projection/creative-delivery.d.ts +3 -1
  265. package/dist/lib/v2/projection/creative-delivery.js +26 -10
  266. package/dist/lib/v2/projection/creative-delivery.mjs +26 -10
  267. package/dist/lib/v2/projection/index.d.mts +1 -1
  268. package/dist/lib/v2/projection/index.d.ts +1 -1
  269. package/dist/lib/v2/projection/legacy-routes.d.mts +24 -2
  270. package/dist/lib/v2/projection/legacy-routes.d.ts +24 -2
  271. package/dist/lib/v2/projection/legacy-routes.js +28 -2
  272. package/dist/lib/v2/projection/legacy-routes.mjs +26 -2
  273. package/dist/lib/validation/schema-loader.d.mts +2 -0
  274. package/dist/lib/validation/schema-loader.d.ts +2 -0
  275. package/dist/lib/validation/schema-loader.js +43 -4
  276. package/dist/lib/validation/schema-loader.mjs +39 -3
  277. package/dist/lib/version.d.mts +3 -3
  278. package/dist/lib/version.d.ts +3 -3
  279. package/dist/lib/version.js +3 -3
  280. package/dist/lib/version.mjs +3 -3
  281. package/docs/TYPE-SUMMARY.md +2 -2
  282. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +4 -0
  283. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +1 -1
  284. package/docs/guides/REPORTING-LEDGER.md +132 -46
  285. package/docs/guides/REPORTING-OPERATIONS.md +25 -4
  286. package/docs/guides/REPORTING-STABILITY.md +76 -0
  287. package/docs/guides/account-resolution.md +101 -0
  288. package/docs/llms.txt +3 -2
  289. package/docs/migration-12-to-13.md +7 -0
  290. package/docs/migration-14.x-rc-worksheet.md +4 -4
  291. package/docs/migration-agent-identity-3.3.md +355 -0
  292. package/docs/migration-agent-resolution-3.3.md +5 -0
  293. package/docs/migration-reporting-row-storage-alignment.md +137 -0
  294. package/examples/storyboards/account-sync-contract.yaml +57 -0
  295. package/package.json +15 -1
@@ -12,12 +12,22 @@ interface ReportingPgClient {
12
12
  query<Row extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<ReportingPgResult<Row>>;
13
13
  release(error?: Error): void;
14
14
  }
15
+ /**
16
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
17
+ */
15
18
  export interface ReportingPgPool {
16
19
  query<Row extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<ReportingPgResult<Row>>;
17
20
  connect(): Promise<ReportingPgClient>;
18
21
  }
22
+ /**
23
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
24
+ */
19
25
  export declare const REPORTING_LEDGER_MIGRATION: string;
20
- /** Constraint installed by {@link REPORTING_LEDGER_FINALITY_WRITER_FENCE_MIGRATION}. */
26
+ /**
27
+ * Constraint installed by {@link REPORTING_LEDGER_FINALITY_WRITER_FENCE_MIGRATION}.
28
+ *
29
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
30
+ */
21
31
  export declare const REPORTING_LEDGER_FINALITY_FENCE_CONSTRAINT = "adcp_reporting_transitions_finality_recorded";
22
32
  /**
23
33
  * Cutover migration that fences pre-SDK-14 writers out of the transition log.
@@ -39,8 +49,13 @@ export declare const REPORTING_LEDGER_FINALITY_FENCE_CONSTRAINT = "adcp_reportin
39
49
  * multiply finality-only events, which is the intended trade: loud rejection
40
50
  * beats a quietly broken invariant. Idempotent and re-runnable; it takes no lock
41
51
  * once installed.
52
+ *
53
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
42
54
  */
43
55
  export declare const REPORTING_LEDGER_FINALITY_WRITER_FENCE_MIGRATION: string;
56
+ /**
57
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
58
+ */
44
59
  export interface PostgresReportingLedgerStoreOptions {
45
60
  /** Assert that the supplied PostgreSQL database/schema is isolated to this deployment. */
46
61
  acknowledgeIsolatedDatabase?: boolean;
@@ -103,21 +118,38 @@ export interface PostgresReportingLedgerStoreOptions {
103
118
  */
104
119
  changeFeed?: boolean;
105
120
  }
121
+ /**
122
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
123
+ */
106
124
  export declare class ReportingLedgerLeaseLostError extends Error {
107
125
  constructor(message?: string);
108
126
  }
109
- /** A planner or writer named a period whose ledger records were retired by retention. */
127
+ /**
128
+ * A planner or writer named a period whose ledger records were retired by retention.
129
+ *
130
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
131
+ */
110
132
  export declare class ReportingLedgerPeriodRetiredError extends Error {
111
133
  constructor(message?: string);
112
134
  }
135
+ /**
136
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
137
+ */
113
138
  export declare class ReportingLedgerContinuityError extends Error {
114
139
  constructor(message?: string);
115
140
  }
116
- /** Bounded global cleanup for expired cursor snapshots and changes checkpoints. */
141
+ /**
142
+ * Bounded global cleanup for expired cursor snapshots and changes checkpoints.
143
+ *
144
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
145
+ */
117
146
  export declare function sweepExpiredReportingLedgerState(pool: Pick<ReportingPgPool, 'query'>, limit?: number): Promise<{
118
147
  snapshotsDeleted: number;
119
148
  checkpointsDeleted: number;
120
149
  }>;
150
+ /**
151
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
152
+ */
121
153
  export declare class PostgresReportingLedgerStore implements ReportingLedgerStore {
122
154
  private readonly pool;
123
155
  /**
@@ -151,9 +183,11 @@ export declare class PostgresReportingLedgerStore implements ReportingLedgerStor
151
183
  /** Append one host change-feed row inside the caller's account-locked transaction. */
152
184
  private appendChange;
153
185
  /**
154
- * Throws `INVALID_INPUT` when any configured object row binding's key template omits
155
- * `{revision_key}`, which makes snapshot compaction unsafe (see `compactSupersededSnapshots`).
156
- * Called by `compactSupersededSnapshots` and by service construction when compaction is enabled.
186
+ * Defense in depth for snapshot compaction (see `compactSupersededSnapshots`): throws `INVALID_INPUT`
187
+ * if a writable object row binding's key template omits `{revision_key}`. Every such binding is
188
+ * already refused when the store is configured, so this only guards a configuration changed after
189
+ * construction; `readOnly` bindings are skipped. Called by `compactSupersededSnapshots` and by
190
+ * service construction when compaction is enabled.
157
191
  */
158
192
  assertCompactionSafeRowBindings(): void;
159
193
  /** Probe and register row storage when enabled. Safe to call repeatedly. */
@@ -475,9 +509,9 @@ export declare class PostgresReportingLedgerStore implements ReportingLedgerStor
475
509
  /**
476
510
  * Delete external row objects, skipping any object another row set still references.
477
511
  *
478
- * A custom `keyTemplate` need only include `{content_sha256}` and `{chunk_index}`, so row sets
479
- * from different obligations or accounts with identical chunk content can share one object (a
480
- * create-only write adopts an existing object). An object is therefore deleted only when no
512
+ * Object keys are unique per row set (every writable template includes `{revision_key}`), but header-only
513
+ * revisions share chunks within an obligation and rows written under an older template can name one
514
+ * object from several row sets. An object is therefore deleted only when no
481
515
  * chunk of a live (or unavailable) row set outside this operation references the same binding,
482
516
  * key and native version, and no other open write intent created it. Row sets already `pruning`
483
517
  * or `pruned` do not count: their own operation deletes the object, and counting them would let
@@ -12,12 +12,22 @@ interface ReportingPgClient {
12
12
  query<Row extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<ReportingPgResult<Row>>;
13
13
  release(error?: Error): void;
14
14
  }
15
+ /**
16
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
17
+ */
15
18
  export interface ReportingPgPool {
16
19
  query<Row extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<ReportingPgResult<Row>>;
17
20
  connect(): Promise<ReportingPgClient>;
18
21
  }
22
+ /**
23
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
24
+ */
19
25
  export declare const REPORTING_LEDGER_MIGRATION: string;
20
- /** Constraint installed by {@link REPORTING_LEDGER_FINALITY_WRITER_FENCE_MIGRATION}. */
26
+ /**
27
+ * Constraint installed by {@link REPORTING_LEDGER_FINALITY_WRITER_FENCE_MIGRATION}.
28
+ *
29
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
30
+ */
21
31
  export declare const REPORTING_LEDGER_FINALITY_FENCE_CONSTRAINT = "adcp_reporting_transitions_finality_recorded";
22
32
  /**
23
33
  * Cutover migration that fences pre-SDK-14 writers out of the transition log.
@@ -39,8 +49,13 @@ export declare const REPORTING_LEDGER_FINALITY_FENCE_CONSTRAINT = "adcp_reportin
39
49
  * multiply finality-only events, which is the intended trade: loud rejection
40
50
  * beats a quietly broken invariant. Idempotent and re-runnable; it takes no lock
41
51
  * once installed.
52
+ *
53
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
42
54
  */
43
55
  export declare const REPORTING_LEDGER_FINALITY_WRITER_FENCE_MIGRATION: string;
56
+ /**
57
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
58
+ */
44
59
  export interface PostgresReportingLedgerStoreOptions {
45
60
  /** Assert that the supplied PostgreSQL database/schema is isolated to this deployment. */
46
61
  acknowledgeIsolatedDatabase?: boolean;
@@ -103,21 +118,38 @@ export interface PostgresReportingLedgerStoreOptions {
103
118
  */
104
119
  changeFeed?: boolean;
105
120
  }
121
+ /**
122
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
123
+ */
106
124
  export declare class ReportingLedgerLeaseLostError extends Error {
107
125
  constructor(message?: string);
108
126
  }
109
- /** A planner or writer named a period whose ledger records were retired by retention. */
127
+ /**
128
+ * A planner or writer named a period whose ledger records were retired by retention.
129
+ *
130
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
131
+ */
110
132
  export declare class ReportingLedgerPeriodRetiredError extends Error {
111
133
  constructor(message?: string);
112
134
  }
135
+ /**
136
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
137
+ */
113
138
  export declare class ReportingLedgerContinuityError extends Error {
114
139
  constructor(message?: string);
115
140
  }
116
- /** Bounded global cleanup for expired cursor snapshots and changes checkpoints. */
141
+ /**
142
+ * Bounded global cleanup for expired cursor snapshots and changes checkpoints.
143
+ *
144
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
145
+ */
117
146
  export declare function sweepExpiredReportingLedgerState(pool: Pick<ReportingPgPool, 'query'>, limit?: number): Promise<{
118
147
  snapshotsDeleted: number;
119
148
  checkpointsDeleted: number;
120
149
  }>;
150
+ /**
151
+ * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
152
+ */
121
153
  export declare class PostgresReportingLedgerStore implements ReportingLedgerStore {
122
154
  private readonly pool;
123
155
  /**
@@ -151,9 +183,11 @@ export declare class PostgresReportingLedgerStore implements ReportingLedgerStor
151
183
  /** Append one host change-feed row inside the caller's account-locked transaction. */
152
184
  private appendChange;
153
185
  /**
154
- * Throws `INVALID_INPUT` when any configured object row binding's key template omits
155
- * `{revision_key}`, which makes snapshot compaction unsafe (see `compactSupersededSnapshots`).
156
- * Called by `compactSupersededSnapshots` and by service construction when compaction is enabled.
186
+ * Defense in depth for snapshot compaction (see `compactSupersededSnapshots`): throws `INVALID_INPUT`
187
+ * if a writable object row binding's key template omits `{revision_key}`. Every such binding is
188
+ * already refused when the store is configured, so this only guards a configuration changed after
189
+ * construction; `readOnly` bindings are skipped. Called by `compactSupersededSnapshots` and by
190
+ * service construction when compaction is enabled.
157
191
  */
158
192
  assertCompactionSafeRowBindings(): void;
159
193
  /** Probe and register row storage when enabled. Safe to call repeatedly. */
@@ -475,9 +509,9 @@ export declare class PostgresReportingLedgerStore implements ReportingLedgerStor
475
509
  /**
476
510
  * Delete external row objects, skipping any object another row set still references.
477
511
  *
478
- * A custom `keyTemplate` need only include `{content_sha256}` and `{chunk_index}`, so row sets
479
- * from different obligations or accounts with identical chunk content can share one object (a
480
- * create-only write adopts an existing object). An object is therefore deleted only when no
512
+ * Object keys are unique per row set (every writable template includes `{revision_key}`), but header-only
513
+ * revisions share chunks within an obligation and rows written under an older template can name one
514
+ * object from several row sets. An object is therefore deleted only when no
481
515
  * chunk of a live (or unavailable) row set outside this operation references the same binding,
482
516
  * key and native version, and no other open write intent created it. Row sets already `pruning`
483
517
  * or `pruned` do not count: their own operation deletes the object, and counting them would let
@@ -468,9 +468,11 @@ class PostgresReportingLedgerStore {
468
468
  );
469
469
  }
470
470
  /**
471
- * Throws `INVALID_INPUT` when any configured object row binding's key template omits
472
- * `{revision_key}`, which makes snapshot compaction unsafe (see `compactSupersededSnapshots`).
473
- * Called by `compactSupersededSnapshots` and by service construction when compaction is enabled.
471
+ * Defense in depth for snapshot compaction (see `compactSupersededSnapshots`): throws `INVALID_INPUT`
472
+ * if a writable object row binding's key template omits `{revision_key}`. Every such binding is
473
+ * already refused when the store is configured, so this only guards a configuration changed after
474
+ * construction; `readOnly` bindings are skipped. Called by `compactSupersededSnapshots` and by
475
+ * service construction when compaction is enabled.
474
476
  */
475
477
  assertCompactionSafeRowBindings() {
476
478
  this.rowStorage.assertCompactionSafeKeyTemplates();
@@ -857,6 +859,7 @@ ${managedDueArm} )
857
859
  rows: revision.rows,
858
860
  finality: revision.finality,
859
861
  periodStart: lease.obligation.period.start,
862
+ sourceTimezone: lease.obligation.period.sourceTimezone,
860
863
  binding: revision.binding,
861
864
  controlTotals: revision.wireRevision.control_totals
862
865
  }) : void 0;
@@ -1015,6 +1018,7 @@ ${managedDueArm} )
1015
1018
  obligationId: adjustment.reporting_obligation_id,
1016
1019
  rows: adjustment.rows,
1017
1020
  periodStart: lease.obligation.period.start,
1021
+ sourceTimezone: lease.obligation.period.sourceTimezone,
1018
1022
  binding: adjustment.binding
1019
1023
  }) : void 0;
1020
1024
  const upload = prepared?.binding.kind === "object" ? await this.uploadRowSetUnlessCommitted(prepared, lease, "adcp_reporting_adjustments", "adjustment_id") : void 0;
@@ -1569,16 +1573,16 @@ ${managedDueArm} )
1569
1573
  );
1570
1574
  if (rowStorage) {
1571
1575
  const objects = await this.query(
1572
- `SELECT DISTINCT row_set.row_binding_id, chunk.object_key, chunk.native_version
1576
+ `SELECT DISTINCT row_set.row_binding_id, chunk.object_ref, chunk.native_version_ref
1573
1577
  FROM adcp_reporting_row_chunks chunk
1574
1578
  JOIN adcp_reporting_row_sets row_set ON row_set.row_set_id = chunk.row_set_id
1575
- WHERE chunk.obligation_id = $1 AND chunk.object_key IS NOT NULL`,
1579
+ WHERE chunk.obligation_id = $1 AND chunk.object_ref IS NOT NULL`,
1576
1580
  [obligationId]
1577
1581
  );
1578
1582
  const byBinding = /* @__PURE__ */ new Map();
1579
1583
  for (const row of objects.rows) {
1580
1584
  const list = byBinding.get(row.row_binding_id) ?? [];
1581
- list.push({ objectKey: row.object_key, nativeVersion: row.native_version });
1585
+ list.push({ objectRef: row.object_ref, nativeVersionRef: row.native_version_ref });
1582
1586
  byBinding.set(row.row_binding_id, list);
1583
1587
  }
1584
1588
  for (const [bindingId, list] of byBinding) {
@@ -1799,15 +1803,15 @@ ${managedDueArm} )
1799
1803
  );
1800
1804
  if (binding.rows.length === 0) return false;
1801
1805
  const objects = await this.query(
1802
- `SELECT DISTINCT chunk.object_key, chunk.native_version
1806
+ `SELECT DISTINCT chunk.object_ref, chunk.native_version_ref
1803
1807
  FROM adcp_reporting_row_chunks chunk
1804
- WHERE chunk.row_set_id = $1 AND chunk.object_key IS NOT NULL`,
1808
+ WHERE chunk.row_set_id = $1 AND chunk.object_ref IS NOT NULL`,
1805
1809
  [revisionId]
1806
1810
  );
1807
1811
  if (objects.rows.length > 0) {
1808
1812
  await this.deleteUnreferencedObjects(
1809
1813
  binding.rows[0].row_binding_id,
1810
- objects.rows.map((row) => ({ objectKey: row.object_key, nativeVersion: row.native_version })),
1814
+ objects.rows.map((row) => ({ objectRef: row.object_ref, nativeVersionRef: row.native_version_ref })),
1811
1815
  { rowSetId: revisionId },
1812
1816
  signal
1813
1817
  );
@@ -1815,10 +1819,10 @@ ${managedDueArm} )
1815
1819
  await this.transaction(
1816
1820
  async (client) => {
1817
1821
  const dropped = await client.query(
1818
- `DELETE FROM adcp_reporting_row_chunks WHERE row_set_id = $1 RETURNING sha256, object_key`,
1822
+ `DELETE FROM adcp_reporting_row_chunks WHERE row_set_id = $1 RETURNING sha256, object_ref`,
1819
1823
  [revisionId]
1820
1824
  );
1821
- const bodies = [...new Set(dropped.rows.filter((row) => row.object_key === null).map((row) => row.sha256))];
1825
+ const bodies = [...new Set(dropped.rows.filter((row) => row.object_ref === null).map((row) => row.sha256))];
1822
1826
  if (bodies.length > 0) {
1823
1827
  await client.query(
1824
1828
  `DELETE FROM adcp_reporting_chunk_bodies body
@@ -1826,7 +1830,7 @@ ${managedDueArm} )
1826
1830
  AND NOT EXISTS (
1827
1831
  SELECT 1 FROM adcp_reporting_row_chunks other
1828
1832
  WHERE other.account_id = body.account_id AND other.obligation_id = body.obligation_id
1829
- AND other.sha256 = body.sha256 AND other.object_key IS NULL
1833
+ AND other.sha256 = body.sha256 AND other.object_ref IS NULL
1830
1834
  )`,
1831
1835
  [accountId, obligationId, bodies]
1832
1836
  );
@@ -1884,7 +1888,12 @@ ${managedDueArm} )
1884
1888
  RETURNING created_objects`,
1885
1889
  key
1886
1890
  );
1887
- return updated.rows[0]?.created_objects;
1891
+ return updated.rows[0]?.created_objects.map((object) => ({
1892
+ objectRef: object.object_ref ?? object.objectKey,
1893
+ nativeVersionRef: object.native_version_ref ?? object.nativeVersion
1894
+ })).filter(
1895
+ (object) => typeof object.objectRef === "string" && typeof object.nativeVersionRef === "string"
1896
+ );
1888
1897
  },
1889
1898
  { preBeginAdvisoryLock: accountLock(intent.account_id) }
1890
1899
  );
@@ -1931,9 +1940,9 @@ ${managedDueArm} )
1931
1940
  /**
1932
1941
  * Delete external row objects, skipping any object another row set still references.
1933
1942
  *
1934
- * A custom `keyTemplate` need only include `{content_sha256}` and `{chunk_index}`, so row sets
1935
- * from different obligations or accounts with identical chunk content can share one object (a
1936
- * create-only write adopts an existing object). An object is therefore deleted only when no
1943
+ * Object keys are unique per row set (every writable template includes `{revision_key}`), but header-only
1944
+ * revisions share chunks within an obligation and rows written under an older template can name one
1945
+ * object from several row sets. An object is therefore deleted only when no
1937
1946
  * chunk of a live (or unavailable) row set outside this operation references the same binding,
1938
1947
  * key and native version, and no other open write intent created it. Row sets already `pruning`
1939
1948
  * or `pruned` do not count: their own operation deletes the object, and counting them would let
@@ -1955,27 +1964,30 @@ ${managedDueArm} )
1955
1964
  signal?.throwIfAborted();
1956
1965
  const removed = await this.transaction(async (client) => {
1957
1966
  await client.query("SELECT pg_advisory_xact_lock(hashtextextended($1, 0))", [
1958
- objectLock(bindingId, object.objectKey)
1967
+ objectLock(bindingId, object.objectRef)
1959
1968
  ]);
1960
1969
  const referenced = await client.query(
1961
1970
  `(SELECT 1 FROM adcp_reporting_row_chunks chunk
1962
1971
  JOIN adcp_reporting_row_sets row_set ON row_set.row_set_id = chunk.row_set_id
1963
- WHERE row_set.row_binding_id = $1 AND chunk.object_key = $2 AND chunk.native_version = $3
1972
+ WHERE row_set.row_binding_id = $1 AND chunk.object_ref = $2 AND chunk.native_version_ref = $3
1964
1973
  AND row_set.rows_state IN ('live', 'unavailable')
1965
1974
  AND ($4::text IS NULL OR chunk.obligation_id <> $4)
1966
1975
  AND ($5::text IS NULL OR chunk.row_set_id <> $5)
1967
1976
  LIMIT 1)
1968
1977
  UNION ALL
1969
1978
  (SELECT 1 FROM adcp_reporting_row_write_intents intent
1970
- WHERE intent.row_binding_id = $1 AND intent.state = 'open' AND intent.created_objects @> $6::jsonb
1979
+ WHERE intent.row_binding_id = $1 AND intent.state = 'open'
1980
+ AND (intent.created_objects @> $6::jsonb OR intent.created_objects @> $7::jsonb)
1971
1981
  LIMIT 1)`,
1972
1982
  [
1973
1983
  bindingId,
1974
- object.objectKey,
1975
- object.nativeVersion,
1984
+ object.objectRef,
1985
+ object.nativeVersionRef,
1976
1986
  scope.obligationId ?? null,
1977
1987
  scope.rowSetId ?? null,
1978
- JSON.stringify([{ objectKey: object.objectKey, nativeVersion: object.nativeVersion }])
1988
+ JSON.stringify([{ object_ref: object.objectRef, native_version_ref: object.nativeVersionRef }]),
1989
+ // An older writer still running during a rolling upgrade records the pre-alignment keys.
1990
+ JSON.stringify([{ objectKey: object.objectRef, nativeVersion: object.nativeVersionRef }])
1979
1991
  ]
1980
1992
  );
1981
1993
  if (referenced.rows.length > 0) return false;
@@ -2061,7 +2073,11 @@ ${managedDueArm} )
2061
2073
  SET created_objects = created_objects || $5::jsonb
2062
2074
  WHERE row_binding_id = $1 AND row_set_id = $2 AND content_sha256 = $3
2063
2075
  AND owner_token = $4 AND state = 'open'`,
2064
- [...intentKey, ownerToken, JSON.stringify([object])]
2076
+ [
2077
+ ...intentKey,
2078
+ ownerToken,
2079
+ JSON.stringify([{ object_ref: object.objectRef, native_version_ref: object.nativeVersionRef }])
2080
+ ]
2065
2081
  );
2066
2082
  if (recorded.rowCount !== 1) {
2067
2083
  throw new import_row_storage.ReportingRowStoreError("STATE_UNAVAILABLE", "the row upload intent was taken over or swept");
@@ -2097,10 +2113,10 @@ ${managedDueArm} )
2097
2113
  }
2098
2114
  }
2099
2115
  if (!upload.sharedFrom) {
2100
- const adopted = upload.locators.filter((locator) => !locator.created).sort((left, right) => left.objectKey < right.objectKey ? -1 : left.objectKey > right.objectKey ? 1 : 0);
2116
+ const adopted = upload.locators.filter((locator) => !locator.created).sort((left, right) => left.objectRef < right.objectRef ? -1 : left.objectRef > right.objectRef ? 1 : 0);
2101
2117
  for (const locator of adopted) {
2102
2118
  await client.query("SELECT pg_advisory_xact_lock(hashtextextended($1, 0))", [
2103
- objectLock(prepared.bindingId, locator.objectKey)
2119
+ objectLock(prepared.bindingId, locator.objectRef)
2104
2120
  ]);
2105
2121
  }
2106
2122
  if (adopted.length > 0) await this.rowStorage.assertObjectsPresent(prepared.bindingId, adopted);
@@ -4294,8 +4310,8 @@ function rfc3339Microseconds(expression) {
4294
4310
  function accountLock(accountId) {
4295
4311
  return `adcp-reporting-account:${accountId}`;
4296
4312
  }
4297
- function objectLock(bindingId, objectKey) {
4298
- return `adcp-reporting-object:${bindingId}:${objectKey}`;
4313
+ function objectLock(bindingId, objectRef) {
4314
+ return `adcp-reporting-object:${bindingId}:${objectRef}`;
4299
4315
  }
4300
4316
  async function resolveStoredFinalityBaseline(transaction, obligationId) {
4301
4317
  const latest = await transaction.query(
@@ -469,9 +469,11 @@ class PostgresReportingLedgerStore {
469
469
  );
470
470
  }
471
471
  /**
472
- * Throws `INVALID_INPUT` when any configured object row binding's key template omits
473
- * `{revision_key}`, which makes snapshot compaction unsafe (see `compactSupersededSnapshots`).
474
- * Called by `compactSupersededSnapshots` and by service construction when compaction is enabled.
472
+ * Defense in depth for snapshot compaction (see `compactSupersededSnapshots`): throws `INVALID_INPUT`
473
+ * if a writable object row binding's key template omits `{revision_key}`. Every such binding is
474
+ * already refused when the store is configured, so this only guards a configuration changed after
475
+ * construction; `readOnly` bindings are skipped. Called by `compactSupersededSnapshots` and by
476
+ * service construction when compaction is enabled.
475
477
  */
476
478
  assertCompactionSafeRowBindings() {
477
479
  this.rowStorage.assertCompactionSafeKeyTemplates();
@@ -858,6 +860,7 @@ ${managedDueArm} )
858
860
  rows: revision.rows,
859
861
  finality: revision.finality,
860
862
  periodStart: lease.obligation.period.start,
863
+ sourceTimezone: lease.obligation.period.sourceTimezone,
861
864
  binding: revision.binding,
862
865
  controlTotals: revision.wireRevision.control_totals
863
866
  }) : void 0;
@@ -1016,6 +1019,7 @@ ${managedDueArm} )
1016
1019
  obligationId: adjustment.reporting_obligation_id,
1017
1020
  rows: adjustment.rows,
1018
1021
  periodStart: lease.obligation.period.start,
1022
+ sourceTimezone: lease.obligation.period.sourceTimezone,
1019
1023
  binding: adjustment.binding
1020
1024
  }) : void 0;
1021
1025
  const upload = prepared?.binding.kind === "object" ? await this.uploadRowSetUnlessCommitted(prepared, lease, "adcp_reporting_adjustments", "adjustment_id") : void 0;
@@ -1570,16 +1574,16 @@ ${managedDueArm} )
1570
1574
  );
1571
1575
  if (rowStorage) {
1572
1576
  const objects = await this.query(
1573
- `SELECT DISTINCT row_set.row_binding_id, chunk.object_key, chunk.native_version
1577
+ `SELECT DISTINCT row_set.row_binding_id, chunk.object_ref, chunk.native_version_ref
1574
1578
  FROM adcp_reporting_row_chunks chunk
1575
1579
  JOIN adcp_reporting_row_sets row_set ON row_set.row_set_id = chunk.row_set_id
1576
- WHERE chunk.obligation_id = $1 AND chunk.object_key IS NOT NULL`,
1580
+ WHERE chunk.obligation_id = $1 AND chunk.object_ref IS NOT NULL`,
1577
1581
  [obligationId]
1578
1582
  );
1579
1583
  const byBinding = /* @__PURE__ */ new Map();
1580
1584
  for (const row of objects.rows) {
1581
1585
  const list = byBinding.get(row.row_binding_id) ?? [];
1582
- list.push({ objectKey: row.object_key, nativeVersion: row.native_version });
1586
+ list.push({ objectRef: row.object_ref, nativeVersionRef: row.native_version_ref });
1583
1587
  byBinding.set(row.row_binding_id, list);
1584
1588
  }
1585
1589
  for (const [bindingId, list] of byBinding) {
@@ -1800,15 +1804,15 @@ ${managedDueArm} )
1800
1804
  );
1801
1805
  if (binding.rows.length === 0) return false;
1802
1806
  const objects = await this.query(
1803
- `SELECT DISTINCT chunk.object_key, chunk.native_version
1807
+ `SELECT DISTINCT chunk.object_ref, chunk.native_version_ref
1804
1808
  FROM adcp_reporting_row_chunks chunk
1805
- WHERE chunk.row_set_id = $1 AND chunk.object_key IS NOT NULL`,
1809
+ WHERE chunk.row_set_id = $1 AND chunk.object_ref IS NOT NULL`,
1806
1810
  [revisionId]
1807
1811
  );
1808
1812
  if (objects.rows.length > 0) {
1809
1813
  await this.deleteUnreferencedObjects(
1810
1814
  binding.rows[0].row_binding_id,
1811
- objects.rows.map((row) => ({ objectKey: row.object_key, nativeVersion: row.native_version })),
1815
+ objects.rows.map((row) => ({ objectRef: row.object_ref, nativeVersionRef: row.native_version_ref })),
1812
1816
  { rowSetId: revisionId },
1813
1817
  signal
1814
1818
  );
@@ -1816,10 +1820,10 @@ ${managedDueArm} )
1816
1820
  await this.transaction(
1817
1821
  async (client) => {
1818
1822
  const dropped = await client.query(
1819
- `DELETE FROM adcp_reporting_row_chunks WHERE row_set_id = $1 RETURNING sha256, object_key`,
1823
+ `DELETE FROM adcp_reporting_row_chunks WHERE row_set_id = $1 RETURNING sha256, object_ref`,
1820
1824
  [revisionId]
1821
1825
  );
1822
- const bodies = [...new Set(dropped.rows.filter((row) => row.object_key === null).map((row) => row.sha256))];
1826
+ const bodies = [...new Set(dropped.rows.filter((row) => row.object_ref === null).map((row) => row.sha256))];
1823
1827
  if (bodies.length > 0) {
1824
1828
  await client.query(
1825
1829
  `DELETE FROM adcp_reporting_chunk_bodies body
@@ -1827,7 +1831,7 @@ ${managedDueArm} )
1827
1831
  AND NOT EXISTS (
1828
1832
  SELECT 1 FROM adcp_reporting_row_chunks other
1829
1833
  WHERE other.account_id = body.account_id AND other.obligation_id = body.obligation_id
1830
- AND other.sha256 = body.sha256 AND other.object_key IS NULL
1834
+ AND other.sha256 = body.sha256 AND other.object_ref IS NULL
1831
1835
  )`,
1832
1836
  [accountId, obligationId, bodies]
1833
1837
  );
@@ -1885,7 +1889,12 @@ ${managedDueArm} )
1885
1889
  RETURNING created_objects`,
1886
1890
  key
1887
1891
  );
1888
- return updated.rows[0]?.created_objects;
1892
+ return updated.rows[0]?.created_objects.map((object) => ({
1893
+ objectRef: object.object_ref ?? object.objectKey,
1894
+ nativeVersionRef: object.native_version_ref ?? object.nativeVersion
1895
+ })).filter(
1896
+ (object) => typeof object.objectRef === "string" && typeof object.nativeVersionRef === "string"
1897
+ );
1889
1898
  },
1890
1899
  { preBeginAdvisoryLock: accountLock(intent.account_id) }
1891
1900
  );
@@ -1932,9 +1941,9 @@ ${managedDueArm} )
1932
1941
  /**
1933
1942
  * Delete external row objects, skipping any object another row set still references.
1934
1943
  *
1935
- * A custom `keyTemplate` need only include `{content_sha256}` and `{chunk_index}`, so row sets
1936
- * from different obligations or accounts with identical chunk content can share one object (a
1937
- * create-only write adopts an existing object). An object is therefore deleted only when no
1944
+ * Object keys are unique per row set (every writable template includes `{revision_key}`), but header-only
1945
+ * revisions share chunks within an obligation and rows written under an older template can name one
1946
+ * object from several row sets. An object is therefore deleted only when no
1938
1947
  * chunk of a live (or unavailable) row set outside this operation references the same binding,
1939
1948
  * key and native version, and no other open write intent created it. Row sets already `pruning`
1940
1949
  * or `pruned` do not count: their own operation deletes the object, and counting them would let
@@ -1956,27 +1965,30 @@ ${managedDueArm} )
1956
1965
  signal?.throwIfAborted();
1957
1966
  const removed = await this.transaction(async (client) => {
1958
1967
  await client.query("SELECT pg_advisory_xact_lock(hashtextextended($1, 0))", [
1959
- objectLock(bindingId, object.objectKey)
1968
+ objectLock(bindingId, object.objectRef)
1960
1969
  ]);
1961
1970
  const referenced = await client.query(
1962
1971
  `(SELECT 1 FROM adcp_reporting_row_chunks chunk
1963
1972
  JOIN adcp_reporting_row_sets row_set ON row_set.row_set_id = chunk.row_set_id
1964
- WHERE row_set.row_binding_id = $1 AND chunk.object_key = $2 AND chunk.native_version = $3
1973
+ WHERE row_set.row_binding_id = $1 AND chunk.object_ref = $2 AND chunk.native_version_ref = $3
1965
1974
  AND row_set.rows_state IN ('live', 'unavailable')
1966
1975
  AND ($4::text IS NULL OR chunk.obligation_id <> $4)
1967
1976
  AND ($5::text IS NULL OR chunk.row_set_id <> $5)
1968
1977
  LIMIT 1)
1969
1978
  UNION ALL
1970
1979
  (SELECT 1 FROM adcp_reporting_row_write_intents intent
1971
- WHERE intent.row_binding_id = $1 AND intent.state = 'open' AND intent.created_objects @> $6::jsonb
1980
+ WHERE intent.row_binding_id = $1 AND intent.state = 'open'
1981
+ AND (intent.created_objects @> $6::jsonb OR intent.created_objects @> $7::jsonb)
1972
1982
  LIMIT 1)`,
1973
1983
  [
1974
1984
  bindingId,
1975
- object.objectKey,
1976
- object.nativeVersion,
1985
+ object.objectRef,
1986
+ object.nativeVersionRef,
1977
1987
  scope.obligationId ?? null,
1978
1988
  scope.rowSetId ?? null,
1979
- JSON.stringify([{ objectKey: object.objectKey, nativeVersion: object.nativeVersion }])
1989
+ JSON.stringify([{ object_ref: object.objectRef, native_version_ref: object.nativeVersionRef }]),
1990
+ // An older writer still running during a rolling upgrade records the pre-alignment keys.
1991
+ JSON.stringify([{ objectKey: object.objectRef, nativeVersion: object.nativeVersionRef }])
1980
1992
  ]
1981
1993
  );
1982
1994
  if (referenced.rows.length > 0) return false;
@@ -2062,7 +2074,11 @@ ${managedDueArm} )
2062
2074
  SET created_objects = created_objects || $5::jsonb
2063
2075
  WHERE row_binding_id = $1 AND row_set_id = $2 AND content_sha256 = $3
2064
2076
  AND owner_token = $4 AND state = 'open'`,
2065
- [...intentKey, ownerToken, JSON.stringify([object])]
2077
+ [
2078
+ ...intentKey,
2079
+ ownerToken,
2080
+ JSON.stringify([{ object_ref: object.objectRef, native_version_ref: object.nativeVersionRef }])
2081
+ ]
2066
2082
  );
2067
2083
  if (recorded.rowCount !== 1) {
2068
2084
  throw new ReportingRowStoreError("STATE_UNAVAILABLE", "the row upload intent was taken over or swept");
@@ -2098,10 +2114,10 @@ ${managedDueArm} )
2098
2114
  }
2099
2115
  }
2100
2116
  if (!upload.sharedFrom) {
2101
- const adopted = upload.locators.filter((locator) => !locator.created).sort((left, right) => left.objectKey < right.objectKey ? -1 : left.objectKey > right.objectKey ? 1 : 0);
2117
+ const adopted = upload.locators.filter((locator) => !locator.created).sort((left, right) => left.objectRef < right.objectRef ? -1 : left.objectRef > right.objectRef ? 1 : 0);
2102
2118
  for (const locator of adopted) {
2103
2119
  await client.query("SELECT pg_advisory_xact_lock(hashtextextended($1, 0))", [
2104
- objectLock(prepared.bindingId, locator.objectKey)
2120
+ objectLock(prepared.bindingId, locator.objectRef)
2105
2121
  ]);
2106
2122
  }
2107
2123
  if (adopted.length > 0) await this.rowStorage.assertObjectsPresent(prepared.bindingId, adopted);
@@ -4295,8 +4311,8 @@ function rfc3339Microseconds(expression) {
4295
4311
  function accountLock(accountId) {
4296
4312
  return `adcp-reporting-account:${accountId}`;
4297
4313
  }
4298
- function objectLock(bindingId, objectKey) {
4299
- return `adcp-reporting-object:${bindingId}:${objectKey}`;
4314
+ function objectLock(bindingId, objectRef) {
4315
+ return `adcp-reporting-object:${bindingId}:${objectRef}`;
4300
4316
  }
4301
4317
  async function resolveStoredFinalityBaseline(transaction, obligationId) {
4302
4318
  const latest = await transaction.query(