Skip to content

Commit 3d0b726

Browse files
committed
Refactor kernel schemas and add composer protocol
Moved manifest and plugin schemas from system to kernel directory. Introduced composer.zod.ts defining the Cloud Composer Protocol, including schemas for dependency requirements, BOM, conflict reports, and composer request/response. Updated exports in kernel and system index files to reflect these changes.
1 parent 82ef153 commit 3d0b726

File tree

5 files changed

+133
-3
lines changed

5 files changed

+133
-3
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import { z } from 'zod';
2+
import { ManifestSchema } from './manifest.zod';
3+
4+
/**
5+
* # Cloud Composer Protocol
6+
*
7+
* Defines the interface for the ObjectStack Composer Service.
8+
* The Composer is responsible for "compiling" a Tenant's configuration (BOM)
9+
* into a single executable System Manifest.
10+
*/
11+
12+
/**
13+
* Dependency Requirement
14+
* Specifies a plugin and its version constraints.
15+
*/
16+
export const DependencyRequirementSchema = z.object({
17+
id: z.string().describe('Plugin ID (e.g. "com.example.crm")'),
18+
version: z.string().default('latest').describe('SemVer range or "latest"'),
19+
20+
/**
21+
* Configuration Overrides
22+
* Tenant-specific settings that override plugin defaults.
23+
* Example: { "currency": "USD", "apiKey": "..." }
24+
*/
25+
configuration: z.record(z.any()).optional().describe('Configuration overrides'),
26+
27+
/**
28+
* Feature Flags
29+
* Enable/Disable specific features within the plugin.
30+
*/
31+
features: z.record(z.boolean()).optional().describe('Feature toggles'),
32+
});
33+
34+
/**
35+
* Bill of Materials (BOM)
36+
* The "Shopping List" for a specific tenant.
37+
* Represents the high-level intent of what the tenant wants to install.
38+
*/
39+
export const BillOfMaterialsSchema = z.object({
40+
tenantId: z.string().describe('Target Tenant ID'),
41+
42+
/**
43+
* List of installed plugins/apps.
44+
* implementation order matters (later plugins override earlier ones by default).
45+
*/
46+
dependencies: z.array(DependencyRequirementSchema).describe('Installed packages'),
47+
48+
/**
49+
* Environment Variables injection.
50+
* Maps abstract keys to secure vault references or concrete values.
51+
*/
52+
environment: z.record(z.string()).optional(),
53+
54+
/**
55+
* Global Resolution Strategy
56+
* How to handle conflicts when multiple plugins define the same resource.
57+
*/
58+
resolutionStrategy: z.enum(['strict', 'override', 'merge']).default('override')
59+
.describe('Conflict resolution strategy (strict=fail, override=last-wins, merge=deep-merge)'),
60+
});
61+
62+
/**
63+
* Conflict Report
64+
* Detailed information about collision during composition.
65+
*/
66+
export const ConflictReportSchema = z.object({
67+
resourceType: z.enum(['object', 'field', 'api', 'ui']).describe('Type of colliding resource'),
68+
resourceId: z.string().describe('ID of the resource'),
69+
sources: z.array(z.string()).describe('List of plugin IDs defining this resource'),
70+
resolution: z.string().describe('How it was resolved (e.g. "com.example.erp won")'),
71+
severity: z.enum(['info', 'warning', 'error']).describe('Severity of the conflict'),
72+
});
73+
74+
/**
75+
* Composer Request
76+
* The RPC payload sent to the Composer Service.
77+
*/
78+
export const ComposerRequestSchema = z.object({
79+
bom: BillOfMaterialsSchema,
80+
81+
/**
82+
* Target Runtime Version
83+
* Ensure generated manifest is compatible with the specific runtime version.
84+
*/
85+
runtimeVersion: z.string().optional(),
86+
87+
/**
88+
* Dry Run
89+
* If true, generates report but does not persist the manifest.
90+
*/
91+
dryRun: z.boolean().default(false),
92+
});
93+
94+
/**
95+
* Composer Response
96+
* The result of the compilation process.
97+
*/
98+
export const ComposerResponseSchema = z.object({
99+
success: z.boolean(),
100+
101+
/**
102+
* The Holy Grail: The Executable System Manifest.
103+
* This is what the Runtime loads to boot.
104+
*/
105+
manifest: ManifestSchema.optional().describe('The compiled System Manifest'),
106+
107+
/**
108+
* Compilation Metadata
109+
*/
110+
buildId: z.string(),
111+
timestamp: z.string().datetime(),
112+
duration: z.number().describe('Compilation time in ms'),
113+
114+
/**
115+
* Analysis
116+
*/
117+
conflicts: z.array(ConflictReportSchema).optional(),
118+
errors: z.array(z.string()).optional(),
119+
});
120+
121+
export type BillOfMaterials = z.infer<typeof BillOfMaterialsSchema>;
122+
export type ComposerRequest = z.infer<typeof ComposerRequestSchema>;
123+
export type ComposerResponse = z.infer<typeof ComposerResponseSchema>;

packages/spec/src/kernel/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Kernel Protocol Exports
3+
*
4+
* The Core Architecture of ObjectStack.
5+
* Defines the Bootloader, Package Management, and Plugin Lifecycle.
6+
*/
7+
8+
export * from './manifest.zod';
9+
export * from './plugin.zod';
10+
export * from './composer.zod';

packages/spec/src/system/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* - Plugin Architecture
99
*/
1010

11-
export * from './manifest.zod';
1211
export * from './identity.zod';
1312
export * from './auth.zod';
1413
export * from './auth-protocol';
@@ -21,8 +20,6 @@ export * from './audit.zod';
2120
export * from './license.zod';
2221
export * from './webhook.zod';
2322
export * from './translation.zod';
24-
export * from './plugin.zod';
2523
export * from './events.zod';
2624
export * from './job.zod';
27-
export * from './constants';
2825
export * from './types';

0 commit comments

Comments
 (0)