@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,689 +0,0 @@
1
- import { REPORTING_LEDGER_AUTHORITY } from './types.mjs';
2
- import type { ReportingLedgerConfigurationV1, ReportingLedgerAdjustmentMetadataV1, ReportingLedgerAdjustmentV1, ReportingLedgerConsumerStatusV1, ReportingLedgerIssueV1, ReportingLedgerLeaseV1, ReportingLedgerObligationV1, ReportingLedgerPageV1, ReportingLedgerRevisionV1, ReportingLedgerSnapshotQueryV1, ReportingLedgerSnapshotV1, ReportingLedgerStatusTransitionV1, ReportingLedgerNotificationActivityPortV1, ReportingLedgerTransactionV1, ReportingObservedFinalityV1, ReportingLedgerStore, ReportingConsumerStatusBatchInputV1, ReportingConsumerStatusBatchResultV1, ReportingConsumerStatusReplayInputV1, ReportingLedgerRevisionMetadataV1, ReportingRevisionRowsPageV1, ReportingRevisionRowsReadV1, ReportingManagedLifecycleProjectionV1, ReportingLedgerAuthorityV1 } from './types.mjs';
3
- import type { ReportingConsumerMismatchEscalationV1 } from './types.mjs';
4
- import { type ReportingChangeKindV1, type ReportingChangesPageV1 } from './change-feed.mjs';
5
- import { type ReportingRowStorageOptionsV1 } from './row-storage.mjs';
6
- type QueryResultRow = Record<string, unknown>;
7
- interface ReportingPgResult<Row extends QueryResultRow> {
8
- rows: Row[];
9
- rowCount: number | null;
10
- }
11
- interface ReportingPgClient {
12
- query<Row extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<ReportingPgResult<Row>>;
13
- release(error?: Error): void;
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
- */
18
- export interface ReportingPgPool {
19
- query<Row extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<ReportingPgResult<Row>>;
20
- connect(): Promise<ReportingPgClient>;
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
- */
25
- export declare const REPORTING_LEDGER_MIGRATION: string;
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
- */
31
- export declare const REPORTING_LEDGER_FINALITY_FENCE_CONSTRAINT = "adcp_reporting_transitions_finality_recorded";
32
- /**
33
- * Cutover migration that fences pre-SDK-14 writers out of the transition log.
34
- *
35
- * A pre-SDK-14 writer appends transitions with no `finality`. Each one becomes
36
- * the latest row, gets its baseline committed as `none`, and can therefore
37
- * produce another redundant finality-only transition — so "at most one per
38
- * obligation at upgrade" only holds once no such writer remains. Wall clocks
39
- * and deploy ordering cannot establish that; a database constraint can.
40
- *
41
- * The constraint is added `NOT VALID`, which enforces it for every INSERT and
42
- * UPDATE while leaving historical rows untouched and unvalidated. Existing
43
- * finality-less rows keep working — the baseline resolver and
44
- * `markTransitionNotified` both write `finality` as part of their update, so the
45
- * new row version satisfies the check.
46
- *
47
- * Run it as part of the cutover, **after** legacy writers are drained. A legacy
48
- * writer that is still running will fail closed on append rather than silently
49
- * multiply finality-only events, which is the intended trade: loud rejection
50
- * beats a quietly broken invariant. Idempotent and re-runnable; it takes no lock
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
54
- */
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
- */
59
- export interface PostgresReportingLedgerStoreOptions {
60
- /** Assert that the supplied PostgreSQL database/schema is isolated to this deployment. */
61
- acknowledgeIsolatedDatabase?: boolean;
62
- /**
63
- * Same advertised escalation commitment passed to
64
- * `createReportingStatusHandler`. The store needs it because the `health`
65
- * query filter is applied while building the snapshot, before the handler
66
- * projects anything — so if the two disagree about when a consumer-status
67
- * mismatch escalates, a filtered `periods` read silently omits obligations
68
- * the unfiltered read shows.
69
- */
70
- consumerMismatchEscalation?: ReportingConsumerMismatchEscalationV1;
71
- /** Explicitly opt this Core store into projecting the additive #2944 tables. */
72
- managedDelivery?: boolean;
73
- /**
74
- * Supplies the principals that owe a receipt for one obligation.
75
- *
76
- * Nothing durable in the managed tables enumerates them — destination
77
- * authorizations and bindings are keyed by
78
- * `(account_id, destination_ref, generation)` with no consumer dimension — so
79
- * without this the store can only report who has already submitted, and must
80
- * stay conservative: a `consumer_receipt` obligation is then never reported
81
- * reconciled on a lifecycle transition. Wire this to whatever your
82
- * authorization layer knows and return `complete: true` to get accurate
83
- * reconciled transitions and webhooks.
84
- *
85
- * `complete: true` is taken at your word, and this is the only place in the
86
- * subsystem where an adopter assertion can mark billing reconciled: a roster
87
- * omitting a principal that owes a receipt makes that duty vanish from the
88
- * fold, so the obligation can be persisted and notified reconciled while
89
- * that principal never accepted. It is invoked outside the store's
90
- * transaction and under a deadline, so it may do I/O — but it must not be
91
- * slower than that deadline.
92
- */
93
- obligatedConsumers?: (input: {
94
- reporting_obligation_id: string;
95
- account_id: string;
96
- }) => Promise<{
97
- ids: readonly string[];
98
- complete: boolean;
99
- version?: string;
100
- }>;
101
- /**
102
- * Durable notification/activity port invoked inside the authoritative
103
- * lifecycle transaction. Its tables must be migrated before transitions run.
104
- */
105
- notificationActivityPort?: ReportingLedgerNotificationActivityPortV1<ReportingLedgerTransactionV1>;
106
- /**
107
- * Store new revision and adjustment rows as verified canonical JSONL chunks
108
- * (see `REPORTING_ROW_STORAGE_MIGRATION`) instead of inline in the ledger
109
- * document. `true` uses a single `postgres` binding. Revisions written
110
- * before enabling this keep their inline rows; reads handle both forms
111
- * whether or not this option is set.
112
- */
113
- rowStorage?: boolean | ReportingRowStorageOptionsV1;
114
- /**
115
- * Append obligation, revision, adjustment and retirement changes to the
116
- * host change feed (`REPORTING_LEDGER_CHANGES_MIGRATION`, PostgreSQL 13+) in
117
- * the same transaction as each record. Required for `changesAfter`.
118
- */
119
- changeFeed?: boolean;
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
- */
124
- export declare class ReportingLedgerLeaseLostError extends Error {
125
- constructor(message?: string);
126
- }
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
- */
132
- export declare class ReportingLedgerPeriodRetiredError extends Error {
133
- constructor(message?: string);
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
- */
138
- export declare class ReportingLedgerContinuityError extends Error {
139
- constructor(message?: string);
140
- }
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
- */
146
- export declare function sweepExpiredReportingLedgerState(pool: Pick<ReportingPgPool, 'query'>, limit?: number): Promise<{
147
- snapshotsDeleted: number;
148
- checkpointsDeleted: number;
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
- */
153
- export declare class PostgresReportingLedgerStore implements ReportingLedgerStore {
154
- private readonly pool;
155
- /**
156
- * Exposed so `createReportingStatusHandler` can inherit it and refuse a
157
- * disagreement. The store applies `health` while building the snapshot and
158
- * the handler projects severity afterwards, so two independently configured
159
- * copies of the escalation window would let a filtered periods read
160
- * contradict the summary.
161
- */
162
- readonly consumerMismatchEscalation?: ReportingConsumerMismatchEscalationV1;
163
- readonly [REPORTING_LEDGER_AUTHORITY]: ReportingLedgerAuthorityV1;
164
- private readonly managedDelivery;
165
- private readonly obligatedConsumers;
166
- readonly transactionalNotificationActivity: boolean;
167
- private readonly notificationActivityPort?;
168
- private readonly rowStorage;
169
- private readonly rowStorageWrites;
170
- private readonly changeFeed;
171
- constructor(pool: ReportingPgPool, options?: PostgresReportingLedgerStoreOptions);
172
- /** Whether this store writes the host change feed (`changeFeed: true`). */
173
- get changeFeedEnabled(): boolean;
174
- /**
175
- * Delete expired cursor snapshots and changes checkpoints, a bounded batch
176
- * at a time. The store-bound form of `sweepExpiredReportingLedgerState`, for
177
- * hosts that hold the store but not the pool.
178
- */
179
- sweepExpiredState(limit?: number): Promise<{
180
- snapshotsDeleted: number;
181
- checkpointsDeleted: number;
182
- }>;
183
- /** Append one host change-feed row inside the caller's account-locked transaction. */
184
- private appendChange;
185
- /**
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.
191
- */
192
- assertCompactionSafeRowBindings(): void;
193
- /** Probe and register row storage when enabled. Safe to call repeatedly. */
194
- readyRowStorage(): Promise<void>;
195
- /**
196
- * Move legacy inline revision and adjustment rows into row storage, a
197
- * bounded batch at a time. Each row set is re-encoded, proven to reproduce
198
- * its committed binding, written, and only then removed from the ledger
199
- * document, in one transaction under the account lock. A document whose
200
- * rows do not reproduce its binding is never rewritten: it is reported in
201
- * `quarantined` and left inline. Pass the returned `cursor` back to resume
202
- * after the last examined document; it is absent once every candidate has
203
- * been examined. Reclaiming the freed space needs `VACUUM FULL` or an online
204
- * repack.
205
- */
206
- migrateInlineRows(input?: {
207
- limit?: number;
208
- account_id?: string;
209
- cursor?: string;
210
- bindingId?: string;
211
- signal?: AbortSignal;
212
- }): Promise<{
213
- migrated: number;
214
- quarantined: string[];
215
- cursor?: string;
216
- }>;
217
- putConfiguration(configuration: ReportingLedgerConfigurationV1): Promise<{
218
- inserted: boolean;
219
- value: ReportingLedgerConfigurationV1;
220
- }>;
221
- listConfigurations(account_id?: string): Promise<ReportingLedgerConfigurationV1[]>;
222
- putObligation(obligation: ReportingLedgerObligationV1): Promise<{
223
- inserted: boolean;
224
- value: ReportingLedgerObligationV1;
225
- }>;
226
- getObligation(id: string, account_id?: string): Promise<ReportingLedgerObligationV1 | null>;
227
- /** Periods retired by retention; planners treat them as already covered. */
228
- listRetiredObligationOrdinals(account_id?: string): Promise<{
229
- configurationId: string;
230
- periodOrdinal: number;
231
- }[]>;
232
- listObligations(account_id?: string): Promise<ReportingLedgerObligationV1[]>;
233
- listLifecycleDueObligations(input: {
234
- ledgerAsOf: string;
235
- account_id?: string;
236
- limit: number;
237
- }): Promise<ReportingLedgerObligationV1[]>;
238
- updateObligation(obligation: ReportingLedgerObligationV1, lease: ReportingLedgerLeaseV1, issue?: ReportingLedgerIssueV1): Promise<void>;
239
- claimObligation(input: {
240
- owner: string;
241
- now: string;
242
- leaseMilliseconds: number;
243
- account_id?: string;
244
- }): Promise<ReportingLedgerLeaseV1 | null>;
245
- releaseObligationLease(lease: ReportingLedgerLeaseV1): Promise<void>;
246
- commitRevision(revision: ReportingLedgerRevisionV1, lease: ReportingLedgerLeaseV1): Promise<{
247
- inserted: boolean;
248
- value: ReportingLedgerRevisionV1;
249
- }>;
250
- getRevision(id: string, accountId: string): Promise<ReportingLedgerRevisionV1 | null>;
251
- getRevisionMetadata(id: string, accountId: string): Promise<ReportingLedgerRevisionMetadataV1 | null>;
252
- readRevisionRows(input: ReportingRevisionRowsReadV1): Promise<ReportingRevisionRowsPageV1 | null>;
253
- listRevisions(obligationId: string): Promise<ReportingLedgerRevisionV1[]>;
254
- listRevisionMetadata(obligationId: string, accountId?: string): Promise<ReportingLedgerRevisionMetadataV1[]>;
255
- commitAdjustment(adjustment: ReportingLedgerAdjustmentV1, lease: ReportingLedgerLeaseV1): Promise<{
256
- inserted: boolean;
257
- value: ReportingLedgerAdjustmentV1;
258
- }>;
259
- listAdjustments(obligationId: string): Promise<ReportingLedgerAdjustmentV1[]>;
260
- /**
261
- * The obligation's current revision header: its official revision if one
262
- * exists, otherwise its highest-numbered snapshot. An official revision is
263
- * terminal, so this is always the highest revision number — one index
264
- * lookup. Rows are read separately through `readRevisionRows`.
265
- */
266
- getCurrentRevision(input: {
267
- account_id: string;
268
- reporting_obligation_id: string;
269
- }): Promise<ReportingLedgerRevisionMetadataV1 | null>;
270
- /**
271
- * Current revision headers for an account's obligations whose period starts
272
- * in `[period_start_from, period_start_to)`, ordered by period start.
273
- * Obligations without a revision yet are omitted. Page with `cursor`.
274
- */
275
- listCurrentRevisions(input: {
276
- account_id: string;
277
- period_start_from: string;
278
- period_start_to: string;
279
- delivery_config_id?: string;
280
- limit?: number;
281
- cursor?: string;
282
- }): Promise<{
283
- revisions: ReportingLedgerRevisionMetadataV1[];
284
- cursor?: string;
285
- }>;
286
- /**
287
- * Host change feed. Omit `cursor` to start from the oldest retained change.
288
- * Account-scoped feeds order by sequence; the deployment-wide feed orders by
289
- * `(xid, seq)` and returns only changes whose transaction precedes every
290
- * transaction still in flight, so no commit is ever skipped. An account page
291
- * also ends before the first change whose transaction has not finished, as
292
- * defense in depth against a change that commits late. An empty page can
293
- * therefore mean either caught up or held back by an older open transaction.
294
- * A ledger database must have exactly one writer SDK; see
295
- * `docs/guides/REPORTING-LEDGER.md`. A cursor older
296
- * than the retained history throws `ReportingChangeCursorExpiredError`;
297
- * resynchronize from `listCurrentRevisions`.
298
- *
299
- * A read without a `cursor` can throw `ReportingChangeCursorExpiredError`
300
- * (`code === 'CURSOR_EXPIRED'`) too. The horizon is re-read after the page,
301
- * so a prune that commits mid-read rejects the page instead of returning one
302
- * that silently skips the pruned changes. Retrying the read starts from the
303
- * new, later horizon. Match on `error.code` rather than `instanceof`, which
304
- * fails when the error crosses a CJS/ESM module boundary.
305
- */
306
- changesAfter(input?: {
307
- cursor?: string;
308
- account_id?: string;
309
- kinds?: readonly ReportingChangeKindV1[];
310
- limit?: number;
311
- }): Promise<ReportingChangesPageV1>;
312
- /**
313
- * Record a named durable consumer's position. Registered consumers hold
314
- * back change-table pruning until `maxFeedHoldDays` after their last update.
315
- *
316
- * Checkpoints are forward-only within a feed scope: a cursor behind the
317
- * saved one is ignored, so a delayed or stale acknowledgment cannot pull the
318
- * retention hold back. Resolves `true` when the checkpoint was written and
319
- * `false` when it was ignored (behind the saved position, or equal with
320
- * `refreshUnchanged: false`). To rewind a consumer deliberately, for example
321
- * to replay changes, pass `rewind: true`; the saved position and retention
322
- * hold then move to `cursor` and the write always applies, even with
323
- * `refreshUnchanged: false`. The cursor is not checked against the
324
- * retention horizon: it must still be inside the retained history or the
325
- * next read throws `ReportingChangeCursorExpiredError`. Any change of
326
- * `account_id` (account to deployment, deployment to account, or between
327
- * accounts) always replaces the position. The feed scope is read from the
328
- * cursor itself, so only pass cursors your own code obtained from
329
- * `changesAfter`, never ones supplied by an untrusted caller.
330
- *
331
- * Set `refreshUnchanged: false` to recover an acknowledgment without
332
- * renewing the retention hold when its position has not advanced.
333
- */
334
- saveFeedConsumerCursor(name: string, cursor: string, options?: {
335
- refreshUnchanged?: boolean;
336
- rewind?: boolean;
337
- }): Promise<boolean>;
338
- /**
339
- * Unregister a durable consumer so it stops holding back change-table
340
- * pruning and period retention. Resolves `true` when a registration was
341
- * removed. Saving a cursor under the same name registers it again.
342
- */
343
- removeFeedConsumer(name: string): Promise<boolean>;
344
- /**
345
- * Delete change rows older than `changeRetentionDays` that every consumer
346
- * updated within `maxFeedHoldDays` has passed, and advance the expiry
347
- * horizon so older cursors fail closed.
348
- */
349
- pruneChanges(input?: {
350
- changeRetentionDays?: number;
351
- maxFeedHoldDays?: number;
352
- limit?: number;
353
- }): Promise<{
354
- deleted: number;
355
- }>;
356
- /**
357
- * Retire whole reporting periods whose retention has elapsed (shared SDK
358
- * persistence spec §4). A period is eligible once both its end and its
359
- * latest publication are older than `max(statusRetentionDays,
360
- * recordRetentionDays)`, no worker holds its lease, and no Managed Delivery
361
- * materialization still references it. Retirement is period-aligned and
362
- * resumable:
363
- *
364
- * 1. under the account lock, record a `retiring` tombstone and mark the
365
- * period's row sets `pruning`, so exact reads answer as expired;
366
- * 2. delete the period's external row objects at their recorded versions;
367
- * 3. under the account lock, delete the period's ledger records (rows,
368
- * revisions, adjustments, consumer statuses, issues, transitions,
369
- * lifecycle state, obligation) and mark the tombstone `retired`.
370
- *
371
- * Planners skip retired periods, and `ledger_retained_from` advances past
372
- * them because their obligations no longer exist.
373
- *
374
- * When the change-feed tables exist, a period that is not yet retiring is
375
- * also held while any live registered feed consumer (updated within
376
- * `maxFeedHoldDays`, default 7) has not passed that period's change rows in
377
- * the consumer's own feed order, the same rule `pruneChanges` applies. A
378
- * held period is simply not a candidate this pass. A consumer that stays
379
- * silent past `maxFeedHoldDays` stops holding, so retention is never
380
- * blocked forever; it then falls behind retention and a sink sees the
381
- * retired revisions as missing.
382
- */
383
- retireExpiredPeriods(input: {
384
- statusRetentionDays: number;
385
- recordRetentionDays?: number;
386
- maxFeedHoldDays?: number;
387
- limit?: number;
388
- account_id?: string;
389
- signal?: AbortSignal;
390
- }): Promise<{
391
- retired: number;
392
- failed: string[];
393
- /** Secret-free cause per period that failed this pass: a row-store code or the error class name. */
394
- failures: {
395
- reporting_obligation_id: string;
396
- cause: string;
397
- }[];
398
- /** Retiring periods currently backing off after a failure; they are not attempted this pass. */
399
- deferred: number;
400
- /**
401
- * Periods that have failed at least five attempts and
402
- * are still retiring (at most 20, worst first). They need operator attention, for example a
403
- * removed binding or a permanent provider error.
404
- */
405
- stuck: {
406
- reporting_obligation_id: string;
407
- attempts: number;
408
- cause: string;
409
- }[];
410
- }>;
411
- /**
412
- * Record a failed retirement attempt on the period's tombstone and push its next
413
- * attempt out by an exponential backoff. Best effort: a failure to record only
414
- * means the period is retried on the next pass.
415
- */
416
- private recordRetirementFailure;
417
- private retirePeriod;
418
- /**
419
- * Compact superseded snapshot revisions to metadata only, as adcontextprotocol/adcp#8100
420
- * permits (`reporting-revision.json` `content_retention`). Opt-in: nothing calls this
421
- * unless the host enables `compaction` in maintenance, and it must not be enabled in
422
- * production before the AdCP release that takes compaction into effect (the next
423
- * eligible minor after November 20, 2026).
424
- *
425
- * A snapshot revision is compacted only when every one of these holds:
426
- *
427
- * - it is superseded: a later revision names it in `supersedes_reporting_revision_id`
428
- * (so a current revision, and every official revision, is never compacted);
429
- * - it is not the revision the current, unsuperseded revision names;
430
- * - its recovery grace has passed: `max(automatedRecoveryWindowSeconds, 3600)` seconds
431
- * since its successor's `created_at`;
432
- * - while its window is open (`statusRetentionDays` since its successor's `created_at`),
433
- * no caller's reporting receipt (any status) names it and no caller's current consumer
434
- * status statement of `received`, `unreadable` or `content_mismatch` names it. The
435
- * check spans every caller, so content any caller is entitled to is kept;
436
- * - it has rows (nothing to reclaim otherwise, and an empty exact read is still correct);
437
- * - no live obligation lease, no pending materialization of it, and no live change-feed
438
- * consumer that has not yet passed its change row (the holds retirement applies,
439
- * narrowed to this revision).
440
- *
441
- * Only row content is dropped: the revision header, its manifest and every metadata
442
- * listing stay. The row set is marked `pruned`, so an exact read answers
443
- * `ROWS_EXPIRED`, which the handlers surface as the same nondisclosing
444
- * `REFERENCE_NOT_FOUND` as an unknown ID. No change-feed row is recorded: the revision's
445
- * metadata is unchanged, and a sink still catching up holds compaction back.
446
- *
447
- * Compaction is resumable and runs in the same three phases as retirement, under the
448
- * account lock where eligibility is decided:
449
- *
450
- * 1. re-check eligibility and mark the row set `pruning`, so reads answer as expired and
451
- * no new revision can share its chunks;
452
- * 2. delete external objects at their recorded versions, skipping any object another
453
- * row set that is not being pruned still references (chunk sharing);
454
- * 3. delete the chunk manifest rows and any PostgreSQL chunk body nothing else
455
- * references, and mark the row set `pruned`.
456
- *
457
- * A crash after phase 1 leaves a `pruning` row set that the next pass resumes.
458
- */
459
- compactSupersededSnapshots(input: {
460
- statusRetentionDays: number;
461
- automatedRecoveryWindowSeconds: number;
462
- maxFeedHoldDays?: number;
463
- limit?: number;
464
- account_id?: string;
465
- signal?: AbortSignal;
466
- }): Promise<{
467
- compacted: number;
468
- failed: string[];
469
- /** Secret-free cause per failed revision: a row-store code or the error class name. */
470
- failures: {
471
- reporting_obligation_id: string;
472
- reporting_revision_id: string;
473
- cause: string;
474
- }[];
475
- }>;
476
- private compactSnapshot;
477
- /**
478
- * Resolve abandoned object uploads (spec §4.3). An expired `open` write
479
- * intent whose ledger commit never happened is moved to `sweeping` under
480
- * the account lock, so no writer can commit against it, then only the
481
- * objects that upload created — never adopted ones, never any object a
482
- * committed chunk references — are deleted at their recorded versions.
483
- * Interrupted sweeps resume.
484
- */
485
- sweepRowWriteIntents(input?: {
486
- limit?: number;
487
- account_id?: string;
488
- overdueAfterSeconds?: number;
489
- signal?: AbortSignal;
490
- }): Promise<{
491
- swept: number;
492
- objectsDeleted: number;
493
- /** Intents whose sweep failed this pass. Each backs off before its next attempt. */
494
- failed: number;
495
- /**
496
- * Expired intents with objects to delete through a binding this host does not configure. They
497
- * are left untouched for a host that configures it; they are not failures of this host.
498
- */
499
- skippedUnconfigured: number;
500
- /** Expired intents backing off after a failed sweep, not attempted this pass. */
501
- deferred: number;
502
- /**
503
- * Intents expired for longer than `overdueAfterSeconds` (default 24 hours) and still not swept,
504
- * including ones backing off. Their objects are leaking: check that a host configures their
505
- * binding and that provider deletes succeed.
506
- */
507
- overdue: number;
508
- }>;
509
- /**
510
- * Delete external row objects, skipping any object another row set still references.
511
- *
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
515
- * chunk of a live (or unavailable) row set outside this operation references the same binding,
516
- * key and native version, and no other open write intent created it. Row sets already `pruning`
517
- * or `pruned` do not count: their own operation deletes the object, and counting them would let
518
- * two concurrent retirements each skip the object and leak it. `scope` names what this
519
- * operation is deleting: an obligation (retirement) or a row set (compaction).
520
- *
521
- * The check and the provider delete run in one transaction under a per-object advisory lock.
522
- * A commit that adopts an existing object takes the same lock before it inserts its chunk rows
523
- * and re-verifies the object under it (`writePreparedRowSet`), and holds it until commit. So
524
- * either the delete wins the lock and the adopting commit then fails cleanly, or the commit wins
525
- * and the delete sees its chunk rows and skips. A skipped object stays for the row set that owns
526
- * it: that row set's own retirement, compaction or sweep deletes it, because by then nothing
527
- * else references it. Locks are taken one object at a time, never while waiting on the account
528
- * lock, so commits (account lock, then object locks) cannot deadlock with these deletes.
529
- */
530
- private deleteUnreferencedObjects;
531
- private optionalTables;
532
- /**
533
- * Upload an object-kind row set before its ledger commit (spec §3.5):
534
- * skip when the document already exists (replay), refuse unless the lease
535
- * still covers the upload deadline, open or take over an expired write
536
- * intent under the account lock, then write every chunk create-only,
537
- * recording each object this upload created in the intent first.
538
- */
539
- private uploadRowSetUnlessCommitted;
540
- /** Persist a prepared row set and close its upload intent in the ledger commit transaction. */
541
- private writePreparedRowSet;
542
- /** Attach verified rows to a revision document whose rows live in row storage. */
543
- private hydrateRevision;
544
- listAdjustmentMetadata(obligationId: string): Promise<ReportingLedgerAdjustmentMetadataV1[]>;
545
- putConsumerStatus(status: ReportingLedgerConsumerStatusV1): Promise<{
546
- inserted: boolean;
547
- value: ReportingLedgerConsumerStatusV1;
548
- }>;
549
- getConsumerStatusBatchReplay(input: ReportingConsumerStatusReplayInputV1): Promise<ReportingConsumerStatusBatchResultV1[] | null>;
550
- syncConsumerStatusBatch(input: ReportingConsumerStatusBatchInputV1): Promise<ReportingConsumerStatusBatchResultV1[]>;
551
- listConsumerStatuses(revisionId: string): Promise<ReportingLedgerConsumerStatusV1[]>;
552
- putIssue(issue: ReportingLedgerIssueV1): Promise<void>;
553
- resolveIssue(issueId: string, resolvedAt: string): Promise<void>;
554
- listIssues(obligationId: string): Promise<ReportingLedgerIssueV1[]>;
555
- /**
556
- * Resolves — and for pre-SDK-14 rows persists — the observed finality baseline
557
- * of the obligation's latest transition, so the lifecycle decision and this
558
- * store's compare-and-set read one committed value.
559
- */
560
- resolveTransitionFinalityBaseline(obligationId: string): Promise<ReportingObservedFinalityV1>;
561
- appendTransition(transition: ReportingLedgerStatusTransitionV1): Promise<{
562
- inserted: boolean;
563
- }>;
564
- private appendTransitionWithinLock;
565
- applyLifecycleProjection(input: {
566
- reporting_obligation_id: string;
567
- expectedRevisionIds: string[];
568
- expectedPreviousHealth: import('./types.mjs').ReportingHealthV1;
569
- expectedPreviousFinality?: ReportingObservedFinalityV1;
570
- expectedObligationState: ReportingLedgerObligationV1['state'];
571
- expectedAttemptCount: number;
572
- projectedIssues: ReportingLedgerIssueV1[];
573
- ledgerAsOf: string;
574
- transition?: ReportingLedgerStatusTransitionV1;
575
- expectedManagedStateVersion?: string;
576
- processedManagedStateVersion?: string;
577
- processedObligatedConsumerRosterVersion?: string;
578
- expectedObligatedConsumerRosterVersion?: string;
579
- }): Promise<{
580
- applied: boolean;
581
- transitionInserted: boolean;
582
- }>;
583
- private applyLifecycleProjectionWithinLock;
584
- markTransitionNotified(transitionId: string, notifiedAt: string): Promise<void>;
585
- listTransitions(obligationId: string): Promise<ReportingLedgerStatusTransitionV1[]>;
586
- listPendingTransitions(input?: {
587
- account_id?: string;
588
- limit?: number;
589
- }): Promise<ReportingLedgerStatusTransitionV1[]>;
590
- createSnapshot(query: ReportingLedgerSnapshotQueryV1): Promise<ReportingLedgerSnapshotV1>;
591
- readSnapshotPage(snapshotId: string, account_id: string, cursor: string | undefined, limit: number): Promise<ReportingLedgerPageV1>;
592
- private listSnapshotConsumerStatuses;
593
- private listSnapshotObligations;
594
- private listSnapshotConfigurations;
595
- private resolveChangesCheckpoint;
596
- private listSnapshotRevisions;
597
- private listSnapshotIssues;
598
- private listSnapshotAdjustments;
599
- /**
600
- * Managed Delivery projection inputs for one obligation, grouped per consumer.
601
- *
602
- * The lifecycle reconciler folds these through the same
603
- * `projectManagedDelivery` the read path uses, so a persisted transition and
604
- * its webhook report the health a read of the same obligation would return.
605
- * Returns `null` when Managed Delivery is not installed or the obligation's
606
- * configuration has no binding, which keeps a Core-only ledger unchanged.
607
- */
608
- getManagedLifecycleProjection(input: {
609
- reporting_obligation_id: string;
610
- ledgerAsOf?: string;
611
- }): Promise<ReportingManagedLifecycleProjectionV1 | null>;
612
- /**
613
- * Digest over every managed row that can change this obligation's projected
614
- * health: materialization status, receipt existence and current-leaf flag,
615
- * adjustments, and the destination authorization's revocation/cleanup state.
616
- *
617
- * `is_current` is included because superseding a receipt flips it with no
618
- * timestamp of its own, and the authorization's `cleanup_completed_at` is
619
- * included because `completeRevocation` does not touch `changed_at`.
620
- */
621
- private readManagedStateVersion;
622
- /**
623
- * Current external roster version, read outside any transaction so the
624
- * reconciler can re-check it immediately before an apply.
625
- */
626
- /**
627
- * Publishes the roster version currently observed for an obligation.
628
- *
629
- * The roster is external, so nothing in this database changes when it does.
630
- * Recording what a reader saw is what lets the due query notice drift from
631
- * the version last reconciled. Never lowers a watermark; it only reports.
632
- */
633
- recordObligatedConsumerRosterVersion(input: {
634
- reporting_obligation_id: string;
635
- version: string;
636
- }): Promise<void>;
637
- /**
638
- * Re-reads the external roster for managed obligations and publishes what
639
- * it saw, so a change made while nothing was scheduled can re-arm.
640
- *
641
- * Ordered by least-recently-refreshed and bounded, so a large account is
642
- * swept over successive passes rather than in one burst of callbacks.
643
- */
644
- refreshObligatedConsumerRosterVersions(input: {
645
- account_id?: string;
646
- limit: number;
647
- }): Promise<number>;
648
- /**
649
- * Records a failed reconcile so the obligation backs off instead of
650
- * re-occupying the head of every sweep, without ever hiding it: the
651
- * watermark is untouched, so it stays unresolved work.
652
- */
653
- recordLifecycleFailure(input: {
654
- reporting_obligation_id: string;
655
- }): Promise<void>;
656
- /** Authoritative instant from the database clock, at microsecond precision. */
657
- readLedgerInstant(): Promise<string>;
658
- readObligatedConsumerRosterVersion(input: {
659
- reporting_obligation_id: string;
660
- }): Promise<string | undefined>;
661
- /** Principals that have engaged with this obligation, as the projection sees them. */
662
- private observedConsumerIds;
663
- private managedDueTablesReadyCache;
664
- /** Whether the managed schema exists, resolved once per store instance. */
665
- private managedDueTablesReady;
666
- /**
667
- * Terminal receipt subjects whose bodies have been pruned.
668
- *
669
- * The projection decides reconciliation from the receipt rows it can see,
670
- * so once an accepted leaf ages out the subject looks unreconciled again
671
- * and a settled billing period reopens. The tombstone is the only remaining
672
- * proof, so the projection has to consult it.
673
- */
674
- private listTombstonedAcceptedSubjects;
675
- private managedTablesInstalled;
676
- private listManagedChangedObligationIds;
677
- private listSnapshotManagedBindings;
678
- private listSnapshotMaterializations;
679
- private listSnapshotMaterializationProjection;
680
- private listSnapshotReceipts;
681
- private one;
682
- private putImmutable;
683
- private accountLockForObligation;
684
- private accountLockForIssue;
685
- private accountLockForTransition;
686
- private transaction;
687
- private query;
688
- }
689
- export {};