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