@tiangong-lca/foundry 0.1.17 → 0.1.19

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.
Files changed (162) hide show
  1. package/README.md +23 -7
  2. package/docs/architecture.md +15 -3
  3. package/docs/foundry-task-contracts.md +27 -3
  4. package/docs/package-distribution-contract.md +45 -13
  5. package/docs/public-runtime-contract.md +85 -5
  6. package/docs/runtime-context-contract.md +22 -4
  7. package/docs/task-authorization-contract.md +15 -3
  8. package/docs/workspace-migration-contract.md +5 -3
  9. package/package-dist/assets/foundry-package-descriptor.json +541 -177
  10. package/package-dist/scripts/foundry-facade.d.ts +5 -0
  11. package/package-dist/scripts/foundry-facade.js +261 -16
  12. package/package-dist/scripts/foundry-runtime.d.ts +2 -2
  13. package/package-dist/scripts/lib/bundle-sample-utils.d.ts +4 -4
  14. package/package-dist/scripts/lib/bundle-source-context.d.ts +6 -4
  15. package/package-dist/scripts/lib/bundle-source-context.js +10 -8
  16. package/package-dist/scripts/lib/decision-owners/identity-preflight.js +18 -6
  17. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.d.ts +72 -1
  18. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.js +123 -3
  19. package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +11 -1
  20. package/package-dist/scripts/lib/finalize-owners/post-authoring.js +65 -9
  21. package/package-dist/scripts/lib/foundry-assessment-producer.d.ts +6 -0
  22. package/package-dist/scripts/lib/foundry-assessment-producer.js +167 -0
  23. package/package-dist/scripts/lib/foundry-authentication-environment.js +1 -1
  24. package/package-dist/scripts/lib/foundry-command-metadata.js +6 -1
  25. package/package-dist/scripts/lib/foundry-curation-queue.d.ts +73 -0
  26. package/package-dist/scripts/lib/foundry-curation-queue.js +261 -0
  27. package/package-dist/scripts/lib/foundry-decision-owners.d.ts +1 -1
  28. package/package-dist/scripts/lib/foundry-decision-owners.js +15 -7
  29. package/package-dist/scripts/lib/foundry-edge-draft-admission.d.ts +17 -0
  30. package/package-dist/scripts/lib/foundry-edge-draft-admission.js +94 -0
  31. package/package-dist/scripts/lib/foundry-edge-identity-preflight.d.ts +47 -0
  32. package/package-dist/scripts/lib/foundry-edge-identity-preflight.js +268 -0
  33. package/package-dist/scripts/lib/foundry-edge-oauth.d.ts +4 -0
  34. package/package-dist/scripts/lib/foundry-edge-oauth.js +154 -0
  35. package/package-dist/scripts/lib/foundry-edge-reference-intent.d.ts +51 -0
  36. package/package-dist/scripts/lib/foundry-edge-reference-intent.js +184 -0
  37. package/package-dist/scripts/lib/foundry-edge-repair-preparation.d.ts +21 -0
  38. package/package-dist/scripts/lib/foundry-edge-repair-preparation.js +120 -0
  39. package/package-dist/scripts/lib/foundry-edge-session.d.ts +15 -0
  40. package/package-dist/scripts/lib/foundry-edge-session.js +69 -0
  41. package/package-dist/scripts/lib/foundry-edge-support-plan.d.ts +69 -0
  42. package/package-dist/scripts/lib/foundry-edge-support-plan.js +245 -0
  43. package/package-dist/scripts/lib/foundry-edge-support-planning.d.ts +115 -0
  44. package/package-dist/scripts/lib/foundry-edge-support-planning.js +259 -0
  45. package/package-dist/scripts/lib/foundry-edge-support.d.ts +19 -0
  46. package/package-dist/scripts/lib/foundry-edge-support.js +188 -0
  47. package/package-dist/scripts/lib/foundry-execution-admission.d.ts +4 -2
  48. package/package-dist/scripts/lib/foundry-execution-admission.js +28 -3
  49. package/package-dist/scripts/lib/foundry-finalize-edge-identity.d.ts +30 -0
  50. package/package-dist/scripts/lib/foundry-finalize-edge-identity.js +102 -0
  51. package/package-dist/scripts/lib/foundry-finalize-owners.d.ts +1 -0
  52. package/package-dist/scripts/lib/foundry-finalize-owners.js +126 -13
  53. package/package-dist/scripts/lib/foundry-identity-stage-input.d.ts +24 -0
  54. package/package-dist/scripts/lib/foundry-identity-stage-input.js +122 -0
  55. package/package-dist/scripts/lib/foundry-identity-stage-state.d.ts +17 -0
  56. package/package-dist/scripts/lib/foundry-identity-stage-state.js +48 -0
  57. package/package-dist/scripts/lib/foundry-installed-entry.d.ts +2 -0
  58. package/package-dist/scripts/lib/foundry-installed-entry.js +173 -0
  59. package/package-dist/scripts/lib/foundry-managed-adoption.d.ts +12 -0
  60. package/package-dist/scripts/lib/foundry-managed-adoption.js +108 -0
  61. package/package-dist/scripts/lib/foundry-managed-authentication.d.ts +4 -0
  62. package/package-dist/scripts/lib/foundry-managed-authentication.js +28 -0
  63. package/package-dist/scripts/lib/foundry-managed-host.js +14 -2
  64. package/package-dist/scripts/lib/foundry-migration-transfer-io.d.ts +2 -0
  65. package/package-dist/scripts/lib/foundry-migration-transfer-io.js +27 -3
  66. package/package-dist/scripts/lib/foundry-operation-result.d.ts +1 -1
  67. package/package-dist/scripts/lib/foundry-operation-result.js +1 -0
  68. package/package-dist/scripts/lib/foundry-owner-execution-store.d.ts +16 -16
  69. package/package-dist/scripts/lib/foundry-owner-execution-store.js +34 -7
  70. package/package-dist/scripts/lib/foundry-owner-readback.d.ts +20 -0
  71. package/package-dist/scripts/lib/foundry-owner-readback.js +42 -0
  72. package/package-dist/scripts/lib/foundry-package-contract.d.ts +4 -4
  73. package/package-dist/scripts/lib/foundry-package-contract.js +10 -2
  74. package/package-dist/scripts/lib/foundry-preparation-cli-validation.d.ts +2 -0
  75. package/package-dist/scripts/lib/foundry-preparation-cli-validation.js +96 -3
  76. package/package-dist/scripts/lib/foundry-process-mass-balance.d.ts +64 -0
  77. package/package-dist/scripts/lib/foundry-process-mass-balance.js +224 -0
  78. package/package-dist/scripts/lib/foundry-process-qa.d.ts +19 -0
  79. package/package-dist/scripts/lib/foundry-process-qa.js +423 -0
  80. package/package-dist/scripts/lib/foundry-quality-review-context.d.ts +3 -0
  81. package/package-dist/scripts/lib/foundry-quality-review-context.js +18 -0
  82. package/package-dist/scripts/lib/foundry-quality-review-input.d.ts +48 -0
  83. package/package-dist/scripts/lib/foundry-quality-review-input.js +284 -0
  84. package/package-dist/scripts/lib/foundry-quality-review-lineage.d.ts +13 -0
  85. package/package-dist/scripts/lib/foundry-quality-review-lineage.js +123 -0
  86. package/package-dist/scripts/lib/foundry-quality-review.d.ts +112 -0
  87. package/package-dist/scripts/lib/foundry-quality-review.js +487 -0
  88. package/package-dist/scripts/lib/foundry-repair-execution.js +13 -2
  89. package/package-dist/scripts/lib/foundry-runtime-environment.d.ts +2 -0
  90. package/package-dist/scripts/lib/foundry-runtime-environment.js +18 -0
  91. package/package-dist/scripts/lib/foundry-runtime-identity.d.ts +1 -0
  92. package/package-dist/scripts/lib/foundry-runtime-identity.js +22 -2
  93. package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
  94. package/package-dist/scripts/lib/foundry-runtime-utils.d.ts +1 -0
  95. package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
  96. package/package-dist/scripts/lib/foundry-task-authorization.d.ts +2 -1
  97. package/package-dist/scripts/lib/foundry-task-authorization.js +32 -11
  98. package/package-dist/scripts/lib/foundry-task-registration.js +4 -5
  99. package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.d.ts +28 -0
  100. package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.js +250 -0
  101. package/package-dist/scripts/lib/foundry-task-runtime-adoption.d.ts +60 -0
  102. package/package-dist/scripts/lib/foundry-task-runtime-adoption.js +549 -0
  103. package/package-dist/scripts/lib/foundry-task-store.d.ts +4 -1
  104. package/package-dist/scripts/lib/foundry-task-store.js +113 -4
  105. package/package-dist/scripts/lib/foundry-task-types.d.ts +2 -1
  106. package/package-dist/scripts/lib/foundry-typed-authoring-patch.d.ts +76 -0
  107. package/package-dist/scripts/lib/foundry-typed-authoring-patch.js +237 -0
  108. package/package-dist/scripts/lib/foundry-typed-context.d.ts +11 -0
  109. package/package-dist/scripts/lib/foundry-typed-context.js +79 -0
  110. package/package-dist/scripts/lib/foundry-typed-flow-qa.d.ts +166 -0
  111. package/package-dist/scripts/lib/foundry-typed-flow-qa.js +226 -0
  112. package/package-dist/scripts/lib/foundry-typed-model-write.d.ts +6 -0
  113. package/package-dist/scripts/lib/foundry-typed-model-write.js +59 -0
  114. package/package-dist/scripts/lib/foundry-validation-reference-context.d.ts +8 -0
  115. package/package-dist/scripts/lib/foundry-validation-reference-context.js +115 -0
  116. package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +1 -0
  117. package/package-dist/scripts/lib/foundry-workflow-assessment.js +165 -34
  118. package/package-dist/scripts/lib/foundry-workflow-authorization.js +99 -5
  119. package/package-dist/scripts/lib/foundry-workflow-child-failure.d.ts +44 -0
  120. package/package-dist/scripts/lib/foundry-workflow-child-failure.js +439 -0
  121. package/package-dist/scripts/lib/foundry-workflow-context.js +92 -22
  122. package/package-dist/scripts/lib/foundry-workflow-execution.js +54 -5
  123. package/package-dist/scripts/lib/foundry-workflow-finalize.js +64 -3
  124. package/package-dist/scripts/lib/foundry-workflow-identity-recovery.d.ts +6 -0
  125. package/package-dist/scripts/lib/foundry-workflow-identity-recovery.js +450 -0
  126. package/package-dist/scripts/lib/foundry-workflow-identity-stage.d.ts +9 -0
  127. package/package-dist/scripts/lib/foundry-workflow-identity-stage.js +717 -0
  128. package/package-dist/scripts/lib/foundry-workflow-identity.js +26 -11
  129. package/package-dist/scripts/lib/foundry-workflow-io.d.ts +7 -1
  130. package/package-dist/scripts/lib/foundry-workflow-io.js +102 -16
  131. package/package-dist/scripts/lib/foundry-workflow-reference-verify.js +102 -29
  132. package/package-dist/scripts/lib/foundry-workflow-repair.js +53 -2
  133. package/package-dist/scripts/lib/foundry-workflow-semantic.js +65 -31
  134. package/package-dist/scripts/lib/foundry-workflow-state.d.ts +4 -0
  135. package/package-dist/scripts/lib/foundry-workflow-state.js +165 -22
  136. package/package-dist/scripts/lib/identity-preflight-artifacts.d.ts +4 -7
  137. package/package-dist/scripts/lib/identity-preflight-artifacts.js +18 -5
  138. package/package-dist/scripts/lib/identity-preflight-proof.d.ts +6 -0
  139. package/package-dist/scripts/lib/identity-preflight-proof.js +92 -13
  140. package/package-dist/scripts/lib/identity-preflight-recovery-proof.d.ts +78 -0
  141. package/package-dist/scripts/lib/identity-preflight-recovery-proof.js +415 -0
  142. package/package-dist/scripts/lib/import-curation/curation-cleanup.d.ts +9 -1
  143. package/package-dist/scripts/lib/import-curation/curation-cleanup.js +39 -2
  144. package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +1 -0
  145. package/package-dist/scripts/lib/import-curation/curation-gate.js +19 -1
  146. package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
  147. package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.js +11 -2
  148. package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.js +4 -1
  149. package/package-dist/scripts/package-entry.js +2 -3
  150. package/package-dist/scripts/public-api.d.ts +5 -0
  151. package/package-dist/scripts/public-api.js +2 -0
  152. package/package-dist/scripts/runtime-entry.d.ts +2 -0
  153. package/package-dist/scripts/runtime-entry.js +42 -15
  154. package/package.json +6 -2
  155. package/specs/schemas/foundry-identity-stage-input.schema.json +47 -0
  156. package/specs/schemas/foundry-managed-adoption.schema.json +40 -0
  157. package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
  158. package/specs/schemas/foundry-operation-result.schema.json +1 -0
  159. package/specs/schemas/foundry-package-descriptor.schema.json +6 -2
  160. package/specs/schemas/foundry-quality-review-draft.schema.json +271 -0
  161. package/specs/schemas/foundry-quality-review-input.schema.json +271 -0
  162. package/specs/schemas/runtime-qualification.schema.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { type FoundryTaskRuntimeAdoptionInput, type TrustedFoundryRuntimeAdoptionQualification } from "./lib/foundry-task-runtime-adoption.ts";
