@substrat-run/control-plane-api 0.205.0 → 0.207.0

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 (45) hide show
  1. package/dist/api.d.ts +27 -4
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +319 -10
  4. package/dist/api.js.map +1 -1
  5. package/dist/cf-observability.d.ts +34 -0
  6. package/dist/cf-observability.d.ts.map +1 -1
  7. package/dist/cf-observability.js +144 -1
  8. package/dist/cf-observability.js.map +1 -1
  9. package/dist/connection-choice.d.ts +47 -0
  10. package/dist/connection-choice.d.ts.map +1 -0
  11. package/dist/connection-choice.js +156 -0
  12. package/dist/connection-choice.js.map +1 -0
  13. package/dist/deploy.d.ts +12 -0
  14. package/dist/deploy.d.ts.map +1 -1
  15. package/dist/deploy.js +13 -1
  16. package/dist/deploy.js.map +1 -1
  17. package/dist/index.d.ts +4 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +4 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/model-reconcile.d.ts +173 -0
  22. package/dist/model-reconcile.d.ts.map +1 -0
  23. package/dist/model-reconcile.js +434 -0
  24. package/dist/model-reconcile.js.map +1 -0
  25. package/dist/platform-entry.generated.d.ts +1 -1
  26. package/dist/platform-entry.generated.d.ts.map +1 -1
  27. package/dist/platform-entry.generated.js +2 -2
  28. package/dist/platform-entry.generated.js.map +1 -1
  29. package/dist/scope-copy-cleanup.d.ts +5 -1
  30. package/dist/scope-copy-cleanup.d.ts.map +1 -1
  31. package/dist/scope-copy-cleanup.js +4 -2
  32. package/dist/scope-copy-cleanup.js.map +1 -1
  33. package/dist/staff-client.d.ts +10 -1
  34. package/dist/staff-client.d.ts.map +1 -1
  35. package/dist/staff-client.js +4 -0
  36. package/dist/staff-client.js.map +1 -1
  37. package/dist/vertical-client.d.ts +37 -3
  38. package/dist/vertical-client.d.ts.map +1 -1
  39. package/dist/vertical-client.js +66 -11
  40. package/dist/vertical-client.js.map +1 -1
  41. package/dist/wfp.d.ts +7 -0
  42. package/dist/wfp.d.ts.map +1 -1
  43. package/dist/wfp.js +6 -0
  44. package/dist/wfp.js.map +1 -1
  45. package/package.json +10 -10
