@adcp/sdk 16.0.0-beta.2 → 16.0.0-beta.4

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 (248) hide show
  1. package/README.md +54 -0
  2. package/dist/lib/auth/oauth/diagnose.js +3 -11
  3. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  4. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  6. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  7. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  8. package/dist/lib/core/ConversationTypes.d.mts +8 -3
  9. package/dist/lib/core/ConversationTypes.d.ts +8 -3
  10. package/dist/lib/core/SingleAgentClient.d.mts +5 -3
  11. package/dist/lib/core/SingleAgentClient.d.ts +5 -3
  12. package/dist/lib/core/TaskExecutor.js +5 -1
  13. package/dist/lib/core/TaskExecutor.mjs +5 -1
  14. package/dist/lib/errors/index.d.mts +9 -4
  15. package/dist/lib/errors/index.d.ts +9 -4
  16. package/dist/lib/index.d.mts +3 -3
  17. package/dist/lib/index.d.ts +3 -3
  18. package/dist/lib/index.js +8 -0
  19. package/dist/lib/index.mjs +14 -2
  20. package/dist/lib/negotiation/types.d.mts +20 -39
  21. package/dist/lib/negotiation/types.d.ts +20 -39
  22. package/dist/lib/protocols/index.d.mts +60 -24
  23. package/dist/lib/protocols/index.d.ts +60 -24
  24. package/dist/lib/protocols/index.js +9 -4
  25. package/dist/lib/protocols/index.mjs +3 -0
  26. package/dist/lib/protocols/mcp-modern.js +1 -0
  27. package/dist/lib/protocols/mcp-modern.mjs +2 -1
  28. package/dist/lib/protocols/mcp.js +1 -0
  29. package/dist/lib/protocols/mcp.mjs +2 -1
  30. package/dist/lib/protocols/responseSizeLimit.d.mts +91 -5
  31. package/dist/lib/protocols/responseSizeLimit.d.ts +91 -5
  32. package/dist/lib/protocols/responseSizeLimit.js +195 -31
  33. package/dist/lib/protocols/responseSizeLimit.mjs +192 -31
  34. package/dist/lib/reporting/consumer-runtime.js +2 -1
  35. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  36. package/dist/lib/reporting/ledger/handler.js +50 -11
  37. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  38. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  39. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  40. package/dist/lib/reporting/ledger/index.js +32 -20
  41. package/dist/lib/reporting/ledger/index.mjs +21 -10
  42. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  43. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  44. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  45. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  46. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  47. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  48. package/dist/lib/reporting/ledger/receipts.js +186 -0
  49. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  50. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  51. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  52. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  53. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  54. package/dist/lib/reporting/ledger/types.js +31 -2
  55. package/dist/lib/reporting/ledger/types.mjs +26 -1
  56. package/dist/lib/reporting/pagination.d.mts +6 -0
  57. package/dist/lib/reporting/pagination.d.ts +6 -0
  58. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  59. package/dist/lib/reporting/pagination.mjs +12 -0
  60. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  61. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  62. package/dist/lib/reporting/reconciliation.js +3 -2
  63. package/dist/lib/reporting/reconciliation.mjs +3 -2
  64. package/dist/lib/reporting/service/index.d.mts +79 -153
  65. package/dist/lib/reporting/service/index.d.ts +79 -153
  66. package/dist/lib/reporting/service/index.js +34 -491
  67. package/dist/lib/reporting/service/index.mjs +36 -510
  68. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  69. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  70. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  71. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  72. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  73. package/dist/lib/signing/canonicalize.d.mts +4 -0
  74. package/dist/lib/signing/canonicalize.d.ts +4 -0
  75. package/dist/lib/signing/canonicalize.js +14 -8
  76. package/dist/lib/signing/canonicalize.mjs +14 -8
  77. package/dist/lib/signing/content-digest.d.mts +8 -0
  78. package/dist/lib/signing/content-digest.d.ts +8 -0
  79. package/dist/lib/signing/content-digest.js +11 -5
  80. package/dist/lib/signing/content-digest.mjs +10 -5
  81. package/dist/lib/signing/crypto.d.mts +15 -0
  82. package/dist/lib/signing/crypto.d.ts +15 -0
  83. package/dist/lib/signing/crypto.js +75 -3
  84. package/dist/lib/signing/crypto.mjs +78 -3
  85. package/dist/lib/signing/server.d.mts +1 -1
  86. package/dist/lib/signing/server.d.ts +1 -1
  87. package/dist/lib/signing/server.js +2 -0
  88. package/dist/lib/signing/server.mjs +2 -1
  89. package/dist/lib/signing/signer.js +11 -14
  90. package/dist/lib/signing/signer.mjs +13 -16
  91. package/dist/lib/signing/testing.js +2 -6
  92. package/dist/lib/signing/testing.mjs +3 -7
  93. package/dist/lib/signing/verifier.js +2 -2
  94. package/dist/lib/signing/verifier.mjs +3 -3
  95. package/dist/lib/signing/web-bot-auth.js +122 -43
  96. package/dist/lib/signing/web-bot-auth.mjs +128 -44
  97. package/dist/lib/signing/webhook-verifier.js +2 -2
  98. package/dist/lib/signing/webhook-verifier.mjs +3 -3
  99. package/dist/lib/substitution/compile.js +2 -1
  100. package/dist/lib/substitution/compile.mjs +2 -1
  101. package/dist/lib/substitution/consent-macros.d.mts +4 -0
  102. package/dist/lib/substitution/consent-macros.d.ts +4 -0
  103. package/dist/lib/substitution/consent-macros.js +45 -0
  104. package/dist/lib/substitution/consent-macros.mjs +20 -0
  105. package/dist/lib/substitution/index.d.mts +1 -1
  106. package/dist/lib/substitution/index.d.ts +1 -1
  107. package/dist/lib/substitution/index.js +2 -0
  108. package/dist/lib/substitution/index.mjs +2 -1
  109. package/dist/lib/substitution/translate.d.mts +15 -2
  110. package/dist/lib/substitution/translate.d.ts +15 -2
  111. package/dist/lib/substitution/translate.js +148 -26
  112. package/dist/lib/substitution/translate.mjs +147 -26
  113. package/dist/lib/testing/client.js +2 -1
  114. package/dist/lib/testing/client.mjs +2 -1
  115. package/dist/lib/testing/scenarios/capabilities.js +1 -1
  116. package/dist/lib/testing/scenarios/capabilities.mjs +1 -1
  117. package/dist/lib/testing/storyboard/junit.js +16 -3
  118. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  119. package/dist/lib/testing/storyboard/request-signing/builder.js +12 -14
  120. package/dist/lib/testing/storyboard/request-signing/builder.mjs +13 -15
  121. package/dist/lib/testing/storyboard/runner.js +94 -25
  122. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  123. package/dist/lib/testing/storyboard/signer-grader/grader.js +2 -7
  124. package/dist/lib/testing/storyboard/signer-grader/grader.mjs +2 -7
  125. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  126. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  127. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  128. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  129. package/dist/lib/types/enums.generated.d.mts +3 -0
  130. package/dist/lib/types/enums.generated.d.ts +3 -0
  131. package/dist/lib/types/enums.generated.js +9 -0
  132. package/dist/lib/types/enums.generated.mjs +6 -0
  133. package/dist/lib/validation/schema-loader.js +25 -0
  134. package/dist/lib/validation/schema-loader.mjs +24 -0
  135. package/dist/lib/version.d.mts +3 -3
  136. package/dist/lib/version.d.ts +3 -3
  137. package/dist/lib/version.js +3 -3
  138. package/dist/lib/version.mjs +3 -3
  139. package/docs/TYPE-SUMMARY.md +28 -5
  140. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +3 -2
  141. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  142. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  143. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  144. package/docs/guides/REPORTING-LEDGER.md +107 -51
  145. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  146. package/docs/guides/REPORTING-STABILITY.md +36 -32
  147. package/docs/guides/UNIVERSAL-MACRO-COMPILATION.md +38 -0
  148. package/docs/guides/VALIDATE-YOUR-AGENT.md +12 -0
  149. package/docs/llms.txt +4 -3
  150. package/docs/migration-14.x-rc-worksheet.md +4 -7
  151. package/docs/migration-reporting-storage-package.md +186 -0
  152. package/examples/README.md +1 -1
  153. package/package.json +14 -78
  154. package/dist/lib/reporting/azure/index.d.mts +0 -31
  155. package/dist/lib/reporting/azure/index.d.ts +0 -31
  156. package/dist/lib/reporting/azure/index.js +0 -266
  157. package/dist/lib/reporting/azure/index.mjs +0 -249
  158. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  159. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  160. package/dist/lib/reporting/bigquery/index.js +0 -633
  161. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  162. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  163. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  164. package/dist/lib/reporting/gcs/adapter.js +0 -342
  165. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  166. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  167. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  168. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  169. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  170. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  171. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  172. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  173. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  174. package/dist/lib/reporting/gcs/fence.js +0 -250
  175. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  176. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  177. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  178. package/dist/lib/reporting/gcs/index.js +0 -44
  179. package/dist/lib/reporting/gcs/index.mjs +0 -14
  180. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  181. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  182. package/dist/lib/reporting/gcs/io.js +0 -95
  183. package/dist/lib/reporting/gcs/io.mjs +0 -69
  184. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  185. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  186. package/dist/lib/reporting/gcs/reader.js +0 -193
  187. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  188. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  189. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  190. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  191. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  192. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  193. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  194. package/dist/lib/reporting/gcs/validation.js +0 -49
  195. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  196. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  197. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  198. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  199. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  200. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  201. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  202. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  203. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  204. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  205. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  206. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  207. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  208. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  209. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  210. package/dist/lib/reporting/ledger/managed.js +0 -761
  211. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  212. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  213. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  214. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  215. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  216. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  217. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  218. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  219. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  220. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  221. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  222. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  223. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  224. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  225. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  226. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  227. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  228. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  229. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  230. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  231. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  232. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  233. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  234. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  235. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  236. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  237. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  238. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  239. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  240. package/dist/lib/reporting/s3/index.d.mts +0 -34
  241. package/dist/lib/reporting/s3/index.d.ts +0 -34
  242. package/dist/lib/reporting/s3/index.js +0 -347
  243. package/dist/lib/reporting/s3/index.mjs +0 -340
  244. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  245. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  246. package/dist/lib/reporting/service/maintenance.js +0 -185
  247. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  248. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,22 +1,24 @@
