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.cjs
CHANGED
|
@@ -397,6 +397,505 @@ var init_file_walker = __esm({
|
|
|
397
397
|
}
|
|
398
398
|
});
|
|
399
399
|
|
|
400
|
+
// src/doctor.ts
|
|
401
|
+
function getShapeValidator() {
|
|
402
|
+
if (!_validateConfigShape) {
|
|
403
|
+
const AjvCtor = import_ajv.default;
|
|
404
|
+
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
405
|
+
_validateConfigShape = ajv.compile(CONFIG_SHAPE_SCHEMA);
|
|
406
|
+
}
|
|
407
|
+
return _validateConfigShape;
|
|
408
|
+
}
|
|
409
|
+
function instancePathToField(instancePath, params) {
|
|
410
|
+
const missing = typeof params?.missingProperty === "string" ? params.missingProperty : void 0;
|
|
411
|
+
if (!instancePath || instancePath === "") {
|
|
412
|
+
return missing && missing.length > 0 ? missing : "(root)";
|
|
413
|
+
}
|
|
414
|
+
const path = instancePath.replace(/^\//, "").replace(/\//g, ".");
|
|
415
|
+
return missing && missing.length > 0 ? `${path}.${missing}` : path;
|
|
416
|
+
}
|
|
417
|
+
function pushError(errors, path, message) {
|
|
418
|
+
errors.push({ path, message, severity: "error" });
|
|
419
|
+
}
|
|
420
|
+
function warnUnknownObjectKeys(value, path, knownKeys, warnings) {
|
|
421
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return;
|
|
422
|
+
for (const key of Object.keys(value)) {
|
|
423
|
+
if (knownKeys.has(key)) continue;
|
|
424
|
+
const field = path ? `${path}.${key}` : key;
|
|
425
|
+
warnings.push({
|
|
426
|
+
path: field,
|
|
427
|
+
message: `Unknown config key ${key} at ${field}: kept for compatibility and not treated as a declared field.`,
|
|
428
|
+
severity: "warning"
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function warnUnknownArrayObjectKeys(value, path, knownKeys, warnings) {
|
|
433
|
+
if (!Array.isArray(value)) return;
|
|
434
|
+
value.forEach((entry, index) => {
|
|
435
|
+
warnUnknownObjectKeys(entry, `${path}.${index}`, knownKeys, warnings);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
function collectNestedUnknownKeyWarnings(document, warnings) {
|
|
439
|
+
warnUnknownObjectKeys(document, "", KNOWN_TOP_LEVEL_KEYS, warnings);
|
|
440
|
+
const types = document.types;
|
|
441
|
+
if (types && typeof types === "object" && !Array.isArray(types)) {
|
|
442
|
+
for (const [typeName, definition] of Object.entries(types)) {
|
|
443
|
+
const typePath = `types.${typeName}`;
|
|
444
|
+
warnUnknownObjectKeys(definition, typePath, TYPE_OBJECT_KEYS, warnings);
|
|
445
|
+
if (definition && typeof definition === "object" && !Array.isArray(definition)) {
|
|
446
|
+
warnUnknownArrayObjectKeys(
|
|
447
|
+
definition.extraFields,
|
|
448
|
+
`${typePath}.extraFields`,
|
|
449
|
+
EXTRA_FIELD_KEYS,
|
|
450
|
+
warnings
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
warnUnknownArrayObjectKeys(document.allowedEdges, "allowedEdges", EDGE_RULE_KEYS, warnings);
|
|
456
|
+
warnUnknownArrayObjectKeys(document.forbiddenEdges, "forbiddenEdges", EDGE_RULE_KEYS, warnings);
|
|
457
|
+
warnUnknownObjectKeys(document.context, "context", CONTEXT_KEYS, warnings);
|
|
458
|
+
const idRanges = document.idRanges;
|
|
459
|
+
if (idRanges && typeof idRanges === "object" && !Array.isArray(idRanges)) {
|
|
460
|
+
for (const [layer, ranges] of Object.entries(idRanges)) {
|
|
461
|
+
if (!ranges || typeof ranges !== "object" || Array.isArray(ranges)) continue;
|
|
462
|
+
for (const [rangeName, entry] of Object.entries(ranges)) {
|
|
463
|
+
warnUnknownObjectKeys(entry, `idRanges.${layer}.${rangeName}`, ID_RANGE_ENTRY_KEYS, warnings);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
const relationSemantics = document.relationSemantics;
|
|
468
|
+
if (relationSemantics && typeof relationSemantics === "object" && !Array.isArray(relationSemantics)) {
|
|
469
|
+
for (const [kind, spec] of Object.entries(relationSemantics)) {
|
|
470
|
+
const specPath = `relationSemantics.${kind}`;
|
|
471
|
+
warnUnknownObjectKeys(spec, specPath, RELATION_SEMANTICS_KEYS, warnings);
|
|
472
|
+
if (spec && typeof spec === "object" && !Array.isArray(spec)) {
|
|
473
|
+
warnUnknownObjectKeys(
|
|
474
|
+
spec.partial,
|
|
475
|
+
`${specPath}.partial`,
|
|
476
|
+
RELATION_PARTIAL_KEYS,
|
|
477
|
+
warnings
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const e2e = document.e2e;
|
|
483
|
+
if (e2e && typeof e2e === "object" && !Array.isArray(e2e)) {
|
|
484
|
+
const e2eRecord = e2e;
|
|
485
|
+
warnUnknownObjectKeys(e2eRecord, "e2e", E2E_KEYS, warnings);
|
|
486
|
+
warnUnknownArrayObjectKeys(e2eRecord.scenario_waivers, "e2e.scenario_waivers", WAIVER_KEYS, warnings);
|
|
487
|
+
warnUnknownArrayObjectKeys(e2eRecord.feature_waivers, "e2e.feature_waivers", WAIVER_KEYS, warnings);
|
|
488
|
+
warnUnknownArrayObjectKeys(e2eRecord.runners, "e2e.runners", RUNNER_KEYS, warnings);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function typeHasDefaultPaths(typeName) {
|
|
492
|
+
const base = DEFAULT_SCHEMA.types[typeName];
|
|
493
|
+
return Array.isArray(base?.paths);
|
|
494
|
+
}
|
|
495
|
+
function collectCustomTypePathErrors(types, errors) {
|
|
496
|
+
if (types === void 0) return;
|
|
497
|
+
if (typeof types !== "object" || types === null || Array.isArray(types)) return;
|
|
498
|
+
for (const [typeName, definition] of Object.entries(types)) {
|
|
499
|
+
if (definition === void 0 || definition === null) {
|
|
500
|
+
if (!typeHasDefaultPaths(typeName)) {
|
|
501
|
+
pushError(errors, `types.${typeName}.paths`, `Invalid types.${typeName}.paths: must be array`);
|
|
502
|
+
}
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
if (typeof definition !== "object" || Array.isArray(definition)) continue;
|
|
506
|
+
const paths = definition.paths;
|
|
507
|
+
if (paths === void 0 && !typeHasDefaultPaths(typeName)) {
|
|
508
|
+
pushError(errors, `types.${typeName}.paths`, `Invalid types.${typeName}.paths: must be array`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function collectRelationSemanticsErrors(value, errors) {
|
|
513
|
+
if (value === void 0) return;
|
|
514
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
515
|
+
pushError(errors, "relationSemantics", "Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
for (const [kind, spec] of Object.entries(value)) {
|
|
519
|
+
const path = `relationSemantics.${kind}`;
|
|
520
|
+
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
521
|
+
pushError(errors, path, `Invalid relationSemantics.${kind}: must be an object.`);
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
const record = spec;
|
|
525
|
+
if (typeof record.label !== "string" || !record.label.trim()) {
|
|
526
|
+
pushError(errors, `${path}.label`, `Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
527
|
+
}
|
|
528
|
+
if (!Array.isArray(record.targetTypes) || record.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
529
|
+
pushError(errors, `${path}.targetTypes`, `Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
530
|
+
}
|
|
531
|
+
if (!Array.isArray(record.fields) || record.fields.length === 0 || record.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
532
|
+
pushError(errors, `${path}.fields`, `Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
533
|
+
}
|
|
534
|
+
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())) {
|
|
535
|
+
pushError(
|
|
536
|
+
errors,
|
|
537
|
+
`${path}.partial.sectionField`,
|
|
538
|
+
`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function collectStatusViewsErrors(value, errors) {
|
|
544
|
+
if (value === void 0) return;
|
|
545
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
546
|
+
pushError(errors, "statusViews", "Invalid statusViews: must be an object keyed by status.");
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
for (const [status, bucket] of Object.entries(value)) {
|
|
550
|
+
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
551
|
+
pushError(errors, `statusViews.${status}`, `Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function collectWaiverErrors(waivers, field, errors) {
|
|
556
|
+
if (waivers === void 0) return;
|
|
557
|
+
if (!Array.isArray(waivers)) {
|
|
558
|
+
pushError(errors, field, `Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
waivers.forEach((entry, index) => {
|
|
562
|
+
const path = `${field}.${index}`;
|
|
563
|
+
if (typeof entry !== "object" || entry === null || !("id" in entry) || !("reason" in entry)) {
|
|
564
|
+
pushError(errors, path, `Invalid ${field} entry: ${JSON.stringify(entry)}. Must be {id, reason} object.`);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
const record = entry;
|
|
568
|
+
if (typeof record.id !== "string" || !record.id.trim()) {
|
|
569
|
+
pushError(errors, `${path}.id`, `Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(record.id)}`);
|
|
570
|
+
}
|
|
571
|
+
if (typeof record.reason !== "string" || !record.reason.trim()) {
|
|
572
|
+
pushError(errors, `${path}.reason`, `Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(record.reason)}`);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
function collectE2eConfigErrors(e2e, errors) {
|
|
577
|
+
if (e2e === void 0) return;
|
|
578
|
+
if (typeof e2e !== "object" || e2e === null || Array.isArray(e2e)) {
|
|
579
|
+
pushError(errors, "e2e", "Invalid e2e: must be an object.");
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
const record = e2e;
|
|
583
|
+
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
584
|
+
if (record[field] !== void 0 && typeof record[field] !== "boolean") {
|
|
585
|
+
pushError(errors, `e2e.${field}`, `Invalid e2e.${field}: must be boolean.`);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (record.executable_ref_warning !== void 0) {
|
|
589
|
+
if (typeof record.executable_ref_warning !== "number" || record.executable_ref_warning < 0 || record.executable_ref_warning > 1) {
|
|
590
|
+
pushError(
|
|
591
|
+
errors,
|
|
592
|
+
"e2e.executable_ref_warning",
|
|
593
|
+
`Invalid e2e.executable_ref_warning: ${JSON.stringify(record.executable_ref_warning)}. Must be a number between 0 and 1.`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (record.executable_ref_error !== void 0) {
|
|
598
|
+
if (typeof record.executable_ref_error !== "number" || record.executable_ref_error < 0 || record.executable_ref_error > 1) {
|
|
599
|
+
pushError(
|
|
600
|
+
errors,
|
|
601
|
+
"e2e.executable_ref_error",
|
|
602
|
+
`Invalid e2e.executable_ref_error: ${JSON.stringify(record.executable_ref_error)}. Must be a number between 0 and 1.`
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
collectWaiverErrors(record.scenario_waivers, "e2e.scenario_waivers", errors);
|
|
607
|
+
collectWaiverErrors(record.feature_waivers, "e2e.feature_waivers", errors);
|
|
608
|
+
if (record.runners === void 0) return;
|
|
609
|
+
if (!Array.isArray(record.runners)) {
|
|
610
|
+
pushError(errors, "e2e.runners", "Invalid e2e.runners: must be an array.");
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
record.runners.forEach((runner, index) => {
|
|
614
|
+
const runnerPath = `e2e.runners.${index}`;
|
|
615
|
+
if (typeof runner !== "object" || runner === null) {
|
|
616
|
+
pushError(errors, runnerPath, "Invalid e2e.runners entry: must be an object.");
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const runnerRecord = runner;
|
|
620
|
+
const name = runnerRecord.name;
|
|
621
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
622
|
+
pushError(errors, `${runnerPath}.name`, "Invalid e2e.runners entry: name must be a non-empty string.");
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if (typeof runnerRecord.root !== "string" || !runnerRecord.root.trim()) {
|
|
626
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: must be a non-empty string.`);
|
|
627
|
+
} else {
|
|
628
|
+
if ((0, import_node_path2.isAbsolute)(runnerRecord.root)) {
|
|
629
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: "${runnerRecord.root}" must not be an absolute path.`);
|
|
630
|
+
}
|
|
631
|
+
if (runnerRecord.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
632
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: "${runnerRecord.root}" must not contain ".." segments.`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (!Array.isArray(runnerRecord.include) || runnerRecord.include.length === 0) {
|
|
636
|
+
pushError(errors, `${runnerPath}.include`, `Invalid e2e.runners[${name}].include: must be a non-empty array of glob patterns.`);
|
|
637
|
+
} else {
|
|
638
|
+
for (const pattern of runnerRecord.include) {
|
|
639
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
640
|
+
pushError(errors, `${runnerPath}.include`, `Invalid e2e.runners[${name}].include: pattern must be a non-empty string.`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (runnerRecord.exclude !== void 0) {
|
|
645
|
+
if (!Array.isArray(runnerRecord.exclude)) {
|
|
646
|
+
pushError(errors, `${runnerPath}.exclude`, `Invalid e2e.runners[${name}].exclude: must be an array.`);
|
|
647
|
+
} else {
|
|
648
|
+
for (const pattern of runnerRecord.exclude) {
|
|
649
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
650
|
+
pushError(errors, `${runnerPath}.exclude`, `Invalid e2e.runners[${name}].exclude: pattern must be a non-empty string.`);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
if (runnerRecord.testIgnore !== void 0) {
|
|
656
|
+
if (!Array.isArray(runnerRecord.testIgnore)) {
|
|
657
|
+
pushError(errors, `${runnerPath}.testIgnore`, `Invalid e2e.runners[${name}].testIgnore: must be an array.`);
|
|
658
|
+
} else {
|
|
659
|
+
for (const pattern of runnerRecord.testIgnore) {
|
|
660
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
661
|
+
pushError(errors, `${runnerPath}.testIgnore`, `Invalid e2e.runners[${name}].testIgnore: pattern must be a non-empty string.`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (runnerRecord.kind !== void 0) {
|
|
667
|
+
if (!["unit", "integration", "e2e"].includes(runnerRecord.kind)) {
|
|
668
|
+
pushError(errors, `${runnerPath}.kind`, `Invalid e2e.runners[${name}].kind: "${runnerRecord.kind}". Must be unit, integration, or e2e.`);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
function collectAllowedEdgesPresenceError(document, errors) {
|
|
674
|
+
if (!Object.prototype.hasOwnProperty.call(document, "allowedEdges")) {
|
|
675
|
+
pushError(errors, "allowedEdges", ALLOWED_EDGES_REQUIRED_MESSAGE);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function collectExistingLoaderErrors(document, errors) {
|
|
679
|
+
collectCustomTypePathErrors(document.types, errors);
|
|
680
|
+
collectE2eConfigErrors(document.e2e, errors);
|
|
681
|
+
collectRelationSemanticsErrors(document.relationSemantics, errors);
|
|
682
|
+
collectStatusViewsErrors(document.statusViews, errors);
|
|
683
|
+
collectAllowedEdgesPresenceError(document, errors);
|
|
684
|
+
}
|
|
685
|
+
function diagnoseConfigDocument(parsed) {
|
|
686
|
+
const errors = [];
|
|
687
|
+
const warnings = [];
|
|
688
|
+
if (parsed === void 0 || parsed === null) {
|
|
689
|
+
return { errors, warnings };
|
|
690
|
+
}
|
|
691
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
692
|
+
errors.push({
|
|
693
|
+
path: "(root)",
|
|
694
|
+
message: `Invalid artifact-graph.config.yaml: expected an object, got ${Array.isArray(parsed) ? "array" : typeof parsed}.`,
|
|
695
|
+
severity: "error"
|
|
696
|
+
});
|
|
697
|
+
return { errors, warnings };
|
|
698
|
+
}
|
|
699
|
+
const document = parsed;
|
|
700
|
+
const validate = getShapeValidator();
|
|
701
|
+
const valid = validate(document);
|
|
702
|
+
if (!valid) {
|
|
703
|
+
for (const err of validate.errors ?? []) {
|
|
704
|
+
const path = instancePathToField(err.instancePath, err.params);
|
|
705
|
+
errors.push({
|
|
706
|
+
path,
|
|
707
|
+
message: `Invalid ${path}: ${err.message ?? "validation error"}`,
|
|
708
|
+
severity: "error"
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
collectExistingLoaderErrors(document, errors);
|
|
713
|
+
collectNestedUnknownKeyWarnings(document, warnings);
|
|
714
|
+
return { errors, warnings };
|
|
715
|
+
}
|
|
716
|
+
async function diagnoseProjectConfig(root) {
|
|
717
|
+
const configPath = (0, import_node_path2.join)(root, "artifact-graph.config.yaml");
|
|
718
|
+
let raw;
|
|
719
|
+
try {
|
|
720
|
+
raw = await (0, import_promises2.readFile)(configPath, "utf-8");
|
|
721
|
+
} catch (error) {
|
|
722
|
+
if (error.code === "ENOENT") {
|
|
723
|
+
return { exists: false, errors: [], warnings: [] };
|
|
724
|
+
}
|
|
725
|
+
return {
|
|
726
|
+
exists: true,
|
|
727
|
+
errors: [{
|
|
728
|
+
path: "artifact-graph.config.yaml",
|
|
729
|
+
message: `Unable to read artifact-graph.config.yaml: ${error.message}`,
|
|
730
|
+
severity: "error"
|
|
731
|
+
}],
|
|
732
|
+
warnings: []
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
let document;
|
|
736
|
+
try {
|
|
737
|
+
document = import_js_yaml.default.load(raw) ?? {};
|
|
738
|
+
} catch (error) {
|
|
739
|
+
return {
|
|
740
|
+
exists: true,
|
|
741
|
+
errors: [{
|
|
742
|
+
path: "artifact-graph.config.yaml",
|
|
743
|
+
message: `Invalid artifact-graph.config.yaml: ${error.message}`,
|
|
744
|
+
severity: "error"
|
|
745
|
+
}],
|
|
746
|
+
warnings: []
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
const diagnosis = diagnoseConfigDocument(document);
|
|
750
|
+
return { exists: true, errors: diagnosis.errors, warnings: diagnosis.warnings };
|
|
751
|
+
}
|
|
752
|
+
var import_js_yaml, import_ajv, import_promises2, import_node_path2, 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;
|
|
753
|
+
var init_doctor = __esm({
|
|
754
|
+
"src/doctor.ts"() {
|
|
755
|
+
"use strict";
|
|
756
|
+
import_js_yaml = __toESM(require("js-yaml"), 1);
|
|
757
|
+
import_ajv = __toESM(require("ajv"), 1);
|
|
758
|
+
import_promises2 = require("fs/promises");
|
|
759
|
+
import_node_path2 = require("path");
|
|
760
|
+
init_index();
|
|
761
|
+
KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
762
|
+
"types",
|
|
763
|
+
"idPatterns",
|
|
764
|
+
"relationFields",
|
|
765
|
+
"allowedEdges",
|
|
766
|
+
"forbiddenEdges",
|
|
767
|
+
"statuses",
|
|
768
|
+
"idRanges",
|
|
769
|
+
"relationSemantics",
|
|
770
|
+
"statusViews",
|
|
771
|
+
"context",
|
|
772
|
+
"e2e"
|
|
773
|
+
]);
|
|
774
|
+
TYPE_OBJECT_KEYS = /* @__PURE__ */ new Set([
|
|
775
|
+
"paths",
|
|
776
|
+
"idPattern",
|
|
777
|
+
"displayName",
|
|
778
|
+
"role",
|
|
779
|
+
"layer",
|
|
780
|
+
"aliases",
|
|
781
|
+
"target",
|
|
782
|
+
"extraFields",
|
|
783
|
+
"format",
|
|
784
|
+
"idField"
|
|
785
|
+
]);
|
|
786
|
+
EXTRA_FIELD_KEYS = /* @__PURE__ */ new Set(["name", "type", "enum"]);
|
|
787
|
+
EDGE_RULE_KEYS = /* @__PURE__ */ new Set(["from", "to", "kind"]);
|
|
788
|
+
CONTEXT_KEYS = /* @__PURE__ */ new Set(["universal_baseline"]);
|
|
789
|
+
ID_RANGE_ENTRY_KEYS = /* @__PURE__ */ new Set(["prefix", "start", "end"]);
|
|
790
|
+
RELATION_SEMANTICS_KEYS = /* @__PURE__ */ new Set(["label", "targetTypes", "fields", "partial"]);
|
|
791
|
+
RELATION_PARTIAL_KEYS = /* @__PURE__ */ new Set(["sectionField"]);
|
|
792
|
+
E2E_KEYS = /* @__PURE__ */ new Set([
|
|
793
|
+
"executable_ref_warning",
|
|
794
|
+
"executable_ref_error",
|
|
795
|
+
"report_uncovered_scenarios",
|
|
796
|
+
"report_uncovered_features",
|
|
797
|
+
"scenario_waivers",
|
|
798
|
+
"feature_waivers",
|
|
799
|
+
"runners"
|
|
800
|
+
]);
|
|
801
|
+
WAIVER_KEYS = /* @__PURE__ */ new Set(["id", "reason"]);
|
|
802
|
+
RUNNER_KEYS = /* @__PURE__ */ new Set(["name", "kind", "root", "include", "exclude", "testIgnore"]);
|
|
803
|
+
EDGE_RULE_SCHEMA = {
|
|
804
|
+
type: "object",
|
|
805
|
+
additionalProperties: true,
|
|
806
|
+
required: ["from", "to", "kind"],
|
|
807
|
+
properties: {
|
|
808
|
+
from: { type: "string", minLength: 1 },
|
|
809
|
+
to: { type: "string", minLength: 1 },
|
|
810
|
+
kind: { type: "string", minLength: 1 }
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
EXTRA_FIELD_SCHEMA = {
|
|
814
|
+
type: "object",
|
|
815
|
+
additionalProperties: true,
|
|
816
|
+
required: ["name", "type"],
|
|
817
|
+
properties: {
|
|
818
|
+
name: { type: "string", minLength: 1 },
|
|
819
|
+
type: { type: "string", enum: ["string", "number", "boolean", "enum"] },
|
|
820
|
+
enum: {
|
|
821
|
+
type: "array",
|
|
822
|
+
items: {
|
|
823
|
+
anyOf: [
|
|
824
|
+
{ type: "string" },
|
|
825
|
+
{ type: "number" },
|
|
826
|
+
{ type: "boolean" }
|
|
827
|
+
]
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
ID_RANGE_ENTRY_SCHEMA = {
|
|
833
|
+
type: "object",
|
|
834
|
+
additionalProperties: true,
|
|
835
|
+
required: ["prefix", "start", "end"],
|
|
836
|
+
properties: {
|
|
837
|
+
prefix: { type: "string" },
|
|
838
|
+
start: { type: "number" },
|
|
839
|
+
end: { type: "number" }
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
CONFIG_SHAPE_SCHEMA = {
|
|
843
|
+
type: "object",
|
|
844
|
+
additionalProperties: true,
|
|
845
|
+
properties: {
|
|
846
|
+
statuses: { type: "array", items: { type: "string" } },
|
|
847
|
+
allowedEdges: {
|
|
848
|
+
anyOf: [
|
|
849
|
+
{ type: "null" },
|
|
850
|
+
{ type: "array", items: EDGE_RULE_SCHEMA }
|
|
851
|
+
]
|
|
852
|
+
},
|
|
853
|
+
forbiddenEdges: { type: "array", items: EDGE_RULE_SCHEMA },
|
|
854
|
+
idPatterns: {
|
|
855
|
+
type: "object",
|
|
856
|
+
additionalProperties: { type: "string" }
|
|
857
|
+
},
|
|
858
|
+
relationFields: {
|
|
859
|
+
type: "object",
|
|
860
|
+
additionalProperties: { type: "array", items: { type: "string" } }
|
|
861
|
+
},
|
|
862
|
+
context: {
|
|
863
|
+
type: "object",
|
|
864
|
+
additionalProperties: true,
|
|
865
|
+
properties: {
|
|
866
|
+
universal_baseline: { type: "boolean" }
|
|
867
|
+
}
|
|
868
|
+
},
|
|
869
|
+
idRanges: {
|
|
870
|
+
type: "object",
|
|
871
|
+
additionalProperties: {
|
|
872
|
+
type: "object",
|
|
873
|
+
additionalProperties: ID_RANGE_ENTRY_SCHEMA
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
types: {
|
|
877
|
+
type: "object",
|
|
878
|
+
additionalProperties: {
|
|
879
|
+
type: "object",
|
|
880
|
+
additionalProperties: true,
|
|
881
|
+
properties: {
|
|
882
|
+
paths: { type: "array", items: { type: "string" } },
|
|
883
|
+
idPattern: { type: "string" },
|
|
884
|
+
displayName: { type: "string" },
|
|
885
|
+
role: { type: "string" },
|
|
886
|
+
layer: { type: "string" },
|
|
887
|
+
aliases: { type: "array", items: { type: "string" } },
|
|
888
|
+
target: { type: "boolean" },
|
|
889
|
+
extraFields: { type: "array", items: EXTRA_FIELD_SCHEMA }
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
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.";
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
|
|
400
899
|
// src/target-selector.ts
|
|
401
900
|
function parseTargetSelector(value) {
|
|
402
901
|
const separator = value.indexOf(":");
|
|
@@ -662,7 +1161,7 @@ async function auditVersionLock(root, lockPath = VERSION_LOCK_PATH, graph, confi
|
|
|
662
1161
|
for (const entry of lock.locks) {
|
|
663
1162
|
if (entry.kind !== "verifies") continue;
|
|
664
1163
|
const sourcePath = entry.source.path;
|
|
665
|
-
const fullSourcePath = (0,
|
|
1164
|
+
const fullSourcePath = (0, import_node_path3.join)(root, sourcePath);
|
|
666
1165
|
if (!(0, import_node_fs.existsSync)(fullSourcePath)) continue;
|
|
667
1166
|
let liveness = livenessCache.get(sourcePath);
|
|
668
1167
|
if (liveness === void 0) {
|
|
@@ -757,14 +1256,14 @@ async function auditVersionLock(root, lockPath = VERSION_LOCK_PATH, graph, confi
|
|
|
757
1256
|
currentArtifactHash: targetNode.contentHash
|
|
758
1257
|
});
|
|
759
1258
|
}
|
|
760
|
-
if (!(0, import_node_fs.existsSync)((0,
|
|
1259
|
+
if (!(0, import_node_fs.existsSync)((0, import_node_path3.join)(root, sourceNode.path))) {
|
|
761
1260
|
entryIssues.push({
|
|
762
1261
|
status: "orphan_lock",
|
|
763
1262
|
edgeId: relEdgeId,
|
|
764
1263
|
message: `Artifact relation source file ${sourceNode.path} no longer exists`
|
|
765
1264
|
});
|
|
766
1265
|
}
|
|
767
|
-
if (!(0, import_node_fs.existsSync)((0,
|
|
1266
|
+
if (!(0, import_node_fs.existsSync)((0, import_node_path3.join)(root, targetNode.path))) {
|
|
768
1267
|
entryIssues.push({
|
|
769
1268
|
status: "orphan_lock",
|
|
770
1269
|
edgeId: relEdgeId,
|
|
@@ -1371,7 +1870,7 @@ function renderTraceVersionMarkdown(result) {
|
|
|
1371
1870
|
async function readVersionLock(root, lockPath) {
|
|
1372
1871
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1373
1872
|
try {
|
|
1374
|
-
const raw = await (0,
|
|
1873
|
+
const raw = await (0, import_promises3.readFile)((0, import_node_path3.join)(root, safeLockPath), "utf-8");
|
|
1375
1874
|
let parsed;
|
|
1376
1875
|
try {
|
|
1377
1876
|
parsed = JSON.parse(raw);
|
|
@@ -1530,9 +2029,9 @@ function requireSafeRelativePath(value, path) {
|
|
|
1530
2029
|
}
|
|
1531
2030
|
async function writeVersionLock(root, lockPath, lock) {
|
|
1532
2031
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1533
|
-
const fullPath = (0,
|
|
1534
|
-
await (0,
|
|
1535
|
-
await (0,
|
|
2032
|
+
const fullPath = (0, import_node_path3.join)(root, safeLockPath);
|
|
2033
|
+
await (0, import_promises3.mkdir)((0, import_node_path3.dirname)(fullPath), { recursive: true });
|
|
2034
|
+
await (0, import_promises3.writeFile)(fullPath, `${JSON.stringify(lock, null, 2)}
|
|
1536
2035
|
`);
|
|
1537
2036
|
}
|
|
1538
2037
|
function implementationEdges(index) {
|
|
@@ -1713,14 +2212,14 @@ async function hashRelativePath(root, path, cache) {
|
|
|
1713
2212
|
const normalized = normalizeRelativePath(root, path);
|
|
1714
2213
|
const cached = cache.get(normalized);
|
|
1715
2214
|
if (cached) return cached;
|
|
1716
|
-
const content = await (0,
|
|
2215
|
+
const content = await (0, import_promises3.readFile)((0, import_node_path3.join)(root, normalized));
|
|
1717
2216
|
const hash = `sha256:${(0, import_node_crypto.createHash)("sha256").update(content).digest("hex")}`;
|
|
1718
2217
|
cache.set(normalized, hash);
|
|
1719
2218
|
return hash;
|
|
1720
2219
|
}
|
|
1721
2220
|
function normalizeRelativePath(root, path) {
|
|
1722
2221
|
const normalized = path.replace(/\\/g, "/");
|
|
1723
|
-
const relativePath = normalized.startsWith("/") ? (0,
|
|
2222
|
+
const relativePath = normalized.startsWith("/") ? (0, import_node_path3.relative)(root, normalized).replace(/\\/g, "/") : normalized.replace(/^\.\//, "");
|
|
1724
2223
|
if (relativePath === ".." || relativePath.startsWith("../")) {
|
|
1725
2224
|
throw new Error(`Path is outside root: ${path}`);
|
|
1726
2225
|
}
|
|
@@ -1736,10 +2235,10 @@ async function getTestFileRunnerLiveness(root, filePath, config) {
|
|
|
1736
2235
|
if (!/e2e/i.test(filePath) && !/\.e2e\./i.test(filePath)) {
|
|
1737
2236
|
return "active";
|
|
1738
2237
|
}
|
|
1739
|
-
const fullSourcePath = (0,
|
|
2238
|
+
const fullSourcePath = (0, import_node_path3.join)(root, filePath);
|
|
1740
2239
|
if (!(0, import_node_fs.existsSync)(fullSourcePath)) return "inactive";
|
|
1741
2240
|
try {
|
|
1742
|
-
const content = await (0,
|
|
2241
|
+
const content = await (0, import_promises3.readFile)(fullSourcePath, "utf-8");
|
|
1743
2242
|
return /\/\/!?\s*@(?:e2e_test|tc)\s+/.test(content) ? "active" : "inactive";
|
|
1744
2243
|
} catch {
|
|
1745
2244
|
return "inactive";
|
|
@@ -1779,14 +2278,14 @@ async function isFileActiveInRunner(root, filePath, runner) {
|
|
|
1779
2278
|
function sortUnique2(items) {
|
|
1780
2279
|
return [...new Set(items)].sort((left, right) => left.localeCompare(right));
|
|
1781
2280
|
}
|
|
1782
|
-
var import_node_crypto, import_node_fs,
|
|
2281
|
+
var import_node_crypto, import_node_fs, import_promises3, import_node_path3, VERSION_LOCK_PATH, VERSION_INDEX_SCHEMA_VERSION, VERSION_LOCK_SCHEMA_VERSION, LIVENESS_MESSAGE_PREFIX, VERSION_LOCK_STATUS_LABELS;
|
|
1783
2282
|
var init_versioned_traceability = __esm({
|
|
1784
2283
|
"src/versioned-traceability.ts"() {
|
|
1785
2284
|
"use strict";
|
|
1786
2285
|
import_node_crypto = require("crypto");
|
|
1787
2286
|
import_node_fs = require("fs");
|
|
1788
|
-
|
|
1789
|
-
|
|
2287
|
+
import_promises3 = require("fs/promises");
|
|
2288
|
+
import_node_path3 = require("path");
|
|
1790
2289
|
init_index();
|
|
1791
2290
|
init_glob_matcher();
|
|
1792
2291
|
VERSION_LOCK_PATH = "artifacts/traceability-version-lock.json";
|
|
@@ -1807,7 +2306,7 @@ var init_versioned_traceability = __esm({
|
|
|
1807
2306
|
|
|
1808
2307
|
// src/impact.ts
|
|
1809
2308
|
async function computeImpact(root, options = {}) {
|
|
1810
|
-
const absoluteRoot = (0,
|
|
2309
|
+
const absoluteRoot = (0, import_node_path4.resolve)(root);
|
|
1811
2310
|
const mode = options.mode ?? "worktree";
|
|
1812
2311
|
if (mode === "base" && !options.base) throw new Error("Impact mode base requires a base ref.");
|
|
1813
2312
|
if (mode === "paths" && !options.paths) throw new Error("Impact mode paths requires paths.");
|
|
@@ -1879,8 +2378,8 @@ function normalizeExplicitPaths(root, paths) {
|
|
|
1879
2378
|
const normalized = paths.map((input) => {
|
|
1880
2379
|
const value = input.trim();
|
|
1881
2380
|
if (!value) return "";
|
|
1882
|
-
const absolutePath = (0,
|
|
1883
|
-
const projectRelative = (0,
|
|
2381
|
+
const absolutePath = (0, import_node_path4.isAbsolute)(value) ? (0, import_node_path4.normalize)(value) : (0, import_node_path4.resolve)(root, value);
|
|
2382
|
+
const projectRelative = (0, import_node_path4.relative)(root, absolutePath);
|
|
1884
2383
|
const result = projectRelative.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1885
2384
|
if (result === ".." || result.startsWith("../") || result.startsWith("/")) {
|
|
1886
2385
|
throw new Error(`Impact path is outside project root: ${input}`);
|
|
@@ -1905,11 +2404,11 @@ function toEdgeRef(candidate) {
|
|
|
1905
2404
|
...candidate.attrs ? { attrs: candidate.attrs } : {}
|
|
1906
2405
|
};
|
|
1907
2406
|
}
|
|
1908
|
-
var
|
|
2407
|
+
var import_node_path4;
|
|
1909
2408
|
var init_impact = __esm({
|
|
1910
2409
|
"src/impact.ts"() {
|
|
1911
2410
|
"use strict";
|
|
1912
|
-
|
|
2411
|
+
import_node_path4 = require("path");
|
|
1913
2412
|
init_index();
|
|
1914
2413
|
init_git_changes();
|
|
1915
2414
|
init_versioned_traceability();
|
|
@@ -1918,7 +2417,7 @@ var init_impact = __esm({
|
|
|
1918
2417
|
|
|
1919
2418
|
// src/coverage.ts
|
|
1920
2419
|
async function computeCoverageBoundary(root, opts = {}) {
|
|
1921
|
-
const absoluteRoot = (0,
|
|
2420
|
+
const absoluteRoot = (0, import_node_path5.resolve)(root);
|
|
1922
2421
|
const schema = opts.schema ?? await loadConfig(absoluteRoot);
|
|
1923
2422
|
const graph = await scanArtifacts(absoluteRoot, schema);
|
|
1924
2423
|
const issues = validateGraph(graph, schema);
|
|
@@ -2020,11 +2519,11 @@ function renderCoverageBoundaryMarkdown(report) {
|
|
|
2020
2519
|
function normalizeInputList(input) {
|
|
2021
2520
|
return [...new Set(input.map((item) => item.trim().replace(/\\/g, "/").replace(/^\.\//, "")).filter(Boolean))].sort((left, right) => left.localeCompare(right));
|
|
2022
2521
|
}
|
|
2023
|
-
var
|
|
2522
|
+
var import_node_path5;
|
|
2024
2523
|
var init_coverage = __esm({
|
|
2025
2524
|
"src/coverage.ts"() {
|
|
2026
2525
|
"use strict";
|
|
2027
|
-
|
|
2526
|
+
import_node_path5 = require("path");
|
|
2028
2527
|
init_index();
|
|
2029
2528
|
init_impact();
|
|
2030
2529
|
init_versioned_traceability();
|
|
@@ -2590,14 +3089,14 @@ async function auditSingleTarget(target, graph, options) {
|
|
|
2590
3089
|
const fmt = options.format ?? "markdown";
|
|
2591
3090
|
const ext = fmt === "json" ? "json" : "md";
|
|
2592
3091
|
const filename = `${target.type}-${target.id}.packet.${ext}`;
|
|
2593
|
-
const outPath = (0,
|
|
3092
|
+
const outPath = (0, import_node_path6.join)(options.outDir, filename);
|
|
2594
3093
|
let content;
|
|
2595
3094
|
if (fmt === "json") {
|
|
2596
3095
|
content = JSON.stringify(packet, null, 2) + "\n";
|
|
2597
3096
|
} else {
|
|
2598
3097
|
content = renderPacketMarkdown(packet);
|
|
2599
3098
|
}
|
|
2600
|
-
await (0,
|
|
3099
|
+
await (0, import_promises4.writeFile)(outPath, content, "utf-8");
|
|
2601
3100
|
entry.outputPath = outPath;
|
|
2602
3101
|
}
|
|
2603
3102
|
} catch (error) {
|
|
@@ -2618,7 +3117,7 @@ async function auditPackets(root, targets, options, graph) {
|
|
|
2618
3117
|
}
|
|
2619
3118
|
}
|
|
2620
3119
|
if (options.outDir) {
|
|
2621
|
-
await (0,
|
|
3120
|
+
await (0, import_promises4.mkdir)(options.outDir, { recursive: true });
|
|
2622
3121
|
}
|
|
2623
3122
|
const sampleSet = options.sampleTargets ? new Set(options.sampleTargets) : null;
|
|
2624
3123
|
const sampleOutputPaths = [];
|
|
@@ -2670,8 +3169,8 @@ async function auditPackets(root, targets, options, graph) {
|
|
|
2670
3169
|
...isCompact ? { summaryDetail: "compact", countsByType } : {}
|
|
2671
3170
|
};
|
|
2672
3171
|
if (options.outDir) {
|
|
2673
|
-
const summaryPath = (0,
|
|
2674
|
-
await (0,
|
|
3172
|
+
const summaryPath = (0, import_node_path6.join)(options.outDir, "summary.json");
|
|
3173
|
+
await (0, import_promises4.writeFile)(summaryPath, JSON.stringify(summary, null, 2) + "\n", "utf-8");
|
|
2675
3174
|
}
|
|
2676
3175
|
return summary;
|
|
2677
3176
|
}
|
|
@@ -2697,14 +3196,14 @@ async function discoverAndAuditPackets(root, options) {
|
|
|
2697
3196
|
universalBaseline: effectiveBaseline
|
|
2698
3197
|
}, graph);
|
|
2699
3198
|
}
|
|
2700
|
-
var
|
|
3199
|
+
var import_promises4, import_node_path6, VALID_TYPES, VALID_TYPES_LABEL;
|
|
2701
3200
|
var init_packet_audit = __esm({
|
|
2702
3201
|
"src/packet-audit.ts"() {
|
|
2703
3202
|
"use strict";
|
|
2704
3203
|
init_index();
|
|
2705
3204
|
init_packet_validator();
|
|
2706
|
-
|
|
2707
|
-
|
|
3205
|
+
import_promises4 = require("fs/promises");
|
|
3206
|
+
import_node_path6 = require("path");
|
|
2708
3207
|
VALID_TYPES = new Set(VALID_PACKET_TARGET_TYPES);
|
|
2709
3208
|
VALID_TYPES_LABEL = VALID_PACKET_TARGET_TYPES.join(", ");
|
|
2710
3209
|
}
|
|
@@ -3178,10 +3677,10 @@ function buildNativeBindingSuccessDiagnostic(probeContext) {
|
|
|
3178
3677
|
};
|
|
3179
3678
|
}
|
|
3180
3679
|
function findPackageRoot(anchorFile) {
|
|
3181
|
-
let dir = (0,
|
|
3680
|
+
let dir = (0, import_node_path7.dirname)(anchorFile);
|
|
3182
3681
|
for (; ; ) {
|
|
3183
|
-
if ((0, import_node_fs2.existsSync)((0,
|
|
3184
|
-
const parent = (0,
|
|
3682
|
+
if ((0, import_node_fs2.existsSync)((0, import_node_path7.join)(dir, "package.json"))) return dir;
|
|
3683
|
+
const parent = (0, import_node_path7.dirname)(dir);
|
|
3185
3684
|
if (parent === dir) return void 0;
|
|
3186
3685
|
dir = parent;
|
|
3187
3686
|
}
|
|
@@ -3197,9 +3696,9 @@ function abiPrebuiltHint(detail) {
|
|
|
3197
3696
|
return match ? `\uFF1Bprebuilt \u76EE\u6807 NODE_MODULE_VERSION=${match[1]}` : "";
|
|
3198
3697
|
}
|
|
3199
3698
|
function betterSqlite3PackagePresent(root) {
|
|
3200
|
-
const direct = (0,
|
|
3699
|
+
const direct = (0, import_node_path7.join)(root, "node_modules", "better-sqlite3", "package.json");
|
|
3201
3700
|
if ((0, import_node_fs2.existsSync)(direct)) return true;
|
|
3202
|
-
const pnpmDir = (0,
|
|
3701
|
+
const pnpmDir = (0, import_node_path7.join)(root, "node_modules", ".pnpm");
|
|
3203
3702
|
let entries;
|
|
3204
3703
|
try {
|
|
3205
3704
|
entries = (0, import_node_fs2.readdirSync)(pnpmDir);
|
|
@@ -3208,16 +3707,16 @@ function betterSqlite3PackagePresent(root) {
|
|
|
3208
3707
|
}
|
|
3209
3708
|
return entries.some((entry) => {
|
|
3210
3709
|
if (!entry.startsWith("better-sqlite3@")) return false;
|
|
3211
|
-
return (0, import_node_fs2.existsSync)((0,
|
|
3710
|
+
return (0, import_node_fs2.existsSync)((0, import_node_path7.join)(pnpmDir, entry, "node_modules", "better-sqlite3", "package.json"));
|
|
3212
3711
|
});
|
|
3213
3712
|
}
|
|
3214
|
-
var import_node_fs2, import_node_module,
|
|
3713
|
+
var import_node_fs2, import_node_module, import_node_path7, import_node_url, import_meta, PNPM_ALLOW_BUILDS_SNIPPET;
|
|
3215
3714
|
var init_native_binding_diagnostics = __esm({
|
|
3216
3715
|
"src/native-binding-diagnostics.ts"() {
|
|
3217
3716
|
"use strict";
|
|
3218
3717
|
import_node_fs2 = require("fs");
|
|
3219
3718
|
import_node_module = require("module");
|
|
3220
|
-
|
|
3719
|
+
import_node_path7 = require("path");
|
|
3221
3720
|
import_node_url = require("url");
|
|
3222
3721
|
import_meta = {};
|
|
3223
3722
|
PNPM_ALLOW_BUILDS_SNIPPET = "pnpm-workspace.yaml:\nallowBuilds:\n better-sqlite3: true";
|
|
@@ -3231,7 +3730,7 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3231
3730
|
const candidates = [
|
|
3232
3731
|
{
|
|
3233
3732
|
source: "node_modules",
|
|
3234
|
-
path: (0,
|
|
3733
|
+
path: (0, import_node_path8.join)(root, "node_modules/.bin/artifact-graph"),
|
|
3235
3734
|
exists: false
|
|
3236
3735
|
},
|
|
3237
3736
|
{
|
|
@@ -3264,8 +3763,8 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3264
3763
|
}
|
|
3265
3764
|
async function doctorArtifactChain(root, options = {}) {
|
|
3266
3765
|
const cli = await resolveArtifactGraphCli(root, options);
|
|
3267
|
-
const configPath = (0,
|
|
3268
|
-
const lockPath = (0,
|
|
3766
|
+
const configPath = (0, import_node_path8.join)(root, "artifact-graph.config.yaml");
|
|
3767
|
+
const lockPath = (0, import_node_path8.join)(root, VERSION_LOCK_PATH);
|
|
3269
3768
|
const supportedCommands = cli.path ? await detectSupportedCommands(cli.path) : [];
|
|
3270
3769
|
const nodeCompatible = isNodeCompatible(process.versions.node);
|
|
3271
3770
|
const pnpmVersion = await detectPnpmVersion();
|
|
@@ -3285,12 +3784,28 @@ async function doctorArtifactChain(root, options = {}) {
|
|
|
3285
3784
|
probedFrom
|
|
3286
3785
|
};
|
|
3287
3786
|
const nativeBinding = probe.ok ? { ok: true, ...buildNativeBindingSuccessDiagnostic(probeContext) } : { ok: false, ...buildNativeBindingDiagnostic(probe, probeContext) };
|
|
3787
|
+
const configDiagnosis = await diagnoseProjectConfig(root);
|
|
3788
|
+
const configShapeMessages = [
|
|
3789
|
+
...configDiagnosis.errors.map((item) => item.message),
|
|
3790
|
+
...configDiagnosis.warnings.map((item) => item.message)
|
|
3791
|
+
];
|
|
3792
|
+
const loadConfigMessages = [];
|
|
3793
|
+
if (configDiagnosis.exists && configDiagnosis.errors.length === 0) {
|
|
3794
|
+
try {
|
|
3795
|
+
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_index(), index_exports));
|
|
3796
|
+
await loadConfig2(root);
|
|
3797
|
+
} catch (error) {
|
|
3798
|
+
loadConfigMessages.push(error.message);
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3288
3801
|
const warnings = [
|
|
3289
3802
|
...cli.warnings,
|
|
3290
3803
|
...nodeCompatible ? [] : [`Node.js ${process.versions.node} does not satisfy ${REQUIRED_NODE_VERSION}.`],
|
|
3291
3804
|
...probe.ok ? [] : [
|
|
3292
3805
|
`better-sqlite3 binding probe FAILED at stage "${probe.failedStage}" (cause ${probe.cause}): ${probe.suggestion}`
|
|
3293
|
-
]
|
|
3806
|
+
],
|
|
3807
|
+
...configShapeMessages,
|
|
3808
|
+
...loadConfigMessages
|
|
3294
3809
|
];
|
|
3295
3810
|
return {
|
|
3296
3811
|
schemaVersion: "1.0",
|
|
@@ -3384,7 +3899,7 @@ ${maybe.stderr ?? ""}`;
|
|
|
3384
3899
|
}
|
|
3385
3900
|
async function pathExists(path) {
|
|
3386
3901
|
try {
|
|
3387
|
-
await (0,
|
|
3902
|
+
await (0, import_promises5.access)(path, import_node_fs3.constants.R_OK);
|
|
3388
3903
|
return true;
|
|
3389
3904
|
} catch {
|
|
3390
3905
|
return false;
|
|
@@ -3400,7 +3915,7 @@ async function findCommandOnPath(command) {
|
|
|
3400
3915
|
}
|
|
3401
3916
|
}
|
|
3402
3917
|
function resolveCandidatePath(root, candidatePath) {
|
|
3403
|
-
return (0,
|
|
3918
|
+
return (0, import_node_path8.isAbsolute)(candidatePath) ? candidatePath : (0, import_node_path8.resolve)(root, candidatePath);
|
|
3404
3919
|
}
|
|
3405
3920
|
function isNodeCompatible(version) {
|
|
3406
3921
|
const match = /^(\d+)\.(\d+)\.(\d+)(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
@@ -3442,7 +3957,7 @@ function bindingInstallRoot(cli, _root) {
|
|
|
3442
3957
|
}
|
|
3443
3958
|
function resolveCliInstallAnchor(cliPath) {
|
|
3444
3959
|
const real = safeRealpath(cliPath);
|
|
3445
|
-
if ((0,
|
|
3960
|
+
if ((0, import_node_path8.basename)((0, import_node_path8.dirname)(real)) !== ".bin") return real;
|
|
3446
3961
|
const shimTarget = readBinShimTarget(real);
|
|
3447
3962
|
return shimTarget ? safeRealpath(shimTarget) : real;
|
|
3448
3963
|
}
|
|
@@ -3456,7 +3971,7 @@ function readBinShimTarget(shimPath) {
|
|
|
3456
3971
|
if (!content.startsWith("#!")) return void 0;
|
|
3457
3972
|
const match = /\$basedir\/(\.\.(?:\/[^"'\s]+)+\.js)/.exec(content);
|
|
3458
3973
|
if (!match) return void 0;
|
|
3459
|
-
return (0,
|
|
3974
|
+
return (0, import_node_path8.resolve)((0, import_node_path8.dirname)(shimPath), match[1]);
|
|
3460
3975
|
}
|
|
3461
3976
|
function safeRealpath(path) {
|
|
3462
3977
|
try {
|
|
@@ -3465,16 +3980,17 @@ function safeRealpath(path) {
|
|
|
3465
3980
|
return path;
|
|
3466
3981
|
}
|
|
3467
3982
|
}
|
|
3468
|
-
var import_node_child_process2, import_node_fs3,
|
|
3983
|
+
var import_node_child_process2, import_node_fs3, import_promises5, import_node_path8, import_node_util2, execFileAsync2, REQUIRED_NODE_VERSION, KNOWN_COMMANDS;
|
|
3469
3984
|
var init_cli_resolver = __esm({
|
|
3470
3985
|
"src/cli-resolver.ts"() {
|
|
3471
3986
|
"use strict";
|
|
3472
3987
|
import_node_child_process2 = require("child_process");
|
|
3473
3988
|
import_node_fs3 = require("fs");
|
|
3474
|
-
|
|
3475
|
-
|
|
3989
|
+
import_promises5 = require("fs/promises");
|
|
3990
|
+
import_node_path8 = require("path");
|
|
3476
3991
|
import_node_util2 = require("util");
|
|
3477
3992
|
init_versioned_traceability();
|
|
3993
|
+
init_doctor();
|
|
3478
3994
|
init_native_binding_diagnostics();
|
|
3479
3995
|
execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process2.execFile);
|
|
3480
3996
|
REQUIRED_NODE_VERSION = ">=22.22.2 <23";
|
|
@@ -3515,14 +4031,14 @@ async function resolveGitHookPath(root, hookName) {
|
|
|
3515
4031
|
]);
|
|
3516
4032
|
const value = stdout.trim();
|
|
3517
4033
|
if (!value) throw new Error(`Git returned an empty hook path for ${hookName}`);
|
|
3518
|
-
return (0,
|
|
4034
|
+
return (0, import_node_path9.isAbsolute)(value) ? (0, import_node_path9.resolve)(value) : (0, import_node_path9.resolve)(root, value);
|
|
3519
4035
|
}
|
|
3520
|
-
var import_node_child_process3,
|
|
4036
|
+
var import_node_child_process3, import_node_path9, import_node_util3, execFileAsync3;
|
|
3521
4037
|
var init_git_hook_path = __esm({
|
|
3522
4038
|
"src/git-hook-path.ts"() {
|
|
3523
4039
|
"use strict";
|
|
3524
4040
|
import_node_child_process3 = require("child_process");
|
|
3525
|
-
|
|
4041
|
+
import_node_path9 = require("path");
|
|
3526
4042
|
import_node_util3 = require("util");
|
|
3527
4043
|
execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
3528
4044
|
}
|
|
@@ -3745,7 +4261,7 @@ async function readHookSnapshot(hookPath) {
|
|
|
3745
4261
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
3746
4262
|
let metadata;
|
|
3747
4263
|
try {
|
|
3748
|
-
metadata = await (0,
|
|
4264
|
+
metadata = await (0, import_promises6.lstat)(hookPath, { bigint: true });
|
|
3749
4265
|
} catch (error) {
|
|
3750
4266
|
if (error.code === "ENOENT") {
|
|
3751
4267
|
return { kind: "missing", bytes: Buffer.alloc(0) };
|
|
@@ -3761,7 +4277,7 @@ async function readHookSnapshot(hookPath) {
|
|
|
3761
4277
|
size: metadata.size,
|
|
3762
4278
|
mtimeNs: metadata.mtimeNs,
|
|
3763
4279
|
mode: metadata.mode,
|
|
3764
|
-
linkTarget: await (0,
|
|
4280
|
+
linkTarget: await (0, import_promises6.readlink)(hookPath)
|
|
3765
4281
|
};
|
|
3766
4282
|
}
|
|
3767
4283
|
if (!metadata.isFile()) {
|
|
@@ -3777,7 +4293,7 @@ async function readHookSnapshot(hookPath) {
|
|
|
3777
4293
|
}
|
|
3778
4294
|
let handle;
|
|
3779
4295
|
try {
|
|
3780
|
-
handle = await (0,
|
|
4296
|
+
handle = await (0, import_promises6.open)(hookPath, import_node_fs4.constants.O_RDONLY | (import_node_fs4.constants.O_NOFOLLOW ?? 0));
|
|
3781
4297
|
const opened = await handle.stat({ bigint: true });
|
|
3782
4298
|
if (opened.dev !== metadata.dev || opened.ino !== metadata.ino) {
|
|
3783
4299
|
await handle.close();
|
|
@@ -3835,15 +4351,15 @@ async function removeHookAtomically(hookPath, snapshot) {
|
|
|
3835
4351
|
throw new ConcurrentHookModificationError(hookPath);
|
|
3836
4352
|
}
|
|
3837
4353
|
if (current.kind !== "missing") {
|
|
3838
|
-
await (0,
|
|
4354
|
+
await (0, import_promises6.unlink)(hookPath);
|
|
3839
4355
|
}
|
|
3840
4356
|
}
|
|
3841
4357
|
async function writeHookAtomically(hookPath, content, snapshot, mode) {
|
|
3842
|
-
await (0,
|
|
3843
|
-
const temporaryPath = (0,
|
|
4358
|
+
await (0, import_promises6.mkdir)((0, import_node_path10.dirname)(hookPath), { recursive: true });
|
|
4359
|
+
const temporaryPath = (0, import_node_path10.join)((0, import_node_path10.dirname)(hookPath), `.${(0, import_node_path10.basename)(hookPath)}.${(0, import_node_crypto2.randomUUID)()}.tmp`);
|
|
3844
4360
|
let temporaryExists = false;
|
|
3845
4361
|
try {
|
|
3846
|
-
const temporary = await (0,
|
|
4362
|
+
const temporary = await (0, import_promises6.open)(temporaryPath, "wx", mode);
|
|
3847
4363
|
temporaryExists = true;
|
|
3848
4364
|
try {
|
|
3849
4365
|
await temporary.writeFile(content);
|
|
@@ -3856,11 +4372,11 @@ async function writeHookAtomically(hookPath, content, snapshot, mode) {
|
|
|
3856
4372
|
if (!sameHookSnapshot(snapshot, current)) {
|
|
3857
4373
|
throw new ConcurrentHookModificationError(hookPath);
|
|
3858
4374
|
}
|
|
3859
|
-
await (0,
|
|
4375
|
+
await (0, import_promises6.rename)(temporaryPath, hookPath);
|
|
3860
4376
|
temporaryExists = false;
|
|
3861
4377
|
} finally {
|
|
3862
4378
|
if (temporaryExists) {
|
|
3863
|
-
await (0,
|
|
4379
|
+
await (0, import_promises6.unlink)(temporaryPath).catch((error) => {
|
|
3864
4380
|
if (error.code !== "ENOENT") {
|
|
3865
4381
|
throw error;
|
|
3866
4382
|
}
|
|
@@ -3886,14 +4402,14 @@ function findManagedRange(content, begin, end) {
|
|
|
3886
4402
|
end: endLine < 0 ? content.length : endLine + 1
|
|
3887
4403
|
};
|
|
3888
4404
|
}
|
|
3889
|
-
var import_node_fs4, import_node_crypto2,
|
|
4405
|
+
var import_node_fs4, import_node_crypto2, import_promises6, import_node_path10, DEFAULT_MARKER_ID, MANAGED_STATE_PREFIX, UnsupportedHookInterpreterError, SymlinkHookUnsupportedError, UnsupportedHookTypeError, InvalidManagedHookStateError, ConcurrentHookModificationError, HookTransactionRollbackError;
|
|
3890
4406
|
var init_hook_installer = __esm({
|
|
3891
4407
|
"src/hook-installer.ts"() {
|
|
3892
4408
|
"use strict";
|
|
3893
4409
|
import_node_fs4 = require("fs");
|
|
3894
4410
|
import_node_crypto2 = require("crypto");
|
|
3895
|
-
|
|
3896
|
-
|
|
4411
|
+
import_promises6 = require("fs/promises");
|
|
4412
|
+
import_node_path10 = require("path");
|
|
3897
4413
|
DEFAULT_MARKER_ID = "artifact-chain-assistant";
|
|
3898
4414
|
MANAGED_STATE_PREFIX = "# artifact-chain-assistant managed state v1:";
|
|
3899
4415
|
UnsupportedHookInterpreterError = class extends Error {
|
|
@@ -3985,9 +4501,9 @@ function harnessKind(error) {
|
|
|
3985
4501
|
return typeof details?.kind === "string" ? details.kind : void 0;
|
|
3986
4502
|
}
|
|
3987
4503
|
async function missingRequiredConfig(root) {
|
|
3988
|
-
const configPath = (0,
|
|
4504
|
+
const configPath = (0, import_node_path11.join)(root, "artifact-graph.config.yaml");
|
|
3989
4505
|
try {
|
|
3990
|
-
await (0,
|
|
4506
|
+
await (0, import_promises7.access)(configPath);
|
|
3991
4507
|
return void 0;
|
|
3992
4508
|
} catch (error) {
|
|
3993
4509
|
if (error.code === "ENOENT") {
|
|
@@ -4105,7 +4621,7 @@ function buildLimitations(checks) {
|
|
|
4105
4621
|
return [...new Set(limitations)];
|
|
4106
4622
|
}
|
|
4107
4623
|
function buildConclusion(root, checks) {
|
|
4108
|
-
const absoluteRoot = (0,
|
|
4624
|
+
const absoluteRoot = (0, import_node_path11.resolve)(root);
|
|
4109
4625
|
const mapped = mapDomain(checks);
|
|
4110
4626
|
const checked = checks.filter((check) => check.status === "completed").map((check) => check.name);
|
|
4111
4627
|
const limitations = buildLimitations(checks);
|
|
@@ -4158,11 +4674,11 @@ async function assertConclusionShape(conclusion) {
|
|
|
4158
4674
|
}
|
|
4159
4675
|
}
|
|
4160
4676
|
async function publishConclusion(absoluteOutput, conclusion) {
|
|
4161
|
-
if (!(0,
|
|
4677
|
+
if (!(0, import_node_path11.isAbsolute)(absoluteOutput)) {
|
|
4162
4678
|
return "--conclusion-output must be an absolute path";
|
|
4163
4679
|
}
|
|
4164
|
-
const outputRoot = (0,
|
|
4165
|
-
const relPath = (0,
|
|
4680
|
+
const outputRoot = (0, import_node_path11.dirname)(absoluteOutput);
|
|
4681
|
+
const relPath = (0, import_node_path11.basename)(absoluteOutput);
|
|
4166
4682
|
if (relPath.length === 0 || relPath === "." || relPath === "..") {
|
|
4167
4683
|
return "--conclusion-output must name a file";
|
|
4168
4684
|
}
|
|
@@ -4180,7 +4696,7 @@ async function publishConclusion(absoluteOutput, conclusion) {
|
|
|
4180
4696
|
}
|
|
4181
4697
|
}
|
|
4182
4698
|
async function runCheckProfessional(options) {
|
|
4183
|
-
const root = (0,
|
|
4699
|
+
const root = (0, import_node_path11.resolve)(options.root);
|
|
4184
4700
|
const configGap = await missingRequiredConfig(root);
|
|
4185
4701
|
const checks = configGap === void 0 ? await Promise.all([
|
|
4186
4702
|
settleCheck(CHECK_VALIDATE, () => runValidate(root)),
|
|
@@ -4196,10 +4712,10 @@ async function runCheckProfessional(options) {
|
|
|
4196
4712
|
if (options.conclusionOutput === void 0) {
|
|
4197
4713
|
return { conclusion };
|
|
4198
4714
|
}
|
|
4199
|
-
if (!(0,
|
|
4715
|
+
if (!(0, import_node_path11.isAbsolute)(options.conclusionOutput)) {
|
|
4200
4716
|
return { conclusion, writeError: "--conclusion-output must be an absolute path" };
|
|
4201
4717
|
}
|
|
4202
|
-
const writeError = await publishConclusion((0,
|
|
4718
|
+
const writeError = await publishConclusion((0, import_node_path11.resolve)(options.conclusionOutput), conclusion);
|
|
4203
4719
|
return { conclusion, ...writeError ? { writeError } : {} };
|
|
4204
4720
|
}
|
|
4205
4721
|
function asRecord(value) {
|
|
@@ -4302,13 +4818,13 @@ async function runReadProof(options) {
|
|
|
4302
4818
|
const exitCode = interpreted.status === "pass" ? 0 : interpreted.status === "not_pass" ? 1 : 2;
|
|
4303
4819
|
return { result: interpreted, exitCode };
|
|
4304
4820
|
}
|
|
4305
|
-
var
|
|
4821
|
+
var import_promises7, import_node_module2, import_node_path11, import_node_url2, import_meta2, GRAPH_PROVIDER_ID, GRAPH_PROVIDER_ENTRY, PROFESSIONAL_CONCLUSION_OBJECT, GRAPH_DOMAIN_CODES, KNOWN_DOMAIN_CODES, CHECK_VALIDATE, CHECK_LOCK, CHECK_COVERAGE, STANDING_LIMITATION, CONTRACTS_PACKAGE_NAME;
|
|
4306
4822
|
var init_professional_conclusion = __esm({
|
|
4307
4823
|
"src/professional-conclusion.ts"() {
|
|
4308
4824
|
"use strict";
|
|
4309
|
-
|
|
4825
|
+
import_promises7 = require("fs/promises");
|
|
4310
4826
|
import_node_module2 = require("module");
|
|
4311
|
-
|
|
4827
|
+
import_node_path11 = require("path");
|
|
4312
4828
|
import_node_url2 = require("url");
|
|
4313
4829
|
init_coverage();
|
|
4314
4830
|
init_index();
|
|
@@ -4933,7 +5449,7 @@ function validatePolicyCompatibility(policy, baseContract) {
|
|
|
4933
5449
|
};
|
|
4934
5450
|
}
|
|
4935
5451
|
async function loadContract(contractPath, options) {
|
|
4936
|
-
const rawContent = await (0,
|
|
5452
|
+
const rawContent = await (0, import_promises8.readFile)(contractPath, "utf-8");
|
|
4937
5453
|
let schema;
|
|
4938
5454
|
try {
|
|
4939
5455
|
schema = JSON.parse(rawContent);
|
|
@@ -4981,10 +5497,10 @@ async function loadContract(contractPath, options) {
|
|
|
4981
5497
|
}
|
|
4982
5498
|
async function loadContractsFromDirectory(contractsDir, options) {
|
|
4983
5499
|
const contracts = [];
|
|
4984
|
-
const entries = await (0,
|
|
5500
|
+
const entries = await (0, import_promises8.readdir)(contractsDir, { withFileTypes: true });
|
|
4985
5501
|
for (const entry of entries) {
|
|
4986
5502
|
if (entry.isDirectory()) {
|
|
4987
|
-
const schemaPath = (0,
|
|
5503
|
+
const schemaPath = (0, import_node_path12.join)(contractsDir, entry.name, "schema.json");
|
|
4988
5504
|
const contract = await loadContract(schemaPath, options);
|
|
4989
5505
|
contracts.push(contract);
|
|
4990
5506
|
}
|
|
@@ -4994,7 +5510,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
4994
5510
|
function getValidator(schema) {
|
|
4995
5511
|
const key = `${schema.$id || "default"}#${computeRevisionDigest(JSON.stringify(schema))}`;
|
|
4996
5512
|
if (!_validatorCache.has(key)) {
|
|
4997
|
-
const AjvCtor =
|
|
5513
|
+
const AjvCtor = import_ajv2.default;
|
|
4998
5514
|
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
4999
5515
|
_validatorCache.set(key, ajv.compile(schema));
|
|
5000
5516
|
}
|
|
@@ -5099,14 +5615,14 @@ async function loadContractCatalog(contractsDir, options) {
|
|
|
5099
5615
|
}
|
|
5100
5616
|
return catalog;
|
|
5101
5617
|
}
|
|
5102
|
-
var import_node_crypto3,
|
|
5618
|
+
var import_node_crypto3, import_promises8, import_node_path12, import_ajv2, CONTRACT_ERROR_CODES, ContractError, OFFICIAL_AUTHORITY, OFFICIAL_NAMESPACE_PATTERN, ContractRegistry, _validatorCache, E2E_NORMALIZER_CONFIG, ContractCatalog;
|
|
5103
5619
|
var init_contract_kernel = __esm({
|
|
5104
5620
|
"src/contract-kernel.ts"() {
|
|
5105
5621
|
"use strict";
|
|
5106
5622
|
import_node_crypto3 = require("crypto");
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5623
|
+
import_promises8 = require("fs/promises");
|
|
5624
|
+
import_node_path12 = require("path");
|
|
5625
|
+
import_ajv2 = __toESM(require("ajv"), 1);
|
|
5110
5626
|
CONTRACT_ERROR_CODES = {
|
|
5111
5627
|
/** Contract identity not found */
|
|
5112
5628
|
CONTRACT_NOT_FOUND: "CONTRACT_NOT_FOUND",
|
|
@@ -5588,13 +6104,13 @@ function rawDigest(value, path) {
|
|
|
5588
6104
|
async function resolveRealRoot(root) {
|
|
5589
6105
|
let canonical;
|
|
5590
6106
|
try {
|
|
5591
|
-
canonical = await (0,
|
|
6107
|
+
canonical = await (0, import_promises9.realpath)((0, import_node_path13.resolve)(root));
|
|
5592
6108
|
} catch (cause) {
|
|
5593
6109
|
return failure("ROOT_INVALID", `Project root cannot be resolved: ${cause.message}`);
|
|
5594
6110
|
}
|
|
5595
6111
|
let info;
|
|
5596
6112
|
try {
|
|
5597
|
-
info = await (0,
|
|
6113
|
+
info = await (0, import_promises9.lstat)(canonical);
|
|
5598
6114
|
} catch (cause) {
|
|
5599
6115
|
return failure("ROOT_INVALID", `Project root cannot be inspected: ${cause.message}`);
|
|
5600
6116
|
}
|
|
@@ -5614,7 +6130,7 @@ async function qualifyRestructureMechanism(root) {
|
|
|
5614
6130
|
if (!canonical.ok) return canonical;
|
|
5615
6131
|
let type;
|
|
5616
6132
|
try {
|
|
5617
|
-
type = (await (0,
|
|
6133
|
+
type = (await (0, import_promises9.statfs)(canonical.data)).type;
|
|
5618
6134
|
} catch (cause) {
|
|
5619
6135
|
return failure("APPLY_ENVIRONMENT_UNSUPPORTED", `Project root filesystem cannot be inspected: ${cause.message}`);
|
|
5620
6136
|
}
|
|
@@ -5627,8 +6143,8 @@ async function qualifyRestructureMechanism(root) {
|
|
|
5627
6143
|
return { ok: true, data: { root: canonical.data, filesystem: RESTRUCTURE_QUALIFIED_FILESYSTEM } };
|
|
5628
6144
|
}
|
|
5629
6145
|
async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
5630
|
-
const target = (0,
|
|
5631
|
-
const current = async () => (0,
|
|
6146
|
+
const target = (0, import_node_path13.join)(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
|
|
6147
|
+
const current = async () => (0, import_promises9.lstat)(target).catch((cause) => cause.code === "ENOENT" ? null : Promise.reject(cause));
|
|
5632
6148
|
let info = await current();
|
|
5633
6149
|
if (info === null) {
|
|
5634
6150
|
if (!options.create) {
|
|
@@ -5639,7 +6155,7 @@ async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
|
5639
6155
|
}
|
|
5640
6156
|
let created = false;
|
|
5641
6157
|
try {
|
|
5642
|
-
await (0,
|
|
6158
|
+
await (0, import_promises9.mkdir)(target, { mode: RESTRUCTURE_RECOVERY_ROOT_MODE });
|
|
5643
6159
|
created = true;
|
|
5644
6160
|
} catch (cause) {
|
|
5645
6161
|
if (cause.code !== "EEXIST") {
|
|
@@ -5652,7 +6168,7 @@ async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
|
5652
6168
|
return failure("MECHANISM_ROOT_UNSAFE", `${target} must be one real directory, not a link or special entry`);
|
|
5653
6169
|
}
|
|
5654
6170
|
if (created && (info.mode & 4095) !== RESTRUCTURE_RECOVERY_ROOT_MODE) {
|
|
5655
|
-
await (0,
|
|
6171
|
+
await (0, import_promises9.chmod)(target, RESTRUCTURE_RECOVERY_ROOT_MODE);
|
|
5656
6172
|
info = await current();
|
|
5657
6173
|
if (info === null || info.isSymbolicLink() || !info.isDirectory()) {
|
|
5658
6174
|
return failure("MECHANISM_ROOT_UNSAFE", `${target} must be one real directory, not a link or special entry`);
|
|
@@ -5741,7 +6257,7 @@ async function applyRestructureFileSet(canonicalRoot, plan, options) {
|
|
|
5741
6257
|
return await verifyMechanismResult(raw);
|
|
5742
6258
|
}
|
|
5743
6259
|
async function observeRestructureJournal(canonicalRoot) {
|
|
5744
|
-
const journalRoot = (0,
|
|
6260
|
+
const journalRoot = (0, import_node_path13.join)(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
|
|
5745
6261
|
const module2 = await loadFoundationModule();
|
|
5746
6262
|
try {
|
|
5747
6263
|
return { ok: true, data: await module2.inspectStateStoreLock(journalRoot, { recoveryObservation: true }) };
|
|
@@ -5928,13 +6444,13 @@ function projectRestructureFileSetResult(result, planPath = "", planDigest = "")
|
|
|
5928
6444
|
const reading = result.operation === "apply" ? applyProjection(result) : result.operation === "recover" ? recoverProjection(result) : pruneProjection(result);
|
|
5929
6445
|
return { ...base, ...reading };
|
|
5930
6446
|
}
|
|
5931
|
-
var import_node_crypto4,
|
|
6447
|
+
var import_node_crypto4, import_promises9, import_node_path13, RESTRUCTURE_RECOVERY_REL_PATH, RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH, RESTRUCTURE_RECOVERY_ROOT_MODE, RESTRUCTURE_QUALIFIED_PLATFORM, RESTRUCTURE_QUALIFIED_ARCH, RESTRUCTURE_QUALIFIED_FILESYSTEM, APFS_STATFS_TYPE, DIGEST_PREFIX, RAW_SHA256_PATTERN, FOUNDATION_PACKAGE_NAME, CONTRACTS_PACKAGE_NAME2, FILE_SET_RESULT_OBJECT, APPLY_MAINTENANCE_ERROR_KINDS;
|
|
5932
6448
|
var init_restructure_file_set = __esm({
|
|
5933
6449
|
"src/restructure-file-set.ts"() {
|
|
5934
6450
|
"use strict";
|
|
5935
6451
|
import_node_crypto4 = require("crypto");
|
|
5936
|
-
|
|
5937
|
-
|
|
6452
|
+
import_promises9 = require("fs/promises");
|
|
6453
|
+
import_node_path13 = require("path");
|
|
5938
6454
|
RESTRUCTURE_RECOVERY_REL_PATH = ".foundation-file-apply";
|
|
5939
6455
|
RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH = `${RESTRUCTURE_RECOVERY_REL_PATH}/journal`;
|
|
5940
6456
|
RESTRUCTURE_RECOVERY_ROOT_MODE = 448;
|
|
@@ -5966,7 +6482,7 @@ function digestRestructureValue(value) {
|
|
|
5966
6482
|
return digestBytes(canonicalJson(value));
|
|
5967
6483
|
}
|
|
5968
6484
|
function normalizeRelativePath2(value) {
|
|
5969
|
-
if (!value || value.includes("\0") || (0,
|
|
6485
|
+
if (!value || value.includes("\0") || (0, import_node_path14.isAbsolute)(value)) return void 0;
|
|
5970
6486
|
const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
5971
6487
|
if (!normalized || normalized === "." || normalized.split("/").some((part) => part === ".." || part === "")) return void 0;
|
|
5972
6488
|
return normalized;
|
|
@@ -5980,13 +6496,13 @@ function isPathAllowed(path, allowed) {
|
|
|
5980
6496
|
async function readContainedFileWithMode(root, path) {
|
|
5981
6497
|
const normalized = normalizeRelativePath2(path);
|
|
5982
6498
|
if (!normalized) throw new Error(`Path must be a project-relative path without traversal: ${path}`);
|
|
5983
|
-
const absoluteRoot = (0,
|
|
5984
|
-
const absolutePath = (0,
|
|
5985
|
-
if ((0,
|
|
6499
|
+
const absoluteRoot = (0, import_node_path14.resolve)(root);
|
|
6500
|
+
const absolutePath = (0, import_node_path14.resolve)(absoluteRoot, normalized);
|
|
6501
|
+
if ((0, import_node_path14.relative)(absoluteRoot, absolutePath).startsWith("..")) throw new Error(`Path escapes project root: ${path}`);
|
|
5986
6502
|
try {
|
|
5987
|
-
const info = await (0,
|
|
6503
|
+
const info = await (0, import_promises10.lstat)(absolutePath);
|
|
5988
6504
|
if (info.isSymbolicLink() || !info.isFile()) throw new Error(`Path is not a regular file: ${path}`);
|
|
5989
|
-
return { buffer: await (0,
|
|
6505
|
+
return { buffer: await (0, import_promises10.readFile)(absolutePath), mode: info.mode & MAX_POSIX_MODE };
|
|
5990
6506
|
} catch (error) {
|
|
5991
6507
|
if (error.code === "ENOENT") return void 0;
|
|
5992
6508
|
throw error;
|
|
@@ -6014,7 +6530,7 @@ async function configSnapshot(root) {
|
|
|
6014
6530
|
return snapshotFile(root, "artifact-graph.config.yaml");
|
|
6015
6531
|
}
|
|
6016
6532
|
async function loadRestructureContract(name) {
|
|
6017
|
-
return loadContract((0,
|
|
6533
|
+
return loadContract((0, import_node_path14.join)(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
|
|
6018
6534
|
}
|
|
6019
6535
|
async function validateDomainContract(name, value) {
|
|
6020
6536
|
const contract = await loadRestructureContract(name);
|
|
@@ -6275,7 +6791,7 @@ function splitMarkdownTarget(target) {
|
|
|
6275
6791
|
}
|
|
6276
6792
|
async function pathExists2(absolutePath) {
|
|
6277
6793
|
try {
|
|
6278
|
-
await (0,
|
|
6794
|
+
await (0, import_promises10.lstat)(absolutePath);
|
|
6279
6795
|
return true;
|
|
6280
6796
|
} catch {
|
|
6281
6797
|
return false;
|
|
@@ -6283,20 +6799,20 @@ async function pathExists2(absolutePath) {
|
|
|
6283
6799
|
}
|
|
6284
6800
|
async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
6285
6801
|
const migrationPaths = [.../* @__PURE__ */ new Set([...sourcePaths, ...targetPaths])];
|
|
6286
|
-
const migrationNames = new Set(migrationPaths.map((path) =>
|
|
6287
|
-
const directories = new Set(migrationPaths.map((path) =>
|
|
6802
|
+
const migrationNames = new Set(migrationPaths.map((path) => import_node_path14.posix.basename(path)));
|
|
6803
|
+
const directories = new Set(migrationPaths.map((path) => import_node_path14.posix.dirname(path)));
|
|
6288
6804
|
const findings = [];
|
|
6289
6805
|
async function visit(directory) {
|
|
6290
|
-
for (const entry of await (0,
|
|
6806
|
+
for (const entry of await (0, import_promises10.readdir)(directory, { withFileTypes: true })) {
|
|
6291
6807
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6292
|
-
const absolute = (0,
|
|
6808
|
+
const absolute = (0, import_node_path14.join)(directory, entry.name);
|
|
6293
6809
|
if (entry.isDirectory()) {
|
|
6294
6810
|
await visit(absolute);
|
|
6295
6811
|
continue;
|
|
6296
6812
|
}
|
|
6297
6813
|
if (!entry.isFile() || !TEXT_EXTENSIONS.test(entry.name)) continue;
|
|
6298
|
-
const path = (0,
|
|
6299
|
-
const raw = await (0,
|
|
6814
|
+
const path = (0, import_node_path14.relative)(root, absolute).replace(/\\/g, "/");
|
|
6815
|
+
const raw = await (0, import_promises10.readFile)(absolute, "utf8");
|
|
6300
6816
|
const namesTheMigration = migrationPaths.some((reference) => raw.includes(reference));
|
|
6301
6817
|
const lines = raw.split(/\r?\n/);
|
|
6302
6818
|
for (const [index, line] of lines.entries()) {
|
|
@@ -6308,8 +6824,8 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6308
6824
|
const literal = match[0];
|
|
6309
6825
|
const { path: linkPath, anchor } = splitMarkdownTarget(match[2]);
|
|
6310
6826
|
if (!linkPath || linkPath.startsWith("/") || /^[a-z][a-z0-9+.-]*:/i.test(linkPath)) continue;
|
|
6311
|
-
if (!migrationNames.has(
|
|
6312
|
-
const resolved = normalizeRelativePath2(
|
|
6827
|
+
if (!migrationNames.has(import_node_path14.posix.basename(linkPath))) continue;
|
|
6828
|
+
const resolved = normalizeRelativePath2(import_node_path14.posix.join(import_node_path14.posix.dirname(path), linkPath));
|
|
6313
6829
|
if (!resolved || targetPaths.includes(resolved)) continue;
|
|
6314
6830
|
if (anchor) {
|
|
6315
6831
|
findings.push(finding(
|
|
@@ -6318,7 +6834,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6318
6834
|
path,
|
|
6319
6835
|
lineNumber
|
|
6320
6836
|
));
|
|
6321
|
-
} else if (!await pathExists2((0,
|
|
6837
|
+
} else if (!await pathExists2((0, import_node_path14.resolve)(root, resolved))) {
|
|
6322
6838
|
findings.push(finding(
|
|
6323
6839
|
"SIBLING_RELATIVE_REFERENCE_UNRESOLVED",
|
|
6324
6840
|
`The relative reference "${literal}" does not resolve inside the project although its file name matches a migration path; its intended destination must be decided explicitly`,
|
|
@@ -6343,7 +6859,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6343
6859
|
}
|
|
6344
6860
|
}
|
|
6345
6861
|
}
|
|
6346
|
-
await visit((0,
|
|
6862
|
+
await visit((0, import_node_path14.resolve)(root));
|
|
6347
6863
|
const unique = new Map(findings.map((item) => [`${item.code} ${item.path} ${item.line} ${item.message}`, item]));
|
|
6348
6864
|
return [...unique.values()].sort((left, right) => (left.path ?? "").localeCompare(right.path ?? "") || (left.line ?? 0) - (right.line ?? 0) || left.code.localeCompare(right.code));
|
|
6349
6865
|
}
|
|
@@ -6359,15 +6875,15 @@ function mergeFindings(target, additions) {
|
|
|
6359
6875
|
async function scanConsumerCandidates(root, references, excludedPaths = /* @__PURE__ */ new Set()) {
|
|
6360
6876
|
const results = [];
|
|
6361
6877
|
async function visit(directory) {
|
|
6362
|
-
for (const entry of await (0,
|
|
6878
|
+
for (const entry of await (0, import_promises10.readdir)(directory, { withFileTypes: true })) {
|
|
6363
6879
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6364
|
-
const absolute = (0,
|
|
6880
|
+
const absolute = (0, import_node_path14.join)(directory, entry.name);
|
|
6365
6881
|
if (entry.isDirectory()) {
|
|
6366
6882
|
await visit(absolute);
|
|
6367
6883
|
} else if (entry.isFile() && TEXT_EXTENSIONS.test(entry.name)) {
|
|
6368
|
-
const path = (0,
|
|
6884
|
+
const path = (0, import_node_path14.relative)(root, absolute).replace(/\\/g, "/");
|
|
6369
6885
|
if (excludedPaths.has(path)) continue;
|
|
6370
|
-
const raw = await (0,
|
|
6886
|
+
const raw = await (0, import_promises10.readFile)(absolute, "utf8");
|
|
6371
6887
|
raw.split(/\r?\n/).forEach((line, index) => {
|
|
6372
6888
|
for (const reference of references) {
|
|
6373
6889
|
if (path !== reference && line.includes(reference)) results.push({ path, line: index + 1, reference });
|
|
@@ -6376,7 +6892,7 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
|
|
|
6376
6892
|
}
|
|
6377
6893
|
}
|
|
6378
6894
|
}
|
|
6379
|
-
await visit((0,
|
|
6895
|
+
await visit((0, import_node_path14.resolve)(root));
|
|
6380
6896
|
return results.sort((left, right) => left.path.localeCompare(right.path) || left.line - right.line || left.reference.localeCompare(right.reference));
|
|
6381
6897
|
}
|
|
6382
6898
|
function expectedRelationTargets(mapping) {
|
|
@@ -6416,7 +6932,7 @@ function restructureBoundaryFindings(operations, limits) {
|
|
|
6416
6932
|
const expectedCreateMode = createModeForUmask(limits.umask);
|
|
6417
6933
|
const applyModeContract = limits.mode_contract === "apply";
|
|
6418
6934
|
for (const operation of operations) {
|
|
6419
|
-
const parent = (0,
|
|
6935
|
+
const parent = (0, import_node_path14.dirname)(operation.path) || ".";
|
|
6420
6936
|
if (!operation.parent_exists) {
|
|
6421
6937
|
findings.push(finding("PARENT_DIRECTORY_MISSING", `Parent directory does not exist or is not a directory: ${parent}`, operation.path));
|
|
6422
6938
|
} else if (operation.parent_device !== null && operation.parent_device !== operation.root_device) {
|
|
@@ -6465,7 +6981,7 @@ function restructureBoundaryFindings(operations, limits) {
|
|
|
6465
6981
|
}
|
|
6466
6982
|
async function probeDirectory(absolutePath) {
|
|
6467
6983
|
try {
|
|
6468
|
-
const info = await (0,
|
|
6984
|
+
const info = await (0, import_promises10.stat)(absolutePath);
|
|
6469
6985
|
return { exists: info.isDirectory(), device: info.dev };
|
|
6470
6986
|
} catch (error) {
|
|
6471
6987
|
const code = error.code;
|
|
@@ -6607,7 +7123,7 @@ async function planRestructure(root, input) {
|
|
|
6607
7123
|
}
|
|
6608
7124
|
pathMoves.push(move);
|
|
6609
7125
|
rangesByPath.set(sourcePath, pathMoves);
|
|
6610
|
-
if ((0,
|
|
7126
|
+
if ((0, import_node_path14.dirname)(sourcePath) !== (0, import_node_path14.dirname)(targetPath)) {
|
|
6611
7127
|
for (const link of findRelativeLinks(fragment.toString("utf8"))) {
|
|
6612
7128
|
const explicitlyEdited = mapping.prose_edits.some((edit) => edit.target_path === targetPath && edit.old_text.includes(link));
|
|
6613
7129
|
if (!explicitlyEdited) blockers.push(finding("RELATIVE_LINK_REQUIRES_MAPPING", `Relative reference "${link}" changes base directory when moved to ${targetPath}`, sourcePath));
|
|
@@ -6724,15 +7240,15 @@ async function planRestructure(root, input) {
|
|
|
6724
7240
|
diff: readableDiff(path, original?.toString("utf8"), deleteFile ? void 0 : candidate.toString("utf8"))
|
|
6725
7241
|
});
|
|
6726
7242
|
}
|
|
6727
|
-
const rootDirectory = await probeDirectory((0,
|
|
7243
|
+
const rootDirectory = await probeDirectory((0, import_node_path14.resolve)(root));
|
|
6728
7244
|
const parentProbes = /* @__PURE__ */ new Map();
|
|
6729
7245
|
for (const candidate of candidates) {
|
|
6730
|
-
const parent = (0,
|
|
6731
|
-
if (!parentProbes.has(parent)) parentProbes.set(parent, await probeDirectory((0,
|
|
7246
|
+
const parent = (0, import_node_path14.dirname)(candidate.path);
|
|
7247
|
+
if (!parentProbes.has(parent)) parentProbes.set(parent, await probeDirectory((0, import_node_path14.resolve)(root, parent)));
|
|
6732
7248
|
}
|
|
6733
7249
|
blockers.push(...restructureBoundaryFindings(
|
|
6734
7250
|
candidates.map((candidate) => {
|
|
6735
|
-
const parent = parentProbes.get((0,
|
|
7251
|
+
const parent = parentProbes.get((0, import_node_path14.dirname)(candidate.path));
|
|
6736
7252
|
return {
|
|
6737
7253
|
path: candidate.path,
|
|
6738
7254
|
action: candidate.action,
|
|
@@ -6858,10 +7374,10 @@ function refusal(code, message, findings = []) {
|
|
|
6858
7374
|
return { ok: false, error: { code, message, ...findings.length === 0 ? {} : { details: findings } } };
|
|
6859
7375
|
}
|
|
6860
7376
|
async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
6861
|
-
const absolute = (0,
|
|
7377
|
+
const absolute = (0, import_node_path14.resolve)(planPath);
|
|
6862
7378
|
let info;
|
|
6863
7379
|
try {
|
|
6864
|
-
info = await (0,
|
|
7380
|
+
info = await (0, import_promises10.lstat)(absolute);
|
|
6865
7381
|
} catch (cause) {
|
|
6866
7382
|
return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
|
|
6867
7383
|
}
|
|
@@ -6870,7 +7386,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
|
6870
7386
|
}
|
|
6871
7387
|
let bytes;
|
|
6872
7388
|
try {
|
|
6873
|
-
bytes = await (0,
|
|
7389
|
+
bytes = await (0, import_promises10.readFile)(absolute);
|
|
6874
7390
|
} catch (cause) {
|
|
6875
7391
|
return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
|
|
6876
7392
|
}
|
|
@@ -6882,7 +7398,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
|
6882
7398
|
}
|
|
6883
7399
|
const gate = await gateRestructureOperationPlan(operation, parsed);
|
|
6884
7400
|
if (!gate.ok) return gate;
|
|
6885
|
-
return { ok: true, data: { path: absolute, realPath: await (0,
|
|
7401
|
+
return { ok: true, data: { path: absolute, realPath: await (0, import_promises10.realpath)(absolute), digest: digestBytes(bytes), root: canonicalRoot, plan: gate.data } };
|
|
6886
7402
|
}
|
|
6887
7403
|
function planRootIdentityFindings(document) {
|
|
6888
7404
|
const findings = [];
|
|
@@ -6901,19 +7417,19 @@ function planRootIdentityFindings(document) {
|
|
|
6901
7417
|
if (document.plan.config_snapshot.path !== "artifact-graph.config.yaml") {
|
|
6902
7418
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan does not record this project's configuration file: ${document.plan.config_snapshot.path}`));
|
|
6903
7419
|
}
|
|
6904
|
-
const relativePlan = (0,
|
|
6905
|
-
if (!relativePlan || relativePlan.startsWith("..") || (0,
|
|
7420
|
+
const relativePlan = (0, import_node_path14.relative)(document.root, document.realPath);
|
|
7421
|
+
if (!relativePlan || relativePlan.startsWith("..") || (0, import_node_path14.isAbsolute)(relativePlan)) {
|
|
6906
7422
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan document is outside the project root: ${document.realPath}`, document.realPath));
|
|
6907
7423
|
}
|
|
6908
7424
|
return findings;
|
|
6909
7425
|
}
|
|
6910
7426
|
async function operationBoundaries(root, plan) {
|
|
6911
|
-
const rootDirectory = await probeDirectory((0,
|
|
7427
|
+
const rootDirectory = await probeDirectory((0, import_node_path14.resolve)(root));
|
|
6912
7428
|
const parents = /* @__PURE__ */ new Map();
|
|
6913
7429
|
const boundaries = [];
|
|
6914
7430
|
for (const candidate of plan.candidates) {
|
|
6915
|
-
const parent = (0,
|
|
6916
|
-
if (!parents.has(parent)) parents.set(parent, await probeDirectory((0,
|
|
7431
|
+
const parent = (0, import_node_path14.dirname)(candidate.path) || ".";
|
|
7432
|
+
if (!parents.has(parent)) parents.set(parent, await probeDirectory((0, import_node_path14.resolve)(root, parent)));
|
|
6917
7433
|
const probe = parents.get(parent);
|
|
6918
7434
|
boundaries.push({
|
|
6919
7435
|
path: candidate.path,
|
|
@@ -6938,7 +7454,7 @@ async function applyPreconditionFindings(root, document) {
|
|
|
6938
7454
|
findings.push(finding("CONFIG_CHANGED", "artifact-graph configuration changed after planning", currentConfig.path));
|
|
6939
7455
|
}
|
|
6940
7456
|
for (const snapshot of plan.input_snapshots) await verifySnapshot(root, snapshot, findings);
|
|
6941
|
-
const relativePlan = (0,
|
|
7457
|
+
const relativePlan = (0, import_node_path14.relative)(root, document.realPath).replace(/\\/g, "/");
|
|
6942
7458
|
for (const candidate of plan.candidates) {
|
|
6943
7459
|
if (candidate.path === relativePlan) {
|
|
6944
7460
|
findings.push(finding("PLAN_IN_WRITE_SET", `The plan document is inside its own candidate write set: ${candidate.path}`, candidate.path));
|
|
@@ -7021,7 +7537,7 @@ async function applyRestructure(input) {
|
|
|
7021
7537
|
if (drift.length > 0) return refusal("APPLY_PRECONDITION_FAILED", "The project drifted after planning; nothing was written", drift);
|
|
7022
7538
|
const mechanismRoot = await ensureRestructureMechanismRoot(qualification.data.root, { create: true });
|
|
7023
7539
|
if (!mechanismRoot.ok) return mechanismRoot;
|
|
7024
|
-
const planRelPath = (0,
|
|
7540
|
+
const planRelPath = (0, import_node_path14.relative)(qualification.data.root, document.data.realPath).replace(/\\/g, "/");
|
|
7025
7541
|
const applied = await applyRestructureFileSet(qualification.data.root, plan, {
|
|
7026
7542
|
validate: createRestructureValidationCallback(plan, [planRelPath])
|
|
7027
7543
|
});
|
|
@@ -7078,13 +7594,13 @@ async function pruneRestructureRecovery(input) {
|
|
|
7078
7594
|
const projection = projectRestructureFileSetResult(pruned.data, document.data.realPath, document.data.digest);
|
|
7079
7595
|
return projection.ok ? { ok: true, data: projection } : { ok: false, error: { code: projection.code, message: projection.message, details: projection } };
|
|
7080
7596
|
}
|
|
7081
|
-
var import_node_crypto5,
|
|
7597
|
+
var import_node_crypto5, import_promises10, import_node_path14, import_node_url3, import_meta3, RESTRUCTURE_PLAN_SCHEMA_VERSION, RESTRUCTURE_VALIDATION_TIMEOUT_MS, RESTRUCTURE_MAX_OPERATIONS, RESTRUCTURE_MAX_TOTAL_BYTES, MAX_POSIX_MODE, CREATE_MODE_BASE, MODULE_DIRECTORY, CONTRACT_ROOT, SKIPPED_SCAN_DIRS, TEXT_EXTENSIONS, MARKDOWN_LINK_PATTERN, RUNTIME_PATH_MARKER, MARKDOWN_FILE_SUFFIX, SCRIPT_FILE_SUFFIX;
|
|
7082
7598
|
var init_restructure = __esm({
|
|
7083
7599
|
"src/restructure.ts"() {
|
|
7084
7600
|
"use strict";
|
|
7085
7601
|
import_node_crypto5 = require("crypto");
|
|
7086
|
-
|
|
7087
|
-
|
|
7602
|
+
import_promises10 = require("fs/promises");
|
|
7603
|
+
import_node_path14 = require("path");
|
|
7088
7604
|
import_node_url3 = require("url");
|
|
7089
7605
|
init_index();
|
|
7090
7606
|
init_contract_kernel();
|
|
@@ -7097,8 +7613,8 @@ var init_restructure = __esm({
|
|
|
7097
7613
|
RESTRUCTURE_MAX_TOTAL_BYTES = 256 * 1024 * 1024;
|
|
7098
7614
|
MAX_POSIX_MODE = 511;
|
|
7099
7615
|
CREATE_MODE_BASE = 438;
|
|
7100
|
-
MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : (0,
|
|
7101
|
-
CONTRACT_ROOT = (0,
|
|
7616
|
+
MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : (0, import_node_path14.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
|
|
7617
|
+
CONTRACT_ROOT = (0, import_node_path14.join)(MODULE_DIRECTORY, "..", "contracts");
|
|
7102
7618
|
SKIPPED_SCAN_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "dist", "coverage", ".tmp", ".codex", ".worktrees", ".foundation-file-apply", ".artifact-graph"]);
|
|
7103
7619
|
TEXT_EXTENSIONS = /\.(?:md|markdown|json|ya?ml|[cm]?[jt]sx?)$/i;
|
|
7104
7620
|
MARKDOWN_LINK_PATTERN = /!?\[([^\]\n]*)\]\(([^)\n]+)\)/g;
|
|
@@ -7164,18 +7680,21 @@ __export(index_exports, {
|
|
|
7164
7680
|
createModeForUmask: () => createModeForUmask,
|
|
7165
7681
|
createRestructureRootBinding: () => createRestructureRootBinding,
|
|
7166
7682
|
createRestructureValidationCallback: () => createRestructureValidationCallback,
|
|
7683
|
+
diagnoseConfigDocument: () => diagnoseConfigDocument,
|
|
7684
|
+
diagnoseProjectConfig: () => diagnoseProjectConfig,
|
|
7167
7685
|
digestRestructureValue: () => digestRestructureValue,
|
|
7168
|
-
dirname: () =>
|
|
7686
|
+
dirname: () => import_node_path15.dirname,
|
|
7169
7687
|
discoverAndAuditPackets: () => discoverAndAuditPackets,
|
|
7170
7688
|
discoverTargets: () => discoverTargets,
|
|
7171
7689
|
doctorArtifactChain: () => doctorArtifactChain,
|
|
7172
7690
|
ensureRestructureMechanismRoot: () => ensureRestructureMechanismRoot,
|
|
7173
|
-
extname: () =>
|
|
7691
|
+
extname: () => import_node_path15.extname,
|
|
7174
7692
|
filterGraphByView: () => filterGraphByView,
|
|
7175
7693
|
formatContextMarkdown: () => formatContextMarkdown,
|
|
7176
7694
|
gateRestructureOperationPlan: () => gateRestructureOperationPlan,
|
|
7177
7695
|
generateE2eRegistry: () => generateE2eRegistry,
|
|
7178
7696
|
getArtifactTypeMetadata: () => getArtifactTypeMetadata,
|
|
7697
|
+
getConfigDiagnostics: () => getConfigDiagnostics,
|
|
7179
7698
|
getExternalEntryInfo: () => getExternalEntryInfo,
|
|
7180
7699
|
getTargetArtifactTypes: () => getTargetArtifactTypes,
|
|
7181
7700
|
inspectRestructure: () => inspectRestructure,
|
|
@@ -7251,6 +7770,27 @@ __export(index_exports, {
|
|
|
7251
7770
|
writeGraphCache: () => writeGraphCache
|
|
7252
7771
|
});
|
|
7253
7772
|
module.exports = __toCommonJS(index_exports);
|
|
7773
|
+
function getConfigDiagnostics(schema) {
|
|
7774
|
+
return configDiagnosticsBySchema.get(schema);
|
|
7775
|
+
}
|
|
7776
|
+
function edgeRule(from, to, kind) {
|
|
7777
|
+
return { from, to, kind };
|
|
7778
|
+
}
|
|
7779
|
+
function matchesEdgeRule(rule, fromType, toType, kind) {
|
|
7780
|
+
return rule.from === fromType && rule.to === toType && rule.kind === kind;
|
|
7781
|
+
}
|
|
7782
|
+
function cloneEdgeRules(rules) {
|
|
7783
|
+
return rules.map((rule) => ({ ...rule }));
|
|
7784
|
+
}
|
|
7785
|
+
function isEmptyAllowedEdgesValue(value) {
|
|
7786
|
+
return value === null || Array.isArray(value) && value.length === 0;
|
|
7787
|
+
}
|
|
7788
|
+
function resolveAllowedEdges(value) {
|
|
7789
|
+
if (isEmptyAllowedEdgesValue(value)) {
|
|
7790
|
+
return cloneEdgeRules(DEFAULT_ALLOWED_EDGES);
|
|
7791
|
+
}
|
|
7792
|
+
return cloneEdgeRules(value);
|
|
7793
|
+
}
|
|
7254
7794
|
function isTargetArtifactType(type) {
|
|
7255
7795
|
return isPacketTargetType(type);
|
|
7256
7796
|
}
|
|
@@ -7292,30 +7832,22 @@ function resolveArtifactTypeName(schema, token) {
|
|
|
7292
7832
|
return void 0;
|
|
7293
7833
|
}
|
|
7294
7834
|
async function loadConfig(root) {
|
|
7295
|
-
const configPath = (0,
|
|
7296
|
-
let
|
|
7835
|
+
const configPath = (0, import_node_path15.join)(root, "artifact-graph.config.yaml");
|
|
7836
|
+
let raw;
|
|
7297
7837
|
try {
|
|
7298
|
-
|
|
7299
|
-
parsed = import_js_yaml.default.load(raw) ?? {};
|
|
7838
|
+
raw = await (0, import_promises11.readFile)(configPath, "utf-8");
|
|
7300
7839
|
} catch (error) {
|
|
7301
|
-
if (error.code
|
|
7302
|
-
throw
|
|
7840
|
+
if (error.code === "ENOENT") {
|
|
7841
|
+
throw new Error(`required configuration is missing: ${configPath}`);
|
|
7303
7842
|
}
|
|
7843
|
+
throw error;
|
|
7304
7844
|
}
|
|
7305
|
-
const
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
);
|
|
7310
|
-
}
|
|
7311
|
-
if (parsed.e2e !== void 0) {
|
|
7312
|
-
if (typeof parsed.e2e !== "object" || parsed.e2e === null || Array.isArray(parsed.e2e)) {
|
|
7313
|
-
throw new Error("Invalid e2e: must be an object.");
|
|
7314
|
-
}
|
|
7315
|
-
validateE2eConfig(parsed.e2e);
|
|
7845
|
+
const document = import_js_yaml2.default.load(raw) ?? {};
|
|
7846
|
+
const shapeDiagnosis = diagnoseConfigDocument(document);
|
|
7847
|
+
if (shapeDiagnosis.errors.length > 0) {
|
|
7848
|
+
throw new Error(shapeDiagnosis.errors[0].message);
|
|
7316
7849
|
}
|
|
7317
|
-
|
|
7318
|
-
validateStatusViewsConfig(parsed.statusViews);
|
|
7850
|
+
const parsed = document;
|
|
7319
7851
|
const mergedE2e = parsed.e2e === void 0 ? DEFAULT_SCHEMA.e2e : {
|
|
7320
7852
|
...DEFAULT_SCHEMA.e2e,
|
|
7321
7853
|
...parsed.e2e,
|
|
@@ -7330,13 +7862,14 @@ async function loadConfig(root) {
|
|
|
7330
7862
|
types: mergeArtifactTypes(DEFAULT_SCHEMA.types, parsed.types),
|
|
7331
7863
|
idPatterns: mergeRecord(DEFAULT_SCHEMA.idPatterns, parsed.idPatterns),
|
|
7332
7864
|
relationFields: mergeRecord(DEFAULT_SCHEMA.relationFields, parsed.relationFields),
|
|
7333
|
-
allowedEdges: parsed.allowedEdges
|
|
7865
|
+
allowedEdges: resolveAllowedEdges(parsed.allowedEdges),
|
|
7334
7866
|
forbiddenEdges: parsed.forbiddenEdges ?? DEFAULT_SCHEMA.forbiddenEdges,
|
|
7335
7867
|
statuses: parsed.statuses ?? DEFAULT_SCHEMA.statuses,
|
|
7336
7868
|
idRanges: mergeRecord(DEFAULT_SCHEMA.idRanges, parsed.idRanges),
|
|
7337
7869
|
e2e: mergedE2e
|
|
7338
7870
|
};
|
|
7339
7871
|
validateJsonArtifactTypes(merged.types);
|
|
7872
|
+
configDiagnosticsBySchema.set(merged, shapeDiagnosis);
|
|
7340
7873
|
return merged;
|
|
7341
7874
|
}
|
|
7342
7875
|
function validateJsonArtifactTypes(types) {
|
|
@@ -7361,131 +7894,6 @@ function validateJsonArtifactTypes(types) {
|
|
|
7361
7894
|
}
|
|
7362
7895
|
}
|
|
7363
7896
|
}
|
|
7364
|
-
function validateRelationSemanticsConfig(value) {
|
|
7365
|
-
if (value === void 0) return;
|
|
7366
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7367
|
-
throw new Error("Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
7368
|
-
}
|
|
7369
|
-
for (const [kind, spec] of Object.entries(value)) {
|
|
7370
|
-
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
7371
|
-
throw new Error(`Invalid relationSemantics.${kind}: must be an object.`);
|
|
7372
|
-
}
|
|
7373
|
-
if (typeof spec.label !== "string" || !spec.label.trim()) {
|
|
7374
|
-
throw new Error(`Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
7375
|
-
}
|
|
7376
|
-
if (!Array.isArray(spec.targetTypes) || spec.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7377
|
-
throw new Error(`Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
7378
|
-
}
|
|
7379
|
-
if (!Array.isArray(spec.fields) || spec.fields.length === 0 || spec.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7380
|
-
throw new Error(`Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
7381
|
-
}
|
|
7382
|
-
if (spec.partial !== void 0 && (typeof spec.partial !== "object" || spec.partial === null || typeof spec.partial.sectionField !== "string" || !spec.partial.sectionField.trim())) {
|
|
7383
|
-
throw new Error(`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`);
|
|
7384
|
-
}
|
|
7385
|
-
}
|
|
7386
|
-
}
|
|
7387
|
-
function validateStatusViewsConfig(value) {
|
|
7388
|
-
if (value === void 0) return;
|
|
7389
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7390
|
-
throw new Error("Invalid statusViews: must be an object keyed by status.");
|
|
7391
|
-
}
|
|
7392
|
-
for (const [status, bucket] of Object.entries(value)) {
|
|
7393
|
-
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
7394
|
-
throw new Error(`Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
7395
|
-
}
|
|
7396
|
-
}
|
|
7397
|
-
}
|
|
7398
|
-
function validateE2eConfig(e2e) {
|
|
7399
|
-
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
7400
|
-
if (e2e[field] !== void 0 && typeof e2e[field] !== "boolean") {
|
|
7401
|
-
throw new Error(`Invalid e2e.${field}: must be boolean.`);
|
|
7402
|
-
}
|
|
7403
|
-
}
|
|
7404
|
-
if (e2e.executable_ref_warning !== void 0) {
|
|
7405
|
-
if (typeof e2e.executable_ref_warning !== "number" || e2e.executable_ref_warning < 0 || e2e.executable_ref_warning > 1) {
|
|
7406
|
-
throw new Error(`Invalid e2e.executable_ref_warning: ${JSON.stringify(e2e.executable_ref_warning)}. Must be a number between 0 and 1.`);
|
|
7407
|
-
}
|
|
7408
|
-
}
|
|
7409
|
-
if (e2e.executable_ref_error !== void 0) {
|
|
7410
|
-
if (typeof e2e.executable_ref_error !== "number" || e2e.executable_ref_error < 0 || e2e.executable_ref_error > 1) {
|
|
7411
|
-
throw new Error(`Invalid e2e.executable_ref_error: ${JSON.stringify(e2e.executable_ref_error)}. Must be a number between 0 and 1.`);
|
|
7412
|
-
}
|
|
7413
|
-
}
|
|
7414
|
-
const validateWaivers = (waivers, field) => {
|
|
7415
|
-
if (waivers === void 0) return;
|
|
7416
|
-
if (!Array.isArray(waivers)) {
|
|
7417
|
-
throw new Error(`Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
7418
|
-
}
|
|
7419
|
-
for (const w of waivers) {
|
|
7420
|
-
if (typeof w !== "object" || w === null || !("id" in w) || !("reason" in w)) {
|
|
7421
|
-
throw new Error(`Invalid ${field} entry: ${JSON.stringify(w)}. Must be {id, reason} object.`);
|
|
7422
|
-
}
|
|
7423
|
-
if (typeof w.id !== "string" || !w.id.trim()) {
|
|
7424
|
-
throw new Error(`Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(w.id)}`);
|
|
7425
|
-
}
|
|
7426
|
-
if (typeof w.reason !== "string" || !w.reason.trim()) {
|
|
7427
|
-
throw new Error(`Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(w.reason)}`);
|
|
7428
|
-
}
|
|
7429
|
-
}
|
|
7430
|
-
};
|
|
7431
|
-
validateWaivers(e2e.scenario_waivers, "e2e.scenario_waivers");
|
|
7432
|
-
validateWaivers(e2e.feature_waivers, "e2e.feature_waivers");
|
|
7433
|
-
if (e2e.runners !== void 0) {
|
|
7434
|
-
if (!Array.isArray(e2e.runners)) {
|
|
7435
|
-
throw new Error(`Invalid e2e.runners: must be an array.`);
|
|
7436
|
-
}
|
|
7437
|
-
for (const runner of e2e.runners) {
|
|
7438
|
-
if (typeof runner !== "object" || runner === null) {
|
|
7439
|
-
throw new Error(`Invalid e2e.runners entry: must be an object.`);
|
|
7440
|
-
}
|
|
7441
|
-
if (typeof runner.name !== "string" || !runner.name.trim()) {
|
|
7442
|
-
throw new Error(`Invalid e2e.runners entry: name must be a non-empty string.`);
|
|
7443
|
-
}
|
|
7444
|
-
if (typeof runner.root !== "string" || !runner.root.trim()) {
|
|
7445
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: must be a non-empty string.`);
|
|
7446
|
-
}
|
|
7447
|
-
if ((0, import_node_path14.isAbsolute)(runner.root)) {
|
|
7448
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not be an absolute path.`);
|
|
7449
|
-
}
|
|
7450
|
-
if (runner.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
7451
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not contain ".." segments.`);
|
|
7452
|
-
}
|
|
7453
|
-
if (!Array.isArray(runner.include) || runner.include.length === 0) {
|
|
7454
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: must be a non-empty array of glob patterns.`);
|
|
7455
|
-
}
|
|
7456
|
-
for (const pattern of runner.include) {
|
|
7457
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7458
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: pattern must be a non-empty string.`);
|
|
7459
|
-
}
|
|
7460
|
-
}
|
|
7461
|
-
if (runner.exclude !== void 0) {
|
|
7462
|
-
if (!Array.isArray(runner.exclude)) {
|
|
7463
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: must be an array.`);
|
|
7464
|
-
}
|
|
7465
|
-
for (const pattern of runner.exclude) {
|
|
7466
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7467
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: pattern must be a non-empty string.`);
|
|
7468
|
-
}
|
|
7469
|
-
}
|
|
7470
|
-
}
|
|
7471
|
-
if (runner.testIgnore !== void 0) {
|
|
7472
|
-
if (!Array.isArray(runner.testIgnore)) {
|
|
7473
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: must be an array.`);
|
|
7474
|
-
}
|
|
7475
|
-
for (const pattern of runner.testIgnore) {
|
|
7476
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7477
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: pattern must be a non-empty string.`);
|
|
7478
|
-
}
|
|
7479
|
-
}
|
|
7480
|
-
}
|
|
7481
|
-
if (runner.kind !== void 0) {
|
|
7482
|
-
if (!["unit", "integration", "e2e"].includes(runner.kind)) {
|
|
7483
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].kind: "${runner.kind}". Must be unit, integration, or e2e.`);
|
|
7484
|
-
}
|
|
7485
|
-
}
|
|
7486
|
-
}
|
|
7487
|
-
}
|
|
7488
|
-
}
|
|
7489
7897
|
function buildGraph(nodes, edges, diagnostics = [], root) {
|
|
7490
7898
|
const graphNodes = nodes.map((node) => ({ ...node, uid: toUid(node.type, node.code) }));
|
|
7491
7899
|
graphNodes.sort(compareNode);
|
|
@@ -7533,7 +7941,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7533
7941
|
continue;
|
|
7534
7942
|
}
|
|
7535
7943
|
scannedFiles.set(file, type);
|
|
7536
|
-
const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await (0,
|
|
7944
|
+
const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await (0, import_promises11.readFile)((0, import_node_path15.join)(root, file), "utf-8");
|
|
7537
7945
|
const parsed = parseFile(type, file, raw, config);
|
|
7538
7946
|
const semantic = isJsonOriginalType(type, config) ? { edges: [], diagnostics: [] } : parseConfiguredRelations(type, file, raw, parsed.nodes, config);
|
|
7539
7947
|
nodes.push(...parsed.nodes);
|
|
@@ -7541,7 +7949,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7541
7949
|
scanDiagnostics.push(...parsed.diagnostics, ...semantic.diagnostics);
|
|
7542
7950
|
}
|
|
7543
7951
|
}
|
|
7544
|
-
const absoluteRoot = (0,
|
|
7952
|
+
const absoluteRoot = (0, import_node_path15.isAbsolute)(root) ? root : (0, import_node_path15.resolve)(root);
|
|
7545
7953
|
const graph = buildGraph(nodes, edges, scanDiagnostics, absoluteRoot);
|
|
7546
7954
|
return resolveMatrixEdges(graph);
|
|
7547
7955
|
}
|
|
@@ -7688,8 +8096,16 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
|
|
|
7688
8096
|
{ edge: edge2 }
|
|
7689
8097
|
));
|
|
7690
8098
|
}
|
|
7691
|
-
if (schema.forbiddenEdges.some((rule) => rule
|
|
8099
|
+
if (schema.forbiddenEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
7692
8100
|
issues.push(issue("FORBIDDEN_EDGE", `Forbidden ${fromType} -> ${toType} ${edge2.kind} relation`, edge2.sourcePath, edge2.sourceLine, { edge: edge2 }));
|
|
8101
|
+
} else if (!schema.allowedEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
8102
|
+
issues.push(issue(
|
|
8103
|
+
"DISALLOWED_EDGE",
|
|
8104
|
+
`Disallowed ${fromType} -> ${toType} ${edge2.kind} relation`,
|
|
8105
|
+
edge2.sourcePath,
|
|
8106
|
+
edge2.sourceLine,
|
|
8107
|
+
{ edge: edge2 }
|
|
8108
|
+
));
|
|
7693
8109
|
}
|
|
7694
8110
|
}
|
|
7695
8111
|
issues.push(...validateE2eTests(graph));
|
|
@@ -7880,7 +8296,7 @@ async function validateScenarioPrdLinkIndex(root, graph) {
|
|
|
7880
8296
|
const indexPath = "artifacts/prd/feature-index.md";
|
|
7881
8297
|
let raw = "";
|
|
7882
8298
|
try {
|
|
7883
|
-
raw = await (0,
|
|
8299
|
+
raw = await (0, import_promises11.readFile)((0, import_node_path15.join)(root, indexPath), "utf-8");
|
|
7884
8300
|
} catch (error) {
|
|
7885
8301
|
if (error.code === "ENOENT") {
|
|
7886
8302
|
return [];
|
|
@@ -8128,12 +8544,12 @@ function nextId(graph, schema, type, rangeName) {
|
|
|
8128
8544
|
throw new Error(`ID range ${type}.${rangeName} is exhausted`);
|
|
8129
8545
|
}
|
|
8130
8546
|
async function writeGraphCache(root, graph) {
|
|
8131
|
-
const cacheDir = (0,
|
|
8132
|
-
await (0,
|
|
8133
|
-
await (0,
|
|
8547
|
+
const cacheDir = (0, import_node_path15.join)(root, ".artifact-graph");
|
|
8548
|
+
await (0, import_promises11.mkdir)(cacheDir, { recursive: true });
|
|
8549
|
+
await (0, import_promises11.writeFile)((0, import_node_path15.join)(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
|
|
8134
8550
|
`);
|
|
8135
8551
|
const { default: Database } = await import("better-sqlite3");
|
|
8136
|
-
const db = new Database((0,
|
|
8552
|
+
const db = new Database((0, import_node_path15.join)(cacheDir, "graph.sqlite"));
|
|
8137
8553
|
try {
|
|
8138
8554
|
db.exec(`
|
|
8139
8555
|
DROP TABLE IF EXISTS nodes;
|
|
@@ -8429,7 +8845,7 @@ function jsonConfiguredRelations(type, path, record, schema, sourceUid) {
|
|
|
8429
8845
|
}
|
|
8430
8846
|
function parseGenericMarkdown(type, path, raw, schema) {
|
|
8431
8847
|
const diagnostics = [];
|
|
8432
|
-
const ext = (0,
|
|
8848
|
+
const ext = (0, import_node_path15.extname)(path).toLowerCase();
|
|
8433
8849
|
if (ext !== ".md" && ext !== ".markdown") {
|
|
8434
8850
|
diagnostics.push(issue(
|
|
8435
8851
|
"UNSUPPORTED_FORMAT",
|
|
@@ -8799,7 +9215,7 @@ function parseDecisions(path, raw) {
|
|
|
8799
9215
|
}
|
|
8800
9216
|
function isTestFile(filePath) {
|
|
8801
9217
|
const normalized = filePath.replace(/\\/g, "/");
|
|
8802
|
-
const name = (0,
|
|
9218
|
+
const name = (0, import_node_path15.basename)(normalized);
|
|
8803
9219
|
if (/\.(test|spec)\.[^.]+$/.test(name)) return true;
|
|
8804
9220
|
if (/(^|\/)(tests|test|__tests__)\//.test(normalized)) return true;
|
|
8805
9221
|
if (/\w+Tests?\.java$/.test(name)) return true;
|
|
@@ -9114,7 +9530,7 @@ function parseE2eTest(path, raw) {
|
|
|
9114
9530
|
const starts = extractE2eTestCaseStarts(lines);
|
|
9115
9531
|
const nodes = [];
|
|
9116
9532
|
const edges = [];
|
|
9117
|
-
const batch = String(data.test_batch ?? (0,
|
|
9533
|
+
const batch = String(data.test_batch ?? (0, import_node_path15.basename)(path, (0, import_node_path15.extname)(path))).trim();
|
|
9118
9534
|
const frontmatterScenarios = toArray(data.related_scenarios).map((value) => String(value).trim()).filter(Boolean);
|
|
9119
9535
|
const scopeFeatures = extractCodes(String(data.scope ?? ""), "feature");
|
|
9120
9536
|
const frontmatterFeatures = [.../* @__PURE__ */ new Set([...Object.keys(asRecord2(data.ac_coverage)), ...scopeFeatures])];
|
|
@@ -9177,7 +9593,7 @@ function parseE2eRegistry(path, raw) {
|
|
|
9177
9593
|
data = { parseError: error.message };
|
|
9178
9594
|
}
|
|
9179
9595
|
return {
|
|
9180
|
-
nodes: [{ type: "e2e_registry", code: (0,
|
|
9596
|
+
nodes: [{ type: "e2e_registry", code: (0, import_node_path15.basename)(path, (0, import_node_path15.extname)(path)), title: "E2E Test Registry", path, line: 1, attrs: data }],
|
|
9181
9597
|
edges: []
|
|
9182
9598
|
};
|
|
9183
9599
|
}
|
|
@@ -10215,10 +10631,10 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10215
10631
|
const tcKeyToFields = /* @__PURE__ */ new Map();
|
|
10216
10632
|
const mdBatches = /* @__PURE__ */ new Set();
|
|
10217
10633
|
for (const relPath of e2eFiles) {
|
|
10218
|
-
const raw = await (0,
|
|
10634
|
+
const raw = await (0, import_promises11.readFile)((0, import_node_path15.join)(root, relPath), "utf-8");
|
|
10219
10635
|
const parsed = (0, import_gray_matter.default)(raw);
|
|
10220
10636
|
const data = parsed.data;
|
|
10221
|
-
const batch = String(data.test_batch ?? (0,
|
|
10637
|
+
const batch = String(data.test_batch ?? (0, import_node_path15.basename)(relPath, (0, import_node_path15.extname)(relPath))).trim();
|
|
10222
10638
|
const lines = raw.split(/\r?\n/);
|
|
10223
10639
|
const tcStarts = extractE2eTestCaseStarts(lines);
|
|
10224
10640
|
for (let i = 0; i < tcStarts.length; i += 1) {
|
|
@@ -10257,10 +10673,10 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10257
10673
|
const tcAnnotationRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+?)\s+\[(\w+)\]/;
|
|
10258
10674
|
const tcAnnotationNoLevelRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+)/;
|
|
10259
10675
|
for (const specFile of specFiles) {
|
|
10260
|
-
const fullSpecPath = (0,
|
|
10676
|
+
const fullSpecPath = (0, import_node_path15.join)(root, specFile);
|
|
10261
10677
|
let content;
|
|
10262
10678
|
try {
|
|
10263
|
-
content = await (0,
|
|
10679
|
+
content = await (0, import_promises11.readFile)(fullSpecPath, "utf-8");
|
|
10264
10680
|
} catch {
|
|
10265
10681
|
continue;
|
|
10266
10682
|
}
|
|
@@ -10339,7 +10755,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10339
10755
|
if (entry.testId) {
|
|
10340
10756
|
let content;
|
|
10341
10757
|
try {
|
|
10342
|
-
content = await (0,
|
|
10758
|
+
content = await (0, import_promises11.readFile)((0, import_node_path15.join)(root, normalizedRefFile), "utf-8");
|
|
10343
10759
|
} catch {
|
|
10344
10760
|
continue;
|
|
10345
10761
|
}
|
|
@@ -10574,7 +10990,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10574
10990
|
let hasActiveE2eRef = false;
|
|
10575
10991
|
for (const entry of parseExecutableRefLines(execRef)) {
|
|
10576
10992
|
const normalized = resolveExecutableRefFile(entry.file, allProjectFiles);
|
|
10577
|
-
if (!normalized || !(0, import_node_fs5.existsSync)((0,
|
|
10993
|
+
if (!normalized || !(0, import_node_fs5.existsSync)((0, import_node_path15.join)(root, normalized))) continue;
|
|
10578
10994
|
const accepting = await getAcceptingRunners(root, normalized, runners);
|
|
10579
10995
|
if (accepting.some((runner) => runner.kind === "e2e")) {
|
|
10580
10996
|
hasActiveE2eRef = true;
|
|
@@ -10633,7 +11049,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10633
11049
|
const acCoverageRateByFeature = {};
|
|
10634
11050
|
const featureAcMap = /* @__PURE__ */ new Map();
|
|
10635
11051
|
for (const node of featureNodes) {
|
|
10636
|
-
const acs = parseAcceptanceCriteria(await (0,
|
|
11052
|
+
const acs = parseAcceptanceCriteria(await (0, import_promises11.readFile)((0, import_node_path15.join)(root, node.path), "utf-8"));
|
|
10637
11053
|
featureAcMap.set(node.code, new Set(acs));
|
|
10638
11054
|
}
|
|
10639
11055
|
const coveredAcByFeature = /* @__PURE__ */ new Map();
|
|
@@ -10681,11 +11097,11 @@ async function generateE2eRegistry(root, opts) {
|
|
|
10681
11097
|
const batchIds = /* @__PURE__ */ new Set();
|
|
10682
11098
|
let totalTestCases = 0;
|
|
10683
11099
|
for (const file of files) {
|
|
10684
|
-
const filePath = (0,
|
|
10685
|
-
const raw = await (0,
|
|
11100
|
+
const filePath = (0, import_node_path15.join)(root, file);
|
|
11101
|
+
const raw = await (0, import_promises11.readFile)(filePath, "utf-8");
|
|
10686
11102
|
const parsed = (0, import_gray_matter.default)(raw);
|
|
10687
11103
|
const data = parsed.data;
|
|
10688
|
-
const batch = String(data.test_batch ?? (0,
|
|
11104
|
+
const batch = String(data.test_batch ?? (0, import_node_path15.basename)(file, (0, import_node_path15.extname)(file))).trim();
|
|
10689
11105
|
const relPath = file;
|
|
10690
11106
|
const scope = String(data.scope ?? "").trim();
|
|
10691
11107
|
const acCoverage = normalizeAcCoverageForRegistry(data.ac_coverage);
|
|
@@ -10807,10 +11223,10 @@ async function validatePartialRustEvidence(tcFields, tcKey, root, allFiles) {
|
|
|
10807
11223
|
if (!normalizedPath) {
|
|
10808
11224
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10809
11225
|
}
|
|
10810
|
-
const fullPath = (0,
|
|
11226
|
+
const fullPath = (0, import_node_path15.join)(root, normalizedPath);
|
|
10811
11227
|
let content;
|
|
10812
11228
|
try {
|
|
10813
|
-
content = await (0,
|
|
11229
|
+
content = await (0, import_promises11.readFile)(fullPath, "utf-8");
|
|
10814
11230
|
} catch {
|
|
10815
11231
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10816
11232
|
}
|
|
@@ -10844,7 +11260,7 @@ function detectTestLevel(specFile, content) {
|
|
|
10844
11260
|
}
|
|
10845
11261
|
function resolveExecutableRefFile(refFile, allFiles) {
|
|
10846
11262
|
const normalized = refFile.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
10847
|
-
if (!normalized || (0,
|
|
11263
|
+
if (!normalized || (0, import_node_path15.isAbsolute)(refFile) || normalized.split("/").includes("..")) {
|
|
10848
11264
|
return void 0;
|
|
10849
11265
|
}
|
|
10850
11266
|
if (allFiles.includes(normalized)) {
|
|
@@ -11150,7 +11566,7 @@ function normalizeDesignCode(value) {
|
|
|
11150
11566
|
if (!raw) {
|
|
11151
11567
|
return "";
|
|
11152
11568
|
}
|
|
11153
|
-
return (0,
|
|
11569
|
+
return (0, import_node_path15.basename)(raw, (0, import_node_path15.extname)(raw));
|
|
11154
11570
|
}
|
|
11155
11571
|
function toUid(type, code) {
|
|
11156
11572
|
return `${type}:${code}`;
|
|
@@ -11426,7 +11842,7 @@ function resolveArtifactContext(graph, opts) {
|
|
|
11426
11842
|
}
|
|
11427
11843
|
if (root) {
|
|
11428
11844
|
for (const ap of ALWAYS_PRESENT_ITEMS) {
|
|
11429
|
-
const fullPath = (0,
|
|
11845
|
+
const fullPath = (0, import_node_path15.join)(root, ap.path);
|
|
11430
11846
|
let stat2;
|
|
11431
11847
|
try {
|
|
11432
11848
|
stat2 = (0, import_node_fs5.statSync)(fullPath);
|
|
@@ -11668,18 +12084,20 @@ function formatContextMarkdown(manifest) {
|
|
|
11668
12084
|
}
|
|
11669
12085
|
return lines.join("\n");
|
|
11670
12086
|
}
|
|
11671
|
-
var import_gray_matter,
|
|
12087
|
+
var import_gray_matter, import_js_yaml2, import_node_fs5, import_promises11, import_node_path15, 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;
|
|
11672
12088
|
var init_index = __esm({
|
|
11673
12089
|
"src/index.ts"() {
|
|
11674
12090
|
import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
11675
|
-
|
|
12091
|
+
import_js_yaml2 = __toESM(require("js-yaml"), 1);
|
|
11676
12092
|
import_node_fs5 = require("fs");
|
|
11677
|
-
|
|
11678
|
-
|
|
12093
|
+
import_promises11 = require("fs/promises");
|
|
12094
|
+
import_node_path15 = require("path");
|
|
11679
12095
|
init_packet_constants();
|
|
11680
12096
|
init_packet_validator();
|
|
11681
12097
|
init_glob_matcher();
|
|
11682
12098
|
init_file_walker();
|
|
12099
|
+
init_doctor();
|
|
12100
|
+
init_doctor();
|
|
11683
12101
|
init_packet_constants();
|
|
11684
12102
|
init_target_selector();
|
|
11685
12103
|
init_impact();
|
|
@@ -11700,6 +12118,44 @@ var init_index = __esm({
|
|
|
11700
12118
|
init_restructure();
|
|
11701
12119
|
init_restructure_file_set();
|
|
11702
12120
|
init_restructure_software();
|
|
12121
|
+
configDiagnosticsBySchema = /* @__PURE__ */ new WeakMap();
|
|
12122
|
+
DEFAULT_ALLOWED_EDGES = [
|
|
12123
|
+
edgeRule("feature", "scenario", "covers"),
|
|
12124
|
+
edgeRule("feature", "decision", "references"),
|
|
12125
|
+
edgeRule("feature", "feature", "depends_on"),
|
|
12126
|
+
edgeRule("feature", "design", "references"),
|
|
12127
|
+
edgeRule("scenario", "feature", "references"),
|
|
12128
|
+
edgeRule("scenario", "decision", "references"),
|
|
12129
|
+
edgeRule("scenario", "entity", "references"),
|
|
12130
|
+
edgeRule("entity", "decision", "references"),
|
|
12131
|
+
edgeRule("decision", "feature", "references"),
|
|
12132
|
+
edgeRule("decision", "scenario", "references"),
|
|
12133
|
+
edgeRule("design", "feature", "references"),
|
|
12134
|
+
edgeRule("design", "scenario", "references"),
|
|
12135
|
+
edgeRule("design", "decision", "references"),
|
|
12136
|
+
edgeRule("design", "entity", "references"),
|
|
12137
|
+
edgeRule("test", "feature", "verifies"),
|
|
12138
|
+
edgeRule("test", "scenario", "verifies"),
|
|
12139
|
+
edgeRule("test", "decision", "verifies"),
|
|
12140
|
+
edgeRule("test", "entity", "verifies"),
|
|
12141
|
+
edgeRule("implementation", "feature", "implements"),
|
|
12142
|
+
edgeRule("implementation", "scenario", "implements"),
|
|
12143
|
+
edgeRule("implementation", "decision", "implements"),
|
|
12144
|
+
edgeRule("implementation", "entity", "implements"),
|
|
12145
|
+
edgeRule("e2e_test", "scenario", "verifies"),
|
|
12146
|
+
edgeRule("e2e_test", "feature", "verifies"),
|
|
12147
|
+
edgeRule("e2e_test", "decision", "references"),
|
|
12148
|
+
edgeRule("e2e_test", "entity", "references"),
|
|
12149
|
+
edgeRule("rule-golden-cases", "design", "references"),
|
|
12150
|
+
edgeRule("traceability-matrix-v2", "traceability-matrix-v2", "references"),
|
|
12151
|
+
edgeRule("traceability-matrix-v2", "traceability-matrix-v2", "covers"),
|
|
12152
|
+
edgeRule("traceability-matrix-v2", "resolve", "references"),
|
|
12153
|
+
edgeRule("traceability-matrix-v2", "resolve", "covers"),
|
|
12154
|
+
...["feature", "scenario", "decision", "design", "entity", "test", "e2e_test"].flatMap((to) => [
|
|
12155
|
+
edgeRule("traceability-matrix-v2", to, "references"),
|
|
12156
|
+
edgeRule("traceability-matrix-v2", to, "covers")
|
|
12157
|
+
])
|
|
12158
|
+
];
|
|
11703
12159
|
TARGET_ARTIFACT_TYPES = VALID_PACKET_TARGET_TYPES;
|
|
11704
12160
|
NON_TARGET_ROLES = ["context", "candidate", "not-recommended"];
|
|
11705
12161
|
DEFAULT_SCHEMA = {
|
|
@@ -11737,7 +12193,7 @@ var init_index = __esm({
|
|
|
11737
12193
|
e2e_test: ["test_batch", "scope", "ac_coverage", "related_scenarios", "related_decisions", "related_entities", "\u8986\u76D6\u573A\u666F", "\u8986\u76D6\u529F\u80FD"],
|
|
11738
12194
|
e2e_registry: ["batches"]
|
|
11739
12195
|
},
|
|
11740
|
-
allowedEdges:
|
|
12196
|
+
allowedEdges: DEFAULT_ALLOWED_EDGES,
|
|
11741
12197
|
forbiddenEdges: [{ from: "scenario", to: "entity", kind: "references" }],
|
|
11742
12198
|
statuses: ["planned", "active", "done", "deprecated"],
|
|
11743
12199
|
idRanges: {},
|
|
@@ -11871,6 +12327,8 @@ init_index();
|
|
|
11871
12327
|
createModeForUmask,
|
|
11872
12328
|
createRestructureRootBinding,
|
|
11873
12329
|
createRestructureValidationCallback,
|
|
12330
|
+
diagnoseConfigDocument,
|
|
12331
|
+
diagnoseProjectConfig,
|
|
11874
12332
|
digestRestructureValue,
|
|
11875
12333
|
dirname,
|
|
11876
12334
|
discoverAndAuditPackets,
|
|
@@ -11883,6 +12341,7 @@ init_index();
|
|
|
11883
12341
|
gateRestructureOperationPlan,
|
|
11884
12342
|
generateE2eRegistry,
|
|
11885
12343
|
getArtifactTypeMetadata,
|
|
12344
|
+
getConfigDiagnostics,
|
|
11886
12345
|
getExternalEntryInfo,
|
|
11887
12346
|
getTargetArtifactTypes,
|
|
11888
12347
|
inspectRestructure,
|