@tiangong-lca/foundry 0.1.10 → 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 +6 -6
- package/docs/architecture.md +6 -6
- package/docs/foundry-task-contracts.md +9 -3
- package/docs/package-distribution-contract.md +6 -4
- package/docs/public-runtime-contract.md +17 -5
- package/docs/runtime-context-contract.md +5 -3
- package/docs/task-authorization-contract.md +5 -3
- package/package-dist/assets/foundry-package-descriptor.json +120 -64
- package/package-dist/scripts/foundry-facade.d.ts +1 -0
- package/package-dist/scripts/foundry-facade.js +165 -31
- package/package-dist/scripts/foundry-runtime.d.ts +2 -1
- package/package-dist/scripts/foundry-runtime.js +2 -2
- 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.js +34 -2
- package/package-dist/scripts/lib/foundry-package-contract.d.ts +3 -3
- package/package-dist/scripts/lib/foundry-package-contract.js +3 -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-task-start-spec.d.ts +11 -0
- package/package-dist/scripts/lib/foundry-task-start-spec.js +36 -0
- package/package-dist/scripts/lib/foundry-task-store.d.ts +1 -1
- 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-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-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 +173 -21
- 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 +2 -1
- package/specs/schemas/foundry-interaction-input.schema.json +173 -0
- package/specs/schemas/foundry-package-descriptor.schema.json +2 -1
- package/specs/schemas/foundry-semantic-input.schema.json +12 -1
- package/specs/schemas/foundry-task-start.schema.json +75 -0
|
@@ -23,6 +23,8 @@ import { completedOwnerScopes, prepareFoundryOwnerExecution, } from "./lib/found
|
|
|
23
23
|
import { executeFoundryOwnerScope } from "./lib/foundry-workflow-execution.js";
|
|
24
24
|
import { inspectFoundryReferences, verifyFoundryReferences, } from "./lib/foundry-workflow-reference-verify.js";
|
|
25
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";
|
|
26
28
|
import { runFoundryWorkflowIdentity } from "./lib/foundry-workflow-identity.js";
|
|
27
29
|
import { finalizeFoundryWorkflow } from "./lib/foundry-workflow-finalize.js";
|
|
28
30
|
import { prepareFoundryRepair, readFoundryRepairPreparation, } from "./lib/foundry-workflow-repair.js";
|
|
@@ -368,12 +370,65 @@ function completionProven(context, record, inspected) {
|
|
|
368
370
|
}
|
|
369
371
|
function taskProjection(operation, context, record, inspected, identity) {
|
|
370
372
|
const artifacts = taskArtifacts(context, inspected);
|
|
371
|
-
|
|
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)
|
|
372
427
|
return createFoundryOperationResult({
|
|
373
428
|
operation,
|
|
374
429
|
status: "completed",
|
|
375
430
|
taskId: record.task_id,
|
|
376
|
-
artifacts,
|
|
431
|
+
artifacts: completedArtifacts(),
|
|
377
432
|
blockers: [],
|
|
378
433
|
nextActions: [],
|
|
379
434
|
runtimeIdentity: identity,
|
|
@@ -460,7 +515,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
460
515
|
operation,
|
|
461
516
|
status: "completed",
|
|
462
517
|
taskId: record.task_id,
|
|
463
|
-
artifacts,
|
|
518
|
+
artifacts: completedArtifacts(),
|
|
464
519
|
blockers: [],
|
|
465
520
|
nextActions: [],
|
|
466
521
|
runtimeIdentity: identity,
|
|
@@ -477,7 +532,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
477
532
|
operation,
|
|
478
533
|
status: noChange ? "completed" : found ? "needs_input" : "ready",
|
|
479
534
|
taskId: record.task_id,
|
|
480
|
-
artifacts,
|
|
535
|
+
artifacts: noChange ? completedArtifacts() : artifacts,
|
|
481
536
|
blockers: noChange || !found
|
|
482
537
|
? []
|
|
483
538
|
: [
|
|
@@ -502,6 +557,30 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
502
557
|
: noPermission(),
|
|
503
558
|
});
|
|
504
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
|
+
}
|
|
505
584
|
const references = inspectFoundryReferences(context, inspected.artifacts);
|
|
506
585
|
const scopeComplete = workflow.rows &&
|
|
507
586
|
(workflow.rows.value.sets.length > 0 || references.scope) &&
|
|
@@ -511,7 +590,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
511
590
|
operation,
|
|
512
591
|
status: "completed",
|
|
513
592
|
taskId: record.task_id,
|
|
514
|
-
artifacts,
|
|
593
|
+
artifacts: completedArtifacts(),
|
|
515
594
|
blockers: [],
|
|
516
595
|
nextActions: [],
|
|
517
596
|
runtimeIdentity: identity,
|
|
@@ -645,15 +724,15 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
645
724
|
});
|
|
646
725
|
const assessment = workflow.assessment?.entry;
|
|
647
726
|
if (assessment) {
|
|
648
|
-
const
|
|
649
|
-
if (!
|
|
650
|
-
typeof
|
|
651
|
-
!("schema" in
|
|
652
|
-
|
|
653
|
-
!("sets" in
|
|
654
|
-
!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))
|
|
655
734
|
throw new FoundryContextError("workflow_assessment_invalid", "Registered assessment metadata is invalid.");
|
|
656
|
-
const pending =
|
|
735
|
+
const pending = workflow.assessment.value.sets.filter((value) => {
|
|
657
736
|
if (!value ||
|
|
658
737
|
typeof value !== "object" ||
|
|
659
738
|
!("curation_counts" in value) ||
|
|
@@ -698,10 +777,13 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
698
777
|
message: `Resolve the current ${set.type} curation and authoring work before a write handoff.`,
|
|
699
778
|
scope: record.task_id,
|
|
700
779
|
})),
|
|
701
|
-
nextActions:
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
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
|
+
],
|
|
705
787
|
runtimeIdentity: identity,
|
|
706
788
|
permissions: noPermission(),
|
|
707
789
|
});
|
|
@@ -710,7 +792,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
710
792
|
? [
|
|
711
793
|
human("review_prepared_rows", "Review the current prepared artifacts and continue the returned task workflow."),
|
|
712
794
|
]
|
|
713
|
-
: record.spec.preparation || !workflow.
|
|
795
|
+
: record.spec.preparation || !workflow.assessmentComplete
|
|
714
796
|
? [resumeCommand(context, record)]
|
|
715
797
|
: [
|
|
716
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."),
|
|
@@ -1037,6 +1119,7 @@ export function createFoundryFacade(options) {
|
|
|
1037
1119
|
artifacts: [
|
|
1038
1120
|
fileArtifact("facade_request_index", requestIndex),
|
|
1039
1121
|
fileArtifact("foundry_job", path.join(context.taskRoot, "foundry-job.json")),
|
|
1122
|
+
...result.artifacts,
|
|
1040
1123
|
],
|
|
1041
1124
|
nextActions: result.next_actions,
|
|
1042
1125
|
runtimeIdentity: result.runtime_identity,
|
|
@@ -1082,6 +1165,16 @@ export function createFoundryFacade(options) {
|
|
|
1082
1165
|
if (input.referenceInputFile !== undefined &&
|
|
1083
1166
|
(typeof input.referenceInputFile !== "string" || !input.referenceInputFile.trim()))
|
|
1084
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.");
|
|
1085
1178
|
current = base();
|
|
1086
1179
|
assertFoundryWorkspaceWrite(current);
|
|
1087
1180
|
const record = loadFoundryFacadeTaskRecord(current, input.taskId, input.actorId);
|
|
@@ -1089,18 +1182,23 @@ export function createFoundryFacade(options) {
|
|
|
1089
1182
|
const qualified = qualification(context, options.runtimeSelection);
|
|
1090
1183
|
const runtime = createFoundryRuntime(context, qualified);
|
|
1091
1184
|
const before = await runtime.inspectTask();
|
|
1092
|
-
if (record.spec.repair &&
|
|
1185
|
+
if (record.spec.repair &&
|
|
1186
|
+
(input.semanticInputFile || input.referenceInputFile || input.interactionInputFile))
|
|
1093
1187
|
throw new FoundryContextError("repair_revision_required", "A repair keeps its before, candidate and contract immutable; changed inputs require an explicit revision.");
|
|
1094
1188
|
assertNotInterrupted(options.signal);
|
|
1095
1189
|
loadFoundryFacadeTaskRecord(current, record.task_id, record.spec.actor_id);
|
|
1096
1190
|
const existing = taskProjection("task.resume", context, record, before, runtimeIdentity(context, qualified));
|
|
1097
|
-
if (input.referenceInputFile
|
|
1191
|
+
if ((input.referenceInputFile || input.interactionInputFile) &&
|
|
1192
|
+
existing.status === "completed")
|
|
1098
1193
|
throw new FoundryContextError("execution_scope_completed", "A completed task cannot replace its reference evidence.");
|
|
1099
1194
|
if (existing.status === "completed" || existing.status === "blocked")
|
|
1100
1195
|
return existing;
|
|
1101
1196
|
const execution = completedOwnerScopes(context, before.artifacts);
|
|
1102
1197
|
if (execution.pending.length) {
|
|
1103
|
-
if (input.authorizationInputFile ||
|
|
1198
|
+
if (input.authorizationInputFile ||
|
|
1199
|
+
input.semanticInputFile ||
|
|
1200
|
+
input.referenceInputFile ||
|
|
1201
|
+
input.interactionInputFile)
|
|
1104
1202
|
throw new FoundryContextError("execution_recovery_required", "Recover the consumed request before submitting changes.");
|
|
1105
1203
|
if (!qualified)
|
|
1106
1204
|
throw new FoundryContextError("runtime_unqualified", "Owner readback requires qualified runtime owners.");
|
|
@@ -1112,6 +1210,25 @@ export function createFoundryFacade(options) {
|
|
|
1112
1210
|
await executeFoundryOwnerScope(selected, qualified, before.artifacts, execution.pending[0], options.authentication);
|
|
1113
1211
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1114
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.");
|
|
1115
1232
|
if (input.referenceInputFile) {
|
|
1116
1233
|
if (input.authorizationInputFile || input.semanticInputFile || record.spec.preparation)
|
|
1117
1234
|
throw new FoundryContextError("reference_input_invalid", "Select reference evidence separately from approval, semantic input or explicit cleanup.");
|
|
@@ -1192,6 +1309,9 @@ export function createFoundryFacade(options) {
|
|
|
1192
1309
|
}
|
|
1193
1310
|
const preparation = record.spec.preparation;
|
|
1194
1311
|
const workflow = currentWorkflowState(context, before.artifacts);
|
|
1312
|
+
if (hasUnresolvedInteraction &&
|
|
1313
|
+
(workflow.authorization || !workflow.assessmentRemainingTypes.length))
|
|
1314
|
+
return existing;
|
|
1195
1315
|
if (record.spec.repair && !workflow.authorization && !execution.completed.size) {
|
|
1196
1316
|
if (!qualified)
|
|
1197
1317
|
throw new FoundryContextError("runtime_qualification_required", "Repair preflight requires the qualified installed owners.");
|
|
@@ -1199,7 +1319,11 @@ export function createFoundryFacade(options) {
|
|
|
1199
1319
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1200
1320
|
}
|
|
1201
1321
|
const references = inspectFoundryReferences(context, before.artifacts);
|
|
1202
|
-
if (!preparation &&
|
|
1322
|
+
if (!preparation &&
|
|
1323
|
+
workflow.assessmentComplete &&
|
|
1324
|
+
workflow.finalization &&
|
|
1325
|
+
references.scope &&
|
|
1326
|
+
!references.verified) {
|
|
1203
1327
|
if (!qualified)
|
|
1204
1328
|
throw new FoundryContextError("runtime_unqualified", "Reference verification requires qualified runtime owners.");
|
|
1205
1329
|
const selected = taskContext(options, current, record, before.artifacts.map((entry) => ({
|
|
@@ -1211,6 +1335,7 @@ export function createFoundryFacade(options) {
|
|
|
1211
1335
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1212
1336
|
}
|
|
1213
1337
|
if (!preparation &&
|
|
1338
|
+
(record.spec.repair || workflow.assessmentComplete) &&
|
|
1214
1339
|
workflow.authorization?.value.status === "sealed" &&
|
|
1215
1340
|
!execution.completed.has(String(workflow.authorization.value.dataset_type))) {
|
|
1216
1341
|
if (!qualified)
|
|
@@ -1288,13 +1413,11 @@ export function createFoundryFacade(options) {
|
|
|
1288
1413
|
await createFoundryRuntime(selected, qualified).materializeRows(facts.map((fact) => fact.path));
|
|
1289
1414
|
assertNotInterrupted(options.signal);
|
|
1290
1415
|
}
|
|
1291
|
-
else if (!preparation &&
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
"dataset-workflow-identity",
|
|
1297
|
-
].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;
|
|
1298
1421
|
const facts = selectedArtifacts.map((artifact) => ({
|
|
1299
1422
|
path: path.join(context.taskRoot, artifact.path),
|
|
1300
1423
|
bytes: artifact.bytes,
|
|
@@ -1309,10 +1432,21 @@ export function createFoundryFacade(options) {
|
|
|
1309
1432
|
.filter((fact) => path.basename(fact.path) === "contract-report.json")
|
|
1310
1433
|
.map((fact) => fact.path);
|
|
1311
1434
|
const selected = taskContext(options, current, record, facts);
|
|
1312
|
-
|
|
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
|
+
});
|
|
1313
1446
|
assertNotInterrupted(options.signal);
|
|
1314
1447
|
}
|
|
1315
1448
|
else if (!preparation &&
|
|
1449
|
+
workflow.assessmentComplete &&
|
|
1316
1450
|
(existing.status === "ready" || workflow.identity?.value.status === "blocked") &&
|
|
1317
1451
|
(!workflow.identity || workflow.identity.value.status === "blocked") &&
|
|
1318
1452
|
workflow.rows?.value.sets.some((set) => ["flow", "process"].includes(set.type))) {
|
|
@@ -1347,7 +1481,7 @@ export function createFoundryFacade(options) {
|
|
|
1347
1481
|
}
|
|
1348
1482
|
if (!preparation &&
|
|
1349
1483
|
existing.status === "ready" &&
|
|
1350
|
-
workflow.
|
|
1484
|
+
workflow.assessmentComplete &&
|
|
1351
1485
|
!workflow.finalization &&
|
|
1352
1486
|
(workflow.identity?.value.status === "completed" ||
|
|
1353
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;
|
|
@@ -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 = {}) => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type FoundryInputFact, type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
2
|
+
import type { ArtifactEntry } from "./foundry-task-types.ts";
|
|
3
|
+
import { type FoundryInteractionInput, type FoundryInteractionState } from "./foundry-interaction-types.ts";
|
|
4
|
+
export { FOUNDRY_INTERACTION_INPUT_SCHEMA, FOUNDRY_INTERACTION_STATE_SCHEMA, FOUNDRY_INTERACTION_COMMAND, FOUNDRY_INTERACTION_REPORT, } from "./foundry-interaction-types.ts";
|
|
5
|
+
export type { FoundryInteractionInput, FoundryInteractionState, } from "./foundry-interaction-types.ts";
|
|
6
|
+
export interface SelectedFoundryInteractionInput {
|
|
7
|
+
readonly spec: FoundryInteractionInput;
|
|
8
|
+
readonly descriptor: FoundryInputFact;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseFoundryInteractionInput(value: unknown): FoundryInteractionInput;
|
|
11
|
+
export declare function advanceFoundryInteractionState(previous: FoundryInteractionState | null, input: FoundryInteractionInput, currentSha256: string | null, availableEvidence: ReadonlySet<string>, allowedTypes: ReadonlySet<string>): FoundryInteractionState;
|
|
12
|
+
export declare function readSelectedFoundryInteractionBytes(fact: FoundryInputFact): Buffer;
|
|
13
|
+
export declare function selectFoundryInteractionInput(context: FoundryRuntimeContext, file: string): SelectedFoundryInteractionInput;
|
|
14
|
+
export declare function assertSelectedFoundryInteractionInput(input: SelectedFoundryInteractionInput): void;
|
|
15
|
+
export declare function currentFoundryInteractionState(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): {
|
|
16
|
+
entry: ArtifactEntry;
|
|
17
|
+
state: FoundryInteractionState;
|
|
18
|
+
} | null;
|
|
19
|
+
export { applicableFoundryInteractionDigest, applicableFoundryInteractionProjection, currentFoundryAssumptions, currentFoundryAssumptionsForType, currentFoundryDecisions, currentFoundryDecisionsForType, currentFoundryInvestigations, currentFoundryQuestions, } from "./foundry-interaction-projection.ts";
|