@fabrika/provider-zerops 0.9.0-dev.4 → 0.9.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/package.json +10 -9
  2. package/src/api/client.ts +12 -0
  3. package/src/api/readers.ts +29 -0
  4. package/src/api/types.ts +52 -0
  5. package/src/api.ts +2 -0
  6. package/src/cli.ts +11 -0
  7. package/src/collaborators.ts +0 -14
  8. package/src/compile.ts +1 -1
  9. package/src/control.ts +9 -57
  10. package/src/execution.ts +63 -185
  11. package/src/index.ts +2 -0
  12. package/src/installation/admin.ts +1 -1
  13. package/src/installation/deploy-options.ts +1 -2
  14. package/src/installation/deploy.ts +225 -80
  15. package/src/installation/generated/platform-console-schema.ts +3 -0
  16. package/src/installation/generated/platform-proxy-manifest.ts +1 -1
  17. package/src/installation/guide.md +48 -18
  18. package/src/installation/hosts.ts +1 -7
  19. package/src/installation/index.ts +13 -16
  20. package/src/installation/init-options.ts +2 -1
  21. package/src/installation/install-environment.ts +47 -108
  22. package/src/installation/install-options.ts +3 -1
  23. package/src/installation/install-secrets.ts +24 -68
  24. package/src/installation/install.ts +9 -4
  25. package/src/installation/sidecar.ts +5 -26
  26. package/src/installation/topology/setups.ts +15 -4
  27. package/src/installation/topology/topology.ts +31 -21
  28. package/src/installation/upgrade-options.ts +2 -2
  29. package/src/managed-env.ts +1 -174
  30. package/src/manifest.ts +2 -9
  31. package/src/namespace/claims.ts +56 -1
  32. package/src/namespace/errors.ts +1 -1
  33. package/src/namespace/manifest.ts +6 -19
  34. package/src/namespace/provisioning.ts +20 -2
  35. package/src/namespace/proxy-attempt.ts +14 -2
  36. package/src/namespace/proxy-reads.ts +12 -22
  37. package/src/namespace/types.ts +2 -0
  38. package/src/namespace-cli.ts +152 -0
  39. package/src/plan.ts +1 -6
  40. package/src/provider.ts +39 -93
  41. package/src/proxy-manifest-carrier.ts +18 -0
  42. package/src/types.ts +0 -2
  43. package/types/src/api/readers.d.ts +148 -10
  44. package/types/src/api/types.d.ts +49 -0
  45. package/types/src/api.d.ts +1 -1
  46. package/types/src/cli.d.ts +3 -0
  47. package/types/src/collaborators.d.ts +0 -2
  48. package/types/src/compile.d.ts +1 -1
  49. package/types/src/control.d.ts +3 -4
  50. package/types/src/execution.d.ts +5 -17
  51. package/types/src/index.d.ts +1 -1
  52. package/types/src/installation/deploy-options.d.ts +1 -1
  53. package/types/src/installation/deploy.d.ts +40 -0
  54. package/types/src/installation/generated/platform-proxy-manifest.d.ts +1 -1
  55. package/types/src/installation/hosts.d.ts +1 -5
  56. package/types/src/installation/index.d.ts +0 -2
  57. package/types/src/installation/install-environment.d.ts +11 -18
  58. package/types/src/installation/install-secrets.d.ts +3 -16
  59. package/types/src/installation/sidecar.d.ts +0 -2
  60. package/types/src/installation/topology/installation-schemas.d.ts +84 -84
  61. package/types/src/installation/topology/setups.d.ts +2 -1
  62. package/types/src/installation/topology/topology.d.ts +15 -10
  63. package/types/src/managed-env.d.ts +0 -33
  64. package/types/src/manifest.d.ts +0 -2
  65. package/types/src/namespace/claims.d.ts +14 -1
  66. package/types/src/namespace/codec.d.ts +4 -4
  67. package/types/src/namespace/errors.d.ts +1 -1
  68. package/types/src/namespace/proxy-attempt.d.ts +3 -0
  69. package/types/src/namespace/proxy-reads.d.ts +4 -15
  70. package/types/src/namespace/types.d.ts +2 -0
  71. package/types/src/namespace-cli.d.ts +2 -0
  72. package/types/src/plan.d.ts +2 -3
  73. package/types/src/provider.d.ts +0 -2
  74. package/types/src/proxy-manifest-carrier.d.ts +8 -0
  75. package/types/src/types.d.ts +0 -2
  76. package/src/installation/mcp.ts +0 -102
  77. package/src/installation/proxy-manifest.ts +0 -214
  78. package/src/installation/secrets.ts +0 -78
  79. package/types/src/installation/mcp.d.ts +0 -18
  80. package/types/src/installation/proxy-manifest.d.ts +0 -105
  81. package/types/src/installation/secrets.d.ts +0 -17
