@wildo-ai/platform-config-lib 1.1.4 → 1.1.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.
- package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts +23 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.js +24 -0
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts +70 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.js +55 -4
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +12 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js +12 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
- package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts +29 -0
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.js +39 -0
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -1
- package/dist/esm/config-authoring.entry.d.ts.map +1 -1
- package/dist/esm/config-authoring.entry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lockfile/build-parallelism.d.ts +40 -0
- package/dist/esm/lockfile/build-parallelism.d.ts.map +1 -0
- package/dist/esm/lockfile/build-parallelism.js +64 -0
- package/dist/esm/lockfile/build-parallelism.js.map +1 -0
- package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.d.ts +1 -1
- package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
- package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.d.ts +899 -15
- package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.js +397 -16
- package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
- package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-minion-config.js +1 -2
- package/dist/esm/project-config/define-minion-config.js.map +1 -1
- package/dist/esm/project-config/define-saas-config.d.ts +90 -25
- package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-saas-config.js +165 -12
- package/dist/esm/project-config/define-saas-config.js.map +1 -1
- package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
- package/dist/esm/project-config/hosted-infra-env-config.d.ts +59 -0
- package/dist/esm/project-config/hosted-infra-env-config.d.ts.map +1 -0
- package/dist/esm/project-config/hosted-infra-env-config.js +187 -0
- package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -0
- package/dist/esm/project-config/index.d.ts +3 -0
- package/dist/esm/project-config/index.d.ts.map +1 -1
- package/dist/esm/project-config/index.js +3 -0
- package/dist/esm/project-config/index.js.map +1 -1
- package/dist/esm/project-config/loader.d.ts +24 -0
- package/dist/esm/project-config/loader.d.ts.map +1 -1
- package/dist/esm/project-config/loader.js +114 -1
- package/dist/esm/project-config/loader.js.map +1 -1
- package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.d.ts +32 -0
- package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.js +82 -12
- package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts +71 -22
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.js +135 -13
- package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
- package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.d.ts +14 -35
- package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.js +14 -35
- package/dist/esm/project-config/shared/auth.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts +17 -12
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.js +17 -12
- package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -1
- package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.d.ts +11 -12
- package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.js +11 -12
- package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.d.ts +152 -12
- package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.js +186 -9
- package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +5 -6
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.js +0 -3
- package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
- package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
- package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
- package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
- package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +77 -47
- package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
- package/dist/esm/project-config/shared/minion-resource-access.validation.js +114 -52
- package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
- package/dist/esm/project-config/shared/platform-services.schemas.d.ts +50 -0
- package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/platform-services.schemas.js +57 -0
- package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts +35 -0
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/platform-storage.schemas.js +37 -0
- package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts +81 -0
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.js +74 -0
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.js.map +1 -0
- package/dist/esm/registry/artifact-domain.schemas.d.ts +1 -1
- package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
- package/dist/esm/registry/companion-api.schemas.d.ts.map +1 -1
- package/dist/esm/registry/digest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/index.d.ts.map +1 -1
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.d.ts +10 -16
- package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.js +14 -20
- package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
- package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
- package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
- package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
- package/dist/esm/release/framework-release.constants.js.map +1 -1
- package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.d.ts +12 -1
- package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.js +14 -1
- package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
- package/dist/esm/workspace-scope/index.d.ts.map +1 -1
- package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +4 -3
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.js +6 -5
- package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts +15 -6
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.js +23 -9
- package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreResourceType, RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES, resolveSharedPersistenceCollectionName, } from '@wildo-ai/saas-models';
|
|
1
|
+
import { CoreResourceType, RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES, RuntimePrincipalDatabaseGrantAxis, resolveSharedPersistenceCollectionName, } from '@wildo-ai/saas-models';
|
|
2
2
|
/**
|
|
3
3
|
* The two safety gates that must hold BEFORE a minion's `resourceAccess` may be
|
|
4
4
|
* turned into database grants (Step 3 shared prerequisites, R11 + the F1 guard).
|
|
@@ -9,63 +9,102 @@ import { CoreResourceType, RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES, resol
|
|
|
9
9
|
* alias map is exactly where it is not.
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
|
-
* Resource types a minion may never declare (D15 / R11).
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* whole `users` collection — every user's
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
12
|
+
* Resource types a minion may never declare (D15 / R11) — every ALIASED door.
|
|
13
|
+
*
|
|
14
|
+
* An aliased door is a resource type whose rows live in ANOTHER resource type's
|
|
15
|
+
* collection (`RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES`). It is always the
|
|
16
|
+
* NARROWER of the two doors, and a database grant cannot be narrower than a
|
|
17
|
+
* collection — so a grant derived from the narrow door carries the wide one.
|
|
18
|
+
*
|
|
19
|
+
* The alias map holds two KINDS of narrow door, and both are refused for that
|
|
20
|
+
* same reason while differing in why they are narrow:
|
|
21
|
+
*
|
|
22
|
+
* - **self doors** (`USER_SELF`, `USER_SELF_PROFILES`, `USER_SELF_PREFERENCES`)
|
|
23
|
+
* address "MY row". They are additionally meaningless for a minion:
|
|
24
|
+
* `APPLICATION_MACHINE` carries no `userId`, so there is no row to be "mine".
|
|
25
|
+
* Declaring `USER_SELF` would grant the whole `users` collection — every user's
|
|
26
|
+
* row, through a door that promises one.
|
|
27
|
+
* - **subset doors** (`APPLICATION_AUDIT_LOGS`, #317) see a different SUBSET of a
|
|
28
|
+
* shared record set. The application audit door and the organization audit door
|
|
29
|
+
* read one trail; a grant derived from either carries the entire trail.
|
|
30
|
+
*
|
|
31
|
+
* This constant was named `MINION_FORBIDDEN_SELF_DOOR_RESOURCE_TYPES` while the
|
|
32
|
+
* map held only self doors, and kept that name — and a refusal message calling
|
|
33
|
+
* every entry a self door — after the audit door joined it (#458). The rule was
|
|
34
|
+
* never "self doors are forbidden"; it is "a grant must not be wider than the
|
|
35
|
+
* declaration reads", and the name now says that.
|
|
36
|
+
*
|
|
37
|
+
* Removing every aliased door from the declarable set is also what makes
|
|
38
|
+
* resource-type → collection INJECTIVE, so a grant derived per resource type means
|
|
39
|
+
* exactly what the author wrote. Relaxing it for convenience silently restores
|
|
40
|
+
* the coarser floor.
|
|
41
|
+
*
|
|
42
|
+
* Derived from the alias map rather than listed, so an alias added there is
|
|
43
|
+
* forbidden here on the same commit instead of quietly becoming declarable — and
|
|
44
|
+
* the pin in `minion-resource-access.validation.test.ts` forces that addition to
|
|
45
|
+
* be reviewed rather than absorbed.
|
|
31
46
|
*/
|
|
32
|
-
export const
|
|
47
|
+
export const MINION_FORBIDDEN_ALIASED_DOOR_RESOURCE_TYPES = Object.keys(RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES);
|
|
33
48
|
/**
|
|
34
|
-
* Reject
|
|
49
|
+
* Reject aliased-door types, and refuse any declaration whose types collapse onto
|
|
35
50
|
* one collection.
|
|
36
51
|
*
|
|
37
52
|
* Returns every violation rather than throwing on the first: an author fixing a
|
|
38
53
|
* config wants the whole list, and a caller that wants to fail closed can do so
|
|
39
54
|
* on a non-empty result.
|
|
40
55
|
*
|
|
41
|
-
* ## The injectivity check is NOT redundant with the
|
|
56
|
+
* ## The injectivity check is NOT redundant with the aliased-door rejection
|
|
42
57
|
*
|
|
43
|
-
* It is tempting to think removing the
|
|
58
|
+
* It is tempting to think removing the aliased doors makes collisions impossible —
|
|
44
59
|
* that is true of TODAY's alias map and is exactly why this must be checked
|
|
45
60
|
* rather than assumed. The alias map is data: a future entry that aliases two
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
61
|
+
* types a minion MAY declare onto one collection would reintroduce the collapse,
|
|
62
|
+
* and the grant derived for one type would silently carry the other's rows.
|
|
63
|
+
* Failing closed here makes that a build failure instead of a containment that
|
|
64
|
+
* quietly widened.
|
|
50
65
|
*/
|
|
51
66
|
export function findMinionResourceAccessViolations(resourceAccess) {
|
|
52
67
|
const violations = [];
|
|
53
68
|
const axes = [
|
|
54
|
-
[
|
|
55
|
-
[
|
|
69
|
+
[RuntimePrincipalDatabaseGrantAxis.READ, resourceAccess.read ?? []],
|
|
70
|
+
[RuntimePrincipalDatabaseGrantAxis.WRITE, resourceAccess.write ?? []],
|
|
56
71
|
];
|
|
72
|
+
// An APPEND-ONLY floor entry may not be widened to WRITE by declaration. Refused here, at parse
|
|
73
|
+
// time, rather than honoured downstream: the write axis carries DELETE, so `write: ['auditLogs']`
|
|
74
|
+
// is not a broader version of the audit floor — it is the one grant that lets a principal remove
|
|
75
|
+
// the evidence of what it did. This used to be permitted as "an explicit, reviewed decision", and
|
|
76
|
+
// the grant derivation kept the declared axis; but a declaration nobody is forced to justify is not
|
|
77
|
+
// a review, and the property the append axis exists for held only until somebody typed one word.
|
|
78
|
+
// Derived from the floor itself, so a type added to the append floor tomorrow is refused on write
|
|
79
|
+
// on the same commit.
|
|
80
|
+
for (const resourceType of resourceAccess.write ?? []) {
|
|
81
|
+
if (MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES.includes(resourceType)) {
|
|
82
|
+
violations.push({
|
|
83
|
+
axis: RuntimePrincipalDatabaseGrantAxis.WRITE,
|
|
84
|
+
resourceType,
|
|
85
|
+
message: `'${resourceType}' cannot be declared on a minion's write axis: the engine already grants it APPEND-only `
|
|
86
|
+
+ '(insert, never update or delete), and a write grant would let this minion modify or remove rows it '
|
|
87
|
+
+ 'appended — for the audit trail, the evidence of its own actions. Remove it from `write`; appending '
|
|
88
|
+
+ 'needs no declaration.',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
57
92
|
for (const [axis, declared] of axes) {
|
|
58
93
|
for (const resourceType of declared) {
|
|
59
|
-
if (
|
|
94
|
+
if (MINION_FORBIDDEN_ALIASED_DOOR_RESOURCE_TYPES.includes(resourceType)) {
|
|
95
|
+
// The message names only what is true of EVERY aliased door: the collection
|
|
96
|
+
// it shares and the wider type that owns it. An earlier message called each
|
|
97
|
+
// entry a "SELF door … every user's row", which was false for the audit door.
|
|
98
|
+
const widerResourceType = RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES[resourceType];
|
|
99
|
+
const collection = resolveSharedPersistenceCollectionName(resourceType);
|
|
60
100
|
violations.push({
|
|
61
101
|
axis,
|
|
62
102
|
resourceType,
|
|
63
|
-
message: `'${resourceType}' is
|
|
64
|
-
+ '
|
|
65
|
-
+ `
|
|
66
|
-
+ `'${
|
|
67
|
-
+ '
|
|
68
|
-
+ 'type explicitly if the minion genuinely needs that breadth.',
|
|
103
|
+
message: `'${resourceType}' is an ALIASED door and cannot be granted to a minion (D15): its rows live in the `
|
|
104
|
+
+ `'${collection}' collection it shares with '${widerResourceType}'. A database grant is issued per `
|
|
105
|
+
+ `collection, so granting '${resourceType}' would reach every row '${widerResourceType}' addresses — `
|
|
106
|
+
+ `wider than the door '${resourceType}' promises. Declare '${widerResourceType}' explicitly if the `
|
|
107
|
+
+ 'minion genuinely needs that breadth.',
|
|
69
108
|
});
|
|
70
109
|
}
|
|
71
110
|
}
|
|
@@ -164,7 +203,7 @@ export function resolveGrantStorageNames(resourceTypes) {
|
|
|
164
203
|
* ## Why this is not declarable, and must not become so
|
|
165
204
|
*
|
|
166
205
|
* `resourceAccess` answers "what application data may this minion touch". These
|
|
167
|
-
*
|
|
206
|
+
* entries answer a different question: "what does the framework itself touch
|
|
168
207
|
* in order to run a repository operation at all". No author decides them, no
|
|
169
208
|
* author can opt out of them, and asking one to write them down would be asking
|
|
170
209
|
* a human for an answer the mechanism already knows — the exact shape
|
|
@@ -178,8 +217,12 @@ export function resolveGrantStorageNames(resourceTypes) {
|
|
|
178
217
|
* so it triggers this one before it ever reaches `todos`.
|
|
179
218
|
* - **`AUDIT_LOGS`, append.** `AuditLogsBackendService` writes one row per audited
|
|
180
219
|
* operation, including the `system_context_read` it emits for the read above.
|
|
220
|
+
* - **`JOB_EXECUTIONS`, read/maintain.** Scheduled receipt, atomic admission,
|
|
221
|
+
* heartbeat and recovery update durable history, including after a restart.
|
|
222
|
+
* - **`JOB_PAYLOAD_STORAGE`, read/append.** Recovery retains completed output
|
|
223
|
+
* without granting the principal permission to rewrite or delete that output.
|
|
181
224
|
*
|
|
182
|
-
*
|
|
225
|
+
* These framework operations bypass the in-process `resourceAccess` whitelist by construction —
|
|
183
226
|
* `MinionScopedServicesRegistryHandlerBackendService` decorates the minion's
|
|
184
227
|
* SERVICES registry, and these go through the repositories registry — so the
|
|
185
228
|
* database grant was the only gate they ever met, and it refused them. That
|
|
@@ -194,12 +237,23 @@ export function resolveGrantStorageNames(resourceTypes) {
|
|
|
194
237
|
* audit trail a principal can delete is not an audit trail. The append axis exists
|
|
195
238
|
* so this floor can be satisfied without handing out that capability.
|
|
196
239
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
240
|
+
* ## What this does NOT cover
|
|
241
|
+
*
|
|
242
|
+
* Named runtime principals only. The APPLICATION BACKEND is issued a database-owning
|
|
243
|
+
* credential on every adapter (PostgreSQL `ALL PRIVILEGES`, MongoDB `readWrite` +
|
|
244
|
+
* `dbAdmin`, Atlas `readWrite`), so nothing at the database layer stops the backend's
|
|
245
|
+
* own credential from amending an audit row; for the backend, audit immutability is
|
|
246
|
+
* the application layer's — `AUDIT_LOGS` exposes no update or delete operation. And
|
|
247
|
+
* only the SELF-MANAGED adapters issue a per-principal credential at all.
|
|
248
|
+
*
|
|
249
|
+
* assurance-control: WILDO.AUDIT.TAMPER_RESISTANCE — a named runtime principal may add
|
|
250
|
+
* audit rows and may never modify or remove them, and may not be granted otherwise.
|
|
199
251
|
*/
|
|
200
|
-
export const MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES = [CoreResourceType.APPLICATION];
|
|
201
|
-
/** @see MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES — the append-only
|
|
202
|
-
export const MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES = [CoreResourceType.AUDIT_LOGS];
|
|
252
|
+
export const MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES = [CoreResourceType.APPLICATION, CoreResourceType.JOB_EXECUTIONS, CoreResourceType.JOB_PAYLOAD_STORAGE];
|
|
253
|
+
/** @see MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES — the append-only floor. */
|
|
254
|
+
export const MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES = [CoreResourceType.AUDIT_LOGS, CoreResourceType.JOB_PAYLOAD_STORAGE];
|
|
255
|
+
/** Insert and update durable execution state, without permission to erase its history. */
|
|
256
|
+
export const MINION_ENGINE_MANDATORY_MAINTAIN_RESOURCE_TYPES = [CoreResourceType.JOB_EXECUTIONS];
|
|
203
257
|
/**
|
|
204
258
|
* Add the engine floor to an authored derivation — the ONE place database grants
|
|
205
259
|
* acquire it.
|
|
@@ -220,15 +274,23 @@ export const MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES = [CoreResourceType.A
|
|
|
220
274
|
*/
|
|
221
275
|
export function deriveMinionDatabaseGrants(grants) {
|
|
222
276
|
const normalize = (resourceTypes) => [...new Set(resourceTypes)].sort();
|
|
223
|
-
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
|
|
277
|
+
const declaredWrite = new Set(grants.write);
|
|
278
|
+
// Fail closed on an append-only floor entry that arrived on the write axis. The parse-time gate in
|
|
279
|
+
// `findMinionResourceAccessViolations` refuses the declaration; reaching here with one means that
|
|
280
|
+
// gate was bypassed (a hand-built grant object), and honouring it would mint the one credential the
|
|
281
|
+
// append axis exists to withhold.
|
|
282
|
+
const widenedAppendFloor = MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES.filter((resourceType) => declaredWrite.has(resourceType));
|
|
283
|
+
if (widenedAppendFloor.length > 0) {
|
|
284
|
+
throw new Error(`Refusing to derive minion database grants that put append-only resource types on the write axis: `
|
|
285
|
+
+ `${widenedAppendFloor.join(', ')}. A write grant carries DELETE; these are granted APPEND only.`);
|
|
286
|
+
}
|
|
228
287
|
return {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
288
|
+
[RuntimePrincipalDatabaseGrantAxis.READ]: normalize([...grants.read, ...MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES]),
|
|
289
|
+
[RuntimePrincipalDatabaseGrantAxis.WRITE]: normalize(grants.write),
|
|
290
|
+
[RuntimePrincipalDatabaseGrantAxis.APPEND]: normalize(MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES),
|
|
291
|
+
// A MAINTAIN floor entry the author also declared on write keeps the wider axis: runtime state is
|
|
292
|
+
// not evidence, so the append-floor refusal above deliberately does not extend to it.
|
|
293
|
+
[RuntimePrincipalDatabaseGrantAxis.MAINTAIN]: normalize(MINION_ENGINE_MANDATORY_MAINTAIN_RESOURCE_TYPES.filter((resourceType) => !declaredWrite.has(resourceType))),
|
|
232
294
|
};
|
|
233
295
|
}
|
|
234
296
|
//# sourceMappingURL=minion-resource-access.validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minion-resource-access.validation.js","sourceRoot":"","sources":["../../../../src/project-config/shared/minion-resource-access.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,8CAA8C,EAC9C,sCAAsC,GAEvC,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,yCAAyC,GACpD,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;AAW9D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kCAAkC,CAAC,cAGlD;IACC,MAAM,UAAU,GAAoC,EAAE,CAAC;IACvD,MAAM,IAAI,GAAiD;QACzD,CAAC,MAAM,EAAE,cAAc,CAAC,IAAI,IAAI,EAAE,CAAC;QACnC,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;KACtC,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;QACpC,KAAK,MAAM,YAAY,IAAI,QAAQ,EAAE,CAAC;YACpC,IAAI,yCAAyC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACrE,UAAU,CAAC,IAAI,CAAC;oBACd,IAAI;oBACJ,YAAY;oBACZ,OAAO,EACL,IAAI,YAAY,4DAA4D;0BAC1E,sFAAsF;0BACtF,iEAAiE;0BACjE,IAAI,sCAAsC,CAAC,YAA4B,CAAC,iBAAiB;0BACzF,wFAAwF;0BACxF,6DAA6D;iBAClE,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,6EAA6E;QAC7E,yDAAyD;QACzD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;QACnD,KAAK,MAAM,YAAY,IAAI,QAAQ,EAAE,CAAC;YACpC,MAAM,UAAU,GAAG,sCAAsC,CAAC,YAA4B,CAAC,CAAC;YACxF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAClD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;gBACxD,UAAU,CAAC,IAAI,CAAC;oBACd,IAAI;oBACJ,YAAY;oBACZ,OAAO,EACL,IAAI,YAAY,UAAU,QAAQ,0BAA0B,UAAU,gBAAgB;0BACpF,sFAAsF;0BACtF,iFAAiF;0BACjF,8BAA8B;iBACnC,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YACD,gBAAgB,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAkCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAA2G,EAC3G,8BAAiD,EAAE;IAEnD,IAAI,CAAC,cAAc;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,UAAU,GAAG,kCAAkC,CAAC,cAAc,CAAC,CAAC;IACtE,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,uEAAuE;QACvE,2EAA2E;QAC3E,oDAAoD;QACpD,MAAM,IAAI,KAAK,CACb,4EAA4E;cAC1E,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACtF,CAAC;IACJ,CAAC;IAED,2EAA2E;IAC3E,oEAAoE;IACpE,MAAM,SAAS,GAAG,CAAC,aAAgC,EAAkB,EAAE,CACrE,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAoB,CAAC;IAEvD,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,GAAG,2BAA2B,CAAC,CAAC;QACjF,KAAK,EAAE,SAAS,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CAAC,aAAsC;IAC7E,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,sCAAsC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACxH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,MAAM,2CAA2C,GACtD,CAAC,gBAAgB,CAAC,WAAW,CAAuC,CAAC;AAEvE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,6CAA6C,GACxD,CAAC,gBAAgB,CAAC,UAAU,CAAuC,CAAC;AAgBtE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAA4B;IACrE,MAAM,SAAS,GAAG,CAAC,aAAsC,EAAkB,EAAE,CAC3E,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAErC,gFAAgF;IAChF,2EAA2E;IAC3E,2EAA2E;IAC3E,0BAA0B;IAC1B,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAE7E,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,2CAA2C,CAAC,CAAC;QACjF,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;QAC9B,MAAM,EAAE,SAAS,CACf,6CAA6C,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAC7G;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n CoreResourceType,\n RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES,\n resolveSharedPersistenceCollectionName,\n type ResourceType,\n} from '@wildo-ai/saas-models';\n\n/**\n * The two safety gates that must hold BEFORE a minion's `resourceAccess` may be\n * turned into database grants (Step 3 shared prerequisites, R11 + the F1 guard).\n *\n * Both exist because of the same asymmetry: `resourceAccess` is a RESOURCE-TYPE\n * whitelist, while a database grant is a COLLECTION grant. The two only line up\n * when the mapping between them is injective over the declarable set — and the\n * alias map is exactly where it is not.\n */\n\n/**\n * Resource types a minion may never declare (D15 / R11).\n *\n * A self-door type addresses \"MY row\" — it is meaningless for a principal that\n * has no row. `APPLICATION_MACHINE` carries no `userId`; a minion is not a user\n * and cannot become one. So the rejection is a SEMANTIC rule that happens to\n * also dissolve F1, not a convenience rule adopted because it was easier.\n *\n * That ordering matters for anyone tempted to relax this later. The alias map\n * holds exactly three entries, and all three are self→admin pairs onto the SAME\n * rows. Remove the self doors from the declarable set and resource-type →\n * collection becomes INJECTIVE, which is what lets a grant derived per resource\n * type mean exactly what the author wrote. Relaxing D15 for convenience would\n * silently restore the coarser floor: declaring `USER_SELF` would grant the\n * whole `users` collection — every user's row, through a door that promises\n * only one.\n *\n * Derived from the alias map rather than listed, so a fourth self door added\n * there is forbidden here on the same commit instead of quietly becoming\n * declarable.\n */\nexport const MINION_FORBIDDEN_SELF_DOOR_RESOURCE_TYPES: readonly string[] =\n Object.keys(RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES);\n\n/** One reason a `resourceAccess` declaration cannot be turned into grants. */\nexport interface MinionResourceAccessViolation {\n /** `read` or `write` — the axis the offending entry was declared on. */\n readonly axis: 'read' | 'write';\n readonly resourceType: string;\n /** Operator-facing explanation naming the consequence and the fix. */\n readonly message: string;\n}\n\n/**\n * Reject self-door types, and refuse any declaration whose types collapse onto\n * one collection.\n *\n * Returns every violation rather than throwing on the first: an author fixing a\n * config wants the whole list, and a caller that wants to fail closed can do so\n * on a non-empty result.\n *\n * ## The injectivity check is NOT redundant with the self-door rejection\n *\n * It is tempting to think removing the self doors makes collisions impossible —\n * that is true of TODAY's alias map and is exactly why this must be checked\n * rather than assumed. The alias map is data: a future entry that aliases two\n * ADMIN types onto one collection would reintroduce the collapse without\n * touching a self door, and the grant derived for one type would silently carry\n * the other's rows. Failing closed here makes that a build failure instead of a\n * containment that quietly widened.\n */\nexport function findMinionResourceAccessViolations(resourceAccess: {\n read?: readonly string[] | undefined;\n write?: readonly string[] | undefined;\n}): MinionResourceAccessViolation[] {\n const violations: MinionResourceAccessViolation[] = [];\n const axes: Array<['read' | 'write', readonly string[]]> = [\n ['read', resourceAccess.read ?? []],\n ['write', resourceAccess.write ?? []],\n ];\n\n for (const [axis, declared] of axes) {\n for (const resourceType of declared) {\n if (MINION_FORBIDDEN_SELF_DOOR_RESOURCE_TYPES.includes(resourceType)) {\n violations.push({\n axis,\n resourceType,\n message:\n `'${resourceType}' is a SELF door and cannot be granted to a minion (D15). `\n + 'A self door addresses \"my row\", and a minion has no row — it is a machine principal '\n + `carrying no userId. Granting it would give access to the whole `\n + `'${resolveSharedPersistenceCollectionName(resourceType as ResourceType)}' collection — `\n + 'every user\\'s row — through a door that promises only one. Declare the ADMIN resource '\n + 'type explicitly if the minion genuinely needs that breadth.',\n });\n }\n }\n\n // Injectivity, per AXIS: two declared types resolving to one collection make\n // the derived grant wider than either declaration reads.\n const collectionOwners = new Map<string, string>();\n for (const resourceType of declared) {\n const collection = resolveSharedPersistenceCollectionName(resourceType as ResourceType);\n const existing = collectionOwners.get(collection);\n if (existing !== undefined && existing !== resourceType) {\n violations.push({\n axis,\n resourceType,\n message:\n `'${resourceType}' and '${existing}' both resolve to the '${collection}' collection, `\n + 'so a grant derived from either carries the other\\'s rows. Refusing to derive grants '\n + 'from a declaration whose types are not injective over collections (F1 guard) — '\n + 'declare exactly one of them.',\n });\n continue;\n }\n collectionOwners.set(collection, resourceType);\n }\n }\n\n return violations;\n}\n\n/**\n * What a minion may touch, per axis — expressed in RESOURCE TYPES, the\n * vocabulary the rest of the platform speaks.\n *\n * ## Why not collection names\n *\n * An earlier revision returned collection names, which quietly made storage the\n * API of a security decision. `resourceAccess` is AUTHORED in resource types,\n * `ResourceType` is what every other Wildo surface passes around, and a\n * collection is one adapter's rendering of where those rows happen to live —\n * MongoDB calls it a collection, PostgreSQL a table, and a future adapter will\n * call it something else again. Naming the security contract after one of them\n * would force every reader to translate back, and would make the grant set look\n * different depending on which database an application chose.\n *\n * The translation therefore happens at the ADAPTER boundary — see\n * {@link resolveGrantStorageNames} — which is the only place that legitimately\n * knows about storage, exactly as external protocol literals are confined to the\n * thin adapter that speaks them.\n *\n * `null` means **no access was declared at all**, which is NOT the same as an\n * empty declaration and must not be flattened into one. Absent ⇒ mint no\n * database user whatsoever (D11 / R3: application-data access is an OPTIONAL\n * capability). Declared-but-empty ⇒ the author asked for a principal with no\n * access, a different and legitimate statement. One \"empty list\" for both would\n * make \"I forgot\" indistinguishable from \"I meant none\".\n */\nexport interface MinionResourceGrants {\n readonly read: readonly ResourceType[];\n readonly write: readonly ResourceType[];\n}\n\n/**\n * Derive a minion's grants from an authored `resourceAccess`.\n *\n * ## `write` does NOT imply `read`, deliberately\n *\n * It is tempting to add read wherever write is granted — most write paths in the\n * backend pipeline do read first (validation, FK resolution, read-modify-write),\n * so a `write: ['todos']` minion will often need `read: ['todos']` too.\n *\n * It is still refused, for the reason this entire workstream exists: a grant the\n * author did not write is a grant nobody reviewed. An insert-only minion is a\n * real shape, and silently widening every writer to a reader would make the\n * declaration stop describing the outcome — the precise property that made\n * `resourceAccess` non-binding before it produced real credentials.\n *\n * The cost is stated rather than hidden: a minion that writes without declaring\n * read will fail at RUNTIME on its first read, with the database naming the\n * action it lacked. A loud, local failure with an obvious fix (declare the read)\n * is the trade this prefers over a silent widening.\n *\n * ## The F2 transitive read path is the CALLER's to supply\n *\n * A declared type can pull in others through nested reads — the closure rule is\n * *declared ∪ child-direction targets declaring nested `onRead`, transitively*.\n * Computing it needs the resource graph, which this layer does not have, so it\n * arrives as `transitiveReadResourceTypes`. Omitting it is correct ONLY when the\n * application declares no nested `onRead` (true of Wonder Todos, measured\n * 2026-08-05); omitting it elsewhere yields a credential that is denied on a\n * path which works today.\n */\nexport function deriveMinionResourceGrants(\n resourceAccess: { read?: readonly string[] | undefined; write?: readonly string[] | undefined } | undefined,\n transitiveReadResourceTypes: readonly string[] = [],\n): MinionResourceGrants | null {\n if (!resourceAccess) return null;\n\n const violations = findMinionResourceAccessViolations(resourceAccess);\n if (violations.length > 0) {\n // Fail closed. Reaching here means the parse-time gate was bypassed (a\n // hand-built object, a future caller); deriving anyway would issue exactly\n // the over-broad grant those gates exist to refuse.\n throw new Error(\n `Refusing to derive minion resource grants from an invalid resourceAccess: `\n + violations.map((violation) => `[${violation.axis}] ${violation.message}`).join(' '),\n );\n }\n\n // Deduped and ordered so a grant set is stable between syncs — an unstable\n // one reads as a change and would re-issue credentials for nothing.\n const normalize = (resourceTypes: readonly string[]): ResourceType[] =>\n [...new Set(resourceTypes)].sort() as ResourceType[];\n\n return {\n read: normalize([...(resourceAccess.read ?? []), ...transitiveReadResourceTypes]),\n write: normalize(resourceAccess.write ?? []),\n };\n}\n\n/**\n * Translate a grant axis into the STORAGE names one adapter will grant on.\n *\n * The single, explicitly-named boundary between the platform vocabulary and a\n * database dialect. A Mongo module builds collection privileges from it; a\n * PostgreSQL module builds table grants; both call the same function so the two\n * cannot disagree about which rows a resource type addresses.\n *\n * Safe to collapse duplicates here ONLY because the F1 guard already refused any\n * declaration whose types share a collection — see\n * {@link findMinionResourceAccessViolations}. Without that guarantee this\n * function would silently merge two declarations into one grant.\n */\nexport function resolveGrantStorageNames(resourceTypes: readonly ResourceType[]): string[] {\n return [...new Set(resourceTypes.map((resourceType) => resolveSharedPersistenceCollectionName(resourceType)))].sort();\n}\n\n/**\n * What the ENGINE reads and writes for every runtime principal, whatever that\n * principal declared — the floor a database role must hold before any authored\n * `resourceAccess` is considered at all.\n *\n * ## Why this is not declarable, and must not become so\n *\n * `resourceAccess` answers \"what application data may this minion touch\". These\n * two entries answer a different question: \"what does the framework itself touch\n * in order to run a repository operation at all\". No author decides them, no\n * author can opt out of them, and asking one to write them down would be asking\n * a human for an answer the mechanism already knows — the exact shape\n * `.claude/rules/derive-before-you-ask.md` refuses. They are derived here, once,\n * from the engine paths that actually perform them:\n *\n * - **`APPLICATION`, read.** `ExecutionContextCreatorBackendService.getApplicationId`\n * resolves the singleton APPLICATION row for EVERY `ResourcePrimaryScope.APPLICATION`\n * operation, through `repositoriesRegistry` directly. That read is structural:\n * a minion declaring `read: ['todos']` is declaring an APPLICATION-scoped read,\n * so it triggers this one before it ever reaches `todos`.\n * - **`AUDIT_LOGS`, append.** `AuditLogsBackendService` writes one row per audited\n * operation, including the `system_context_read` it emits for the read above.\n *\n * Both bypass the in-process `resourceAccess` whitelist by construction —\n * `MinionScopedServicesRegistryHandlerBackendService` decorates the minion's\n * SERVICES registry, and these go through the repositories registry — so the\n * database grant was the only gate they ever met, and it refused them. That\n * asymmetry is the defect: the in-process policy already permits these reads,\n * and the credential did not.\n *\n * ## Why AUDIT_LOGS is APPEND and not WRITE\n *\n * The `write` axis grants `INSERT, UPDATE, DELETE`. Putting the audit table there\n * would let every minion rewrite or delete the evidence of its own actions, which\n * is not a smaller version of the right answer — it is the opposite of one. An\n * audit trail a principal can delete is not an audit trail. The append axis exists\n * so this floor can be satisfied without handing out that capability.\n *\n * assurance-control: WILDO.AUDIT.TAMPER_RESISTANCE — a runtime principal may add\n * audit rows and may never modify or remove them.\n */\nexport const MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES: readonly ResourceType[] =\n [CoreResourceType.APPLICATION] as unknown as readonly ResourceType[];\n\n/** @see MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES — the append-only half. */\nexport const MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES: readonly ResourceType[] =\n [CoreResourceType.AUDIT_LOGS] as unknown as readonly ResourceType[];\n\n/**\n * A minion's grants as a DATABASE role must hold them: what the author declared,\n * plus the engine floor above.\n *\n * The third axis is what keeps the floor honest — see\n * {@link MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES}.\n */\nexport interface MinionDatabaseGrants {\n readonly read: readonly ResourceType[];\n readonly write: readonly ResourceType[];\n /** Insert-only. Never update, never delete. */\n readonly append: readonly ResourceType[];\n}\n\n/**\n * Add the engine floor to an authored derivation — the ONE place database grants\n * acquire it.\n *\n * ## Why here and not in {@link deriveMinionResourceGrants}\n *\n * That function answers \"what did the author declare\", and it has a THIRD\n * consumer that must not receive this floor: the object-storage credential path\n * turns the same grants into blob key prefixes. Widening it there would confine a\n * minion's storage credential to an `applications/` prefix nobody asked for and\n * nothing writes. The floor is a property of holding a DATABASE role, so it is\n * applied at the boundary where a database role is minted — and both database\n * adapters call this one function, so they cannot drift apart the way the mint\n * and revoke halves of those adapters already have once\n * (`.claude/rules/invariant-call-site-enumeration.md` #18).\n *\n * Idempotent: a floor entry the author also declared appears once.\n */\nexport function deriveMinionDatabaseGrants(grants: MinionResourceGrants): MinionDatabaseGrants {\n const normalize = (resourceTypes: readonly ResourceType[]): ResourceType[] =>\n [...new Set(resourceTypes)].sort();\n\n // A floor entry the author declared on a WIDER axis keeps that axis rather than\n // being demoted: declaring `write: ['auditLogs']` is an explicit, reviewed\n // decision, and silently narrowing it here would make the declaration stop\n // describing the outcome.\n const declaredElsewhere = new Set<string>([...grants.read, ...grants.write]);\n\n return {\n read: normalize([...grants.read, ...MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES]),\n write: normalize(grants.write),\n append: normalize(\n MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES.filter((resourceType) => !declaredElsewhere.has(resourceType)),\n ),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"minion-resource-access.validation.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/minion-resource-access.validation.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n CoreResourceType,\n RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES,\n RuntimePrincipalDatabaseGrantAxis,\n resolveSharedPersistenceCollectionName,\n type ResourceType,\n} from '@wildo-ai/saas-models';\n\n/**\n * The two safety gates that must hold BEFORE a minion's `resourceAccess` may be\n * turned into database grants (Step 3 shared prerequisites, R11 + the F1 guard).\n *\n * Both exist because of the same asymmetry: `resourceAccess` is a RESOURCE-TYPE\n * whitelist, while a database grant is a COLLECTION grant. The two only line up\n * when the mapping between them is injective over the declarable set — and the\n * alias map is exactly where it is not.\n */\n\n/**\n * Resource types a minion may never declare (D15 / R11) — every ALIASED door.\n *\n * An aliased door is a resource type whose rows live in ANOTHER resource type's\n * collection (`RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES`). It is always the\n * NARROWER of the two doors, and a database grant cannot be narrower than a\n * collection — so a grant derived from the narrow door carries the wide one.\n *\n * The alias map holds two KINDS of narrow door, and both are refused for that\n * same reason while differing in why they are narrow:\n *\n * - **self doors** (`USER_SELF`, `USER_SELF_PROFILES`, `USER_SELF_PREFERENCES`)\n * address \"MY row\". They are additionally meaningless for a minion:\n * `APPLICATION_MACHINE` carries no `userId`, so there is no row to be \"mine\".\n * Declaring `USER_SELF` would grant the whole `users` collection — every user's\n * row, through a door that promises one.\n * - **subset doors** (`APPLICATION_AUDIT_LOGS`, #317) see a different SUBSET of a\n * shared record set. The application audit door and the organization audit door\n * read one trail; a grant derived from either carries the entire trail.\n *\n * This constant was named `MINION_FORBIDDEN_SELF_DOOR_RESOURCE_TYPES` while the\n * map held only self doors, and kept that name — and a refusal message calling\n * every entry a self door — after the audit door joined it (#458). The rule was\n * never \"self doors are forbidden\"; it is \"a grant must not be wider than the\n * declaration reads\", and the name now says that.\n *\n * Removing every aliased door from the declarable set is also what makes\n * resource-type → collection INJECTIVE, so a grant derived per resource type means\n * exactly what the author wrote. Relaxing it for convenience silently restores\n * the coarser floor.\n *\n * Derived from the alias map rather than listed, so an alias added there is\n * forbidden here on the same commit instead of quietly becoming declarable — and\n * the pin in `minion-resource-access.validation.test.ts` forces that addition to\n * be reviewed rather than absorbed.\n */\nexport const MINION_FORBIDDEN_ALIASED_DOOR_RESOURCE_TYPES: readonly string[] =\n Object.keys(RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES);\n\n/** One reason a `resourceAccess` declaration cannot be turned into grants. */\nexport interface MinionResourceAccessViolation {\n /** The AUTHORED axis the offending entry was declared on — `resourceAccess` has only these two. */\n readonly axis: RuntimePrincipalDatabaseGrantAxis.READ | RuntimePrincipalDatabaseGrantAxis.WRITE;\n readonly resourceType: string;\n /** Operator-facing explanation naming the consequence and the fix. */\n readonly message: string;\n}\n\n/**\n * Reject aliased-door types, and refuse any declaration whose types collapse onto\n * one collection.\n *\n * Returns every violation rather than throwing on the first: an author fixing a\n * config wants the whole list, and a caller that wants to fail closed can do so\n * on a non-empty result.\n *\n * ## The injectivity check is NOT redundant with the aliased-door rejection\n *\n * It is tempting to think removing the aliased doors makes collisions impossible —\n * that is true of TODAY's alias map and is exactly why this must be checked\n * rather than assumed. The alias map is data: a future entry that aliases two\n * types a minion MAY declare onto one collection would reintroduce the collapse,\n * and the grant derived for one type would silently carry the other's rows.\n * Failing closed here makes that a build failure instead of a containment that\n * quietly widened.\n */\nexport function findMinionResourceAccessViolations(resourceAccess: {\n read?: readonly string[] | undefined;\n write?: readonly string[] | undefined;\n}): MinionResourceAccessViolation[] {\n const violations: MinionResourceAccessViolation[] = [];\n const axes: Array<[MinionResourceAccessViolation['axis'], readonly string[]]> = [\n [RuntimePrincipalDatabaseGrantAxis.READ, resourceAccess.read ?? []],\n [RuntimePrincipalDatabaseGrantAxis.WRITE, resourceAccess.write ?? []],\n ];\n\n // An APPEND-ONLY floor entry may not be widened to WRITE by declaration. Refused here, at parse\n // time, rather than honoured downstream: the write axis carries DELETE, so `write: ['auditLogs']`\n // is not a broader version of the audit floor — it is the one grant that lets a principal remove\n // the evidence of what it did. This used to be permitted as \"an explicit, reviewed decision\", and\n // the grant derivation kept the declared axis; but a declaration nobody is forced to justify is not\n // a review, and the property the append axis exists for held only until somebody typed one word.\n // Derived from the floor itself, so a type added to the append floor tomorrow is refused on write\n // on the same commit.\n for (const resourceType of resourceAccess.write ?? []) {\n if ((MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES as readonly string[]).includes(resourceType)) {\n violations.push({\n axis: RuntimePrincipalDatabaseGrantAxis.WRITE,\n resourceType,\n message:\n `'${resourceType}' cannot be declared on a minion's write axis: the engine already grants it APPEND-only `\n + '(insert, never update or delete), and a write grant would let this minion modify or remove rows it '\n + 'appended — for the audit trail, the evidence of its own actions. Remove it from `write`; appending '\n + 'needs no declaration.',\n });\n }\n }\n\n for (const [axis, declared] of axes) {\n for (const resourceType of declared) {\n if (MINION_FORBIDDEN_ALIASED_DOOR_RESOURCE_TYPES.includes(resourceType)) {\n // The message names only what is true of EVERY aliased door: the collection\n // it shares and the wider type that owns it. An earlier message called each\n // entry a \"SELF door … every user's row\", which was false for the audit door.\n const widerResourceType = RESOURCE_SHARED_PERSISTENCE_COLLECTION_ALIASES[resourceType]!;\n const collection = resolveSharedPersistenceCollectionName(resourceType as ResourceType);\n violations.push({\n axis,\n resourceType,\n message:\n `'${resourceType}' is an ALIASED door and cannot be granted to a minion (D15): its rows live in the `\n + `'${collection}' collection it shares with '${widerResourceType}'. A database grant is issued per `\n + `collection, so granting '${resourceType}' would reach every row '${widerResourceType}' addresses — `\n + `wider than the door '${resourceType}' promises. Declare '${widerResourceType}' explicitly if the `\n + 'minion genuinely needs that breadth.',\n });\n }\n }\n\n // Injectivity, per AXIS: two declared types resolving to one collection make\n // the derived grant wider than either declaration reads.\n const collectionOwners = new Map<string, string>();\n for (const resourceType of declared) {\n const collection = resolveSharedPersistenceCollectionName(resourceType as ResourceType);\n const existing = collectionOwners.get(collection);\n if (existing !== undefined && existing !== resourceType) {\n violations.push({\n axis,\n resourceType,\n message:\n `'${resourceType}' and '${existing}' both resolve to the '${collection}' collection, `\n + 'so a grant derived from either carries the other\\'s rows. Refusing to derive grants '\n + 'from a declaration whose types are not injective over collections (F1 guard) — '\n + 'declare exactly one of them.',\n });\n continue;\n }\n collectionOwners.set(collection, resourceType);\n }\n }\n\n return violations;\n}\n\n/**\n * What a minion may touch, per axis — expressed in RESOURCE TYPES, the\n * vocabulary the rest of the platform speaks.\n *\n * ## Why not collection names\n *\n * An earlier revision returned collection names, which quietly made storage the\n * API of a security decision. `resourceAccess` is AUTHORED in resource types,\n * `ResourceType` is what every other Wildo surface passes around, and a\n * collection is one adapter's rendering of where those rows happen to live —\n * MongoDB calls it a collection, PostgreSQL a table, and a future adapter will\n * call it something else again. Naming the security contract after one of them\n * would force every reader to translate back, and would make the grant set look\n * different depending on which database an application chose.\n *\n * The translation therefore happens at the ADAPTER boundary — see\n * {@link resolveGrantStorageNames} — which is the only place that legitimately\n * knows about storage, exactly as external protocol literals are confined to the\n * thin adapter that speaks them.\n *\n * `null` means **no access was declared at all**, which is NOT the same as an\n * empty declaration and must not be flattened into one. Absent ⇒ no authored business-data access. The database credential owner\n * separately supplies the mandatory runtime floor; object storage must not receive\n * that floor. Declared-but-empty remains an explicit author decision. One \"empty list\" for both would\n * make \"I forgot\" indistinguishable from \"I meant none\".\n */\nexport interface MinionResourceGrants {\n readonly read: readonly ResourceType[];\n readonly write: readonly ResourceType[];\n}\n\n/**\n * Derive a minion's grants from an authored `resourceAccess`.\n *\n * ## `write` does NOT imply `read`, deliberately\n *\n * It is tempting to add read wherever write is granted — most write paths in the\n * backend pipeline do read first (validation, FK resolution, read-modify-write),\n * so a `write: ['todos']` minion will often need `read: ['todos']` too.\n *\n * It is still refused, for the reason this entire workstream exists: a grant the\n * author did not write is a grant nobody reviewed. An insert-only minion is a\n * real shape, and silently widening every writer to a reader would make the\n * declaration stop describing the outcome — the precise property that made\n * `resourceAccess` non-binding before it produced real credentials.\n *\n * The cost is stated rather than hidden: a minion that writes without declaring\n * read will fail at RUNTIME on its first read, with the database naming the\n * action it lacked. A loud, local failure with an obvious fix (declare the read)\n * is the trade this prefers over a silent widening.\n *\n * ## The F2 transitive read path is the CALLER's to supply\n *\n * A declared type can pull in others through nested reads — the closure rule is\n * *declared ∪ child-direction targets declaring nested `onRead`, transitively*.\n * Computing it needs the resource graph, which this layer does not have, so it\n * arrives as `transitiveReadResourceTypes`. Omitting it is correct ONLY when the\n * application declares no nested `onRead` (true of Wonder Todos, measured\n * 2026-08-05); omitting it elsewhere yields a credential that is denied on a\n * path which works today.\n */\nexport function deriveMinionResourceGrants(\n resourceAccess: { read?: readonly string[] | undefined; write?: readonly string[] | undefined } | undefined,\n transitiveReadResourceTypes: readonly string[] = [],\n): MinionResourceGrants | null {\n if (!resourceAccess) return null;\n\n const violations = findMinionResourceAccessViolations(resourceAccess);\n if (violations.length > 0) {\n // Fail closed. Reaching here means the parse-time gate was bypassed (a\n // hand-built object, a future caller); deriving anyway would issue exactly\n // the over-broad grant those gates exist to refuse.\n throw new Error(\n `Refusing to derive minion resource grants from an invalid resourceAccess: `\n + violations.map((violation) => `[${violation.axis}] ${violation.message}`).join(' '),\n );\n }\n\n // Deduped and ordered so a grant set is stable between syncs — an unstable\n // one reads as a change and would re-issue credentials for nothing.\n const normalize = (resourceTypes: readonly string[]): ResourceType[] =>\n [...new Set(resourceTypes)].sort() as ResourceType[];\n\n return {\n read: normalize([...(resourceAccess.read ?? []), ...transitiveReadResourceTypes]),\n write: normalize(resourceAccess.write ?? []),\n };\n}\n\n/**\n * Translate a grant axis into the STORAGE names one adapter will grant on.\n *\n * The single, explicitly-named boundary between the platform vocabulary and a\n * database dialect. A Mongo module builds collection privileges from it; a\n * PostgreSQL module builds table grants; both call the same function so the two\n * cannot disagree about which rows a resource type addresses.\n *\n * Safe to collapse duplicates here ONLY because the F1 guard already refused any\n * declaration whose types share a collection — see\n * {@link findMinionResourceAccessViolations}. Without that guarantee this\n * function would silently merge two declarations into one grant.\n */\nexport function resolveGrantStorageNames(resourceTypes: readonly ResourceType[]): string[] {\n return [...new Set(resourceTypes.map((resourceType) => resolveSharedPersistenceCollectionName(resourceType)))].sort();\n}\n\n/**\n * What the ENGINE reads and writes for every runtime principal, whatever that\n * principal declared — the floor a database role must hold before any authored\n * `resourceAccess` is considered at all.\n *\n * ## Why this is not declarable, and must not become so\n *\n * `resourceAccess` answers \"what application data may this minion touch\". These\n * entries answer a different question: \"what does the framework itself touch\n * in order to run a repository operation at all\". No author decides them, no\n * author can opt out of them, and asking one to write them down would be asking\n * a human for an answer the mechanism already knows — the exact shape\n * `.claude/rules/derive-before-you-ask.md` refuses. They are derived here, once,\n * from the engine paths that actually perform them:\n *\n * - **`APPLICATION`, read.** `ExecutionContextCreatorBackendService.getApplicationId`\n * resolves the singleton APPLICATION row for EVERY `ResourcePrimaryScope.APPLICATION`\n * operation, through `repositoriesRegistry` directly. That read is structural:\n * a minion declaring `read: ['todos']` is declaring an APPLICATION-scoped read,\n * so it triggers this one before it ever reaches `todos`.\n * - **`AUDIT_LOGS`, append.** `AuditLogsBackendService` writes one row per audited\n * operation, including the `system_context_read` it emits for the read above.\n * - **`JOB_EXECUTIONS`, read/maintain.** Scheduled receipt, atomic admission,\n * heartbeat and recovery update durable history, including after a restart.\n * - **`JOB_PAYLOAD_STORAGE`, read/append.** Recovery retains completed output\n * without granting the principal permission to rewrite or delete that output.\n *\n * These framework operations bypass the in-process `resourceAccess` whitelist by construction —\n * `MinionScopedServicesRegistryHandlerBackendService` decorates the minion's\n * SERVICES registry, and these go through the repositories registry — so the\n * database grant was the only gate they ever met, and it refused them. That\n * asymmetry is the defect: the in-process policy already permits these reads,\n * and the credential did not.\n *\n * ## Why AUDIT_LOGS is APPEND and not WRITE\n *\n * The `write` axis grants `INSERT, UPDATE, DELETE`. Putting the audit table there\n * would let every minion rewrite or delete the evidence of its own actions, which\n * is not a smaller version of the right answer — it is the opposite of one. An\n * audit trail a principal can delete is not an audit trail. The append axis exists\n * so this floor can be satisfied without handing out that capability.\n *\n * ## What this does NOT cover\n *\n * Named runtime principals only. The APPLICATION BACKEND is issued a database-owning\n * credential on every adapter (PostgreSQL `ALL PRIVILEGES`, MongoDB `readWrite` +\n * `dbAdmin`, Atlas `readWrite`), so nothing at the database layer stops the backend's\n * own credential from amending an audit row; for the backend, audit immutability is\n * the application layer's — `AUDIT_LOGS` exposes no update or delete operation. And\n * only the SELF-MANAGED adapters issue a per-principal credential at all.\n *\n * assurance-control: WILDO.AUDIT.TAMPER_RESISTANCE — a named runtime principal may add\n * audit rows and may never modify or remove them, and may not be granted otherwise.\n */\nexport const MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES: readonly ResourceType[] =\n [CoreResourceType.APPLICATION, CoreResourceType.JOB_EXECUTIONS, CoreResourceType.JOB_PAYLOAD_STORAGE] as unknown as readonly ResourceType[];\n\n/** @see MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES — the append-only floor. */\nexport const MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES: readonly ResourceType[] =\n [CoreResourceType.AUDIT_LOGS, CoreResourceType.JOB_PAYLOAD_STORAGE] as unknown as readonly ResourceType[];\n\n/** Insert and update durable execution state, without permission to erase its history. */\nexport const MINION_ENGINE_MANDATORY_MAINTAIN_RESOURCE_TYPES: readonly ResourceType[] =\n [CoreResourceType.JOB_EXECUTIONS] as unknown as readonly ResourceType[];\n\n/**\n * A minion's grants as a DATABASE role must hold them: what the author declared,\n * plus the engine floor above — one resource-type list per\n * {@link RuntimePrincipalDatabaseGrantAxis}, whose members document each axis's verbs.\n *\n * Mapped over the axis vocabulary rather than spelled out, so an axis added there is a compile error\n * at every site that builds or consumes one of these until it is handled.\n *\n * Separate append and maintain axes keep the floor honest — see\n * {@link MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES}.\n */\nexport type MinionDatabaseGrants = {\n readonly [Axis in RuntimePrincipalDatabaseGrantAxis]: readonly ResourceType[];\n};\n\n/**\n * Add the engine floor to an authored derivation — the ONE place database grants\n * acquire it.\n *\n * ## Why here and not in {@link deriveMinionResourceGrants}\n *\n * That function answers \"what did the author declare\", and it has a THIRD\n * consumer that must not receive this floor: the object-storage credential path\n * turns the same grants into blob key prefixes. Widening it there would confine a\n * minion's storage credential to an `applications/` prefix nobody asked for and\n * nothing writes. The floor is a property of holding a DATABASE role, so it is\n * applied at the boundary where a database role is minted — and both database\n * adapters call this one function, so they cannot drift apart the way the mint\n * and revoke halves of those adapters already have once\n * (`.claude/rules/invariant-call-site-enumeration.md` #18).\n *\n * Idempotent: a floor entry the author also declared appears once.\n */\nexport function deriveMinionDatabaseGrants(grants: MinionResourceGrants): MinionDatabaseGrants {\n const normalize = (resourceTypes: readonly ResourceType[]): ResourceType[] =>\n [...new Set(resourceTypes)].sort();\n\n const declaredWrite = new Set<string>(grants.write);\n\n // Fail closed on an append-only floor entry that arrived on the write axis. The parse-time gate in\n // `findMinionResourceAccessViolations` refuses the declaration; reaching here with one means that\n // gate was bypassed (a hand-built grant object), and honouring it would mint the one credential the\n // append axis exists to withhold.\n const widenedAppendFloor = MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES.filter((resourceType) => declaredWrite.has(resourceType));\n if (widenedAppendFloor.length > 0) {\n throw new Error(\n `Refusing to derive minion database grants that put append-only resource types on the write axis: `\n + `${widenedAppendFloor.join(', ')}. A write grant carries DELETE; these are granted APPEND only.`,\n );\n }\n\n return {\n [RuntimePrincipalDatabaseGrantAxis.READ]: normalize([...grants.read, ...MINION_ENGINE_MANDATORY_READ_RESOURCE_TYPES]),\n [RuntimePrincipalDatabaseGrantAxis.WRITE]: normalize(grants.write),\n [RuntimePrincipalDatabaseGrantAxis.APPEND]: normalize(MINION_ENGINE_MANDATORY_APPEND_RESOURCE_TYPES),\n // A MAINTAIN floor entry the author also declared on write keeps the wider axis: runtime state is\n // not evidence, so the append-floor refusal above deliberately does not extend to it.\n [RuntimePrincipalDatabaseGrantAxis.MAINTAIN]: normalize(\n MINION_ENGINE_MANDATORY_MAINTAIN_RESOURCE_TYPES.filter((resourceType) => !declaredWrite.has(resourceType)),\n ),\n };\n}\n"]}
|
|
@@ -42,6 +42,56 @@ export type ProvisionedPlatformApplicationType = PlatformApplicationType.PLATFOR
|
|
|
42
42
|
* other, once the other side was corrected. Both sides now read this one table.
|
|
43
43
|
*/
|
|
44
44
|
export declare const PLATFORM_SERVICE_RUNTIME_SLUG: Record<ProvisionedPlatformApplicationType, PlatformWildoServices>;
|
|
45
|
+
/**
|
|
46
|
+
* The platform-side JWT KEY NAME of a provisioned platform service — the property name under which
|
|
47
|
+
* that service's signing keypair is stored in its platform secrets (`jwt.privateKey[<name>]`,
|
|
48
|
+
* `jwt.publicKey[<name>]`) and under which its public key is PUBLISHED into the platform config's
|
|
49
|
+
* `jwtPublicKeys`.
|
|
50
|
+
*
|
|
51
|
+
* ## Two concepts that share spellings, and must not be merged
|
|
52
|
+
*
|
|
53
|
+
* 1. **This vocabulary — every provisioned platform service's key name.** TOTAL by nature: every
|
|
54
|
+
* service apps-manager provisions gets a keypair, so every one has a name. The platform-side
|
|
55
|
+
* vocabularies (`PlatformJwtPrivateKeys` / `PlatformJwtPublicKeys` in `platform-shared-lib`) are
|
|
56
|
+
* DERIVED from it, and every map from a service to its key name is keyed by
|
|
57
|
+
* {@link ProvisionedPlatformApplicationType} and required per member.
|
|
58
|
+
* 2. **`JwtPublicKeys` in `@wildo-ai/saas-models` — the platform services whose tokens APPLICATIONS
|
|
59
|
+
* verify.** A deliberate SUBSET: module-registry signs nothing to an application, so it is not
|
|
60
|
+
* there, and adding it would invent an issuer/audience verification nothing performs.
|
|
61
|
+
* `platform-shared-lib` asserts at the type level that that subset stays inside this vocabulary.
|
|
62
|
+
*
|
|
63
|
+
* ## Why this is the ONE source
|
|
64
|
+
*
|
|
65
|
+
* Before #514 the same population was enumerated by hand in four places — two of them
|
|
66
|
+
* `Partial<Record<…>>` maps that omitted module-registry. A `Partial` map is exactly the hand-copied
|
|
67
|
+
* population that broke every fresh install when module-registry was added (see
|
|
68
|
+
* `.claude/rules/invariant-call-site-enumeration.md` #21): it compiles with the member missing and
|
|
69
|
+
* falls back to a key the service's secrets never hold.
|
|
70
|
+
*
|
|
71
|
+
* The string VALUES are persisted keys (platform secrets documents, published `jwtPublicKeys`) and
|
|
72
|
+
* must never change spelling.
|
|
73
|
+
*/
|
|
74
|
+
export declare enum PlatformServiceJwtKeyName {
|
|
75
|
+
PLATFORM_APPS_MANAGER = "PLATFORM_APPS_MANAGER",
|
|
76
|
+
PLATFORM_CRONTABS_BATCHES_MANAGER = "PLATFORM_CRONTABS_BATCHES_MANAGER",
|
|
77
|
+
PLATFORM_MODULE_REGISTRY = "PLATFORM_MODULE_REGISTRY"
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Provisioned platform service → its platform-side JWT key name. Required for every member of
|
|
81
|
+
* {@link ProvisionedPlatformApplicationType}, so a fourth provisioned service fails to compile here
|
|
82
|
+
* until it is given a name.
|
|
83
|
+
*/
|
|
84
|
+
export declare const PLATFORM_SERVICE_JWT_KEY_NAME: {
|
|
85
|
+
readonly platform_apps_manager: PlatformServiceJwtKeyName.PLATFORM_APPS_MANAGER;
|
|
86
|
+
readonly platform_crontabs_batches_manager: PlatformServiceJwtKeyName.PLATFORM_CRONTABS_BATCHES_MANAGER;
|
|
87
|
+
readonly platform_module_registry: PlatformServiceJwtKeyName.PLATFORM_MODULE_REGISTRY;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The platform-side JWT key name for a platform-application type name, or `undefined` when the name
|
|
91
|
+
* is not a provisioned platform service. Callers holding a runtime string (a service's own
|
|
92
|
+
* `serviceName`, an inbound service id) go through here rather than casting into the map.
|
|
93
|
+
*/
|
|
94
|
+
export declare function resolvePlatformServiceJwtKeyName(serviceName: string | undefined): PlatformServiceJwtKeyName | undefined;
|
|
45
95
|
/**
|
|
46
96
|
* The runtime slug for a platform-application type name, or `undefined` when the name is not a
|
|
47
97
|
* provisioned platform service — a caller then reports or refuses rather than rooting a key
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-services.schemas.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"platform-services.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/project-config/shared/platform-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,oBAAY,qBAAqB;IAC/B,aAAa,kBAAkB;IAC/B,YAAY,0BAA0B;IACtC,wBAAwB,sCAAsC;IAC9D;;;;OAIG;IACH,eAAe,6BAA6B;CAC7C;AA4BD,eAAO,MAAM,2BAA2B,kGAGyB,CAAC;AAElE,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAC1C,uBAAuB,CAAC,qBAAqB,GAC7C,uBAAuB,CAAC,iCAAiC,GACzD,uBAAuB,CAAC,wBAAwB,CAAC;AAErD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAAC,kCAAkC,EAAE,qBAAqB,CAI3G,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,oBAAY,yBAAyB;IACnC,qBAAqB,0BAA0B;IAC/C,iCAAiC,sCAAsC;IACvE,wBAAwB,6BAA6B;CACtD;AAED;;;;GAIG;AACH,eAAO,MAAM,6BAA6B;;;;CAIgD,CAAC;AAc3F;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,yBAAyB,GAAG,SAAS,CAGvH;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,qBAAqB,GAAG,SAAS,CAGpH;AAeD,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,IAAI,SAAS;CACd"}
|
|
@@ -42,6 +42,63 @@ export const PLATFORM_SERVICE_RUNTIME_SLUG = {
|
|
|
42
42
|
[PlatformApplicationType.PLATFORM_CRONTABS_BATCHES_MANAGER]: PlatformWildoServices.CRONTABS_BATCHES_MANAGER,
|
|
43
43
|
[PlatformApplicationType.PLATFORM_MODULE_REGISTRY]: PlatformWildoServices.MODULE_REGISTRY,
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* The platform-side JWT KEY NAME of a provisioned platform service — the property name under which
|
|
47
|
+
* that service's signing keypair is stored in its platform secrets (`jwt.privateKey[<name>]`,
|
|
48
|
+
* `jwt.publicKey[<name>]`) and under which its public key is PUBLISHED into the platform config's
|
|
49
|
+
* `jwtPublicKeys`.
|
|
50
|
+
*
|
|
51
|
+
* ## Two concepts that share spellings, and must not be merged
|
|
52
|
+
*
|
|
53
|
+
* 1. **This vocabulary — every provisioned platform service's key name.** TOTAL by nature: every
|
|
54
|
+
* service apps-manager provisions gets a keypair, so every one has a name. The platform-side
|
|
55
|
+
* vocabularies (`PlatformJwtPrivateKeys` / `PlatformJwtPublicKeys` in `platform-shared-lib`) are
|
|
56
|
+
* DERIVED from it, and every map from a service to its key name is keyed by
|
|
57
|
+
* {@link ProvisionedPlatformApplicationType} and required per member.
|
|
58
|
+
* 2. **`JwtPublicKeys` in `@wildo-ai/saas-models` — the platform services whose tokens APPLICATIONS
|
|
59
|
+
* verify.** A deliberate SUBSET: module-registry signs nothing to an application, so it is not
|
|
60
|
+
* there, and adding it would invent an issuer/audience verification nothing performs.
|
|
61
|
+
* `platform-shared-lib` asserts at the type level that that subset stays inside this vocabulary.
|
|
62
|
+
*
|
|
63
|
+
* ## Why this is the ONE source
|
|
64
|
+
*
|
|
65
|
+
* Before #514 the same population was enumerated by hand in four places — two of them
|
|
66
|
+
* `Partial<Record<…>>` maps that omitted module-registry. A `Partial` map is exactly the hand-copied
|
|
67
|
+
* population that broke every fresh install when module-registry was added (see
|
|
68
|
+
* `.claude/rules/invariant-call-site-enumeration.md` #21): it compiles with the member missing and
|
|
69
|
+
* falls back to a key the service's secrets never hold.
|
|
70
|
+
*
|
|
71
|
+
* The string VALUES are persisted keys (platform secrets documents, published `jwtPublicKeys`) and
|
|
72
|
+
* must never change spelling.
|
|
73
|
+
*/
|
|
74
|
+
export var PlatformServiceJwtKeyName;
|
|
75
|
+
(function (PlatformServiceJwtKeyName) {
|
|
76
|
+
PlatformServiceJwtKeyName["PLATFORM_APPS_MANAGER"] = "PLATFORM_APPS_MANAGER";
|
|
77
|
+
PlatformServiceJwtKeyName["PLATFORM_CRONTABS_BATCHES_MANAGER"] = "PLATFORM_CRONTABS_BATCHES_MANAGER";
|
|
78
|
+
PlatformServiceJwtKeyName["PLATFORM_MODULE_REGISTRY"] = "PLATFORM_MODULE_REGISTRY";
|
|
79
|
+
})(PlatformServiceJwtKeyName || (PlatformServiceJwtKeyName = {}));
|
|
80
|
+
/**
|
|
81
|
+
* Provisioned platform service → its platform-side JWT key name. Required for every member of
|
|
82
|
+
* {@link ProvisionedPlatformApplicationType}, so a fourth provisioned service fails to compile here
|
|
83
|
+
* until it is given a name.
|
|
84
|
+
*/
|
|
85
|
+
export const PLATFORM_SERVICE_JWT_KEY_NAME = {
|
|
86
|
+
[PlatformApplicationType.PLATFORM_APPS_MANAGER]: PlatformServiceJwtKeyName.PLATFORM_APPS_MANAGER,
|
|
87
|
+
[PlatformApplicationType.PLATFORM_CRONTABS_BATCHES_MANAGER]: PlatformServiceJwtKeyName.PLATFORM_CRONTABS_BATCHES_MANAGER,
|
|
88
|
+
[PlatformApplicationType.PLATFORM_MODULE_REGISTRY]: PlatformServiceJwtKeyName.PLATFORM_MODULE_REGISTRY,
|
|
89
|
+
};
|
|
90
|
+
const _assertEveryJwtKeyNameIsMapped = true;
|
|
91
|
+
void _assertEveryJwtKeyNameIsMapped;
|
|
92
|
+
/**
|
|
93
|
+
* The platform-side JWT key name for a platform-application type name, or `undefined` when the name
|
|
94
|
+
* is not a provisioned platform service. Callers holding a runtime string (a service's own
|
|
95
|
+
* `serviceName`, an inbound service id) go through here rather than casting into the map.
|
|
96
|
+
*/
|
|
97
|
+
export function resolvePlatformServiceJwtKeyName(serviceName) {
|
|
98
|
+
if (serviceName === undefined)
|
|
99
|
+
return undefined;
|
|
100
|
+
return PLATFORM_SERVICE_JWT_KEY_NAME[serviceName];
|
|
101
|
+
}
|
|
45
102
|
/**
|
|
46
103
|
* The runtime slug for a platform-application type name, or `undefined` when the name is not a
|
|
47
104
|
* provisioned platform service — a caller then reports or refuses rather than rooting a key
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-services.schemas.js","sourceRoot":"","sources":["../../../../src/project-config/shared/platform-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,qBAUX;AAVD,WAAY,qBAAqB;IAC/B,wDAA+B,CAAA;IAC/B,+DAAsC,CAAA;IACtC,uFAA8D,CAAA;IAC9D;;;;OAIG;IACH,qEAA4C,CAAA;AAC9C,CAAC,EAVW,qBAAqB,KAArB,qBAAqB,QAUhC;AA4BD,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,qBAAqB,CAAC,wBAAwB;IAC9C,qBAAqB,CAAC,eAAe;CAC0B,CAAC;AAelE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAsE;IAC9G,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC,YAAY;IACnF,CAAC,uBAAuB,CAAC,iCAAiC,CAAC,EAAE,qBAAqB,CAAC,wBAAwB;IAC3G,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,EAAE,qBAAqB,CAAC,eAAe;CAC1F,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAA+B;IAC/E,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAChD,OAAQ,6BAAmF,CAAC,WAAW,CAAC,CAAC;AAC3G,CAAC;AAYD,MAAM,kCAAkC,GAAuC,IAAI,CAAC;AACpF,KAAK,kCAAkC,CAAC;AAExC,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,gCAAa,CAAA;AACf,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B","sourcesContent":["import { PlatformApplicationType } from '@wildo-ai/platform-core-shared';\n\n/**\n * Platform microservices. All use the same Docker image (wildo-platform)\n * differentiated at runtime via PLATFORM_SERVICE env var.\n *\n * For app developers: deployed as Docker containers.\n * For framework developers: run natively from source (hot-reload).\n */\nexport enum PlatformWildoServices {\n PLATFORM_INIT = 'platform-init',\n APPS_MANAGER = 'platform-apps-manager',\n CRONTABS_BATCHES_MANAGER = 'platform-crontabs-batches-manager',\n /**\n * Module-registry server (`platform-module-registry`, KD-7).\n * Hosts the central `wildo registry *` HTTP surface; pinned port\n * `PLATFORM_DEFAULT_PORTS.MODULE_REGISTRY` (5154).\n */\n MODULE_REGISTRY = 'platform-module-registry',\n}\n\n/**\n * Bootstrap platform services — long-running platform microservices that boot\n * from the same env contract via `PlatformEnvVarsBuilder.buildBootstrapEnv`.\n *\n * Excludes:\n * - `PLATFORM_INIT` — one-shot initialization job, not a long-running service.\n * - `APPS_MANAGER` — has its own dedicated full-env builder\n * (`PlatformEnvVarsBuilder.buildAppsManagerFullEnv`) with extra wiring\n * (Atlas creds, GitHub provisioning keys, etc.).\n *\n * Single source of truth for everything that iterates \"all bootstrap services\":\n * K8s Secret/ConfigMap emit (`k8s-secrets-generator.service.ts`), Compose\n * runtime catalog, and tests asserting cross-service env contracts.\n *\n * The `satisfies` clause below forces this list to cover every member of\n * `PlatformWildoServices` other than the two explicitly excluded ones —\n * adding a new enum member without listing it here is a compile error.\n * Without that coupling, the previous `Exclude<…>`-based local type alias\n * silently widened to include any future enum member, which masked the\n * \"service in enum but not yet handled by the bootstrap path\" drift class.\n */\ntype BootstrapPlatformServiceCandidate = Exclude<\n PlatformWildoServices,\n PlatformWildoServices.PLATFORM_INIT | PlatformWildoServices.APPS_MANAGER\n>;\n\nexport const BOOTSTRAP_PLATFORM_SERVICES = [\n PlatformWildoServices.CRONTABS_BATCHES_MANAGER,\n PlatformWildoServices.MODULE_REGISTRY,\n] as const satisfies readonly BootstrapPlatformServiceCandidate[];\n\nexport type BootstrapPlatformService = (typeof BOOTSTRAP_PLATFORM_SERVICES)[number];\n\n/**\n * The platform-application TYPES the platform provisions credentials for — the same three the\n * apps-manager provisioner iterates. Named here so the runtime-slug ledger below can be REQUIRED per\n * member: a fourth provisioned service that is not mapped fails to compile before it provisions a\n * grant nobody can use.\n */\nexport type ProvisionedPlatformApplicationType =\n | PlatformApplicationType.PLATFORM_APPS_MANAGER\n | PlatformApplicationType.PLATFORM_CRONTABS_BATCHES_MANAGER\n | PlatformApplicationType.PLATFORM_MODULE_REGISTRY;\n\n/**\n * ONE service, TWO spellings — and this is the join between them.\n *\n * `PlatformApplicationType` (`platform_crontabs_batches_manager`, underscores) is the platform-\n * application RECORD type: the row in `platformApplications`, the Redis ACL USERNAME, the RabbitMQ\n * user. `PlatformWildoServices` (`platform-crontabs-batches-manager`, hyphens) is the RUNTIME SLUG:\n * the Docker/K8s service name and, since 2026-09-09, the `appSlug` each service process boots with.\n *\n * Why the join matters: every Redis key a platform process writes is rooted at its runtime slug —\n * the engine's `RedisService` roots at `${appSlug}:`, the platform's `PlatformRedisService` at the\n * same slug through this ledger — and the ACL grant minted for the service must therefore be\n * `~<runtime slug>:*`. Two writers rooted at the USERNAME instead (the provisioner's grant, then the\n * platform Redis service's prefix) each produced `NOPERM` on the service's first key, one after the\n * other, once the other side was corrected. Both sides now read this one table.\n */\nexport const PLATFORM_SERVICE_RUNTIME_SLUG: Record<ProvisionedPlatformApplicationType, PlatformWildoServices> = {\n [PlatformApplicationType.PLATFORM_APPS_MANAGER]: PlatformWildoServices.APPS_MANAGER,\n [PlatformApplicationType.PLATFORM_CRONTABS_BATCHES_MANAGER]: PlatformWildoServices.CRONTABS_BATCHES_MANAGER,\n [PlatformApplicationType.PLATFORM_MODULE_REGISTRY]: PlatformWildoServices.MODULE_REGISTRY,\n};\n\n/**\n * The runtime slug for a platform-application type name, or `undefined` when the name is not a\n * provisioned platform service — a caller then reports or refuses rather than rooting a key\n * namespace, or a grant, on a guess.\n */\nexport function resolvePlatformServiceRuntimeSlug(serviceName: string | undefined): PlatformWildoServices | undefined {\n if (serviceName === undefined) return undefined;\n return (PLATFORM_SERVICE_RUNTIME_SLUG as Record<string, PlatformWildoServices | undefined>)[serviceName];\n}\n\n/**\n * Compile-time assertion: every non-excluded `PlatformWildoServices` member\n * MUST appear in `BOOTSTRAP_PLATFORM_SERVICES`. Adding a new member to the\n * enum without listing it above triggers a `Type 'X' is not assignable to\n * type 'never'` error pointing here, so the exhaustiveness check the\n * `addServiceExtras` switch used to provide for `Exclude<…>`-derived types\n * is preserved.\n */\ntype _AssertExhaustiveBootstrapCoverage =\n Exclude<BootstrapPlatformServiceCandidate, BootstrapPlatformService> extends never ? true : never;\nconst _assertExhaustiveBootstrapCoverage: _AssertExhaustiveBootstrapCoverage = true;\nvoid _assertExhaustiveBootstrapCoverage;\n\nexport enum AppsManagerMode {\n NORMAL = 'normal',\n INIT = 'init',\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"platform-services.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/platform-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,qBAUX;AAVD,WAAY,qBAAqB;IAC/B,wDAA+B,CAAA;IAC/B,+DAAsC,CAAA;IACtC,uFAA8D,CAAA;IAC9D;;;;OAIG;IACH,qEAA4C,CAAA;AAC9C,CAAC,EAVW,qBAAqB,KAArB,qBAAqB,QAUhC;AA4BD,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,qBAAqB,CAAC,wBAAwB;IAC9C,qBAAqB,CAAC,eAAe;CAC0B,CAAC;AAelE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAsE;IAC9G,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC,YAAY;IACnF,CAAC,uBAAuB,CAAC,iCAAiC,CAAC,EAAE,qBAAqB,CAAC,wBAAwB;IAC3G,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,EAAE,qBAAqB,CAAC,eAAe;CAC1F,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAN,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACnC,4EAA+C,CAAA;IAC/C,oGAAuE,CAAA;IACvE,kFAAqD,CAAA;AACvD,CAAC,EAJW,yBAAyB,KAAzB,yBAAyB,QAIpC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,yBAAyB,CAAC,qBAAqB;IAChG,CAAC,uBAAuB,CAAC,iCAAiC,CAAC,EAAE,yBAAyB,CAAC,iCAAiC;IACxH,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,EAAE,yBAAyB,CAAC,wBAAwB;CACd,CAAC;AAW3F,MAAM,8BAA8B,GAAmC,IAAI,CAAC;AAC5E,KAAK,8BAA8B,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAA+B;IAC9E,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAChD,OAAQ,6BAAuF,CAAC,WAAW,CAAC,CAAC;AAC/G,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAA+B;IAC/E,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAChD,OAAQ,6BAAmF,CAAC,WAAW,CAAC,CAAC;AAC3G,CAAC;AAYD,MAAM,kCAAkC,GAAuC,IAAI,CAAC;AACpF,KAAK,kCAAkC,CAAC;AAExC,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,gCAAa,CAAA;AACf,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B","sourcesContent":["import { PlatformApplicationType } from '@wildo-ai/platform-core-shared';\n\n/**\n * Platform microservices. All use the same Docker image (wildo-platform)\n * differentiated at runtime via PLATFORM_SERVICE env var.\n *\n * For app developers: deployed as Docker containers.\n * For framework developers: run natively from source (hot-reload).\n */\nexport enum PlatformWildoServices {\n PLATFORM_INIT = 'platform-init',\n APPS_MANAGER = 'platform-apps-manager',\n CRONTABS_BATCHES_MANAGER = 'platform-crontabs-batches-manager',\n /**\n * Module-registry server (`platform-module-registry`, KD-7).\n * Hosts the central `wildo registry *` HTTP surface; pinned port\n * `PLATFORM_DEFAULT_PORTS.MODULE_REGISTRY` (5154).\n */\n MODULE_REGISTRY = 'platform-module-registry',\n}\n\n/**\n * Bootstrap platform services — long-running platform microservices that boot\n * from the same env contract via `PlatformEnvVarsBuilder.buildBootstrapEnv`.\n *\n * Excludes:\n * - `PLATFORM_INIT` — one-shot initialization job, not a long-running service.\n * - `APPS_MANAGER` — has its own dedicated full-env builder\n * (`PlatformEnvVarsBuilder.buildAppsManagerFullEnv`) with extra wiring\n * (Atlas creds, GitHub provisioning keys, etc.).\n *\n * Single source of truth for everything that iterates \"all bootstrap services\":\n * K8s Secret/ConfigMap emit (`k8s-secrets-generator.service.ts`), Compose\n * runtime catalog, and tests asserting cross-service env contracts.\n *\n * The `satisfies` clause below forces this list to cover every member of\n * `PlatformWildoServices` other than the two explicitly excluded ones —\n * adding a new enum member without listing it here is a compile error.\n * Without that coupling, the previous `Exclude<…>`-based local type alias\n * silently widened to include any future enum member, which masked the\n * \"service in enum but not yet handled by the bootstrap path\" drift class.\n */\ntype BootstrapPlatformServiceCandidate = Exclude<\n PlatformWildoServices,\n PlatformWildoServices.PLATFORM_INIT | PlatformWildoServices.APPS_MANAGER\n>;\n\nexport const BOOTSTRAP_PLATFORM_SERVICES = [\n PlatformWildoServices.CRONTABS_BATCHES_MANAGER,\n PlatformWildoServices.MODULE_REGISTRY,\n] as const satisfies readonly BootstrapPlatformServiceCandidate[];\n\nexport type BootstrapPlatformService = (typeof BOOTSTRAP_PLATFORM_SERVICES)[number];\n\n/**\n * The platform-application TYPES the platform provisions credentials for — the same three the\n * apps-manager provisioner iterates. Named here so the runtime-slug ledger below can be REQUIRED per\n * member: a fourth provisioned service that is not mapped fails to compile before it provisions a\n * grant nobody can use.\n */\nexport type ProvisionedPlatformApplicationType =\n | PlatformApplicationType.PLATFORM_APPS_MANAGER\n | PlatformApplicationType.PLATFORM_CRONTABS_BATCHES_MANAGER\n | PlatformApplicationType.PLATFORM_MODULE_REGISTRY;\n\n/**\n * ONE service, TWO spellings — and this is the join between them.\n *\n * `PlatformApplicationType` (`platform_crontabs_batches_manager`, underscores) is the platform-\n * application RECORD type: the row in `platformApplications`, the Redis ACL USERNAME, the RabbitMQ\n * user. `PlatformWildoServices` (`platform-crontabs-batches-manager`, hyphens) is the RUNTIME SLUG:\n * the Docker/K8s service name and, since 2026-09-09, the `appSlug` each service process boots with.\n *\n * Why the join matters: every Redis key a platform process writes is rooted at its runtime slug —\n * the engine's `RedisService` roots at `${appSlug}:`, the platform's `PlatformRedisService` at the\n * same slug through this ledger — and the ACL grant minted for the service must therefore be\n * `~<runtime slug>:*`. Two writers rooted at the USERNAME instead (the provisioner's grant, then the\n * platform Redis service's prefix) each produced `NOPERM` on the service's first key, one after the\n * other, once the other side was corrected. Both sides now read this one table.\n */\nexport const PLATFORM_SERVICE_RUNTIME_SLUG: Record<ProvisionedPlatformApplicationType, PlatformWildoServices> = {\n [PlatformApplicationType.PLATFORM_APPS_MANAGER]: PlatformWildoServices.APPS_MANAGER,\n [PlatformApplicationType.PLATFORM_CRONTABS_BATCHES_MANAGER]: PlatformWildoServices.CRONTABS_BATCHES_MANAGER,\n [PlatformApplicationType.PLATFORM_MODULE_REGISTRY]: PlatformWildoServices.MODULE_REGISTRY,\n};\n\n/**\n * The platform-side JWT KEY NAME of a provisioned platform service — the property name under which\n * that service's signing keypair is stored in its platform secrets (`jwt.privateKey[<name>]`,\n * `jwt.publicKey[<name>]`) and under which its public key is PUBLISHED into the platform config's\n * `jwtPublicKeys`.\n *\n * ## Two concepts that share spellings, and must not be merged\n *\n * 1. **This vocabulary — every provisioned platform service's key name.** TOTAL by nature: every\n * service apps-manager provisions gets a keypair, so every one has a name. The platform-side\n * vocabularies (`PlatformJwtPrivateKeys` / `PlatformJwtPublicKeys` in `platform-shared-lib`) are\n * DERIVED from it, and every map from a service to its key name is keyed by\n * {@link ProvisionedPlatformApplicationType} and required per member.\n * 2. **`JwtPublicKeys` in `@wildo-ai/saas-models` — the platform services whose tokens APPLICATIONS\n * verify.** A deliberate SUBSET: module-registry signs nothing to an application, so it is not\n * there, and adding it would invent an issuer/audience verification nothing performs.\n * `platform-shared-lib` asserts at the type level that that subset stays inside this vocabulary.\n *\n * ## Why this is the ONE source\n *\n * Before #514 the same population was enumerated by hand in four places — two of them\n * `Partial<Record<…>>` maps that omitted module-registry. A `Partial` map is exactly the hand-copied\n * population that broke every fresh install when module-registry was added (see\n * `.claude/rules/invariant-call-site-enumeration.md` #21): it compiles with the member missing and\n * falls back to a key the service's secrets never hold.\n *\n * The string VALUES are persisted keys (platform secrets documents, published `jwtPublicKeys`) and\n * must never change spelling.\n */\nexport enum PlatformServiceJwtKeyName {\n PLATFORM_APPS_MANAGER = 'PLATFORM_APPS_MANAGER',\n PLATFORM_CRONTABS_BATCHES_MANAGER = 'PLATFORM_CRONTABS_BATCHES_MANAGER',\n PLATFORM_MODULE_REGISTRY = 'PLATFORM_MODULE_REGISTRY',\n}\n\n/**\n * Provisioned platform service → its platform-side JWT key name. Required for every member of\n * {@link ProvisionedPlatformApplicationType}, so a fourth provisioned service fails to compile here\n * until it is given a name.\n */\nexport const PLATFORM_SERVICE_JWT_KEY_NAME = {\n [PlatformApplicationType.PLATFORM_APPS_MANAGER]: PlatformServiceJwtKeyName.PLATFORM_APPS_MANAGER,\n [PlatformApplicationType.PLATFORM_CRONTABS_BATCHES_MANAGER]: PlatformServiceJwtKeyName.PLATFORM_CRONTABS_BATCHES_MANAGER,\n [PlatformApplicationType.PLATFORM_MODULE_REGISTRY]: PlatformServiceJwtKeyName.PLATFORM_MODULE_REGISTRY,\n} as const satisfies Record<ProvisionedPlatformApplicationType, PlatformServiceJwtKeyName>;\n\n/**\n * Compile-time assertion: every {@link PlatformServiceJwtKeyName} member is the key name of SOME\n * provisioned service. A name nothing maps to would be a vocabulary member no keypair is ever stored\n * under.\n */\ntype _AssertEveryJwtKeyNameIsMapped =\n Exclude<PlatformServiceJwtKeyName, (typeof PLATFORM_SERVICE_JWT_KEY_NAME)[ProvisionedPlatformApplicationType]> extends never\n ? true\n : never;\nconst _assertEveryJwtKeyNameIsMapped: _AssertEveryJwtKeyNameIsMapped = true;\nvoid _assertEveryJwtKeyNameIsMapped;\n\n/**\n * The platform-side JWT key name for a platform-application type name, or `undefined` when the name\n * is not a provisioned platform service. Callers holding a runtime string (a service's own\n * `serviceName`, an inbound service id) go through here rather than casting into the map.\n */\nexport function resolvePlatformServiceJwtKeyName(serviceName: string | undefined): PlatformServiceJwtKeyName | undefined {\n if (serviceName === undefined) return undefined;\n return (PLATFORM_SERVICE_JWT_KEY_NAME as Record<string, PlatformServiceJwtKeyName | undefined>)[serviceName];\n}\n\n/**\n * The runtime slug for a platform-application type name, or `undefined` when the name is not a\n * provisioned platform service — a caller then reports or refuses rather than rooting a key\n * namespace, or a grant, on a guess.\n */\nexport function resolvePlatformServiceRuntimeSlug(serviceName: string | undefined): PlatformWildoServices | undefined {\n if (serviceName === undefined) return undefined;\n return (PLATFORM_SERVICE_RUNTIME_SLUG as Record<string, PlatformWildoServices | undefined>)[serviceName];\n}\n\n/**\n * Compile-time assertion: every non-excluded `PlatformWildoServices` member\n * MUST appear in `BOOTSTRAP_PLATFORM_SERVICES`. Adding a new member to the\n * enum without listing it above triggers a `Type 'X' is not assignable to\n * type 'never'` error pointing here, so the exhaustiveness check the\n * `addServiceExtras` switch used to provide for `Exclude<…>`-derived types\n * is preserved.\n */\ntype _AssertExhaustiveBootstrapCoverage =\n Exclude<BootstrapPlatformServiceCandidate, BootstrapPlatformService> extends never ? true : never;\nconst _assertExhaustiveBootstrapCoverage: _AssertExhaustiveBootstrapCoverage = true;\nvoid _assertExhaustiveBootstrapCoverage;\n\nexport enum AppsManagerMode {\n NORMAL = 'normal',\n INIT = 'init',\n}\n\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The PLATFORM tier's own object-storage bucket, authored for a remote environment (#1112).
|
|
4
|
+
*
|
|
5
|
+
* ## Why the platform needs its own, separate from `backingServices.s3.bucket`
|
|
6
|
+
*
|
|
7
|
+
* `backingServices.s3.bucket` is an APPLICATION's bucket: its backend reads and writes there, and apps-manager
|
|
8
|
+
* confines that application's storage credential to it (#1107). The platform services — apps-manager itself and
|
|
9
|
+
* module-registry — store their own objects too, and both halves of that pair must address ONE bucket: the
|
|
10
|
+
* platform-services STS door confines to the bucket apps-manager's env names, while module-registry addresses
|
|
11
|
+
* objects in the bucket its own env names.
|
|
12
|
+
*
|
|
13
|
+
* Until #1112 the CLI rendered that platform bucket from the `config.json` of whichever application was being
|
|
14
|
+
* registered or deployed, so it became the last-registered application's bucket, and platform objects written
|
|
15
|
+
* earlier went out of reach. Measured on 2026-09-14: module-registry's uploads sat in `wonder-todos-local`, and
|
|
16
|
+
* registering a second application rewrote every platform service's env to that application's bucket.
|
|
17
|
+
*
|
|
18
|
+
* ## Local: a constant. Remote: authored.
|
|
19
|
+
*
|
|
20
|
+
* A local platform is shared by every application checked out beside it, and no configuration on disk is shared
|
|
21
|
+
* across them — every infra file, `config.json` and `secrets.json` belongs to one application. So a local
|
|
22
|
+
* platform's bucket is the constant {@link STORAGE_DEFAULTS.BUCKET}, and authoring this block in a local
|
|
23
|
+
* environment is refused at parse time (the same shape as `cdn`, which is remote-only for its own reason).
|
|
24
|
+
*
|
|
25
|
+
* A remote environment is deployed from one application's infra file and may need a globally unique S3 name, so
|
|
26
|
+
* it can author one here. Absent, the constant applies there too.
|
|
27
|
+
*/
|
|
28
|
+
export declare const WildoPlatformStorageConfigSchema: z.ZodObject<{
|
|
29
|
+
/** The bucket apps-manager and module-registry store the platform's own objects in. */
|
|
30
|
+
bucket: z.ZodString;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export type WildoPlatformStorageConfig = z.infer<typeof WildoPlatformStorageConfigSchema>;
|
|
33
|
+
/** The platform tier's bucket: the authored remote override, else {@link STORAGE_DEFAULTS.BUCKET}. */
|
|
34
|
+
export declare function resolvePlatformObjectStorageBucket(platformStorage: WildoPlatformStorageConfig | undefined): string;
|
|
35
|
+
//# sourceMappingURL=platform-storage.schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-storage.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/project-config/shared/platform-storage.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gCAAgC;IAC3C,uFAAuF;;kBAEvF,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,sGAAsG;AACtG,wBAAgB,kCAAkC,CAAC,eAAe,EAAE,0BAA0B,GAAG,SAAS,GAAG,MAAM,CAElH"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { STORAGE_DEFAULTS } from './infrastructure-defaults.schemas.js';
|
|
3
|
+
/**
|
|
4
|
+
* The PLATFORM tier's own object-storage bucket, authored for a remote environment (#1112).
|
|
5
|
+
*
|
|
6
|
+
* ## Why the platform needs its own, separate from `backingServices.s3.bucket`
|
|
7
|
+
*
|
|
8
|
+
* `backingServices.s3.bucket` is an APPLICATION's bucket: its backend reads and writes there, and apps-manager
|
|
9
|
+
* confines that application's storage credential to it (#1107). The platform services — apps-manager itself and
|
|
10
|
+
* module-registry — store their own objects too, and both halves of that pair must address ONE bucket: the
|
|
11
|
+
* platform-services STS door confines to the bucket apps-manager's env names, while module-registry addresses
|
|
12
|
+
* objects in the bucket its own env names.
|
|
13
|
+
*
|
|
14
|
+
* Until #1112 the CLI rendered that platform bucket from the `config.json` of whichever application was being
|
|
15
|
+
* registered or deployed, so it became the last-registered application's bucket, and platform objects written
|
|
16
|
+
* earlier went out of reach. Measured on 2026-09-14: module-registry's uploads sat in `wonder-todos-local`, and
|
|
17
|
+
* registering a second application rewrote every platform service's env to that application's bucket.
|
|
18
|
+
*
|
|
19
|
+
* ## Local: a constant. Remote: authored.
|
|
20
|
+
*
|
|
21
|
+
* A local platform is shared by every application checked out beside it, and no configuration on disk is shared
|
|
22
|
+
* across them — every infra file, `config.json` and `secrets.json` belongs to one application. So a local
|
|
23
|
+
* platform's bucket is the constant {@link STORAGE_DEFAULTS.BUCKET}, and authoring this block in a local
|
|
24
|
+
* environment is refused at parse time (the same shape as `cdn`, which is remote-only for its own reason).
|
|
25
|
+
*
|
|
26
|
+
* A remote environment is deployed from one application's infra file and may need a globally unique S3 name, so
|
|
27
|
+
* it can author one here. Absent, the constant applies there too.
|
|
28
|
+
*/
|
|
29
|
+
export const WildoPlatformStorageConfigSchema = z.strictObject({
|
|
30
|
+
/** The bucket apps-manager and module-registry store the platform's own objects in. */
|
|
31
|
+
bucket: z.string().min(1),
|
|
32
|
+
});
|
|
33
|
+
/** The platform tier's bucket: the authored remote override, else {@link STORAGE_DEFAULTS.BUCKET}. */
|
|
34
|
+
export function resolvePlatformObjectStorageBucket(platformStorage) {
|
|
35
|
+
return platformStorage?.bucket ?? STORAGE_DEFAULTS.BUCKET;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=platform-storage.schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-storage.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/platform-storage.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,YAAY,CAAC;IAC7D,uFAAuF;IACvF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC1B,CAAC,CAAC;AAGH,sGAAsG;AACtG,MAAM,UAAU,kCAAkC,CAAC,eAAuD;IACxG,OAAO,eAAe,EAAE,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5D,CAAC","sourcesContent":["import { z } from 'zod';\n\nimport { STORAGE_DEFAULTS } from './infrastructure-defaults.schemas';\n\n/**\n * The PLATFORM tier's own object-storage bucket, authored for a remote environment (#1112).\n *\n * ## Why the platform needs its own, separate from `backingServices.s3.bucket`\n *\n * `backingServices.s3.bucket` is an APPLICATION's bucket: its backend reads and writes there, and apps-manager\n * confines that application's storage credential to it (#1107). The platform services — apps-manager itself and\n * module-registry — store their own objects too, and both halves of that pair must address ONE bucket: the\n * platform-services STS door confines to the bucket apps-manager's env names, while module-registry addresses\n * objects in the bucket its own env names.\n *\n * Until #1112 the CLI rendered that platform bucket from the `config.json` of whichever application was being\n * registered or deployed, so it became the last-registered application's bucket, and platform objects written\n * earlier went out of reach. Measured on 2026-09-14: module-registry's uploads sat in `wonder-todos-local`, and\n * registering a second application rewrote every platform service's env to that application's bucket.\n *\n * ## Local: a constant. Remote: authored.\n *\n * A local platform is shared by every application checked out beside it, and no configuration on disk is shared\n * across them — every infra file, `config.json` and `secrets.json` belongs to one application. So a local\n * platform's bucket is the constant {@link STORAGE_DEFAULTS.BUCKET}, and authoring this block in a local\n * environment is refused at parse time (the same shape as `cdn`, which is remote-only for its own reason).\n *\n * A remote environment is deployed from one application's infra file and may need a globally unique S3 name, so\n * it can author one here. Absent, the constant applies there too.\n */\nexport const WildoPlatformStorageConfigSchema = z.strictObject({\n /** The bucket apps-manager and module-registry store the platform's own objects in. */\n bucket: z.string().min(1),\n});\nexport type WildoPlatformStorageConfig = z.infer<typeof WildoPlatformStorageConfigSchema>;\n\n/** The platform tier's bucket: the authored remote override, else {@link STORAGE_DEFAULTS.BUCKET}. */\nexport function resolvePlatformObjectStorageBucket(platformStorage: WildoPlatformStorageConfig | undefined): string {\n return platformStorage?.bucket ?? STORAGE_DEFAULTS.BUCKET;\n}\n"]}
|