@adcp/sdk 16.0.0-beta.3 → 16.0.0-beta.5

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 (185) hide show
  1. package/dist/lib/auth/oauth/diagnose.js +3 -11
  2. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  3. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  4. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  6. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  7. package/dist/lib/index.d.mts +1 -1
  8. package/dist/lib/index.d.ts +1 -1
  9. package/dist/lib/index.js +2 -0
  10. package/dist/lib/index.mjs +7 -1
  11. package/dist/lib/reporting/consumer-runtime.js +2 -1
  12. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  13. package/dist/lib/reporting/ledger/handler.js +50 -11
  14. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  15. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  16. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  17. package/dist/lib/reporting/ledger/index.js +32 -20
  18. package/dist/lib/reporting/ledger/index.mjs +21 -10
  19. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  20. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  21. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  22. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  23. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  24. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  25. package/dist/lib/reporting/ledger/receipts.js +186 -0
  26. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  27. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  28. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  29. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  30. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  31. package/dist/lib/reporting/ledger/types.js +31 -2
  32. package/dist/lib/reporting/ledger/types.mjs +26 -1
  33. package/dist/lib/reporting/pagination.d.mts +6 -0
  34. package/dist/lib/reporting/pagination.d.ts +6 -0
  35. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  36. package/dist/lib/reporting/pagination.mjs +12 -0
  37. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  38. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  39. package/dist/lib/reporting/reconciliation.js +3 -2
  40. package/dist/lib/reporting/reconciliation.mjs +3 -2
  41. package/dist/lib/reporting/service/index.d.mts +79 -153
  42. package/dist/lib/reporting/service/index.d.ts +79 -153
  43. package/dist/lib/reporting/service/index.js +34 -491
  44. package/dist/lib/reporting/service/index.mjs +36 -510
  45. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  46. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  47. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  48. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  49. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  50. package/dist/lib/signing/canonicalize.d.mts +4 -0
  51. package/dist/lib/signing/canonicalize.d.ts +4 -0
  52. package/dist/lib/signing/canonicalize.js +14 -8
  53. package/dist/lib/signing/canonicalize.mjs +14 -8
  54. package/dist/lib/signing/content-digest.d.mts +8 -0
  55. package/dist/lib/signing/content-digest.d.ts +8 -0
  56. package/dist/lib/signing/content-digest.js +11 -5
  57. package/dist/lib/signing/content-digest.mjs +10 -5
  58. package/dist/lib/signing/signer.js +9 -6
  59. package/dist/lib/signing/signer.mjs +10 -7
  60. package/dist/lib/signing/web-bot-auth.js +103 -37
  61. package/dist/lib/signing/web-bot-auth.mjs +108 -37
  62. package/dist/lib/testing/storyboard/junit.js +16 -3
  63. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  64. package/dist/lib/testing/storyboard/request-signing/builder.js +10 -9
  65. package/dist/lib/testing/storyboard/request-signing/builder.mjs +10 -9
  66. package/dist/lib/testing/storyboard/runner.js +94 -25
  67. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  68. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  69. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  70. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  71. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  72. package/dist/lib/types/schemas.generated.d.ts +907 -60
  73. package/dist/lib/types/schemas.generated.js +7 -7
  74. package/dist/lib/types/schemas.generated.mjs +7 -7
  75. package/dist/lib/version.d.mts +3 -3
  76. package/dist/lib/version.d.ts +3 -3
  77. package/dist/lib/version.js +3 -3
  78. package/dist/lib/version.mjs +3 -3
  79. package/docs/TYPE-SUMMARY.md +23 -5
  80. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  81. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  82. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  83. package/docs/guides/REPORTING-LEDGER.md +107 -51
  84. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  85. package/docs/guides/REPORTING-STABILITY.md +36 -32
  86. package/docs/llms.txt +4 -3
  87. package/docs/migration-14.x-rc-worksheet.md +4 -7
  88. package/docs/migration-reporting-storage-package.md +186 -0
  89. package/examples/README.md +1 -1
  90. package/package.json +13 -78
  91. package/dist/lib/reporting/azure/index.d.mts +0 -31
  92. package/dist/lib/reporting/azure/index.d.ts +0 -31
  93. package/dist/lib/reporting/azure/index.js +0 -266
  94. package/dist/lib/reporting/azure/index.mjs +0 -249
  95. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  96. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  97. package/dist/lib/reporting/bigquery/index.js +0 -633
  98. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  99. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  100. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  101. package/dist/lib/reporting/gcs/adapter.js +0 -342
  102. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  103. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  104. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  105. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  106. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  107. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  108. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  109. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  110. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  111. package/dist/lib/reporting/gcs/fence.js +0 -250
  112. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  113. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  114. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  115. package/dist/lib/reporting/gcs/index.js +0 -44
  116. package/dist/lib/reporting/gcs/index.mjs +0 -14
  117. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  118. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  119. package/dist/lib/reporting/gcs/io.js +0 -95
  120. package/dist/lib/reporting/gcs/io.mjs +0 -69
  121. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  122. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  123. package/dist/lib/reporting/gcs/reader.js +0 -193
  124. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  125. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  126. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  127. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  128. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  129. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  130. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  131. package/dist/lib/reporting/gcs/validation.js +0 -49
  132. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  133. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  134. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  135. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  136. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  137. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  138. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  139. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  140. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  141. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  142. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  143. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  144. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  145. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  146. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  147. package/dist/lib/reporting/ledger/managed.js +0 -761
  148. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  149. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  150. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  151. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  152. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  153. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  154. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  155. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  156. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  157. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  158. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  159. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  160. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  161. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  162. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  163. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  164. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  165. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  166. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  167. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  168. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  169. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  170. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  171. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  172. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  173. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  174. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  175. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  176. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  177. package/dist/lib/reporting/s3/index.d.mts +0 -34
  178. package/dist/lib/reporting/s3/index.d.ts +0 -34
  179. package/dist/lib/reporting/s3/index.js +0 -347
  180. package/dist/lib/reporting/s3/index.mjs +0 -340
  181. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  182. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  183. package/dist/lib/reporting/service/maintenance.js +0 -185
  184. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  185. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,293 +0,0 @@