package/dist/api.d.ts CHANGED
@@ -6,6 +6,7 @@ import { type ConnectionCertificate, z, type ScopeStoreNeed, type StoreDriverReg
6
6
  import type { Connection, ConnectionActivity, ConnectionActivitySource, ConnectionCredential, ConnectionProbe, PlatformActorId, ScopeId, TenantId } from '@substrat-run/contracts';
7
7
  import { type MailInAddress, type MailInAddressAct, type MailInStanding } from '@substrat-run/contracts';
8
8
  import type { CrossVerticalOptions, HostAdmin, MailSender, OpsFailureInput, ScopeHost } from '@substrat-run/kernel';
9
+ import { type ConnectionLandingOptionsInput } from '@substrat-run/kernel';
9
10
  import type { PlatformActorAuth, BuilderAuth, Principal, TenantServiceAuth } from './auth.js';
10
11
  import { type VerticalClient } from './vertical-client.js';
11
12
  import { type CopyJobs } from './copy-job.js';
@@ -14,6 +15,7 @@ import { type ScopeStoreEnsurerOptions, type StoreCanaryTarget, type StoreDriver
14
15
  import { type CanaryCall, type StoreReleaseBytes } from './store-releases.js';
15
16
  import type { PersonaIssuerSeam } from './persona-issuer.js';
16
17
  import { type ConnectionCandidatePrepare, type VerticalConnectorDeclarationOf } from './connection-relay.js';
18
+ import { type ModelCostReader } from './model-reconcile.js';
17
19
  import type { DeployVerticalFn, FetchVerticalAssetFn, FetchVerticalModulesFn } from './deploy.js';
18
20
  import type { PatchScriptBindingsFn } from './wfp.js';
19
21
  import { type ObservabilityReader } from './observability.js';
@@ -129,9 +131,9 @@ export interface ControlPlaneApiOptions {
129
131
  /** Monotonic clock for the bounded tenant usage composition (injectable in tests). */
130
132
  meteredUsageNow?: () => number;
131
133
  /**
132
- * The platform's margin over list price for model usage it provides (#1054), whole
133
- * percent, applied at read time by `GET /model-usage/summary`. One global number
134
- * today; a per-provider rate is an additive change later. Default 20.
134
+ * The margin over list price for model usage (#1054), whole percent, for a host that keeps no
135
+ * markup schedule. A host that keeps one (#3316, both adapters) prices from its rows instead,
136
+ * and this is ignored. Default `DEFAULT_MODEL_MARGIN_PERCENT`.
135
137
  */
136
138
  modelMarginPercent?: number;
137
139
  /**
@@ -144,6 +146,14 @@ export interface ControlPlaneApiOptions {
144
146
  readonly scope: ScopeId;
145
147
  readonly zeroRated: boolean;
146
148
  };
149
+ /**
150
+ * #1054: what `GET /model-usage/reconciliation` reads Cloudflare's side from, and which provider
151
+ * rows send their calls through AI Gateway. Unset: the route answers 501.
152
+ */
153
+ modelReconciliation?: {
154
+ readonly reader: ModelCostReader;
155
+ readonly gatewayProviders: readonly string[];
156
+ };
147
157
  host: ScopeHost;
148
158
  /**
149
159
  * How edge health reaches the two ends of a cross-vertical edge (#1705 PR 3): the phase's own
@@ -476,6 +486,11 @@ export interface ControlPlaneApiOptions {
476
486
  * verify a Fortnox key yet" is a true statement; "your Fortnox key is fine" is not.
477
487
  */
478
488
  connectionInspectors?: Record<string, ConnectionInspector>;
489
+ /**
490
+ * #3221: the connector pass's landing reader and binders, so the tenant's door choosing which
491
+ * connection an install lands through binds exactly as the pass would. Absent, that door 501s.
492
+ */
493
+ connectionLandings?: ConnectionLandingOptionsInput;
479
494
  /**
480
495
  * The mail sender each provider that sends as a tenant's own addresses registers (#2098), by
481
496
  * provider — the same `{ provider → sender }` the email relay routes through. Behind
@@ -659,7 +674,15 @@ export declare const denialLogQuery: z.ZodObject<{
659
674
  }, z.core.$strip>;
660
675
  /** The per-provider read bound: past it the count is a floor, and says so (`capped`). */
661
676
  export declare const CONNECTOR_DEAD_LETTER_CAP = 200;
662
- export declare const DEFAULT_MODEL_MARGIN_PERCENT = 20;
677
+ /** The most days one reconciliation read covers: each is a ledger walk and a GraphQL read. */
678
+ export declare const MODEL_RECONCILIATION_MAX_DAYS = 14;
679
+ /**
680
+ * The margin over list price on platform-provided model calls, whole percent: the markup
681
+ * schedule's seeded `model-calls` row (30%, the owner's rate of 2026-11-21, #3316), read from the
682
+ * seed rather than restated. The ledger's reads price from the schedule itself, a tenant's own
683
+ * row and a dated change included; this is the rate only for a host that keeps no schedule.
684
+ */
685
+ export declare const DEFAULT_MODEL_MARGIN_PERCENT: number;
663
686
  /**
664
687
  * The most review lines one tenant's metered-usage read folds. A tenant's reviews are capped far
665
688
  * below it at intake (50 kept in 30 days), so reaching it marks the figure a lower bound.
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2D,KAAK,kBAAkB,EAAoB,KAAK,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AACxL,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAE9G,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAyBL,KAAK,qBAAqB,EA0F1B,CAAC,EAkBD,KAAK,cAAc,EAEnB,KAAK,uBAAuB,EAK7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAOV,UAAU,EACV,kBAAkB,EAGlB,wBAAwB,EACxB,oBAAoB,EAEpB,eAAe,EAKf,eAAe,EAKf,OAAO,EAOP,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAoC,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE3I,OAAO,KAAK,EAAoB,oBAAoB,EAAE,SAAS,EAAc,UAAU,EAAE,eAAe,EAAkC,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAyClL,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9F,OAAO,EAAuL,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAA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;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAmCzC,KAAK,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAkMjE;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEvF;AAwCD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CA26YhG"}
package/dist/api.js CHANGED
@@ -4,14 +4,14 @@ import { PREVIEW_CONNECTIONS_REFUSAL } from './connection-relay.js';
4
4
  import { bindingChangeRefusal, bindingOptionsRefusal, connectionBindingOptions, refusesBindingChange } from './connection-binding-options.js';
5
5
  import { resolveObservabilityWindow } from './observability-window.js';
6
6
  import { Hono } from 'hono';
7
- import { permissionKey, parseHostname, withLabel, RESERVED_LABEL_SEPARATOR, adminAction, lakeEventsInput, ownerTransferInput, memberInviteInput, memberRoleInput, ASSET_PART_PREFIX, assetHash, STORE_DRIVERS, storeDriverErasesSubjects, storeDriverServesVertical, storeCatalogOperation, storeDriverBasisAdmits, channelName, connectLinkId, connectionActivity, connectionActivitySource, connectionCredential, connectionCertificate, connectionFilter, connectionHealthState, connectionProvider, connectorDispatchKind, PROVISION_SIBLING_KIND, ARCHIVE_SCOPE_KIND, PROVISION_TENANT_KIND, SET_ENTITLEMENTS_KIND, MODEL_USAGE_KIND, SWEEP_RUNS_KIND, toConnectionHealthEntry, CONNECTION_EXPIRY_WARNING_DAYS, CONNECTION_STALE_DAYS, connectionProbe, connectionSendTest, connectionSendTestResult, connectionSenders, createTenantInput, entitlementGrantInput, hostname as hostnameSchema, hostnameRegion, hostnameStatus, identityLink, errorCode, issueStatus, issueStatusInput, FINDINGS_LIMIT_DEFAULT, FINDINGS_LIMIT_MAX, findingCursorOf, findingKind, findingRuleInput, findingStatus, findingStatusInput, listPageQuery, matchesOutboundHost, pageOf, platformRequestFilter, principalId as principalIdSchema, impersonationStamp, promotionAcknowledgement, bindAcknowledgement, rebindAcknowledgement, provisionableJurisdiction, publishVersionInput, queryScopeInput, readScopeTableInput, entityHistoryInput, eventFacetInput, eventCauseInput, eventEffectsInput, invocationEventsInput, deadLettersInput, lifecycleFlowInput, operationSeriesCount, operationSeriesInput, delegatedReadParams, createOrgInput, roleKey as roleKeySchema, peerSwitch, verticalSlug, scopeText, systemSwitch, DEFAULT_DENIAL_LIMIT, DENIAL_LIMIT_MAX, denialGroupBy, registerVerticalInput, platformScriptCollision, platformScriptRefusal, PLATFORM_SCRIPT_NAMES, serviceDimensions, sweepRunKind, sweepRunOutcome, scopeDump, mergeDumpPages, dataSubjectId as dataSubjectIdSchema, scopeId as scopeIdSchema, scopeStatus, requestRollupReading, meterDaysReading, verticalOwnersReading, utcDay, storageShape, surfaceName, modelUsageLine, tenantId as tenantIdSchema, tenantStatus, versionOrigin, z, PROBLEM_CONTENT_TYPE, toProblem, validationIssuesFrom, redrainEventsInput, importCursorMove, importCursorAcknowledgementMissing, REDRAIN_BATCH, migrationsOnTop, substratError, errorCodeOf, envVarSpec, capabilityFilterQuery, capabilityId as capabilityIdSchema, PLATFORM_FEATURES_HEADER, PLATFORM_FEATURE_SCOPE_SWEEPER, PLATFORM_FEATURE_SOURCE_BUILDS, SOCIAL_RELAY_VERTICALS, isVerticalConnectorProvider, previewTag, buildPreviewTagPrefix, } from '@substrat-run/contracts';
7
+ import { MARKUP_SEED, MARKUP_SEED_EFFECTIVE_FROM, markupPercentFor, markupRowInput, permissionKey, parseHostname, withLabel, RESERVED_LABEL_SEPARATOR, adminAction, lakeEventsInput, ownerTransferInput, memberInviteInput, memberRoleInput, ASSET_PART_PREFIX, assetHash, STORE_DRIVERS, storeDriverErasesSubjects, storeDriverServesVertical, storeCatalogOperation, storeDriverBasisAdmits, channelName, connectLinkId, connectionActivity, connectionActivitySource, connectionCredential, connectionCertificate, connectionFilter, connectionHealthState, connectionProvider, connectorDispatchKind, PROVISION_SIBLING_KIND, ARCHIVE_SCOPE_KIND, PROVISION_TENANT_KIND, SET_ENTITLEMENTS_KIND, MODEL_USAGE_KIND, SWEEP_RUNS_KIND, toConnectionHealthEntry, CONNECTION_EXPIRY_WARNING_DAYS, CONNECTION_STALE_DAYS, connectionProbe, connectionSendTest, connectionSendTestResult, connectionSenders, createTenantInput, entitlementGrantInput, hostname as hostnameSchema, hostnameRegion, hostnameStatus, identityLink, errorCode, issueStatus, issueStatusInput, FINDINGS_LIMIT_DEFAULT, FINDINGS_LIMIT_MAX, findingCursorOf, findingKind, findingRuleInput, findingStatus, findingStatusInput, listPageQuery, matchesOutboundHost, pageOf, platformRequestFilter, principalId as principalIdSchema, impersonationStamp, promotionAcknowledgement, bindAcknowledgement, rebindAcknowledgement, provisionableJurisdiction, publishVersionInput, queryScopeInput, readScopeTableInput, entityHistoryInput, eventFacetInput, eventCauseInput, eventEffectsInput, invocationEventsInput, deadLettersInput, lifecycleFlowInput, operationSeriesCount, operationSeriesInput, delegatedReadParams, createOrgInput, roleKey as roleKeySchema, peerSwitch, verticalSlug, scopeText, systemSwitch, DEFAULT_DENIAL_LIMIT, DENIAL_LIMIT_MAX, denialGroupBy, registerVerticalInput, platformScriptCollision, platformScriptRefusal, PLATFORM_SCRIPT_NAMES, serviceDimensions, sweepRunKind, sweepRunOutcome, scopeDump, mergeDumpPages, dataSubjectId as dataSubjectIdSchema, scopeId as scopeIdSchema, scopeDumpSample, scopeStatus, requestRollupReading, costRollupReading, costAttribution, cloudflareUsageDay, meterDaysReading, verticalOwnersReading, utcDay, storageShape, surfaceName, modelUsageLine, tenantId as tenantIdSchema, tenantStatus, versionOrigin, z, PROBLEM_CONTENT_TYPE, toProblem, validationIssuesFrom, redrainEventsInput, importCursorMove, importCursorAcknowledgementMissing, REDRAIN_BATCH, migrationsOnTop, substratError, errorCodeOf, envVarSpec, capabilityFilterQuery, capabilityId as capabilityIdSchema, PLATFORM_FEATURES_HEADER, PLATFORM_FEATURE_SCOPE_SWEEPER, PLATFORM_FEATURE_SOURCE_BUILDS, SOCIAL_RELAY_VERTICALS, isVerticalConnectorProvider, previewTag, buildPreviewTagPrefix, } from '@substrat-run/contracts';
8
8
  import { upstreamHandleIn, upstreamReferenceOf, withUpstreamReference } from '@substrat-run/contracts';
9
9
  import { mailInAddressAct, mailInStanding } from '@substrat-run/contracts';
10
10
  import { ENGINE_ENTITLEMENT_KEYS, bareSlug, declarableEntitlementKey, entitlementNamespaceRefusal, grantableEntitlements } from '@substrat-run/contracts';
11
11
  import { SCOPE_COPY_LEASE_MS, copyRestoreFence, publishedMigrationDigest, replayStoreErasures, storesFencedRefusal } from '@substrat-run/kernel';
12
12
  import { attributeFailure } from './failure-attribution.js';
13
13
  import { auditedChange, withAuditedOutcomes } from './audited-change.js';
14
- import { BIND_EXPORT_BREAK_REFUSAL, CARRIED_AWAY_KEY, bindExportBreakRefusal, dumpMetaValue, metaValueIn, crossVerticalHealth, exportBreakRefusal, isBindExportBreakRefusal, isExportBreakRefusal, listedPromoteRefusal, isExportBreakUnjudged, isPrimaryScope, promoteReviewDigest, rebindReviewDigest, assertRebindReviewCurrent, migrationProgress, ulid, auditWarningOf, REQUEST_ROLLUP_LIMIT_DEFAULT, REQUEST_ROLLUP_LIMIT_MAX, STORAGE_HISTORY_LIMIT_MAX, STORAGE_GAUGE_RETENTION_MONTHS, BUILD_USAGE_RETENTION_DAYS, MODEL_USAGE_RETENTION_DAYS, BILLING_ROLLUP_RETENTION_MONTHS, METER_DAYS_LIMIT_DEFAULT, METER_DAYS_LIMIT_MAX, releaseRolesAskScopes, releaseRoleSetRefusal, withheldOpsFailure, foldModelUsage, } from '@substrat-run/kernel';
14
+ import { BIND_EXPORT_BREAK_REFUSAL, CARRIED_AWAY_KEY, bindExportBreakRefusal, dumpMetaValue, metaValueIn, crossVerticalHealth, exportBreakRefusal, isBindExportBreakRefusal, isExportBreakRefusal, listedPromoteRefusal, isExportBreakUnjudged, isPrimaryScope, promoteReviewDigest, rebindReviewDigest, assertRebindReviewCurrent, migrationProgress, ulid, auditWarningOf, REQUEST_ROLLUP_LIMIT_DEFAULT, REQUEST_ROLLUP_LIMIT_MAX, COST_ROLLUP_LIMIT_DEFAULT, COST_ROLLUP_LIMIT_MAX, STORAGE_HISTORY_LIMIT_MAX, STORAGE_GAUGE_RETENTION_MONTHS, BUILD_USAGE_RETENTION_DAYS, MODEL_USAGE_RETENTION_DAYS, BILLING_ROLLUP_RETENTION_MONTHS, METER_DAYS_LIMIT_DEFAULT, METER_DAYS_LIMIT_MAX, releaseRolesAskScopes, releaseRoleSetRefusal, withheldOpsFailure, foldModelUsage, } from '@substrat-run/kernel';
15
15
  import { TENANT_HEADER, confinedTenant } from './auth.js';
16
16
  import { mintTenantToken } from './tenant-token.js';
17
17
  import { issuerOnlyConfigKeyOf } from './issuer-config.js';
@@ -28,6 +28,7 @@ import { oidcCallbackUrl, retireClientsOfReapedScope, wirePreviewAuth } from './
28
28
  import { scopeDeployment, versionReachedAt } from './scope-deployment.js';
29
29
  import { reconcileConnectionGrants } from './connection-grants.js';
30
30
  import { reconcileOutcomeOf, reconcileThenReassert, reviewedEntityGrants, switchCarryFor } from './reconcile.js';
31
+ import { chooseScopeConnection, readScopeConnectionChoice } from './connection-choice.js';
31
32
  import { ConnectionRelayError, relayConnectionUpsert } from './connection-relay.js';
32
33
  import { ControlPlaneError } from '@substrat-run/control-plane-client';
33
34
  import { provisionSiblingScope } from './platform-drain.js';
@@ -36,6 +37,8 @@ import { maskDump, maskRecords } from './mask.js';
36
37
  import { createPseudonymizer } from './pseudonymize.js';
37
38
  import { assembleSubjectAccess, renderSubjectAccessHtml } from './subject-access.js';
38
39
  import { SUBJECT_READ_PAGE_MAX, subjectAccessBody } from '@substrat-run/contracts';
40
+ import { modelReconciliation } from '@substrat-run/contracts';
41
+ import { daysBetween, reconcileModelDays } from './model-reconcile.js';
39
42
  /**
40
43
  * The most `readSubject` pages one access request assembles (D-74): past it the package would not
41
44
  * fit one response, and the request is refused rather than truncated. A later phase writes such a
@@ -43,7 +46,7 @@ import { SUBJECT_READ_PAGE_MAX, subjectAccessBody } from '@substrat-run/contract
43
46
  */
44
47
  const SUBJECT_ACCESS_MAX_PAGES = 50;
45
48
  import { openDump, sealDump } from './seal.js';
46
- import { assertSandboxContract, verticalUploadBindings, migrationsDigestBindings, deployManifest, storedDeployManifest, pushedOwnerGrantProblems, pushedConnectorProblems, pushedModuleRegistryProblems, pushedLandingProblems, pushedDelegationProblems, pushedPermissionRegistry, delegationsOf, deploymentRefFor, stableDeploymentRefFor, nextMigrationTag, upstreamStatusOf, } from './deploy.js';
49
+ import { assertSandboxContract, verticalUploadBindings, migrationsDigestBindings, scopeWorkBindings, deployManifest, storedDeployManifest, pushedOwnerGrantProblems, pushedConnectorProblems, pushedModuleRegistryProblems, pushedLandingProblems, pushedDelegationProblems, pushedPermissionRegistry, delegationsOf, deploymentRefFor, stableDeploymentRefFor, nextMigrationTag, upstreamStatusOf, } from './deploy.js';
47
50
  /**
48
51
  * Answer with a problem document (#113 phase 4).
49
52
  *
@@ -406,6 +409,9 @@ const snapshotScopeBody = z.object({
406
409
  kind: z.string().min(1).optional(),
407
410
  expiresAt: z.string().datetime({ offset: true }).optional(),
408
411
  });
412
+ // Move a fork's GC deadline (#3314): an instant, or `null` to pin it until deliberately deleted.
413
+ // The key is required, so an empty body is a 400 rather than a silent pin.
414
+ const scopeExpiresAtBody = z.object({ expiresAt: z.string().datetime({ offset: true }).nullable() }).strict();
409
415
  // A reap request (#493). `backup` is deliberately TRI-STATE, not a defaulted boolean:
410
416
  // true — back up or refuse (the console always sends this, so a control plane
411
417
  // deployed without a backup store fails loudly instead of quietly wiping)
@@ -550,6 +556,16 @@ const createPreviewBody = z.object({
550
556
  // never starts one: it answers the copy's progress, finishes it once it is done, or says it is gone.
551
557
  // A call after a 202 naming another push's copy (one being finished) is not a poll: it may start its own.
552
558
  poll: z.boolean().optional(),
559
+ // #3232: a fork copies a SAMPLE of its source: the newest `sample` rows of each table, among those
560
+ // whose parents it keeps, and the spine that follows them. A fresh fork only: a push to an existing
561
+ // preview carries the preview's own data, whatever it was forked as.
562
+ sample: scopeDumpSample.shape.rows.optional(),
563
+ // #3232: the cost cap. A fresh fork estimates the rows it would copy before it copies anything, and
564
+ // is refused (413, the estimate in the refusal) above `maxRows`.
565
+ maxRows: z.number().int().positive().optional(),
566
+ // #3232: with `maxRows`, a fork over the cap copies a sample of this many rows per table instead of
567
+ // being refused, and is refused only when that sample is over the cap too.
568
+ sampleOverCap: scopeDumpSample.shape.rows.optional(),
553
569
  });
554
570
  const listRolesQuery = z.object({
555
571
  tenantId: tenantIdSchema.optional(),
@@ -740,6 +756,13 @@ const modelUsageQuery = z.object({
740
756
  until: z.string().optional(),
741
757
  ...listPageQuery.shape,
742
758
  });
759
+ /** Inclusive UTC days for `GET /model-usage/reconciliation`; both default to yesterday. */
760
+ const modelReconciliationQuery = z.object({
761
+ since: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
762
+ until: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
763
+ });
764
+ /** The most days one reconciliation read covers: each is a ledger walk and a GraphQL read. */
765
+ export const MODEL_RECONCILIATION_MAX_DAYS = 14;
743
766
  /** The summary window: a half-open `[since, until)`; defaults to the current calendar month so far. */
744
767
  /**
745
768
  * One line for a model call no drain carries (`POST /model-usage`). `requestId` is the ledger's
@@ -751,7 +774,32 @@ const modelUsageSummaryQuery = z.object({
751
774
  since: z.string().optional(),
752
775
  until: z.string().optional(),
753
776
  });
754
- export const DEFAULT_MODEL_MARGIN_PERCENT = 20;
777
+ /**
778
+ * The margin over list price on platform-provided model calls, whole percent: the markup
779
+ * schedule's seeded `model-calls` row (30%, the owner's rate of 2026-11-21, #3316), read from the
780
+ * seed rather than restated. The ledger's reads price from the schedule itself, a tenant's own
781
+ * row and a dated change included; this is the rate only for a host that keeps no schedule.
782
+ */
783
+ export const DEFAULT_MODEL_MARGIN_PERCENT = markupPercentFor(MARKUP_SEED, {
784
+ tenantId: null,
785
+ dimension: 'model-calls',
786
+ kind: 'live',
787
+ day: MARKUP_SEED_EFFECTIVE_FROM,
788
+ });
789
+ /**
790
+ * The markup schedule a read prices from (#3316): every row, or the rows that can price one
791
+ * tenant. Null from a host that keeps no schedule, whose reads fall back to the fixed rate.
792
+ */
793
+ async function markupScheduleFor(admin, actor, tenantId) {
794
+ if (!admin.listMarkup)
795
+ return null;
796
+ return admin.listMarkup(actor, tenantId ? { tenantId } : undefined);
797
+ }
798
+ /** The platform's `model-calls` rate on `at`'s day: the summary's headline rate. */
799
+ function platformModelMarginFor(markup, at, fallback) {
800
+ const percent = markup ? markupPercentFor(markup, { tenantId: null, dimension: 'model-calls', kind: 'live', day: at.slice(0, 10) }) : null;
801
+ return percent ?? fallback;
802
+ }
755
803
  /**
756
804
  * The most review lines one tenant's metered-usage read folds. A tenant's reviews are capped far
757
805
  * below it at intake (50 kept in 30 days), so reaching it marks the figure a lower bound.
@@ -787,6 +835,9 @@ const TENANT_ROUTES = [
787
835
  // #2343: a mail connection's test send. The dashboard sends it only to the signed-in person.
788
836
  { method: 'POST', re: /\/tenants\/[^/]+\/connections\/[^/]+\/send-test$/, pin: 'path' },
789
837
  { method: 'GET', re: /\/tenants\/[^/]+\/connections\/[^/]+\/senders$/, pin: 'path' },
838
+ // #3221: which of the tenant's connections an install's checkouts go through.
839
+ { method: 'GET', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/connections\/[^/]+\/choice$/, pin: 'path' },
840
+ { method: 'PUT', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/connections\/[^/]+\/choice$/, pin: 'path' },
790
841
  // #2611: one app's mail-in address — read it, and request, rotate or revoke it.
791
842
  { method: 'GET', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/mail-in$/, pin: 'path' },
792
843
  { method: 'POST', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/mail-in$/, pin: 'path' },
@@ -1190,6 +1241,8 @@ export function createControlPlaneApi(options) {
1190
1241
  }
1191
1242
  };
1192
1243
  const app = new Hono();
1244
+ /** #3316: the platform's model-calls rate on a day, or the fixed rate from a host keeping no schedule. */
1245
+ const platformModelMargin = (markup, at) => platformModelMarginFor(markup, at, options.modelMarginPercent ?? DEFAULT_MODEL_MARGIN_PERCENT);
1193
1246
  // Every refusal is a problem document (#113): the tripwire. A route answers a failure
1194
1247
  // through `refuse`/`refuseStatus`/`problem`, and anything else — a hand-rolled
1195
1248
  // `c.json({ error }, 4xx)`, a sub-app's text 404 — is logged here as
@@ -2064,8 +2117,10 @@ export function createControlPlaneApi(options) {
2064
2117
  });
2065
2118
  const kept = lines.slice(0, REVIEW_USAGE_READ_MAX);
2066
2119
  const clipped = lines.length > REVIEW_USAGE_READ_MAX;
2120
+ const markup = await markupScheduleFor(admin, actor, tenantId);
2067
2121
  const folded = foldModelUsage(kept, {
2068
- readAt, ...window, marginPercent: options.modelMarginPercent ?? DEFAULT_MODEL_MARGIN_PERCENT,
2122
+ readAt, ...window, marginPercent: platformModelMargin(markup, until),
2123
+ ...(markup ? { markup } : {}),
2069
2124
  ...(zeroRated ? { zeroRatedScopes: [options.reviewUsage.scope] } : {}),
2070
2125
  }).totals;
2071
2126
  const reported = kept.filter((line) => line.reported);
@@ -2275,6 +2330,72 @@ export function createControlPlaneApi(options) {
2275
2330
  days,
2276
2331
  }));
