@fabrika/provider-contract 0.9.0-dev.2 → 0.9.0-dev.20

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.
@@ -0,0 +1,22 @@
1
+ import { type ControlProvider, type ProviderDeployInput } from './control';
2
+ /** What the suite hands a fake cloud: `accepted` is called once the cloud has taken the deploy's operation. */
3
+ export interface ConformanceCloudHooks {
4
+ accepted(): void;
5
+ }
6
+ /** One provider over one fresh fake cloud. */
7
+ export interface ConformanceCloud {
8
+ readonly provider: ControlProvider;
9
+ /** A deploy the fake cloud accepts and lets succeed. Each case sets `dryRun`, `signal` and `events` itself. */
10
+ readonly input: Omit<ProviderDeployInput, 'dryRun' | 'signal' | 'events'>;
11
+ /** The credentials the provider holds itself (a cloud token, a signed URL); no event may carry one. */
12
+ readonly credentials: readonly string[];
13
+ /** Every request that changed the cloud: a write, a created resource, started work. A preview the cloud runs is none. */
14
+ mutations(): readonly string[];
15
+ /** Every request to stop or remove the deploy's work: a cancelled build or job, a deleted version. */
16
+ stops(): readonly string[];
17
+ }
18
+ export interface ControlProviderConformanceHarness {
19
+ /** Called once per case, and once per event in the lease-loss sweep. */
20
+ create(hooks: ConformanceCloudHooks): ConformanceCloud;
21
+ }
22
+ export declare function describeControlProviderConformance(name: string, harness: ControlProviderConformanceHarness): void;
@@ -1,4 +1,5 @@
1
- import type { AppSchema, ContractArtifact } from '@fabrika/auth-core';
1
+ import type { ApplicationObjects, AppSchema, ContractArtifact, ManagedEnvironment } from '@fabrika/auth-core';
2
+ import type { InstallationBrand } from '@fabrika/proxy-core/brand';
2
3
  import type { JsonValue, ProviderEnvelope } from './json';
3
4
  /** Events whose persistence and presentation belong to the control plane. */
4
5
  export interface ProviderRunEvents {
@@ -13,8 +14,11 @@ export interface ProviderRunEvents {
13
14
  */
14
15
  boundary(): Promise<void>;
15
16
  }
16
- /** Complete platform-owned runtime state. A null value removes the key from persistent targets. */
17
- export type ProviderManagedEnvironment = Readonly<Record<string, string | null>>;
17
+ /**
18
+ * Complete platform-owned runtime state, parsed by Control (`parseManagedEnvironment`). A provider writes each entry as
19
+ * a secret when it is a `credential`, removes one whose value is null, and removes the stale ones `staleManagedVariables` names.
20
+ */
21
+ export type ProviderManagedEnvironment = ManagedEnvironment;
18
22
  /** Provider-neutral coordinates for obtaining one app revision. */
19
23
  export interface ProviderSource {
20
24
  readonly repoUrl: string;
@@ -35,8 +39,7 @@ export interface ProviderDeploymentNamespace {
35
39
  readonly exclusiveAppId?: string;
36
40
  readonly target: ProviderEnvelope;
37
41
  }
38
- /** A framework release as npm publishes it; the only form one may take before it reaches a generated build command. */
39
- export declare const FRAMEWORK_RELEASE_PATTERN: RegExp;
42
+ export { FRAMEWORK_RELEASE_PATTERN } from '@fabrika/auth-core';
40
43
  /**
41
44
  * The access Control approved for one application environment (ADR-0050): the contract the proxy enforces and the
42
45
  * IAM vocabulary compiled from it. A provider publishes a contract application's endpoint table and reconciles its
@@ -57,6 +60,12 @@ export interface ProviderApprovedAccess {
57
60
  * the framework minor it pins (ADR-0062). Its build checks with that release.
58
61
  */
59
62
  readonly checker: string;
63
+ /**
64
+ * The `@fabrika/app` release the application's `bun.lock` pins (`FRAMEWORK_RELEASE_PATTERN`), which a release gate
65
+ * reads: `checker` is this platform's patch of that minor, newer than a prerelease pin. Absent in an access Control
66
+ * approved before it recorded the pin.
67
+ */
68
+ readonly framework?: string;
60
69
  }
61
70
  /**
62
71
  * `dev`: the environment follows a workspace through a platform-owned launcher, which its provider starts instead of the
@@ -78,12 +87,18 @@ export interface ProviderEnvironment {
78
87
  * application's proxy manifest entry as `crossOrigins`.
79
88
  */
80
89
  readonly crossOrigins?: readonly string[];
90
+ /**
91
+ * The origin of the environment's active Operations ingest DSN, never the DSN: a contract application's proxy admits
92
+ * it in `connect-src`. Control sets it on a deploy; absent while the environment has no active ingest.
93
+ */
94
+ readonly operationsOrigin?: string;
81
95
  readonly namespace?: ProviderDeploymentNamespace;
82
96
  readonly target: ProviderEnvelope;
83
97
  readonly artifact: ProviderEnvelope;
84
98
  /**
85
99
  * The environment's approved contract, from Control's `approvedSnapshot`. Absent when nothing is approved: then a
86
100
  * provider publishes no endpoint table and reconciles no IAM schema, whatever the artifact claims (ADR-0050).
101
+ * Control refuses a non-dry deploy without it.
87
102
  */
88
103
  readonly access?: ProviderApprovedAccess;
89
104
  }
