@tiangong-lca/foundry 0.1.15 → 0.1.17
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 +5 -5
- package/docs/architecture.md +7 -5
- package/docs/foundry-task-contracts.md +3 -3
- package/docs/package-distribution-contract.md +12 -10
- package/docs/public-runtime-contract.md +8 -4
- package/docs/runtime-context-contract.md +5 -5
- package/docs/task-authorization-contract.md +3 -3
- package/package-dist/assets/foundry-package-descriptor.json +57 -37
- 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-preparation-cli-validation.d.ts +20 -0
- package/package-dist/scripts/lib/foundry-preparation-cli-validation.js +191 -0
- 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-workflow-assessment.js +47 -9
- package/package-dist/scripts/lib/foundry-workflow-io.js +3 -2
- package/package-dist/scripts/lib/foundry-workflow-state.js +10 -0
- package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +5 -1
- package/package-dist/scripts/lib/import-curation/curation-gate.js +29 -1
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
- package/package-dist/scripts/lib/tidas-adapter.js +38 -15
- package/package-dist/scripts/lib/tidas-process-flow-context.d.ts +12 -0
- package/package-dist/scripts/lib/tidas-process-flow-context.js +96 -0
- package/package.json +2 -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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { sha256Json } from "./identity-preflight-proof.js";
|
|
2
|
+
function record(value) {
|
|
3
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
4
|
+
}
|
|
5
|
+
/** Preserve explicit owner-row Flow evidence in one native manifest, rejecting exact identity conflicts. */
|
|
6
|
+
export function augmentTidasProcessFlowContext(rows, payloadForRow, identityForPayload) {
|
|
7
|
+
const documents = [...rows];
|
|
8
|
+
const supplementalOwners = new Map();
|
|
9
|
+
const exactFlows = new Map();
|
|
10
|
+
for (const [ordinal, row] of rows.entries()) {
|
|
11
|
+
const flow = payloadForRow(row);
|
|
12
|
+
if (!record(flow.flowDataSet))
|
|
13
|
+
continue;
|
|
14
|
+
const identity = identityForPayload(flow, "flowDataSet", "flowInformation");
|
|
15
|
+
if (!identity.id || !identity.version)
|
|
16
|
+
continue;
|
|
17
|
+
const key = JSON.stringify([identity.id, identity.version]);
|
|
18
|
+
const hash = sha256Json(flow);
|
|
19
|
+
const prior = exactFlows.get(key);
|
|
20
|
+
if (prior && prior.hash !== hash)
|
|
21
|
+
throw new Error("tidas_flow_context_identity_conflict");
|
|
22
|
+
if (!prior)
|
|
23
|
+
exactFlows.set(key, { hash, ordinal });
|
|
24
|
+
}
|
|
25
|
+
for (const [owner, row] of rows.entries()) {
|
|
26
|
+
if (!record(payloadForRow(row).processDataSet))
|
|
27
|
+
continue;
|
|
28
|
+
const context = record(row.semantic_context);
|
|
29
|
+
const flows = context?.flow_documents;
|
|
30
|
+
if (!Array.isArray(flows))
|
|
31
|
+
continue;
|
|
32
|
+
for (const [flowIndex, raw] of flows.entries()) {
|
|
33
|
+
const flow = record(raw);
|
|
34
|
+
if (!flow || !record(flow.flowDataSet))
|
|
35
|
+
throw new Error("tidas_flow_context_document_invalid");
|
|
36
|
+
const identity = identityForPayload(flow, "flowDataSet", "flowInformation");
|
|
37
|
+
const key = JSON.stringify([identity.id, identity.version]);
|
|
38
|
+
const hash = sha256Json(flow);
|
|
39
|
+
const existing = identity.id && identity.version ? exactFlows.get(key) : undefined;
|
|
40
|
+
if (existing && existing.hash !== hash)
|
|
41
|
+
throw new Error("tidas_flow_context_identity_conflict");
|
|
42
|
+
const ordinal = existing?.ordinal ?? documents.length;
|
|
43
|
+
if (!existing) {
|
|
44
|
+
documents.push(flow);
|
|
45
|
+
if (identity.id && identity.version)
|
|
46
|
+
exactFlows.set(key, { hash, ordinal });
|
|
47
|
+
}
|
|
48
|
+
if (!supplementalOwners.has(ordinal))
|
|
49
|
+
supplementalOwners.set(ordinal, new Map(ordinal < rows.length ? [[ordinal, ""]] : []));
|
|
50
|
+
supplementalOwners.get(ordinal).set(owner, `/semantic_context/flow_documents/${flowIndex}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { documents, supplementalOwners };
|
|
54
|
+
}
|
|
55
|
+
/** Admit the native profile's transport coverage without deciding scientific validity. */
|
|
56
|
+
export function assertTidasProcessCoverage(coverage, binaryVersion, processCount, invalidProcessCount) {
|
|
57
|
+
const versionParts = binaryVersion.split(".").map(Number);
|
|
58
|
+
const requiresCoverage = processCount > 0 &&
|
|
59
|
+
(coverage || (versionParts[0] === 0 && versionParts[1] === 3 && versionParts[2] >= 4));
|
|
60
|
+
if (requiresCoverage &&
|
|
61
|
+
(!coverage ||
|
|
62
|
+
coverage.profile !== "tidas.process-allocation-reference.v1" ||
|
|
63
|
+
coverage.process_count !== processCount ||
|
|
64
|
+
typeof coverage.complete !== "boolean" ||
|
|
65
|
+
!record(coverage.checks)))
|
|
66
|
+
throw new Error("tidas_process_semantic_coverage_invalid");
|
|
67
|
+
if (coverage && coverage.complete === false && invalidProcessCount === 0)
|
|
68
|
+
throw new Error("tidas_process_semantic_coverage_incomplete");
|
|
69
|
+
if (coverage && processCount > 0) {
|
|
70
|
+
const checks = record(coverage.checks);
|
|
71
|
+
let unresolved = 0;
|
|
72
|
+
let invalid = 0;
|
|
73
|
+
// Native 0.3.4 contracts.rs aggregates emitted checks, not a fixed seven-key map.
|
|
74
|
+
// Unconditional valid-Process checks remain mandatory; invalid schema input may omit them.
|
|
75
|
+
if (invalidProcessCount === 0 &&
|
|
76
|
+
[
|
|
77
|
+
"allocation-target-type",
|
|
78
|
+
"allocation-vector",
|
|
79
|
+
"exchange-identity",
|
|
80
|
+
"quantitative-reference",
|
|
81
|
+
].some((name) => !record(checks[name])))
|
|
82
|
+
throw new Error("tidas_process_semantic_coverage_invalid");
|
|
83
|
+
for (const value of Object.values(checks)) {
|
|
84
|
+
const check = record(value);
|
|
85
|
+
if (!check ||
|
|
86
|
+
["passed", "invalid", "unresolved", "not_applicable"].some((key) => !Number.isSafeInteger(check[key]) || Number(check[key]) < 0))
|
|
87
|
+
throw new Error("tidas_process_semantic_coverage_invalid");
|
|
88
|
+
unresolved += Number(check.unresolved);
|
|
89
|
+
invalid += Number(check.invalid);
|
|
90
|
+
}
|
|
91
|
+
if (coverage.complete !== (unresolved === 0))
|
|
92
|
+
throw new Error("tidas_process_semantic_coverage_invalid");
|
|
93
|
+
if ((unresolved > 0 || invalid > 0) && invalidProcessCount === 0)
|
|
94
|
+
throw new Error("tidas_process_semantic_coverage_incomplete");
|
|
95
|
+
}
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiangong-lca/foundry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Control plane for TianGong LCA external dataset import and TIDAS authoring work.",
|
|
6
6
|
"repository": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"license": "MIT",
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@tiangong-lca/cli": "0.1.
|
|
85
|
+
"@tiangong-lca/cli": "0.1.27"
|
|
86
86
|
},
|
|
87
87
|
"foundryRuntime": {
|
|
88
88
|
"schema": "tiangong-foundry.runtime-layout.v2",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"const": "@tiangong-lca/foundry"
|
|
19
19
|
},
|
|
20
20
|
"version": {
|
|
21
|
-
"const": "0.1.
|
|
21
|
+
"const": "0.1.17"
|
|
22
22
|
},
|
|
23
23
|
"cli_dependency": {
|
|
24
24
|
"type": "object",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"const": "@tiangong-lca/cli"
|
|
30
30
|
},
|
|
31
31
|
"version": {
|
|
32
|
-
"const": "0.1.
|
|
32
|
+
"const": "0.1.27"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
},
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"additionalProperties": false,
|
|
15
15
|
"required": ["package_version", "platform", "content_sha256", "node_version", "node_sha256"],
|
|
16
16
|
"properties": {
|
|
17
|
-
"package_version": { "const": "0.1.
|
|
17
|
+
"package_version": { "const": "0.1.27" },
|
|
18
18
|
"platform": {
|
|
19
19
|
"enum": ["linux-x64", "linux-arm64", "darwin-arm64", "win32-x64"]
|
|
20
20
|
},
|