@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.
Files changed (45) hide show
  1. package/README.md +6 -6
  2. package/docs/architecture.md +8 -6
  3. package/docs/foundry-task-contracts.md +7 -5
  4. package/docs/import-profiles/worldsteel/constraints.md +3 -3
  5. package/docs/import-profiles/worldsteel/import-coverage.md +3 -3
  6. package/docs/import-profiles/worldsteel/import-plan.md +4 -4
  7. package/docs/import-profiles/worldsteel/profile.md +3 -3
  8. package/docs/package-distribution-contract.md +10 -10
  9. package/docs/public-runtime-contract.md +14 -8
  10. package/docs/runtime-context-contract.md +6 -4
  11. package/docs/task-authorization-contract.md +3 -3
  12. package/package-dist/assets/foundry-package-descriptor.json +97 -67
  13. package/package-dist/scripts/foundry-facade.js +321 -22
  14. package/package-dist/scripts/lib/foundry-interaction-input.d.ts +4 -3
  15. package/package-dist/scripts/lib/foundry-interaction-input.js +40 -7
  16. package/package-dist/scripts/lib/foundry-interaction-projection.d.ts +21 -2
  17. package/package-dist/scripts/lib/foundry-interaction-projection.js +49 -8
  18. package/package-dist/scripts/lib/foundry-interaction-scope.d.ts +7 -0
  19. package/package-dist/scripts/lib/foundry-interaction-scope.js +40 -0
  20. package/package-dist/scripts/lib/foundry-interaction-types.d.ts +5 -0
  21. package/package-dist/scripts/lib/foundry-native-validation-failure.d.ts +36 -0
  22. package/package-dist/scripts/lib/foundry-native-validation-failure.js +142 -0
  23. package/package-dist/scripts/lib/foundry-owner-execution-store.js +6 -13
  24. package/package-dist/scripts/lib/foundry-package-contract.d.ts +2 -2
  25. package/package-dist/scripts/lib/foundry-package-contract.js +2 -2
  26. package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
  27. package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
  28. package/package-dist/scripts/lib/foundry-semantic-interaction.d.ts +11 -1
  29. package/package-dist/scripts/lib/foundry-semantic-interaction.js +64 -14
  30. package/package-dist/scripts/lib/foundry-tidas-source.js +4 -4
  31. package/package-dist/scripts/lib/foundry-workflow-approval-continuation.js +3 -0
  32. package/package-dist/scripts/lib/foundry-workflow-assessment.js +201 -4
  33. package/package-dist/scripts/lib/foundry-workflow-authorization.js +3 -0
  34. package/package-dist/scripts/lib/foundry-workflow-interaction.js +22 -3
  35. package/package-dist/scripts/lib/foundry-workflow-object-scope.d.ts +53 -0
  36. package/package-dist/scripts/lib/foundry-workflow-object-scope.js +326 -0
  37. package/package-dist/scripts/lib/foundry-workflow-semantic.d.ts +5 -0
  38. package/package-dist/scripts/lib/foundry-workflow-semantic.js +200 -6
  39. package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
  40. package/package.json +2 -2
  41. package/specs/import-profiles.json +1 -1
  42. package/specs/schemas/foundry-interaction-input.schema.json +29 -2
  43. package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
  44. package/specs/schemas/foundry-package-descriptor.schema.json +2 -2
  45. package/specs/schemas/runtime-qualification.schema.json +1 -1
@@ -10,11 +10,13 @@ import { readTaskBytes } from "./foundry-task-io.js";
10
10
  import { deriveTaskAuthorizationGrant, validateTaskAuthorization } from "./task-authorization.js";
11
11
  import { sha256Json } from "./identity-preflight-proof.js";
12
12
  import { completedOwnerScopes } from "./foundry-owner-execution-store.js";
13
+ import { assertFoundryInteractionWriteReady } from "./foundry-workflow-object-scope.js";
13
14
  const digest = (bytes) => createHash("sha256").update(bytes).digest("hex");
