@substrat-run/control-plane-api 0.205.0 → 0.206.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.
- package/dist/api.d.ts +27 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +240 -7
- package/dist/api.js.map +1 -1
- package/dist/cf-observability.d.ts +34 -0
- package/dist/cf-observability.d.ts.map +1 -1
- package/dist/cf-observability.js +144 -1
- package/dist/cf-observability.js.map +1 -1
- package/dist/connection-choice.d.ts +47 -0
- package/dist/connection-choice.d.ts.map +1 -0
- package/dist/connection-choice.js +156 -0
- package/dist/connection-choice.js.map +1 -0
- package/dist/deploy.d.ts +12 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +13 -1
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/model-reconcile.d.ts +173 -0
- package/dist/model-reconcile.d.ts.map +1 -0
- package/dist/model-reconcile.js +434 -0
- package/dist/model-reconcile.js.map +1 -0
- package/dist/platform-entry.generated.d.ts +1 -1
- package/dist/platform-entry.generated.d.ts.map +1 -1
- package/dist/platform-entry.generated.js +2 -2
- package/dist/platform-entry.generated.js.map +1 -1
- package/dist/scope-copy-cleanup.d.ts +5 -1
- package/dist/scope-copy-cleanup.d.ts.map +1 -1
- package/dist/scope-copy-cleanup.js +4 -2
- package/dist/scope-copy-cleanup.js.map +1 -1
- package/dist/staff-client.d.ts +10 -1
- package/dist/staff-client.d.ts.map +1 -1
- package/dist/staff-client.js +4 -0
- package/dist/staff-client.js.map +1 -1
- package/dist/vertical-client.d.ts +6 -0
- package/dist/vertical-client.d.ts.map +1 -1
- package/dist/vertical-client.js +12 -0
- package/dist/vertical-client.js.map +1 -1
- package/dist/wfp.d.ts +7 -0
- package/dist/wfp.d.ts.map +1 -1
- package/dist/wfp.js +6 -0
- package/dist/wfp.js.map +1 -1
- package/package.json +9 -9
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
|
|
133
|
-
*
|
|
134
|
-
*
|
|
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
|
-
|
|
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,
|
|
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,OA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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, 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)
|
|
@@ -740,6 +746,13 @@ const modelUsageQuery = z.object({
|
|
|
740
746
|
until: z.string().optional(),
|
|
741
747
|
...listPageQuery.shape,
|
|
742
748
|
});
|
|
749
|
+
/** Inclusive UTC days for `GET /model-usage/reconciliation`; both default to yesterday. */
|
|
750
|
+
const modelReconciliationQuery = z.object({
|
|
751
|
+
since: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
752
|
+
until: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
753
|
+
});
|
|
754
|
+
/** The most days one reconciliation read covers: each is a ledger walk and a GraphQL read. */
|
|
755
|
+
export const MODEL_RECONCILIATION_MAX_DAYS = 14;
|
|
743
756
|
/** The summary window: a half-open `[since, until)`; defaults to the current calendar month so far. */
|
|
744
757
|
/**
|
|
745
758
|
* One line for a model call no drain carries (`POST /model-usage`). `requestId` is the ledger's
|
|
@@ -751,7 +764,32 @@ const modelUsageSummaryQuery = z.object({
|
|
|
751
764
|
since: z.string().optional(),
|
|
752
765
|
until: z.string().optional(),
|
|
753
766
|
});
|
|
754
|
-
|
|
767
|
+
/**
|
|
768
|
+
* The margin over list price on platform-provided model calls, whole percent: the markup
|
|
769
|
+
* schedule's seeded `model-calls` row (30%, the owner's rate of 2026-11-21, #3316), read from the
|
|
770
|
+
* seed rather than restated. The ledger's reads price from the schedule itself, a tenant's own
|
|
771
|
+
* row and a dated change included; this is the rate only for a host that keeps no schedule.
|
|
772
|
+
*/
|
|
773
|
+
export const DEFAULT_MODEL_MARGIN_PERCENT = markupPercentFor(MARKUP_SEED, {
|
|
774
|
+
tenantId: null,
|
|
775
|
+
dimension: 'model-calls',
|
|
776
|
+
kind: 'live',
|
|
777
|
+
day: MARKUP_SEED_EFFECTIVE_FROM,
|
|
778
|
+
});
|
|
779
|
+
/**
|
|
780
|
+
* The markup schedule a read prices from (#3316): every row, or the rows that can price one
|
|
781
|
+
* tenant. Null from a host that keeps no schedule, whose reads fall back to the fixed rate.
|
|
782
|
+
*/
|
|
783
|
+
async function markupScheduleFor(admin, actor, tenantId) {
|
|
784
|
+
if (!admin.listMarkup)
|
|
785
|
+
return null;
|
|
786
|
+
return admin.listMarkup(actor, tenantId ? { tenantId } : undefined);
|
|
787
|
+
}
|
|
788
|
+
/** The platform's `model-calls` rate on `at`'s day: the summary's headline rate. */
|
|
789
|
+
function platformModelMarginFor(markup, at, fallback) {
|
|
790
|
+
const percent = markup ? markupPercentFor(markup, { tenantId: null, dimension: 'model-calls', kind: 'live', day: at.slice(0, 10) }) : null;
|
|
791
|
+
return percent ?? fallback;
|
|
792
|
+
}
|
|
755
793
|
/**
|
|
756
794
|
* The most review lines one tenant's metered-usage read folds. A tenant's reviews are capped far
|
|
757
795
|
* below it at intake (50 kept in 30 days), so reaching it marks the figure a lower bound.
|
|
@@ -787,6 +825,9 @@ const TENANT_ROUTES = [
|
|
|
787
825
|
// #2343: a mail connection's test send. The dashboard sends it only to the signed-in person.
|
|
788
826
|
{ method: 'POST', re: /\/tenants\/[^/]+\/connections\/[^/]+\/send-test$/, pin: 'path' },
|
|
789
827
|
{ method: 'GET', re: /\/tenants\/[^/]+\/connections\/[^/]+\/senders$/, pin: 'path' },
|
|
828
|
+
// #3221: which of the tenant's connections an install's checkouts go through.
|
|
829
|
+
{ method: 'GET', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/connections\/[^/]+\/choice$/, pin: 'path' },
|
|
830
|
+
{ method: 'PUT', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/connections\/[^/]+\/choice$/, pin: 'path' },
|
|
790
831
|
// #2611: one app's mail-in address — read it, and request, rotate or revoke it.
|
|
791
832
|
{ method: 'GET', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/mail-in$/, pin: 'path' },
|
|
792
833
|
{ method: 'POST', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/mail-in$/, pin: 'path' },
|
|
@@ -1190,6 +1231,8 @@ export function createControlPlaneApi(options) {
|
|
|
1190
1231
|
}
|
|
1191
1232
|
};
|
|
1192
1233
|
const app = new Hono();
|
|
1234
|
+
/** #3316: the platform's model-calls rate on a day, or the fixed rate from a host keeping no schedule. */
|
|
1235
|
+
const platformModelMargin = (markup, at) => platformModelMarginFor(markup, at, options.modelMarginPercent ?? DEFAULT_MODEL_MARGIN_PERCENT);
|
|
1193
1236
|
// Every refusal is a problem document (#113): the tripwire. A route answers a failure
|
|
1194
1237
|
// through `refuse`/`refuseStatus`/`problem`, and anything else — a hand-rolled
|
|
1195
1238
|
// `c.json({ error }, 4xx)`, a sub-app's text 404 — is logged here as
|
|
@@ -2064,8 +2107,10 @@ export function createControlPlaneApi(options) {
|
|
|
2064
2107
|
});
|
|
2065
2108
|
const kept = lines.slice(0, REVIEW_USAGE_READ_MAX);
|
|
2066
2109
|
const clipped = lines.length > REVIEW_USAGE_READ_MAX;
|
|
2110
|
+
const markup = await markupScheduleFor(admin, actor, tenantId);
|
|
2067
2111
|
const folded = foldModelUsage(kept, {
|
|
2068
|
-
readAt, ...window, marginPercent:
|
|
2112
|
+
readAt, ...window, marginPercent: platformModelMargin(markup, until),
|
|
2113
|
+
...(markup ? { markup } : {}),
|
|
2069
2114
|
...(zeroRated ? { zeroRatedScopes: [options.reviewUsage.scope] } : {}),
|
|
2070
2115
|
}).totals;
|
|
2071
2116
|
const reported = kept.filter((line) => line.reported);
|
|
@@ -2275,6 +2320,72 @@ export function createControlPlaneApi(options) {
|
|
|
2275
2320
|
days,
|
|
2276
2321
|
}));
|
|
2277
2322
|
});
|
|
2323
|
+
// The daily Cloudflare cost rollup (#3316): the stored cost inputs per (day, script, scope, Durable
|
|
2324
|
+
// Object class, billed dimension), attributed through the directory, and the rollup's record of each
|
|
2325
|
+
// day in the window. Staff-only like `/meters`. Quantities only, never a price: the markup schedule
|
|
2326
|
+
// prices them at read. A directory read; nothing is queried live.
|
|
2327
|
+
const COST_ROLLUP_PAGE_MAX = COST_ROLLUP_LIMIT_MAX / 2;
|
|
2328
|
+
app.get('/meters/cloudflare-costs', async (c) => {
|
|
2329
|
+
const admin = c.var.admin;
|
|
2330
|
+
if (!admin.listCostDays || !admin.listCostRollupDays) {
|
|
2331
|
+
return refuseStatus(c, 501, 'this control plane keeps no Cloudflare cost rollup');
|
|
2332
|
+
}
|
|
2333
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
2334
|
+
const q = z
|
|
2335
|
+
.object({
|
|
2336
|
+
tenantId: tenantIdSchema.optional(),
|
|
2337
|
+
scopeId: scopeIdSchema.optional(),
|
|
2338
|
+
vertical: z.string().min(1).optional(),
|
|
2339
|
+
attribution: costAttribution.optional(),
|
|
2340
|
+
since: utcDay.optional(),
|
|
2341
|
+
until: utcDay.default(today),
|
|
2342
|
+
limit: z.coerce.number().int().min(1).max(COST_ROLLUP_PAGE_MAX).default(COST_ROLLUP_LIMIT_DEFAULT),
|
|
2343
|
+
})
|
|
2344
|
+
.parse({
|
|
2345
|
+
tenantId: c.req.query('tenantId') || undefined,
|
|
2346
|
+
scopeId: c.req.query('scopeId') || undefined,
|
|
2347
|
+
vertical: c.req.query('vertical') || undefined,
|
|
2348
|
+
attribution: c.req.query('attribution') || undefined,
|
|
2349
|
+
since: c.req.query('since') || undefined,
|
|
2350
|
+
until: c.req.query('until') || undefined,
|
|
2351
|
+
limit: c.req.query('limit') || undefined,
|
|
2352
|
+
});
|
|
2353
|
+
const since = q.since ?? windowSince(q.until);
|
|
2354
|
+
if (since > q.until)
|
|
2355
|
+
return refuse(c, 'validation_failed', '`since` is after `until`');
|
|
2356
|
+
const actor = c.get('actor');
|
|
2357
|
+
const rows = await admin.listCostDays(actor, {
|
|
2358
|
+
...(q.tenantId ? { tenantId: q.tenantId } : {}),
|
|
2359
|
+
...(q.scopeId ? { scopeId: q.scopeId } : {}),
|
|
2360
|
+
...(q.vertical ? { vertical: q.vertical } : {}),
|
|
2361
|
+
...(q.attribution ? { attribution: q.attribution } : {}),
|
|
2362
|
+
since,
|
|
2363
|
+
until: q.until,
|
|
2364
|
+
limit: q.limit + 1,
|
|
2365
|
+
});
|
|
2366
|
+
const days = await admin.listCostRollupDays(actor, { since, until: q.until });
|
|
2367
|
+
return c.json(costRollupReading.parse({ since, until: q.until, rows: rows.slice(0, q.limit), truncated: rows.length > q.limit, days }));
|
|
2368
|
+
});
|
|
2369
|
+
// #3316: load one day of a raw Cloudflare usage snapshot into the cost rollup, for the history the
|
|
2370
|
+
// analytics no longer answer for. The day is attributed through the directory by the same code the
|
|
2371
|
+
// scheduled pass runs. A day already read is refused, so a snapshot never replaces a read that
|
|
2372
|
+
// carries its confidence intervals; so is a day that has not ended. Staff-only like `/meters`.
|
|
2373
|
+
app.post('/meters/cloudflare-costs/days', async (c) => {
|
|
2374
|
+
const admin = c.var.admin;
|
|
2375
|
+
if (!admin.recordCostDay || !admin.listCostRollupDays) {
|
|
2376
|
+
return refuseStatus(c, 501, 'this control plane keeps no Cloudflare cost rollup');
|
|
2377
|
+
}
|
|
2378
|
+
const usage = cloudflareUsageDay.parse(await c.req.json());
|
|
2379
|
+
if (usage.day >= new Date().toISOString().slice(0, 10)) {
|
|
2380
|
+
return refuse(c, 'validation_failed', `${usage.day} has not ended`);
|
|
2381
|
+
}
|
|
2382
|
+
const actor = c.get('actor');
|
|
2383
|
+
const [read] = await admin.listCostRollupDays(actor, { since: usage.day, until: usage.day });
|
|
2384
|
+
if (read?.readAt)
|
|
2385
|
+
return refuse(c, 'conflict', `${usage.day} was already read at ${read.readAt}; a snapshot does not replace it`);
|
|
2386
|
+
const { recorded } = await admin.recordCostDay(actor, { day: usage.day, attemptedAt: new Date().toISOString(), usage });
|
|
2387
|
+
return c.json({ day: usage.day, recorded }, 201);
|
|
2388
|
+
});
|
|
2278
2389
|
// The daily meter snapshot (#2501): meters 1 and 2 as the first scheduled pass of each UTC day
|
|
2279
2390
|
// found them, one row per (day, tenant), and the record of each day in the window. Staff-only
|
|
2280
2391
|
// like `/meters`. A directory read; nothing is recomputed, so a past day reads as it was then.
|
|
@@ -2850,6 +2961,48 @@ export function createControlPlaneApi(options) {
|
|
|
2850
2961
|
}
|
|
2851
2962
|
return c.json({ ...done.result, permissionHeld: true, ...('unrecorded' in done ? { auditWarning: done.unrecorded } : {}) });
|
|
2852
2963
|
});
|
|
2964
|
+
/**
|
|
2965
|
+
* #3221: which tenant connection one install lands through, for a provider that lands each install
|
|
2966
|
+
* through one (a payment provider, `ConnectionBinder.exclusive`). Tenant-callable: the choice is the
|
|
2967
|
+
* tenant's, made from its dashboard. See `connection-choice.ts`.
|
|
2968
|
+
*/
|
|
2969
|
+
const choiceRefusal = (c, err) => {
|
|
2970
|
+
if (err instanceof ConnectionRelayError && err.status < 500) {
|
|
2971
|
+
return err.code ? refuse(c, err.code, err.message) : refuseStatus(c, err.status, err.message);
|
|
2972
|
+
}
|
|
2973
|
+
throw err;
|
|
2974
|
+
};
|
|
2975
|
+
const choiceInput = (c) => ({
|
|
2976
|
+
tenantId: tenantIdSchema.parse(c.req.param('tenantId')),
|
|
2977
|
+
scopeId: scopeIdSchema.parse(c.req.param('scopeId')),
|
|
2978
|
+
provider: connectionProvider.parse(c.req.param('provider')),
|
|
2979
|
+
});
|
|
2980
|
+
app.get('/tenants/:tenantId/scopes/:scopeId/connections/:provider/choice', async (c) => {
|
|
2981
|
+
const landings = options.connectionLandings;
|
|
2982
|
+
if (!landings)
|
|
2983
|
+
return refuseStatus(c, 501, 'this control plane binds no connection landings');
|
|
2984
|
+
try {
|
|
2985
|
+
return c.json(await readScopeConnectionChoice(c.var.host, c.get('actor'), choiceInput(c), { landings }));
|
|
2986
|
+
}
|
|
2987
|
+
catch (err) {
|
|
2988
|
+
return choiceRefusal(c, err);
|
|
2989
|
+
}
|
|
2990
|
+
});
|
|
2991
|
+
app.put('/tenants/:tenantId/scopes/:scopeId/connections/:provider/choice', async (c) => {
|
|
2992
|
+
const landings = options.connectionLandings;
|
|
2993
|
+
if (!landings)
|
|
2994
|
+
return refuseStatus(c, 501, 'this control plane binds no connection landings');
|
|
2995
|
+
const body = z
|
|
2996
|
+
.object({ connectionId: z.string().min(1), chosenBy: z.string().min(1).max(200).optional() })
|
|
2997
|
+
.strict()
|
|
2998
|
+
.parse(await c.req.json());
|
|
2999
|
+
try {
|
|
3000
|
+
return c.json(await chooseScopeConnection(c.var.host, c.get('actor'), { ...choiceInput(c), ...body }, { landings }));
|
|
3001
|
+
}
|
|
3002
|
+
catch (err) {
|
|
3003
|
+
return choiceRefusal(c, err);
|
|
3004
|
+
}
|
|
3005
|
+
});
|
|
2853
3006
|
/**
|
|
2854
3007
|
* **Verify a credential against the provider** (#605) — the read that turns "stored"
|
|
2855
3008
|
* into "works, and for this account".
|
|
@@ -5606,6 +5759,26 @@ export function createControlPlaneApi(options) {
|
|
|
5606
5759
|
throw e;
|
|
5607
5760
|
}
|
|
5608
5761
|
});
|
|
5762
|
+
// Move a fork's GC deadline (#3314), over the audited `setScopeExpiresAt`. The snapshot GC
|
|
5763
|
+
// reaps exactly what this admits — a fork, or a source-less preview — once the instant passes,
|
|
5764
|
+
// so a primary scope is refused: an expiry on it would mean nothing, and reads as if it did.
|
|
5765
|
+
// `null` pins a fork (a pre-promote snapshot someone means to keep); an instant gives one an
|
|
5766
|
+
// end, which is how the snapshots made before pre-promote copies expired are backfilled.
|
|
5767
|
+
// Staff/service only: on neither the builder nor the tenant-credential allowlist.
|
|
5768
|
+
app.put('/tenants/:tenantId/scopes/:scopeId/expires-at', async (c) => {
|
|
5769
|
+
const tenantId = tenantIdSchema.parse(c.req.param('tenantId'));
|
|
5770
|
+
const scopeId = scopeIdSchema.parse(c.req.param('scopeId'));
|
|
5771
|
+
const actor = c.get('actor');
|
|
5772
|
+
const { expiresAt } = await readJsonBody(c, scopeExpiresAtBody);
|
|
5773
|
+
const scope = await c.var.admin.getScopeRecord(actor, tenantId, scopeId);
|
|
5774
|
+
if (!scope)
|
|
5775
|
+
return refuse(c, 'not_found', `unknown scope for tenant: (${tenantId}, ${scopeId})`);
|
|
5776
|
+
if (!scope.forkedFrom && scope.kind !== 'preview') {
|
|
5777
|
+
return refuse(c, 'conflict', `scope ${scopeId} is not a fork or a preview — only a copy may expire`);
|
|
5778
|
+
}
|
|
5779
|
+
await c.var.admin.setScopeExpiresAt(actor, tenantId, scopeId, expiresAt === null ? null : new Date(expiresAt).toISOString());
|
|
5780
|
+
return c.json(await c.var.admin.getScopeRecord(actor, tenantId, scopeId));
|
|
5781
|
+
});
|
|
5609
5782
|
// Reap a fork. The fork-only refusal is surfaced HERE, before any delegation —
|
|
5610
5783
|
// the vertical must never even be asked to wipe a primary scope — and re-checked
|
|
5611
5784
|
// below the seam by deleteSnapshot, which also wipes the co-located storage,
|
|
@@ -8663,6 +8836,8 @@ export function createControlPlaneApi(options) {
|
|
|
8663
8836
|
platformBindings: [
|
|
8664
8837
|
...storeBindings,
|
|
8665
8838
|
...(await migrationsDigestBindings(await admin.versionMigrations(actor, slug, versionId))),
|
|
8839
|
+
// #3316: what each scope object's row counts are stamped with — this is the live script.
|
|
8840
|
+
...scopeWorkBindings(slug, 'live'),
|
|
8666
8841
|
],
|
|
8667
8842
|
}),
|
|
8668
8843
|
// #1242: the version now being served, injected as `SUBSTRAT_VERSION_ID` so the
|
|
@@ -9498,7 +9673,11 @@ export function createControlPlaneApi(options) {
|
|
|
9498
9673
|
manifest,
|
|
9499
9674
|
drivers: options.storeDrivers,
|
|
9500
9675
|
// #2349: the migrations this push declares, which are the ones the version stores.
|
|
9501
|
-
platformBindings:
|
|
9676
|
+
platformBindings: [
|
|
9677
|
+
...(await migrationsDigestBindings(manifest.migrations ?? null)),
|
|
9678
|
+
// #3316: this version's own script, where its previews (and their forks) run.
|
|
9679
|
+
...scopeWorkBindings(slug, 'preview'),
|
|
9680
|
+
],
|
|
9502
9681
|
}),
|
|
9503
9682
|
// #1242: the freshly minted version id — this archive script IS that version,
|
|
9504
9683
|
// and a preview routed at it stamps the signals `version` dimension honestly.
|
|
@@ -12208,9 +12387,63 @@ export function createControlPlaneApi(options) {
|
|
|
12208
12387
|
const now = new Date();
|
|
12209
12388
|
const since = q.since ?? new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)).toISOString();
|
|
12210
12389
|
const until = q.until ?? now.toISOString();
|
|
12211
|
-
|
|
12390
|
+
// #3316: each line at the model-calls row in force for its tenant on its day; the summary's
|
|
12391
|
+
// `marginPercent` is the platform's rate on the window's last day.
|
|
12392
|
+
const markup = await markupScheduleFor(c.var.admin, c.get('actor'), q.tenantId);
|
|
12393
|
+
const summary = await c.var.admin.summarizeModelUsage(c.get('actor'), { ...(q.tenantId ? { tenantId: q.tenantId } : {}), since, until }, platformModelMargin(markup, until), {
|
|
12394
|
+
...(markup ? { markup } : {}),
|
|
12395
|
+
...(options.reviewUsage?.zeroRated ? { zeroRatedScopes: [options.reviewUsage.scope] } : {}),
|
|
12396
|
+
});
|
|
12212
12397
|
return c.json(summary);
|
|
12213
12398
|
});
|
|
12399
|
+
// -- the markup schedule (#3316, Pricing) -------------------------------------
|
|
12400
|
+
// What a tenant is charged over cost: a default plus overrides per tenant, billed dimension and
|
|
12401
|
+
// kind, dated and never edited. Staff only, on neither allowlist: a tenant sees prices, never the
|
|
12402
|
+
// markup behind them. Every row added is a `setMarkup` admin row, committed with it.
|
|
12403
|
+
app.get('/markup-schedule', async (c) => {
|
|
12404
|
+
if (c.get('principal').kind !== 'staff')
|
|
12405
|
+
return refuse(c, 'forbidden', 'forbidden');
|
|
12406
|
+
const { tenantId } = z.object({ tenantId: tenantIdSchema.optional() }).parse({ tenantId: c.req.query('tenantId') });
|
|
12407
|
+
const rows = await markupScheduleFor(c.var.admin, c.get('actor'), tenantId);
|
|
12408
|
+
if (!rows)
|
|
12409
|
+
throw new ControlPlaneError(501, 'this control plane keeps no markup schedule');
|
|
12410
|
+
return c.json({ rows });
|
|
12411
|
+
});
|
|
12412
|
+
app.post('/markup-schedule', async (c) => {
|
|
12413
|
+
if (c.get('principal').kind !== 'staff')
|
|
12414
|
+
return refuse(c, 'forbidden', 'forbidden');
|
|
12415
|
+
if (!c.var.admin.setMarkup)
|
|
12416
|
+
throw new ControlPlaneError(501, 'this control plane keeps no markup schedule');
|
|
12417
|
+
const input = markupRowInput.parse(await c.req.json());
|
|
12418
|
+
if (input.tenantId && !(await c.var.admin.getTenant(c.get('actor'), input.tenantId))) {
|
|
12419
|
+
return refuse(c, 'not_found', 'no such tenant');
|
|
12420
|
+
}
|
|
12421
|
+
return c.json(await c.var.admin.setMarkup(c.get('actor'), input), 201);
|
|
12422
|
+
});
|
|
12423
|
+
// #1054: the ledger against what Cloudflare saw, per closed UTC day and per (tenant, scope, model).
|
|
12424
|
+
// Staff-only, like the ledger it reads, and computed on every request: nothing is stored. The
|
|
12425
|
+
// scheduled pass files each day's findings once; this is where a person reads the whole day.
|
|
12426
|
+
// Gateway analytics answer for about two months, so a day older than that reads as gateway-free.
|
|
12427
|
+
app.get('/model-usage/reconciliation', async (c) => {
|
|
12428
|
+
const recon = options.modelReconciliation;
|
|
12429
|
+
if (!recon)
|
|
12430
|
+
throw new ControlPlaneError(501, 'this control plane does not read Cloudflare analytics');
|
|
12431
|
+
const q = modelReconciliationQuery.parse({ since: c.req.query('since'), until: c.req.query('until') });
|
|
12432
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
12433
|
+
const yesterday = new Date(Date.parse(`${today}T00:00:00.000Z`) - 86_400_000).toISOString().slice(0, 10);
|
|
12434
|
+
const since = q.since ?? q.until ?? yesterday;
|
|
12435
|
+
const until = q.until ?? (q.since && q.since > yesterday ? q.since : yesterday);
|
|
12436
|
+
if (since > until)
|
|
12437
|
+
return refuse(c, 'validation_failed', '`since` is after `until`');
|
|
12438
|
+
if (until >= today)
|
|
12439
|
+
return refuse(c, 'validation_failed', 'only closed UTC days reconcile: `until` must be before today');
|
|
12440
|
+
const days = daysBetween(since, until);
|
|
12441
|
+
if (days.length > MODEL_RECONCILIATION_MAX_DAYS) {
|
|
12442
|
+
return refuse(c, 'validation_failed', `at most ${MODEL_RECONCILIATION_MAX_DAYS} days per read`);
|
|
12443
|
+
}
|
|
12444
|
+
const result = await reconcileModelDays({ admin: c.var.admin, actor: c.get('actor'), reader: recon.reader, gatewayProviders: recon.gatewayProviders }, days);
|
|
12445
|
+
return c.json(modelReconciliation.parse({ since, until, days: result }));
|
|
12446
|
+
});
|
|
12214
12447
|
// -- store-driver releases (D-63, #2300) ----------------------------------------
|
|
12215
12448
|
// Staff only: none of these is on the builder or the tenant allowlist. A write is also made by a
|
|
12216
12449
|
// person: `humanStaffActor` must name the same actor from a human staff sign-in, so the
|