@substrat-run/control-plane-api 0.201.0 → 0.202.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 +42 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +159 -6
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/managed-sign-in.d.ts +83 -0
- package/dist/managed-sign-in.d.ts.map +1 -0
- package/dist/managed-sign-in.js +111 -0
- package/dist/managed-sign-in.js.map +1 -0
- package/dist/platform-drain.d.ts +0 -12
- package/dist/platform-drain.d.ts.map +1 -1
- package/dist/platform-drain.js +34 -18
- package/dist/platform-drain.js.map +1 -1
- package/dist/social-relay.d.ts +39 -2
- package/dist/social-relay.d.ts.map +1 -1
- package/dist/social-relay.js +27 -1
- package/dist/social-relay.js.map +1 -1
- package/dist/vertical-client.d.ts +10 -1
- package/dist/vertical-client.d.ts.map +1 -1
- package/dist/vertical-client.js +17 -4
- package/dist/vertical-client.js.map +1 -1
- package/package.json +10 -10
package/dist/api.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { ConnectionScopeBinding, ConnectionScopeBindingInput } from '@subst
|
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { type ConnectionCertificate, z, type ScopeStoreNeed, type StoreDriverRegistration } from '@substrat-run/contracts';
|
|
6
6
|
import type { Connection, ConnectionActivity, ConnectionActivitySource, ConnectionCredential, ConnectionProbe, PlatformActorId, ScopeId, TenantId } from '@substrat-run/contracts';
|
|
7
|
+
import { type MailInAddress, type MailInAddressAct, type MailInStanding } from '@substrat-run/contracts';
|
|
7
8
|
import type { CrossVerticalOptions, HostAdmin, MailSender, OpsFailureInput, ScopeHost } from '@substrat-run/kernel';
|
|
8
9
|
import type { PlatformActorAuth, BuilderAuth, Principal, TenantServiceAuth } from './auth.js';
|
|
9
10
|
import { type VerticalClient } from './vertical-client.js';
|
|
@@ -26,6 +27,27 @@ import type { WireSettingsApi } from './wire-settings.js';
|
|
|
26
27
|
import { type LakeQueryEngine } from './lake-gateway.js';
|
|
27
28
|
import { type CustomHostnameProvisioner } from './custom-hostnames.js';
|
|
28
29
|
import { type SocialRelayOptions } from './social-relay.js';
|
|
30
|
+
/**
|
|
31
|
+
* Inbound mail's tenant door (#2611): a team reads, requests, rotates and revokes one of its apps'
|
|
32
|
+
* mail-in addresses, behind `GET`/`POST /tenants/:t/scopes/:s/mail-in`. Host-injected, because the
|
|
33
|
+
* address lifecycle is the platform's mail-in connector, which this package does not carry. Both
|
|
34
|
+
* halves take the scope with its tenant, and answer a scope that is not the tenant's as one that
|
|
35
|
+
* does not exist.
|
|
36
|
+
*
|
|
37
|
+
* A refusal is thrown as an error carrying `status` (and, where the taxonomy has one, `code`): a
|
|
38
|
+
* status under 500 is answered as the caller's problem, anything else is the platform's.
|
|
39
|
+
*/
|
|
40
|
+
export interface MailInTenantDoor {
|
|
41
|
+
standing(host: ScopeHost, scope: {
|
|
42
|
+
tenantId: TenantId;
|
|
43
|
+
scopeId: ScopeId;
|
|
44
|
+
}): Promise<MailInStanding>;
|
|
45
|
+
/** The address after the act: null once revoked. */
|
|
46
|
+
act(host: ScopeHost, scope: {
|
|
47
|
+
tenantId: TenantId;
|
|
48
|
+
scopeId: ScopeId;
|
|
49
|
+
}, act: MailInAddressAct): Promise<MailInAddress | null>;
|
|
50
|
+
}
|
|
29
51
|
/**
|
|
30
52
|
* What one provider can answer about a live connection (#605) — the seam behind
|
|
31
53
|
* `POST /tenants/:t/connections/:id/verify` and `GET …/activity`.
|
|
@@ -112,6 +134,16 @@ export interface ControlPlaneApiOptions {
|
|
|
112
134
|
* today; a per-provider rate is an additive change later. Default 20.
|
|
113
135
|
*/
|
|
114
136
|
modelMarginPercent?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Where code reviews' model usage is filed, and whether it is priced at zero for now (#2365,
|
|
139
|
+
* zero-rated through the review runner's phase 2). Set: `GET /model-usage/summary` prices those
|
|
140
|
+
* lines at zero beside what they would cost, and a tenant's metered usage gains a `reviews`
|
|
141
|
+
* block with its review tokens, their would-be cost and what is charged. Unset: neither.
|
|
142
|
+
*/
|
|
143
|
+
reviewUsage?: {
|
|
144
|
+
readonly scope: ScopeId;
|
|
145
|
+
readonly zeroRated: boolean;
|
|
146
|
+
};
|
|
115
147
|
host: ScopeHost;
|
|
116
148
|
/**
|
|
117
149
|
* How edge health reaches the two ends of a cross-vertical edge (#1705 PR 3): the phase's own
|
|
@@ -450,6 +482,11 @@ export interface ControlPlaneApiOptions {
|
|
|
450
482
|
* `POST …/connections/:id/send-test` (#2343); a provider absent here 501s there.
|
|
451
483
|
*/
|
|
452
484
|
mailSenders?: Readonly<Record<string, MailSender>>;
|
|
485
|
+
/**
|
|
486
|
+
* Inbound mail's tenant door (#2611), behind `…/scopes/:s/mail-in`. Absent ⇒ those routes 501:
|
|
487
|
+
* this deployment has no mail-in connector wired.
|
|
488
|
+
*/
|
|
489
|
+
mailIn?: MailInTenantDoor;
|
|
453
490
|
/**
|
|
454
491
|
* The inspector for a vertical-defined provider (`<namespace>.<name>`, vertical-connectors.md
|
|
455
492
|
* §6.4), which `connectionInspectors` never names: built per (tenant, vertical), since its code
|
|
@@ -623,6 +660,11 @@ export declare const denialLogQuery: z.ZodObject<{
|
|
|
623
660
|
/** The per-provider read bound: past it the count is a floor, and says so (`capped`). */
|
|
624
661
|
export declare const CONNECTOR_DEAD_LETTER_CAP = 200;
|
|
625
662
|
export declare const DEFAULT_MODEL_MARGIN_PERCENT = 20;
|
|
663
|
+
/**
|
|
664
|
+
* The most review lines one tenant's metered-usage read folds. A tenant's reviews are capped far
|
|
665
|
+
* below it at intake (50 kept in 30 days), so reaching it marks the figure a lower bound.
|
|
666
|
+
*/
|
|
667
|
+
export declare const REVIEW_USAGE_READ_MAX = 500;
|
|
626
668
|
type TenantPin = 'path' | 'query' | 'catalog' | 'body' | 'owner';
|
|
627
669
|
/**
|
|
628
670
|
* How a tenant-scoped credential's pin is checked on this route, or `undefined` when
|
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,
|
|
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,CAAC;AAEhP,OAAO,EAEe,KAAK,QAAQ,EAClC,MAAM,eAAe,CAAC;AACvB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sBAAsB,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CAmjYhG"}
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sourceBuildRequest } from '@substrat-run/contracts';
|
|
1
|
+
import { addDecimal, sourceBuildRequest } from '@substrat-run/contracts';
|
|
2
2
|
import { SourceBuildInterrupted } from './source-builds.js';
|
|
3
3
|
import { PREVIEW_CONNECTIONS_REFUSAL } from './connection-relay.js';
|
|
4
4
|
import { bindingChangeRefusal, bindingOptionsRefusal, connectionBindingOptions, refusesBindingChange } from './connection-binding-options.js';
|
|
@@ -6,15 +6,17 @@ import { resolveObservabilityWindow } from './observability-window.js';
|
|
|
6
6
|
import { Hono } from 'hono';
|
|
7
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';
|
|
8
8
|
import { upstreamHandleIn, upstreamReferenceOf, withUpstreamReference } from '@substrat-run/contracts';
|
|
9
|
+
import { mailInAddressAct, mailInStanding } from '@substrat-run/contracts';
|
|
9
10
|
import { ENGINE_ENTITLEMENT_KEYS, bareSlug, declarableEntitlementKey, entitlementNamespaceRefusal, grantableEntitlements } from '@substrat-run/contracts';
|
|
10
11
|
import { SCOPE_COPY_LEASE_MS, copyRestoreFence, publishedMigrationDigest, replayStoreErasures, storesFencedRefusal } from '@substrat-run/kernel';
|
|
11
12
|
import { attributeFailure } from './failure-attribution.js';
|
|
12
13
|
import { auditedChange, withAuditedOutcomes } from './audited-change.js';
|
|
13
|
-
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, } 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, 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
15
|
import { TENANT_HEADER, confinedTenant } from './auth.js';
|
|
15
16
|
import { mintTenantToken } from './tenant-token.js';
|
|
16
17
|
import { issuerOnlyConfigKeyOf } from './issuer-config.js';
|
|
17
18
|
import { COPY_MAX_BYTES, abandonCopy, beginTransfer, connectionGrantsForScope, transferScope, isScopeNotHeld, notHeldIsBenign } from './vertical-client.js';
|
|
19
|
+
import { ManagedSignInIncomplete, removeManagedSignIn, unlistManagedTenant } from './managed-sign-in.js';
|
|
18
20
|
import { COPY_JOB_MAX_MS, copyJobAt, copyJobHeld, copyJobId, copyJobLive, copyTagId, versionIdOfOrder, versionOrderOf, } from './copy-job.js';
|
|
19
21
|
import { exportStoreDumps, runningVersionOf, runningVersionStoresOf, scopeStoreReachOf, scopeStoresOf, unrouteScope } from './platform-scope-stores.js';
|
|
20
22
|
import { liveApprovalOf } from './store-script.js';
|
|
@@ -742,6 +744,11 @@ const modelUsageSummaryQuery = z.object({
|
|
|
742
744
|
until: z.string().optional(),
|
|
743
745
|
});
|
|
744
746
|
export const DEFAULT_MODEL_MARGIN_PERCENT = 20;
|
|
747
|
+
/**
|
|
748
|
+
* The most review lines one tenant's metered-usage read folds. A tenant's reviews are capped far
|
|
749
|
+
* below it at intake (50 kept in 30 days), so reaching it marks the figure a lower bound.
|
|
750
|
+
*/
|
|
751
|
+
export const REVIEW_USAGE_READ_MAX = 500;
|
|
745
752
|
const TENANT_ROUTES = [
|
|
746
753
|
{ method: 'GET', re: /\/verticals\/[^/]+\/email-sender$/, pin: 'owner' },
|
|
747
754
|
{ method: 'POST', re: /\/verticals\/[^/]+\/email-sender$/, pin: 'owner' },
|
|
@@ -772,6 +779,9 @@ const TENANT_ROUTES = [
|
|
|
772
779
|
// #2343: a mail connection's test send. The dashboard sends it only to the signed-in person.
|
|
773
780
|
{ method: 'POST', re: /\/tenants\/[^/]+\/connections\/[^/]+\/send-test$/, pin: 'path' },
|
|
774
781
|
{ method: 'GET', re: /\/tenants\/[^/]+\/connections\/[^/]+\/senders$/, pin: 'path' },
|
|
782
|
+
// #2611: one app's mail-in address — read it, and request, rotate or revoke it.
|
|
783
|
+
{ method: 'GET', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/mail-in$/, pin: 'path' },
|
|
784
|
+
{ method: 'POST', re: /\/tenants\/[^/]+\/scopes\/[^/]+\/mail-in$/, pin: 'path' },
|
|
775
785
|
// A vertical's mailed connect links (connections.md §3.5.4): the consent landing's liveness
|
|
776
786
|
// read, the callback's spend and its undo, and the integrations card's list and revoke.
|
|
777
787
|
{ method: 'GET', re: /\/tenants\/[^/]+\/connect-links$/, pin: 'path' },
|
|
@@ -1770,6 +1780,21 @@ export function createControlPlaneApi(options) {
|
|
|
1770
1780
|
// under the tenant. The blast radius is the console's to show; the audit row
|
|
1771
1781
|
// is this layer's to guarantee.
|
|
1772
1782
|
await c.var.admin.setTenantStatus(c.get('actor'), tenantId, status);
|
|
1783
|
+
// #3261, D-72: a managed tenant entering `deleting` is taken off its manager's auth-servers'
|
|
1784
|
+
// account pages, so nobody's list shows a business being deleted. After the transition, so
|
|
1785
|
+
// the containment never waits on an auth-server; a failure is answered rather than hidden,
|
|
1786
|
+
// and the reap removes the place again.
|
|
1787
|
+
if (status === 'deleting') {
|
|
1788
|
+
try {
|
|
1789
|
+
await unlistManagedTenant(managedSignInDeps(c), tenantId);
|
|
1790
|
+
}
|
|
1791
|
+
catch (e) {
|
|
1792
|
+
if (!(e instanceof ManagedSignInIncomplete))
|
|
1793
|
+
throw e;
|
|
1794
|
+
return refuseStatus(c, 502, `tenant ${tenantId} is deleting, but its place may still be listed at its manager's auth-server — ` +
|
|
1795
|
+
'repeat this request to retry; reaping the tenant removes it too', { reason: e.message });
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1773
1798
|
return c.json(await c.var.admin.getTenant(c.get('actor'), tenantId));
|
|
1774
1799
|
});
|
|
1775
1800
|
// Reap a DELETING tenant now (control-plane.md §4.8) — the staff "reap now" that skips
|
|
@@ -1791,6 +1816,8 @@ export function createControlPlaneApi(options) {
|
|
|
1791
1816
|
if (tenant.status !== 'deleting') {
|
|
1792
1817
|
return refuse(c, 'conflict', `tenant ${tenantId} is ${tenant.status}, not deleting — only a deleting tenant may be reaped`);
|
|
1793
1818
|
}
|
|
1819
|
+
// #3261, D-72: a managed tenant's client and place at its manager's auth-servers go BEFORE
|
|
1820
|
+
// anything is wiped, so a failure leaves the tenant whole and the reap is simply retried.
|
|
1794
1821
|
try {
|
|
1795
1822
|
for (const scope of await c.var.admin.listScopes(actor, { tenantId })) {
|
|
1796
1823
|
if (scope.status === 'reaped')
|
|
@@ -1811,7 +1838,12 @@ export function createControlPlaneApi(options) {
|
|
|
1811
1838
|
const vertical = await verticalForScope(c, scope);
|
|
1812
1839
|
// Archived above, so the router no longer serves it (`READ_ROUTE_SQL` wants an active scope of
|
|
1813
1840
|
// an active tenant), and reapScope below releases its names.
|
|
1814
|
-
|
|
1841
|
+
const fenceStores = await platformStoresFence(c, scope, { outlives: true, whileTenantDeleting: true });
|
|
1842
|
+
// #3261, D-72: past the backup and the stores' preflight, which touch nothing, and before
|
|
1843
|
+
// the fence and the wipe, so an auth-server that cannot be reached stops the reap here.
|
|
1844
|
+
// The mark commits the reap first, so no un-delete can land while the client is deleted.
|
|
1845
|
+
await removeManagedSignIn(managedSignInDeps(c), tenantId, scope.id, () => c.var.admin.markScopeStoresFenced(actor, tenantId, scope.id, { whileTenantDeleting: true }));
|
|
1846
|
+
await fenceStores();
|
|
1815
1847
|
if (vertical)
|
|
1816
1848
|
await vertical.deleteScope({ tenantId, scopeId: scope.id });
|
|
1817
1849
|
// Tenant teardown reaps every scope and releases every name by design — force past
|
|
@@ -1825,6 +1857,8 @@ export function createControlPlaneApi(options) {
|
|
|
1825
1857
|
return c.json(await c.var.admin.getTenant(actor, tenantId));
|
|
1826
1858
|
}
|
|
1827
1859
|
catch (e) {
|
|
1860
|
+
if (e instanceof ManagedSignInIncomplete)
|
|
1861
|
+
return refuseStatus(c, 502, ...notReapedForSignIn(e));
|
|
1828
1862
|
if (e instanceof ControlPlaneError) {
|
|
1829
1863
|
return relayRefusal(c, e);
|
|
1830
1864
|
}
|
|
@@ -2002,6 +2036,43 @@ export function createControlPlaneApi(options) {
|
|
|
2002
2036
|
if (rows.length < STORAGE_HISTORY_LIMIT_MAX)
|
|
2003
2037
|
storageDays = { rows };
|
|
2004
2038
|
}
|
|
2039
|
+
// The tenant's code reviews, priced (#2365): the one figure on this read with a price, because
|
|
2040
|
+
// a review is metered to the tenant and the tenant sees what it would cost before it is
|
|
2041
|
+
// charged. The lines are the tenant's own in the review scope, folded as the ledger bills.
|
|
2042
|
+
let reviews;
|
|
2043
|
+
if (options.reviewUsage) {
|
|
2044
|
+
const window = { since: `${since}T00:00:00Z`, until: `${until}T00:00:00Z` };
|
|
2045
|
+
const zeroRated = options.reviewUsage.zeroRated;
|
|
2046
|
+
reviews = { state: 'unavailable', calls: null, reportedCalls: 0, inputTokens: null, outputTokens: null, unpriced: 0, wouldCostUsd: null, chargedUsd: null, zeroRated, lowerBound: false, ...window };
|
|
2047
|
+
if (usageNow() < deadline) {
|
|
2048
|
+
// The ledger compares `at` as text, and a line's `at` carries milliseconds, so the bounds do
|
|
2049
|
+
// too: `T00:00:00Z` sorts after `T00:00:00.500Z` and would drop the first second of the window.
|
|
2050
|
+
const lines = await admin.listModelUsage(actor, {
|
|
2051
|
+
tenantId, scopeId: options.reviewUsage.scope, since: `${since}T00:00:00.000Z`, until: `${until}T00:00:00.000Z`,
|
|
2052
|
+
limit: REVIEW_USAGE_READ_MAX + 1, order: 'asc',
|
|
2053
|
+
});
|
|
2054
|
+
const kept = lines.slice(0, REVIEW_USAGE_READ_MAX);
|
|
2055
|
+
const clipped = lines.length > REVIEW_USAGE_READ_MAX;
|
|
2056
|
+
const folded = foldModelUsage(kept, {
|
|
2057
|
+
readAt, ...window, marginPercent: options.modelMarginPercent ?? DEFAULT_MODEL_MARGIN_PERCENT,
|
|
2058
|
+
...(zeroRated ? { zeroRatedScopes: [options.reviewUsage.scope] } : {}),
|
|
2059
|
+
}).totals;
|
|
2060
|
+
const reported = kept.filter((line) => line.reported);
|
|
2061
|
+
reviews = {
|
|
2062
|
+
...reviews,
|
|
2063
|
+
state: kept.length === 0 ? 'empty' : clipped ? 'truncated' : 'complete',
|
|
2064
|
+
calls: kept.length > 0 ? kept.length : null,
|
|
2065
|
+
reportedCalls: reported.length,
|
|
2066
|
+
inputTokens: reported.length > 0 ? folded.inputTokens : null,
|
|
2067
|
+
outputTokens: reported.length > 0 ? folded.outputTokens : null,
|
|
2068
|
+
unpriced: folded.unpriced,
|
|
2069
|
+
// What they would cost at the platform's rate, and what of that is charged: nothing while zero-rated.
|
|
2070
|
+
wouldCostUsd: kept.length > 0 ? addDecimal(folded.billedUsd, folded.zeroRatedUsd) : null,
|
|
2071
|
+
chargedUsd: kept.length > 0 ? folded.billedUsd : null,
|
|
2072
|
+
lowerBound: clipped,
|
|
2073
|
+
};
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2005
2076
|
const hasModelLedger = typeof admin.listTenantModelUsageMeter === 'function' && !modelSkipped;
|
|
2006
2077
|
let builds = { state: 'unavailable', builds: null, ms: null, lowerBound: false, since: `${since}T00:00:00Z`, until: `${until}T00:00:00Z`, byVertical: [], breakdownTruncated: false };
|
|
2007
2078
|
if (usageNow() < deadline) {
|
|
@@ -2025,6 +2096,7 @@ export function createControlPlaneApi(options) {
|
|
|
2025
2096
|
requests,
|
|
2026
2097
|
models,
|
|
2027
2098
|
builds,
|
|
2099
|
+
...(reviews ? { reviews } : {}),
|
|
2028
2100
|
days: usageDays(utcDaysBetween(since, through), {
|
|
2029
2101
|
requests: requestDays,
|
|
2030
2102
|
models: hasModelLedger ? { rows: modelDayRows, truncated } : null,
|
|
@@ -2857,6 +2929,66 @@ export function createControlPlaneApi(options) {
|
|
|
2857
2929
|
}));
|
|
2858
2930
|
}
|
|
2859
2931
|
});
|
|
2932
|
+
/**
|
|
2933
|
+
* **One app's mail-in address** (#2611): its standing, and the three acts on it. The caller has
|
|
2934
|
+
* already made its own in-scope check (the dashboard's `dashboard/begin-connection`) and names
|
|
2935
|
+
* the principal it was for as `createdBy`; the tenant is the path's. Not an admin-log mutation
|
|
2936
|
+
* of its own: the address's connection is created, granted and revoked through `HostAdmin`,
|
|
2937
|
+
* which logs each. Who asked is on the request record, beside the connection's `createdBy`.
|
|
2938
|
+
*/
|
|
2939
|
+
const mailInScope = (c) => ({
|
|
2940
|
+
tenantId: tenantIdSchema.parse(c.req.param('tenantId')),
|
|
2941
|
+
scopeId: scopeIdSchema.parse(c.req.param('scopeId')),
|
|
2942
|
+
});
|
|
2943
|
+
const mailInRefusal = (c, e) => {
|
|
2944
|
+
const status = e?.status;
|
|
2945
|
+
if (typeof status !== 'number' || status >= 500 || !(e instanceof Error))
|
|
2946
|
+
return undefined;
|
|
2947
|
+
const code = e.code;
|
|
2948
|
+
return code ? refuse(c, code, e.message) : refuseStatus(c, status, e.message);
|
|
2949
|
+
};
|
|
2950
|
+
app.get('/tenants/:tenantId/scopes/:scopeId/mail-in', async (c) => {
|
|
2951
|
+
const door = options.mailIn;
|
|
2952
|
+
if (!door)
|
|
2953
|
+
return refuseStatus(c, 501, 'inbound mail is not wired on this deployment');
|
|
2954
|
+
try {
|
|
2955
|
+
return c.json(mailInStanding.parse(await door.standing(c.var.host, mailInScope(c))));
|
|
2956
|
+
}
|
|
2957
|
+
catch (e) {
|
|
2958
|
+
const refused = mailInRefusal(c, e);
|
|
2959
|
+
if (refused)
|
|
2960
|
+
return refused;
|
|
2961
|
+
throw e;
|
|
2962
|
+
}
|
|
2963
|
+
});
|
|
2964
|
+
app.post('/tenants/:tenantId/scopes/:scopeId/mail-in', async (c) => {
|
|
2965
|
+
const door = options.mailIn;
|
|
2966
|
+
if (!door)
|
|
2967
|
+
return refuseStatus(c, 501, 'inbound mail is not wired on this deployment');
|
|
2968
|
+
const body = mailInAddressAct.safeParse(await c.req.json().catch(() => null));
|
|
2969
|
+
if (!body.success) {
|
|
2970
|
+
const first = body.error.issues[0];
|
|
2971
|
+
return refuse(c, 'validation_failed', `invalid mail-in act: ${first ? `${first.path.join('.') || '(root)'} — ${first.message}` : 'malformed body'}`);
|
|
2972
|
+
}
|
|
2973
|
+
const scope = mailInScope(c);
|
|
2974
|
+
const principal = c.get('principal');
|
|
2975
|
+
console.log('mail-in.address', {
|
|
2976
|
+
tenantId: scope.tenantId,
|
|
2977
|
+
scopeId: scope.scopeId,
|
|
2978
|
+
action: body.data.action,
|
|
2979
|
+
actor: c.get('actor'),
|
|
2980
|
+
onBehalfOf: principal.kind === 'tenant' ? (principal.onBehalfOf?.principal ?? null) : null,
|
|
2981
|
+
});
|
|
2982
|
+
try {
|
|
2983
|
+
return c.json({ address: await door.act(c.var.host, scope, body.data) });
|
|
2984
|
+
}
|
|
2985
|
+
catch (e) {
|
|
2986
|
+
const refused = mailInRefusal(c, e);
|
|
2987
|
+
if (refused)
|
|
2988
|
+
return refused;
|
|
2989
|
+
throw e;
|
|
2990
|
+
}
|
|
2991
|
+
});
|
|
2860
2992
|
/**
|
|
2861
2993
|
* **What the connection has done** (#605) — the connector's dispatch ledger, projected.
|
|
2862
2994
|
*
|
|
@@ -3035,6 +3167,14 @@ export function createControlPlaneApi(options) {
|
|
|
3035
3167
|
open: (items) => c.var.admin.openSubjectPayloads(c.get('actor'), tenantId, scopeId, items),
|
|
3036
3168
|
});
|
|
3037
3169
|
const verticalForScope = async (c, scope) => (await deploymentForScope(c, scope))?.client;
|
|
3170
|
+
/** What `managed-sign-in.ts` needs, for this request (#3261). */
|
|
3171
|
+
const managedSignInDeps = (c) => ({
|
|
3172
|
+
admin: c.var.admin,
|
|
3173
|
+
actor: c.get('actor'),
|
|
3174
|
+
resolveVerticalForScope: (scope) => verticalForScope(c, scope),
|
|
3175
|
+
});
|
|
3176
|
+
/** The refusal of a reap whose managed sign-in could not be removed (#3261): nothing was wiped. */
|
|
3177
|
+
const notReapedForSignIn = (e) => ["not reaped — the managed tenant's sign-in could not be removed at its manager's auth-server, and nothing more was wiped; retry", { reason: e.message }];
|
|
3038
3178
|
/**
|
|
3039
3179
|
* Reconcile one install's client at the social relay (#1544). Skips — never throws for — an
|
|
3040
3180
|
* install the relay is not for: not configured here, not an Auth Server, or no deployment to
|
|
@@ -5494,7 +5634,9 @@ export function createControlPlaneApi(options) {
|
|
|
5494
5634
|
* it was before the ledger. Without per-script resolution there is only that deployment, and
|
|
5495
5635
|
* a ledgered copy the platform cannot reach refuses the reap.
|
|
5496
5636
|
*/
|
|
5497
|
-
const reapScopeStorage = async (c, scope, row = { outlives: false }
|
|
5637
|
+
const reapScopeStorage = async (c, scope, row = { outlives: false },
|
|
5638
|
+
/** #3261: also remove a managed tenant's sign-in at its manager's auth-servers (throws `ManagedSignInIncomplete`). */
|
|
5639
|
+
signIn = {}) => {
|
|
5498
5640
|
const actor = c.get('actor');
|
|
5499
5641
|
const dispatch = options.resolveVerticalRef;
|
|
5500
5642
|
// #2285: every refusal that can be decided up front comes before anything is destroyed, the
|
|
@@ -5504,6 +5646,13 @@ export function createControlPlaneApi(options) {
|
|
|
5504
5646
|
else
|
|
5505
5647
|
await assertNoUnreachableScopeCopies(c.var.admin, actor, scope.tenantId, scope.id);
|
|
5506
5648
|
const fenceStores = await platformStoresFence(c, scope, row);
|
|
5649
|
+
// #3261, D-72: past every refusal above, which touch nothing, and before the unroute and the
|
|
5650
|
+
// wipe, so an auth-server that cannot be reached stops the reap with the scope whole, and a
|
|
5651
|
+
// refused reap keeps the client the scope still signs in with.
|
|
5652
|
+
// The mark commits the reap first, so no unarchive can land while the client is deleted.
|
|
5653
|
+
if (signIn.managed) {
|
|
5654
|
+
await removeManagedSignIn(managedSignInDeps(c), scope.tenantId, scope.id, () => c.var.admin.markScopeStoresFenced(actor, scope.tenantId, scope.id));
|
|
5655
|
+
}
|
|
5507
5656
|
// Stop routing first: that is the fast path, which ends new requests. A call already past the
|
|
5508
5657
|
// router, or signed and still on its way, is what the fence below is for (D-71). It would
|
|
5509
5658
|
// otherwise recreate the store object after the wipe, and nothing left could reach it.
|
|
@@ -6320,10 +6469,12 @@ export function createControlPlaneApi(options) {
|
|
|
6320
6469
|
'retry, or reap with backup=false to accept an unrecoverable wipe', { detail: e instanceof Error ? e.message : String(e) });
|
|
6321
6470
|
}
|
|
6322
6471
|
}
|
|
6472
|
+
// #3261, D-72: a managed tenant's scope takes its client and place at its manager's
|
|
6473
|
+
// auth-servers with it, before its bytes go, so a failure leaves the scope as it was.
|
|
6323
6474
|
try {
|
|
6324
6475
|
// By this point the backup contract has resolved (a copy landed, or the caller
|
|
6325
6476
|
// explicitly declined one), so stranding is a bookkeeping fact, not data loss.
|
|
6326
|
-
const storageStranded = await reapScopeStorage(c, scope, { outlives: true });
|
|
6477
|
+
const storageStranded = await reapScopeStorage(c, scope, { outlives: true }, { managed: true });
|
|
6327
6478
|
await c.var.admin.reapScope(actor, tenantId, scopeId, {
|
|
6328
6479
|
...(backup ? { backupRef: backupRefOf(backup) } : {}),
|
|
6329
6480
|
});
|
|
@@ -6331,6 +6482,8 @@ export function createControlPlaneApi(options) {
|
|
|
6331
6482
|
return c.json({ ...reaped, backup, ...(storageStranded ? { storageStranded: true } : {}) });
|
|
6332
6483
|
}
|
|
6333
6484
|
catch (e) {
|
|
6485
|
+
if (e instanceof ManagedSignInIncomplete)
|
|
6486
|
+
return refuseStatus(c, 502, ...notReapedForSignIn(e));
|
|
6334
6487
|
if (e instanceof ControlPlaneError) {
|
|
6335
6488
|
return relayRefusal(c, e);
|
|
6336
6489
|
}
|
|
@@ -11944,7 +12097,7 @@ export function createControlPlaneApi(options) {
|
|
|
11944
12097
|
const now = new Date();
|
|
11945
12098
|
const since = q.since ?? new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)).toISOString();
|
|
11946
12099
|
const until = q.until ?? now.toISOString();
|
|
11947
|
-
const summary = await c.var.admin.summarizeModelUsage(c.get('actor'), { ...(q.tenantId ? { tenantId: q.tenantId } : {}), since, until }, options.modelMarginPercent ?? DEFAULT_MODEL_MARGIN_PERCENT);
|
|
12100
|
+
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] } : {});
|
|
11948
12101
|
return c.json(summary);
|
|
11949
12102
|
});
|
|
11950
12103
|
// -- store-driver releases (D-63, #2300) ----------------------------------------
|