@buildr-ai/buildr 0.1.0-rc.20 → 0.1.0-rc.21

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.
@@ -7409,9 +7409,90 @@ function spawnCommandSync(executable2, args, options = {}) {
7409
7409
  shell: invocation.shell
7410
7410
  });
7411
7411
  }
7412
- var import_node_fs5, import_node_path5, import_node_process3, import_node_child_process;
7412
+ function realExecutable(value, label) {
7413
+ if (!import_node_path5.default.isAbsolute(value || "")) throw new Error(`${label} must be an absolute executable path.`);
7414
+ try {
7415
+ import_node_fs5.default.accessSync(value, import_node_fs5.default.constants.X_OK);
7416
+ return import_node_fs5.default.realpathSync(value);
7417
+ } catch (error3) {
7418
+ throw new Error(`${label} is not executable: ${value} (${error3.code || error3.message})`);
7419
+ }
7420
+ }
7421
+ function createExactNodePathEnvironment(sourceEnv, bin, options = {}) {
7422
+ const platform = options.platform ?? import_node_process3.default.platform;
7423
+ const pathApi = platform === "win32" ? import_node_path5.default.win32 : import_node_path5.default;
7424
+ const inheritedEnv = { ...sourceEnv };
7425
+ const matchingKeys = Object.keys(inheritedEnv).filter((key) => key.toLowerCase() === "path");
7426
+ const sourceKey = platform === "win32" ? matchingKeys.find((key) => key === "PATH") ?? matchingKeys[0] : "PATH";
7427
+ const inheritedPath = String(inheritedEnv[sourceKey] ?? "");
7428
+ if (platform === "win32") for (const key of matchingKeys) delete inheritedEnv[key];
7429
+ const normalizedBin = pathApi.resolve(bin);
7430
+ const pathEntries = [
7431
+ bin,
7432
+ ...inheritedPath.split(pathApi.delimiter).filter(Boolean).filter((entry) => {
7433
+ const normalizedEntry = pathApi.resolve(entry);
7434
+ return platform === "win32" ? normalizedEntry.toLowerCase() !== normalizedBin.toLowerCase() : normalizedEntry !== normalizedBin;
7435
+ })
7436
+ ];
7437
+ return { env: { ...inheritedEnv, PATH: pathEntries.join(pathApi.delimiter) }, pathEntries };
7438
+ }
7439
+ function createExactNodeExecutionEnvironment(options = {}) {
7440
+ const inheritedEnv = { ...options.env ?? import_node_process3.default.env };
7441
+ const nodeExecutable = realExecutable(options.nodeExecutable ?? import_node_process3.default.execPath, "Node executable");
7442
+ const bin = import_node_path5.default.dirname(nodeExecutable);
7443
+ const nodeName = import_node_process3.default.platform === "win32" ? "node.exe" : "node";
7444
+ const npmName = import_node_process3.default.platform === "win32" ? "npm.cmd" : "npm";
7445
+ const pathNode = import_node_path5.default.join(bin, nodeName);
7446
+ const npmExecutable = import_node_path5.default.join(bin, npmName);
7447
+ if (!import_node_fs5.default.statSync(pathNode, { throwIfNoEntry: false })?.isFile() && import_node_path5.default.basename(nodeExecutable).toLowerCase() !== nodeName) {
7448
+ throw new Error(`Node bin does not contain ${nodeName}: ${bin}`);
7449
+ }
7450
+ if (options.requireNpm && !import_node_fs5.default.statSync(npmExecutable, { throwIfNoEntry: false })?.isFile()) {
7451
+ throw new Error(`Exact Node bin does not contain ${npmName}: ${bin}`);
7452
+ }
7453
+ const { env, pathEntries } = createExactNodePathEnvironment(inheritedEnv, bin);
7454
+ let version = options.expectedVersion ?? (nodeExecutable === import_node_fs5.default.realpathSync(import_node_process3.default.execPath) ? import_node_process3.default.versions.node : null);
7455
+ let reportedExecutable = nodeExecutable;
7456
+ if (options.verify !== false) {
7457
+ const probe2 = (0, import_node_child_process.spawnSync)(nodeExecutable, ["-p", "JSON.stringify({version:process.versions.node,execPath:process.execPath})"], { encoding: "utf8", env });
7458
+ if (probe2.status !== 0) throw new Error(`Exact Node identity probe failed: ${(probe2.stderr || probe2.stdout || "").trim()}`);
7459
+ let identity6;
7460
+ try {
7461
+ identity6 = JSON.parse(probe2.stdout);
7462
+ } catch {
7463
+ throw new Error("Exact Node identity probe returned invalid JSON.");
7464
+ }
7465
+ version = identity6.version;
7466
+ reportedExecutable = realExecutable(identity6.execPath, "Node reported executable");
7467
+ const pathProbe = (0, import_node_child_process.spawnSync)("node", ["-p", "JSON.stringify({version:process.versions.node,execPath:process.execPath})"], { encoding: "utf8", env, shell: false });
7468
+ if (pathProbe.status !== 0) throw new Error(`PATH Node identity probe failed: ${(pathProbe.stderr || pathProbe.stdout || "").trim()}`);
7469
+ let pathIdentity;
7470
+ try {
7471
+ pathIdentity = JSON.parse(pathProbe.stdout);
7472
+ } catch {
7473
+ throw new Error("PATH Node identity probe returned invalid JSON.");
7474
+ }
7475
+ const pathExecutable = realExecutable(pathIdentity.execPath, "PATH Node reported executable");
7476
+ if (pathExecutable !== reportedExecutable || pathIdentity.version !== version) {
7477
+ throw new Error(`PATH Node identity does not match the exact executable: ${JSON.stringify({ exact: { executable: reportedExecutable, version }, path: { executable: pathExecutable, version: pathIdentity.version } })}`);
7478
+ }
7479
+ }
7480
+ if (options.expectedVersion && version !== options.expectedVersion) throw new Error(`Exact Node version ${version} does not match required ${options.expectedVersion}.`);
7481
+ const audit = {
7482
+ schemaVersion: "buildr.exact-node-execution-environment/v1",
7483
+ executable: reportedExecutable,
7484
+ version,
7485
+ bin,
7486
+ pathHead: pathEntries[0],
7487
+ npmExecutable: import_node_fs5.default.statSync(npmExecutable, { throwIfNoEntry: false })?.isFile() ? npmExecutable : null
7488
+ };
7489
+ audit.identity = `sha256-${import_node_crypto4.default.createHash("sha256").update(JSON.stringify(audit)).digest("hex")}`;
7490
+ return { nodeExecutable: reportedExecutable, npmExecutable: audit.npmExecutable, env, audit };
7491
+ }
7492
+ var import_node_crypto4, import_node_fs5, import_node_path5, import_node_process3, import_node_child_process;
7413
7493
  var init_process = __esm({
7414
7494
  "src/infrastructure/process.mjs"() {
7495
+ import_node_crypto4 = __toESM(require("node:crypto"), 1);
7415
7496
  import_node_fs5 = __toESM(require("node:fs"), 1);
7416
7497
  import_node_path5 = __toESM(require("node:path"), 1);
7417
7498
  import_node_process3 = __toESM(require("node:process"), 1);
@@ -7596,7 +7677,7 @@ function gitArguments(args) {
7596
7677
  return process.platform === "win32" ? ["-c", "core.longpaths=true", ...args] : args;
7597
7678
  }
7598
7679
  function digest9(value) {
7599
- return `sha256-${import_node_crypto38.default.createHash("sha256").update(value).digest("hex")}`;
7680
+ return `sha256-${import_node_crypto39.default.createHash("sha256").update(value).digest("hex")}`;
7600
7681
  }
7601
7682
  function normalizePath(value) {
7602
7683
  return import_node_path64.default.posix.normalize(String(value || "").replaceAll("\\", "/")).replace(/^\.\//, "");
@@ -7685,10 +7766,10 @@ function observeGitTaskContribution({ root, deliveryBaselineHead }) {
7685
7766
  source: { head: sourceHead, tree: sourceTree }
7686
7767
  }));
7687
7768
  }
7688
- var import_node_crypto38, import_node_fs56, import_node_os8, import_node_path64, import_node_child_process4, MAX_BUFFER;
7769
+ var import_node_crypto39, import_node_fs56, import_node_os8, import_node_path64, import_node_child_process4, MAX_BUFFER;
7689
7770
  var init_git_task_contribution = __esm({
7690
7771
  "src/infrastructure/git/git-task-contribution.mjs"() {
7691
- import_node_crypto38 = __toESM(require("node:crypto"), 1);
7772
+ import_node_crypto39 = __toESM(require("node:crypto"), 1);
7692
7773
  import_node_fs56 = __toESM(require("node:fs"), 1);
7693
7774
  import_node_os8 = __toESM(require("node:os"), 1);
7694
7775
  import_node_path64 = __toESM(require("node:path"), 1);
@@ -7700,7 +7781,7 @@ var init_git_task_contribution = __esm({
7700
7781
 
7701
7782
  // src/application/task-finish/task-finish-delivery-commit.mjs
7702
7783
  function digest10(message) {
7703
- return `sha256-${import_node_crypto39.default.createHash("sha256").update(message).digest("hex")}`;
7784
+ return `sha256-${import_node_crypto40.default.createHash("sha256").update(message).digest("hex")}`;
7704
7785
  }
7705
7786
  function deliveryCommitError(code, message) {
7706
7787
  return Object.assign(new Error(message), {
@@ -7756,10 +7837,10 @@ function taskFinishDeliveryCommitMatches(expected, actualMessage) {
7756
7837
  const observed = taskFinishDeliveryCommitFromMessage(actualMessage);
7757
7838
  return { matches: expected.identity === observed.identity && expected.subject === observed.subject, observed };
7758
7839
  }
7759
- var import_node_crypto39, BUILD_TASK_TRAILER;
7840
+ var import_node_crypto40, BUILD_TASK_TRAILER;
7760
7841
  var init_task_finish_delivery_commit = __esm({
7761
7842
  "src/application/task-finish/task-finish-delivery-commit.mjs"() {
7762
- import_node_crypto39 = __toESM(require("node:crypto"), 1);
7843
+ import_node_crypto40 = __toESM(require("node:crypto"), 1);
7763
7844
  BUILD_TASK_TRAILER = /^Buildr-Task:\s*(.*)$/;
7764
7845
  }
7765
7846
  });
@@ -7775,7 +7856,7 @@ function carrierRoot(workspaceRoot, runId, repositorySelector = null) {
7775
7856
  const container = carrierContainer(workspaceRoot, runId);
7776
7857
  if (!repositorySelector) return container;
7777
7858
  const readable = String(repositorySelector).replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || "repository";
7778
- const identity6 = import_node_crypto40.default.createHash("sha256").update(String(repositorySelector)).digest("hex").slice(0, 12);
7859
+ const identity6 = import_node_crypto41.default.createHash("sha256").update(String(repositorySelector)).digest("hex").slice(0, 12);
7779
7860
  const target = import_node_path65.default.resolve(container, `${readable}-${identity6}`);
7780
7861
  if (import_node_path65.default.dirname(target) !== container) throw new Error("Task Finish repository carrier path escapes its run-owned root.");
7781
7862
  return target;
@@ -7817,7 +7898,7 @@ function taskContributionConflictPaths(repositoryRoot, taskContribution, deliver
7817
7898
  return activationPaths2.filter((file) => deliveryBaselinePaths.has(file));
7818
7899
  }
7819
7900
  function containmentIdentity(value) {
7820
- return `sha256-${import_node_crypto40.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
7901
+ return `sha256-${import_node_crypto41.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
7821
7902
  }
7822
7903
  function inspectGitCarrierContainment({ repositoryRoot, targetRef, carrier }) {
7823
7904
  const carrierRef = carrier?.head || null;
@@ -8160,10 +8241,10 @@ function verifyGitNoContributionProof({ taskRoot, targetRef, proof }) {
8160
8241
  return { status: "stale", code: "git_worktree_no_contribution_proof_failed", diagnostic: error3.message };
8161
8242
  }
8162
8243
  }
8163
- var import_node_crypto40, import_node_fs57, import_node_path65;
8244
+ var import_node_crypto41, import_node_fs57, import_node_path65;
8164
8245
  var init_git_task_contribution2 = __esm({
8165
8246
  "src/application/task-finish/git-task-contribution.mjs"() {
8166
- import_node_crypto40 = __toESM(require("node:crypto"), 1);
8247
+ import_node_crypto41 = __toESM(require("node:crypto"), 1);
8167
8248
  import_node_fs57 = __toESM(require("node:fs"), 1);
8168
8249
  import_node_path65 = __toESM(require("node:path"), 1);
8169
8250
  init_git_task_contribution();
@@ -8260,7 +8341,7 @@ var init_task_finish_delivery_remote = __esm({
8260
8341
 
8261
8342
  // src/application/task-finish/task-finish-repository-set.mjs
8262
8343
  function digest11(value) {
8263
- return `sha256-${import_node_crypto42.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
8344
+ return `sha256-${import_node_crypto43.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
8264
8345
  }
8265
8346
  function requiredString(value, field) {
8266
8347
  if (typeof value !== "string" || !value.trim()) throw new Error(`Task Finish repository requires ${field}.`);
@@ -8366,10 +8447,10 @@ function taskFinishDeliverySetIdentity(repositories) {
8366
8447
  const deliveries = (repositories || []).filter((repository) => repository.delivery?.finalRemoteRef).map((repository) => ({ selector: repository.selector, finalRemoteRef: repository.delivery.finalRemoteRef }));
8367
8448
  return deliveries.length ? digest11(deliveries) : null;
8368
8449
  }
8369
- var import_node_crypto42, import_node_path69, TASK_FINISH_REPOSITORY_DISPOSITIONS;
8450
+ var import_node_crypto43, import_node_path69, TASK_FINISH_REPOSITORY_DISPOSITIONS;
8370
8451
  var init_task_finish_repository_set = __esm({
8371
8452
  "src/application/task-finish/task-finish-repository-set.mjs"() {
8372
- import_node_crypto42 = __toESM(require("node:crypto"), 1);
8453
+ import_node_crypto43 = __toESM(require("node:crypto"), 1);
8373
8454
  import_node_path69 = __toESM(require("node:path"), 1);
8374
8455
  TASK_FINISH_REPOSITORY_DISPOSITIONS = Object.freeze(["applicable", "not-applicable"]);
8375
8456
  }
@@ -8385,7 +8466,7 @@ var init_task_retrospective_prompt = __esm({
8385
8466
 
8386
8467
  // src/application/task-finish/execution-record.mjs
8387
8468
  function digest12(value) {
8388
- return `sha256-${import_node_crypto43.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
8469
+ return `sha256-${import_node_crypto44.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
8389
8470
  }
8390
8471
  function portableFailure(value) {
8391
8472
  if (!value) return null;
@@ -8615,10 +8696,10 @@ function publicTaskFinishExecutionRecord(status, options = {}) {
8615
8696
  nextActions: options.nextActions || []
8616
8697
  };
8617
8698
  }
8618
- var import_node_crypto43, TASK_FINISH_EXECUTION_RECORD_OWNER, TASK_FINISH_EXECUTION_RECORD_KIND, TASK_FINISH_EXECUTION_RECORD_PRODUCER, TASK_FINISH_RAW_COMMAND_OUTPUT, PUBLIC_STATUSES, OUTCOMES, PHASES, MAPPER_FIELDS;
8699
+ var import_node_crypto44, TASK_FINISH_EXECUTION_RECORD_OWNER, TASK_FINISH_EXECUTION_RECORD_KIND, TASK_FINISH_EXECUTION_RECORD_PRODUCER, TASK_FINISH_RAW_COMMAND_OUTPUT, PUBLIC_STATUSES, OUTCOMES, PHASES, MAPPER_FIELDS;
8619
8700
  var init_execution_record = __esm({
8620
8701
  "src/application/task-finish/execution-record.mjs"() {
8621
- import_node_crypto43 = __toESM(require("node:crypto"), 1);
8702
+ import_node_crypto44 = __toESM(require("node:crypto"), 1);
8622
8703
  TASK_FINISH_EXECUTION_RECORD_OWNER = "task-finish";
8623
8704
  TASK_FINISH_EXECUTION_RECORD_KIND = "finish-diagnostics";
8624
8705
  TASK_FINISH_EXECUTION_RECORD_PRODUCER = "buildr.task-finish-runner/v1";
@@ -8651,7 +8732,7 @@ function now(clock) {
8651
8732
  return new Date(clock()).toISOString();
8652
8733
  }
8653
8734
  function sha2565(value) {
8654
- return `sha256-${import_node_crypto44.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
8735
+ return `sha256-${import_node_crypto45.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
8655
8736
  }
8656
8737
  function resolvedFinishContext(identity6) {
8657
8738
  const repositories = (identity6.repositories || []).map((repository) => ({
@@ -8752,7 +8833,7 @@ function normalizeIdentity(input) {
8752
8833
  }
8753
8834
  function generateRunId(identity6, clock) {
8754
8835
  const stamp = new Date(clock()).toISOString().replace(/[-:.TZ]/g, "").slice(0, 14);
8755
- return `${identity6.task}-${stamp}-${import_node_crypto44.default.randomBytes(4).toString("hex")}`;
8836
+ return `${identity6.task}-${stamp}-${import_node_crypto45.default.randomBytes(4).toString("hex")}`;
8756
8837
  }
8757
8838
  function normalizeDevelopmentHandoff(handoff, identity6) {
8758
8839
  if (handoff == null) return null;
@@ -9196,10 +9277,10 @@ function readTaskFinishResults({ root, taskId: taskId2, clock = Date.now, runtim
9196
9277
  }))
9197
9278
  };
9198
9279
  }
9199
- var import_node_crypto44, import_node_path70, LEGACY_FINISH_RUN_SCHEMA, FINISH_RUN_SCHEMA, FINISH_RESULT_SCHEMA, FINISH_PHASES, FINISH_PHASE_STATUSES, RUN_ID_PATTERN;
9280
+ var import_node_crypto45, import_node_path70, LEGACY_FINISH_RUN_SCHEMA, FINISH_RUN_SCHEMA, FINISH_RESULT_SCHEMA, FINISH_PHASES, FINISH_PHASE_STATUSES, RUN_ID_PATTERN;
9200
9281
  var init_task_finish_run = __esm({
9201
9282
  "src/application/task-finish/task-finish-run.mjs"() {
9202
- import_node_crypto44 = __toESM(require("node:crypto"), 1);
9283
+ import_node_crypto45 = __toESM(require("node:crypto"), 1);
9203
9284
  import_node_path70 = __toESM(require("node:path"), 1);
9204
9285
  init_task_retrospective_prompt();
9205
9286
  init_execution_record();
@@ -9216,7 +9297,7 @@ var init_task_finish_run = __esm({
9216
9297
 
9217
9298
  // src/application/task-finish/task-finish-activation.mjs
9218
9299
  function digest15(value) {
9219
- return `sha256-${import_node_crypto47.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
9300
+ return `sha256-${import_node_crypto48.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
9220
9301
  }
9221
9302
  function portable(value) {
9222
9303
  return String(value || "").replaceAll("\\", "/").replace(/^\.\//, "");
@@ -9231,10 +9312,10 @@ function planRetainedTaskFinishActivation({ agent, changedPaths = [] }) {
9231
9312
  if (runtimePaths.length) return finishPlan({ mode: "render-runtime", agent, matchedPaths: runtimePaths, gitEffect: "forbidden" });
9232
9313
  return finishPlan({ mode: "none", agent, matchedPaths: [], gitEffect: "forbidden" });
9233
9314
  }
9234
- var import_node_crypto47, ROOT_RUNTIME_SOURCE;
9315
+ var import_node_crypto48, ROOT_RUNTIME_SOURCE;
9235
9316
  var init_task_finish_activation = __esm({
9236
9317
  "src/application/task-finish/task-finish-activation.mjs"() {
9237
- import_node_crypto47 = __toESM(require("node:crypto"), 1);
9318
+ import_node_crypto48 = __toESM(require("node:crypto"), 1);
9238
9319
  ROOT_RUNTIME_SOURCE = /^(?:AGENTS\.md$|rules\/|skills\/|components\/|commands\/|capabilities\.yml$|commands\.yml$)/;
9239
9320
  }
9240
9321
  });
@@ -9245,7 +9326,7 @@ __export(task_finish_product_executor_exports, {
9245
9326
  createTaskFinishProductHandlers: () => createTaskFinishProductHandlers
9246
9327
  });
9247
9328
  function digest16(value) {
9248
- return `sha256-${import_node_crypto48.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
9329
+ return `sha256-${import_node_crypto49.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
9249
9330
  }
9250
9331
  function remoteReadback(root, remote, branch, operations2) {
9251
9332
  let observed = null;
@@ -9352,14 +9433,14 @@ function commandObservation(id3, command, args, cwd, result5, startedAt, duratio
9352
9433
  function runCommand(id3, command, args, cwd, options = {}) {
9353
9434
  const started = import_node_process32.default.hrtime.bigint();
9354
9435
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
9355
- const runtimePath2 = `${import_node_path74.default.dirname(import_node_process32.default.execPath)}${import_node_path74.default.delimiter}${import_node_process32.default.env.PATH || ""}`;
9436
+ const exactNode = createExactNodeExecutionEnvironment({ nodeExecutable: import_node_process32.default.execPath, env: import_node_process32.default.env, verify: false });
9356
9437
  let result5;
9357
9438
  try {
9358
9439
  result5 = (0, import_node_child_process9.spawnSync)(command, args, {
9359
9440
  cwd,
9360
9441
  encoding: "utf8",
9361
9442
  maxBuffer: MAX_OUTPUT_BYTES4,
9362
- env: options.env || { ...import_node_process32.default.env, PATH: runtimePath2 }
9443
+ env: options.env || exactNode.env
9363
9444
  });
9364
9445
  } catch (error3) {
9365
9446
  result5 = { status: null, signal: null, error: error3, stdout: "", stderr: "" };
@@ -10296,10 +10377,10 @@ function createTaskFinishProductHandlers(options) {
10296
10377
  const repositorySet = createRepositorySetTaskFinishProductHandlers(options);
10297
10378
  return Object.fromEntries(Object.keys(legacy).map((phase2) => [phase2, (input) => Array.isArray(input.run?.identity?.repositories) && input.run.identity.repositories.length > 0 ? repositorySet[phase2](input) : legacy[phase2](input)]));
10298
10379
  }
10299
- var import_node_crypto48, import_node_fs61, import_node_path74, import_node_process32, import_node_child_process9, MAX_OUTPUT_BYTES4, REMOTE_READBACK_ATTEMPTS;
10380
+ var import_node_crypto49, import_node_fs61, import_node_path74, import_node_process32, import_node_child_process9, MAX_OUTPUT_BYTES4, REMOTE_READBACK_ATTEMPTS;
10300
10381
  var init_task_finish_product_executor = __esm({
10301
10382
  "src/application/task-finish/task-finish-product-executor.mjs"() {
10302
- import_node_crypto48 = __toESM(require("node:crypto"), 1);
10383
+ import_node_crypto49 = __toESM(require("node:crypto"), 1);
10303
10384
  import_node_fs61 = __toESM(require("node:fs"), 1);
10304
10385
  import_node_path74 = __toESM(require("node:path"), 1);
10305
10386
  import_node_process32 = __toESM(require("node:process"), 1);
@@ -10312,6 +10393,7 @@ var init_task_finish_product_executor = __esm({
10312
10393
  init_execution_record();
10313
10394
  init_task_finish_delivery_commit();
10314
10395
  init_final_doctor_process();
10396
+ init_process();
10315
10397
  init_git_task_contribution2();
10316
10398
  init_task_finish_repository_set();
10317
10399
  MAX_OUTPUT_BYTES4 = 4 * 1024 * 1024;
@@ -10449,13 +10531,31 @@ function validateApplicationPayloadManifest(value) {
10449
10531
  function sourceServiceRoot() {
10450
10532
  try {
10451
10533
  const moduleUrl = import_meta.url;
10452
- if (typeof moduleUrl === "string" && moduleUrl.startsWith("file:")) return import_node_path.default.resolve(import_node_path.default.dirname((0, import_node_url.fileURLToPath)(moduleUrl)), "../../..");
10534
+ if (typeof moduleUrl === "string" && moduleUrl.startsWith("file:")) {
10535
+ const moduleFile = (0, import_node_url.fileURLToPath)(moduleUrl);
10536
+ if (import_node_path.default.basename(moduleFile) === "index.mjs" && import_node_path.default.basename(import_node_path.default.dirname(moduleFile)) === "product-resources") {
10537
+ return import_node_path.default.resolve(import_node_path.default.dirname(moduleFile), "../../..");
10538
+ }
10539
+ if (import_node_path.default.basename(moduleFile) === "buildr.cjs" && import_node_path.default.basename(import_node_path.default.dirname(moduleFile)) === "runtime") {
10540
+ return import_node_path.default.resolve(import_node_path.default.dirname(moduleFile), "..");
10541
+ }
10542
+ }
10543
+ } catch {
10544
+ }
10545
+ let invoked = import_node_path.default.resolve(import_node_process.default.argv[1] || "");
10546
+ try {
10547
+ invoked = import_node_fs.default.realpathSync(invoked);
10453
10548
  } catch {
10454
10549
  }
10455
- const invoked = import_node_path.default.resolve(import_node_process.default.argv[1] || "");
10456
10550
  if (import_node_path.default.basename(invoked) === "buildr.mjs" && import_node_path.default.basename(import_node_path.default.dirname(invoked)) === "bin") return import_node_path.default.resolve(import_node_path.default.dirname(invoked), "..");
10457
10551
  return null;
10458
10552
  }
10553
+ function resolveControllerSourceRoot({ required = true } = {}) {
10554
+ const root = sourceServiceRoot();
10555
+ if (root) return root;
10556
+ if (required) throw new Error("Buildr controller source root is unavailable; writer provenance cannot use application payload identity as a fallback.");
10557
+ return null;
10558
+ }
10459
10559
  function candidateInstalledRoots() {
10460
10560
  const roots = [];
10461
10561
  if (import_node_process.default.env.BUILDR_APPLICATION_PAYLOAD_ROOT) roots.push(import_node_path.default.resolve(import_node_process.default.env.BUILDR_APPLICATION_PAYLOAD_ROOT));
@@ -10533,7 +10633,7 @@ function resolveProductRoot() {
10533
10633
  const layout = layoutForRoot(payloadRoot);
10534
10634
  return layout === "installed" ? import_node_path.default.join(payloadRoot, "payload", "product") : import_node_path.default.join(payloadRoot, "resources", "product");
10535
10635
  }
10536
- const source = sourceServiceRoot();
10636
+ const source = resolveControllerSourceRoot({ required: false });
10537
10637
  if (!source) throw new Error("Buildr product root is unavailable.");
10538
10638
  return source;
10539
10639
  }
@@ -11604,7 +11704,7 @@ function registerWorkspaceManifestRepository(runtime2) {
11604
11704
  }
11605
11705
 
11606
11706
  // src/infrastructure/filesystem/workspace-registry-repository.mjs
11607
- var import_node_crypto6 = __toESM(require("node:crypto"), 1);
11707
+ var import_node_crypto7 = __toESM(require("node:crypto"), 1);
11608
11708
  var import_node_fs9 = __toESM(require("node:fs"), 1);
11609
11709
  var import_node_path10 = __toESM(require("node:path"), 1);
11610
11710
  var import_node_process7 = __toESM(require("node:process"), 1);
@@ -11614,7 +11714,7 @@ var import_node_fs8 = __toESM(require("node:fs"), 1);
11614
11714
  var import_node_path8 = __toESM(require("node:path"), 1);
11615
11715
 
11616
11716
  // src/infrastructure/product-identity/installation-origin.mjs
11617
- var import_node_crypto4 = __toESM(require("node:crypto"), 1);
11717
+ var import_node_crypto5 = __toESM(require("node:crypto"), 1);
11618
11718
  var import_node_fs7 = __toESM(require("node:fs"), 1);
11619
11719
  var import_node_path7 = __toESM(require("node:path"), 1);
11620
11720
  var import_node_process5 = __toESM(require("node:process"), 1);
@@ -11638,7 +11738,7 @@ var RECEIPT_KEYS = Object.freeze([
11638
11738
  "ownershipIdentity"
11639
11739
  ]);
11640
11740
  function sha2562(value) {
11641
- return `sha256-${import_node_crypto4.default.createHash("sha256").update(value).digest("hex")}`;
11741
+ return `sha256-${import_node_crypto5.default.createHash("sha256").update(value).digest("hex")}`;
11642
11742
  }
11643
11743
  function originMaterial(value) {
11644
11744
  return {
@@ -11840,7 +11940,7 @@ function readCurrentProductIdentity() {
11840
11940
  }
11841
11941
 
11842
11942
  // src/infrastructure/product-identity/web-profile.mjs
11843
- var import_node_crypto5 = __toESM(require("node:crypto"), 1);
11943
+ var import_node_crypto6 = __toESM(require("node:crypto"), 1);
11844
11944
  var import_node_os2 = __toESM(require("node:os"), 1);
11845
11945
  var import_node_path9 = __toESM(require("node:path"), 1);
11846
11946
  var import_node_process6 = __toESM(require("node:process"), 1);
@@ -11848,7 +11948,7 @@ init_filesystem_path_identity();
11848
11948
  var WEB_PROFILE_SCHEMA = "buildr.web-profile/v1";
11849
11949
  var WEB_PROFILE_NAMES = Object.freeze(["released", "development"]);
11850
11950
  function sha2563(value) {
11851
- return `sha256-${import_node_crypto5.default.createHash("sha256").update(value).digest("hex")}`;
11951
+ return `sha256-${import_node_crypto6.default.createHash("sha256").update(value).digest("hex")}`;
11852
11952
  }
11853
11953
  function runtimeRole(identity6) {
11854
11954
  return identity6?.runtime?.role || identity6?.runtimeRole || "unknown";
@@ -11923,7 +12023,7 @@ function oppositeWebProfile(profile, productIdentity, options = {}) {
11923
12023
  // src/infrastructure/filesystem/workspace-registry-repository.mjs
11924
12024
  var WORKSPACE_REGISTRY_SCHEMA = "buildr.local-workspace-registry/v1";
11925
12025
  function registryRevision(content) {
11926
- return `sha256-${import_node_crypto6.default.createHash("sha256").update(content).digest("hex")}`;
12026
+ return `sha256-${import_node_crypto7.default.createHash("sha256").update(content).digest("hex")}`;
11927
12027
  }
11928
12028
  function localAppDataRoot({ respectOverride = true } = {}) {
11929
12029
  if (respectOverride && import_node_process7.default.env.BUILDR_APP_DATA_DIR) return import_node_path10.default.resolve(import_node_process7.default.env.BUILDR_APP_DATA_DIR);
@@ -12259,7 +12359,7 @@ function registerWorkspaceManagementFence(runtime2, options = {}) {
12259
12359
  }
12260
12360
 
12261
12361
  // src/infrastructure/filesystem/project-manifest-repository.mjs
12262
- var import_node_crypto7 = __toESM(require("node:crypto"), 1);
12362
+ var import_node_crypto8 = __toESM(require("node:crypto"), 1);
12263
12363
  var import_node_fs11 = __toESM(require("node:fs"), 1);
12264
12364
  var import_node_path12 = __toESM(require("node:path"), 1);
12265
12365
  var import_yaml4 = __toESM(require_dist(), 1);
@@ -12410,7 +12510,7 @@ function renderProjectsManifest(projects) {
12410
12510
  return import_yaml4.default.stringify(document, { lineWidth: 0 });
12411
12511
  }
12412
12512
  function projectManifestRevision(content) {
12413
- return `sha256-${import_node_crypto7.default.createHash("sha256").update(content).digest("hex")}`;
12513
+ return `sha256-${import_node_crypto8.default.createHash("sha256").update(content).digest("hex")}`;
12414
12514
  }
12415
12515
  function registerProjectManifestRepository(runtime2) {
12416
12516
  function projectsManifestPath(targetRoot) {
@@ -12444,7 +12544,7 @@ function registerProjectManifestRepository(runtime2) {
12444
12544
  }
12445
12545
 
12446
12546
  // src/infrastructure/filesystem/service-manifest-repository.mjs
12447
- var import_node_crypto8 = __toESM(require("node:crypto"), 1);
12547
+ var import_node_crypto9 = __toESM(require("node:crypto"), 1);
12448
12548
  var import_node_fs12 = __toESM(require("node:fs"), 1);
12449
12549
  var import_node_path13 = __toESM(require("node:path"), 1);
12450
12550
  var import_yaml5 = __toESM(require_dist(), 1);
@@ -12599,7 +12699,7 @@ function renderServicesDomainManifest(projectId, services) {
12599
12699
  return import_yaml5.default.stringify(document, { lineWidth: 0 });
12600
12700
  }
12601
12701
  function serviceManifestRevision(content) {
12602
- return `sha256-${import_node_crypto8.default.createHash("sha256").update(content).digest("hex")}`;
12702
+ return `sha256-${import_node_crypto9.default.createHash("sha256").update(content).digest("hex")}`;
12603
12703
  }
12604
12704
  function registerServiceManifestRepository(runtime2) {
12605
12705
  function serviceDomainManifestPath(targetRoot, projectCode) {
@@ -12620,7 +12720,7 @@ function registerServiceManifestRepository(runtime2) {
12620
12720
  }
12621
12721
 
12622
12722
  // src/infrastructure/sqlite/workspace-sqlite.mjs
12623
- var import_node_crypto9 = __toESM(require("node:crypto"), 1);
12723
+ var import_node_crypto10 = __toESM(require("node:crypto"), 1);
12624
12724
  var import_node_fs14 = __toESM(require("node:fs"), 1);
12625
12725
  var import_node_path15 = __toESM(require("node:path"), 1);
12626
12726
  var import_node_sqlite = require("node:sqlite");
@@ -12630,7 +12730,7 @@ var MIGRATIONS_ROOT = resolveProductResource("product/src/infrastructure/sqlite/
12630
12730
  var BUSY_TIMEOUT_MS = 5e3;
12631
12731
  var defaultMigrationScripts = null;
12632
12732
  function digest(bytes) {
12633
- return `sha256-${import_node_crypto9.default.createHash("sha256").update(bytes).digest("hex")}`;
12733
+ return `sha256-${import_node_crypto10.default.createHash("sha256").update(bytes).digest("hex")}`;
12634
12734
  }
12635
12735
  function structuredStoreError(code, message, status = 409, details = void 0, nextAction = void 0) {
12636
12736
  const error3 = new Error(message);
@@ -12742,9 +12842,10 @@ function configure(database, { writable }) {
12742
12842
  }
12743
12843
  function registerWorkspaceSqlite(runtime2, { observeCheckout = observeGitCheckoutIdentity, sourceRoot = null } = {}) {
12744
12844
  const operationScopes = [];
12845
+ let writerSourceRoot = sourceRoot ? import_node_path15.default.resolve(sourceRoot) : null;
12745
12846
  function runtimeSourceCheckout() {
12746
- const root = import_node_path15.default.resolve(sourceRoot || runtime2.productRoot());
12747
- return { root, checkout: observeCheckout(root) };
12847
+ writerSourceRoot ||= import_node_path15.default.resolve(resolveControllerSourceRoot());
12848
+ return { root: writerSourceRoot, checkout: observeCheckout(writerSourceRoot) };
12748
12849
  }
12749
12850
  function isCandidateValidationWorkspace(source, target) {
12750
12851
  return Boolean(
@@ -12936,7 +13037,7 @@ function registerWorkspaceSqlite(runtime2, { observeCheckout = observeGitCheckou
12936
13037
  }
12937
13038
 
12938
13039
  // src/infrastructure/sqlite/task-record-repository.mjs
12939
- var import_node_crypto10 = __toESM(require("node:crypto"), 1);
13040
+ var import_node_crypto11 = __toESM(require("node:crypto"), 1);
12940
13041
  var import_node_fs15 = __toESM(require("node:fs"), 1);
12941
13042
  var import_node_path16 = __toESM(require("node:path"), 1);
12942
13043
 
@@ -13107,7 +13208,7 @@ function normalizeTaskRecord(value, { expectedTaskId = null } = {}) {
13107
13208
 
13108
13209
  // src/infrastructure/sqlite/task-record-repository.mjs
13109
13210
  function digestRecord(record) {
13110
- return `sha256-${import_node_crypto10.default.createHash("sha256").update(JSON.stringify(record)).digest("hex")}`;
13211
+ return `sha256-${import_node_crypto11.default.createHash("sha256").update(JSON.stringify(record)).digest("hex")}`;
13111
13212
  }
13112
13213
  function asTaskRecordError(error3, operation) {
13113
13214
  if (error3.taskRecordBusiness) return error3;
@@ -13522,7 +13623,7 @@ function registerTaskRecordRepository(runtime2) {
13522
13623
  }
13523
13624
 
13524
13625
  // src/infrastructure/sqlite/task-review-repository.mjs
13525
- var import_node_crypto11 = __toESM(require("node:crypto"), 1);
13626
+ var import_node_crypto12 = __toESM(require("node:crypto"), 1);
13526
13627
 
13527
13628
  // src/domain/task-review/task-review.mjs
13528
13629
  var TASK_REVIEW_RESULT_SCHEMA = "buildr.task-review-result/v1";
@@ -13635,7 +13736,7 @@ function locator(taskId2, reviewType) {
13635
13736
  return `workspace-sqlite:task-review/${taskId2}/${reviewType}`;
13636
13737
  }
13637
13738
  function digest2(value) {
13638
- return `sha256-${import_node_crypto11.default.createHash("sha256").update(value).digest("hex")}`;
13739
+ return `sha256-${import_node_crypto12.default.createHash("sha256").update(value).digest("hex")}`;
13639
13740
  }
13640
13741
  function asError(error3, operation, taskId2, reviewType, stage = void 0) {
13641
13742
  if (error3.taskReviewBusiness) return error3;
@@ -13737,7 +13838,7 @@ function registerTaskReviewRepository(runtime2) {
13737
13838
  }
13738
13839
 
13739
13840
  // src/infrastructure/sqlite/task-retrospective-repository.mjs
13740
- var import_node_crypto12 = __toESM(require("node:crypto"), 1);
13841
+ var import_node_crypto13 = __toESM(require("node:crypto"), 1);
13741
13842
 
13742
13843
  // src/domain/task-retrospective/task-retrospective.mjs
13743
13844
  var TASK_RETROSPECTIVE_RESULT_SCHEMA = "buildr.task-retrospective-result/v1";
@@ -13819,7 +13920,7 @@ function locator2(taskId2) {
13819
13920
  return `workspace-sqlite:task-retrospective/${taskId2}`;
13820
13921
  }
13821
13922
  function digest3(value) {
13822
- return `sha256-${import_node_crypto12.default.createHash("sha256").update(value).digest("hex")}`;
13923
+ return `sha256-${import_node_crypto13.default.createHash("sha256").update(value).digest("hex")}`;
13823
13924
  }
13824
13925
  function decode2(serialized, taskId2) {
13825
13926
  try {
@@ -13985,7 +14086,7 @@ function registerTaskRetrospectiveRepository(runtime2) {
13985
14086
  }
13986
14087
 
13987
14088
  // src/infrastructure/sqlite/task-verification-repository.mjs
13988
- var import_node_crypto13 = __toESM(require("node:crypto"), 1);
14089
+ var import_node_crypto14 = __toESM(require("node:crypto"), 1);
13989
14090
 
13990
14091
  // src/domain/task-verification/task-verification.mjs
13991
14092
  var TASK_VERIFICATION_RESULT_SCHEMA = "buildr.task-verification-result/v1";
@@ -14151,7 +14252,7 @@ function locator3(taskId2) {
14151
14252
  return `workspace-sqlite:task-verification/${taskId2}`;
14152
14253
  }
14153
14254
  function digest4(value) {
14154
- return `sha256-${import_node_crypto13.default.createHash("sha256").update(value).digest("hex")}`;
14255
+ return `sha256-${import_node_crypto14.default.createHash("sha256").update(value).digest("hex")}`;
14155
14256
  }
14156
14257
  function asError3(error3, operation, taskId2, stage = void 0) {
14157
14258
  if (error3.taskVerificationBusiness) return error3;
@@ -14250,10 +14351,10 @@ function registerTaskVerificationRepository(runtime2) {
14250
14351
  }
14251
14352
 
14252
14353
  // src/domain/task-development/task-development.mjs
14253
- var import_node_crypto15 = __toESM(require("node:crypto"), 1);
14354
+ var import_node_crypto16 = __toESM(require("node:crypto"), 1);
14254
14355
 
14255
14356
  // src/domain/parent-coordination/parent-coordination.mjs
14256
- var import_node_crypto14 = __toESM(require("node:crypto"), 1);
14357
+ var import_node_crypto15 = __toESM(require("node:crypto"), 1);
14257
14358
  var PARENT_PLAN_SCHEMA = "buildr.parent-plan/v1";
14258
14359
  var CONTRIBUTION_HANDOFF_SCHEMA = "buildr.contribution-handoff/v1";
14259
14360
  var ID = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/;
@@ -14265,7 +14366,7 @@ function parentCoordinationError(code, message, status = 400, details = void 0,
14265
14366
  return error3;
14266
14367
  }
14267
14368
  function parentCoordinationDigest(value) {
14268
- return `sha256-${import_node_crypto14.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
14369
+ return `sha256-${import_node_crypto15.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
14269
14370
  }
14270
14371
  function object6(value, field) {
14271
14372
  if (!value || typeof value !== "object" || Array.isArray(value)) throw parentCoordinationError("parent_coordination_field_invalid", `${field} 必须是对象。`, 400, { field });
@@ -14420,7 +14521,7 @@ function taskDevelopmentError(code, message, status = 400, details = void 0, nex
14420
14521
  }
14421
14522
  function taskDevelopmentDigest(value) {
14422
14523
  const content = typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value);
14423
- return `sha256-${import_node_crypto15.default.createHash("sha256").update(content).digest("hex")}`;
14524
+ return `sha256-${import_node_crypto16.default.createHash("sha256").update(content).digest("hex")}`;
14424
14525
  }
14425
14526
  function object7(value, field) {
14426
14527
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -15000,7 +15101,7 @@ function registerTaskOverviewRepository(runtime2) {
15000
15101
  }
15001
15102
 
15002
15103
  // src/infrastructure/sqlite/task-finish-repository.mjs
15003
- var import_node_crypto16 = __toESM(require("node:crypto"), 1);
15104
+ var import_node_crypto17 = __toESM(require("node:crypto"), 1);
15004
15105
  var import_node_fs16 = __toESM(require("node:fs"), 1);
15005
15106
  var RUN_LOCATOR = "workspace-sqlite:task-finish-run";
15006
15107
  var COMPLETION_LOCATOR = "workspace-sqlite:task-finish-completion";
@@ -15057,7 +15158,7 @@ function clone(value) {
15057
15158
  return value == null ? value : JSON.parse(JSON.stringify(value));
15058
15159
  }
15059
15160
  function digest5(value) {
15060
- return `sha256-${import_node_crypto16.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
15161
+ return `sha256-${import_node_crypto17.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
15061
15162
  }
15062
15163
  function error2(code, message, status = 409, details = void 0, nextAction = void 0) {
15063
15164
  const failure3 = new Error(message);
@@ -15653,7 +15754,7 @@ function registerTaskFinishRepository(runtime2) {
15653
15754
  }
15654
15755
  database.prepare("UPDATE task_finish_current SET lease_target_identity = NULL, lease_token = NULL, lease_expires_at = NULL WHERE task_id = ? AND run_id = ? AND lease_token = ?").run(owner.task_id, owner.run_id, owner.lease_token);
15655
15756
  }
15656
- const token = requested.lease_target_identity === resolvedTargetIdentity && requested.lease_token ? requested.lease_token : import_node_crypto16.default.randomUUID();
15757
+ const token = requested.lease_target_identity === resolvedTargetIdentity && requested.lease_token ? requested.lease_token : import_node_crypto17.default.randomUUID();
15657
15758
  const expiresAt = timestamp5(currentTime + leaseDurationMs);
15658
15759
  const changed = database.prepare("UPDATE task_finish_current SET lease_target_identity = ?, lease_token = ?, lease_expires_at = ?, updated_at = ? WHERE task_id = ? AND run_id = ?").run(resolvedTargetIdentity, token, expiresAt, timestamp5(currentTime), taskId2, runId);
15659
15760
  if (changed.changes !== 1) throw error2("task_finish_target_lease_failed", "Task Finish target lease owner更新失败。", 409, { taskId: taskId2, runId });
@@ -15767,7 +15868,7 @@ function registerTaskFinishRepository(runtime2) {
15767
15868
  }
15768
15869
 
15769
15870
  // src/domain/task-execution-record/task-execution-record.mjs
15770
- var import_node_crypto17 = __toESM(require("node:crypto"), 1);
15871
+ var import_node_crypto18 = __toESM(require("node:crypto"), 1);
15771
15872
  var TASK_EXECUTION_RECORD_SCHEMA = "buildr.task-execution-record/v1";
15772
15873
  var TASK_EXECUTION_RECORD_REDACTION_VERSION = "buildr.task-execution-record-redaction/v1";
15773
15874
  var TASK_EXECUTION_RECORD_OWNER_KINDS = Object.freeze({
@@ -15973,7 +16074,7 @@ function normalizeTaskExecutionRecord(value, { expectedTaskId = null, expectedRe
15973
16074
  if (normalized.body.redactionVersion !== TASK_EXECUTION_RECORD_REDACTION_VERSION) throw taskExecutionRecordError("task_execution_record_redaction_version_invalid", `redactionVersion必须是${TASK_EXECUTION_RECORD_REDACTION_VERSION}。`, 409);
15974
16075
  return assertState(normalized);
15975
16076
  }
15976
- function createOpenTaskExecutionRecord({ recordId = `task-exec-${import_node_crypto17.default.randomUUID()}`, taskId: taskId2, owner, kind, runIdentity, invocationIdentity = null, targetIdentity, producer, openedAt = (/* @__PURE__ */ new Date()).toISOString() }) {
16077
+ function createOpenTaskExecutionRecord({ recordId = `task-exec-${import_node_crypto18.default.randomUUID()}`, taskId: taskId2, owner, kind, runIdentity, invocationIdentity = null, targetIdentity, producer, openedAt = (/* @__PURE__ */ new Date()).toISOString() }) {
15977
16078
  return normalizeTaskExecutionRecord({
15978
16079
  schemaVersion: TASK_EXECUTION_RECORD_SCHEMA,
15979
16080
  recordId,
@@ -16471,7 +16572,7 @@ function registerTaskExecutionRecordRepository(runtime2) {
16471
16572
  }
16472
16573
 
16473
16574
  // src/infrastructure/filesystem/task-execution-record-body-store.mjs
16474
- var import_node_crypto18 = __toESM(require("node:crypto"), 1);
16575
+ var import_node_crypto19 = __toESM(require("node:crypto"), 1);
16475
16576
  var import_node_fs17 = __toESM(require("node:fs"), 1);
16476
16577
  var import_node_path17 = __toESM(require("node:path"), 1);
16477
16578
  var BODY_FILES = Object.freeze({
@@ -16485,7 +16586,7 @@ var MANIFEST_FILE = ".record-manifest.json";
16485
16586
  var MANIFEST_RESERVE_BYTES = 64 * 1024;
16486
16587
  var TASK_EXECUTION_RECORD_BODY_READ_LIMIT_BYTES = 512 * 1024;
16487
16588
  function digest6(value) {
16488
- return `sha256-${import_node_crypto18.default.createHash("sha256").update(value).digest("hex")}`;
16589
+ return `sha256-${import_node_crypto19.default.createHash("sha256").update(value).digest("hex")}`;
16489
16590
  }
16490
16591
  function bodyError(code, message, status = 400, details = void 0, nextAction = void 0) {
16491
16592
  return taskExecutionRecordError(code, message, status, details, nextAction);
@@ -16675,7 +16776,7 @@ function registerTaskExecutionRecordBodyStore(runtime2) {
16675
16776
  const ownerRoot = prepareOwnerRoot(root, record.owner);
16676
16777
  const finalDirectory = import_node_path17.default.join(ownerRoot, record.recordId);
16677
16778
  if (import_node_fs17.default.existsSync(finalDirectory)) return readPublished(finalDirectory, record).body;
16678
- const staging = import_node_path17.default.join(ownerRoot, `.staging-${record.recordId}-${import_node_crypto18.default.randomUUID()}`);
16779
+ const staging = import_node_path17.default.join(ownerRoot, `.staging-${record.recordId}-${import_node_crypto19.default.randomUUID()}`);
16679
16780
  import_node_fs17.default.mkdirSync(staging, { mode: 448 });
16680
16781
  try {
16681
16782
  for (const file of prepared.files) syncFile(import_node_path17.default.join(staging, file.name), file.content);
@@ -16773,7 +16874,7 @@ function registerTaskExecutionRecordBodyStore(runtime2) {
16773
16874
  }
16774
16875
 
16775
16876
  // src/infrastructure/filesystem/task-environment-repository.mjs
16776
- var import_node_crypto20 = __toESM(require("node:crypto"), 1);
16877
+ var import_node_crypto21 = __toESM(require("node:crypto"), 1);
16777
16878
  var import_node_fs18 = __toESM(require("node:fs"), 1);
16778
16879
  var import_node_path20 = __toESM(require("node:path"), 1);
16779
16880
 
@@ -16781,7 +16882,7 @@ var import_node_path20 = __toESM(require("node:path"), 1);
16781
16882
  var import_node_path19 = __toESM(require("node:path"), 1);
16782
16883
 
16783
16884
  // src/domain/task-environment/task-environment-plan.mjs
16784
- var import_node_crypto19 = __toESM(require("node:crypto"), 1);
16885
+ var import_node_crypto20 = __toESM(require("node:crypto"), 1);
16785
16886
  var import_node_path18 = __toESM(require("node:path"), 1);
16786
16887
  var TASK_ENVIRONMENT_PLAN_SCHEMA = "buildr.task-environment-plan/v2";
16787
16888
  var LEGACY_TASK_ENVIRONMENT_PLAN_SCHEMA = "buildr.task-environment-plan/v1";
@@ -16872,7 +16973,7 @@ function normalizePreparationStepDefinition(value, serviceField, index) {
16872
16973
  }
16873
16974
  var normalizeStep = normalizePreparationStepDefinition;
16874
16975
  function taskEnvironmentPlanDigest(value) {
16875
- return `sha256-${import_node_crypto19.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
16976
+ return `sha256-${import_node_crypto20.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
16876
16977
  }
16877
16978
  function normalizeLegacyTaskEnvironmentPlan(value, { serviceSelectors = [] } = {}) {
16878
16979
  const plan = object9(value, "Environment Plan");
@@ -17473,7 +17574,7 @@ function locator6(taskId2) {
17473
17574
  return `workspace-sqlite:task-environment/${taskId2}`;
17474
17575
  }
17475
17576
  function digest7(value) {
17476
- return `sha256-${import_node_crypto20.default.createHash("sha256").update(value).digest("hex")}`;
17577
+ return `sha256-${import_node_crypto21.default.createHash("sha256").update(value).digest("hex")}`;
17477
17578
  }
17478
17579
  function decode5(serialized, taskId2, status = null) {
17479
17580
  let receipt;
@@ -17594,7 +17695,7 @@ function registerTaskEnvironmentRepository(runtime2) {
17594
17695
  }
17595
17696
 
17596
17697
  // src/infrastructure/content/content-target-observer.mjs
17597
- var import_node_crypto21 = __toESM(require("node:crypto"), 1);
17698
+ var import_node_crypto22 = __toESM(require("node:crypto"), 1);
17598
17699
  var import_node_fs19 = __toESM(require("node:fs"), 1);
17599
17700
  var import_node_path22 = __toESM(require("node:path"), 1);
17600
17701
  init_process();
@@ -17656,7 +17757,7 @@ function gitPaths(root, run2, io) {
17656
17757
  }))].sort((left, right) => posix(import_node_path22.default.relative(root, left)).localeCompare(posix(import_node_path22.default.relative(root, right))));
17657
17758
  }
17658
17759
  function contentInventoryIdentity(root, files, io = import_node_fs19.default) {
17659
- const hash = import_node_crypto21.default.createHash("sha256");
17760
+ const hash = import_node_crypto22.default.createHash("sha256");
17660
17761
  for (const file of files) {
17661
17762
  const relative6 = posix(import_node_path22.default.relative(root, file));
17662
17763
  hash.update(relative6);
@@ -17880,13 +17981,13 @@ function parseSkillFrontmatterNameFromContent(content, label) {
17880
17981
  }
17881
17982
 
17882
17983
  // src/infrastructure/runtime/skills/contributions.mjs
17883
- var import_node_crypto23 = __toESM(require("node:crypto"), 1);
17984
+ var import_node_crypto24 = __toESM(require("node:crypto"), 1);
17884
17985
  var import_node_fs22 = __toESM(require("node:fs"), 1);
17885
17986
  var import_node_path25 = __toESM(require("node:path"), 1);
17886
17987
  var import_yaml7 = __toESM(require_dist(), 1);
17887
17988
 
17888
17989
  // src/infrastructure/runtime/skills/manifests.mjs
17889
- var import_node_crypto22 = __toESM(require("node:crypto"), 1);
17990
+ var import_node_crypto23 = __toESM(require("node:crypto"), 1);
17890
17991
  var import_node_fs21 = __toESM(require("node:fs"), 1);
17891
17992
  var import_node_path24 = __toESM(require("node:path"), 1);
17892
17993
  var import_yaml6 = __toESM(require_dist(), 1);
@@ -17916,7 +18017,7 @@ var CONTRACT_SECTIONS = Object.freeze([
17916
18017
  var CAPABILITY_ID = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)+$/;
17917
18018
  var IDENTITY = /^[a-z][a-z0-9+._:-]*$/;
17918
18019
  function stableUuid(value) {
17919
- const hex = import_node_crypto22.default.createHash("sha256").update(value).digest("hex").slice(0, 32).split("");
18020
+ const hex = import_node_crypto23.default.createHash("sha256").update(value).digest("hex").slice(0, 32).split("");
17920
18021
  hex[12] = "5";
17921
18022
  hex[16] = (Number.parseInt(hex[16], 16) & 3 | 8).toString(16);
17922
18023
  return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
@@ -17975,7 +18076,7 @@ function parseCapabilityContract(contractPath, assertion = null) {
17975
18076
  id: metadata.id,
17976
18077
  version: metadata.version,
17977
18078
  content,
17978
- digest: import_node_crypto22.default.createHash("sha256").update(Buffer.from(content, "utf8")).digest("hex")
18079
+ digest: import_node_crypto23.default.createHash("sha256").update(Buffer.from(content, "utf8")).digest("hex")
17979
18080
  };
17980
18081
  }
17981
18082
  function validateDeclarations(items, label, modeRequired = false) {
@@ -18205,7 +18306,7 @@ function workspaceAssetIntegrity(organizationRoot, relativePath4, label) {
18205
18306
  if (import_node_fs22.default.existsSync(current) && import_node_fs22.default.lstatSync(current).isSymbolicLink()) throw new Error(`${label} crosses a symbolic link: ${current}`);
18206
18307
  }
18207
18308
  if (!import_node_fs22.default.existsSync(absolute3)) throw new Error(`${label} not found: ${absolute3}`);
18208
- const hash = import_node_crypto23.default.createHash("sha256");
18309
+ const hash = import_node_crypto24.default.createHash("sha256");
18209
18310
  if (import_node_fs22.default.statSync(absolute3).isFile()) hash.update(import_node_fs22.default.readFileSync(absolute3));
18210
18311
  else if (import_node_fs22.default.statSync(absolute3).isDirectory()) {
18211
18312
  const files = [];
@@ -18293,7 +18394,7 @@ function resolveComponentContributions(organizationRoot) {
18293
18394
  }
18294
18395
 
18295
18396
  // src/infrastructure/runtime/skills/sources.mjs
18296
- var import_node_crypto24 = __toESM(require("node:crypto"), 1);
18397
+ var import_node_crypto25 = __toESM(require("node:crypto"), 1);
18297
18398
  var import_node_fs23 = __toESM(require("node:fs"), 1);
18298
18399
  var import_node_path26 = __toESM(require("node:path"), 1);
18299
18400
 
@@ -18319,8 +18420,14 @@ function assertVerificationNetworkAllowed(url, options = {}) {
18319
18420
  var import_node_process10 = __toESM(require("node:process"), 1);
18320
18421
  function currentProductInvocation(options = {}) {
18321
18422
  const env = options.env ?? import_node_process10.default.env;
18322
- const cliPath = options.cliPath || env.BUILDR_NPM_ENTRY_PATH || import_node_process10.default.argv[1];
18423
+ const argv = options.argv ?? import_node_process10.default.argv;
18424
+ const explicitCliPath = options.cliPath || env.BUILDR_NPM_ENTRY_PATH || null;
18425
+ const cliPath = explicitCliPath || argv[1];
18323
18426
  if (!cliPath) throw new Error("Host/development Buildr invocation requires an explicit CLI entry path.");
18427
+ const portableCliPath = String(cliPath).replaceAll("\\", "/");
18428
+ if (!explicitCliPath && (/(?:^|\/)test(?:\/|$)/u.test(portableCliPath) || /\.test\.mjs$/u.test(portableCliPath))) {
18429
+ throw new Error("Host/development Buildr invocation cannot infer a Node test entry; pass the delivered bin/buildr.mjs explicitly.");
18430
+ }
18324
18431
  return Object.freeze({ command: import_node_process10.default.execPath, argsPrefix: [cliPath], kind: options.kind || "host-node" });
18325
18432
  }
18326
18433
  function productInvocationArgs(invocation, args) {
@@ -18473,7 +18580,7 @@ function parseSkillSourceRef(sourceRef) {
18473
18580
  return { type: "package", id: match[1] };
18474
18581
  }
18475
18582
  function hashContent(content) {
18476
- return import_node_crypto24.default.createHash("sha256").update(content).digest("hex");
18583
+ return import_node_crypto25.default.createHash("sha256").update(content).digest("hex");
18477
18584
  }
18478
18585
  function verifyIntegrity(content, integrity, label) {
18479
18586
  if (!integrity) return;
@@ -18664,7 +18771,7 @@ function resolveSkills(organizationRoot, projectRoot, options = {}) {
18664
18771
  }
18665
18772
 
18666
18773
  // src/infrastructure/runtime/skills/render-plan.mjs
18667
- var import_node_crypto26 = __toESM(require("node:crypto"), 1);
18774
+ var import_node_crypto27 = __toESM(require("node:crypto"), 1);
18668
18775
  var import_node_fs27 = __toESM(require("node:fs"), 1);
18669
18776
  var import_node_path30 = __toESM(require("node:path"), 1);
18670
18777
 
@@ -18675,7 +18782,7 @@ var import_node_path28 = __toESM(require("node:path"), 1);
18675
18782
  var import_node_process13 = __toESM(require("node:process"), 1);
18676
18783
 
18677
18784
  // src/infrastructure/runtime/skills/projection-files.mjs
18678
- var import_node_crypto25 = __toESM(require("node:crypto"), 1);
18785
+ var import_node_crypto26 = __toESM(require("node:crypto"), 1);
18679
18786
  var import_node_fs24 = __toESM(require("node:fs"), 1);
18680
18787
  var import_node_path27 = __toESM(require("node:path"), 1);
18681
18788
  var import_node_process12 = __toESM(require("node:process"), 1);
@@ -18699,7 +18806,7 @@ function toPosix(value) {
18699
18806
  return value.split(import_node_path27.default.sep).join("/");
18700
18807
  }
18701
18808
  function sha256Integrity(content) {
18702
- return `sha256-${import_node_crypto25.default.createHash("sha256").update(content).digest("hex")}`;
18809
+ return `sha256-${import_node_crypto26.default.createHash("sha256").update(content).digest("hex")}`;
18703
18810
  }
18704
18811
  function ownerExecutable(mode) {
18705
18812
  return (mode & 64) === 64;
@@ -20150,7 +20257,7 @@ function buildRuntimeSkillDirectory(targetRoot, skill, runtime2) {
20150
20257
  return import_node_path30.default.join(targetRoot, root, "skills", ...runtimePath2.split("/"));
20151
20258
  }
20152
20259
  function sourceHash(content) {
20153
- return import_node_crypto26.default.createHash("sha256").update(content).digest("hex");
20260
+ return import_node_crypto27.default.createHash("sha256").update(content).digest("hex");
20154
20261
  }
20155
20262
  function buildSkillContent(repoRoot, skill) {
20156
20263
  const rawSource = skill.sourceContent ?? import_node_fs27.default.readFileSync(skill.sourceFile, "utf8");
@@ -20451,7 +20558,7 @@ function buildSkillRenderPlan(repoRoot, targetRoot, skills, runtime2, options =
20451
20558
 
20452
20559
  // src/infrastructure/runtime/projection.mjs
20453
20560
  var import_node_fs30 = __toESM(require("node:fs"), 1);
20454
- var import_node_crypto27 = __toESM(require("node:crypto"), 1);
20561
+ var import_node_crypto28 = __toESM(require("node:crypto"), 1);
20455
20562
  var import_node_path34 = __toESM(require("node:path"), 1);
20456
20563
 
20457
20564
  // src/infrastructure/runtime/skills/inventory.mjs
@@ -21017,7 +21124,7 @@ function liveReferenceBridge(current, targetFile, sourceFile) {
21017
21124
  function referenceMetadataStale(current, sourceFile) {
21018
21125
  const hash = current.match(/\bhash:\s*([a-f0-9]{64})\b/i)?.[1]?.toLowerCase();
21019
21126
  if (!hash) return false;
21020
- return hash !== import_node_crypto27.default.createHash("sha256").update(import_node_fs30.default.readFileSync(sourceFile)).digest("hex");
21127
+ return hash !== import_node_crypto28.default.createHash("sha256").update(import_node_fs30.default.readFileSync(sourceFile)).digest("hex");
21021
21128
  }
21022
21129
  function toPosixRelative2(root, file) {
21023
21130
  return import_node_path34.default.relative(root, file).split(import_node_path34.default.sep).join("/") || ".";
@@ -21052,7 +21159,7 @@ function sourceId(repoRoot, sourceFile) {
21052
21159
  const directory2 = import_node_path34.default.posix.dirname(relative6);
21053
21160
  const depth = directory2 === "." ? 0 : directory2.split("/").length;
21054
21161
  const slug = (directory2 === "." ? "root" : directory2).replace(/[^A-Za-z0-9._-]+/g, "-").slice(0, 72);
21055
- const hash = import_node_crypto27.default.createHash("sha256").update(relative6).digest("hex").slice(0, 10);
21162
+ const hash = import_node_crypto28.default.createHash("sha256").update(relative6).digest("hex").slice(0, 10);
21056
21163
  return `${String(depth).padStart(3, "0")}-${slug}-${hash}`;
21057
21164
  }
21058
21165
  function vendorRuleTarget(repoRoot, targetRoot, sourceFile, rules) {
@@ -21277,7 +21384,7 @@ function summarize(findings) {
21277
21384
  return counts;
21278
21385
  }
21279
21386
  function projectionIdentity(plan) {
21280
- const contentHash = (content) => import_node_crypto27.default.createHash("sha256").update(content || "").digest("hex");
21387
+ const contentHash = (content) => import_node_crypto28.default.createHash("sha256").update(content || "").digest("hex");
21281
21388
  const relative6 = (file) => toPosixRelative2(plan.targetRoot, file);
21282
21389
  const identity6 = {
21283
21390
  adapterId: plan.adapterId,
@@ -21288,7 +21395,7 @@ function projectionIdentity(plan) {
21288
21395
  content: import_node_fs30.default.existsSync(item.targetFile) ? contentHash(import_node_fs30.default.readFileSync(item.targetFile)) : null
21289
21396
  })).sort((a, b) => a.path.localeCompare(b.path))
21290
21397
  };
21291
- return `sha256-${import_node_crypto27.default.createHash("sha256").update(JSON.stringify(identity6)).digest("hex")}`;
21398
+ return `sha256-${import_node_crypto28.default.createHash("sha256").update(JSON.stringify(identity6)).digest("hex")}`;
21292
21399
  }
21293
21400
  function adoptionModes(adapter) {
21294
21401
  return adapter.traits.activation.skills === "explicit-reload" ? ["new-session", "reentered", "reload"] : ["new-session", "reentered"];
@@ -21606,7 +21713,7 @@ function registerDomainsRuntime(runtime2) {
21606
21713
 
21607
21714
  // src/application/domains/workspace.mjs
21608
21715
  var import_node_fs31 = __toESM(require("node:fs"), 1);
21609
- var import_node_crypto28 = __toESM(require("node:crypto"), 1);
21716
+ var import_node_crypto29 = __toESM(require("node:crypto"), 1);
21610
21717
  var import_node_path37 = __toESM(require("node:path"), 1);
21611
21718
  var import_node_process18 = __toESM(require("node:process"), 1);
21612
21719
  init_process();
@@ -22079,7 +22186,7 @@ function registerDomainsWorkspace(runtime2) {
22079
22186
  }
22080
22187
  const affected = [projectRoot, projectsManifestPath(targetRoot), import_node_path37.default.join(targetRoot, ".gitignore")];
22081
22188
  return withWorkspaceMutation(targetRoot, `project.create:${project}`, affected, () => {
22082
- const staging = import_node_path37.default.join(import_node_path37.default.dirname(projectRoot), `.${project}.buildr-stage-${import_node_crypto28.default.randomUUID()}`);
22189
+ const staging = import_node_path37.default.join(import_node_path37.default.dirname(projectRoot), `.${project}.buildr-stage-${import_node_crypto29.default.randomUUID()}`);
22083
22190
  try {
22084
22191
  if (repoRef && !existsDirectory(projectRoot)) {
22085
22192
  (0, import_node_child_process.execFileSync)("git", ["clone", repoRef, staging], { stdio: "inherit" });
@@ -22183,7 +22290,7 @@ function registerDomainsWorkspace(runtime2) {
22183
22290
  const affected = [servicePath, servicesManifestPath(projectRoot), import_node_path37.default.join(projectRoot, ".gitignore"), import_node_path37.default.join(targetRoot, ".gitignore")];
22184
22291
  return withWorkspaceMutation(targetRoot, `service.create:${project}/${service}`, affected, () => {
22185
22292
  ensureDirectory3(servicesRoot);
22186
- const staging = import_node_path37.default.join(servicesRoot, `.${service}.buildr-stage-${import_node_crypto28.default.randomUUID()}`);
22293
+ const staging = import_node_path37.default.join(servicesRoot, `.${service}.buildr-stage-${import_node_crypto29.default.randomUUID()}`);
22187
22294
  try {
22188
22295
  if (!import_node_fs31.default.existsSync(servicePath)) {
22189
22296
  if (gitSource) {
@@ -22230,7 +22337,7 @@ function registerDomainsWorkspace(runtime2) {
22230
22337
 
22231
22338
  // src/application/domains/components.mjs
22232
22339
  var import_node_fs32 = __toESM(require("node:fs"), 1);
22233
- var import_node_crypto29 = __toESM(require("node:crypto"), 1);
22340
+ var import_node_crypto30 = __toESM(require("node:crypto"), 1);
22234
22341
  var import_node_path38 = __toESM(require("node:path"), 1);
22235
22342
  var import_node_process19 = __toESM(require("node:process"), 1);
22236
22343
  init_final_doctor_process();
@@ -22525,7 +22632,7 @@ function registerDomainsComponents(runtime2) {
22525
22632
  }
22526
22633
  function assetIntegrity(assetPath) {
22527
22634
  if (!existsFile(assetPath) && !existsDirectory(assetPath)) return null;
22528
- const hash = import_node_crypto29.default.createHash("sha256");
22635
+ const hash = import_node_crypto30.default.createHash("sha256");
22529
22636
  if (import_node_fs32.default.lstatSync(assetPath).isSymbolicLink()) throw new Error(`Integrity input must not be a symbolic link: ${assetPath}`);
22530
22637
  if (existsFile(assetPath)) {
22531
22638
  hash.update(import_node_fs32.default.readFileSync(assetPath));
@@ -24581,13 +24688,13 @@ function registerDomainsRules(runtime2) {
24581
24688
 
24582
24689
  // src/application/domains/openspec.mjs
24583
24690
  var import_node_fs39 = __toESM(require("node:fs"), 1);
24584
- var import_node_crypto33 = __toESM(require("node:crypto"), 1);
24691
+ var import_node_crypto34 = __toESM(require("node:crypto"), 1);
24585
24692
  var import_node_path47 = __toESM(require("node:path"), 1);
24586
24693
  var import_node_process22 = __toESM(require("node:process"), 1);
24587
24694
  init_process();
24588
24695
 
24589
24696
  // src/application/openspec/convergence-model.mjs
24590
- var import_node_crypto30 = __toESM(require("node:crypto"), 1);
24697
+ var import_node_crypto31 = __toESM(require("node:crypto"), 1);
24591
24698
  var CONVERGENCE_ALGORITHM_VERSION = 4;
24592
24699
  var CONVERGENCE_PLAN_SCHEMA = "buildr.openspec-convergence-plan/v1";
24593
24700
  var CONVERGENCE_RECEIPT_SCHEMA = "buildr.openspec-convergence-receipt/v3";
@@ -24596,7 +24703,7 @@ function normalizeConvergenceText(value) {
24596
24703
  }
24597
24704
  function convergenceDigest(value) {
24598
24705
  const serialized = typeof value === "string" ? value : stableJson(value);
24599
- return `sha256-${import_node_crypto30.default.createHash("sha256").update(serialized).digest("hex")}`;
24706
+ return `sha256-${import_node_crypto31.default.createHash("sha256").update(serialized).digest("hex")}`;
24600
24707
  }
24601
24708
  function stableJson(value) {
24602
24709
  if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
@@ -24890,11 +24997,11 @@ function observeConvergence({ projectRoot, receipt, archived = false, io }) {
24890
24997
  }
24891
24998
 
24892
24999
  // src/application/openspec/deterministic-sync.mjs
24893
- var import_node_crypto31 = __toESM(require("node:crypto"), 1);
25000
+ var import_node_crypto32 = __toESM(require("node:crypto"), 1);
24894
25001
  var import_node_fs35 = __toESM(require("node:fs"), 1);
24895
25002
  var import_node_path43 = __toESM(require("node:path"), 1);
24896
25003
  function digest8(value) {
24897
- return `sha256-${import_node_crypto31.default.createHash("sha256").update(value).digest("hex")}`;
25004
+ return `sha256-${import_node_crypto32.default.createHash("sha256").update(value).digest("hex")}`;
24898
25005
  }
24899
25006
  function deterministicSyncPlanIdentity(plan) {
24900
25007
  return digest8(JSON.stringify({ change: plan.change, project: plan.project, deltaHash: plan.deltaHash, files: plan.files, operations: plan.operations }));
@@ -25335,12 +25442,12 @@ function runOpenSpecConvergencePreflight({
25335
25442
  }
25336
25443
 
25337
25444
  // src/application/openspec/projected-validator.mjs
25338
- var import_node_crypto32 = __toESM(require("node:crypto"), 1);
25445
+ var import_node_crypto33 = __toESM(require("node:crypto"), 1);
25339
25446
  var import_node_fs38 = __toESM(require("node:fs"), 1);
25340
25447
  var import_node_os5 = __toESM(require("node:os"), 1);
25341
25448
  var import_node_path46 = __toESM(require("node:path"), 1);
25342
25449
  init_process();
25343
- var diagnosticDigest2 = (value) => `sha256-${import_node_crypto32.default.createHash("sha256").update(value).digest("hex")}`;
25450
+ var diagnosticDigest2 = (value) => `sha256-${import_node_crypto33.default.createHash("sha256").update(value).digest("hex")}`;
25344
25451
  function validateProjectedOpenSpec({ projectRoot, files = [], executable: executable2, copyDirectory, atomicWriteFile: atomicWriteFile3, removePath, spawn: spawn2 = spawnCommandSync, mode = "projected" }) {
25345
25452
  const startedAt = Date.now();
25346
25453
  const temporaryRoot = import_node_fs38.default.mkdtempSync(import_node_path46.default.join(import_node_os5.default.tmpdir(), "buildr-openspec-convergence-"));
@@ -25449,7 +25556,7 @@ function registerDomainsOpenspec(runtime2) {
25449
25556
  const existsFile = (...args) => runtime2.existsFile(...args);
25450
25557
  const assertInitializedBuildrWorkspace = (...args) => runtime2.assertInitializedBuildrWorkspace(...args);
25451
25558
  function openSpecContractHash(value) {
25452
- return `sha256-${import_node_crypto33.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
25559
+ return `sha256-${import_node_crypto34.default.createHash("sha256").update(typeof value === "string" ? value : JSON.stringify(value)).digest("hex")}`;
25453
25560
  }
25454
25561
  function openSpecContractChangePath(projectRoot, change) {
25455
25562
  assertName(change, "OpenSpec change");
@@ -25651,7 +25758,7 @@ function registerDomainsOpenspec(runtime2) {
25651
25758
  projectRoot: context.projectRoot,
25652
25759
  executable: executable2,
25653
25760
  version: versionResult.status === 0 ? versionResult.stdout.trim() : null,
25654
- sha256: import_node_crypto33.default.createHash("sha256").update(import_node_fs39.default.readFileSync(executable2)).digest("hex")
25761
+ sha256: import_node_crypto34.default.createHash("sha256").update(import_node_fs39.default.readFileSync(executable2)).digest("hex")
25655
25762
  });
25656
25763
  }
25657
25764
  function observeOpenSpecCanonicalProject(projectRoot) {
@@ -27064,7 +27171,7 @@ var import_node_path49 = __toESM(require("node:path"), 1);
27064
27171
  var import_yaml11 = __toESM(require_dist(), 1);
27065
27172
 
27066
27173
  // src/domain/task-environment/project-environment-preparation.mjs
27067
- var import_node_crypto34 = __toESM(require("node:crypto"), 1);
27174
+ var import_node_crypto35 = __toESM(require("node:crypto"), 1);
27068
27175
  var import_yaml10 = __toESM(require_dist(), 1);
27069
27176
  var PROJECT_ENVIRONMENT_PREPARATION_SCHEMA = "buildr.project-environment-preparation/v1";
27070
27177
  var ID2 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
@@ -27127,7 +27234,7 @@ function normalizeProjectEnvironmentPreparation(value, { projectCode, services =
27127
27234
  });
27128
27235
  if (new Set(recipes.map((recipe) => recipe.id)).size !== recipes.length) throw failure("preparation.recipes id不能重复。");
27129
27236
  const payload = { schemaVersion: PROJECT_ENVIRONMENT_PREPARATION_SCHEMA, project: projectCode, recipes };
27130
- return { ...payload, identity: `sha256-${import_node_crypto34.default.createHash("sha256").update(JSON.stringify(payload)).digest("hex")}` };
27237
+ return { ...payload, identity: `sha256-${import_node_crypto35.default.createHash("sha256").update(JSON.stringify(payload)).digest("hex")}` };
27131
27238
  }
27132
27239
  function projectEnvironmentPreparationScopeSelector(project, recipe) {
27133
27240
  return recipe.scope.kind === "project" ? `project:${project}` : `service:${project}/${recipe.scope.service}`;
@@ -27281,6 +27388,74 @@ function printProductInstallationReport(result5) {
27281
27388
  printRuntimeIdentity("Current main process", inventory.currentInstallation?.runtime, inventory.currentInstallation?.status);
27282
27389
  }
27283
27390
 
27391
+ // src/application/doctor/internal-workflow-route-diagnostics.mjs
27392
+ var CONSUMERS = Object.freeze([
27393
+ Object.freeze({ path: "package/targets/workspace/skills/buildr/task-development/SKILL.md", routes: Object.freeze(["task-development", "task-planning-identity"]), retainedInvocation: true }),
27394
+ Object.freeze({ path: "package/targets/workspace/skills/buildr/task-retrospective/SKILL.md", routes: Object.freeze(["task-retrospective"]), retainedInvocation: true }),
27395
+ Object.freeze({ path: "package/targets/workspace/skills/buildr/task-review/SKILL.md", routes: Object.freeze(["task-planning-identity"]), retainedInvocation: true }),
27396
+ Object.freeze({ path: "package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md", routes: Object.freeze(["task-planning-identity"]), retainedInvocation: true }),
27397
+ Object.freeze({ path: "package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md", routes: Object.freeze(["task-planning-identity"]), retainedInvocation: true }),
27398
+ Object.freeze({ path: "package/targets/workspace/components/buildr/openspec/contributions/openspec-update-sidebar.md", routes: Object.freeze(["task-planning-identity"]), retainedInvocation: true }),
27399
+ Object.freeze({ path: "package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md", routes: Object.freeze(["task-planning-identity"]), retainedInvocation: true })
27400
+ ]);
27401
+ function createInternalWorkflowRouteDiagnostics({ addDoctorFinding, fs: fs74, path: path91, productRoot: productRoot2, inspectRoutes }) {
27402
+ function diagnoseInternalWorkflowRoutes(result5) {
27403
+ let inventory;
27404
+ try {
27405
+ inventory = inspectRoutes();
27406
+ const ids = inventory.routes?.map((route) => route.id) || [];
27407
+ if (inventory.status !== "ready" || ids.length === 0 || new Set(ids).size !== ids.length) throw new Error("route inventory is empty, duplicated, or not ready");
27408
+ for (const route of inventory.routes) {
27409
+ if (!route.runner || !["read-only", "read-write"].includes(route.mode)) throw new Error(`route ${route.id || "<missing>"} has no runner binding`);
27410
+ }
27411
+ } catch (error3) {
27412
+ addDoctorFinding(result5, "error", "product.internal_workflow_routes_invalid", `Buildr内部工作流route inventory无效:${error3.message}`, {
27413
+ suggestion: "更新到包含完整internal workflow routes的Buildr安装产物。",
27414
+ userActionRequired: true
27415
+ });
27416
+ return;
27417
+ }
27418
+ const routeIds = new Set(inventory.routes.map((route) => route.id));
27419
+ const root = productRoot2();
27420
+ const failures = [];
27421
+ for (const consumer of CONSUMERS) {
27422
+ const file = path91.join(root, consumer.path);
27423
+ let content;
27424
+ try {
27425
+ content = fs74.readFileSync(file, "utf8");
27426
+ } catch {
27427
+ failures.push(`${consumer.path}:missing`);
27428
+ continue;
27429
+ }
27430
+ for (const route of consumer.routes) {
27431
+ if (!routeIds.has(route) || !content.includes(`__internal ${route}`)) failures.push(`${consumer.path}:${route}`);
27432
+ }
27433
+ if (consumer.retainedInvocation && !/retained[^\n]{0,80}(?:controller|Buildr)|controllerInvocation/u.test(content)) failures.push(`${consumer.path}:retained-controller`);
27434
+ if (/src\/interfaces\/internal\/task-(?:development|retrospective|planning-identity)-driver\.mjs/u.test(content)) failures.push(`${consumer.path}:source-driver`);
27435
+ }
27436
+ if (failures.length) addDoctorFinding(result5, "error", "product.internal_workflow_route_closure_invalid", "Buildr受管Skill与bundled internal workflow routes不闭合。", {
27437
+ failures,
27438
+ suggestion: "更新或重新安装matching Buildr package;不要用development checkout的source driver兼容写入。",
27439
+ userActionRequired: true
27440
+ });
27441
+ }
27442
+ return { diagnoseInternalWorkflowRoutes };
27443
+ }
27444
+
27445
+ // src/application/internal-workflow-route-inventory.mjs
27446
+ var REQUIRED_INTERNAL_WORKFLOW_ROUTES = Object.freeze([
27447
+ Object.freeze({ id: "task-development", runner: "task-development-driver-runner.mjs", mode: "read-write" }),
27448
+ Object.freeze({ id: "task-retrospective", runner: "task-retrospective-driver-runner.mjs", mode: "read-write" }),
27449
+ Object.freeze({ id: "task-planning-identity", runner: "task-planning-identity-driver-runner.mjs", mode: "read-only" })
27450
+ ]);
27451
+ function inspectRequiredInternalWorkflowRoutes() {
27452
+ return {
27453
+ schemaVersion: "buildr.internal-workflow-route-inventory/v1",
27454
+ status: "ready",
27455
+ routes: REQUIRED_INTERNAL_WORKFLOW_ROUTES.map((route) => ({ ...route }))
27456
+ };
27457
+ }
27458
+
27284
27459
  // src/application/doctor.mjs
27285
27460
  function registerApplicationDoctor(runtime2) {
27286
27461
  const runCommandsCheck = (...args) => runtime2.runCommandsCheck(...args);
@@ -27310,6 +27485,7 @@ function registerApplicationDoctor(runtime2) {
27310
27485
  const buildrWorkspaceIdentity = (...args) => runtime2.buildrWorkspaceIdentity(...args);
27311
27486
  const observeProjectGit2 = (...args) => runtime2.observeProjectGit(...args);
27312
27487
  const sameGitIdentity = (...args) => runtime2.sameGitIdentity(...args);
27488
+ const productRoot2 = (...args) => runtime2.productRoot(...args);
27313
27489
  const {
27314
27490
  scopeParts,
27315
27491
  workspaceName,
@@ -27396,6 +27572,7 @@ function registerApplicationDoctor(runtime2) {
27396
27572
  const { diagnoseSkillCapabilities, printCapabilityReport } = createCapabilityDiagnostics({ addDoctorFinding, isSupportedAgent, path: import_node_path50.default });
27397
27573
  const { diagnoseProjectVerification } = createProjectVerificationDiagnostics({ addDoctorFinding });
27398
27574
  const { diagnoseProjectEnvironmentPreparation } = createProjectEnvironmentPreparationDiagnostics({ addDoctorFinding });
27575
+ const { diagnoseInternalWorkflowRoutes } = createInternalWorkflowRouteDiagnostics({ addDoctorFinding, fs: import_node_fs42.default, path: import_node_path50.default, productRoot: productRoot2, inspectRoutes: inspectRequiredInternalWorkflowRoutes });
27399
27576
  function diagnoseSkillsManifestSchemas(result5, targetRoot, scopes) {
27400
27577
  const checked = /* @__PURE__ */ new Set();
27401
27578
  const scopeRoots = [targetRoot];
@@ -27498,6 +27675,7 @@ function registerApplicationDoctor(runtime2) {
27498
27675
  diagnoseSkillCapabilities,
27499
27676
  diagnoseProjectVerification,
27500
27677
  diagnoseProjectEnvironmentPreparation,
27678
+ diagnoseInternalWorkflowRoutes,
27501
27679
  finalizeDoctorResult,
27502
27680
  printDoctorReport
27503
27681
  });
@@ -28893,7 +29071,7 @@ function registerDomainsSkills(runtime2) {
28893
29071
 
28894
29072
  // src/application/package-maintenance.mjs
28895
29073
  var import_node_fs46 = __toESM(require("node:fs"), 1);
28896
- var import_node_crypto35 = __toESM(require("node:crypto"), 1);
29074
+ var import_node_crypto36 = __toESM(require("node:crypto"), 1);
28897
29075
  var import_node_os6 = __toESM(require("node:os"), 1);
28898
29076
  var import_node_path54 = __toESM(require("node:path"), 1);
28899
29077
  var import_node_process24 = __toESM(require("node:process"), 1);
@@ -28946,7 +29124,7 @@ function createPackageOutput(deps) {
28946
29124
  assertSafeAssetTarget,
28947
29125
  atomicWriteJson: atomicWriteJson3,
28948
29126
  collectFiles,
28949
- crypto: crypto60,
29127
+ crypto: crypto61,
28950
29128
  ensureDirectory: ensureDirectory3,
28951
29129
  existsDirectory,
28952
29130
  existsFile,
@@ -28965,11 +29143,11 @@ function createPackageOutput(deps) {
28965
29143
  if (!existsDirectory(outputRoot)) return [];
28966
29144
  return collectFiles(outputRoot).filter((file) => path91.basename(file) !== PACKAGE_OUTPUT_RECEIPT).map((file) => ({
28967
29145
  path: toPosixRelative3(outputRoot, file),
28968
- integrity: `sha256-${crypto60.createHash("sha256").update(fs74.readFileSync(file)).digest("hex")}`
29146
+ integrity: `sha256-${crypto61.createHash("sha256").update(fs74.readFileSync(file)).digest("hex")}`
28969
29147
  })).sort((left, right) => left.path.localeCompare(right.path));
28970
29148
  }
28971
29149
  function packageOutputIntegrity(inventory) {
28972
- return `sha256-${crypto60.createHash("sha256").update(JSON.stringify(inventory)).digest("hex")}`;
29150
+ return `sha256-${crypto61.createHash("sha256").update(JSON.stringify(inventory)).digest("hex")}`;
28973
29151
  }
28974
29152
  function readPackageOutputReceipt(outDir) {
28975
29153
  const file = path91.join(outDir, PACKAGE_OUTPUT_RECEIPT);
@@ -29054,8 +29232,8 @@ function createPackageOutput(deps) {
29054
29232
  const manifest = readPackageManifest();
29055
29233
  const outDir = assertSafePackageOutput(path91.resolve(optionValue(args, "--out", path91.join(root, "dist", "buildr-package"))));
29056
29234
  validateReplaceablePackageOutput(outDir);
29057
- const staging = path91.join(path91.dirname(outDir), `.${path91.basename(outDir)}.buildr-stage-${crypto60.randomUUID()}`);
29058
- const backup = path91.join(path91.dirname(outDir), `.${path91.basename(outDir)}.buildr-backup-${crypto60.randomUUID()}`);
29235
+ const staging = path91.join(path91.dirname(outDir), `.${path91.basename(outDir)}.buildr-stage-${crypto61.randomUUID()}`);
29236
+ const backup = path91.join(path91.dirname(outDir), `.${path91.basename(outDir)}.buildr-backup-${crypto61.randomUUID()}`);
29059
29237
  try {
29060
29238
  buildPackageOutput(staging, root, manifest);
29061
29239
  if (fs74.existsSync(outDir)) fs74.renameSync(outDir, backup);
@@ -29996,7 +30174,10 @@ function createPackageStaticValidator(deps) {
29996
30174
  const sourceContracts = /* @__PURE__ */ new Map([
29997
30175
  ["src/domain/task-planning-identity/task-planning-identity.mjs", ["createTaskPlanningIdentity", "checklist-completion", "change-lifecycle-provenance"]],
29998
30176
  ["src/application/task-planning-identity/task-planning-identity-application.mjs", ["inspectTaskPlanningIdentity", "resolveTaskScopedChange", "includeContent: true", "effects: []"]],
29999
- ["src/interfaces/internal/task-planning-identity-driver.mjs", ["inspect --task <task-id> --target <canonical-workspace>", "inspectTaskPlanningIdentity"]],
30177
+ ["src/interfaces/internal/task-planning-identity-driver.mjs", ["runTaskPlanningIdentityDriver"]],
30178
+ ["src/interfaces/internal/task-planning-identity-driver-runner.mjs", ["inspect --task <task-id> --target <canonical-workspace>", "inspectTaskPlanningIdentity"]],
30179
+ ["src/application/internal-workflow-route-inventory.mjs", ["id: 'task-planning-identity'", "task-planning-identity-driver-runner.mjs"]],
30180
+ ["src/interfaces/internal/formal-workflow-routes.mjs", ["runRequiredInternalWorkflowRoute", "runTaskPlanningIdentityDriver"]],
30000
30181
  ["src/application/compose-runtime.mjs", ["registerTaskPlanningIdentityApplication"]]
30001
30182
  ]);
30002
30183
  for (const [relative6, requiredTexts] of sourceContracts) {
@@ -30011,12 +30192,12 @@ function createPackageStaticValidator(deps) {
30011
30192
  }
30012
30193
  }
30013
30194
  const consumers = /* @__PURE__ */ new Map([
30014
- ["package/targets/workspace/skills/buildr/task-development/SKILL.md", ["task-planning-identity-driver.mjs inspect", "`planningNodes`", "raw digest"]],
30015
- ["package/targets/workspace/skills/buildr/task-review/SKILL.md", ["task-planning-identity-driver.mjs inspect", "checkbox progress", "不重复record"]],
30016
- ["package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md", ["buildr openspec convergence preflight", "task-planning-identity-driver.mjs inspect", "Planning Review不拥有、不复制也不解释preflight逻辑", "再次调用Task Planning Identity resolver"]],
30017
- ["package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md", ["buildr openspec convergence preflight", "task-planning-identity-driver.mjs inspect", "`planningNodes`"]],
30018
- ["package/targets/workspace/components/buildr/openspec/contributions/openspec-update-sidebar.md", ["buildr openspec convergence preflight", "task-planning-identity-driver.mjs inspect", "target不变则不重复record Review"]],
30019
- ["package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md", ["buildr openspec convergence preflight", "task-planning-identity-driver.mjs inspect", "target与apply前相同则复用current Planning Review"]],
30195
+ ["package/targets/workspace/skills/buildr/task-development/SKILL.md", ["__internal task-planning-identity inspect", "`planningNodes`", "raw digest", "environment.controllerInvocation"]],
30196
+ ["package/targets/workspace/skills/buildr/task-review/SKILL.md", ["__internal task-planning-identity inspect", "checkbox progress", "不重复record", "environment.controllerInvocation"]],
30197
+ ["package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md", ["buildr openspec convergence preflight", "__internal task-planning-identity inspect", "Planning Review不拥有、不复制也不解释preflight逻辑", "再次调用Task Planning Identity resolver", "environment.controllerInvocation"]],
30198
+ ["package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md", ["buildr openspec convergence preflight", "__internal task-planning-identity inspect", "`planningNodes`", "environment.controllerInvocation"]],
30199
+ ["package/targets/workspace/components/buildr/openspec/contributions/openspec-update-sidebar.md", ["buildr openspec convergence preflight", "__internal task-planning-identity inspect", "target不变则不重复record Review", "environment.controllerInvocation"]],
30200
+ ["package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md", ["buildr openspec convergence preflight", "__internal task-planning-identity inspect", "target与apply前相同则复用current Planning Review", "environment.controllerInvocation"]],
30020
30201
  ["package/targets/workspace/components/buildr/openspec/contributions/openspec-sync-converge.md", ["重新调用Task Planning Identity resolver"]],
30021
30202
  ["package/targets/workspace/components/buildr/openspec/contributions/openspec-archive-converge.md", ["重新调用Task Planning Identity resolver"]]
30022
30203
  ]);
@@ -30033,6 +30214,41 @@ function createPackageStaticValidator(deps) {
30033
30214
  for (const forbidden of ["shasum proposal.md", "sha256sum proposal.md"]) {
30034
30215
  if (content.includes(forbidden)) problems.push(`Task Planning Identity consumer ${relative6} must not instruct manual OpenSpec target hashing with ${JSON.stringify(forbidden)}.`);
30035
30216
  }
30217
+ if (/src\/interfaces\/internal\/task-(?:development|retrospective|planning-identity)-driver\.mjs/u.test(content)) problems.push(`Task Planning Identity consumer ${relative6} must use the bundled retained-controller route, not a source driver path.`);
30218
+ }
30219
+ }
30220
+ function validateInternalWorkflowRouteClosure(context) {
30221
+ const { root, problems } = context;
30222
+ const inventory = path91.join(root, "src/application/internal-workflow-route-inventory.mjs");
30223
+ const cli = path91.join(root, "src/interfaces/cli/main.mjs");
30224
+ if (!existsFile(inventory)) problems.push("Required internal workflow route inventory is missing.");
30225
+ if (!existsFile(cli)) problems.push("Buildr CLI internal workflow route dispatcher is missing.");
30226
+ else if (!fs74.readFileSync(cli, "utf8").includes("runRequiredInternalWorkflowRoute")) problems.push("Buildr CLI must dispatch the required internal workflow route inventory.");
30227
+ for (const route of REQUIRED_INTERNAL_WORKFLOW_ROUTES) {
30228
+ const runner = path91.join(root, "src/interfaces/internal", route.runner);
30229
+ const wrapper = path91.join(root, "src/interfaces/internal", `${route.id}-driver.mjs`);
30230
+ if (!existsFile(runner)) problems.push(`Required internal workflow runner is missing: ${route.runner}.`);
30231
+ if (!existsFile(wrapper)) problems.push(`Required internal workflow checkout wrapper is missing: ${route.id}-driver.mjs.`);
30232
+ }
30233
+ const consumers = [
30234
+ ["package/targets/workspace/skills/buildr/task-development/SKILL.md", ["task-development", "task-planning-identity"]],
30235
+ ["package/targets/workspace/skills/buildr/task-retrospective/SKILL.md", ["task-retrospective"]],
30236
+ ["package/targets/workspace/skills/buildr/task-review/SKILL.md", ["task-planning-identity"]],
30237
+ ["package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md", ["task-planning-identity"]],
30238
+ ["package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md", ["task-planning-identity"]],
30239
+ ["package/targets/workspace/components/buildr/openspec/contributions/openspec-update-sidebar.md", ["task-planning-identity"]],
30240
+ ["package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md", ["task-planning-identity"]]
30241
+ ];
30242
+ for (const [relative6, routes] of consumers) {
30243
+ const file = path91.join(root, relative6);
30244
+ if (!existsFile(file)) {
30245
+ problems.push(`Required internal workflow consumer is missing: ${relative6}.`);
30246
+ continue;
30247
+ }
30248
+ const content = fs74.readFileSync(file, "utf8");
30249
+ for (const route of routes) if (!content.includes(`__internal ${route}`)) problems.push(`Required internal workflow consumer ${relative6} must use bundled route ${route}.`);
30250
+ if (!content.includes("controllerInvocation") && relative6 !== "package/targets/workspace/skills/buildr/task-retrospective/SKILL.md") problems.push(`Required internal workflow consumer ${relative6} must use a retained controllerInvocation.`);
30251
+ if (/src\/interfaces\/internal\/task-(?:development|retrospective|planning-identity)-driver\.mjs/u.test(content)) problems.push(`Required internal workflow consumer ${relative6} must not use a source driver path.`);
30036
30252
  }
30037
30253
  }
30038
30254
  function parseJsonOutput(label, output2) {
@@ -30776,9 +30992,10 @@ ${excerpt}`);
30776
30992
  "不可得时直接标记缺失",
30777
30993
  "隐藏推理、完整对话、完整工具日志或后台事件",
30778
30994
  "不读取、迁移或删除`.buildr/asset-review/`",
30779
- "task-retrospective-driver.mjs inspect",
30780
- "task-retrospective-driver.mjs record",
30781
- "task-retrospective-driver.mjs handle",
30995
+ "__internal task-retrospective inspect",
30996
+ "__internal task-retrospective record",
30997
+ "__internal task-retrospective handle",
30998
+ "matching retained Buildr controller invocation",
30782
30999
  "expected-current-digest",
30783
31000
  "`handled|no-action` 必须提供非空完整处理意见",
30784
31001
  "完整原始 `reportMarkdown`",
@@ -30962,6 +31179,7 @@ ${excerpt}`);
30962
31179
  validateTaskLifecycleRetirement(context);
30963
31180
  validateTaskReviewAuthority(context);
30964
31181
  validateTaskPlanningIdentityAuthority(context);
31182
+ validateInternalWorkflowRouteClosure(context);
30965
31183
  validateMappedEntries(context);
30966
31184
  validatePackageComponents(context);
30967
31185
  const skillSourceIds = validatePackageSkills(context);
@@ -30979,10 +31197,10 @@ ${excerpt}`);
30979
31197
 
30980
31198
  // src/application/package-maintenance/builtin-receipts.mjs
30981
31199
  function createBuiltinReceipts(deps) {
30982
- const { atomicWriteJson: atomicWriteJson3, collectFiles, crypto: crypto60, ensureDirectory: ensureDirectory3, existsDirectory, existsFile, fs: fs74, isPlainObject: isPlainObject3, path: path91, toPosixRelative: toPosixRelative3 } = deps;
31200
+ const { atomicWriteJson: atomicWriteJson3, collectFiles, crypto: crypto61, ensureDirectory: ensureDirectory3, existsDirectory, existsFile, fs: fs74, isPlainObject: isPlainObject3, path: path91, toPosixRelative: toPosixRelative3 } = deps;
30983
31201
  const schemaVersion = "buildr.builtin-receipts/v1";
30984
31202
  const relativePath4 = ".buildr/builtin-receipts.json";
30985
- const sha2567 = (value) => `sha256-${crypto60.createHash("sha256").update(value).digest("hex")}`;
31203
+ const sha2567 = (value) => `sha256-${crypto61.createHash("sha256").update(value).digest("hex")}`;
30986
31204
  function assetInventory(assetPath, kind) {
30987
31205
  if (kind === "command") return [{ path: "manifest-entry", integrity: sha2567(JSON.stringify(assetPath)) }];
30988
31206
  if (kind === "rule") {
@@ -31494,7 +31712,7 @@ function createBuiltinLifecycle(deps) {
31494
31712
  }
31495
31713
 
31496
31714
  // src/application/package-maintenance/capability-retirement.mjs
31497
- function createCapabilityRetirement({ assertSafeAssetTarget, crypto: crypto60, existsFile, fs: fs74, path: path91, removePath }) {
31715
+ function createCapabilityRetirement({ assertSafeAssetTarget, crypto: crypto61, existsFile, fs: fs74, path: path91, removePath }) {
31498
31716
  function applyCapabilityRetirements({ targetRoot, manifest, contracts: contracts2, bindings, findings, changed, checkOnly }) {
31499
31717
  const retirements = (manifest.capabilityContracts || []).flatMap((contract) => contract.replaces || []);
31500
31718
  const currentKeys = new Set((manifest.capabilityContracts || []).map((contract) => `${contract.id}@${contract.version}`));
@@ -31530,7 +31748,7 @@ function createCapabilityRetirement({ assertSafeAssetTarget, crypto: crypto60, e
31530
31748
  const bindingEntry = bindingMatches[0] || null;
31531
31749
  if (bindingEntry && bindingEntry.provider !== retirement.provider) throw new Error(`Capability retirement binding has drifted: ${retirement.id}@${retirement.version}`);
31532
31750
  if (targetExists) {
31533
- const integrity = `sha256-${crypto60.createHash("sha256").update(fs74.readFileSync(targetFile)).digest("hex")}`;
31751
+ const integrity = `sha256-${crypto61.createHash("sha256").update(fs74.readFileSync(targetFile)).digest("hex")}`;
31534
31752
  const acceptedIntegrities = /* @__PURE__ */ new Set([retirement.integrity, ...retirement.legacyIntegrities || []]);
31535
31753
  if (!acceptedIntegrities.has(integrity)) throw new Error(`Capability retirement file has drifted: ${retirement.target}`);
31536
31754
  }
@@ -31676,9 +31894,9 @@ function registerApplicationPackageMaintenance(runtime2) {
31676
31894
  write: writeBuiltinReceipts,
31677
31895
  fromSnapshot: receiptFromSnapshot,
31678
31896
  resolveState: resolveBuiltinState
31679
- } = createBuiltinReceipts({ atomicWriteJson: atomicWriteJson3, collectFiles, crypto: import_node_crypto35.default, ensureDirectory: ensureDirectory3, existsDirectory, existsFile, fs: import_node_fs46.default, isPlainObject: isPlainObject3, path: import_node_path54.default, toPosixRelative: toPosixRelative3 });
31897
+ } = createBuiltinReceipts({ atomicWriteJson: atomicWriteJson3, collectFiles, crypto: import_node_crypto36.default, ensureDirectory: ensureDirectory3, existsDirectory, existsFile, fs: import_node_fs46.default, isPlainObject: isPlainObject3, path: import_node_path54.default, toPosixRelative: toPosixRelative3 });
31680
31898
  const { handleSkillReplacement } = createBuiltinReplacement({ builtinReceiptKey, builtinSnapshot, copyDirectoryIfChanged, existsDirectory, path: import_node_path54.default });
31681
- const { applyCapabilityRetirements } = createCapabilityRetirement({ assertSafeAssetTarget, crypto: import_node_crypto35.default, existsFile, fs: import_node_fs46.default, path: import_node_path54.default, removePath });
31899
+ const { applyCapabilityRetirements } = createCapabilityRetirement({ assertSafeAssetTarget, crypto: import_node_crypto36.default, existsFile, fs: import_node_fs46.default, path: import_node_path54.default, removePath });
31682
31900
  const { packageBuiltinMutationPaths, builtinSyncPlanSignature } = createPackageSyncPlan({ assertSafeSyncMutationPaths, missingAncestorForMutation, mutationPathFingerprint, packageRegistryMutationPaths, path: import_node_path54.default, readPackageManifest, targetPathFromBuiltin, toPosixRelative: toPosixRelative3 });
31683
31901
  function syncPackageBuiltins(targetRoot, options = {}) {
31684
31902
  const manifest = readPackageManifest();
@@ -32061,7 +32279,7 @@ function registerApplicationPackageMaintenance(runtime2) {
32061
32279
  assertSafeAssetTarget,
32062
32280
  atomicWriteJson: atomicWriteJson3,
32063
32281
  collectFiles,
32064
- crypto: import_node_crypto35.default,
32282
+ crypto: import_node_crypto36.default,
32065
32283
  ensureDirectory: ensureDirectory3,
32066
32284
  existsDirectory,
32067
32285
  existsFile,
@@ -32119,6 +32337,7 @@ function registerApplicationWorkspaceOperations(runtime2) {
32119
32337
  const diagnoseSkillCapabilities = (...args) => runtime2.diagnoseSkillCapabilities(...args);
32120
32338
  const diagnoseProjectVerification = (...args) => runtime2.diagnoseProjectVerification(...args);
32121
32339
  const diagnoseProjectEnvironmentPreparation = (...args) => runtime2.diagnoseProjectEnvironmentPreparation(...args);
32340
+ const diagnoseInternalWorkflowRoutes = (...args) => runtime2.diagnoseInternalWorkflowRoutes(...args);
32122
32341
  const inspectTaskFinishPersistence = (...args) => runtime2.inspectTaskFinishPersistence(...args);
32123
32342
  const syncPackageBuiltins = (...args) => runtime2.syncPackageBuiltins(...args);
32124
32343
  const finalizeDoctorResult = (...args) => runtime2.finalizeDoctorResult(...args);
@@ -32406,6 +32625,7 @@ function registerApplicationWorkspaceOperations(runtime2) {
32406
32625
  diagnoseProjectEnvironmentPreparation(result5, targetRoot, registry);
32407
32626
  diagnoseServices(result5, targetRoot, scopes, registry);
32408
32627
  diagnoseSkillsManifestSchemas(result5, targetRoot, scopes);
32628
+ diagnoseInternalWorkflowRoutes(result5);
32409
32629
  if (result5.workspace?.initialized) diagnoseSkillCapabilities(result5, targetRoot, scopes, requestedAgent);
32410
32630
  if (result5.workspace?.initialized) {
32411
32631
  try {
@@ -32888,7 +33108,7 @@ function defaultReleaseTrack(version) {
32888
33108
  init_process();
32889
33109
 
32890
33110
  // src/infrastructure/product-identity/installation-registry.mjs
32891
- var import_node_crypto36 = __toESM(require("node:crypto"), 1);
33111
+ var import_node_crypto37 = __toESM(require("node:crypto"), 1);
32892
33112
  var import_node_fs49 = __toESM(require("node:fs"), 1);
32893
33113
  var import_node_path57 = __toESM(require("node:path"), 1);
32894
33114
  var import_node_process27 = __toESM(require("node:process"), 1);
@@ -32907,7 +33127,7 @@ var INSTALLATION_FIELDS = /* @__PURE__ */ new Set([
32907
33127
  var RUNTIME_FIELDS = /* @__PURE__ */ new Set(["role", "executable", "version", "platform", "architecture", "identity"]);
32908
33128
  var UPDATE_AUTHORITY_FIELDS = /* @__PURE__ */ new Set(["type", "nodeExecutable", "npmCliPath", "prefix", "identity"]);
32909
33129
  function sha2564(value) {
32910
- return `sha256-${import_node_crypto36.default.createHash("sha256").update(value).digest("hex")}`;
33130
+ return `sha256-${import_node_crypto37.default.createHash("sha256").update(value).digest("hex")}`;
32911
33131
  }
32912
33132
  function assertClosed(value, fields, label) {
32913
33133
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object.`);
@@ -34786,7 +35006,7 @@ function registerServiceApplication(runtime2) {
34786
35006
  }
34787
35007
 
34788
35008
  // src/application/change/change-application.mjs
34789
- var import_node_crypto37 = __toESM(require("node:crypto"), 1);
35009
+ var import_node_crypto38 = __toESM(require("node:crypto"), 1);
34790
35010
  var import_node_fs55 = __toESM(require("node:fs"), 1);
34791
35011
  var import_node_path63 = __toESM(require("node:path"), 1);
34792
35012
  var SAFE_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -34873,7 +35093,7 @@ function uiPreviewTitle(content, relative6) {
34873
35093
  return title || import_node_path63.default.basename(relative6, import_node_path63.default.extname(relative6));
34874
35094
  }
34875
35095
  function uiPreviewId(project, change, relative6) {
34876
- return import_node_crypto37.default.createHash("sha256").update(`${project}\0${change}\0${relative6}`).digest("hex").slice(0, 32);
35096
+ return import_node_crypto38.default.createHash("sha256").update(`${project}\0${change}\0${relative6}`).digest("hex").slice(0, 32);
34877
35097
  }
34878
35098
  function discoverUiPreviews(changeRoot) {
34879
35099
  const previews = [];
@@ -35221,7 +35441,7 @@ function registerChangeApplication(runtime2) {
35221
35441
  }
35222
35442
 
35223
35443
  // src/application/worktree/git-worktree-provider.mjs
35224
- var import_node_crypto41 = __toESM(require("node:crypto"), 1);
35444
+ var import_node_crypto42 = __toESM(require("node:crypto"), 1);
35225
35445
  var import_node_fs58 = __toESM(require("node:fs"), 1);
35226
35446
  var import_node_path66 = __toESM(require("node:path"), 1);
35227
35447
  var import_node_process31 = __toESM(require("node:process"), 1);
@@ -35242,7 +35462,7 @@ function inside6(parent, child) {
35242
35462
  return relative6 === "" || !import_node_path66.default.isAbsolute(relative6) && relative6 !== ".." && !relative6.startsWith(`..${import_node_path66.default.sep}`);
35243
35463
  }
35244
35464
  function planDigest(plan) {
35245
- return `sha256-${import_node_crypto41.default.createHash("sha256").update(JSON.stringify(plan.repositories.map((item) => ({
35465
+ return `sha256-${import_node_crypto42.default.createHash("sha256").update(JSON.stringify(plan.repositories.map((item) => ({
35246
35466
  selector: item.selector,
35247
35467
  entityType: item.entityType,
35248
35468
  sourcePath: item.sourcePath,
@@ -35624,7 +35844,7 @@ function registerGitWorktreeProvider(runtime2) {
35624
35844
  }
35625
35845
 
35626
35846
  // src/application/task-finish/task-finish-application.mjs
35627
- var import_node_crypto49 = __toESM(require("node:crypto"), 1);
35847
+ var import_node_crypto50 = __toESM(require("node:crypto"), 1);
35628
35848
  var import_node_path75 = __toESM(require("node:path"), 1);
35629
35849
  init_filesystem_path_identity();
35630
35850
 
@@ -36225,7 +36445,7 @@ function cleanupTaskFinishDiagnosticsEvidence(evidence, options = {}) {
36225
36445
  init_task_finish_delivery_commit();
36226
36446
 
36227
36447
  // src/application/task-finish/task-finish-self-bootstrap-projection.mjs
36228
- var import_node_crypto45 = __toESM(require("node:crypto"), 1);
36448
+ var import_node_crypto46 = __toESM(require("node:crypto"), 1);
36229
36449
  var import_node_path72 = __toESM(require("node:path"), 1);
36230
36450
  var SUPPORTED_RESULT_SCHEMAS = /* @__PURE__ */ new Set([
36231
36451
  "buildr.task-finish-result/v2",
@@ -36244,7 +36464,7 @@ function projectionError(message, details = null) {
36244
36464
  return error3;
36245
36465
  }
36246
36466
  function digest13(value) {
36247
- return `sha256-${import_node_crypto45.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
36467
+ return `sha256-${import_node_crypto46.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
36248
36468
  }
36249
36469
  function optionalString2(value) {
36250
36470
  return typeof value === "string" && value.trim() ? value : null;
@@ -36757,7 +36977,7 @@ function projectTaskFinishResult(result5, detail = "compact") {
36757
36977
  }
36758
36978
 
36759
36979
  // src/application/task-finish/task-finish-bootstrap-recovery.mjs
36760
- var import_node_crypto46 = __toESM(require("node:crypto"), 1);
36980
+ var import_node_crypto47 = __toESM(require("node:crypto"), 1);
36761
36981
  var import_node_fs60 = __toESM(require("node:fs"), 1);
36762
36982
  var import_node_path73 = __toESM(require("node:path"), 1);
36763
36983
  var import_node_child_process8 = require("node:child_process");
@@ -36780,7 +37000,7 @@ function clone3(value) {
36780
37000
  return value == null ? value : JSON.parse(JSON.stringify(value));
36781
37001
  }
36782
37002
  function digest14(value) {
36783
- return `sha256-${import_node_crypto46.default.createHash("sha256").update(typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value)).digest("hex")}`;
37003
+ return `sha256-${import_node_crypto47.default.createHash("sha256").update(typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value)).digest("hex")}`;
36784
37004
  }
36785
37005
  function recoveryError(code, message, details = null) {
36786
37006
  const error3 = new Error(message);
@@ -37331,7 +37551,7 @@ function assertArgs(action, args) {
37331
37551
  }
37332
37552
  function finishInvocationId(task) {
37333
37553
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.TZ]/g, "").slice(0, 14);
37334
- return `${task}-${stamp}-${import_node_crypto49.default.randomBytes(6).toString("hex")}`;
37554
+ return `${task}-${stamp}-${import_node_crypto50.default.randomBytes(6).toString("hex")}`;
37335
37555
  }
37336
37556
  function withExecutionRecord(result5, executionRecord2) {
37337
37557
  return { ...result5, executionRecord: executionRecord2 };
@@ -38455,12 +38675,12 @@ function registerTaskRetrospectiveApplication(runtime2) {
38455
38675
  }
38456
38676
 
38457
38677
  // src/application/task-verification/task-verification-application.mjs
38458
- var import_node_crypto50 = __toESM(require("node:crypto"), 1);
38678
+ var import_node_crypto51 = __toESM(require("node:crypto"), 1);
38459
38679
  var import_node_fs62 = __toESM(require("node:fs"), 1);
38460
38680
  var import_node_path77 = __toESM(require("node:path"), 1);
38461
38681
  init_filesystem_path_identity();
38462
38682
  function digest17(value) {
38463
- return `sha256-${import_node_crypto50.default.createHash("sha256").update(typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value)).digest("hex")}`;
38683
+ return `sha256-${import_node_crypto51.default.createHash("sha256").update(typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value)).digest("hex")}`;
38464
38684
  }
38465
38685
  function assertObject6(input, label) {
38466
38686
  if (!input || typeof input !== "object" || Array.isArray(input)) throw taskVerificationError("task_verification_input_invalid", `${label} 必须是对象。`);
@@ -38574,6 +38794,12 @@ function registerTaskVerificationApplication(runtime2) {
38574
38794
  const expected = new Map(result5.declarations.map((item) => [item.project, item]));
38575
38795
  const actual = declarationsInput === void 0 ? null : new Map(declarationsInput.map((item) => [item.project, item]));
38576
38796
  const reasons = [];
38797
+ if (currentTargetIdentity === void 0) {
38798
+ reasons.push({ axis: "target", code: "target-identity-not-provided", message: "Caller 未提供 current target identity;未执行外部观察。" });
38799
+ }
38800
+ if (actual == null) {
38801
+ reasons.push({ axis: "declaration", code: "declaration-identities-not-provided", message: "Caller 未提供 current declaration identities;未执行外部观察。" });
38802
+ }
38577
38803
  if (actual) {
38578
38804
  for (const [project, declaration] of expected) {
38579
38805
  const observed = actual.get(project);
@@ -39731,10 +39957,12 @@ function commandRoute(next, execution, taskId2) {
39731
39957
  verify: ["task", "verification", "inspect", taskId2, "--target", execution.workspaceRoot, "--json"],
39732
39958
  finish: ["task", "finish", "run", "--task", taskId2, "--target", execution.workspaceRoot, "--json"]
39733
39959
  }[next.action] || null;
39960
+ const internalArgs = next.owner === "task-development" && TASK_DEVELOPMENT_ACTIONS.includes(next.action) ? ["__internal", "task-development", next.action, "--task", taskId2, "--target", execution.workspaceRoot] : null;
39961
+ const args = publicArgs || internalArgs;
39734
39962
  return {
39735
39963
  writer: next.owner === "agent" ? "agent" : "retained-controller",
39736
39964
  invocation: controller,
39737
- argv: publicArgs ? [...controller.argsPrefix, ...publicArgs] : null
39965
+ argv: args ? [...controller.argsPrefix, ...args] : null
39738
39966
  };
39739
39967
  }
39740
39968
  function profileEntry(startedAt, reads, attempts, status) {
@@ -39844,7 +40072,7 @@ function registerTaskEntrySnapshotApplication(runtime2) {
39844
40072
  }
39845
40073
 
39846
40074
  // src/domain/task-planning-identity/task-planning-identity.mjs
39847
- var import_node_crypto51 = __toESM(require("node:crypto"), 1);
40075
+ var import_node_crypto52 = __toESM(require("node:crypto"), 1);
39848
40076
  var TASK_PLANNING_IDENTITY_RESULT_SCHEMA = "buildr.task-planning-identity-result/v1";
39849
40077
  var TASK_PLANNING_IDENTITY_AUTHORITY = "buildr.task-planning-identity/v1";
39850
40078
  var TASK_PLANNING_IGNORED_FACTS = Object.freeze([
@@ -39869,7 +40097,7 @@ function taskPlanningIdentityError(code, message, details = void 0, nextAction =
39869
40097
  }
39870
40098
  function taskPlanningIdentityDigest(value) {
39871
40099
  const content = typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value);
39872
- return `sha256-${import_node_crypto51.default.createHash("sha256").update(content).digest("hex")}`;
40100
+ return `sha256-${import_node_crypto52.default.createHash("sha256").update(content).digest("hex")}`;
39873
40101
  }
39874
40102
  function text12(value, field) {
39875
40103
  if (typeof value !== "string" || !value.trim()) {
@@ -40159,9 +40387,9 @@ function registerTaskPlanningIdentityApplication(runtime2) {
40159
40387
  }
40160
40388
 
40161
40389
  // src/application/task-overview/task-overview-application.mjs
40162
- var import_node_crypto52 = __toESM(require("node:crypto"), 1);
40390
+ var import_node_crypto53 = __toESM(require("node:crypto"), 1);
40163
40391
  function digest18(value) {
40164
- return value == null ? null : `sha256-${import_node_crypto52.default.createHash("sha256").update(value).digest("hex")}`;
40392
+ return value == null ? null : `sha256-${import_node_crypto53.default.createHash("sha256").update(value).digest("hex")}`;
40165
40393
  }
40166
40394
  function parsed(value) {
40167
40395
  return value == null ? null : JSON.parse(value);
@@ -40631,7 +40859,7 @@ function registerProjectDailyProgressApplication(runtime2) {
40631
40859
  }
40632
40860
 
40633
40861
  // src/application/task-environment/task-environment-application.mjs
40634
- var import_node_crypto53 = __toESM(require("node:crypto"), 1);
40862
+ var import_node_crypto54 = __toESM(require("node:crypto"), 1);
40635
40863
  var import_node_fs64 = __toESM(require("node:fs"), 1);
40636
40864
  var import_node_path80 = __toESM(require("node:path"), 1);
40637
40865
  var import_node_process33 = __toESM(require("node:process"), 1);
@@ -40654,7 +40882,7 @@ function now3() {
40654
40882
  return (/* @__PURE__ */ new Date()).toISOString();
40655
40883
  }
40656
40884
  function digestFiles(root) {
40657
- const hash = import_node_crypto53.default.createHash("sha256");
40885
+ const hash = import_node_crypto54.default.createHash("sha256");
40658
40886
  const visit = (target) => {
40659
40887
  if (!import_node_fs64.default.existsSync(target)) return;
40660
40888
  const stat = import_node_fs64.default.lstatSync(target);
@@ -40680,7 +40908,7 @@ function probe(status, identity6 = null, diagnostic2 = null, observedAt = now3()
40680
40908
  return { status, identity: identity6, observedAt, diagnostic: diagnostic2 };
40681
40909
  }
40682
40910
  function fileIdentity(file) {
40683
- return import_node_fs64.default.existsSync(file) && import_node_fs64.default.statSync(file).isFile() ? `sha256-${import_node_crypto53.default.createHash("sha256").update(import_node_fs64.default.readFileSync(file)).digest("hex")}` : null;
40911
+ return import_node_fs64.default.existsSync(file) && import_node_fs64.default.statSync(file).isFile() ? `sha256-${import_node_crypto54.default.createHash("sha256").update(import_node_fs64.default.readFileSync(file)).digest("hex")}` : null;
40684
40912
  }
40685
40913
  function registerTaskEnvironmentApplication(runtime2) {
40686
40914
  const productInvocation = (options) => (runtime2.currentProductInvocation || currentProductInvocation)(options);
@@ -40969,7 +41197,7 @@ function registerTaskEnvironmentApplication(runtime2) {
40969
41197
  const stat = import_node_fs64.default.statSync(executable2);
40970
41198
  if (!stat.isFile()) return null;
40971
41199
  const payload = [import_node_fs64.default.realpathSync(executable2), stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.mode];
40972
- return `sha256-${import_node_crypto53.default.createHash("sha256").update(JSON.stringify(payload)).digest("hex")}`;
41200
+ return `sha256-${import_node_crypto54.default.createHash("sha256").update(JSON.stringify(payload)).digest("hex")}`;
40973
41201
  } catch {
40974
41202
  return null;
40975
41203
  }
@@ -41218,7 +41446,7 @@ function registerTaskEnvironmentApplication(runtime2) {
41218
41446
  const relevant = preparationScopes.filter((item) => scope.kind === "workspace" || scope.kind === "project" && (item.selector === scope.selector || item.selector.startsWith(`service:${scope.project}/`)) || item.selector === scope.selector);
41219
41447
  if (!relevant.length) return { ...scope, preparation: probe("not-applicable", null, null) };
41220
41448
  const blockedScope = relevant.find((item) => item.status === "blocked");
41221
- const preparationIdentity = `sha256-${import_node_crypto53.default.createHash("sha256").update(JSON.stringify(relevant.map((item) => [item.selector, item.status, ...item.recipeIds]))).digest("hex")}`;
41449
+ const preparationIdentity = `sha256-${import_node_crypto54.default.createHash("sha256").update(JSON.stringify(relevant.map((item) => [item.selector, item.status, ...item.recipeIds]))).digest("hex")}`;
41222
41450
  return { ...scope, preparation: blockedScope ? probe("blocked", preparationIdentity, `${blockedScope.selector}: ${blockedScope.diagnostic}`, blockedScope.observedAt) : probe("ready", preparationIdentity, null) };
41223
41451
  });
41224
41452
  return { scopes, declarations, preparationScopes, recipes };
@@ -41937,7 +42165,7 @@ var import_node_os10 = __toESM(require("node:os"), 1);
41937
42165
  var import_node_path83 = __toESM(require("node:path"), 1);
41938
42166
 
41939
42167
  // src/application/verification/execution-record.mjs
41940
- var import_node_crypto54 = __toESM(require("node:crypto"), 1);
42168
+ var import_node_crypto55 = __toESM(require("node:crypto"), 1);
41941
42169
  var import_node_path82 = __toESM(require("node:path"), 1);
41942
42170
  var VERIFICATION_EXECUTION_RECORD_OWNER = "task-verification";
41943
42171
  var VERIFICATION_EXECUTION_RECORD_KIND = "verification-execution";
@@ -41968,7 +42196,7 @@ var MAPPER_FIELDS2 = /* @__PURE__ */ new Set([
41968
42196
  "diagnostic"
41969
42197
  ]);
41970
42198
  function digest19(value) {
41971
- return `sha256-${import_node_crypto54.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
42199
+ return `sha256-${import_node_crypto55.default.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
41972
42200
  }
41973
42201
  function verificationInvocationIdentity({ taskId: taskId2, projectCode, declarationIdentity, targetIdentity, selectedCapabilities }) {
41974
42202
  return digest19({
@@ -43017,7 +43245,7 @@ function registerTaskExecutionRecordApplication(runtime2) {
43017
43245
  }
43018
43246
 
43019
43247
  // src/application/verification/verification-application.mjs
43020
- var import_node_crypto56 = __toESM(require("node:crypto"), 1);
43248
+ var import_node_crypto57 = __toESM(require("node:crypto"), 1);
43021
43249
  var import_node_fs69 = __toESM(require("node:fs"), 1);
43022
43250
  var import_node_path86 = __toESM(require("node:path"), 1);
43023
43251
  var import_node_process35 = __toESM(require("node:process"), 1);
@@ -43116,7 +43344,7 @@ function executeVerificationCommand(step, options = {}) {
43116
43344
  }
43117
43345
 
43118
43346
  // src/application/verification/resource-coordinator.mjs
43119
- var import_node_crypto55 = __toESM(require("node:crypto"), 1);
43347
+ var import_node_crypto56 = __toESM(require("node:crypto"), 1);
43120
43348
  var import_node_fs68 = __toESM(require("node:fs"), 1);
43121
43349
  var import_node_os11 = __toESM(require("node:os"), 1);
43122
43350
  var import_node_path85 = __toESM(require("node:path"), 1);
@@ -43129,14 +43357,14 @@ function safeIdentity(value, fallback) {
43129
43357
  return (normalized || fallback).slice(0, 80);
43130
43358
  }
43131
43359
  function digest20(value) {
43132
- return import_node_crypto55.default.createHash("sha256").update(String(value)).digest("hex");
43360
+ return import_node_crypto56.default.createHash("sha256").update(String(value)).digest("hex");
43133
43361
  }
43134
43362
  function scopedIdentity(value, fallback) {
43135
43363
  const raw = String(value || fallback);
43136
43364
  return `${safeIdentity(raw, fallback).slice(0, 60)}-${digest20(raw).slice(0, 12)}`;
43137
43365
  }
43138
43366
  function atomicWriteJson2(file, value) {
43139
- const temporary = `${file}.tmp-${import_node_process34.default.pid}-${import_node_crypto55.default.randomBytes(4).toString("hex")}`;
43367
+ const temporary = `${file}.tmp-${import_node_process34.default.pid}-${import_node_crypto56.default.randomBytes(4).toString("hex")}`;
43140
43368
  import_node_fs68.default.writeFileSync(temporary, `${JSON.stringify(value, null, 2)}
43141
43369
  `, { mode: 384 });
43142
43370
  import_node_fs68.default.renameSync(temporary, file);
@@ -43237,7 +43465,7 @@ function createVerificationResourceCoordinator(options) {
43237
43465
  function createTicket(resource) {
43238
43466
  const waitersRoot = import_node_path85.default.join(resourceRoot(resource), "waiters");
43239
43467
  import_node_fs68.default.mkdirSync(waitersRoot, { recursive: true, mode: 448 });
43240
- const token = import_node_crypto55.default.randomUUID();
43468
+ const token = import_node_crypto56.default.randomUUID();
43241
43469
  const directory2 = import_node_path85.default.join(waitersRoot, token);
43242
43470
  const temporary = import_node_path85.default.join(waitersRoot, `.${token}.creating-${import_node_process34.default.pid}`);
43243
43471
  const ticket = ticketValue(resource, token);
@@ -43259,7 +43487,7 @@ function createVerificationResourceCoordinator(options) {
43259
43487
  const file = import_node_path85.default.join(ticket.directory, "ticket.json");
43260
43488
  const current = readJson2(file);
43261
43489
  if (!current || current.token !== ticket.ticket.token || !ownerMatches(current, owner)) return false;
43262
- const removed = `${ticket.directory}.${suffix}-${import_node_process34.default.pid}-${import_node_crypto55.default.randomBytes(3).toString("hex")}`;
43490
+ const removed = `${ticket.directory}.${suffix}-${import_node_process34.default.pid}-${import_node_crypto56.default.randomBytes(3).toString("hex")}`;
43263
43491
  try {
43264
43492
  releaseLeaseDirectory(ticket.directory, removed);
43265
43493
  return true;
@@ -43272,7 +43500,7 @@ function createVerificationResourceCoordinator(options) {
43272
43500
  const file = import_node_path85.default.join(directory2, "ticket.json");
43273
43501
  const current = readJson2(file);
43274
43502
  if (!current || current.token !== ticket.token || Date.parse(current.expiresAt) > now4()) return false;
43275
- const expired = `${directory2}.expired-${import_node_process34.default.pid}-${import_node_crypto55.default.randomBytes(3).toString("hex")}`;
43503
+ const expired = `${directory2}.expired-${import_node_process34.default.pid}-${import_node_crypto56.default.randomBytes(3).toString("hex")}`;
43276
43504
  try {
43277
43505
  releaseLeaseDirectory(directory2, expired);
43278
43506
  return true;
@@ -43322,7 +43550,7 @@ function createVerificationResourceCoordinator(options) {
43322
43550
  const currentResourceRoot = resourceRoot(resource);
43323
43551
  for (let slot2 = 0; slot2 < definition.capacity; slot2 += 1) {
43324
43552
  const directory2 = import_node_path85.default.join(currentResourceRoot, `slot-${slot2}`);
43325
- const token = import_node_crypto55.default.randomUUID();
43553
+ const token = import_node_crypto56.default.randomUUID();
43326
43554
  try {
43327
43555
  import_node_fs68.default.mkdirSync(directory2, { mode: 448 });
43328
43556
  const lease = leaseValue(resource, slot2, token);
@@ -43334,7 +43562,7 @@ function createVerificationResourceCoordinator(options) {
43334
43562
  const file = import_node_path85.default.join(directory2, "lease.json");
43335
43563
  const existing = readJson2(file);
43336
43564
  if (!existing || Date.parse(existing.expiresAt) > now4()) continue;
43337
- const stale = `${directory2}.stale-${import_node_process34.default.pid}-${import_node_crypto55.default.randomBytes(3).toString("hex")}`;
43565
+ const stale = `${directory2}.stale-${import_node_process34.default.pid}-${import_node_crypto56.default.randomBytes(3).toString("hex")}`;
43338
43566
  try {
43339
43567
  replaceExpiredLeaseDirectory(directory2, stale);
43340
43568
  import_node_fs68.default.mkdirSync(directory2, { mode: 448 });
@@ -43360,7 +43588,7 @@ function createVerificationResourceCoordinator(options) {
43360
43588
  results.push({ resource: claim.resource, slot: claim.slot, status: "ownership-mismatch" });
43361
43589
  continue;
43362
43590
  }
43363
- const released = `${claim.directory}.released-${import_node_process34.default.pid}-${import_node_crypto55.default.randomBytes(3).toString("hex")}`;
43591
+ const released = `${claim.directory}.released-${import_node_process34.default.pid}-${import_node_crypto56.default.randomBytes(3).toString("hex")}`;
43364
43592
  try {
43365
43593
  releaseLeaseDirectory(claim.directory, released);
43366
43594
  results.push({ resource: claim.resource, slot: claim.slot, status: "released" });
@@ -43438,7 +43666,7 @@ function createVerificationResourceCoordinator(options) {
43438
43666
 
43439
43667
  // src/application/verification/verification-application.mjs
43440
43668
  function digest21(value) {
43441
- return `sha256-${import_node_crypto56.default.createHash("sha256").update(typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value)).digest("hex")}`;
43669
+ return `sha256-${import_node_crypto57.default.createHash("sha256").update(typeof value === "string" || Buffer.isBuffer(value) ? value : JSON.stringify(value)).digest("hex")}`;
43442
43670
  }
43443
43671
  function inside11(parent, child) {
43444
43672
  const relative6 = import_node_path86.default.relative(parent, child);
@@ -43569,7 +43797,7 @@ function optionValues(args, option) {
43569
43797
  }
43570
43798
  return values;
43571
43799
  }
43572
- function sanitizeCheck(result5) {
43800
+ function executionCheck(result5) {
43573
43801
  return {
43574
43802
  id: result5.id,
43575
43803
  title: result5.title,
@@ -43586,6 +43814,30 @@ function sanitizeCheck(result5) {
43586
43814
  resourceCoordination: result5.resourceCoordination || null
43587
43815
  };
43588
43816
  }
43817
+ function publicFailureSummary(check) {
43818
+ if (check.status !== "failed") return null;
43819
+ const outcome = check.signal ? `signal ${check.signal}` : Number.isInteger(check.exitCode) ? `exit code ${check.exitCode}` : "a non-passing process outcome";
43820
+ return {
43821
+ code: "verification.capability_failed",
43822
+ message: `Capability ${check.id} failed with ${outcome}.`
43823
+ };
43824
+ }
43825
+ function publicCheck(check) {
43826
+ return {
43827
+ id: check.id,
43828
+ title: check.title,
43829
+ status: check.status,
43830
+ exitCode: check.exitCode,
43831
+ signal: check.signal,
43832
+ durationMs: check.durationMs,
43833
+ queuedAt: check.queuedAt,
43834
+ startedAt: check.startedAt,
43835
+ finishedAt: check.finishedAt,
43836
+ queueDurationMs: check.queueDurationMs,
43837
+ resourceCoordination: check.resourceCoordination,
43838
+ failureSummary: publicFailureSummary(check)
43839
+ };
43840
+ }
43589
43841
  function verificationExecutionIdentityMaterial({ project, declaration, target, context, observation: observation2, checks }) {
43590
43842
  return {
43591
43843
  schemaVersion: PUBLIC_JSON_SCHEMAS.verificationExecution,
@@ -43678,7 +43930,7 @@ function registerVerificationApplication(runtime2) {
43678
43930
  targetIdentity,
43679
43931
  selectedCapabilities: selected
43680
43932
  }) : null;
43681
- const runId = `verification-${Date.now()}-${import_node_crypto56.default.randomBytes(4).toString("hex")}`;
43933
+ const runId = `verification-${Date.now()}-${import_node_crypto57.default.randomBytes(4).toString("hex")}`;
43682
43934
  let openedExecutionRecord = null;
43683
43935
  if (context) {
43684
43936
  try {
@@ -43761,11 +44013,12 @@ function registerVerificationApplication(runtime2) {
43761
44013
  const after = executionContentObservation(targetRoot);
43762
44014
  const durationMs = Math.round(Number(import_node_process35.default.hrtime.bigint() - started) / 1e6);
43763
44015
  const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
43764
- const checks = results.map(sanitizeCheck);
44016
+ const executionChecks = results.map(executionCheck);
44017
+ const checks = executionChecks.map(publicCheck);
43765
44018
  const targetStable = digest21(before) === digest21(after);
43766
44019
  const targetDrift = targetDriftSummary(before, after);
43767
44020
  const passed = targetStable && checks.every((check) => check.status === "passed");
43768
- const executionRecordOutcome = verificationExecutionRecordOutcome({ passed, checks });
44021
+ const executionRecordOutcome = verificationExecutionRecordOutcome({ passed, checks: executionChecks });
43769
44022
  const identityMaterial = verificationExecutionIdentityMaterial({
43770
44023
  project: projectCode,
43771
44024
  declaration: declarationIdentity,
@@ -43826,7 +44079,7 @@ function registerVerificationApplication(runtime2) {
43826
44079
  selectedCapabilities: selected,
43827
44080
  authorizedCapabilities,
43828
44081
  authorizedResources,
43829
- checks,
44082
+ checks: executionChecks,
43830
44083
  outcome: executionRecordOutcome,
43831
44084
  durationMs,
43832
44085
  startedAt,
@@ -43933,7 +44186,7 @@ var import_node_process37 = __toESM(require("node:process"), 1);
43933
44186
  var import_node_util = require("node:util");
43934
44187
 
43935
44188
  // src/infrastructure/product-launcher/index.mjs
43936
- var import_node_crypto58 = __toESM(require("node:crypto"), 1);
44189
+ var import_node_crypto59 = __toESM(require("node:crypto"), 1);
43937
44190
  var import_node_fs71 = __toESM(require("node:fs"), 1);
43938
44191
  var import_node_os12 = __toESM(require("node:os"), 1);
43939
44192
  var import_node_path88 = __toESM(require("node:path"), 1);
@@ -43942,7 +44195,7 @@ var import_node_child_process13 = require("node:child_process");
43942
44195
  init_filesystem_path_identity();
43943
44196
 
43944
44197
  // src/infrastructure/product-identity/launcher-binding.mjs
43945
- var import_node_crypto57 = __toESM(require("node:crypto"), 1);
44198
+ var import_node_crypto58 = __toESM(require("node:crypto"), 1);
43946
44199
  var import_node_fs70 = __toESM(require("node:fs"), 1);
43947
44200
  var import_node_path87 = __toESM(require("node:path"), 1);
43948
44201
  init_filesystem_path_identity();
@@ -43976,7 +44229,7 @@ var FILE_IDENTITY_FIELDS = /* @__PURE__ */ new Set(["path", "version", "sha256"]
43976
44229
  var ENTRY_IDENTITY_FIELDS = /* @__PURE__ */ new Set(["path", "sha256"]);
43977
44230
  var WEB_PORT_FIELDS = /* @__PURE__ */ new Set(["preferred", "fallback"]);
43978
44231
  function digest22(value) {
43979
- return `sha256-${import_node_crypto57.default.createHash("sha256").update(value).digest("hex")}`;
44232
+ return `sha256-${import_node_crypto58.default.createHash("sha256").update(value).digest("hex")}`;
43980
44233
  }
43981
44234
  function fileDigest2(file) {
43982
44235
  return digest22(import_node_fs70.default.readFileSync(file));
@@ -44150,6 +44403,7 @@ function macLauncherScript(binding) {
44150
44403
  const jobPrefix = `ai.buildr.web.npm-launcher.runner.${binding.launcherOwnershipIdentity.slice("sha256-".length, "sha256-".length + 16)}`;
44151
44404
  return `#!/bin/sh
44152
44405
  NODE=${quoteShell(binding.hostNode.path)}
44406
+ NODE_BIN=$(/usr/bin/dirname "\${NODE}")
44153
44407
  NODE_SHA=${quoteShell(binding.hostNode.sha256.slice("sha256-".length))}
44154
44408
  ENTRY=${quoteShell(binding.packageEntry.path)}
44155
44409
  ENTRY_SHA=${quoteShell(binding.packageEntry.sha256.slice("sha256-".length))}
@@ -44175,12 +44429,13 @@ NO_OPEN="\${BUILDR_LAUNCHER_NO_OPEN-}"
44175
44429
  /bin/launchctl submit -l "\${LABEL}" -- /bin/sh -c '
44176
44430
  LABEL="$1"
44177
44431
  NODE="$2"
44178
- ENTRY="$3"
44179
- BINDING="$4"
44180
- LOG_FILE="$5"
44181
- APP_DATA="$6"
44182
- PRODUCT_DATA="$7"
44183
- NO_OPEN="$8"
44432
+ NODE_BIN="$3"
44433
+ ENTRY="$4"
44434
+ BINDING="$5"
44435
+ LOG_FILE="$6"
44436
+ APP_DATA="$7"
44437
+ PRODUCT_DATA="$8"
44438
+ NO_OPEN="$9"
44184
44439
  cleanup() {
44185
44440
  /bin/launchctl remove "\${LABEL}" >/dev/null 2>&1 || true
44186
44441
  }
@@ -44188,13 +44443,18 @@ trap cleanup 0
44188
44443
  [ -n "\${APP_DATA}" ] && export BUILDR_APP_DATA_DIR="\${APP_DATA}" || unset BUILDR_APP_DATA_DIR
44189
44444
  [ -n "\${PRODUCT_DATA}" ] && export BUILDR_PRODUCT_DATA_DIR="\${PRODUCT_DATA}" || unset BUILDR_PRODUCT_DATA_DIR
44190
44445
  [ -n "\${NO_OPEN}" ] && export BUILDR_LAUNCHER_NO_OPEN="\${NO_OPEN}" || unset BUILDR_LAUNCHER_NO_OPEN
44446
+ export PATH="\${NODE_BIN}\${PATH:+:\${PATH}}"
44447
+ NODE_VERSION="$("\${NODE}" -p "process.versions.node")"
44448
+ NODE_EXECUTABLE="$("\${NODE}" -p "process.execPath")"
44449
+ printf "%s
44450
+ " "Node identity: executable=\${NODE_EXECUTABLE} version=\${NODE_VERSION} pathHead=\${NODE_BIN}" >>"\${LOG_FILE}"
44191
44451
  "\${NODE}" "\${ENTRY}" web --launcher-binding "\${BINDING}" >>"\${LOG_FILE}" 2>&1
44192
44452
  STATUS=$?
44193
44453
  if [ "\${STATUS}" -ne 0 ]; then
44194
44454
  printf "%s\\n" "Buildr Web exited with status \${STATUS}" >>"\${LOG_FILE}"
44195
44455
  /usr/bin/osascript -e "display alert \\"Buildr Web 无法启动\\" message \\"正式 Launcher 启动失败。请在终端运行 buildr web launcher status,然后执行 buildr web launcher repair。\\" as critical" >/dev/null 2>&1 || true
44196
44456
  fi
44197
- ' buildr-web-launcher "\${LABEL}" "\${NODE}" "\${ENTRY}" "\${BINDING}" "\${LOG_FILE}" "\${APP_DATA}" "\${PRODUCT_DATA}" "\${NO_OPEN}"
44457
+ ' buildr-web-launcher "\${LABEL}" "\${NODE}" "\${NODE_BIN}" "\${ENTRY}" "\${BINDING}" "\${LOG_FILE}" "\${APP_DATA}" "\${PRODUCT_DATA}" "\${NO_OPEN}"
44198
44458
  STATUS=$?
44199
44459
  [ "\${STATUS}" -eq 0 ] || fail "Could not submit Buildr Web background runner: status \${STATUS}"
44200
44460
  exit 0
@@ -44668,7 +44928,7 @@ __export(platform_exports, {
44668
44928
  buildRuleDiscoveryPlan: () => buildRuleDiscoveryPlan,
44669
44929
  checkClaudeCodeRuntime: () => checkClaudeCodeRuntime,
44670
44930
  checkCodexRuntime: () => checkCodexRuntime,
44671
- crypto: () => import_node_crypto59.default,
44931
+ crypto: () => import_node_crypto60.default,
44672
44932
  execFileSync: () => import_node_child_process.execFileSync,
44673
44933
  fileURLToPath: () => import_node_url4.fileURLToPath,
44674
44934
  fs: () => import_node_fs73.default,
@@ -44690,7 +44950,7 @@ __export(platform_exports, {
44690
44950
  spawnSync: () => import_node_child_process.spawnSync
44691
44951
  });
44692
44952
  var import_node_fs73 = __toESM(require("node:fs"), 1);
44693
- var import_node_crypto59 = __toESM(require("node:crypto"), 1);
44953
+ var import_node_crypto60 = __toESM(require("node:crypto"), 1);
44694
44954
  var import_node_os14 = __toESM(require("node:os"), 1);
44695
44955
  var import_node_path90 = __toESM(require("node:path"), 1);
44696
44956
  var import_node_process38 = __toESM(require("node:process"), 1);