@greatwait/contracts 0.1.0-alpha.4 → 0.1.0-alpha.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 (84) hide show
  1. package/README.md +1 -1
  2. package/dist/billing.d.ts +231 -1
  3. package/dist/billing.js +150 -1
  4. package/dist/callback-safety.js +13 -3
  5. package/dist/configuration-bounds.d.ts +13 -0
  6. package/dist/configuration-bounds.js +13 -0
  7. package/dist/effective-limits.d.ts +40 -0
  8. package/dist/effective-limits.js +42 -0
  9. package/dist/endpoints.d.ts +5 -5
  10. package/dist/endpoints.js +5 -5
  11. package/dist/first-value-journey.d.ts +1 -1
  12. package/dist/first-value-journey.js +11 -7
  13. package/dist/forecast.d.ts +111 -21
  14. package/dist/forecast.js +87 -24
  15. package/dist/index.d.ts +5 -4
  16. package/dist/index.js +5 -4
  17. package/dist/mcp.js +1 -1
  18. package/dist/operational-config.d.ts +101 -0
  19. package/dist/operational-config.js +341 -0
  20. package/dist/operations.d.ts +597 -16
  21. package/dist/operations.js +384 -23
  22. package/dist/partition.d.ts +17 -9
  23. package/dist/partition.js +3 -3
  24. package/dist/problems.d.ts +25 -2
  25. package/dist/problems.js +49 -1
  26. package/dist/protocol.d.ts +5 -5
  27. package/dist/protocol.js +2 -1
  28. package/dist/scheduling-records.d.ts +6 -0
  29. package/dist/scheduling.d.ts +37 -1
  30. package/dist/scheduling.js +60 -4
  31. package/dist/usage.js +6 -21
  32. package/generated/v1/examples/attempts.list.response.json +2 -0
  33. package/generated/v1/examples/attempts.read.response.json +2 -0
  34. package/generated/v1/examples/billing.fundingconfirm.response.json +120 -0
  35. package/generated/v1/examples/billing.invoicehistory.response.json +6 -0
  36. package/generated/v1/examples/billing.invoices.response.json +15 -0
  37. package/generated/v1/examples/billing.paymenthistory.response.json +6 -0
  38. package/generated/v1/examples/billing.paymentmethod.response.json +16 -0
  39. package/generated/v1/examples/billing.paymentmethodconfirm.request.json +3 -0
  40. package/generated/v1/examples/billing.paymentmethodconfirm.response.json +16 -0
  41. package/generated/v1/examples/billing.paymentmethodremove.request.json +3 -0
  42. package/generated/v1/examples/billing.paymentmethodremove.response.json +4 -0
  43. package/generated/v1/examples/billing.paymentmethodsetup.request.json +1 -0
  44. package/generated/v1/examples/billing.paymentmethodsetup.response.json +3 -0
  45. package/generated/v1/examples/limits.read.response.json +16 -0
  46. package/generated/v1/examples/occurrences.redeliver.response.json +2 -0
  47. package/generated/v1/first-value-journey.json +24 -8
  48. package/generated/v1/manifest.json +342 -10
  49. package/generated/v1/openapi.json +12395 -6543
  50. package/generated/v1/policy-matrix.json +65 -2
  51. package/generated/v1/schemas/attempts.list.response.json +15 -0
  52. package/generated/v1/schemas/attempts.read.response.json +15 -0
  53. package/generated/v1/schemas/billing.fundingconfirm.response.json +552 -0
  54. package/generated/v1/schemas/billing.invoicehistory.query.json +16 -0
  55. package/generated/v1/schemas/billing.invoicehistory.response.json +88 -0
  56. package/generated/v1/schemas/billing.invoices.response.json +51 -0
  57. package/generated/v1/schemas/billing.ledger.response.json +5 -0
  58. package/generated/v1/schemas/billing.notificationsettingsupdate.request.json +24 -17
  59. package/generated/v1/schemas/billing.paymenthistory.query.json +16 -0
  60. package/generated/v1/schemas/billing.paymenthistory.response.json +182 -0
  61. package/generated/v1/schemas/billing.paymentmethod.response.json +137 -0
  62. package/generated/v1/schemas/billing.paymentmethodconfirm.request.json +14 -0
  63. package/generated/v1/schemas/billing.paymentmethodconfirm.response.json +137 -0
  64. package/generated/v1/schemas/billing.paymentmethodremove.request.json +12 -0
  65. package/generated/v1/schemas/billing.paymentmethodremove.response.json +137 -0
  66. package/generated/v1/schemas/billing.paymentmethodsetup.request.json +12 -0
  67. package/generated/v1/schemas/billing.paymentmethodsetup.response.json +11 -0
  68. package/generated/v1/schemas/billing.purchase.request.json +4 -0
  69. package/generated/v1/schemas/forecast.read.request-headers.json +10 -0
  70. package/generated/v1/schemas/forecast.read.response.json +148 -0
  71. package/generated/v1/schemas/limits.read.response.json +79 -0
  72. package/generated/v1/schemas/occurrences.redeliver.response.json +15 -0
  73. package/generated/v1/snippets/billing.fundingconfirm.json +6 -0
  74. package/generated/v1/snippets/billing.invoicehistory.json +6 -0
  75. package/generated/v1/snippets/billing.invoices.json +6 -0
  76. package/generated/v1/snippets/billing.notificationsettingsupdate.json +1 -1
  77. package/generated/v1/snippets/billing.paymenthistory.json +6 -0
  78. package/generated/v1/snippets/billing.paymentmethod.json +6 -0
  79. package/generated/v1/snippets/billing.paymentmethodconfirm.json +6 -0
  80. package/generated/v1/snippets/billing.paymentmethodremove.json +6 -0
  81. package/generated/v1/snippets/billing.paymentmethodsetup.json +6 -0
  82. package/generated/v1/snippets/forecast.windows.json +1 -1
  83. package/generated/v1/snippets/limits.read.json +6 -0
  84. package/package.json +7 -2
