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.cjs CHANGED
@@ -3411,11 +3411,10 @@ async function detectPnpmVersion() {
3411
3411
  return void 0;
3412
3412
  }
3413
3413
  }
3414
- function bindingInstallBase(cli, root) {
3414
+ function bindingInstallBase(cli, _root) {
3415
3415
  if (!cli.path || !cli.source) return void 0;
3416
3416
  switch (cli.source) {
3417
3417
  case "node_modules":
3418
- return (0, import_node_path7.join)(root, "package.json");
3419
3418
  case "plugin-bundled":
3420
3419
  case "path":
3421
3420
  case "legacy":
@@ -3424,11 +3423,10 @@ function bindingInstallBase(cli, root) {
3424
3423
  return void 0;
3425
3424
  }
3426
3425
  }
3427
- function bindingInstallRoot(cli, root) {
3426
+ function bindingInstallRoot(cli, _root) {
3428
3427
  if (!cli.path || !cli.source) return void 0;
3429
3428
  switch (cli.source) {
3430
3429
  case "node_modules":
3431
- return root;
3432
3430
  case "plugin-bundled":
3433
3431
  case "path":
3434
3432
  case "legacy":
@@ -3956,6 +3954,379 @@ var init_hook_installer = __esm({
3956
3954
  }
3957
3955
  });
3958
3956
 
3957
+ // src/professional-conclusion.ts
3958
+ async function loadContracts() {
3959
+ return await import(CONTRACTS_PACKAGE_NAME);
3960
+ }
3961
+ async function loadHarness() {
3962
+ return await import("skill-family-harness-node");
3963
+ }
3964
+ function providerVersion() {
3965
+ const anchor = typeof __filename === "string" ? __filename : import_meta2.url;
3966
+ const parsed = (0, import_node_module2.createRequire)(anchor)("../package.json");
3967
+ if (typeof parsed.version !== "string" || parsed.version.length === 0) {
3968
+ throw new Error("artifact-graph package.json is missing version");
3969
+ }
3970
+ return parsed.version;
3971
+ }
3972
+ function errorMessage(error) {
3973
+ return error instanceof Error ? error.message : String(error);
3974
+ }
3975
+ function harnessKind(error) {
3976
+ if (error === null || typeof error !== "object" || !("details" in error)) {
3977
+ return void 0;
3978
+ }
3979
+ const details = error.details;
3980
+ return typeof details?.kind === "string" ? details.kind : void 0;
3981
+ }
3982
+ async function missingRequiredConfig(root) {
3983
+ const configPath = (0, import_node_path10.join)(root, "artifact-graph.config.yaml");
3984
+ try {
3985
+ await (0, import_promises6.access)(configPath);
3986
+ return void 0;
3987
+ } catch (error) {
3988
+ if (error.code === "ENOENT") {
3989
+ return `required configuration is missing: ${configPath}`;
3990
+ }
3991
+ return errorMessage(error);
3992
+ }
3993
+ }
3994
+ async function runValidate(root) {
3995
+ const config = await loadConfig(root);
3996
+ const graph = await scanArtifacts(root, config);
3997
+ const issues = validateGraph(graph, config);
3998
+ issues.push(...await validateScenarioPrdLinkIndex(root, graph));
3999
+ issues.push(...await validateExecutableTraceability(root, config));
4000
+ const includeCoverage = config.e2e?.executable_ref_warning !== void 0 || config.e2e?.executable_ref_error !== void 0;
4001
+ if (includeCoverage) {
4002
+ const e2eConfig = config.e2e ?? {};
4003
+ const coverageStats = await computeE2eCoverageStats(graph, root, {
4004
+ executableRefWarning: e2eConfig.executable_ref_warning,
4005
+ executableRefError: e2eConfig.executable_ref_error,
4006
+ reportUncoveredScenarios: e2eConfig.report_uncovered_scenarios,
4007
+ reportUncoveredFeatures: e2eConfig.report_uncovered_features,
4008
+ scenarioWaivers: e2eConfig.scenario_waivers,
4009
+ featureWaivers: e2eConfig.feature_waivers
4010
+ });
4011
+ for (const msg of coverageStats.thresholdWarnings) {
4012
+ issues.push({
4013
+ code: "E2E_COVERAGE_WARNING",
4014
+ severity: "warning",
4015
+ message: msg,
4016
+ path: "e2e-coverage",
4017
+ line: 1
4018
+ });
4019
+ }
4020
+ for (const msg of coverageStats.thresholdErrors) {
4021
+ issues.push({
4022
+ code: "E2E_COVERAGE_ERROR",
4023
+ severity: "error",
4024
+ message: msg,
4025
+ path: "e2e-coverage",
4026
+ line: 1
4027
+ });
4028
+ }
4029
+ }
4030
+ return { name: CHECK_VALIDATE, status: "completed", issues };
4031
+ }
4032
+ async function runLockAudit(root) {
4033
+ const result = await auditVersionLock(root);
4034
+ return { name: CHECK_LOCK, status: "completed", issues: result.issues };
4035
+ }
4036
+ async function runCoverage(root) {
4037
+ const report = await computeCoverageBoundary(root);
4038
+ return {
4039
+ name: CHECK_COVERAGE,
4040
+ status: "completed",
4041
+ issues: [],
4042
+ coverage: {
4043
+ assessment: report.graphHealth.assessment,
4044
+ changedPathScope: report.scanCoverage.changedPathScope,
4045
+ behaviorStatus: report.behaviorVerification.status
4046
+ }
4047
+ };
4048
+ }
4049
+ async function settleCheck(name, run) {
4050
+ try {
4051
+ return await run();
4052
+ } catch (error) {
4053
+ return { name, status: "not-performed", issues: [], reason: errorMessage(error) };
4054
+ }
4055
+ }
4056
+ function mapDomain(checks) {
4057
+ const completed = checks.filter((check) => check.status === "completed");
4058
+ const missing = checks.filter((check) => check.status === "not-performed");
4059
+ const hasFindings = completed.some((check) => check.issues.length > 0);
4060
+ if (completed.length === 0) {
4061
+ return {
4062
+ code: GRAPH_DOMAIN_CODES.UNAVAILABLE,
4063
+ completion: "not-performed",
4064
+ summary: "Graph checks did not start because configuration, runtime, or inputs were unavailable."
4065
+ };
4066
+ }
4067
+ if (hasFindings) {
4068
+ return {
4069
+ code: GRAPH_DOMAIN_CODES.FINDINGS,
4070
+ completion: missing.length > 0 ? "partial" : "complete",
4071
+ summary: "At least one completed graph check reported issues. Original issues are preserved."
4072
+ };
4073
+ }
4074
+ if (missing.length > 0) {
4075
+ return {
4076
+ code: GRAPH_DOMAIN_CODES.INCOMPLETE,
4077
+ completion: "partial",
4078
+ summary: "Some declared graph checks completed without findings; others lacked input or could not finish."
4079
+ };
4080
+ }
4081
+ return {
4082
+ code: GRAPH_DOMAIN_CODES.CLEAR,
4083
+ completion: "complete",
4084
+ summary: "Declared graph checks completed without issues. This does not prove unregistered relations or content correctness."
4085
+ };
4086
+ }
4087
+ function buildLimitations(checks) {
4088
+ const limitations = [STANDING_LIMITATION];
4089
+ for (const check of checks) {
4090
+ if (check.status === "not-performed") {
4091
+ limitations.push(`${check.name} did not complete: ${check.reason ?? "unknown error"}`);
4092
+ }
4093
+ if (check.coverage?.behaviorStatus === "not-evaluated") {
4094
+ limitations.push("coverage does not evaluate whether declared verification actually ran.");
4095
+ }
4096
+ if (check.coverage?.changedPathScope === "unavailable") {
4097
+ limitations.push("coverage could not observe Git worktree changes.");
4098
+ }
4099
+ }
4100
+ return [...new Set(limitations)];
4101
+ }
4102
+ function buildConclusion(root, checks) {
4103
+ const absoluteRoot = (0, import_node_path10.resolve)(root);
4104
+ const mapped = mapDomain(checks);
4105
+ const checked = checks.filter((check) => check.status === "completed").map((check) => check.name);
4106
+ const limitations = buildLimitations(checks);
4107
+ const issues = checks.flatMap((check) => check.issues);
4108
+ return {
4109
+ schemaVersion: 1,
4110
+ kind: "skill-family.professional-conclusion",
4111
+ provider: {
4112
+ id: GRAPH_PROVIDER_ID,
4113
+ version: providerVersion(),
4114
+ entry: GRAPH_PROVIDER_ENTRY
4115
+ },
4116
+ subject: {
4117
+ ref: (0, import_node_url2.pathToFileURL)(absoluteRoot).href
4118
+ },
4119
+ scope: {
4120
+ checked: mapped.completion === "not-performed" ? [] : checked,
4121
+ limitations
4122
+ },
4123
+ outcome: {
4124
+ completion: mapped.completion,
4125
+ code: mapped.code,
4126
+ summary: mapped.summary
4127
+ },
4128
+ details: {
4129
+ checks: checks.map((check) => ({
4130
+ name: check.name,
4131
+ status: check.status,
4132
+ issueCount: check.issues.length,
4133
+ ...check.reason ? { reason: check.reason } : {},
4134
+ ...check.coverage ? { coverage: check.coverage } : {}
4135
+ })),
4136
+ issues
4137
+ }
4138
+ };
4139
+ }
4140
+ async function assertConclusionShape(conclusion) {
4141
+ const contracts = await loadContracts();
4142
+ const registration = contracts.findSchemaByObject(PROFESSIONAL_CONCLUSION_OBJECT);
4143
+ if (registration === null) {
4144
+ throw new Error("skill-family-contracts 0.22.0 does not register professional-conclusion");
4145
+ }
4146
+ const verdict = contracts.validateDocument(conclusion, {
4147
+ schemaId: registration.$id,
4148
+ dialect: registration.dialect,
4149
+ policy: "strict"
4150
+ });
4151
+ if (!verdict.valid) {
4152
+ throw new Error(`constructed professional conclusion failed public schema validation (${verdict.errorCode ?? "invalid"})`);
4153
+ }
4154
+ }
4155
+ async function publishConclusion(absoluteOutput, conclusion) {
4156
+ if (!(0, import_node_path10.isAbsolute)(absoluteOutput)) {
4157
+ return "--conclusion-output must be an absolute path";
4158
+ }
4159
+ const outputRoot = (0, import_node_path10.dirname)(absoluteOutput);
4160
+ const relPath = (0, import_node_path10.basename)(absoluteOutput);
4161
+ if (relPath.length === 0 || relPath === "." || relPath === "..") {
4162
+ return "--conclusion-output must name a file";
4163
+ }
4164
+ try {
4165
+ const harness = await loadHarness();
4166
+ await harness.publishFileExclusive(outputRoot, relPath, `${JSON.stringify(conclusion, null, 2)}
4167
+ `);
4168
+ return void 0;
4169
+ } catch (error) {
4170
+ const kind = harnessKind(error);
4171
+ if (kind === "exclusive-publish-conflict") {
4172
+ return `exclusive publication target already exists: ${absoluteOutput}`;
4173
+ }
4174
+ return errorMessage(error);
4175
+ }
4176
+ }
4177
+ async function runCheckProfessional(options) {
4178
+ const root = (0, import_node_path10.resolve)(options.root);
4179
+ const configGap = await missingRequiredConfig(root);
4180
+ const checks = configGap === void 0 ? await Promise.all([
4181
+ settleCheck(CHECK_VALIDATE, () => runValidate(root)),
4182
+ settleCheck(CHECK_LOCK, () => runLockAudit(root)),
4183
+ settleCheck(CHECK_COVERAGE, () => runCoverage(root))
4184
+ ]) : [
4185
+ { name: CHECK_VALIDATE, status: "not-performed", issues: [], reason: configGap },
4186
+ { name: CHECK_LOCK, status: "not-performed", issues: [], reason: configGap },
4187
+ { name: CHECK_COVERAGE, status: "not-performed", issues: [], reason: configGap }
4188
+ ];
4189
+ const conclusion = buildConclusion(root, checks);
4190
+ await assertConclusionShape(conclusion);
4191
+ if (options.conclusionOutput === void 0) {
4192
+ return { conclusion };
4193
+ }
4194
+ if (!(0, import_node_path10.isAbsolute)(options.conclusionOutput)) {
4195
+ return { conclusion, writeError: "--conclusion-output must be an absolute path" };
4196
+ }
4197
+ const writeError = await publishConclusion((0, import_node_path10.resolve)(options.conclusionOutput), conclusion);
4198
+ return { conclusion, ...writeError ? { writeError } : {} };
4199
+ }
4200
+ function asRecord(value) {
4201
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4202
+ return null;
4203
+ }
4204
+ return value;
4205
+ }
4206
+ function readProvider(value) {
4207
+ const record = asRecord(value);
4208
+ if (record === null) {
4209
+ return null;
4210
+ }
4211
+ const provider = {};
4212
+ if (typeof record.id === "string") provider.id = record.id;
4213
+ if (typeof record.version === "string") provider.version = record.version;
4214
+ if (typeof record.entry === "string") provider.entry = record.entry;
4215
+ return Object.keys(provider).length > 0 ? provider : null;
4216
+ }
4217
+ function interpretConclusion(conclusion) {
4218
+ const provider = conclusion.provider;
4219
+ if (provider.id !== GRAPH_PROVIDER_ID) {
4220
+ return {
4221
+ status: "unavailable",
4222
+ reason: `proof provider ${provider.id} is not ${GRAPH_PROVIDER_ID}`,
4223
+ provider,
4224
+ conclusion
4225
+ };
4226
+ }
4227
+ if (!KNOWN_DOMAIN_CODES.has(conclusion.outcome.code)) {
4228
+ return {
4229
+ status: "unavailable",
4230
+ reason: `unknown same-version domain code: ${conclusion.outcome.code}`,
4231
+ provider,
4232
+ conclusion
4233
+ };
4234
+ }
4235
+ if (conclusion.outcome.code === GRAPH_DOMAIN_CODES.CLEAR && conclusion.outcome.completion === "complete") {
4236
+ return {
4237
+ status: "pass",
4238
+ reason: "GRAPH_CLEAR with complete scope is acceptable for this provider version.",
4239
+ provider,
4240
+ conclusion
4241
+ };
4242
+ }
4243
+ return {
4244
+ status: "not_pass",
4245
+ reason: `proof records ${conclusion.outcome.code} (${conclusion.outcome.completion}); complete does not mean pass.`,
4246
+ provider,
4247
+ conclusion
4248
+ };
4249
+ }
4250
+ async function runReadProof(options) {
4251
+ const unavailable = (reason, provider = null, conclusion = null) => ({
4252
+ result: { status: "unavailable", reason, provider, conclusion },
4253
+ exitCode: 2
4254
+ });
4255
+ let receipt;
4256
+ try {
4257
+ const harness = await loadHarness();
4258
+ receipt = await harness.readFileStrict(options.proofRoot, options.proof, { encoding: "utf8" });
4259
+ } catch (error) {
4260
+ const kind = harnessKind(error);
4261
+ if (kind === "missing-resource") {
4262
+ return unavailable(`proof file does not exist: ${options.proof}`, null, null);
4263
+ }
4264
+ return unavailable(errorMessage(error), null, null);
4265
+ }
4266
+ const raw = typeof receipt.content === "string" ? receipt.content : receipt.content.toString("utf8");
4267
+ let parsed;
4268
+ try {
4269
+ parsed = JSON.parse(raw);
4270
+ } catch (error) {
4271
+ return unavailable(`proof is not valid JSON: ${errorMessage(error)}`, null, null);
4272
+ }
4273
+ const previewProvider = readProvider(asRecord(parsed)?.provider);
4274
+ let contracts;
4275
+ try {
4276
+ contracts = await loadContracts();
4277
+ } catch (error) {
4278
+ return unavailable(`cannot load skill-family-contracts: ${errorMessage(error)}`, previewProvider, null);
4279
+ }
4280
+ const registration = contracts.findSchemaByObject(PROFESSIONAL_CONCLUSION_OBJECT);
4281
+ if (registration === null) {
4282
+ return unavailable("professional-conclusion schema is not registered", previewProvider, null);
4283
+ }
4284
+ const verdict = contracts.validateDocument(parsed, {
4285
+ schemaId: registration.$id,
4286
+ dialect: registration.dialect,
4287
+ policy: "strict"
4288
+ });
4289
+ if (!verdict.valid) {
4290
+ return unavailable(
4291
+ `proof failed professional-conclusion schema validation (${verdict.errorCode ?? "invalid"})`,
4292
+ previewProvider,
4293
+ null
4294
+ );
4295
+ }
4296
+ const interpreted = interpretConclusion(parsed);
4297
+ const exitCode = interpreted.status === "pass" ? 0 : interpreted.status === "not_pass" ? 1 : 2;
4298
+ return { result: interpreted, exitCode };
4299
+ }
4300
+ var import_promises6, import_node_module2, import_node_path10, import_node_url2, import_meta2, GRAPH_PROVIDER_ID, GRAPH_PROVIDER_ENTRY, PROFESSIONAL_CONCLUSION_OBJECT, GRAPH_DOMAIN_CODES, KNOWN_DOMAIN_CODES, CHECK_VALIDATE, CHECK_LOCK, CHECK_COVERAGE, STANDING_LIMITATION, CONTRACTS_PACKAGE_NAME;
4301
+ var init_professional_conclusion = __esm({
4302
+ "src/professional-conclusion.ts"() {
4303
+ "use strict";
4304
+ import_promises6 = require("fs/promises");
4305
+ import_node_module2 = require("module");
4306
+ import_node_path10 = require("path");
4307
+ import_node_url2 = require("url");
4308
+ init_coverage();
4309
+ init_index();
4310
+ init_versioned_traceability();
4311
+ import_meta2 = {};
4312
+ GRAPH_PROVIDER_ID = "artifact-graph";
4313
+ GRAPH_PROVIDER_ENTRY = "check-professional";
4314
+ PROFESSIONAL_CONCLUSION_OBJECT = "professional-conclusion";
4315
+ GRAPH_DOMAIN_CODES = Object.freeze({
4316
+ CLEAR: "GRAPH_CLEAR",
4317
+ FINDINGS: "GRAPH_FINDINGS",
4318
+ INCOMPLETE: "GRAPH_CHECK_INCOMPLETE",
4319
+ UNAVAILABLE: "GRAPH_CHECK_UNAVAILABLE"
4320
+ });
4321
+ KNOWN_DOMAIN_CODES = new Set(Object.values(GRAPH_DOMAIN_CODES));
4322
+ CHECK_VALIDATE = "validate";
4323
+ CHECK_LOCK = "version-lock-audit";
4324
+ CHECK_COVERAGE = "coverage";
4325
+ STANDING_LIMITATION = "Graph checks do not prove content semantics, method execution, or publication facts.";
4326
+ CONTRACTS_PACKAGE_NAME = "skill-family-contracts";
4327
+ }
4328
+ });
4329
+
3959
4330
  // src/review-result-validator.ts
3960
4331
  function validateReviewResult(input) {
3961
4332
  const errors = [];
@@ -4557,7 +4928,7 @@ function validatePolicyCompatibility(policy, baseContract) {
4557
4928
  };
4558
4929
  }
4559
4930
  async function loadContract(contractPath, options) {
4560
- const rawContent = await (0, import_promises6.readFile)(contractPath, "utf-8");
4931
+ const rawContent = await (0, import_promises7.readFile)(contractPath, "utf-8");
4561
4932
  let schema;
4562
4933
  try {
4563
4934
  schema = JSON.parse(rawContent);
@@ -4605,10 +4976,10 @@ async function loadContract(contractPath, options) {
4605
4976
  }
4606
4977
  async function loadContractsFromDirectory(contractsDir, options) {
4607
4978
  const contracts = [];
4608
- const entries = await (0, import_promises6.readdir)(contractsDir, { withFileTypes: true });
4979
+ const entries = await (0, import_promises7.readdir)(contractsDir, { withFileTypes: true });
4609
4980
  for (const entry of entries) {
4610
4981
  if (entry.isDirectory()) {
4611
- const schemaPath = (0, import_node_path10.join)(contractsDir, entry.name, "schema.json");
4982
+ const schemaPath = (0, import_node_path11.join)(contractsDir, entry.name, "schema.json");
4612
4983
  const contract = await loadContract(schemaPath, options);
4613
4984
  contracts.push(contract);
4614
4985
  }
@@ -4723,13 +5094,13 @@ async function loadContractCatalog(contractsDir, options) {
4723
5094
  }
4724
5095
  return catalog;
4725
5096
  }
4726
- var import_node_crypto3, import_promises6, import_node_path10, import_ajv, CONTRACT_ERROR_CODES, ContractError, OFFICIAL_AUTHORITY, OFFICIAL_NAMESPACE_PATTERN, ContractRegistry, _validatorCache, E2E_NORMALIZER_CONFIG, ContractCatalog;
5097
+ var import_node_crypto3, import_promises7, import_node_path11, import_ajv, CONTRACT_ERROR_CODES, ContractError, OFFICIAL_AUTHORITY, OFFICIAL_NAMESPACE_PATTERN, ContractRegistry, _validatorCache, E2E_NORMALIZER_CONFIG, ContractCatalog;
4727
5098
  var init_contract_kernel = __esm({
4728
5099
  "src/contract-kernel.ts"() {
4729
5100
  "use strict";
4730
5101
  import_node_crypto3 = require("crypto");
4731
- import_promises6 = require("fs/promises");
4732
- import_node_path10 = require("path");
5102
+ import_promises7 = require("fs/promises");
5103
+ import_node_path11 = require("path");
4733
5104
  import_ajv = __toESM(require("ajv"), 1);
4734
5105
  CONTRACT_ERROR_CODES = {
4735
5106
  /** Contract identity not found */
@@ -5159,7 +5530,7 @@ async function loadFoundationModule() {
5159
5530
  return await import(FOUNDATION_PACKAGE_NAME);
5160
5531
  }
5161
5532
  async function loadContractsModule() {
5162
- return await import(CONTRACTS_PACKAGE_NAME);
5533
+ return await import(CONTRACTS_PACKAGE_NAME2);
5163
5534
  }
5164
5535
  async function verifyMechanismResult(result) {
5165
5536
  if (typeof result !== "object" || result === null || Array.isArray(result)) {
@@ -5212,13 +5583,13 @@ function rawDigest(value, path) {
5212
5583
  async function resolveRealRoot(root) {
5213
5584
  let canonical;
5214
5585
  try {
5215
- canonical = await (0, import_promises7.realpath)((0, import_node_path11.resolve)(root));
5586
+ canonical = await (0, import_promises8.realpath)((0, import_node_path12.resolve)(root));
5216
5587
  } catch (cause) {
5217
5588
  return failure("ROOT_INVALID", `Project root cannot be resolved: ${cause.message}`);
5218
5589
  }
5219
5590
  let info;
5220
5591
  try {
5221
- info = await (0, import_promises7.lstat)(canonical);
5592
+ info = await (0, import_promises8.lstat)(canonical);
5222
5593
  } catch (cause) {
5223
5594
  return failure("ROOT_INVALID", `Project root cannot be inspected: ${cause.message}`);
5224
5595
  }
@@ -5238,7 +5609,7 @@ async function qualifyRestructureMechanism(root) {
5238
5609
  if (!canonical.ok) return canonical;
5239
5610
  let type;
5240
5611
  try {
5241
- type = (await (0, import_promises7.statfs)(canonical.data)).type;
5612
+ type = (await (0, import_promises8.statfs)(canonical.data)).type;
5242
5613
  } catch (cause) {
5243
5614
  return failure("APPLY_ENVIRONMENT_UNSUPPORTED", `Project root filesystem cannot be inspected: ${cause.message}`);
5244
5615
  }
@@ -5251,8 +5622,8 @@ async function qualifyRestructureMechanism(root) {
5251
5622
  return { ok: true, data: { root: canonical.data, filesystem: RESTRUCTURE_QUALIFIED_FILESYSTEM } };
5252
5623
  }
5253
5624
  async function ensureRestructureMechanismRoot(canonicalRoot, options) {
5254
- const target = (0, import_node_path11.join)(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
5255
- const current = async () => (0, import_promises7.lstat)(target).catch((cause) => cause.code === "ENOENT" ? null : Promise.reject(cause));
5625
+ const target = (0, import_node_path12.join)(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
5626
+ const current = async () => (0, import_promises8.lstat)(target).catch((cause) => cause.code === "ENOENT" ? null : Promise.reject(cause));
5256
5627
  let info = await current();
5257
5628
  if (info === null) {
5258
5629
  if (!options.create) {
@@ -5263,7 +5634,7 @@ async function ensureRestructureMechanismRoot(canonicalRoot, options) {
5263
5634
  }
5264
5635
  let created = false;
5265
5636
  try {
5266
- await (0, import_promises7.mkdir)(target, { mode: RESTRUCTURE_RECOVERY_ROOT_MODE });
5637
+ await (0, import_promises8.mkdir)(target, { mode: RESTRUCTURE_RECOVERY_ROOT_MODE });
5267
5638
  created = true;
5268
5639
  } catch (cause) {
5269
5640
  if (cause.code !== "EEXIST") {
@@ -5276,7 +5647,7 @@ async function ensureRestructureMechanismRoot(canonicalRoot, options) {
5276
5647
  return failure("MECHANISM_ROOT_UNSAFE", `${target} must be one real directory, not a link or special entry`);
5277
5648
  }
5278
5649
  if (created && (info.mode & 4095) !== RESTRUCTURE_RECOVERY_ROOT_MODE) {
5279
- await (0, import_promises7.chmod)(target, RESTRUCTURE_RECOVERY_ROOT_MODE);
5650
+ await (0, import_promises8.chmod)(target, RESTRUCTURE_RECOVERY_ROOT_MODE);
5280
5651
  info = await current();
5281
5652
  if (info === null || info.isSymbolicLink() || !info.isDirectory()) {
5282
5653
  return failure("MECHANISM_ROOT_UNSAFE", `${target} must be one real directory, not a link or special entry`);
@@ -5365,7 +5736,7 @@ async function applyRestructureFileSet(canonicalRoot, plan, options) {
5365
5736
  return await verifyMechanismResult(raw);
5366
5737
  }
5367
5738
  async function observeRestructureJournal(canonicalRoot) {
5368
- const journalRoot = (0, import_node_path11.join)(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
5739
+ const journalRoot = (0, import_node_path12.join)(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
5369
5740
  const module2 = await loadFoundationModule();
5370
5741
  try {
5371
5742
  return { ok: true, data: await module2.inspectStateStoreLock(journalRoot, { recoveryObservation: true }) };
@@ -5552,13 +5923,13 @@ function projectRestructureFileSetResult(result, planPath = "", planDigest = "")
5552
5923
  const reading = result.operation === "apply" ? applyProjection(result) : result.operation === "recover" ? recoverProjection(result) : pruneProjection(result);
5553
5924
  return { ...base, ...reading };
5554
5925
  }
5555
- var import_node_crypto4, import_promises7, import_node_path11, 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;
5926
+ var import_node_crypto4, import_promises8, import_node_path12, 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;
5556
5927
  var init_restructure_file_set = __esm({
5557
5928
  "src/restructure-file-set.ts"() {
5558
5929
  "use strict";
5559
5930
  import_node_crypto4 = require("crypto");
5560
- import_promises7 = require("fs/promises");
5561
- import_node_path11 = require("path");
5931
+ import_promises8 = require("fs/promises");
5932
+ import_node_path12 = require("path");
5562
5933
  RESTRUCTURE_RECOVERY_REL_PATH = ".foundation-file-apply";
5563
5934
  RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH = `${RESTRUCTURE_RECOVERY_REL_PATH}/journal`;
5564
5935
  RESTRUCTURE_RECOVERY_ROOT_MODE = 448;
@@ -5569,7 +5940,7 @@ var init_restructure_file_set = __esm({
5569
5940
  DIGEST_PREFIX = "sha256:";
5570
5941
  RAW_SHA256_PATTERN = /^[a-f0-9]{64}$/;
5571
5942
  FOUNDATION_PACKAGE_NAME = "skill-family-harness-node";
5572
- CONTRACTS_PACKAGE_NAME = "skill-family-contracts";
5943
+ CONTRACTS_PACKAGE_NAME2 = "skill-family-contracts";
5573
5944
  FILE_SET_RESULT_OBJECT = "file-set-result";
5574
5945
  APPLY_MAINTENANCE_ERROR_KINDS = ["lock-release-failed"];
5575
5946
  }
@@ -5590,7 +5961,7 @@ function digestRestructureValue(value) {
5590
5961
  return digestBytes(canonicalJson(value));
5591
5962
  }
5592
5963
  function normalizeRelativePath2(value) {
5593
- if (!value || value.includes("\0") || (0, import_node_path12.isAbsolute)(value)) return void 0;
5964
+ if (!value || value.includes("\0") || (0, import_node_path13.isAbsolute)(value)) return void 0;
5594
5965
  const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "");
5595
5966
  if (!normalized || normalized === "." || normalized.split("/").some((part) => part === ".." || part === "")) return void 0;
5596
5967
  return normalized;
@@ -5604,13 +5975,13 @@ function isPathAllowed(path, allowed) {
5604
5975
  async function readContainedFileWithMode(root, path) {
5605
5976
  const normalized = normalizeRelativePath2(path);
5606
5977
  if (!normalized) throw new Error(`Path must be a project-relative path without traversal: ${path}`);
5607
- const absoluteRoot = (0, import_node_path12.resolve)(root);
5608
- const absolutePath = (0, import_node_path12.resolve)(absoluteRoot, normalized);
5609
- if ((0, import_node_path12.relative)(absoluteRoot, absolutePath).startsWith("..")) throw new Error(`Path escapes project root: ${path}`);
5978
+ const absoluteRoot = (0, import_node_path13.resolve)(root);
5979
+ const absolutePath = (0, import_node_path13.resolve)(absoluteRoot, normalized);
5980
+ if ((0, import_node_path13.relative)(absoluteRoot, absolutePath).startsWith("..")) throw new Error(`Path escapes project root: ${path}`);
5610
5981
  try {
5611
- const info = await (0, import_promises8.lstat)(absolutePath);
5982
+ const info = await (0, import_promises9.lstat)(absolutePath);
5612
5983
  if (info.isSymbolicLink() || !info.isFile()) throw new Error(`Path is not a regular file: ${path}`);
5613
- return { buffer: await (0, import_promises8.readFile)(absolutePath), mode: info.mode & MAX_POSIX_MODE };
5984
+ return { buffer: await (0, import_promises9.readFile)(absolutePath), mode: info.mode & MAX_POSIX_MODE };
5614
5985
  } catch (error) {
5615
5986
  if (error.code === "ENOENT") return void 0;
5616
5987
  throw error;
@@ -5638,7 +6009,7 @@ async function configSnapshot(root) {
5638
6009
  return snapshotFile(root, "artifact-graph.config.yaml");
5639
6010
  }
5640
6011
  async function loadRestructureContract(name) {
5641
- return loadContract((0, import_node_path12.join)(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
6012
+ return loadContract((0, import_node_path13.join)(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
5642
6013
  }
5643
6014
  async function validateDomainContract(name, value) {
5644
6015
  const contract = await loadRestructureContract(name);
@@ -5899,7 +6270,7 @@ function splitMarkdownTarget(target) {
5899
6270
  }
5900
6271
  async function pathExists2(absolutePath) {
5901
6272
  try {
5902
- await (0, import_promises8.lstat)(absolutePath);
6273
+ await (0, import_promises9.lstat)(absolutePath);
5903
6274
  return true;
5904
6275
  } catch {
5905
6276
  return false;
@@ -5907,20 +6278,20 @@ async function pathExists2(absolutePath) {
5907
6278
  }
5908
6279
  async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
5909
6280
  const migrationPaths = [.../* @__PURE__ */ new Set([...sourcePaths, ...targetPaths])];
5910
- const migrationNames = new Set(migrationPaths.map((path) => import_node_path12.posix.basename(path)));
5911
- const directories = new Set(migrationPaths.map((path) => import_node_path12.posix.dirname(path)));
6281
+ const migrationNames = new Set(migrationPaths.map((path) => import_node_path13.posix.basename(path)));
6282
+ const directories = new Set(migrationPaths.map((path) => import_node_path13.posix.dirname(path)));
5912
6283
  const findings = [];
5913
6284
  async function visit(directory) {
5914
- for (const entry of await (0, import_promises8.readdir)(directory, { withFileTypes: true })) {
6285
+ for (const entry of await (0, import_promises9.readdir)(directory, { withFileTypes: true })) {
5915
6286
  if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
5916
- const absolute = (0, import_node_path12.join)(directory, entry.name);
6287
+ const absolute = (0, import_node_path13.join)(directory, entry.name);
5917
6288
  if (entry.isDirectory()) {
5918
6289
  await visit(absolute);
5919
6290
  continue;
5920
6291
  }
5921
6292
  if (!entry.isFile() || !TEXT_EXTENSIONS.test(entry.name)) continue;
5922
- const path = (0, import_node_path12.relative)(root, absolute).replace(/\\/g, "/");
5923
- const raw = await (0, import_promises8.readFile)(absolute, "utf8");
6293
+ const path = (0, import_node_path13.relative)(root, absolute).replace(/\\/g, "/");
6294
+ const raw = await (0, import_promises9.readFile)(absolute, "utf8");
5924
6295
  const namesTheMigration = migrationPaths.some((reference) => raw.includes(reference));
5925
6296
  const lines = raw.split(/\r?\n/);
5926
6297
  for (const [index, line] of lines.entries()) {
@@ -5932,8 +6303,8 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
5932
6303
  const literal = match[0];
5933
6304
  const { path: linkPath, anchor } = splitMarkdownTarget(match[2]);
5934
6305
  if (!linkPath || linkPath.startsWith("/") || /^[a-z][a-z0-9+.-]*:/i.test(linkPath)) continue;
5935
- if (!migrationNames.has(import_node_path12.posix.basename(linkPath))) continue;
5936
- const resolved = normalizeRelativePath2(import_node_path12.posix.join(import_node_path12.posix.dirname(path), linkPath));
6306
+ if (!migrationNames.has(import_node_path13.posix.basename(linkPath))) continue;
6307
+ const resolved = normalizeRelativePath2(import_node_path13.posix.join(import_node_path13.posix.dirname(path), linkPath));
5937
6308
  if (!resolved || targetPaths.includes(resolved)) continue;
5938
6309
  if (anchor) {
5939
6310
  findings.push(finding(
@@ -5942,7 +6313,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
5942
6313
  path,
5943
6314
  lineNumber
5944
6315
  ));
5945
- } else if (!await pathExists2((0, import_node_path12.resolve)(root, resolved))) {
6316
+ } else if (!await pathExists2((0, import_node_path13.resolve)(root, resolved))) {
5946
6317
  findings.push(finding(
5947
6318
  "SIBLING_RELATIVE_REFERENCE_UNRESOLVED",
5948
6319
  `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`,
@@ -5967,7 +6338,7 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
5967
6338
  }
5968
6339
  }
5969
6340
  }
5970
- await visit((0, import_node_path12.resolve)(root));
6341
+ await visit((0, import_node_path13.resolve)(root));
5971
6342
  const unique = new Map(findings.map((item) => [`${item.code} ${item.path} ${item.line} ${item.message}`, item]));
5972
6343
  return [...unique.values()].sort((left, right) => (left.path ?? "").localeCompare(right.path ?? "") || (left.line ?? 0) - (right.line ?? 0) || left.code.localeCompare(right.code));
5973
6344
  }
@@ -5983,15 +6354,15 @@ function mergeFindings(target, additions) {
5983
6354
  async function scanConsumerCandidates(root, references, excludedPaths = /* @__PURE__ */ new Set()) {
5984
6355
  const results = [];
5985
6356
  async function visit(directory) {
5986
- for (const entry of await (0, import_promises8.readdir)(directory, { withFileTypes: true })) {
6357
+ for (const entry of await (0, import_promises9.readdir)(directory, { withFileTypes: true })) {
5987
6358
  if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
5988
- const absolute = (0, import_node_path12.join)(directory, entry.name);
6359
+ const absolute = (0, import_node_path13.join)(directory, entry.name);
5989
6360
  if (entry.isDirectory()) {
5990
6361
  await visit(absolute);
5991
6362
  } else if (entry.isFile() && TEXT_EXTENSIONS.test(entry.name)) {
5992
- const path = (0, import_node_path12.relative)(root, absolute).replace(/\\/g, "/");
6363
+ const path = (0, import_node_path13.relative)(root, absolute).replace(/\\/g, "/");
5993
6364
  if (excludedPaths.has(path)) continue;
5994
- const raw = await (0, import_promises8.readFile)(absolute, "utf8");
6365
+ const raw = await (0, import_promises9.readFile)(absolute, "utf8");
5995
6366
  raw.split(/\r?\n/).forEach((line, index) => {
5996
6367
  for (const reference of references) {
5997
6368
  if (path !== reference && line.includes(reference)) results.push({ path, line: index + 1, reference });
@@ -6000,7 +6371,7 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
6000
6371
  }
6001
6372
  }
6002
6373
  }
6003
- await visit((0, import_node_path12.resolve)(root));
6374
+ await visit((0, import_node_path13.resolve)(root));
6004
6375
  return results.sort((left, right) => left.path.localeCompare(right.path) || left.line - right.line || left.reference.localeCompare(right.reference));
6005
6376
  }
6006
6377
  function expectedRelationTargets(mapping) {
@@ -6040,7 +6411,7 @@ function restructureBoundaryFindings(operations, limits) {
6040
6411
  const expectedCreateMode = createModeForUmask(limits.umask);
6041
6412
  const applyModeContract = limits.mode_contract === "apply";
6042
6413
  for (const operation of operations) {
6043
- const parent = (0, import_node_path12.dirname)(operation.path) || ".";
6414
+ const parent = (0, import_node_path13.dirname)(operation.path) || ".";
6044
6415
  if (!operation.parent_exists) {
6045
6416
  findings.push(finding("PARENT_DIRECTORY_MISSING", `Parent directory does not exist or is not a directory: ${parent}`, operation.path));
6046
6417
  } else if (operation.parent_device !== null && operation.parent_device !== operation.root_device) {
@@ -6089,7 +6460,7 @@ function restructureBoundaryFindings(operations, limits) {
6089
6460
  }
6090
6461
  async function probeDirectory(absolutePath) {
6091
6462
  try {
6092
- const info = await (0, import_promises8.stat)(absolutePath);
6463
+ const info = await (0, import_promises9.stat)(absolutePath);
6093
6464
  return { exists: info.isDirectory(), device: info.dev };
6094
6465
  } catch (error) {
6095
6466
  const code = error.code;
@@ -6231,7 +6602,7 @@ async function planRestructure(root, input) {
6231
6602
  }
6232
6603
  pathMoves.push(move);
6233
6604
  rangesByPath.set(sourcePath, pathMoves);
6234
- if ((0, import_node_path12.dirname)(sourcePath) !== (0, import_node_path12.dirname)(targetPath)) {
6605
+ if ((0, import_node_path13.dirname)(sourcePath) !== (0, import_node_path13.dirname)(targetPath)) {
6235
6606
  for (const link of findRelativeLinks(fragment.toString("utf8"))) {
6236
6607
  const explicitlyEdited = mapping.prose_edits.some((edit) => edit.target_path === targetPath && edit.old_text.includes(link));
6237
6608
  if (!explicitlyEdited) blockers.push(finding("RELATIVE_LINK_REQUIRES_MAPPING", `Relative reference "${link}" changes base directory when moved to ${targetPath}`, sourcePath));
@@ -6348,15 +6719,15 @@ async function planRestructure(root, input) {
6348
6719
  diff: readableDiff(path, original?.toString("utf8"), deleteFile ? void 0 : candidate.toString("utf8"))
6349
6720
  });
6350
6721
  }
6351
- const rootDirectory = await probeDirectory((0, import_node_path12.resolve)(root));
6722
+ const rootDirectory = await probeDirectory((0, import_node_path13.resolve)(root));
6352
6723
  const parentProbes = /* @__PURE__ */ new Map();
6353
6724
  for (const candidate of candidates) {
6354
- const parent = (0, import_node_path12.dirname)(candidate.path);
6355
- if (!parentProbes.has(parent)) parentProbes.set(parent, await probeDirectory((0, import_node_path12.resolve)(root, parent)));
6725
+ const parent = (0, import_node_path13.dirname)(candidate.path);
6726
+ if (!parentProbes.has(parent)) parentProbes.set(parent, await probeDirectory((0, import_node_path13.resolve)(root, parent)));
6356
6727
  }
6357
6728
  blockers.push(...restructureBoundaryFindings(
6358
6729
  candidates.map((candidate) => {
6359
- const parent = parentProbes.get((0, import_node_path12.dirname)(candidate.path));
6730
+ const parent = parentProbes.get((0, import_node_path13.dirname)(candidate.path));
6360
6731
  return {
6361
6732
  path: candidate.path,
6362
6733
  action: candidate.action,
@@ -6482,10 +6853,10 @@ function refusal(code, message, findings = []) {
6482
6853
  return { ok: false, error: { code, message, ...findings.length === 0 ? {} : { details: findings } } };
6483
6854
  }
6484
6855
  async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
6485
- const absolute = (0, import_node_path12.resolve)(planPath);
6856
+ const absolute = (0, import_node_path13.resolve)(planPath);
6486
6857
  let info;
6487
6858
  try {
6488
- info = await (0, import_promises8.lstat)(absolute);
6859
+ info = await (0, import_promises9.lstat)(absolute);
6489
6860
  } catch (cause) {
6490
6861
  return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
6491
6862
  }
@@ -6494,7 +6865,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
6494
6865
  }
6495
6866
  let bytes;
6496
6867
  try {
6497
- bytes = await (0, import_promises8.readFile)(absolute);
6868
+ bytes = await (0, import_promises9.readFile)(absolute);
6498
6869
  } catch (cause) {
6499
6870
  return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
6500
6871
  }
@@ -6506,7 +6877,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
6506
6877
  }
6507
6878
  const gate = await gateRestructureOperationPlan(operation, parsed);
6508
6879
  if (!gate.ok) return gate;
6509
- return { ok: true, data: { path: absolute, realPath: await (0, import_promises8.realpath)(absolute), digest: digestBytes(bytes), root: canonicalRoot, plan: gate.data } };
6880
+ return { ok: true, data: { path: absolute, realPath: await (0, import_promises9.realpath)(absolute), digest: digestBytes(bytes), root: canonicalRoot, plan: gate.data } };
6510
6881
  }
6511
6882
  function planRootIdentityFindings(document) {
6512
6883
  const findings = [];
@@ -6525,19 +6896,19 @@ function planRootIdentityFindings(document) {
6525
6896
  if (document.plan.config_snapshot.path !== "artifact-graph.config.yaml") {
6526
6897
  findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan does not record this project's configuration file: ${document.plan.config_snapshot.path}`));
6527
6898
  }
6528
- const relativePlan = (0, import_node_path12.relative)(document.root, document.realPath);
6529
- if (!relativePlan || relativePlan.startsWith("..") || (0, import_node_path12.isAbsolute)(relativePlan)) {
6899
+ const relativePlan = (0, import_node_path13.relative)(document.root, document.realPath);
6900
+ if (!relativePlan || relativePlan.startsWith("..") || (0, import_node_path13.isAbsolute)(relativePlan)) {
6530
6901
  findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan document is outside the project root: ${document.realPath}`, document.realPath));
6531
6902
  }
6532
6903
  return findings;
6533
6904
  }
6534
6905
  async function operationBoundaries(root, plan) {
6535
- const rootDirectory = await probeDirectory((0, import_node_path12.resolve)(root));
6906
+ const rootDirectory = await probeDirectory((0, import_node_path13.resolve)(root));
6536
6907
  const parents = /* @__PURE__ */ new Map();
6537
6908
  const boundaries = [];
6538
6909
  for (const candidate of plan.candidates) {
6539
- const parent = (0, import_node_path12.dirname)(candidate.path) || ".";
6540
- if (!parents.has(parent)) parents.set(parent, await probeDirectory((0, import_node_path12.resolve)(root, parent)));
6910
+ const parent = (0, import_node_path13.dirname)(candidate.path) || ".";
6911
+ if (!parents.has(parent)) parents.set(parent, await probeDirectory((0, import_node_path13.resolve)(root, parent)));
6541
6912
  const probe = parents.get(parent);
6542
6913
  boundaries.push({
6543
6914
  path: candidate.path,
@@ -6562,7 +6933,7 @@ async function applyPreconditionFindings(root, document) {
6562
6933
  findings.push(finding("CONFIG_CHANGED", "artifact-graph configuration changed after planning", currentConfig.path));
6563
6934
  }
6564
6935
  for (const snapshot of plan.input_snapshots) await verifySnapshot(root, snapshot, findings);
6565
- const relativePlan = (0, import_node_path12.relative)(root, document.realPath).replace(/\\/g, "/");
6936
+ const relativePlan = (0, import_node_path13.relative)(root, document.realPath).replace(/\\/g, "/");
6566
6937
  for (const candidate of plan.candidates) {
6567
6938
  if (candidate.path === relativePlan) {
6568
6939
  findings.push(finding("PLAN_IN_WRITE_SET", `The plan document is inside its own candidate write set: ${candidate.path}`, candidate.path));
@@ -6645,7 +7016,7 @@ async function applyRestructure(input) {
6645
7016
  if (drift.length > 0) return refusal("APPLY_PRECONDITION_FAILED", "The project drifted after planning; nothing was written", drift);
6646
7017
  const mechanismRoot = await ensureRestructureMechanismRoot(qualification.data.root, { create: true });
6647
7018
  if (!mechanismRoot.ok) return mechanismRoot;
6648
- const planRelPath = (0, import_node_path12.relative)(qualification.data.root, document.data.realPath).replace(/\\/g, "/");
7019
+ const planRelPath = (0, import_node_path13.relative)(qualification.data.root, document.data.realPath).replace(/\\/g, "/");
6649
7020
  const applied = await applyRestructureFileSet(qualification.data.root, plan, {
6650
7021
  validate: createRestructureValidationCallback(plan, [planRelPath])
6651
7022
  });
@@ -6702,27 +7073,27 @@ async function pruneRestructureRecovery(input) {
6702
7073
  const projection = projectRestructureFileSetResult(pruned.data, document.data.realPath, document.data.digest);
6703
7074
  return projection.ok ? { ok: true, data: projection } : { ok: false, error: { code: projection.code, message: projection.message, details: projection } };
6704
7075
  }
6705
- var import_node_crypto5, import_promises8, import_node_path12, import_node_url2, import_meta2, RESTRUCTURE_PLAN_SCHEMA_VERSION, RESTRUCTURE_VALIDATION_TIMEOUT_MS, RESTRUCTURE_MAX_OPERATIONS, RESTRUCTURE_MAX_TOTAL_BYTES, MAX_POSIX_MODE, CREATE_MODE_BASE, MODULE_DIRECTORY, CONTRACT_ROOT, SKIPPED_SCAN_DIRS, TEXT_EXTENSIONS, MARKDOWN_LINK_PATTERN, RUNTIME_PATH_MARKER, MARKDOWN_FILE_SUFFIX, SCRIPT_FILE_SUFFIX;
7076
+ var import_node_crypto5, import_promises9, import_node_path13, import_node_url3, import_meta3, RESTRUCTURE_PLAN_SCHEMA_VERSION, RESTRUCTURE_VALIDATION_TIMEOUT_MS, RESTRUCTURE_MAX_OPERATIONS, RESTRUCTURE_MAX_TOTAL_BYTES, MAX_POSIX_MODE, CREATE_MODE_BASE, MODULE_DIRECTORY, CONTRACT_ROOT, SKIPPED_SCAN_DIRS, TEXT_EXTENSIONS, MARKDOWN_LINK_PATTERN, RUNTIME_PATH_MARKER, MARKDOWN_FILE_SUFFIX, SCRIPT_FILE_SUFFIX;
6706
7077
  var init_restructure = __esm({
6707
7078
  "src/restructure.ts"() {
6708
7079
  "use strict";
6709
7080
  import_node_crypto5 = require("crypto");
6710
- import_promises8 = require("fs/promises");
6711
- import_node_path12 = require("path");
6712
- import_node_url2 = require("url");
7081
+ import_promises9 = require("fs/promises");
7082
+ import_node_path13 = require("path");
7083
+ import_node_url3 = require("url");
6713
7084
  init_index();
6714
7085
  init_contract_kernel();
6715
7086
  init_restructure_software();
6716
7087
  init_restructure_file_set();
6717
- import_meta2 = {};
7088
+ import_meta3 = {};
6718
7089
  RESTRUCTURE_PLAN_SCHEMA_VERSION = "1.1";
6719
7090
  RESTRUCTURE_VALIDATION_TIMEOUT_MS = 3e4;
6720
7091
  RESTRUCTURE_MAX_OPERATIONS = 1024;
6721
7092
  RESTRUCTURE_MAX_TOTAL_BYTES = 256 * 1024 * 1024;
6722
7093
  MAX_POSIX_MODE = 511;
6723
7094
  CREATE_MODE_BASE = 438;
6724
- MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : (0, import_node_path12.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
6725
- CONTRACT_ROOT = (0, import_node_path12.join)(MODULE_DIRECTORY, "..", "contracts");
7095
+ MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : (0, import_node_path13.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
7096
+ CONTRACT_ROOT = (0, import_node_path13.join)(MODULE_DIRECTORY, "..", "contracts");
6726
7097
  SKIPPED_SCAN_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "dist", "coverage", ".tmp", ".codex", ".worktrees", ".foundation-file-apply", ".artifact-graph"]);
6727
7098
  TEXT_EXTENSIONS = /\.(?:md|markdown|json|ya?ml|[cm]?[jt]sx?)$/i;
6728
7099
  MARKDOWN_LINK_PATTERN = /!?\[([^\]\n]*)\]\(([^)\n]+)\)/g;
@@ -6739,7 +7110,7 @@ __export(index_exports, {
6739
7110
  BASELINE_CONSTRAINTS: () => BASELINE_CONSTRAINTS,
6740
7111
  BASELINE_CONSTRAINTS_COUNT: () => BASELINE_CONSTRAINTS_COUNT,
6741
7112
  BASELINE_ITEMS_COUNT: () => BASELINE_ITEMS_COUNT,
6742
- CONTRACTS_PACKAGE_NAME: () => CONTRACTS_PACKAGE_NAME,
7113
+ CONTRACTS_PACKAGE_NAME: () => CONTRACTS_PACKAGE_NAME2,
6743
7114
  CONTRACT_ERROR_CODES: () => CONTRACT_ERROR_CODES,
6744
7115
  ContractCatalog: () => ContractCatalog,
6745
7116
  ContractError: () => ContractError,
@@ -6749,7 +7120,11 @@ __export(index_exports, {
6749
7120
  E2E_NORMALIZER_CONFIG: () => E2E_NORMALIZER_CONFIG,
6750
7121
  FILE_SET_RESULT_OBJECT: () => FILE_SET_RESULT_OBJECT,
6751
7122
  FOUNDATION_PACKAGE_NAME: () => FOUNDATION_PACKAGE_NAME,
7123
+ GRAPH_DOMAIN_CODES: () => GRAPH_DOMAIN_CODES,
7124
+ GRAPH_PROVIDER_ENTRY: () => GRAPH_PROVIDER_ENTRY,
7125
+ GRAPH_PROVIDER_ID: () => GRAPH_PROVIDER_ID,
6752
7126
  MIN_PROMPT_CHARS: () => MIN_PROMPT_CHARS,
7127
+ PROFESSIONAL_CONCLUSION_OBJECT: () => PROFESSIONAL_CONCLUSION_OBJECT,
6753
7128
  RESTRUCTURE_MAX_OPERATIONS: () => RESTRUCTURE_MAX_OPERATIONS,
6754
7129
  RESTRUCTURE_MAX_TOTAL_BYTES: () => RESTRUCTURE_MAX_TOTAL_BYTES,
6755
7130
  RESTRUCTURE_PLAN_SCHEMA_VERSION: () => RESTRUCTURE_PLAN_SCHEMA_VERSION,
@@ -6785,12 +7160,12 @@ __export(index_exports, {
6785
7160
  createRestructureRootBinding: () => createRestructureRootBinding,
6786
7161
  createRestructureValidationCallback: () => createRestructureValidationCallback,
6787
7162
  digestRestructureValue: () => digestRestructureValue,
6788
- dirname: () => import_node_path13.dirname,
7163
+ dirname: () => import_node_path14.dirname,
6789
7164
  discoverAndAuditPackets: () => discoverAndAuditPackets,
6790
7165
  discoverTargets: () => discoverTargets,
6791
7166
  doctorArtifactChain: () => doctorArtifactChain,
6792
7167
  ensureRestructureMechanismRoot: () => ensureRestructureMechanismRoot,
6793
- extname: () => import_node_path13.extname,
7168
+ extname: () => import_node_path14.extname,
6794
7169
  filterGraphByView: () => filterGraphByView,
6795
7170
  formatContextMarkdown: () => formatContextMarkdown,
6796
7171
  gateRestructureOperationPlan: () => gateRestructureOperationPlan,
@@ -6849,6 +7224,8 @@ __export(index_exports, {
6849
7224
  resolveNodeTimeView: () => resolveNodeTimeView,
6850
7225
  resolveRealRoot: () => resolveRealRoot,
6851
7226
  restructureBoundaryFindings: () => restructureBoundaryFindings,
7227
+ runCheckProfessional: () => runCheckProfessional,
7228
+ runReadProof: () => runReadProof,
6852
7229
  scanArtifacts: () => scanArtifacts,
6853
7230
  traceVersion: () => traceVersion,
6854
7231
  updateVersionLock: () => updateVersionLock,
@@ -6910,10 +7287,10 @@ function resolveArtifactTypeName(schema, token) {
6910
7287
  return void 0;
6911
7288
  }
6912
7289
  async function loadConfig(root) {
6913
- const configPath = (0, import_node_path13.join)(root, "artifact-graph.config.yaml");
7290
+ const configPath = (0, import_node_path14.join)(root, "artifact-graph.config.yaml");
6914
7291
  let parsed = {};
6915
7292
  try {
6916
- const raw = await (0, import_promises9.readFile)(configPath, "utf-8");
7293
+ const raw = await (0, import_promises10.readFile)(configPath, "utf-8");
6917
7294
  parsed = import_js_yaml.default.load(raw) ?? {};
6918
7295
  } catch (error) {
6919
7296
  if (error.code !== "ENOENT") {
@@ -6954,8 +7331,31 @@ async function loadConfig(root) {
6954
7331
  idRanges: mergeRecord(DEFAULT_SCHEMA.idRanges, parsed.idRanges),
6955
7332
  e2e: mergedE2e
6956
7333
  };
7334
+ validateJsonArtifactTypes(merged.types);
6957
7335
  return merged;
6958
7336
  }
7337
+ function validateJsonArtifactTypes(types) {
7338
+ for (const [type, definition] of Object.entries(types)) {
7339
+ const raw = definition;
7340
+ const format = raw.format;
7341
+ const idField = raw.idField;
7342
+ if (format === void 0) {
7343
+ if (idField !== void 0) {
7344
+ throw new Error(`Invalid types.${type}.idField: idField requires format json.`);
7345
+ }
7346
+ continue;
7347
+ }
7348
+ if (format !== "json") {
7349
+ throw new Error(`Invalid types.${type}.format: only json is supported. Omit format to keep Markdown parsing.`);
7350
+ }
7351
+ if (SPECIALIZED_PARSER_TYPES.has(type)) {
7352
+ throw new Error(`Invalid types.${type}.format: JSON format applies only to custom types. ${type} keeps its dedicated parser.`);
7353
+ }
7354
+ if (typeof idField !== "string" || idField.length === 0 || idField.trim() !== idField) {
7355
+ throw new Error(`Invalid types.${type}.idField: format json requires the name of one root property.`);
7356
+ }
7357
+ }
7358
+ }
6959
7359
  function validateRelationSemanticsConfig(value) {
6960
7360
  if (value === void 0) return;
6961
7361
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -7039,7 +7439,7 @@ function validateE2eConfig(e2e) {
7039
7439
  if (typeof runner.root !== "string" || !runner.root.trim()) {
7040
7440
  throw new Error(`Invalid e2e.runners[${runner.name}].root: must be a non-empty string.`);
7041
7441
  }
7042
- if ((0, import_node_path13.isAbsolute)(runner.root)) {
7442
+ if ((0, import_node_path14.isAbsolute)(runner.root)) {
7043
7443
  throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not be an absolute path.`);
7044
7444
  }
7045
7445
  if (runner.root.replace(/\\/g, "/").split("/").includes("..")) {
@@ -7128,15 +7528,15 @@ async function scanArtifacts(root, schema, options = {}) {
7128
7528
  continue;
7129
7529
  }
7130
7530
  scannedFiles.set(file, type);
7131
- const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await (0, import_promises9.readFile)((0, import_node_path13.join)(root, file), "utf-8");
7531
+ const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await (0, import_promises10.readFile)((0, import_node_path14.join)(root, file), "utf-8");
7132
7532
  const parsed = parseFile(type, file, raw, config);
7133
- const semantic = parseConfiguredRelations(type, file, raw, parsed.nodes, config);
7533
+ const semantic = isJsonOriginalType(type, config) ? { edges: [], diagnostics: [] } : parseConfiguredRelations(type, file, raw, parsed.nodes, config);
7134
7534
  nodes.push(...parsed.nodes);
7135
7535
  edges.push(...parsed.edges, ...semantic.edges);
7136
7536
  scanDiagnostics.push(...parsed.diagnostics, ...semantic.diagnostics);
7137
7537
  }
7138
7538
  }
7139
- const absoluteRoot = (0, import_node_path13.isAbsolute)(root) ? root : (0, import_node_path13.resolve)(root);
7539
+ const absoluteRoot = (0, import_node_path14.isAbsolute)(root) ? root : (0, import_node_path14.resolve)(root);
7140
7540
  const graph = buildGraph(nodes, edges, scanDiagnostics, absoluteRoot);
7141
7541
  return resolveMatrixEdges(graph);
7142
7542
  }
@@ -7341,33 +7741,6 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
7341
7741
  issues.push(issue("CYCLE_DETECTED", `depends_on cycle detected: ${cycle.join(" -> ")}`, "", 1, { node: cycle[0] }));
7342
7742
  }
7343
7743
  const defaultTypeKeys = new Set(Object.keys(DEFAULT_SCHEMA.types));
7344
- const specializedParserTypes = /* @__PURE__ */ new Set([
7345
- "feature",
7346
- "scenario",
7347
- "entity",
7348
- "decision",
7349
- "test",
7350
- "design",
7351
- "e2e_test",
7352
- "e2e_registry",
7353
- "rule-golden-cases",
7354
- "test-strategy",
7355
- "traceability-matrix-v2",
7356
- "traceability-version-lock",
7357
- "interface_contracts",
7358
- "data_contracts",
7359
- "application_state_machines",
7360
- "error_model",
7361
- "domain-glossary",
7362
- "bounded-context-map",
7363
- "domain-invariants",
7364
- "generation-packet-spec",
7365
- "report-contracts",
7366
- "verification-fixtures",
7367
- "ui-flow-contracts",
7368
- "non-functional-budgets",
7369
- "implementation-blueprint"
7370
- ]);
7371
7744
  const uidsWithEdges = /* @__PURE__ */ new Set();
7372
7745
  for (const edge2 of graph.edges) {
7373
7746
  uidsWithEdges.add(edge2.from);
@@ -7375,7 +7748,7 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
7375
7748
  }
7376
7749
  for (const node of graph.nodes) {
7377
7750
  if (defaultTypeKeys.has(node.type)) continue;
7378
- if (specializedParserTypes.has(node.type)) continue;
7751
+ if (SPECIALIZED_PARSER_TYPES.has(node.type)) continue;
7379
7752
  if (!schema.types[node.type]) continue;
7380
7753
  if (!uidsWithEdges.has(node.uid)) {
7381
7754
  issues.push(issue(
@@ -7502,7 +7875,7 @@ async function validateScenarioPrdLinkIndex(root, graph) {
7502
7875
  const indexPath = "artifacts/prd/feature-index.md";
7503
7876
  let raw = "";
7504
7877
  try {
7505
- raw = await (0, import_promises9.readFile)((0, import_node_path13.join)(root, indexPath), "utf-8");
7878
+ raw = await (0, import_promises10.readFile)((0, import_node_path14.join)(root, indexPath), "utf-8");
7506
7879
  } catch (error) {
7507
7880
  if (error.code === "ENOENT") {
7508
7881
  return [];
@@ -7750,12 +8123,12 @@ function nextId(graph, schema, type, rangeName) {
7750
8123
  throw new Error(`ID range ${type}.${rangeName} is exhausted`);
7751
8124
  }
7752
8125
  async function writeGraphCache(root, graph) {
7753
- const cacheDir = (0, import_node_path13.join)(root, ".artifact-graph");
7754
- await (0, import_promises9.mkdir)(cacheDir, { recursive: true });
7755
- await (0, import_promises9.writeFile)((0, import_node_path13.join)(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
8126
+ const cacheDir = (0, import_node_path14.join)(root, ".artifact-graph");
8127
+ await (0, import_promises10.mkdir)(cacheDir, { recursive: true });
8128
+ await (0, import_promises10.writeFile)((0, import_node_path14.join)(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
7756
8129
  `);
7757
8130
  const { default: Database } = await import("better-sqlite3");
7758
- const db = new Database((0, import_node_path13.join)(cacheDir, "graph.sqlite"));
8131
+ const db = new Database((0, import_node_path14.join)(cacheDir, "graph.sqlite"));
7759
8132
  try {
7760
8133
  db.exec(`
7761
8134
  DROP TABLE IF EXISTS nodes;
@@ -7796,7 +8169,13 @@ async function writeGraphCache(root, graph) {
7796
8169
  db.close();
7797
8170
  }
7798
8171
  }
8172
+ function isJsonOriginalType(type, schema) {
8173
+ return schema.types[type]?.format === "json" && !SPECIALIZED_PARSER_TYPES.has(type);
8174
+ }
7799
8175
  function parseFile(type, path, raw, schema = DEFAULT_SCHEMA) {
8176
+ if (isJsonOriginalType(type, schema)) {
8177
+ return parseGenericJson(type, path, raw, schema);
8178
+ }
7800
8179
  if (type === "feature") {
7801
8180
  return { ...parseFeature(path, raw), diagnostics: [] };
7802
8181
  }
@@ -7865,9 +8244,187 @@ function parseFile(type, path, raw, schema = DEFAULT_SCHEMA) {
7865
8244
  }
7866
8245
  return parseGenericMarkdown(type, path, raw, schema);
7867
8246
  }
8247
+ function isJsonObject(value) {
8248
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8249
+ }
8250
+ function jsonRootKind(value) {
8251
+ if (Array.isArray(value)) return "array";
8252
+ if (value === null) return "null";
8253
+ return typeof value;
8254
+ }
8255
+ function parseGenericJson(type, path, raw, schema) {
8256
+ const diagnostics = [];
8257
+ const idField = schema.types[type]?.idField;
8258
+ if (typeof idField !== "string" || idField.length === 0 || idField.trim() !== idField) {
8259
+ diagnostics.push(issue(
8260
+ "INVALID_JSON",
8261
+ `types.${type}.idField must name one root property when format is json`,
8262
+ path,
8263
+ 1
8264
+ ));
8265
+ return { nodes: [], edges: [], diagnostics };
8266
+ }
8267
+ let parsed;
8268
+ try {
8269
+ parsed = JSON.parse(raw);
8270
+ } catch (error) {
8271
+ diagnostics.push(issue(
8272
+ "INVALID_JSON",
8273
+ `JSON artifact ${path} is not valid JSON: ${error.message}`,
8274
+ path,
8275
+ 1
8276
+ ));
8277
+ return { nodes: [], edges: [], diagnostics };
8278
+ }
8279
+ if (!isJsonObject(parsed)) {
8280
+ diagnostics.push(issue(
8281
+ "INVALID_JSON_ROOT",
8282
+ `JSON artifact ${path} must be one root object, got ${jsonRootKind(parsed)}`,
8283
+ path,
8284
+ 1
8285
+ ));
8286
+ return { nodes: [], edges: [], diagnostics };
8287
+ }
8288
+ if (!Object.prototype.hasOwnProperty.call(parsed, idField)) {
8289
+ diagnostics.push(issue(
8290
+ "ARTIFACT_ID_MISSING",
8291
+ `Artifact of type ${type} at ${path} has no root property ${idField}`,
8292
+ path,
8293
+ 1,
8294
+ { severity: "warning" }
8295
+ ));
8296
+ return { nodes: [], edges: [], diagnostics };
8297
+ }
8298
+ const idValue = parsed[idField];
8299
+ if (typeof idValue !== "string") {
8300
+ diagnostics.push(issue(
8301
+ "INVALID_ID",
8302
+ `Artifact of type ${type} at ${path} field ${idField} must be a non-empty string`,
8303
+ path,
8304
+ 1
8305
+ ));
8306
+ return { nodes: [], edges: [], diagnostics };
8307
+ }
8308
+ if (idValue.trim() === "") {
8309
+ diagnostics.push(issue(
8310
+ "ARTIFACT_ID_MISSING",
8311
+ `Artifact of type ${type} at ${path} field ${idField} must be a non-empty string`,
8312
+ path,
8313
+ 1,
8314
+ { severity: "warning" }
8315
+ ));
8316
+ return { nodes: [], edges: [], diagnostics };
8317
+ }
8318
+ const code = idValue;
8319
+ const idPattern = schema.idPatterns[type];
8320
+ if (idPattern && !new RegExp(idPattern).test(code)) {
8321
+ diagnostics.push(issue(
8322
+ "INVALID_ID",
8323
+ `Artifact ${type}:${code} field ${idField} does not match ${idPattern}`,
8324
+ path,
8325
+ 1,
8326
+ { node: toUid(type, code) }
8327
+ ));
8328
+ }
8329
+ const node = {
8330
+ type,
8331
+ code,
8332
+ title: code,
8333
+ path,
8334
+ line: 1
8335
+ };
8336
+ const relations = jsonConfiguredRelations(type, path, parsed, schema, toUid(type, code));
8337
+ diagnostics.push(...relations.diagnostics);
8338
+ return { nodes: [node], edges: relations.edges, diagnostics };
8339
+ }
8340
+ function readJsonRelation(record, field) {
8341
+ const segments = field.split(".");
8342
+ if (segments.some((segment) => segment.length === 0)) {
8343
+ return { status: "illegal-path" };
8344
+ }
8345
+ let current = record;
8346
+ for (let index = 0; index < segments.length; index += 1) {
8347
+ const key = segments[index] ?? "";
8348
+ if (!isJsonObject(current)) {
8349
+ return { status: "type-error", at: segments.slice(0, index).join(".") };
8350
+ }
8351
+ if (!Object.prototype.hasOwnProperty.call(current, key)) {
8352
+ return { status: "absent" };
8353
+ }
8354
+ const next = current[key];
8355
+ const last = index === segments.length - 1;
8356
+ if (!last && !isJsonObject(next)) {
8357
+ return { status: "type-error", at: segments.slice(0, index + 1).join(".") };
8358
+ }
8359
+ current = next;
8360
+ }
8361
+ return { status: "value", value: current };
8362
+ }
8363
+ function jsonRelationTerminal(value, field, path, sourceUid, diagnostics) {
8364
+ const message = `Relation field ${field} in ${path} must be a non-empty string or an array of non-empty strings`;
8365
+ if (typeof value === "string") {
8366
+ if (value.trim() === "") {
8367
+ diagnostics.push(issue("RELATION_VALUE_TYPE", message, path, 1, { node: sourceUid }));
8368
+ return [];
8369
+ }
8370
+ return [value];
8371
+ }
8372
+ if (Array.isArray(value)) {
8373
+ const refs = [];
8374
+ for (const item of value) {
8375
+ if (typeof item !== "string" || item.trim() === "") {
8376
+ diagnostics.push(issue(
8377
+ "RELATION_VALUE_TYPE",
8378
+ `Relation field ${field} in ${path} must contain only non-empty strings`,
8379
+ path,
8380
+ 1,
8381
+ { node: sourceUid }
8382
+ ));
8383
+ continue;
8384
+ }
8385
+ refs.push(item);
8386
+ }
8387
+ return refs;
8388
+ }
8389
+ diagnostics.push(issue("RELATION_VALUE_TYPE", message, path, 1, { node: sourceUid }));
8390
+ return [];
8391
+ }
8392
+ function jsonConfiguredRelations(type, path, record, schema, sourceUid) {
8393
+ const edges = [];
8394
+ const diagnostics = [];
8395
+ for (const [kind, spec] of Object.entries(schema.relationSemantics ?? {})) {
8396
+ for (const field of spec.fields) {
8397
+ const read = readJsonRelation(record, field);
8398
+ if (read.status === "absent") continue;
8399
+ if (read.status === "illegal-path") {
8400
+ diagnostics.push(issue(
8401
+ "INVALID_RELATION_FIELD",
8402
+ `Relation field ${field} is not a fixed path of own properties`,
8403
+ path,
8404
+ 1,
8405
+ { node: sourceUid }
8406
+ ));
8407
+ continue;
8408
+ }
8409
+ if (read.status === "type-error") {
8410
+ diagnostics.push(issue(
8411
+ "RELATION_VALUE_TYPE",
8412
+ `Relation field ${field} in ${path} cannot be read at ${read.at}: expected an object`,
8413
+ path,
8414
+ 1,
8415
+ { node: sourceUid }
8416
+ ));
8417
+ continue;
8418
+ }
8419
+ const values = jsonRelationTerminal(read.value, field, path, sourceUid, diagnostics);
8420
+ appendConfiguredRelationEdges(sourceUid, kind, field, values, spec, schema, path, "json", edges, diagnostics);
8421
+ }
8422
+ }
8423
+ return { edges, diagnostics };
8424
+ }
7868
8425
  function parseGenericMarkdown(type, path, raw, schema) {
7869
8426
  const diagnostics = [];
7870
- const ext = (0, import_node_path13.extname)(path).toLowerCase();
8427
+ const ext = (0, import_node_path14.extname)(path).toLowerCase();
7871
8428
  if (ext !== ".md" && ext !== ".markdown") {
7872
8429
  diagnostics.push(issue(
7873
8430
  "UNSUPPORTED_FORMAT",
@@ -7983,38 +8540,18 @@ function parseConfiguredRelations(type, path, raw, nodes, schema) {
7983
8540
  const diagnostics = [];
7984
8541
  for (const [kind, spec] of Object.entries(schema.relationSemantics ?? {})) {
7985
8542
  for (const field of spec.fields) {
7986
- for (const value of toArray(data[field])) {
7987
- const parsed = parseConfiguredRelationTarget(value, spec, schema);
7988
- if (!parsed?.code) continue;
7989
- const matchingTargetTypes = parsed.targetType ? [] : relationTargetTypeMatches(parsed.code, spec.targetTypes, schema);
7990
- const targetType = parsed.targetType ?? inferRelationTargetType(parsed.code, spec.targetTypes, schema);
7991
- if (!parsed.targetType && matchingTargetTypes.length > 1) {
7992
- diagnostics.push(issue(
7993
- "AMBIGUOUS_RELATION_TARGET",
7994
- `${sourceUid} relation ${kind} target "${parsed.code}" matches ${matchingTargetTypes.join(", ")}; use a qualified type:id reference`,
7995
- path,
7996
- 1,
7997
- { node: sourceUid }
7998
- ));
7999
- }
8000
- const targetUid = targetType ? toUid(targetType, parsed.code) : `resolve:${parsed.code}`;
8001
- if (targetType) {
8002
- const pattern = schema.idPatterns[targetType];
8003
- if (pattern && !new RegExp(pattern).test(parsed.code)) {
8004
- diagnostics.push(issue(
8005
- "FORMAT_ERROR",
8006
- `${sourceUid} has invalid ${targetType} reference "${parsed.code}" in field ${field} (expected ${pattern})`,
8007
- path,
8008
- 1,
8009
- { node: sourceUid }
8010
- ));
8011
- }
8012
- }
8013
- edges.push({
8014
- ...edge(sourceUid, targetUid, kind, "frontmatter", path, 1),
8015
- ...parsed.sections.length > 0 ? { attrs: { sections: parsed.sections } } : {}
8016
- });
8017
- }
8543
+ appendConfiguredRelationEdges(
8544
+ sourceUid,
8545
+ kind,
8546
+ field,
8547
+ toArray(data[field]),
8548
+ spec,
8549
+ schema,
8550
+ path,
8551
+ "frontmatter",
8552
+ edges,
8553
+ diagnostics
8554
+ );
8018
8555
  }
8019
8556
  }
8020
8557
  const external = getExternalEntryInfo({
@@ -8033,6 +8570,40 @@ function parseConfiguredRelations(type, path, raw, nodes, schema) {
8033
8570
  }
8034
8571
  return { edges, diagnostics };
8035
8572
  }
8573
+ function appendConfiguredRelationEdges(sourceUid, kind, field, values, spec, schema, path, edgeSource, edges, diagnostics) {
8574
+ for (const value of values) {
8575
+ const parsed = parseConfiguredRelationTarget(value, spec, schema);
8576
+ if (!parsed?.code) continue;
8577
+ const matchingTargetTypes = parsed.targetType ? [] : relationTargetTypeMatches(parsed.code, spec.targetTypes, schema);
8578
+ const targetType = parsed.targetType ?? inferRelationTargetType(parsed.code, spec.targetTypes, schema);
8579
+ if (!parsed.targetType && matchingTargetTypes.length > 1) {
8580
+ diagnostics.push(issue(
8581
+ "AMBIGUOUS_RELATION_TARGET",
8582
+ `${sourceUid} relation ${kind} target "${parsed.code}" matches ${matchingTargetTypes.join(", ")}; use a qualified type:id reference`,
8583
+ path,
8584
+ 1,
8585
+ { node: sourceUid }
8586
+ ));
8587
+ }
8588
+ const targetUid = targetType ? toUid(targetType, parsed.code) : `resolve:${parsed.code}`;
8589
+ if (targetType) {
8590
+ const pattern = schema.idPatterns[targetType];
8591
+ if (pattern && !new RegExp(pattern).test(parsed.code)) {
8592
+ diagnostics.push(issue(
8593
+ "FORMAT_ERROR",
8594
+ `${sourceUid} has invalid ${targetType} reference "${parsed.code}" in field ${field} (expected ${pattern})`,
8595
+ path,
8596
+ 1,
8597
+ { node: sourceUid }
8598
+ ));
8599
+ }
8600
+ }
8601
+ edges.push({
8602
+ ...edge(sourceUid, targetUid, kind, edgeSource, path, 1),
8603
+ ...parsed.sections.length > 0 ? { attrs: { sections: parsed.sections } } : {}
8604
+ });
8605
+ }
8606
+ }
8036
8607
  function parseConfiguredRelationTarget(value, spec, schema) {
8037
8608
  if (typeof value === "string" || typeof value === "number") {
8038
8609
  const raw = String(value).trim();
@@ -8223,7 +8794,7 @@ function parseDecisions(path, raw) {
8223
8794
  }
8224
8795
  function isTestFile(filePath) {
8225
8796
  const normalized = filePath.replace(/\\/g, "/");
8226
- const name = (0, import_node_path13.basename)(normalized);
8797
+ const name = (0, import_node_path14.basename)(normalized);
8227
8798
  if (/\.(test|spec)\.[^.]+$/.test(name)) return true;
8228
8799
  if (/(^|\/)(tests|test|__tests__)\//.test(normalized)) return true;
8229
8800
  if (/\w+Tests?\.java$/.test(name)) return true;
@@ -8538,10 +9109,10 @@ function parseE2eTest(path, raw) {
8538
9109
  const starts = extractE2eTestCaseStarts(lines);
8539
9110
  const nodes = [];
8540
9111
  const edges = [];
8541
- const batch = String(data.test_batch ?? (0, import_node_path13.basename)(path, (0, import_node_path13.extname)(path))).trim();
9112
+ const batch = String(data.test_batch ?? (0, import_node_path14.basename)(path, (0, import_node_path14.extname)(path))).trim();
8542
9113
  const frontmatterScenarios = toArray(data.related_scenarios).map((value) => String(value).trim()).filter(Boolean);
8543
9114
  const scopeFeatures = extractCodes(String(data.scope ?? ""), "feature");
8544
- const frontmatterFeatures = [.../* @__PURE__ */ new Set([...Object.keys(asRecord(data.ac_coverage)), ...scopeFeatures])];
9115
+ const frontmatterFeatures = [.../* @__PURE__ */ new Set([...Object.keys(asRecord2(data.ac_coverage)), ...scopeFeatures])];
8545
9116
  const frontmatterDecisions = toArray(data.related_decisions).map((value) => String(value).trim()).filter(Boolean);
8546
9117
  const frontmatterEntities = toArray(data.related_entities).map((value) => String(value).trim()).filter(Boolean);
8547
9118
  for (let index = 0; index < starts.length; index += 1) {
@@ -8601,7 +9172,7 @@ function parseE2eRegistry(path, raw) {
8601
9172
  data = { parseError: error.message };
8602
9173
  }
8603
9174
  return {
8604
- nodes: [{ type: "e2e_registry", code: (0, import_node_path13.basename)(path, (0, import_node_path13.extname)(path)), title: "E2E Test Registry", path, line: 1, attrs: data }],
9175
+ nodes: [{ type: "e2e_registry", code: (0, import_node_path14.basename)(path, (0, import_node_path14.extname)(path)), title: "E2E Test Registry", path, line: 1, attrs: data }],
8605
9176
  edges: []
8606
9177
  };
8607
9178
  }
@@ -9409,13 +9980,13 @@ function markdownRelationOccurrences(path, scenario, block, codeLines, label, ta
9409
9980
  return result;
9410
9981
  }
9411
9982
  function relationOccurrences2(node, field, targetType) {
9412
- const relationRecord = asRecord(node.attrs?.relationOccurrences);
9983
+ const relationRecord = asRecord2(node.attrs?.relationOccurrences);
9413
9984
  const rawOccurrences = toArray(relationRecord[field]);
9414
9985
  return rawOccurrences.flatMap((value) => {
9415
9986
  if (typeof value === "string") {
9416
9987
  return [{ field, targetType, target: value, path: node.path, line: node.line }];
9417
9988
  }
9418
- const record = asRecord(value);
9989
+ const record = asRecord2(value);
9419
9990
  const target = String(record.target ?? "").trim();
9420
9991
  if (!target) {
9421
9992
  return [];
@@ -9522,7 +10093,7 @@ function validateE2eTests(graph) {
9522
10093
  issues.push(issue("E2E_REQUIRED_FRONTMATTER", `${node.uid} missing required frontmatter ${field}`, node.path, 1, { node: node.uid, severity: "warning" }));
9523
10094
  }
9524
10095
  }
9525
- const fields = asRecord(attrs.tcFields);
10096
+ const fields = asRecord2(attrs.tcFields);
9526
10097
  const requiredTcFields = [
9527
10098
  ["\u6807\u9898", node.title],
9528
10099
  ["\u524D\u7F6E\u6761\u4EF6", fields["\u524D\u7F6E\u6761\u4EF6"]],
@@ -9572,7 +10143,7 @@ function validateE2eTests(graph) {
9572
10143
  }
9573
10144
  for (const [path, nodes] of nodesByPath) {
9574
10145
  const first = nodes[0];
9575
- const declared = flattenAcCoverage(asRecord(first.attrs?.ac_coverage));
10146
+ const declared = flattenAcCoverage(asRecord2(first.attrs?.ac_coverage));
9576
10147
  const covered = new Set(nodes.flatMap((node) => toArray(node.attrs?.coveredFeatures).map((value) => {
9577
10148
  const ref = value;
9578
10149
  return `${String(ref.feature)}:${String(ref.ac)}`;
@@ -9616,7 +10187,7 @@ function validateE2eRegistry(graph) {
9616
10187
  const first = actualNodes[0];
9617
10188
  compareRegistryValue(issues, registry, batch, "batch_id", first.attrs?.test_batch);
9618
10189
  compareRegistryValue(issues, registry, batch, "scope", first.attrs?.scope);
9619
- compareRegistryAcCoverage(issues, registry, batch, asRecord(first.attrs?.ac_coverage));
10190
+ compareRegistryAcCoverage(issues, registry, batch, asRecord2(first.attrs?.ac_coverage));
9620
10191
  compareRegistryArray(issues, registry, batch, "related_scenarios", toArray(first.attrs?.related_scenarios).map((value) => String(value)));
9621
10192
  compareRegistryValue(issues, registry, batch, "test_case_count", actualNodes.filter((node) => node.attrs?.fileLevelOnly !== true).length);
9622
10193
  }
@@ -9639,10 +10210,10 @@ async function validateExecutableTraceability(root, config) {
9639
10210
  const tcKeyToFields = /* @__PURE__ */ new Map();
9640
10211
  const mdBatches = /* @__PURE__ */ new Set();
9641
10212
  for (const relPath of e2eFiles) {
9642
- const raw = await (0, import_promises9.readFile)((0, import_node_path13.join)(root, relPath), "utf-8");
10213
+ const raw = await (0, import_promises10.readFile)((0, import_node_path14.join)(root, relPath), "utf-8");
9643
10214
  const parsed = (0, import_gray_matter.default)(raw);
9644
10215
  const data = parsed.data;
9645
- const batch = String(data.test_batch ?? (0, import_node_path13.basename)(relPath, (0, import_node_path13.extname)(relPath))).trim();
10216
+ const batch = String(data.test_batch ?? (0, import_node_path14.basename)(relPath, (0, import_node_path14.extname)(relPath))).trim();
9646
10217
  const lines = raw.split(/\r?\n/);
9647
10218
  const tcStarts = extractE2eTestCaseStarts(lines);
9648
10219
  for (let i = 0; i < tcStarts.length; i += 1) {
@@ -9681,10 +10252,10 @@ async function validateExecutableTraceability(root, config) {
9681
10252
  const tcAnnotationRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+?)\s+\[(\w+)\]/;
9682
10253
  const tcAnnotationNoLevelRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+)/;
9683
10254
  for (const specFile of specFiles) {
9684
- const fullSpecPath = (0, import_node_path13.join)(root, specFile);
10255
+ const fullSpecPath = (0, import_node_path14.join)(root, specFile);
9685
10256
  let content;
9686
10257
  try {
9687
- content = await (0, import_promises9.readFile)(fullSpecPath, "utf-8");
10258
+ content = await (0, import_promises10.readFile)(fullSpecPath, "utf-8");
9688
10259
  } catch {
9689
10260
  continue;
9690
10261
  }
@@ -9763,7 +10334,7 @@ async function validateExecutableTraceability(root, config) {
9763
10334
  if (entry.testId) {
9764
10335
  let content;
9765
10336
  try {
9766
- content = await (0, import_promises9.readFile)((0, import_node_path13.join)(root, normalizedRefFile), "utf-8");
10337
+ content = await (0, import_promises10.readFile)((0, import_node_path14.join)(root, normalizedRefFile), "utf-8");
9767
10338
  } catch {
9768
10339
  continue;
9769
10340
  }
@@ -9942,11 +10513,11 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9942
10513
  const chainTypeBreakdown = {};
9943
10514
  const tcFieldsMap = new Map(e2eNodes.map((node) => [
9944
10515
  node.code,
9945
- asRecord(node.attrs?.tcFields)
10516
+ asRecord2(node.attrs?.tcFields)
9946
10517
  ]));
9947
10518
  for (const node of e2eNodes) {
9948
10519
  const tcKey = node.code;
9949
- const fields = tcFieldsMap.get(tcKey) ?? asRecord(node.attrs?.tcFields);
10520
+ const fields = tcFieldsMap.get(tcKey) ?? asRecord2(node.attrs?.tcFields);
9950
10521
  const execRef = String(fields["executable_ref"] ?? "").trim();
9951
10522
  if (execRef && !isPendingExecutableRef(execRef)) {
9952
10523
  withExecutableRef++;
@@ -9976,8 +10547,8 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9976
10547
  }
9977
10548
  }
9978
10549
  for (const node of e2eNodes) {
9979
- const fields = tcFieldsMap.get(node.code) ?? asRecord(node.attrs?.tcFields);
9980
- const acCoverage = asRecord(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10550
+ const fields = tcFieldsMap.get(node.code) ?? asRecord2(node.attrs?.tcFields);
10551
+ const acCoverage = asRecord2(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
9981
10552
  for (const feature of Object.keys(acCoverage)) {
9982
10553
  acCoveredFeatures.add(feature);
9983
10554
  }
@@ -9989,7 +10560,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9989
10560
  const runners = (await loadConfig(root)).e2e?.runners ?? [];
9990
10561
  const allProjectFiles = await walkFiles(root);
9991
10562
  for (const node of e2eNodes) {
9992
- const fields = tcFieldsMap.get(node.code) ?? asRecord(node.attrs?.tcFields);
10563
+ const fields = tcFieldsMap.get(node.code) ?? asRecord2(node.attrs?.tcFields);
9993
10564
  const status = String(fields["status"] ?? "").trim().toLowerCase();
9994
10565
  const execRef = String(fields["executable_ref"] ?? "").trim();
9995
10566
  if (status !== "verified") continue;
@@ -9998,7 +10569,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
9998
10569
  let hasActiveE2eRef = false;
9999
10570
  for (const entry of parseExecutableRefLines(execRef)) {
10000
10571
  const normalized = resolveExecutableRefFile(entry.file, allProjectFiles);
10001
- if (!normalized || !(0, import_node_fs5.existsSync)((0, import_node_path13.join)(root, normalized))) continue;
10572
+ if (!normalized || !(0, import_node_fs5.existsSync)((0, import_node_path14.join)(root, normalized))) continue;
10002
10573
  const accepting = await getAcceptingRunners(root, normalized, runners);
10003
10574
  if (accepting.some((runner) => runner.kind === "e2e")) {
10004
10575
  hasActiveE2eRef = true;
@@ -10010,7 +10581,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
10010
10581
  for (const scenario of relatedScenarios) {
10011
10582
  verifiedScenarios.add(scenario);
10012
10583
  }
10013
- const acCoverage = asRecord(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10584
+ const acCoverage = asRecord2(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10014
10585
  for (const feature of Object.keys(acCoverage)) {
10015
10586
  verifiedFeatures.add(feature);
10016
10587
  }
@@ -10057,13 +10628,13 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
10057
10628
  const acCoverageRateByFeature = {};
10058
10629
  const featureAcMap = /* @__PURE__ */ new Map();
10059
10630
  for (const node of featureNodes) {
10060
- const acs = parseAcceptanceCriteria(await (0, import_promises9.readFile)((0, import_node_path13.join)(root, node.path), "utf-8"));
10631
+ const acs = parseAcceptanceCriteria(await (0, import_promises10.readFile)((0, import_node_path14.join)(root, node.path), "utf-8"));
10061
10632
  featureAcMap.set(node.code, new Set(acs));
10062
10633
  }
10063
10634
  const coveredAcByFeature = /* @__PURE__ */ new Map();
10064
10635
  for (const node of e2eNodes) {
10065
- const fields = tcFieldsMap.get(node.code) ?? asRecord(node.attrs?.tcFields);
10066
- const acCoverage = asRecord(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10636
+ const fields = tcFieldsMap.get(node.code) ?? asRecord2(node.attrs?.tcFields);
10637
+ const acCoverage = asRecord2(fields["ac_coverage"] ?? node.attrs?.ac_coverage);
10067
10638
  for (const [feature, acs] of Object.entries(acCoverage)) {
10068
10639
  const existing = coveredAcByFeature.get(feature) ?? /* @__PURE__ */ new Set();
10069
10640
  for (const ac of toArray(acs)) {
@@ -10105,11 +10676,11 @@ async function generateE2eRegistry(root, opts) {
10105
10676
  const batchIds = /* @__PURE__ */ new Set();
10106
10677
  let totalTestCases = 0;
10107
10678
  for (const file of files) {
10108
- const filePath = (0, import_node_path13.join)(root, file);
10109
- const raw = await (0, import_promises9.readFile)(filePath, "utf-8");
10679
+ const filePath = (0, import_node_path14.join)(root, file);
10680
+ const raw = await (0, import_promises10.readFile)(filePath, "utf-8");
10110
10681
  const parsed = (0, import_gray_matter.default)(raw);
10111
10682
  const data = parsed.data;
10112
- const batch = String(data.test_batch ?? (0, import_node_path13.basename)(file, (0, import_node_path13.extname)(file))).trim();
10683
+ const batch = String(data.test_batch ?? (0, import_node_path14.basename)(file, (0, import_node_path14.extname)(file))).trim();
10113
10684
  const relPath = file;
10114
10685
  const scope = String(data.scope ?? "").trim();
10115
10686
  const acCoverage = normalizeAcCoverageForRegistry(data.ac_coverage);
@@ -10231,10 +10802,10 @@ async function validatePartialRustEvidence(tcFields, tcKey, root, allFiles) {
10231
10802
  if (!normalizedPath) {
10232
10803
  return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
10233
10804
  }
10234
- const fullPath = (0, import_node_path13.join)(root, normalizedPath);
10805
+ const fullPath = (0, import_node_path14.join)(root, normalizedPath);
10235
10806
  let content;
10236
10807
  try {
10237
- content = await (0, import_promises9.readFile)(fullPath, "utf-8");
10808
+ content = await (0, import_promises10.readFile)(fullPath, "utf-8");
10238
10809
  } catch {
10239
10810
  return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
10240
10811
  }
@@ -10268,7 +10839,7 @@ function detectTestLevel(specFile, content) {
10268
10839
  }
10269
10840
  function resolveExecutableRefFile(refFile, allFiles) {
10270
10841
  const normalized = refFile.replace(/\\/g, "/").replace(/^\.\//, "");
10271
- if (!normalized || (0, import_node_path13.isAbsolute)(refFile) || normalized.split("/").includes("..")) {
10842
+ if (!normalized || (0, import_node_path14.isAbsolute)(refFile) || normalized.split("/").includes("..")) {
10272
10843
  return void 0;
10273
10844
  }
10274
10845
  if (allFiles.includes(normalized)) {
@@ -10443,7 +11014,7 @@ function flattenAcCoverage(value) {
10443
11014
  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)}`) })));
10444
11015
  }
10445
11016
  function needsDesktopChainWarning(node) {
10446
- const tcFields = asRecord(node.attrs?.tcFields);
11017
+ const tcFields = asRecord2(node.attrs?.tcFields);
10447
11018
  const chainType = String(tcFields["chain_type"] ?? "").trim().toLowerCase();
10448
11019
  if (chainType && VALID_CHAIN_TYPES.has(chainType) && chainType !== "desktop_chain" || chainType in DEPRECATED_CHAIN_TYPE_ALIASES) {
10449
11020
  return false;
@@ -10500,7 +11071,7 @@ function compareRegistryAcCoverage(issues, registry, batch, actual) {
10500
11071
  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" }));
10501
11072
  return;
10502
11073
  }
10503
- if (normalizeAcCoverage(asRecord(batch.ac_coverage)) !== normalizeAcCoverage(actual)) {
11074
+ if (normalizeAcCoverage(asRecord2(batch.ac_coverage)) !== normalizeAcCoverage(actual)) {
10504
11075
  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" }));
10505
11076
  }
10506
11077
  }
@@ -10515,7 +11086,7 @@ function groupBy(values, key) {
10515
11086
  }
10516
11087
  return result;
10517
11088
  }
10518
- function asRecord(value) {
11089
+ function asRecord2(value) {
10519
11090
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
10520
11091
  }
10521
11092
  function isEmptyValue(value) {
@@ -10574,7 +11145,7 @@ function normalizeDesignCode(value) {
10574
11145
  if (!raw) {
10575
11146
  return "";
10576
11147
  }
10577
- return (0, import_node_path13.basename)(raw, (0, import_node_path13.extname)(raw));
11148
+ return (0, import_node_path14.basename)(raw, (0, import_node_path14.extname)(raw));
10578
11149
  }
10579
11150
  function toUid(type, code) {
10580
11151
  return `${type}:${code}`;
@@ -10850,7 +11421,7 @@ function resolveArtifactContext(graph, opts) {
10850
11421
  }
10851
11422
  if (root) {
10852
11423
  for (const ap of ALWAYS_PRESENT_ITEMS) {
10853
- const fullPath = (0, import_node_path13.join)(root, ap.path);
11424
+ const fullPath = (0, import_node_path14.join)(root, ap.path);
10854
11425
  let stat2;
10855
11426
  try {
10856
11427
  stat2 = (0, import_node_fs5.statSync)(fullPath);
@@ -11092,14 +11663,14 @@ function formatContextMarkdown(manifest) {
11092
11663
  }
11093
11664
  return lines.join("\n");
11094
11665
  }
11095
- var import_gray_matter, import_js_yaml, import_node_fs5, import_promises9, import_node_path13, 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;
11666
+ var import_gray_matter, import_js_yaml, import_node_fs5, import_promises10, import_node_path14, 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;
11096
11667
  var init_index = __esm({
11097
11668
  "src/index.ts"() {
11098
11669
  import_gray_matter = __toESM(require("gray-matter"), 1);
11099
11670
  import_js_yaml = __toESM(require("js-yaml"), 1);
11100
11671
  import_node_fs5 = require("fs");
11101
- import_promises9 = require("fs/promises");
11102
- import_node_path13 = require("path");
11672
+ import_promises10 = require("fs/promises");
11673
+ import_node_path14 = require("path");
11103
11674
  init_packet_constants();
11104
11675
  init_packet_validator();
11105
11676
  init_glob_matcher();
@@ -11118,6 +11689,7 @@ var init_index = __esm({
11118
11689
  init_git_changes();
11119
11690
  init_git_hook_path();
11120
11691
  init_hook_installer();
11692
+ init_professional_conclusion();
11121
11693
  init_review_result_validator();
11122
11694
  init_contract_kernel();
11123
11695
  init_restructure();
@@ -11170,6 +11742,33 @@ var init_index = __esm({
11170
11742
  runners: []
11171
11743
  }
11172
11744
  };
11745
+ SPECIALIZED_PARSER_TYPES = /* @__PURE__ */ new Set([
11746
+ "feature",
11747
+ "scenario",
11748
+ "entity",
11749
+ "decision",
11750
+ "test",
11751
+ "design",
11752
+ "e2e_test",
11753
+ "e2e_registry",
11754
+ "rule-golden-cases",
11755
+ "test-strategy",
11756
+ "traceability-matrix-v2",
11757
+ "traceability-version-lock",
11758
+ "interface_contracts",
11759
+ "data_contracts",
11760
+ "application_state_machines",
11761
+ "error_model",
11762
+ "domain-glossary",
11763
+ "bounded-context-map",
11764
+ "domain-invariants",
11765
+ "generation-packet-spec",
11766
+ "report-contracts",
11767
+ "verification-fixtures",
11768
+ "ui-flow-contracts",
11769
+ "non-functional-budgets",
11770
+ "implementation-blueprint"
11771
+ ]);
11173
11772
  EMPTY_RELATION_FIELD_VALUES = /* @__PURE__ */ new Set(["\u65E0", "none", "n/a", "-"]);
11174
11773
  VALID_TC_STATUSES = /* @__PURE__ */ new Set(["created", "automated", "verified", "waived"]);
11175
11774
  VALID_CHAIN_TYPES = /* @__PURE__ */ new Set([
@@ -11228,7 +11827,11 @@ init_index();
11228
11827
  E2E_NORMALIZER_CONFIG,
11229
11828
  FILE_SET_RESULT_OBJECT,
11230
11829
  FOUNDATION_PACKAGE_NAME,
11830
+ GRAPH_DOMAIN_CODES,
11831
+ GRAPH_PROVIDER_ENTRY,
11832
+ GRAPH_PROVIDER_ID,
11231
11833
  MIN_PROMPT_CHARS,
11834
+ PROFESSIONAL_CONCLUSION_OBJECT,
11232
11835
  RESTRUCTURE_MAX_OPERATIONS,
11233
11836
  RESTRUCTURE_MAX_TOTAL_BYTES,
11234
11837
  RESTRUCTURE_PLAN_SCHEMA_VERSION,
@@ -11328,6 +11931,8 @@ init_index();
11328
11931
  resolveNodeTimeView,
11329
11932
  resolveRealRoot,
11330
11933
  restructureBoundaryFindings,
11934
+ runCheckProfessional,
11935
+ runReadProof,
11331
11936
  scanArtifacts,
11332
11937
  traceVersion,
11333
11938
  updateVersionLock,