1
1
  /**
2
- * Reliable Reporting service wiring, conformance runner and ledger maintenance.
2
+ * Reliable Reporting service wiring and conformance runner.
3
3
  *
4
- * Only the retention, compaction and change-feed maintenance exports (`./maintenance`) are `@experimental`.
5
- * The service factories and conformance runner follow normal semver.
4
+ * `createReliableReportingService` takes any `ReportingLedgerStore`. The PostgreSQL store, the production
5
+ * composition (`createPostgresReliableReportingProductionService`) and ledger maintenance
6
+ * (`reportingLedgerMaintenance`) live in `@adcp/reporting-storage`.
7
+ *
8
+ * The scheduler primitives (`reportingSchedulerDelay`, `rotateReportingRoster`, ...) and
9
+ * `REPORTING_MANAGED_DELIVERY_COMPOSITION_V1` are storage-facing building blocks for compositions such as
10
+ * `@adcp/reporting-storage/service`, covered by the experimental policy below; applications should not use them.
6
11
  *
7
12
  * Stability policy: https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
8
13
  *
9
14
  * @packageDocumentation
10
15
  */
11
- import type { Account, ResolveContext } from '../../server/decisioning/account.mjs';
16
+ import type { Account } from '../../server/decisioning/account.mjs';
12
17
  import type { RequestContext } from '../../server/decisioning/context.mjs';
13
18
  import type { DecisioningPlatform } from '../../server/decisioning/platform.mjs';
14
19
  import type { ReliableReportingPlatform } from '../../server/decisioning/specialisms/reporting.mjs';
15
20
  import type { ReportingDeliveryCapabilities, ReportingDeliveryOffering } from '../../types/tools.generated.mjs';