2277
2332
  });
2333
+ // The daily Cloudflare cost rollup (#3316): the stored cost inputs per (day, script, scope, Durable
2334
+ // Object class, billed dimension), attributed through the directory, and the rollup's record of each
2335
+ // day in the window. Staff-only like `/meters`. Quantities only, never a price: the markup schedule
2336
+ // prices them at read. A directory read; nothing is queried live.
2337
+ const COST_ROLLUP_PAGE_MAX = COST_ROLLUP_LIMIT_MAX / 2;
2338
+ app.get('/meters/cloudflare-costs', async (c) => {
2339
+ const admin = c.var.admin;
2340
+ if (!admin.listCostDays || !admin.listCostRollupDays) {
2341
+ return refuseStatus(c, 501, 'this control plane keeps no Cloudflare cost rollup');
2342
+ }
2343
+ const today = new Date().toISOString().slice(0, 10);
2344
+ const q = z
2345
+ .object({
2346
+ tenantId: tenantIdSchema.optional(),
2347
+ scopeId: scopeIdSchema.optional(),
2348
+ vertical: z.string().min(1).optional(),
2349
+ attribution: costAttribution.optional(),
2350
+ since: utcDay.optional(),
2351
+ until: utcDay.default(today),
2352
+ limit: z.coerce.number().int().min(1).max(COST_ROLLUP_PAGE_MAX).default(COST_ROLLUP_LIMIT_DEFAULT),
2353
+ })
2354
+ .parse({
2355
+ tenantId: c.req.query('tenantId') || undefined,
2356
+ scopeId: c.req.query('scopeId') || undefined,
2357
+ vertical: c.req.query('vertical') || undefined,
2358
+ attribution: c.req.query('attribution') || undefined,
2359
+ since: c.req.query('since') || undefined,
2360
+ until: c.req.query('until') || undefined,
2361
+ limit: c.req.query('limit') || undefined,
2362
+ });
2363
+ const since = q.since ?? windowSince(q.until);
2364
+ if (since > q.until)
2365
+ return refuse(c, 'validation_failed', '`since` is after `until`');
2366
+ const actor = c.get('actor');
2367
+ const rows = await admin.listCostDays(actor, {
2368
+ ...(q.tenantId ? { tenantId: q.tenantId } : {}),
2369
+ ...(q.scopeId ? { scopeId: q.scopeId } : {}),
2370
+ ...(q.vertical ? { vertical: q.vertical } : {}),
2371
+ ...(q.attribution ? { attribution: q.attribution } : {}),
2372
+ since,
2373
+ until: q.until,
2374
+ limit: q.limit + 1,
2375
+ });
2376
+ const days = await admin.listCostRollupDays(actor, { since, until: q.until });
2377
+ return c.json(costRollupReading.parse({ since, until: q.until, rows: rows.slice(0, q.limit), truncated: rows.length > q.limit, days }));
2378
+ });
2379
+ // #3316: load one day of a raw Cloudflare usage snapshot into the cost rollup, for the history the
2380
+ // analytics no longer answer for. The day is attributed through the directory by the same code the
2381
+ // scheduled pass runs. A day already read is refused, so a snapshot never replaces a read that
2382
+ // carries its confidence intervals; so is a day that has not ended. Staff-only like `/meters`.
2383
+ app.post('/meters/cloudflare-costs/days', async (c) => {
2384
+ const admin = c.var.admin;
2385
+ if (!admin.recordCostDay || !admin.listCostRollupDays) {
2386
+ return refuseStatus(c, 501, 'this control plane keeps no Cloudflare cost rollup');
2387
+ }
2388
+ const usage = cloudflareUsageDay.parse(await c.req.json());
2389
+ if (usage.day >= new Date().toISOString().slice(0, 10)) {
2390
+ return refuse(c, 'validation_failed', `${usage.day} has not ended`);
2391
+ }
2392
+ const actor = c.get('actor');
2393
+ const [read] = await admin.listCostRollupDays(actor, { since: usage.day, until: usage.day });
2394
+ if (read?.readAt)
2395
+ return refuse(c, 'conflict', `${usage.day} was already read at ${read.readAt}; a snapshot does not replace it`);
2396
+ const { recorded } = await admin.recordCostDay(actor, { day: usage.day, attemptedAt: new Date().toISOString(), usage });
2397
+ return c.json({ day: usage.day, recorded }, 201);
2398
+ });
2278
2399
  // The daily meter snapshot (#2501): meters 1 and 2 as the first scheduled pass of each UTC day
