-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvalidate.ts
More file actions
618 lines (573 loc) · 27.7 KB
/
Copy pathvalidate.ts
File metadata and controls
618 lines (573 loc) · 27.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { Args, Command, Flags } from '@oclif/core';
import { existsSync, readFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import { join, dirname } from 'node:path';
import chalk from 'chalk';
import { ZodError } from 'zod';
import { ObjectStackDefinitionSchema, normalizeStackInput, type ConversionNotice } from '@objectstack/spec';
import { loadConfig } from '../utils/config.js';
import { validateStackExpressions } from '@objectstack/lint';
import { validateListViewMode } from '@objectstack/lint';
import { validateViewContainers } from '@objectstack/lint';
import { validateWidgetBindings } from '@objectstack/lint';
import { validateDashboardActionRefs } from '@objectstack/lint';
import { validateResponsiveStyles } from '@objectstack/lint';
import { validateJsxPages, validateReactPages, validateReactPageProps, validatePageSourceStyling } from '@objectstack/lint';
import { validateCapabilityReferences } from '@objectstack/lint';
import { validateVisibilityPredicates } from '@objectstack/lint';
import { validateSecurityPosture } from '@objectstack/lint';
import { validateFlowTriggerReadiness } from '@objectstack/lint';
import { preflightRequiredCapabilities, renderCapabilityMessage } from '../utils/capability-preflight.js';
import {
printHeader,
printKV,
printSuccess,
printError,
printStep,
createTimer,
formatZodErrors,
collectMetadataStats,
printMetadataStats,
} from '../utils/format.js';
import { checkSpecVersionGap } from '../utils/spec-version.js';
export default class Validate extends Command {
static override description =
'Validate ObjectStack configuration against the protocol schema, CEL expressions, and widget bindings (no artifact emitted)';
static override args = {
config: Args.string({ description: 'Configuration file path', required: false }),
};
static override flags = {
strict: Flags.boolean({ description: 'Treat warnings as errors' }),
json: Flags.boolean({ description: 'Output results as JSON' }),
};
async run(): Promise<void> {
const { args, flags } = await this.parse(Validate);
const timer = createTimer();
if (!flags.json) {
printHeader('Validate');
}
try {
// 1. Load configuration
if (!flags.json) printStep('Loading configuration...');
const { config, absolutePath, duration } = await loadConfig(args.config);
if (!flags.json) {
printKV('Config', absolutePath);
printKV('Load time', `${duration}ms`);
}
// 2. Normalize map-formatted stack definition and validate against schema.
// The ADR-0087 D2 conversion layer runs here (inside normalizeStackInput);
// surface each applied conversion as a non-blocking deprecation notice so
// the author knows the source still carries an old-shape key that will
// retire from the load path in a future major.
if (!flags.json) printStep('Validating against ObjectStack Protocol...');
const conversionNotices: ConversionNotice[] = [];
const normalized = normalizeStackInput(config as Record<string, unknown>, {
onConversionNotice: (n) => conversionNotices.push(n),
});
const result = ObjectStackDefinitionSchema.safeParse(normalized);
if (!result.success) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: (result.error as unknown as ZodError).issues,
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError('Validation failed');
formatZodErrors(result.error as unknown as ZodError);
this.exit(1);
}
// 2b. Expression validation (ADR-0032 §1a/1b) — the same gate `os build`
// runs, brought to the read-only check so authors catch it without
// emitting an artifact. CEL predicates in actions/validations/flows/
// sharing/hooks are checked for syntax AND that `record.<field>`
// references resolve on the target object. This is what catches a
// BARE field ref (`done` instead of `record.done`) that would
// otherwise silently hide an action on every record (#2183/#2185).
if (!flags.json) printStep('Validating expressions (ADR-0032)...');
const exprIssues = validateStackExpressions(result.data as Record<string, unknown>);
const exprErrors = exprIssues.filter((i) => i.severity !== 'warning');
const exprWarnings = exprIssues.filter((i) => i.severity === 'warning');
if (exprErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: exprErrors,
warnings: exprWarnings,
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`Expression validation failed (${exprErrors.length} issue${exprErrors.length > 1 ? 's' : ''})`);
for (const i of exprErrors.slice(0, 50)) {
console.log(` • ${i.where}: ${i.message}`);
console.log(chalk.dim(` source: \`${i.source}\``));
}
this.exit(1);
}
// 2c. ADR-0053 list-view navigation modes — `userFilters`/`quickFilters`
// on an object list view ("views" mode) are silently dropped: the
// object-list schema (ObjectListViewSchema) OMITS them, so this is
// checked on `normalized` (PRE-parse) — `result.data` has already had
// the field stripped. They belong to a page list ("filters" mode).
// See objectui #2219 and ADR-0053 phase 4.
if (!flags.json) printStep('Checking list-view navigation modes (ADR-0053)...');
const listViewFindings = validateListViewMode(normalized as Record<string, unknown>);
const listViewErrors = listViewFindings.filter((f) => f.severity === 'error');
if (listViewErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: listViewErrors,
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`List-view mode check failed (${listViewErrors.length} issue${listViewErrors.length > 1 ? 's' : ''})`);
for (const f of listViewErrors.slice(0, 50)) {
console.log(` • ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
// 2d. View container shape — a flat list-view object in `views: []`
// parses to an EMPTY container (ViewSchema strips unknown keys), so
// the schema step passes while zero views register and the Console
// silently renders nothing. Checked on `normalized` (PRE-parse) —
// `result.data` has already had the flat keys stripped.
if (!flags.json) printStep('Checking view container shape...');
const viewContainerFindings = validateViewContainers(normalized as Record<string, unknown>);
const viewContainerErrors = viewContainerFindings.filter((f) => f.severity === 'error');
if (viewContainerErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: viewContainerErrors,
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`View container check failed (${viewContainerErrors.length} issue${viewContainerErrors.length > 1 ? 's' : ''})`);
for (const f of viewContainerErrors.slice(0, 50)) {
console.log(` • ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
// 3. Dashboard widget reference integrity (issue #1721) — a semantic
// cross-reference pass the protocol schema cannot express: every
// widget's `dataset`/`dimensions`/`values` and chartConfig
// axis/series fields must resolve against the declared datasets
// (ADR-0021). Errors fail validation; warnings are advisory.
if (!flags.json) printStep('Checking dashboard widget bindings (ADR-0021)...');
const widgetFindings = validateWidgetBindings(result.data as Record<string, unknown>);
const widgetErrors = widgetFindings.filter((f) => f.severity === 'error');
const widgetWarnings = widgetFindings.filter((f) => f.severity === 'warning');
if (widgetErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: widgetErrors,
warnings: widgetWarnings,
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`Dashboard widget integrity failed (${widgetErrors.length} issue${widgetErrors.length > 1 ? 's' : ''})`);
for (const f of widgetErrors.slice(0, 50)) {
console.log(` • ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
// 3a-bis. Dashboard action/route reference integrity (ADR-0049 for
// references, #3367) — a header/widget action names a `script`/`modal`
// target that resolves to no defined action, or a `url` target that
// matches no in-app route. Nothing else flags it, so it ships as a
// button that renders and silently does nothing on click (a false
// affordance). Dead script/modal targets are errors (fail open at
// runtime); unresolved url routes are advisory warnings.
if (!flags.json) printStep('Checking dashboard action references (ADR-0049)...');
const actionRefFindings = validateDashboardActionRefs(result.data as Record<string, unknown>);
const actionRefErrors = actionRefFindings.filter((f) => f.severity === 'error');
const actionRefWarnings = actionRefFindings.filter((f) => f.severity === 'warning');
if (actionRefErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: actionRefErrors,
warnings: [...widgetWarnings, ...actionRefWarnings],
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`Dashboard action reference check failed (${actionRefErrors.length} issue${actionRefErrors.length > 1 ? 's' : ''})`);
for (const f of actionRefErrors.slice(0, 50)) {
console.log(` • ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
if (!flags.json) {
for (const w of actionRefWarnings.slice(0, 50)) {
console.log(chalk.yellow(` ⚠ ${w.where}: ${w.message}`));
console.log(chalk.dim(` ${w.hint}`));
}
}
// 3b. SDUI scoped-styling correctness (ADR-0065) — a styled node's
// responsiveStyles must be scopable (needs an `id`), reference real
// CSS properties + design tokens, and carry a `large` base;
// Tailwind-in-className silently does nothing. Same bar for
// hand-authored and AI-generated pages (ADR-0019).
if (!flags.json) printStep('Checking SDUI styling (ADR-0065)...');
const styleFindings = validateResponsiveStyles(result.data as Record<string, unknown>);
const styleErrors = styleFindings.filter((f) => f.severity === 'error');
const styleWarnings = styleFindings.filter((f) => f.severity === 'warning');
if (styleErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: styleErrors,
warnings: [...widgetWarnings, ...styleWarnings],
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`SDUI styling check failed (${styleErrors.length} issue${styleErrors.length > 1 ? 's' : ''})`);
for (const f of styleErrors.slice(0, 50)) {
console.log(` • ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
// 3b. JSX-source pages (ADR-0080) — a kind:'jsx' page's `source` is
// parsed (never executed) and compiled to the SDUI tree at save
// time. Parse it now so malformed source fails loudly (ADR-0078)
// instead of being stored and breaking only at render.
if (!flags.json) printStep('Checking JSX-source pages (ADR-0080)...');
// Optional component manifest (ADR-0080): if the project ships a
// `sdui.manifest.json` (generated from the registry's public tier), the
// gate does full component/prop validation; otherwise parse-level.
let sduiManifest: unknown;
try {
const mp = join(process.cwd(), 'sdui.manifest.json');
if (existsSync(mp)) sduiManifest = JSON.parse(readFileSync(mp, 'utf8'));
if (!sduiManifest) {
// Fall back to the manifest shipped inside @objectstack/console
// (built from objectui's public-tier registry; cli already deps it).
const cp = createRequire(import.meta.url).resolve('@objectstack/console/dist/sdui.manifest.json');
if (existsSync(cp)) sduiManifest = JSON.parse(readFileSync(cp, 'utf8'));
}
} catch { /* fall back to parse-level */ }
const jsxFindings = validateJsxPages(
result.data as Record<string, unknown>,
sduiManifest ? { manifest: sduiManifest as never } : {},
);
const jsxErrors = jsxFindings.filter((f) => f.severity === 'error');
const jsxWarnings = jsxFindings.filter((f) => f.severity === 'warning');
if (jsxErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: jsxErrors,
warnings: [...widgetWarnings, ...styleWarnings, ...jsxWarnings],
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`JSX-source page check failed (${jsxErrors.length} issue${jsxErrors.length > 1 ? 's' : ''})`);
for (const f of jsxErrors.slice(0, 50)) {
console.log(` \u2022 ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
// 3c. React-source pages (ADR-0081) — a kind:'react' page's `source` is
// real React executed at render. Transpile it now (Sucrase, never
// executed) so syntax errors fail loudly at build, not at render.
if (!flags.json) printStep('Checking React-source pages (ADR-0081)...');
const reactFindings = validateReactPages(result.data as Record<string, unknown>);
const reactErrors = reactFindings.filter((f) => f.severity === 'error');
if (reactErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: reactErrors,
warnings: [...widgetWarnings, ...styleWarnings, ...jsxWarnings],
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`React-source page check failed (${reactErrors.length} issue${reactErrors.length > 1 ? 's' : ''})`);
for (const f of reactErrors.slice(0, 50)) {
console.log(` \u2022 ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
// 3d. React-source pages — prop usage against the component contract
// (ADR-0081 Phase 2): missing required bindings (error) + likely
// prop typos (warning), parsed from the real JSX.
if (!flags.json) printStep('Checking React-source page props (ADR-0081)...');
const reactPropFindings = validateReactPageProps(result.data as Record<string, unknown>);
const reactPropErrors = reactPropFindings.filter((f) => f.severity === 'error');
const reactPropWarnings = reactPropFindings.filter((f) => f.severity === 'warning');
if (!flags.json) {
for (const w of reactPropWarnings.slice(0, 50)) {
console.log(chalk.yellow(` \u26a0 ${w.where}: ${w.message}`));
console.log(chalk.dim(` ${w.hint}`));
}
}
if (reactPropErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: reactPropErrors,
warnings: [...widgetWarnings, ...styleWarnings, ...jsxWarnings, ...reactPropWarnings],
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`React-source page prop check failed (${reactPropErrors.length} issue${reactPropErrors.length > 1 ? 's' : ''})`);
for (const f of reactPropErrors.slice(0, 50)) {
console.log(` \u2022 ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
// 3e. Source-tier page styling (ADR-0065): Tailwind className in a
// kind:'html'/'react' page source silently no-ops (the build never
// scans authored metadata) — warn with the inline-style fix.
if (!flags.json) printStep('Checking source-page styling (ADR-0065)...');
const sourceStyleFindings = validatePageSourceStyling(result.data as Record<string, unknown>);
const sourceStyleWarnings = sourceStyleFindings.filter((f) => f.severity === 'warning');
if (!flags.json) {
for (const w of sourceStyleWarnings.slice(0, 50)) {
console.log(chalk.yellow(` \u26a0 ${w.where}: ${w.message}`));
console.log(chalk.dim(` ${w.hint}`));
}
}
// 3f. Capability references (ADR-0066 ⑨): a requiredPermissions entry
// naming a capability registered nowhere (no built-in, no permission
// set grants it, no sys_capability seed) is almost certainly a typo —
// it fails closed at runtime. Advisory: the capability may legitimately
// be provided by another installed package.
if (!flags.json) printStep('Checking capability references (ADR-0066)...');
const capFindings = validateCapabilityReferences(result.data as Record<string, unknown>);
const capWarnings = capFindings.filter((f) => f.severity === 'warning');
if (!flags.json) {
for (const w of capWarnings.slice(0, 50)) {
console.log(chalk.yellow(` ⚠ ${w.where}: ${w.message}`));
console.log(chalk.dim(` ${w.hint}`));
}
}
// 3g. Auto-launched flow trigger wiring (2026-07-17 third-party eval):
// a record-change flow whose start-node objectName matches nothing
// never fires — silently. Also nudges auto-triggered flows to declare
// an explicit deployment status (the schema default is 'draft', and
// draft flows DO still fire — ambiguous intent). Advisory: objects
// may come from other installed packages.
if (!flags.json) printStep('Checking flow trigger wiring...');
const flowReadinessFindings = validateFlowTriggerReadiness(normalized as Record<string, unknown>);
const flowReadinessWarnings = flowReadinessFindings.filter((f) => f.severity === 'warning');
if (!flags.json) {
for (const w of flowReadinessWarnings.slice(0, 50)) {
console.log(chalk.yellow(` ⚠ ${w.where}: ${w.message}`));
console.log(chalk.dim(` ${w.hint}`));
}
}
// 3f. [ADR-0090 D7] Security posture — the same gate `os compile`/`os build`
// run. Without it here, `os validate` passed a stack (e.g. a custom
// object with no explicit sharingModel) that the build then rejected,
// breaking this command's contract of being the artifact-free run of
// the same gates. Errors gate; advisories print dimmed.
if (!flags.json) printStep('Checking security posture (ADR-0090 D7)...');
const securityFindings = validateSecurityPosture(result.data as Record<string, unknown>);
const securityErrors = securityFindings.filter((f) => f.severity === 'error');
const securityAdvisories = securityFindings.filter((f) => f.severity !== 'error');
if (securityErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: securityErrors,
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`Security posture check failed (${securityErrors.length} issue${securityErrors.length > 1 ? 's' : ''})`);
for (const f of securityErrors.slice(0, 50)) {
console.log(` • ${f.where}: ${f.message}`);
console.log(chalk.dim(` ${f.hint}`));
console.log(chalk.dim(` rule: ${f.rule} at ${f.path}`));
}
this.exit(1);
}
if (!flags.json) {
for (const f of securityAdvisories.slice(0, 50)) {
console.log(chalk.yellow(` ⚠ ${f.where}: ${f.message}`));
console.log(chalk.dim(` ${f.hint}`));
}
}
// 3h. [#3366] Installable-provider preflight — the shift-left of the
// `serve`-time capability check. `os validate` previously only checked
// the `requires` tokens against the vocabulary (ADR-0066), never
// whether each token's provider is resolvable in the active edition. A
// token whose provider has NO installable version here (e.g. `ai` →
// @objectstack/service-ai, cloud-only) fails; absent-but-installable is
// an advisory `pnpm add` hint. Mirrors the `os build` gate exactly.
if (!flags.json) printStep('Checking capability providers (#3366)...');
const capProviderPreflight = preflightRequiredCapabilities({
requires: Array.isArray((config as { requires?: unknown[] }).requires)
? ((config as { requires?: unknown[] }).requires as unknown[])
: [],
projectDir: dirname(absolutePath),
});
const capProviderErrors = capProviderPreflight.errors;
const capProviderWarnings = capProviderPreflight.warnings.map((c) => ({
token: c.token,
message: renderCapabilityMessage(c),
}));
if (capProviderErrors.length > 0) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
errors: capProviderErrors.map((c) => ({ token: c.token, message: renderCapabilityMessage(c) })),
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(`Capability provider check failed (${capProviderErrors.length} issue${capProviderErrors.length > 1 ? 's' : ''})`);
for (const c of capProviderErrors) {
console.log(` • ${renderCapabilityMessage(c)}`);
}
this.exit(1);
}
// 4. Collect and display stats
const stats = collectMetadataStats(config);
// Spec-version drift advisory (non-blocking): if the installed platform
// is a newer major than the app declares, point at the migration guide.
const specGap = checkSpecVersionGap(config.manifest);
if (flags.json) {
console.log(JSON.stringify({
valid: true,
manifest: config.manifest,
stats,
warnings: [...exprWarnings, ...widgetWarnings, ...actionRefWarnings, ...styleWarnings, ...jsxWarnings, ...capWarnings, ...flowReadinessWarnings, ...securityAdvisories, ...capProviderWarnings],
conversions: conversionNotices,
specVersionGap: specGap,
duration: timer.elapsed(),
}, null, 2));
return;
}
// 5. Warnings (non-blocking)
const warnings: string[] = [];
// [#3366] Installable-provider hints — a declared capability whose provider
// is absent but addable (`pnpm add`), or an unknown token (typo).
for (const w of capProviderWarnings) {
warnings.push(w.message);
}
// ADR-0089 D3b — deprecated visibility aliases + mis-layered binding root.
// Checked on `normalized` (PRE-parse): the schema folds `visibleOn`/
// `visibility` into `visibleWhen` during parse, so `result.data` no longer
// carries the alias the author actually wrote.
const visibilityFindings = validateVisibilityPredicates(normalized as Record<string, unknown>);
for (const f of visibilityFindings) {
warnings.push(`${f.where}: ${f.message} — ${f.hint}`);
}
// ADR-0087 D2 conversion notices: the source used a deprecated shape that
// was auto-converted at load. No action is required to keep loading, but
// the notice steers the author to the canonical key before it retires.
for (const n of conversionNotices) {
warnings.push(`${n.path}: '${n.from}' → '${n.to}' (converted at load; conversion '${n.conversionId}', retires in protocol ${n.retiresIn})`);
}
for (const i of exprWarnings) {
warnings.push(`${i.where}: ${i.message}`);
}
for (const f of widgetWarnings) {
warnings.push(`${f.where}: ${f.message}`);
}
for (const f of styleWarnings) {
warnings.push(`${f.where}: ${f.message}`);
}
for (const f of jsxWarnings) {
warnings.push(`${f.where}: ${f.message}`);
}
if (stats.objects === 0) {
warnings.push('No objects defined — this stack has no data model');
}
if (stats.apps === 0 && stats.plugins === 0) {
warnings.push('No apps or plugins defined — this stack may not do much');
}
if (!config.manifest?.id) {
warnings.push('Missing manifest.id — required for deployment');
}
if (!config.manifest?.namespace) {
warnings.push('Missing manifest.namespace — required for multi-app hosting');
}
// 6. Display results
console.log('');
printSuccess(`Validation passed ${chalk.dim(`(${timer.display()})`)}`);
console.log('');
if (config.manifest) {
console.log(` ${chalk.bold(config.manifest.name || config.manifest.id || 'Unnamed')} ${chalk.dim(`v${config.manifest.version || '0.0.0'}`)}`);
if (config.manifest.description) {
console.log(chalk.dim(` ${config.manifest.description}`));
}
console.log('');
}
printMetadataStats(stats);
if (warnings.length > 0) {
console.log('');
for (const w of warnings) {
console.log(chalk.yellow(` ⚠ ${w}`));
}
if (flags.strict) {
console.log('');
printError('Strict mode: warnings treated as errors');
this.exit(1);
}
}
// Non-blocking upgrade advisory — never gated by --strict.
if (specGap) {
console.log('');
console.log(chalk.yellow(` ⚠ ${specGap.message}`));
console.log(chalk.dim(` → ${specGap.hint}`));
}
console.log('');
} catch (error: any) {
if (flags.json) {
console.log(JSON.stringify({
valid: false,
error: error.message,
duration: timer.elapsed(),
}, null, 2));
this.exit(1);
}
console.log('');
printError(error.message || String(error));
this.exit(1);
}
}
}