16
- import { type CreatePostgresPersistentNotificationRuntimeOptions, type PostgresPersistentNotificationRuntime } from '../../server/notification-subscriptions/index.mjs';
17
- import { REPORTING_LEDGER_MIGRATION, PostgresReportingLedgerStore, PostgresReportingManagedDeliveryStore, type CreateReportingProducerOptionsV1, type ReportingConsumerMismatchEscalationV1, type ReportingLedgerConfigurationV1, type ReportingLedgerStore, type ReportingLegacyRevisionReaderV1, type ReportingProducerContactV1, type ReportingProducerV1, type ReportingManagedDeliveryAdapterV1, type ReportingManagedDeliveryRuntimeV1, type PostgresReportingManagedDeliveryStoreOptions, type PostgresReportingNotificationActivityOptions, type PostgresReportingNotificationActivityRuntime, type ReportingPgPool, type ReportingRowStorageOptionsV1, type ReportingSourceWithReaderV1 } from '../ledger/index.mjs';
18
- import { type PostgresReportingWebhookActivityV1 } from '../webhook-activity.mjs';
19
- import { type ReportingChangeFeedMaintenanceOptionsV1, type ReportingLedgerMaintenanceTaskResultV1, type ReportingCompactionOptionsV1, type ReportingRetentionOptionsV1 } from './maintenance.mjs';
21
+ import { type CreateReportingProducerOptionsV1, type ReportingConsumerMismatchEscalationV1, type ReportingLedgerConfigurationV1, type ReportingLedgerStore, type ReportingLegacyRevisionReaderV1, type ReportingProducerContactV1, type ReportingProducerV1, type ReportingSourceWithReaderV1 } from '../ledger/index.mjs';
20
22
  import type { InlineReportingReplayRetentionV1 } from '../source/index.mjs';
21
23
  import { type InlineReportingDeliveryFetchV1, type ReportingSourceOfferingV1 } from '../source/index.mjs';
22
24
  /** The intentionally small provider boundary: one bounded slice fetch plus immutable metadata. */
@@ -161,20 +163,18 @@ export interface CreateReliableReportingServiceOptionsV1<TCtxMeta = Record<strin
161
163
  statusRetentionDays: number;
162
164
  subscribers?: CreateReportingProducerOptionsV1['subscribers'];
163
165
  /**
164
- * Opt in to scheduled ledger maintenance for a Core-only deployment on a
165
- * `PostgresReportingLedgerStore`. `start()` runs it at most once per
166
- * `intervalMilliseconds`; `runMaintenance()` runs it on demand for a host
167
- * with its own scheduler. The production service does this itself and does
168
- * not take this option.
166
+ * Opt in to scheduled ledger maintenance (retention, compaction, change-feed pruning, abandoned-upload
167
+ * sweeps) for a Core-only deployment. `start()` runs it at most once per `intervalMilliseconds`;
168
+ * `runMaintenance()` runs it on demand for a host with its own scheduler.
169
169
  *
170
- * Always swept: expired cursor snapshots and checkpoints, and abandoned row
171
- * uploads. `retention` and `changeFeed` have the same shape and meaning as
172
- * on `createPostgresReliableReportingProductionService`. Retention uses
173
- * this service's `statusRetentionDays`, so it can never retire a period
174
- * earlier than the retention advertised to buyers. `changeFeed` requires the
175
- * store to be built with `changeFeed: true`.
170
+ * The SDK does not know what maintenance a store needs: the option takes a factory, called once at
171
+ * construction with the store and the retention and recovery-window commitments this service advertises
172
+ * to buyers, so maintenance can never retire a period earlier than that retention. For the PostgreSQL
173
+ * store, pass `reportingLedgerMaintenance({ ... })` from `@adcp/reporting-storage`. A factory that
174
+ * throws fails service construction, not the first scheduled pass. The production service in
175
+ * `@adcp/reporting-storage/service` runs maintenance itself and does not take this option.
176
176
  */
177
- maintenance?: ReliableReportingMaintenanceOptionsV1;
177
+ maintenance?: ReliableReportingMaintenanceFactoryV1;
178
178
  /**
179
179
  * Serve exact revision reads (`get_media_buy_delivery`) for revisions this
180
180
  * ledger does not hold, such as a seller's pre-cutover ledger tables. The
@@ -192,19 +192,66 @@ export interface CreateReliableReportingServiceOptionsV1<TCtxMeta = Record<strin
192
192
  */
193
193
  legacyRevisionReader?: ReportingLegacyRevisionReaderV1;
194
194
  }