2279
2400
  // found them, one row per (day, tenant), and the record of each day in the window. Staff-only
2280
2401
  // like `/meters`. A directory read; nothing is recomputed, so a past day reads as it was then.
@@ -2850,6 +2971,48 @@ export function createControlPlaneApi(options) {
2850
2971
  }
2851
2972
  return c.json({ ...done.result, permissionHeld: true, ...('unrecorded' in done ? { auditWarning: done.unrecorded } : {}) });
2852
2973
  });
2974
+ /**
2975
+ * #3221: which tenant connection one install lands through, for a provider that lands each install
2976
+ * through one (a payment provider, `ConnectionBinder.exclusive`). Tenant-callable: the choice is the
2977
+ * tenant's, made from its dashboard. See `connection-choice.ts`.
2978
+ */
2979
+ const choiceRefusal = (c, err) => {
2980
+ if (err instanceof ConnectionRelayError && err.status < 500) {
2981
+ return err.code ? refuse(c, err.code, err.message) : refuseStatus(c, err.status, err.message);
2982
+ }
2983
+ throw err;
2984
+ };
2985
+ const choiceInput = (c) => ({
2986
+ tenantId: tenantIdSchema.parse(c.req.param('tenantId')),
2987
+ scopeId: scopeIdSchema.parse(c.req.param('scopeId')),
2988
+ provider: connectionProvider.parse(c.req.param('provider')),
2989
+ });
2990
+ app.get('/tenants/:tenantId/scopes/:scopeId/connections/:provider/choice', async (c) => {
2991
+ const landings = options.connectionLandings;
2992
+ if (!landings)
2993
+ return refuseStatus(c, 501, 'this control plane binds no connection landings');
2994
+ try {
2995
+ return c.json(await readScopeConnectionChoice(c.var.host, c.get('actor'), choiceInput(c), { landings }));
2996
+ }
2997
+ catch (err) {
2998
+ return choiceRefusal(c, err);
2999
+ }
3000
+ });
3001
+ app.put('/tenants/:tenantId/scopes/:scopeId/connections/:provider/choice', async (c) => {
3002
+ const landings = options.connectionLandings;
3003
+ if (!landings)
3004
+ return refuseStatus(c, 501, 'this control plane binds no connection landings');
3005
+ const body = z
3006
+ .object({ connectionId: z.string().min(1), chosenBy: z.string().min(1).max(200).optional() })
3007
+ .strict()
3008
+ .parse(await c.req.json());
3009
+ try {
3010
+ return c.json(await chooseScopeConnection(c.var.host, c.get('actor'), { ...choiceInput(c), ...body }, { landings }));
3011
+ }
3012
+ catch (err) {
3013
+ return choiceRefusal(c, err);
3014
+ }
3015
+ });
2853
3016
  /**
2854
3017
  * **Verify a credential against the provider** (#605) — the read that turns "stored"
2855
3018
  * into "works, and for this account".
@@ -5606,6 +5769,26 @@ export function createControlPlaneApi(options) {
5606
5769
  throw e;
5607
5770
  }
5608
5771
  });
5772
+ // Move a fork's GC deadline (#3314), over the audited `setScopeExpiresAt`. The snapshot GC
5773
+ // reaps exactly what this admits — a fork, or a source-less preview — once the instant passes,
5774
+ // so a primary scope is refused: an expiry on it would mean nothing, and reads as if it did.
5775
+ // `null` pins a fork (a pre-promote snapshot someone means to keep); an instant gives one an
5776
+ // end, which is how the snapshots made before pre-promote copies expired are backfilled.
5777
+ // Staff/service only: on neither the builder nor the tenant-credential allowlist.
5778
+ app.put('/tenants/:tenantId/scopes/:scopeId/expires-at', async (c) => {
5779
+ const tenantId = tenantIdSchema.parse(c.req.param('tenantId'));
5780
+ const scopeId = scopeIdSchema.parse(c.req.param('scopeId'));
5781
+ const actor = c.get('actor');
5782
+ const { expiresAt } = await readJsonBody(c, scopeExpiresAtBody);
5783
+ const scope = await c.var.admin.getScopeRecord(actor, tenantId, scopeId);
5784
+ if (!scope)
5785
+ return refuse(c, 'not_found', `unknown scope for tenant: (${tenantId}, ${scopeId})`);
5786
+ if (!scope.forkedFrom && scope.kind !== 'preview') {
5787
+ return refuse(c, 'conflict', `scope ${scopeId} is not a fork or a preview — only a copy may expire`);
5788
+ }
5789
+ await c.var.admin.setScopeExpiresAt(actor, tenantId, scopeId, expiresAt === null ? null : new Date(expiresAt).toISOString());
5790
+ return c.json(await c.var.admin.getScopeRecord(actor, tenantId, scopeId));
5791
+ });
5609
5792
  // Reap a fork. The fork-only refusal is surfaced HERE, before any delegation —
5610
5793
  // the vertical must never even be asked to wipe a primary scope — and re-checked
5611
5794
  // below the seam by deleteSnapshot, which also wipes the co-located storage,
@@ -8663,6 +8846,8 @@ export function createControlPlaneApi(options) {
8663
8846
  platformBindings: [
8664
8847
  ...storeBindings,
8665
8848
  ...(await migrationsDigestBindings(await admin.versionMigrations(actor, slug, versionId))),
8849
+ // #3316: what each scope object's row counts are stamped with — this is the live script.
8850
+ ...scopeWorkBindings(slug, 'live'),
8666
8851
  ],
8667
8852
  }),
8668
8853
  // #1242: the version now being served, injected as `SUBSTRAT_VERSION_ID` so the
@@ -9498,7 +9683,11 @@ export function createControlPlaneApi(options) {
9498
9683
  manifest,
9499
9684
  drivers: options.storeDrivers,
9500
9685
  // #2349: the migrations this push declares, which are the ones the version stores.
9501
- platformBindings: await migrationsDigestBindings(manifest.migrations ?? null),
9686
+ platformBindings: [
9687
+ ...(await migrationsDigestBindings(manifest.migrations ?? null)),
9688
+ // #3316: this version's own script, where its previews (and their forks) run.
9689
+ ...scopeWorkBindings(slug, 'preview'),
9690
+ ],
9502
9691
  }),
9503
9692
  // #1242: the freshly minted version id — this archive script IS that version,
9504
9693
  // and a preview routed at it stamps the signals `version` dimension honestly.
@@ -10555,6 +10744,52 @@ export function createControlPlaneApi(options) {
10555
10744
  const handle = tenant?.slug ?? tenantId;
10556
10745
  return `${slug.split('/').at(-1)}-${handle}.${jurisdiction}.${baseDomain}`;
10557
10746
  };
10747
+ /** #3232: a sample asked of a scope this control plane holds itself, whose host copies only whole. */
10748
+ const sampleNeedsVertical = (scopeId) => new ControlPlaneError(409, `scope ${scopeId} is held by the control plane's own host, which copies a scope only whole (#3232). Nothing was copied.`);
10749
+ /**
10750
+ * #3232: what a fresh fork copies, decided before it copies anything. With `maxRows`, the copy is
10751
+ * estimated at its source first (rows, per table): at or under the cap it copies as asked, over it
10752
+ * it copies `sampleOverCap` instead when that sample fits, and is otherwise refused (413) with the
10753
+ * estimate, the cap and the largest tables in the refusal. A source that cannot estimate (a
10754
+ * deployment that predates it) is copied as asked, ungated, and the note says so: the size gate
10755
+ * (`COPY_MAX_BYTES`) treats an unknown size the same way.
10756
+ */
10757
+ const forkCopyPlan = async (c, source, opts) => {
10758
+ const sampleNote = (rows, estimate) => `Data: a sample of production, the newest ${rows} rows of each table and what they reference` +
10759
+ `${estimate === undefined ? '' : ` (about ${estimate} rows)`}, not a whole copy.`;
10760
+ if (opts.maxRows === undefined)
10761
+ return opts.sample === undefined ? { note: null } : { sample: opts.sample, note: sampleNote(opts.sample) };
10762
+ const cap = opts.maxRows;
10763
+ const client = await verticalForScope(c, source);
10764
+ const estimate = (sample) => client ? retryTransient(() => client.estimateScopeCopy(source.id, sample === undefined ? {} : { sample })) : Promise.resolve('predates');
10765
+ const asked = opts.sample;
10766
+ const first = await estimate(asked);
10767
+ if (first === 'predates') {
10768
+ return {
10769
+ ...(asked === undefined ? {} : { sample: asked }),
10770
+ note: `Data: the copy could not be estimated (its source predates estimates, #3232), so the --max-rows cap of ${cap} was not applied.`,
10771
+ };
10772
+ }
10773
+ if (first.rows <= cap) {
10774
+ return asked === undefined ? { note: `Data: a whole copy of production, about ${first.rows} rows (cap ${cap}).` } : { sample: asked, note: sampleNote(asked, first.rows) };
10775
+ }
10776
+ const largest = [...first.tables].sort((a, b) => b.rows - a.rows).slice(0, 3).map((t) => `${t.name} ${t.rows}`).join(', ');
10777
+ if (asked === undefined && opts.sampleOverCap !== undefined) {
10778
+ const fallback = await estimate(opts.sampleOverCap);
10779
+ if (fallback !== 'predates' && fallback.rows <= cap) {
10780
+ return {
10781
+ sample: opts.sampleOverCap,
10782
+ note: `${sampleNote(opts.sampleOverCap, fallback.rows)} A whole copy would move about ${first.rows} rows, over the cap of ${cap}.`,
10783
+ };
10784
+ }
10785
+ throw new ControlPlaneError(413, `a copy of scope ${source.id} would move about ${first.rows} rows, and a sample of ${opts.sampleOverCap} rows per table ` +
10786
+ `${fallback === 'predates' ? 'could not be estimated' : `about ${fallback.rows}`}: over the cap of ${cap} rows (--max-rows). ` +
10787
+ `Largest tables: ${largest}. Nothing was copied (#3232). Lower --sample-over-cap, or raise --max-rows.`);
10788
+ }
10789
+ throw new ControlPlaneError(413, `a ${asked === undefined ? 'copy' : `sample of ${asked} rows per table`} of scope ${source.id} would move about ${first.rows} rows, ` +
10790
+ `over the cap of ${cap} rows (--max-rows). Largest tables: ${largest}. Nothing was copied (#3232). ` +
10791
+ (asked === undefined ? 'Pass --sample <n> to copy the newest n rows of each table instead, or raise --max-rows.' : 'Pass a smaller --sample, or raise --max-rows.'));
10792
+ };
10558
10793
  const orchestratedPreview = async (c, tenantId, slug,
10559
10794
  // A FORK copies this scope's data; `null` provisions an empty clean-room scope (#509 (b)).
10560
10795
  source, opts) => {
@@ -10828,8 +11063,11 @@ export function createControlPlaneApi(options) {
10828
11063
  'Anyone on the team can, once signed in to Substrat.',
10829
11064
  };
10830
11065
  };
