artifact-graph 0.14.1 → 0.16.0
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 +29 -0
- package/INSTALL.md +9 -0
- package/README.md +24 -1
- package/README.zh-CN.md +20 -1
- package/contracts/spec/schema.json +44 -0
- package/dist/cli.js +905 -271
- package/dist/index.cjs +787 -323
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +837 -227
- package/package.json +4 -1
- package/profiles/project-artifact-profiles.json +109 -0
- package/schemas/project-artifact-profiles.schema.json +120 -0
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,
|
|
@@ -968,17 +1467,22 @@ async function bootstrapVersionLock(root, options = {}) {
|
|
|
968
1467
|
source: sourceRefFromNode(source)
|
|
969
1468
|
});
|
|
970
1469
|
}
|
|
971
|
-
const artifactRelationEntries =
|
|
1470
|
+
const artifactRelationEntries = /* @__PURE__ */ new Map();
|
|
972
1471
|
for (const edge2 of artifactRelationEdges(index)) {
|
|
973
1472
|
const source = nodeByUid.get(edge2.from);
|
|
974
1473
|
const target = nodeByUid.get(edge2.to);
|
|
975
1474
|
if (!source || !target) continue;
|
|
976
|
-
|
|
1475
|
+
const relationLock = artifactRelationLockFromEdge(edge2, source, target);
|
|
1476
|
+
const identity = artifactRelationLockSortKey(relationLock);
|
|
1477
|
+
if (artifactRelationEntries.has(identity)) {
|
|
1478
|
+
continue;
|
|
1479
|
+
}
|
|
1480
|
+
artifactRelationEntries.set(identity, relationLock);
|
|
977
1481
|
}
|
|
978
1482
|
const next = {
|
|
979
1483
|
schemaVersion: VERSION_LOCK_SCHEMA_VERSION,
|
|
980
1484
|
locks: sortBy([...entries.values()], (item) => item.edgeId),
|
|
981
|
-
artifactRelations: sortBy(artifactRelationEntries, artifactRelationLockSortKey)
|
|
1485
|
+
artifactRelations: sortBy([...artifactRelationEntries.values()], artifactRelationLockSortKey)
|
|
982
1486
|
};
|
|
983
1487
|
await writeVersionLock(root, lockPath, next);
|
|
984
1488
|
return next;
|
|
@@ -1366,7 +1870,7 @@ function renderTraceVersionMarkdown(result) {
|
|
|
1366
1870
|
async function readVersionLock(root, lockPath) {
|
|
1367
1871
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1368
1872
|
try {
|
|
1369
|
-
const raw = await (0,
|
|
1873
|
+
const raw = await (0, import_promises3.readFile)((0, import_node_path3.join)(root, safeLockPath), "utf-8");
|
|
1370
1874
|
let parsed;
|
|
1371
1875
|
try {
|
|
1372
1876
|
parsed = JSON.parse(raw);
|
|
@@ -1525,9 +2029,9 @@ function requireSafeRelativePath(value, path) {
|
|
|
1525
2029
|
}
|
|
1526
2030
|
async function writeVersionLock(root, lockPath, lock) {
|
|
1527
2031
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1528
|
-
const fullPath = (0,
|
|
1529
|
-
await (0,
|
|
1530
|
-
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)}
|
|
1531
2035
|
`);
|
|
1532
2036
|
}
|
|
1533
2037
|
function implementationEdges(index) {
|
|
@@ -1708,14 +2212,14 @@ async function hashRelativePath(root, path, cache) {
|
|
|
1708
2212
|
const normalized = normalizeRelativePath(root, path);
|
|
1709
2213
|
const cached = cache.get(normalized);
|
|
1710
2214
|
if (cached) return cached;
|
|
1711
|
-
const content = await (0,
|
|
2215
|
+
const content = await (0, import_promises3.readFile)((0, import_node_path3.join)(root, normalized));
|
|
1712
2216
|
const hash = `sha256:${(0, import_node_crypto.createHash)("sha256").update(content).digest("hex")}`;
|
|
1713
2217
|
cache.set(normalized, hash);
|
|
1714
2218
|
return hash;
|
|
1715
2219
|
}
|
|
1716
2220
|
function normalizeRelativePath(root, path) {
|
|
1717
2221
|
const normalized = path.replace(/\\/g, "/");
|
|
1718
|
-
const relativePath = normalized.startsWith("/") ? (0,
|
|
2222
|
+
const relativePath = normalized.startsWith("/") ? (0, import_node_path3.relative)(root, normalized).replace(/\\/g, "/") : normalized.replace(/^\.\//, "");
|
|
1719
2223
|
if (relativePath === ".." || relativePath.startsWith("../")) {
|
|
1720
2224
|
throw new Error(`Path is outside root: ${path}`);
|
|
1721
2225
|
}
|
|
@@ -1731,10 +2235,10 @@ async function getTestFileRunnerLiveness(root, filePath, config) {
|
|
|
1731
2235
|
if (!/e2e/i.test(filePath) && !/\.e2e\./i.test(filePath)) {
|
|
1732
2236
|
return "active";
|
|
1733
2237
|
}
|
|
1734
|
-
const fullSourcePath = (0,
|
|
2238
|
+
const fullSourcePath = (0, import_node_path3.join)(root, filePath);
|
|
1735
2239
|
if (!(0, import_node_fs.existsSync)(fullSourcePath)) return "inactive";
|
|
1736
2240
|
try {
|
|
1737
|
-
const content = await (0,
|
|
2241
|
+
const content = await (0, import_promises3.readFile)(fullSourcePath, "utf-8");
|
|
1738
2242
|
return /\/\/!?\s*@(?:e2e_test|tc)\s+/.test(content) ? "active" : "inactive";
|
|
1739
2243
|
} catch {
|
|
1740
2244
|
return "inactive";
|
|
@@ -1774,14 +2278,14 @@ async function isFileActiveInRunner(root, filePath, runner) {
|
|
|
1774
2278
|
function sortUnique2(items) {
|
|
1775
2279
|
return [...new Set(items)].sort((left, right) => left.localeCompare(right));
|
|
1776
2280
|
}
|
|
1777
|
-
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;
|
|
1778
2282
|
var init_versioned_traceability = __esm({
|
|
1779
2283
|
"src/versioned-traceability.ts"() {
|
|
1780
2284
|
"use strict";
|
|
1781
2285
|
import_node_crypto = require("crypto");
|
|
1782
2286
|
import_node_fs = require("fs");
|
|
1783
|
-
|
|
1784
|
-
|
|
2287
|
+
import_promises3 = require("fs/promises");
|
|
2288
|
+
import_node_path3 = require("path");
|
|
1785
2289
|
init_index();
|
|
1786
2290
|
init_glob_matcher();
|
|
1787
2291
|
VERSION_LOCK_PATH = "artifacts/traceability-version-lock.json";
|
|
@@ -1802,7 +2306,7 @@ var init_versioned_traceability = __esm({
|
|
|
1802
2306
|
|
|
1803
2307
|
// src/impact.ts
|
|
1804
2308
|
async function computeImpact(root, options = {}) {
|
|
1805
|
-
const absoluteRoot = (0,
|
|
2309
|
+
const absoluteRoot = (0, import_node_path4.resolve)(root);
|
|
1806
2310
|
const mode = options.mode ?? "worktree";
|
|
1807
2311
|
if (mode === "base" && !options.base) throw new Error("Impact mode base requires a base ref.");
|
|
1808
2312
|
if (mode === "paths" && !options.paths) throw new Error("Impact mode paths requires paths.");
|
|
@@ -1874,8 +2378,8 @@ function normalizeExplicitPaths(root, paths) {
|
|
|
1874
2378
|
const normalized = paths.map((input) => {
|
|
1875
2379
|
const value = input.trim();
|
|
1876
2380
|
if (!value) return "";
|
|
1877
|
-
const absolutePath = (0,
|
|
1878
|
-
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);
|
|
1879
2383
|
const result = projectRelative.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1880
2384
|
if (result === ".." || result.startsWith("../") || result.startsWith("/")) {
|
|
1881
2385
|
throw new Error(`Impact path is outside project root: ${input}`);
|
|
@@ -1900,11 +2404,11 @@ function toEdgeRef(candidate) {
|
|
|
1900
2404
|
...candidate.attrs ? { attrs: candidate.attrs } : {}
|
|
1901
2405
|
};
|
|
1902
2406
|
}
|
|
1903
|
-
var
|
|
2407
|
+
var import_node_path4;
|
|
1904
2408
|
var init_impact = __esm({
|
|
1905
2409
|
"src/impact.ts"() {
|
|
1906
2410
|
"use strict";
|
|
1907
|
-
|
|
2411
|
+
import_node_path4 = require("path");
|
|
1908
2412
|
init_index();
|
|
1909
2413
|
init_git_changes();
|
|
1910
2414
|
init_versioned_traceability();
|
|
@@ -1913,7 +2417,7 @@ var init_impact = __esm({
|
|
|
1913
2417
|
|
|
1914
2418
|
// src/coverage.ts
|
|
1915
2419
|
async function computeCoverageBoundary(root, opts = {}) {
|
|
1916
|
-
const absoluteRoot = (0,
|
|
2420
|
+
const absoluteRoot = (0, import_node_path5.resolve)(root);
|
|
1917
2421
|
const schema = opts.schema ?? await loadConfig(absoluteRoot);
|
|
1918
2422
|
const graph = await scanArtifacts(absoluteRoot, schema);
|
|
1919
2423
|
const issues = validateGraph(graph, schema);
|
|
@@ -2015,11 +2519,11 @@ function renderCoverageBoundaryMarkdown(report) {
|
|
|
2015
2519
|
function normalizeInputList(input) {
|
|
2016
2520
|
return [...new Set(input.map((item) => item.trim().replace(/\\/g, "/").replace(/^\.\//, "")).filter(Boolean))].sort((left, right) => left.localeCompare(right));
|
|
2017
2521
|
}
|
|
2018
|
-
var
|
|
2522
|
+
var import_node_path5;
|
|
2019
2523
|
var init_coverage = __esm({
|
|
2020
2524
|
"src/coverage.ts"() {
|
|
2021
2525
|
"use strict";
|
|
2022
|
-
|
|
2526
|
+
import_node_path5 = require("path");
|
|
2023
2527
|
init_index();
|
|
2024
2528
|
init_impact();
|
|
2025
2529
|
init_versioned_traceability();
|
|
@@ -2585,14 +3089,14 @@ async function auditSingleTarget(target, graph, options) {
|
|
|
2585
3089
|
const fmt = options.format ?? "markdown";
|
|
2586
3090
|
const ext = fmt === "json" ? "json" : "md";
|
|
2587
3091
|
const filename = `${target.type}-${target.id}.packet.${ext}`;
|
|
2588
|
-
const outPath = (0,
|
|
3092
|
+
const outPath = (0, import_node_path6.join)(options.outDir, filename);
|
|
2589
3093
|
let content;
|
|
2590
3094
|
if (fmt === "json") {
|
|
2591
3095
|
content = JSON.stringify(packet, null, 2) + "\n";
|
|
2592
3096
|
} else {
|
|
2593
3097
|
content = renderPacketMarkdown(packet);
|
|
2594
3098
|
}
|
|
2595
|
-
await (0,
|
|
3099
|
+
await (0, import_promises4.writeFile)(outPath, content, "utf-8");
|
|
2596
3100
|
entry.outputPath = outPath;
|
|
2597
3101
|
}
|
|
2598
3102
|
} catch (error) {
|
|
@@ -2613,7 +3117,7 @@ async function auditPackets(root, targets, options, graph) {
|
|
|
2613
3117
|
}
|
|
2614
3118
|
}
|
|
2615
3119
|
if (options.outDir) {
|
|
2616
|
-
await (0,
|
|
3120
|
+
await (0, import_promises4.mkdir)(options.outDir, { recursive: true });
|
|
2617
3121
|
}
|
|
2618
3122
|
const sampleSet = options.sampleTargets ? new Set(options.sampleTargets) : null;
|
|
2619
3123
|
const sampleOutputPaths = [];
|
|
@@ -2665,8 +3169,8 @@ async function auditPackets(root, targets, options, graph) {
|
|
|
2665
3169
|
...isCompact ? { summaryDetail: "compact", countsByType } : {}
|
|
2666
3170
|
};
|
|
2667
3171
|
if (options.outDir) {
|
|
2668
|
-
const summaryPath = (0,
|
|
2669
|
-
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");
|
|
2670
3174
|
}
|
|
2671
3175
|
return summary;
|
|
2672
3176
|
}
|
|
@@ -2692,14 +3196,14 @@ async function discoverAndAuditPackets(root, options) {
|
|
|
2692
3196
|
universalBaseline: effectiveBaseline
|
|
2693
3197
|
}, graph);
|
|
2694
3198
|
}
|
|
2695
|
-
var
|
|
3199
|
+
var import_promises4, import_node_path6, VALID_TYPES, VALID_TYPES_LABEL;
|
|
2696
3200
|
var init_packet_audit = __esm({
|
|
2697
3201
|
"src/packet-audit.ts"() {
|
|
2698
3202
|
"use strict";
|
|
2699
3203
|
init_index();
|
|
2700
3204
|
init_packet_validator();
|
|
2701
|
-
|
|
2702
|
-
|
|
3205
|
+
import_promises4 = require("fs/promises");
|
|
3206
|
+
import_node_path6 = require("path");
|
|
2703
3207
|
VALID_TYPES = new Set(VALID_PACKET_TARGET_TYPES);
|
|
2704
3208
|
VALID_TYPES_LABEL = VALID_PACKET_TARGET_TYPES.join(", ");
|
|
2705
3209
|
}
|
|
@@ -3173,10 +3677,10 @@ function buildNativeBindingSuccessDiagnostic(probeContext) {
|
|
|
3173
3677
|
};
|
|
3174
3678
|
}
|
|
3175
3679
|
function findPackageRoot(anchorFile) {
|
|
3176
|
-
let dir = (0,
|
|
3680
|
+
let dir = (0, import_node_path7.dirname)(anchorFile);
|
|
3177
3681
|
for (; ; ) {
|
|
3178
|
-
if ((0, import_node_fs2.existsSync)((0,
|
|
3179
|
-
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);
|
|
3180
3684
|
if (parent === dir) return void 0;
|
|
3181
3685
|
dir = parent;
|
|
3182
3686
|
}
|
|
@@ -3192,9 +3696,9 @@ function abiPrebuiltHint(detail) {
|
|
|
3192
3696
|
return match ? `\uFF1Bprebuilt \u76EE\u6807 NODE_MODULE_VERSION=${match[1]}` : "";
|
|
3193
3697
|
}
|
|
3194
3698
|
function betterSqlite3PackagePresent(root) {
|
|
3195
|
-
const direct = (0,
|
|
3699
|
+
const direct = (0, import_node_path7.join)(root, "node_modules", "better-sqlite3", "package.json");
|
|
3196
3700
|
if ((0, import_node_fs2.existsSync)(direct)) return true;
|
|
3197
|
-
const pnpmDir = (0,
|
|
3701
|
+
const pnpmDir = (0, import_node_path7.join)(root, "node_modules", ".pnpm");
|
|
3198
3702
|
let entries;
|
|
3199
3703
|
try {
|
|
3200
3704
|
entries = (0, import_node_fs2.readdirSync)(pnpmDir);
|
|
@@ -3203,16 +3707,16 @@ function betterSqlite3PackagePresent(root) {
|
|
|
3203
3707
|
}
|
|
3204
3708
|
return entries.some((entry) => {
|
|
3205
3709
|
if (!entry.startsWith("better-sqlite3@")) return false;
|
|
3206
|
-
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"));
|
|
3207
3711
|
});
|
|
3208
3712
|
}
|
|
3209
|
-
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;
|
|
3210
3714
|
var init_native_binding_diagnostics = __esm({
|
|
3211
3715
|
"src/native-binding-diagnostics.ts"() {
|
|
3212
3716
|
"use strict";
|
|
3213
3717
|
import_node_fs2 = require("fs");
|
|
3214
3718
|
import_node_module = require("module");
|
|
3215
|
-
|
|
3719
|
+
import_node_path7 = require("path");
|
|
3216
3720
|
import_node_url = require("url");
|
|
3217
3721
|
import_meta = {};
|
|
3218
3722
|
PNPM_ALLOW_BUILDS_SNIPPET = "pnpm-workspace.yaml:\nallowBuilds:\n better-sqlite3: true";
|
|
@@ -3226,7 +3730,7 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3226
3730
|
const candidates = [
|
|
3227
3731
|
{
|
|
3228
3732
|
source: "node_modules",
|
|
3229
|
-
path: (0,
|
|
3733
|
+
path: (0, import_node_path8.join)(root, "node_modules/.bin/artifact-graph"),
|
|
3230
3734
|
exists: false
|
|
3231
3735
|
},
|
|
3232
3736
|
{
|
|
@@ -3259,8 +3763,8 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3259
3763
|
}
|
|
3260
3764
|
async function doctorArtifactChain(root, options = {}) {
|
|
3261
3765
|
const cli = await resolveArtifactGraphCli(root, options);
|
|
3262
|
-
const configPath = (0,
|
|
3263
|
-
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);
|
|
3264
3768
|
const supportedCommands = cli.path ? await detectSupportedCommands(cli.path) : [];
|
|
3265
3769
|
const nodeCompatible = isNodeCompatible(process.versions.node);
|
|
3266
3770
|
const pnpmVersion = await detectPnpmVersion();
|
|
@@ -3280,12 +3784,28 @@ async function doctorArtifactChain(root, options = {}) {
|
|
|
3280
3784
|
probedFrom
|
|
3281
3785
|
};
|
|
3282
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
|
+
}
|
|
3283
3801
|
const warnings = [
|
|
3284
3802
|
...cli.warnings,
|
|
3285
3803
|
...nodeCompatible ? [] : [`Node.js ${process.versions.node} does not satisfy ${REQUIRED_NODE_VERSION}.`],
|
|
3286
3804
|
...probe.ok ? [] : [
|
|
3287
3805
|
`better-sqlite3 binding probe FAILED at stage "${probe.failedStage}" (cause ${probe.cause}): ${probe.suggestion}`
|
|
3288
|
-
]
|
|
3806
|
+
],
|
|
3807
|
+
...configShapeMessages,
|
|
3808
|
+
...loadConfigMessages
|
|
3289
3809
|
];
|
|
3290
3810
|
return {
|
|
3291
3811
|
schemaVersion: "1.0",
|
|
@@ -3379,7 +3899,7 @@ ${maybe.stderr ?? ""}`;
|
|
|
3379
3899
|
}
|
|
3380
3900
|
async function pathExists(path) {
|
|
3381
3901
|
try {
|
|
3382
|
-
await (0,
|
|
3902
|
+
await (0, import_promises5.access)(path, import_node_fs3.constants.R_OK);
|
|
3383
3903
|
return true;
|
|
3384
3904
|
} catch {
|
|
3385
3905
|
return false;
|
|
@@ -3395,7 +3915,7 @@ async function findCommandOnPath(command) {
|
|
|
3395
3915
|
}
|
|
3396
3916
|
}
|
|
3397
3917
|
function resolveCandidatePath(root, candidatePath) {
|
|
3398
|
-
return (0,
|
|
3918
|
+
return (0, import_node_path8.isAbsolute)(candidatePath) ? candidatePath : (0, import_node_path8.resolve)(root, candidatePath);
|
|
3399
3919
|
}
|
|
3400
3920
|
function isNodeCompatible(version) {
|
|
3401
3921
|
const match = /^(\d+)\.(\d+)\.(\d+)(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
@@ -3437,7 +3957,7 @@ function bindingInstallRoot(cli, _root) {
|
|
|
3437
3957
|
}
|
|
3438
3958
|
function resolveCliInstallAnchor(cliPath) {
|
|
3439
3959
|
const real = safeRealpath(cliPath);
|
|
3440
|
-
if ((0,
|
|
3960
|
+
if ((0, import_node_path8.basename)((0, import_node_path8.dirname)(real)) !== ".bin") return real;
|
|
3441
3961
|
const shimTarget = readBinShimTarget(real);
|
|
3442
3962
|
return shimTarget ? safeRealpath(shimTarget) : real;
|
|
3443
3963
|
}
|
|
@@ -3451,7 +3971,7 @@ function readBinShimTarget(shimPath) {
|
|
|
3451
3971
|
if (!content.startsWith("#!")) return void 0;
|
|
3452
3972
|
const match = /\$basedir\/(\.\.(?:\/[^"'\s]+)+\.js)/.exec(content);
|
|
3453
3973
|
if (!match) return void 0;
|
|
3454
|
-
return (0,
|
|
3974
|
+
return (0, import_node_path8.resolve)((0, import_node_path8.dirname)(shimPath), match[1]);
|
|
3455
3975
|
}
|
|
3456
3976
|
function safeRealpath(path) {
|
|
3457
3977
|
try {
|
|
@@ -3460,16 +3980,17 @@ function safeRealpath(path) {
|
|
|
3460
3980
|
return path;
|
|
3461
3981
|
}
|
|
3462
3982
|
}
|
|
3463
|
-
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;
|
|
3464
3984
|
var init_cli_resolver = __esm({
|
|
3465
3985
|
"src/cli-resolver.ts"() {
|
|
3466
3986
|
"use strict";
|
|
3467
3987
|
import_node_child_process2 = require("child_process");
|
|
3468
3988
|
import_node_fs3 = require("fs");
|
|
3469
|
-
|
|
3470
|
-
|
|
3989
|
+
import_promises5 = require("fs/promises");
|
|
3990
|
+
import_node_path8 = require("path");
|
|
3471
3991
|
import_node_util2 = require("util");
|
|
3472
3992
|
init_versioned_traceability();
|
|
3993
|
+
init_doctor();
|
|
3473
3994
|
init_native_binding_diagnostics();
|
|
3474
3995
|
execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process2.execFile);
|
|
3475
3996
|
REQUIRED_NODE_VERSION = ">=22.22.2 <23";
|
|
@@ -3510,14 +4031,14 @@ async function resolveGitHookPath(root, hookName) {
|
|
|
3510
4031
|
]);
|
|
3511
4032
|
const value = stdout.trim();
|
|
3512
4033
|
if (!value) throw new Error(`Git returned an empty hook path for ${hookName}`);
|
|
3513
|
-
return (0,
|
|
4034
|
+
return (0, import_node_path9.isAbsolute)(value) ? (0, import_node_path9.resolve)(value) : (0, import_node_path9.resolve)(root, value);
|
|
3514
4035
|
}
|
|
3515
|
-
var import_node_child_process3,
|
|
4036
|
+
var import_node_child_process3, import_node_path9, import_node_util3, execFileAsync3;
|
|
3516
4037
|
var init_git_hook_path = __esm({
|
|
3517
4038
|
"src/git-hook-path.ts"() {
|
|
3518
4039
|
"use strict";
|
|
3519
4040
|
import_node_child_process3 = require("child_process");
|
|
3520
|
-
|
|
4041
|
+
import_node_path9 = require("path");
|
|
3521
4042
|
import_node_util3 = require("util");
|
|
3522
4043
|
execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
3523
4044
|
}
|
|
@@ -3740,7 +4261,7 @@ async function readHookSnapshot(hookPath) {
|
|
|
3740
4261
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
3741
4262
|
let metadata;
|
|
3742
4263
|
try {
|
|
3743
|
-
metadata = await (0,
|
|
4264
|
+
metadata = await (0, import_promises6.lstat)(hookPath, { bigint: true });
|
|
3744
4265
|
} catch (error) {
|
|
3745
4266
|
if (error.code === "ENOENT") {
|
|
3746
4267
|
return { kind: "missing", bytes: Buffer.alloc(0) };
|
|
@@ -3756,7 +4277,7 @@ async function readHookSnapshot(hookPath) {
|
|
|
3756
4277
|
size: metadata.size,
|
|
3757
4278
|
mtimeNs: metadata.mtimeNs,
|
|
3758
4279
|
mode: metadata.mode,
|
|
3759
|
-
linkTarget: await (0,
|
|
4280
|
+
linkTarget: await (0, import_promises6.readlink)(hookPath)
|
|
3760
4281
|
};
|
|
3761
4282
|
}
|
|
3762
4283
|
if (!metadata.isFile()) {
|
|
@@ -3772,7 +4293,7 @@ async function readHookSnapshot(hookPath) {
|
|
|
3772
4293
|
}
|
|
3773
4294
|
let handle;
|
|
3774
4295
|
try {
|
|
3775
|
-
handle = await (0,
|
|
4296
|
+
handle = await (0, import_promises6.open)(hookPath, import_node_fs4.constants.O_RDONLY | (import_node_fs4.constants.O_NOFOLLOW ?? 0));
|
|
3776
4297
|
const opened = await handle.stat({ bigint: true });
|
|
3777
4298
|
if (opened.dev !== metadata.dev || opened.ino !== metadata.ino) {
|
|
3778
4299
|
await handle.close();
|
|
@@ -3830,15 +4351,15 @@ async function removeHookAtomically(hookPath, snapshot) {
|
|
|
3830
4351
|
throw new ConcurrentHookModificationError(hookPath);
|
|
3831
4352
|
}
|
|
3832
4353
|
if (current.kind !== "missing") {
|
|
3833
|
-
await (0,
|
|
4354
|
+
await (0, import_promises6.unlink)(hookPath);
|
|
3834
4355
|
}
|
|
3835
4356
|
}
|
|
3836
4357
|
async function writeHookAtomically(hookPath, content, snapshot, mode) {
|
|
3837
|
-
await (0,
|
|
3838
|
-
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`);
|
|
3839
4360
|
let temporaryExists = false;
|
|
3840
4361
|
try {
|
|
3841
|
-
const temporary = await (0,
|
|
4362
|
+
const temporary = await (0, import_promises6.open)(temporaryPath, "wx", mode);
|
|
3842
4363
|
temporaryExists = true;
|
|
3843
4364
|
try {
|
|
3844
4365
|
await temporary.writeFile(content);
|
|
@@ -3851,11 +4372,11 @@ async function writeHookAtomically(hookPath, content, snapshot, mode) {
|
|
|
3851
4372
|
if (!sameHookSnapshot(snapshot, current)) {
|
|
3852
4373
|
throw new ConcurrentHookModificationError(hookPath);
|
|
3853
4374
|
}
|
|
3854
|
-
await (0,
|
|
4375
|
+
await (0, import_promises6.rename)(temporaryPath, hookPath);
|
|
3855
4376
|
temporaryExists = false;
|
|
3856
4377
|
} finally {
|
|
3857
4378
|
if (temporaryExists) {
|
|
3858
|
-
await (0,
|
|
4379
|
+
await (0, import_promises6.unlink)(temporaryPath).catch((error) => {
|
|
3859
4380
|
if (error.code !== "ENOENT") {
|
|
3860
4381
|
throw error;
|
|
3861
4382
|
}
|
|
@@ -3881,14 +4402,14 @@ function findManagedRange(content, begin, end) {
|
|
|
3881
4402
|
end: endLine < 0 ? content.length : endLine + 1
|
|
3882
4403
|
};
|
|
3883
4404
|
}
|
|
3884
|
-
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;
|
|
3885
4406
|
var init_hook_installer = __esm({
|
|
3886
4407
|
"src/hook-installer.ts"() {
|
|
3887
4408
|
"use strict";
|
|
3888
4409
|
import_node_fs4 = require("fs");
|
|
3889
4410
|
import_node_crypto2 = require("crypto");
|
|
3890
|
-
|
|
3891
|
-
|
|
4411
|
+
import_promises6 = require("fs/promises");
|
|
4412
|
+
import_node_path10 = require("path");
|
|
3892
4413
|
DEFAULT_MARKER_ID = "artifact-chain-assistant";
|
|
3893
4414
|
MANAGED_STATE_PREFIX = "# artifact-chain-assistant managed state v1:";
|
|
3894
4415
|
UnsupportedHookInterpreterError = class extends Error {
|
|
@@ -3980,9 +4501,9 @@ function harnessKind(error) {
|
|
|
3980
4501
|
return typeof details?.kind === "string" ? details.kind : void 0;
|
|
3981
4502
|
}
|
|
3982
4503
|
async function missingRequiredConfig(root) {
|
|
3983
|
-
const configPath = (0,
|
|
4504
|
+
const configPath = (0, import_node_path11.join)(root, "artifact-graph.config.yaml");
|
|
3984
4505
|
try {
|
|
3985
|
-
await (0,
|
|
4506
|
+
await (0, import_promises7.access)(configPath);
|
|
3986
4507
|
return void 0;
|
|
3987
4508
|
} catch (error) {
|
|
3988
4509
|
if (error.code === "ENOENT") {
|
|
@@ -4100,7 +4621,7 @@ function buildLimitations(checks) {
|
|
|
4100
4621
|
return [...new Set(limitations)];
|
|
4101
4622
|
}
|
|
4102
4623
|
function buildConclusion(root, checks) {
|
|
4103
|
-
const absoluteRoot = (0,
|
|
4624
|
+
const absoluteRoot = (0, import_node_path11.resolve)(root);
|
|
4104
4625
|
const mapped = mapDomain(checks);
|
|
4105
4626
|
const checked = checks.filter((check) => check.status === "completed").map((check) => check.name);
|
|
4106
4627
|
const limitations = buildLimitations(checks);
|
|
@@ -4153,11 +4674,11 @@ async function assertConclusionShape(conclusion) {
|
|
|
4153
4674
|
}
|
|
4154
4675
|
}
|
|
4155
4676
|
async function publishConclusion(absoluteOutput, conclusion) {
|
|
4156
|
-
if (!(0,
|
|
4677
|
+
if (!(0, import_node_path11.isAbsolute)(absoluteOutput)) {
|
|
4157
4678
|
return "--conclusion-output must be an absolute path";
|
|
4158
4679
|
}
|
|
4159
|
-
const outputRoot = (0,
|
|
4160
|
-
const relPath = (0,
|
|
4680
|
+
const outputRoot = (0, import_node_path11.dirname)(absoluteOutput);
|
|
4681
|
+
const relPath = (0, import_node_path11.basename)(absoluteOutput);
|
|
4161
4682
|
if (relPath.length === 0 || relPath === "." || relPath === "..") {
|
|
4162
4683
|
return "--conclusion-output must name a file";
|
|
4163
4684
|
}
|
|
@@ -4175,7 +4696,7 @@ async function publishConclusion(absoluteOutput, conclusion) {
|
|
|
4175
4696
|
}
|
|
4176
4697
|
}
|
|
4177
4698
|
async function runCheckProfessional(options) {
|
|
4178
|
-
const root = (0,
|
|
4699
|
+
const root = (0, import_node_path11.resolve)(options.root);
|
|
4179
4700
|
const configGap = await missingRequiredConfig(root);
|
|
4180
4701
|
const checks = configGap === void 0 ? await Promise.all([
|
|
4181
4702
|
settleCheck(CHECK_VALIDATE, () => runValidate(root)),
|
|
@@ -4191,10 +4712,10 @@ async function runCheckProfessional(options) {
|
|
|
4191
4712
|
if (options.conclusionOutput === void 0) {
|
|
4192
4713
|
return { conclusion };
|
|
4193
4714
|
}
|
|
4194
|
-
if (!(0,
|
|
4715
|
+
if (!(0, import_node_path11.isAbsolute)(options.conclusionOutput)) {
|
|
4195
4716
|
return { conclusion, writeError: "--conclusion-output must be an absolute path" };
|
|
4196
4717
|
}
|
|
4197
|
-
const writeError = await publishConclusion((0,
|
|
4718
|
+
const writeError = await publishConclusion((0, import_node_path11.resolve)(options.conclusionOutput), conclusion);
|
|
4198
4719
|
return { conclusion, ...writeError ? { writeError } : {} };
|
|
4199
4720
|
}
|
|
4200
4721
|
function asRecord(value) {
|
|
@@ -4297,13 +4818,13 @@ async function runReadProof(options) {
|
|
|
4297
4818
|
const exitCode = interpreted.status === "pass" ? 0 : interpreted.status === "not_pass" ? 1 : 2;
|
|
4298
4819
|
return { result: interpreted, exitCode };
|
|
4299
4820
|
}
|
|
4300
|
-
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;
|
|
4301
4822
|
var init_professional_conclusion = __esm({
|
|
4302
4823
|
"src/professional-conclusion.ts"() {
|
|
4303
4824
|
"use strict";
|
|
4304
|
-
|
|
4825
|
+
import_promises7 = require("fs/promises");
|
|
4305
4826
|
import_node_module2 = require("module");
|
|
4306
|
-
|
|
4827
|
+
import_node_path11 = require("path");
|
|
4307
4828
|
import_node_url2 = require("url");
|
|
4308
4829
|
init_coverage();
|
|
4309
4830
|
init_index();
|
|
@@ -4928,7 +5449,7 @@ function validatePolicyCompatibility(policy, baseContract) {
|
|
|
4928
5449
|
};
|
|
4929
5450
|
}
|
|
4930
5451
|
async function loadContract(contractPath, options) {
|
|
4931
|
-
const rawContent = await (0,
|
|
5452
|
+
const rawContent = await (0, import_promises8.readFile)(contractPath, "utf-8");
|
|
4932
5453
|
let schema;
|
|
4933
5454
|
try {
|
|
4934
5455
|
schema = JSON.parse(rawContent);
|
|
@@ -4976,10 +5497,10 @@ async function loadContract(contractPath, options) {
|
|
|
4976
5497
|
}
|
|
4977
5498
|
async function loadContractsFromDirectory(contractsDir, options) {
|
|
4978
5499
|
const contracts = [];
|
|
4979
|
-
const entries = await (0,
|
|
5500
|
+
const entries = await (0, import_promises8.readdir)(contractsDir, { withFileTypes: true });
|
|
4980
5501
|
for (const entry of entries) {
|
|
4981
5502
|
if (entry.isDirectory()) {
|
|
4982
|
-
const schemaPath = (0,
|
|
5503
|
+
const schemaPath = (0, import_node_path12.join)(contractsDir, entry.name, "schema.json");
|
|
4983
5504
|
const contract = await loadContract(schemaPath, options);
|
|
4984
5505
|
contracts.push(contract);
|
|
4985
5506
|
}
|
|
@@ -4989,7 +5510,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
4989
5510
|
function getValidator(schema) {
|
|
4990
5511
|
const key = `${schema.$id || "default"}#${computeRevisionDigest(JSON.stringify(schema))}`;
|
|
4991
5512
|
if (!_validatorCache.has(key)) {
|
|
4992
|
-
const AjvCtor =
|
|
5513
|
+
const AjvCtor = import_ajv2.default;
|
|
4993
5514
|
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
4994
5515
|
_validatorCache.set(key, ajv.compile(schema));
|
|
4995
5516
|
}
|
|
@@ -5094,14 +5615,14 @@ async function loadContractCatalog(contractsDir, options) {
|
|
|
5094
5615
|
}
|
|
5095
5616
|
return catalog;
|
|
5096
5617
|
}
|
|
5097
|
-
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;
|
|
5098
5619
|
var init_contract_kernel = __esm({
|
|
5099
5620
|
"src/contract-kernel.ts"() {
|
|
5100
5621
|
"use strict";
|
|
5101
5622
|
import_node_crypto3 = require("crypto");
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5623
|
+
import_promises8 = require("fs/promises");
|
|
5624
|
+
import_node_path12 = require("path");
|
|
5625
|
+
import_ajv2 = __toESM(require("ajv"), 1);
|
|
5105
5626
|
CONTRACT_ERROR_CODES = {
|
|
5106
5627
|
/** Contract identity not found */
|
|
5107
5628
|
CONTRACT_NOT_FOUND: "CONTRACT_NOT_FOUND",
|
|
@@ -5583,13 +6104,13 @@ function rawDigest(value, path) {
|
|
|
5583
6104
|
async function resolveRealRoot(root) {
|
|
5584
6105
|
let canonical;
|
|
5585
6106
|
try {
|
|
5586
|
-
canonical = await (0,
|
|
6107
|
+
canonical = await (0, import_promises9.realpath)((0, import_node_path13.resolve)(root));
|
|
5587
6108
|
} catch (cause) {
|
|
5588
6109
|
return failure("ROOT_INVALID", `Project root cannot be resolved: ${cause.message}`);
|
|
5589
6110
|
}
|
|
5590
6111
|
let info;
|
|
5591
6112
|
try {
|
|
5592
|
-
info = await (0,
|
|
6113
|
+
info = await (0, import_promises9.lstat)(canonical);
|
|
5593
6114
|
} catch (cause) {
|
|
5594
6115
|
return failure("ROOT_INVALID", `Project root cannot be inspected: ${cause.message}`);
|
|
5595
6116
|
}
|
|
@@ -5609,7 +6130,7 @@ async function qualifyRestructureMechanism(root) {
|
|
|
5609
6130
|
if (!canonical.ok) return canonical;
|
|
5610
6131
|
let type;
|
|
5611
6132
|
try {
|
|
5612
|
-
type = (await (0,
|
|
6133
|
+
type = (await (0, import_promises9.statfs)(canonical.data)).type;
|
|
5613
6134
|
} catch (cause) {
|
|
5614
6135
|
return failure("APPLY_ENVIRONMENT_UNSUPPORTED", `Project root filesystem cannot be inspected: ${cause.message}`);
|
|
5615
6136
|
}
|
|
@@ -5622,8 +6143,8 @@ async function qualifyRestructureMechanism(root) {
|
|
|
5622
6143
|
return { ok: true, data: { root: canonical.data, filesystem: RESTRUCTURE_QUALIFIED_FILESYSTEM } };
|
|
5623
6144
|
}
|
|
5624
6145
|
async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
5625
|
-
const target = (0,
|
|
5626
|
-
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));
|
|
5627
6148
|
let info = await current();
|
|
5628
6149
|
if (info === null) {
|
|
5629
6150
|
if (!options.create) {
|
|
@@ -5634,7 +6155,7 @@ async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
|
5634
6155
|
}
|
|
5635
6156
|
let created = false;
|
|
5636
6157
|
try {
|
|
5637
|
-
await (0,
|
|
6158
|
+
await (0, import_promises9.mkdir)(target, { mode: RESTRUCTURE_RECOVERY_ROOT_MODE });
|
|
5638
6159
|
created = true;
|
|
5639
6160
|
} catch (cause) {
|
|
5640
6161
|
if (cause.code !== "EEXIST") {
|
|
@@ -5647,7 +6168,7 @@ async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
|
5647
6168
|
return failure("MECHANISM_ROOT_UNSAFE", `${target} must be one real directory, not a link or special entry`);
|
|
5648
6169
|
}
|
|
5649
6170
|
if (created && (info.mode & 4095) !== RESTRUCTURE_RECOVERY_ROOT_MODE) {
|
|
5650
|
-
await (0,
|
|
6171
|
+
await (0, import_promises9.chmod)(target, RESTRUCTURE_RECOVERY_ROOT_MODE);
|
|
5651
6172
|
info = await current();
|
|
5652
6173
|
if (info === null || info.isSymbolicLink() || !info.isDirectory()) {
|
|
5653
6174
|
return failure("MECHANISM_ROOT_UNSAFE", `${target} must be one real directory, not a link or special entry`);
|
|
@@ -5736,7 +6257,7 @@ async function applyRestructureFileSet(canonicalRoot, plan, options) {
|
|
|
5736
6257
|
return await verifyMechanismResult(raw);
|
|
5737
6258
|
}
|
|
5738
6259
|
async function observeRestructureJournal(canonicalRoot) {
|
|
5739
|
-
const journalRoot = (0,
|
|
6260
|
+
const journalRoot = (0, import_node_path13.join)(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
|
|
5740
6261
|
const module2 = await loadFoundationModule();
|
|
5741
6262
|
try {
|
|
5742
6263
|
return { ok: true, data: await module2.inspectStateStoreLock(journalRoot, { recoveryObservation: true }) };
|
|
@@ -5923,13 +6444,13 @@ function projectRestructureFileSetResult(result, planPath = "", planDigest = "")
|
|
|
5923
6444
|
const reading = result.operation === "apply" ? applyProjection(result) : result.operation === "recover" ? recoverProjection(result) : pruneProjection(result);
|
|
5924
6445
|
return { ...base, ...reading };
|
|
5925
6446
|
}
|
|
5926
|
-
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;
|
|
5927
6448
|
var init_restructure_file_set = __esm({
|
|
5928
6449
|
"src/restructure-file-set.ts"() {
|
|
5929
6450
|
"use strict";
|
|
5930
6451
|
import_node_crypto4 = require("crypto");
|
|
5931
|
-
|
|
5932
|
-
|
|
6452
|
+
import_promises9 = require("fs/promises");
|
|
6453
|
+
import_node_path13 = require("path");
|
|
5933
6454
|
RESTRUCTURE_RECOVERY_REL_PATH = ".foundation-file-apply";
|
|
5934
6455
|
RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH = `${RESTRUCTURE_RECOVERY_REL_PATH}/journal`;
|
|
5935
6456
|
RESTRUCTURE_RECOVERY_ROOT_MODE = 448;
|
|
@@ -5961,7 +6482,7 @@ function digestRestructureValue(value) {
|
|
|
5961
6482
|
return digestBytes(canonicalJson(value));
|
|
5962
6483
|
}
|
|
5963
6484
|
function normalizeRelativePath2(value) {
|
|
5964
|
-
if (!value || value.includes("\0") || (0,
|
|
6485
|
+
if (!value || value.includes("\0") || (0, import_node_path14.isAbsolute)(value)) return void 0;
|
|
5965
6486
|
const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
5966
6487
|
if (!normalized || normalized === "." || normalized.split("/").some((part) => part === ".." || part === "")) return void 0;
|
|
5967
6488
|
return normalized;
|
|
@@ -5975,13 +6496,13 @@ function isPathAllowed(path, allowed) {
|
|
|
5975
6496
|
async function readContainedFileWithMode(root, path) {
|
|
5976
6497
|
const normalized = normalizeRelativePath2(path);
|
|
5977
6498
|
if (!normalized) throw new Error(`Path must be a project-relative path without traversal: ${path}`);
|
|
5978
|
-
const absoluteRoot = (0,
|
|
5979
|
-
const absolutePath = (0,
|
|
5980
|
-
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}`);
|
|
5981
6502
|
try {
|
|
5982
|
-
const info = await (0,
|
|
6503
|
+
const info = await (0, import_promises10.lstat)(absolutePath);
|
|
5983
6504
|
if (info.isSymbolicLink() || !info.isFile()) throw new Error(`Path is not a regular file: ${path}`);
|
|
5984
|
-
return { buffer: await (0,
|
|
6505
|
+
return { buffer: await (0, import_promises10.readFile)(absolutePath), mode: info.mode & MAX_POSIX_MODE };
|
|
5985
6506
|
} catch (error) {
|
|
5986
6507
|
if (error.code === "ENOENT") return void 0;
|
|
5987
6508
|
throw error;
|
|
@@ -6009,7 +6530,7 @@ async function configSnapshot(root) {
|
|
|
6009
6530
|
return snapshotFile(root, "artifact-graph.config.yaml");
|
|
6010
6531
|
}
|
|
6011
6532
|
async function loadRestructureContract(name) {
|
|
6012
|
-
return loadContract((0,
|
|
6533
|
+
return loadContract((0, import_node_path14.join)(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
|
|
6013
6534
|
}
|
|
6014
6535
|
async function validateDomainContract(name, value) {
|
|
6015
6536
|
const contract = await loadRestructureContract(name);
|
|
@@ -6270,7 +6791,7 @@ function splitMarkdownTarget(target) {
|
|
|
6270
6791
|
}
|
|
6271
6792
|
async function pathExists2(absolutePath) {
|
|
6272
6793
|
try {
|
|
6273
|
-
await (0,
|
|
6794
|
+
await (0, import_promises10.lstat)(absolutePath);
|
|
6274
6795
|
return true;
|
|
6275
6796
|
} catch {
|
|
6276
6797
|
return false;
|
|
@@ -6278,20 +6799,20 @@ async function pathExists2(absolutePath) {
|
|
|
6278
6799
|
}
|
|
6279
6800
|
async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
6280
6801
|
const migrationPaths = [.../* @__PURE__ */ new Set([...sourcePaths, ...targetPaths])];
|
|
6281
|
-
const migrationNames = new Set(migrationPaths.map((path) =>
|
|
6282
|
-
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)));
|
|
6283
6804
|
const findings = [];
|
|
6284
6805
|
async function visit(directory) {
|
|
6285
|
-
for (const entry of await (0,
|
|
6806
|
+
for (const entry of await (0, import_promises10.readdir)(directory, { withFileTypes: true })) {
|
|
6286
6807
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6287
|
-
const absolute = (0,
|
|
6808
|
+
const absolute = (0, import_node_path14.join)(directory, entry.name);
|
|
6288
6809
|
if (entry.isDirectory()) {
|
|
6289
6810
|
await visit(absolute);
|
|
6290
6811
|
continue;
|
|
6291
6812
|
}
|
|
6292
6813
|
if (!entry.isFile() || !TEXT_EXTENSIONS.test(entry.name)) continue;
|
|
6293
|
-
const path = (0,
|
|
6294
|
-
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");
|
|
6295
6816
|
const namesTheMigration = migrationPaths.some((reference) => raw.includes(reference));
|
|
6296
6817
|
const lines = raw.split(/\r?\n/);
|
|
6297
6818
|
for (const [index, line] of lines.entries()) {
|
|
@@ -6303,8 +6824,8 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6303
6824
|
const literal = match[0];
|
|
6304
6825
|
const { path: linkPath, anchor } = splitMarkdownTarget(match[2]);
|
|
6305
6826
|
if (!linkPath || linkPath.startsWith("/") || /^[a-z][a-z0-9+.-]*:/i.test(linkPath)) continue;
|
|
6306
|
-
if (!migrationNames.has(
|
|
6307
|
-
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));
|
|
6308
6829
|
if (!resolved || targetPaths.includes(resolved)) continue;
|
|
6309
6830
|
if (anchor) {
|
|
6310
6831
|
findings.push(finding(
|
|
@@ -6313,7 +6834,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6313
6834
|
path,
|
|
6314
6835
|
lineNumber
|
|
6315
6836
|
));
|
|
6316
|
-
} else if (!await pathExists2((0,
|
|
6837
|
+
} else if (!await pathExists2((0, import_node_path14.resolve)(root, resolved))) {
|
|
6317
6838
|
findings.push(finding(
|
|
6318
6839
|
"SIBLING_RELATIVE_REFERENCE_UNRESOLVED",
|
|
6319
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`,
|
|
@@ -6338,7 +6859,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6338
6859
|
}
|
|
6339
6860
|
}
|
|
6340
6861
|
}
|
|
6341
|
-
await visit((0,
|
|
6862
|
+
await visit((0, import_node_path14.resolve)(root));
|
|
6342
6863
|
const unique = new Map(findings.map((item) => [`${item.code} ${item.path} ${item.line} ${item.message}`, item]));
|
|
6343
6864
|
return [...unique.values()].sort((left, right) => (left.path ?? "").localeCompare(right.path ?? "") || (left.line ?? 0) - (right.line ?? 0) || left.code.localeCompare(right.code));
|
|
6344
6865
|
}
|
|
@@ -6354,15 +6875,15 @@ function mergeFindings(target, additions) {
|
|
|
6354
6875
|
async function scanConsumerCandidates(root, references, excludedPaths = /* @__PURE__ */ new Set()) {
|
|
6355
6876
|
const results = [];
|
|
6356
6877
|
async function visit(directory) {
|
|
6357
|
-
for (const entry of await (0,
|
|
6878
|
+
for (const entry of await (0, import_promises10.readdir)(directory, { withFileTypes: true })) {
|
|
6358
6879
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6359
|
-
const absolute = (0,
|
|
6880
|
+
const absolute = (0, import_node_path14.join)(directory, entry.name);
|
|
6360
6881
|
if (entry.isDirectory()) {
|
|
6361
6882
|
await visit(absolute);
|
|
6362
6883
|
} else if (entry.isFile() && TEXT_EXTENSIONS.test(entry.name)) {
|
|
6363
|
-
const path = (0,
|
|
6884
|
+
const path = (0, import_node_path14.relative)(root, absolute).replace(/\\/g, "/");
|
|
6364
6885
|
if (excludedPaths.has(path)) continue;
|
|
6365
|
-
const raw = await (0,
|
|
6886
|
+
const raw = await (0, import_promises10.readFile)(absolute, "utf8");
|
|
6366
6887
|
raw.split(/\r?\n/).forEach((line, index) => {
|
|
6367
6888
|
for (const reference of references) {
|
|
6368
6889
|
if (path !== reference && line.includes(reference)) results.push({ path, line: index + 1, reference });
|
|
@@ -6371,7 +6892,7 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
|
|
|
6371
6892
|
}
|
|
6372
6893
|
}
|
|
6373
6894
|
}
|
|
6374
|
-
await visit((0,
|
|
6895
|
+
await visit((0, import_node_path14.resolve)(root));
|
|
6375
6896
|
return results.sort((left, right) => left.path.localeCompare(right.path) || left.line - right.line || left.reference.localeCompare(right.reference));
|
|
6376
6897
|
}
|
|
6377
6898
|
function expectedRelationTargets(mapping) {
|
|
@@ -6411,7 +6932,7 @@ function restructureBoundaryFindings(operations, limits) {
|
|
|
6411
6932
|
const expectedCreateMode = createModeForUmask(limits.umask);
|
|
6412
6933
|
const applyModeContract = limits.mode_contract === "apply";
|
|
6413
6934
|
for (const operation of operations) {
|
|
6414
|
-
const parent = (0,
|
|
6935
|
+
const parent = (0, import_node_path14.dirname)(operation.path) || ".";
|
|
6415
6936
|
if (!operation.parent_exists) {
|
|
6416
6937
|
findings.push(finding("PARENT_DIRECTORY_MISSING", `Parent directory does not exist or is not a directory: ${parent}`, operation.path));
|
|
6417
6938
|
} else if (operation.parent_device !== null && operation.parent_device !== operation.root_device) {
|
|
@@ -6460,7 +6981,7 @@ function restructureBoundaryFindings(operations, limits) {
|
|
|
6460
6981
|
}
|
|
6461
6982
|
async function probeDirectory(absolutePath) {
|
|
6462
6983
|
try {
|
|
6463
|
-
const info = await (0,
|
|
6984
|
+
const info = await (0, import_promises10.stat)(absolutePath);
|
|
6464
6985
|
return { exists: info.isDirectory(), device: info.dev };
|
|
6465
6986
|
} catch (error) {
|
|
6466
6987
|
const code = error.code;
|
|
@@ -6602,7 +7123,7 @@ async function planRestructure(root, input) {
|
|
|
6602
7123
|
}
|
|
6603
7124
|
pathMoves.push(move);
|
|
6604
7125
|
rangesByPath.set(sourcePath, pathMoves);
|
|
6605
|
-
if ((0,
|
|
7126
|
+
if ((0, import_node_path14.dirname)(sourcePath) !== (0, import_node_path14.dirname)(targetPath)) {
|
|
6606
7127
|
for (const link of findRelativeLinks(fragment.toString("utf8"))) {
|
|
6607
7128
|
const explicitlyEdited = mapping.prose_edits.some((edit) => edit.target_path === targetPath && edit.old_text.includes(link));
|
|
6608
7129
|
if (!explicitlyEdited) blockers.push(finding("RELATIVE_LINK_REQUIRES_MAPPING", `Relative reference "${link}" changes base directory when moved to ${targetPath}`, sourcePath));
|
|
@@ -6719,15 +7240,15 @@ async function planRestructure(root, input) {
|
|
|
6719
7240
|
diff: readableDiff(path, original?.toString("utf8"), deleteFile ? void 0 : candidate.toString("utf8"))
|
|
6720
7241
|
});
|
|
6721
7242
|
}
|
|
6722
|
-
const rootDirectory = await probeDirectory((0,
|
|
7243
|
+
const rootDirectory = await probeDirectory((0, import_node_path14.resolve)(root));
|
|
6723
7244
|
const parentProbes = /* @__PURE__ */ new Map();
|
|
6724
7245
|
for (const candidate of candidates) {
|
|
6725
|
-
const parent = (0,
|
|
6726
|
-
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)));
|
|
6727
7248
|
}
|
|
6728
7249
|
blockers.push(...restructureBoundaryFindings(
|
|
6729
7250
|
candidates.map((candidate) => {
|
|
6730
|
-
const parent = parentProbes.get((0,
|
|
7251
|
+
const parent = parentProbes.get((0, import_node_path14.dirname)(candidate.path));
|
|
6731
7252
|
return {
|
|
6732
7253
|
path: candidate.path,
|
|
6733
7254
|
action: candidate.action,
|
|
@@ -6853,10 +7374,10 @@ function refusal(code, message, findings = []) {
|
|
|
6853
7374
|
return { ok: false, error: { code, message, ...findings.length === 0 ? {} : { details: findings } } };
|
|
6854
7375
|
}
|
|
6855
7376
|
async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
6856
|
-
const absolute = (0,
|
|
7377
|
+
const absolute = (0, import_node_path14.resolve)(planPath);
|
|
6857
7378
|
let info;
|
|
6858
7379
|
try {
|
|
6859
|
-
info = await (0,
|
|
7380
|
+
info = await (0, import_promises10.lstat)(absolute);
|
|
6860
7381
|
} catch (cause) {
|
|
6861
7382
|
return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
|
|
6862
7383
|
}
|
|
@@ -6865,7 +7386,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
|
6865
7386
|
}
|
|
6866
7387
|
let bytes;
|
|
6867
7388
|
try {
|
|
6868
|
-
bytes = await (0,
|
|
7389
|
+
bytes = await (0, import_promises10.readFile)(absolute);
|
|
6869
7390
|
} catch (cause) {
|
|
6870
7391
|
return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
|
|
6871
7392
|
}
|
|
@@ -6877,7 +7398,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
|
6877
7398
|
}
|
|
6878
7399
|
const gate = await gateRestructureOperationPlan(operation, parsed);
|
|
6879
7400
|
if (!gate.ok) return gate;
|
|
6880
|
-
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 } };
|
|
6881
7402
|
}
|
|
6882
7403
|
function planRootIdentityFindings(document) {
|
|
6883
7404
|
const findings = [];
|
|
@@ -6896,19 +7417,19 @@ function planRootIdentityFindings(document) {
|
|
|
6896
7417
|
if (document.plan.config_snapshot.path !== "artifact-graph.config.yaml") {
|
|
6897
7418
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan does not record this project's configuration file: ${document.plan.config_snapshot.path}`));
|
|
6898
7419
|
}
|
|
6899
|
-
const relativePlan = (0,
|
|
6900
|
-
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)) {
|
|
6901
7422
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan document is outside the project root: ${document.realPath}`, document.realPath));
|
|
6902
7423
|
}
|
|
6903
7424
|
return findings;
|
|
6904
7425
|
}
|
|
6905
7426
|
async function operationBoundaries(root, plan) {
|
|
6906
|
-
const rootDirectory = await probeDirectory((0,
|
|
7427
|
+
const rootDirectory = await probeDirectory((0, import_node_path14.resolve)(root));
|
|
6907
7428
|
const parents = /* @__PURE__ */ new Map();
|
|
6908
7429
|
const boundaries = [];
|
|
6909
7430
|
for (const candidate of plan.candidates) {
|
|
6910
|
-
const parent = (0,
|
|
6911
|
-
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)));
|
|
6912
7433
|
const probe = parents.get(parent);
|
|
6913
7434
|
boundaries.push({
|
|
6914
7435
|
path: candidate.path,
|
|
@@ -6933,7 +7454,7 @@ async function applyPreconditionFindings(root, document) {
|
|
|
6933
7454
|
findings.push(finding("CONFIG_CHANGED", "artifact-graph configuration changed after planning", currentConfig.path));
|
|
6934
7455
|
}
|
|
6935
7456
|
for (const snapshot of plan.input_snapshots) await verifySnapshot(root, snapshot, findings);
|
|
6936
|
-
const relativePlan = (0,
|
|
7457
|
+
const relativePlan = (0, import_node_path14.relative)(root, document.realPath).replace(/\\/g, "/");
|
|
6937
7458
|
for (const candidate of plan.candidates) {
|
|
6938
7459
|
if (candidate.path === relativePlan) {
|
|
6939
7460
|
findings.push(finding("PLAN_IN_WRITE_SET", `The plan document is inside its own candidate write set: ${candidate.path}`, candidate.path));
|
|
@@ -7016,7 +7537,7 @@ async function applyRestructure(input) {
|
|
|
7016
7537
|
if (drift.length > 0) return refusal("APPLY_PRECONDITION_FAILED", "The project drifted after planning; nothing was written", drift);
|
|
7017
7538
|
const mechanismRoot = await ensureRestructureMechanismRoot(qualification.data.root, { create: true });
|
|
7018
7539
|
if (!mechanismRoot.ok) return mechanismRoot;
|
|
7019
|
-
const planRelPath = (0,
|
|
7540
|
+
const planRelPath = (0, import_node_path14.relative)(qualification.data.root, document.data.realPath).replace(/\\/g, "/");
|
|
7020
7541
|
const applied = await applyRestructureFileSet(qualification.data.root, plan, {
|
|
7021
7542
|
validate: createRestructureValidationCallback(plan, [planRelPath])
|
|
7022
7543
|
});
|
|
@@ -7073,13 +7594,13 @@ async function pruneRestructureRecovery(input) {
|
|
|
7073
7594
|
const projection = projectRestructureFileSetResult(pruned.data, document.data.realPath, document.data.digest);
|
|
7074
7595
|
return projection.ok ? { ok: true, data: projection } : { ok: false, error: { code: projection.code, message: projection.message, details: projection } };
|
|
7075
7596
|
}
|
|
7076
|
-
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;
|
|
7077
7598
|
var init_restructure = __esm({
|
|
7078
7599
|
"src/restructure.ts"() {
|
|
7079
7600
|
"use strict";
|
|
7080
7601
|
import_node_crypto5 = require("crypto");
|
|
7081
|
-
|
|
7082
|
-
|
|
7602
|
+
import_promises10 = require("fs/promises");
|
|
7603
|
+
import_node_path14 = require("path");
|
|
7083
7604
|
import_node_url3 = require("url");
|
|
7084
7605
|
init_index();
|
|
7085
7606
|
init_contract_kernel();
|
|
@@ -7092,8 +7613,8 @@ var init_restructure = __esm({
|
|
|
7092
7613
|
RESTRUCTURE_MAX_TOTAL_BYTES = 256 * 1024 * 1024;
|
|
7093
7614
|
MAX_POSIX_MODE = 511;
|
|
7094
7615
|
CREATE_MODE_BASE = 438;
|
|
7095
|
-
MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : (0,
|
|
7096
|
-
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");
|
|
7097
7618
|
SKIPPED_SCAN_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "dist", "coverage", ".tmp", ".codex", ".worktrees", ".foundation-file-apply", ".artifact-graph"]);
|
|
7098
7619
|
TEXT_EXTENSIONS = /\.(?:md|markdown|json|ya?ml|[cm]?[jt]sx?)$/i;
|
|
7099
7620
|
MARKDOWN_LINK_PATTERN = /!?\[([^\]\n]*)\]\(([^)\n]+)\)/g;
|
|
@@ -7159,18 +7680,21 @@ __export(index_exports, {
|
|
|
7159
7680
|
createModeForUmask: () => createModeForUmask,
|
|
7160
7681
|
createRestructureRootBinding: () => createRestructureRootBinding,
|
|
7161
7682
|
createRestructureValidationCallback: () => createRestructureValidationCallback,
|
|
7683
|
+
diagnoseConfigDocument: () => diagnoseConfigDocument,
|
|
7684
|
+
diagnoseProjectConfig: () => diagnoseProjectConfig,
|
|
7162
7685
|
digestRestructureValue: () => digestRestructureValue,
|
|
7163
|
-
dirname: () =>
|
|
7686
|
+
dirname: () => import_node_path15.dirname,
|
|
7164
7687
|
discoverAndAuditPackets: () => discoverAndAuditPackets,
|
|
7165
7688
|
discoverTargets: () => discoverTargets,
|
|
7166
7689
|
doctorArtifactChain: () => doctorArtifactChain,
|
|
7167
7690
|
ensureRestructureMechanismRoot: () => ensureRestructureMechanismRoot,
|
|
7168
|
-
extname: () =>
|
|
7691
|
+
extname: () => import_node_path15.extname,
|
|
7169
7692
|
filterGraphByView: () => filterGraphByView,
|
|
7170
7693
|
formatContextMarkdown: () => formatContextMarkdown,
|
|
7171
7694
|
gateRestructureOperationPlan: () => gateRestructureOperationPlan,
|
|
7172
7695
|
generateE2eRegistry: () => generateE2eRegistry,
|
|
7173
7696
|
getArtifactTypeMetadata: () => getArtifactTypeMetadata,
|
|
7697
|
+
getConfigDiagnostics: () => getConfigDiagnostics,
|
|
7174
7698
|
getExternalEntryInfo: () => getExternalEntryInfo,
|
|
7175
7699
|
getTargetArtifactTypes: () => getTargetArtifactTypes,
|
|
7176
7700
|
inspectRestructure: () => inspectRestructure,
|
|
@@ -7246,6 +7770,27 @@ __export(index_exports, {
|
|
|
7246
7770
|
writeGraphCache: () => writeGraphCache
|
|
7247
7771
|
});
|
|
7248
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
|
+
}
|
|
7249
7794
|
function isTargetArtifactType(type) {
|
|
7250
7795
|
return isPacketTargetType(type);
|
|
7251
7796
|
}
|
|
@@ -7287,30 +7832,22 @@ function resolveArtifactTypeName(schema, token) {
|
|
|
7287
7832
|
return void 0;
|
|
7288
7833
|
}
|
|
7289
7834
|
async function loadConfig(root) {
|
|
7290
|
-
const configPath = (0,
|
|
7291
|
-
let
|
|
7835
|
+
const configPath = (0, import_node_path15.join)(root, "artifact-graph.config.yaml");
|
|
7836
|
+
let raw;
|
|
7292
7837
|
try {
|
|
7293
|
-
|
|
7294
|
-
parsed = import_js_yaml.default.load(raw) ?? {};
|
|
7838
|
+
raw = await (0, import_promises11.readFile)(configPath, "utf-8");
|
|
7295
7839
|
} catch (error) {
|
|
7296
|
-
if (error.code
|
|
7297
|
-
throw
|
|
7840
|
+
if (error.code === "ENOENT") {
|
|
7841
|
+
throw new Error(`required configuration is missing: ${configPath}`);
|
|
7298
7842
|
}
|
|
7843
|
+
throw error;
|
|
7299
7844
|
}
|
|
7300
|
-
const
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
);
|
|
7305
|
-
}
|
|
7306
|
-
if (parsed.e2e !== void 0) {
|
|
7307
|
-
if (typeof parsed.e2e !== "object" || parsed.e2e === null || Array.isArray(parsed.e2e)) {
|
|
7308
|
-
throw new Error("Invalid e2e: must be an object.");
|
|
7309
|
-
}
|
|
7310
|
-
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);
|
|
7311
7849
|
}
|
|
7312
|
-
|
|
7313
|
-
validateStatusViewsConfig(parsed.statusViews);
|
|
7850
|
+
const parsed = document;
|
|
7314
7851
|
const mergedE2e = parsed.e2e === void 0 ? DEFAULT_SCHEMA.e2e : {
|
|
7315
7852
|
...DEFAULT_SCHEMA.e2e,
|
|
7316
7853
|
...parsed.e2e,
|
|
@@ -7325,13 +7862,14 @@ async function loadConfig(root) {
|
|
|
7325
7862
|
types: mergeArtifactTypes(DEFAULT_SCHEMA.types, parsed.types),
|
|
7326
7863
|
idPatterns: mergeRecord(DEFAULT_SCHEMA.idPatterns, parsed.idPatterns),
|
|
7327
7864
|
relationFields: mergeRecord(DEFAULT_SCHEMA.relationFields, parsed.relationFields),
|
|
7328
|
-
allowedEdges: parsed.allowedEdges
|
|
7865
|
+
allowedEdges: resolveAllowedEdges(parsed.allowedEdges),
|
|
7329
7866
|
forbiddenEdges: parsed.forbiddenEdges ?? DEFAULT_SCHEMA.forbiddenEdges,
|
|
7330
7867
|
statuses: parsed.statuses ?? DEFAULT_SCHEMA.statuses,
|
|
7331
7868
|
idRanges: mergeRecord(DEFAULT_SCHEMA.idRanges, parsed.idRanges),
|
|
7332
7869
|
e2e: mergedE2e
|
|
7333
7870
|
};
|
|
7334
7871
|
validateJsonArtifactTypes(merged.types);
|
|
7872
|
+
configDiagnosticsBySchema.set(merged, shapeDiagnosis);
|
|
7335
7873
|
return merged;
|
|
7336
7874
|
}
|
|
7337
7875
|
function validateJsonArtifactTypes(types) {
|
|
@@ -7356,131 +7894,6 @@ function validateJsonArtifactTypes(types) {
|
|
|
7356
7894
|
}
|
|
7357
7895
|
}
|
|
7358
7896
|
}
|
|
7359
|
-
function validateRelationSemanticsConfig(value) {
|
|
7360
|
-
if (value === void 0) return;
|
|
7361
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7362
|
-
throw new Error("Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
7363
|
-
}
|
|
7364
|
-
for (const [kind, spec] of Object.entries(value)) {
|
|
7365
|
-
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
7366
|
-
throw new Error(`Invalid relationSemantics.${kind}: must be an object.`);
|
|
7367
|
-
}
|
|
7368
|
-
if (typeof spec.label !== "string" || !spec.label.trim()) {
|
|
7369
|
-
throw new Error(`Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
7370
|
-
}
|
|
7371
|
-
if (!Array.isArray(spec.targetTypes) || spec.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7372
|
-
throw new Error(`Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
7373
|
-
}
|
|
7374
|
-
if (!Array.isArray(spec.fields) || spec.fields.length === 0 || spec.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7375
|
-
throw new Error(`Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
7376
|
-
}
|
|
7377
|
-
if (spec.partial !== void 0 && (typeof spec.partial !== "object" || spec.partial === null || typeof spec.partial.sectionField !== "string" || !spec.partial.sectionField.trim())) {
|
|
7378
|
-
throw new Error(`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`);
|
|
7379
|
-
}
|
|
7380
|
-
}
|
|
7381
|
-
}
|
|
7382
|
-
function validateStatusViewsConfig(value) {
|
|
7383
|
-
if (value === void 0) return;
|
|
7384
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7385
|
-
throw new Error("Invalid statusViews: must be an object keyed by status.");
|
|
7386
|
-
}
|
|
7387
|
-
for (const [status, bucket] of Object.entries(value)) {
|
|
7388
|
-
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
7389
|
-
throw new Error(`Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
7390
|
-
}
|
|
7391
|
-
}
|
|
7392
|
-
}
|
|
7393
|
-
function validateE2eConfig(e2e) {
|
|
7394
|
-
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
7395
|
-
if (e2e[field] !== void 0 && typeof e2e[field] !== "boolean") {
|
|
7396
|
-
throw new Error(`Invalid e2e.${field}: must be boolean.`);
|
|
7397
|
-
}
|
|
7398
|
-
}
|
|
7399
|
-
if (e2e.executable_ref_warning !== void 0) {
|
|
7400
|
-
if (typeof e2e.executable_ref_warning !== "number" || e2e.executable_ref_warning < 0 || e2e.executable_ref_warning > 1) {
|
|
7401
|
-
throw new Error(`Invalid e2e.executable_ref_warning: ${JSON.stringify(e2e.executable_ref_warning)}. Must be a number between 0 and 1.`);
|
|
7402
|
-
}
|
|
7403
|
-
}
|
|
7404
|
-
if (e2e.executable_ref_error !== void 0) {
|
|
7405
|
-
if (typeof e2e.executable_ref_error !== "number" || e2e.executable_ref_error < 0 || e2e.executable_ref_error > 1) {
|
|
7406
|
-
throw new Error(`Invalid e2e.executable_ref_error: ${JSON.stringify(e2e.executable_ref_error)}. Must be a number between 0 and 1.`);
|
|
7407
|
-
}
|
|
7408
|
-
}
|
|
7409
|
-
const validateWaivers = (waivers, field) => {
|
|
7410
|
-
if (waivers === void 0) return;
|
|
7411
|
-
if (!Array.isArray(waivers)) {
|
|
7412
|
-
throw new Error(`Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
7413
|
-
}
|
|
7414
|
-
for (const w of waivers) {
|
|
7415
|
-
if (typeof w !== "object" || w === null || !("id" in w) || !("reason" in w)) {
|
|
7416
|
-
throw new Error(`Invalid ${field} entry: ${JSON.stringify(w)}. Must be {id, reason} object.`);
|
|
7417
|
-
}
|
|
7418
|
-
if (typeof w.id !== "string" || !w.id.trim()) {
|
|
7419
|
-
throw new Error(`Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(w.id)}`);
|
|
7420
|
-
}
|
|
7421
|
-
if (typeof w.reason !== "string" || !w.reason.trim()) {
|
|
7422
|
-
throw new Error(`Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(w.reason)}`);
|
|
7423
|
-
}
|
|
7424
|
-
}
|
|
7425
|
-
};
|
|
7426
|
-
validateWaivers(e2e.scenario_waivers, "e2e.scenario_waivers");
|
|
7427
|
-
validateWaivers(e2e.feature_waivers, "e2e.feature_waivers");
|
|
7428
|
-
if (e2e.runners !== void 0) {
|
|
7429
|
-
if (!Array.isArray(e2e.runners)) {
|
|
7430
|
-
throw new Error(`Invalid e2e.runners: must be an array.`);
|
|
7431
|
-
}
|
|
7432
|
-
for (const runner of e2e.runners) {
|
|
7433
|
-
if (typeof runner !== "object" || runner === null) {
|
|
7434
|
-
throw new Error(`Invalid e2e.runners entry: must be an object.`);
|
|
7435
|
-
}
|
|
7436
|
-
if (typeof runner.name !== "string" || !runner.name.trim()) {
|
|
7437
|
-
throw new Error(`Invalid e2e.runners entry: name must be a non-empty string.`);
|
|
7438
|
-
}
|
|
7439
|
-
if (typeof runner.root !== "string" || !runner.root.trim()) {
|
|
7440
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: must be a non-empty string.`);
|
|
7441
|
-
}
|
|
7442
|
-
if ((0, import_node_path14.isAbsolute)(runner.root)) {
|
|
7443
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not be an absolute path.`);
|
|
7444
|
-
}
|
|
7445
|
-
if (runner.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
7446
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not contain ".." segments.`);
|
|
7447
|
-
}
|
|
7448
|
-
if (!Array.isArray(runner.include) || runner.include.length === 0) {
|
|
7449
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: must be a non-empty array of glob patterns.`);
|
|
7450
|
-
}
|
|
7451
|
-
for (const pattern of runner.include) {
|
|
7452
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7453
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: pattern must be a non-empty string.`);
|
|
7454
|
-
}
|
|
7455
|
-
}
|
|
7456
|
-
if (runner.exclude !== void 0) {
|
|
7457
|
-
if (!Array.isArray(runner.exclude)) {
|
|
7458
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: must be an array.`);
|
|
7459
|
-
}
|
|
7460
|
-
for (const pattern of runner.exclude) {
|
|
7461
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7462
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: pattern must be a non-empty string.`);
|
|
7463
|
-
}
|
|
7464
|
-
}
|
|
7465
|
-
}
|
|
7466
|
-
if (runner.testIgnore !== void 0) {
|
|
7467
|
-
if (!Array.isArray(runner.testIgnore)) {
|
|
7468
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: must be an array.`);
|
|
7469
|
-
}
|
|
7470
|
-
for (const pattern of runner.testIgnore) {
|
|
7471
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7472
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: pattern must be a non-empty string.`);
|
|
7473
|
-
}
|
|
7474
|
-
}
|
|
7475
|
-
}
|
|
7476
|
-
if (runner.kind !== void 0) {
|
|
7477
|
-
if (!["unit", "integration", "e2e"].includes(runner.kind)) {
|
|
7478
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].kind: "${runner.kind}". Must be unit, integration, or e2e.`);
|
|
7479
|
-
}
|
|
7480
|
-
}
|
|
7481
|
-
}
|
|
7482
|
-
}
|
|
7483
|
-
}
|
|
7484
7897
|
function buildGraph(nodes, edges, diagnostics = [], root) {
|
|
7485
7898
|
const graphNodes = nodes.map((node) => ({ ...node, uid: toUid(node.type, node.code) }));
|
|
7486
7899
|
graphNodes.sort(compareNode);
|
|
@@ -7528,7 +7941,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7528
7941
|
continue;
|
|
7529
7942
|
}
|
|
7530
7943
|
scannedFiles.set(file, type);
|
|
7531
|
-
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");
|
|
7532
7945
|
const parsed = parseFile(type, file, raw, config);
|
|
7533
7946
|
const semantic = isJsonOriginalType(type, config) ? { edges: [], diagnostics: [] } : parseConfiguredRelations(type, file, raw, parsed.nodes, config);
|
|
7534
7947
|
nodes.push(...parsed.nodes);
|
|
@@ -7536,7 +7949,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7536
7949
|
scanDiagnostics.push(...parsed.diagnostics, ...semantic.diagnostics);
|
|
7537
7950
|
}
|
|
7538
7951
|
}
|
|
7539
|
-
const absoluteRoot = (0,
|
|
7952
|
+
const absoluteRoot = (0, import_node_path15.isAbsolute)(root) ? root : (0, import_node_path15.resolve)(root);
|
|
7540
7953
|
const graph = buildGraph(nodes, edges, scanDiagnostics, absoluteRoot);
|
|
7541
7954
|
return resolveMatrixEdges(graph);
|
|
7542
7955
|
}
|
|
@@ -7683,8 +8096,16 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
|
|
|
7683
8096
|
{ edge: edge2 }
|
|
7684
8097
|
));
|
|
7685
8098
|
}
|
|
7686
|
-
if (schema.forbiddenEdges.some((rule) => rule
|
|
8099
|
+
if (schema.forbiddenEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
7687
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
|
+
));
|
|
7688
8109
|
}
|
|
7689
8110
|
}
|
|
7690
8111
|
issues.push(...validateE2eTests(graph));
|
|
@@ -7875,7 +8296,7 @@ async function validateScenarioPrdLinkIndex(root, graph) {
|
|
|
7875
8296
|
const indexPath = "artifacts/prd/feature-index.md";
|
|
7876
8297
|
let raw = "";
|
|
7877
8298
|
try {
|
|
7878
|
-
raw = await (0,
|
|
8299
|
+
raw = await (0, import_promises11.readFile)((0, import_node_path15.join)(root, indexPath), "utf-8");
|
|
7879
8300
|
} catch (error) {
|
|
7880
8301
|
if (error.code === "ENOENT") {
|
|
7881
8302
|
return [];
|
|
@@ -8123,12 +8544,12 @@ function nextId(graph, schema, type, rangeName) {
|
|
|
8123
8544
|
throw new Error(`ID range ${type}.${rangeName} is exhausted`);
|
|
8124
8545
|
}
|
|
8125
8546
|
async function writeGraphCache(root, graph) {
|
|
8126
|
-
const cacheDir = (0,
|
|
8127
|
-
await (0,
|
|
8128
|
-
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)}
|
|
8129
8550
|
`);
|
|
8130
8551
|
const { default: Database } = await import("better-sqlite3");
|
|
8131
|
-
const db = new Database((0,
|
|
8552
|
+
const db = new Database((0, import_node_path15.join)(cacheDir, "graph.sqlite"));
|
|
8132
8553
|
try {
|
|
8133
8554
|
db.exec(`
|
|
8134
8555
|
DROP TABLE IF EXISTS nodes;
|
|
@@ -8424,7 +8845,7 @@ function jsonConfiguredRelations(type, path, record, schema, sourceUid) {
|
|
|
8424
8845
|
}
|
|
8425
8846
|
function parseGenericMarkdown(type, path, raw, schema) {
|
|
8426
8847
|
const diagnostics = [];
|
|
8427
|
-
const ext = (0,
|
|
8848
|
+
const ext = (0, import_node_path15.extname)(path).toLowerCase();
|
|
8428
8849
|
if (ext !== ".md" && ext !== ".markdown") {
|
|
8429
8850
|
diagnostics.push(issue(
|
|
8430
8851
|
"UNSUPPORTED_FORMAT",
|
|
@@ -8794,7 +9215,7 @@ function parseDecisions(path, raw) {
|
|
|
8794
9215
|
}
|
|
8795
9216
|
function isTestFile(filePath) {
|
|
8796
9217
|
const normalized = filePath.replace(/\\/g, "/");
|
|
8797
|
-
const name = (0,
|
|
9218
|
+
const name = (0, import_node_path15.basename)(normalized);
|
|
8798
9219
|
if (/\.(test|spec)\.[^.]+$/.test(name)) return true;
|
|
8799
9220
|
if (/(^|\/)(tests|test|__tests__)\//.test(normalized)) return true;
|
|
8800
9221
|
if (/\w+Tests?\.java$/.test(name)) return true;
|
|
@@ -9109,7 +9530,7 @@ function parseE2eTest(path, raw) {
|
|
|
9109
9530
|
const starts = extractE2eTestCaseStarts(lines);
|
|
9110
9531
|
const nodes = [];
|
|
9111
9532
|
const edges = [];
|
|
9112
|
-
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();
|
|
9113
9534
|
const frontmatterScenarios = toArray(data.related_scenarios).map((value) => String(value).trim()).filter(Boolean);
|
|
9114
9535
|
const scopeFeatures = extractCodes(String(data.scope ?? ""), "feature");
|
|
9115
9536
|
const frontmatterFeatures = [.../* @__PURE__ */ new Set([...Object.keys(asRecord2(data.ac_coverage)), ...scopeFeatures])];
|
|
@@ -9172,7 +9593,7 @@ function parseE2eRegistry(path, raw) {
|
|
|
9172
9593
|
data = { parseError: error.message };
|
|
9173
9594
|
}
|
|
9174
9595
|
return {
|
|
9175
|
-
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 }],
|
|
9176
9597
|
edges: []
|
|
9177
9598
|
};
|
|
9178
9599
|
}
|
|
@@ -10210,10 +10631,10 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10210
10631
|
const tcKeyToFields = /* @__PURE__ */ new Map();
|
|
10211
10632
|
const mdBatches = /* @__PURE__ */ new Set();
|
|
10212
10633
|
for (const relPath of e2eFiles) {
|
|
10213
|
-
const raw = await (0,
|
|
10634
|
+
const raw = await (0, import_promises11.readFile)((0, import_node_path15.join)(root, relPath), "utf-8");
|
|
10214
10635
|
const parsed = (0, import_gray_matter.default)(raw);
|
|
10215
10636
|
const data = parsed.data;
|
|
10216
|
-
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();
|
|
10217
10638
|
const lines = raw.split(/\r?\n/);
|
|
10218
10639
|
const tcStarts = extractE2eTestCaseStarts(lines);
|
|
10219
10640
|
for (let i = 0; i < tcStarts.length; i += 1) {
|
|
@@ -10252,10 +10673,10 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10252
10673
|
const tcAnnotationRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+?)\s+\[(\w+)\]/;
|
|
10253
10674
|
const tcAnnotationNoLevelRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+)/;
|
|
10254
10675
|
for (const specFile of specFiles) {
|
|
10255
|
-
const fullSpecPath = (0,
|
|
10676
|
+
const fullSpecPath = (0, import_node_path15.join)(root, specFile);
|
|
10256
10677
|
let content;
|
|
10257
10678
|
try {
|
|
10258
|
-
content = await (0,
|
|
10679
|
+
content = await (0, import_promises11.readFile)(fullSpecPath, "utf-8");
|
|
10259
10680
|
} catch {
|
|
10260
10681
|
continue;
|
|
10261
10682
|
}
|
|
@@ -10334,7 +10755,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10334
10755
|
if (entry.testId) {
|
|
10335
10756
|
let content;
|
|
10336
10757
|
try {
|
|
10337
|
-
content = await (0,
|
|
10758
|
+
content = await (0, import_promises11.readFile)((0, import_node_path15.join)(root, normalizedRefFile), "utf-8");
|
|
10338
10759
|
} catch {
|
|
10339
10760
|
continue;
|
|
10340
10761
|
}
|
|
@@ -10569,7 +10990,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10569
10990
|
let hasActiveE2eRef = false;
|
|
10570
10991
|
for (const entry of parseExecutableRefLines(execRef)) {
|
|
10571
10992
|
const normalized = resolveExecutableRefFile(entry.file, allProjectFiles);
|
|
10572
|
-
if (!normalized || !(0, import_node_fs5.existsSync)((0,
|
|
10993
|
+
if (!normalized || !(0, import_node_fs5.existsSync)((0, import_node_path15.join)(root, normalized))) continue;
|
|
10573
10994
|
const accepting = await getAcceptingRunners(root, normalized, runners);
|
|
10574
10995
|
if (accepting.some((runner) => runner.kind === "e2e")) {
|
|
10575
10996
|
hasActiveE2eRef = true;
|
|
@@ -10628,7 +11049,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10628
11049
|
const acCoverageRateByFeature = {};
|
|
10629
11050
|
const featureAcMap = /* @__PURE__ */ new Map();
|
|
10630
11051
|
for (const node of featureNodes) {
|
|
10631
|
-
const acs = parseAcceptanceCriteria(await (0,
|
|
11052
|
+
const acs = parseAcceptanceCriteria(await (0, import_promises11.readFile)((0, import_node_path15.join)(root, node.path), "utf-8"));
|
|
10632
11053
|
featureAcMap.set(node.code, new Set(acs));
|
|
10633
11054
|
}
|
|
10634
11055
|
const coveredAcByFeature = /* @__PURE__ */ new Map();
|
|
@@ -10676,11 +11097,11 @@ async function generateE2eRegistry(root, opts) {
|
|
|
10676
11097
|
const batchIds = /* @__PURE__ */ new Set();
|
|
10677
11098
|
let totalTestCases = 0;
|
|
10678
11099
|
for (const file of files) {
|
|
10679
|
-
const filePath = (0,
|
|
10680
|
-
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");
|
|
10681
11102
|
const parsed = (0, import_gray_matter.default)(raw);
|
|
10682
11103
|
const data = parsed.data;
|
|
10683
|
-
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();
|
|
10684
11105
|
const relPath = file;
|
|
10685
11106
|
const scope = String(data.scope ?? "").trim();
|
|
10686
11107
|
const acCoverage = normalizeAcCoverageForRegistry(data.ac_coverage);
|
|
@@ -10802,10 +11223,10 @@ async function validatePartialRustEvidence(tcFields, tcKey, root, allFiles) {
|
|
|
10802
11223
|
if (!normalizedPath) {
|
|
10803
11224
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10804
11225
|
}
|
|
10805
|
-
const fullPath = (0,
|
|
11226
|
+
const fullPath = (0, import_node_path15.join)(root, normalizedPath);
|
|
10806
11227
|
let content;
|
|
10807
11228
|
try {
|
|
10808
|
-
content = await (0,
|
|
11229
|
+
content = await (0, import_promises11.readFile)(fullPath, "utf-8");
|
|
10809
11230
|
} catch {
|
|
10810
11231
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10811
11232
|
}
|
|
@@ -10839,7 +11260,7 @@ function detectTestLevel(specFile, content) {
|
|
|
10839
11260
|
}
|
|
10840
11261
|
function resolveExecutableRefFile(refFile, allFiles) {
|
|
10841
11262
|
const normalized = refFile.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
10842
|
-
if (!normalized || (0,
|
|
11263
|
+
if (!normalized || (0, import_node_path15.isAbsolute)(refFile) || normalized.split("/").includes("..")) {
|
|
10843
11264
|
return void 0;
|
|
10844
11265
|
}
|
|
10845
11266
|
if (allFiles.includes(normalized)) {
|
|
@@ -11145,7 +11566,7 @@ function normalizeDesignCode(value) {
|
|
|
11145
11566
|
if (!raw) {
|
|
11146
11567
|
return "";
|
|
11147
11568
|
}
|
|
11148
|
-
return (0,
|
|
11569
|
+
return (0, import_node_path15.basename)(raw, (0, import_node_path15.extname)(raw));
|
|
11149
11570
|
}
|
|
11150
11571
|
function toUid(type, code) {
|
|
11151
11572
|
return `${type}:${code}`;
|
|
@@ -11421,7 +11842,7 @@ function resolveArtifactContext(graph, opts) {
|
|
|
11421
11842
|
}
|
|
11422
11843
|
if (root) {
|
|
11423
11844
|
for (const ap of ALWAYS_PRESENT_ITEMS) {
|
|
11424
|
-
const fullPath = (0,
|
|
11845
|
+
const fullPath = (0, import_node_path15.join)(root, ap.path);
|
|
11425
11846
|
let stat2;
|
|
11426
11847
|
try {
|
|
11427
11848
|
stat2 = (0, import_node_fs5.statSync)(fullPath);
|
|
@@ -11663,18 +12084,20 @@ function formatContextMarkdown(manifest) {
|
|
|
11663
12084
|
}
|
|
11664
12085
|
return lines.join("\n");
|
|
11665
12086
|
}
|
|
11666
|
-
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;
|
|
11667
12088
|
var init_index = __esm({
|
|
11668
12089
|
"src/index.ts"() {
|
|
11669
12090
|
import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
11670
|
-
|
|
12091
|
+
import_js_yaml2 = __toESM(require("js-yaml"), 1);
|
|
11671
12092
|
import_node_fs5 = require("fs");
|
|
11672
|
-
|
|
11673
|
-
|
|
12093
|
+
import_promises11 = require("fs/promises");
|
|
12094
|
+
import_node_path15 = require("path");
|
|
11674
12095
|
init_packet_constants();
|
|
11675
12096
|
init_packet_validator();
|
|
11676
12097
|
init_glob_matcher();
|
|
11677
12098
|
init_file_walker();
|
|
12099
|
+
init_doctor();
|
|
12100
|
+
init_doctor();
|
|
11678
12101
|
init_packet_constants();
|
|
11679
12102
|
init_target_selector();
|
|
11680
12103
|
init_impact();
|
|
@@ -11695,6 +12118,44 @@ var init_index = __esm({
|
|
|
11695
12118
|
init_restructure();
|
|
11696
12119
|
init_restructure_file_set();
|
|
11697
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
|
+
];
|
|
11698
12159
|
TARGET_ARTIFACT_TYPES = VALID_PACKET_TARGET_TYPES;
|
|
11699
12160
|
NON_TARGET_ROLES = ["context", "candidate", "not-recommended"];
|
|
11700
12161
|
DEFAULT_SCHEMA = {
|
|
@@ -11732,7 +12193,7 @@ var init_index = __esm({
|
|
|
11732
12193
|
e2e_test: ["test_batch", "scope", "ac_coverage", "related_scenarios", "related_decisions", "related_entities", "\u8986\u76D6\u573A\u666F", "\u8986\u76D6\u529F\u80FD"],
|
|
11733
12194
|
e2e_registry: ["batches"]
|
|
11734
12195
|
},
|
|
11735
|
-
allowedEdges:
|
|
12196
|
+
allowedEdges: DEFAULT_ALLOWED_EDGES,
|
|
11736
12197
|
forbiddenEdges: [{ from: "scenario", to: "entity", kind: "references" }],
|
|
11737
12198
|
statuses: ["planned", "active", "done", "deprecated"],
|
|
11738
12199
|
idRanges: {},
|
|
@@ -11866,6 +12327,8 @@ init_index();
|
|
|
11866
12327
|
createModeForUmask,
|
|
11867
12328
|
createRestructureRootBinding,
|
|
11868
12329
|
createRestructureValidationCallback,
|
|
12330
|
+
diagnoseConfigDocument,
|
|
12331
|
+
diagnoseProjectConfig,
|
|
11869
12332
|
digestRestructureValue,
|
|
11870
12333
|
dirname,
|
|
11871
12334
|
discoverAndAuditPackets,
|
|
@@ -11878,6 +12341,7 @@ init_index();
|
|
|
11878
12341
|
gateRestructureOperationPlan,
|
|
11879
12342
|
generateE2eRegistry,
|
|
11880
12343
|
getArtifactTypeMetadata,
|
|
12344
|
+
getConfigDiagnostics,
|
|
11881
12345
|
getExternalEntryInfo,
|
|
11882
12346
|
getTargetArtifactTypes,
|
|
11883
12347
|
inspectRestructure,
|