195
- export interface ReliableReportingMaintenanceOptionsV1 {
196
- /** Minimum time between scheduled maintenance passes. Defaults to 300000 (5 minutes). */
197
- intervalMilliseconds?: number;
198
- /** Period-aligned retention; see the production service's `retention`. */
199
- retention?: ReportingRetentionOptionsV1;
200
- /** Opt-in snapshot compaction; see the production service's `compaction`. */
201
- compaction?: ReportingCompactionOptionsV1;
202
- /** Change-feed pruning and consumer hold; see the production service's `changeFeed`. */
203
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1;
195
+ /**
196
+ * Outcome of one maintenance task. A task that resolved but could not process some items is `completed`
197
+ * with `partialFailure` set; the pass resumes those items next time.
198
+ */
199
+ export type ReliableReportingMaintenanceTaskResultV1 = {
200
+ readonly task: string;
201
+ readonly status: 'completed';
202
+ readonly result: unknown;
203
+ readonly partialFailure?: Error;
204
+ } | {
205
+ readonly task: string;
206
+ readonly status: 'failed';
207
+ readonly error: unknown;
208
+ };
209
+ /** One scheduled maintenance pass, as built by a {@link ReliableReportingMaintenanceFactoryV1}. */
210
+ export interface ReliableReportingMaintenanceV1 {
211
+ /** Minimum time between scheduled passes. A positive safe integer. */
212
+ readonly intervalMilliseconds: number;
213
+ /**
214
+ * Run one pass. Tasks are isolated: a task failure is reported in its result, never thrown. `report`
215
+ * is awaited, in task order, for every task that rejected or partially failed, unless `signal` has
216
+ * aborted (an abort is shutdown, not a fault).
217
+ */
218
+ run(input: {
219
+ signal?: AbortSignal | undefined;
220
+ report?: (error: unknown) => Promise<void>;
221
+ }): Promise<readonly ReliableReportingMaintenanceTaskResultV1[]>;
222
+ }
223
+ /** What the service tells a maintenance factory about the store it will maintain. */
224
+ export interface ReliableReportingMaintenanceContextV1 {
225
+ readonly store: ReportingLedgerStore;
226
+ /** The `statusRetentionDays` this service advertises. */
227
+ readonly statusRetentionDays: number;
228
+ /** The `automatedRecoveryWindowSeconds` this service advertises. */
229
+ readonly automatedRecoveryWindowSeconds: number;
204
230
  }
231
+ /**
232
+ * Builds the maintenance for one service. Throw from it to refuse a configuration the store cannot
233
+ * serve; the service lets the error reach the caller of `createReliableReportingService`.
234
+ */
235
+ export type ReliableReportingMaintenanceFactoryV1 = (context: ReliableReportingMaintenanceContextV1) => ReliableReportingMaintenanceV1;
236
+ /**
237
+ * Composition token, for packages that compose this service with a managed-delivery runtime (such as
238
+ * `createPostgresReliableReportingProductionService` in `@adcp/reporting-storage/service`). Such a
239
+ * composition passes `{ [REPORTING_MANAGED_DELIVERY_COMPOSITION_V1]: store }`, naming the very `store` it passes
240
+ * as `store`, so the Core service accepts the managed-delivery and reconciled-billing offerings that only that
241
+ * composition can serve. A plain Core service refuses them.
242
+ *
243
+ * It is an assertion by the composer, not an authentication boundary: it keeps a Core-only service from
244
+ * advertising capabilities it has no runtime for by accident (the value must be the store itself, so a copied
245
+ * `true` does nothing). It is a `Symbol.for` key so it holds across duplicate copies of the SDK. Applications
246
+ * should not use it.
247
+ *
248
+ * @experimental Storage-facing building block: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
249
+ */
250
+ export declare const REPORTING_MANAGED_DELIVERY_COMPOSITION_V1: unique symbol;
205
251
  export interface ReliableReportingSetupV1 {
206
252
  readonly component: 'reliable-reporting-core';
207
- readonly migrations: readonly [typeof REPORTING_LEDGER_MIGRATION];
253
+ /** The store's own `migrations`: what to apply before first use. Empty for a store that needs none. */
254
+ readonly migrations: readonly string[];
208
255
  readonly requiresIsolatedLedgerDatabaseAcknowledgement: true;
209
256
  }
210
257
  export interface ReliableReportingServiceV1<TCtxMeta = Record<string, unknown>> {
@@ -238,7 +285,7 @@ export interface ReliableReportingServiceV1<TCtxMeta = Record<string, unknown>>
238
285
  */
239
286
  runMaintenance(options?: {
240
287
  signal?: AbortSignal;
241
- }): Promise<ReportingLedgerMaintenanceTaskResultV1[]>;
288
+ }): Promise<readonly ReliableReportingMaintenanceTaskResultV1[]>;
242
289
  start(options: ReliableReportingSchedulerOptionsV1): void;
243
290
  stop(): Promise<void>;
244
291
  }
@@ -247,126 +294,5 @@ export interface ReliableReportingServiceV1<TCtxMeta = Record<string, unknown>>
247
294
  * and scheduler into one Reliable Reporting Core lifecycle owner.
248
295
  */
249
296
  export declare function createReliableReportingService<TCtxMeta = Record<string, unknown>>(options: CreateReliableReportingServiceOptionsV1<TCtxMeta>): ReliableReportingServiceV1<TCtxMeta>;
