artifact-graph 0.13.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3386,11 +3386,10 @@ async function detectPnpmVersion() {
3386
3386
  return void 0;
3387
3387
  }
3388
3388
  }
3389
- function bindingInstallBase(cli, root) {
3389
+ function bindingInstallBase(cli, _root) {
3390
3390
  if (!cli.path || !cli.source) return void 0;
3391
3391
  switch (cli.source) {
3392
3392
  case "node_modules":
3393
- return join5(root, "package.json");
3394
3393
  case "plugin-bundled":
3395
3394
  case "path":
3396
3395
  case "legacy":
@@ -3399,11 +3398,10 @@ function bindingInstallBase(cli, root) {
3399
3398
  return void 0;
3400
3399
  }
3401
3400
  }
3402
- function bindingInstallRoot(cli, root) {
3401
+ function bindingInstallRoot(cli, _root) {
3403
3402
  if (!cli.path || !cli.source) return void 0;
3404
3403
  switch (cli.source) {
3405
3404
  case "node_modules":
3406
- return root;
3407
3405
  case "plugin-bundled":
3408
3406
  case "path":
3409
3407
  case "legacy":
@@ -3926,6 +3924,378 @@ var init_hook_installer = __esm({
3926
3924
  }
3927
3925
  });
3928
3926
 
3927
+ // src/professional-conclusion.ts
3928
+ import { access as access2 } from "fs/promises";
3929
+ import { createRequire as createRequire2 } from "module";
3930
+ import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute4, join as join7, resolve as resolve5 } from "path";
3931
+ import { pathToFileURL } from "url";
3932
+ async function loadContracts() {
3933
+ return await import(CONTRACTS_PACKAGE_NAME);
3934
+ }
3935
+ async function loadHarness() {
3936
+ return await import("skill-family-harness-node");
3937
+ }
3938
+ function providerVersion() {
3939
+ const anchor = typeof __filename === "string" ? __filename : import.meta.url;
3940
+ const parsed = createRequire2(anchor)("../package.json");
3941
+ if (typeof parsed.version !== "string" || parsed.version.length === 0) {
3942
+ throw new Error("artifact-graph package.json is missing version");
3943
+ }
3944
+ return parsed.version;
3945
+ }
3946
+ function errorMessage(error) {
3947
+ return error instanceof Error ? error.message : String(error);
3948
+ }
3949
+ function harnessKind(error) {
3950
+ if (error === null || typeof error !== "object" || !("details" in error)) {
3951
+ return void 0;
3952
+ }
3953
+ const details = error.details;
3954
+ return typeof details?.kind === "string" ? details.kind : void 0;
3955
+ }
3956
+ async function missingRequiredConfig(root) {
3957
+ const configPath = join7(root, "artifact-graph.config.yaml");
3958
+ try {
3959
+ await access2(configPath);
3960
+ return void 0;
3961
+ } catch (error) {
3962
+ if (error.code === "ENOENT") {
3963
+ return `required configuration is missing: ${configPath}`;
3964
+ }
3965
+ return errorMessage(error);
3966
+ }
3967
+ }
3968
+ async function runValidate(root) {
3969
+ const config = await loadConfig(root);
3970
+ const graph = await scanArtifacts(root, config);
3971
+ const issues = validateGraph(graph, config);
3972
+ issues.push(...await validateScenarioPrdLinkIndex(root, graph));
3973
+ issues.push(...await validateExecutableTraceability(root, config));
3974
+ const includeCoverage = config.e2e?.executable_ref_warning !== void 0 || config.e2e?.executable_ref_error !== void 0;
3975
+ if (includeCoverage) {
3976
+ const e2eConfig = config.e2e ?? {};
3977
+ const coverageStats = await computeE2eCoverageStats(graph, root, {
3978
+ executableRefWarning: e2eConfig.executable_ref_warning,
3979
+ executableRefError: e2eConfig.executable_ref_error,
3980
+ reportUncoveredScenarios: e2eConfig.report_uncovered_scenarios,
3981
+ reportUncoveredFeatures: e2eConfig.report_uncovered_features,
3982
+ scenarioWaivers: e2eConfig.scenario_waivers,
3983
+ featureWaivers: e2eConfig.feature_waivers
3984
+ });
3985
+ for (const msg of coverageStats.thresholdWarnings) {
3986
+ issues.push({
3987
+ code: "E2E_COVERAGE_WARNING",
3988
+ severity: "warning",
3989
+ message: msg,
3990
+ path: "e2e-coverage",
3991
+ line: 1
3992
+ });
3993
+ }
3994
+ for (const msg of coverageStats.thresholdErrors) {
3995
+ issues.push({
3996
+ code: "E2E_COVERAGE_ERROR",
3997
+ severity: "error",
3998
+ message: msg,
3999
+ path: "e2e-coverage",
4000
+ line: 1
4001
+ });
4002
+ }
4003
+ }
4004
+ return { name: CHECK_VALIDATE, status: "completed", issues };
4005
+ }
4006
+ async function runLockAudit(root) {
4007
+ const result = await auditVersionLock(root);
4008
+ return { name: CHECK_LOCK, status: "completed", issues: result.issues };
4009
+ }
4010
+ async function runCoverage(root) {
4011
+ const report = await computeCoverageBoundary(root);
4012
+ return {
4013
+ name: CHECK_COVERAGE,
4014
+ status: "completed",
4015
+ issues: [],
4016
+ coverage: {
4017
+ assessment: report.graphHealth.assessment,
4018
+ changedPathScope: report.scanCoverage.changedPathScope,
4019
+ behaviorStatus: report.behaviorVerification.status
4020
+ }
4021
+ };
4022
+ }
4023
+ async function settleCheck(name, run) {
4024
+ try {
4025
+ return await run();
4026
+ } catch (error) {
4027
+ return { name, status: "not-performed", issues: [], reason: errorMessage(error) };
4028
+ }
4029
+ }
4030
+ function mapDomain(checks) {
4031
+ const completed = checks.filter((check) => check.status === "completed");
4032
+ const missing = checks.filter((check) => check.status === "not-performed");
4033
+ const hasFindings = completed.some((check) => check.issues.length > 0);
4034
+ if (completed.length === 0) {
4035
+ return {
4036
+ code: GRAPH_DOMAIN_CODES.UNAVAILABLE,
4037
+ completion: "not-performed",
4038
+ summary: "Graph checks did not start because configuration, runtime, or inputs were unavailable."
4039
+ };
4040
+ }
4041
+ if (hasFindings) {
4042
+ return {
4043
+ code: GRAPH_DOMAIN_CODES.FINDINGS,
4044
+ completion: missing.length > 0 ? "partial" : "complete",
4045
+ summary: "At least one completed graph check reported issues. Original issues are preserved."
4046
+ };
4047
+ }
4048
+ if (missing.length > 0) {
4049
+ return {
4050
+ code: GRAPH_DOMAIN_CODES.INCOMPLETE,
4051
+ completion: "partial",
4052
+ summary: "Some declared graph checks completed without findings; others lacked input or could not finish."
4053
+ };
4054
+ }
4055
+ return {
4056
+ code: GRAPH_DOMAIN_CODES.CLEAR,
4057
+ completion: "complete",
4058
+ summary: "Declared graph checks completed without issues. This does not prove unregistered relations or content correctness."
4059
+ };
4060
+ }
4061
+ function buildLimitations(checks) {
4062
+ const limitations = [STANDING_LIMITATION];
4063
+ for (const check of checks) {
4064
+ if (check.status === "not-performed") {
4065
+ limitations.push(`${check.name} did not complete: ${check.reason ?? "unknown error"}`);
4066
+ }
4067
+ if (check.coverage?.behaviorStatus === "not-evaluated") {
4068
+ limitations.push("coverage does not evaluate whether declared verification actually ran.");
4069
+ }
4070
+ if (check.coverage?.changedPathScope === "unavailable") {
4071
+ limitations.push("coverage could not observe Git worktree changes.");
4072
+ }
4073
+ }
4074
+ return [...new Set(limitations)];
4075
+ }
4076
+ function buildConclusion(root, checks) {
4077
+ const absoluteRoot = resolve5(root);
4078
+ const mapped = mapDomain(checks);
4079
+ const checked = checks.filter((check) => check.status === "completed").map((check) => check.name);
4080
+ const limitations = buildLimitations(checks);
4081
+ const issues = checks.flatMap((check) => check.issues);
4082
+ return {
4083
+ schemaVersion: 1,
4084
+ kind: "skill-family.professional-conclusion",
4085
+ provider: {
4086
+ id: GRAPH_PROVIDER_ID,
4087
+ version: providerVersion(),
4088
+ entry: GRAPH_PROVIDER_ENTRY
4089
+ },
4090
+ subject: {
4091
+ ref: pathToFileURL(absoluteRoot).href
4092
+ },
4093
+ scope: {
4094
+ checked: mapped.completion === "not-performed" ? [] : checked,
4095
+ limitations
4096
+ },
4097
+ outcome: {
4098
+ completion: mapped.completion,
4099
+ code: mapped.code,
4100
+ summary: mapped.summary
4101
+ },
4102
+ details: {
4103
+ checks: checks.map((check) => ({
4104
+ name: check.name,
4105
+ status: check.status,
4106
+ issueCount: check.issues.length,
4107
+ ...check.reason ? { reason: check.reason } : {},
4108
+ ...check.coverage ? { coverage: check.coverage } : {}
4109
+ })),
4110
+ issues
4111
+ }
4112
+ };
4113
+ }
4114
+ async function assertConclusionShape(conclusion) {
4115
+ const contracts = await loadContracts();
4116
+ const registration = contracts.findSchemaByObject(PROFESSIONAL_CONCLUSION_OBJECT);
4117
+ if (registration === null) {
4118
+ throw new Error("skill-family-contracts 0.22.0 does not register professional-conclusion");
4119
+ }
4120
+ const verdict = contracts.validateDocument(conclusion, {
4121
+ schemaId: registration.$id,
4122
+ dialect: registration.dialect,
4123
+ policy: "strict"
4124
+ });
4125
+ if (!verdict.valid) {
4126
+ throw new Error(`constructed professional conclusion failed public schema validation (${verdict.errorCode ?? "invalid"})`);
4127
+ }
4128
+ }
4129
+ async function publishConclusion(absoluteOutput, conclusion) {
4130
+ if (!isAbsolute4(absoluteOutput)) {
4131
+ return "--conclusion-output must be an absolute path";
4132
+ }
4133
+ const outputRoot = dirname5(absoluteOutput);
4134
+ const relPath = basename3(absoluteOutput);
4135
+ if (relPath.length === 0 || relPath === "." || relPath === "..") {
4136
+ return "--conclusion-output must name a file";
4137
+ }
4138
+ try {
4139
+ const harness = await loadHarness();
4140
+ await harness.publishFileExclusive(outputRoot, relPath, `${JSON.stringify(conclusion, null, 2)}
4141
+ `);
4142
+ return void 0;
4143
+ } catch (error) {
4144
+ const kind = harnessKind(error);
4145
+ if (kind === "exclusive-publish-conflict") {
4146
+ return `exclusive publication target already exists: ${absoluteOutput}`;
4147
+ }
4148
+ return errorMessage(error);
4149
+ }
4150
+ }
4151
+ async function runCheckProfessional(options) {
4152
+ const root = resolve5(options.root);
4153
+ const configGap = await missingRequiredConfig(root);
4154
+ const checks = configGap === void 0 ? await Promise.all([
4155
+ settleCheck(CHECK_VALIDATE, () => runValidate(root)),
4156
+ settleCheck(CHECK_LOCK, () => runLockAudit(root)),
4157
+ settleCheck(CHECK_COVERAGE, () => runCoverage(root))
4158
+ ]) : [
4159
+ { name: CHECK_VALIDATE, status: "not-performed", issues: [], reason: configGap },
4160
+ { name: CHECK_LOCK, status: "not-performed", issues: [], reason: configGap },
4161
+ { name: CHECK_COVERAGE, status: "not-performed", issues: [], reason: configGap }
4162
+ ];
4163
+ const conclusion = buildConclusion(root, checks);
4164
+ await assertConclusionShape(conclusion);
4165
+ if (options.conclusionOutput === void 0) {
4166
+ return { conclusion };
4167
+ }
4168
+ if (!isAbsolute4(options.conclusionOutput)) {
4169
+ return { conclusion, writeError: "--conclusion-output must be an absolute path" };
4170
+ }
4171
+ const writeError = await publishConclusion(resolve5(options.conclusionOutput), conclusion);
4172
+ return { conclusion, ...writeError ? { writeError } : {} };
4173
+ }
4174
+ function asRecord(value) {
4175
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4176
+ return null;
4177
+ }
4178
+ return value;
4179
+ }
4180
+ function readProvider(value) {
4181
+ const record = asRecord(value);
4182
+ if (record === null) {
4183
+ return null;
4184
+ }
4185
+ const provider = {};
4186
+ if (typeof record.id === "string") provider.id = record.id;
4187
+ if (typeof record.version === "string") provider.version = record.version;
4188
+ if (typeof record.entry === "string") provider.entry = record.entry;
4189
+ return Object.keys(provider).length > 0 ? provider : null;
4190
+ }
4191
+ function interpretConclusion(conclusion) {
4192
+ const provider = conclusion.provider;
4193
+ if (provider.id !== GRAPH_PROVIDER_ID) {
4194
+ return {
4195
+ status: "unavailable",
4196
+ reason: `proof provider ${provider.id} is not ${GRAPH_PROVIDER_ID}`,
4197
+ provider,
4198
+ conclusion
4199
+ };
4200
+ }
4201
+ if (!KNOWN_DOMAIN_CODES.has(conclusion.outcome.code)) {
4202
+ return {
4203
+ status: "unavailable",
4204
+ reason: `unknown same-version domain code: ${conclusion.outcome.code}`,
4205
+ provider,
4206
+ conclusion
4207
+ };
4208
+ }
4209
+ if (conclusion.outcome.code === GRAPH_DOMAIN_CODES.CLEAR && conclusion.outcome.completion === "complete") {
4210
+ return {
4211
+ status: "pass",
4212
+ reason: "GRAPH_CLEAR with complete scope is acceptable for this provider version.",
4213
+ provider,
4214
+ conclusion
4215
+ };
4216
+ }
4217
+ return {
4218
+ status: "not_pass",
4219
+ reason: `proof records ${conclusion.outcome.code} (${conclusion.outcome.completion}); complete does not mean pass.`,
4220
+ provider,
4221
+ conclusion
4222
+ };
4223
+ }
4224
+ async function runReadProof(options) {
4225
+ const unavailable = (reason, provider = null, conclusion = null) => ({
4226
+ result: { status: "unavailable", reason, provider, conclusion },
4227
+ exitCode: 2
4228
+ });
4229
+ let receipt;
4230
+ try {
4231
+ const harness = await loadHarness();
4232
+ receipt = await harness.readFileStrict(options.proofRoot, options.proof, { encoding: "utf8" });
4233
+ } catch (error) {
4234
+ const kind = harnessKind(error);
4235
+ if (kind === "missing-resource") {
4236
+ return unavailable(`proof file does not exist: ${options.proof}`, null, null);
4237
+ }
4238
+ return unavailable(errorMessage(error), null, null);
4239
+ }
4240
+ const raw = typeof receipt.content === "string" ? receipt.content : receipt.content.toString("utf8");
4241
+ let parsed;
4242
+ try {
4243
+ parsed = JSON.parse(raw);
4244
+ } catch (error) {
4245
+ return unavailable(`proof is not valid JSON: ${errorMessage(error)}`, null, null);
4246
+ }
4247
+ const previewProvider = readProvider(asRecord(parsed)?.provider);
4248
+ let contracts;
4249
+ try {
4250
+ contracts = await loadContracts();
4251
+ } catch (error) {
4252
+ return unavailable(`cannot load skill-family-contracts: ${errorMessage(error)}`, previewProvider, null);
4253
+ }
4254
+ const registration = contracts.findSchemaByObject(PROFESSIONAL_CONCLUSION_OBJECT);
4255
+ if (registration === null) {
4256
+ return unavailable("professional-conclusion schema is not registered", previewProvider, null);
4257
+ }
4258
+ const verdict = contracts.validateDocument(parsed, {
4259
+ schemaId: registration.$id,
4260
+ dialect: registration.dialect,
4261
+ policy: "strict"
4262
+ });
4263
+ if (!verdict.valid) {
4264
+ return unavailable(
4265
+ `proof failed professional-conclusion schema validation (${verdict.errorCode ?? "invalid"})`,
4266
+ previewProvider,
4267
+ null
4268
+ );
4269
+ }
4270
+ const interpreted = interpretConclusion(parsed);
4271
+ const exitCode = interpreted.status === "pass" ? 0 : interpreted.status === "not_pass" ? 1 : 2;
4272
+ return { result: interpreted, exitCode };
4273
+ }
4274
+ var 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;
4275
+ var init_professional_conclusion = __esm({
4276
+ "src/professional-conclusion.ts"() {
4277
+ "use strict";
4278
+ init_coverage();
4279
+ init_index();
4280
+ init_versioned_traceability();
4281
+ GRAPH_PROVIDER_ID = "artifact-graph";
4282
+ GRAPH_PROVIDER_ENTRY = "check-professional";
4283
+ PROFESSIONAL_CONCLUSION_OBJECT = "professional-conclusion";
4284
+ GRAPH_DOMAIN_CODES = Object.freeze({
4285
+ CLEAR: "GRAPH_CLEAR",
4286
+ FINDINGS: "GRAPH_FINDINGS",
4287
+ INCOMPLETE: "GRAPH_CHECK_INCOMPLETE",
4288
+ UNAVAILABLE: "GRAPH_CHECK_UNAVAILABLE"
4289
+ });
4290
+ KNOWN_DOMAIN_CODES = new Set(Object.values(GRAPH_DOMAIN_CODES));
4291
+ CHECK_VALIDATE = "validate";
4292
+ CHECK_LOCK = "version-lock-audit";
4293
+ CHECK_COVERAGE = "coverage";
4294
+ STANDING_LIMITATION = "Graph checks do not prove content semantics, method execution, or publication facts.";
4295
+ CONTRACTS_PACKAGE_NAME = "skill-family-contracts";
4296
+ }
4297
+ });
4298
+
3929
4299
  // src/review-result-validator.ts
3930
4300
  function validateReviewResult(input) {
3931
4301
  const errors = [];
@@ -4250,7 +4620,7 @@ var init_review_result_validator = __esm({
4250
4620
  // src/contract-kernel.ts
4251
4621
  import { createHash as createHash2 } from "crypto";
4252
4622
  import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
4253
- import { join as join7 } from "path";
4623
+ import { join as join8 } from "path";
4254
4624
  import _AjvModule from "ajv";
4255
4625
  function isOfficialNamespace(namespace) {
4256
4626
  return OFFICIAL_NAMESPACE_PATTERN.test(namespace);
@@ -4582,7 +4952,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
4582
4952
  const entries = await readdir2(contractsDir, { withFileTypes: true });
4583
4953
  for (const entry of entries) {
4584
4954
  if (entry.isDirectory()) {
4585
- const schemaPath = join7(contractsDir, entry.name, "schema.json");
4955
+ const schemaPath = join8(contractsDir, entry.name, "schema.json");
4586
4956
  const contract = await loadContract(schemaPath, options);
4587
4957
  contracts.push(contract);
4588
4958
  }
@@ -5127,12 +5497,12 @@ var init_restructure_software = __esm({
5127
5497
  // src/restructure-file-set.ts
5128
5498
  import { createHash as createHash3 } from "crypto";
5129
5499
  import { chmod, lstat as lstat2, mkdir as mkdir4, realpath, statfs } from "fs/promises";
5130
- import { join as join8, resolve as resolve5 } from "path";
5500
+ import { join as join9, resolve as resolve6 } from "path";
5131
5501
  async function loadFoundationModule() {
5132
5502
  return await import(FOUNDATION_PACKAGE_NAME);
5133
5503
  }
5134
5504
  async function loadContractsModule() {
5135
- return await import(CONTRACTS_PACKAGE_NAME);
5505
+ return await import(CONTRACTS_PACKAGE_NAME2);
5136
5506
  }
5137
5507
  async function verifyMechanismResult(result) {
5138
5508
  if (typeof result !== "object" || result === null || Array.isArray(result)) {
@@ -5185,7 +5555,7 @@ function rawDigest(value, path) {
5185
5555
  async function resolveRealRoot(root) {
5186
5556
  let canonical;
5187
5557
  try {
5188
- canonical = await realpath(resolve5(root));
5558
+ canonical = await realpath(resolve6(root));
5189
5559
  } catch (cause) {
5190
5560
  return failure("ROOT_INVALID", `Project root cannot be resolved: ${cause.message}`);
5191
5561
  }
@@ -5224,7 +5594,7 @@ async function qualifyRestructureMechanism(root) {
5224
5594
  return { ok: true, data: { root: canonical.data, filesystem: RESTRUCTURE_QUALIFIED_FILESYSTEM } };
5225
5595
  }
5226
5596
  async function ensureRestructureMechanismRoot(canonicalRoot, options) {
5227
- const target = join8(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
5597
+ const target = join9(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
5228
5598
  const current = async () => lstat2(target).catch((cause) => cause.code === "ENOENT" ? null : Promise.reject(cause));
5229
5599
  let info = await current();
5230
5600
  if (info === null) {
@@ -5338,7 +5708,7 @@ async function applyRestructureFileSet(canonicalRoot, plan, options) {
5338
5708
  return await verifyMechanismResult(raw);
5339
5709
  }
5340
5710
  async function observeRestructureJournal(canonicalRoot) {
5341
- const journalRoot = join8(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
5711
+ const journalRoot = join9(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
5342
5712
  const module = await loadFoundationModule();
5343
5713
  try {
5344
5714
  return { ok: true, data: await module.inspectStateStoreLock(journalRoot, { recoveryObservation: true }) };
@@ -5525,7 +5895,7 @@ function projectRestructureFileSetResult(result, planPath = "", planDigest = "")
5525
5895
  const reading = result.operation === "apply" ? applyProjection(result) : result.operation === "recover" ? recoverProjection(result) : pruneProjection(result);
5526
5896
  return { ...base, ...reading };
5527
5897
  }
5528
- var 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_NAME, FILE_SET_RESULT_OBJECT, APPLY_MAINTENANCE_ERROR_KINDS;
5898
+ var 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;
5529
5899
  var init_restructure_file_set = __esm({
5530
5900
  "src/restructure-file-set.ts"() {
5531
5901
  "use strict";
@@ -5539,7 +5909,7 @@ var init_restructure_file_set = __esm({
5539
5909
  DIGEST_PREFIX = "sha256:";
5540
5910
  RAW_SHA256_PATTERN = /^[a-f0-9]{64}$/;
5541
5911
  FOUNDATION_PACKAGE_NAME = "skill-family-harness-node";
5542
- CONTRACTS_PACKAGE_NAME = "skill-family-contracts";
5912
+ CONTRACTS_PACKAGE_NAME2 = "skill-family-contracts";
5543
5913
  FILE_SET_RESULT_OBJECT = "file-set-result";
5544
5914
  APPLY_MAINTENANCE_ERROR_KINDS = ["lock-release-failed"];
5545
5915
  }
@@ -5548,7 +5918,7 @@ var init_restructure_file_set = __esm({
5548
5918
  // src/restructure.ts
5549
5919
  import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
5550
5920
  import { lstat as lstat3, readFile as readFile3, readdir as readdir3, realpath as realpath2, stat } from "fs/promises";
5551
- import { dirname as dirname5, isAbsolute as isAbsolute4, join as join9, posix, relative as relative4, resolve as resolve6 } from "path";
5921
+ import { dirname as dirname6, isAbsolute as isAbsolute5, join as join10, posix, relative as relative4, resolve as resolve7 } from "path";
5552
5922
  import { fileURLToPath as fileURLToPath2 } from "url";
5553
5923
  function digestBytes(value) {
5554
5924
  return `sha256:${createHash4("sha256").update(value).digest("hex")}`;
@@ -5564,7 +5934,7 @@ function digestRestructureValue(value) {
5564
5934
  return digestBytes(canonicalJson(value));
5565
5935
  }
5566
5936
  function normalizeRelativePath2(value) {
5567
- if (!value || value.includes("\0") || isAbsolute4(value)) return void 0;
5937
+ if (!value || value.includes("\0") || isAbsolute5(value)) return void 0;
5568
5938
  const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "");
5569
5939
  if (!normalized || normalized === "." || normalized.split("/").some((part) => part === ".." || part === "")) return void 0;
5570
5940
  return normalized;
@@ -5578,8 +5948,8 @@ function isPathAllowed(path, allowed) {
5578
5948
  async function readContainedFileWithMode(root, path) {
5579
5949
  const normalized = normalizeRelativePath2(path);
5580
5950
  if (!normalized) throw new Error(`Path must be a project-relative path without traversal: ${path}`);
5581
- const absoluteRoot = resolve6(root);
5582
- const absolutePath = resolve6(absoluteRoot, normalized);
5951
+ const absoluteRoot = resolve7(root);
5952
+ const absolutePath = resolve7(absoluteRoot, normalized);
5583
5953
  if (relative4(absoluteRoot, absolutePath).startsWith("..")) throw new Error(`Path escapes project root: ${path}`);
5584
5954
  try {
5585
5955
  const info = await lstat3(absolutePath);
@@ -5612,7 +5982,7 @@ async function configSnapshot(root) {
5612
5982
  return snapshotFile(root, "artifact-graph.config.yaml");
5613
5983
  }
5614
5984
  async function loadRestructureContract(name) {
5615
- return loadContract(join9(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
5985
+ return loadContract(join10(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
5616
5986
  }
5617
5987
  async function validateDomainContract(name, value) {
5618
5988
  const contract = await loadRestructureContract(name);
@@ -5887,7 +6257,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
5887
6257
  async function visit(directory) {
5888
6258
  for (const entry of await readdir3(directory, { withFileTypes: true })) {
5889
6259
  if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
5890
- const absolute = join9(directory, entry.name);
6260
+ const absolute = join10(directory, entry.name);
5891
6261
  if (entry.isDirectory()) {
5892
6262
  await visit(absolute);
5893
6263
  continue;
@@ -5916,7 +6286,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
5916
6286
  path,
5917
6287
  lineNumber
5918
6288
  ));
5919
- } else if (!await pathExists2(resolve6(root, resolved))) {
6289
+ } else if (!await pathExists2(resolve7(root, resolved))) {
5920
6290
  findings.push(finding(
5921
6291
  "SIBLING_RELATIVE_REFERENCE_UNRESOLVED",
5922
6292
  `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`,
@@ -5941,7 +6311,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
5941
6311
  }
5942
6312
  }
5943
6313
  }
5944
- await visit(resolve6(root));
6314
+ await visit(resolve7(root));
5945
6315
  const unique = new Map(findings.map((item) => [`${item.code} ${item.path} ${item.line} ${item.message}`, item]));
5946
6316
  return [...unique.values()].sort((left, right) => (left.path ?? "").localeCompare(right.path ?? "") || (left.line ?? 0) - (right.line ?? 0) || left.code.localeCompare(right.code));
5947
6317
  }
@@ -5959,7 +6329,7 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
5959
6329
  async function visit(directory) {
5960
6330
  for (const entry of await readdir3(directory, { withFileTypes: true })) {
5961
6331
  if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
5962
- const absolute = join9(directory, entry.name);
6332
+ const absolute = join10(directory, entry.name);
5963
6333
  if (entry.isDirectory()) {
5964
6334
  await visit(absolute);
5965
6335
  } else if (entry.isFile() && TEXT_EXTENSIONS.test(entry.name)) {
@@ -5974,7 +6344,7 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
5974
6344
  }
5975
6345
  }
5976
6346
  }
5977
- await visit(resolve6(root));
6347
+ await visit(resolve7(root));
5978
6348
  return results.sort((left, right) => left.path.localeCompare(right.path) || left.line - right.line || left.reference.localeCompare(right.reference));
5979
6349
  }
5980
6350
  function expectedRelationTargets(mapping) {
@@ -6014,7 +6384,7 @@ function restructureBoundaryFindings(operations, limits) {
6014
6384
  const expectedCreateMode = createModeForUmask(limits.umask);
6015
6385
  const applyModeContract = limits.mode_contract === "apply";
6016
6386
  for (const operation of operations) {
6017
- const parent = dirname5(operation.path) || ".";
6387
+ const parent = dirname6(operation.path) || ".";
6018
6388
  if (!operation.parent_exists) {
6019
6389
  findings.push(finding("PARENT_DIRECTORY_MISSING", `Parent directory does not exist or is not a directory: ${parent}`, operation.path));
6020
6390
  } else if (operation.parent_device !== null && operation.parent_device !== operation.root_device) {
@@ -6205,7 +6575,7 @@ async function planRestructure(root, input) {
6205
6575
  }
6206
6576
  pathMoves.push(move);
6207
6577
  rangesByPath.set(sourcePath, pathMoves);
6208
- if (dirname5(sourcePath) !== dirname5(targetPath)) {
6578
+ if (dirname6(sourcePath) !== dirname6(targetPath)) {
6209
6579
  for (const link of findRelativeLinks(fragment.toString("utf8"))) {
6210
6580
  const explicitlyEdited = mapping.prose_edits.some((edit) => edit.target_path === targetPath && edit.old_text.includes(link));
6211
6581
  if (!explicitlyEdited) blockers.push(finding("RELATIVE_LINK_REQUIRES_MAPPING", `Relative reference "${link}" changes base directory when moved to ${targetPath}`, sourcePath));
@@ -6322,15 +6692,15 @@ async function planRestructure(root, input) {
6322
6692
  diff: readableDiff(path, original?.toString("utf8"), deleteFile ? void 0 : candidate.toString("utf8"))
6323
6693
  });
6324
6694
  }
6325
- const rootDirectory = await probeDirectory(resolve6(root));
6695
+ const rootDirectory = await probeDirectory(resolve7(root));
6326
6696
  const parentProbes = /* @__PURE__ */ new Map();
6327
6697
  for (const candidate of candidates) {
6328
- const parent = dirname5(candidate.path);
6329
- if (!parentProbes.has(parent)) parentProbes.set(parent, await probeDirectory(resolve6(root, parent)));
6698
+ const parent = dirname6(candidate.path);
6699
+ if (!parentProbes.has(parent)) parentProbes.set(parent, await probeDirectory(resolve7(root, parent)));
6330
6700
  }
6331
6701
  blockers.push(...restructureBoundaryFindings(
6332
6702
  candidates.map((candidate) => {
6333
- const parent = parentProbes.get(dirname5(candidate.path));
6703
+ const parent = parentProbes.get(dirname6(candidate.path));
6334
6704
  return {
6335
6705
  path: candidate.path,
6336
6706
  action: candidate.action,
@@ -6456,7 +6826,7 @@ function refusal(code, message, findings = []) {
6456
6826
  return { ok: false, error: { code, message, ...findings.length === 0 ? {} : { details: findings } } };
6457
6827
  }
6458
6828
  async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
6459
- const absolute = resolve6(planPath);
6829
+ const absolute = resolve7(planPath);
6460
6830
  let info;
6461
6831
  try {
6462
6832
  info = await lstat3(absolute);
@@ -6500,18 +6870,18 @@ function planRootIdentityFindings(document) {
6500
6870
  findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan does not record this project's configuration file: ${document.plan.config_snapshot.path}`));
6501
6871
  }
6502
6872
  const relativePlan = relative4(document.root, document.realPath);
6503
- if (!relativePlan || relativePlan.startsWith("..") || isAbsolute4(relativePlan)) {
6873
+ if (!relativePlan || relativePlan.startsWith("..") || isAbsolute5(relativePlan)) {
6504
6874
  findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan document is outside the project root: ${document.realPath}`, document.realPath));
6505
6875
  }
6506
6876
  return findings;
6507
6877
  }
6508
6878
  async function operationBoundaries(root, plan) {
6509
- const rootDirectory = await probeDirectory(resolve6(root));
6879
+ const rootDirectory = await probeDirectory(resolve7(root));
6510
6880
  const parents = /* @__PURE__ */ new Map();
6511
6881
  const boundaries = [];
6512
6882
  for (const candidate of plan.candidates) {
6513
- const parent = dirname5(candidate.path) || ".";
6514
- if (!parents.has(parent)) parents.set(parent, await probeDirectory(resolve6(root, parent)));
6883
+ const parent = dirname6(candidate.path) || ".";
6884
+ if (!parents.has(parent)) parents.set(parent, await probeDirectory(resolve7(root, parent)));
6515
6885
  const probe = parents.get(parent);
6516
6886
  boundaries.push({
6517
6887
  path: candidate.path,
@@ -6690,8 +7060,8 @@ var init_restructure = __esm({
6690
7060
  RESTRUCTURE_MAX_TOTAL_BYTES = 256 * 1024 * 1024;
6691
7061
  MAX_POSIX_MODE = 511;
6692
7062
  CREATE_MODE_BASE = 438;
6693
- MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : dirname5(fileURLToPath2(import.meta.url));
6694
- CONTRACT_ROOT = join9(MODULE_DIRECTORY, "..", "contracts");
7063
+ MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : dirname6(fileURLToPath2(import.meta.url));
7064
+ CONTRACT_ROOT = join10(MODULE_DIRECTORY, "..", "contracts");
6695
7065
  SKIPPED_SCAN_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "dist", "coverage", ".tmp", ".codex", ".worktrees", ".foundation-file-apply", ".artifact-graph"]);
6696
7066
  TEXT_EXTENSIONS = /\.(?:md|markdown|json|ya?ml|[cm]?[jt]sx?)$/i;
6697
7067
  MARKDOWN_LINK_PATTERN = /!?\[([^\]\n]*)\]\(([^)\n]+)\)/g;
@@ -6706,7 +7076,7 @@ import matter from "gray-matter";
6706
7076
  import yaml from "js-yaml";
6707
7077
  import { accessSync, constants as fsConstants, existsSync as existsSync3, statSync } from "fs";
6708
7078
  import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
6709
- import { basename as basename4, dirname as dirname6, extname, isAbsolute as isAbsolute5, join as join10, resolve as resolve7 } from "path";
7079
+ import { basename as basename5, dirname as dirname7, extname, isAbsolute as isAbsolute6, join as join11, resolve as resolve8 } from "path";
6710
7080
  function isTargetArtifactType(type) {
6711
7081
  return isPacketTargetType(type);
6712
7082
  }
@@ -6748,7 +7118,7 @@ function resolveArtifactTypeName(schema, token) {
6748
7118
  return void 0;
6749
7119
  }
6750
7120
  async function loadConfig(root) {
6751
- const configPath = join10(root, "artifact-graph.config.yaml");
7121
+ const configPath = join11(root, "artifact-graph.config.yaml");
6752
7122
  let parsed = {};
6753
7123
  try {
6754
7124
  const raw = await readFile4(configPath, "utf-8");
@@ -6792,8 +7162,31 @@ async function loadConfig(root) {
6792
7162
  idRanges: mergeRecord(DEFAULT_SCHEMA.idRanges, parsed.idRanges),
6793
7163
  e2e: mergedE2e
6794
7164
  };
7165
+ validateJsonArtifactTypes(merged.types);
6795
7166
  return merged;
6796
7167
  }
7168
+ function validateJsonArtifactTypes(types) {
7169
+ for (const [type, definition] of Object.entries(types)) {
7170
+ const raw = definition;
7171
+ const format = raw.format;
7172
+ const idField = raw.idField;
7173
+ if (format === void 0) {
7174
+ if (idField !== void 0) {
7175
+ throw new Error(`Invalid types.${type}.idField: idField requires format json.`);
7176
+ }
7177
+ continue;
7178
+ }
7179
+ if (format !== "json") {
7180
+ throw new Error(`Invalid types.${type}.format: only json is supported. Omit format to keep Markdown parsing.`);
7181
+ }
7182
+ if (SPECIALIZED_PARSER_TYPES.has(type)) {
7183
+ throw new Error(`Invalid types.${type}.format: JSON format applies only to custom types. ${type} keeps its dedicated parser.`);
7184
+ }
7185
+ if (typeof idField !== "string" || idField.length === 0 || idField.trim() !== idField) {
7186
+ throw new Error(`Invalid types.${type}.idField: format json requires the name of one root property.`);
7187
+ }
7188
+ }
7189
+ }
6797
7190
  function validateRelationSemanticsConfig(value) {
6798
7191
  if (value === void 0) return;
6799
7192
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -6877,7 +7270,7 @@ function validateE2eConfig(e2e) {
6877
7270
  if (typeof runner.root !== "string" || !runner.root.trim()) {
6878
7271
  throw new Error(`Invalid e2e.runners[${runner.name}].root: must be a non-empty string.`);
6879
7272
  }
6880
- if (isAbsolute5(runner.root)) {
7273
+ if (isAbsolute6(runner.root)) {
6881
7274
  throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not be an absolute path.`);
6882
7275
  }
6883
7276
  if (runner.root.replace(/\\/g, "/").split("/").includes("..")) {
@@ -6966,15 +7359,15 @@ async function scanArtifacts(root, schema, options = {}) {
6966
7359
  continue;
6967
7360
  }
6968
7361
  scannedFiles.set(file, type);
6969
- const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await readFile4(join10(root, file), "utf-8");
7362
+ const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await readFile4(join11(root, file), "utf-8");
6970
7363
  const parsed = parseFile(type, file, raw, config);
6971
- const semantic = parseConfiguredRelations(type, file, raw, parsed.nodes, config);
7364
+ const semantic = isJsonOriginalType(type, config) ? { edges: [], diagnostics: [] } : parseConfiguredRelations(type, file, raw, parsed.nodes, config);
6972
7365
  nodes.push(...parsed.nodes);
6973
7366
  edges.push(...parsed.edges, ...semantic.edges);
6974
7367
  scanDiagnostics.push(...parsed.diagnostics, ...semantic.diagnostics);
6975
7368
  }
6976
7369
  }
6977
- const absoluteRoot = isAbsolute5(root) ? root : resolve7(root);
7370
+ const absoluteRoot = isAbsolute6(root) ? root : resolve8(root);
6978
7371
  const graph = buildGraph(nodes, edges, scanDiagnostics, absoluteRoot);
6979
7372
  return resolveMatrixEdges(graph);
6980
7373
  }
@@ -7179,33 +7572,6 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
7179
7572
  issues.push(issue("CYCLE_DETECTED", `depends_on cycle detected: ${cycle.join(" -> ")}`, "", 1, { node: cycle[0] }));
7180
7573
  }
7181
7574
  const defaultTypeKeys = new Set(Object.keys(DEFAULT_SCHEMA.types));
7182
- const specializedParserTypes = /* @__PURE__ */ new Set([
7183
- "feature",
7184
- "scenario",
7185
- "entity",
7186
- "decision",
7187
- "test",
7188
- "design",
7189
- "e2e_test",
7190
- "e2e_registry",
7191
- "rule-golden-cases",
7192
- "test-strategy",
7193
- "traceability-matrix-v2",
7194
- "traceability-version-lock",
7195
- "interface_contracts",
7196
- "data_contracts",
7197
- "application_state_machines",
7198
- "error_model",
7199
- "domain-glossary",
7200
- "bounded-context-map",
7201
- "domain-invariants",
7202
- "generation-packet-spec",
7203
- "report-contracts",
7204
- "verification-fixtures",
7205
- "ui-flow-contracts",
7206
- "non-functional-budgets",
7207
- "implementation-blueprint"
7208
- ]);
7209
7575
  const uidsWithEdges = /* @__PURE__ */ new Set();
7210
7576
  for (const edge2 of graph.edges) {
7211
7577
  uidsWithEdges.add(edge2.from);
@@ -7213,7 +7579,7 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
7213
7579
  }
7214
7580
  for (const node of graph.nodes) {
7215
7581
  if (defaultTypeKeys.has(node.type)) continue;
7216
- if (specializedParserTypes.has(node.type)) continue;
7582
+ if (SPECIALIZED_PARSER_TYPES.has(node.type)) continue;
7217
7583
  if (!schema.types[node.type]) continue;
7218
7584
  if (!uidsWithEdges.has(node.uid)) {
7219
7585
  issues.push(issue(
@@ -7340,7 +7706,7 @@ async function validateScenarioPrdLinkIndex(root, graph) {
7340
7706
  const indexPath = "artifacts/prd/feature-index.md";
7341
7707
  let raw = "";
7342
7708
  try {
7343
- raw = await readFile4(join10(root, indexPath), "utf-8");
7709
+ raw = await readFile4(join11(root, indexPath), "utf-8");
7344
7710
  } catch (error) {
7345
7711
  if (error.code === "ENOENT") {
7346
7712
  return [];
@@ -7588,12 +7954,12 @@ function nextId(graph, schema, type, rangeName) {
7588
7954
  throw new Error(`ID range ${type}.${rangeName} is exhausted`);
7589
7955
  }
7590
7956
  async function writeGraphCache(root, graph) {
7591
- const cacheDir = join10(root, ".artifact-graph");
7957
+ const cacheDir = join11(root, ".artifact-graph");
7592
7958
  await mkdir5(cacheDir, { recursive: true });
7593
- await writeFile3(join10(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
7959
+ await writeFile3(join11(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
7594
7960
  `);
7595
7961
  const { default: Database } = await import("better-sqlite3");
7596
- const db = new Database(join10(cacheDir, "graph.sqlite"));
7962
+ const db = new Database(join11(cacheDir, "graph.sqlite"));
7597
7963
  try {
7598
7964
  db.exec(`
7599
7965
  DROP TABLE IF EXISTS nodes;
@@ -7634,7 +8000,13 @@ async function writeGraphCache(root, graph) {
7634
8000
  db.close();
7635
8001
  }
7636
8002
  }
8003
+ function isJsonOriginalType(type, schema) {
8004
+ return schema.types[type]?.format === "json" && !SPECIALIZED_PARSER_TYPES.has(type);
8005
+ }
7637
8006
  function parseFile(type, path, raw, schema = DEFAULT_SCHEMA) {
8007
+ if (isJsonOriginalType(type, schema)) {
8008
+ return parseGenericJson(type, path, raw, schema);
8009
+ }
7638
8010
  if (type === "feature") {
7639
8011
  return { ...parseFeature(path, raw), diagnostics: [] };
7640
8012
  }
@@ -7703,6 +8075,184 @@ function parseFile(type, path, raw, schema = DEFAULT_SCHEMA) {
7703
8075
  }
7704
8076
  return parseGenericMarkdown(type, path, raw, schema);
7705
8077
  }
8078
+ function isJsonObject(value) {
8079
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8080
+ }
8081
+ function jsonRootKind(value) {
8082
+ if (Array.isArray(value)) return "array";
8083
+ if (value === null) return "null";
8084
+ return typeof value;
8085
+ }
8086
+ function parseGenericJson(type, path, raw, schema) {
8087
+ const diagnostics = [];
8088
+ const idField = schema.types[type]?.idField;
8089
+ if (typeof idField !== "string" || idField.length === 0 || idField.trim() !== idField) {
8090
+ diagnostics.push(issue(
8091
+ "INVALID_JSON",
8092
+ `types.${type}.idField must name one root property when format is json`,
8093
+ path,
8094
+ 1
8095
+ ));
8096
+ return { nodes: [], edges: [], diagnostics };
8097
+ }
8098
+ let parsed;
8099
+ try {
8100
+ parsed = JSON.parse(raw);
8101
+ } catch (error) {
8102
+ diagnostics.push(issue(
8103
+ "INVALID_JSON",
8104
+ `JSON artifact ${path} is not valid JSON: ${error.message}`,
8105
+ path,
8106
+ 1
8107
+ ));
8108
+ return { nodes: [], edges: [], diagnostics };
8109
+ }
8110
+ if (!isJsonObject(parsed)) {
8111
+ diagnostics.push(issue(
8112
+ "INVALID_JSON_ROOT",
8113
+ `JSON artifact ${path} must be one root object, got ${jsonRootKind(parsed)}`,
8114
+ path,
8115
+ 1
8116
+ ));
8117
+ return { nodes: [], edges: [], diagnostics };
8118
+ }
8119
+ if (!Object.prototype.hasOwnProperty.call(parsed, idField)) {
8120
+ diagnostics.push(issue(
8121
+ "ARTIFACT_ID_MISSING",
8122
+ `Artifact of type ${type} at ${path} has no root property ${idField}`,
8123
+ path,
8124
+ 1,
8125
+ { severity: "warning" }
8126
+ ));
8127
+ return { nodes: [], edges: [], diagnostics };
8128
+ }
8129
+ const idValue = parsed[idField];
8130
+ if (typeof idValue !== "string") {
8131
+ diagnostics.push(issue(
8132
+ "INVALID_ID",
8133
+ `Artifact of type ${type} at ${path} field ${idField} must be a non-empty string`,
8134
+ path,
8135
+ 1
8136
+ ));
8137
+ return { nodes: [], edges: [], diagnostics };
8138
+ }
8139
+ if (idValue.trim() === "") {
8140
+ diagnostics.push(issue(
8141
+ "ARTIFACT_ID_MISSING",
8142
+ `Artifact of type ${type} at ${path} field ${idField} must be a non-empty string`,
8143
+ path,
8144
+ 1,
8145
+ { severity: "warning" }
8146
+ ));
8147
+ return { nodes: [], edges: [], diagnostics };
8148
+ }
8149
+ const code = idValue;
8150
+ const idPattern = schema.idPatterns[type];
8151
+ if (idPattern && !new RegExp(idPattern).test(code)) {
8152
+ diagnostics.push(issue(
8153
+ "INVALID_ID",
8154
+ `Artifact ${type}:${code} field ${idField} does not match ${idPattern}`,
8155
+ path,
8156
+ 1,
8157
+ { node: toUid(type, code) }
8158
+ ));
8159
+ }
8160
+ const node = {
8161
+ type,
8162
+ code,
8163
+ title: code,
8164
+ path,
8165
+ line: 1
8166
+ };
8167
+ const relations = jsonConfiguredRelations(type, path, parsed, schema, toUid(type, code));
8168
+ diagnostics.push(...relations.diagnostics);
8169
+ return { nodes: [node], edges: relations.edges, diagnostics };
8170
+ }
8171
+ function readJsonRelation(record, field) {
8172
+ const segments = field.split(".");
8173
+ if (segments.some((segment) => segment.length === 0)) {
8174
+ return { status: "illegal-path" };
8175
+ }
8176
+ let current = record;
8177
+ for (let index = 0; index < segments.length; index += 1) {
8178
+ const key = segments[index] ?? "";
8179
+ if (!isJsonObject(current)) {
8180
+ return { status: "type-error", at: segments.slice(0, index).join(".") };
8181
+ }
8182
+ if (!Object.prototype.hasOwnProperty.call(current, key)) {
8183
+ return { status: "absent" };
8184
+ }
8185
+ const next = current[key];
8186
+ const last = index === segments.length - 1;
8187
+ if (!last && !isJsonObject(next)) {
8188
+ return { status: "type-error", at: segments.slice(0, index + 1).join(".") };
8189
+ }
8190
+ current = next;
8191
+ }
8192
+ return { status: "value", value: current };
8193
+ }
8194
+ function jsonRelationTerminal(value, field, path, sourceUid, diagnostics) {
8195
+ const message = `Relation field ${field} in ${path} must be a non-empty string or an array of non-empty strings`;
8196
+ if (typeof value === "string") {
8197
+ if (value.trim() === "") {
8198
+ diagnostics.push(issue("RELATION_VALUE_TYPE", message, path, 1, { node: sourceUid }));
8199
+ return [];
8200
+ }
8201
+ return [value];
8202
+ }
8203
+ if (Array.isArray(value)) {
8204
+ const refs = [];
8205
+ for (const item of value) {
8206
+ if (typeof item !== "string" || item.trim() === "") {
8207
+ diagnostics.push(issue(
8208
+ "RELATION_VALUE_TYPE",
8209
+ `Relation field ${field} in ${path} must contain only non-empty strings`,
8210
+ path,
8211
+ 1,
8212
+ { node: sourceUid }
8213
+ ));
8214
+ continue;
8215
+ }
8216
+ refs.push(item);
8217
+ }
8218
+ return refs;
8219
+ }
8220
+ diagnostics.push(issue("RELATION_VALUE_TYPE", message, path, 1, { node: sourceUid }));
8221
+ return [];
8222
+ }
8223
+ function jsonConfiguredRelations(type, path, record, schema, sourceUid) {
8224
+ const edges = [];
8225
+ const diagnostics = [];
8226
+ for (const [kind, spec] of Object.entries(schema.relationSemantics ?? {})) {
8227
+ for (const field of spec.fields) {
8228
+ const read = readJsonRelation(record, field);
8229
+ if (read.status === "absent") continue;
8230
+ if (read.status === "illegal-path") {
8231
+ diagnostics.push(issue(
8232
+ "INVALID_RELATION_FIELD",
8233
+ `Relation field ${field} is not a fixed path of own properties`,
8234
+ path,
8235
+ 1,
8236
+ { node: sourceUid }
8237
+ ));
8238
+ continue;
8239
+ }
8240
+ if (read.status === "type-error") {
8241
+ diagnostics.push(issue(
8242
+ "RELATION_VALUE_TYPE",
8243
+ `Relation field ${field} in ${path} cannot be read at ${read.at}: expected an object`,
8244
+ path,
8245
+ 1,
8246
+ { node: sourceUid }
8247
+ ));
8248
+ continue;
8249
+ }
8250
+ const values = jsonRelationTerminal(read.value, field, path, sourceUid, diagnostics);
8251
+ appendConfiguredRelationEdges(sourceUid, kind, field, values, spec, schema, path, "json", edges, diagnostics);
8252
+ }
8253
+ }
8254
+ return { edges, diagnostics };
8255
+ }
7706
8256
  function parseGenericMarkdown(type, path, raw, schema) {
7707
8257
  const diagnostics = [];
7708
8258
  const ext = extname(path).toLowerCase();
@@ -7821,38 +8371,18 @@ function parseConfiguredRelations(type, path, raw, nodes, schema) {
7821
8371
  const diagnostics = [];
7822
8372
  for (const [kind, spec] of Object.entries(schema.relationSemantics ?? {})) {
7823
8373
  for (const field of spec.fields) {
7824
- for (const value of toArray(data[field])) {
7825
- const parsed = parseConfiguredRelationTarget(value, spec, schema);
7826
- if (!parsed?.code) continue;
7827
- const matchingTargetTypes = parsed.targetType ? [] : relationTargetTypeMatches(parsed.code, spec.targetTypes, schema);
7828
- const targetType = parsed.targetType ?? inferRelationTargetType(parsed.code, spec.targetTypes, schema);
7829
- if (!parsed.targetType && matchingTargetTypes.length > 1) {
7830
- diagnostics.push(issue(
7831
- "AMBIGUOUS_RELATION_TARGET",
7832
- `${sourceUid} relation ${kind} target "${parsed.code}" matches ${matchingTargetTypes.join(", ")}; use a qualified type:id reference`,
7833
- path,
7834
- 1,
7835
- { node: sourceUid }
7836
- ));
7837
- }
7838
- const targetUid = targetType ? toUid(targetType, parsed.code) : `resolve:${parsed.code}`;
7839
- if (targetType) {
7840
- const pattern = schema.idPatterns[targetType];
7841
- if (pattern && !new RegExp(pattern).test(parsed.code)) {
7842
- diagnostics.push(issue(
7843
- "FORMAT_ERROR",
7844
- `${sourceUid} has invalid ${targetType} reference "${parsed.code}" in field ${field} (expected ${pattern})`,
7845
- path,
7846
- 1,
7847
- { node: sourceUid }
7848
- ));
7849
- }
7850
- }
7851
- edges.push({
7852
- ...edge(sourceUid, targetUid, kind, "frontmatter", path, 1),
7853
- ...parsed.sections.length > 0 ? { attrs: { sections: parsed.sections } } : {}
7854
- });
7855
- }
8374
+ appendConfiguredRelationEdges(
8375
+ sourceUid,
8376
+ kind,
8377
+ field,
8378
+ toArray(data[field]),
8379
+ spec,
8380
+ schema,
8381
+ path,
8382
+ "frontmatter",
8383
+ edges,
8384
+ diagnostics
8385
+ );
7856
8386
  }
7857
8387
  }
7858
8388
  const external = getExternalEntryInfo({
@@ -7871,6 +8401,40 @@ function parseConfiguredRelations(type, path, raw, nodes, schema) {
7871
8401
  }
7872
8402
  return { edges, diagnostics };
7873
8403
  }
8404
+ function appendConfiguredRelationEdges(sourceUid, kind, field, values, spec, schema, path, edgeSource, edges, diagnostics) {
8405
+ for (const value of values) {
8406
+ const parsed = parseConfiguredRelationTarget(value, spec, schema);
8407
+ if (!parsed?.code) continue;
8408
+ const matchingTargetTypes = parsed.targetType ? [] : relationTargetTypeMatches(parsed.code, spec.targetTypes, schema);
8409
+ const targetType = parsed.targetType ?? inferRelationTargetType(parsed.code, spec.targetTypes, schema);
8410
+ if (!parsed.targetType && matchingTargetTypes.length > 1) {
8411
+ diagnostics.push(issue(
8412
+ "AMBIGUOUS_RELATION_TARGET",
8413
+ `${sourceUid} relation ${kind} target "${parsed.code}" matches ${matchingTargetTypes.join(", ")}; use a qualified type:id reference`,
8414
+ path,
8415
+ 1,
8416
+ { node: sourceUid }
8417
+ ));
8418
+ }
8419
+ const targetUid = targetType ? toUid(targetType, parsed.code) : `resolve:${parsed.code}`;
8420
+ if (targetType) {
8421
+ const pattern = schema.idPatterns[targetType];
8422
+ if (pattern && !new RegExp(pattern).test(parsed.code)) {
8423
+ diagnostics.push(issue(
8424
+ "FORMAT_ERROR",
8425
+ `${sourceUid} has invalid ${targetType} reference "${parsed.code}" in field ${field} (expected ${pattern})`,
8426
+ path,
8427
+ 1,
8428
+ { node: sourceUid }
8429
+ ));
8430
+ }
8431
+ }
8432
+ edges.push({
8433
+ ...edge(sourceUid, targetUid, kind, edgeSource, path, 1),
8434
+ ...parsed.sections.length > 0 ? { attrs: { sections: parsed.sections } } : {}
8435
+ });
8436
+ }
8437
+ }
7874
8438
  function parseConfiguredRelationTarget(value, spec, schema) {
7875
8439
  if (typeof value === "string" || typeof value === "number") {
7876
8440
  const raw = String(value).trim();
@@ -8061,7 +8625,7 @@ function parseDecisions(path, raw) {
8061
8625
  }
8062
8626
  function isTestFile(filePath) {
8063
8627
  const normalized = filePath.replace(/\\/g, "/");
8064
- const name = basename4(normalized);
8628
+ const name = basename5(normalized);
8065
8629
  if (/\.(test|spec)\.[^.]+$/.test(name)) return true;
8066
8630
  if (/(^|\/)(tests|test|__tests__)\//.test(normalized)) return true;
8067
8631
  if (/\w+Tests?\.java$/.test(name)) return true;
@@ -8376,10 +8940,10 @@ function parseE2eTest(path, raw) {
8376
8940
  const starts = extractE2eTestCaseStarts(lines);
8377
8941
  const nodes = [];
8378
8942
  const edges = [];
8379
- const batch = String(data.test_batch ?? basename4(path, extname(path))).trim();
8943
+ const batch = String(data.test_batch ?? basename5(path, extname(path))).trim();
8380
8944
  const frontmatterScenarios = toArray(data.related_scenarios).map((value) => String(value).trim()).filter(Boolean);
8381
8945
  const scopeFeatures = extractCodes(String(data.scope ?? ""), "feature");
8382
- const frontmatterFeatures = [.../* @__PURE__ */ new Set([...Object.keys(asRecord(data.ac_coverage)), ...scopeFeatures])];
8946
+ const frontmatterFeatures = [.../* @__PURE__ */ new Set([...Object.keys(asRecord2(data.ac_coverage)), ...scopeFeatures])];
8383
8947
  const frontmatterDecisions = toArray(data.related_decisions).map((value) => String(value).trim()).filter(Boolean);
8384
8948
  const frontmatterEntities = toArray(data.related_entities).map((value) => String(value).trim()).filter(Boolean);
8385
8949
  for (let index = 0; index < starts.length; index += 1) {
@@ -8439,7 +9003,7 @@ function parseE2eRegistry(path, raw) {
8439
9003
  data = { parseError: error.message };
8440
9004
  }
8441
9005
  return {
8442
- nodes: [{ type: "e2e_registry", code: basename4(path, extname(path)), title: "E2E Test Registry", path, line: 1, attrs: data }],
9006
+ nodes: [{ type: "e2e_registry", code: basename5(path, extname(path)), title: "E2E Test Registry", path, line: 1, attrs: data }],
8443
9007
  edges: []
8444
9008
  };
8445
9009
  }
@@ -9247,13 +9811,13 @@ function markdownRelationOccurrences(path, scenario, block, codeLines, label, ta
9247
9811
  return result;
9248
9812
  }
9249
9813
  function relationOccurrences2(node, field, targetType) {
9250
- const relationRecord = asRecord(node.attrs?.relationOccurrences);
9814
+ const relationRecord = asRecord2(node.attrs?.relationOccurrences);
9251
9815
  const rawOccurrences = toArray(relationRecord[field]);
9252
9816
  return rawOccurrences.flatMap((value) => {
9253
9817
  if (typeof value === "string") {
9254
9818
  return [{ field, targetType, target: value, path: node.path, line: node.line }];
9255
9819
  }
9256
- const record = asRecord(value);
9820
+ const record = asRecord2(value);
9257
9821
  const target = String(record.target ?? "").trim();
9258
9822
  if (!target) {
9259
9823
  return [];
@@ -9360,7 +9924,7 @@ function validateE2eTests(graph) {
9360
9924
  issues.push(issue("E2E_REQUIRED_FRONTMATTER", `${node.uid} missing required frontmatter ${field}`, node.path, 1, { node: node.uid, severity: "warning" }));
9361
9925
  }
9362
9926
  }
9363
- const fields = asRecord(attrs.tcFields);
9927
+ const fields = asRecord2(attrs.tcFields);
9364
9928
  const requiredTcFields = [
9365
9929
  ["\u6807\u9898", node.title],
9366
9930
  ["\u524D\u7F6E\u6761\u4EF6", fields["\u524D\u7F6E\u6761\u4EF6"]],
@@ -9410,7 +9974,7 @@ function validateE2eTests(graph) {
9410
9974
  }
9411
9975
  for (const [path, nodes] of nodesByPath) {
9412
9976
  const first = nodes[0];
9413
- const declared = flattenAcCoverage(asRecord(first.attrs?.ac_coverage));
9977
+ const declared = flattenAcCoverage(asRecord2(first.attrs?.ac_coverage));
9414
9978
  const covered = new Set(nodes.flatMap((node) => toArray(node.attrs?.coveredFeatures).map((value) => {
9415
9979
  const ref = value;
9416
9980
  return `${String(ref.feature)}:${String(ref.ac)}`;
@@ -9454,7 +10018,7 @@ function validateE2eRegistry(graph) {
9454
10018
  const first = actualNodes[0];
9455
10019
  compareRegistryValue(issues, registry, batch, "batch_id", first.attrs?.test_batch);
9456
10020
  compareRegistryValue(issues, registry, batch, "scope", first.attrs?.scope);
9457
- compareRegistryAcCoverage(issues, registry, batch, asRecord(first.attrs?.ac_coverage));
10021
+ compareRegistryAcCoverage(issues, registry, batch, asRecord2(first.attrs?.ac_coverage));
9458
10022
  compareRegistryArray(issues, registry, batch, "related_scenarios", toArray(first.attrs?.related_scenarios).map((value) => String(value)));
9459
10023
  compareRegistryValue(issues, registry, batch, "test_case_count", actualNodes.filter((node) => node.attrs?.fileLevelOnly !== true).length);
9460
10024
  }
@@ -9477,10 +10041,10 @@ async function validateExecutableTraceability(root, config) {
9477
10041
  const tcKeyToFields = /* @__PURE__ */ new Map();
9478
10042
  const mdBatches = /* @__PURE__ */ new Set();
9479
10043
  for (const relPath of e2eFiles) {
9480
- const raw = await readFile4(join10(root, relPath), "utf-8");
10044
+ const raw = await readFile4(join11(root, relPath), "utf-8");
9481
10045
  const parsed = matter(raw);
9482
10046
  const data = parsed.data;
9483
- const batch = String(data.test_batch ?? basename4(relPath, extname(relPath))).trim();
10047
+ const batch = String(data.test_batch ?? basename5(relPath, extname(relPath))).trim();
9484
10048
  const lines = raw.split(/\r?\n/);
9485
10049
  const tcStarts = extractE2eTestCaseStarts(lines);
9486
10050
  for (let i = 0; i < tcStarts.length; i += 1) {
@@ -9519,7 +10083,7 @@ async function validateExecutableTraceability(root, config) {
9519
10083
  const tcAnnotationRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+?)\s+\[(\w+)\]/;
9520
10084
  const tcAnnotationNoLevelRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+)/;
9521
10085
  for (const specFile of specFiles) {
9522
- const fullSpecPath = join10(root, specFile);
10086
+ const fullSpecPath = join11(root, specFile);
9523
10087
  let content;
9524
10088
  try {
9525
10089
  content = await readFile4(fullSpecPath, "utf-8");
@@ -9601,7 +10165,7 @@ async function validateExecutableTraceability(root, config) {
9601
10165
  if (entry.testId) {
9602
10166
  let content;
9603
10167
  try {
9604
- content = await readFile4(join10(root, normalizedRefFile), "utf-8");
10168
+ content = await readFile4(join11(root, normalizedRefFile), "utf-8");
9605
10169
  } catch {
9606
10170
  continue;
9607
10171
  }
@@ -9780,11 +10344,11 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9780
10344
  const chainTypeBreakdown = {};
9781
10345
  const tcFieldsMap = new Map(e2eNodes.map((node) => [
9782
10346
  node.code,
9783
- asRecord(node.attrs?.tcFields)
10347
+ asRecord2(node.attrs?.tcFields)
9784
10348
  ]));
9785
10349
  for (const node of e2eNodes) {
9786
10350
  const tcKey = node.code;
9787
- const fields = tcFieldsMap.get(tcKey) ?? asRecord(node.attrs?.tcFields);
10351
+ const fields = tcFieldsMap.get(tcKey) ?? asRecord2(node.attrs?.tcFields);
9788
10352
  const execRef = String(fields["executable_ref"] ?? "").trim();
9789
10353
  if (execRef && !isPendingExecutableRef(execRef)) {
9790
10354
  withExecutableRef++;
@@ -9814,8 +10378,8 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9814
10378
  }
9815
10379
  }
9816
10380
  for (const node of e2eNodes) {
9817
- const fields = tcFieldsMap.get(node.code) ?? asRecord(node.attrs?.tcFields);
9818
- const acCoverage = asRecord(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10381
+ const fields = tcFieldsMap.get(node.code) ?? asRecord2(node.attrs?.tcFields);
10382
+ const acCoverage = asRecord2(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
9819
10383
  for (const feature of Object.keys(acCoverage)) {
9820
10384
  acCoveredFeatures.add(feature);
9821
10385
  }
@@ -9827,7 +10391,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9827
10391
  const runners = (await loadConfig(root)).e2e?.runners ?? [];
9828
10392
  const allProjectFiles = await walkFiles(root);
9829
10393
  for (const node of e2eNodes) {
9830
- const fields = tcFieldsMap.get(node.code) ?? asRecord(node.attrs?.tcFields);
10394
+ const fields = tcFieldsMap.get(node.code) ?? asRecord2(node.attrs?.tcFields);
9831
10395
  const status = String(fields["status"] ?? "").trim().toLowerCase();
9832
10396
  const execRef = String(fields["executable_ref"] ?? "").trim();
9833
10397
  if (status !== "verified") continue;
@@ -9836,7 +10400,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9836
10400
  let hasActiveE2eRef = false;
9837
10401
  for (const entry of parseExecutableRefLines(execRef)) {
9838
10402
  const normalized = resolveExecutableRefFile(entry.file, allProjectFiles);
9839
- if (!normalized || !existsSync3(join10(root, normalized))) continue;
10403
+ if (!normalized || !existsSync3(join11(root, normalized))) continue;
9840
10404
  const accepting = await getAcceptingRunners(root, normalized, runners);
9841
10405
  if (accepting.some((runner) => runner.kind === "e2e")) {
9842
10406
  hasActiveE2eRef = true;
@@ -9848,7 +10412,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9848
10412
  for (const scenario of relatedScenarios) {
9849
10413
  verifiedScenarios.add(scenario);
9850
10414
  }
9851
- const acCoverage = asRecord(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10415
+ const acCoverage = asRecord2(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
9852
10416
  for (const feature of Object.keys(acCoverage)) {
9853
10417
  verifiedFeatures.add(feature);
9854
10418
  }
@@ -9895,13 +10459,13 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9895
10459
  const acCoverageRateByFeature = {};
9896
10460
  const featureAcMap = /* @__PURE__ */ new Map();
9897
10461
  for (const node of featureNodes) {
9898
- const acs = parseAcceptanceCriteria(await readFile4(join10(root, node.path), "utf-8"));
10462
+ const acs = parseAcceptanceCriteria(await readFile4(join11(root, node.path), "utf-8"));
9899
10463
  featureAcMap.set(node.code, new Set(acs));
9900
10464
  }
9901
10465
  const coveredAcByFeature = /* @__PURE__ */ new Map();
9902
10466
  for (const node of e2eNodes) {
9903
- const fields = tcFieldsMap.get(node.code) ?? asRecord(node.attrs?.tcFields);
9904
- const acCoverage = asRecord(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10467
+ const fields = tcFieldsMap.get(node.code) ?? asRecord2(node.attrs?.tcFields);
10468
+ const acCoverage = asRecord2(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
9905
10469
  for (const [feature, acs] of Object.entries(acCoverage)) {
9906
10470
  const existing = coveredAcByFeature.get(feature) ?? /* @__PURE__ */ new Set();
9907
10471
  for (const ac of toArray(acs)) {
@@ -9943,11 +10507,11 @@ async function generateE2eRegistry(root, opts) {
9943
10507
  const batchIds = /* @__PURE__ */ new Set();
9944
10508
  let totalTestCases = 0;
9945
10509
  for (const file of files) {
9946
- const filePath = join10(root, file);
10510
+ const filePath = join11(root, file);
9947
10511
  const raw = await readFile4(filePath, "utf-8");
9948
10512
  const parsed = matter(raw);
9949
10513
  const data = parsed.data;
9950
- const batch = String(data.test_batch ?? basename4(file, extname(file))).trim();
10514
+ const batch = String(data.test_batch ?? basename5(file, extname(file))).trim();
9951
10515
  const relPath = file;
9952
10516
  const scope = String(data.scope ?? "").trim();
9953
10517
  const acCoverage = normalizeAcCoverageForRegistry(data.ac_coverage);
@@ -10069,7 +10633,7 @@ async function validatePartialRustEvidence(tcFields, tcKey, root, allFiles) {
10069
10633
  if (!normalizedPath) {
10070
10634
  return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
10071
10635
  }
10072
- const fullPath = join10(root, normalizedPath);
10636
+ const fullPath = join11(root, normalizedPath);
10073
10637
  let content;
10074
10638
  try {
10075
10639
  content = await readFile4(fullPath, "utf-8");
@@ -10106,7 +10670,7 @@ function detectTestLevel(specFile, content) {
10106
10670
  }
10107
10671
  function resolveExecutableRefFile(refFile, allFiles) {
10108
10672
  const normalized = refFile.replace(/\\/g, "/").replace(/^\.\//, "");
10109
- if (!normalized || isAbsolute5(refFile) || normalized.split("/").includes("..")) {
10673
+ if (!normalized || isAbsolute6(refFile) || normalized.split("/").includes("..")) {
10110
10674
  return void 0;
10111
10675
  }
10112
10676
  if (allFiles.includes(normalized)) {
@@ -10281,7 +10845,7 @@ function flattenAcCoverage(value) {
10281
10845
  return Object.entries(value).flatMap(([feature, refs]) => toArray(refs).map((ac) => ({ feature, ac: String(ac).replace(/^AC[-\s]?(\d+)$/i, (_match, digits) => `AC${Number(digits)}`) })));
10282
10846
  }
10283
10847
  function needsDesktopChainWarning(node) {
10284
- const tcFields = asRecord(node.attrs?.tcFields);
10848
+ const tcFields = asRecord2(node.attrs?.tcFields);
10285
10849
  const chainType = String(tcFields["chain_type"] ?? "").trim().toLowerCase();
10286
10850
  if (chainType && VALID_CHAIN_TYPES.has(chainType) && chainType !== "desktop_chain" || chainType in DEPRECATED_CHAIN_TYPE_ALIASES) {
10287
10851
  return false;
@@ -10338,7 +10902,7 @@ function compareRegistryAcCoverage(issues, registry, batch, actual) {
10338
10902
  issues.push(issue("E2E_REGISTRY_MISMATCH", `registry batch ${String(batch.batch_id ?? "")} ac_coverage cannot be determined`, registry.path, registry.line, { node: registry.uid, severity: "warning" }));
10339
10903
  return;
10340
10904
  }
10341
- if (normalizeAcCoverage(asRecord(batch.ac_coverage)) !== normalizeAcCoverage(actual)) {
10905
+ if (normalizeAcCoverage(asRecord2(batch.ac_coverage)) !== normalizeAcCoverage(actual)) {
10342
10906
  issues.push(issue("E2E_REGISTRY_MISMATCH", `registry batch ${String(batch.batch_id ?? "")} ac_coverage does not match actual file`, registry.path, registry.line, { node: registry.uid, severity: "warning" }));
10343
10907
  }
10344
10908
  }
@@ -10353,7 +10917,7 @@ function groupBy(values, key) {
10353
10917
  }
10354
10918
  return result;
10355
10919
  }
10356
- function asRecord(value) {
10920
+ function asRecord2(value) {
10357
10921
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
10358
10922
  }
10359
10923
  function isEmptyValue(value) {
@@ -10412,7 +10976,7 @@ function normalizeDesignCode(value) {
10412
10976
  if (!raw) {
10413
10977
  return "";
10414
10978
  }
10415
- return basename4(raw, extname(raw));
10979
+ return basename5(raw, extname(raw));
10416
10980
  }
10417
10981
  function toUid(type, code) {
10418
10982
  return `${type}:${code}`;
@@ -10688,7 +11252,7 @@ function resolveArtifactContext(graph, opts) {
10688
11252
  }
10689
11253
  if (root) {
10690
11254
  for (const ap of ALWAYS_PRESENT_ITEMS) {
10691
- const fullPath = join10(root, ap.path);
11255
+ const fullPath = join11(root, ap.path);
10692
11256
  let stat2;
10693
11257
  try {
10694
11258
  stat2 = statSync(fullPath);
@@ -10930,7 +11494,7 @@ function formatContextMarkdown(manifest) {
10930
11494
  }
10931
11495
  return lines.join("\n");
10932
11496
  }
10933
- var TARGET_ARTIFACT_TYPES, NON_TARGET_ROLES, DEFAULT_SCHEMA, EMPTY_RELATION_FIELD_VALUES, VALID_TC_STATUSES, VALID_CHAIN_TYPES, DEPRECATED_CHAIN_TYPE_ALIASES, CONTEXT_CATEGORIES, TIER_ORDER;
11497
+ var TARGET_ARTIFACT_TYPES, NON_TARGET_ROLES, DEFAULT_SCHEMA, SPECIALIZED_PARSER_TYPES, EMPTY_RELATION_FIELD_VALUES, VALID_TC_STATUSES, VALID_CHAIN_TYPES, DEPRECATED_CHAIN_TYPE_ALIASES, CONTEXT_CATEGORIES, TIER_ORDER;
10934
11498
  var init_index = __esm({
10935
11499
  "src/index.ts"() {
10936
11500
  init_packet_constants();
@@ -10951,6 +11515,7 @@ var init_index = __esm({
10951
11515
  init_git_changes();
10952
11516
  init_git_hook_path();
10953
11517
  init_hook_installer();
11518
+ init_professional_conclusion();
10954
11519
  init_review_result_validator();
10955
11520
  init_contract_kernel();
10956
11521
  init_restructure();
@@ -11003,6 +11568,33 @@ var init_index = __esm({
11003
11568
  runners: []
11004
11569
  }
11005
11570
  };
11571
+ SPECIALIZED_PARSER_TYPES = /* @__PURE__ */ new Set([
11572
+ "feature",
11573
+ "scenario",
11574
+ "entity",
11575
+ "decision",
11576
+ "test",
11577
+ "design",
11578
+ "e2e_test",
11579
+ "e2e_registry",
11580
+ "rule-golden-cases",
11581
+ "test-strategy",
11582
+ "traceability-matrix-v2",
11583
+ "traceability-version-lock",
11584
+ "interface_contracts",
11585
+ "data_contracts",
11586
+ "application_state_machines",
11587
+ "error_model",
11588
+ "domain-glossary",
11589
+ "bounded-context-map",
11590
+ "domain-invariants",
11591
+ "generation-packet-spec",
11592
+ "report-contracts",
11593
+ "verification-fixtures",
11594
+ "ui-flow-contracts",
11595
+ "non-functional-budgets",
11596
+ "implementation-blueprint"
11597
+ ]);
11006
11598
  EMPTY_RELATION_FIELD_VALUES = /* @__PURE__ */ new Set(["\u65E0", "none", "n/a", "-"]);
11007
11599
  VALID_TC_STATUSES = /* @__PURE__ */ new Set(["created", "automated", "verified", "waived"]);
11008
11600
  VALID_CHAIN_TYPES = /* @__PURE__ */ new Set([
@@ -11050,7 +11642,7 @@ export {
11050
11642
  BASELINE_CONSTRAINTS,
11051
11643
  BASELINE_CONSTRAINTS_COUNT,
11052
11644
  BASELINE_ITEMS_COUNT,
11053
- CONTRACTS_PACKAGE_NAME,
11645
+ CONTRACTS_PACKAGE_NAME2 as CONTRACTS_PACKAGE_NAME,
11054
11646
  CONTRACT_ERROR_CODES,
11055
11647
  ContractCatalog,
11056
11648
  ContractError,
@@ -11060,7 +11652,11 @@ export {
11060
11652
  E2E_NORMALIZER_CONFIG,
11061
11653
  FILE_SET_RESULT_OBJECT,
11062
11654
  FOUNDATION_PACKAGE_NAME,
11655
+ GRAPH_DOMAIN_CODES,
11656
+ GRAPH_PROVIDER_ENTRY,
11657
+ GRAPH_PROVIDER_ID,
11063
11658
  MIN_PROMPT_CHARS,
11659
+ PROFESSIONAL_CONCLUSION_OBJECT,
11064
11660
  RESTRUCTURE_MAX_OPERATIONS,
11065
11661
  RESTRUCTURE_MAX_TOTAL_BYTES,
11066
11662
  RESTRUCTURE_PLAN_SCHEMA_VERSION,
@@ -11096,7 +11692,7 @@ export {
11096
11692
  createRestructureRootBinding,
11097
11693
  createRestructureValidationCallback,
11098
11694
  digestRestructureValue,
11099
- dirname6 as dirname,
11695
+ dirname7 as dirname,
11100
11696
  discoverAndAuditPackets,
11101
11697
  discoverTargets,
11102
11698
  doctorArtifactChain,
@@ -11160,6 +11756,8 @@ export {
11160
11756
  resolveNodeTimeView,
11161
11757
  resolveRealRoot,
11162
11758
  restructureBoundaryFindings,
11759
+ runCheckProfessional,
11760
+ runReadProof,
11163
11761
  scanArtifacts,
11164
11762
  traceVersion,
11165
11763
  updateVersionLock,