@tiangong-lca/foundry 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -7
- package/docs/architecture.md +15 -3
- package/docs/foundry-task-contracts.md +27 -3
- package/docs/package-distribution-contract.md +45 -13
- package/docs/public-runtime-contract.md +73 -5
- package/docs/runtime-context-contract.md +20 -4
- package/docs/task-authorization-contract.md +15 -3
- package/docs/workspace-migration-contract.md +5 -3
- package/package-dist/assets/foundry-package-descriptor.json +333 -139
- package/package-dist/scripts/foundry-facade.d.ts +5 -0
- package/package-dist/scripts/foundry-facade.js +258 -16
- package/package-dist/scripts/foundry-runtime.d.ts +1 -1
- package/package-dist/scripts/lib/bundle-sample-utils.d.ts +4 -4
- package/package-dist/scripts/lib/bundle-source-context.d.ts +6 -4
- package/package-dist/scripts/lib/bundle-source-context.js +10 -8
- package/package-dist/scripts/lib/decision-owners/identity-preflight.js +16 -6
- package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +2 -1
- package/package-dist/scripts/lib/finalize-owners/post-authoring.js +28 -1
- package/package-dist/scripts/lib/foundry-assessment-producer.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-assessment-producer.js +167 -0
- package/package-dist/scripts/lib/foundry-command-metadata.js +6 -1
- package/package-dist/scripts/lib/foundry-decision-owners.d.ts +1 -1
- package/package-dist/scripts/lib/foundry-decision-owners.js +15 -7
- package/package-dist/scripts/lib/foundry-execution-admission.js +4 -1
- package/package-dist/scripts/lib/foundry-finalize-owners.js +64 -17
- package/package-dist/scripts/lib/foundry-identity-stage-input.d.ts +24 -0
- package/package-dist/scripts/lib/foundry-identity-stage-input.js +122 -0
- package/package-dist/scripts/lib/foundry-identity-stage-state.d.ts +17 -0
- package/package-dist/scripts/lib/foundry-identity-stage-state.js +48 -0
- package/package-dist/scripts/lib/foundry-installed-entry.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-installed-entry.js +173 -0
- package/package-dist/scripts/lib/foundry-managed-adoption.d.ts +12 -0
- package/package-dist/scripts/lib/foundry-managed-adoption.js +108 -0
- package/package-dist/scripts/lib/foundry-managed-authentication.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-managed-authentication.js +28 -0
- package/package-dist/scripts/lib/foundry-managed-host.js +14 -2
- package/package-dist/scripts/lib/foundry-migration-transfer-io.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-migration-transfer-io.js +27 -3
- package/package-dist/scripts/lib/foundry-operation-result.d.ts +1 -1
- package/package-dist/scripts/lib/foundry-operation-result.js +1 -0
- package/package-dist/scripts/lib/foundry-package-contract.d.ts +4 -4
- package/package-dist/scripts/lib/foundry-package-contract.js +10 -2
- package/package-dist/scripts/lib/foundry-preparation-cli-validation.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-preparation-cli-validation.js +25 -3
- package/package-dist/scripts/lib/foundry-quality-review-context.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-quality-review-context.js +18 -0
- package/package-dist/scripts/lib/foundry-quality-review-input.d.ts +48 -0
- package/package-dist/scripts/lib/foundry-quality-review-input.js +284 -0
- package/package-dist/scripts/lib/foundry-quality-review-lineage.d.ts +13 -0
- package/package-dist/scripts/lib/foundry-quality-review-lineage.js +123 -0
- package/package-dist/scripts/lib/foundry-quality-review.d.ts +112 -0
- package/package-dist/scripts/lib/foundry-quality-review.js +487 -0
- package/package-dist/scripts/lib/foundry-runtime-identity.js +3 -1
- package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
- package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
- package/package-dist/scripts/lib/foundry-task-authorization.d.ts +2 -1
- package/package-dist/scripts/lib/foundry-task-authorization.js +32 -11
- package/package-dist/scripts/lib/foundry-task-registration.js +4 -5
- package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.d.ts +28 -0
- package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.js +250 -0
- package/package-dist/scripts/lib/foundry-task-runtime-adoption.d.ts +60 -0
- package/package-dist/scripts/lib/foundry-task-runtime-adoption.js +549 -0
- package/package-dist/scripts/lib/foundry-task-store.d.ts +4 -1
- package/package-dist/scripts/lib/foundry-task-store.js +113 -4
- package/package-dist/scripts/lib/foundry-task-types.d.ts +2 -1
- package/package-dist/scripts/lib/foundry-validation-reference-context.d.ts +8 -0
- package/package-dist/scripts/lib/foundry-validation-reference-context.js +115 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +1 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.js +115 -22
- package/package-dist/scripts/lib/foundry-workflow-authorization.js +17 -4
- package/package-dist/scripts/lib/foundry-workflow-child-failure.d.ts +44 -0
- package/package-dist/scripts/lib/foundry-workflow-child-failure.js +439 -0
- package/package-dist/scripts/lib/foundry-workflow-context.js +37 -8
- package/package-dist/scripts/lib/foundry-workflow-finalize.js +37 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-recovery.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-recovery.js +450 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-stage.d.ts +9 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-stage.js +676 -0
- package/package-dist/scripts/lib/foundry-workflow-identity.js +10 -1
- package/package-dist/scripts/lib/foundry-workflow-io.d.ts +7 -1
- package/package-dist/scripts/lib/foundry-workflow-io.js +76 -11
- package/package-dist/scripts/lib/foundry-workflow-semantic.js +27 -13
- package/package-dist/scripts/lib/foundry-workflow-state.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-workflow-state.js +165 -22
- package/package-dist/scripts/lib/identity-preflight-artifacts.d.ts +4 -7
- package/package-dist/scripts/lib/identity-preflight-artifacts.js +18 -5
- package/package-dist/scripts/lib/identity-preflight-proof.d.ts +5 -0
- package/package-dist/scripts/lib/identity-preflight-proof.js +73 -1
- package/package-dist/scripts/lib/identity-preflight-recovery-proof.d.ts +78 -0
- package/package-dist/scripts/lib/identity-preflight-recovery-proof.js +415 -0
- package/package-dist/scripts/lib/import-curation/curation-cleanup.d.ts +9 -1
- package/package-dist/scripts/lib/import-curation/curation-cleanup.js +39 -2
- package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +1 -0
- package/package-dist/scripts/lib/import-curation/curation-gate.js +19 -1
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
- package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.js +11 -2
- package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.js +4 -1
- package/package-dist/scripts/package-entry.js +2 -3
- package/package-dist/scripts/public-api.d.ts +5 -0
- package/package-dist/scripts/public-api.js +2 -0
- package/package-dist/scripts/runtime-entry.d.ts +2 -0
- package/package-dist/scripts/runtime-entry.js +42 -15
- package/package.json +6 -2
- package/specs/schemas/foundry-identity-stage-input.schema.json +47 -0
- package/specs/schemas/foundry-managed-adoption.schema.json +40 -0
- package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
- package/specs/schemas/foundry-operation-result.schema.json +1 -0
- package/specs/schemas/foundry-package-descriptor.schema.json +6 -2
- package/specs/schemas/foundry-quality-review-draft.schema.json +271 -0
- package/specs/schemas/foundry-quality-review-input.schema.json +271 -0
- package/specs/schemas/runtime-qualification.schema.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { readRows } from "./import-curation/internal/runtime-io.js";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import { sha256Text } from "./identity-preflight-proof.js";
|
|
4
|
-
import { FoundryContextError } from "./foundry-runtime-context.js";
|
|
5
|
+
import { captureFoundryInput, FoundryContextError, } from "./foundry-runtime-context.js";
|
|
5
6
|
import { sha256Json } from "./identity-preflight-proof.js";
|
|
6
7
|
import { datasetIdentity } from "./import-curation/internal/dataset-payload.js";
|
|
7
8
|
function record(value) {
|
|
@@ -177,12 +178,33 @@ export function preparationValidationEvidence(row, report, hash) {
|
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
180
|
export function readPreparationCliEvidence(receipt, rows, input) {
|
|
181
|
+
let validationRows = rows;
|
|
182
|
+
let validationInput = input;
|
|
183
|
+
if (receipt.input) {
|
|
184
|
+
const current = captureFoundryInput(receipt.input.path);
|
|
185
|
+
if (current.bytes > 8 * 1024 * 1024 || sha256Json(current) !== sha256Json(receipt.input))
|
|
186
|
+
fail();
|
|
187
|
+
validationRows = readRows(current.path);
|
|
188
|
+
if (validationRows.length !== rows.length ||
|
|
189
|
+
validationRows.some((row, index) => {
|
|
190
|
+
const original = datasetIdentity(rows[index], index, "process");
|
|
191
|
+
const derived = datasetIdentity(row, index, "process");
|
|
192
|
+
const source = record(rows[index]), wrapper = record(row);
|
|
193
|
+
return (original.id !== derived.id ||
|
|
194
|
+
original.version !== derived.version ||
|
|
195
|
+
sha256Json(original.payload) !== sha256Json(derived.payload) ||
|
|
196
|
+
source.id !== wrapper.id ||
|
|
197
|
+
source.version !== wrapper.version);
|
|
198
|
+
}))
|
|
199
|
+
fail();
|
|
200
|
+
validationInput = current.path;
|
|
201
|
+
}
|
|
180
202
|
const bytes = fs.readFileSync(receipt.report, "utf8");
|
|
181
203
|
return {
|
|
182
204
|
rows: parseFoundryPreparationCliReport({
|
|
183
205
|
report: JSON.parse(bytes),
|
|
184
|
-
rows,
|
|
185
|
-
input,
|
|
206
|
+
rows: validationRows,
|
|
207
|
+
input: validationInput,
|
|
186
208
|
outDir: path.dirname(path.dirname(receipt.report)),
|
|
187
209
|
exit: receipt.exit,
|
|
188
210
|
}),
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FoundryInteractionState } from "./foundry-interaction-types.ts";
|
|
2
|
+
/** Include both broad and object-scoped Process decisions, without importing other entity types. */
|
|
3
|
+
export declare function qualityReviewInteractionDigest(interaction: FoundryInteractionState | null, processRows: readonly unknown[]): string | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { applicableFoundryInteractionDigestForObject } from "./foundry-interaction-projection.js";
|
|
2
|
+
import { datasetIdentity } from "./import-curation/internal/dataset-payload.js";
|
|
3
|
+
import { sha256Json } from "./identity-preflight-proof.js";
|
|
4
|
+
/** Include both broad and object-scoped Process decisions, without importing other entity types. */
|
|
5
|
+
export function qualityReviewInteractionDigest(interaction, processRows) {
|
|
6
|
+
if (!interaction)
|
|
7
|
+
return null;
|
|
8
|
+
const scope = processRows.map((row, index) => {
|
|
9
|
+
const identity = datasetIdentity(row, index, "process");
|
|
10
|
+
return {
|
|
11
|
+
row_index: index,
|
|
12
|
+
id: identity.id,
|
|
13
|
+
version: identity.version,
|
|
14
|
+
interaction_sha256: applicableFoundryInteractionDigestForObject(interaction, "process", identity.id, identity.version),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return scope.some((item) => item.interaction_sha256 !== null) ? sha256Json(scope) : null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type FoundryInputFact, type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
2
|
+
import type { TaskAuthorizationBinding } from "./task-authorization.ts";
|
|
3
|
+
export declare const FOUNDRY_QUALITY_REVIEW_INPUT_SCHEMA: "tiangong-foundry.quality-review-input.v1";
|
|
4
|
+
export declare const FOUNDRY_QUALITY_REVIEW_DRAFT_SCHEMA: "tiangong-foundry.quality-review-draft.v1";
|
|
5
|
+
export interface FoundryQualityReview {
|
|
6
|
+
readonly row_index: number;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly version: string;
|
|
9
|
+
readonly payload_sha256: string;
|
|
10
|
+
readonly finding_sha256: string;
|
|
11
|
+
readonly code: "process_material_balance_deviation";
|
|
12
|
+
readonly evidence_ids: readonly string[];
|
|
13
|
+
readonly rationale: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FoundryQualityReviewEvidence {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly kind: "user-decision" | "source-model";
|
|
18
|
+
/** v1 evidence is selected as strict UTF-8 text, including source-model JSON. */
|
|
19
|
+
readonly file: string;
|
|
20
|
+
readonly sha256: string;
|
|
21
|
+
}
|
|
22
|
+
export interface FoundryQualityReviewInput {
|
|
23
|
+
readonly schema: typeof FOUNDRY_QUALITY_REVIEW_INPUT_SCHEMA;
|
|
24
|
+
readonly binding: Readonly<TaskAuthorizationBinding>;
|
|
25
|
+
readonly runtime_qualification_sha256: string;
|
|
26
|
+
readonly rows_manifest_sha256: string;
|
|
27
|
+
readonly assessment_sha256: string;
|
|
28
|
+
readonly context_sha256: string;
|
|
29
|
+
readonly reference_inputs_sha256: string | null;
|
|
30
|
+
readonly interaction_context_sha256: string | null;
|
|
31
|
+
readonly qa_report_sha256: string;
|
|
32
|
+
readonly qa_findings_sha256: string;
|
|
33
|
+
readonly expected_previous_sha256: string | null;
|
|
34
|
+
readonly issued_at_utc: string;
|
|
35
|
+
readonly expires_at_utc: string;
|
|
36
|
+
readonly reviews: readonly FoundryQualityReview[];
|
|
37
|
+
readonly evidence: readonly FoundryQualityReviewEvidence[];
|
|
38
|
+
}
|
|
39
|
+
export interface SelectedFoundryQualityReviewInput {
|
|
40
|
+
readonly spec: FoundryQualityReviewInput;
|
|
41
|
+
readonly descriptor: FoundryInputFact;
|
|
42
|
+
readonly evidence: readonly FoundryInputFact[];
|
|
43
|
+
}
|
|
44
|
+
export declare function parseFoundryQualityReviewInput(value: unknown): FoundryQualityReviewInput;
|
|
45
|
+
/** Expand only explicit completed decisions; file facts are captured by the owning caller. */
|
|
46
|
+
export declare function materializeFoundryQualityReviewInput(value: unknown, captureEvidence: (file: string) => FoundryInputFact): FoundryQualityReviewInput;
|
|
47
|
+
export declare function selectFoundryQualityReviewInput(context: FoundryRuntimeContext, descriptorFile: string): SelectedFoundryQualityReviewInput;
|
|
48
|
+
export declare function assertSelectedFoundryQualityReviewInput(value: SelectedFoundryQualityReviewInput): void;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { captureFoundryInput, FoundryContextError, } from "./foundry-runtime-context.js";
|
|
4
|
+
import { assertNotFoundrySessionFile, migrationCredentialPath } from "./foundry-private-path.js";
|
|
5
|
+
import { readSelectedSemanticBytes } from "./foundry-semantic-input.js";
|
|
6
|
+
export const FOUNDRY_QUALITY_REVIEW_INPUT_SCHEMA = "tiangong-foundry.quality-review-input.v1";
|
|
7
|
+
export const FOUNDRY_QUALITY_REVIEW_DRAFT_SCHEMA = "tiangong-foundry.quality-review-draft.v1";
|
|
8
|
+
const selections = new WeakSet();
|
|
9
|
+
const sha = /^[0-9a-f]{64}$/u;
|
|
10
|
+
const identifier = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,255}$/u;
|
|
11
|
+
const bindingKeys = [
|
|
12
|
+
"workspace_id",
|
|
13
|
+
"task_id",
|
|
14
|
+
"actor_id",
|
|
15
|
+
"project_ref",
|
|
16
|
+
"user_id",
|
|
17
|
+
"profile_id",
|
|
18
|
+
"profile_sha256",
|
|
19
|
+
"input_scope_sha256",
|
|
20
|
+
];
|
|
21
|
+
const hashKeys = [
|
|
22
|
+
"runtime_qualification_sha256",
|
|
23
|
+
"rows_manifest_sha256",
|
|
24
|
+
"assessment_sha256",
|
|
25
|
+
"context_sha256",
|
|
26
|
+
"qa_report_sha256",
|
|
27
|
+
"qa_findings_sha256",
|
|
28
|
+
];
|
|
29
|
+
function invalid(message) {
|
|
30
|
+
throw new FoundryContextError("quality_review_input_invalid", message);
|
|
31
|
+
}
|
|
32
|
+
function record(value) {
|
|
33
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
34
|
+
invalid("Quality review input requires complete objects.");
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function exact(value, keys) {
|
|
38
|
+
if (Object.keys(value).length !== keys.length || keys.some((key) => !Object.hasOwn(value, key)))
|
|
39
|
+
invalid("Quality review input has missing or unsupported fields.");
|
|
40
|
+
}
|
|
41
|
+
function validTime(value) {
|
|
42
|
+
return (typeof value === "string" &&
|
|
43
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u.test(value) &&
|
|
44
|
+
Number.isFinite(Date.parse(value)) &&
|
|
45
|
+
new Date(value).toISOString() === value);
|
|
46
|
+
}
|
|
47
|
+
function validPath(value) {
|
|
48
|
+
return (typeof value === "string" &&
|
|
49
|
+
Boolean(value.trim()) &&
|
|
50
|
+
value.length <= 4096 &&
|
|
51
|
+
!/[\0\r\n]/u.test(value));
|
|
52
|
+
}
|
|
53
|
+
export function parseFoundryQualityReviewInput(value) {
|
|
54
|
+
const data = record(value);
|
|
55
|
+
exact(data, [
|
|
56
|
+
"schema",
|
|
57
|
+
"binding",
|
|
58
|
+
...hashKeys,
|
|
59
|
+
"reference_inputs_sha256",
|
|
60
|
+
"interaction_context_sha256",
|
|
61
|
+
"expected_previous_sha256",
|
|
62
|
+
"issued_at_utc",
|
|
63
|
+
"expires_at_utc",
|
|
64
|
+
"reviews",
|
|
65
|
+
"evidence",
|
|
66
|
+
]);
|
|
67
|
+
const binding = record(data.binding);
|
|
68
|
+
exact(binding, bindingKeys);
|
|
69
|
+
if (data.schema !== FOUNDRY_QUALITY_REVIEW_INPUT_SCHEMA ||
|
|
70
|
+
bindingKeys.some((key) => typeof binding[key] !== "string" ||
|
|
71
|
+
!(key.endsWith("_sha256") ? sha : identifier).test(binding[key])) ||
|
|
72
|
+
!/^task-[0-9a-f]{64}-r[0-9]{4}$/u.test(String(binding.task_id)) ||
|
|
73
|
+
hashKeys.some((key) => typeof data[key] !== "string" || !sha.test(data[key])) ||
|
|
74
|
+
[
|
|
75
|
+
data.reference_inputs_sha256,
|
|
76
|
+
data.interaction_context_sha256,
|
|
77
|
+
data.expected_previous_sha256,
|
|
78
|
+
].some((hash) => hash !== null && (typeof hash !== "string" || !sha.test(hash))) ||
|
|
79
|
+
!validTime(data.issued_at_utc) ||
|
|
80
|
+
!validTime(data.expires_at_utc) ||
|
|
81
|
+
!Array.isArray(data.reviews) ||
|
|
82
|
+
!data.reviews.length ||
|
|
83
|
+
data.reviews.length > 128 ||
|
|
84
|
+
!Array.isArray(data.evidence) ||
|
|
85
|
+
!data.evidence.length ||
|
|
86
|
+
data.evidence.length > 100)
|
|
87
|
+
invalid("Quality review scope, hashes, timestamps or bounded lists are invalid.");
|
|
88
|
+
const lifetime = Date.parse(data.expires_at_utc) - Date.parse(data.issued_at_utc);
|
|
89
|
+
if (lifetime <= 0 || lifetime > 24 * 60 * 60 * 1000)
|
|
90
|
+
invalid("Quality review validity must be a positive interval of at most 24 hours.");
|
|
91
|
+
const evidence = data.evidence.map((raw) => {
|
|
92
|
+
const item = record(raw);
|
|
93
|
+
exact(item, ["id", "kind", "file", "sha256"]);
|
|
94
|
+
if (typeof item.id !== "string" ||
|
|
95
|
+
!identifier.test(item.id) ||
|
|
96
|
+
(item.kind !== "user-decision" && item.kind !== "source-model") ||
|
|
97
|
+
!validPath(item.file) ||
|
|
98
|
+
typeof item.sha256 !== "string" ||
|
|
99
|
+
!sha.test(item.sha256))
|
|
100
|
+
invalid("Quality review evidence selection is invalid.");
|
|
101
|
+
return Object.freeze({ id: item.id, kind: item.kind, file: item.file, sha256: item.sha256 });
|
|
102
|
+
});
|
|
103
|
+
const evidenceById = new Map(evidence.map((item) => [item.id, item]));
|
|
104
|
+
if (evidenceById.size !== evidence.length)
|
|
105
|
+
invalid("Quality review evidence ids must be unique.");
|
|
106
|
+
const used = new Set();
|
|
107
|
+
const reviews = data.reviews.map((raw) => {
|
|
108
|
+
const item = record(raw);
|
|
109
|
+
exact(item, [
|
|
110
|
+
"row_index",
|
|
111
|
+
"id",
|
|
112
|
+
"version",
|
|
113
|
+
"payload_sha256",
|
|
114
|
+
"finding_sha256",
|
|
115
|
+
"code",
|
|
116
|
+
"evidence_ids",
|
|
117
|
+
"rationale",
|
|
118
|
+
]);
|
|
119
|
+
if (typeof item.row_index !== "number" ||
|
|
120
|
+
!Number.isSafeInteger(item.row_index) ||
|
|
121
|
+
item.row_index < 0 ||
|
|
122
|
+
typeof item.id !== "string" ||
|
|
123
|
+
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u.test(item.id) ||
|
|
124
|
+
typeof item.version !== "string" ||
|
|
125
|
+
!/^[0-9]{2}\.[0-9]{2}\.[0-9]{3}$/u.test(item.version) ||
|
|
126
|
+
typeof item.payload_sha256 !== "string" ||
|
|
127
|
+
!sha.test(item.payload_sha256) ||
|
|
128
|
+
typeof item.finding_sha256 !== "string" ||
|
|
129
|
+
!sha.test(item.finding_sha256) ||
|
|
130
|
+
item.code !== "process_material_balance_deviation" ||
|
|
131
|
+
!Array.isArray(item.evidence_ids) ||
|
|
132
|
+
!item.evidence_ids.length ||
|
|
133
|
+
item.evidence_ids.length > 100 ||
|
|
134
|
+
item.evidence_ids.some((id) => typeof id !== "string" || !identifier.test(id)) ||
|
|
135
|
+
new Set(item.evidence_ids).size !== item.evidence_ids.length ||
|
|
136
|
+
typeof item.rationale !== "string" ||
|
|
137
|
+
!item.rationale.trim() ||
|
|
138
|
+
item.rationale.length > 8192)
|
|
139
|
+
invalid("Quality review row, finding or rationale is invalid.");
|
|
140
|
+
const ids = item.evidence_ids;
|
|
141
|
+
const kinds = new Set(ids.map((id) => {
|
|
142
|
+
const selected = evidenceById.get(id);
|
|
143
|
+
if (!selected)
|
|
144
|
+
invalid("Every quality review evidence id must resolve.");
|
|
145
|
+
used.add(id);
|
|
146
|
+
return selected.kind;
|
|
147
|
+
}));
|
|
148
|
+
if (!kinds.has("user-decision") || !kinds.has("source-model"))
|
|
149
|
+
invalid("Every quality review requires user-decision and source-model evidence.");
|
|
150
|
+
return Object.freeze({
|
|
151
|
+
row_index: item.row_index,
|
|
152
|
+
id: item.id,
|
|
153
|
+
version: item.version,
|
|
154
|
+
payload_sha256: item.payload_sha256,
|
|
155
|
+
finding_sha256: item.finding_sha256,
|
|
156
|
+
code: item.code,
|
|
157
|
+
evidence_ids: Object.freeze([...ids]),
|
|
158
|
+
rationale: item.rationale,
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
if (used.size !== evidence.length ||
|
|
162
|
+
new Set(reviews.map((item) => item.row_index)).size !== reviews.length ||
|
|
163
|
+
new Set(reviews.map((item) => `${item.id}/${item.version}`)).size !== reviews.length ||
|
|
164
|
+
new Set(reviews.map((item) => item.finding_sha256)).size !== reviews.length)
|
|
165
|
+
invalid("Quality reviews cannot duplicate rows, identities or findings, or select unused evidence.");
|
|
166
|
+
return Object.freeze({
|
|
167
|
+
schema: FOUNDRY_QUALITY_REVIEW_INPUT_SCHEMA,
|
|
168
|
+
binding: Object.freeze({ ...binding }),
|
|
169
|
+
runtime_qualification_sha256: data.runtime_qualification_sha256,
|
|
170
|
+
rows_manifest_sha256: data.rows_manifest_sha256,
|
|
171
|
+
assessment_sha256: data.assessment_sha256,
|
|
172
|
+
context_sha256: data.context_sha256,
|
|
173
|
+
reference_inputs_sha256: data.reference_inputs_sha256,
|
|
174
|
+
interaction_context_sha256: data.interaction_context_sha256,
|
|
175
|
+
qa_report_sha256: data.qa_report_sha256,
|
|
176
|
+
qa_findings_sha256: data.qa_findings_sha256,
|
|
177
|
+
expected_previous_sha256: data.expected_previous_sha256,
|
|
178
|
+
issued_at_utc: data.issued_at_utc,
|
|
179
|
+
expires_at_utc: data.expires_at_utc,
|
|
180
|
+
reviews: Object.freeze(reviews),
|
|
181
|
+
evidence: Object.freeze(evidence),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function strictText(fact) {
|
|
185
|
+
try {
|
|
186
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(readSelectedSemanticBytes(fact));
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return invalid("Quality review input must retain exact strict UTF-8 bytes.");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** Expand only explicit completed decisions; file facts are captured by the owning caller. */
|
|
193
|
+
export function materializeFoundryQualityReviewInput(value, captureEvidence) {
|
|
194
|
+
const data = record(value);
|
|
195
|
+
if (data.schema !== FOUNDRY_QUALITY_REVIEW_DRAFT_SCHEMA)
|
|
196
|
+
return parseFoundryQualityReviewInput(data);
|
|
197
|
+
if (!Array.isArray(data.reviews) ||
|
|
198
|
+
!data.reviews.length ||
|
|
199
|
+
data.reviews.length > 128 ||
|
|
200
|
+
!Array.isArray(data.evidence) ||
|
|
201
|
+
!data.evidence.length ||
|
|
202
|
+
data.evidence.length > 100)
|
|
203
|
+
invalid("Complete the selected review decisions and evidence before submission.");
|
|
204
|
+
const reviews = data.reviews.map((raw) => {
|
|
205
|
+
const review = record(raw);
|
|
206
|
+
if (review.disposition !== "accept-interpretation")
|
|
207
|
+
invalid("Each selected review requires an explicit accept-interpretation decision.");
|
|
208
|
+
const { disposition: _disposition, ...decision } = review;
|
|
209
|
+
return decision;
|
|
210
|
+
});
|
|
211
|
+
const evidence = data.evidence.map((raw) => {
|
|
212
|
+
const entry = record(raw);
|
|
213
|
+
exact(entry, ["id", "kind", "file"]);
|
|
214
|
+
if (!validPath(entry.file))
|
|
215
|
+
invalid("Select the actual quality review evidence file.");
|
|
216
|
+
return { ...entry, sha256: captureEvidence(entry.file).sha256 };
|
|
217
|
+
});
|
|
218
|
+
return parseFoundryQualityReviewInput({
|
|
219
|
+
...data,
|
|
220
|
+
schema: FOUNDRY_QUALITY_REVIEW_INPUT_SCHEMA,
|
|
221
|
+
reviews,
|
|
222
|
+
evidence,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
export function selectFoundryQualityReviewInput(context, descriptorFile) {
|
|
226
|
+
let total = 0;
|
|
227
|
+
const captured = new Map();
|
|
228
|
+
const capture = (name) => {
|
|
229
|
+
if (!validPath(name))
|
|
230
|
+
invalid("Quality review input path is invalid.");
|
|
231
|
+
const target = path.resolve(context.workspaceRoot, name);
|
|
232
|
+
if (migrationCredentialPath(path.relative(context.workspaceRoot, target)))
|
|
233
|
+
invalid("Credential paths cannot be quality review inputs.");
|
|
234
|
+
assertNotFoundrySessionFile(target, context.accountIntent?.sessionReference);
|
|
235
|
+
const previous = captured.get(target);
|
|
236
|
+
if (previous) {
|
|
237
|
+
readSelectedSemanticBytes(previous);
|
|
238
|
+
return previous;
|
|
239
|
+
}
|
|
240
|
+
const stat = fs.lstatSync(target);
|
|
241
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 8 * 1024 * 1024)
|
|
242
|
+
invalid("Quality review inputs must be bounded regular files.");
|
|
243
|
+
total += stat.size;
|
|
244
|
+
if (total > 64 * 1024 * 1024)
|
|
245
|
+
invalid("Quality review inputs exceed the 64 MiB batch limit.");
|
|
246
|
+
const fact = Object.freeze(captureFoundryInput(target));
|
|
247
|
+
captured.set(target, fact);
|
|
248
|
+
return fact;
|
|
249
|
+
};
|
|
250
|
+
const descriptor = capture(descriptorFile);
|
|
251
|
+
let spec;
|
|
252
|
+
try {
|
|
253
|
+
spec = materializeFoundryQualityReviewInput(JSON.parse(strictText(descriptor)), capture);
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
invalid("Select a complete supported quality review input descriptor.");
|
|
257
|
+
}
|
|
258
|
+
if (spec.binding.workspace_id !== context.workspaceId ||
|
|
259
|
+
spec.binding.task_id !== context.taskId ||
|
|
260
|
+
spec.binding.actor_id !== context.actorId ||
|
|
261
|
+
!context.accountIntent ||
|
|
262
|
+
spec.binding.project_ref !== context.accountIntent.projectRef ||
|
|
263
|
+
spec.binding.user_id !== context.accountIntent.userId)
|
|
264
|
+
invalid("Quality review selection belongs to another workspace, task, actor or account.");
|
|
265
|
+
const evidence = spec.evidence.map((entry) => {
|
|
266
|
+
const fact = capture(entry.file);
|
|
267
|
+
if (fact.sha256 !== entry.sha256)
|
|
268
|
+
invalid("Quality review evidence differs from the selected digest.");
|
|
269
|
+
if (!strictText(fact).trim())
|
|
270
|
+
invalid("Quality review evidence must contain the actual decision or source-model evidence.");
|
|
271
|
+
return fact;
|
|
272
|
+
});
|
|
273
|
+
if (new Set([descriptor.path, ...evidence.map((fact) => fact.path)]).size !== evidence.length + 1)
|
|
274
|
+
invalid("Select each quality review file only once.");
|
|
275
|
+
const result = Object.freeze({ spec, descriptor, evidence: Object.freeze(evidence) });
|
|
276
|
+
selections.add(result);
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
export function assertSelectedFoundryQualityReviewInput(value) {
|
|
280
|
+
if (!selections.has(value))
|
|
281
|
+
invalid("Quality review input must be selected by the current host.");
|
|
282
|
+
for (const fact of [value.descriptor, ...value.evidence])
|
|
283
|
+
readSelectedSemanticBytes(fact);
|
|
284
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Verify the existing cleanup producer's explicit validation-context proof. Never transform rows. */
|
|
2
|
+
export declare function unchangedQualityReviewRows(input: {
|
|
3
|
+
originalRows: readonly unknown[];
|
|
4
|
+
finalRowsFile: string;
|
|
5
|
+
taskRoot: string;
|
|
6
|
+
assetRoot: string;
|
|
7
|
+
cleanupReport?: unknown;
|
|
8
|
+
referenceFiles: readonly {
|
|
9
|
+
path: string;
|
|
10
|
+
bytes: number;
|
|
11
|
+
sha256: string;
|
|
12
|
+
}[];
|
|
13
|
+
}): boolean;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { captureFoundryInput } from "./foundry-runtime-context.js";
|
|
4
|
+
import { sha256Json as cleanupProofSha256 } from "./import-curation/internal/hash-utils.js";
|
|
5
|
+
import { canonicalPayloadSha256 } from "./post-write-root-proof.js";
|
|
6
|
+
import { readRows } from "./import-curation/internal/runtime-io.js";
|
|
7
|
+
import { datasetIdentity, unwrapDatasetPayload, } from "./import-curation/internal/dataset-payload.js";
|
|
8
|
+
function object(value) {
|
|
9
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
10
|
+
}
|
|
11
|
+
function same(a, b) {
|
|
12
|
+
return canonicalPayloadSha256(a) === canonicalPayloadSha256(b);
|
|
13
|
+
}
|
|
14
|
+
/** Verify the existing cleanup producer's explicit validation-context proof. Never transform rows. */
|
|
15
|
+
export function unchangedQualityReviewRows(input) {
|
|
16
|
+
const rows = readRows(input.finalRowsFile);
|
|
17
|
+
if (same(rows, input.originalRows))
|
|
18
|
+
return true;
|
|
19
|
+
if (typeof input.cleanupReport !== "string" ||
|
|
20
|
+
!input.referenceFiles.length ||
|
|
21
|
+
rows.length !== input.originalRows.length)
|
|
22
|
+
return false;
|
|
23
|
+
const reportFile = path.resolve(input.assetRoot, input.cleanupReport);
|
|
24
|
+
if (!fs.realpathSync(reportFile).startsWith(`${fs.realpathSync(input.taskRoot)}${path.sep}`))
|
|
25
|
+
return false;
|
|
26
|
+
const report = object(JSON.parse(fs.readFileSync(reportFile, "utf8")));
|
|
27
|
+
const proof = object(report?.process_validation_references);
|
|
28
|
+
if (report?.command !== "dataset-curation-cleanup" ||
|
|
29
|
+
report.status !== "completed" ||
|
|
30
|
+
report.dataset_type !== "process" ||
|
|
31
|
+
report.remote_write_mode !== "read-only" ||
|
|
32
|
+
typeof report.rows_file !== "string" ||
|
|
33
|
+
typeof report.cleaned_rows_file !== "string" ||
|
|
34
|
+
path.resolve(input.assetRoot, report.cleaned_rows_file) !== input.finalRowsFile ||
|
|
35
|
+
!proof ||
|
|
36
|
+
!Array.isArray(proof.files) ||
|
|
37
|
+
!Array.isArray(proof.rows) ||
|
|
38
|
+
proof.rows.length !== rows.length)
|
|
39
|
+
return false;
|
|
40
|
+
const sourceFile = path.resolve(input.assetRoot, report.rows_file);
|
|
41
|
+
if (!same(readRows(sourceFile), input.originalRows))
|
|
42
|
+
return false;
|
|
43
|
+
if (proof.files.length !== input.referenceFiles.length)
|
|
44
|
+
return false;
|
|
45
|
+
const documents = new Map();
|
|
46
|
+
const documentKey = (value) => {
|
|
47
|
+
const identity = datasetIdentity(value, 0, "flow");
|
|
48
|
+
return JSON.stringify([identity.id, identity.version]);
|
|
49
|
+
};
|
|
50
|
+
for (const [index, original] of input.referenceFiles.entries()) {
|
|
51
|
+
const recorded = object(proof.files[index]);
|
|
52
|
+
if (!recorded ||
|
|
53
|
+
typeof recorded.path !== "string" ||
|
|
54
|
+
recorded.bytes !== original.bytes ||
|
|
55
|
+
recorded.sha256 !== original.sha256 ||
|
|
56
|
+
path.resolve(input.assetRoot, recorded.path) !== original.path)
|
|
57
|
+
return false;
|
|
58
|
+
const observed = captureFoundryInput(original.path);
|
|
59
|
+
if (observed.bytes !== original.bytes || observed.sha256 !== original.sha256)
|
|
60
|
+
return false;
|
|
61
|
+
for (const row of readRows(original.path)) {
|
|
62
|
+
const payload = unwrapDatasetPayload(row, "flow");
|
|
63
|
+
if (object(payload)?.flowDataSet) {
|
|
64
|
+
const key = documentKey(payload), previous = documents.get(key);
|
|
65
|
+
if (previous && !same(previous, payload))
|
|
66
|
+
return false;
|
|
67
|
+
documents.set(key, payload);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return rows.every((row, index) => {
|
|
72
|
+
const before = input.originalRows[index], original = datasetIdentity(before, index, "process"), current = datasetIdentity(row, index, "process");
|
|
73
|
+
if (original.id !== current.id ||
|
|
74
|
+
original.version !== current.version ||
|
|
75
|
+
!same(original.payload, current.payload))
|
|
76
|
+
return false;
|
|
77
|
+
const expectedWrapper = original.payload === before ? { json: original.payload } : { ...object(before) };
|
|
78
|
+
const actualWrapper = { ...object(row) };
|
|
79
|
+
delete expectedWrapper.semantic_context;
|
|
80
|
+
delete actualWrapper.semantic_context;
|
|
81
|
+
if (!same(expectedWrapper, actualWrapper))
|
|
82
|
+
return false;
|
|
83
|
+
const sourceContext = object(object(before)?.semantic_context) ?? {};
|
|
84
|
+
const finalContext = object(object(row)?.semantic_context);
|
|
85
|
+
const flowDocuments = finalContext?.flow_documents;
|
|
86
|
+
if (!finalContext || !Array.isArray(flowDocuments))
|
|
87
|
+
return false;
|
|
88
|
+
const { flow_documents: priorDocuments, ...priorOther } = sourceContext;
|
|
89
|
+
const { flow_documents: _currentDocuments, ...currentOther } = finalContext;
|
|
90
|
+
if (!same(priorOther, currentOther) ||
|
|
91
|
+
(priorDocuments !== undefined && !Array.isArray(priorDocuments)))
|
|
92
|
+
return false;
|
|
93
|
+
const prior = Array.isArray(priorDocuments) ? priorDocuments : [];
|
|
94
|
+
if (flowDocuments.length < prior.length ||
|
|
95
|
+
prior.some((value, i) => !same(value, flowDocuments[i])))
|
|
96
|
+
return false;
|
|
97
|
+
const process = object(object(current.payload)?.processDataSet), exchanges = object(process?.exchanges)?.exchange;
|
|
98
|
+
const refs = (Array.isArray(exchanges) ? exchanges : exchanges ? [exchanges] : []).flatMap((value) => {
|
|
99
|
+
const ref = object(object(value)?.referenceToFlowDataSet);
|
|
100
|
+
return ref ? [JSON.stringify([ref["@refObjectId"], ref["@version"]])] : [];
|
|
101
|
+
});
|
|
102
|
+
const included = new Map();
|
|
103
|
+
for (const document of prior) {
|
|
104
|
+
if (!object(document)?.flowDataSet)
|
|
105
|
+
return false;
|
|
106
|
+
const key = documentKey(document), selected = documents.get(key), earlier = included.get(key);
|
|
107
|
+
if ((selected && !same(selected, document)) || (earlier && !same(earlier, document)))
|
|
108
|
+
return false;
|
|
109
|
+
included.set(key, document);
|
|
110
|
+
}
|
|
111
|
+
const expectedKeys = [...new Set(refs)].filter((key) => documents.has(key) && !included.has(key));
|
|
112
|
+
const added = flowDocuments.slice(prior.length);
|
|
113
|
+
if (added.length !== expectedKeys.length ||
|
|
114
|
+
added.some((document, i) => documentKey(document) !== expectedKeys[i] ||
|
|
115
|
+
!same(document, documents.get(expectedKeys[i]))))
|
|
116
|
+
return false;
|
|
117
|
+
const recorded = object(proof.rows[index]);
|
|
118
|
+
return (recorded?.row_index === index &&
|
|
119
|
+
recorded.input_payload_sha256 === cleanupProofSha256(original.payload) &&
|
|
120
|
+
recorded.output_payload_sha256 === cleanupProofSha256(current.payload) &&
|
|
121
|
+
recorded.flow_documents_sha256 === cleanupProofSha256(flowDocuments));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type FoundryInputFact, type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
2
|
+
import { type QualifiedFoundryRuntime } from "./foundry-runtime-qualification.ts";
|
|
3
|
+
import { type FoundryQualityReviewInput, type SelectedFoundryQualityReviewInput } from "./foundry-quality-review-input.ts";
|
|
4
|
+
import { currentWorkflowState } from "./foundry-workflow-state.ts";
|
|
5
|
+
import type { ArtifactEntry } from "./foundry-task-types.ts";
|
|
6
|
+
type JsonRecord = Record<string, unknown>;
|
|
7
|
+
/** Read-only scope projection, not a review decision or an approval template with default consent. */
|
|
8
|
+
export declare function foundryQualityReviewScope(context: FoundryRuntimeContext, qualificationSha256: string, entries: readonly ArtifactEntry[], state?: ReturnType<typeof currentWorkflowState>): {
|
|
9
|
+
binding: {
|
|
10
|
+
workspace_id: string;
|
|
11
|
+
task_id: string;
|
|
12
|
+
actor_id: string;
|
|
13
|
+
project_ref: string;
|
|
14
|
+
user_id: string;
|
|
15
|
+
profile_id: string;
|
|
16
|
+
profile_sha256: string;
|
|
17
|
+
input_scope_sha256: string;
|
|
18
|
+
};
|
|
19
|
+
runtime_qualification_sha256: string;
|
|
20
|
+
rows_manifest_sha256: string;
|
|
21
|
+
assessment_sha256: string;
|
|
22
|
+
context_sha256: string;
|
|
23
|
+
reference_inputs_sha256: string | null;
|
|
24
|
+
interaction_context_sha256: string | null;
|
|
25
|
+
qa_report_sha256: string;
|
|
26
|
+
qa_findings_sha256: string;
|
|
27
|
+
expected_previous_sha256: string | null;
|
|
28
|
+
candidates: {
|
|
29
|
+
row_index: number;
|
|
30
|
+
id: string;
|
|
31
|
+
version: string;
|
|
32
|
+
payload_sha256: string;
|
|
33
|
+
code: string;
|
|
34
|
+
finding_sha256: string;
|
|
35
|
+
finding: {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
}[];
|
|
39
|
+
input: FoundryInputFact;
|
|
40
|
+
qa: FoundryInputFact;
|
|
41
|
+
rows_content_sha256: string;
|
|
42
|
+
qa_observation_sha256: string;
|
|
43
|
+
} | null;
|
|
44
|
+
/** Mechanical selection material; an untouched draft is deliberately not an accepted input. */
|
|
45
|
+
export declare function createFoundryQualityReviewTemplate(scope: NonNullable<ReturnType<typeof foundryQualityReviewScope>>): {
|
|
46
|
+
schema: "tiangong-foundry.quality-review-draft.v1";
|
|
47
|
+
binding: {
|
|
48
|
+
workspace_id: string;
|
|
49
|
+
task_id: string;
|
|
50
|
+
actor_id: string;
|
|
51
|
+
project_ref: string;
|
|
52
|
+
user_id: string;
|
|
53
|
+
profile_id: string;
|
|
54
|
+
profile_sha256: string;
|
|
55
|
+
input_scope_sha256: string;
|
|
56
|
+
};
|
|
57
|
+
runtime_qualification_sha256: string;
|
|
58
|
+
rows_manifest_sha256: string;
|
|
59
|
+
assessment_sha256: string;
|
|
60
|
+
context_sha256: string;
|
|
61
|
+
reference_inputs_sha256: string | null;
|
|
62
|
+
interaction_context_sha256: string | null;
|
|
63
|
+
qa_report_sha256: string;
|
|
64
|
+
qa_findings_sha256: string;
|
|
65
|
+
expected_previous_sha256: string | null;
|
|
66
|
+
issued_at_utc: string;
|
|
67
|
+
expires_at_utc: string;
|
|
68
|
+
reviews: {
|
|
69
|
+
row_index: number;
|
|
70
|
+
id: string;
|
|
71
|
+
version: string;
|
|
72
|
+
payload_sha256: string;
|
|
73
|
+
code: string;
|
|
74
|
+
finding_sha256: string;
|
|
75
|
+
disposition: null;
|
|
76
|
+
evidence_ids: string[];
|
|
77
|
+
rationale: string;
|
|
78
|
+
}[];
|
|
79
|
+
evidence: {
|
|
80
|
+
id: string;
|
|
81
|
+
kind: "user-decision" | "source-model";
|
|
82
|
+
file: string;
|
|
83
|
+
}[];
|
|
84
|
+
};
|
|
85
|
+
export declare function recordFoundryQualityReview(context: FoundryRuntimeContext, qualified: QualifiedFoundryRuntime, entries: readonly ArtifactEntry[], selected: SelectedFoundryQualityReviewInput): Promise<import("./foundry-task-types.ts").JsonRecord>;
|
|
86
|
+
export interface FoundryQualityReview {
|
|
87
|
+
readonly receipt_sha256: string;
|
|
88
|
+
readonly expires_at_utc: string;
|
|
89
|
+
readonly spec: FoundryQualityReviewInput;
|
|
90
|
+
readonly rows_content_sha256: string;
|
|
91
|
+
readonly qa_observation_sha256: string;
|
|
92
|
+
readonly qaReferenceRows: readonly string[];
|
|
93
|
+
readonly validate: () => void;
|
|
94
|
+
readonly rowsMatch: (rowsFile: string, cleanupReport?: unknown) => boolean;
|
|
95
|
+
}
|
|
96
|
+
export declare function loadFoundryQualityReview(context: FoundryRuntimeContext, qualified: QualifiedFoundryRuntime, entries: readonly ArtifactEntry[]): FoundryQualityReview | null;
|
|
97
|
+
/** Called by the existing curation owner after fresh QA, including on cleaned final rows. */
|
|
98
|
+
export declare function reviewedFoundryQualityFindings(review: unknown, rowsFile: string, qaReport: JsonRecord, findings: readonly JsonRecord[], cleanupReport?: unknown): {
|
|
99
|
+
row_index: number;
|
|
100
|
+
id: string;
|
|
101
|
+
version: string;
|
|
102
|
+
payload_sha256: string;
|
|
103
|
+
finding_sha256: string;
|
|
104
|
+
code: "process_material_balance_deviation";
|
|
105
|
+
evidence_ids: readonly string[];
|
|
106
|
+
rationale: string;
|
|
107
|
+
finding: JsonRecord;
|
|
108
|
+
receipt_sha256: string;
|
|
109
|
+
}[];
|
|
110
|
+
/** Recheck local review evidence at write admission; this function grants no write capability. */
|
|
111
|
+
export declare function assertFoundryQualityReviewForExecution(context: FoundryRuntimeContext, qualified: QualifiedFoundryRuntime, entries: readonly ArtifactEntry[], finalRowsFile: string): void;
|
|
112
|
+
export {};
|