250
- type ProductionNotificationOptions = Omit<CreatePostgresPersistentNotificationRuntimeOptions, 'db' | 'publisherScope' | 'checkpointDeliveryAttempt' | 'supportedAccountEventTypes'>;
251
- export type CreatePostgresReliableReportingProductionServiceOptionsV1<TCtxMeta = Record<string, unknown>> = Omit<CreateReliableReportingServiceOptionsV1<TCtxMeta>, 'store' | 'subscribers' | 'maintenance'> & {
252
- db: ReportingPgPool;
253
- /** Stable, non-secret deployment namespace shared by reporting workers. */
254
- namespace: string;
255
- /** Stable webhook publisher identity; credentials must never be used here. */
256
- publisherScope: string;
257
- /** Explicit acknowledgement required by the authoritative Core store. */
258
- acknowledgeIsolatedDatabase: true;
259
- /**
260
- * Store new revision rows as verified canonical JSONL chunks. Adds
261
- * `REPORTING_ROW_STORAGE_MIGRATION` (PostgreSQL 13+) to `setup.migrations`
262
- * and probes it before publishing capabilities.
263
- */
264
- rowStorage?: boolean | ReportingRowStorageOptionsV1;
265
- /**
266
- * Opt in to period-aligned retention. Each scheduler pass retires whole
267
- * periods once `max(statusRetentionDays, recordRetentionDays)` has elapsed
268
- * since both the period end and its latest publication, deleting their
269
- * rows and ledger records and leaving a tombstone. Abandoned row uploads
270
- * and expired cursor snapshots are always swept. With `changeFeed`, a
271
- * period is also held until every live registered feed consumer (updated
272
- * within `changeFeed.maxFeedHoldDays`, default 7) has read its changes.
273
- */
274
- retention?: ReportingRetentionOptionsV1;
275
- /**
276
- * Opt in to compacting superseded snapshot revisions to metadata only, as
277
- * adcontextprotocol/adcp#8100 permits. Off by default. Each scheduler pass
278
- * drops the row content of snapshots that are superseded, past their
279
- * recovery grace and not owed to any caller (receipts, current
280
- * `received` / `unreadable` / `content_mismatch` statements), while every
281
- * revision's metadata stays. Official revisions are never compacted. Uses
282
- * this service's `statusRetentionDays` and `automatedRecoveryWindowSeconds`.
283
- * The protocol takes compaction into effect only in the next eligible minor
284
- * after November 20, 2026: do not enable this in production before then.
285
- */
286
- compaction?: ReportingCompactionOptionsV1;
287
- /**
288
- * Maintain the host change feed (`changesAfter`, `getCurrentRevision`,
289
- * `listCurrentRevisions` on `stores.core`). Adds
290
- * `REPORTING_LEDGER_CHANGES_MIGRATION` (PostgreSQL 13+); the scheduler prunes
291
- * changes older than `changeRetentionDays` (default 30) unless a registered
292
- * consumer updated within `maxFeedHoldDays` (default 7) still needs them.
293
- */
294
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1;
295
- notifications: ProductionNotificationOptions;
296
- managedDelivery: {
297
- adapter: ReportingManagedDeliveryAdapterV1;
298
- resourceRetentionDays: number;
299
- authorizationRevocationSeconds: number;
300
- store?: Omit<PostgresReportingManagedDeliveryStoreOptions, 'notificationActivityPort'>;
301
- };
302
- activity: Omit<PostgresReportingNotificationActivityOptions, 'db' | 'notifications' | 'namespace' | 'attemptCheckpoint' | 'tenantScopeForAccount'> & {
303
- tenantScopeForAccount(accountId: string): string;
304
- };
305
- webhookActivity?: {
306
- tableName?: string;
307
- retentionDays?: number;
308
- };
309
- /** Resolve activity visibility from verified auth/registry state, never request fields. */
310
- resolveWebhookActivityScope(context: ResolveContext): {
311
- tenantId: string;
312
- principalId: string;
313
- } | Promise<{
314
- tenantId: string;
315
- principalId: string;
316
- }>;
317
- /** Trusted complete roster of consumers that owe receipts for an obligation. */
318
- obligatedConsumers?: (input: {
319
- reporting_obligation_id: string;
320
- account_id: string;
321
- }) => Promise<{
322
- ids: readonly string[];
323
- complete: boolean;
324
- version?: string;
325
- }>;
326
- /** Optional migration-system bridge. Called before any capability probe. */
327
- applyMigrations?: (migrations: readonly string[]) => Promise<void>;
328
- };
329
- export interface PostgresReliableReportingProductionServiceV1<TCtxMeta = Record<string, unknown>> {
330
- readonly setup: {
331
- readonly component: 'reliable-reporting-production';
332
- readonly migrations: readonly string[];
333
- };
334
- readonly capabilities: ReportingDeliveryCapabilities;
335
- readonly platform: ReliableReportingPlatform<TCtxMeta>;
336
- readonly core: ReliableReportingServiceV1<TCtxMeta>;
337
- readonly managed: ReportingManagedDeliveryRuntimeV1<RequestContext<Account<TCtxMeta>>>;
338
- readonly notifications: PostgresPersistentNotificationRuntime;
339
- readonly notificationActivity: PostgresReportingNotificationActivityRuntime;
340
- readonly webhookActivity: PostgresReportingWebhookActivityV1;
341
- readonly stores: {
342
- core: PostgresReportingLedgerStore;
343
- managed: PostgresReportingManagedDeliveryStore;
344
- };
345
- readonly running: boolean;
346
- installConfiguration: ReliableReportingServiceV1<TCtxMeta>['installConfiguration'];
347
- install<TPlatform extends DecisioningPlatform<unknown, TCtxMeta>>(platform: TPlatform): TPlatform & {
348
- reporting: ReliableReportingPlatform<TCtxMeta>;
349
- };
350
- runCycle(options: ReliableReportingCycleOptionsV1): Promise<{
351
- core: Awaited<ReturnType<ReliableReportingServiceV1<TCtxMeta>['runCycle']>>;
352
- managed: Awaited<ReturnType<ReportingManagedDeliveryRuntimeV1['runWorker']>>;
353
- }>;
354
- recoverOnce(options: {
355
- deploymentWide: true;
356
- }): Promise<{
357
- activity: Awaited<ReturnType<PostgresReportingNotificationActivityRuntime['recoverOnce']>>;
358
- webhookOutbox: Awaited<ReturnType<PostgresPersistentNotificationRuntime['recoverOnce']>>;
359
- }>;
360
- start(options: ReliableReportingSchedulerOptionsV1 & {
361
- deploymentWide: true;
362
- }): void;
363
- stop(): Promise<void>;
364
- }
365
- /**
366
- * Assemble and probe the complete seller-side Reliable Reporting production
367
- * chain. Capability publication happens only after every durable component is
368
- * present and the managed policy has been adopted.
369
- */
370
- export declare function createPostgresReliableReportingProductionService<TCtxMeta = Record<string, unknown>>(options: CreatePostgresReliableReportingProductionServiceOptionsV1<TCtxMeta>): Promise<PostgresReliableReportingProductionServiceV1<TCtxMeta>>;
371
297
  export * from './conformance.mjs';
372
- export { ReportingMaintenancePartialFailureError, type ReportingChangeFeedMaintenanceOptionsV1, type ReportingCompactionOptionsV1, type ReportingLedgerMaintenanceStoreV1, type ReportingLedgerMaintenanceTaskNameV1, type ReportingLedgerMaintenanceTaskResultV1, type ReportingRetentionOptionsV1, } from './maintenance.mjs';
298
+ export * from './scheduler-support.mjs';
@@ -1,22 +1,24 @@
1
1
  /**
2
- * Reliable Reporting service wiring, conformance runner and ledger maintenance.
2
+ * Reliable Reporting service wiring and conformance runner.
3
3
  *
4
- * Only the retention, compaction and change-feed maintenance exports (`./maintenance`) are `@experimental`.
5
- * The service factories and conformance runner follow normal semver.
4
+ * `createReliableReportingService` takes any `ReportingLedgerStore`. The PostgreSQL store, the production
5
+ * composition (`createPostgresReliableReportingProductionService`) and ledger maintenance
6
+ * (`reportingLedgerMaintenance`) live in `@adcp/reporting-storage`.
7
+ *
8
+ * The scheduler primitives (`reportingSchedulerDelay`, `rotateReportingRoster`, ...) and
9
+ * `REPORTING_MANAGED_DELIVERY_COMPOSITION_V1` are storage-facing building blocks for compositions such as
10
+ * `@adcp/reporting-storage/service`, covered by the experimental policy below; applications should not use them.
6
11
  *
7
12
  * Stability policy: https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
8
13
  *
9
14
  * @packageDocumentation
10
15
  */
