Skip to content

Commit c3d0cf2

Browse files
Copilothotlong
andcommitted
Phase 2 tasks: create shared metadata-types, rename kernel security schemas, rename realtime presence schemas
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 16242c6 commit c3d0cf2

13 files changed

Lines changed: 129 additions & 50 deletions

packages/spec/json-schema/api/Presence.json renamed to packages/spec/json-schema/api/RealtimePresence.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"$ref": "#/definitions/Presence",
2+
"$ref": "#/definitions/RealtimePresence",
33
"definitions": {
4-
"Presence": {
4+
"RealtimePresence": {
55
"type": "object",
66
"properties": {
77
"userId": {

packages/spec/json-schema/api/PresenceStatus.json renamed to packages/spec/json-schema/api/RealtimePresenceStatus.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"$ref": "#/definitions/PresenceStatus",
2+
"$ref": "#/definitions/RealtimePresenceStatus",
33
"definitions": {
4-
"PresenceStatus": {
4+
"RealtimePresenceStatus": {
55
"type": "string",
66
"enum": [
77
"online",

packages/spec/json-schema/kernel/SecurityPolicy.json renamed to packages/spec/json-schema/kernel/KernelSecurityPolicy.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"$ref": "#/definitions/SecurityPolicy",
2+
"$ref": "#/definitions/KernelSecurityPolicy",
33
"definitions": {
4-
"SecurityPolicy": {
4+
"KernelSecurityPolicy": {
55
"type": "object",
66
"properties": {
77
"csp": {

packages/spec/json-schema/kernel/SecurityScanResult.json renamed to packages/spec/json-schema/kernel/KernelSecurityScanResult.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"$ref": "#/definitions/SecurityScanResult",
2+
"$ref": "#/definitions/KernelSecurityScanResult",
33
"definitions": {
4-
"SecurityScanResult": {
4+
"KernelSecurityScanResult": {
55
"type": "object",
66
"properties": {
77
"timestamp": {

packages/spec/json-schema/kernel/SecurityVulnerability.json renamed to packages/spec/json-schema/kernel/KernelSecurityVulnerability.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"$ref": "#/definitions/SecurityVulnerability",
2+
"$ref": "#/definitions/KernelSecurityVulnerability",
33
"definitions": {
4-
"SecurityVulnerability": {
4+
"KernelSecurityVulnerability": {
55
"type": "object",
66
"properties": {
77
"cve": {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"$ref": "#/definitions/BaseMetadataRecord",
3+
"definitions": {
4+
"BaseMetadataRecord": {
5+
"type": "object",
6+
"properties": {
7+
"id": {
8+
"type": "string",
9+
"description": "Unique metadata record identifier"
10+
},
11+
"type": {
12+
"type": "string",
13+
"description": "Metadata type (e.g. \"object\", \"view\", \"flow\")"
14+
},
15+
"name": {
16+
"type": "string",
17+
"minLength": 2,
18+
"pattern": "^[a-z][a-z0-9_]*$",
19+
"description": "Machine name (snake_case)"
20+
},
21+
"format": {
22+
"type": "string",
23+
"enum": [
24+
"yaml",
25+
"json",
26+
"typescript",
27+
"javascript"
28+
],
29+
"description": "Source file format"
30+
}
31+
},
32+
"required": [
33+
"id",
34+
"type",
35+
"name"
36+
],
37+
"additionalProperties": false,
38+
"description": "Base metadata record fields shared across kernel and system"
39+
}
40+
},
41+
"$schema": "http://json-schema.org/draft-07/schema#"
42+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$ref": "#/definitions/MetadataFormat",
3+
"definitions": {
4+
"MetadataFormat": {
5+
"type": "string",
6+
"enum": [
7+
"yaml",
8+
"json",
9+
"typescript",
10+
"javascript"
11+
],
12+
"description": "Metadata file format"
13+
}
14+
},
15+
"$schema": "http://json-schema.org/draft-07/schema#"
16+
}

packages/spec/src/api/realtime.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import {
44
RealtimeEventType,
55
SubscriptionEventSchema,
66
SubscriptionSchema,
7-
PresenceStatus,
8-
PresenceSchema,
7+
RealtimePresenceStatus,
8+
RealtimePresenceSchema,
99
RealtimeAction,
1010
RealtimeEventSchema,
1111
type Subscription,
12-
type Presence,
12+
type RealtimePresence,
1313
type RealtimeEvent,
1414
} from './realtime.zod';
1515

@@ -190,29 +190,29 @@ describe('SubscriptionSchema', () => {
190190
});
191191
});
192192

193-
describe('PresenceStatus', () => {
193+
describe('RealtimePresenceStatus', () => {
194194
it('should accept valid presence statuses', () => {
195-
expect(() => PresenceStatus.parse('online')).not.toThrow();
196-
expect(() => PresenceStatus.parse('away')).not.toThrow();
197-
expect(() => PresenceStatus.parse('offline')).not.toThrow();
195+
expect(() => RealtimePresenceStatus.parse('online')).not.toThrow();
196+
expect(() => RealtimePresenceStatus.parse('away')).not.toThrow();
197+
expect(() => RealtimePresenceStatus.parse('offline')).not.toThrow();
198198
});
199199

200200
it('should reject invalid presence statuses', () => {
201-
expect(() => PresenceStatus.parse('busy')).toThrow();
202-
expect(() => PresenceStatus.parse('idle')).toThrow();
203-
expect(() => PresenceStatus.parse('')).toThrow();
201+
expect(() => RealtimePresenceStatus.parse('busy')).toThrow();
202+
expect(() => RealtimePresenceStatus.parse('idle')).toThrow();
203+
expect(() => RealtimePresenceStatus.parse('')).toThrow();
204204
});
205205
});
206206

207-
describe('PresenceSchema', () => {
207+
describe('RealtimePresenceSchema', () => {
208208
it('should accept valid minimal presence', () => {
209-
const presence: Presence = {
209+
const presence: RealtimePresence = {
210210
userId: 'user-123',
211211
status: 'online',
212212
lastSeen: '2024-01-15T10:30:00Z',
213213
};
214214

215-
expect(() => PresenceSchema.parse(presence)).not.toThrow();
215+
expect(() => RealtimePresenceSchema.parse(presence)).not.toThrow();
216216
});
217217

218218
it('should accept presence with metadata', () => {
@@ -227,13 +227,13 @@ describe('PresenceSchema', () => {
227227
},
228228
};
229229

230-
const parsed = PresenceSchema.parse(presence);
230+
const parsed = RealtimePresenceSchema.parse(presence);
231231
expect(parsed.metadata).toBeDefined();
232232
expect(parsed.metadata?.currentPage).toBe('/dashboard');
233233
});
234234

235235
it('should accept all presence statuses', () => {
236-
const statuses: Array<Presence['status']> = ['online', 'away', 'offline'];
236+
const statuses: Array<RealtimePresence['status']> = ['online', 'away', 'offline'];
237237

238238
statuses.forEach(status => {
239239
const presence = {
@@ -242,37 +242,37 @@ describe('PresenceSchema', () => {
242242
lastSeen: '2024-01-15T10:30:00Z',
243243
};
244244

245-
const parsed = PresenceSchema.parse(presence);
245+
const parsed = RealtimePresenceSchema.parse(presence);
246246
expect(parsed.status).toBe(status);
247247
});
248248
});
249249

250250
it('should validate datetime format', () => {
251-
expect(() => PresenceSchema.parse({
251+
expect(() => RealtimePresenceSchema.parse({
252252
userId: 'user-123',
253253
status: 'online',
254254
lastSeen: 'not-a-datetime',
255255
})).toThrow();
256256

257-
expect(() => PresenceSchema.parse({
257+
expect(() => RealtimePresenceSchema.parse({
258258
userId: 'user-123',
259259
status: 'online',
260260
lastSeen: '2024-01-15T10:30:00Z',
261261
})).not.toThrow();
262262
});
263263

264264
it('should reject presence without required fields', () => {
265-
expect(() => PresenceSchema.parse({
265+
expect(() => RealtimePresenceSchema.parse({
266266
status: 'online',
267267
lastSeen: '2024-01-15T10:30:00Z',
268268
})).toThrow();
269269

270-
expect(() => PresenceSchema.parse({
270+
expect(() => RealtimePresenceSchema.parse({
271271
userId: 'user-123',
272272
lastSeen: '2024-01-15T10:30:00Z',
273273
})).toThrow();
274274

275-
expect(() => PresenceSchema.parse({
275+
expect(() => RealtimePresenceSchema.parse({
276276
userId: 'user-123',
277277
status: 'online',
278278
})).toThrow();

packages/spec/src/api/realtime.zod.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,26 @@ export type Subscription = z.infer<typeof SubscriptionSchema>;
5252
* Presence Status Enum
5353
* User online/offline status
5454
*/
55-
export const PresenceStatus = z.enum([
55+
export const RealtimePresenceStatus = z.enum([
5656
'online',
5757
'away',
5858
'offline',
5959
]);
6060

61-
export type PresenceStatus = z.infer<typeof PresenceStatus>;
61+
export type RealtimePresenceStatus = z.infer<typeof RealtimePresenceStatus>;
6262

6363
/**
6464
* Presence Schema
6565
* Tracks user online status and metadata
6666
*/
67-
export const PresenceSchema = z.object({
67+
export const RealtimePresenceSchema = z.object({
6868
userId: z.string().describe('User identifier'),
69-
status: PresenceStatus.describe('Current presence status'),
69+
status: RealtimePresenceStatus.describe('Current presence status'),
7070
lastSeen: z.string().datetime().describe('ISO 8601 datetime of last activity'),
7171
metadata: z.record(z.string(), z.any()).optional().describe('Custom presence data (e.g., current page, custom status)'),
7272
});
7373

74-
export type Presence = z.infer<typeof PresenceSchema>;
74+
export type RealtimePresence = z.infer<typeof RealtimePresenceSchema>;
7575

7676
/**
7777
* Realtime Action Enum

packages/spec/src/kernel/plugin-security-advanced.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
SandboxConfigSchema,
55
PermissionSchema,
66
PermissionSetSchema,
7-
SecurityPolicySchema,
7+
KernelSecurityPolicySchema,
88
PluginSecurityManifestSchema,
99
} from './plugin-security-advanced.zod';
1010

@@ -218,7 +218,7 @@ describe('Plugin Security Advanced Schemas', () => {
218218
});
219219
});
220220

221-
describe('SecurityPolicySchema', () => {
221+
describe('KernelSecurityPolicySchema', () => {
222222
it('should validate comprehensive security policy', () => {
223223
const policy = {
224224
csp: {
@@ -257,7 +257,7 @@ describe('Plugin Security Advanced Schemas', () => {
257257
retention: 90,
258258
},
259259
};
260-
const result = SecurityPolicySchema.parse(policy);
260+
const result = KernelSecurityPolicySchema.parse(policy);
261261
expect(result.rateLimit?.enabled).toBe(true);
262262
expect(result.authentication?.required).toBe(true);
263263
expect(result.encryption?.dataAtRest).toBe(true);

0 commit comments

Comments
 (0)