1
- import type { ReportingMaterialization, SyncReportingReceiptsResponse } from '../../types/index.mjs';
2
- import type { ReportingPgPool } from './postgres.mjs';
3
- import type { ReportingLedgerNotificationActivityPortV1, ReportingLedgerTransactionV1, ReportingManagedDeliveryBindingV1, ReportingLedgerStore } from './types.mjs';
4
- import { type ReportingObjectWritePlanV1, type ReportingObjectWriteScopeV1, type ReportingObjectWriteCursorV1, type ReportingObjectWriteV1, type ReportingObjectWriteBindingV1, type ReportingObjectWriteContextV1, type ReportingObjectWriteStoreV1, type ReportingObjectWriteAuthorityStoreV1 } from './object-writes.mjs';
5
- import { type ReportingDestinationAuthorizationV1, type ReportingDestinationRevocationLeaseV1, type ReportingManagedDeliveryLeaseV1, type ReportingManagedDeliveryAdvertisedPoliciesV1, type ReportingManagedDeliveryStore, type ReportingReceiptBatchInputV1 } from './managed.mjs';
6
- /**
7
- * Additive migration owned by #2944. It intentionally does not alter the Core
8
- * tables so the #2943 notification/activity bridge can evolve that schema
9
- * independently. Apply after REPORTING_LEDGER_MIGRATION in the same schema.
10
- *
11
- * @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
12
- */
13
- export declare const REPORTING_MANAGED_DELIVERY_MIGRATION: string;
14
- /**
15
- * @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
16
- */
17
- export interface PostgresReportingManagedDeliveryStoreOptions {
18
- /** Transactional reporting outbox used for successful delivery-ready events. */
19
- notificationActivityPort?: ReportingLedgerNotificationActivityPortV1<ReportingLedgerTransactionV1>;
20
- /**
21
- * The `automated_recovery_window_seconds` this deployment advertises.
22
- *
23
- * The capability is agent-wide and immutable once published, while bindings
24
- * arrive over time, so validating only at startup leaves the window open:
25
- * an agent advertising 60s starts clean and a 900s binding installed an hour
26
- * later silently makes the published promise false until the next restart.
27
- * Set here, `installBinding` refuses any Core configuration whose recovery
28
- * window exceeds the advertised bound, inside the same transaction that
29
- * checks binding eligibility. `createReportingManagedDeliveryRuntime` adopts
30
- * its own advertised value into the store at wiring time, so setting it
31
- * explicitly is only needed when bindings are installed without a runtime.
32
- */
33
- advertisedRecoveryWindowSeconds?: number;
34
- /**
35
- * The `status_retention_days` this deployment advertises.
36
- *
37
- * Supply it together with `evidenceRetentionDays` so the store can refuse a
38
- * retention shorter than a horizon you have already promised. Pruning
39
- * evidence the capability document still says is queryable is a broken
40
- * promise, not a capacity optimisation.
41
- */
42
- statusRetentionDays?: number;
43
- /**
44
- * Days of managed evidence an account is still accountable for.
45
- *
46
- * MAX_MATERIALIZATIONS_PER_ACCOUNT and MAX_RECEIPTS_PER_CONSUMER are
47
- * lifetime counts. Left unbounded they are a one-way door: a long-lived
48
- * account eventually reaches them and then stops planning materializations
49
- * and refuses every receipt, permanently, with no operator-visible way back
50
- * — evidence is immutable, so nothing ever frees capacity.
51
- *
52
- * Setting this makes the caps active-scope: only evidence recorded inside
53
- * the window counts against them, and `pruneExpiredEvidence` can delete what
54
- * falls outside it. Choose a value at least as long as the
55
- * `status_retention_days` you advertise, since that is the period you
56
- * promised the metadata stays queryable. Omit it to keep the previous
57
- * lifetime accounting with no pruning.
58
- */
59
- evidenceRetentionDays?: number;
60
- }
61
- /**
62
- * @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
63
- */
64
- export declare class PostgresReportingManagedDeliveryStore implements ReportingManagedDeliveryStore, ReportingObjectWriteStoreV1, ReportingObjectWriteAuthorityStoreV1 {
65
- private readonly pool;
66
- private readonly evidenceRetentionDays;
67
- private readonly statusRetentionDays;
68
- private readonly pendingRecoveryWindowSeconds;
69
- private policyRegistered;
70
- private bindingAdmission;
71
- private readonly notificationActivityPort?;
72
- /**
73
- * Durably records the agent-wide advertised recovery window.
74
- *
75
- * Written to the database, not held in memory: the promise is agent-wide,
76
- * so a second store instance — in this process or another replica — must be
77
- * held to the same value, and `installBinding` must read it inside its own
78
- * transaction rather than trusting whatever the local object happens to
79
- * know. Multiple replicas monotonically retain the smallest registered
80
- * maximum: a shorter recovery promise is stronger and can never be widened
81
- * by a later runtime.
82
- */
83
- adoptAdvertisedRecoveryWindowSeconds(seconds: number): Promise<void>;
84
- /**
85
- * Durably records the advertised `status_retention_days`.
86
- *
87
- * Retention is enforced against the widest promise any runtime registered
88
- * over this database, so a store configured with a short evidence retention
89
- * cannot prune inside a horizon a differently configured runtime published.
90
- */
91
- adoptAdvertisedStatusRetentionDays(days: number): Promise<void>;
92
- /** Registers the complete capability policy under one lock and transaction. */
93
- adoptAdvertisedPolicies(policy: ReportingManagedDeliveryAdvertisedPoliciesV1): Promise<ReportingManagedDeliveryAdvertisedPoliciesV1>;
94
- /**
95
- * Flushes constructor-supplied promises into the durable registry.
96
- *
97
- * Called from every entry point that depends on them, so a store built with
98
- * options behaves identically to one a runtime adopted into.
99
- */
100
- private ensurePolicyRegistered;
101
- private upsertPolicy;
102
- private upsertPolicies;
103
- private validateRecoveryWindow;
104
- private readPolicyRow;
105
- private readPolicy;
106
- /** Read-only access to PostgreSQL row chunks for claim hydration. */
107
- private readonly rowStorage;
108
- constructor(pool: ReportingPgPool, options?: PostgresReportingManagedDeliveryStoreOptions);
109
- /** SQL fragment scoping a count to the active retention window, if one is set. */
110
- private activeScope;
111
- /**
112
- * Deletes managed evidence that has aged out of `evidenceRetentionDays`.
113
- *
114
- * Only ever removes evidence the deployment no longer promises: nothing
115
- * inside the retention window, nothing still `pending` or leased, and no
116
- * receipt batch inside its own replay retention. Immutable evidence stays
117
- * immutable while it is retained — this frees capacity at the far end of the
118
- * window rather than rewriting anything. Returns what it removed so a
119
- * scheduler can page through with `limit`.
120
- */
121
- pruneExpiredEvidence(input: {
122
- account_id: string;
123
- limit?: number;
124
- }): Promise<{
125
- materializations: number;
126
- receipts: number;
127
- batches: number;
128
- }>;
129
- probe(coreStore: ReportingLedgerStore): Promise<boolean>;
130
- listInstalledRecoveryWindowSeconds(): Promise<number[]>;
131
- authorizeDestination(input: Omit<ReportingDestinationAuthorizationV1, 'revoked_at' | 'cleanup_completed_at'>): Promise<void>;
132
- revokeDestination(input: {
133
- account_id: string;
134
- destination_ref: string;
135
- generation: number;
136
- revoked_at: string;
137
- }): Promise<boolean>;
138
- setBindingAdmission(admit: ((binding: ReportingManagedDeliveryBindingV1) => void) | undefined): void;
139
- installBinding(binding: ReportingManagedDeliveryBindingV1): Promise<{
140
- inserted: boolean;
141
- }>;
142
- planMaterializations(input?: {
143
- account_id?: string;
144
- limit?: number;
145
- }): Promise<number>;
146
- /**
147
- * Claims a bounded, durable round-robin page of accounts that currently
148
- * have at least one materialization candidate.
149
- *
150
- * The policy row serializes only the final cursor compare-and-set. Eligible
151
- * account discovery runs without that global lock so retained revision
152
- * history cannot block materialization settlement or revocation. The cursor
153
- * advances before provider work; a crash may defer a selected account until
154
- * the ring wraps, but can never pin every future sweep behind it.
155
- */
156
- private claimMaterializationPlanningAccounts;
157
- claimMaterialization(input: {
158
- owner: string;
159
- now: string;
160
- lease_milliseconds: number;
161
- account_id?: string;
162
- }): Promise<ReportingManagedDeliveryLeaseV1 | null>;
163
- /**
164
- * Fails materializations that have used every delivery attempt.
165
- *
166
- * The claim predicate stops handing them out, so without this they would
167
- * stay `pending` — invisible to the planner, which skips an obligation with
168
- * any pending row, and so never retried or replanned.
169
- */
170
- failExhaustedMaterializations(input?: {
171
- account_id?: string;
172
- limit?: number;
173
- }): Promise<number>;
174
- settleMaterialization(input: {
175
- lease: ReportingManagedDeliveryLeaseV1;
176
- now: string;
177
- /** Retention the database must see satisfied, not just the worker. */
178
- minimum_resource_retention_days?: number;
179
- outcome: {
180
- status: 'available' | 'delivered';
181
- resource: NonNullable<ReportingMaterialization['resource']>;
182
- verification: NonNullable<ReportingMaterialization['verification']>;
183
- } | {
184
- status: 'failed';
185
- failure_code: string;
186
- };
187
- }): Promise<boolean>;
188
- claimRevocation(input: {
189
- owner: string;
190
- now: string;
191
- lease_milliseconds: number;
192
- account_id?: string;
193
- authorization_revocation_seconds?: number;
194
- steal_after_milliseconds?: number;
195
- }): Promise<ReportingDestinationRevocationLeaseV1 | null>;
196
- completeRevocation(input: {
197
- lease: ReportingDestinationRevocationLeaseV1;
198
- completed_at: string;
199
- }): Promise<boolean>;
200
- releaseRevocation(input: {
201
- lease: ReportingDestinationRevocationLeaseV1;
202
- backoff_milliseconds?: number;
203
- }): Promise<boolean>;
204
- getReadableResource(input: {
205
- account_id: string;
206
- resource_ref: string;
207
- }): Promise<{
208
- materialization: {
209
- reporting_materialization_id: string;
210
- reporting_revision_id: string;
211
- reporting_obligation_id: string;
212
- delivery_config_id: string;
213
- delivery_config_version: number;
214
- destination_ref: string;
215
- feed_purpose: import("../../types/tools.generated.mjs").ReportingFeedPurpose;
216
- method: "file_transfer" | "dataset_share" | "warehouse_materialization";
217
- transport?: string;
218
- attempt: number;
219
- status: "pending" | "available" | "delivered" | "failed";
220
- ready_at?: string;
221
- failed_at?: string;
222
- failure_code?: string;
223
- resource?: import("../../types/index.mjs").ReportingResource;
224
- verification?: import("../../types/index.mjs").ReportingVerification;
225
- created_at: string;
226
- };
227
- binding: ReportingManagedDeliveryBindingV1;
228
- } | null>;
229
- /** Freeze all writable names under the same locks as revokeDestination. */
230
- registerObjectWritePlan(input: ReportingObjectWritePlanV1, context?: ReportingObjectWriteContextV1): Promise<'registered' | 'unchanged' | 'revoked'>;
231
- listRevokedObjectWrites(inputScope: ReportingObjectWriteScopeV1, inputOptions?: {
232
- after?: ReportingObjectWriteCursorV1;
233
- limit?: number;
234
- }, context?: ReportingObjectWriteContextV1): Promise<Array<ReportingObjectWriteV1 & ReportingObjectWriteCursorV1>>;
235
- markObjectWriteFenced(input: ReportingObjectWriteScopeV1 & ReportingObjectWriteCursorV1 & {
236
- tombstone_generation: string;
237
- }, context?: ReportingObjectWriteContextV1): Promise<void>;
238
- getObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
239
- probeObjectWriteAuthority(context?: ReportingObjectWriteContextV1): Promise<boolean>;
240
- getObjectWriteAuthorityId(context?: ReportingObjectWriteContextV1): Promise<string>;
241
- getAuthorizedObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
242
- getObjectWritePlan(input: ReportingObjectWriteScopeV1, planId: string, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWritePlanV1 | null>;
243
- /**
244
- * Generations that carry no recorded pattern/transport, with why the
245
- * migration backfill could not infer them. These are routed to a router's
246
- * `legacyDefault` (or fail revocation with a typed error) until the host
247
- * supplies the contract. Read-only; it never edits a row.
248
- *
249
- * `no_binding`: nothing to infer from. `binding_without_transport`: at least
250
- * one binding names no transport. `bindings_disagree`: the bindings name
251
- * different methods or transports. `not_recorded`: the bindings agree, but
252
- * the generation was created without a contract after the one-time backfill
253
- * ran, so nothing records it.
254
- */
255
- listDestinationAuthorizationsWithoutContract(input?: {
256
- account_id?: string;
257
- limit?: number;
258
- }): Promise<Array<{
259
- account_id: string;
260
- destination_ref: string;
261
- generation: number;
262
- reason: 'no_binding' | 'binding_without_transport' | 'bindings_disagree' | 'not_recorded';
263
- }>>;
264
- isAuthorizationCurrent(input: {
265
- account_id: string;
266
- destination_ref: string;
267
- generation: number;
268
- }): Promise<boolean>;
269
- syncReceiptBatch(input: ReportingReceiptBatchInputV1): Promise<SyncReportingReceiptsResponse['results']>;
270
- /**
271
- * Rebuilds a prior batch response from the compact replay record plus the
272
- * append-only receipt rows, re-checking authorization exactly as the first
273
- * call did so a revoked destination cannot be replayed back into disclosure.
274
- */
275
- /**
276
- * Replays a prior batch response exactly.
277
- *
278
- * An exact same-key replay is side-effect free and returns the caller its own
279
- * previously recorded verdict, so later revocation of the destination does
280
- * not change it. Downgrading a replay to `failed` once authorization ended
281
- * broke the protocol-wide rule that a replayed idempotency key returns the
282
- * same response, and bought nothing: the body is the caller's own receipt
283
- * echoed back with the verdict it already received, so a revoked caller
284
- * learns nothing it did not already hold. Fail-closed still governs every
285
- * path that *accepts* new evidence — `loadReceiptEvidence` joins
286
- * `revoked_at IS NULL` — and nothing here reads another consumer's rows.
287
- */
288
- private replayReceiptBatch;
289
- private recordReceipt;
290
- private loadReceiptEvidence;
291
- private transaction;
292
- private query;
293
- }
@@ -1,293 +0,0 @@
1
- import type { ReportingMaterialization, SyncReportingReceiptsResponse } from '../../types';
2
- import type { ReportingPgPool } from './postgres';
3
- import type { ReportingLedgerNotificationActivityPortV1, ReportingLedgerTransactionV1, ReportingManagedDeliveryBindingV1, ReportingLedgerStore } from './types';
4
- import { type ReportingObjectWritePlanV1, type ReportingObjectWriteScopeV1, type ReportingObjectWriteCursorV1, type ReportingObjectWriteV1, type ReportingObjectWriteBindingV1, type ReportingObjectWriteContextV1, type ReportingObjectWriteStoreV1, type ReportingObjectWriteAuthorityStoreV1 } from './object-writes';
5
- import { type ReportingDestinationAuthorizationV1, type ReportingDestinationRevocationLeaseV1, type ReportingManagedDeliveryLeaseV1, type ReportingManagedDeliveryAdvertisedPoliciesV1, type ReportingManagedDeliveryStore, type ReportingReceiptBatchInputV1 } from './managed';
6
- /**
7
- * Additive migration owned by #2944. It intentionally does not alter the Core
8
- * tables so the #2943 notification/activity bridge can evolve that schema
9
- * independently. Apply after REPORTING_LEDGER_MIGRATION in the same schema.
10
- *
11
- * @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
12
- */
13
- export declare const REPORTING_MANAGED_DELIVERY_MIGRATION: string;
14
- /**
15
- * @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
16
- */
17
- export interface PostgresReportingManagedDeliveryStoreOptions {
18
- /** Transactional reporting outbox used for successful delivery-ready events. */
19
- notificationActivityPort?: ReportingLedgerNotificationActivityPortV1<ReportingLedgerTransactionV1>;
20
- /**
21
- * The `automated_recovery_window_seconds` this deployment advertises.
22
- *
23
- * The capability is agent-wide and immutable once published, while bindings
24
- * arrive over time, so validating only at startup leaves the window open:
25
- * an agent advertising 60s starts clean and a 900s binding installed an hour
26
- * later silently makes the published promise false until the next restart.
27
- * Set here, `installBinding` refuses any Core configuration whose recovery
28
- * window exceeds the advertised bound, inside the same transaction that
29
- * checks binding eligibility. `createReportingManagedDeliveryRuntime` adopts
30
- * its own advertised value into the store at wiring time, so setting it
31
- * explicitly is only needed when bindings are installed without a runtime.
32
- */
33
- advertisedRecoveryWindowSeconds?: number;
34
- /**
35
- * The `status_retention_days` this deployment advertises.
36
- *
37
- * Supply it together with `evidenceRetentionDays` so the store can refuse a
38
- * retention shorter than a horizon you have already promised. Pruning
39
- * evidence the capability document still says is queryable is a broken
40
- * promise, not a capacity optimisation.
41
- */
42
- statusRetentionDays?: number;
43
- /**
44
- * Days of managed evidence an account is still accountable for.
45
- *
46
- * MAX_MATERIALIZATIONS_PER_ACCOUNT and MAX_RECEIPTS_PER_CONSUMER are
47
- * lifetime counts. Left unbounded they are a one-way door: a long-lived
48
- * account eventually reaches them and then stops planning materializations
49
- * and refuses every receipt, permanently, with no operator-visible way back
50
- * — evidence is immutable, so nothing ever frees capacity.
51
- *
52
- * Setting this makes the caps active-scope: only evidence recorded inside
53
- * the window counts against them, and `pruneExpiredEvidence` can delete what
54
- * falls outside it. Choose a value at least as long as the
55
- * `status_retention_days` you advertise, since that is the period you
56
- * promised the metadata stays queryable. Omit it to keep the previous
57
- * lifetime accounting with no pruning.
58
- */
59
- evidenceRetentionDays?: number;
60
- }
61
- /**
62
- * @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
63
- */
64
- export declare class PostgresReportingManagedDeliveryStore implements ReportingManagedDeliveryStore, ReportingObjectWriteStoreV1, ReportingObjectWriteAuthorityStoreV1 {
65
- private readonly pool;
66
- private readonly evidenceRetentionDays;
67
- private readonly statusRetentionDays;
68
- private readonly pendingRecoveryWindowSeconds;
69
- private policyRegistered;
70
- private bindingAdmission;
71
- private readonly notificationActivityPort?;
72
- /**
73
- * Durably records the agent-wide advertised recovery window.
74
- *
75
- * Written to the database, not held in memory: the promise is agent-wide,
76
- * so a second store instance — in this process or another replica — must be
77
- * held to the same value, and `installBinding` must read it inside its own
78
- * transaction rather than trusting whatever the local object happens to
79
- * know. Multiple replicas monotonically retain the smallest registered
80
- * maximum: a shorter recovery promise is stronger and can never be widened
81
- * by a later runtime.
82
- */
83
- adoptAdvertisedRecoveryWindowSeconds(seconds: number): Promise<void>;
84
- /**
85
- * Durably records the advertised `status_retention_days`.
86
- *
87
- * Retention is enforced against the widest promise any runtime registered
88
- * over this database, so a store configured with a short evidence retention
89
- * cannot prune inside a horizon a differently configured runtime published.
90
- */
91
- adoptAdvertisedStatusRetentionDays(days: number): Promise<void>;
92
- /** Registers the complete capability policy under one lock and transaction. */
93
- adoptAdvertisedPolicies(policy: ReportingManagedDeliveryAdvertisedPoliciesV1): Promise<ReportingManagedDeliveryAdvertisedPoliciesV1>;
94
- /**
95
- * Flushes constructor-supplied promises into the durable registry.
96
- *
97
- * Called from every entry point that depends on them, so a store built with
98
- * options behaves identically to one a runtime adopted into.
99
- */
100
- private ensurePolicyRegistered;
101
- private upsertPolicy;
102
- private upsertPolicies;
103
- private validateRecoveryWindow;
104
- private readPolicyRow;
105
- private readPolicy;
106
- /** Read-only access to PostgreSQL row chunks for claim hydration. */
107
- private readonly rowStorage;
108
- constructor(pool: ReportingPgPool, options?: PostgresReportingManagedDeliveryStoreOptions);
109
- /** SQL fragment scoping a count to the active retention window, if one is set. */
110
- private activeScope;
111
- /**
112
- * Deletes managed evidence that has aged out of `evidenceRetentionDays`.
113
- *
114
- * Only ever removes evidence the deployment no longer promises: nothing
115
- * inside the retention window, nothing still `pending` or leased, and no
116
- * receipt batch inside its own replay retention. Immutable evidence stays
117
- * immutable while it is retained — this frees capacity at the far end of the
118
- * window rather than rewriting anything. Returns what it removed so a
119
- * scheduler can page through with `limit`.
120
- */
121
- pruneExpiredEvidence(input: {
122
- account_id: string;
123
- limit?: number;
124
- }): Promise<{
125
- materializations: number;
126
- receipts: number;
127
- batches: number;
128
- }>;
129
- probe(coreStore: ReportingLedgerStore): Promise<boolean>;
130
- listInstalledRecoveryWindowSeconds(): Promise<number[]>;
131
- authorizeDestination(input: Omit<ReportingDestinationAuthorizationV1, 'revoked_at' | 'cleanup_completed_at'>): Promise<void>;
132
- revokeDestination(input: {
133
- account_id: string;
134
- destination_ref: string;
135
- generation: number;
136
- revoked_at: string;
137
- }): Promise<boolean>;
138
- setBindingAdmission(admit: ((binding: ReportingManagedDeliveryBindingV1) => void) | undefined): void;
139
- installBinding(binding: ReportingManagedDeliveryBindingV1): Promise<{
140
- inserted: boolean;
141
- }>;
142
- planMaterializations(input?: {
143
- account_id?: string;
144
- limit?: number;
145
- }): Promise<number>;
146
- /**
147
- * Claims a bounded, durable round-robin page of accounts that currently
148
- * have at least one materialization candidate.
149
- *
150
- * The policy row serializes only the final cursor compare-and-set. Eligible
151
- * account discovery runs without that global lock so retained revision
152
- * history cannot block materialization settlement or revocation. The cursor
153
- * advances before provider work; a crash may defer a selected account until
154
- * the ring wraps, but can never pin every future sweep behind it.
155
- */
156
- private claimMaterializationPlanningAccounts;
157
- claimMaterialization(input: {
158
- owner: string;
159
- now: string;
160
- lease_milliseconds: number;
161
- account_id?: string;
162
- }): Promise<ReportingManagedDeliveryLeaseV1 | null>;
163
- /**
164
- * Fails materializations that have used every delivery attempt.
165
- *
166
- * The claim predicate stops handing them out, so without this they would
167
- * stay `pending` — invisible to the planner, which skips an obligation with
168
- * any pending row, and so never retried or replanned.
169
- */
170
- failExhaustedMaterializations(input?: {
171
- account_id?: string;
172
- limit?: number;
173
- }): Promise<number>;
174
- settleMaterialization(input: {
175
- lease: ReportingManagedDeliveryLeaseV1;
176
- now: string;
177
- /** Retention the database must see satisfied, not just the worker. */
178
- minimum_resource_retention_days?: number;
179
- outcome: {
180
- status: 'available' | 'delivered';
181
- resource: NonNullable<ReportingMaterialization['resource']>;
182
- verification: NonNullable<ReportingMaterialization['verification']>;
183
- } | {
184
- status: 'failed';
185
- failure_code: string;
186
- };
187
- }): Promise<boolean>;
188
- claimRevocation(input: {
189
- owner: string;
190
- now: string;
191
- lease_milliseconds: number;
192
- account_id?: string;
193
- authorization_revocation_seconds?: number;
194
- steal_after_milliseconds?: number;
195
- }): Promise<ReportingDestinationRevocationLeaseV1 | null>;
196
- completeRevocation(input: {
197
- lease: ReportingDestinationRevocationLeaseV1;
198
- completed_at: string;
199
- }): Promise<boolean>;
200
- releaseRevocation(input: {
201
- lease: ReportingDestinationRevocationLeaseV1;
202
- backoff_milliseconds?: number;
203
- }): Promise<boolean>;
204
- getReadableResource(input: {
205
- account_id: string;
206
- resource_ref: string;
207
- }): Promise<{
208
- materialization: {
209
- reporting_materialization_id: string;
210
- reporting_revision_id: string;
211
- reporting_obligation_id: string;
212
- delivery_config_id: string;
213
- delivery_config_version: number;
214
- destination_ref: string;
215
- feed_purpose: import("../../types/tools.generated").ReportingFeedPurpose;
216
- method: "file_transfer" | "dataset_share" | "warehouse_materialization";
217
- transport?: string;
218
- attempt: number;
219
- status: "pending" | "available" | "delivered" | "failed";
220
- ready_at?: string;
221
- failed_at?: string;
222
- failure_code?: string;
223
- resource?: import("../../types").ReportingResource;
224
- verification?: import("../../types").ReportingVerification;
225
- created_at: string;
226
- };
227
- binding: ReportingManagedDeliveryBindingV1;
228
- } | null>;
229
- /** Freeze all writable names under the same locks as revokeDestination. */
230
- registerObjectWritePlan(input: ReportingObjectWritePlanV1, context?: ReportingObjectWriteContextV1): Promise<'registered' | 'unchanged' | 'revoked'>;
231
- listRevokedObjectWrites(inputScope: ReportingObjectWriteScopeV1, inputOptions?: {
232
- after?: ReportingObjectWriteCursorV1;
233
- limit?: number;
234
- }, context?: ReportingObjectWriteContextV1): Promise<Array<ReportingObjectWriteV1 & ReportingObjectWriteCursorV1>>;
235
- markObjectWriteFenced(input: ReportingObjectWriteScopeV1 & ReportingObjectWriteCursorV1 & {
236
- tombstone_generation: string;
237
- }, context?: ReportingObjectWriteContextV1): Promise<void>;
238
- getObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
239
- probeObjectWriteAuthority(context?: ReportingObjectWriteContextV1): Promise<boolean>;
240
- getObjectWriteAuthorityId(context?: ReportingObjectWriteContextV1): Promise<string>;
241
- getAuthorizedObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
242
- getObjectWritePlan(input: ReportingObjectWriteScopeV1, planId: string, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWritePlanV1 | null>;
243
- /**
244
- * Generations that carry no recorded pattern/transport, with why the
245
- * migration backfill could not infer them. These are routed to a router's
246
- * `legacyDefault` (or fail revocation with a typed error) until the host
247
- * supplies the contract. Read-only; it never edits a row.
248
- *
249
- * `no_binding`: nothing to infer from. `binding_without_transport`: at least
250
- * one binding names no transport. `bindings_disagree`: the bindings name
251
- * different methods or transports. `not_recorded`: the bindings agree, but
252
- * the generation was created without a contract after the one-time backfill
253
- * ran, so nothing records it.
254
- */
255
- listDestinationAuthorizationsWithoutContract(input?: {
256
- account_id?: string;
257
- limit?: number;
258
- }): Promise<Array<{
259
- account_id: string;
260
- destination_ref: string;
261
- generation: number;
262
- reason: 'no_binding' | 'binding_without_transport' | 'bindings_disagree' | 'not_recorded';
263
- }>>;
264
- isAuthorizationCurrent(input: {
265
- account_id: string;
266
- destination_ref: string;
267
- generation: number;
268
- }): Promise<boolean>;
269
- syncReceiptBatch(input: ReportingReceiptBatchInputV1): Promise<SyncReportingReceiptsResponse['results']>;
270
- /**
271
- * Rebuilds a prior batch response from the compact replay record plus the
272
- * append-only receipt rows, re-checking authorization exactly as the first
273
- * call did so a revoked destination cannot be replayed back into disclosure.
274
- */
275
- /**
276
- * Replays a prior batch response exactly.
277
- *
278
- * An exact same-key replay is side-effect free and returns the caller its own
279
- * previously recorded verdict, so later revocation of the destination does
280
- * not change it. Downgrading a replay to `failed` once authorization ended
281
- * broke the protocol-wide rule that a replayed idempotency key returns the
282
- * same response, and bought nothing: the body is the caller's own receipt
283
- * echoed back with the verdict it already received, so a revoked caller
284
- * learns nothing it did not already hold. Fail-closed still governs every
285
- * path that *accepts* new evidence — `loadReceiptEvidence` joins
286
- * `revoked_at IS NULL` — and nothing here reads another consumer's rows.
287
- */
288
- private replayReceiptBatch;
289
- private recordReceipt;
290
- private loadReceiptEvidence;
291
- private transaction;
292
- private query;
293
- }