@@ -0,0 +1,152 @@
1
+ // `fabrika namespace` on Zerops: the provider options, the plan, and the namespace each command hands Control. The
2
+ // `fabrika` command holds Control's origin and credential, and prints the result.
3
+
4
+ import type { JsonValue, ProviderDeploymentNamespace, ProviderNamespacePlan } from '@fabrika/provider-contract'
5
+ import type { NamespaceCli, NamespaceCommandContext, NamespaceCommandResult } from '@fabrika/provider-contract/app-cli'
6
+ import { parseZeropsCliArgs, type ZeropsCliArgs } from './cli-args'
7
+ import {
8
+ createZeropsNamespaceOperator,
9
+ decodeZeropsNamespaceProxySource,
10
+ verifyZeropsNamespaceProxySource,
11
+ zeropsNamespaceTargetCodec,
12
+ } from './namespace'
13
+ import type { ZeropsNamespacePostgres } from './namespace'
14
+ import { postgresSchema } from './namespace/codec'
15
+
16
+ const NAMESPACE_USAGE = `fabrika namespace — Zerops deployment namespaces
17
+
18
+ Usage:
19
+ fabrika namespace plan --provider=zerops --id=<id> --env=<env> --preset=<cheap|mid|full> [namespace options]
20
+ fabrika namespace create --provider=zerops --id=<id> --env=<env> --preset=<cheap|mid|full> [namespace options] [--control-url=<url>]
21
+ fabrika namespace adopt --provider=zerops --id=<id> --env=<env> --preset=<cheap|mid|full> --project-id=<id> [namespace options] [--control-url=<url>]
22
+ fabrika namespace reconcile --provider=zerops --id=<id> [--control-url=<url>]
23
+
24
+ Options:
25
+ --id=<id> Namespace id.
26
+ --env=<env> Environment.
27
+ --preset=<cheap|mid|full> Provider-owned namespace preset.
28
+ --exclusive-app=<id> App reserved by a full namespace.
29
+ --project-id=<id> Existing Zerops project id for adoption.
30
+ --project-name=<name> Zerops project name (create: default fabrika-<env>-<id>;
31
+ adopt: the existing project's name, default the namespace id).
32
+ --core-package=<tier> LIGHT or SERIOUS.
33
+ --public-access=<mode> custom-domain or zerops-subdomain.
34
+ --postgres-type=<type> Cheap-tier PostgreSQL type.
35
+ --postgres-profile=<profile> Cheap-tier PostgreSQL profile.
36
+ --control-url=<url> Control origin; or FABRIKA_CONTROL_URL.
37
+ --json Print the result as JSON instead of rows.
38
+ -h, --help Show this help.
39
+
40
+ \`plan\` prints one \`<path>\\t<value>\` row per field of the plan, keyed by its path in --json; a multi-line
41
+ value such as the proxy's descriptor file is shown by size only. The other commands print one
42
+ \`<id>\\t<env>\\t<state>\\t<exclusive app>\` row.
43
+
44
+ Mutating namespace commands read the Bearer credential from FABRIKA_CONTROL_TOKEN.
45
+ Plan/create/adopt require FABRIKA_ZEROPS_PROXY_SOURCE_JSON:
46
+ {"repository":{"owner":"...","name":"..."},"commitSha":"...","descriptor":{"path":"zerops.yaml","contents":"...","sha256":"..."}}
47
+ Reconcile uses the persisted namespace source.
48
+ `
49
+
50
+ const required = (value: string | undefined, label: string): string => {
51
+ if (value === undefined || value.trim() === '') {
52
+ throw new Error(`${label} is required`)
53
+ }
54
+ return value.trim()
55
+ }
56
+
57
+ const postgres = (args: ZeropsCliArgs): ZeropsNamespacePostgres | undefined => {
58
+ const type = args.postgresType
59
+ const profile = args.postgresProfile
60
+ if (type === undefined && profile === undefined) return undefined
61
+ if (type === undefined) {
62
+ throw new Error('--postgres-type is required with --postgres-profile')
63
+ }
64
+ const result = postgresSchema.safeParse({ type, profile })
65
+ if (result.success) return result.data
66
+ if (result.error.issues[0]?.path[0] === 'type') throw new Error('--postgres-type must be postgresql:ha@18 or postgresql:single@18')
67
+ throw new Error(`--postgres-profile ${profile} is not supported by ${type}`)
68
+ }
69
+
70
+ const planOptions = (args: ZeropsCliArgs): { [key: string]: JsonValue } | undefined => {
71
+ const values: { [key: string]: JsonValue } = {}
72
+ if (args.projectName !== undefined) values['projectName'] = required(args.projectName, '--project-name')
73
+ if (args.corePackage !== undefined) values['corePackage'] = required(args.corePackage, '--core-package')
74
+ if (args.publicAccess !== undefined) values['publicAccess'] = required(args.publicAccess, '--public-access')
75
+ const database = postgres(args)
76
+ if (database !== undefined) {
77
+ values['postgres'] = database.profile === undefined ? { type: database.type } : { type: database.type, profile: database.profile }
78
+ }
79
+ return Object.keys(values).length === 0 ? undefined : values
80
+ }
81
+
82
+ const namespacePlan = async (
83
+ args: ZeropsCliArgs,
84
+ source: Readonly<Record<string, string | undefined>>,
85
+ ): Promise<ProviderNamespacePlan> => {
86
+ // `FABRIKA_ZEROPS_*` because Zerops reserves the bare `ZEROPS_` prefix and refuses to store a custom
87
+ // variable using it (`userDataZeropsPrefixForbidden`).
88
+ const serialized = required(source['FABRIKA_ZEROPS_PROXY_SOURCE_JSON'], 'FABRIKA_ZEROPS_PROXY_SOURCE_JSON')
89
+ let value: unknown
90
+ try {
91
+ value = JSON.parse(serialized)
92
+ } catch {
93
+ throw new Error('FABRIKA_ZEROPS_PROXY_SOURCE_JSON must contain valid JSON')
94
+ }
95
+ const proxySource = decodeZeropsNamespaceProxySource(value)
96
+ await verifyZeropsNamespaceProxySource(proxySource)
97
+ const operator = createZeropsNamespaceOperator({ proxySource })
98
+ const options = planOptions(args)
99
+ return operator.plan({
100
+ id: required(args.namespaceId, '--id'),
101
+ env: required(args.env, '--env'),
102
+ preset: required(args.preset, '--preset'),
103
+ ...(args.exclusiveAppId === undefined ? {} : { exclusiveAppId: required(args.exclusiveAppId, '--exclusive-app') }),
104
+ ...(options === undefined ? {} : { options }),
105
+ })
106
+ }
107
+
108
+ /** One namespace command. Every input is validated before `context.control()` is read. */
109
+ const runZeropsNamespaceCommand = async (
110
+ subcommand: string,
111
+ argv: readonly string[],
112
+ context: NamespaceCommandContext,
113
+ ): Promise<NamespaceCommandResult> => {
114
+ const args = parseZeropsCliArgs(['namespace', subcommand, ...argv])
115
+ if (subcommand === 'plan') {
116
+ return { plan: await namespacePlan(args, context.source) }
117
+ }
118
+ if (subcommand === 'reconcile') {
119
+ const id = required(args.namespaceId, '--id')
120
+ return { namespace: await context.control().reconcile(id) }
121
+ }
122
+ if (subcommand !== 'create' && subcommand !== 'adopt') {
123
+ throw new Error(`Unknown namespace command: ${subcommand}`)
124
+ }
125
+
126
+ const planned = await namespacePlan(args, context.source)
127
+ const control = context.control()
128
+ if (subcommand === 'create') {
129
+ return { namespace: await control.create(planned.namespace) }
130
+ }
131
+
132
+ const projectId = required(args.projectId, '--project-id')
133
+ const decoded = zeropsNamespaceTargetCodec.decode(planned.namespace.target.payload)
134
+ const namespace: ProviderDeploymentNamespace = {
135
+ ...planned.namespace,
136
+ target: {
137
+ provider: 'zerops',
138
+ version: zeropsNamespaceTargetCodec.version,
139
+ payload: zeropsNamespaceTargetCodec.encode({
140
+ ...decoded,
141
+ // An adopted project keeps its own name, so the plan's default for a created one does not apply.
142
+ projectName: args.projectName ?? planned.namespace.id,
143
+ managed: false,
144
+ projectId,
145
+ ready: false,
146
+ }),
147
+ },
148
+ }
149
+ return { namespace: await control.adopt(namespace) }
150
+ }
151
+
152
+ export const zeropsNamespaceCli: NamespaceCli = { usage: NAMESPACE_USAGE, run: runZeropsNamespaceCommand }
package/src/plan.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { type FabrikaManifest, manifestServiceHostnames } from './manifest'
2
- import type { ZeropsRuntimeTarget } from './types'
3
2
 