11
- import type { Account, ResolveContext } from '../../server/decisioning/account';
16
+ import type { Account } from '../../server/decisioning/account';
12
17
  import type { RequestContext } from '../../server/decisioning/context';
13
18
  import type { DecisioningPlatform } from '../../server/decisioning/platform';
14
19
  import type { ReliableReportingPlatform } from '../../server/decisioning/specialisms/reporting';
15
20
  import type { ReportingDeliveryCapabilities, ReportingDeliveryOffering } from '../../types/tools.generated';
16
- import { type CreatePostgresPersistentNotificationRuntimeOptions, type PostgresPersistentNotificationRuntime } from '../../server/notification-subscriptions';
17
- import { REPORTING_LEDGER_MIGRATION, PostgresReportingLedgerStore, PostgresReportingManagedDeliveryStore, type CreateReportingProducerOptionsV1, type ReportingConsumerMismatchEscalationV1, type ReportingLedgerConfigurationV1, type ReportingLedgerStore, type ReportingLegacyRevisionReaderV1, type ReportingProducerContactV1, type ReportingProducerV1, type ReportingManagedDeliveryAdapterV1, type ReportingManagedDeliveryRuntimeV1, type PostgresReportingManagedDeliveryStoreOptions, type PostgresReportingNotificationActivityOptions, type PostgresReportingNotificationActivityRuntime, type ReportingPgPool, type ReportingRowStorageOptionsV1, type ReportingSourceWithReaderV1 } from '../ledger';
18
- import { type PostgresReportingWebhookActivityV1 } from '../webhook-activity';
19
- import { type ReportingChangeFeedMaintenanceOptionsV1, type ReportingLedgerMaintenanceTaskResultV1, type ReportingCompactionOptionsV1, type ReportingRetentionOptionsV1 } from './maintenance';
21
+ import { type CreateReportingProducerOptionsV1, type ReportingConsumerMismatchEscalationV1, type ReportingLedgerConfigurationV1, type ReportingLedgerStore, type ReportingLegacyRevisionReaderV1, type ReportingProducerContactV1, type ReportingProducerV1, type ReportingSourceWithReaderV1 } from '../ledger';
20
22
  import type { InlineReportingReplayRetentionV1 } from '../source';
21
23
  import { type InlineReportingDeliveryFetchV1, type ReportingSourceOfferingV1 } from '../source';
22
24
  /** The intentionally small provider boundary: one bounded slice fetch plus immutable metadata. */
@@ -161,20 +163,18 @@ export interface CreateReliableReportingServiceOptionsV1<TCtxMeta = Record<strin
161
163
  statusRetentionDays: number;
162
164
  subscribers?: CreateReportingProducerOptionsV1['subscribers'];
163
165
  /**
164
- * Opt in to scheduled ledger maintenance for a Core-only deployment on a
165
- * `PostgresReportingLedgerStore`. `start()` runs it at most once per
166
- * `intervalMilliseconds`; `runMaintenance()` runs it on demand for a host
167
- * with its own scheduler. The production service does this itself and does
168
- * not take this option.
166
+ * Opt in to scheduled ledger maintenance (retention, compaction, change-feed pruning, abandoned-upload
167
+ * sweeps) for a Core-only deployment. `start()` runs it at most once per `intervalMilliseconds`;
168
+ * `runMaintenance()` runs it on demand for a host with its own scheduler.
169
169
  *
170
- * Always swept: expired cursor snapshots and checkpoints, and abandoned row
171
- * uploads. `retention` and `changeFeed` have the same shape and meaning as
172
- * on `createPostgresReliableReportingProductionService`. Retention uses
173
- * this service's `statusRetentionDays`, so it can never retire a period
174
- * earlier than the retention advertised to buyers. `changeFeed` requires the
175
- * store to be built with `changeFeed: true`.
170
+ * The SDK does not know what maintenance a store needs: the option takes a factory, called once at
171
+ * construction with the store and the retention and recovery-window commitments this service advertises
172
+ * to buyers, so maintenance can never retire a period earlier than that retention. For the PostgreSQL
173
+ * store, pass `reportingLedgerMaintenance({ ... })` from `@adcp/reporting-storage`. A factory that
174
+ * throws fails service construction, not the first scheduled pass. The production service in
175
+ * `@adcp/reporting-storage/service` runs maintenance itself and does not take this option.
176
176
  */
177
- maintenance?: ReliableReportingMaintenanceOptionsV1;
177
+ maintenance?: ReliableReportingMaintenanceFactoryV1;
178
178
  /**
179
179
  * Serve exact revision reads (`get_media_buy_delivery`) for revisions this
180
180
  * ledger does not hold, such as a seller's pre-cutover ledger tables. The
@@ -192,19 +192,66 @@ export interface CreateReliableReportingServiceOptionsV1<TCtxMeta = Record<strin
192
192
  */
193
193
  legacyRevisionReader?: ReportingLegacyRevisionReaderV1;
194
194
  }