@@ -1,13 +1,14 @@
1
+ import { effectiveCustomerLimitsSchema } from "./effective-limits.js";
1
2
  import { z } from "./zod.js";
2
3
  import { DATA_EXPORT_OPERATIONS } from "./data-export.js";
3
4
  import { ORGANIZATION_LIFECYCLE_OPERATIONS } from "./organization-lifecycle.js";
4
5
  import { API_UNUSED_RESPONSE_SCHEMA } from "./operation-definitions.js";
5
6
  import { credentialContextSchema } from "./authority.js";
6
7
  import { callbackEndpointCreatedSchema, callbackEndpointPageSchema, callbackEndpointRequestSchema, callbackEndpointRotatedSchema, callbackEndpointSchema, callbackEndpointSigningSecretsSchema, callbackSigningKeyRotationRequestSchema, } from "./endpoints.js";
7
- import { FORECAST_WINDOW_VERSION, forecastRequestSchema, forecastSchema, forecastWindowsSchema, } from "./forecast.js";
8
+ import { FORECAST_WINDOW_VERSION, forecastRequestSchema, forecastSchema, forecastRequestHeadersSchema, forecastWindowsSchema, } from "./forecast.js";
8
9
  import { usageRequestSchema, usageSchema } from "./usage.js";
9
10
  import { deliveryTimingSummarySchema } from "./timing.js";
10
- import { billingAutoTopUpApplyRequestSchema, billingAutoTopUpPreviewRequestSchema, billingAutoTopUpPreviewSchema, billingCeilingUpdateRequestSchema, billingFundingQuoteRequestSchema, billingFundingQuoteSchema, billingFundingViewSchema, billingNoticePageSchema, billingNotificationSettingsSchema, billingNotificationSettingsUpdateRequestSchema, billingLedgerPageSchema, billingLedgerRequestSchema, billingBudgetUpdateRequestHeadersSchema, billingBudgetUpdateRequestSchema, billingBudgetUpdateResponseSchema, billingPurchaseRequestSchema, billingRefundRequestCreateSchema, billingRefundResolutionRequestSchema, billingRefundRequestViewSchema, billingSummarySchema, projectBillingStateSchema, projectBillingQuoteSchema, projectBillingQuoteRequestSchema, projectBillingChangeRequestSchema, billingPortalSchema, } from "./billing.js";
11
+ import { billingAutoTopUpApplyRequestSchema, billingAutoTopUpPreviewRequestSchema, billingAutoTopUpPreviewSchema, billingCeilingUpdateRequestSchema, billingFundingQuoteRequestSchema, billingFundingQuoteSchema, billingFundingViewSchema, billingNoticePageSchema, billingNotificationSettingsSchema, billingNotificationSettingsUpdateRequestSchema, billingLedgerPageSchema, billingLedgerRequestSchema, billingBudgetUpdateRequestHeadersSchema, billingBudgetUpdateRequestSchema, billingBudgetUpdateResponseSchema, billingPurchaseRequestSchema, billingRefundRequestCreateSchema, billingRefundResolutionRequestSchema, billingRefundRequestViewSchema, billingSummarySchema, projectBillingStateSchema, projectBillingQuoteSchema, projectBillingQuoteRequestSchema, projectBillingChangeRequestSchema, billingPortalSchema, billingInvoiceListSchema, billingPaymentHistoryPageSchema, billingInvoiceHistoryPageSchema, billingPaymentMethodSchema, billingPaymentMethodSetupRequestSchema, billingPaymentMethodConfirmRequestSchema, billingPaymentMethodRemoveRequestSchema, } from "./billing.js";
11
12
  import { conditionalRequestHeaderSchema, idempotencyReplayResponseHeaderSchema, idempotencyRequestHeaderSchema, historyPageRequestSchema, pageRequestSchema, scheduleListRequestSchema, replayedResponseHeaderSchema, requiredConditionalRequestHeaderSchema, requiredIdempotencyRequestHeaderSchema, versionResponseHeaderSchema, } from "./protocol.js";
12
13
  import { oauthGrantListSchema, oauthGrantRevokedSchema } from "./oauth.js";
13
14
  import { credentialCreatedSchema, credentialPageSchema, credentialRequestSchema, credentialRevokedSchema, credentialRotatedSchema, credentialRotationRequestSchema, } from "./secrets.js";
