artifact-graph 0.15.0 → 0.16.1
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/CHANGELOG.md +25 -0
- package/INSTALL.md +9 -0
- package/README.md +6 -1
- package/README.zh-CN.md +6 -1
- package/contracts/spec/schema.json +44 -0
- package/dist/cli.js +897 -268
- package/dist/index.cjs +779 -320
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +829 -224
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
1
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
3
|
var __esm = (fn, res) => function __init() {
|
|
3
4
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
5
|
};
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
5
10
|
|
|
6
11
|
// src/packet-constants.ts
|
|
7
12
|
var ALWAYS_PRESENT_ITEMS, BASELINE_ITEMS_COUNT, BASELINE_CONSTRAINTS, BASELINE_CONSTRAINTS_COUNT;
|
|
@@ -370,6 +375,505 @@ var init_file_walker = __esm({
|
|
|
370
375
|
}
|
|
371
376
|
});
|
|
372
377
|
|
|
378
|
+
// src/doctor.ts
|
|
379
|
+
import yaml from "js-yaml";
|
|
380
|
+
import _AjvModule from "ajv";
|
|
381
|
+
import { readFile } from "fs/promises";
|
|
382
|
+
import { isAbsolute, join as join2 } from "path";
|
|
383
|
+
function getShapeValidator() {
|
|
384
|
+
if (!_validateConfigShape) {
|
|
385
|
+
const AjvCtor = _AjvModule;
|
|
386
|
+
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
387
|
+
_validateConfigShape = ajv.compile(CONFIG_SHAPE_SCHEMA);
|
|
388
|
+
}
|
|
389
|
+
return _validateConfigShape;
|
|
390
|
+
}
|
|
391
|
+
function instancePathToField(instancePath, params) {
|
|
392
|
+
const missing = typeof params?.missingProperty === "string" ? params.missingProperty : void 0;
|
|
393
|
+
if (!instancePath || instancePath === "") {
|
|
394
|
+
return missing && missing.length > 0 ? missing : "(root)";
|
|
395
|
+
}
|
|
396
|
+
const path = instancePath.replace(/^\//, "").replace(/\//g, ".");
|
|
397
|
+
return missing && missing.length > 0 ? `${path}.${missing}` : path;
|
|
398
|
+
}
|
|
399
|
+
function pushError(errors, path, message) {
|
|
400
|
+
errors.push({ path, message, severity: "error" });
|
|
401
|
+
}
|
|
402
|
+
function warnUnknownObjectKeys(value, path, knownKeys, warnings) {
|
|
403
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return;
|
|
404
|
+
for (const key of Object.keys(value)) {
|
|
405
|
+
if (knownKeys.has(key)) continue;
|
|
406
|
+
const field = path ? `${path}.${key}` : key;
|
|
407
|
+
warnings.push({
|
|
408
|
+
path: field,
|
|
409
|
+
message: `Unknown config key ${key} at ${field}: kept for compatibility and not treated as a declared field.`,
|
|
410
|
+
severity: "warning"
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function warnUnknownArrayObjectKeys(value, path, knownKeys, warnings) {
|
|
415
|
+
if (!Array.isArray(value)) return;
|
|
416
|
+
value.forEach((entry, index) => {
|
|
417
|
+
warnUnknownObjectKeys(entry, `${path}.${index}`, knownKeys, warnings);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function collectNestedUnknownKeyWarnings(document, warnings) {
|
|
421
|
+
warnUnknownObjectKeys(document, "", KNOWN_TOP_LEVEL_KEYS, warnings);
|
|
422
|
+
const types = document.types;
|
|
423
|
+
if (types && typeof types === "object" && !Array.isArray(types)) {
|
|
424
|
+
for (const [typeName, definition] of Object.entries(types)) {
|
|
425
|
+
const typePath = `types.${typeName}`;
|
|
426
|
+
warnUnknownObjectKeys(definition, typePath, TYPE_OBJECT_KEYS, warnings);
|
|
427
|
+
if (definition && typeof definition === "object" && !Array.isArray(definition)) {
|
|
428
|
+
warnUnknownArrayObjectKeys(
|
|
429
|
+
definition.extraFields,
|
|
430
|
+
`${typePath}.extraFields`,
|
|
431
|
+
EXTRA_FIELD_KEYS,
|
|
432
|
+
warnings
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
warnUnknownArrayObjectKeys(document.allowedEdges, "allowedEdges", EDGE_RULE_KEYS, warnings);
|
|
438
|
+
warnUnknownArrayObjectKeys(document.forbiddenEdges, "forbiddenEdges", EDGE_RULE_KEYS, warnings);
|
|
439
|
+
warnUnknownObjectKeys(document.context, "context", CONTEXT_KEYS, warnings);
|
|
440
|
+
const idRanges = document.idRanges;
|
|
441
|
+
if (idRanges && typeof idRanges === "object" && !Array.isArray(idRanges)) {
|
|
442
|
+
for (const [layer, ranges] of Object.entries(idRanges)) {
|
|
443
|
+
if (!ranges || typeof ranges !== "object" || Array.isArray(ranges)) continue;
|
|
444
|
+
for (const [rangeName, entry] of Object.entries(ranges)) {
|
|
445
|
+
warnUnknownObjectKeys(entry, `idRanges.${layer}.${rangeName}`, ID_RANGE_ENTRY_KEYS, warnings);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const relationSemantics = document.relationSemantics;
|
|
450
|
+
if (relationSemantics && typeof relationSemantics === "object" && !Array.isArray(relationSemantics)) {
|
|
451
|
+
for (const [kind, spec] of Object.entries(relationSemantics)) {
|
|
452
|
+
const specPath = `relationSemantics.${kind}`;
|
|
453
|
+
warnUnknownObjectKeys(spec, specPath, RELATION_SEMANTICS_KEYS, warnings);
|
|
454
|
+
if (spec && typeof spec === "object" && !Array.isArray(spec)) {
|
|
455
|
+
warnUnknownObjectKeys(
|
|
456
|
+
spec.partial,
|
|
457
|
+
`${specPath}.partial`,
|
|
458
|
+
RELATION_PARTIAL_KEYS,
|
|
459
|
+
warnings
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const e2e = document.e2e;
|
|
465
|
+
if (e2e && typeof e2e === "object" && !Array.isArray(e2e)) {
|
|
466
|
+
const e2eRecord = e2e;
|
|
467
|
+
warnUnknownObjectKeys(e2eRecord, "e2e", E2E_KEYS, warnings);
|
|
468
|
+
warnUnknownArrayObjectKeys(e2eRecord.scenario_waivers, "e2e.scenario_waivers", WAIVER_KEYS, warnings);
|
|
469
|
+
warnUnknownArrayObjectKeys(e2eRecord.feature_waivers, "e2e.feature_waivers", WAIVER_KEYS, warnings);
|
|
470
|
+
warnUnknownArrayObjectKeys(e2eRecord.runners, "e2e.runners", RUNNER_KEYS, warnings);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function typeHasDefaultPaths(typeName) {
|
|
474
|
+
const base = DEFAULT_SCHEMA.types[typeName];
|
|
475
|
+
return Array.isArray(base?.paths);
|
|
476
|
+
}
|
|
477
|
+
function collectCustomTypePathErrors(types, errors) {
|
|
478
|
+
if (types === void 0) return;
|
|
479
|
+
if (typeof types !== "object" || types === null || Array.isArray(types)) return;
|
|
480
|
+
for (const [typeName, definition] of Object.entries(types)) {
|
|
481
|
+
if (definition === void 0 || definition === null) {
|
|
482
|
+
if (!typeHasDefaultPaths(typeName)) {
|
|
483
|
+
pushError(errors, `types.${typeName}.paths`, `Invalid types.${typeName}.paths: must be array`);
|
|
484
|
+
}
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (typeof definition !== "object" || Array.isArray(definition)) continue;
|
|
488
|
+
const paths = definition.paths;
|
|
489
|
+
if (paths === void 0 && !typeHasDefaultPaths(typeName)) {
|
|
490
|
+
pushError(errors, `types.${typeName}.paths`, `Invalid types.${typeName}.paths: must be array`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function collectRelationSemanticsErrors(value, errors) {
|
|
495
|
+
if (value === void 0) return;
|
|
496
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
497
|
+
pushError(errors, "relationSemantics", "Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
for (const [kind, spec] of Object.entries(value)) {
|
|
501
|
+
const path = `relationSemantics.${kind}`;
|
|
502
|
+
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
503
|
+
pushError(errors, path, `Invalid relationSemantics.${kind}: must be an object.`);
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
const record = spec;
|
|
507
|
+
if (typeof record.label !== "string" || !record.label.trim()) {
|
|
508
|
+
pushError(errors, `${path}.label`, `Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
509
|
+
}
|
|
510
|
+
if (!Array.isArray(record.targetTypes) || record.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
511
|
+
pushError(errors, `${path}.targetTypes`, `Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
512
|
+
}
|
|
513
|
+
if (!Array.isArray(record.fields) || record.fields.length === 0 || record.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
514
|
+
pushError(errors, `${path}.fields`, `Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
515
|
+
}
|
|
516
|
+
if (record.partial !== void 0 && (typeof record.partial !== "object" || record.partial === null || Array.isArray(record.partial) || typeof record.partial.sectionField !== "string" || !record.partial.sectionField.trim())) {
|
|
517
|
+
pushError(
|
|
518
|
+
errors,
|
|
519
|
+
`${path}.partial.sectionField`,
|
|
520
|
+
`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function collectStatusViewsErrors(value, errors) {
|
|
526
|
+
if (value === void 0) return;
|
|
527
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
528
|
+
pushError(errors, "statusViews", "Invalid statusViews: must be an object keyed by status.");
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
for (const [status, bucket] of Object.entries(value)) {
|
|
532
|
+
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
533
|
+
pushError(errors, `statusViews.${status}`, `Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function collectWaiverErrors(waivers, field, errors) {
|
|
538
|
+
if (waivers === void 0) return;
|
|
539
|
+
if (!Array.isArray(waivers)) {
|
|
540
|
+
pushError(errors, field, `Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
waivers.forEach((entry, index) => {
|
|
544
|
+
const path = `${field}.${index}`;
|
|
545
|
+
if (typeof entry !== "object" || entry === null || !("id" in entry) || !("reason" in entry)) {
|
|
546
|
+
pushError(errors, path, `Invalid ${field} entry: ${JSON.stringify(entry)}. Must be {id, reason} object.`);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
const record = entry;
|
|
550
|
+
if (typeof record.id !== "string" || !record.id.trim()) {
|
|
551
|
+
pushError(errors, `${path}.id`, `Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(record.id)}`);
|
|
552
|
+
}
|
|
553
|
+
if (typeof record.reason !== "string" || !record.reason.trim()) {
|
|
554
|
+
pushError(errors, `${path}.reason`, `Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(record.reason)}`);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
function collectE2eConfigErrors(e2e, errors) {
|
|
559
|
+
if (e2e === void 0) return;
|
|
560
|
+
if (typeof e2e !== "object" || e2e === null || Array.isArray(e2e)) {
|
|
561
|
+
pushError(errors, "e2e", "Invalid e2e: must be an object.");
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
const record = e2e;
|
|
565
|
+
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
566
|
+
if (record[field] !== void 0 && typeof record[field] !== "boolean") {
|
|
567
|
+
pushError(errors, `e2e.${field}`, `Invalid e2e.${field}: must be boolean.`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (record.executable_ref_warning !== void 0) {
|
|
571
|
+
if (typeof record.executable_ref_warning !== "number" || record.executable_ref_warning < 0 || record.executable_ref_warning > 1) {
|
|
572
|
+
pushError(
|
|
573
|
+
errors,
|
|
574
|
+
"e2e.executable_ref_warning",
|
|
575
|
+
`Invalid e2e.executable_ref_warning: ${JSON.stringify(record.executable_ref_warning)}. Must be a number between 0 and 1.`
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (record.executable_ref_error !== void 0) {
|
|
580
|
+
if (typeof record.executable_ref_error !== "number" || record.executable_ref_error < 0 || record.executable_ref_error > 1) {
|
|
581
|
+
pushError(
|
|
582
|
+
errors,
|
|
583
|
+
"e2e.executable_ref_error",
|
|
584
|
+
`Invalid e2e.executable_ref_error: ${JSON.stringify(record.executable_ref_error)}. Must be a number between 0 and 1.`
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
collectWaiverErrors(record.scenario_waivers, "e2e.scenario_waivers", errors);
|
|
589
|
+
collectWaiverErrors(record.feature_waivers, "e2e.feature_waivers", errors);
|
|
590
|
+
if (record.runners === void 0) return;
|
|
591
|
+
if (!Array.isArray(record.runners)) {
|
|
592
|
+
pushError(errors, "e2e.runners", "Invalid e2e.runners: must be an array.");
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
record.runners.forEach((runner, index) => {
|
|
596
|
+
const runnerPath = `e2e.runners.${index}`;
|
|
597
|
+
if (typeof runner !== "object" || runner === null) {
|
|
598
|
+
pushError(errors, runnerPath, "Invalid e2e.runners entry: must be an object.");
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
const runnerRecord = runner;
|
|
602
|
+
const name = runnerRecord.name;
|
|
603
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
604
|
+
pushError(errors, `${runnerPath}.name`, "Invalid e2e.runners entry: name must be a non-empty string.");
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (typeof runnerRecord.root !== "string" || !runnerRecord.root.trim()) {
|
|
608
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: must be a non-empty string.`);
|
|
609
|
+
} else {
|
|
610
|
+
if (isAbsolute(runnerRecord.root)) {
|
|
611
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: "${runnerRecord.root}" must not be an absolute path.`);
|
|
612
|
+
}
|
|
613
|
+
if (runnerRecord.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
614
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: "${runnerRecord.root}" must not contain ".." segments.`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (!Array.isArray(runnerRecord.include) || runnerRecord.include.length === 0) {
|
|
618
|
+
pushError(errors, `${runnerPath}.include`, `Invalid e2e.runners[${name}].include: must be a non-empty array of glob patterns.`);
|
|
619
|
+
} else {
|
|
620
|
+
for (const pattern of runnerRecord.include) {
|
|
621
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
622
|
+
pushError(errors, `${runnerPath}.include`, `Invalid e2e.runners[${name}].include: pattern must be a non-empty string.`);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (runnerRecord.exclude !== void 0) {
|
|
627
|
+
if (!Array.isArray(runnerRecord.exclude)) {
|
|
628
|
+
pushError(errors, `${runnerPath}.exclude`, `Invalid e2e.runners[${name}].exclude: must be an array.`);
|
|
629
|
+
} else {
|
|
630
|
+
for (const pattern of runnerRecord.exclude) {
|
|
631
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
632
|
+
pushError(errors, `${runnerPath}.exclude`, `Invalid e2e.runners[${name}].exclude: pattern must be a non-empty string.`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (runnerRecord.testIgnore !== void 0) {
|
|
638
|
+
if (!Array.isArray(runnerRecord.testIgnore)) {
|
|
639
|
+
pushError(errors, `${runnerPath}.testIgnore`, `Invalid e2e.runners[${name}].testIgnore: must be an array.`);
|
|
640
|
+
} else {
|
|
641
|
+
for (const pattern of runnerRecord.testIgnore) {
|
|
642
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
643
|
+
pushError(errors, `${runnerPath}.testIgnore`, `Invalid e2e.runners[${name}].testIgnore: pattern must be a non-empty string.`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (runnerRecord.kind !== void 0) {
|
|
649
|
+
if (!["unit", "integration", "e2e"].includes(runnerRecord.kind)) {
|
|
650
|
+
pushError(errors, `${runnerPath}.kind`, `Invalid e2e.runners[${name}].kind: "${runnerRecord.kind}". Must be unit, integration, or e2e.`);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
function collectAllowedEdgesPresenceError(document, errors) {
|
|
656
|
+
if (!Object.prototype.hasOwnProperty.call(document, "allowedEdges")) {
|
|
657
|
+
pushError(errors, "allowedEdges", ALLOWED_EDGES_REQUIRED_MESSAGE);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function collectExistingLoaderErrors(document, errors) {
|
|
661
|
+
collectCustomTypePathErrors(document.types, errors);
|
|
662
|
+
collectE2eConfigErrors(document.e2e, errors);
|
|
663
|
+
collectRelationSemanticsErrors(document.relationSemantics, errors);
|
|
664
|
+
collectStatusViewsErrors(document.statusViews, errors);
|
|
665
|
+
collectAllowedEdgesPresenceError(document, errors);
|
|
666
|
+
}
|
|
667
|
+
function diagnoseConfigDocument(parsed) {
|
|
668
|
+
const errors = [];
|
|
669
|
+
const warnings = [];
|
|
670
|
+
if (parsed === void 0 || parsed === null) {
|
|
671
|
+
return { errors, warnings };
|
|
672
|
+
}
|
|
673
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
674
|
+
errors.push({
|
|
675
|
+
path: "(root)",
|
|
676
|
+
message: `Invalid artifact-graph.config.yaml: expected an object, got ${Array.isArray(parsed) ? "array" : typeof parsed}.`,
|
|
677
|
+
severity: "error"
|
|
678
|
+
});
|
|
679
|
+
return { errors, warnings };
|
|
680
|
+
}
|
|
681
|
+
const document = parsed;
|
|
682
|
+
const validate = getShapeValidator();
|
|
683
|
+
const valid = validate(document);
|
|
684
|
+
if (!valid) {
|
|
685
|
+
for (const err of validate.errors ?? []) {
|
|
686
|
+
const path = instancePathToField(err.instancePath, err.params);
|
|
687
|
+
errors.push({
|
|
688
|
+
path,
|
|
689
|
+
message: `Invalid ${path}: ${err.message ?? "validation error"}`,
|
|
690
|
+
severity: "error"
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
collectExistingLoaderErrors(document, errors);
|
|
695
|
+
collectNestedUnknownKeyWarnings(document, warnings);
|
|
696
|
+
return { errors, warnings };
|
|
697
|
+
}
|
|
698
|
+
async function diagnoseProjectConfig(root) {
|
|
699
|
+
const configPath = join2(root, "artifact-graph.config.yaml");
|
|
700
|
+
let raw;
|
|
701
|
+
try {
|
|
702
|
+
raw = await readFile(configPath, "utf-8");
|
|
703
|
+
} catch (error) {
|
|
704
|
+
if (error.code === "ENOENT") {
|
|
705
|
+
return { exists: false, errors: [], warnings: [] };
|
|
706
|
+
}
|
|
707
|
+
return {
|
|
708
|
+
exists: true,
|
|
709
|
+
errors: [{
|
|
710
|
+
path: "artifact-graph.config.yaml",
|
|
711
|
+
message: `Unable to read artifact-graph.config.yaml: ${error.message}`,
|
|
712
|
+
severity: "error"
|
|
713
|
+
}],
|
|
714
|
+
warnings: []
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
let document;
|
|
718
|
+
try {
|
|
719
|
+
document = yaml.load(raw) ?? {};
|
|
720
|
+
} catch (error) {
|
|
721
|
+
return {
|
|
722
|
+
exists: true,
|
|
723
|
+
errors: [{
|
|
724
|
+
path: "artifact-graph.config.yaml",
|
|
725
|
+
message: `Invalid artifact-graph.config.yaml: ${error.message}`,
|
|
726
|
+
severity: "error"
|
|
727
|
+
}],
|
|
728
|
+
warnings: []
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
const diagnosis = diagnoseConfigDocument(document);
|
|
732
|
+
return { exists: true, errors: diagnosis.errors, warnings: diagnosis.warnings };
|
|
733
|
+
}
|
|
734
|
+
var KNOWN_TOP_LEVEL_KEYS, TYPE_OBJECT_KEYS, EXTRA_FIELD_KEYS, EDGE_RULE_KEYS, CONTEXT_KEYS, ID_RANGE_ENTRY_KEYS, RELATION_SEMANTICS_KEYS, RELATION_PARTIAL_KEYS, E2E_KEYS, WAIVER_KEYS, RUNNER_KEYS, EDGE_RULE_SCHEMA, EXTRA_FIELD_SCHEMA, ID_RANGE_ENTRY_SCHEMA, CONFIG_SHAPE_SCHEMA, _validateConfigShape, ALLOWED_EDGES_REQUIRED_MESSAGE;
|
|
735
|
+
var init_doctor = __esm({
|
|
736
|
+
"src/doctor.ts"() {
|
|
737
|
+
"use strict";
|
|
738
|
+
init_index();
|
|
739
|
+
KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
740
|
+
"types",
|
|
741
|
+
"idPatterns",
|
|
742
|
+
"relationFields",
|
|
743
|
+
"allowedEdges",
|
|
744
|
+
"forbiddenEdges",
|
|
745
|
+
"statuses",
|
|
746
|
+
"idRanges",
|
|
747
|
+
"relationSemantics",
|
|
748
|
+
"statusViews",
|
|
749
|
+
"context",
|
|
750
|
+
"e2e"
|
|
751
|
+
]);
|
|
752
|
+
TYPE_OBJECT_KEYS = /* @__PURE__ */ new Set([
|
|
753
|
+
"paths",
|
|
754
|
+
"idPattern",
|
|
755
|
+
"displayName",
|
|
756
|
+
"role",
|
|
757
|
+
"layer",
|
|
758
|
+
"aliases",
|
|
759
|
+
"target",
|
|
760
|
+
"extraFields",
|
|
761
|
+
"format",
|
|
762
|
+
"idField"
|
|
763
|
+
]);
|
|
764
|
+
EXTRA_FIELD_KEYS = /* @__PURE__ */ new Set(["name", "type", "enum"]);
|
|
765
|
+
EDGE_RULE_KEYS = /* @__PURE__ */ new Set(["from", "to", "kind"]);
|
|
766
|
+
CONTEXT_KEYS = /* @__PURE__ */ new Set(["universal_baseline"]);
|
|
767
|
+
ID_RANGE_ENTRY_KEYS = /* @__PURE__ */ new Set(["prefix", "start", "end"]);
|
|
768
|
+
RELATION_SEMANTICS_KEYS = /* @__PURE__ */ new Set(["label", "targetTypes", "fields", "partial"]);
|
|
769
|
+
RELATION_PARTIAL_KEYS = /* @__PURE__ */ new Set(["sectionField"]);
|
|
770
|
+
E2E_KEYS = /* @__PURE__ */ new Set([
|
|
771
|
+
"executable_ref_warning",
|
|
772
|
+
"executable_ref_error",
|
|
773
|
+
"report_uncovered_scenarios",
|
|
774
|
+
"report_uncovered_features",
|
|
775
|
+
"scenario_waivers",
|
|
776
|
+
"feature_waivers",
|
|
777
|
+
"runners"
|
|
778
|
+
]);
|
|
779
|
+
WAIVER_KEYS = /* @__PURE__ */ new Set(["id", "reason"]);
|
|
780
|
+
RUNNER_KEYS = /* @__PURE__ */ new Set(["name", "kind", "root", "include", "exclude", "testIgnore"]);
|
|
781
|
+
EDGE_RULE_SCHEMA = {
|
|
782
|
+
type: "object",
|
|
783
|
+
additionalProperties: true,
|
|
784
|
+
required: ["from", "to", "kind"],
|
|
785
|
+
properties: {
|
|
786
|
+
from: { type: "string", minLength: 1 },
|
|
787
|
+
to: { type: "string", minLength: 1 },
|
|
788
|
+
kind: { type: "string", minLength: 1 }
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
EXTRA_FIELD_SCHEMA = {
|
|
792
|
+
type: "object",
|
|
793
|
+
additionalProperties: true,
|
|
794
|
+
required: ["name", "type"],
|
|
795
|
+
properties: {
|
|
796
|
+
name: { type: "string", minLength: 1 },
|
|
797
|
+
type: { type: "string", enum: ["string", "number", "boolean", "enum"] },
|
|
798
|
+
enum: {
|
|
799
|
+
type: "array",
|
|
800
|
+
items: {
|
|
801
|
+
anyOf: [
|
|
802
|
+
{ type: "string" },
|
|
803
|
+
{ type: "number" },
|
|
804
|
+
{ type: "boolean" }
|
|
805
|
+
]
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
ID_RANGE_ENTRY_SCHEMA = {
|
|
811
|
+
type: "object",
|
|
812
|
+
additionalProperties: true,
|
|
813
|
+
required: ["prefix", "start", "end"],
|
|
814
|
+
properties: {
|
|
815
|
+
prefix: { type: "string" },
|
|
816
|
+
start: { type: "number" },
|
|
817
|
+
end: { type: "number" }
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
CONFIG_SHAPE_SCHEMA = {
|
|
821
|
+
type: "object",
|
|
822
|
+
additionalProperties: true,
|
|
823
|
+
properties: {
|
|
824
|
+
statuses: { type: "array", items: { type: "string" } },
|
|
825
|
+
allowedEdges: {
|
|
826
|
+
anyOf: [
|
|
827
|
+
{ type: "null" },
|
|
828
|
+
{ type: "array", items: EDGE_RULE_SCHEMA }
|
|
829
|
+
]
|
|
830
|
+
},
|
|
831
|
+
forbiddenEdges: { type: "array", items: EDGE_RULE_SCHEMA },
|
|
832
|
+
idPatterns: {
|
|
833
|
+
type: "object",
|
|
834
|
+
additionalProperties: { type: "string" }
|
|
835
|
+
},
|
|
836
|
+
relationFields: {
|
|
837
|
+
type: "object",
|
|
838
|
+
additionalProperties: { type: "array", items: { type: "string" } }
|
|
839
|
+
},
|
|
840
|
+
context: {
|
|
841
|
+
type: "object",
|
|
842
|
+
additionalProperties: true,
|
|
843
|
+
properties: {
|
|
844
|
+
universal_baseline: { type: "boolean" }
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
idRanges: {
|
|
848
|
+
type: "object",
|
|
849
|
+
additionalProperties: {
|
|
850
|
+
type: "object",
|
|
851
|
+
additionalProperties: ID_RANGE_ENTRY_SCHEMA
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
types: {
|
|
855
|
+
type: "object",
|
|
856
|
+
additionalProperties: {
|
|
857
|
+
type: "object",
|
|
858
|
+
additionalProperties: true,
|
|
859
|
+
properties: {
|
|
860
|
+
paths: { type: "array", items: { type: "string" } },
|
|
861
|
+
idPattern: { type: "string" },
|
|
862
|
+
displayName: { type: "string" },
|
|
863
|
+
role: { type: "string" },
|
|
864
|
+
layer: { type: "string" },
|
|
865
|
+
aliases: { type: "array", items: { type: "string" } },
|
|
866
|
+
target: { type: "boolean" },
|
|
867
|
+
extraFields: { type: "array", items: EXTRA_FIELD_SCHEMA }
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
ALLOWED_EDGES_REQUIRED_MESSAGE = "Invalid allowedEdges: field is required. Use allowedEdges: [] or allowedEdges: null to adopt the built-in DEFAULT_SCHEMA.allowedEdges, or list explicit {from, to, kind} triples as a strict whitelist that replaces the default table.";
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
|
|
373
877
|
// src/target-selector.ts
|
|
374
878
|
function parseTargetSelector(value) {
|
|
375
879
|
const separator = value.indexOf(":");
|
|
@@ -502,8 +1006,8 @@ var init_git_changes = __esm({
|
|
|
502
1006
|
// src/versioned-traceability.ts
|
|
503
1007
|
import { createHash } from "crypto";
|
|
504
1008
|
import { existsSync } from "fs";
|
|
505
|
-
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
506
|
-
import { dirname, join as
|
|
1009
|
+
import { mkdir, readFile as readFile2, writeFile } from "fs/promises";
|
|
1010
|
+
import { dirname, join as join3, relative as relative2 } from "path";
|
|
507
1011
|
async function buildVersionIndex(root, graph) {
|
|
508
1012
|
const scannedGraph = graph ?? await scanArtifacts(root);
|
|
509
1013
|
const hashCache = /* @__PURE__ */ new Map();
|
|
@@ -639,7 +1143,7 @@ async function auditVersionLock(root, lockPath = VERSION_LOCK_PATH, graph, confi
|
|
|
639
1143
|
for (const entry of lock.locks) {
|
|
640
1144
|
if (entry.kind !== "verifies") continue;
|
|
641
1145
|
const sourcePath = entry.source.path;
|
|
642
|
-
const fullSourcePath =
|
|
1146
|
+
const fullSourcePath = join3(root, sourcePath);
|
|
643
1147
|
if (!existsSync(fullSourcePath)) continue;
|
|
644
1148
|
let liveness = livenessCache.get(sourcePath);
|
|
645
1149
|
if (liveness === void 0) {
|
|
@@ -734,14 +1238,14 @@ async function auditVersionLock(root, lockPath = VERSION_LOCK_PATH, graph, confi
|
|
|
734
1238
|
currentArtifactHash: targetNode.contentHash
|
|
735
1239
|
});
|
|
736
1240
|
}
|
|
737
|
-
if (!existsSync(
|
|
1241
|
+
if (!existsSync(join3(root, sourceNode.path))) {
|
|
738
1242
|
entryIssues.push({
|
|
739
1243
|
status: "orphan_lock",
|
|
740
1244
|
edgeId: relEdgeId,
|
|
741
1245
|
message: `Artifact relation source file ${sourceNode.path} no longer exists`
|
|
742
1246
|
});
|
|
743
1247
|
}
|
|
744
|
-
if (!existsSync(
|
|
1248
|
+
if (!existsSync(join3(root, targetNode.path))) {
|
|
745
1249
|
entryIssues.push({
|
|
746
1250
|
status: "orphan_lock",
|
|
747
1251
|
edgeId: relEdgeId,
|
|
@@ -1348,7 +1852,7 @@ function renderTraceVersionMarkdown(result) {
|
|
|
1348
1852
|
async function readVersionLock(root, lockPath) {
|
|
1349
1853
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1350
1854
|
try {
|
|
1351
|
-
const raw = await
|
|
1855
|
+
const raw = await readFile2(join3(root, safeLockPath), "utf-8");
|
|
1352
1856
|
let parsed;
|
|
1353
1857
|
try {
|
|
1354
1858
|
parsed = JSON.parse(raw);
|
|
@@ -1507,7 +2011,7 @@ function requireSafeRelativePath(value, path) {
|
|
|
1507
2011
|
}
|
|
1508
2012
|
async function writeVersionLock(root, lockPath, lock) {
|
|
1509
2013
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1510
|
-
const fullPath =
|
|
2014
|
+
const fullPath = join3(root, safeLockPath);
|
|
1511
2015
|
await mkdir(dirname(fullPath), { recursive: true });
|
|
1512
2016
|
await writeFile(fullPath, `${JSON.stringify(lock, null, 2)}
|
|
1513
2017
|
`);
|
|
@@ -1690,7 +2194,7 @@ async function hashRelativePath(root, path, cache) {
|
|
|
1690
2194
|
const normalized = normalizeRelativePath(root, path);
|
|
1691
2195
|
const cached = cache.get(normalized);
|
|
1692
2196
|
if (cached) return cached;
|
|
1693
|
-
const content = await
|
|
2197
|
+
const content = await readFile2(join3(root, normalized));
|
|
1694
2198
|
const hash = `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
1695
2199
|
cache.set(normalized, hash);
|
|
1696
2200
|
return hash;
|
|
@@ -1713,10 +2217,10 @@ async function getTestFileRunnerLiveness(root, filePath, config) {
|
|
|
1713
2217
|
if (!/e2e/i.test(filePath) && !/\.e2e\./i.test(filePath)) {
|
|
1714
2218
|
return "active";
|
|
1715
2219
|
}
|
|
1716
|
-
const fullSourcePath =
|
|
2220
|
+
const fullSourcePath = join3(root, filePath);
|
|
1717
2221
|
if (!existsSync(fullSourcePath)) return "inactive";
|
|
1718
2222
|
try {
|
|
1719
|
-
const content = await
|
|
2223
|
+
const content = await readFile2(fullSourcePath, "utf-8");
|
|
1720
2224
|
return /\/\/!?\s*@(?:e2e_test|tc)\s+/.test(content) ? "active" : "inactive";
|
|
1721
2225
|
} catch {
|
|
1722
2226
|
return "inactive";
|
|
@@ -1779,7 +2283,7 @@ var init_versioned_traceability = __esm({
|
|
|
1779
2283
|
});
|
|
1780
2284
|
|
|
1781
2285
|
// src/impact.ts
|
|
1782
|
-
import { isAbsolute, normalize, relative as relative3, resolve } from "path";
|
|
2286
|
+
import { isAbsolute as isAbsolute2, normalize, relative as relative3, resolve } from "path";
|
|
1783
2287
|
async function computeImpact(root, options = {}) {
|
|
1784
2288
|
const absoluteRoot = resolve(root);
|
|
1785
2289
|
const mode = options.mode ?? "worktree";
|
|
@@ -1853,7 +2357,7 @@ function normalizeExplicitPaths(root, paths) {
|
|
|
1853
2357
|
const normalized = paths.map((input) => {
|
|
1854
2358
|
const value = input.trim();
|
|
1855
2359
|
if (!value) return "";
|
|
1856
|
-
const absolutePath =
|
|
2360
|
+
const absolutePath = isAbsolute2(value) ? normalize(value) : resolve(root, value);
|
|
1857
2361
|
const projectRelative = relative3(root, absolutePath);
|
|
1858
2362
|
const result = projectRelative.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1859
2363
|
if (result === ".." || result.startsWith("../") || result.startsWith("/")) {
|
|
@@ -2472,7 +2976,7 @@ var init_packet_assembler = __esm({
|
|
|
2472
2976
|
|
|
2473
2977
|
// src/packet-audit.ts
|
|
2474
2978
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
2475
|
-
import { join as
|
|
2979
|
+
import { join as join4 } from "path";
|
|
2476
2980
|
function parseTargetsFile(content, schema) {
|
|
2477
2981
|
const validTypes = schema ? new Set(getTargetArtifactTypes(schema)) : VALID_TYPES;
|
|
2478
2982
|
const validTypesLabel = [...validTypes].join(", ");
|
|
@@ -2563,7 +3067,7 @@ async function auditSingleTarget(target, graph, options) {
|
|
|
2563
3067
|
const fmt = options.format ?? "markdown";
|
|
2564
3068
|
const ext = fmt === "json" ? "json" : "md";
|
|
2565
3069
|
const filename = `${target.type}-${target.id}.packet.${ext}`;
|
|
2566
|
-
const outPath =
|
|
3070
|
+
const outPath = join4(options.outDir, filename);
|
|
2567
3071
|
let content;
|
|
2568
3072
|
if (fmt === "json") {
|
|
2569
3073
|
content = JSON.stringify(packet, null, 2) + "\n";
|
|
@@ -2643,7 +3147,7 @@ async function auditPackets(root, targets, options, graph) {
|
|
|
2643
3147
|
...isCompact ? { summaryDetail: "compact", countsByType } : {}
|
|
2644
3148
|
};
|
|
2645
3149
|
if (options.outDir) {
|
|
2646
|
-
const summaryPath =
|
|
3150
|
+
const summaryPath = join4(options.outDir, "summary.json");
|
|
2647
3151
|
await writeFile2(summaryPath, JSON.stringify(summary, null, 2) + "\n", "utf-8");
|
|
2648
3152
|
}
|
|
2649
3153
|
return summary;
|
|
@@ -3014,7 +3518,7 @@ var init_packet_prompt_validator = __esm({
|
|
|
3014
3518
|
// src/native-binding-diagnostics.ts
|
|
3015
3519
|
import { existsSync as existsSync2, readdirSync } from "fs";
|
|
3016
3520
|
import { createRequire } from "module";
|
|
3017
|
-
import { dirname as dirname2, join as
|
|
3521
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
3018
3522
|
import { fileURLToPath } from "url";
|
|
3019
3523
|
function parsePnpmVersion(stdout) {
|
|
3020
3524
|
const trimmed = stdout.trim();
|
|
@@ -3155,7 +3659,7 @@ function buildNativeBindingSuccessDiagnostic(probeContext) {
|
|
|
3155
3659
|
function findPackageRoot(anchorFile) {
|
|
3156
3660
|
let dir = dirname2(anchorFile);
|
|
3157
3661
|
for (; ; ) {
|
|
3158
|
-
if (existsSync2(
|
|
3662
|
+
if (existsSync2(join5(dir, "package.json"))) return dir;
|
|
3159
3663
|
const parent = dirname2(dir);
|
|
3160
3664
|
if (parent === dir) return void 0;
|
|
3161
3665
|
dir = parent;
|
|
@@ -3172,9 +3676,9 @@ function abiPrebuiltHint(detail) {
|
|
|
3172
3676
|
return match ? `\uFF1Bprebuilt \u76EE\u6807 NODE_MODULE_VERSION=${match[1]}` : "";
|
|
3173
3677
|
}
|
|
3174
3678
|
function betterSqlite3PackagePresent(root) {
|
|
3175
|
-
const direct =
|
|
3679
|
+
const direct = join5(root, "node_modules", "better-sqlite3", "package.json");
|
|
3176
3680
|
if (existsSync2(direct)) return true;
|
|
3177
|
-
const pnpmDir =
|
|
3681
|
+
const pnpmDir = join5(root, "node_modules", ".pnpm");
|
|
3178
3682
|
let entries;
|
|
3179
3683
|
try {
|
|
3180
3684
|
entries = readdirSync(pnpmDir);
|
|
@@ -3183,7 +3687,7 @@ function betterSqlite3PackagePresent(root) {
|
|
|
3183
3687
|
}
|
|
3184
3688
|
return entries.some((entry) => {
|
|
3185
3689
|
if (!entry.startsWith("better-sqlite3@")) return false;
|
|
3186
|
-
return existsSync2(
|
|
3690
|
+
return existsSync2(join5(pnpmDir, entry, "node_modules", "better-sqlite3", "package.json"));
|
|
3187
3691
|
});
|
|
3188
3692
|
}
|
|
3189
3693
|
var PNPM_ALLOW_BUILDS_SNIPPET;
|
|
@@ -3198,7 +3702,7 @@ var init_native_binding_diagnostics = __esm({
|
|
|
3198
3702
|
import { execFile as execFile2 } from "child_process";
|
|
3199
3703
|
import { constants, readFileSync, realpathSync } from "fs";
|
|
3200
3704
|
import { access } from "fs/promises";
|
|
3201
|
-
import { basename, dirname as dirname3, isAbsolute as
|
|
3705
|
+
import { basename, dirname as dirname3, isAbsolute as isAbsolute3, join as join6, resolve as resolve3 } from "path";
|
|
3202
3706
|
import { promisify as promisify2 } from "util";
|
|
3203
3707
|
async function resolveArtifactGraphCli(root, options = {}) {
|
|
3204
3708
|
const pathCli = await findCommandOnPath("artifact-graph");
|
|
@@ -3206,7 +3710,7 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3206
3710
|
const candidates = [
|
|
3207
3711
|
{
|
|
3208
3712
|
source: "node_modules",
|
|
3209
|
-
path:
|
|
3713
|
+
path: join6(root, "node_modules/.bin/artifact-graph"),
|
|
3210
3714
|
exists: false
|
|
3211
3715
|
},
|
|
3212
3716
|
{
|
|
@@ -3239,8 +3743,8 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3239
3743
|
}
|
|
3240
3744
|
async function doctorArtifactChain(root, options = {}) {
|
|
3241
3745
|
const cli = await resolveArtifactGraphCli(root, options);
|
|
3242
|
-
const configPath =
|
|
3243
|
-
const lockPath =
|
|
3746
|
+
const configPath = join6(root, "artifact-graph.config.yaml");
|
|
3747
|
+
const lockPath = join6(root, VERSION_LOCK_PATH);
|
|
3244
3748
|
const supportedCommands = cli.path ? await detectSupportedCommands(cli.path) : [];
|
|
3245
3749
|
const nodeCompatible = isNodeCompatible(process.versions.node);
|
|
3246
3750
|
const pnpmVersion = await detectPnpmVersion();
|
|
@@ -3260,12 +3764,28 @@ async function doctorArtifactChain(root, options = {}) {
|
|
|
3260
3764
|
probedFrom
|
|
3261
3765
|
};
|
|
3262
3766
|
const nativeBinding = probe.ok ? { ok: true, ...buildNativeBindingSuccessDiagnostic(probeContext) } : { ok: false, ...buildNativeBindingDiagnostic(probe, probeContext) };
|
|
3767
|
+
const configDiagnosis = await diagnoseProjectConfig(root);
|
|
3768
|
+
const configShapeMessages = [
|
|
3769
|
+
...configDiagnosis.errors.map((item) => item.message),
|
|
3770
|
+
...configDiagnosis.warnings.map((item) => item.message)
|
|
3771
|
+
];
|
|
3772
|
+
const loadConfigMessages = [];
|
|
3773
|
+
if (configDiagnosis.exists && configDiagnosis.errors.length === 0) {
|
|
3774
|
+
try {
|
|
3775
|
+
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_index(), index_exports));
|
|
3776
|
+
await loadConfig2(root);
|
|
3777
|
+
} catch (error) {
|
|
3778
|
+
loadConfigMessages.push(error.message);
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3263
3781
|
const warnings = [
|
|
3264
3782
|
...cli.warnings,
|
|
3265
3783
|
...nodeCompatible ? [] : [`Node.js ${process.versions.node} does not satisfy ${REQUIRED_NODE_VERSION}.`],
|
|
3266
3784
|
...probe.ok ? [] : [
|
|
3267
3785
|
`better-sqlite3 binding probe FAILED at stage "${probe.failedStage}" (cause ${probe.cause}): ${probe.suggestion}`
|
|
3268
|
-
]
|
|
3786
|
+
],
|
|
3787
|
+
...configShapeMessages,
|
|
3788
|
+
...loadConfigMessages
|
|
3269
3789
|
];
|
|
3270
3790
|
return {
|
|
3271
3791
|
schemaVersion: "1.0",
|
|
@@ -3375,7 +3895,7 @@ async function findCommandOnPath(command) {
|
|
|
3375
3895
|
}
|
|
3376
3896
|
}
|
|
3377
3897
|
function resolveCandidatePath(root, candidatePath) {
|
|
3378
|
-
return
|
|
3898
|
+
return isAbsolute3(candidatePath) ? candidatePath : resolve3(root, candidatePath);
|
|
3379
3899
|
}
|
|
3380
3900
|
function isNodeCompatible(version) {
|
|
3381
3901
|
const match = /^(\d+)\.(\d+)\.(\d+)(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
@@ -3445,6 +3965,7 @@ var init_cli_resolver = __esm({
|
|
|
3445
3965
|
"src/cli-resolver.ts"() {
|
|
3446
3966
|
"use strict";
|
|
3447
3967
|
init_versioned_traceability();
|
|
3968
|
+
init_doctor();
|
|
3448
3969
|
init_native_binding_diagnostics();
|
|
3449
3970
|
execFileAsync2 = promisify2(execFile2);
|
|
3450
3971
|
REQUIRED_NODE_VERSION = ">=22.22.2 <23";
|
|
@@ -3476,7 +3997,7 @@ var init_cli_resolver = __esm({
|
|
|
3476
3997
|
|
|
3477
3998
|
// src/git-hook-path.ts
|
|
3478
3999
|
import { execFile as execFile3 } from "child_process";
|
|
3479
|
-
import { isAbsolute as
|
|
4000
|
+
import { isAbsolute as isAbsolute4, resolve as resolve4 } from "path";
|
|
3480
4001
|
import { promisify as promisify3 } from "util";
|
|
3481
4002
|
async function resolveGitHookPath(root, hookName) {
|
|
3482
4003
|
const { stdout } = await execFileAsync3("git", [
|
|
@@ -3488,7 +4009,7 @@ async function resolveGitHookPath(root, hookName) {
|
|
|
3488
4009
|
]);
|
|
3489
4010
|
const value = stdout.trim();
|
|
3490
4011
|
if (!value) throw new Error(`Git returned an empty hook path for ${hookName}`);
|
|
3491
|
-
return
|
|
4012
|
+
return isAbsolute4(value) ? resolve4(value) : resolve4(root, value);
|
|
3492
4013
|
}
|
|
3493
4014
|
var execFileAsync3;
|
|
3494
4015
|
var init_git_hook_path = __esm({
|
|
@@ -3502,7 +4023,7 @@ var init_git_hook_path = __esm({
|
|
|
3502
4023
|
import { constants as constants2 } from "fs";
|
|
3503
4024
|
import { randomUUID } from "crypto";
|
|
3504
4025
|
import { lstat, mkdir as mkdir3, open, readlink, rename, unlink } from "fs/promises";
|
|
3505
|
-
import { basename as basename2, dirname as dirname4, join as
|
|
4026
|
+
import { basename as basename2, dirname as dirname4, join as join7 } from "path";
|
|
3506
4027
|
function detectHookInterpreter(content) {
|
|
3507
4028
|
if (content.trim().length === 0) {
|
|
3508
4029
|
return "empty";
|
|
@@ -3814,7 +4335,7 @@ async function removeHookAtomically(hookPath, snapshot) {
|
|
|
3814
4335
|
}
|
|
3815
4336
|
async function writeHookAtomically(hookPath, content, snapshot, mode) {
|
|
3816
4337
|
await mkdir3(dirname4(hookPath), { recursive: true });
|
|
3817
|
-
const temporaryPath =
|
|
4338
|
+
const temporaryPath = join7(dirname4(hookPath), `.${basename2(hookPath)}.${randomUUID()}.tmp`);
|
|
3818
4339
|
let temporaryExists = false;
|
|
3819
4340
|
try {
|
|
3820
4341
|
const temporary = await open(temporaryPath, "wx", mode);
|
|
@@ -3932,7 +4453,7 @@ var init_hook_installer = __esm({
|
|
|
3932
4453
|
// src/professional-conclusion.ts
|
|
3933
4454
|
import { access as access2 } from "fs/promises";
|
|
3934
4455
|
import { createRequire as createRequire2 } from "module";
|
|
3935
|
-
import { basename as basename3, dirname as dirname5, isAbsolute as
|
|
4456
|
+
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute5, join as join8, resolve as resolve5 } from "path";
|
|
3936
4457
|
import { pathToFileURL } from "url";
|
|
3937
4458
|
async function loadContracts() {
|
|
3938
4459
|
return await import(CONTRACTS_PACKAGE_NAME);
|
|
@@ -3959,7 +4480,7 @@ function harnessKind(error) {
|
|
|
3959
4480
|
return typeof details?.kind === "string" ? details.kind : void 0;
|
|
3960
4481
|
}
|
|
3961
4482
|
async function missingRequiredConfig(root) {
|
|
3962
|
-
const configPath =
|
|
4483
|
+
const configPath = join8(root, "artifact-graph.config.yaml");
|
|
3963
4484
|
try {
|
|
3964
4485
|
await access2(configPath);
|
|
3965
4486
|
return void 0;
|
|
@@ -4132,7 +4653,7 @@ async function assertConclusionShape(conclusion) {
|
|
|
4132
4653
|
}
|
|
4133
4654
|
}
|
|
4134
4655
|
async function publishConclusion(absoluteOutput, conclusion) {
|
|
4135
|
-
if (!
|
|
4656
|
+
if (!isAbsolute5(absoluteOutput)) {
|
|
4136
4657
|
return "--conclusion-output must be an absolute path";
|
|
4137
4658
|
}
|
|
4138
4659
|
const outputRoot = dirname5(absoluteOutput);
|
|
@@ -4170,7 +4691,7 @@ async function runCheckProfessional(options) {
|
|
|
4170
4691
|
if (options.conclusionOutput === void 0) {
|
|
4171
4692
|
return { conclusion };
|
|
4172
4693
|
}
|
|
4173
|
-
if (!
|
|
4694
|
+
if (!isAbsolute5(options.conclusionOutput)) {
|
|
4174
4695
|
return { conclusion, writeError: "--conclusion-output must be an absolute path" };
|
|
4175
4696
|
}
|
|
4176
4697
|
const writeError = await publishConclusion(resolve5(options.conclusionOutput), conclusion);
|
|
@@ -4624,9 +5145,9 @@ var init_review_result_validator = __esm({
|
|
|
4624
5145
|
|
|
4625
5146
|
// src/contract-kernel.ts
|
|
4626
5147
|
import { createHash as createHash2 } from "crypto";
|
|
4627
|
-
import { readFile as
|
|
4628
|
-
import { join as
|
|
4629
|
-
import
|
|
5148
|
+
import { readFile as readFile3, readdir as readdir2 } from "fs/promises";
|
|
5149
|
+
import { join as join9 } from "path";
|
|
5150
|
+
import _AjvModule2 from "ajv";
|
|
4630
5151
|
function isOfficialNamespace(namespace) {
|
|
4631
5152
|
return OFFICIAL_NAMESPACE_PATTERN.test(namespace);
|
|
4632
5153
|
}
|
|
@@ -4906,7 +5427,7 @@ function validatePolicyCompatibility(policy, baseContract) {
|
|
|
4906
5427
|
};
|
|
4907
5428
|
}
|
|
4908
5429
|
async function loadContract(contractPath, options) {
|
|
4909
|
-
const rawContent = await
|
|
5430
|
+
const rawContent = await readFile3(contractPath, "utf-8");
|
|
4910
5431
|
let schema;
|
|
4911
5432
|
try {
|
|
4912
5433
|
schema = JSON.parse(rawContent);
|
|
@@ -4957,7 +5478,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
4957
5478
|
const entries = await readdir2(contractsDir, { withFileTypes: true });
|
|
4958
5479
|
for (const entry of entries) {
|
|
4959
5480
|
if (entry.isDirectory()) {
|
|
4960
|
-
const schemaPath =
|
|
5481
|
+
const schemaPath = join9(contractsDir, entry.name, "schema.json");
|
|
4961
5482
|
const contract = await loadContract(schemaPath, options);
|
|
4962
5483
|
contracts.push(contract);
|
|
4963
5484
|
}
|
|
@@ -4967,7 +5488,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
4967
5488
|
function getValidator(schema) {
|
|
4968
5489
|
const key = `${schema.$id || "default"}#${computeRevisionDigest(JSON.stringify(schema))}`;
|
|
4969
5490
|
if (!_validatorCache.has(key)) {
|
|
4970
|
-
const AjvCtor =
|
|
5491
|
+
const AjvCtor = _AjvModule2;
|
|
4971
5492
|
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
4972
5493
|
_validatorCache.set(key, ajv.compile(schema));
|
|
4973
5494
|
}
|
|
@@ -5502,7 +6023,7 @@ var init_restructure_software = __esm({
|
|
|
5502
6023
|
// src/restructure-file-set.ts
|
|
5503
6024
|
import { createHash as createHash3 } from "crypto";
|
|
5504
6025
|
import { chmod, lstat as lstat2, mkdir as mkdir4, realpath, statfs } from "fs/promises";
|
|
5505
|
-
import { join as
|
|
6026
|
+
import { join as join10, resolve as resolve6 } from "path";
|
|
5506
6027
|
async function loadFoundationModule() {
|
|
5507
6028
|
return await import(FOUNDATION_PACKAGE_NAME);
|
|
5508
6029
|
}
|
|
@@ -5599,7 +6120,7 @@ async function qualifyRestructureMechanism(root) {
|
|
|
5599
6120
|
return { ok: true, data: { root: canonical.data, filesystem: RESTRUCTURE_QUALIFIED_FILESYSTEM } };
|
|
5600
6121
|
}
|
|
5601
6122
|
async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
5602
|
-
const target =
|
|
6123
|
+
const target = join10(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
|
|
5603
6124
|
const current = async () => lstat2(target).catch((cause) => cause.code === "ENOENT" ? null : Promise.reject(cause));
|
|
5604
6125
|
let info = await current();
|
|
5605
6126
|
if (info === null) {
|
|
@@ -5713,7 +6234,7 @@ async function applyRestructureFileSet(canonicalRoot, plan, options) {
|
|
|
5713
6234
|
return await verifyMechanismResult(raw);
|
|
5714
6235
|
}
|
|
5715
6236
|
async function observeRestructureJournal(canonicalRoot) {
|
|
5716
|
-
const journalRoot =
|
|
6237
|
+
const journalRoot = join10(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
|
|
5717
6238
|
const module = await loadFoundationModule();
|
|
5718
6239
|
try {
|
|
5719
6240
|
return { ok: true, data: await module.inspectStateStoreLock(journalRoot, { recoveryObservation: true }) };
|
|
@@ -5922,8 +6443,8 @@ var init_restructure_file_set = __esm({
|
|
|
5922
6443
|
|
|
5923
6444
|
// src/restructure.ts
|
|
5924
6445
|
import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
5925
|
-
import { lstat as lstat3, readFile as
|
|
5926
|
-
import { dirname as dirname6, isAbsolute as
|
|
6446
|
+
import { lstat as lstat3, readFile as readFile4, readdir as readdir3, realpath as realpath2, stat } from "fs/promises";
|
|
6447
|
+
import { dirname as dirname6, isAbsolute as isAbsolute6, join as join11, posix, relative as relative4, resolve as resolve7 } from "path";
|
|
5927
6448
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5928
6449
|
function digestBytes(value) {
|
|
5929
6450
|
return `sha256:${createHash4("sha256").update(value).digest("hex")}`;
|
|
@@ -5939,7 +6460,7 @@ function digestRestructureValue(value) {
|
|
|
5939
6460
|
return digestBytes(canonicalJson(value));
|
|
5940
6461
|
}
|
|
5941
6462
|
function normalizeRelativePath2(value) {
|
|
5942
|
-
if (!value || value.includes("\0") ||
|
|
6463
|
+
if (!value || value.includes("\0") || isAbsolute6(value)) return void 0;
|
|
5943
6464
|
const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
5944
6465
|
if (!normalized || normalized === "." || normalized.split("/").some((part) => part === ".." || part === "")) return void 0;
|
|
5945
6466
|
return normalized;
|
|
@@ -5959,7 +6480,7 @@ async function readContainedFileWithMode(root, path) {
|
|
|
5959
6480
|
try {
|
|
5960
6481
|
const info = await lstat3(absolutePath);
|
|
5961
6482
|
if (info.isSymbolicLink() || !info.isFile()) throw new Error(`Path is not a regular file: ${path}`);
|
|
5962
|
-
return { buffer: await
|
|
6483
|
+
return { buffer: await readFile4(absolutePath), mode: info.mode & MAX_POSIX_MODE };
|
|
5963
6484
|
} catch (error) {
|
|
5964
6485
|
if (error.code === "ENOENT") return void 0;
|
|
5965
6486
|
throw error;
|
|
@@ -5987,7 +6508,7 @@ async function configSnapshot(root) {
|
|
|
5987
6508
|
return snapshotFile(root, "artifact-graph.config.yaml");
|
|
5988
6509
|
}
|
|
5989
6510
|
async function loadRestructureContract(name) {
|
|
5990
|
-
return loadContract(
|
|
6511
|
+
return loadContract(join11(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
|
|
5991
6512
|
}
|
|
5992
6513
|
async function validateDomainContract(name, value) {
|
|
5993
6514
|
const contract = await loadRestructureContract(name);
|
|
@@ -6262,14 +6783,14 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6262
6783
|
async function visit(directory) {
|
|
6263
6784
|
for (const entry of await readdir3(directory, { withFileTypes: true })) {
|
|
6264
6785
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6265
|
-
const absolute =
|
|
6786
|
+
const absolute = join11(directory, entry.name);
|
|
6266
6787
|
if (entry.isDirectory()) {
|
|
6267
6788
|
await visit(absolute);
|
|
6268
6789
|
continue;
|
|
6269
6790
|
}
|
|
6270
6791
|
if (!entry.isFile() || !TEXT_EXTENSIONS.test(entry.name)) continue;
|
|
6271
6792
|
const path = relative4(root, absolute).replace(/\\/g, "/");
|
|
6272
|
-
const raw = await
|
|
6793
|
+
const raw = await readFile4(absolute, "utf8");
|
|
6273
6794
|
const namesTheMigration = migrationPaths.some((reference) => raw.includes(reference));
|
|
6274
6795
|
const lines = raw.split(/\r?\n/);
|
|
6275
6796
|
for (const [index, line] of lines.entries()) {
|
|
@@ -6334,13 +6855,13 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
|
|
|
6334
6855
|
async function visit(directory) {
|
|
6335
6856
|
for (const entry of await readdir3(directory, { withFileTypes: true })) {
|
|
6336
6857
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6337
|
-
const absolute =
|
|
6858
|
+
const absolute = join11(directory, entry.name);
|
|
6338
6859
|
if (entry.isDirectory()) {
|
|
6339
6860
|
await visit(absolute);
|
|
6340
6861
|
} else if (entry.isFile() && TEXT_EXTENSIONS.test(entry.name)) {
|
|
6341
6862
|
const path = relative4(root, absolute).replace(/\\/g, "/");
|
|
6342
6863
|
if (excludedPaths.has(path)) continue;
|
|
6343
|
-
const raw = await
|
|
6864
|
+
const raw = await readFile4(absolute, "utf8");
|
|
6344
6865
|
raw.split(/\r?\n/).forEach((line, index) => {
|
|
6345
6866
|
for (const reference of references) {
|
|
6346
6867
|
if (path !== reference && line.includes(reference)) results.push({ path, line: index + 1, reference });
|
|
@@ -6843,7 +7364,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
|
6843
7364
|
}
|
|
6844
7365
|
let bytes;
|
|
6845
7366
|
try {
|
|
6846
|
-
bytes = await
|
|
7367
|
+
bytes = await readFile4(absolute);
|
|
6847
7368
|
} catch (cause) {
|
|
6848
7369
|
return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
|
|
6849
7370
|
}
|
|
@@ -6875,7 +7396,7 @@ function planRootIdentityFindings(document) {
|
|
|
6875
7396
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan does not record this project's configuration file: ${document.plan.config_snapshot.path}`));
|
|
6876
7397
|
}
|
|
6877
7398
|
const relativePlan = relative4(document.root, document.realPath);
|
|
6878
|
-
if (!relativePlan || relativePlan.startsWith("..") ||
|
|
7399
|
+
if (!relativePlan || relativePlan.startsWith("..") || isAbsolute6(relativePlan)) {
|
|
6879
7400
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan document is outside the project root: ${document.realPath}`, document.realPath));
|
|
6880
7401
|
}
|
|
6881
7402
|
return findings;
|
|
@@ -7066,7 +7587,7 @@ var init_restructure = __esm({
|
|
|
7066
7587
|
MAX_POSIX_MODE = 511;
|
|
7067
7588
|
CREATE_MODE_BASE = 438;
|
|
7068
7589
|
MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : dirname6(fileURLToPath2(import.meta.url));
|
|
7069
|
-
CONTRACT_ROOT =
|
|
7590
|
+
CONTRACT_ROOT = join11(MODULE_DIRECTORY, "..", "contracts");
|
|
7070
7591
|
SKIPPED_SCAN_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "dist", "coverage", ".tmp", ".codex", ".worktrees", ".foundation-file-apply", ".artifact-graph"]);
|
|
7071
7592
|
TEXT_EXTENSIONS = /\.(?:md|markdown|json|ya?ml|[cm]?[jt]sx?)$/i;
|
|
7072
7593
|
MARKDOWN_LINK_PATTERN = /!?\[([^\]\n]*)\]\(([^)\n]+)\)/g;
|
|
@@ -7077,11 +7598,176 @@ var init_restructure = __esm({
|
|
|
7077
7598
|
});
|
|
7078
7599
|
|
|
7079
7600
|
// src/index.ts
|
|
7601
|
+
var index_exports = {};
|
|
7602
|
+
__export(index_exports, {
|
|
7603
|
+
ALWAYS_PRESENT: () => ALWAYS_PRESENT_ITEMS,
|
|
7604
|
+
BASELINE_CONSTRAINTS: () => BASELINE_CONSTRAINTS,
|
|
7605
|
+
BASELINE_CONSTRAINTS_COUNT: () => BASELINE_CONSTRAINTS_COUNT,
|
|
7606
|
+
BASELINE_ITEMS_COUNT: () => BASELINE_ITEMS_COUNT,
|
|
7607
|
+
CONTRACTS_PACKAGE_NAME: () => CONTRACTS_PACKAGE_NAME2,
|
|
7608
|
+
CONTRACT_ERROR_CODES: () => CONTRACT_ERROR_CODES,
|
|
7609
|
+
ContractCatalog: () => ContractCatalog,
|
|
7610
|
+
ContractError: () => ContractError,
|
|
7611
|
+
ContractRegistry: () => ContractRegistry,
|
|
7612
|
+
DEFAULT_MAX_CHARS: () => DEFAULT_MAX_CHARS,
|
|
7613
|
+
DEFAULT_SCHEMA: () => DEFAULT_SCHEMA,
|
|
7614
|
+
E2E_NORMALIZER_CONFIG: () => E2E_NORMALIZER_CONFIG,
|
|
7615
|
+
FILE_SET_RESULT_OBJECT: () => FILE_SET_RESULT_OBJECT,
|
|
7616
|
+
FOUNDATION_PACKAGE_NAME: () => FOUNDATION_PACKAGE_NAME,
|
|
7617
|
+
GRAPH_DOMAIN_CODES: () => GRAPH_DOMAIN_CODES,
|
|
7618
|
+
GRAPH_PROVIDER_ENTRY: () => GRAPH_PROVIDER_ENTRY,
|
|
7619
|
+
GRAPH_PROVIDER_ID: () => GRAPH_PROVIDER_ID,
|
|
7620
|
+
MIN_PROMPT_CHARS: () => MIN_PROMPT_CHARS,
|
|
7621
|
+
PROFESSIONAL_CONCLUSION_OBJECT: () => PROFESSIONAL_CONCLUSION_OBJECT,
|
|
7622
|
+
RESTRUCTURE_MAX_OPERATIONS: () => RESTRUCTURE_MAX_OPERATIONS,
|
|
7623
|
+
RESTRUCTURE_MAX_TOTAL_BYTES: () => RESTRUCTURE_MAX_TOTAL_BYTES,
|
|
7624
|
+
RESTRUCTURE_PLAN_SCHEMA_VERSION: () => RESTRUCTURE_PLAN_SCHEMA_VERSION,
|
|
7625
|
+
RESTRUCTURE_QUALIFIED_ARCH: () => RESTRUCTURE_QUALIFIED_ARCH,
|
|
7626
|
+
RESTRUCTURE_QUALIFIED_FILESYSTEM: () => RESTRUCTURE_QUALIFIED_FILESYSTEM,
|
|
7627
|
+
RESTRUCTURE_QUALIFIED_PLATFORM: () => RESTRUCTURE_QUALIFIED_PLATFORM,
|
|
7628
|
+
RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH: () => RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH,
|
|
7629
|
+
RESTRUCTURE_RECOVERY_REL_PATH: () => RESTRUCTURE_RECOVERY_REL_PATH,
|
|
7630
|
+
RESTRUCTURE_RECOVERY_ROOT_MODE: () => RESTRUCTURE_RECOVERY_ROOT_MODE,
|
|
7631
|
+
RESTRUCTURE_VALIDATION_TIMEOUT_MS: () => RESTRUCTURE_VALIDATION_TIMEOUT_MS,
|
|
7632
|
+
TARGET_ARTIFACT_TYPES: () => TARGET_ARTIFACT_TYPES,
|
|
7633
|
+
VALID_PACKET_TARGET_TYPES: () => VALID_PACKET_TARGET_TYPES,
|
|
7634
|
+
VERSION_INDEX_SCHEMA_VERSION: () => VERSION_INDEX_SCHEMA_VERSION,
|
|
7635
|
+
VERSION_LOCK_PATH: () => VERSION_LOCK_PATH,
|
|
7636
|
+
VERSION_LOCK_SCHEMA_VERSION: () => VERSION_LOCK_SCHEMA_VERSION,
|
|
7637
|
+
applyPreparedManagedHookBlocks: () => applyPreparedManagedHookBlocks,
|
|
7638
|
+
applyRestructure: () => applyRestructure,
|
|
7639
|
+
applyRestructureFileSet: () => applyRestructureFileSet,
|
|
7640
|
+
assemblePacket: () => assemblePacket,
|
|
7641
|
+
auditPackets: () => auditPackets,
|
|
7642
|
+
auditVersionLock: () => auditVersionLock,
|
|
7643
|
+
bootstrapVersionLock: () => bootstrapVersionLock,
|
|
7644
|
+
buildFileSetApplyRequest: () => buildFileSetApplyRequest,
|
|
7645
|
+
buildGraph: () => buildGraph,
|
|
7646
|
+
buildVersionIndex: () => buildVersionIndex,
|
|
7647
|
+
candidateByteDigest: () => candidateByteDigest,
|
|
7648
|
+
collectChangedPaths: () => collectChangedPaths,
|
|
7649
|
+
computeCoverageBoundary: () => computeCoverageBoundary,
|
|
7650
|
+
computeE2eCoverageStats: () => computeE2eCoverageStats,
|
|
7651
|
+
computeImpact: () => computeImpact,
|
|
7652
|
+
computeRevisionDigest: () => computeRevisionDigest,
|
|
7653
|
+
createModeForUmask: () => createModeForUmask,
|
|
7654
|
+
createRestructureRootBinding: () => createRestructureRootBinding,
|
|
7655
|
+
createRestructureValidationCallback: () => createRestructureValidationCallback,
|
|
7656
|
+
diagnoseConfigDocument: () => diagnoseConfigDocument,
|
|
7657
|
+
diagnoseProjectConfig: () => diagnoseProjectConfig,
|
|
7658
|
+
digestRestructureValue: () => digestRestructureValue,
|
|
7659
|
+
dirname: () => dirname7,
|
|
7660
|
+
discoverAndAuditPackets: () => discoverAndAuditPackets,
|
|
7661
|
+
discoverTargets: () => discoverTargets,
|
|
7662
|
+
doctorArtifactChain: () => doctorArtifactChain,
|
|
7663
|
+
ensureRestructureMechanismRoot: () => ensureRestructureMechanismRoot,
|
|
7664
|
+
extname: () => extname,
|
|
7665
|
+
filterGraphByView: () => filterGraphByView,
|
|
7666
|
+
formatContextMarkdown: () => formatContextMarkdown,
|
|
7667
|
+
gateRestructureOperationPlan: () => gateRestructureOperationPlan,
|
|
7668
|
+
generateE2eRegistry: () => generateE2eRegistry,
|
|
7669
|
+
getArtifactTypeMetadata: () => getArtifactTypeMetadata,
|
|
7670
|
+
getConfigDiagnostics: () => getConfigDiagnostics,
|
|
7671
|
+
getExternalEntryInfo: () => getExternalEntryInfo,
|
|
7672
|
+
getTargetArtifactTypes: () => getTargetArtifactTypes,
|
|
7673
|
+
inspectRestructure: () => inspectRestructure,
|
|
7674
|
+
installManagedHookBlock: () => installManagedHookBlock,
|
|
7675
|
+
isOfficialNamespace: () => isOfficialNamespace,
|
|
7676
|
+
isPacketTargetType: () => isPacketTargetType,
|
|
7677
|
+
isPacketTargetTypeDynamic: () => isPacketTargetTypeDynamic,
|
|
7678
|
+
isTargetArtifactType: () => isTargetArtifactType,
|
|
7679
|
+
isVersionLockIssueBlocking: () => isVersionLockIssueBlocking,
|
|
7680
|
+
loadConfig: () => loadConfig,
|
|
7681
|
+
loadContract: () => loadContract,
|
|
7682
|
+
loadContractCatalog: () => loadContractCatalog,
|
|
7683
|
+
loadContractsFromDirectory: () => loadContractsFromDirectory,
|
|
7684
|
+
loadFoundationModule: () => loadFoundationModule,
|
|
7685
|
+
locateSoftwareRecord: () => locateSoftwareRecord,
|
|
7686
|
+
markdownRecordHeadings: () => markdownRecordHeadings,
|
|
7687
|
+
matchesConfiguredArtifactPath: () => matchesConfiguredArtifactPath,
|
|
7688
|
+
nextId: () => nextId,
|
|
7689
|
+
normalizeE2eLegacyArtifact: () => normalizeE2eLegacyArtifact,
|
|
7690
|
+
normalizeToCanonical: () => normalizeToCanonical,
|
|
7691
|
+
observeRestructureJournal: () => observeRestructureJournal,
|
|
7692
|
+
parseTargetSelector: () => parseTargetSelector,
|
|
7693
|
+
parseTargetsFile: () => parseTargetsFile,
|
|
7694
|
+
planRestructure: () => planRestructure,
|
|
7695
|
+
planningUmask: () => planningUmask,
|
|
7696
|
+
prepareManagedHookBlock: () => prepareManagedHookBlock,
|
|
7697
|
+
projectRestructureFileSetResult: () => projectRestructureFileSetResult,
|
|
7698
|
+
pruneRestructureFileSet: () => pruneRestructureFileSet,
|
|
7699
|
+
pruneRestructureRecovery: () => pruneRestructureRecovery,
|
|
7700
|
+
qualifyRestructureMechanism: () => qualifyRestructureMechanism,
|
|
7701
|
+
queryGraph: () => queryGraph,
|
|
7702
|
+
recoverRestructure: () => recoverRestructure,
|
|
7703
|
+
recoverRestructureFileSet: () => recoverRestructureFileSet,
|
|
7704
|
+
refreshVersionLock: () => refreshVersionLock,
|
|
7705
|
+
renderCoverageBoundaryMarkdown: () => renderCoverageBoundaryMarkdown,
|
|
7706
|
+
renderDoctorMarkdown: () => renderDoctorMarkdown,
|
|
7707
|
+
renderImpactMarkdown: () => renderImpactMarkdown,
|
|
7708
|
+
renderMermaid: () => renderMermaid,
|
|
7709
|
+
renderPacketMarkdown: () => renderPacketMarkdown,
|
|
7710
|
+
renderPacketPrompt: () => renderPacketPrompt,
|
|
7711
|
+
renderTraceVersionMarkdown: () => renderTraceVersionMarkdown,
|
|
7712
|
+
renderVersionLockAuditMarkdown: () => renderVersionLockAuditMarkdown,
|
|
7713
|
+
renderVersionLockRefreshMarkdown: () => renderVersionLockRefreshMarkdown,
|
|
7714
|
+
replaceSoftwareHeader: () => replaceSoftwareHeader,
|
|
7715
|
+
resolveArtifactContext: () => resolveArtifactContext,
|
|
7716
|
+
resolveArtifactGraphCli: () => resolveArtifactGraphCli,
|
|
7717
|
+
resolveArtifactTypeName: () => resolveArtifactTypeName,
|
|
7718
|
+
resolveCliTarget: () => resolveCliTarget,
|
|
7719
|
+
resolveGitHookPath: () => resolveGitHookPath,
|
|
7720
|
+
resolveMatrixEdges: () => resolveMatrixEdges,
|
|
7721
|
+
resolveNodeTimeView: () => resolveNodeTimeView,
|
|
7722
|
+
resolveRealRoot: () => resolveRealRoot,
|
|
7723
|
+
restructureBoundaryFindings: () => restructureBoundaryFindings,
|
|
7724
|
+
runCheckProfessional: () => runCheckProfessional,
|
|
7725
|
+
runReadProof: () => runReadProof,
|
|
7726
|
+
scanArtifacts: () => scanArtifacts,
|
|
7727
|
+
traceVersion: () => traceVersion,
|
|
7728
|
+
updateVersionLock: () => updateVersionLock,
|
|
7729
|
+
validateContractAgainstSchema: () => validateContractAgainstSchema,
|
|
7730
|
+
validateExecutableTraceability: () => validateExecutableTraceability,
|
|
7731
|
+
validateGraph: () => validateGraph,
|
|
7732
|
+
validateNamespaceAuthority: () => validateNamespaceAuthority,
|
|
7733
|
+
validatePacket: () => validatePacket,
|
|
7734
|
+
validatePacketMarkdown: () => validatePacketMarkdown,
|
|
7735
|
+
validatePacketPrompt: () => validatePacketPrompt,
|
|
7736
|
+
validatePolicyCompatibility: () => validatePolicyCompatibility,
|
|
7737
|
+
validateReviewResult: () => validateReviewResult,
|
|
7738
|
+
validateScenarioPrdLinkIndex: () => validateScenarioPrdLinkIndex,
|
|
7739
|
+
validateScenarioPrdLinks: () => validateScenarioPrdLinks,
|
|
7740
|
+
verifyDigest: () => verifyDigest,
|
|
7741
|
+
verifyMechanismResult: () => verifyMechanismResult,
|
|
7742
|
+
versionLockIssueSeverity: () => versionLockIssueSeverity,
|
|
7743
|
+
writeGraphCache: () => writeGraphCache
|
|
7744
|
+
});
|
|
7080
7745
|
import matter from "gray-matter";
|
|
7081
|
-
import
|
|
7746
|
+
import yaml2 from "js-yaml";
|
|
7082
7747
|
import { accessSync, constants as fsConstants, existsSync as existsSync3, statSync } from "fs";
|
|
7083
|
-
import { mkdir as mkdir5, readFile as
|
|
7084
|
-
import { basename as basename5, dirname as dirname7, extname, isAbsolute as
|
|
7748
|
+
import { mkdir as mkdir5, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
7749
|
+
import { basename as basename5, dirname as dirname7, extname, isAbsolute as isAbsolute7, join as join12, resolve as resolve8 } from "path";
|
|
7750
|
+
function getConfigDiagnostics(schema) {
|
|
7751
|
+
return configDiagnosticsBySchema.get(schema);
|
|
7752
|
+
}
|
|
7753
|
+
function edgeRule(from, to, kind) {
|
|
7754
|
+
return { from, to, kind };
|
|
7755
|
+
}
|
|
7756
|
+
function matchesEdgeRule(rule, fromType, toType, kind) {
|
|
7757
|
+
return rule.from === fromType && rule.to === toType && rule.kind === kind;
|
|
7758
|
+
}
|
|
7759
|
+
function cloneEdgeRules(rules) {
|
|
7760
|
+
return rules.map((rule) => ({ ...rule }));
|
|
7761
|
+
}
|
|
7762
|
+
function isEmptyAllowedEdgesValue(value) {
|
|
7763
|
+
return value === null || Array.isArray(value) && value.length === 0;
|
|
7764
|
+
}
|
|
7765
|
+
function resolveAllowedEdges(value) {
|
|
7766
|
+
if (isEmptyAllowedEdgesValue(value)) {
|
|
7767
|
+
return cloneEdgeRules(DEFAULT_ALLOWED_EDGES);
|
|
7768
|
+
}
|
|
7769
|
+
return cloneEdgeRules(value);
|
|
7770
|
+
}
|
|
7085
7771
|
function isTargetArtifactType(type) {
|
|
7086
7772
|
return isPacketTargetType(type);
|
|
7087
7773
|
}
|
|
@@ -7123,30 +7809,22 @@ function resolveArtifactTypeName(schema, token) {
|
|
|
7123
7809
|
return void 0;
|
|
7124
7810
|
}
|
|
7125
7811
|
async function loadConfig(root) {
|
|
7126
|
-
const configPath =
|
|
7127
|
-
let
|
|
7812
|
+
const configPath = join12(root, "artifact-graph.config.yaml");
|
|
7813
|
+
let raw;
|
|
7128
7814
|
try {
|
|
7129
|
-
|
|
7130
|
-
parsed = yaml.load(raw) ?? {};
|
|
7815
|
+
raw = await readFile5(configPath, "utf-8");
|
|
7131
7816
|
} catch (error) {
|
|
7132
|
-
if (error.code
|
|
7133
|
-
throw
|
|
7817
|
+
if (error.code === "ENOENT") {
|
|
7818
|
+
throw new Error(`required configuration is missing: ${configPath}`);
|
|
7134
7819
|
}
|
|
7820
|
+
throw error;
|
|
7135
7821
|
}
|
|
7136
|
-
const
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
);
|
|
7141
|
-
}
|
|
7142
|
-
if (parsed.e2e !== void 0) {
|
|
7143
|
-
if (typeof parsed.e2e !== "object" || parsed.e2e === null || Array.isArray(parsed.e2e)) {
|
|
7144
|
-
throw new Error("Invalid e2e: must be an object.");
|
|
7145
|
-
}
|
|
7146
|
-
validateE2eConfig(parsed.e2e);
|
|
7822
|
+
const document = yaml2.load(raw) ?? {};
|
|
7823
|
+
const shapeDiagnosis = diagnoseConfigDocument(document);
|
|
7824
|
+
if (shapeDiagnosis.errors.length > 0) {
|
|
7825
|
+
throw new Error(shapeDiagnosis.errors[0].message);
|
|
7147
7826
|
}
|
|
7148
|
-
|
|
7149
|
-
validateStatusViewsConfig(parsed.statusViews);
|
|
7827
|
+
const parsed = document;
|
|
7150
7828
|
const mergedE2e = parsed.e2e === void 0 ? DEFAULT_SCHEMA.e2e : {
|
|
7151
7829
|
...DEFAULT_SCHEMA.e2e,
|
|
7152
7830
|
...parsed.e2e,
|
|
@@ -7161,13 +7839,14 @@ async function loadConfig(root) {
|
|
|
7161
7839
|
types: mergeArtifactTypes(DEFAULT_SCHEMA.types, parsed.types),
|
|
7162
7840
|
idPatterns: mergeRecord(DEFAULT_SCHEMA.idPatterns, parsed.idPatterns),
|
|
7163
7841
|
relationFields: mergeRecord(DEFAULT_SCHEMA.relationFields, parsed.relationFields),
|
|
7164
|
-
allowedEdges: parsed.allowedEdges
|
|
7842
|
+
allowedEdges: resolveAllowedEdges(parsed.allowedEdges),
|
|
7165
7843
|
forbiddenEdges: parsed.forbiddenEdges ?? DEFAULT_SCHEMA.forbiddenEdges,
|
|
7166
7844
|
statuses: parsed.statuses ?? DEFAULT_SCHEMA.statuses,
|
|
7167
7845
|
idRanges: mergeRecord(DEFAULT_SCHEMA.idRanges, parsed.idRanges),
|
|
7168
7846
|
e2e: mergedE2e
|
|
7169
7847
|
};
|
|
7170
7848
|
validateJsonArtifactTypes(merged.types);
|
|
7849
|
+
configDiagnosticsBySchema.set(merged, shapeDiagnosis);
|
|
7171
7850
|
return merged;
|
|
7172
7851
|
}
|
|
7173
7852
|
function validateJsonArtifactTypes(types) {
|
|
@@ -7192,131 +7871,6 @@ function validateJsonArtifactTypes(types) {
|
|
|
7192
7871
|
}
|
|
7193
7872
|
}
|
|
7194
7873
|
}
|
|
7195
|
-
function validateRelationSemanticsConfig(value) {
|
|
7196
|
-
if (value === void 0) return;
|
|
7197
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7198
|
-
throw new Error("Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
7199
|
-
}
|
|
7200
|
-
for (const [kind, spec] of Object.entries(value)) {
|
|
7201
|
-
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
7202
|
-
throw new Error(`Invalid relationSemantics.${kind}: must be an object.`);
|
|
7203
|
-
}
|
|
7204
|
-
if (typeof spec.label !== "string" || !spec.label.trim()) {
|
|
7205
|
-
throw new Error(`Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
7206
|
-
}
|
|
7207
|
-
if (!Array.isArray(spec.targetTypes) || spec.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7208
|
-
throw new Error(`Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
7209
|
-
}
|
|
7210
|
-
if (!Array.isArray(spec.fields) || spec.fields.length === 0 || spec.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7211
|
-
throw new Error(`Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
7212
|
-
}
|
|
7213
|
-
if (spec.partial !== void 0 && (typeof spec.partial !== "object" || spec.partial === null || typeof spec.partial.sectionField !== "string" || !spec.partial.sectionField.trim())) {
|
|
7214
|
-
throw new Error(`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`);
|
|
7215
|
-
}
|
|
7216
|
-
}
|
|
7217
|
-
}
|
|
7218
|
-
function validateStatusViewsConfig(value) {
|
|
7219
|
-
if (value === void 0) return;
|
|
7220
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7221
|
-
throw new Error("Invalid statusViews: must be an object keyed by status.");
|
|
7222
|
-
}
|
|
7223
|
-
for (const [status, bucket] of Object.entries(value)) {
|
|
7224
|
-
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
7225
|
-
throw new Error(`Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
7226
|
-
}
|
|
7227
|
-
}
|
|
7228
|
-
}
|
|
7229
|
-
function validateE2eConfig(e2e) {
|
|
7230
|
-
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
7231
|
-
if (e2e[field] !== void 0 && typeof e2e[field] !== "boolean") {
|
|
7232
|
-
throw new Error(`Invalid e2e.${field}: must be boolean.`);
|
|
7233
|
-
}
|
|
7234
|
-
}
|
|
7235
|
-
if (e2e.executable_ref_warning !== void 0) {
|
|
7236
|
-
if (typeof e2e.executable_ref_warning !== "number" || e2e.executable_ref_warning < 0 || e2e.executable_ref_warning > 1) {
|
|
7237
|
-
throw new Error(`Invalid e2e.executable_ref_warning: ${JSON.stringify(e2e.executable_ref_warning)}. Must be a number between 0 and 1.`);
|
|
7238
|
-
}
|
|
7239
|
-
}
|
|
7240
|
-
if (e2e.executable_ref_error !== void 0) {
|
|
7241
|
-
if (typeof e2e.executable_ref_error !== "number" || e2e.executable_ref_error < 0 || e2e.executable_ref_error > 1) {
|
|
7242
|
-
throw new Error(`Invalid e2e.executable_ref_error: ${JSON.stringify(e2e.executable_ref_error)}. Must be a number between 0 and 1.`);
|
|
7243
|
-
}
|
|
7244
|
-
}
|
|
7245
|
-
const validateWaivers = (waivers, field) => {
|
|
7246
|
-
if (waivers === void 0) return;
|
|
7247
|
-
if (!Array.isArray(waivers)) {
|
|
7248
|
-
throw new Error(`Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
7249
|
-
}
|
|
7250
|
-
for (const w of waivers) {
|
|
7251
|
-
if (typeof w !== "object" || w === null || !("id" in w) || !("reason" in w)) {
|
|
7252
|
-
throw new Error(`Invalid ${field} entry: ${JSON.stringify(w)}. Must be {id, reason} object.`);
|
|
7253
|
-
}
|
|
7254
|
-
if (typeof w.id !== "string" || !w.id.trim()) {
|
|
7255
|
-
throw new Error(`Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(w.id)}`);
|
|
7256
|
-
}
|
|
7257
|
-
if (typeof w.reason !== "string" || !w.reason.trim()) {
|
|
7258
|
-
throw new Error(`Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(w.reason)}`);
|
|
7259
|
-
}
|
|
7260
|
-
}
|
|
7261
|
-
};
|
|
7262
|
-
validateWaivers(e2e.scenario_waivers, "e2e.scenario_waivers");
|
|
7263
|
-
validateWaivers(e2e.feature_waivers, "e2e.feature_waivers");
|
|
7264
|
-
if (e2e.runners !== void 0) {
|
|
7265
|
-
if (!Array.isArray(e2e.runners)) {
|
|
7266
|
-
throw new Error(`Invalid e2e.runners: must be an array.`);
|
|
7267
|
-
}
|
|
7268
|
-
for (const runner of e2e.runners) {
|
|
7269
|
-
if (typeof runner !== "object" || runner === null) {
|
|
7270
|
-
throw new Error(`Invalid e2e.runners entry: must be an object.`);
|
|
7271
|
-
}
|
|
7272
|
-
if (typeof runner.name !== "string" || !runner.name.trim()) {
|
|
7273
|
-
throw new Error(`Invalid e2e.runners entry: name must be a non-empty string.`);
|
|
7274
|
-
}
|
|
7275
|
-
if (typeof runner.root !== "string" || !runner.root.trim()) {
|
|
7276
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: must be a non-empty string.`);
|
|
7277
|
-
}
|
|
7278
|
-
if (isAbsolute6(runner.root)) {
|
|
7279
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not be an absolute path.`);
|
|
7280
|
-
}
|
|
7281
|
-
if (runner.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
7282
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not contain ".." segments.`);
|
|
7283
|
-
}
|
|
7284
|
-
if (!Array.isArray(runner.include) || runner.include.length === 0) {
|
|
7285
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: must be a non-empty array of glob patterns.`);
|
|
7286
|
-
}
|
|
7287
|
-
for (const pattern of runner.include) {
|
|
7288
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7289
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: pattern must be a non-empty string.`);
|
|
7290
|
-
}
|
|
7291
|
-
}
|
|
7292
|
-
if (runner.exclude !== void 0) {
|
|
7293
|
-
if (!Array.isArray(runner.exclude)) {
|
|
7294
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: must be an array.`);
|
|
7295
|
-
}
|
|
7296
|
-
for (const pattern of runner.exclude) {
|
|
7297
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7298
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: pattern must be a non-empty string.`);
|
|
7299
|
-
}
|
|
7300
|
-
}
|
|
7301
|
-
}
|
|
7302
|
-
if (runner.testIgnore !== void 0) {
|
|
7303
|
-
if (!Array.isArray(runner.testIgnore)) {
|
|
7304
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: must be an array.`);
|
|
7305
|
-
}
|
|
7306
|
-
for (const pattern of runner.testIgnore) {
|
|
7307
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7308
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: pattern must be a non-empty string.`);
|
|
7309
|
-
}
|
|
7310
|
-
}
|
|
7311
|
-
}
|
|
7312
|
-
if (runner.kind !== void 0) {
|
|
7313
|
-
if (!["unit", "integration", "e2e"].includes(runner.kind)) {
|
|
7314
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].kind: "${runner.kind}". Must be unit, integration, or e2e.`);
|
|
7315
|
-
}
|
|
7316
|
-
}
|
|
7317
|
-
}
|
|
7318
|
-
}
|
|
7319
|
-
}
|
|
7320
7874
|
function buildGraph(nodes, edges, diagnostics = [], root) {
|
|
7321
7875
|
const graphNodes = nodes.map((node) => ({ ...node, uid: toUid(node.type, node.code) }));
|
|
7322
7876
|
graphNodes.sort(compareNode);
|
|
@@ -7364,7 +7918,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7364
7918
|
continue;
|
|
7365
7919
|
}
|
|
7366
7920
|
scannedFiles.set(file, type);
|
|
7367
|
-
const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await
|
|
7921
|
+
const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await readFile5(join12(root, file), "utf-8");
|
|
7368
7922
|
const parsed = parseFile(type, file, raw, config);
|
|
7369
7923
|
const semantic = isJsonOriginalType(type, config) ? { edges: [], diagnostics: [] } : parseConfiguredRelations(type, file, raw, parsed.nodes, config);
|
|
7370
7924
|
nodes.push(...parsed.nodes);
|
|
@@ -7372,7 +7926,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7372
7926
|
scanDiagnostics.push(...parsed.diagnostics, ...semantic.diagnostics);
|
|
7373
7927
|
}
|
|
7374
7928
|
}
|
|
7375
|
-
const absoluteRoot =
|
|
7929
|
+
const absoluteRoot = isAbsolute7(root) ? root : resolve8(root);
|
|
7376
7930
|
const graph = buildGraph(nodes, edges, scanDiagnostics, absoluteRoot);
|
|
7377
7931
|
return resolveMatrixEdges(graph);
|
|
7378
7932
|
}
|
|
@@ -7519,8 +8073,16 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
|
|
|
7519
8073
|
{ edge: edge2 }
|
|
7520
8074
|
));
|
|
7521
8075
|
}
|
|
7522
|
-
if (schema.forbiddenEdges.some((rule) => rule
|
|
8076
|
+
if (schema.forbiddenEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
7523
8077
|
issues.push(issue("FORBIDDEN_EDGE", `Forbidden ${fromType} -> ${toType} ${edge2.kind} relation`, edge2.sourcePath, edge2.sourceLine, { edge: edge2 }));
|
|
8078
|
+
} else if (!schema.allowedEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
8079
|
+
issues.push(issue(
|
|
8080
|
+
"DISALLOWED_EDGE",
|
|
8081
|
+
`Disallowed ${fromType} -> ${toType} ${edge2.kind} relation`,
|
|
8082
|
+
edge2.sourcePath,
|
|
8083
|
+
edge2.sourceLine,
|
|
8084
|
+
{ edge: edge2 }
|
|
8085
|
+
));
|
|
7524
8086
|
}
|
|
7525
8087
|
}
|
|
7526
8088
|
issues.push(...validateE2eTests(graph));
|
|
@@ -7711,7 +8273,7 @@ async function validateScenarioPrdLinkIndex(root, graph) {
|
|
|
7711
8273
|
const indexPath = "artifacts/prd/feature-index.md";
|
|
7712
8274
|
let raw = "";
|
|
7713
8275
|
try {
|
|
7714
|
-
raw = await
|
|
8276
|
+
raw = await readFile5(join12(root, indexPath), "utf-8");
|
|
7715
8277
|
} catch (error) {
|
|
7716
8278
|
if (error.code === "ENOENT") {
|
|
7717
8279
|
return [];
|
|
@@ -7959,12 +8521,12 @@ function nextId(graph, schema, type, rangeName) {
|
|
|
7959
8521
|
throw new Error(`ID range ${type}.${rangeName} is exhausted`);
|
|
7960
8522
|
}
|
|
7961
8523
|
async function writeGraphCache(root, graph) {
|
|
7962
|
-
const cacheDir =
|
|
8524
|
+
const cacheDir = join12(root, ".artifact-graph");
|
|
7963
8525
|
await mkdir5(cacheDir, { recursive: true });
|
|
7964
|
-
await writeFile3(
|
|
8526
|
+
await writeFile3(join12(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
|
|
7965
8527
|
`);
|
|
7966
8528
|
const { default: Database } = await import("better-sqlite3");
|
|
7967
|
-
const db = new Database(
|
|
8529
|
+
const db = new Database(join12(cacheDir, "graph.sqlite"));
|
|
7968
8530
|
try {
|
|
7969
8531
|
db.exec(`
|
|
7970
8532
|
DROP TABLE IF EXISTS nodes;
|
|
@@ -10046,7 +10608,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10046
10608
|
const tcKeyToFields = /* @__PURE__ */ new Map();
|
|
10047
10609
|
const mdBatches = /* @__PURE__ */ new Set();
|
|
10048
10610
|
for (const relPath of e2eFiles) {
|
|
10049
|
-
const raw = await
|
|
10611
|
+
const raw = await readFile5(join12(root, relPath), "utf-8");
|
|
10050
10612
|
const parsed = matter(raw);
|
|
10051
10613
|
const data = parsed.data;
|
|
10052
10614
|
const batch = String(data.test_batch ?? basename5(relPath, extname(relPath))).trim();
|
|
@@ -10088,10 +10650,10 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10088
10650
|
const tcAnnotationRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+?)\s+\[(\w+)\]/;
|
|
10089
10651
|
const tcAnnotationNoLevelRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+)/;
|
|
10090
10652
|
for (const specFile of specFiles) {
|
|
10091
|
-
const fullSpecPath =
|
|
10653
|
+
const fullSpecPath = join12(root, specFile);
|
|
10092
10654
|
let content;
|
|
10093
10655
|
try {
|
|
10094
|
-
content = await
|
|
10656
|
+
content = await readFile5(fullSpecPath, "utf-8");
|
|
10095
10657
|
} catch {
|
|
10096
10658
|
continue;
|
|
10097
10659
|
}
|
|
@@ -10170,7 +10732,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10170
10732
|
if (entry.testId) {
|
|
10171
10733
|
let content;
|
|
10172
10734
|
try {
|
|
10173
|
-
content = await
|
|
10735
|
+
content = await readFile5(join12(root, normalizedRefFile), "utf-8");
|
|
10174
10736
|
} catch {
|
|
10175
10737
|
continue;
|
|
10176
10738
|
}
|
|
@@ -10405,7 +10967,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10405
10967
|
let hasActiveE2eRef = false;
|
|
10406
10968
|
for (const entry of parseExecutableRefLines(execRef)) {
|
|
10407
10969
|
const normalized = resolveExecutableRefFile(entry.file, allProjectFiles);
|
|
10408
|
-
if (!normalized || !existsSync3(
|
|
10970
|
+
if (!normalized || !existsSync3(join12(root, normalized))) continue;
|
|
10409
10971
|
const accepting = await getAcceptingRunners(root, normalized, runners);
|
|
10410
10972
|
if (accepting.some((runner) => runner.kind === "e2e")) {
|
|
10411
10973
|
hasActiveE2eRef = true;
|
|
@@ -10464,7 +11026,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10464
11026
|
const acCoverageRateByFeature = {};
|
|
10465
11027
|
const featureAcMap = /* @__PURE__ */ new Map();
|
|
10466
11028
|
for (const node of featureNodes) {
|
|
10467
|
-
const acs = parseAcceptanceCriteria(await
|
|
11029
|
+
const acs = parseAcceptanceCriteria(await readFile5(join12(root, node.path), "utf-8"));
|
|
10468
11030
|
featureAcMap.set(node.code, new Set(acs));
|
|
10469
11031
|
}
|
|
10470
11032
|
const coveredAcByFeature = /* @__PURE__ */ new Map();
|
|
@@ -10512,8 +11074,8 @@ async function generateE2eRegistry(root, opts) {
|
|
|
10512
11074
|
const batchIds = /* @__PURE__ */ new Set();
|
|
10513
11075
|
let totalTestCases = 0;
|
|
10514
11076
|
for (const file of files) {
|
|
10515
|
-
const filePath =
|
|
10516
|
-
const raw = await
|
|
11077
|
+
const filePath = join12(root, file);
|
|
11078
|
+
const raw = await readFile5(filePath, "utf-8");
|
|
10517
11079
|
const parsed = matter(raw);
|
|
10518
11080
|
const data = parsed.data;
|
|
10519
11081
|
const batch = String(data.test_batch ?? basename5(file, extname(file))).trim();
|
|
@@ -10638,10 +11200,10 @@ async function validatePartialRustEvidence(tcFields, tcKey, root, allFiles) {
|
|
|
10638
11200
|
if (!normalizedPath) {
|
|
10639
11201
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10640
11202
|
}
|
|
10641
|
-
const fullPath =
|
|
11203
|
+
const fullPath = join12(root, normalizedPath);
|
|
10642
11204
|
let content;
|
|
10643
11205
|
try {
|
|
10644
|
-
content = await
|
|
11206
|
+
content = await readFile5(fullPath, "utf-8");
|
|
10645
11207
|
} catch {
|
|
10646
11208
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10647
11209
|
}
|
|
@@ -10675,7 +11237,7 @@ function detectTestLevel(specFile, content) {
|
|
|
10675
11237
|
}
|
|
10676
11238
|
function resolveExecutableRefFile(refFile, allFiles) {
|
|
10677
11239
|
const normalized = refFile.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
10678
|
-
if (!normalized ||
|
|
11240
|
+
if (!normalized || isAbsolute7(refFile) || normalized.split("/").includes("..")) {
|
|
10679
11241
|
return void 0;
|
|
10680
11242
|
}
|
|
10681
11243
|
if (allFiles.includes(normalized)) {
|
|
@@ -11257,7 +11819,7 @@ function resolveArtifactContext(graph, opts) {
|
|
|
11257
11819
|
}
|
|
11258
11820
|
if (root) {
|
|
11259
11821
|
for (const ap of ALWAYS_PRESENT_ITEMS) {
|
|
11260
|
-
const fullPath =
|
|
11822
|
+
const fullPath = join12(root, ap.path);
|
|
11261
11823
|
let stat2;
|
|
11262
11824
|
try {
|
|
11263
11825
|
stat2 = statSync(fullPath);
|
|
@@ -11499,13 +12061,15 @@ function formatContextMarkdown(manifest) {
|
|
|
11499
12061
|
}
|
|
11500
12062
|
return lines.join("\n");
|
|
11501
12063
|
}
|
|
11502
|
-
var TARGET_ARTIFACT_TYPES, NON_TARGET_ROLES, DEFAULT_SCHEMA, SPECIALIZED_PARSER_TYPES, EMPTY_RELATION_FIELD_VALUES, VALID_TC_STATUSES, VALID_CHAIN_TYPES, DEPRECATED_CHAIN_TYPE_ALIASES, CONTEXT_CATEGORIES, TIER_ORDER;
|
|
12064
|
+
var configDiagnosticsBySchema, DEFAULT_ALLOWED_EDGES, TARGET_ARTIFACT_TYPES, NON_TARGET_ROLES, DEFAULT_SCHEMA, SPECIALIZED_PARSER_TYPES, EMPTY_RELATION_FIELD_VALUES, VALID_TC_STATUSES, VALID_CHAIN_TYPES, DEPRECATED_CHAIN_TYPE_ALIASES, CONTEXT_CATEGORIES, TIER_ORDER;
|
|
11503
12065
|
var init_index = __esm({
|
|
11504
12066
|
"src/index.ts"() {
|
|
11505
12067
|
init_packet_constants();
|
|
11506
12068
|
init_packet_validator();
|
|
11507
12069
|
init_glob_matcher();
|
|
11508
12070
|
init_file_walker();
|
|
12071
|
+
init_doctor();
|
|
12072
|
+
init_doctor();
|
|
11509
12073
|
init_packet_constants();
|
|
11510
12074
|
init_target_selector();
|
|
11511
12075
|
init_impact();
|
|
@@ -11526,6 +12090,44 @@ var init_index = __esm({
|
|
|
11526
12090
|
init_restructure();
|
|
11527
12091
|
init_restructure_file_set();
|
|
11528
12092
|
init_restructure_software();
|
|
12093
|
+
configDiagnosticsBySchema = /* @__PURE__ */ new WeakMap();
|
|
12094
|
+
DEFAULT_ALLOWED_EDGES = [
|
|
12095
|
+
edgeRule("feature", "scenario", "covers"),
|
|
12096
|
+
edgeRule("feature", "decision", "references"),
|
|
12097
|
+
edgeRule("feature", "feature", "depends_on"),
|
|
12098
|
+
edgeRule("feature", "design", "references"),
|
|
12099
|
+
edgeRule("scenario", "feature", "references"),
|
|
12100
|
+
edgeRule("scenario", "decision", "references"),
|
|
12101
|
+
edgeRule("scenario", "entity", "references"),
|
|
12102
|
+
edgeRule("entity", "decision", "references"),
|
|
12103
|
+
edgeRule("decision", "feature", "references"),
|
|
12104
|
+
edgeRule("decision", "scenario", "references"),
|
|
12105
|
+
edgeRule("design", "feature", "references"),
|
|
12106
|
+
edgeRule("design", "scenario", "references"),
|
|
12107
|
+
edgeRule("design", "decision", "references"),
|
|
12108
|
+
edgeRule("design", "entity", "references"),
|
|
12109
|
+
edgeRule("test", "feature", "verifies"),
|
|
12110
|
+
edgeRule("test", "scenario", "verifies"),
|
|
12111
|
+
edgeRule("test", "decision", "verifies"),
|
|
12112
|
+
edgeRule("test", "entity", "verifies"),
|
|
12113
|
+
edgeRule("implementation", "feature", "implements"),
|
|
12114
|
+
edgeRule("implementation", "scenario", "implements"),
|
|
12115
|
+
edgeRule("implementation", "decision", "implements"),
|
|
12116
|
+
edgeRule("implementation", "entity", "implements"),
|
|
12117
|
+
edgeRule("e2e_test", "scenario", "verifies"),
|
|
12118
|
+
edgeRule("e2e_test", "feature", "verifies"),
|
|
12119
|
+
edgeRule("e2e_test", "decision", "references"),
|
|
12120
|
+
edgeRule("e2e_test", "entity", "references"),
|
|
12121
|
+
edgeRule("rule-golden-cases", "design", "references"),
|
|
12122
|
+
edgeRule("traceability-matrix-v2", "traceability-matrix-v2", "references"),
|
|
12123
|
+
edgeRule("traceability-matrix-v2", "traceability-matrix-v2", "covers"),
|
|
12124
|
+
edgeRule("traceability-matrix-v2", "resolve", "references"),
|
|
12125
|
+
edgeRule("traceability-matrix-v2", "resolve", "covers"),
|
|
12126
|
+
...["feature", "scenario", "decision", "design", "entity", "test", "e2e_test"].flatMap((to) => [
|
|
12127
|
+
edgeRule("traceability-matrix-v2", to, "references"),
|
|
12128
|
+
edgeRule("traceability-matrix-v2", to, "covers")
|
|
12129
|
+
])
|
|
12130
|
+
];
|
|
11529
12131
|
TARGET_ARTIFACT_TYPES = VALID_PACKET_TARGET_TYPES;
|
|
11530
12132
|
NON_TARGET_ROLES = ["context", "candidate", "not-recommended"];
|
|
11531
12133
|
DEFAULT_SCHEMA = {
|
|
@@ -11563,7 +12165,7 @@ var init_index = __esm({
|
|
|
11563
12165
|
e2e_test: ["test_batch", "scope", "ac_coverage", "related_scenarios", "related_decisions", "related_entities", "\u8986\u76D6\u573A\u666F", "\u8986\u76D6\u529F\u80FD"],
|
|
11564
12166
|
e2e_registry: ["batches"]
|
|
11565
12167
|
},
|
|
11566
|
-
allowedEdges:
|
|
12168
|
+
allowedEdges: DEFAULT_ALLOWED_EDGES,
|
|
11567
12169
|
forbiddenEdges: [{ from: "scenario", to: "entity", kind: "references" }],
|
|
11568
12170
|
statuses: ["planned", "active", "done", "deprecated"],
|
|
11569
12171
|
idRanges: {},
|
|
@@ -11696,6 +12298,8 @@ export {
|
|
|
11696
12298
|
createModeForUmask,
|
|
11697
12299
|
createRestructureRootBinding,
|
|
11698
12300
|
createRestructureValidationCallback,
|
|
12301
|
+
diagnoseConfigDocument,
|
|
12302
|
+
diagnoseProjectConfig,
|
|
11699
12303
|
digestRestructureValue,
|
|
11700
12304
|
dirname7 as dirname,
|
|
11701
12305
|
discoverAndAuditPackets,
|
|
@@ -11708,6 +12312,7 @@ export {
|
|
|
11708
12312
|
gateRestructureOperationPlan,
|
|
11709
12313
|
generateE2eRegistry,
|
|
11710
12314
|
getArtifactTypeMetadata,
|
|
12315
|
+
getConfigDiagnostics,
|
|
11711
12316
|
getExternalEntryInfo,
|
|
11712
12317
|
getTargetArtifactTypes,
|
|
11713
12318
|
inspectRestructure,
|