195
- export interface ReliableReportingMaintenanceOptionsV1 {
196
- /** Minimum time between scheduled maintenance passes. Defaults to 300000 (5 minutes). */
197
- intervalMilliseconds?: number;
198
- /** Period-aligned retention; see the production service's `retention`. */
199
- retention?: ReportingRetentionOptionsV1;
200
- /** Opt-in snapshot compaction; see the production service's `compaction`. */
201
- compaction?: ReportingCompactionOptionsV1;
202
- /** Change-feed pruning and consumer hold; see the production service's `changeFeed`. */
203
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1;
195
+ /**
196
+ * Outcome of one maintenance task. A task that resolved but could not process some items is `completed`
197
+ * with `partialFailure` set; the pass resumes those items next time.
198
+ */
199
+ export type ReliableReportingMaintenanceTaskResultV1 = {
200
+ readonly task: string;
201
+ readonly status: 'completed';
202
+ readonly result: unknown;
203
+ readonly partialFailure?: Error;
204
+ } | {
205
+ readonly task: string;
206
+ readonly status: 'failed';
207
+ readonly error: unknown;
208
+ };
209
+ /** One scheduled maintenance pass, as built by a {@link ReliableReportingMaintenanceFactoryV1}. */
210
+ export interface ReliableReportingMaintenanceV1 {
211
+ /** Minimum time between scheduled passes. A positive safe integer. */
212
+ readonly intervalMilliseconds: number;
213
+ /**
214
+ * Run one pass. Tasks are isolated: a task failure is reported in its result, never thrown. `report`
215
+ * is awaited, in task order, for every task that rejected or partially failed, unless `signal` has
216
+ * aborted (an abort is shutdown, not a fault).
217
+ */
218
+ run(input: {
219
+ signal?: AbortSignal | undefined;
220
+ report?: (error: unknown) => Promise<void>;
221
+ }): Promise<readonly ReliableReportingMaintenanceTaskResultV1[]>;
222
+ }
223
+ /** What the service tells a maintenance factory about the store it will maintain. */
224
+ export interface ReliableReportingMaintenanceContextV1 {
225
+ readonly store: ReportingLedgerStore;
226
+ /** The `statusRetentionDays` this service advertises. */
227
+ readonly statusRetentionDays: number;
228
+ /** The `automatedRecoveryWindowSeconds` this service advertises. */
229
+ readonly automatedRecoveryWindowSeconds: number;
204
230
  }
231
+ /**
232
+ * Builds the maintenance for one service. Throw from it to refuse a configuration the store cannot
233
+ * serve; the service lets the error reach the caller of `createReliableReportingService`.
234
+ */
235
+ export type ReliableReportingMaintenanceFactoryV1 = (context: ReliableReportingMaintenanceContextV1) => ReliableReportingMaintenanceV1;
236
+ /**
237
+ * Composition token, for packages that compose this service with a managed-delivery runtime (such as
238
+ * `createPostgresReliableReportingProductionService` in `@adcp/reporting-storage/service`). Such a
239
+ * composition passes `{ [REPORTING_MANAGED_DELIVERY_COMPOSITION_V1]: store }`, naming the very `store` it passes
240
+ * as `store`, so the Core service accepts the managed-delivery and reconciled-billing offerings that only that
241
+ * composition can serve. A plain Core service refuses them.
242
+ *
243
+ * It is an assertion by the composer, not an authentication boundary: it keeps a Core-only service from
244
+ * advertising capabilities it has no runtime for by accident (the value must be the store itself, so a copied
245
+ * `true` does nothing). It is a `Symbol.for` key so it holds across duplicate copies of the SDK. Applications
246
+ * should not use it.
247
+ *
248
+ * @experimental Storage-facing building block: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
249
+ */
250
+ export declare const REPORTING_MANAGED_DELIVERY_COMPOSITION_V1: unique symbol;
205
251
  export interface ReliableReportingSetupV1 {
206
252
  readonly component: 'reliable-reporting-core';
207
- readonly migrations: readonly [typeof REPORTING_LEDGER_MIGRATION];
253
+ /** The store's own `migrations`: what to apply before first use. Empty for a store that needs none. */
254
+ readonly migrations: readonly string[];
208
255
  readonly requiresIsolatedLedgerDatabaseAcknowledgement: true;
209
256
  }
210
257
  export interface ReliableReportingServiceV1<TCtxMeta = Record<string, unknown>> {
@@ -238,7 +285,7 @@ export interface ReliableReportingServiceV1<TCtxMeta = Record<string, unknown>>
238
285
  */
239
286
  runMaintenance(options?: {
240
287
  signal?: AbortSignal;
241
- }): Promise<ReportingLedgerMaintenanceTaskResultV1[]>;
288
+ }): Promise<readonly ReliableReportingMaintenanceTaskResultV1[]>;
242
289
  start(options: ReliableReportingSchedulerOptionsV1): void;
243
290
  stop(): Promise<void>;
244
291
  }
@@ -247,126 +294,5 @@ export interface ReliableReportingServiceV1<TCtxMeta = Record<string, unknown>>
247
294
  * and scheduler into one Reliable Reporting Core lifecycle owner.
248
295
  */
249
296
  export declare function createReliableReportingService<TCtxMeta = Record<string, unknown>>(options: CreateReliableReportingServiceOptionsV1<TCtxMeta>): ReliableReportingServiceV1<TCtxMeta>;