11066
+ /** #3232: what this create decided to copy, said where the person pushing reads it. */
11067
+ let copyNote = null;
10831
11068
  const notesFor = (parent) => parent
10832
11069
  ? [
11070
+ ...(copyNote ? [copyNote] : []),
10833
11071
  "Settings: only non-secret Env tab settings explicitly declared for preview carryover are delivered; " +
10834
11072
  "other settings use the deployment's defaults.",
10835
11073
  ]
@@ -11226,6 +11464,11 @@ export function createControlPlaneApi(options) {
11226
11464
  ],
11227
11465
  };
11228
11466
  }
11467
+ // #3232: a fresh fork decides what it copies (whole, or a sample) before anything is reaped or
11468
+ // provisioned, so a fork refused for its cost leaves the preview it would replace in place.
11469
+ const copyPlan = source && !poll ? await forkCopyPlan(c, source, opts) : { note: null };
11470
+ copyNote = copyPlan.note;
11471
+ const sampled = copyPlan.sample === undefined ? {} : { sample: copyPlan.sample };
11229
11472
  // Free the tag: the slug is unique per tenant and the `--<tag>` hostname is still bound
11230
11473
  // to the old row, so the fresh fork below cannot be provisioned until this one is gone.
11231
11474
  // A marked row is also the GC sweep's to reap (its `expiresAt` has passed), so the sweep