14
15
  function invalid(message) {
15
16
  throw new FoundryContextError("authorization_continuation_invalid", message);
16
17
  }
17
18
  export async function continueFoundryPreparedApproval(context, qualified, entries, approval, authentication = { mode: "oauth" }) {
19
+ assertFoundryInteractionWriteReady(context, entries);
18
20
  const state = currentWorkflowState(context, entries), finalization = state.finalization;
19
21
  if (!finalization || approval.value.input_kind !== "current_rows")
20
22
  invalid("Select current prepared-row approval evidence.");
@@ -69,6 +71,7 @@ export async function continueFoundryPreparedApproval(context, qualified, entrie
69
71
  const identity = verifyFoundryRuntimeIdentity(context, authentication, process.env, qualified);
70
72
  const pointer = digest(readTaskBytes(context, "authorization.json"));
71
73
  const current = (index) => {
74
+ assertFoundryInteractionWriteReady(context, index);
72
75
  const now = currentWorkflowState(context, index);
73
76
  if (now.finalization?.entry.sha256 !== finalization.entry.sha256)
74
77
  invalid("Finalization changed during prepared-approval continuation.");
@@ -1,11 +1,13 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { createHash } from "node:crypto";
3
4
  import { FoundryContextError, readFoundryInput, resolveFoundryAsset, resolveFoundryOutput, captureFoundryInput, } from "./foundry-runtime-context.js";
4
5
  import { assertQualifiedFoundryRuntime, } from "./foundry-runtime-qualification.js";
5
6
  import { copyFoundryIsolatedExecutable } from "./foundry-runtime-environment.js";
6
7
  import { createFoundryIsolatedChildEnvironment } from "./foundry-runtime-environment.js";
7
8
  import { runFoundryTaskOperation } from "./foundry-task-store.js";
8
9
  import { runTidasRowsValidation } from "./tidas-adapter.js";
10
+ import { nativeFailureFileName, nativeFailureResultName, nativeValidationFailureEvidence, } from "./foundry-native-validation-failure.js";
9
11
  import { runDatasetCurationGate } from "./import-curation/curation-gate.js";
10
12
  import { runDatasetAuthoringTaskBuild } from "./import-curation/authoring-packages.js";
11
13
  import { routeFoundryDecisionAction } from "./foundry-decision-routing.js";
@@ -13,12 +15,183 @@ import { prepareFoundryDecisionWork } from "./foundry-workflow-decisions.js";
13
15
  import { currentWorkflowState, workflowAssessmentQueueScopeSha256, } from "./foundry-workflow-state.js";
14
16
  import { currentFoundryInteractionState } from "./foundry-interaction-input.js";
15
17
  import { applicableFoundryInteractionDigest, applicableFoundryInteractionProjection, } from "./foundry-interaction-projection.js";
16
- import { createWorkflowStageDirectory, createWorkflowDirectory, registerWorkflowStageFiles, runWorkflowLocalCli, } from "./foundry-workflow-io.js";
18
+ import { createWorkflowStageDirectory, createWorkflowDirectory, registerWorkflowStageFiles, runWorkflowLocalCli, runWorkflowLocalCliResult, } from "./foundry-workflow-io.js";
17
19
  function record(value) {
18
20
  if (!value || typeof value !== "object" || Array.isArray(value))
19
21
  throw new FoundryContextError("workflow_report_invalid", "Stage metadata must be an object.");
20
22
  return value;
21
23
  }
24
+ function assertCurrentQueueBuild(context, queueDir, result, sets) {
25
+ const invalid = () => {
26
+ throw new FoundryContextError("workflow_queue_invalid", "The local curation queue report does not match current rows and bounded output files.");
27
+ };
28
+ const object = (value) => value && typeof value === "object" && !Array.isArray(value)
29
+ ? value
30
+ : invalid();
31
+ const exactJson = (a, b) => JSON.stringify(a) === JSON.stringify(b);
32
+ const expectedPath = (value, expected) => value === expected;
33
+ const outputFile = (value, expected) => {
34
+ if (!expectedPath(value, expected))
35
+ return invalid();
36
+ try {
37
+ const fact = captureFoundryInput(expected);
38
+ if (fact.path !== expected || fact.bytes > 32 * 1024 * 1024)
39
+ return invalid();
40
+ const bytes = fs.readFileSync(expected);
41
+ if (bytes.length !== fact.bytes ||
42
+ createHash("sha256").update(bytes).digest("hex") !== fact.sha256)
43
+ return invalid();
44
+ return bytes.toString("utf8");
45
+ }
46
+ catch {
47
+ return invalid();
48
+ }
49
+ };
50
+ const jsonFile = (value, expected) => {
51
+ try {
52
+ return JSON.parse(outputFile(value, expected));
53
+ }
54
+ catch {
55
+ return invalid();
56
+ }
57
+ };
58
+ const jsonLines = (value, expected) => {
59
+ try {
60
+ return outputFile(value, expected)
61
+ .split(/\r?\n/u)
62
+ .filter((line) => line.length > 0)
63
+ .map((line) => JSON.parse(line));
64
+ }
65
+ catch {
66
+ return invalid();
67
+ }
68
+ };
69
+ try {
70
+ if (fs.realpathSync(queueDir) !== queueDir)
71
+ invalid();
72
+ }
73
+ catch {
74
+ invalid();
75
+ }
76
+ const report = result.report;
77
+ if (report.schema_version !== 1 ||
78
+ !((result.exit === 0 && report.status === "ready") ||
79
+ (result.exit === 1 && report.status === "blocked")) ||
80
+ !expectedPath(report.out_dir, queueDir))
81
+ invalid();
82
+ const typedSets = sets.map((set) => {
83
+ if (typeof set.type !== "string" ||
84
+ typeof set.file !== "string" ||
85
+ typeof set.count !== "number" ||
86
+ !Number.isSafeInteger(set.count) ||
87
+ set.count < 0)
88
+ return invalid();
89
+ return { type: set.type, file: set.file, count: set.count };
90
+ });
91
+ const processes = typedSets.find((set) => set.type === "process");
92
+ const flows = typedSets.find((set) => set.type === "flow");
93
+ const support = typedSets.filter((set) => ["contact", "source", "unitgroup", "flowproperty"].includes(set.type));
94
+ if (!processes)
95
+ return invalid();
96
+ const selected = [processes, ...(flows ? [flows] : []), ...support];
97
+ const inputs = object(report.inputs);
98
+ const supportPaths = support.map((set) => set.file);
99
+ if (!expectedPath(inputs.processes, processes.file) ||
100
+ (flows ? !expectedPath(inputs.flows, flows.file) : inputs.flows !== null) ||
101
+ !exactJson(inputs.support, supportPaths) ||
102
+ !exactJson(inputs.external_flow_refs, []))
103
+ invalid();
104
+ const expectedHashes = new Map(selected.map((set) => {
105
+ const file = set.file;
106
+ readFoundryInput(context, file);
107
+ return [file, captureFoundryInput(file).sha256];
108
+ }));
109
+ const hashes = object(object(report.hashes).inputs);
110
+ const taskRecords = Array.isArray(report.tasks) ? report.tasks.map(object) : invalid();
111
+ const taskIds = taskRecords.map((task) => {
112
+ if (typeof task.task_id !== "string" || !task.task_id)
113
+ return invalid();
114
+ return task.task_id;
115
+ });
116
+ if (!exactJson(Object.keys(hashes).sort(), [...expectedHashes.keys()].sort()) ||
117
+ [...expectedHashes].some(([file, sha256]) => hashes[file] !== sha256) ||
118
+ object(report.hashes).task_order !==
119
+ createHash("sha256").update(taskIds.join("\n")).digest("hex"))
120
+ invalid();
121
+ const counts = object(report.counts);
122
+ const supportCount = support.reduce((total, set) => total + set.count, 0);
123
+ // This call supplies no process filters; the CLI emits one task and lock per selected row.
124
+ const expectedTasks = processes.count + (flows?.count ?? 0) + supportCount;
125
+ const blockers = report.blockers;
126
+ const tasks = report.tasks;
127
+ if (!Array.isArray(blockers) || !Array.isArray(tasks))
128
+ return invalid();
129
+ for (const candidate of blockers) {
130
+ const blocker = object(candidate);
131
+ if (blocker.schema_version !== 1 ||
132
+ blocker.severity !== "blocker" ||
133
+ typeof blocker.code !== "string" ||
134
+ !blocker.code ||
135
+ typeof blocker.message !== "string" ||
136
+ !blocker.message)
137
+ invalid();
138
+ if (blocker.code === "process_flow_reference_unresolved") {
139
+ const refs = object(blocker.details).missing_flow_refs;
140
+ if (!Array.isArray(refs) || !refs.length)
141
+ return invalid();
142
+ for (const candidateRef of refs) {
143
+ const ref = object(candidateRef);
144
+ if (typeof ref.id !== "string" ||
145
+ !ref.id ||
146
+ !(ref.version === null || (typeof ref.version === "string" && ref.version)) ||
147
+ typeof ref.path !== "string" ||
148
+ !ref.path)
149
+ invalid();
150
+ }
151
+ }
152
+ }
153
+ if (counts.process_rows !== processes.count ||
154
+ counts.flow_rows !== (flows?.count ?? 0) ||
155
+ counts.support_rows !== supportCount ||
156
+ counts.external_flow_refs !== 0 ||
157
+ counts.tasks !== expectedTasks ||
158
+ counts.blockers !== blockers.length ||
159
+ tasks.length !== expectedTasks ||
160
+ (report.status === "blocked") !== blockers.length > 0)
161
+ invalid();
162
+ const files = object(report.files);
163
+ const outputs = path.join(queueDir, "outputs");
164
+ const manifest = jsonFile(files.manifest, path.join(outputs, "curation-queue-manifest.json"));
165
+ const taskRows = jsonLines(files.tasks, path.join(outputs, "curation-queue-tasks.jsonl"));
166
+ const blockerRows = jsonLines(files.blockers, path.join(outputs, "curation-queue-blockers.jsonl"));
167
+ const locks = object(jsonFile(files.locks, path.join(outputs, "curation-queue-locks.json")));
168
+ if (!Array.isArray(locks.locks))
169
+ return invalid();
170
+ if (!exactJson(manifest, report) ||
171
+ !exactJson(taskRows, tasks) ||
172
+ !exactJson(blockerRows, blockers) ||
173
+ locks.schema_version !== 1 ||
174
+ locks.locks.length !== tasks.length)
175
+ invalid();
176
+ for (let index = 0; index < taskRecords.length; index += 1) {
177
+ const task = taskRecords[index], lock = object(locks.locks[index]);
178
+ for (const key of ["task_id", "entity_type", "entity_id", "version", "lock_key"])
179
+ if (task[key] !== lock[key])
180
+ invalid();
181
+ }
182
+ for (const candidate of tasks) {
183
+ const task = object(candidate);
184
+ for (const key of ["input_rows_file", "closure_file", "run_plan_file"]) {
185
+ const file = task[key];
186
+ if (typeof file !== "string" || file !== path.resolve(file))
187
+ return invalid();
188
+ const resolved = path.resolve(file);
189
+ if (!resolved.startsWith(`${queueDir}${path.sep}`))
190
+ invalid();
191
+ outputFile(file, resolved);
192
+ }
193
+ }
194
+ }
22
195
  export function assessFoundryWorkflowRows(context, qualified, rowsReport, contextReports, identityReport, options = {}) {
23
196
  assertQualifiedFoundryRuntime(context, qualified);
24
197
  resolveFoundryAsset(context, "specs/prewrite-content-policy.json");
@@ -178,7 +351,7 @@ export function assessFoundryWorkflowRows(context, qualified, rowsReport, contex
178
351
  else if (["contact", "source", "unitgroup", "flowproperty"].includes(String(set.type)))
179
352
  args.push("--support", set.file);
180
353
  }
181
- runWorkflowLocalCli(context, qualified, temporary, args);
354
+ assertCurrentQueueBuild(context, queueDir, runWorkflowLocalCliResult(context, qualified, temporary, args), selectedSets);
182
355
  }
183
356
  const assessed = previousSets.map(record);
184
357
  const toAssess = options.scopeType
@@ -211,8 +384,32 @@ export function assessFoundryWorkflowRows(context, qualified, rowsReport, contex
211
384
  },
212
385
  environment,
213
386
  });
214
- if (typeof schema.report_file !== "string")
215
- throw new FoundryContextError("workflow_schema_failed", "Native validation returned no compatible report.");
387
+ if (typeof schema.report_file !== "string") {
388
+ const evidence = nativeValidationFailureEvidence(schema, set.type, set.file, captureFoundryInput(set.file).sha256, Number(set.count));
389
+ const evidenceFile = path.join(output, set.type, nativeFailureFileName);
390
+ operation.writeJson(evidenceFile, evidence);
391
+ const result = {
392
+ schema: "tiangong-foundry.assessment-failure.v1",
393
+ status: "blocked",
394
+ task_id: context.taskId,
395
+ rows_report: rowsReport,
396
+ rows_report_sha256: captureFoundryInput(rowsReport).sha256,
397
+ rows_file: set.file,
398
+ rows_file_sha256: evidence.rows_sha256,
399
+ row_count: evidence.row_count,
400
+ dataset_type: set.type,
401
+ exit_code: evidence.exit_code,
402
+ exit_class: evidence.exit_class,
403
+ diagnostic_code: evidence.diagnostic_code,
404
+ diagnostic_message: evidence.diagnostic_message,
405
+ evidence_file: evidenceFile,
406
+ evidence_sha256: "",
407
+ };
408
+ result.evidence_sha256 = captureFoundryInput(evidenceFile).sha256;
409
+ operation.writeJson(path.join(output, nativeFailureResultName), result);
410
+ registerWorkflowStageFiles(context, operation, output);
411
+ return result;
412
+ }
216
413
  const qaDir = path.join(output, set.type, "qa");
217
414
  let qaReport;
218
415
  if (["flow", "process", "lifecyclemodel"].includes(set.type)) {
@@ -19,9 +19,11 @@ import { readNativeDraftHandoff } from "./finalize-owners/native-draft-handoff.j
19
19
  import { foundryRepairSelection, readFoundryRepairPreparation } from "./foundry-workflow-repair.js";
20
20
  import { createFoundryRepairHandoffPlan } from "./foundry-repair-handoff.js";
21
21
  import { readTaskJson } from "./foundry-task-io.js";
22
+ import { assertFoundryInteractionWriteReady } from "./foundry-workflow-object-scope.js";
22
23
  export async function authorizeFoundryWorkflow(context, qualified, entries, selected, authentication = { mode: "oauth" }) {
23
24
  assertSelectedAuthorizationInput(selected);
24
25
  assertQualifiedFoundryRuntime(context, qualified);
26
+ assertFoundryInteractionWriteReady(context, entries);
25
27
  const state = currentWorkflowState(context, entries), spec = selected.spec;
26
28
  if (spec.input_kind === "repair_rows")
27
29
  return authorizeFoundryRepair(context, qualified, entries, selected, authentication, state);
@@ -61,6 +63,7 @@ export async function authorizeFoundryWorkflow(context, qualified, entries, sele
61
63
  const grant = JSON.parse(readSelectedSemanticBytes(selected.grant).toString("utf8"));
62
64
  const current = (index) => {
63
65
  assertSelectedAuthorizationInput(selected);
66
+ assertFoundryInteractionWriteReady(context, index);
64
67
  if (currentWorkflowState(context, index).finalization?.entry.sha256 !== finalization.entry.sha256)
65
68
  throw new FoundryContextError("authorization_finalization_changed", "Finalization changed before approval activation.");
66
69
  };
@@ -4,6 +4,8 @@ import { runFoundryTaskOperation } from "./foundry-task-store.js";
4
4
  import { advanceFoundryInteractionState, assertSelectedFoundryInteractionInput, currentFoundryInteractionState, FOUNDRY_INTERACTION_COMMAND, FOUNDRY_INTERACTION_REPORT, readSelectedFoundryInteractionBytes, } from "./foundry-interaction-input.js";
5
5
  import { readWorkflowArtifact } from "./foundry-workflow-state.js";
6
6
  import { createWorkflowStageDirectory } from "./foundry-workflow-io.js";
7
+ import { sha256Json } from "./identity-preflight-proof.js";
8
+ import { currentFoundryObjectScopes, currentFoundryNarrowObjects, requireCurrentFoundryObjectScope, verifiedFoundryObjectProofs, } from "./foundry-workflow-object-scope.js";
7
9
  const resultName = "interaction-result.json";
8
10
  function priorSubmission(context, entries, sha256) {
9
11
  for (const entry of [...entries].reverse()) {
@@ -27,7 +29,8 @@ export async function recordFoundryInteractionInput(context, entries, selected,
27
29
  ...context.inputs.map((fact) => fact.sha256),
28
30
  ...entries.map((entry) => entry.sha256),
29
31
  ]);
30
- const accepted = advanceFoundryInteractionState(current?.state ?? null, selected.spec, currentSha, known, new Set(targetEntities));
32
+ const newObjectScope = selected.spec.events.some((item) => Object.hasOwn(item, "object_scope"));
33
+ const accepted = advanceFoundryInteractionState(current?.state ?? null, selected.spec, currentSha, known, new Set(targetEntities), newObjectScope ? verifiedFoundryObjectProofs(context, entries) : new Set());
31
34
  return runFoundryTaskOperation(context, {
32
35
  command: FOUNDRY_INTERACTION_COMMAND,
33
36
  options: {
@@ -35,11 +38,27 @@ export async function recordFoundryInteractionInput(context, entries, selected,
35
38
  expected_state_sha256: currentSha,
36
39
  },
37
40
  validateCurrent(index) {
38
- if (index.some((entry) => ["dataset-workflow-execution-prepare", "dataset-workflow-execution-consume"].includes(entry.command)))
39
- throw new FoundryContextError("interaction_after_approval", "Preserve the approved or attempted scope; a changed decision needs a separately reviewed task revision.");
41
+ if (index.some((entry) => [
42
+ "dataset-workflow-authorization",
43
+ "dataset-workflow-execution-prepare",
44
+ "dataset-workflow-execution-consume",
45
+ ].includes(entry.command)))
46
+ throw new FoundryContextError("interaction_after_approval", "Preserve the authorized or attempted scope; a changed decision needs a separately reviewed task revision.");
40
47
  const present = currentFoundryInteractionState(context, index);
41
48
  if ((present?.entry.sha256 ?? null) !== currentSha)
42
49
  throw new FoundryContextError("interaction_state_changed", "Interaction state changed before this input acquired the task lock.");
50
+ if (accepted.events.some((item) => Object.hasOwn(item, "object_scope"))) {
51
+ const objects = currentFoundryObjectScopes(context, index);
52
+ for (const item of currentFoundryNarrowObjects(accepted)) {
53
+ requireCurrentFoundryObjectScope(context, index, accepted, objects, item.dataset_type, item.entity_id, item.version);
54
+ }
55
+ }
56
+ const rechecked = advanceFoundryInteractionState(present?.state ?? null, selected.spec, currentSha, new Set([
57
+ ...context.inputs.map((fact) => fact.sha256),
58
+ ...index.map((item) => item.sha256),
59
+ ]), new Set(targetEntities), newObjectScope ? verifiedFoundryObjectProofs(context, index) : new Set());
60
+ if (sha256Json(rechecked) !== sha256Json(accepted))
61
+ throw new FoundryContextError("interaction_state_changed", "Object scope or current row evidence changed before this input acquired the task lock.");
43
62
  },
44
63
  }, (operation) => {
45
64
  assertSelectedFoundryInteractionInput(selected);
@@ -0,0 +1,53 @@
1
+ import type { FoundryInteractionState } from "./foundry-interaction-types.ts";
2
+ import { type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
3
+ import type { ArtifactEntry } from "./foundry-task-types.ts";
4
+ export interface CurrentFoundryObject {
5
+ readonly dataset_type: string;
6
+ readonly entity_id: string;
7
+ readonly version: string;
8
+ readonly row_sha256: string;
9
+ }
10
+ export interface IndexedFoundryRowAdoption {
11
+ readonly dataset_type: string;
12
+ readonly object_scope: Readonly<{
13
+ entity_id: string;
14
+ version: string;
15
+ }>;
16
+ readonly work_item_sha256: string;
17
+ readonly before_row_sha256: string;
18
+ readonly after_row_sha256: string;
19
+ readonly decision_ids: readonly string[];
20
+ readonly semantic_result_sha256: string;
21
+ }
22
+ export declare function foundryExplicitObjectIdentity(row: unknown, type: string): {
23
+ entity_id: string;
24
+ version: string;
25
+ } | null;
26
+ /** Read current registered row bytes, never a caller-supplied identity alone. */
27
+ export declare function currentFoundryObjectScopes(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): ReadonlyMap<string, CurrentFoundryObject | null>;
28
+ export declare function verifiedFoundryObjectProofs(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): ReadonlySet<string>;
29
+ export declare function requireCurrentFoundryObject(objects: ReadonlyMap<string, CurrentFoundryObject | null>, type: string, entityId: string, version: string): CurrentFoundryObject;
30
+ export declare function requireUniqueFoundryObjectInRows(file: string, type: string, entityId: string, version: string, reader?: (file: string) => string): CurrentFoundryObject;
31
+ export declare function indexedFoundryRowAdoptions(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): readonly IndexedFoundryRowAdoption[];
32
+ /** A new answer needs its own indexed adoption after earlier semantic work on that object. */
33
+ export declare function currentFoundryObjectDecisionReassessments(state: FoundryInteractionState, objects: ReadonlyMap<string, CurrentFoundryObject | null>, adoptions: readonly IndexedFoundryRowAdoption[], requireEarlierWork?: boolean): ReadonlyArray<{
34
+ readonly dataset_type: string;
35
+ readonly entity_id: string;
36
+ readonly version: string;
37
+ readonly decision_id: string;
38
+ }>;
39
+ export declare function currentFoundryNarrowObjects(state: FoundryInteractionState): ReadonlyArray<{
40
+ dataset_type: string;
41
+ entity_id: string;
42
+ version: string;
43
+ }>;
44
+ /** An old row proof may follow only a recorded, decision-bound semantic successor. */
45
+ export declare function currentFoundryObjectScopeIsBound(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[], state: FoundryInteractionState, objects: ReadonlyMap<string, CurrentFoundryObject | null>, type: string, entityId: string, version: string, adoptions?: readonly IndexedFoundryRowAdoption[]): boolean;
46
+ export declare function requireCurrentFoundryObjectScope(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[], state: FoundryInteractionState, objects: ReadonlyMap<string, CurrentFoundryObject | null>, type: string, entityId: string, version: string): CurrentFoundryObject;
47
+ /** Recheck the current indexed interaction before any write approval or approved continuation. */
48
+ export declare function currentFoundryInteractionWriteBlocker(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): Readonly<{
49
+ code: string;
50
+ message: string;
51
+ scope?: string;
52
+ }> | null;
53
+ export declare function assertFoundryInteractionWriteReady(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): void;