250
- type ProductionNotificationOptions = Omit<CreatePostgresPersistentNotificationRuntimeOptions, 'db' | 'publisherScope' | 'checkpointDeliveryAttempt' | 'supportedAccountEventTypes'>;
251
- export type CreatePostgresReliableReportingProductionServiceOptionsV1<TCtxMeta = Record<string, unknown>> = Omit<CreateReliableReportingServiceOptionsV1<TCtxMeta>, 'store' | 'subscribers' | 'maintenance'> & {
252
- db: ReportingPgPool;
253
- /** Stable, non-secret deployment namespace shared by reporting workers. */
254
- namespace: string;
255
- /** Stable webhook publisher identity; credentials must never be used here. */
256
- publisherScope: string;
257
- /** Explicit acknowledgement required by the authoritative Core store. */
258
- acknowledgeIsolatedDatabase: true;
259
- /**
260
- * Store new revision rows as verified canonical JSONL chunks. Adds
261
- * `REPORTING_ROW_STORAGE_MIGRATION` (PostgreSQL 13+) to `setup.migrations`
262
- * and probes it before publishing capabilities.
263
- */
264
- rowStorage?: boolean | ReportingRowStorageOptionsV1;
265
- /**
266
- * Opt in to period-aligned retention. Each scheduler pass retires whole
267
- * periods once `max(statusRetentionDays, recordRetentionDays)` has elapsed
268
- * since both the period end and its latest publication, deleting their
269
- * rows and ledger records and leaving a tombstone. Abandoned row uploads
270
- * and expired cursor snapshots are always swept. With `changeFeed`, a
271
- * period is also held until every live registered feed consumer (updated
272
- * within `changeFeed.maxFeedHoldDays`, default 7) has read its changes.
273
- */
274
- retention?: ReportingRetentionOptionsV1;
275
- /**
276
- * Opt in to compacting superseded snapshot revisions to metadata only, as
277
- * adcontextprotocol/adcp#8100 permits. Off by default. Each scheduler pass
278
- * drops the row content of snapshots that are superseded, past their
279
- * recovery grace and not owed to any caller (receipts, current
280
- * `received` / `unreadable` / `content_mismatch` statements), while every
281
- * revision's metadata stays. Official revisions are never compacted. Uses
282
- * this service's `statusRetentionDays` and `automatedRecoveryWindowSeconds`.
283
- * The protocol takes compaction into effect only in the next eligible minor
284
- * after November 20, 2026: do not enable this in production before then.
285
- */
286
- compaction?: ReportingCompactionOptionsV1;
287
- /**
288
- * Maintain the host change feed (`changesAfter`, `getCurrentRevision`,
289
- * `listCurrentRevisions` on `stores.core`). Adds
290
- * `REPORTING_LEDGER_CHANGES_MIGRATION` (PostgreSQL 13+); the scheduler prunes
291
- * changes older than `changeRetentionDays` (default 30) unless a registered
292
- * consumer updated within `maxFeedHoldDays` (default 7) still needs them.
293
- */
294
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1;
295
- notifications: ProductionNotificationOptions;
296
- managedDelivery: {
297
- adapter: ReportingManagedDeliveryAdapterV1;
298
- resourceRetentionDays: number;
299
- authorizationRevocationSeconds: number;
300
- store?: Omit<PostgresReportingManagedDeliveryStoreOptions, 'notificationActivityPort'>;
301
- };
302
- activity: Omit<PostgresReportingNotificationActivityOptions, 'db' | 'notifications' | 'namespace' | 'attemptCheckpoint' | 'tenantScopeForAccount'> & {
303
- tenantScopeForAccount(accountId: string): string;
304
- };
305
- webhookActivity?: {
306
- tableName?: string;
307
- retentionDays?: number;
308
- };
309
- /** Resolve activity visibility from verified auth/registry state, never request fields. */
310
- resolveWebhookActivityScope(context: ResolveContext): {
311
- tenantId: string;
312
- principalId: string;
313
- } | Promise<{
314
- tenantId: string;
315
- principalId: string;
316
- }>;
317
- /** Trusted complete roster of consumers that owe receipts for an obligation. */
318
- obligatedConsumers?: (input: {
319
- reporting_obligation_id: string;
320
- account_id: string;
321
- }) => Promise<{
322
- ids: readonly string[];
323
- complete: boolean;
324
- version?: string;
325
- }>;
326
- /** Optional migration-system bridge. Called before any capability probe. */
327
- applyMigrations?: (migrations: readonly string[]) => Promise<void>;
328
- };
329
- export interface PostgresReliableReportingProductionServiceV1<TCtxMeta = Record<string, unknown>> {
330
- readonly setup: {
331
- readonly component: 'reliable-reporting-production';
332
- readonly migrations: readonly string[];
333
- };
334
- readonly capabilities: ReportingDeliveryCapabilities;
335
- readonly platform: ReliableReportingPlatform<TCtxMeta>;
336
- readonly core: ReliableReportingServiceV1<TCtxMeta>;
337
- readonly managed: ReportingManagedDeliveryRuntimeV1<RequestContext<Account<TCtxMeta>>>;
338
- readonly notifications: PostgresPersistentNotificationRuntime;
339
- readonly notificationActivity: PostgresReportingNotificationActivityRuntime;
340
- readonly webhookActivity: PostgresReportingWebhookActivityV1;
341
- readonly stores: {
342
- core: PostgresReportingLedgerStore;
343
- managed: PostgresReportingManagedDeliveryStore;
344
- };
345
- readonly running: boolean;
346
- installConfiguration: ReliableReportingServiceV1<TCtxMeta>['installConfiguration'];
347
- install<TPlatform extends DecisioningPlatform<unknown, TCtxMeta>>(platform: TPlatform): TPlatform & {
348
- reporting: ReliableReportingPlatform<TCtxMeta>;
349
- };
350
- runCycle(options: ReliableReportingCycleOptionsV1): Promise<{
351
- core: Awaited<ReturnType<ReliableReportingServiceV1<TCtxMeta>['runCycle']>>;
352
- managed: Awaited<ReturnType<ReportingManagedDeliveryRuntimeV1['runWorker']>>;
353
- }>;
354
- recoverOnce(options: {
355
- deploymentWide: true;
356
- }): Promise<{
357
- activity: Awaited<ReturnType<PostgresReportingNotificationActivityRuntime['recoverOnce']>>;
358
- webhookOutbox: Awaited<ReturnType<PostgresPersistentNotificationRuntime['recoverOnce']>>;
359
- }>;
360
- start(options: ReliableReportingSchedulerOptionsV1 & {
361
- deploymentWide: true;
362
- }): void;
363
- stop(): Promise<void>;
364
- }
365
- /**
366
- * Assemble and probe the complete seller-side Reliable Reporting production
367
- * chain. Capability publication happens only after every durable component is
368
- * present and the managed policy has been adopted.
369
- */
370
- export declare function createPostgresReliableReportingProductionService<TCtxMeta = Record<string, unknown>>(options: CreatePostgresReliableReportingProductionServiceOptionsV1<TCtxMeta>): Promise<PostgresReliableReportingProductionServiceV1<TCtxMeta>>;
371
297
  export * from './conformance';
372
- export { ReportingMaintenancePartialFailureError, type ReportingChangeFeedMaintenanceOptionsV1, type ReportingCompactionOptionsV1, type ReportingLedgerMaintenanceStoreV1, type ReportingLedgerMaintenanceTaskNameV1, type ReportingLedgerMaintenanceTaskResultV1, type ReportingRetentionOptionsV1, } from './maintenance';
298
+ export * from './scheduler-support';