@@ -11274,11 +11517,16 @@ export function createControlPlaneApi(options) {
11274
11517
  // restore blip reloads the same stage and an export fault is not recorded as a restore's.
11275
11518
  forkData = sourceClient
11276
11519
  ? async () => {
11277
- const moved = await transferScope(sourceClient, target, { from: source.id, to: previewId }, { retry: retryTransient, stamp: false, maxBytes: copyMaxBytes });
11520
+ const moved = await transferScope(sourceClient, target, { from: source.id, to: previewId }, { retry: retryTransient, stamp: false, maxBytes: copyMaxBytes, ...sampled });
11278
11521
  refuseWipedSource(moved.meta, source.id);
11279
11522
  return moved.dump;
11280
11523
  }
11281
- : async () => canonical.tables;
11524
+ : async () => {
11525
+ // #3232: this control plane's own host copies only whole; a sample asked for is never quietly dropped.
11526
+ if (copyPlan.sample !== undefined)
11527
+ throw sampleNeedsVertical(source.id);
11528
+ return canonical.tables;
11529
+ };
11282
11530
  // Directory row FIRST as `provisioning` (K-31 two-phase): a crash before the data
11283
11531
  // copy leaves an inert row that — carrying `forkedFrom` + `expiresAt` — the GC sweep
11284
11532
  // reaps, never copied data with no record.
@@ -11354,7 +11602,7 @@ export function createControlPlaneApi(options) {
11354
11602
  if (forkPaged && jobs && move && targetRef && target) {
11355
11603
  // #2450 step 2: the first page moves here. A fork that needs more moves in a job, and a
11356
11604
  // later call to this route finishes it (`finishForkJob`); the row stays `provisioning`.
11357
- const begun = await beginTransfer({ source: forkPaged.source, dest: target }, { from: forkPaged.sourceScopeId, to: previewId }, { retry: retryTransient, stamp: false, alwaysStage: true, maxBytes: copyMaxBytes });
11605
+ const begun = await beginTransfer({ source: forkPaged.source, dest: target }, { from: forkPaged.sourceScopeId, to: previewId }, { retry: retryTransient, stamp: false, alwaysStage: true, maxBytes: copyMaxBytes, ...sampled });
11358
11606
  if ('state' in begun) {
11359
11607
  const staged = begun.state;
11360
11608
  const ends = { source: forkPaged.source, dest: target };
@@ -11526,6 +11774,13 @@ export function createControlPlaneApi(options) {
11526
11774
  if (body.seed && !body.empty) {
11527
11775
  return refuse(c, 'validation_failed', 'seed needs empty: a sample world is seated only in a clean-room preview');
11528
11776
  }
11777
+ // #3232: a sample and a cap shape a FORK's copy; a clean room copies nothing.
11778
+ if (body.empty && (body.sample !== undefined || body.maxRows !== undefined || body.sampleOverCap !== undefined)) {
11779
+ return refuse(c, 'validation_failed', 'sample, maxRows and sampleOverCap shape a fork\'s copy; a clean-room preview copies nothing');
11780
+ }
11781
+ if (body.sampleOverCap !== undefined && (body.maxRows === undefined || body.sample !== undefined)) {
11782
+ return refuse(c, 'validation_failed', 'sampleOverCap needs maxRows, and replaces sample: pass sample to always copy a sample');
11783
+ }
11529
11784
  if (body.seed && !options.personaIssuer) {
11530
11785
  return refuse(c, 'unavailable', 'this control plane runs no persona issuer, so it cannot sign a seeded preview in');
11531
11786
  }
@@ -12208,9 +12463,63 @@ export function createControlPlaneApi(options) {
12208
12463
  const now = new Date();
12209
12464
  const since = q.since ?? new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)).toISOString();
12210
12465
  const until = q.until ?? now.toISOString();
12211
- const summary = await c.var.admin.summarizeModelUsage(c.get('actor'), { ...(q.tenantId ? { tenantId: q.tenantId } : {}), since, until }, options.modelMarginPercent ?? DEFAULT_MODEL_MARGIN_PERCENT, options.reviewUsage?.zeroRated ? { zeroRatedScopes: [options.reviewUsage.scope] } : {});
12466
+ // #3316: each line at the model-calls row in force for its tenant on its day; the summary's
12467
+ // `marginPercent` is the platform's rate on the window's last day.
12468
+ const markup = await markupScheduleFor(c.var.admin, c.get('actor'), q.tenantId);
12469
+ const summary = await c.var.admin.summarizeModelUsage(c.get('actor'), { ...(q.tenantId ? { tenantId: q.tenantId } : {}), since, until }, platformModelMargin(markup, until), {
12470
+ ...(markup ? { markup } : {}),
12471
+ ...(options.reviewUsage?.zeroRated ? { zeroRatedScopes: [options.reviewUsage.scope] } : {}),
12472
+ });
12212
12473
  return c.json(summary);
12213
12474
  });
12475
+ // -- the markup schedule (#3316, Pricing) -------------------------------------
12476
+ // What a tenant is charged over cost: a default plus overrides per tenant, billed dimension and
12477
+ // kind, dated and never edited. Staff only, on neither allowlist: a tenant sees prices, never the
12478
+ // markup behind them. Every row added is a `setMarkup` admin row, committed with it.
12479
+ app.get('/markup-schedule', async (c) => {
12480
+ if (c.get('principal').kind !== 'staff')
12481
+ return refuse(c, 'forbidden', 'forbidden');
12482
+ const { tenantId } = z.object({ tenantId: tenantIdSchema.optional() }).parse({ tenantId: c.req.query('tenantId') });
12483
+ const rows = await markupScheduleFor(c.var.admin, c.get('actor'), tenantId);
12484
+ if (!rows)
12485
+ throw new ControlPlaneError(501, 'this control plane keeps no markup schedule');
12486
+ return c.json({ rows });
12487
+ });
12488
+ app.post('/markup-schedule', async (c) => {
12489
+ if (c.get('principal').kind !== 'staff')
12490
+ return refuse(c, 'forbidden', 'forbidden');
12491
+ if (!c.var.admin.setMarkup)
12492
+ throw new ControlPlaneError(501, 'this control plane keeps no markup schedule');
12493
+ const input = markupRowInput.parse(await c.req.json());
12494
+ if (input.tenantId && !(await c.var.admin.getTenant(c.get('actor'), input.tenantId))) {
12495
+ return refuse(c, 'not_found', 'no such tenant');
12496
+ }
12497
+ return c.json(await c.var.admin.setMarkup(c.get('actor'), input), 201);
12498
+ });
12499
+ // #1054: the ledger against what Cloudflare saw, per closed UTC day and per (tenant, scope, model).
12500
+ // Staff-only, like the ledger it reads, and computed on every request: nothing is stored. The
12501
+ // scheduled pass files each day's findings once; this is where a person reads the whole day.
12502
+ // Gateway analytics answer for about two months, so a day older than that reads as gateway-free.
12503
+ app.get('/model-usage/reconciliation', async (c) => {
12504
+ const recon = options.modelReconciliation;
12505
+ if (!recon)
12506
+ throw new ControlPlaneError(501, 'this control plane does not read Cloudflare analytics');
12507
+ const q = modelReconciliationQuery.parse({ since: c.req.query('since'), until: c.req.query('until') });
12508
+ const today = new Date().toISOString().slice(0, 10);
12509
+ const yesterday = new Date(Date.parse(`${today}T00:00:00.000Z`) - 86_400_000).toISOString().slice(0, 10);
12510
+ const since = q.since ?? q.until ?? yesterday;
12511
+ const until = q.until ?? (q.since && q.since > yesterday ? q.since : yesterday);
12512
+ if (since > until)
12513
+ return refuse(c, 'validation_failed', '`since` is after `until`');
12514
+ if (until >= today)
12515
+ return refuse(c, 'validation_failed', 'only closed UTC days reconcile: `until` must be before today');
12516
+ const days = daysBetween(since, until);
12517
+ if (days.length > MODEL_RECONCILIATION_MAX_DAYS) {
12518
+ return refuse(c, 'validation_failed', `at most ${MODEL_RECONCILIATION_MAX_DAYS} days per read`);
12519
+ }
12520
+ const result = await reconcileModelDays({ admin: c.var.admin, actor: c.get('actor'), reader: recon.reader, gatewayProviders: recon.gatewayProviders }, days);
12521
+ return c.json(modelReconciliation.parse({ since, until, days: result }));
12522
+ });
12214
12523
  // -- store-driver releases (D-63, #2300) ----------------------------------------
12215
12524
  // Staff only: none of these is on the builder or the tenant allowlist. A write is also made by a
12216
12525
  // person: `humanStaffActor` must name the same actor from a human staff sign-in, so the