@@ -299,7 +300,7 @@ const BILLING_NOTIFICATION_SETTINGS_OPERATION = {
299
300
  creates: false,
300
301
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
301
302
  ? ""
302
- : "Reads the USD 2.00 default low-credit threshold and optional-email choice. Critical email remains mandatory for owners and active billing-role members; addresses and contact management are absent.",
303
+ : "Reads the low-credit threshold in effect and the optional-email choice. Unless a threshold was chosen, it is one fifth of the organization's most recent credit purchase or grant, rounded down to a whole cent, and zero before any credit was granted. Critical email remains mandatory for owners and active billing-role members; addresses and contact management are absent.",
303
304
  example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
304
305
  ? {}
305
306
  : BILLING_NOTIFICATION_SETTINGS_EXAMPLE,
@@ -325,7 +326,7 @@ const BILLING_NOTIFICATION_SETTINGS_UPDATE_OPERATION = {
325
326
  creates: false,
326
327
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
327
328
  ? ""
328
- : "Replaces the low-credit threshold and noncritical email choice at an expected revision. Critical email stays mandatory; idempotent retries converge and agents require explicit approval.",
329
+ : "Replaces the low-credit threshold and noncritical email choice at an expected revision. A null threshold returns to the default of one fifth of the most recent credit purchase or grant; an omitted threshold is left exactly as it is. Critical email stays mandatory; idempotent retries converge and agents require explicit approval.",
329
330
  environments: ["live"],
330
331
  example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
331
332
  ? {}
@@ -469,6 +470,60 @@ const BILLING_AUTO_TOP_UP_APPLY_OPERATION = withBillingFundingContract({
469
470
  surfaces: ["api", "mock"],
470
471
  });
471
472
  export const OPERATIONS = [
473
+ {
474
+ creates: false,
475
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
476
+ ? ""
477
+ : "Read the verified organization's execution-credit payments with bounded cursor continuation. Existing recent-history responses remain compatible.",
478
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
479
+ ? {}
480
+ : { data: [], freshness: { kind: "authoritative" } },
481
+ id: "billing.paymenthistory",
482
+ idempotent: true,
483
+ mcp: { destructive: false, kind: "tool", openWorld: false },
484
+ method: "GET",
485
+ mutates: false,
486
+ path: "/v1/billing/payment-history",
487
+ principals: ["api-credential", "oauth", "session"],
488
+ problems: ["invalid_request", "service_unavailable"],
489
+ query: pageRequestSchema,
490
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
491
+ ? API_UNUSED_RESPONSE_SCHEMA
492
+ : billingPaymentHistoryPageSchema,
493
+ scopes: ["usage:read"],
494
+ sessionAuthority: "headers",
495
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
496
+ ? ""
497
+ : "Page execution-credit payments",
498
+ surfaces: ["api", "mock"],
499
+ },
500
+ {
501
+ creates: false,
502
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
503
+ ? ""
504
+ : "Read the verified organization's project subscription invoices with bounded cursor continuation. Existing recent-history responses remain compatible.",
505
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
506
+ ? {}
507
+ : { data: [], freshness: { kind: "authoritative" } },
508
+ id: "billing.invoicehistory",
509
+ idempotent: true,
510
+ mcp: { destructive: false, kind: "tool", openWorld: false },
511
+ method: "GET",
512
+ mutates: false,
513
+ path: "/v1/billing/invoice-history",
514
+ principals: ["api-credential", "oauth", "session"],
515
+ problems: ["invalid_request", "service_unavailable"],
516
+ query: pageRequestSchema,
517
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
518
+ ? API_UNUSED_RESPONSE_SCHEMA
519
+ : billingInvoiceHistoryPageSchema,
520
+ scopes: ["usage:read"],
521
+ sessionAuthority: "headers",
522
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
523
+ ? ""
524
+ : "Page project subscription invoices",
525
+ surfaces: ["api", "mock"],
526
+ },
472
527
  ...DATA_EXPORT_OPERATIONS,
473
528
  ...ORGANIZATION_LIFECYCLE_OPERATIONS,
474
529
  {
@@ -604,7 +659,7 @@ export const OPERATIONS = [
604
659
  creates: true,
605
660
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
606
661
  ? ""
607
- : "Creates a reusable callback endpoint in the caller's project and environment. The destination must be HTTPS on effective port 443, contain no URL credentials or fragment, and resolve only to public unicast addresses. The endpoint is active and usable the moment it exists; there is nothing to verify. A disabled endpoint is never delivered to, and a schedule write naming one answers not_found, because disabling is terminal rather than a state to recover from. The per-endpoint secret is returned in this response and nowhere else. The 50-record safety ceiling includes disabled endpoints because they remain readable for audit.",
662
+ : "Creates a reusable callback endpoint in the caller's project and environment. The destination must be HTTPS on effective port 443, contain no URL credentials or fragment, and resolve only to public unicast addresses. The endpoint is active and usable the moment it exists; there is nothing to verify. A disabled endpoint is never delivered to, and a schedule write naming one answers not_found, because disabling is terminal rather than a state to recover from. The per-endpoint secret is returned to this call and to no other call an API credential or an OAuth token can make; a signed-in member can read it again through endpoints.revealSigningSecret. There is no endpoint-count ceiling. Disabled endpoints remain readable for audit; request and DNS inspection admission bound creation work and reads are paged.",
608
663
  example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
609
664
  ? {}
610
665
  : {
@@ -792,7 +847,7 @@ export const OPERATIONS = [
792
847
  creates: true,
793
848
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
794
849
  ? ""
795
- : "Creates the next endpoint signing key and selects it immediately for new deliveries while retaining the current key in the receiver acceptance set for a bounded overlap. The overlap defaults to and cannot exceed 24 hours. A second rotation is refused until the current overlap ends. The new secret is returned once and has no recovery operation, so a call whose answer was never read may have rotated a key nobody holds: read the endpoint and compare its signing keys before repeating one. Send If-Match with the version the endpoint was read at to be refused rather than rotate an endpoint that has changed since.",
850
+ : "Creates the next endpoint signing key and selects it immediately for new deliveries while retaining the current key in the receiver acceptance set for a bounded overlap. The overlap defaults to and cannot exceed 24 hours. A second rotation is refused until the current overlap ends. The new secret is returned once to this call, so a call whose answer was never read has rotated a key the caller does not hold. It is recoverable: a signed-in member can read both keys, and the instant the overlap ends, through endpoints.revealSigningSecret. An API credential or an OAuth token cannot, so an integration that loses the answer needs a member to read it back rather than a second rotation, which is refused until the overlap ends. Send If-Match with the version the endpoint was read at to be refused rather than rotate an endpoint that has changed since.",
796
851
  example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
797
852
  ? {}
798
853
  : {
@@ -2083,10 +2138,11 @@ export const OPERATIONS = [
2083
2138
  "not_found",
2084
2139
  // The organization ceiling, the same code and the same shape
2085
2140
  // `projects.create` and `endpoints.create` use. A plan may bound the
2086
- // live schedules an organization holds, the distinct partition keys it
2087
- // has live, and how large a `data` body it may carry; all three refuse
2088
- // here rather than truncating, because a schedule created without the
2089
- // body the caller sent is not the schedule they asked for.
2141
+ // distinct partition keys an organization has live and how large a
2142
+ // `data` body it may carry; both refuse here rather than truncating,
2143
+ // because a schedule created without the body the caller sent is not
2144
+ // the schedule they asked for. How many schedules an organization holds
2145
+ // is not bounded (FXO-2556).
2090
2146
  "plan_limit_reached",
2091
2147
  "service_unavailable",
2092
2148
  // A schedule against a disabled endpoint. Refused rather than accepted
@@ -2230,7 +2286,7 @@ export const OPERATIONS = [
2230
2286
  creates: false,
2231
2287
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2232
2288
  ? ""
2233
- : "Counts the occurrences this project and environment expect to fire, in epoch-aligned time buckets, with a latency-class split on every bucket and an optional customer partition-key breakdown. A recurring series contributes every instant it fires inside the window rather than only its next one, and `nextFireCount` reports how many of a bucket's occurrences are a schedule's next firing. The answer states its own freshness and is refused rather than shortened when a partition cannot complete it. It carries counts only: no schedule identifier, callback destination, payload or endpoint detail has a field in the response.",
2289
+ : "Counts the occurrences this project and environment expect to fire, in epoch-aligned time buckets, with a latency-class split on every bucket and an optional customer partition-key breakdown. A recurring series contributes every instant it fires inside the window rather than only its next one, and `nextFireCount` reports how many of a bucket's occurrences are a schedule's next firing. The answer states freshness and explicit coverage. Clients sending X-Greatwait-Accept-Partial-Forecast: true receive bounded lower-bound counts when a book reaches a row, cell or recurrence-work bound, with coverage.complete false and the exact bounds reached. Without this capability header the previous refusal behavior remains safe for clients that only read totals. Unavailable or stale sources still refuse. Coverage identifies the selected recurring schedule range but never includes destinations, payload or endpoint detail.",
2234
2290
  example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2235
2291
  ? {}
2236
2292
  : {
@@ -2255,6 +2311,7 @@ export const OPERATIONS = [
2255
2311
  to: "2026-07-29T15:00:00.000Z",
2256
2312
  },
2257
2313
  },
2314
+ requestHeaders: forecastRequestHeadersSchema,
2258
2315
  id: "forecast.read",
2259
2316
  idempotent: true,
2260
2317
  mcp: { destructive: false, kind: "tool", openWorld: false },
@@ -2278,7 +2335,7 @@ export const OPERATIONS = [
2278
2335
  creates: false,
2279
2336
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2280
2337
  ? ""
2281
- : "Reads the verified principal's organization-wide prepaid execution position from the authoritative PostgreSQL ledger. Desired and effective revisions remain distinct, and pending stays true until D1 records PostgreSQL confirmation. Amounts are exact integer microdollars encoded as decimal strings; currency is USD and scale is six. Reserved credit has already been committed to a logical attempt but is not yet a settled debit. A missing hard cap means the customer elected no execution spending cap, never zero room. Shadow mode records what enforcement would have done without charging or blocking, and the activation boundary prevents retroactive charges.",
2338
+ : "Reads the verified principal's organization-wide prepaid execution position from the authoritative PostgreSQL ledger. Desired and effective revisions remain distinct, and pending stays true until the control plane records PostgreSQL confirmation. Amounts are exact integer microdollars encoded as decimal strings; currency is USD and scale is six. Reserved credit has already been committed to a logical attempt but is not yet a settled debit. A missing hard cap means the customer elected no execution spending cap, never zero room. Shadow mode records what enforcement would have done without charging or blocking, and the activation boundary prevents retroactive charges.",
2282
2339
  example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2283
2340
  ? {}
2284
2341
  : BILLING_SUMMARY_EXAMPLE,
@@ -2289,7 +2346,7 @@ export const OPERATIONS = [
2289
2346
  mutates: false,
2290
2347
  path: "/v1/billing/summary",
2291
2348
  principals: ["api-credential", "oauth", "session"],
2292
- problems: [],
2349
+ problems: ["billing_not_ready", "service_unavailable"],
2293
2350
  response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2294
2351
  ? API_UNUSED_RESPONSE_SCHEMA
2295
2352
  : billingSummarySchema,
@@ -2405,6 +2462,32 @@ export const OPERATIONS = [
2405
2462
  : "Confirm manual execution funding",
2406
2463
  surfaces: ["api", "mock"],
2407
2464
  }),
2465
+ withBillingFundingContract({
2466
+ creates: false,
2467
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2468
+ ? ""
2469
+ : "Confirms one execution-credit payment or saved-payment-method setup now, typically when the customer returns from hosted Checkout, instead of waiting for the provider's notification or the scheduled repair. It reads that one operation from the payment provider under the caller organization's authenticated account and applies what the provider reports: a paid Checkout grants its exact credit once, an open or unpaid one stays pending, and an operation already settled is answered without reading the provider. Nothing in the request can claim a payment succeeded — it names only which operation to read. Repeating the call is safe and converges on the same state. Returns the same execution-funding position as billing.funding.",
2470
+ environments: ["live"],
2471
+ id: "billing.fundingconfirm",
2472
+ idempotent: true,
2473
+ mcp: { destructive: false, kind: "tool", openWorld: false },
2474
+ method: "POST",
2475
+ mutates: true,
2476
+ path: "/v1/billing/funding/{paymentOperation}/confirm",
2477
+ principals: ["api-credential", "oauth", "session"],
2478
+ problems: [
2479
+ "not_found",
2480
+ "service_unavailable",
2481
+ "state_conflict",
2482
+ "test_to_live_escalation",
2483
+ ],
2484
+ scopes: ["billing:write"],
2485
+ sessionAuthority: "headers",
2486
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2487
+ ? ""
2488
+ : "Confirm one payment with the provider now",
2489
+ surfaces: ["api", "mock"],
2490
+ }),
2408
2491
  withBillingFundingContract({
2409
2492
  creates: false,
2410
2493
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
@@ -2455,7 +2538,7 @@ export const OPERATIONS = [
2455
2538
  creates: true,
2456
2539
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2457
2540
  ? ""
2458
- : "Records an explicitly approved billing-owner request for operator review of unused purchased execution credit. It never submits a refund, cashes out credit or grants an MCP cash-out path; the Idempotency-Key preserves one request across retries. Trial credit has no cash value, provider submission remains an operator action, and any later refund does not restore automatic purchasing authority for the month.",
2541
+ : "Reserves unused purchased execution credit against one original payment, with the billing owner's explicit confirmation. Purchased credit is not refundable except where a charge is refunded because the service did not work as described, so this records no promise of a refund: it never calls Stripe, cashes out credit or grants an MCP cash-out path. A Stripe refund of that payment settles the reservation when it carries the same credit and supersedes it otherwise; the Idempotency-Key preserves one reservation across retries. Trial credit has no cash value, and a refund does not restore automatic purchasing authority used in the month.",
2459
2542
  environments: ["live"],
2460
2543
  example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2461
2544
  ? {}
@@ -2472,7 +2555,14 @@ export const OPERATIONS = [
2472
2555
  method: "POST",
2473
2556
  mutates: true,
2474
2557
  path: "/v1/billing/funding/refunds",
2475
- principals: ["api-credential", "oauth", "session"],
2558
+ // **No browser session** (W9-09). The dashboard's refund request and
2559
+ // refund review forms were an operator's procedure rendered on a customer's
2560
+ // home screen, and they are gone; refunds are a conversation with support.
2561
+ // The operation is unchanged for an API credential and OAuth — the CLI's
2562
+ // `billing refund-request` — and a session write nothing calls is an
2563
+ // authorization path nobody exercises, which `workspace-mutations.test.ts`
2564
+ // exists to refuse.
2565
+ principals: ["api-credential", "oauth"],
2476
2566
  problems: [
2477
2567
  "idempotency_key_reused",
2478
2568
  "invalid_request",
@@ -2499,17 +2589,16 @@ export const OPERATIONS = [
2499
2589
  ? {}
2500
2590
  : { responseHeaders: idempotencyReplayResponseHeaderSchema }),
2501
2591
  scopes: ["billing:write"],
2502
- sessionAuthority: "headers",
2503
2592
  summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2504
2593
  ? ""
2505
- : "Request operator-reviewed refund",
2594
+ : "Reserve credit against a payment for refund",
2506
2595
  surfaces: ["api", "mock"],
2507
2596
  },
2508
2597
  withBillingFundingContract({
2509
2598
  creates: false,
2510
2599
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2511
2600
  ? ""
2512
- : "Records an already-made external operator decision on a pending unused-credit refund request. Completion verifies an existing Stripe refund by authenticated provider read before applying the exact credit, tax and gross adjustment; it never creates a provider refund. Decline releases the reserved credit without contacting the provider. The Idempotency-Key makes either decision converge across retries.",
2601
+ : "Completes or declines a pending refund reservation. Completion verifies an existing Stripe refund by authenticated provider read before applying the exact credit, tax and gross adjustment, and converges on the recorded adjustment when that refund already settled the reservation; it never creates a provider refund. Decline releases the reserved credit without contacting the provider, and a reservation a Stripe refund superseded is refused as a state conflict. The Idempotency-Key makes either outcome converge across retries.",
2513
2602
  environments: ["live"],
2514
2603
  id: "billing.refundresolution",
2515
2604
  idempotent: true,
@@ -2517,7 +2606,14 @@ export const OPERATIONS = [
2517
2606
  method: "PATCH",
2518
2607
  mutates: true,
2519
2608
  path: "/v1/billing/funding/refunds/{refundRequest}",
2520
- principals: ["api-credential", "oauth", "session"],
2609
+ // **No browser session** (W9-09). The dashboard's refund request and
2610
+ // refund review forms were an operator's procedure rendered on a customer's
2611
+ // home screen, and they are gone; refunds are a conversation with support.
2612
+ // The operation is unchanged for an API credential and OAuth — the CLI's
2613
+ // `billing refund-request` — and a session write nothing calls is an
2614
+ // authorization path nobody exercises, which `workspace-mutations.test.ts`
2615
+ // exists to refuse.
2616
+ principals: ["api-credential", "oauth"],
2521
2617
  problems: [
2522
2618
  "idempotency_key_reused",
2523
2619
  "invalid_request",
@@ -2539,10 +2635,9 @@ export const OPERATIONS = [
2539
2635
  ? {}
2540
2636
  : { responseHeaders: idempotencyReplayResponseHeaderSchema }),
2541
2637
  scopes: ["billing:write"],
2542
- sessionAuthority: "headers",
2543
2638
  summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2544
2639
  ? ""
2545
- : "Record a reviewed refund decision",
2640
+ : "Complete or decline a refund reservation",
2546
2641
  surfaces: ["api", "mock"],
2547
2642
  }),
2548
2643
  {
@@ -2695,6 +2790,209 @@ export const OPERATIONS = [
2695
2790
  "test_to_live_escalation",
2696
2791
  ],
2697
2792
  },
2793
+ {
2794
+ creates: false,
2795
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2796
+ ? ""
2797
+ : "Reads the verified organization's saved payment method: the one method automatic execution top-ups and project subscriptions charge. It is the payment provider's default payment method for the organization, read by authenticated provider call. method says what it is — type card with brand, last four digits and expiry; type link with the email Link reports, when it reports one; or type other with the provider's type name (cashapp, amazon_pay, klarna and the like) — and every variant carries label, the name to show a person. card repeats the card details when the method is a card and is null otherwise; it is kept for clients written before other payment methods were accepted. A method the organization already authorized for automatic top-up or a project subscription is adopted as the saved method, so an existing customer is not told they have none. method and card are null when the organization has none.",
2798
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2799
+ ? {}
2800
+ : {
2801
+ card: { brand: "visa", expMonth: 12, expYear: 2030, last4: "4242" },
2802
+ method: {
2803
+ brand: "visa",
2804
+ expMonth: 12,
2805
+ expYear: 2030,
2806
+ label: "Visa ending in 4242",
2807
+ last4: "4242",
2808
+ type: "card",
2809
+ },
2810
+ },
2811
+ id: "billing.paymentmethod",
2812
+ idempotent: true,
2813
+ mcp: { destructive: false, kind: "tool", openWorld: false },
2814
+ method: "GET",
2815
+ mutates: false,
2816
+ path: "/v1/billing/payment-method",
2817
+ principals: ["api-credential", "oauth", "session"],
2818
+ problems: ["service_unavailable"],
2819
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2820
+ ? API_UNUSED_RESPONSE_SCHEMA
2821
+ : billingPaymentMethodSchema,
2822
+ scopes: ["usage:read"],
2823
+ sessionAuthority: "headers",
2824
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2825
+ ? ""
2826
+ : "Read the saved payment method",
2827
+ surfaces: ["api", "mock"],
2828
+ },
2829
+ {
2830
+ creates: false,
2831
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2832
+ ? ""
2833
+ : "Lists the verified organization's project subscription charges: the payment provider's invoices for its project subscription, read by authenticated provider call, most recent first and at most 24. Execution-credit purchases are not listed here; billing.funding reports them. Draft and zero-amount invoices are omitted. Each amount is the invoice total including tax, and the receipt link, when present, is the provider-hosted invoice page. An organization that has never been billed has an empty list; reading it creates nothing and changes nothing.",
2834
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2835
+ ? {}
2836
+ : {
2837
+ data: [
2838
+ {
2839
+ amount: {
2840
+ currency: "USD",
2841
+ microdollars: "5000000",
2842
+ scale: 6,
2843
+ },
2844
+ createdAt: "2026-09-01T12:00:00.000Z",
2845
+ id: "in_example_project_charge",
2846
+ receiptUrl: "https://invoice.stripe.com/i/acct_example/example",
2847
+ state: "paid",
2848
+ },
2849
+ ],
2850
+ },
2851
+ id: "billing.invoices",
2852
+ idempotent: true,
2853
+ mcp: { destructive: false, kind: "tool", openWorld: false },
2854
+ method: "GET",
2855
+ mutates: false,
2856
+ path: "/v1/billing/invoices",
2857
+ principals: ["api-credential", "oauth", "session"],
2858
+ problems: ["service_unavailable"],
2859
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2860
+ ? API_UNUSED_RESPONSE_SCHEMA
2861
+ : billingInvoiceListSchema,
2862
+ scopes: ["usage:read"],
2863
+ sessionAuthority: "headers",
2864
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2865
+ ? ""
2866
+ : "List project subscription charges",
2867
+ surfaces: ["api", "mock"],
2868
+ },
2869
+ {
2870
+ creates: false,
2871
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2872
+ ? ""
2873
+ : "Creates a short-lived provider-hosted payment-method setup session for the verified organization and returns its address. It offers every payment method the provider account enables that can be charged later without the customer present — cards, Link and others. Saving one there charges nothing; it becomes the saved payment method only once billing.paymentmethodconfirm (when the browser returns) or the provider's notification reads the completed setup by authenticated provider call. An optional return address must share the origin of the configured billing page.",
2874
+ environments: ["live"],
2875
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2876
+ ? {}
2877
+ : { url: "https://checkout.stripe.com/c/pay/example-card-setup" },
2878
+ id: "billing.paymentmethodsetup",
2879
+ idempotent: false,
2880
+ mcp: { destructive: false, kind: "tool", openWorld: false },
2881
+ method: "POST",
2882
+ mutates: true,
2883
+ path: "/v1/billing/payment-method/setup",
2884
+ principals: ["api-credential", "oauth", "session"],
2885
+ problems: [
2886
+ "invalid_request",
2887
+ "service_unavailable",
2888
+ "state_conflict",
2889
+ "not_found",
2890
+ "revision_conflict",
2891
+ "test_to_live_escalation",
2892
+ ],
2893
+ request: billingPaymentMethodSetupRequestSchema,
2894
+ requestExample: globalThis
2895
+ .GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2896
+ ? {}
2897
+ : {},
2898
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2899
+ ? API_UNUSED_RESPONSE_SCHEMA
2900
+ : billingPortalSchema,
2901
+ scopes: ["billing:write"],
2902
+ sessionAuthority: "headers",
2903
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2904
+ ? ""
2905
+ : "Start saving a payment method",
2906
+ surfaces: ["api", "mock"],
2907
+ },
2908
+ {
2909
+ creates: false,
2910
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2911
+ ? ""
2912
+ : "Makes the payment method saved in one completed hosted setup the organization's saved payment method, typically when the browser returns from it. The session is read by authenticated provider call and must belong to the verified organization's own customer; a session of another organization is answered not found. It becomes the provider default for invoices, the default of the organization's project subscription, and the automatic top-up payment method — readying a top-up rule that was waiting for one. The response has the shape billing.paymentmethod returns. When the previous method was removed (billing.paymentmethodremove) and the paid period it let run out has not ended, renewal resumes for the projects that removal stopped; a project the customer cancelled themselves stays cancelled. Nothing in the request can claim a setup succeeded, and repeating the call is safe.",
2913
+ environments: ["live"],
2914
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2915
+ ? {}
2916
+ : {
2917
+ card: { brand: "visa", expMonth: 12, expYear: 2030, last4: "4242" },
2918
+ method: {
2919
+ brand: "visa",
2920
+ expMonth: 12,
2921
+ expYear: 2030,
2922
+ label: "Visa ending in 4242",
2923
+ last4: "4242",
2924
+ type: "card",
2925
+ },
2926
+ },
2927
+ id: "billing.paymentmethodconfirm",
2928
+ idempotent: true,
2929
+ mcp: { destructive: false, kind: "tool", openWorld: false },
2930
+ method: "POST",
2931
+ mutates: true,
2932
+ path: "/v1/billing/payment-method/confirm",
2933
+ principals: ["api-credential", "oauth", "session"],
2934
+ problems: [
2935
+ "invalid_request",
2936
+ "not_found",
2937
+ "service_unavailable",
2938
+ "state_conflict",
2939
+ "revision_conflict",
2940
+ "test_to_live_escalation",
2941
+ ],
2942
+ request: billingPaymentMethodConfirmRequestSchema,
2943
+ requestExample: globalThis
2944
+ .GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2945
+ ? {}
2946
+ : { checkoutSession: "cs_example_card_setup" },
2947
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2948
+ ? API_UNUSED_RESPONSE_SCHEMA
2949
+ : billingPaymentMethodSchema,
2950
+ scopes: ["billing:write"],
2951
+ sessionAuthority: "headers",
2952
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2953
+ ? ""
2954
+ : "Confirm a saved payment method",
2955
+ surfaces: ["api", "mock"],
2956
+ },
2957
+ {
2958
+ creates: false,
2959
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
2960
+ ? ""
2961
+ : "Removes the verified organization's saved payment method, and with it everything that charges it. Removing it stops renewal: every project subscription is set to end at the end of the period already paid for, so paid projects keep running until then and then stop, with nothing refunded and nothing more charged; billing.projects shows each one's cancellationAt. The included free project is unaffected. Automatic top-up turns off immediately and forgets its payment method. A pending or declined project addition is ended, so nothing later starts a checkout or a charge, and no project can be added until a payment method is saved again. The method stops being the provider default and is detached from the organization's customer. The request must carry confirmed: true. Repeating the call is safe: with nothing on file it answers a null method and card and still makes sure nothing is left that could charge one. Saving a payment method through billing.paymentmethodsetup before the period ends keeps those projects: renewal resumes on the new method, except for any project the customer cancelled themselves. After the period ends, a paid project must be added again.",
2962
+ environments: ["live"],
2963
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2964
+ ? {}
2965
+ : { card: null, method: null },
2966
+ id: "billing.paymentmethodremove",
2967
+ idempotent: true,
2968
+ mcp: { destructive: true, kind: "tool", openWorld: false },
2969
+ method: "POST",
2970
+ mutates: true,
2971
+ path: "/v1/billing/payment-method/remove",
2972
+ principals: ["api-credential", "oauth", "session"],
2973
+ problems: [
2974
+ "invalid_request",
2975
+ "not_found",
2976
+ "service_unavailable",
2977
+ "state_conflict",
2978
+ "revision_conflict",
2979
+ "test_to_live_escalation",
2980
+ ],
2981
+ request: billingPaymentMethodRemoveRequestSchema,
2982
+ requestExample: globalThis
2983
+ .GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
2984
+ ? {}
2985
+ : { confirmed: true },
2986
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2987
+ ? API_UNUSED_RESPONSE_SCHEMA
2988
+ : billingPaymentMethodSchema,
2989
+ scopes: ["billing:write"],
2990
+ sessionAuthority: "headers",
2991
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2992
+ ? ""
2993
+ : "Remove the saved payment method",
2994
+ surfaces: ["api", "mock"],
2995
+ },
2698
2996
  {
2699
2997
  creates: false,
2700
2998
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
@@ -2711,7 +3009,16 @@ export const OPERATIONS = [
2711
3009
  mutates: true,
2712
3010
  path: "/v1/billing/reconcile",
2713
3011
  principals: ["api-credential", "oauth", "session"],
2714
- problems: ["service_unavailable", "test_to_live_escalation"],
3012
+ // `billing.reconcile` answers from the same summary read as
3013
+ // `billing.summary`, so it reaches the same not-provisioned refusal. It is
3014
+ // declared here because an integrator reading the published OpenAPI would
3015
+ // otherwise be told a 503 on this operation can only ever be
3016
+ // `service_unavailable`.
3017
+ problems: [
3018
+ "billing_not_ready",
3019
+ "service_unavailable",
3020
+ "test_to_live_escalation",
3021
+ ],
2715
3022
  response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
2716
3023
  ? API_UNUSED_RESPONSE_SCHEMA
2717
3024
  : billingSummarySchema,
@@ -2838,6 +3145,44 @@ export const OPERATIONS = [
2838
3145
  : "List immutable billing entries",
2839
3146
  surfaces: ["api", "mock"],
2840
3147
  },
3148
+ {
3149
+ creates: false,
3150
+ description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
3151
+ ? ""
3152
+ : "Read effective customer allowances for the verified organization. Deployment and organization revisions identify the policy used; infrastructure and other organizations' settings are excluded.",
3153
+ example: globalThis.GREATWAIT_RUNTIME_WITHOUT_EXAMPLES
3154
+ ? {}
3155
+ : {
3156
+ limits: {
3157
+ inlinePayloadBytes: 65536,
3158
+ forecastHorizonSeconds: 90000,
3159
+ usageWindowDays: 366,
3160
+ },
3161
+ provenance: {
3162
+ inlinePayloadBytes: "default",
3163
+ forecastHorizonSeconds: "default",
3164
+ usageWindowDays: "default",
3165
+ },
3166
+ revision: { global: 0, organization: 0 },
3167
+ },
3168
+ id: "limits.read",
3169
+ idempotent: true,
3170
+ mcp: { destructive: false, kind: "tool", openWorld: false },
3171
+ method: "GET",
3172
+ mutates: false,
3173
+ path: "/v1/limits",
3174
+ principals: ["api-credential", "oauth", "session"],
3175
+ problems: ["service_unavailable"],
3176
+ response: globalThis.GREATWAIT_API_REQUEST_REGISTRY
3177
+ ? API_UNUSED_RESPONSE_SCHEMA
3178
+ : effectiveCustomerLimitsSchema,
3179
+ scopes: ["schedules:read"],
3180
+ sessionAuthority: "headers",
3181
+ summary: globalThis.GREATWAIT_API_REQUEST_REGISTRY
3182
+ ? ""
3183
+ : "Read effective customer limits",
3184
+ surfaces: ["api", "mock"],
3185
+ },
2841
3186
  {
2842
3187
  creates: false,
2843
3188
  description: globalThis.GREATWAIT_RUNTIME_CONTRACTS_ONLY
@@ -2972,7 +3317,7 @@ export const OPERATIONS = [
2972
3317
  // scheduled for removal, which is the opposite of what a tool list is for.
2973
3318
  mcp: {
2974
3319
  kind: "unavailable",
2975
- reason: "A transitional shape for the autoscaler migration, scheduled for withdrawal once W6-02 has cut over. forecast.read is the same data in the shape this product publishes, and it is the tool an agent should reach for.",
3320
+ reason: "A transitional shape for the autoscaler migration, withdrawn after its cutover. forecast.read is the same data in the shape this product publishes, and it is the tool an agent should reach for.",
2976
3321
  },
2977
3322
  method: "GET",
2978
3323
  mutates: false,
@@ -3127,6 +3472,8 @@ export const OPERATIONS = [
3127
3472
  {
3128
3473
  attemptNumber: 1,
3129
3474
  classifiedAt: "2026-07-28T15:00:00.071Z",
3475
+ dispatchRecoveries: 0,
3476
+ localReceiptRecoveries: 0,
3130
3477
  delivery: "dlv_01h8xyz9k2m4n6p8r0t2v4w6y8",
3131
3478
  diagnostic: "http_retryable",
3132
3479
  durationMs: 71,
@@ -3176,6 +3523,8 @@ export const OPERATIONS = [
3176
3523
  attempt: {
3177
3524
  attemptNumber: 2,
3178
3525
  classifiedAt: "2026-07-28T15:02:00.000Z",
3526
+ dispatchRecoveries: 2,
3527
+ localReceiptRecoveries: 1,
3179
3528
  delivery: "dlv_11h8xyz9k2m4n6p8r0t2v4w6y8",
3180
3529
  diagnostic: "network_ambiguous",
3181
3530
  durationMs: 10_000,
@@ -3220,6 +3569,8 @@ export const OPERATIONS = [
3220
3569
  : {
3221
3570
  attempt: {
3222
3571
  attemptNumber: 3,
3572
+ dispatchRecoveries: 0,
3573
+ localReceiptRecoveries: 0,
3223
3574
  delivery: "dlv_21h8xyz9k2m4n6p8r0t2v4w6y8",
3224
3575
  id: "att_21h8xyz9k2m4n6p8r0t2v4w6y8",
3225
3576
  occurrence: "occ_01h8xyz9k2m4n6p8r0t2v4w6y8",
@@ -3652,6 +4003,16 @@ export function successStatusFor(operation) {
3652
4003
  * so an operation's own `problems` list stays about that operation.
3653
4004
  */
3654
4005
  export const UNIVERSAL_PROBLEMS = [
4006
+ // **Universal rather than per-operation, because its earliest raise sites
4007
+ // are before any operation exists.** Request admission runs as pre-route
4008
+ // middleware on every `/v1/*`, `/oauth/*` and `/mcp` path, and the Worker
4009
+ // refuses an unconfigured PostgreSQL authority before it builds an app at
4010
+ // all. Declaring it operation by operation would leave the published
4011
+ // contract, the mock and the SDK telling an integrator that a 503 on those
4012
+ // paths can only be `service_unavailable` — which is the mistake a review
4013
+ // round caught when `billing_not_ready` was declared on one of its two
4014
+ // operations and not the other.
4015
+ "capability_not_configured",
3655
4016
  "rate_limited",
3656
4017
  "service_unavailable",
3657
4018
  ];