4
3
  export type ZeropsStepKind =
5
4
  | 'apply-import'
@@ -11,7 +10,6 @@ export type ZeropsStepKind =
11
10
  | 'upload-source'
12
11
  | 'trigger-build'
13
12
  | 'await-version'
14
- | 'reconcile-schema'
15
13
 
16
14
  export interface ZeropsStep {
17
15
  readonly id: string
@@ -30,7 +28,7 @@ export const resolveDeployHostname = (manifest: FabrikaManifest): string => {
30
28
  }
31
29
 
32
30
  /** Build the provider-owned deploy order without touching the platform. */
33
- export const buildZeropsPlan = (manifest: FabrikaManifest, target: ZeropsRuntimeTarget): readonly ZeropsStep[] => {
31
+ export const buildZeropsPlan = (manifest: FabrikaManifest): readonly ZeropsStep[] => {
34
32
  const serviceHostnames = manifestServiceHostnames(manifest)
35
33
  const steps: ZeropsStep[] = []
36
34
 
@@ -59,9 +57,6 @@ export const buildZeropsPlan = (manifest: FabrikaManifest, target: ZeropsRuntime
59
57
  steps.push({ id: 'upload-source', kind: 'upload-source', description: 'Upload the resolved repository snapshot' })
60
58
  steps.push({ id: 'trigger-build', kind: 'trigger-build', description: 'Trigger the Zerops build+deploy pipeline' })
61
59
  steps.push({ id: 'await-version', kind: 'await-version', description: 'Await the Zerops pipeline and relay its build log' })
62
- if (manifest.app.schema !== undefined && target.propustkaUrl !== undefined) {
63
- steps.push({ id: 'reconcile-schema', kind: 'reconcile-schema', description: 'Reconcile authz schema into IAM' })
64
- }
65
60
 
66
61
  return steps
67
62
  }
package/src/provider.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  // The Zerops provider owns its plan and every effect needed to execute it.
2
2
  //
3
3
  // A Zerops deploy is HTTP and nothing else (ADR-0003) — no container, no shell, no filesystem — so this
4
- // driver's whole side-effect surface is one REST client plus the portable schema reconciler
5
- // (`./collaborators.ts`). It never spawns a process and has no `runCommand` to be handed.
4
+ // driver's whole side-effect surface is one REST client (`./collaborators.ts`). It never spawns a process and has
5
+ // no `runCommand` to be handed.
6
6
  //
7
7
  // The interesting step is `await-version`: fabrika does not RUN the build, it WATCHES one the platform
8
8
  // runs. Recovery never resumes a deploy (ADR-0044): a version reserved but never triggered is deleted, and
9
9
  // one whose build may have been requested is settled only by polling it.
10
10
 
11
- import { appEnvironmentId, FABRIKA_SOURCE_MAP_UPLOAD_KEY } from '@fabrika/auth-core'
11
+ import { FABRIKA_SOURCE_MAP_UPLOAD_KEY, managedValue, staleManagedVariables } from '@fabrika/auth-core'
12
12
  import { type OperationsSourceMapUploadState, readSourceMapUploadReport } from '@fabrika/operations-contract/releases'
13
13
  import {
14
14
  type DeployStepResult,
@@ -66,20 +66,9 @@ import {
66
66
  type StorageProvenanceMarker,
67
67
  unprovenBucketReason,
68
68
  } from './exposure'
69
- import {
70
- assertAuthoredManagedDocument,
71
- assertAuthoredManagedInputs,
72
- isFrameworkFamilyVariable,
73
- isSensitiveFamilyVariable,
74
- type ManagedValues,
75
- overlayRelease,
76
- parseManagedEnvironment,
77
- SENSITIVE_MANAGED_KEYS,
78
- SERVICE_MANAGED_KEYS,
79
- } from './managed-env'
69
+ import { assertAuthoredManagedDocument, assertAuthoredManagedInputs, overlayRelease } from './managed-env'
80
70
  import {
81
71
  applicationDatabaseOf,
82
- approvedSchemaOf,
83
72
  type FabrikaImportDocument,
84
73
  type FabrikaManifest,
85
74
  lockedExecutionFor,
@@ -97,8 +86,6 @@ export const CANCELLED = 'deploy cancelled'
97
86
  export interface ZeropsDeployRun {
98
87
  readonly appId: string
99
88
  readonly env: string
100
- /** Every origin IAM may hand this app a session at; app-wide, because IAM's registry is keyed by app id. */
101
- readonly returnOrigins?: readonly string[]
102
89
  readonly secrets: Readonly<Record<string, string>>
103
90
  readonly vars: Readonly<Record<string, string>>
104
91
  /** Platform-owned runtime configuration, separate from operator-managed application vars. */
@@ -335,9 +322,8 @@ interface StepEnv {
335
322
  signal: AbortSignal
336
323
  dryRun: boolean
337
324
  attempt: Attempt
338
- managedValues: ManagedValues
339
- /** The key of each job and webhook of the approved contract, by its variable (ADR-0022 "Principal kinds"). */
340
- familyVariables: Readonly<Record<string, string>>
325
+ /** What Control handed (`parseManagedEnvironment`). */
326
+ managed: ProviderManagedEnvironment
341
327
  /** `await-version` gives up at this instant. */
342
328
  deadlineMs: number
343
329
  }
@@ -580,9 +566,9 @@ const verifyExposure = async (env: StepEnv): Promise<void> => {
580
566
  }
581
567
  }
582
568
  if (findings.length > 0) {
583
- const dsn = env.managedValues.FABRIKA_OPERATIONS_DSN
569
+ const dsn = managedValue(env.managed, 'FABRIKA_OPERATIONS_DSN')
584
570
  if (dsn !== null) {
585
- const alert = { appId: run.appId, env: run.env, release: env.managedValues.FABRIKA_RELEASE, findings }
571
+ const alert = { appId: run.appId, env: run.env, release: managedValue(env.managed, 'FABRIKA_RELEASE'), findings }
586
572
  await zerops.alertExposure({ dsn, alert, signal }).then(
587
573
  () => log(' raised an Operations alert'),
588
574
  () => log(' [warn] the Operations alert could not be sent'),
@@ -598,23 +584,28 @@ const verifyExposure = async (env: StepEnv): Promise<void> => {
598
584
  )
599
585
  }
600
586
 
601
- /** Write the eleven service-level managed keys; `FABRIKA_RELEASE` is never a service variable (ADR-0044). */
587
+ /** Write the managed variables Control handed; `FABRIKA_RELEASE` is never a service variable (ADR-0044). */
602
588
  const writeServiceEnv = async (env: StepEnv): Promise<void> => {
603
- const { zerops, log, signal, managedValues, familyVariables } = env
589
+ const { zerops, log, signal, managed } = env
604
590
  const serviceId = env.run.target.serviceId
591
+ const written = Object.entries(managed).flatMap(([key, { value, credential }]) =>
592
+ key === 'FABRIKA_RELEASE' || value === null ? [] : [{ key, value, credential }]
593
+ )
594
+ const writtenKeys = new Set(written.map(({ key }) => key))
605
595
  if (env.dryRun) {
606
596
  const upload = env.run.artifactUpload !== undefined
607
- const written = [
608
- ...SERVICE_MANAGED_KEYS.filter((key) => managedValues[key] !== null),
609
- ...Object.keys(familyVariables),
610
- ...(upload ? [FABRIKA_SOURCE_MAP_UPLOAD_KEY] : []),
611
- ]
612
- const removed = [...SERVICE_MANAGED_KEYS.filter((key) => managedValues[key] === null), ...(upload ? [] : [FABRIKA_SOURCE_MAP_UPLOAD_KEY])]
613
- log(` [dry-run] would write service variables on ${serviceId}: ${written.join(', ') || '(none)'}`)
614
- log(` [dry-run] would remove service variables on ${serviceId} if present: ${removed.join(', ') || '(none)'}`)
615
- if (Object.keys(familyVariables).length > 0) {
616
- log(` [dry-run] would remove every other job, webhook, connector and mail variable on ${serviceId}`)
617
- }
597
+ const removed = Object.keys(managed).filter((key) => key !== 'FABRIKA_RELEASE' && !writtenKeys.has(key))
598
+ log(
599
+ ` [dry-run] would write service variables on ${serviceId}: ${
600
+ [...writtenKeys, ...(upload ? [FABRIKA_SOURCE_MAP_UPLOAD_KEY] : [])].join(', ') || '(none)'
601
+ }`,
602
+ )
603
+ log(
604
+ ` [dry-run] would remove service variables on ${serviceId} if present: ${
605
+ [...removed, ...(upload ? [] : [FABRIKA_SOURCE_MAP_UPLOAD_KEY])].join(', ') || '(none)'
606
+ }`,
607
+ )
608
+ log(` [dry-run] would remove every other job, webhook, connector, mail and platform variable on ${serviceId}`)
618
609
  return
619
610
  }
620
611
  assertRunning(signal)
@@ -627,29 +618,23 @@ const writeServiceEnv = async (env: StepEnv): Promise<void> => {
627
618
  const remove = (key: string, envId: string): void => {
628
619
  changes.push({ line: `${key}: removed`, apply: () => zerops.api.deleteServiceEnv({ envId, signal }) })
629
620
  }
630
- for (const key of SERVICE_MANAGED_KEYS) {
631
- const value = managedValues[key]
621
+ // A credential is written sensitive and never read back, so it is written every time.
622
+ for (const { key, value, credential } of written) {
632
623
  const existing = records.find((record) => record.key === key)
633
- const sensitive = SENSITIVE_MANAGED_KEYS.has(key)
634
- if (value !== null && (sensitive || readableContent(existing) !== value)) put(key, value, sensitive)
635
- else if (value === null && existing !== undefined) remove(key, existing.id)
624
+ if (credential || readableContent(existing) !== value) put(key, value, credential)
636
625
  else changes.push({ line: `${key}: unchanged`, apply: null })
637
626
  }
627
+ // A variable Control no longer hands is removed, so no stale key stays readable. `/env` also reports the descriptor's
628
+ // `FABRIKA_RELEASE`, which Zerops refuses to delete.
629
+ const stale = new Set(staleManagedVariables(records.map((record) => record.key), new Set([...writtenKeys, 'FABRIKA_RELEASE'])))
630
+ for (const record of records) {
631
+ if (stale.has(record.key)) remove(record.key, record.id)
632
+ }
638
633
  const provenance = env.attempt.storageProvenance
639
634
  const marker = records.find((record) => record.key === STORAGE_PROVENANCE_KEY)
640
635
  // Not a credential, and the exposure read-back above reads it: it must stay readable.
641
636
  if (typeof provenance === 'string' && readableContent(marker) !== provenance) put(STORAGE_PROVENANCE_KEY, provenance, false)
642
637
  else if (provenance === null && marker !== undefined) remove(STORAGE_PROVENANCE_KEY, marker.id)
643
- // A workload key is written like a managed key; one whose workload is gone is removed, so no stale key stays readable.
644
- for (const [key, value] of Object.entries(familyVariables)) {
645
- const existing = records.find((record) => record.key === key)
646
- const sensitive = isSensitiveFamilyVariable(key)
647
- if (sensitive || readableContent(existing) !== value) put(key, value, sensitive)
648
- else changes.push({ line: `${key}: unchanged`, apply: null })
649
- }
650
- for (const record of records) {
651
- if (isFrameworkFamilyVariable(record.key) && !Object.hasOwn(familyVariables, record.key)) remove(record.key, record.id)
652
- }
653
638
  // The build lifts the upload's bearer from here (`${RUNTIME_…}`), so the descriptor never holds it.
654
639
  const bearer = env.run.artifactUpload?.bearer ?? null
655
640
  const uploadKey = records.find((record) => record.key === FABRIKA_SOURCE_MAP_UPLOAD_KEY)
@@ -833,7 +818,7 @@ const sizeDatabase = async (env: StepEnv): Promise<void> => {
833
818
  const deploy = await zerops.api.getService({ serviceId: run.target.serviceId, signal })
834
819
  const demand: ZeropsDatabaseDemand = {
835
820
  maxContainers: deploy.currentAutoscaling?.horizontal.maxContainerCount ?? ZEROPS_MAX_CONTAINERS,
836
- jobs: zeropsJobProcesses(locked.contract),
821
+ jobs: zeropsJobProcesses(locked),
837
822
  }
838
823
  const service = await zerops.api.findService({ projectId: run.target.projectId, hostname: database.hostname, signal })
839
824
  if (service === null) throw new Error(`zerops: the database ${database.hostname} does not exist, so its connections cannot be sized`)
@@ -995,7 +980,7 @@ const runStep = async (spec: ZeropsStep, env: StepEnv): Promise<void> => {
995
980
  const appVersionId = requireVersion(env, 'trigger-build')
996
981
  await verifyZeropsArtifactSourceDescriptor(artifact.target.sourceDescriptor)
997
982
  const { contents } = artifact.target.sourceDescriptor
998
- const release = env.managedValues.FABRIKA_RELEASE
983
+ const release = managedValue(env.managed, 'FABRIKA_RELEASE')
999
984
  const descriptor = locked === null
1000
985
  ? overlayRelease(contents, artifact.target.zeropsSetup, release)
1001
986
  : renderLockedExecutionDescriptor(contents, artifact.target.zeropsSetup, release, sizedExecution(locked, attempt))
@@ -1045,35 +1030,6 @@ const runStep = async (spec: ZeropsStep, env: StepEnv): Promise<void> => {
1045
1030
  await awaitVersion(env, appVersionId, attempt.processId, locked !== null && locked.databaseUrl !== null)
1046
1031
  return
1047
1032
  }
1048
-
1049
- case 'reconcile-schema': {
1050
- const schema = approvedSchemaOf(run)
1051
- const propustkaUrl = target.propustkaUrl
1052
- if (schema === undefined || propustkaUrl === undefined) {
1053
- return
1054
- }
1055
- // Return origins ride this step because `apps.setReturnOrigins` 404s for an app IAM has never
1056
- // heard of, and the schema reconcile is what registers it. Separate call, same moment.
1057
- const returnOrigins = run.returnOrigins !== undefined && run.returnOrigins.length > 0 ? run.returnOrigins : undefined
1058
- const iamApp = appEnvironmentId(artifact.app.id, artifact.app.env)
1059
- if (dryRun) {
1060
- log(` [dry-run] would reconcile schema for \`${iamApp}\` against ${propustkaUrl}`)
1061
- if (returnOrigins !== undefined) {
1062
- log(` [dry-run] would register return origins for \`${iamApp}\`: ${returnOrigins.join(', ')}`)
1063
- }
1064
- return
1065
- }
1066
- assertRunning(signal)
1067
- await zerops.reconcileSchema({
1068
- url: propustkaUrl,
1069
- app: iamApp,
1070
- schema,
1071
- ...(returnOrigins === undefined ? {} : { returnOrigins }),
1072
- adminKey: target.adminKey,
1073
- signal,
1074
- })
1075
- return
1076
- }
1077
1033
  }
1078
1034
  }
1079
1035
 
@@ -1095,15 +1051,6 @@ async (run: ZeropsDeployRun): Promise<ZeropsDeployResult> => {
1095
1051
  throw new Error(`zerops: artifact environment drift: expected \`${run.env}\`, got \`${run.artifact.app.env}\``)
1096
1052
  }
1097
1053
  assertAuthoredManagedInputs({ variableNames: Object.keys(run.vars), secretNames: Object.keys(run.secrets) })
1098
- // The proxy serves an endpoint table exactly when Control approved a contract, whatever the artifact says.
1099
- const contractProxy = run.access !== undefined
1100
- const { values: handed, familyVariables } = parseManagedEnvironment(run.managedEnvironment)
1101
- // Only a contract application checks the secret; any other would merely hold a credential its own code can print.
1102
- const managedValues: ManagedValues = contractProxy ? handed : { ...handed, FABRIKA_PROXY_SECRET: null }
1103
- if (!run.dryRun && contractProxy && managedValues.FABRIKA_PROXY_SECRET === null) {
1104
- // The application would refuse every request its proxy sends (ADR-0022 rule 5).
1105
- throw new Error('zerops: a contract application needs its proxy secret, and Control supplied none')
1106
- }
1107
1054
  const hostnames = manifestServiceHostnames(run.artifact)
1108
1055
  const document = interpolateManifest(run.artifact.target.importDocument, run.artifact.app.pipeline.vars, run.vars, hostnames)
1109
1056
  const compiled = { yaml: renderYaml(document), hostnames }
@@ -1117,11 +1064,10 @@ async (run: ZeropsDeployRun): Promise<ZeropsDeployResult> => {
1117
1064
  signal: run.signal,
1118
1065
  dryRun: run.dryRun,
1119
1066
  attempt: { triggered: false },
1120
- managedValues,
1121
- familyVariables,
1067
+ managed: run.managedEnvironment,
1122
1068
  deadlineMs: Date.now() + ZEROPS_VERSION_DEADLINE_MS,
1123
1069
  }
1124
- const steps = buildZeropsPlan(run.artifact, run.target)
1070
+ const steps = buildZeropsPlan(run.artifact)
1125
1071
  const options = { appId: run.appId, env: run.env, dryRun: run.dryRun, signal: run.signal, log: run.events.log }
1126
1072
  const result = await runSteps(steps, options, (step) => runStep(step, env))
1127
1073
  const { appVersionId, triggered } = env.attempt
@@ -30,3 +30,21 @@ export const zeropsProxyManifestCarrier = (descriptorContents: string, setup = '
30
30
  }
31
31
  return 'archive'
32
32
  }
33
+
34
+ /** The build variable that marks a proxy source whose manifest parser knows `brand` (ADR-0066). */
35
+ export const FABRIKA_PROXY_MANIFEST_BRAND = 'FABRIKA_PROXY_MANIFEST_BRAND'
36
+
37
+ /**
38
+ * Whether a pinned descriptor's proxy reads a manifest that carries the installation's client logo. An older parser
39
+ * refuses the unknown key and fails the build, so a namespace kept on such a pin gets no logo and keeps the fabrika
40
+ * mark until it is re-pinned (`--proxy-source=current`). Decided by the build section Zerops applies, as the carrier is.
41
+ */
42
+ export const zeropsProxyAcceptsBrand = (descriptorContents: string, setup = 'proxy'): boolean => {
43
+ const parsed = parseZeropsDescriptor(descriptorContents)
44
+ for (const entry of appliedZeropsSetups(parsed, selectZeropsDescriptorSetup(parsed, setup))) {
45
+ const read = buildSectionSchema.safeParse(entry)
46
+ if (!read.success) continue
47
+ return read.data.build.envVariables?.[FABRIKA_PROXY_MANIFEST_BRAND] === '1'
48
+ }
49
+ return false
50
+ }
package/src/types.ts CHANGED
@@ -150,6 +150,4 @@ export interface ZeropsRuntimeTarget {
150
150
  /** Absent only for dry runs, which perform no source or Zerops mutation. */
151
151
  source?: ZeropsRuntimeSource
152
152
  apiBaseUrl?: string
153
- propustkaUrl?: string
154
- adminKey?: string
155
153
  }