1
2
  import { type FoundryAccountIntent, type FoundryWorkspaceAccess } from "./lib/foundry-runtime-context.ts";
2
3
  import { type FoundryOperationResult } from "./lib/foundry-operation-result.ts";
3
4
  import { type MigrationAdoptionSelection } from "./lib/foundry-migration-adoption-plan.ts";
@@ -21,8 +22,10 @@ export interface FoundryFacadeOptions {
21
22
  readonly signal?: AbortSignal;
22
23
  readonly workspaceAccess?: FoundryWorkspaceAccess;
23
24
  readonly runtimeManager?: FoundryRuntimeManagerOptions;
25
+ readonly runtimeAdoptionQualification?: TrustedFoundryRuntimeAdoptionQualification;
24
26
  }
25
27
  export declare function createFoundryFacade(options: FoundryFacadeOptions): Readonly<{
28
+ adoptTaskRuntime(input: FoundryTaskRuntimeAdoptionInput): Promise<FoundryOperationResult>;
26
29
  runtimeUse(input: {
27
30
  manifest: TrustedRuntimeManifest;
28
31
  requestId: string;
@@ -72,6 +75,8 @@ export declare function createFoundryFacade(options: FoundryFacadeOptions): Read
72
75
  interactionInputFile?: string;
73
76
  authorizationInputFile?: string;
74
77
  referenceInputFile?: string;
78
+ identityStageInputFile?: string;
79
+ qualityReviewInputFile?: string;
75
80
  }): Promise<FoundryOperationResult>;
76
81
  requestBinding(input: {
77
82
  taskId: string;
@@ -1,3 +1,5 @@
1
+ import { planFoundryTaskRuntimeAdoption, applyFoundryTaskRuntimeAdoption, } from "./lib/foundry-task-runtime-adoption-write.js";
2
+ import { assertRuntimeAdoptionToolkit, assertAdoptedRuntimeToolkit, readFoundryTaskRuntimeAdoption, } from "./lib/foundry-task-runtime-adoption.js";
1
3
  import { assertFoundryRepairExecution } from "./lib/foundry-repair-execution.js";
2
4
  import { createHash } from "node:crypto";
3
5
  import fs from "node:fs";
@@ -19,6 +21,7 @@ import { readFoundryMigrationAuthority } from "./lib/foundry-migration-authority
19
21
  import { selectFoundryWorkspaceRuntime, } from "./lib/foundry-runtime-selection.js";
20
22
  import { datasetTypePlural } from "./lib/import-curation/internal/dataset-types.js";
21
23
  import { currentWorkflowState, readWorkflowArtifact, workflowObject, } from "./lib/foundry-workflow-state.js";
24
+ import { WorkflowChildFailure, readWorkflowChildFailure, } from "./lib/foundry-workflow-child-failure.js";
22
25
  import { currentNativeValidationFailure } from "./lib/foundry-native-validation-failure.js";
23
26
  import { completedOwnerScopes, prepareFoundryOwnerExecution, } from "./lib/foundry-owner-execution-store.js";
24
27
  import { executeFoundryOwnerScope } from "./lib/foundry-workflow-execution.js";
@@ -28,7 +31,12 @@ import { currentFoundryInteractionState, currentFoundryQuestions, currentFoundry
28
31
  import { currentFoundryObjectDecisionReassessments, currentFoundryInteractionWriteBlocker, currentFoundryObjectScopes, currentFoundryObjectScopeIsBound, currentFoundryNarrowObjects, indexedFoundryRowAdoptions, } from "./lib/foundry-workflow-object-scope.js";
29
32
  import { recordFoundryInteractionInput } from "./lib/foundry-workflow-interaction.js";
30
33
  import { runFoundryWorkflowIdentity } from "./lib/foundry-workflow-identity.js";
34
+ import { pendingFoundryIdentityStage } from "./lib/foundry-identity-stage-state.js";
35
+ import { runExplicitFoundryIdentityStage } from "./lib/foundry-workflow-identity-stage.js";
36
+ import { selectFoundryIdentityStageInput } from "./lib/foundry-identity-stage-input.js";
31
37
  import { finalizeFoundryWorkflow } from "./lib/foundry-workflow-finalize.js";
38
+ import { selectFoundryQualityReviewInput } from "./lib/foundry-quality-review-input.js";
39
+ import { foundryQualityReviewScope, createFoundryQualityReviewTemplate, recordFoundryQualityReview, } from "./lib/foundry-quality-review.js";
32
40
  import { prepareFoundryRepair, readFoundryRepairPreparation, } from "./lib/foundry-workflow-repair.js";
33
41
  import { selectFoundryReferenceInput, recordFoundryReferenceInput, } from "./lib/foundry-reference-input.js";
34
42
  import { selectFoundryAuthorizationInput, snapshotFoundryAuthorizationContract, } from "./lib/foundry-authorization-input.js";
@@ -147,14 +155,16 @@ function accountReadiness(context) {
147
155
  }
148
156
  return Object.freeze({ status: "configured_unverified", reference_selected: true });
149
157
  }
150
- function qualification(context, selected) {
151
- return selected
158
+ function qualification(context, selected, allowTransition = false) {
159
+ const qualified = selected
152
160
  ? qualifyFoundryRuntime(context, {
153
161
  cliExpectation: selected.cliExpectation,
154
162
  tidasExpectation: selected.tidasExpectation,
155
163
  tidasExecutable: selected.tidasExecutable,
156
164
  })
157
165
  : undefined;
166
+ assertAdoptedRuntimeToolkit(context, qualified, allowTransition);
167
+ return qualified;
158
168
  }
159
169
  function runtimeIdentity(context, selected) {
160
170
  const described = createFoundryRuntime(context, selected).describe();
@@ -189,6 +199,9 @@ function failure(operation, taskId, error, identity = null) {
189
199
  "EMFILE",
190
200
  "ENFILE",
191
201
  "EBUSY",
202
+ "BATCH_RUN_LOCK_TIMEOUT",
203
+ "BATCH_RUN_LOCK_IDENTITY_CONFLICT",
204
+ "ERR_SYSTEM_ERROR",
192
205
  "UNKNOWN",
193
206
  "ERR_INVALID_ARG_TYPE",
194
207
  "ERR_INVALID_ARG_VALUE",
@@ -203,8 +216,16 @@ function failure(operation, taskId, error, identity = null) {
203
216
  const message = error instanceof FoundryContextError
204
217
  ? error.message
205
218
  : `Foundry could not complete this operation${systemCode ? ` (${systemCode})` : ""}; selected state was preserved.`;
206
- const needsAuth = code === "needs_auth" || code.startsWith("identity_");
219
+ const recoveryUnproven = code === "identity_preflight_recovery_unproven";
220
+ const stageInput = code.startsWith("identity_stage_");
221
+ const needsAuth = !recoveryUnproven && !stageInput && (code === "needs_auth" || code.startsWith("identity_"));
207
222
  const needsInputCodes = new Set([
223
+ "identity_preflight_recovery_unproven",
224
+ "identity_stage_unproven",
225
+ "identity_stage_input_invalid",
226
+ "identity_stage_interrupted",
227
+ "interaction_decision_pending",
228
+ "interaction_investigation_pending",
208
229
  "task_not_found",
209
230
  "workspace_not_initialized",
210
231
  "input_not_selected",
@@ -220,6 +241,7 @@ function failure(operation, taskId, error, identity = null) {
220
241
  "task_source_invalid",
221
242
  ]);
222
243
  const blockedCodes = new Set([
244
+ "runtime_adoption_plan_stale",
223
245
  "facade_crash_recovery_conflict",
224
246
  "task_actor_mismatch",
225
247
  "task_account_mismatch",
@@ -253,9 +275,21 @@ function failure(operation, taskId, error, identity = null) {
253
275
  operation,
254
276
  status: needsAuth ? "needs_auth" : needsInput ? "needs_input" : blocked ? "blocked" : "failed",
255
277
  taskId,
256
- artifacts: [],
278
+ artifacts: error instanceof WorkflowChildFailure && error.retainedArtifact
279
+ ? [{ kind: "file", role: "workflow-child-failure.json", ...error.retainedArtifact }]
280
+ : [],
257
281
  blockers: [{ code, message, scope: taskId }],
258
- nextActions: [],
282
+ nextActions: recoveryUnproven
283
+ ? [
284
+ human("verify_original_identity_recovery", `Recovery remains UNKNOWN for original task ${taskId}. Verify the retained original producer, receipt, request and attempt binding through this task's recovery entry. Preserve the original attempt and do not repeat its CLI query.`),
285
+ ]
286
+ : code === "identity_stage_unproven"
287
+ ? [
288
+ human("inspect_identity_stage", "Inspect the indexed claim and retained outcome of the explicitly new read-only stage. Preserve UNKNOWN and do not dispatch another query through ordinary resume."),
289
+ ]
290
+ : error instanceof WorkflowChildFailure
291
+ ? [human("repair_failed_local_operation", error.message)]
292
+ : [],
259
293
  runtimeIdentity: identity,
260
294
  permissions: noPermission(),
261
295
  });
@@ -442,7 +476,7 @@ function currentIndexedQueueBlockers(context, workflow, entries) {
442
476
  }, 0);
443
477
  const scope = missing ? "process" : String(set.type);
444
478
  const message = missing
445
- ? `Selected Process data has ${missing} unresolved Flow reference occurrence${missing === 1 ? "" : "s"}: the cited Flow evidence is absent from the selected inputs and has no verified external declaration. Process review is blocked; unrelated records can continue. Provide the cited Flow evidence or verified references, or keep the gap open. Adding selected sources requires a new task revision because this task's inputs are frozen. Full IDs and paths: ${detailsFile}.`
479
+ ? `Selected Process data has ${missing} unresolved Flow reference occurrence${missing === 1 ? "" : "s"}: the cited Flow evidence is absent from the selected inputs and has no verified external declaration. Process review is blocked; unrelated records can continue. Select existing read-only Flow evidence and its complete FlowProperty/UnitGroup QA chain using this Process task's --reference-input, or keep the gap open. Only changing the frozen selected sources requires a new task revision. Full IDs and paths: ${detailsFile}.`
446
480
  : `The selected ${scope} dependency queue has ${recorded.length} blocker${recorded.length === 1 ? "" : "s"}. Independent types can continue. Review the exact registered evidence at ${detailsFile} before revising the source or closure.`;
447
481
  blockers.push({ code: "curation_queue_blocked", message, scope });
448
482
  actions.push(human("review_queue_blockers", message));
@@ -536,6 +570,37 @@ function scopedAuthoringPresentation(context, entries, workflow, interaction, ob
536
570
  }
537
571
  function taskProjection(operation, context, record, inspected, identity) {
538
572
  const artifacts = taskArtifacts(context, inspected);
573
+ const childFailure = readWorkflowChildFailure(context, inspected.artifacts);
574
+ if (childFailure) {
575
+ const file = path.join(context.taskRoot, childFailure.entry.path);
576
+ const message = `The original local CLI ${childFailure.failure.kind} failure is retained at ${file}. The operation remains failed. Repair the runtime or selected input and use an explicitly reviewed task revision; this task cannot rerun the failed call.`;
577
+ return createFoundryOperationResult({
578
+ operation,
579
+ status: "blocked",
580
+ taskId: record.task_id,
581
+ artifacts,
582
+ blockers: [
583
+ { code: "workflow_child_failed", message, scope: String(childFailure.result.command) },
584
+ ],
585
+ nextActions: [human("repair_failed_local_operation", message)],
586
+ runtimeIdentity: identity,
587
+ permissions: noPermission(),
588
+ });
589
+ }
590
+ let projectedWorkflow;
591
+ let qualityScope = null;
592
+ const qualifiedIdentity = workflowObject(workflowObject(identity).qualification ?? {}).identity;
593
+ if (qualifiedIdentity && context.accountIntent) {
594
+ const digest = workflowObject(qualifiedIdentity).qualification_sha256;
595
+ if (typeof digest === "string") {
596
+ projectedWorkflow = currentWorkflowState(context, inspected.artifacts);
597
+ qualityScope = foundryQualityReviewScope(context, digest, inspected.artifacts, projectedWorkflow);
598
+ if (qualityScope) {
599
+ artifacts.push(inlineArtifact("quality_review_scope", qualityScope));
600
+ artifacts.push(inlineArtifact("quality_review_input_template", createFoundryQualityReviewTemplate(qualityScope)));
601
+ }
602
+ }
603
+ }
539
604
  const interaction = currentFoundryInteractionState(context, inspected.artifacts);
540
605
  const pendingQuestions = interaction ? currentFoundryQuestions(interaction.state) : [];
541
606
  const investigations = interaction ? currentFoundryInvestigations(interaction.state) : [];
@@ -665,6 +730,29 @@ function taskProjection(operation, context, record, inspected, identity) {
665
730
  runtimeIdentity: identity,
666
731
  permissions: noPermission(),
667
732
  });
733
+ const pendingIdentity = pendingFoundryIdentityStage(context, inspected.artifacts);
734
+ if (pendingIdentity)
735
+ return createFoundryOperationResult({
736
+ operation,
737
+ status: "needs_input",
738
+ taskId: record.task_id,
739
+ artifacts: [
740
+ ...artifacts,
741
+ inlineArtifact("explicit_readonly_identity_stage", pendingIdentity),
742
+ ],
743
+ blockers: [
744
+ {
745
+ code: "identity_stage_unproven",
746
+ message: "The indexed explicit read-only stage has no proven completed outcome. Preserve UNKNOWN and inspect its retained admission and claims.",
747
+ scope: record.task_id,
748
+ },
749
+ ],
750
+ nextActions: [
751
+ human("inspect_identity_stage", "Inspect the indexed new-stage evidence. Ordinary resume cannot repeat the query or proceed to write stages."),
752
+ ],
753
+ runtimeIdentity: identity,
754
+ permissions: noPermission(),
755
+ });
668
756
  const prepared = inspected.artifacts.some((entry) => entry.command === "dataset-curation-cleanup");
669
757
  const nativeReport = artifacts.find((artifact) => artifact.kind === "file" &&
670
758
  path.basename(artifact.path) === "foundry-native-import.json" &&
@@ -698,7 +786,7 @@ function taskProjection(operation, context, record, inspected, identity) {
698
786
  permissions: noPermission(),
699
787
  });
700
788
  }
701
- const workflow = currentWorkflowState(context, inspected.artifacts);
789
+ const workflow = projectedWorkflow ?? currentWorkflowState(context, inspected.artifacts);
702
790
  const queueIssues = currentIndexedQueueBlockers(context, workflow, inspected.artifacts);
703
791
  const nativeFailure = currentNativeValidationFailure(context, inspected.artifacts, workflow.rows
704
792
  ? {
@@ -995,12 +1083,12 @@ function taskProjection(operation, context, record, inspected, identity) {
995
1083
  blockers: [
996
1084
  {
997
1085
  code: "identity_preflight_requires_input",
998
- message: "Review the identity preflight diagnostics. A subsequent resume retries this read-only stage against the same current rows.",
1086
+ message: "Review the retained identity diagnostics. Resume verifies eligible original reports before continuing into semantic review; incomplete original proof remains UNKNOWN without repeating its query.",
999
1087
  scope: record.task_id,
1000
1088
  },
1001
1089
  ],
1002
1090
  nextActions: [
1003
- human("review_identity_preflight", `Read ${workflow.identity.file} and resolve the reported query or execution failure before retrying.`),
1091
+ human("review_identity_preflight", `Read ${workflow.identity.file}. Use the same task's resume entry to verify retained diagnostic evidence; preserve original attempts and report bindings.`),
1004
1092
  ],
1005
1093
  runtimeIdentity: identity,
1006
1094
  permissions: noPermission(),
@@ -1066,6 +1154,11 @@ function taskProjection(operation, context, record, inspected, identity) {
1066
1154
  nextActions: [
1067
1155
  ...queueIssues.actions,
1068
1156
  ...scoped.actions,
1157
+ ...(qualityScope
1158
+ ? [
1159
+ human("review_process_mass_observation", "Save the quality_review_input_template artifact, select only the Process observations actually reviewed, and fill an explicit accept-interpretation disposition, rationale and source-model evidence file references under applicable user authority. Submit the completed descriptor through --quality-review-input, then resume to reassess. The template accepts nothing by default; preserve quantities and raw QA. This input grants no write permission."),
1160
+ ]
1161
+ : []),
1069
1162
  ...pending.flatMap((set) => [
1070
1163
  ...(!scoped.types.includes(set.type)
1071
1164
  ? [
@@ -1103,6 +1196,45 @@ function taskProjection(operation, context, record, inspected, identity) {
1103
1196
  export function createFoundryFacade(options) {
1104
1197
  const base = () => createFoundryRuntimeContext(contextOptions(options));
1105
1198
  return Object.freeze({
1199
+ async adoptTaskRuntime(input) {
1200
+ try {
1201
+ assertNotInterrupted(options.signal);
1202
+ const current = base(), record = loadFoundryFacadeTaskRecord(current, input.taskId, input.actorId);
1203
+ const context = taskContext(options, current, record);
1204
+ if ((input.mode === "plan" && (input.selection === undefined || input.plan !== undefined)) ||
1205
+ (input.mode === "apply" && (input.plan === undefined || input.selection !== undefined)) ||
1206
+ (input.mode === "audit" && (input.plan !== undefined || input.selection !== undefined)))
1207
+ throw new FoundryContextError("runtime_adoption_selection_invalid", "Select exactly one plan, apply or audit input.");
1208
+ if (input.mode !== "audit" && options.runtimeAdoptionQualification)
1209
+ assertRuntimeAdoptionToolkit(qualification(context, options.runtimeSelection, true), input.mode === "plan"
1210
+ ? input.selection
1211
+ : input.plan?.selection);
1212
+ const value = input.mode === "plan"
1213
+ ? planFoundryTaskRuntimeAdoption(context, record, input.selection, options.runtimeAdoptionQualification)
1214
+ : input.mode === "apply"
1215
+ ? await applyFoundryTaskRuntimeAdoption(context, record, input.plan, options.runtimeAdoptionQualification)
1216
+ : input.mode === "audit"
1217
+ ? readFoundryTaskRuntimeAdoption(context)
1218
+ : null;
1219
+ if (!value)
1220
+ throw new FoundryContextError("runtime_adoption_missing", "No explicit task runtime adoption exists.");
1221
+ return createFoundryOperationResult({
1222
+ operation: "task.adopt-runtime",
1223
+ status: input.mode === "plan" ? "ready" : "completed",
1224
+ taskId: record.task_id,
1225
+ artifacts: [
1226
+ inlineArtifact(input.mode === "plan" ? "runtime_adoption_plan" : "runtime_adoption_result", value),
1227
+ ],
1228
+ blockers: [],
1229
+ nextActions: [],
1230
+ runtimeIdentity: runtimeIdentity(context),
1231
+ permissions: noPermission(),
1232
+ });
1233
+ }
1234
+ catch (error) {
1235
+ return failure("task.adopt-runtime", input.taskId, error);
1236
+ }
1237
+ },
1106
1238
  async runtimeUse(input) {
1107
1239
  try {
1108
1240
  assertNotInterrupted(options.signal);
@@ -1454,6 +1586,12 @@ export function createFoundryFacade(options) {
1454
1586
  let current = null;
1455
1587
  try {
1456
1588
  assertNotInterrupted(options.signal);
1589
+ if (input.identityStageInputFile !== undefined &&
1590
+ (typeof input.identityStageInputFile !== "string" || !input.identityStageInputFile.trim()))
1591
+ throw new FoundryContextError("identity_stage_input_invalid", "An explicit identity stage requires one nonempty file path.");
1592
+ if (input.qualityReviewInputFile !== undefined &&
1593
+ (typeof input.qualityReviewInputFile !== "string" || !input.qualityReviewInputFile.trim()))
1594
+ throw new FoundryContextError("quality_review_input_invalid", "Select one nonempty quality-review input path.");
1457
1595
  if (input.referenceInputFile !== undefined &&
1458
1596
  (typeof input.referenceInputFile !== "string" || !input.referenceInputFile.trim()))
1459
1597
  throw new FoundryContextError("reference_input_invalid", "An explicit reference input requires one nonempty file path.");
@@ -1465,6 +1603,8 @@ export function createFoundryFacade(options) {
1465
1603
  input.authorizationInputFile,
1466
1604
  input.referenceInputFile,
1467
1605
  input.interactionInputFile,
1606
+ input.identityStageInputFile,
1607
+ input.qualityReviewInputFile,
1468
1608
  ].filter((file) => file !== undefined).length > 1)
1469
1609
  throw new FoundryContextError("task_input_conflict", "Submit one task input kind at a time.");
1470
1610
  current = base();
@@ -1475,12 +1615,100 @@ export function createFoundryFacade(options) {
1475
1615
  const runtime = createFoundryRuntime(context, qualified);
1476
1616
  const before = await runtime.inspectTask();
1477
1617
  if (record.spec.repair &&
1478
- (input.semanticInputFile || input.referenceInputFile || input.interactionInputFile))
1618
+ (input.semanticInputFile ||
1619
+ input.referenceInputFile ||
1620
+ input.interactionInputFile ||
1621
+ input.qualityReviewInputFile))
1479
1622
  throw new FoundryContextError("repair_revision_required", "A repair keeps its before, candidate and contract immutable; changed inputs require an explicit revision.");
1480
1623
  assertNotInterrupted(options.signal);
1481
1624
  loadFoundryFacadeTaskRecord(current, record.task_id, record.spec.actor_id);
1482
1625
  const existing = taskProjection("task.resume", context, record, before, runtimeIdentity(context, qualified));
1483
- if ((input.referenceInputFile || input.interactionInputFile) &&
1626
+ if (input.identityStageInputFile !== undefined) {
1627
+ if (!qualified)
1628
+ throw new FoundryContextError("runtime_unqualified", "An explicit read-only identity stage requires exact qualified runtime owners.");
1629
+ if (record.spec.lane !== "source-evidence-dataset-development" ||
1630
+ record.spec.preparation ||
1631
+ record.spec.repair)
1632
+ throw new FoundryContextError("identity_stage_input_invalid", "An explicit identity stage applies only to the original source-evidence Task.");
1633
+ const selected = selectFoundryIdentityStageInput(context, input.identityStageInputFile);
1634
+ const rowsEntry = before.artifacts.find((entry) => ["dataset-workflow-rows", "dataset-semantic-apply"].includes(entry.command) &&
1635
+ path.basename(entry.path) === "foundry-rows.json" &&
1636
+ entry.sha256 === selected.value.rows_report_sha256);
1637
+ const priorEntry = before.artifacts.find((entry) => entry.command === "dataset-workflow-identity" &&
1638
+ path.basename(entry.path) === "foundry-identity.json" &&
1639
+ entry.sha256 === selected.value.predecessor_identity_sha256);
1640
+ if (!rowsEntry || !priorEntry)
1641
+ throw new FoundryContextError("identity_stage_input_invalid", "Explicit identity stage must bind registered original rows and predecessor identity.");
1642
+ const rowReport = readWorkflowArtifact(context, rowsEntry).value;
1643
+ if (!Array.isArray(rowReport.sets))
1644
+ throw new FoundryContextError("workflow_rows_invalid", "Registered row report has no exact row sets.");
1645
+ const rowFiles = rowReport.sets.map((set) => workflowObject(set).file);
1646
+ const fixedEntries = [
1647
+ rowsEntry,
1648
+ priorEntry,
1649
+ ...rowFiles.map((file) => {
1650
+ if (typeof file !== "string")
1651
+ throw new FoundryContextError("workflow_rows_invalid", "Registered row file is invalid.");
1652
+ const entry = before.artifacts.find((item) => resolveFoundryOutput(context, item.path) === file);
1653
+ if (!entry)
1654
+ throw new FoundryContextError("workflow_rows_invalid", "Registered row file lacks its producer.");
1655
+ return entry;
1656
+ }),
1657
+ ];
1658
+ const fixedContext = taskContext(options, current, record, fixedEntries.map((entry) => ({
1659
+ path: resolveFoundryOutput(context, entry.path),
1660
+ bytes: entry.bytes,
1661
+ sha256: entry.sha256,
1662
+ })));
1663
+ const stage = await runExplicitFoundryIdentityStage(fixedContext, qualified, before.artifacts, selected, options.authentication, { signal: options.signal });
1664
+ const inspected = await runtime.inspectTask();
1665
+ const projected = taskProjection("task.resume", context, record, inspected, runtimeIdentity(context, qualified));
1666
+ const stageStatus = stage.status;
1667
+ const stageUnproven = stageStatus === "unproven" ||
1668
+ (stageStatus === "blocked" &&
1669
+ Array.isArray(stage.blockers) &&
1670
+ stage.blockers.some((item) => workflowObject(item).code === "identity_stage_outcome_unproven"));
1671
+ if (stageUnproven || stageStatus === "running")
1672
+ return createFoundryOperationResult({
1673
+ operation: "task.resume",
1674
+ taskId: record.task_id,
1675
+ status: stageStatus === "running" ? "running" : "needs_input",
1676
+ artifacts: [
1677
+ ...projected.artifacts,
1678
+ inlineArtifact("explicit_readonly_identity_stage", stage),
1679
+ ],
1680
+ blockers: [
1681
+ {
1682
+ code: stageStatus === "running"
1683
+ ? "identity_stage_running"
1684
+ : "identity_stage_unproven",
1685
+ message: "Inspect the retained explicit-stage admission and execution evidence. An incomplete dispatched read-only query cannot be repeated automatically.",
1686
+ scope: record.task_id,
1687
+ },
1688
+ ],
1689
+ nextActions: [
1690
+ human("inspect_identity_stage", "Preserve the original Task and read its indexed new-stage evidence; no query or write replay is permitted."),
1691
+ ],
1692
+ runtimeIdentity: projected.runtime_identity,
1693
+ permissions: noPermission(),
1694
+ });
1695
+ return createFoundryOperationResult({
1696
+ operation: "task.resume",
1697
+ taskId: record.task_id,
1698
+ status: projected.status,
1699
+ artifacts: [
1700
+ ...projected.artifacts,
1701
+ inlineArtifact("explicit_readonly_identity_stage", stage),
1702
+ ],
1703
+ blockers: projected.blockers,
1704
+ nextActions: projected.next_actions,
1705
+ runtimeIdentity: projected.runtime_identity,
1706
+ permissions: noPermission(),
1707
+ });
1708
+ }
1709
+ if ((input.referenceInputFile ||
1710
+ input.interactionInputFile ||
1711
+ input.qualityReviewInputFile) &&
1484
1712
  existing.status === "completed")
1485
1713
  throw new FoundryContextError("execution_scope_completed", "A completed task cannot replace its reference evidence.");
1486
1714
  if (existing.status === "completed" || existing.status === "blocked")
@@ -1490,7 +1718,8 @@ export function createFoundryFacade(options) {
1490
1718
  if (input.authorizationInputFile ||
1491
1719
  input.semanticInputFile ||
1492
1720
  input.referenceInputFile ||
1493
- input.interactionInputFile)
1721
+ input.interactionInputFile ||
1722
+ input.qualityReviewInputFile)
1494
1723
  throw new FoundryContextError("execution_recovery_required", "Recover the consumed request before submitting changes.");
1495
1724
  if (!qualified)
1496
1725
  throw new FoundryContextError("runtime_unqualified", "Owner readback requires qualified runtime owners.");
@@ -1515,6 +1744,8 @@ export function createFoundryFacade(options) {
1515
1744
  assertNotInterrupted(options.signal);
1516
1745
  return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
1517
1746
  }
1747
+ if (pendingFoundryIdentityStage(context, before.artifacts))
1748
+ return existing;
1518
1749
  const unresolvedInteraction = currentFoundryInteractionState(context, before.artifacts);
1519
1750
  const hasUnresolvedInteraction = Boolean(unresolvedInteraction &&
1520
1751
  (currentFoundryQuestions(unresolvedInteraction.state).length ||
@@ -1536,6 +1767,20 @@ export function createFoundryFacade(options) {
1536
1767
  await recordFoundryReferenceInput(selected, before.artifacts, submission);
1537
1768
  return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
1538
1769
  }
1770
+ if (input.qualityReviewInputFile) {
1771
+ if (record.spec.preparation || record.spec.repair)
1772
+ throw new FoundryContextError("quality_review_input_invalid", "Quality review requires an ordinary assessed Process task.");
1773
+ if (!qualified)
1774
+ throw new FoundryContextError("runtime_unqualified", "Quality review requires qualified runtime owners.");
1775
+ const selected = taskContext(options, current, record, before.artifacts.map((entry) => ({
1776
+ path: path.join(context.taskRoot, entry.path),
1777
+ bytes: entry.bytes,
1778
+ sha256: entry.sha256,
1779
+ })));
1780
+ const submission = selectFoundryQualityReviewInput(selected, input.qualityReviewInputFile);
1781
+ await recordFoundryQualityReview(selected, qualified, before.artifacts, submission);
1782
+ return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
1783
+ }
1539
1784
  if (input.authorizationInputFile) {
1540
1785
  const interactionBlocker = currentFoundryInteractionWriteBlocker(context, before.artifacts);
1541
1786
  if (interactionBlocker)
@@ -1680,7 +1925,7 @@ export function createFoundryFacade(options) {
1680
1925
  return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
1681
1926
  }
1682
1927
  const imported = before.artifacts.some((artifact) => artifact.command === "dataset-tidas-import");
1683
- const contextPrepared = before.artifacts.some((artifact) => artifact.command === "dataset-context-pack");
1928
+ const contextPrepared = workflow.currentContextReports.length > 0;
1684
1929
  const nativeRows = before.artifacts.filter((artifact) => artifact.command === "dataset-tidas-import" &&
1685
1930
  artifact.path.endsWith(".json") &&
1686
1931
  Object.values(datasetTypePlural).includes(/^outputs\/import\/[^/]+\/tidas\/([^/]+)\//u.exec(artifact.path)?.[1] ?? ""));
@@ -1727,20 +1972,20 @@ export function createFoundryFacade(options) {
1727
1972
  : undefined;
1728
1973
  if (!rows)
1729
1974
  throw new FoundryContextError("workflow_rows_required", "Registered row preparation is required.");
1730
- const contracts = facts
1731
- .filter((fact) => path.basename(fact.path) === "contract-report.json")
1732
- .map((fact) => fact.path);
1975
+ const contracts = workflow.currentContextReports;
1733
1976
  const selected = taskContext(options, current, record, facts);
1734
1977
  const identityReport = workflow.identity?.value.status === "completed" ? workflow.identity.file : undefined;
1735
1978
  if (workflow.assessmentRemainingTypes.length)
1736
1979
  await createFoundryRuntime(selected, qualified).assessRows(rows.path, contracts, identityReport, {
1737
1980
  scopeType: workflow.assessmentRemainingTypes[0],
1981
+ qualityReviewSha256: workflow.qualityReviewSha256,
1738
1982
  previousAssessment: workflow.assessment?.file,
1739
1983
  interactionSha256: currentFoundryInteractionState(context, before.artifacts)?.entry.sha256 ?? null,
1740
1984
  });
1741
1985
  else
1742
1986
  await createFoundryRuntime(selected, qualified).assessRows(rows.path, contracts, identityReport, {
1743
1987
  interactionSha256: currentFoundryInteractionState(context, before.artifacts)?.entry.sha256 ?? null,
1988
+ qualityReviewSha256: workflow.qualityReviewSha256,
1744
1989
  });
1745
1990
  assertNotInterrupted(options.signal);
1746
1991
  }
@@ -138,7 +138,7 @@ export declare function createFoundryRuntime(context: FoundryRuntimeContext, qua
138
138
  capsule_sha256: string;
139
139
  }>>;
140
140
  rehydrateExecution: (identity: VerifiedFoundryIdentity, options: RehydrateFoundryExecutionAdmissionOptions) => Promise<FoundryExecutionAdmission>;
141
- admitExecution: (identity: VerifiedFoundryIdentity, admission: FoundryExecutionAdmission) => Promise<import("@tiangong-lca/cli/command-spec").FoundryCommandSpec>;
141
+ admitExecution: (identity: VerifiedFoundryIdentity, admission: FoundryExecutionAdmission) => Promise<import("./lib/foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec>;
142
142
  profiles: () => import("./lib/import-curation/internal/profiles-config.ts").ImportProfilesList;
143
143
  describe: () => {
144
144
  platform: string;
@@ -181,7 +181,7 @@ export declare function createFoundryRuntime(context: FoundryRuntimeContext, qua
181
181
  };
182
182
  command_policy: {
183
183
  total: number;
184
- public_operations: readonly ["workspace.init", "doctor", "task.start", "task.status", "task.resume", "workspace.migrate"];
184
+ public_operations: readonly ["workspace.init", "doctor", "task.start", "task.status", "task.resume", "task.adopt-runtime", "workspace.migrate"];
185
185
  public_facade: ("acceptance-check" | "capabilities-list" | "dataset-authoring-patch-collect" | "dataset-authoring-plan" | "dataset-authoring-task-build" | "dataset-bafu-authoring-patches-autofill" | "dataset-bafu-batch-import-run" | "dataset-bafu-identity-decisions-autofill" | "dataset-bafu-leaf-classification-category-map-project" | "dataset-bafu-leaf-classification-tasks-prepare" | "dataset-bafu-process-scope-e2e" | "dataset-bafu-universe-coverage-report" | "dataset-bundle-sample-rows" | "dataset-canonical-support-mappings-autofill" | "dataset-classification-decision-task-build" | "dataset-classification-decisions-apply" | "dataset-commit-handoff-plan" | "dataset-curation-cleanup" | "dataset-curation-gate" | "dataset-curation-queue-build" | "dataset-identity-decision-task-build" | "dataset-identity-decisions-apply" | "dataset-identity-preflight-index-merge" | "dataset-identity-preflight-query-audit" | "dataset-identity-preflight-requests-build" | "dataset-identity-preflight-run" | "dataset-identity-reference-rewrites-apply" | "dataset-import-completion-report" | "dataset-import-ledger-report" | "dataset-incremental-change-set-compose" | "dataset-library-authoring-plan" | "dataset-library-classification-decisions-project" | "dataset-library-decisions-apply" | "dataset-library-identity-decisions-from-preflight" | "dataset-library-index-build" | "dataset-location-decision-task-build" | "dataset-location-decisions-apply" | "dataset-location-decisions-suggest" | "dataset-mutation-manifest" | "dataset-patch-apply" | "dataset-post-authoring-finalize" | "dataset-post-write-closeout" | "dataset-process-scope-run" | "dataset-support-cache-refresh" | "dataset-tidas-import" | "dataset-tidas-validate" | "dataset-topology-convergence-compose" | "dataset-uslci-batch-import-run" | "dataset-worldsteel-batch-import-run" | "doctor" | "env-check" | "execution-capsule-admit" | "final-delivery-promote" | "init" | "profiles-list" | "route-task" | "storage-check" | "surface-audit" | "task-complete" | "tasks-check" | "tasks-list" | "tidas-handshake" | "workflow-check" | "workspace-map")[];
186
186
  internal_only: number;
187
187
  excluded: ("acceptance-check" | "capabilities-list" | "dataset-authoring-patch-collect" | "dataset-authoring-plan" | "dataset-authoring-task-build" | "dataset-bafu-authoring-patches-autofill" | "dataset-bafu-batch-import-run" | "dataset-bafu-identity-decisions-autofill" | "dataset-bafu-leaf-classification-category-map-project" | "dataset-bafu-leaf-classification-tasks-prepare" | "dataset-bafu-process-scope-e2e" | "dataset-bafu-universe-coverage-report" | "dataset-bundle-sample-rows" | "dataset-canonical-support-mappings-autofill" | "dataset-classification-decision-task-build" | "dataset-classification-decisions-apply" | "dataset-commit-handoff-plan" | "dataset-curation-cleanup" | "dataset-curation-gate" | "dataset-curation-queue-build" | "dataset-identity-decision-task-build" | "dataset-identity-decisions-apply" | "dataset-identity-preflight-index-merge" | "dataset-identity-preflight-query-audit" | "dataset-identity-preflight-requests-build" | "dataset-identity-preflight-run" | "dataset-identity-reference-rewrites-apply" | "dataset-import-completion-report" | "dataset-import-ledger-report" | "dataset-incremental-change-set-compose" | "dataset-library-authoring-plan" | "dataset-library-classification-decisions-project" | "dataset-library-decisions-apply" | "dataset-library-identity-decisions-from-preflight" | "dataset-library-index-build" | "dataset-location-decision-task-build" | "dataset-location-decisions-apply" | "dataset-location-decisions-suggest" | "dataset-mutation-manifest" | "dataset-patch-apply" | "dataset-post-authoring-finalize" | "dataset-post-write-closeout" | "dataset-process-scope-run" | "dataset-support-cache-refresh" | "dataset-tidas-import" | "dataset-tidas-validate" | "dataset-topology-convergence-compose" | "dataset-uslci-batch-import-run" | "dataset-worldsteel-batch-import-run" | "doctor" | "env-check" | "execution-capsule-admit" | "final-delivery-promote" | "init" | "profiles-list" | "route-task" | "storage-check" | "surface-audit" | "task-complete" | "tasks-check" | "tasks-list" | "tidas-handshake" | "workflow-check" | "workspace-map")[];
@@ -143,10 +143,10 @@ export declare function createBundleSampleUtils({ asText, bundleClassificationPa
143
143
  flowNameParts: (payload: {
144
144
  [x: string]: unknown;
145
145
  } | null) => {
146
- base_name: string;
147
- treatment_standards_routes: string;
148
- mix_and_location_types: string;
149
- functional_unit_flow_properties: string;
146
+ base_name: string | string[];
147
+ treatment_standards_routes: string | string[];
148
+ mix_and_location_types: string | string[];
149
+ functional_unit_flow_properties: string | string[];
150
150
  };
151
151
  listProcessBundleDirs: (bundlesDir: unknown) => string[];
152
152
  processAuthoringContextFromTrace: (sourceTraces: {
@@ -1,12 +1,14 @@
1
1
  type JsonRecord = Record<string, unknown>;
2
+ /** Preserve individual language texts so query owners can filter and bound each value. */
3
+ export declare function namePartText(value: unknown, asText: (value: unknown) => string): string | string[];
2
4
  export declare function createBundleSourceContextUtils({ asText }: {
3
5
  asText: (value: unknown) => string;
4
6
  }): {
5
7
  flowNameParts: (payload: JsonRecord | null) => {
6
- base_name: string;
7
- treatment_standards_routes: string;
8
- mix_and_location_types: string;
9
- functional_unit_flow_properties: string;
8
+ base_name: string | string[];
9
+ treatment_standards_routes: string | string[];
10
+ mix_and_location_types: string | string[];
11
+ functional_unit_flow_properties: string | string[];
10
12
  };
11
13
  collectSourceTracePayloads: (value: unknown, traces?: JsonRecord[]) => JsonRecord[];
12
14
  sourceTraceAttribute: (sourceTraces: JsonRecord[], attributeName: string) => string | null;
@@ -13,6 +13,12 @@ function nestedValue(value, ...keys) {
13
13
  }
14
14
  return current;
15
15
  }
16
+ /** Preserve individual language texts so query owners can filter and bound each value. */
17
+ export function namePartText(value, asText) {
18
+ if (Array.isArray(value))
19
+ return value.flatMap((item) => namePartText(item, asText));
20
+ return asText(isJsonRecord(value) ? value["#text"] : value);
21
+ }
16
22
  export function createBundleSourceContextUtils({ asText }) {
17
23
  function isLikelyLocationCodeText(value) {
18
24
  const text = asText(value).trim();
@@ -22,15 +28,11 @@ export function createBundleSourceContextUtils({ asText }) {
22
28
  }
23
29
  function flowNameParts(payload) {
24
30
  const name = asJsonRecord(nestedValue(payload, "flowDataSet", "flowInformation", "dataSetInformation", "name"));
25
- const baseName = asJsonRecord(name.baseName);
26
- const treatmentStandardsRoutes = asJsonRecord(name.treatmentStandardsRoutes);
27
- const mixAndLocationTypes = asJsonRecord(name.mixAndLocationTypes);
28
- const functionalUnitFlowProperties = asJsonRecord(name.functionalUnitFlowProperties);
29
31
  return {
30
- base_name: asText(baseName["#text"] ?? name.baseName),
31
- treatment_standards_routes: asText(treatmentStandardsRoutes["#text"] ?? name.treatmentStandardsRoutes),
32
- mix_and_location_types: asText(mixAndLocationTypes["#text"] ?? name.mixAndLocationTypes),
33
- functional_unit_flow_properties: asText(functionalUnitFlowProperties["#text"] ?? name.functionalUnitFlowProperties),
32
+ base_name: namePartText(name.baseName, asText),
33
+ treatment_standards_routes: namePartText(name.treatmentStandardsRoutes, asText),
34
+ mix_and_location_types: namePartText(name.mixAndLocationTypes, asText),
35
+ functional_unit_flow_properties: namePartText(name.flowProperties, asText),
34
36
  };
35
37
  }
36
38
  function collectSourceTracePayloads(value, traces = []) {