@tiangong-lca/foundry 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -7
- package/docs/architecture.md +19 -5
- package/docs/foundry-task-contracts.md +27 -3
- package/docs/package-distribution-contract.md +47 -15
- package/docs/public-runtime-contract.md +77 -5
- package/docs/runtime-context-contract.md +21 -5
- package/docs/task-authorization-contract.md +15 -3
- package/docs/workspace-migration-contract.md +5 -3
- package/package-dist/assets/foundry-package-descriptor.json +351 -137
- package/package-dist/scripts/foundry-facade.d.ts +5 -0
- package/package-dist/scripts/foundry-facade.js +258 -16
- package/package-dist/scripts/foundry-runtime.d.ts +1 -1
- package/package-dist/scripts/lib/bundle-sample-utils.d.ts +4 -4
- package/package-dist/scripts/lib/bundle-source-context.d.ts +6 -4
- package/package-dist/scripts/lib/bundle-source-context.js +10 -8
- package/package-dist/scripts/lib/decision-owners/identity-preflight.js +16 -6
- package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +2 -1
- package/package-dist/scripts/lib/finalize-owners/post-authoring.js +28 -1
- package/package-dist/scripts/lib/foundry-assessment-producer.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-assessment-producer.js +167 -0
- package/package-dist/scripts/lib/foundry-command-metadata.js +6 -1
- package/package-dist/scripts/lib/foundry-decision-owners.d.ts +1 -1
- package/package-dist/scripts/lib/foundry-decision-owners.js +15 -7
- package/package-dist/scripts/lib/foundry-execution-admission.js +4 -1
- package/package-dist/scripts/lib/foundry-finalize-owners.js +64 -17
- package/package-dist/scripts/lib/foundry-identity-stage-input.d.ts +24 -0
- package/package-dist/scripts/lib/foundry-identity-stage-input.js +122 -0
- package/package-dist/scripts/lib/foundry-identity-stage-state.d.ts +17 -0
- package/package-dist/scripts/lib/foundry-identity-stage-state.js +48 -0
- package/package-dist/scripts/lib/foundry-installed-entry.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-installed-entry.js +173 -0
- package/package-dist/scripts/lib/foundry-managed-adoption.d.ts +12 -0
- package/package-dist/scripts/lib/foundry-managed-adoption.js +108 -0
- package/package-dist/scripts/lib/foundry-managed-authentication.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-managed-authentication.js +28 -0
- package/package-dist/scripts/lib/foundry-managed-host.js +14 -2
- package/package-dist/scripts/lib/foundry-migration-transfer-io.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-migration-transfer-io.js +27 -3
- package/package-dist/scripts/lib/foundry-operation-result.d.ts +1 -1
- package/package-dist/scripts/lib/foundry-operation-result.js +1 -0
- package/package-dist/scripts/lib/foundry-package-contract.d.ts +4 -4
- package/package-dist/scripts/lib/foundry-package-contract.js +10 -2
- package/package-dist/scripts/lib/foundry-preparation-cli-validation.d.ts +22 -0
- package/package-dist/scripts/lib/foundry-preparation-cli-validation.js +213 -0
- package/package-dist/scripts/lib/foundry-quality-review-context.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-quality-review-context.js +18 -0
- package/package-dist/scripts/lib/foundry-quality-review-input.d.ts +48 -0
- package/package-dist/scripts/lib/foundry-quality-review-input.js +284 -0
- package/package-dist/scripts/lib/foundry-quality-review-lineage.d.ts +13 -0
- package/package-dist/scripts/lib/foundry-quality-review-lineage.js +123 -0
- package/package-dist/scripts/lib/foundry-quality-review.d.ts +112 -0
- package/package-dist/scripts/lib/foundry-quality-review.js +487 -0
- package/package-dist/scripts/lib/foundry-runtime-identity.js +3 -1
- package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
- package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
- package/package-dist/scripts/lib/foundry-task-authorization.d.ts +2 -1
- package/package-dist/scripts/lib/foundry-task-authorization.js +32 -11
- package/package-dist/scripts/lib/foundry-task-registration.js +4 -5
- package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.d.ts +28 -0
- package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.js +250 -0
- package/package-dist/scripts/lib/foundry-task-runtime-adoption.d.ts +60 -0
- package/package-dist/scripts/lib/foundry-task-runtime-adoption.js +549 -0
- package/package-dist/scripts/lib/foundry-task-store.d.ts +4 -1
- package/package-dist/scripts/lib/foundry-task-store.js +113 -4
- package/package-dist/scripts/lib/foundry-task-types.d.ts +2 -1
- package/package-dist/scripts/lib/foundry-validation-reference-context.d.ts +8 -0
- package/package-dist/scripts/lib/foundry-validation-reference-context.js +115 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +1 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.js +149 -18
- package/package-dist/scripts/lib/foundry-workflow-authorization.js +17 -4
- package/package-dist/scripts/lib/foundry-workflow-child-failure.d.ts +44 -0
- package/package-dist/scripts/lib/foundry-workflow-child-failure.js +439 -0
- package/package-dist/scripts/lib/foundry-workflow-context.js +37 -8
- package/package-dist/scripts/lib/foundry-workflow-finalize.js +37 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-recovery.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-recovery.js +450 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-stage.d.ts +9 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-stage.js +676 -0
- package/package-dist/scripts/lib/foundry-workflow-identity.js +10 -1
- package/package-dist/scripts/lib/foundry-workflow-io.d.ts +7 -1
- package/package-dist/scripts/lib/foundry-workflow-io.js +79 -13
- package/package-dist/scripts/lib/foundry-workflow-semantic.js +27 -13
- package/package-dist/scripts/lib/foundry-workflow-state.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-workflow-state.js +175 -22
- package/package-dist/scripts/lib/identity-preflight-artifacts.d.ts +4 -7
- package/package-dist/scripts/lib/identity-preflight-artifacts.js +18 -5
- package/package-dist/scripts/lib/identity-preflight-proof.d.ts +5 -0
- package/package-dist/scripts/lib/identity-preflight-proof.js +73 -1
- package/package-dist/scripts/lib/identity-preflight-recovery-proof.d.ts +78 -0
- package/package-dist/scripts/lib/identity-preflight-recovery-proof.js +415 -0
- package/package-dist/scripts/lib/import-curation/curation-cleanup.d.ts +9 -1
- package/package-dist/scripts/lib/import-curation/curation-cleanup.js +39 -2
- package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +6 -1
- package/package-dist/scripts/lib/import-curation/curation-gate.js +48 -2
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
- package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.js +11 -2
- package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.js +4 -1
- package/package-dist/scripts/lib/tidas-adapter.js +38 -15
- package/package-dist/scripts/lib/tidas-process-flow-context.d.ts +12 -0
- package/package-dist/scripts/lib/tidas-process-flow-context.js +96 -0
- package/package-dist/scripts/package-entry.js +2 -3
- package/package-dist/scripts/public-api.d.ts +5 -0
- package/package-dist/scripts/public-api.js +2 -0
- package/package-dist/scripts/runtime-entry.d.ts +2 -0
- package/package-dist/scripts/runtime-entry.js +42 -15
- package/package.json +6 -2
- package/specs/schemas/foundry-identity-stage-input.schema.json +47 -0
- package/specs/schemas/foundry-managed-adoption.schema.json +40 -0
- package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
- package/specs/schemas/foundry-operation-result.schema.json +1 -0
- package/specs/schemas/foundry-package-descriptor.schema.json +6 -2
- package/specs/schemas/foundry-quality-review-draft.schema.json +271 -0
- package/specs/schemas/foundry-quality-review-input.schema.json +271 -0
- 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
|
-
|
|
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();
|
|
@@ -203,8 +213,16 @@ function failure(operation, taskId, error, identity = null) {
|
|
|
203
213
|
const message = error instanceof FoundryContextError
|
|
204
214
|
? error.message
|
|
205
215
|
: `Foundry could not complete this operation${systemCode ? ` (${systemCode})` : ""}; selected state was preserved.`;
|
|
206
|
-
const
|
|
216
|
+
const recoveryUnproven = code === "identity_preflight_recovery_unproven";
|
|
217
|
+
const stageInput = code.startsWith("identity_stage_");
|
|
218
|
+
const needsAuth = !recoveryUnproven && !stageInput && (code === "needs_auth" || code.startsWith("identity_"));
|
|
207
219
|
const needsInputCodes = new Set([
|
|
220
|
+
"identity_preflight_recovery_unproven",
|
|
221
|
+
"identity_stage_unproven",
|
|
222
|
+
"identity_stage_input_invalid",
|
|
223
|
+
"identity_stage_interrupted",
|
|
224
|
+
"interaction_decision_pending",
|
|
225
|
+
"interaction_investigation_pending",
|
|
208
226
|
"task_not_found",
|
|
209
227
|
"workspace_not_initialized",
|
|
210
228
|
"input_not_selected",
|
|
@@ -220,6 +238,7 @@ function failure(operation, taskId, error, identity = null) {
|
|
|
220
238
|
"task_source_invalid",
|
|
221
239
|
]);
|
|
222
240
|
const blockedCodes = new Set([
|
|
241
|
+
"runtime_adoption_plan_stale",
|
|
223
242
|
"facade_crash_recovery_conflict",
|
|
224
243
|
"task_actor_mismatch",
|
|
225
244
|
"task_account_mismatch",
|
|
@@ -253,9 +272,21 @@ function failure(operation, taskId, error, identity = null) {
|
|
|
253
272
|
operation,
|
|
254
273
|
status: needsAuth ? "needs_auth" : needsInput ? "needs_input" : blocked ? "blocked" : "failed",
|
|
255
274
|
taskId,
|
|
256
|
-
artifacts:
|
|
275
|
+
artifacts: error instanceof WorkflowChildFailure && error.retainedArtifact
|
|
276
|
+
? [{ kind: "file", role: "workflow-child-failure.json", ...error.retainedArtifact }]
|
|
277
|
+
: [],
|
|
257
278
|
blockers: [{ code, message, scope: taskId }],
|
|
258
|
-
nextActions:
|
|
279
|
+
nextActions: recoveryUnproven
|
|
280
|
+
? [
|
|
281
|
+
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.`),
|
|
282
|
+
]
|
|
283
|
+
: code === "identity_stage_unproven"
|
|
284
|
+
? [
|
|
285
|
+
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."),
|
|
286
|
+
]
|
|
287
|
+
: error instanceof WorkflowChildFailure
|
|
288
|
+
? [human("repair_failed_local_operation", error.message)]
|
|
289
|
+
: [],
|
|
259
290
|
runtimeIdentity: identity,
|
|
260
291
|
permissions: noPermission(),
|
|
261
292
|
});
|
|
@@ -442,7 +473,7 @@ function currentIndexedQueueBlockers(context, workflow, entries) {
|
|
|
442
473
|
}, 0);
|
|
443
474
|
const scope = missing ? "process" : String(set.type);
|
|
444
475
|
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.
|
|
476
|
+
? `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
477
|
: `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
478
|
blockers.push({ code: "curation_queue_blocked", message, scope });
|
|
448
479
|
actions.push(human("review_queue_blockers", message));
|
|
@@ -536,6 +567,37 @@ function scopedAuthoringPresentation(context, entries, workflow, interaction, ob
|
|
|
536
567
|
}
|
|
537
568
|
function taskProjection(operation, context, record, inspected, identity) {
|
|
538
569
|
const artifacts = taskArtifacts(context, inspected);
|
|
570
|
+
const childFailure = readWorkflowChildFailure(context, inspected.artifacts);
|
|
571
|
+
if (childFailure) {
|
|
572
|
+
const file = path.join(context.taskRoot, childFailure.entry.path);
|
|
573
|
+
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.`;
|
|
574
|
+
return createFoundryOperationResult({
|
|
575
|
+
operation,
|
|
576
|
+
status: "blocked",
|
|
577
|
+
taskId: record.task_id,
|
|
578
|
+
artifacts,
|
|
579
|
+
blockers: [
|
|
580
|
+
{ code: "workflow_child_failed", message, scope: String(childFailure.result.command) },
|
|
581
|
+
],
|
|
582
|
+
nextActions: [human("repair_failed_local_operation", message)],
|
|
583
|
+
runtimeIdentity: identity,
|
|
584
|
+
permissions: noPermission(),
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
let projectedWorkflow;
|
|
588
|
+
let qualityScope = null;
|
|
589
|
+
const qualifiedIdentity = workflowObject(workflowObject(identity).qualification ?? {}).identity;
|
|
590
|
+
if (qualifiedIdentity && context.accountIntent) {
|
|
591
|
+
const digest = workflowObject(qualifiedIdentity).qualification_sha256;
|
|
592
|
+
if (typeof digest === "string") {
|
|
593
|
+
projectedWorkflow = currentWorkflowState(context, inspected.artifacts);
|
|
594
|
+
qualityScope = foundryQualityReviewScope(context, digest, inspected.artifacts, projectedWorkflow);
|
|
595
|
+
if (qualityScope) {
|
|
596
|
+
artifacts.push(inlineArtifact("quality_review_scope", qualityScope));
|
|
597
|
+
artifacts.push(inlineArtifact("quality_review_input_template", createFoundryQualityReviewTemplate(qualityScope)));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
539
601
|
const interaction = currentFoundryInteractionState(context, inspected.artifacts);
|
|
540
602
|
const pendingQuestions = interaction ? currentFoundryQuestions(interaction.state) : [];
|
|
541
603
|
const investigations = interaction ? currentFoundryInvestigations(interaction.state) : [];
|
|
@@ -665,6 +727,29 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
665
727
|
runtimeIdentity: identity,
|
|
666
728
|
permissions: noPermission(),
|
|
667
729
|
});
|
|
730
|
+
const pendingIdentity = pendingFoundryIdentityStage(context, inspected.artifacts);
|
|
731
|
+
if (pendingIdentity)
|
|
732
|
+
return createFoundryOperationResult({
|
|
733
|
+
operation,
|
|
734
|
+
status: "needs_input",
|
|
735
|
+
taskId: record.task_id,
|
|
736
|
+
artifacts: [
|
|
737
|
+
...artifacts,
|
|
738
|
+
inlineArtifact("explicit_readonly_identity_stage", pendingIdentity),
|
|
739
|
+
],
|
|
740
|
+
blockers: [
|
|
741
|
+
{
|
|
742
|
+
code: "identity_stage_unproven",
|
|
743
|
+
message: "The indexed explicit read-only stage has no proven completed outcome. Preserve UNKNOWN and inspect its retained admission and claims.",
|
|
744
|
+
scope: record.task_id,
|
|
745
|
+
},
|
|
746
|
+
],
|
|
747
|
+
nextActions: [
|
|
748
|
+
human("inspect_identity_stage", "Inspect the indexed new-stage evidence. Ordinary resume cannot repeat the query or proceed to write stages."),
|
|
749
|
+
],
|
|
750
|
+
runtimeIdentity: identity,
|
|
751
|
+
permissions: noPermission(),
|
|
752
|
+
});
|
|
668
753
|
const prepared = inspected.artifacts.some((entry) => entry.command === "dataset-curation-cleanup");
|
|
669
754
|
const nativeReport = artifacts.find((artifact) => artifact.kind === "file" &&
|
|
670
755
|
path.basename(artifact.path) === "foundry-native-import.json" &&
|
|
@@ -698,7 +783,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
698
783
|
permissions: noPermission(),
|
|
699
784
|
});
|
|
700
785
|
}
|
|
701
|
-
const workflow = currentWorkflowState(context, inspected.artifacts);
|
|
786
|
+
const workflow = projectedWorkflow ?? currentWorkflowState(context, inspected.artifacts);
|
|
702
787
|
const queueIssues = currentIndexedQueueBlockers(context, workflow, inspected.artifacts);
|
|
703
788
|
const nativeFailure = currentNativeValidationFailure(context, inspected.artifacts, workflow.rows
|
|
704
789
|
? {
|
|
@@ -995,12 +1080,12 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
995
1080
|
blockers: [
|
|
996
1081
|
{
|
|
997
1082
|
code: "identity_preflight_requires_input",
|
|
998
|
-
message: "Review the identity
|
|
1083
|
+
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
1084
|
scope: record.task_id,
|
|
1000
1085
|
},
|
|
1001
1086
|
],
|
|
1002
1087
|
nextActions: [
|
|
1003
|
-
human("review_identity_preflight", `Read ${workflow.identity.file}
|
|
1088
|
+
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
1089
|
],
|
|
1005
1090
|
runtimeIdentity: identity,
|
|
1006
1091
|
permissions: noPermission(),
|
|
@@ -1066,6 +1151,11 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
1066
1151
|
nextActions: [
|
|
1067
1152
|
...queueIssues.actions,
|
|
1068
1153
|
...scoped.actions,
|
|
1154
|
+
...(qualityScope
|
|
1155
|
+
? [
|
|
1156
|
+
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."),
|
|
1157
|
+
]
|
|
1158
|
+
: []),
|
|
1069
1159
|
...pending.flatMap((set) => [
|
|
1070
1160
|
...(!scoped.types.includes(set.type)
|
|
1071
1161
|
? [
|
|
@@ -1103,6 +1193,45 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
1103
1193
|
export function createFoundryFacade(options) {
|
|
1104
1194
|
const base = () => createFoundryRuntimeContext(contextOptions(options));
|
|
1105
1195
|
return Object.freeze({
|
|
1196
|
+
async adoptTaskRuntime(input) {
|
|
1197
|
+
try {
|
|
1198
|
+
assertNotInterrupted(options.signal);
|
|
1199
|
+
const current = base(), record = loadFoundryFacadeTaskRecord(current, input.taskId, input.actorId);
|
|
1200
|
+
const context = taskContext(options, current, record);
|
|
1201
|
+
if ((input.mode === "plan" && (input.selection === undefined || input.plan !== undefined)) ||
|
|
1202
|
+
(input.mode === "apply" && (input.plan === undefined || input.selection !== undefined)) ||
|
|
1203
|
+
(input.mode === "audit" && (input.plan !== undefined || input.selection !== undefined)))
|
|
1204
|
+
throw new FoundryContextError("runtime_adoption_selection_invalid", "Select exactly one plan, apply or audit input.");
|
|
1205
|
+
if (input.mode !== "audit" && options.runtimeAdoptionQualification)
|
|
1206
|
+
assertRuntimeAdoptionToolkit(qualification(context, options.runtimeSelection, true), input.mode === "plan"
|
|
1207
|
+
? input.selection
|
|
1208
|
+
: input.plan?.selection);
|
|
1209
|
+
const value = input.mode === "plan"
|
|
1210
|
+
? planFoundryTaskRuntimeAdoption(context, record, input.selection, options.runtimeAdoptionQualification)
|
|
1211
|
+
: input.mode === "apply"
|
|
1212
|
+
? await applyFoundryTaskRuntimeAdoption(context, record, input.plan, options.runtimeAdoptionQualification)
|
|
1213
|
+
: input.mode === "audit"
|
|
1214
|
+
? readFoundryTaskRuntimeAdoption(context)
|
|
1215
|
+
: null;
|
|
1216
|
+
if (!value)
|
|
1217
|
+
throw new FoundryContextError("runtime_adoption_missing", "No explicit task runtime adoption exists.");
|
|
1218
|
+
return createFoundryOperationResult({
|
|
1219
|
+
operation: "task.adopt-runtime",
|
|
1220
|
+
status: input.mode === "plan" ? "ready" : "completed",
|
|
1221
|
+
taskId: record.task_id,
|
|
1222
|
+
artifacts: [
|
|
1223
|
+
inlineArtifact(input.mode === "plan" ? "runtime_adoption_plan" : "runtime_adoption_result", value),
|
|
1224
|
+
],
|
|
1225
|
+
blockers: [],
|
|
1226
|
+
nextActions: [],
|
|
1227
|
+
runtimeIdentity: runtimeIdentity(context),
|
|
1228
|
+
permissions: noPermission(),
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
catch (error) {
|
|
1232
|
+
return failure("task.adopt-runtime", input.taskId, error);
|
|
1233
|
+
}
|
|
1234
|
+
},
|
|
1106
1235
|
async runtimeUse(input) {
|
|
1107
1236
|
try {
|
|
1108
1237
|
assertNotInterrupted(options.signal);
|
|
@@ -1454,6 +1583,12 @@ export function createFoundryFacade(options) {
|
|
|
1454
1583
|
let current = null;
|
|
1455
1584
|
try {
|
|
1456
1585
|
assertNotInterrupted(options.signal);
|
|
1586
|
+
if (input.identityStageInputFile !== undefined &&
|
|
1587
|
+
(typeof input.identityStageInputFile !== "string" || !input.identityStageInputFile.trim()))
|
|
1588
|
+
throw new FoundryContextError("identity_stage_input_invalid", "An explicit identity stage requires one nonempty file path.");
|
|
1589
|
+
if (input.qualityReviewInputFile !== undefined &&
|
|
1590
|
+
(typeof input.qualityReviewInputFile !== "string" || !input.qualityReviewInputFile.trim()))
|
|
1591
|
+
throw new FoundryContextError("quality_review_input_invalid", "Select one nonempty quality-review input path.");
|
|
1457
1592
|
if (input.referenceInputFile !== undefined &&
|
|
1458
1593
|
(typeof input.referenceInputFile !== "string" || !input.referenceInputFile.trim()))
|
|
1459
1594
|
throw new FoundryContextError("reference_input_invalid", "An explicit reference input requires one nonempty file path.");
|
|
@@ -1465,6 +1600,8 @@ export function createFoundryFacade(options) {
|
|
|
1465
1600
|
input.authorizationInputFile,
|
|
1466
1601
|
input.referenceInputFile,
|
|
1467
1602
|
input.interactionInputFile,
|
|
1603
|
+
input.identityStageInputFile,
|
|
1604
|
+
input.qualityReviewInputFile,
|
|
1468
1605
|
].filter((file) => file !== undefined).length > 1)
|
|
1469
1606
|
throw new FoundryContextError("task_input_conflict", "Submit one task input kind at a time.");
|
|
1470
1607
|
current = base();
|
|
@@ -1475,12 +1612,100 @@ export function createFoundryFacade(options) {
|
|
|
1475
1612
|
const runtime = createFoundryRuntime(context, qualified);
|
|
1476
1613
|
const before = await runtime.inspectTask();
|
|
1477
1614
|
if (record.spec.repair &&
|
|
1478
|
-
(input.semanticInputFile ||
|
|
1615
|
+
(input.semanticInputFile ||
|
|
1616
|
+
input.referenceInputFile ||
|
|
1617
|
+
input.interactionInputFile ||
|
|
1618
|
+
input.qualityReviewInputFile))
|
|
1479
1619
|
throw new FoundryContextError("repair_revision_required", "A repair keeps its before, candidate and contract immutable; changed inputs require an explicit revision.");
|
|
1480
1620
|
assertNotInterrupted(options.signal);
|
|
1481
1621
|
loadFoundryFacadeTaskRecord(current, record.task_id, record.spec.actor_id);
|
|
1482
1622
|
const existing = taskProjection("task.resume", context, record, before, runtimeIdentity(context, qualified));
|
|
1483
|
-
if (
|
|
1623
|
+
if (input.identityStageInputFile !== undefined) {
|
|
1624
|
+
if (!qualified)
|
|
1625
|
+
throw new FoundryContextError("runtime_unqualified", "An explicit read-only identity stage requires exact qualified runtime owners.");
|
|
1626
|
+
if (record.spec.lane !== "source-evidence-dataset-development" ||
|
|
1627
|
+
record.spec.preparation ||
|
|
1628
|
+
record.spec.repair)
|
|
1629
|
+
throw new FoundryContextError("identity_stage_input_invalid", "An explicit identity stage applies only to the original source-evidence Task.");
|
|
1630
|
+
const selected = selectFoundryIdentityStageInput(context, input.identityStageInputFile);
|
|
1631
|
+
const rowsEntry = before.artifacts.find((entry) => ["dataset-workflow-rows", "dataset-semantic-apply"].includes(entry.command) &&
|
|
1632
|
+
path.basename(entry.path) === "foundry-rows.json" &&
|
|
1633
|
+
entry.sha256 === selected.value.rows_report_sha256);
|
|
1634
|
+
const priorEntry = before.artifacts.find((entry) => entry.command === "dataset-workflow-identity" &&
|
|
1635
|
+
path.basename(entry.path) === "foundry-identity.json" &&
|
|
1636
|
+
entry.sha256 === selected.value.predecessor_identity_sha256);
|
|
1637
|
+
if (!rowsEntry || !priorEntry)
|
|
1638
|
+
throw new FoundryContextError("identity_stage_input_invalid", "Explicit identity stage must bind registered original rows and predecessor identity.");
|
|
1639
|
+
const rowReport = readWorkflowArtifact(context, rowsEntry).value;
|
|
1640
|
+
if (!Array.isArray(rowReport.sets))
|
|
1641
|
+
throw new FoundryContextError("workflow_rows_invalid", "Registered row report has no exact row sets.");
|
|
1642
|
+
const rowFiles = rowReport.sets.map((set) => workflowObject(set).file);
|
|
1643
|
+
const fixedEntries = [
|
|
1644
|
+
rowsEntry,
|
|
1645
|
+
priorEntry,
|
|
1646
|
+
...rowFiles.map((file) => {
|
|
1647
|
+
if (typeof file !== "string")
|
|
1648
|
+
throw new FoundryContextError("workflow_rows_invalid", "Registered row file is invalid.");
|
|
1649
|
+
const entry = before.artifacts.find((item) => resolveFoundryOutput(context, item.path) === file);
|
|
1650
|
+
if (!entry)
|
|
1651
|
+
throw new FoundryContextError("workflow_rows_invalid", "Registered row file lacks its producer.");
|
|
1652
|
+
return entry;
|
|
1653
|
+
}),
|
|
1654
|
+
];
|
|
1655
|
+
const fixedContext = taskContext(options, current, record, fixedEntries.map((entry) => ({
|
|
1656
|
+
path: resolveFoundryOutput(context, entry.path),
|
|
1657
|
+
bytes: entry.bytes,
|
|
1658
|
+
sha256: entry.sha256,
|
|
1659
|
+
})));
|
|
1660
|
+
const stage = await runExplicitFoundryIdentityStage(fixedContext, qualified, before.artifacts, selected, options.authentication, { signal: options.signal });
|
|
1661
|
+
const inspected = await runtime.inspectTask();
|
|
1662
|
+
const projected = taskProjection("task.resume", context, record, inspected, runtimeIdentity(context, qualified));
|
|
1663
|
+
const stageStatus = stage.status;
|
|
1664
|
+
const stageUnproven = stageStatus === "unproven" ||
|
|
1665
|
+
(stageStatus === "blocked" &&
|
|
1666
|
+
Array.isArray(stage.blockers) &&
|
|
1667
|
+
stage.blockers.some((item) => workflowObject(item).code === "identity_stage_outcome_unproven"));
|
|
1668
|
+
if (stageUnproven || stageStatus === "running")
|
|
1669
|
+
return createFoundryOperationResult({
|
|
1670
|
+
operation: "task.resume",
|
|
1671
|
+
taskId: record.task_id,
|
|
1672
|
+
status: stageStatus === "running" ? "running" : "needs_input",
|
|
1673
|
+
artifacts: [
|
|
1674
|
+
...projected.artifacts,
|
|
1675
|
+
inlineArtifact("explicit_readonly_identity_stage", stage),
|
|
1676
|
+
],
|
|
1677
|
+
blockers: [
|
|
1678
|
+
{
|
|
1679
|
+
code: stageStatus === "running"
|
|
1680
|
+
? "identity_stage_running"
|
|
1681
|
+
: "identity_stage_unproven",
|
|
1682
|
+
message: "Inspect the retained explicit-stage admission and execution evidence. An incomplete dispatched read-only query cannot be repeated automatically.",
|
|
1683
|
+
scope: record.task_id,
|
|
1684
|
+
},
|
|
1685
|
+
],
|
|
1686
|
+
nextActions: [
|
|
1687
|
+
human("inspect_identity_stage", "Preserve the original Task and read its indexed new-stage evidence; no query or write replay is permitted."),
|
|
1688
|
+
],
|
|
1689
|
+
runtimeIdentity: projected.runtime_identity,
|
|
1690
|
+
permissions: noPermission(),
|
|
1691
|
+
});
|
|
1692
|
+
return createFoundryOperationResult({
|
|
1693
|
+
operation: "task.resume",
|
|
1694
|
+
taskId: record.task_id,
|
|
1695
|
+
status: projected.status,
|
|
1696
|
+
artifacts: [
|
|
1697
|
+
...projected.artifacts,
|
|
1698
|
+
inlineArtifact("explicit_readonly_identity_stage", stage),
|
|
1699
|
+
],
|
|
1700
|
+
blockers: projected.blockers,
|
|
1701
|
+
nextActions: projected.next_actions,
|
|
1702
|
+
runtimeIdentity: projected.runtime_identity,
|
|
1703
|
+
permissions: noPermission(),
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
if ((input.referenceInputFile ||
|
|
1707
|
+
input.interactionInputFile ||
|
|
1708
|
+
input.qualityReviewInputFile) &&
|
|
1484
1709
|
existing.status === "completed")
|
|
1485
1710
|
throw new FoundryContextError("execution_scope_completed", "A completed task cannot replace its reference evidence.");
|
|
1486
1711
|
if (existing.status === "completed" || existing.status === "blocked")
|
|
@@ -1490,7 +1715,8 @@ export function createFoundryFacade(options) {
|
|
|
1490
1715
|
if (input.authorizationInputFile ||
|
|
1491
1716
|
input.semanticInputFile ||
|
|
1492
1717
|
input.referenceInputFile ||
|
|
1493
|
-
input.interactionInputFile
|
|
1718
|
+
input.interactionInputFile ||
|
|
1719
|
+
input.qualityReviewInputFile)
|
|
1494
1720
|
throw new FoundryContextError("execution_recovery_required", "Recover the consumed request before submitting changes.");
|
|
1495
1721
|
if (!qualified)
|
|
1496
1722
|
throw new FoundryContextError("runtime_unqualified", "Owner readback requires qualified runtime owners.");
|
|
@@ -1515,6 +1741,8 @@ export function createFoundryFacade(options) {
|
|
|
1515
1741
|
assertNotInterrupted(options.signal);
|
|
1516
1742
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1517
1743
|
}
|
|
1744
|
+
if (pendingFoundryIdentityStage(context, before.artifacts))
|
|
1745
|
+
return existing;
|
|
1518
1746
|
const unresolvedInteraction = currentFoundryInteractionState(context, before.artifacts);
|
|
1519
1747
|
const hasUnresolvedInteraction = Boolean(unresolvedInteraction &&
|
|
1520
1748
|
(currentFoundryQuestions(unresolvedInteraction.state).length ||
|
|
@@ -1536,6 +1764,20 @@ export function createFoundryFacade(options) {
|
|
|
1536
1764
|
await recordFoundryReferenceInput(selected, before.artifacts, submission);
|
|
1537
1765
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1538
1766
|
}
|
|
1767
|
+
if (input.qualityReviewInputFile) {
|
|
1768
|
+
if (record.spec.preparation || record.spec.repair)
|
|
1769
|
+
throw new FoundryContextError("quality_review_input_invalid", "Quality review requires an ordinary assessed Process task.");
|
|
1770
|
+
if (!qualified)
|
|
1771
|
+
throw new FoundryContextError("runtime_unqualified", "Quality review requires qualified runtime owners.");
|
|
1772
|
+
const selected = taskContext(options, current, record, before.artifacts.map((entry) => ({
|
|
1773
|
+
path: path.join(context.taskRoot, entry.path),
|
|
1774
|
+
bytes: entry.bytes,
|
|
1775
|
+
sha256: entry.sha256,
|
|
1776
|
+
})));
|
|
1777
|
+
const submission = selectFoundryQualityReviewInput(selected, input.qualityReviewInputFile);
|
|
1778
|
+
await recordFoundryQualityReview(selected, qualified, before.artifacts, submission);
|
|
1779
|
+
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1780
|
+
}
|
|
1539
1781
|
if (input.authorizationInputFile) {
|
|
1540
1782
|
const interactionBlocker = currentFoundryInteractionWriteBlocker(context, before.artifacts);
|
|
1541
1783
|
if (interactionBlocker)
|
|
@@ -1680,7 +1922,7 @@ export function createFoundryFacade(options) {
|
|
|
1680
1922
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1681
1923
|
}
|
|
1682
1924
|
const imported = before.artifacts.some((artifact) => artifact.command === "dataset-tidas-import");
|
|
1683
|
-
const contextPrepared =
|
|
1925
|
+
const contextPrepared = workflow.currentContextReports.length > 0;
|
|
1684
1926
|
const nativeRows = before.artifacts.filter((artifact) => artifact.command === "dataset-tidas-import" &&
|
|
1685
1927
|
artifact.path.endsWith(".json") &&
|
|
1686
1928
|
Object.values(datasetTypePlural).includes(/^outputs\/import\/[^/]+\/tidas\/([^/]+)\//u.exec(artifact.path)?.[1] ?? ""));
|
|
@@ -1727,20 +1969,20 @@ export function createFoundryFacade(options) {
|
|
|
1727
1969
|
: undefined;
|
|
1728
1970
|
if (!rows)
|
|
1729
1971
|
throw new FoundryContextError("workflow_rows_required", "Registered row preparation is required.");
|
|
1730
|
-
const contracts =
|
|
1731
|
-
.filter((fact) => path.basename(fact.path) === "contract-report.json")
|
|
1732
|
-
.map((fact) => fact.path);
|
|
1972
|
+
const contracts = workflow.currentContextReports;
|
|
1733
1973
|
const selected = taskContext(options, current, record, facts);
|
|
1734
1974
|
const identityReport = workflow.identity?.value.status === "completed" ? workflow.identity.file : undefined;
|
|
1735
1975
|
if (workflow.assessmentRemainingTypes.length)
|
|
1736
1976
|
await createFoundryRuntime(selected, qualified).assessRows(rows.path, contracts, identityReport, {
|
|
1737
1977
|
scopeType: workflow.assessmentRemainingTypes[0],
|
|
1978
|
+
qualityReviewSha256: workflow.qualityReviewSha256,
|
|
1738
1979
|
previousAssessment: workflow.assessment?.file,
|
|
1739
1980
|
interactionSha256: currentFoundryInteractionState(context, before.artifacts)?.entry.sha256 ?? null,
|
|
1740
1981
|
});
|
|
1741
1982
|
else
|
|
1742
1983
|
await createFoundryRuntime(selected, qualified).assessRows(rows.path, contracts, identityReport, {
|
|
1743
1984
|
interactionSha256: currentFoundryInteractionState(context, before.artifacts)?.entry.sha256 ?? null,
|
|
1985
|
+
qualityReviewSha256: workflow.qualityReviewSha256,
|
|
1744
1986
|
});
|
|
1745
1987
|
assertNotInterrupted(options.signal);
|
|
1746
1988
|
}
|
|
@@ -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:
|
|
31
|
-
treatment_standards_routes:
|
|
32
|
-
mix_and_location_types:
|
|
33
|
-
functional_unit_flow_properties:
|
|
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 = []) {
|
|
@@ -74,6 +74,10 @@ export function createIdentityPreflightRunCommands({ executionEnvironment = proc
|
|
|
74
74
|
const graceMs = Math.min(5_000, Math.max(250, Math.ceil(timeoutMs * 0.1)));
|
|
75
75
|
return timeoutMs + graceMs;
|
|
76
76
|
}
|
|
77
|
+
function identityPreflightRunPath(value) {
|
|
78
|
+
const resolved = resolveRepoPath(value);
|
|
79
|
+
return resolved ? path.resolve(resolved) : null;
|
|
80
|
+
}
|
|
77
81
|
function identityPreflightRunReportFile(row) {
|
|
78
82
|
const explicit = row.expected_report_file ||
|
|
79
83
|
row.identity_decision_file ||
|
|
@@ -81,21 +85,21 @@ export function createIdentityPreflightRunCommands({ executionEnvironment = proc
|
|
|
81
85
|
row.report_file ||
|
|
82
86
|
row.reportFile;
|
|
83
87
|
if (explicit)
|
|
84
|
-
return
|
|
88
|
+
return identityPreflightRunPath(explicit);
|
|
85
89
|
const outputDir = row.output_dir || row.outputDir;
|
|
86
90
|
return outputDir
|
|
87
|
-
? path.join(
|
|
91
|
+
? path.join(identityPreflightRunPath(outputDir), "outputs", "identity-decision.json")
|
|
88
92
|
: null;
|
|
89
93
|
}
|
|
90
94
|
function identityPreflightRunOutputDir(row) {
|
|
91
95
|
const outputDir = row.output_dir || row.outputDir;
|
|
92
96
|
if (outputDir)
|
|
93
|
-
return
|
|
97
|
+
return identityPreflightRunPath(outputDir);
|
|
94
98
|
const reportFile = identityPreflightRunReportFile(row);
|
|
95
99
|
return reportFile ? path.dirname(path.dirname(reportFile)) : null;
|
|
96
100
|
}
|
|
97
101
|
function identityPreflightRunRequestFile(row) {
|
|
98
|
-
return
|
|
102
|
+
return identityPreflightRunPath(row.request_file || row.requestFile || row.input);
|
|
99
103
|
}
|
|
100
104
|
function identityPreflightRunRowKey(row, index) {
|
|
101
105
|
return [
|
|
@@ -286,6 +290,7 @@ export function createIdentityPreflightRunCommands({ executionEnvironment = proc
|
|
|
286
290
|
maxAgeMs: positiveIntegerOption(options.authReceiptMaxAgeMs, 300_000) ?? 300_000,
|
|
287
291
|
expectedProjectRef,
|
|
288
292
|
expectedUserId,
|
|
293
|
+
sessionMode: executionEnvironment.TIANGONG_LCA_AUTH_MODE === "access_token" ? "headless" : "oauth",
|
|
289
294
|
});
|
|
290
295
|
}
|
|
291
296
|
const logDir = path.join(outDir, "logs");
|
|
@@ -594,6 +599,11 @@ export function createIdentityPreflightRunCommands({ executionEnvironment = proc
|
|
|
594
599
|
startedAtMs,
|
|
595
600
|
diskReportMtimeMs: reportFile && fileExists(reportFile) ? fs.statSync(reportFile).mtimeMs : null,
|
|
596
601
|
completedAtUtc: nowIso(),
|
|
602
|
+
requestFile: requestFile ?? undefined,
|
|
603
|
+
outputDir,
|
|
604
|
+
reportFile: reportFile ?? undefined,
|
|
605
|
+
stderrText: result.stderr || "",
|
|
606
|
+
signal: result.signal,
|
|
597
607
|
});
|
|
598
608
|
if (executionValidation?.ok) {
|
|
599
609
|
writeJson(executionManifestFile, executionValidation.manifest);
|
|
@@ -770,8 +780,8 @@ export function createIdentityPreflightRunCommands({ executionEnvironment = proc
|
|
|
770
780
|
blockers: blockers.length,
|
|
771
781
|
},
|
|
772
782
|
policy: {
|
|
773
|
-
fail_closed_execution: "
|
|
774
|
-
valid_identity_findings: "A blocked/needs_review report remains diagnostic evidence only
|
|
783
|
+
fail_closed_execution: "Nonzero CLI exits fail except the qualified CLI 0.1.28 complete, bound, error-free needs_review/manual_review exit 1 diagnostic. Missing/malformed or stale reports, stdout/disk mismatch, ok:false, failed/error status, execution signals/stderr and binding drift remain failures.",
|
|
784
|
+
valid_identity_findings: "A blocked/needs_review report remains scientific diagnostic evidence only with a valid execution manifest; the pinned manual-review exit 1 contract does not resolve identity or grant a write.",
|
|
775
785
|
curation_gate_usage: "Pass this same index to dataset-curation-gate with --identity-preflight-index so authoring packages include current and dependency identity-preflight context.",
|
|
776
786
|
},
|
|
777
787
|
files: {
|