@tiangong-lca/foundry 0.1.9 → 0.1.11
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 +13 -11
- package/docs/architecture.md +12 -10
- package/docs/foundry-task-contracts.md +16 -4
- package/docs/import-profiles/bafu/constraints.md +1 -1
- package/docs/import-profiles/bafu/profile.md +1 -1
- package/docs/import-profiles/worldsteel/constraints.md +3 -3
- package/docs/import-profiles/worldsteel/import-coverage.md +3 -3
- package/docs/import-profiles/worldsteel/import-plan.md +4 -4
- package/docs/import-profiles/worldsteel/profile.md +3 -3
- package/docs/package-distribution-contract.md +11 -9
- package/docs/public-runtime-contract.md +31 -9
- package/docs/runtime-context-contract.md +7 -5
- package/docs/task-authorization-contract.md +5 -3
- package/package-dist/assets/foundry-package-descriptor.json +300 -154
- package/package-dist/scripts/foundry-facade.d.ts +1 -0
- package/package-dist/scripts/foundry-facade.js +233 -28
- package/package-dist/scripts/foundry-runtime.d.ts +14 -3
- package/package-dist/scripts/foundry-runtime.js +2 -2
- package/package-dist/scripts/lib/finalize-owners/commit-handoff.js +3 -3
- package/package-dist/scripts/lib/finalize-owners/{native-insert-closeout.d.ts → native-draft-closeout.d.ts} +1 -1
- package/package-dist/scripts/lib/finalize-owners/{native-insert-closeout.js → native-draft-closeout.js} +10 -6
- package/package-dist/scripts/lib/finalize-owners/{native-insert-handoff.d.ts → native-draft-handoff.d.ts} +7 -5
- package/package-dist/scripts/lib/finalize-owners/{native-insert-handoff.js → native-draft-handoff.js} +30 -11
- package/package-dist/scripts/lib/finalize-owners/post-write-closeout.js +2 -2
- package/package-dist/scripts/lib/foundry-authorization-input.d.ts +10 -1
- package/package-dist/scripts/lib/foundry-authorization-input.js +27 -3
- package/package-dist/scripts/lib/foundry-command-metadata.js +25 -2
- package/package-dist/scripts/lib/foundry-command-registry.d.ts +4 -4
- package/package-dist/scripts/lib/foundry-command-registry.js +3 -0
- package/package-dist/scripts/lib/foundry-execution-admission.js +3 -3
- package/package-dist/scripts/lib/foundry-facade-store.js +56 -6
- package/package-dist/scripts/lib/foundry-interaction-input.d.ts +19 -0
- package/package-dist/scripts/lib/foundry-interaction-input.js +327 -0
- package/package-dist/scripts/lib/foundry-interaction-projection.d.ts +22 -0
- package/package-dist/scripts/lib/foundry-interaction-projection.js +81 -0
- package/package-dist/scripts/lib/foundry-interaction-types.d.ts +17 -0
- package/package-dist/scripts/lib/foundry-interaction-types.js +4 -0
- package/package-dist/scripts/lib/foundry-owner-execution-store.d.ts +33 -16
- package/package-dist/scripts/lib/foundry-owner-execution-store.js +66 -5
- package/package-dist/scripts/lib/foundry-owner-readback.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-owner-readback.js +101 -27
- package/package-dist/scripts/lib/foundry-package-contract.d.ts +4 -4
- package/package-dist/scripts/lib/foundry-package-contract.js +4 -2
- package/package-dist/scripts/lib/foundry-repair-execution.d.ts +11 -0
- package/package-dist/scripts/lib/foundry-repair-execution.js +70 -0
- package/package-dist/scripts/lib/foundry-repair-handoff.d.ts +16 -0
- package/package-dist/scripts/lib/foundry-repair-handoff.js +108 -0
- package/package-dist/scripts/lib/foundry-repair-preflight.d.ts +96 -0
- package/package-dist/scripts/lib/foundry-repair-preflight.js +313 -0
- package/package-dist/scripts/lib/foundry-repair-reference-binding.d.ts +26 -0
- package/package-dist/scripts/lib/foundry-repair-reference-binding.js +120 -0
- package/package-dist/scripts/lib/foundry-repair-reference-proof.d.ts +63 -0
- package/package-dist/scripts/lib/foundry-repair-reference-proof.js +329 -0
- package/package-dist/scripts/lib/foundry-repair-scope.d.ts +76 -0
- package/package-dist/scripts/lib/foundry-repair-scope.js +304 -0
- package/package-dist/scripts/lib/foundry-runtime-command-policy.js +1 -0
- package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
- package/package-dist/scripts/lib/foundry-runtime-utils.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-runtime-utils.js +6 -1
- package/package-dist/scripts/lib/foundry-semantic-input.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-semantic-input.js +29 -2
- package/package-dist/scripts/lib/foundry-semantic-interaction.d.ts +12 -0
- package/package-dist/scripts/lib/foundry-semantic-interaction.js +38 -0
- package/package-dist/scripts/lib/foundry-successor-predecessor.d.ts +36 -0
- package/package-dist/scripts/lib/foundry-successor-predecessor.js +399 -0
- package/package-dist/scripts/lib/foundry-task-registration.js +64 -3
- package/package-dist/scripts/lib/foundry-task-start-spec.d.ts +14 -0
- package/package-dist/scripts/lib/foundry-task-start-spec.js +60 -1
- package/package-dist/scripts/lib/foundry-task-store.d.ts +13 -1
- package/package-dist/scripts/lib/foundry-task-store.js +23 -12
- package/package-dist/scripts/lib/foundry-task-types.d.ts +22 -1
- package/package-dist/scripts/lib/foundry-tidas-source.d.ts +15 -0
- package/package-dist/scripts/lib/foundry-tidas-source.js +90 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +7 -1
- package/package-dist/scripts/lib/foundry-workflow-assessment.js +127 -6
- package/package-dist/scripts/lib/foundry-workflow-authorization.d.ts +2 -1
- package/package-dist/scripts/lib/foundry-workflow-authorization.js +194 -26
- package/package-dist/scripts/lib/foundry-workflow-context.js +4 -0
- package/package-dist/scripts/lib/foundry-workflow-execution.js +6 -1
- package/package-dist/scripts/lib/foundry-workflow-finalize.js +7 -4
- package/package-dist/scripts/lib/foundry-workflow-interaction.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-workflow-interaction.js +63 -0
- package/package-dist/scripts/lib/foundry-workflow-repair.d.ts +36 -0
- package/package-dist/scripts/lib/foundry-workflow-repair.js +580 -0
- package/package-dist/scripts/lib/foundry-workflow-semantic.js +21 -1
- package/package-dist/scripts/lib/foundry-workflow-state.d.ts +9 -1
- package/package-dist/scripts/lib/foundry-workflow-state.js +239 -39
- package/package-dist/scripts/lib/import-curation/curation-cleanup.js +39 -8
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
- package/package-dist/scripts/lib/import-curation/internal/prewrite-cleanup.d.ts +13 -2
- package/package-dist/scripts/lib/import-curation/internal/prewrite-cleanup.js +100 -29
- package/package-dist/scripts/lib/import-curation/internal/workflow-authoring-tasks.js +1 -2
- package/package-dist/scripts/lib/import-curation/internal/workflow-patch-collect.js +2 -3
- package/package-dist/scripts/lib/import-curation/internal/workflow-queue-context.js +8 -8
- package/package-dist/scripts/lib/import-curation/internal/workflow-semantic-actions.js +12 -2
- package/package-dist/scripts/public-api.d.ts +2 -0
- package/package-dist/scripts/public-api.js +1 -0
- package/package-dist/scripts/runtime-entry.js +9 -1
- package/package.json +3 -2
- package/specs/import-profiles.json +1 -1
- package/specs/schemas/foundry-authorization-input.schema.json +45 -2
- package/specs/schemas/foundry-interaction-input.schema.json +173 -0
- package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
- package/specs/schemas/foundry-package-descriptor.schema.json +3 -2
- package/specs/schemas/foundry-semantic-input.schema.json +12 -1
- package/specs/schemas/foundry-task-start.schema.json +275 -19
- package/specs/schemas/runtime-qualification.schema.json +1 -1
|
@@ -69,6 +69,7 @@ export declare function createFoundryFacade(options: FoundryFacadeOptions): Read
|
|
|
69
69
|
taskId: string;
|
|
70
70
|
actorId: string;
|
|
71
71
|
semanticInputFile?: string;
|
|
72
|
+
interactionInputFile?: string;
|
|
72
73
|
authorizationInputFile?: string;
|
|
73
74
|
referenceInputFile?: string;
|
|
74
75
|
}): Promise<FoundryOperationResult>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertFoundryRepairExecution } from "./lib/foundry-repair-execution.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
@@ -22,8 +23,11 @@ import { completedOwnerScopes, prepareFoundryOwnerExecution, } from "./lib/found
|
|
|
22
23
|
import { executeFoundryOwnerScope } from "./lib/foundry-workflow-execution.js";
|
|
23
24
|
import { inspectFoundryReferences, verifyFoundryReferences, } from "./lib/foundry-workflow-reference-verify.js";
|
|
24
25
|
import { selectFoundrySemanticInput } from "./lib/foundry-semantic-input.js";
|
|
26
|
+
import { currentFoundryInteractionState, currentFoundryQuestions, currentFoundryDecisions, currentFoundryInvestigations, currentFoundryAssumptions, selectFoundryInteractionInput, } from "./lib/foundry-interaction-input.js";
|
|
27
|
+
import { recordFoundryInteractionInput } from "./lib/foundry-workflow-interaction.js";
|
|
25
28
|
import { runFoundryWorkflowIdentity } from "./lib/foundry-workflow-identity.js";
|
|
26
29
|
import { finalizeFoundryWorkflow } from "./lib/foundry-workflow-finalize.js";
|
|
30
|
+
import { prepareFoundryRepair, readFoundryRepairPreparation, } from "./lib/foundry-workflow-repair.js";
|
|
27
31
|
import { selectFoundryReferenceInput, recordFoundryReferenceInput, } from "./lib/foundry-reference-input.js";
|
|
28
32
|
import { selectFoundryAuthorizationInput, snapshotFoundryAuthorizationContract, } from "./lib/foundry-authorization-input.js";
|
|
29
33
|
import { authorizeFoundryWorkflow } from "./lib/foundry-workflow-authorization.js";
|
|
@@ -366,12 +370,65 @@ function completionProven(context, record, inspected) {
|
|
|
366
370
|
}
|
|
367
371
|
function taskProjection(operation, context, record, inspected, identity) {
|
|
368
372
|
const artifacts = taskArtifacts(context, inspected);
|
|
369
|
-
|
|
373
|
+
const interaction = currentFoundryInteractionState(context, inspected.artifacts);
|
|
374
|
+
const pendingQuestions = interaction ? currentFoundryQuestions(interaction.state) : [];
|
|
375
|
+
const investigations = interaction ? currentFoundryInvestigations(interaction.state) : [];
|
|
376
|
+
if (record.spec.brief)
|
|
377
|
+
artifacts.push(inlineArtifact("task_brief", record.spec.brief));
|
|
378
|
+
if (interaction)
|
|
379
|
+
artifacts.push(Object.freeze({
|
|
380
|
+
kind: "file",
|
|
381
|
+
role: "current_interaction_state",
|
|
382
|
+
path: path.join(context.taskRoot, interaction.entry.path),
|
|
383
|
+
bytes: interaction.entry.bytes,
|
|
384
|
+
sha256: interaction.entry.sha256,
|
|
385
|
+
}));
|
|
386
|
+
const recap = (completionProven) => {
|
|
387
|
+
const questions = new Map(interaction?.state.events
|
|
388
|
+
.filter((event) => event.kind === "question")
|
|
389
|
+
.map((event) => [String(event.id), event]) ?? []);
|
|
390
|
+
return inlineArtifact("decision_recap", {
|
|
391
|
+
schema: "tiangong-foundry.decision-recap.v1",
|
|
392
|
+
task_id: record.task_id,
|
|
393
|
+
completion_proven: completionProven,
|
|
394
|
+
brief: record.spec.brief ?? null,
|
|
395
|
+
user_decisions: interaction
|
|
396
|
+
? currentFoundryDecisions(interaction.state).map((answer) => ({
|
|
397
|
+
question_id: answer.question_id,
|
|
398
|
+
dataset_type: questions.get(String(answer.question_id))?.dataset_type ?? null,
|
|
399
|
+
impact: questions.get(String(answer.question_id))?.impact ?? null,
|
|
400
|
+
raw_answer_sha256: createHash("sha256").update(String(answer.raw_answer)).digest("hex"),
|
|
401
|
+
adopted_decision: answer.adopted_decision,
|
|
402
|
+
decision_id: answer.decision_id,
|
|
403
|
+
supersedes_decision_id: answer.supersedes_decision_id,
|
|
404
|
+
evidence_sha256: answer.evidence_sha256,
|
|
405
|
+
}))
|
|
406
|
+
: [],
|
|
407
|
+
ai_assumptions: interaction ? currentFoundryAssumptions(interaction.state) : [],
|
|
408
|
+
unresolved_questions: [...pendingQuestions, ...investigations].map((question) => ({
|
|
409
|
+
id: question.id,
|
|
410
|
+
dataset_type: question.dataset_type,
|
|
411
|
+
missing: question.missing,
|
|
412
|
+
impact: question.impact,
|
|
413
|
+
ask: question.ask,
|
|
414
|
+
choices: question.choices,
|
|
415
|
+
})),
|
|
416
|
+
source_interaction_sha256: interaction?.entry.sha256 ?? null,
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
if (record.spec.brief || interaction)
|
|
420
|
+
artifacts.push(recap(false));
|
|
421
|
+
const completedArtifacts = () => record.spec.brief || interaction
|
|
422
|
+
? [...artifacts.filter((artifact) => artifact.role !== "decision_recap"), recap(true)]
|
|
423
|
+
: artifacts;
|
|
424
|
+
if (completionProven(context, record, inspected) &&
|
|
425
|
+
!pendingQuestions.length &&
|
|
426
|
+
!investigations.length)
|
|
370
427
|
return createFoundryOperationResult({
|
|
371
428
|
operation,
|
|
372
429
|
status: "completed",
|
|
373
430
|
taskId: record.task_id,
|
|
374
|
-
artifacts,
|
|
431
|
+
artifacts: completedArtifacts(),
|
|
375
432
|
blockers: [],
|
|
376
433
|
nextActions: [],
|
|
377
434
|
runtimeIdentity: identity,
|
|
@@ -440,6 +497,90 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
440
497
|
});
|
|
441
498
|
}
|
|
442
499
|
const workflow = currentWorkflowState(context, inspected.artifacts);
|
|
500
|
+
if (record.spec.repair && execution.verified.size) {
|
|
501
|
+
if (execution.requests.length !== 1 || execution.verified.size !== 1)
|
|
502
|
+
throw new FoundryContextError("repair_execution_mismatch", "A repair task must retain one exact verified execution scope.");
|
|
503
|
+
const requested = execution.requests[0];
|
|
504
|
+
const repair = assertFoundryRepairExecution(context, inspected.artifacts, requested.request);
|
|
505
|
+
const verified = execution.verified.get(requested.request.scope_id);
|
|
506
|
+
const proof = verified?.value.readback;
|
|
507
|
+
const bound = proof?.repair_preparation;
|
|
508
|
+
if (!repair ||
|
|
509
|
+
!verified ||
|
|
510
|
+
bound?.sha256 !== repair.preparation.entry.sha256 ||
|
|
511
|
+
bound?.bytes !== repair.preparation.entry.bytes ||
|
|
512
|
+
proof?.publication_ready !== false)
|
|
513
|
+
throw new FoundryContextError("repair_execution_mismatch", "Repair completion requires the same prepared scope and independent native receipt/readback proof.");
|
|
514
|
+
return createFoundryOperationResult({
|
|
515
|
+
operation,
|
|
516
|
+
status: "completed",
|
|
517
|
+
taskId: record.task_id,
|
|
518
|
+
artifacts: completedArtifacts(),
|
|
519
|
+
blockers: [],
|
|
520
|
+
nextActions: [],
|
|
521
|
+
runtimeIdentity: identity,
|
|
522
|
+
permissions: noPermission(),
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
if (record.spec.repair && !workflow.authorization && !execution.completed.size) {
|
|
526
|
+
const found = readFoundryRepairPreparation(context, inspected.artifacts);
|
|
527
|
+
const noChange = found?.value.status === "no_change_verified";
|
|
528
|
+
const preparedRepair = found?.value.status === "prepared";
|
|
529
|
+
if (noChange && execution.requests.length)
|
|
530
|
+
throw new FoundryContextError("repair_noop_attempt_conflict", "No-write completion cannot replace an owner execution request.");
|
|
531
|
+
return createFoundryOperationResult({
|
|
532
|
+
operation,
|
|
533
|
+
status: noChange ? "completed" : found ? "needs_input" : "ready",
|
|
534
|
+
taskId: record.task_id,
|
|
535
|
+
artifacts: noChange ? completedArtifacts() : artifacts,
|
|
536
|
+
blockers: noChange || !found
|
|
537
|
+
? []
|
|
538
|
+
: [
|
|
539
|
+
{
|
|
540
|
+
code: preparedRepair ? "repair_authorization_required" : "repair_preflight_blocked",
|
|
541
|
+
message: preparedRepair
|
|
542
|
+
? "The exact draft repair is prepared. Current task approval is required before any write."
|
|
543
|
+
: "Review the registered repair preflight findings; a resume may repeat only the read-only preparation.",
|
|
544
|
+
scope: record.task_id,
|
|
545
|
+
},
|
|
546
|
+
],
|
|
547
|
+
nextActions: noChange
|
|
548
|
+
? []
|
|
549
|
+
: preparedRepair
|
|
550
|
+
? [
|
|
551
|
+
human("authorize_repair", `Review the content-bound repair evidence ${found.file} before authorizing its exact owner-draft scope.`),
|
|
552
|
+
]
|
|
553
|
+
: [resumeCommand(context, record)],
|
|
554
|
+
runtimeIdentity: identity,
|
|
555
|
+
permissions: preparedRepair
|
|
556
|
+
? { state: "required", requested_actions: [], approval_reference: null }
|
|
557
|
+
: noPermission(),
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
if (pendingQuestions.length || investigations.length) {
|
|
561
|
+
const describe = (question) => `${String(question.missing)} ${String(question.impact)} ${String(question.recommendation)} ${String(question.ask)}`;
|
|
562
|
+
const askActions = pendingQuestions.map((question) => human("answer_current_question", `${describe(question)}${Array.isArray(question.choices) && question.choices.length ? ` ${question.choices.join(" / ")}` : ""}`));
|
|
563
|
+
const investigationIds = new Set(investigations.map((question) => String(question.id)));
|
|
564
|
+
return createFoundryOperationResult({
|
|
565
|
+
operation,
|
|
566
|
+
status: "needs_input",
|
|
567
|
+
taskId: record.task_id,
|
|
568
|
+
artifacts,
|
|
569
|
+
blockers: [...pendingQuestions, ...investigations].map((question) => ({
|
|
570
|
+
code: investigationIds.has(String(question.id))
|
|
571
|
+
? "interaction_investigation_pending"
|
|
572
|
+
: "interaction_decision_pending",
|
|
573
|
+
message: `${String(question.missing)} ${String(question.impact)}`,
|
|
574
|
+
scope: String(question.dataset_type ?? record.task_id),
|
|
575
|
+
})),
|
|
576
|
+
nextActions: [
|
|
577
|
+
...askActions,
|
|
578
|
+
...(workflow.assessmentRemainingTypes.length ? [resumeCommand(context, record)] : []),
|
|
579
|
+
],
|
|
580
|
+
runtimeIdentity: identity,
|
|
581
|
+
permissions: noPermission(),
|
|
582
|
+
});
|
|
583
|
+
}
|
|
443
584
|
const references = inspectFoundryReferences(context, inspected.artifacts);
|
|
444
585
|
const scopeComplete = workflow.rows &&
|
|
445
586
|
(workflow.rows.value.sets.length > 0 || references.scope) &&
|
|
@@ -449,7 +590,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
449
590
|
operation,
|
|
450
591
|
status: "completed",
|
|
451
592
|
taskId: record.task_id,
|
|
452
|
-
artifacts,
|
|
593
|
+
artifacts: completedArtifacts(),
|
|
453
594
|
blockers: [],
|
|
454
595
|
nextActions: [],
|
|
455
596
|
runtimeIdentity: identity,
|
|
@@ -583,15 +724,15 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
583
724
|
});
|
|
584
725
|
const assessment = workflow.assessment?.entry;
|
|
585
726
|
if (assessment) {
|
|
586
|
-
const
|
|
587
|
-
if (!
|
|
588
|
-
typeof
|
|
589
|
-
!("schema" in
|
|
590
|
-
|
|
591
|
-
!("sets" in
|
|
592
|
-
!Array.isArray(
|
|
727
|
+
const rawReport = JSON.parse(readCaptured({ ...assessment, path: path.join(context.taskRoot, assessment.path) }, maxSeedBytes, "workflow_assessment_invalid").toString("utf8"));
|
|
728
|
+
if (!rawReport ||
|
|
729
|
+
typeof rawReport !== "object" ||
|
|
730
|
+
!("schema" in rawReport) ||
|
|
731
|
+
rawReport.schema !== "tiangong-foundry.assessment-stage.v1" ||
|
|
732
|
+
!("sets" in rawReport) ||
|
|
733
|
+
!Array.isArray(rawReport.sets))
|
|
593
734
|
throw new FoundryContextError("workflow_assessment_invalid", "Registered assessment metadata is invalid.");
|
|
594
|
-
const pending =
|
|
735
|
+
const pending = workflow.assessment.value.sets.filter((value) => {
|
|
595
736
|
if (!value ||
|
|
596
737
|
typeof value !== "object" ||
|
|
597
738
|
!("curation_counts" in value) ||
|
|
@@ -636,10 +777,13 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
636
777
|
message: `Resolve the current ${set.type} curation and authoring work before a write handoff.`,
|
|
637
778
|
scope: record.task_id,
|
|
638
779
|
})),
|
|
639
|
-
nextActions:
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
780
|
+
nextActions: [
|
|
781
|
+
...pending.flatMap((set) => [
|
|
782
|
+
human("review_semantic_work", `Read the registered curation report ${set.curation_report} and authoring manifest ${set.authoring_manifest}. Use their bound source/context evidence; no write permission is implied.`),
|
|
783
|
+
...(set.decisions ?? []).map((work) => human(`review_${work.kind}_decisions`, `Read registered ${work.kind} task ${work.task} (${work.status}). Complete its bound decision template and submit it with semantic-input kind=${work.kind}.`)),
|
|
784
|
+
]),
|
|
785
|
+
...(workflow.assessmentRemainingTypes.length ? [resumeCommand(context, record)] : []),
|
|
786
|
+
],
|
|
643
787
|
runtimeIdentity: identity,
|
|
644
788
|
permissions: noPermission(),
|
|
645
789
|
});
|
|
@@ -648,7 +792,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
648
792
|
? [
|
|
649
793
|
human("review_prepared_rows", "Review the current prepared artifacts and continue the returned task workflow."),
|
|
650
794
|
]
|
|
651
|
-
: record.spec.preparation || !workflow.
|
|
795
|
+
: record.spec.preparation || !workflow.assessmentComplete
|
|
652
796
|
? [resumeCommand(context, record)]
|
|
653
797
|
: [
|
|
654
798
|
human("review_assessment", "Review the registered curation reports and authoring-task manifests. Resolve their current semantic work before requesting a write handoff; assessment does not grant permission."),
|
|
@@ -952,6 +1096,7 @@ export function createFoundryFacade(options) {
|
|
|
952
1096
|
profileId: selectedSpec.spec.profile_id,
|
|
953
1097
|
targetEntities: [...selectedSpec.spec.target_entities],
|
|
954
1098
|
seed: selectedSeed,
|
|
1099
|
+
...(selectedSpec.spec.repair ? { repair: selectedSpec.spec.repair } : {}),
|
|
955
1100
|
});
|
|
956
1101
|
return {
|
|
957
1102
|
created_at_utc: task.job.created_at_utc,
|
|
@@ -974,6 +1119,7 @@ export function createFoundryFacade(options) {
|
|
|
974
1119
|
artifacts: [
|
|
975
1120
|
fileArtifact("facade_request_index", requestIndex),
|
|
976
1121
|
fileArtifact("foundry_job", path.join(context.taskRoot, "foundry-job.json")),
|
|
1122
|
+
...result.artifacts,
|
|
977
1123
|
],
|
|
978
1124
|
nextActions: result.next_actions,
|
|
979
1125
|
runtimeIdentity: result.runtime_identity,
|
|
@@ -1019,6 +1165,16 @@ export function createFoundryFacade(options) {
|
|
|
1019
1165
|
if (input.referenceInputFile !== undefined &&
|
|
1020
1166
|
(typeof input.referenceInputFile !== "string" || !input.referenceInputFile.trim()))
|
|
1021
1167
|
throw new FoundryContextError("reference_input_invalid", "An explicit reference input requires one nonempty file path.");
|
|
1168
|
+
if (input.interactionInputFile !== undefined &&
|
|
1169
|
+
(typeof input.interactionInputFile !== "string" || !input.interactionInputFile.trim()))
|
|
1170
|
+
throw new FoundryContextError("interaction_input_invalid", "An explicit interaction input requires one nonempty file path.");
|
|
1171
|
+
if ([
|
|
1172
|
+
input.semanticInputFile,
|
|
1173
|
+
input.authorizationInputFile,
|
|
1174
|
+
input.referenceInputFile,
|
|
1175
|
+
input.interactionInputFile,
|
|
1176
|
+
].filter((file) => file !== undefined).length > 1)
|
|
1177
|
+
throw new FoundryContextError("task_input_conflict", "Submit one task input kind at a time.");
|
|
1022
1178
|
current = base();
|
|
1023
1179
|
assertFoundryWorkspaceWrite(current);
|
|
1024
1180
|
const record = loadFoundryFacadeTaskRecord(current, input.taskId, input.actorId);
|
|
@@ -1026,16 +1182,23 @@ export function createFoundryFacade(options) {
|
|
|
1026
1182
|
const qualified = qualification(context, options.runtimeSelection);
|
|
1027
1183
|
const runtime = createFoundryRuntime(context, qualified);
|
|
1028
1184
|
const before = await runtime.inspectTask();
|
|
1185
|
+
if (record.spec.repair &&
|
|
1186
|
+
(input.semanticInputFile || input.referenceInputFile || input.interactionInputFile))
|
|
1187
|
+
throw new FoundryContextError("repair_revision_required", "A repair keeps its before, candidate and contract immutable; changed inputs require an explicit revision.");
|
|
1029
1188
|
assertNotInterrupted(options.signal);
|
|
1030
1189
|
loadFoundryFacadeTaskRecord(current, record.task_id, record.spec.actor_id);
|
|
1031
1190
|
const existing = taskProjection("task.resume", context, record, before, runtimeIdentity(context, qualified));
|
|
1032
|
-
if (input.referenceInputFile
|
|
1191
|
+
if ((input.referenceInputFile || input.interactionInputFile) &&
|
|
1192
|
+
existing.status === "completed")
|
|
1033
1193
|
throw new FoundryContextError("execution_scope_completed", "A completed task cannot replace its reference evidence.");
|
|
1034
1194
|
if (existing.status === "completed" || existing.status === "blocked")
|
|
1035
1195
|
return existing;
|
|
1036
1196
|
const execution = completedOwnerScopes(context, before.artifacts);
|
|
1037
1197
|
if (execution.pending.length) {
|
|
1038
|
-
if (input.authorizationInputFile ||
|
|
1198
|
+
if (input.authorizationInputFile ||
|
|
1199
|
+
input.semanticInputFile ||
|
|
1200
|
+
input.referenceInputFile ||
|
|
1201
|
+
input.interactionInputFile)
|
|
1039
1202
|
throw new FoundryContextError("execution_recovery_required", "Recover the consumed request before submitting changes.");
|
|
1040
1203
|
if (!qualified)
|
|
1041
1204
|
throw new FoundryContextError("runtime_unqualified", "Owner readback requires qualified runtime owners.");
|
|
@@ -1047,6 +1210,25 @@ export function createFoundryFacade(options) {
|
|
|
1047
1210
|
await executeFoundryOwnerScope(selected, qualified, before.artifacts, execution.pending[0], options.authentication);
|
|
1048
1211
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1049
1212
|
}
|
|
1213
|
+
if (input.interactionInputFile) {
|
|
1214
|
+
if (execution.consumed.size)
|
|
1215
|
+
throw new FoundryContextError("execution_scope_consumed", "Recover and preserve consumed scope evidence before changing task decisions.");
|
|
1216
|
+
const selected = selectFoundryInteractionInput(context, input.interactionInputFile);
|
|
1217
|
+
const facts = before.artifacts.map((entry) => ({
|
|
1218
|
+
path: path.join(context.taskRoot, entry.path),
|
|
1219
|
+
bytes: entry.bytes,
|
|
1220
|
+
sha256: entry.sha256,
|
|
1221
|
+
}));
|
|
1222
|
+
await recordFoundryInteractionInput(taskContext(options, current, record, facts), before.artifacts, selected, record.spec.target_entities);
|
|
1223
|
+
assertNotInterrupted(options.signal);
|
|
1224
|
+
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1225
|
+
}
|
|
1226
|
+
const unresolvedInteraction = currentFoundryInteractionState(context, before.artifacts);
|
|
1227
|
+
const hasUnresolvedInteraction = Boolean(unresolvedInteraction &&
|
|
1228
|
+
(currentFoundryQuestions(unresolvedInteraction.state).length ||
|
|
1229
|
+
currentFoundryInvestigations(unresolvedInteraction.state).length));
|
|
1230
|
+
if (hasUnresolvedInteraction && input.authorizationInputFile)
|
|
1231
|
+
throw new FoundryContextError("interaction_decision_pending", "Resolve the current question or investigation before write approval.");
|
|
1050
1232
|
if (input.referenceInputFile) {
|
|
1051
1233
|
if (input.authorizationInputFile || input.semanticInputFile || record.spec.preparation)
|
|
1052
1234
|
throw new FoundryContextError("reference_input_invalid", "Select reference evidence separately from approval, semantic input or explicit cleanup.");
|
|
@@ -1127,8 +1309,21 @@ export function createFoundryFacade(options) {
|
|
|
1127
1309
|
}
|
|
1128
1310
|
const preparation = record.spec.preparation;
|
|
1129
1311
|
const workflow = currentWorkflowState(context, before.artifacts);
|
|
1312
|
+
if (hasUnresolvedInteraction &&
|
|
1313
|
+
(workflow.authorization || !workflow.assessmentRemainingTypes.length))
|
|
1314
|
+
return existing;
|
|
1315
|
+
if (record.spec.repair && !workflow.authorization && !execution.completed.size) {
|
|
1316
|
+
if (!qualified)
|
|
1317
|
+
throw new FoundryContextError("runtime_qualification_required", "Repair preflight requires the qualified installed owners.");
|
|
1318
|
+
await prepareFoundryRepair(context, qualified, before.artifacts, options.authentication ?? { mode: "oauth" });
|
|
1319
|
+
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1320
|
+
}
|
|
1130
1321
|
const references = inspectFoundryReferences(context, before.artifacts);
|
|
1131
|
-
if (!preparation &&
|
|
1322
|
+
if (!preparation &&
|
|
1323
|
+
workflow.assessmentComplete &&
|
|
1324
|
+
workflow.finalization &&
|
|
1325
|
+
references.scope &&
|
|
1326
|
+
!references.verified) {
|
|
1132
1327
|
if (!qualified)
|
|
1133
1328
|
throw new FoundryContextError("runtime_unqualified", "Reference verification requires qualified runtime owners.");
|
|
1134
1329
|
const selected = taskContext(options, current, record, before.artifacts.map((entry) => ({
|
|
@@ -1140,6 +1335,7 @@ export function createFoundryFacade(options) {
|
|
|
1140
1335
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1141
1336
|
}
|
|
1142
1337
|
if (!preparation &&
|
|
1338
|
+
(record.spec.repair || workflow.assessmentComplete) &&
|
|
1143
1339
|
workflow.authorization?.value.status === "sealed" &&
|
|
1144
1340
|
!execution.completed.has(String(workflow.authorization.value.dataset_type))) {
|
|
1145
1341
|
if (!qualified)
|
|
@@ -1217,13 +1413,11 @@ export function createFoundryFacade(options) {
|
|
|
1217
1413
|
await createFoundryRuntime(selected, qualified).materializeRows(facts.map((fact) => fact.path));
|
|
1218
1414
|
assertNotInterrupted(options.signal);
|
|
1219
1415
|
}
|
|
1220
|
-
else if (!preparation &&
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
"dataset-workflow-identity",
|
|
1226
|
-
].includes(artifact.command));
|
|
1416
|
+
else if (!preparation &&
|
|
1417
|
+
workflow.rows &&
|
|
1418
|
+
(workflow.assessmentRemainingTypes.length ||
|
|
1419
|
+
(!workflow.assessmentComplete && !workflow.rows.value.sets.length))) {
|
|
1420
|
+
const selectedArtifacts = before.artifacts;
|
|
1227
1421
|
const facts = selectedArtifacts.map((artifact) => ({
|
|
1228
1422
|
path: path.join(context.taskRoot, artifact.path),
|
|
1229
1423
|
bytes: artifact.bytes,
|
|
@@ -1238,10 +1432,21 @@ export function createFoundryFacade(options) {
|
|
|
1238
1432
|
.filter((fact) => path.basename(fact.path) === "contract-report.json")
|
|
1239
1433
|
.map((fact) => fact.path);
|
|
1240
1434
|
const selected = taskContext(options, current, record, facts);
|
|
1241
|
-
|
|
1435
|
+
const identityReport = workflow.identity?.value.status === "completed" ? workflow.identity.file : undefined;
|
|
1436
|
+
if (workflow.assessmentRemainingTypes.length)
|
|
1437
|
+
await createFoundryRuntime(selected, qualified).assessRows(rows.path, contracts, identityReport, {
|
|
1438
|
+
scopeType: workflow.assessmentRemainingTypes[0],
|
|
1439
|
+
previousAssessment: workflow.assessment?.file,
|
|
1440
|
+
interactionSha256: currentFoundryInteractionState(context, before.artifacts)?.entry.sha256 ?? null,
|
|
1441
|
+
});
|
|
1442
|
+
else
|
|
1443
|
+
await createFoundryRuntime(selected, qualified).assessRows(rows.path, contracts, identityReport, {
|
|
1444
|
+
interactionSha256: currentFoundryInteractionState(context, before.artifacts)?.entry.sha256 ?? null,
|
|
1445
|
+
});
|
|
1242
1446
|
assertNotInterrupted(options.signal);
|
|
1243
1447
|
}
|
|
1244
1448
|
else if (!preparation &&
|
|
1449
|
+
workflow.assessmentComplete &&
|
|
1245
1450
|
(existing.status === "ready" || workflow.identity?.value.status === "blocked") &&
|
|
1246
1451
|
(!workflow.identity || workflow.identity.value.status === "blocked") &&
|
|
1247
1452
|
workflow.rows?.value.sets.some((set) => ["flow", "process"].includes(set.type))) {
|
|
@@ -1276,7 +1481,7 @@ export function createFoundryFacade(options) {
|
|
|
1276
1481
|
}
|
|
1277
1482
|
if (!preparation &&
|
|
1278
1483
|
existing.status === "ready" &&
|
|
1279
|
-
workflow.
|
|
1484
|
+
workflow.assessmentComplete &&
|
|
1280
1485
|
!workflow.finalization &&
|
|
1281
1486
|
(workflow.identity?.value.status === "completed" ||
|
|
1282
1487
|
!workflow.rows?.value.sets.some((set) => ["flow", "process"].includes(set.type)))) {
|
|
@@ -4,6 +4,7 @@ import { type FoundryAuthentication, type VerifiedFoundryIdentity } from "./lib/
|
|
|
4
4
|
import { type QualifiedFoundryRuntime } from "./lib/foundry-runtime-qualification.ts";
|
|
5
5
|
import { type PrepareDerivedFoundryTaskAuthorizationOptions, type TaskApprovalEvidence } from "./lib/foundry-task-authorization.ts";
|
|
6
6
|
import { type CreateFoundryExecutionCapsuleOptions, type FoundryExecutionAdmission, type RehydrateFoundryExecutionAdmissionOptions } from "./lib/foundry-execution-admission.ts";
|
|
7
|
+
import { type FoundryAssessmentOptions } from "./lib/foundry-workflow-assessment.ts";
|
|
7
8
|
import type { SelectedSemanticInput } from "./lib/foundry-semantic-input.ts";
|
|
8
9
|
import type { ArtifactEntry } from "./lib/foundry-task-types.ts";
|
|
9
10
|
export interface FoundryCleanupRequest {
|
|
@@ -20,7 +21,7 @@ export declare function createFoundryRuntime(context: FoundryRuntimeContext, qua
|
|
|
20
21
|
importPackage: (input: string) => Promise<import("./lib/foundry-task-types.ts").JsonRecord>;
|
|
21
22
|
prepareContext: (types: readonly string[]) => Promise<import("./lib/foundry-task-types.ts").JsonRecord>;
|
|
22
23
|
materializeRows: (sources: readonly string[]) => Promise<import("./lib/foundry-task-types.ts").JsonRecord>;
|
|
23
|
-
assessRows: (rows: string, contracts: readonly string[], identityReport?: string) => Promise<import("./lib/foundry-task-types.ts").JsonRecord>;
|
|
24
|
+
assessRows: (rows: string, contracts: readonly string[], identityReport?: string, options?: FoundryAssessmentOptions) => Promise<import("./lib/foundry-task-types.ts").JsonRecord>;
|
|
24
25
|
applySemantic: (entries: readonly ArtifactEntry[], submission: SelectedSemanticInput) => Promise<import("./lib/foundry-task-types.ts").JsonRecord>;
|
|
25
26
|
initializeWorkspace: () => {
|
|
26
27
|
workspace_id: string;
|
|
@@ -46,6 +47,16 @@ export declare function createFoundryRuntime(context: FoundryRuntimeContext, qua
|
|
|
46
47
|
remote_state_code: 0;
|
|
47
48
|
};
|
|
48
49
|
created_at_utc: string;
|
|
50
|
+
repair?: Readonly<{
|
|
51
|
+
kind: string;
|
|
52
|
+
contract: string;
|
|
53
|
+
before: string;
|
|
54
|
+
candidate: string;
|
|
55
|
+
predecessor: Readonly<{
|
|
56
|
+
task_id: string;
|
|
57
|
+
receipt_sha256: string;
|
|
58
|
+
}> | null;
|
|
59
|
+
}>;
|
|
49
60
|
}>;
|
|
50
61
|
job_sha256: string;
|
|
51
62
|
sources: readonly Readonly<{
|
|
@@ -171,9 +182,9 @@ export declare function createFoundryRuntime(context: FoundryRuntimeContext, qua
|
|
|
171
182
|
command_policy: {
|
|
172
183
|
total: number;
|
|
173
184
|
public_operations: readonly ["workspace.init", "doctor", "task.start", "task.status", "task.resume", "workspace.migrate"];
|
|
174
|
-
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" | "init" | "profiles-list" | "route-task" | "storage-check" | "surface-audit" | "task-complete" | "tasks-check" | "tasks-list" | "tidas-handshake" | "workflow-check" | "workspace-map")[];
|
|
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")[];
|
|
175
186
|
internal_only: number;
|
|
176
|
-
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" | "init" | "profiles-list" | "route-task" | "storage-check" | "surface-audit" | "task-complete" | "tasks-check" | "tasks-list" | "tidas-handshake" | "workflow-check" | "workspace-map")[];
|
|
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")[];
|
|
177
188
|
};
|
|
178
189
|
};
|
|
179
190
|
cleanup(request: FoundryCleanupRequest): Promise<import("./lib/foundry-task-types.ts").JsonRecord>;
|
|
@@ -15,7 +15,7 @@ import { readRows } from "./lib/import-curation/internal/runtime-io.js";
|
|
|
15
15
|
import { importFoundryWorkflowPackage } from "./lib/foundry-workflow-import.js";
|
|
16
16
|
import { prepareFoundryWorkflowContext } from "./lib/foundry-workflow-context.js";
|
|
17
17
|
import { materializeFoundryWorkflowRows } from "./lib/foundry-workflow-rows.js";
|
|
18
|
-
import { assessFoundryWorkflowRows } from "./lib/foundry-workflow-assessment.js";
|
|
18
|
+
import { assessFoundryWorkflowRows, } from "./lib/foundry-workflow-assessment.js";
|
|
19
19
|
import { applyFoundrySemanticInput } from "./lib/foundry-workflow-semantic.js";
|
|
20
20
|
/** Application boundary for user workspaces. Repository maintenance stays outside it. */
|
|
21
21
|
export function createFoundryRuntime(context, qualification) {
|
|
@@ -34,7 +34,7 @@ export function createFoundryRuntime(context, qualification) {
|
|
|
34
34
|
importPackage: (input) => importFoundryWorkflowPackage(context, requireQualification(), resolveFoundryInputPath(context, input)),
|
|
35
35
|
prepareContext: (types) => prepareFoundryWorkflowContext(context, requireQualification(), types),
|
|
36
36
|
materializeRows: (sources) => materializeFoundryWorkflowRows(context, sources),
|
|
37
|
-
assessRows: (rows, contracts, identityReport) => assessFoundryWorkflowRows(context, requireQualification(), rows, contracts, identityReport),
|
|
37
|
+
assessRows: (rows, contracts, identityReport, options) => assessFoundryWorkflowRows(context, requireQualification(), rows, contracts, identityReport, options),
|
|
38
38
|
applySemantic: (entries, submission) => applyFoundrySemanticInput(context, requireQualification(), entries, submission),
|
|
39
39
|
initializeWorkspace: () => initializeFoundryWorkspace(context),
|
|
40
40
|
startTask: (options = {}) => {
|
|
@@ -7,7 +7,7 @@ import { taskAuthorizationAllows, taskAuthorizationMatches, taskAuthorizationWai
|
|
|
7
7
|
import { datasetIdentity, detectDatasetType } from "../import-curation/internal/dataset-payload.js";
|
|
8
8
|
import { readRows } from "../import-curation/internal/runtime-io.js";
|
|
9
9
|
import { flowPrewriteIdentityBlockers } from "../import-curation/internal/workflow-identity-preflight.js";
|
|
10
|
-
import { assertExecutionContractSelection,
|
|
10
|
+
import { assertExecutionContractSelection, readNativeDraftHandoff, reserveNativeHandoffDirectory, nativeDraftCommitArguments, } from "./native-draft-handoff.js";
|
|
11
11
|
function commitCommandForDatasetType(datasetType, rowsFile, outDir, { appendOption, resolveTiangongLcaCliBin, resolveTiangongLcaCliCommand, targetUserId = null, allowAccountLocalSupportAndElementary = false, } = {}) {
|
|
12
12
|
const cliPrefix = () => {
|
|
13
13
|
if (resolveTiangongLcaCliCommand) {
|
|
@@ -218,7 +218,7 @@ export function createCommitHandoffCommands({ executionEnvironment = process.env
|
|
|
218
218
|
if (contractFile && fileExists(outDir))
|
|
219
219
|
throw new Error("--execution-contract-file requires a fresh handoff output directory.");
|
|
220
220
|
const native = contractFile && finalRowsFile
|
|
221
|
-
?
|
|
221
|
+
? readNativeDraftHandoff({
|
|
222
222
|
contractFile,
|
|
223
223
|
rowsFile: finalRowsFile,
|
|
224
224
|
datasetType,
|
|
@@ -390,7 +390,7 @@ export function createCommitHandoffCommands({ executionEnvironment = process.env
|
|
|
390
390
|
})()
|
|
391
391
|
: [resolveTiangongLcaCliBin()];
|
|
392
392
|
const commitArgs = native && finalRowsFile && contractFile
|
|
393
|
-
?
|
|
393
|
+
? nativeDraftCommitArguments(cliPrefix, datasetType, finalRowsFile, outDir, contractFile)
|
|
394
394
|
: legacyCommitArgs;
|
|
395
395
|
const verifyArgs = finalRowsFile
|
|
396
396
|
? [
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { parseFoundryCommandSpec } from "../foundry-command-spec.js";
|
|
3
3
|
import { sha256Json } from "../identity-preflight-proof.js";
|
|
4
|
-
import {
|
|
4
|
+
import { readNativeDraftHandoff } from "./native-draft-handoff.js";
|
|
5
5
|
function requireEvidence(condition) {
|
|
6
6
|
if (!condition)
|
|
7
|
-
throw new Error("Native
|
|
7
|
+
throw new Error("Native draft completion evidence is missing or inconsistent.");
|
|
8
8
|
}
|
|
9
9
|
function object(value) {
|
|
10
10
|
requireEvidence(value && typeof value === "object" && !Array.isArray(value));
|
|
11
11
|
return value;
|
|
12
12
|
}
|
|
13
|
-
export function
|
|
13
|
+
export function validateNativeDraftCloseout(input) {
|
|
14
14
|
const resolveFile = (value) => {
|
|
15
15
|
const file = input.resolveFile(value);
|
|
16
16
|
return file ? path.resolve(file) : null;
|
|
@@ -22,8 +22,8 @@ export function validateNativeInsertCloseout(input) {
|
|
|
22
22
|
const binding = object(input.handoff.execution_contract);
|
|
23
23
|
const artifact = object(binding.artifact);
|
|
24
24
|
const contractFile = resolveFile(artifact.path);
|
|
25
|
-
requireEvidence(contractFile
|
|
26
|
-
const native =
|
|
25
|
+
requireEvidence(contractFile);
|
|
26
|
+
const native = readNativeDraftHandoff({
|
|
27
27
|
contractFile,
|
|
28
28
|
rowsFile: input.rowsFile,
|
|
29
29
|
datasetType: input.datasetType,
|
|
@@ -33,6 +33,7 @@ export function validateNativeInsertCloseout(input) {
|
|
|
33
33
|
relativePath: input.relativePath,
|
|
34
34
|
});
|
|
35
35
|
requireEvidence(sha256Json(artifact) === sha256Json(native.artifact) &&
|
|
36
|
+
binding.operation === native.metadata.operation &&
|
|
36
37
|
binding.canonical_sha256 === native.canonical_sha256 &&
|
|
37
38
|
binding.execution_id === native.contract.execution_id &&
|
|
38
39
|
binding.project_ref === native.contract.project_ref);
|
|
@@ -82,6 +83,8 @@ export function validateNativeInsertCloseout(input) {
|
|
|
82
83
|
report.rows.length === actions.length);
|
|
83
84
|
for (const [index, action] of actions.entries()) {
|
|
84
85
|
const row = object(report.rows[index]);
|
|
86
|
+
// A recovered row is a consumed attempt whose exact desired state was proven by readback, so
|
|
87
|
+
// it must satisfy every other check unchanged. Nothing else may substitute for it.
|
|
85
88
|
requireEvidence(row.index === index &&
|
|
86
89
|
row.type === input.datasetType &&
|
|
87
90
|
row.table === action.table &&
|
|
@@ -90,7 +93,8 @@ export function validateNativeInsertCloseout(input) {
|
|
|
90
93
|
row.action_id === action.action_id &&
|
|
91
94
|
row.desired_sha256 === action.desired_sha256 &&
|
|
92
95
|
row.status === "executed" &&
|
|
93
|
-
row.operation ===
|
|
96
|
+
(row.operation === action.expected_operation ||
|
|
97
|
+
row.operation === "recovered_exact_readback") &&
|
|
94
98
|
row.attempt_consumed === true &&
|
|
95
99
|
row.replayed === false &&
|
|
96
100
|
row.readback === "desired_exact");
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
type JsonRecord = Record<string, unknown>;
|
|
2
|
+
export type NativeDraftOperation = "insert" | "save_draft";
|
|
3
|
+
export type NativeDraftContractOperation = NativeDraftOperation | "mixed";
|
|
2
4
|
export declare function assertExecutionContractSelection(options: JsonRecord): void;
|
|
3
5
|
/** Consumer admission only; CLI owns parsing at execution, attempts and readback. */
|
|
4
|
-
export declare function
|
|
6
|
+
export declare function readNativeDraftHandoff(input: {
|
|
5
7
|
contractFile: string;
|
|
6
8
|
rowsFile: string;
|
|
7
9
|
datasetType: string;
|
|
@@ -24,11 +26,11 @@ export declare function readNativeInsertHandoff(input: {
|
|
|
24
26
|
actions: {
|
|
25
27
|
action_id: string;
|
|
26
28
|
desired_sha256: string;
|
|
27
|
-
expected_operation:
|
|
29
|
+
expected_operation: NativeDraftOperation;
|
|
28
30
|
table: string;
|
|
29
31
|
id: string;
|
|
30
32
|
version: string;
|
|
31
|
-
before_sha256: null;
|
|
33
|
+
before_sha256: string | null;
|
|
32
34
|
dependency_action_ids: string[];
|
|
33
35
|
}[];
|
|
34
36
|
};
|
|
@@ -38,10 +40,10 @@ export declare function readNativeInsertHandoff(input: {
|
|
|
38
40
|
canonical_sha256: string;
|
|
39
41
|
execution_id: string;
|
|
40
42
|
project_ref: string;
|
|
41
|
-
operation:
|
|
43
|
+
operation: NativeDraftContractOperation;
|
|
42
44
|
};
|
|
43
45
|
rows_sha256: string;
|
|
44
46
|
};
|
|
45
47
|
export declare function reserveNativeHandoffDirectory(directory: string): void;
|
|
46
|
-
export declare function
|
|
48
|
+
export declare function nativeDraftCommitArguments(prefix: readonly string[], datasetType: string, rowsFile: string, outDir: string, contractFile: string): string[];
|
|
47
49
|
export {};
|