@tiangong-lca/foundry 0.1.11 → 0.1.13
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 +8 -6
- package/docs/foundry-task-contracts.md +7 -5
- 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 +10 -10
- package/docs/public-runtime-contract.md +14 -8
- package/docs/runtime-context-contract.md +6 -4
- package/docs/task-authorization-contract.md +3 -3
- package/package-dist/assets/foundry-package-descriptor.json +97 -67
- package/package-dist/scripts/foundry-facade.js +321 -22
- package/package-dist/scripts/lib/foundry-interaction-input.d.ts +4 -3
- package/package-dist/scripts/lib/foundry-interaction-input.js +40 -7
- package/package-dist/scripts/lib/foundry-interaction-projection.d.ts +21 -2
- package/package-dist/scripts/lib/foundry-interaction-projection.js +49 -8
- package/package-dist/scripts/lib/foundry-interaction-scope.d.ts +7 -0
- package/package-dist/scripts/lib/foundry-interaction-scope.js +40 -0
- package/package-dist/scripts/lib/foundry-interaction-types.d.ts +5 -0
- package/package-dist/scripts/lib/foundry-native-validation-failure.d.ts +36 -0
- package/package-dist/scripts/lib/foundry-native-validation-failure.js +142 -0
- package/package-dist/scripts/lib/foundry-owner-execution-store.js +6 -13
- package/package-dist/scripts/lib/foundry-package-contract.d.ts +2 -2
- package/package-dist/scripts/lib/foundry-package-contract.js +2 -2
- 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-semantic-interaction.d.ts +11 -1
- package/package-dist/scripts/lib/foundry-semantic-interaction.js +64 -14
- package/package-dist/scripts/lib/foundry-tidas-source.js +4 -4
- package/package-dist/scripts/lib/foundry-workflow-approval-continuation.js +3 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.js +201 -4
- package/package-dist/scripts/lib/foundry-workflow-authorization.js +3 -0
- package/package-dist/scripts/lib/foundry-workflow-interaction.js +22 -3
- package/package-dist/scripts/lib/foundry-workflow-object-scope.d.ts +53 -0
- package/package-dist/scripts/lib/foundry-workflow-object-scope.js +326 -0
- package/package-dist/scripts/lib/foundry-workflow-semantic.d.ts +5 -0
- package/package-dist/scripts/lib/foundry-workflow-semantic.js +200 -6
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
- package/package.json +2 -2
- package/specs/import-profiles.json +1 -1
- package/specs/schemas/foundry-interaction-input.schema.json +29 -2
- package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
- package/specs/schemas/foundry-package-descriptor.schema.json +2 -2
- package/specs/schemas/runtime-qualification.schema.json +1 -1
|
@@ -4,7 +4,7 @@ import fs from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { assertFoundryCacheRootSeparated } from "./lib/foundry-runtime-cache.js";
|
|
6
6
|
import { createFoundryRuntime } from "./foundry-runtime.js";
|
|
7
|
-
import { captureFoundryInput, assertFoundryRuntimeHost, assertFoundryWorkspaceWrite, createFoundryRuntimeContext, FoundryContextError, initializeFoundryWorkspace, pendingFoundryMigration, } from "./lib/foundry-runtime-context.js";
|
|
7
|
+
import { captureFoundryInput, assertFoundryRuntimeHost, assertFoundryWorkspaceWrite, createFoundryRuntimeContext, FoundryContextError, initializeFoundryWorkspace, pendingFoundryMigration, resolveFoundryOutput, } from "./lib/foundry-runtime-context.js";
|
|
8
8
|
import { commandNextActionBindingSha256, createFoundryOperationResult, } from "./lib/foundry-operation-result.js";
|
|
9
9
|
import { loadFoundryFacadeTaskRecord, registerFoundryFacadeTask, } from "./lib/foundry-facade-store.js";
|
|
10
10
|
import { parseFoundryTaskStartSpec, } from "./lib/foundry-task-start-spec.js";
|
|
@@ -18,12 +18,14 @@ import { applyFoundryMigrationAdoption } from "./lib/foundry-migration-adoption.
|
|
|
18
18
|
import { readFoundryMigrationAuthority } from "./lib/foundry-migration-authority.js";
|
|
19
19
|
import { selectFoundryWorkspaceRuntime, } from "./lib/foundry-runtime-selection.js";
|
|
20
20
|
import { datasetTypePlural } from "./lib/import-curation/internal/dataset-types.js";
|
|
21
|
-
import { currentWorkflowState, workflowObject } from "./lib/foundry-workflow-state.js";
|
|
21
|
+
import { currentWorkflowState, readWorkflowArtifact, workflowObject, } from "./lib/foundry-workflow-state.js";
|
|
22
|
+
import { currentNativeValidationFailure } from "./lib/foundry-native-validation-failure.js";
|
|
22
23
|
import { completedOwnerScopes, prepareFoundryOwnerExecution, } from "./lib/foundry-owner-execution-store.js";
|
|
23
24
|
import { executeFoundryOwnerScope } from "./lib/foundry-workflow-execution.js";
|
|
24
25
|
import { inspectFoundryReferences, verifyFoundryReferences, } from "./lib/foundry-workflow-reference-verify.js";
|
|
25
26
|
import { selectFoundrySemanticInput } from "./lib/foundry-semantic-input.js";
|
|
26
|
-
import { currentFoundryInteractionState, currentFoundryQuestions, currentFoundryDecisions, currentFoundryInvestigations, currentFoundryAssumptions, selectFoundryInteractionInput, } from "./lib/foundry-interaction-input.js";
|
|
27
|
+
import { currentFoundryInteractionState, currentFoundryQuestions, currentFoundryDecisions, currentFoundryInvestigations, currentFoundryAssumptions, foundryInteractionObjectKey, applicableFoundryInteractionProjectionForObject, applicableFoundryInteractionDigestForObject, selectFoundryInteractionInput, } from "./lib/foundry-interaction-input.js";
|
|
28
|
+
import { currentFoundryObjectDecisionReassessments, currentFoundryInteractionWriteBlocker, currentFoundryObjectScopes, currentFoundryObjectScopeIsBound, currentFoundryNarrowObjects, indexedFoundryRowAdoptions, } from "./lib/foundry-workflow-object-scope.js";
|
|
27
29
|
import { recordFoundryInteractionInput } from "./lib/foundry-workflow-interaction.js";
|
|
28
30
|
import { runFoundryWorkflowIdentity } from "./lib/foundry-workflow-identity.js";
|
|
29
31
|
import { finalizeFoundryWorkflow } from "./lib/foundry-workflow-finalize.js";
|
|
@@ -34,6 +36,7 @@ import { authorizeFoundryWorkflow } from "./lib/foundry-workflow-authorization.j
|
|
|
34
36
|
import { continueFoundryPreparedApproval } from "./lib/foundry-workflow-approval-continuation.js";
|
|
35
37
|
const maxSpecBytes = 1024 * 1024;
|
|
36
38
|
const maxSeedBytes = 8 * 1024 * 1024;
|
|
39
|
+
const maxQueueBytes = 32 * 1024 * 1024;
|
|
37
40
|
function readCaptured(fact, maxBytes, code) {
|
|
38
41
|
if (fact.bytes > maxBytes)
|
|
39
42
|
throw new FoundryContextError(code, "Selected facade input exceeds its byte limit.");
|
|
@@ -368,11 +371,184 @@ function completionProven(context, record, inspected) {
|
|
|
368
371
|
}
|
|
369
372
|
return false;
|
|
370
373
|
}
|
|
374
|
+
function independentLocalPreparationPending(record, workflow, entries) {
|
|
375
|
+
if (record.spec.repair)
|
|
376
|
+
return false;
|
|
377
|
+
if (record.spec.preparation)
|
|
378
|
+
return !entries.some((entry) => entry.command === "dataset-curation-cleanup");
|
|
379
|
+
return !workflow.rows || workflow.assessmentRemainingTypes.length > 0;
|
|
380
|
+
}
|
|
381
|
+
function currentIndexedQueueBlockers(context, workflow, entries) {
|
|
382
|
+
const blockers = [];
|
|
383
|
+
const actions = [];
|
|
384
|
+
const seenBlockerSha256 = new Set();
|
|
385
|
+
const queueExpected = workflow.rows?.value.sets.some((set) => set.type === "process") ?? false;
|
|
386
|
+
for (const set of workflow.assessment?.value.sets ?? []) {
|
|
387
|
+
if (typeof set.curation_report !== "string")
|
|
388
|
+
continue;
|
|
389
|
+
const curation = entries.find((entry) => entry.command === "dataset-workflow-assessment" &&
|
|
390
|
+
path.join(context.taskRoot, entry.path) === set.curation_report);
|
|
391
|
+
if (!curation)
|
|
392
|
+
continue;
|
|
393
|
+
// Artifact-index paths use '/' on every platform, including Windows.
|
|
394
|
+
const manifest = entries.find((entry) => entry.operation_id === curation.operation_id &&
|
|
395
|
+
entry.path.endsWith("/queue/outputs/curation-queue-manifest.json"));
|
|
396
|
+
if (!manifest) {
|
|
397
|
+
if (queueExpected && ["flow", "process"].includes(String(set.type)))
|
|
398
|
+
throw new FoundryContextError("workflow_queue_invalid", "The registered assessment is missing its curation queue evidence.");
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
const blockerFile = entries.find((entry) => entry.operation_id === curation.operation_id &&
|
|
402
|
+
entry.path.endsWith("/queue/outputs/curation-queue-blockers.jsonl"));
|
|
403
|
+
if (!blockerFile)
|
|
404
|
+
throw new FoundryContextError("workflow_queue_invalid", "The registered curation queue is missing its complete blocker evidence.");
|
|
405
|
+
const manifestFile = path.join(context.taskRoot, manifest.path);
|
|
406
|
+
const detailsFile = path.join(context.taskRoot, blockerFile.path);
|
|
407
|
+
const report = workflowObject(JSON.parse(readCaptured({ path: manifestFile, bytes: manifest.bytes, sha256: manifest.sha256 }, maxQueueBytes, "workflow_queue_invalid").toString("utf8")));
|
|
408
|
+
if (report.status !== "blocked")
|
|
409
|
+
continue;
|
|
410
|
+
const reportFiles = workflowObject(report.files);
|
|
411
|
+
const reportCounts = workflowObject(report.counts);
|
|
412
|
+
if (report.schema_version !== 1 ||
|
|
413
|
+
reportFiles.manifest !== manifestFile ||
|
|
414
|
+
reportFiles.blockers !== detailsFile ||
|
|
415
|
+
!Array.isArray(report.blockers) ||
|
|
416
|
+
!report.blockers.length ||
|
|
417
|
+
reportCounts.blockers !== report.blockers.length)
|
|
418
|
+
throw new FoundryContextError("workflow_queue_invalid", "The registered curation queue blocker manifest is invalid.");
|
|
419
|
+
const recorded = report.blockers;
|
|
420
|
+
let blockerRows;
|
|
421
|
+
try {
|
|
422
|
+
blockerRows = readCaptured({ path: detailsFile, bytes: blockerFile.bytes, sha256: blockerFile.sha256 }, maxQueueBytes, "workflow_queue_invalid")
|
|
423
|
+
.toString("utf8")
|
|
424
|
+
.split(/\r?\n/u)
|
|
425
|
+
.filter((line) => line.length > 0)
|
|
426
|
+
.map((line) => JSON.parse(line));
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
throw new FoundryContextError("workflow_queue_invalid", "The registered curation queue blocker file is invalid or changed.");
|
|
430
|
+
}
|
|
431
|
+
if (JSON.stringify(blockerRows) !== JSON.stringify(recorded))
|
|
432
|
+
throw new FoundryContextError("workflow_queue_invalid", "The registered curation queue blocker file does not match its manifest.");
|
|
433
|
+
if (seenBlockerSha256.has(blockerFile.sha256))
|
|
434
|
+
continue;
|
|
435
|
+
seenBlockerSha256.add(blockerFile.sha256);
|
|
436
|
+
const missing = recorded
|
|
437
|
+
.map(workflowObject)
|
|
438
|
+
.filter((item) => item.code === "process_flow_reference_unresolved")
|
|
439
|
+
.reduce((total, item) => {
|
|
440
|
+
const refs = workflowObject(item.details).missing_flow_refs;
|
|
441
|
+
return total + (Array.isArray(refs) ? refs.length : 0);
|
|
442
|
+
}, 0);
|
|
443
|
+
const scope = missing ? "process" : String(set.type);
|
|
444
|
+
const message = missing
|
|
445
|
+
? `Selected Process data has ${missing} unresolved Flow reference occurrence${missing === 1 ? "" : "s"}: the cited Flow evidence is absent from the selected inputs and has no verified external declaration. Process review is blocked; unrelated records can continue. Provide the cited Flow evidence or verified references, or keep the gap open. Adding selected sources requires a new task revision because this task's inputs are frozen. Full IDs and paths: ${detailsFile}.`
|
|
446
|
+
: `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
|
+
blockers.push({ code: "curation_queue_blocked", message, scope });
|
|
448
|
+
actions.push(human("review_queue_blockers", message));
|
|
449
|
+
}
|
|
450
|
+
return { blockers, actions };
|
|
451
|
+
}
|
|
452
|
+
function scopedAuthoringPresentation(context, entries, workflow, interaction, objects, reassessments, staleObjects) {
|
|
453
|
+
const narrow = currentFoundryNarrowObjects(interaction.state);
|
|
454
|
+
const artifacts = [];
|
|
455
|
+
const actions = [];
|
|
456
|
+
const blockers = [];
|
|
457
|
+
for (const item of staleObjects) {
|
|
458
|
+
blockers.push({
|
|
459
|
+
code: "interaction_object_evidence_changed",
|
|
460
|
+
message: `The reviewed ${item.dataset_type} changed without a proven link to the earlier decision. Recheck only this record and its proven dependents. Record ID: ${item.entity_id}; version: ${item.version}.`,
|
|
461
|
+
scope: `${item.dataset_type}:${item.entity_id}`,
|
|
462
|
+
});
|
|
463
|
+
actions.push(human("review_object_scope", `The earlier answer may no longer fit this ${item.dataset_type}. Recheck its current row and source evidence before using that answer. Record ID: ${item.entity_id}; version: ${item.version}.`));
|
|
464
|
+
}
|
|
465
|
+
for (const item of reassessments) {
|
|
466
|
+
blockers.push({
|
|
467
|
+
code: "interaction_object_decision_changed",
|
|
468
|
+
message: `A newer answer for this ${item.dataset_type} has not been applied to its current row. Review it before authorization. Record ID: ${item.entity_id}; version: ${item.version}; decision ID: ${item.decision_id}.`,
|
|
469
|
+
scope: `${item.dataset_type}:${item.entity_id}`,
|
|
470
|
+
});
|
|
471
|
+
actions.push(human("review_corrected_object_decision", `A newer answer for this ${item.dataset_type} still needs to be reflected in the data. Check its current source evidence, then submit matching semantic work. If no matching work remains, start a revised task. Other records can continue. Record ID: ${item.entity_id}; version: ${item.version}; decision ID: ${item.decision_id}.`));
|
|
472
|
+
}
|
|
473
|
+
if (!narrow.length || !workflow.assessment)
|
|
474
|
+
return { artifacts, actions, blockers, types: [] };
|
|
475
|
+
const narrowTypes = new Set(narrow.map((item) => item.dataset_type));
|
|
476
|
+
const reassessmentKeys = new Set(reassessments.map((item) => JSON.stringify([item.dataset_type, item.entity_id, item.version])));
|
|
477
|
+
const staleKeys = new Set(staleObjects.map((item) => JSON.stringify([item.dataset_type, item.entity_id, item.version])));
|
|
478
|
+
let shown = 0;
|
|
479
|
+
for (const set of workflow.assessment.value.sets) {
|
|
480
|
+
const type = String(set.type);
|
|
481
|
+
if (!narrowTypes.has(type))
|
|
482
|
+
continue;
|
|
483
|
+
for (const raw of Array.isArray(set.decisions) ? set.decisions : []) {
|
|
484
|
+
const decision = workflowObject(raw);
|
|
485
|
+
if (typeof decision.kind !== "string" || typeof decision.task !== "string")
|
|
486
|
+
continue;
|
|
487
|
+
actions.push(human(`review_${decision.kind}_decisions`, `A ${decision.kind} decision batch needs review. Check each affected record's evidence and resolve its pending questions before submitting the batch. Registered task: ${decision.task}; status: ${String(decision.status)}.`));
|
|
488
|
+
}
|
|
489
|
+
const manifestFile = String(set.authoring_manifest);
|
|
490
|
+
const manifestEntry = entries.find((entry) => resolveFoundryOutput(context, entry.path) === manifestFile);
|
|
491
|
+
if (!manifestEntry)
|
|
492
|
+
throw new FoundryContextError("workflow_assessment_invalid", "Current object work has no registered authoring manifest.");
|
|
493
|
+
const manifest = readWorkflowArtifact(context, manifestEntry).value;
|
|
494
|
+
if (!Array.isArray(manifest.tasks))
|
|
495
|
+
throw new FoundryContextError("workflow_assessment_invalid", "Current authoring manifest has no bounded task list.");
|
|
496
|
+
for (const raw of manifest.tasks) {
|
|
497
|
+
if (shown >= 64) {
|
|
498
|
+
actions.push(human("review_remaining_object_work", `More object work is indexed at ${manifestFile}; inspect its exact task identities before continuing.`));
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
const task = workflowObject(raw);
|
|
502
|
+
const files = workflowObject(task.files);
|
|
503
|
+
const taskFile = path.resolve(workflow.assessment.value.owner_base, String(files.task_json));
|
|
504
|
+
const taskEntry = entries.find((entry) => resolveFoundryOutput(context, entry.path) === taskFile);
|
|
505
|
+
if (!taskEntry)
|
|
506
|
+
throw new FoundryContextError("workflow_assessment_invalid", "Current object work has no registered authoring task.");
|
|
507
|
+
const registered = readWorkflowArtifact(context, taskEntry).value;
|
|
508
|
+
const entity = workflowObject(registered.entity);
|
|
509
|
+
if (entity.dataset_type !== type ||
|
|
510
|
+
typeof entity.entity_id !== "string" ||
|
|
511
|
+
typeof entity.version !== "string")
|
|
512
|
+
throw new FoundryContextError("workflow_assessment_invalid", "Current authoring task has no exact object identity.");
|
|
513
|
+
const current = objects.get(foundryInteractionObjectKey(type, entity.entity_id, entity.version)) ?? null;
|
|
514
|
+
const projection = applicableFoundryInteractionProjectionForObject(interaction.state, type, entity.entity_id, entity.version);
|
|
515
|
+
const decisionCurrent = !reassessmentKeys.has(JSON.stringify([type, entity.entity_id, entity.version]));
|
|
516
|
+
const bound = !staleKeys.has(JSON.stringify([type, entity.entity_id, entity.version]));
|
|
517
|
+
artifacts.push(inlineArtifact("object_interaction_context", {
|
|
518
|
+
...projection,
|
|
519
|
+
work_item_sha256: taskEntry.sha256,
|
|
520
|
+
current_row_sha256: current?.row_sha256 ?? null,
|
|
521
|
+
source_state_sha256: interaction.entry.sha256,
|
|
522
|
+
applicable_digest: applicableFoundryInteractionDigestForObject(interaction.state, type, entity.entity_id, entity.version),
|
|
523
|
+
evidence_current: bound,
|
|
524
|
+
decision_current: decisionCurrent,
|
|
525
|
+
}));
|
|
526
|
+
shown += 1;
|
|
527
|
+
if (bound &&
|
|
528
|
+
registered.status === "ready_for_ai_authoring" &&
|
|
529
|
+
!projection.pending_questions.length &&
|
|
530
|
+
!projection.investigations.length) {
|
|
531
|
+
actions.push(human("review_semantic_work", `This ${type} has independent authoring work ready. Review its remaining gaps and source evidence in the registered task and matching object_interaction_context, then cite only decisions that apply to this record. Record ID: ${entity.entity_id}; version: ${entity.version}; task: ${taskFile}. This does not grant write permission.`));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return { artifacts, actions, blockers, types: [...narrowTypes] };
|
|
536
|
+
}
|
|
371
537
|
function taskProjection(operation, context, record, inspected, identity) {
|
|
372
538
|
const artifacts = taskArtifacts(context, inspected);
|
|
373
539
|
const interaction = currentFoundryInteractionState(context, inspected.artifacts);
|
|
374
540
|
const pendingQuestions = interaction ? currentFoundryQuestions(interaction.state) : [];
|
|
375
541
|
const investigations = interaction ? currentFoundryInvestigations(interaction.state) : [];
|
|
542
|
+
const narrow = interaction ? currentFoundryNarrowObjects(interaction.state) : [];
|
|
543
|
+
const objectAdoptions = interaction && narrow.length ? indexedFoundryRowAdoptions(context, inspected.artifacts) : [];
|
|
544
|
+
const objectScopes = narrow.length
|
|
545
|
+
? currentFoundryObjectScopes(context, inspected.artifacts)
|
|
546
|
+
: new Map();
|
|
547
|
+
const reassessments = interaction
|
|
548
|
+
? currentFoundryObjectDecisionReassessments(interaction.state, objectScopes, objectAdoptions)
|
|
549
|
+
: [];
|
|
550
|
+
const staleObjects = narrow.filter((item) => !currentFoundryObjectScopeIsBound(context, inspected.artifacts, interaction.state, objectScopes, item.dataset_type, item.entity_id, item.version, objectAdoptions));
|
|
551
|
+
const objectEvidenceCurrent = staleObjects.length === 0;
|
|
376
552
|
if (record.spec.brief)
|
|
377
553
|
artifacts.push(inlineArtifact("task_brief", record.spec.brief));
|
|
378
554
|
if (interaction)
|
|
@@ -396,6 +572,28 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
396
572
|
? currentFoundryDecisions(interaction.state).map((answer) => ({
|
|
397
573
|
question_id: answer.question_id,
|
|
398
574
|
dataset_type: questions.get(String(answer.question_id))?.dataset_type ?? null,
|
|
575
|
+
...(questions.get(String(answer.question_id))?.object_scope
|
|
576
|
+
? {
|
|
577
|
+
object_scope: questions.get(String(answer.question_id))?.object_scope,
|
|
578
|
+
applied_to: objectAdoptions
|
|
579
|
+
.filter((adoption) => adoption.decision_ids.includes(String(answer.decision_id)))
|
|
580
|
+
.filter((adoption) => {
|
|
581
|
+
const scope = questions.get(String(answer.question_id))?.object_scope;
|
|
582
|
+
return (scope &&
|
|
583
|
+
adoption.dataset_type ===
|
|
584
|
+
questions.get(String(answer.question_id))?.dataset_type &&
|
|
585
|
+
adoption.object_scope.entity_id === scope.entity_id &&
|
|
586
|
+
adoption.object_scope.version === scope.version);
|
|
587
|
+
})
|
|
588
|
+
.slice(-16)
|
|
589
|
+
.map((adoption) => ({
|
|
590
|
+
work_item_sha256: adoption.work_item_sha256,
|
|
591
|
+
before_row_sha256: adoption.before_row_sha256,
|
|
592
|
+
after_row_sha256: adoption.after_row_sha256,
|
|
593
|
+
semantic_result_sha256: adoption.semantic_result_sha256,
|
|
594
|
+
})),
|
|
595
|
+
}
|
|
596
|
+
: {}),
|
|
399
597
|
impact: questions.get(String(answer.question_id))?.impact ?? null,
|
|
400
598
|
raw_answer_sha256: createHash("sha256").update(String(answer.raw_answer)).digest("hex"),
|
|
401
599
|
adopted_decision: answer.adopted_decision,
|
|
@@ -408,6 +606,7 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
408
606
|
unresolved_questions: [...pendingQuestions, ...investigations].map((question) => ({
|
|
409
607
|
id: question.id,
|
|
410
608
|
dataset_type: question.dataset_type,
|
|
609
|
+
...(question.object_scope ? { object_scope: question.object_scope } : {}),
|
|
411
610
|
missing: question.missing,
|
|
412
611
|
impact: question.impact,
|
|
413
612
|
ask: question.ask,
|
|
@@ -423,7 +622,10 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
423
622
|
: artifacts;
|
|
424
623
|
if (completionProven(context, record, inspected) &&
|
|
425
624
|
!pendingQuestions.length &&
|
|
426
|
-
!investigations.length
|
|
625
|
+
!investigations.length &&
|
|
626
|
+
!reassessments.length &&
|
|
627
|
+
objectEvidenceCurrent &&
|
|
628
|
+
!currentFoundryInteractionWriteBlocker(context, inspected.artifacts))
|
|
427
629
|
return createFoundryOperationResult({
|
|
428
630
|
operation,
|
|
429
631
|
status: "completed",
|
|
@@ -497,6 +699,42 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
497
699
|
});
|
|
498
700
|
}
|
|
499
701
|
const workflow = currentWorkflowState(context, inspected.artifacts);
|
|
702
|
+
const queueIssues = currentIndexedQueueBlockers(context, workflow, inspected.artifacts);
|
|
703
|
+
const nativeFailure = currentNativeValidationFailure(context, inspected.artifacts, workflow.rows
|
|
704
|
+
? {
|
|
705
|
+
file: workflow.rows.file,
|
|
706
|
+
sha256: workflow.rows.entry.sha256,
|
|
707
|
+
sets: workflow.rows.value.sets,
|
|
708
|
+
}
|
|
709
|
+
: null);
|
|
710
|
+
if (nativeFailure) {
|
|
711
|
+
const report = nativeFailure.result;
|
|
712
|
+
const type = String(report.dataset_type);
|
|
713
|
+
const label = `${type.slice(0, 1).toUpperCase()}${type.slice(1)}`;
|
|
714
|
+
const code = String(report.diagnostic_code);
|
|
715
|
+
const detail = String(report.diagnostic_message);
|
|
716
|
+
const normalized = detail.replace(/\s+/gu, " ").trim();
|
|
717
|
+
const preview = normalized.length > 240 ? `${normalized.slice(0, 237)}…` : normalized;
|
|
718
|
+
const rowCount = Number(report.row_count);
|
|
719
|
+
const affectedRows = `${rowCount} selected ${label} row${rowCount === 1 ? "" : "s"}`;
|
|
720
|
+
const failureKind = report.exit_class === "io"
|
|
721
|
+
? `${context.platform.startsWith("win32") ? "Windows " : ""}file I/O`
|
|
722
|
+
: "native validation";
|
|
723
|
+
const message = `Native ${label} validation stopped on ${failureKind} (${report.exit_class}/${code}): ${preview} The ${affectedRows} remain unassessed; no write can proceed. Inspect the complete indexed diagnostic at ${nativeFailure.file}, correct the native runtime or filesystem failure, and start an explicitly reviewed task revision under the replacement runtime.`;
|
|
724
|
+
return createFoundryOperationResult({
|
|
725
|
+
operation,
|
|
726
|
+
status: "blocked",
|
|
727
|
+
taskId: record.task_id,
|
|
728
|
+
artifacts,
|
|
729
|
+
blockers: [
|
|
730
|
+
{ code: "native_validation_failed", message, scope: type },
|
|
731
|
+
...queueIssues.blockers,
|
|
732
|
+
],
|
|
733
|
+
nextActions: [human("repair_native_validation", message), ...queueIssues.actions],
|
|
734
|
+
runtimeIdentity: identity,
|
|
735
|
+
permissions: noPermission(),
|
|
736
|
+
});
|
|
737
|
+
}
|
|
500
738
|
if (record.spec.repair && execution.verified.size) {
|
|
501
739
|
if (execution.requests.length !== 1 || execution.verified.size !== 1)
|
|
502
740
|
throw new FoundryContextError("repair_execution_mismatch", "A repair task must retain one exact verified execution scope.");
|
|
@@ -557,8 +795,18 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
557
795
|
: noPermission(),
|
|
558
796
|
});
|
|
559
797
|
}
|
|
560
|
-
|
|
561
|
-
|
|
798
|
+
const scoped = interaction
|
|
799
|
+
? scopedAuthoringPresentation(context, inspected.artifacts, workflow, interaction, objectScopes, reassessments, staleObjects)
|
|
800
|
+
: { artifacts: [], actions: [], blockers: [], types: [] };
|
|
801
|
+
artifacts.push(...scoped.artifacts);
|
|
802
|
+
if (pendingQuestions.length || investigations.length || scoped.blockers.length) {
|
|
803
|
+
const describe = (question) => {
|
|
804
|
+
const object = question.object_scope;
|
|
805
|
+
const target = object
|
|
806
|
+
? ` Affected ${String(question.dataset_type)}: ID ${object.entity_id}, version ${object.version}. The indexed task artifacts retain its exact row and source evidence.`
|
|
807
|
+
: "";
|
|
808
|
+
return `Question: ${String(question.ask)} Missing information: ${String(question.missing)} Why it matters: ${String(question.impact)} Suggested next step: ${String(question.recommendation)}${target}`;
|
|
809
|
+
};
|
|
562
810
|
const askActions = pendingQuestions.map((question) => human("answer_current_question", `${describe(question)}${Array.isArray(question.choices) && question.choices.length ? ` ${question.choices.join(" / ")}` : ""}`));
|
|
563
811
|
const investigationIds = new Set(investigations.map((question) => String(question.id)));
|
|
564
812
|
return createFoundryOperationResult({
|
|
@@ -566,21 +814,56 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
566
814
|
status: "needs_input",
|
|
567
815
|
taskId: record.task_id,
|
|
568
816
|
artifacts,
|
|
569
|
-
blockers: [
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
817
|
+
blockers: [
|
|
818
|
+
...[...pendingQuestions, ...investigations].map((question) => ({
|
|
819
|
+
code: investigationIds.has(String(question.id))
|
|
820
|
+
? "interaction_investigation_pending"
|
|
821
|
+
: "interaction_decision_pending",
|
|
822
|
+
message: `${String(question.missing)} ${String(question.impact)}`,
|
|
823
|
+
scope: question.object_scope
|
|
824
|
+
? `${String(question.dataset_type)}:${String(question.object_scope.entity_id)}`
|
|
825
|
+
: String(question.dataset_type ?? record.task_id),
|
|
826
|
+
})),
|
|
827
|
+
...queueIssues.blockers,
|
|
828
|
+
...scoped.blockers,
|
|
829
|
+
],
|
|
576
830
|
nextActions: [
|
|
577
831
|
...askActions,
|
|
578
|
-
...
|
|
832
|
+
...queueIssues.actions,
|
|
833
|
+
...scoped.actions,
|
|
834
|
+
...(independentLocalPreparationPending(record, workflow, inspected.artifacts)
|
|
835
|
+
? [resumeCommand(context, record)]
|
|
836
|
+
: []),
|
|
579
837
|
],
|
|
580
838
|
runtimeIdentity: identity,
|
|
581
839
|
permissions: noPermission(),
|
|
582
840
|
});
|
|
583
841
|
}
|
|
842
|
+
const writeBlocker = workflow.finalization
|
|
843
|
+
? currentFoundryInteractionWriteBlocker(context, inspected.artifacts)
|
|
844
|
+
: null;
|
|
845
|
+
if (writeBlocker)
|
|
846
|
+
return createFoundryOperationResult({
|
|
847
|
+
operation,
|
|
848
|
+
status: "needs_input",
|
|
849
|
+
taskId: record.task_id,
|
|
850
|
+
artifacts,
|
|
851
|
+
blockers: [
|
|
852
|
+
...queueIssues.blockers,
|
|
853
|
+
{
|
|
854
|
+
code: writeBlocker.code,
|
|
855
|
+
message: writeBlocker.message,
|
|
856
|
+
scope: writeBlocker.scope ?? record.task_id,
|
|
857
|
+
},
|
|
858
|
+
],
|
|
859
|
+
nextActions: [
|
|
860
|
+
...queueIssues.actions,
|
|
861
|
+
...scoped.actions,
|
|
862
|
+
human("review_unadopted_object_decision", `${writeBlocker.message} If this task has no matching semantic work left, start a revised task with the current source evidence.`),
|
|
863
|
+
],
|
|
864
|
+
runtimeIdentity: identity,
|
|
865
|
+
permissions: noPermission(),
|
|
866
|
+
});
|
|
584
867
|
const references = inspectFoundryReferences(context, inspected.artifacts);
|
|
585
868
|
const scopeComplete = workflow.rows &&
|
|
586
869
|
(workflow.rows.value.sets.length > 0 || references.scope) &&
|
|
@@ -772,15 +1055,24 @@ function taskProjection(operation, context, record, inspected, identity) {
|
|
|
772
1055
|
status: "needs_input",
|
|
773
1056
|
taskId: record.task_id,
|
|
774
1057
|
artifacts,
|
|
775
|
-
blockers:
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
1058
|
+
blockers: [
|
|
1059
|
+
...queueIssues.blockers,
|
|
1060
|
+
...pending.map((set) => ({
|
|
1061
|
+
code: "curation_requires_input",
|
|
1062
|
+
message: `Resolve the current ${set.type} curation and authoring work before a write handoff.`,
|
|
1063
|
+
scope: record.task_id,
|
|
1064
|
+
})),
|
|
1065
|
+
],
|
|
780
1066
|
nextActions: [
|
|
1067
|
+
...queueIssues.actions,
|
|
1068
|
+
...scoped.actions,
|
|
781
1069
|
...pending.flatMap((set) => [
|
|
782
|
-
|
|
783
|
-
|
|
1070
|
+
...(!scoped.types.includes(set.type)
|
|
1071
|
+
? [
|
|
1072
|
+
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.`),
|
|
1073
|
+
]
|
|
1074
|
+
: []),
|
|
1075
|
+
...(!scoped.types.includes(set.type) ? (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
1076
|
]),
|
|
785
1077
|
...(workflow.assessmentRemainingTypes.length ? [resumeCommand(context, record)] : []),
|
|
786
1078
|
],
|
|
@@ -1245,6 +1537,9 @@ export function createFoundryFacade(options) {
|
|
|
1245
1537
|
return taskProjection("task.resume", context, record, await runtime.inspectTask(), runtimeIdentity(context, qualified));
|
|
1246
1538
|
}
|
|
1247
1539
|
if (input.authorizationInputFile) {
|
|
1540
|
+
const interactionBlocker = currentFoundryInteractionWriteBlocker(context, before.artifacts);
|
|
1541
|
+
if (interactionBlocker)
|
|
1542
|
+
throw new FoundryContextError(interactionBlocker.code, interactionBlocker.message);
|
|
1248
1543
|
if (input.semanticInputFile || record.spec.preparation)
|
|
1249
1544
|
throw new FoundryContextError("task_authorization_input_invalid", "Submit approval separately from semantic input or explicit cleanup.");
|
|
1250
1545
|
if (!qualified)
|
|
@@ -1309,8 +1604,12 @@ export function createFoundryFacade(options) {
|
|
|
1309
1604
|
}
|
|
1310
1605
|
const preparation = record.spec.preparation;
|
|
1311
1606
|
const workflow = currentWorkflowState(context, before.artifacts);
|
|
1607
|
+
if ((workflow.authorization || workflow.preparedApproval) &&
|
|
1608
|
+
currentFoundryInteractionWriteBlocker(context, before.artifacts))
|
|
1609
|
+
return existing;
|
|
1312
1610
|
if (hasUnresolvedInteraction &&
|
|
1313
|
-
(workflow.authorization ||
|
|
1611
|
+
(workflow.authorization ||
|
|
1612
|
+
!independentLocalPreparationPending(record, workflow, before.artifacts)))
|
|
1314
1613
|
return existing;
|
|
1315
1614
|
if (record.spec.repair && !workflow.authorization && !execution.completed.size) {
|
|
1316
1615
|
if (!qualified)
|
|
@@ -2,13 +2,14 @@ import { type FoundryInputFact, type FoundryRuntimeContext } from "./foundry-run
|
|
|
2
2
|
import type { ArtifactEntry } from "./foundry-task-types.ts";
|
|
3
3
|
import { type FoundryInteractionInput, type FoundryInteractionState } from "./foundry-interaction-types.ts";
|
|
4
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";
|
|
5
|
+
export type { FoundryInteractionInput, FoundryInteractionObjectScope, FoundryInteractionState, } from "./foundry-interaction-types.ts";
|
|
6
|
+
export { foundryInteractionObjectKey, foundryInteractionObjectProofKey, } from "./foundry-interaction-scope.ts";
|
|
6
7
|
export interface SelectedFoundryInteractionInput {
|
|
7
8
|
readonly spec: FoundryInteractionInput;
|
|
8
9
|
readonly descriptor: FoundryInputFact;
|
|
9
10
|
}
|
|
10
11
|
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 advanceFoundryInteractionState(previous: FoundryInteractionState | null, input: FoundryInteractionInput, currentSha256: string | null, availableEvidence: ReadonlySet<string>, allowedTypes: ReadonlySet<string>, verifiedObjectScopes?: ReadonlySet<string>): FoundryInteractionState;
|
|
12
13
|
export declare function readSelectedFoundryInteractionBytes(fact: FoundryInputFact): Buffer;
|
|
13
14
|
export declare function selectFoundryInteractionInput(context: FoundryRuntimeContext, file: string): SelectedFoundryInteractionInput;
|
|
14
15
|
export declare function assertSelectedFoundryInteractionInput(input: SelectedFoundryInteractionInput): void;
|
|
@@ -16,4 +17,4 @@ export declare function currentFoundryInteractionState(context: FoundryRuntimeCo
|
|
|
16
17
|
entry: ArtifactEntry;
|
|
17
18
|
state: FoundryInteractionState;
|
|
18
19
|
} | null;
|
|
19
|
-
export { applicableFoundryInteractionDigest, applicableFoundryInteractionProjection, currentFoundryAssumptions, currentFoundryAssumptionsForType, currentFoundryDecisions, currentFoundryDecisionsForType, currentFoundryInvestigations, currentFoundryQuestions, } from "./foundry-interaction-projection.ts";
|
|
20
|
+
export { applicableFoundryInteractionDigest, applicableFoundryInteractionDigestForObject, applicableFoundryInteractionProjection, applicableFoundryInteractionProjectionForObject, currentFoundryAssumptions, currentFoundryAssumptionsForObject, currentFoundryAssumptionsForType, currentFoundryDecisions, currentFoundryDecisionsForObject, currentFoundryDecisionsForType, currentFoundryInvestigations, currentFoundryInvestigationsForObject, currentFoundryQuestions, currentFoundryQuestionsForObject, foundryInteractionEventAppliesToObject, } from "./foundry-interaction-projection.ts";
|
|
@@ -5,7 +5,9 @@ import { captureFoundryInput, FoundryContextError, } from "./foundry-runtime-con
|
|
|
5
5
|
import { assertNotFoundrySessionFile, migrationCredentialPath } from "./foundry-private-path.js";
|
|
6
6
|
import { readWorkflowArtifact } from "./foundry-workflow-state.js";
|
|
7
7
|
import { FOUNDRY_INTERACTION_INPUT_SCHEMA, FOUNDRY_INTERACTION_STATE_SCHEMA, FOUNDRY_INTERACTION_COMMAND, FOUNDRY_INTERACTION_REPORT, } from "./foundry-interaction-types.js";
|
|
8
|
+
import { foundryInteractionObjectProofKey, sameFoundryInteractionScope, } from "./foundry-interaction-scope.js";
|
|
8
9
|
export { FOUNDRY_INTERACTION_INPUT_SCHEMA, FOUNDRY_INTERACTION_STATE_SCHEMA, FOUNDRY_INTERACTION_COMMAND, FOUNDRY_INTERACTION_REPORT, } from "./foundry-interaction-types.js";
|
|
10
|
+
export { foundryInteractionObjectKey, foundryInteractionObjectProofKey, } from "./foundry-interaction-scope.js";
|
|
9
11
|
const idPattern = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,255}$/u;
|
|
10
12
|
const taskPattern = /^task-[0-9a-f]{64}-r\d{4}$/u;
|
|
11
13
|
const shaPattern = /^[0-9a-f]{64}$/u;
|
|
@@ -61,6 +63,19 @@ function datasetType(value) {
|
|
|
61
63
|
invalid("Question or assumption dataset type is invalid.");
|
|
62
64
|
return value;
|
|
63
65
|
}
|
|
66
|
+
function objectScope(item, type) {
|
|
67
|
+
if (!Object.hasOwn(item, "object_scope"))
|
|
68
|
+
return undefined;
|
|
69
|
+
if (type === null || type === "support")
|
|
70
|
+
invalid("An object scope requires one concrete dataset type.");
|
|
71
|
+
const scope = record(item.object_scope);
|
|
72
|
+
exact(scope, ["entity_id", "version", "row_sha256"]);
|
|
73
|
+
const entityId = identifier(scope.entity_id, "Object entity id");
|
|
74
|
+
const version = identifier(scope.version, "Object version");
|
|
75
|
+
if (typeof scope.row_sha256 !== "string" || !shaPattern.test(scope.row_sha256))
|
|
76
|
+
invalid("Object row SHA-256 is invalid.");
|
|
77
|
+
return Object.freeze({ entity_id: entityId, version, row_sha256: scope.row_sha256 });
|
|
78
|
+
}
|
|
64
79
|
function event(value) {
|
|
65
80
|
const item = record(value);
|
|
66
81
|
if (item.kind === "question") {
|
|
@@ -75,16 +90,20 @@ function event(value) {
|
|
|
75
90
|
"choices",
|
|
76
91
|
"evidence_sha256",
|
|
77
92
|
"supersedes",
|
|
93
|
+
...(Object.hasOwn(item, "object_scope") ? ["object_scope"] : []),
|
|
78
94
|
]);
|
|
79
95
|
if (!Array.isArray(item.choices) || item.choices.length > 4)
|
|
80
96
|
invalid("A question may offer at most four short choices.");
|
|
81
97
|
const choices = item.choices.map((choice) => bounded(choice, "Choice", 240));
|
|
82
98
|
if (new Set(choices).size !== choices.length)
|
|
83
99
|
invalid("Question choices must be unique.");
|
|
100
|
+
const type = datasetType(item.dataset_type);
|
|
101
|
+
const scope = objectScope(item, type);
|
|
84
102
|
return Object.freeze({
|
|
85
103
|
kind: "question",
|
|
86
104
|
id: identifier(item.id, "Question id"),
|
|
87
|
-
dataset_type:
|
|
105
|
+
dataset_type: type,
|
|
106
|
+
...(scope ? { object_scope: scope } : {}),
|
|
88
107
|
missing: bounded(item.missing, "Missing information", 1_200),
|
|
89
108
|
impact: bounded(item.impact, "Impact", 1_200),
|
|
90
109
|
recommendation: bounded(item.recommendation, "Recommendation", 1_200),
|
|
@@ -132,11 +151,15 @@ function event(value) {
|
|
|
132
151
|
"impact",
|
|
133
152
|
"evidence_sha256",
|
|
134
153
|
"supersedes",
|
|
154
|
+
...(Object.hasOwn(item, "object_scope") ? ["object_scope"] : []),
|
|
135
155
|
]);
|
|
156
|
+
const type = datasetType(item.dataset_type);
|
|
157
|
+
const scope = objectScope(item, type);
|
|
136
158
|
return Object.freeze({
|
|
137
159
|
kind: "assumption",
|
|
138
160
|
id: identifier(item.id, "Assumption id"),
|
|
139
|
-
dataset_type:
|
|
161
|
+
dataset_type: type,
|
|
162
|
+
...(scope ? { object_scope: scope } : {}),
|
|
140
163
|
statement: bounded(item.statement, "Assumption"),
|
|
141
164
|
impact: bounded(item.impact, "Assumption impact"),
|
|
142
165
|
evidence_sha256: evidence(item.evidence_sha256),
|
|
@@ -168,7 +191,7 @@ export function parseFoundryInteractionInput(value) {
|
|
|
168
191
|
events: Object.freeze(item.events.map(event)),
|
|
169
192
|
});
|
|
170
193
|
}
|
|
171
|
-
export function advanceFoundryInteractionState(previous, input, currentSha256, availableEvidence, allowedTypes) {
|
|
194
|
+
export function advanceFoundryInteractionState(previous, input, currentSha256, availableEvidence, allowedTypes, verifiedObjectScopes = new Set()) {
|
|
172
195
|
if (input.expected_state_sha256 !== currentSha256)
|
|
173
196
|
invalid("Interaction state changed; reload the current question and submit against its digest.");
|
|
174
197
|
if (previous && (previous.task_id !== input.task_id || previous.actor_id !== input.actor_id))
|
|
@@ -202,6 +225,11 @@ export function advanceFoundryInteractionState(previous, input, currentSha256, a
|
|
|
202
225
|
const type = item.dataset_type;
|
|
203
226
|
if (typeof type === "string" && !allowedTypes.has(type))
|
|
204
227
|
invalid("Interaction scope is outside this task's target entity types.");
|
|
228
|
+
if (item.kind !== "answer" && Object.hasOwn(item, "object_scope")) {
|
|
229
|
+
const scope = item.object_scope;
|
|
230
|
+
if (!verifiedObjectScopes.has(foundryInteractionObjectProofKey(String(type), scope.entity_id, scope.version, scope.row_sha256)))
|
|
231
|
+
invalid("Interaction object scope is not bound to a registered row.");
|
|
232
|
+
}
|
|
205
233
|
for (const sha of item.evidence_sha256)
|
|
206
234
|
if (!availableEvidence.has(sha))
|
|
207
235
|
invalid("Interaction evidence is not a registered source or artifact.");
|
|
@@ -213,12 +241,12 @@ export function advanceFoundryInteractionState(previous, input, currentSha256, a
|
|
|
213
241
|
const prior = questions.get(String(item.supersedes));
|
|
214
242
|
if (!prior ||
|
|
215
243
|
supersededQuestions.has(String(item.supersedes)) ||
|
|
216
|
-
prior
|
|
244
|
+
!sameFoundryInteractionScope(prior, item))
|
|
217
245
|
invalid("A replacement question must name one current question in the same scope.");
|
|
218
246
|
supersededQuestions.add(String(item.supersedes));
|
|
219
247
|
}
|
|
220
248
|
if ([...questions.values()].some((prior) => !supersededQuestions.has(String(prior.id)) &&
|
|
221
|
-
prior
|
|
249
|
+
sameFoundryInteractionScope(prior, item) &&
|
|
222
250
|
prior.missing === item.missing &&
|
|
223
251
|
prior.ask === item.ask))
|
|
224
252
|
invalid("Duplicate current question; use its existing id and answer.");
|
|
@@ -243,11 +271,16 @@ export function advanceFoundryInteractionState(previous, input, currentSha256, a
|
|
|
243
271
|
if (item.supersedes) {
|
|
244
272
|
const prior = assumptions.get(String(item.supersedes));
|
|
245
273
|
if (!prior ||
|
|
246
|
-
prior
|
|
274
|
+
!sameFoundryInteractionScope(prior, item) ||
|
|
247
275
|
supersededAssumptions.has(String(item.supersedes)))
|
|
248
276
|
invalid("A replacement assumption must name one current assumption in the same scope.");
|
|
249
277
|
supersededAssumptions.add(String(item.supersedes));
|
|
250
278
|
}
|
|
279
|
+
if (Object.hasOwn(item, "object_scope") &&
|
|
280
|
+
[...assumptions.values()].some((prior) => !supersededAssumptions.has(String(prior.id)) &&
|
|
281
|
+
sameFoundryInteractionScope(prior, item) &&
|
|
282
|
+
prior.statement === item.statement))
|
|
283
|
+
invalid("Duplicate current assumption for this object scope.");
|
|
251
284
|
assumptions.set(String(item.id), item);
|
|
252
285
|
}
|
|
253
286
|
events.push(item);
|
|
@@ -324,4 +357,4 @@ export function currentFoundryInteractionState(context, entries) {
|
|
|
324
357
|
}
|
|
325
358
|
return null;
|
|
326
359
|
}
|
|
327
|
-
export { applicableFoundryInteractionDigest, applicableFoundryInteractionProjection, currentFoundryAssumptions, currentFoundryAssumptionsForType, currentFoundryDecisions, currentFoundryDecisionsForType, currentFoundryInvestigations, currentFoundryQuestions, } from "./foundry-interaction-projection.js";
|
|
360
|
+
export { applicableFoundryInteractionDigest, applicableFoundryInteractionDigestForObject, applicableFoundryInteractionProjection, applicableFoundryInteractionProjectionForObject, currentFoundryAssumptions, currentFoundryAssumptionsForObject, currentFoundryAssumptionsForType, currentFoundryDecisions, currentFoundryDecisionsForObject, currentFoundryDecisionsForType, currentFoundryInvestigations, currentFoundryInvestigationsForObject, currentFoundryQuestions, currentFoundryQuestionsForObject, foundryInteractionEventAppliesToObject, } from "./foundry-interaction-projection.js";
|