@@ -130,13 +145,33 @@ export interface ProviderDeployInput {
130
145
  /** Platform-owned runtime configuration, separate from operator-managed application vars. */
131
146
  readonly managedEnvironment: ProviderManagedEnvironment;
132
147
  /**
133
- * Every origin IAM may hand this app a session at (ADR-0022). App-wide, not per-environment:
134
- * IAM's registry is keyed by app id, so the set is assembled from every environment of the app.
135
- * Absent when the app has no public origin at all, which leaves IAM's registry untouched.
148
+ * The object that serves the environment's ordinary traffic and the objects its ops channel reaches, as Control records
149
+ * them (ADR-0070 §9). A provider whose application runs in no object ignores it; absent, the provider's defaults.
150
+ */
151
+ readonly applicationObjects?: ApplicationObjects;
152
+ /**
153
+ * Present when the deploy brings migration files with a `dataLoss` statement of any kind, which may change stored data, and that the version running does not hold
154
+ * (ADR-0050): the provider backs up the application's database, and waits until the backup is stored, before any
155
+ * version that can run them starts. A backup that fails or does not finish fails the run with nothing deployed.
156
+ * Control hands it only to a provider without `dataOperations`, whose migration phase backs up itself (ADR-0070 §8),
157
+ * and never to a dry run or a dev bootstrap.
136
158
  */
137
- readonly returnOrigins?: readonly string[];
159
+ readonly backupBeforeMigrations?: {
160
+ readonly migrations: readonly string[];
161
+ };
138
162
  readonly dryRun: boolean;
139
163
  readonly sourceBinding?: ProviderSourceBinding;
164
+ /**
165
+ * Present on a dev bootstrap: the provider deploys into this workspace's sandbox, which `devSandboxes.ensure` created
166
+ * before the run, and serves it at `origin`. Absent on every other deploy.
167
+ */
168
+ readonly devSandbox?: {
169
+ readonly workspaceId: string;
170
+ readonly sandboxId: string;
171
+ readonly origin: string;
172
+ /** See `ProviderDevSandboxInput.sandboxKey`. */
173
+ readonly sandboxKey: string;
174
+ };
140
175
  /** Optional short-lived, run-scoped Operations artifact destination. */
141
176
  readonly artifactUpload?: {
142
177
  readonly url: string;
@@ -150,7 +185,10 @@ export interface ProviderDeployInput {
150
185
  readonly signal: AbortSignal;
151
186
  readonly events: ProviderRunEvents;
152
187
  }
153
- /** A terminal provider operation result. */
188
+ /**
189
+ * A terminal provider operation result. `succeeded` means the version is live: Control then writes the environment's
190
+ * approved IAM schema itself (ADR-0011), so a provider never calls IAM for an application.
191
+ */
154
192
  export interface ProviderTerminalOutcome {
155
193
  readonly state: 'succeeded' | 'failed';
156
194
  readonly exitCode?: number;
@@ -190,13 +228,9 @@ export interface ProviderRunReference {
190
228
  }
191
229
  export interface ProviderCancelInput extends ProviderRunReference {
192
230
  readonly signal: AbortSignal;
193
- /** See `ProviderDeployInput.returnOrigins`; a cancel that settles an activated deploy projects the same set. */
194
- readonly returnOrigins?: readonly string[];
195
231
  }
196
232
  export interface ProviderReconcileInput extends ProviderRunReference {
197
233
  readonly signal: AbortSignal;
198
- /** See `ProviderDeployInput.returnOrigins`; a provider that settles a deploy here projects the same set. */
199
- readonly returnOrigins?: readonly string[];
200
234
  /** Append a line to the run's log. */
201
235
  log?(line: string): Promise<void>;
202
236
  }
@@ -279,12 +313,48 @@ export interface ProviderNamespaceMember {
279
313
  readonly operationsOrigin?: string;
280
314
  /** See `ProviderEnvironment.access`: the proxy table of a contract application comes only from here. */
281
315
  readonly access?: ProviderApprovedAccess;
316
+ /**
317
+ * Present for a dev member, which is routed ONLY through these entries (none while it has no sandbox), never through
318
+ * its own `domain` and `access`.
319
+ */
320
+ readonly devSandboxes?: readonly ProviderNamespaceDevSandbox[];
321
+ }
322
+ /** One workspace sandbox of a `dev` member, which the namespace proxy routes as its own entry. */
323
+ export interface ProviderNamespaceDevSandbox {
324
+ readonly workspaceId: string;
325
+ /** The public host the proxy answers the workspace on (`<workspaceId>.<domain>`). */
326
+ readonly host: string;
327
+ /** See `ProviderDevSandbox.upstreamHost`. */
328
+ readonly upstreamHost: string;
329
+ /** See `ProviderNamespaceMember.proxySecret`: sealed per workspace. */
330
+ readonly proxySecret?: string;
331
+ /** The access of the workspace's own published bootstrap run. */
332
+ readonly access: ProviderApprovedAccess;
333
+ }
334
+ /** What decides the hosts a namespace entry point routes one member on: `ProviderNamespaceMember` without its secrets. */
335
+ export interface ProviderNamespaceMemberRouting {
336
+ readonly appId: string;
337
+ readonly env: string;
338
+ readonly domain?: string;
339
+ readonly artifact: ProviderEnvelope;
340
+ readonly access?: ProviderApprovedAccess;
341
+ readonly devSandboxes?: readonly Pick<ProviderNamespaceDevSandbox, 'workspaceId' | 'host'>[];
282
342
  }
283
343
  /** One idempotent namespace lifecycle invocation. */
284
344
  export interface ProviderNamespaceMutationInput {
285
345
  readonly namespace: ProviderDeploymentNamespace;
286
346
  /** Every app environment assigned to the namespace, read under its lease. */
287
347
  readonly members: readonly ProviderNamespaceMember[];
348
+ /**
349
+ * The installation's client logo for the pages the namespace's proxy answers with (ADR-0066), read from IAM for this
350
+ * mutation; absent or null shows the fabrika mark. A provider passes it only to a proxy that can parse it.
351
+ */
352
+ readonly brand?: InstallationBrand | null;
353
+ /**
354
+ * Present when a member is a `dev` environment: the namespace's sandbox host is provisioned with it as its API key, and
355
+ * see `ProviderDevSandboxInput.sandboxKey`. Absent, the provider provisions no sandbox host.
356
+ */
357
+ readonly sandboxKey?: string;
288
358
  readonly signal: AbortSignal;
289
359
  readonly events: ProviderNamespaceEvents;
290
360
  }
@@ -308,6 +378,16 @@ export declare const PROVIDER_NAMESPACE_IMMUTABLE = "namespaceImmutable";
308
378
  * and is not confirmed. Any other failure means nothing changed. Applying the same plan again must converge.
309
379
  */
310
380
  export declare const PROVIDER_NAMESPACE_UPDATE_UNCONFIRMED = "namespaceUpdateUnconfirmed";
381
+ /**
382
+ * The `code` of a `ProviderNamespaceError` a `devSandboxes` call throws when the namespace's sandbox host has no room
383
+ * to create or wake one more sandbox. Nothing changed; it succeeds once another sandbox is parked or removed.
384
+ */
385
+ export declare const PROVIDER_DEV_CAPACITY = "devCapacity";
386
+ /**
387
+ * The `code` of a `ProviderNamespaceError` a `devSandboxes` call throws when the namespace has no sandbox host yet.
388
+ * Nothing changed; it succeeds once a namespace mutation handed the sandbox host key has created the host.
389
+ */
390
+ export declare const PROVIDER_DEV_HOST_PENDING = "devHostPending";
311
391
  /** One provider-described change, safe to audit: names and values only, never a credential. */
312
392
  export interface ProviderNamespaceChange {
313
393
  readonly field: string;
@@ -400,6 +480,17 @@ export interface ProviderNamespaceOperator {
400
480
  plan(input: ProviderNamespacePlanInput): ProviderNamespacePlan;
401
481
  present(namespace: ProviderDeploymentNamespace): ProviderNamespacePresentation;
402
482
  }
483
+ /** The app-owned claims of one namespace whose resources Control is asked to confirm gone. */
484
+ export interface ProviderClaimedResourcesInput {
485
+ readonly namespace: ProviderDeploymentNamespace;
486
+ readonly resourceKeys: readonly string[];
487
+ readonly signal: AbortSignal;
488
+ }
489
+ /** What the provider observed for one claimed resource. */
490
+ export interface ProviderClaimedResource {
491
+ readonly resourceKey: string;
492
+ readonly exists: boolean;
493
+ }
403
494
  /** Optional placement lifecycle owned by providers that use deployment namespaces. */
404
495
  export interface ProviderNamespaceCapabilities {
405
496
  normalize(namespace: ProviderDeploymentNamespace): ProviderDeploymentNamespace;
@@ -416,22 +507,80 @@ export interface ProviderNamespaceCapabilities {
416
507
  reconcile(input: ProviderNamespaceMutationInput): Promise<ProviderDeploymentNamespace>;
417
508
  /** Absent means the namespace has no entry point that follows its members. */
418
509
  republish?(input: ProviderNamespaceRepublishInput): Promise<ProviderNamespaceRepublishResult>;
510
+ /**
511
+ * The hosts the namespace's entry point routes this member on, lower-cased, by the rule its compiler applies; none for
512
+ * a member it does not route. Throws for a member it cannot route. Absent means no member is routed by host.
513
+ */
514
+ memberHosts?(member: ProviderNamespaceMemberRouting): readonly string[];
515
+ /**
516
+ * Read-only: whether each claimed resource still exists, one answer per key. Throws when it cannot tell, so Control
517
+ * releases a claim only over a resource the provider confirmed gone. Absent means no claim can be released.
518
+ */
519
+ claimedResources?(input: ProviderClaimedResourcesInput): Promise<readonly ProviderClaimedResource[]>;
419
520
  /** Absent means the provider changes no namespace in place. */
420
521
  readonly updates?: ProviderNamespaceUpdates;
421
522
  readonly operator?: ProviderNamespaceOperator;
422
523
  }
423
- /** One call on the service of a `dev` environment, between its bootstrap runs. */
424
- export interface ProviderDevEnvironmentInput {
524
+ export interface ProviderAuthoring {
525
+ /** The file NAMES (no `/`) that configure the provider's deploy; a workspace changes none of them, at any depth. */
526
+ readonly protectedFiles: readonly string[];
527
+ }
528
+ /** The provider's handle on one workspace sandbox, which Control persists; stable for the workspace's life. */
529
+ export interface ProviderDevSandboxRef {
530
+ readonly sandboxId: string;
531
+ }
532
+ /** One running workspace sandbox of a `dev` environment. */
533
+ export interface ProviderDevSandbox {
534
+ readonly sandboxId: string;
535
+ /** The base image the sandbox was created from. */
536
+ readonly baseDigest: string;
537
+ /** The Host the namespace proxy sends to reach the sandbox's application port (e.g. `3000-<id>.<box domain>`). */
538
+ readonly upstreamHost: string;
539
+ }
540
+ /** Create a workspace's sandbox, or return the one it already has. */
541
+ export interface ProviderDevSandboxEnsureInput {
542
+ readonly environment: ProviderEnvironment;
543
+ readonly workspaceId: string;
544
+ /** See `ProviderDevSandboxInput.sandboxKey`. */
545
+ readonly sandboxKey: string;
546
+ readonly signal: AbortSignal;
547
+ }
548
+ /** One lifecycle call on an existing workspace sandbox. */
549
+ export interface ProviderDevSandboxInput {
425
550
  readonly environment: ProviderEnvironment;
551
+ readonly sandbox: ProviderDevSandboxRef;
552
+ /** The bearer of the namespace's sandbox host API, composed by Control from its vault for this call; never persisted or logged. */
553
+ readonly sandboxKey: string;
554
+ readonly signal: AbortSignal;
555
+ }
556
+ /** Remove a workspace's sandbox; with no recorded `sandbox`, the one an unrecorded `ensure` may have created. */
557
+ export interface ProviderDevSandboxRemoveInput {
558
+ readonly environment: ProviderEnvironment;
559
+ readonly workspaceId: string;
560
+ readonly sandbox: ProviderDevSandboxRef | null;
561
+ /** See `ProviderDevSandboxInput.sandboxKey`. */
562
+ readonly sandboxKey: string;
426
563
  readonly signal: AbortSignal;
427
564
  }
428
565
  /**
429
- * The service of a `dev` environment outside a run (ADR-0049): Control stops it after an idle period and starts it on
430
- * the next commit. Files the launcher wrote survive both.
566
+ * The per-workspace sandboxes of a `dev` environment outside a run. Every call is idempotent: `ensure` creates at most
567
+ * one sandbox per `workspaceId` and returns it running, `park` and `wake` converge on their state, and `remove` treats a
568
+ * sandbox already gone as removed. A full sandbox host throws `PROVIDER_DEV_CAPACITY`, a namespace without one yet
569
+ * `PROVIDER_DEV_HOST_PENDING`; `remove` there is a no-op, since no sandbox can exist.
431
570
  */
432
- export interface ProviderDevEnvironments {
433
- stop(input: ProviderDevEnvironmentInput): Promise<void>;
434
- start(input: ProviderDevEnvironmentInput): Promise<void>;
571
+ export interface ProviderDevSandboxes {
572
+ /**
573
+ * Mutation-free check that the environment's placement can serve a workspace sandbox. Control calls it before it
574
+ * records one, because a recorded sandbox reaches every later republish of the namespace. A refusal is a
575
+ * `ProviderNamespaceError` that is not retryable, whose one-line message the author may read; any other throw is a failure.
576
+ */
577
+ admit(input: {
578
+ readonly environment: ProviderEnvironment;
579
+ }): void;
580
+ ensure(input: ProviderDevSandboxEnsureInput): Promise<ProviderDevSandbox>;
581
+ park(input: ProviderDevSandboxInput): Promise<void>;
582
+ wake(input: ProviderDevSandboxInput): Promise<void>;
583
+ remove(input: ProviderDevSandboxRemoveInput): Promise<void>;
435
584
  }
436
585
  /**
437
586
  * The control-plane capability bundle selected statically by one composition root.
@@ -457,8 +606,29 @@ export interface ControlProvider {
457
606
  reconcile?(input: ProviderReconcileInput): Promise<ProviderReconcileOutcome>;
458
607
  readonly secrets?: ProviderManagedSecrets;
459
608
  readonly namespaces?: ProviderNamespaceCapabilities;
609
+ /** MCP authoring (ADR-0049): an environment of this provider can be an authoring target. Absent means none can. */
610
+ readonly authoring?: ProviderAuthoring;
611
+ /**
612
+ * Every application environment gets `FABRIKA_PROXY_SECRET`, with or without a namespace proxy: the provider's own
613
+ * hop to the application carries it (Cloudflare's Worker to its Durable Object, ADR-0065). Absent means only a
614
+ * namespace proxy's environments get one.
615
+ */
616
+ readonly applicationHopSecret?: true;
460
617
  /** Absent means the provider runs no `dev` environment, and Control refuses one. */
461
- readonly devEnvironments?: ProviderDevEnvironments;
618
+ readonly devSandboxes?: ProviderDevSandboxes;
619
+ /**
620
+ * Whether an environment at this approved access is served the ops channel through which Control reaches its object
621
+ * (ADR-0069), so its deploy gets `FABRIKA_OPS_KEY_DIGESTS`. The release gate is the provider's, so core keeps no
622
+ * release logic. Absent means no environment of this provider is.
623
+ */
624
+ opsChannel?(access: ProviderApprovedAccess): boolean;
625
+ /**
626
+ * Whether the object at this approved access, served the ops channel, also holds the maintenance barrier (`state`,
627
+ * `migrate`) and serves Control's data operations: the daily backups, a deploy's migration phase and the side restore
628
+ * (ADR-0069 §3, ADR-0070). A release can serve the channel without them. Absent means no environment of this
629
+ * provider is.
630
+ */
631
+ dataOperations?(access: ProviderApprovedAccess): boolean;
462
632
  /** Absent means the provider deploys public sources only. */
463
633
  readonly source?: ProviderSourceCapabilities;
464
634
  /**
@@ -479,4 +649,9 @@ export interface ControlProvider {
479
649
  * access snapshot there (ADR-0050). Absent means the repository root.
480
650
  */
481
651
  applicationRoot?(source: ProviderSource): string | null;
652
+ /**
653
+ * The database an application of this provider runs its migrations on, which Control classifies them for: SQLite in
654
+ * the application's Durable Object on Cloudflare (ADR-0065). Absent means Postgres.
655
+ */
656
+ readonly applicationDialect?: 'postgres' | 'sqlite';
482
657
  }
@@ -1,5 +1,6 @@
1
1
  export * from './authoring';
2
2
  export * from './control';
3
3
  export * from './json';
4
+ export * from './plain-credentials';
4
5
  export * from './schema';
5
6
  export * from './steps';
@@ -0,0 +1,16 @@
1
+ /** Why a name and value look like a credential. `because` completes "… looks like a credential: <because>". */
2
+ export interface PlainCredentialFinding {
3
+ readonly basis: 'name' | 'value';
4
+ readonly because: string;
5
+ }
6
+ /**
7
+ * Whether a plain `name = value` looks like a credential, and why; null when it does not.
8
+ *
9
+ * The name matches on a credential word (`TOKEN`, `SECRET`, `PASSWORD`, `PASS`, `BASIC_AUTH`, a `KEY` or `KEYS` that is
10
+ * not an id, a public key or a cache key), unless its last word makes it describe one (`TOKEN_URL`,
11
+ * `PASSWORD_MIN_LENGTH`). A name match needs a literal that could be a credential: an empty value, one made only of
12
+ * references or a boolean is not, nor a short number or duration under a name that says it is a quantity. The value matches on its own: a private key, an
13
+ * Authorization header, a URL with a password, an issuer's token prefix, or a long random string unless the name says
14
+ * the value is public (a publishable or site key, an id).
15
+ */
16
+ export declare function plainCredentialFinding(name: string, value: string): PlainCredentialFinding | null;