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