@tiangong-lca/foundry 0.1.18 → 0.1.19
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/docs/package-distribution-contract.md +5 -5
- package/docs/public-runtime-contract.md +12 -0
- package/docs/runtime-context-contract.md +2 -0
- package/package-dist/assets/foundry-package-descriptor.json +268 -98
- package/package-dist/scripts/foundry-facade.js +3 -0
- package/package-dist/scripts/foundry-runtime.d.ts +1 -1
- package/package-dist/scripts/lib/decision-owners/identity-preflight.js +3 -1
- package/package-dist/scripts/lib/finalize-owners/cli-wrappers.d.ts +72 -1
- package/package-dist/scripts/lib/finalize-owners/cli-wrappers.js +123 -3
- package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +9 -0
- package/package-dist/scripts/lib/finalize-owners/post-authoring.js +37 -8
- package/package-dist/scripts/lib/foundry-authentication-environment.js +1 -1
- package/package-dist/scripts/lib/foundry-curation-queue.d.ts +73 -0
- package/package-dist/scripts/lib/foundry-curation-queue.js +261 -0
- package/package-dist/scripts/lib/foundry-edge-draft-admission.d.ts +17 -0
- package/package-dist/scripts/lib/foundry-edge-draft-admission.js +94 -0
- package/package-dist/scripts/lib/foundry-edge-identity-preflight.d.ts +47 -0
- package/package-dist/scripts/lib/foundry-edge-identity-preflight.js +268 -0
- package/package-dist/scripts/lib/foundry-edge-oauth.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-edge-oauth.js +154 -0
- package/package-dist/scripts/lib/foundry-edge-reference-intent.d.ts +51 -0
- package/package-dist/scripts/lib/foundry-edge-reference-intent.js +184 -0
- package/package-dist/scripts/lib/foundry-edge-repair-preparation.d.ts +21 -0
- package/package-dist/scripts/lib/foundry-edge-repair-preparation.js +120 -0
- package/package-dist/scripts/lib/foundry-edge-session.d.ts +15 -0
- package/package-dist/scripts/lib/foundry-edge-session.js +69 -0
- package/package-dist/scripts/lib/foundry-edge-support-plan.d.ts +69 -0
- package/package-dist/scripts/lib/foundry-edge-support-plan.js +245 -0
- package/package-dist/scripts/lib/foundry-edge-support-planning.d.ts +115 -0
- package/package-dist/scripts/lib/foundry-edge-support-planning.js +259 -0
- package/package-dist/scripts/lib/foundry-edge-support.d.ts +19 -0
- package/package-dist/scripts/lib/foundry-edge-support.js +188 -0
- package/package-dist/scripts/lib/foundry-execution-admission.d.ts +4 -2
- package/package-dist/scripts/lib/foundry-execution-admission.js +24 -2
- package/package-dist/scripts/lib/foundry-finalize-edge-identity.d.ts +30 -0
- package/package-dist/scripts/lib/foundry-finalize-edge-identity.js +102 -0
- package/package-dist/scripts/lib/foundry-finalize-owners.d.ts +1 -0
- package/package-dist/scripts/lib/foundry-finalize-owners.js +68 -2
- package/package-dist/scripts/lib/foundry-managed-authentication.js +1 -1
- package/package-dist/scripts/lib/foundry-owner-execution-store.d.ts +16 -16
- package/package-dist/scripts/lib/foundry-owner-execution-store.js +34 -7
- package/package-dist/scripts/lib/foundry-owner-readback.d.ts +20 -0
- package/package-dist/scripts/lib/foundry-owner-readback.js +42 -0
- 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.js +71 -0
- package/package-dist/scripts/lib/foundry-process-mass-balance.d.ts +64 -0
- package/package-dist/scripts/lib/foundry-process-mass-balance.js +224 -0
- package/package-dist/scripts/lib/foundry-process-qa.d.ts +19 -0
- package/package-dist/scripts/lib/foundry-process-qa.js +423 -0
- package/package-dist/scripts/lib/foundry-repair-execution.js +13 -2
- package/package-dist/scripts/lib/foundry-runtime-environment.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-runtime-environment.js +18 -0
- package/package-dist/scripts/lib/foundry-runtime-identity.d.ts +1 -0
- package/package-dist/scripts/lib/foundry-runtime-identity.js +19 -1
- package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
- package/package-dist/scripts/lib/foundry-runtime-utils.d.ts +1 -0
- package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
- package/package-dist/scripts/lib/foundry-typed-authoring-patch.d.ts +76 -0
- package/package-dist/scripts/lib/foundry-typed-authoring-patch.js +237 -0
- package/package-dist/scripts/lib/foundry-typed-context.d.ts +11 -0
- package/package-dist/scripts/lib/foundry-typed-context.js +79 -0
- package/package-dist/scripts/lib/foundry-typed-flow-qa.d.ts +166 -0
- package/package-dist/scripts/lib/foundry-typed-flow-qa.js +226 -0
- package/package-dist/scripts/lib/foundry-typed-model-write.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-typed-model-write.js +59 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.js +67 -29
- package/package-dist/scripts/lib/foundry-workflow-authorization.js +82 -1
- package/package-dist/scripts/lib/foundry-workflow-context.js +59 -18
- package/package-dist/scripts/lib/foundry-workflow-execution.js +54 -5
- package/package-dist/scripts/lib/foundry-workflow-finalize.js +27 -3
- package/package-dist/scripts/lib/foundry-workflow-identity-stage.js +202 -161
- package/package-dist/scripts/lib/foundry-workflow-identity.js +16 -10
- package/package-dist/scripts/lib/foundry-workflow-io.js +27 -6
- package/package-dist/scripts/lib/foundry-workflow-reference-verify.js +102 -29
- package/package-dist/scripts/lib/foundry-workflow-repair.js +53 -2
- package/package-dist/scripts/lib/foundry-workflow-semantic.js +41 -21
- package/package-dist/scripts/lib/identity-preflight-proof.d.ts +1 -0
- package/package-dist/scripts/lib/identity-preflight-proof.js +19 -12
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
- 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
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
1
3
|
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { runFoundryTypedDatasetQa } from "./foundry-typed-flow-qa.js";
|
|
5
|
+
import { isFoundryEdgeDraftType } from "./foundry-edge-support-plan.js";
|
|
6
|
+
import { planFoundryEdgeSupportStage } from "./foundry-edge-support-planning.js";
|
|
7
|
+
import { buildFoundryCurationQueue } from "./foundry-curation-queue.js";
|
|
2
8
|
import { bindWorkflowChildExecution, workflowChildFailure, } from "./foundry-workflow-child-failure.js";
|
|
3
9
|
import { parseScalar } from "./foundry-args.js";
|
|
4
10
|
import { createFoundryRuntimeUtils, resolveTiangongLcaCliRuntimeCommand, } from "./foundry-runtime-utils.js";
|
|
@@ -29,7 +35,7 @@ import { datasetIdentity, unwrapDatasetPayload, } from "./import-curation/intern
|
|
|
29
35
|
import { workflowObject } from "./foundry-workflow-state.js";
|
|
30
36
|
import { assertWorkflowReportArtifact, runWorkflowLocalCliResult } from "./foundry-workflow-io.js";
|
|
31
37
|
import { createFoundryIsolatedChildEnvironment } from "./foundry-runtime-environment.js";
|
|
32
|
-
import { FoundryContextError, readFoundryInput, } from "./foundry-runtime-context.js";
|
|
38
|
+
import { FoundryContextError, readFoundryInput, resolveFoundryOutput, writeFoundryArtifact, } from "./foundry-runtime-context.js";
|
|
33
39
|
import { assertQualifiedFoundryRuntime, } from "./foundry-runtime-qualification.js";
|
|
34
40
|
function bind(factory, dependencies) {
|
|
35
41
|
return factory(dependencies);
|
|
@@ -40,6 +46,18 @@ export function createFoundryFinalizeOwners(context, qualified, temporary, execu
|
|
|
40
46
|
const runtime = createFoundryRuntimeUtils({ parseScalar, repoRoot: context.assetRoot });
|
|
41
47
|
const rows = createTidasRowUtils({ ...runtime, bundleRowTypes });
|
|
42
48
|
const localEnvironment = createFoundryIsolatedChildEnvironment({ tempRoot: temporary });
|
|
49
|
+
const readStageRows = (file) => {
|
|
50
|
+
const selected = runtime.resolveRepoPath(file);
|
|
51
|
+
if (execution.outputRoot) {
|
|
52
|
+
const relative = path.relative(execution.outputRoot, selected);
|
|
53
|
+
if (relative &&
|
|
54
|
+
relative !== ".." &&
|
|
55
|
+
!relative.startsWith(`..${path.sep}`) &&
|
|
56
|
+
!path.isAbsolute(relative))
|
|
57
|
+
return fs.readFileSync(assertWorkflowReportArtifact(context, selected, execution.outputRoot));
|
|
58
|
+
}
|
|
59
|
+
return readFoundryInput(context, selected);
|
|
60
|
+
};
|
|
43
61
|
const cli = resolveTiangongLcaCliRuntimeCommand({});
|
|
44
62
|
const base = {
|
|
45
63
|
...runtime,
|
|
@@ -88,7 +106,27 @@ export function createFoundryFinalizeOwners(context, qualified, temporary, execu
|
|
|
88
106
|
const finalizeUtils = bind(createPostAuthoringFinalizeUtils, {
|
|
89
107
|
...base,
|
|
90
108
|
...references,
|
|
91
|
-
cliWrapperCommands:
|
|
109
|
+
cliWrapperCommands: qualified.cli.expectation.package_version === "0.4.0"
|
|
110
|
+
? {
|
|
111
|
+
...cliWrappers,
|
|
112
|
+
runDatasetCurationQueueBuild: (options) => {
|
|
113
|
+
const file = (value) => resolveFoundryOutput(context, String(value));
|
|
114
|
+
const processes = file(options.processes);
|
|
115
|
+
return buildFoundryCurationQueue({
|
|
116
|
+
processes,
|
|
117
|
+
flows: options.flows ? runtime.resolveRepoPath(options.flows) : null,
|
|
118
|
+
support: runtime
|
|
119
|
+
.normalizedList(options.support)
|
|
120
|
+
.map((name) => runtime.resolveRepoPath(name)),
|
|
121
|
+
external: runtime
|
|
122
|
+
.normalizedList(options.externalFlowRef)
|
|
123
|
+
.map((name) => runtime.resolveRepoPath(name)),
|
|
124
|
+
outDir: file(options.outDir),
|
|
125
|
+
readInput: readStageRows,
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
: cliWrappers,
|
|
92
130
|
identityPreflightCommands: identityCommands,
|
|
93
131
|
executionEnvironment: execution.environment,
|
|
94
132
|
readRowsFile: (file) => runtime.readRowsFile(file).map((row) => unwrapDatasetPayload(row, "")),
|
|
@@ -121,6 +159,34 @@ export function createFoundryFinalizeOwners(context, qualified, temporary, execu
|
|
|
121
159
|
const remoteRead = name === "dataset verify-remote";
|
|
122
160
|
if (argv.some((arg) => /^--(?:commit|execute)(?:=|$)/u.test(arg)))
|
|
123
161
|
throw new FoundryContextError("finalize_write_forbidden", "Finalization cannot dispatch a remote mutation.");
|
|
162
|
+
const supportType = execution.datasetType;
|
|
163
|
+
if (qualified.cli.expectation.package_version === "0.4.0" &&
|
|
164
|
+
isFoundryEdgeDraftType(supportType) &&
|
|
165
|
+
(dryRun || remoteRead)) {
|
|
166
|
+
return planFoundryEdgeSupportStage(context, qualified, execution.environment, supportType, stage, argv, remoteRead, execution.receiptFile);
|
|
167
|
+
}
|
|
168
|
+
const qaType = argv[0] === "qa" ? argv[1] : null;
|
|
169
|
+
if (qualified.cli.expectation.package_version === "0.4.0" &&
|
|
170
|
+
(qaType === "flow" || qaType === "process" || qaType === "lifecyclemodel")) {
|
|
171
|
+
const rowsFile = argv[argv.indexOf("--rows-file") + 1];
|
|
172
|
+
const directory = argv[argv.indexOf("--out-dir") + 1];
|
|
173
|
+
const result = runFoundryTypedDatasetQa(context, qualified, temporary, (file, value) => writeFoundryArtifact(context, file, JSON.stringify(value, null, 2) + "\n"), qaType, rowsFile, directory, {
|
|
174
|
+
readRowsFile: (file) => readStageRows(file).toString("utf8"),
|
|
175
|
+
referenceFiles: argv.flatMap((value, index) => value === "--reference-rows-file" ? [argv[index + 1]] : []),
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
stage,
|
|
179
|
+
exit_code: result.exit || (qaType !== "process" && result.report.findings.length) ? 2 : 0,
|
|
180
|
+
report: result.report,
|
|
181
|
+
...(qaType === "process"
|
|
182
|
+
? { cli_validation: { report: result.validationReportFile, exit: result.exit } }
|
|
183
|
+
: {}),
|
|
184
|
+
status: result.report.status,
|
|
185
|
+
command: cli.command,
|
|
186
|
+
args: [...cli.args, "dataset", qaType === "lifecyclemodel" ? "model" : qaType, "validate"],
|
|
187
|
+
stderr: "",
|
|
188
|
+
};
|
|
189
|
+
}
|
|
124
190
|
if (!dryRun && !remoteRead) {
|
|
125
191
|
const result = runWorkflowLocalCliResult(context, qualified, temporary, argv);
|
|
126
192
|
return result.validate(() => {
|
|
@@ -4,7 +4,7 @@ export function createManagedFoundryAuthentication(environment, carrierAdmitted,
|
|
|
4
4
|
if (!carrierAdmitted || environment !== "cli-auth")
|
|
5
5
|
return undefined;
|
|
6
6
|
const mode = source.TIANGONG_LCA_AUTH_MODE || "oauth";
|
|
7
|
-
if (mode === "access_token") {
|
|
7
|
+
if (mode === "access_token" || mode === "access-token") {
|
|
8
8
|
const accessToken = source.TIANGONG_LCA_ACCESS_TOKEN;
|
|
9
9
|
const apiBaseUrl = source.TIANGONG_LCA_API_BASE_URL;
|
|
10
10
|
const publishableKey = source.TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY;
|
|
@@ -21,8 +21,8 @@ declare function buildRequest(context: FoundryRuntimeContext, authorization: Ret
|
|
|
21
21
|
authorization: string;
|
|
22
22
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
23
23
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
24
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
25
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
24
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
25
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
26
26
|
};
|
|
27
27
|
policy: {
|
|
28
28
|
task_id: string;
|
|
@@ -59,8 +59,8 @@ export declare function readOwnerExecutionRequests(context: FoundryRuntimeContex
|
|
|
59
59
|
authorization: string;
|
|
60
60
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
61
61
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
62
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
63
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
62
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
63
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
64
64
|
};
|
|
65
65
|
policy: {
|
|
66
66
|
task_id: string;
|
|
@@ -111,8 +111,8 @@ export declare function inspectOwnerExecutions(context: FoundryRuntimeContext, e
|
|
|
111
111
|
authorization: string;
|
|
112
112
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
113
113
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
114
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
115
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
114
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
115
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
116
116
|
};
|
|
117
117
|
policy: {
|
|
118
118
|
task_id: string;
|
|
@@ -149,8 +149,8 @@ export declare function inspectOwnerExecutions(context: FoundryRuntimeContext, e
|
|
|
149
149
|
authorization: string;
|
|
150
150
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
151
151
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
152
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
153
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
152
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
153
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
154
154
|
};
|
|
155
155
|
policy: {
|
|
156
156
|
task_id: string;
|
|
@@ -188,8 +188,8 @@ export declare function inspectOwnerExecutions(context: FoundryRuntimeContext, e
|
|
|
188
188
|
authorization: string;
|
|
189
189
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
190
190
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
191
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
192
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
191
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
192
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
193
193
|
};
|
|
194
194
|
policy: {
|
|
195
195
|
task_id: string;
|
|
@@ -228,8 +228,8 @@ export declare function completedOwnerScopes(context: FoundryRuntimeContext, ent
|
|
|
228
228
|
authorization: string;
|
|
229
229
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
230
230
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
231
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
232
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
231
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
232
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
233
233
|
};
|
|
234
234
|
policy: {
|
|
235
235
|
task_id: string;
|
|
@@ -266,8 +266,8 @@ export declare function completedOwnerScopes(context: FoundryRuntimeContext, ent
|
|
|
266
266
|
authorization: string;
|
|
267
267
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
268
268
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
269
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
270
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
269
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
270
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
271
271
|
};
|
|
272
272
|
policy: {
|
|
273
273
|
task_id: string;
|
|
@@ -305,8 +305,8 @@ export declare function completedOwnerScopes(context: FoundryRuntimeContext, ent
|
|
|
305
305
|
authorization: string;
|
|
306
306
|
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
307
307
|
capsule: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
308
|
-
commit: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
309
|
-
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
308
|
+
commit: import("./foundry-edge-support-plan.ts").EdgeSupportPlan | import("@tiangong-lca/cli/command-spec").FoundryCommandSpec;
|
|
309
|
+
verify: import("@tiangong-lca/cli/command-spec").FoundryCommandSpec | null;
|
|
310
310
|
};
|
|
311
311
|
policy: {
|
|
312
312
|
task_id: string;
|
|
@@ -9,6 +9,7 @@ import { currentWorkflowState, readWorkflowArtifact, workflowObject, } from "./f
|
|
|
9
9
|
import { runFoundryTaskOperation } from "./foundry-task-store.js";
|
|
10
10
|
import { sha256Json } from "./identity-preflight-proof.js";
|
|
11
11
|
import { assertFoundryInteractionWriteReady } from "./foundry-workflow-object-scope.js";
|
|
12
|
+
import { isEdgeSupportPlan } from "./foundry-edge-support-plan.js";
|
|
12
13
|
function assertOwnerInteractionReady(context, entries, repairScope) {
|
|
13
14
|
if (repairScope)
|
|
14
15
|
return;
|
|
@@ -44,7 +45,13 @@ function buildRequest(context, authorization) {
|
|
|
44
45
|
!context.accountIntent)
|
|
45
46
|
throw new FoundryContextError("execution_request_invalid", "Select a sealed current owner scope.");
|
|
46
47
|
readFoundryInput(context, input.path);
|
|
47
|
-
const commands = workflowObject(handoff.commands)
|
|
48
|
+
const commands = workflowObject(handoff.commands);
|
|
49
|
+
const commit = isEdgeSupportPlan(commands.commit)
|
|
50
|
+
? commands.commit
|
|
51
|
+
: parseFoundryCommandSpec(commands.commit);
|
|
52
|
+
const verify = isEdgeSupportPlan(commit)
|
|
53
|
+
? null
|
|
54
|
+
: parseFoundryCommandSpec(commands.post_write_verify);
|
|
48
55
|
const capsuleFile = resolveFoundryOutput(context, String(capsule.capsule_file));
|
|
49
56
|
const capsuleFact = captureFoundryInput(capsuleFile);
|
|
50
57
|
if (capsuleFact.sha256 !== capsule.capsule_sha256)
|
|
@@ -121,8 +128,18 @@ export function readOwnerExecutionRequests(context, entries) {
|
|
|
121
128
|
request.policy.actor_id !== context.actorId)
|
|
122
129
|
throw new FoundryContextError("execution_request_invalid", "Execution request does not belong to this task.");
|
|
123
130
|
parseBatchItemContract(request.item_contract);
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
if (isEdgeSupportPlan(request.content.commit)) {
|
|
132
|
+
if (request.content.verify !== null ||
|
|
133
|
+
request.content.commit.dataset_type !== request.policy.dataset_type ||
|
|
134
|
+
request.content.commit.user_id !== request.policy.user_id ||
|
|
135
|
+
request.content.commit.project_ref !== request.policy.project_ref ||
|
|
136
|
+
sha256Json(request.content.commit.input) !== sha256Json(request.content.input))
|
|
137
|
+
throw new FoundryContextError("execution_request_invalid", "The Edge draft request differs from the sealed scope.");
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
parseFoundryCommandSpec(request.content.commit);
|
|
141
|
+
parseFoundryCommandSpec(request.content.verify);
|
|
142
|
+
}
|
|
126
143
|
const content = JSON.parse(JSON.stringify(request.content));
|
|
127
144
|
if (request.scope_id !==
|
|
128
145
|
sha256Json({ task: context.taskId, type: request.policy.dataset_type }) ||
|
|
@@ -300,11 +317,21 @@ export function inspectOwnerExecutions(context, entries) {
|
|
|
300
317
|
!Array.isArray(proof.blockers) ||
|
|
301
318
|
proof.blockers.length)
|
|
302
319
|
throw new FoundryContextError("execution_result_invalid", "Execution result has no verified readback.");
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
320
|
+
const edge = isEdgeSupportPlan(item.request.content.commit)
|
|
321
|
+
? item.request.content.commit
|
|
322
|
+
: null;
|
|
323
|
+
if (edge && proof.edge_plan_sha256 !== edge.sha256)
|
|
324
|
+
throw new FoundryContextError("execution_result_invalid", "Readback must bind the original Edge draft plan.");
|
|
325
|
+
const native = !edge &&
|
|
326
|
+
commandSpecOptionValue(item.request.content.commit, "--execution-contract") !== null;
|
|
327
|
+
const referenceSpec = edge ? null : parseFoundryCommandSpec(item.request.content.verify);
|
|
328
|
+
const referenceSelected = Boolean(edge?.reference_intent) ||
|
|
329
|
+
(referenceSpec !== null &&
|
|
330
|
+
commandSpecOptionValue(referenceSpec, "--reference-intent-file") !== null);
|
|
306
331
|
const referenceFacts = referenceSelected ? proof.reference_evidence : [];
|
|
307
|
-
const expectedReferenceFacts =
|
|
332
|
+
const expectedReferenceFacts = edge?.reference_intent && edge.reference_evidence
|
|
333
|
+
? [edge.reference_evidence, ...edge.reference_intent]
|
|
334
|
+
: (referenceSpec?.binding.artifacts.filter((fact) => ["reference_intent", "reference_precommit", "reference_review"].includes(fact.role)) ?? []);
|
|
308
335
|
if (!Array.isArray(referenceFacts) ||
|
|
309
336
|
(referenceSelected &&
|
|
310
337
|
(expectedReferenceFacts.length < 3 ||
|
|
@@ -3,6 +3,26 @@ import { type QualifiedFoundryRuntime } from "./foundry-runtime-qualification.ts
|
|
|
3
3
|
import { type FoundryAuthentication } from "./foundry-runtime-identity.ts";
|
|
4
4
|
import type { OwnerExecutionRequest } from "./foundry-owner-execution-store.ts";
|
|
5
5
|
export declare function readbackFoundryOwner(context: FoundryRuntimeContext, qualified: QualifiedFoundryRuntime, request: OwnerExecutionRequest, authentication?: FoundryAuthentication, commitReport?: string): Promise<{
|
|
6
|
+
output: string;
|
|
7
|
+
proof: {
|
|
8
|
+
schema: string;
|
|
9
|
+
status: string;
|
|
10
|
+
request_scope: string;
|
|
11
|
+
input: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
12
|
+
edge_plan_sha256: string;
|
|
13
|
+
reference_evidence?: import("./foundry-runtime-context-types.ts").FoundryInputFact[] | undefined;
|
|
14
|
+
repair_preparation?: import("./foundry-runtime-context-types.ts").FoundryInputFact | undefined;
|
|
15
|
+
publication_ready?: boolean | undefined;
|
|
16
|
+
report: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
17
|
+
checks: import("./foundry-runtime-context-types.ts").FoundryInputFact;
|
|
18
|
+
blockers: {
|
|
19
|
+
table: string;
|
|
20
|
+
id: string;
|
|
21
|
+
version: string;
|
|
22
|
+
role: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
6
26
|
output: string;
|
|
7
27
|
proof: {
|
|
8
28
|
schema: string;
|
|
@@ -22,6 +22,10 @@ import { readRows, repoRelativePath } from "./import-curation/internal/runtime-i
|
|
|
22
22
|
import { bundleRowTypes } from "./bundle-row-types.js";
|
|
23
23
|
import { workflowObject } from "./foundry-workflow-state.js";
|
|
24
24
|
import { acceptFoundryOwnerTraceDifference } from "./foundry-owner-trace-acceptance.js";
|
|
25
|
+
import { verifySelectedEdgeDraftPlan } from "./foundry-edge-draft-admission.js";
|
|
26
|
+
import { isEdgeSupportPlan } from "./foundry-edge-support-plan.js";
|
|
27
|
+
import { createFoundryEdgeActor } from "./foundry-edge-session.js";
|
|
28
|
+
import { verifyFoundryEdgeSupport } from "./foundry-edge-support.js";
|
|
25
29
|
export async function readbackFoundryOwner(context, qualified, request, authentication = { mode: "oauth" }, commitReport) {
|
|
26
30
|
assertQualifiedFoundryRuntime(context, qualified);
|
|
27
31
|
const repair = await withFoundryTaskMetadata(context, (_, entries) => assertFoundryRepairExecution(context, entries, request));
|
|
@@ -29,6 +33,44 @@ export async function readbackFoundryOwner(context, qualified, request, authenti
|
|
|
29
33
|
if (identity.receipt.project.project_ref !== request.policy.project_ref ||
|
|
30
34
|
identity.receipt.identity.user_id !== request.policy.user_id)
|
|
31
35
|
throw new FoundryContextError("execution_account_mismatch", "Readback account differs from the recorded owner intent.");
|
|
36
|
+
if (isEdgeSupportPlan(request.content.commit)) {
|
|
37
|
+
const plan = request.content.commit;
|
|
38
|
+
verifySelectedEdgeDraftPlan(context, plan, captureFoundryInput(request.content.input.path), request.policy);
|
|
39
|
+
const actor = await createFoundryEdgeActor(context, qualified, authentication);
|
|
40
|
+
const verification = await verifyFoundryEdgeSupport(actor, plan, "after");
|
|
41
|
+
const output = resolveFoundryOutput(context, `outputs/owner-readback/${randomUUID()}`);
|
|
42
|
+
fs.mkdirSync(output, { recursive: true, mode: 0o700 });
|
|
43
|
+
const report = path.join(output, "edge-verification.json");
|
|
44
|
+
const checks = path.join(output, "edge-checks.json");
|
|
45
|
+
fs.writeFileSync(report, JSON.stringify(verification.responses, null, 2) + "\n", {
|
|
46
|
+
mode: 0o600,
|
|
47
|
+
});
|
|
48
|
+
fs.writeFileSync(checks, JSON.stringify(verification.blockers, null, 2) + "\n", {
|
|
49
|
+
mode: 0o600,
|
|
50
|
+
});
|
|
51
|
+
readFoundryInput(context, request.content.input.path);
|
|
52
|
+
const proof = {
|
|
53
|
+
schema: "tiangong-foundry.owner-readback.v1",
|
|
54
|
+
status: verification.blockers.length ? "unresolved" : "verified",
|
|
55
|
+
request_scope: request.scope_id,
|
|
56
|
+
input: request.content.input,
|
|
57
|
+
edge_plan_sha256: plan.sha256,
|
|
58
|
+
...(plan.reference_intent && plan.reference_evidence
|
|
59
|
+
? { reference_evidence: [plan.reference_evidence, ...plan.reference_intent] }
|
|
60
|
+
: {}),
|
|
61
|
+
...(repair && plan.update
|
|
62
|
+
? {
|
|
63
|
+
repair_preparation: captureFoundryInput(repair.preparation.file),
|
|
64
|
+
publication_ready: false,
|
|
65
|
+
}
|
|
66
|
+
: {}),
|
|
67
|
+
report: captureFoundryInput(report),
|
|
68
|
+
checks: captureFoundryInput(checks),
|
|
69
|
+
blockers: verification.blockers,
|
|
70
|
+
};
|
|
71
|
+
fs.writeFileSync(path.join(output, "owner-readback.json"), JSON.stringify(proof, null, 2) + "\n", { mode: 0o600 });
|
|
72
|
+
return { output, proof };
|
|
73
|
+
}
|
|
32
74
|
const source = parseFoundryCommandSpec(request.content.verify), cli = resolveInstalledTiangongLcaCliPackage();
|
|
33
75
|
if (source.executable !== process.execPath ||
|
|
34
76
|
source.argv[0] !== cli.binPath ||
|
|
@@ -2,9 +2,9 @@ export declare const FOUNDRY_PACKAGE_DESCRIPTOR_SCHEMA: "tiangong-foundry.packag
|
|
|
2
2
|
export declare const foundryPackageDescriptorPath: "package-dist/assets/foundry-package-descriptor.json";
|
|
3
3
|
export declare const foundryPackageStaticFiles: readonly ["package-dist/", "specs/import-profiles.json", "specs/prewrite-content-policy.json", "specs/canonical-support/flow-properties-unit-groups.json", "specs/schemas/authorization-derivation.schema.json", "specs/schemas/execution-context.schema.json", "specs/schemas/foundry-facade-request-index.schema.json", "specs/schemas/foundry-operation-result.schema.json", "specs/schemas/foundry-package-descriptor.schema.json", "specs/schemas/foundry-task-start.schema.json", "specs/schemas/foundry-semantic-input.schema.json", "specs/schemas/foundry-interaction-input.schema.json", "specs/schemas/foundry-authorization-input.schema.json", "specs/schemas/foundry-reference-input.schema.json", "specs/schemas/foundry-identity-stage-input.schema.json", "specs/schemas/foundry-quality-review-input.schema.json", "specs/schemas/foundry-quality-review-draft.schema.json", "specs/schemas/foundry-workspace-migration-plan.schema.json", "specs/schemas/foundry-workspace-migration-transfer-plan.schema.json", "specs/schemas/foundry-migration-transfer-receipt.schema.json", "specs/schemas/foundry-workspace-migration-pending.schema.json", "specs/schemas/foundry-migration-adoption-plan.schema.json", "specs/schemas/foundry-migration-activation.schema.json", "specs/schemas/foundry-workspace-v2.schema.json", "specs/schemas/foundry-runtime-selection.schema.json", "specs/schemas/foundry-managed-runtime.schema.json", "specs/schemas/foundry-managed-adoption.schema.json", "specs/schemas/runtime-qualification.schema.json", "specs/schemas/task-authorization.schema.json", "specs/schemas/tidas-runtime-expectation.schema.json", "docs/architecture.md", "docs/package-distribution-contract.md", "docs/foundry-task-contracts.md", "docs/public-runtime-contract.md", "docs/runtime-context-contract.md", "docs/workspace-migration-contract.md", "docs/safety-policy.md", "docs/task-authorization-contract.md", "docs/import-profiles/bafu/constraints.md", "docs/import-profiles/bafu/leaf-process-classification-authoring.md", "docs/import-profiles/bafu/profile.md", "docs/import-profiles/uslci/constraints.md", "docs/import-profiles/uslci/profile.md", "docs/uslci-import-runbook.md", "docs/import-profiles/worldsteel/constraints.md", "docs/import-profiles/worldsteel/import-coverage.md", "docs/import-profiles/worldsteel/import-plan.md", "docs/import-profiles/worldsteel/profile.md", "README.md", "LICENSE"];
|
|
4
4
|
declare const packageName = "@tiangong-lca/foundry";
|
|
5
|
-
declare const packageVersion = "0.1.
|
|
5
|
+
declare const packageVersion = "0.1.19";
|
|
6
6
|
declare const cliPackageName = "@tiangong-lca/cli";
|
|
7
|
-
declare const cliPackageVersion = "0.
|
|
7
|
+
declare const cliPackageVersion = "0.4.0";
|
|
8
8
|
declare const packageBin = "package-dist/scripts/package-entry.js";
|
|
9
9
|
declare const packageApi = "package-dist/scripts/public-api.js";
|
|
10
10
|
declare const packageTypes = "package-dist/scripts/public-api.d.ts";
|
|
@@ -57,10 +57,10 @@ export const foundryPackageStaticFiles = Object.freeze([
|
|
|
57
57
|
"LICENSE",
|
|
58
58
|
]);
|
|
59
59
|
const packageName = "@tiangong-lca/foundry";
|
|
60
|
-
const packageVersion = "0.1.
|
|
60
|
+
const packageVersion = "0.1.19";
|
|
61
61
|
const packageDescription = "Control plane for TianGong LCA external dataset import and TIDAS authoring work.";
|
|
62
62
|
const cliPackageName = "@tiangong-lca/cli";
|
|
63
|
-
const cliPackageVersion = "0.
|
|
63
|
+
const cliPackageVersion = "0.4.0";
|
|
64
64
|
const packageBin = "package-dist/scripts/package-entry.js";
|
|
65
65
|
const packageApi = "package-dist/scripts/public-api.js";
|
|
66
66
|
const packageTypes = "package-dist/scripts/public-api.d.ts";
|
|
@@ -45,6 +45,43 @@ function findings(value, statuses) {
|
|
|
45
45
|
/** Verify transport and content bindings; the CLI retains every scientific validation decision. */
|
|
46
46
|
export function parseFoundryPreparationCliReport(options) {
|
|
47
47
|
const report = object(options.report);
|
|
48
|
+
if (report.schema === "tiangong-foundry.typed-process-qa.v1") {
|
|
49
|
+
if (report.status !== "completed_typed_process_validation" ||
|
|
50
|
+
report.validation_input !== options.input ||
|
|
51
|
+
report.validation_operation !== "dataset process validate" ||
|
|
52
|
+
object(report.files).report !==
|
|
53
|
+
path.join(options.outDir, "outputs", "validation-report.json") ||
|
|
54
|
+
!Array.isArray(report.rows) ||
|
|
55
|
+
!Array.isArray(report.validations) ||
|
|
56
|
+
report.rows.length !== options.rows.length ||
|
|
57
|
+
report.validations.length !== options.rows.length)
|
|
58
|
+
return fail();
|
|
59
|
+
const validations = report.validations;
|
|
60
|
+
const rows = report.rows.map((raw, index) => {
|
|
61
|
+
const { findings: rawFindings, ...complete } = object(raw);
|
|
62
|
+
const checked = object(validations[index]);
|
|
63
|
+
const identity = datasetIdentity(options.rows[index], index, "process");
|
|
64
|
+
if (complete.type !== "process" ||
|
|
65
|
+
complete.index !== 0 ||
|
|
66
|
+
complete.id !== identity.id ||
|
|
67
|
+
complete.version !== identity.version ||
|
|
68
|
+
complete.payload_sha256 !== sha256Json(identity.payload) ||
|
|
69
|
+
!["passed", "failed", "incomplete"].includes(String(complete.status)) ||
|
|
70
|
+
checked.id !== identity.id ||
|
|
71
|
+
checked.version !== identity.version ||
|
|
72
|
+
checked.result !== path.join(options.outDir, `validation-${index + 1}.json`) ||
|
|
73
|
+
checked.complete_sha256 !== sha256Json(complete) ||
|
|
74
|
+
!Array.isArray(complete.issues) ||
|
|
75
|
+
complete.issue_count !== complete.issues.length ||
|
|
76
|
+
!Array.isArray(rawFindings) ||
|
|
77
|
+
(complete.status === "passed") !== (rawFindings.length === 0))
|
|
78
|
+
return fail();
|
|
79
|
+
return { ...complete, typed_findings: rawFindings.map(object) };
|
|
80
|
+
});
|
|
81
|
+
if (options.exit !== (rows.some((row) => row.status !== "passed") ? 1 : 0))
|
|
82
|
+
fail();
|
|
83
|
+
return rows;
|
|
84
|
+
}
|
|
48
85
|
if (report.input_path !== options.input ||
|
|
49
86
|
report.requested_type !== "process" ||
|
|
50
87
|
object(report.files).report !==
|
|
@@ -150,6 +187,40 @@ export function preparationValidationActions(row, receipt) {
|
|
|
150
187
|
...layerNames.map((name) => ({ name, value: object(layers[name]) })),
|
|
151
188
|
{ name: "allocation_semantics", value: semantics },
|
|
152
189
|
];
|
|
190
|
+
if (Array.isArray(row.typed_findings)) {
|
|
191
|
+
const typedGroups = [
|
|
192
|
+
...groups,
|
|
193
|
+
{ name: "flow_reference_names", value: record(row.flow_reference_names) },
|
|
194
|
+
{ name: "annual_volume", value: record(row.annual_volume) },
|
|
195
|
+
];
|
|
196
|
+
return row.typed_findings.map((item) => {
|
|
197
|
+
const issue = object(item);
|
|
198
|
+
const group = typedGroups.find(({ value }) => Array.isArray(value.issues) &&
|
|
199
|
+
value.issues.some((entry) => {
|
|
200
|
+
const ownerIssue = object(entry);
|
|
201
|
+
return ownerIssue.code === issue.code && ownerIssue.path === issue.path;
|
|
202
|
+
}));
|
|
203
|
+
return {
|
|
204
|
+
source: "cli_validation",
|
|
205
|
+
validation_layer: group?.name ?? "typed_process_business",
|
|
206
|
+
code: issue.code,
|
|
207
|
+
path: issue.path,
|
|
208
|
+
message: issue.message,
|
|
209
|
+
action_kind: "ai_authoring",
|
|
210
|
+
required_owner: "foundry_ai_authoring",
|
|
211
|
+
ai_required: true,
|
|
212
|
+
instruction: "Review the complete owner validation and exact Process references before applying a source-backed authoring patch.",
|
|
213
|
+
evidence: {
|
|
214
|
+
...receipt,
|
|
215
|
+
candidate_sha256: row.payload_sha256,
|
|
216
|
+
validation_layers: row.validation_layers,
|
|
217
|
+
allocation_semantics: row.allocation_semantics,
|
|
218
|
+
flow_reference_names: row.flow_reference_names,
|
|
219
|
+
annual_volume: row.annual_volume,
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
}
|
|
153
224
|
return groups.flatMap(({ name, value }) => value.issues.map((issue) => ({
|
|
154
225
|
source: "cli_validation",
|
|
155
226
|
validation_layer: name,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
type JsonObject = Record<string, unknown>;
|
|
2
|
+
type ReferenceKind = "flow" | "flowproperty" | "unitgroup";
|
|
3
|
+
type Dimension = "mass" | "count" | "energy" | "length" | "area" | "volume" | "time" | "area_time";
|
|
4
|
+
type Unit = {
|
|
5
|
+
name: string;
|
|
6
|
+
dimension: Dimension;
|
|
7
|
+
kilograms: number | null;
|
|
8
|
+
};
|
|
9
|
+
type EvidenceRow = {
|
|
10
|
+
payload: JsonObject;
|
|
11
|
+
sha256: string;
|
|
12
|
+
};
|
|
13
|
+
export type MassReferenceEvidence = {
|
|
14
|
+
rows: Map<string, EvidenceRow>;
|
|
15
|
+
};
|
|
16
|
+
export type MassExchangeObservation = {
|
|
17
|
+
exchange_index: number;
|
|
18
|
+
exchange_internal_id: string;
|
|
19
|
+
amount: number | null;
|
|
20
|
+
unit: Unit | null;
|
|
21
|
+
mass_kg: number | null;
|
|
22
|
+
references: {
|
|
23
|
+
kind: ReferenceKind;
|
|
24
|
+
id: string;
|
|
25
|
+
version: string;
|
|
26
|
+
payload_sha256: string;
|
|
27
|
+
}[];
|
|
28
|
+
error: string | null;
|
|
29
|
+
};
|
|
30
|
+
export type ProcessMassBalance = {
|
|
31
|
+
process_file: string;
|
|
32
|
+
process_payload_sha256: string;
|
|
33
|
+
status: "applicable" | "not_applicable" | "unresolved";
|
|
34
|
+
unit: "kg";
|
|
35
|
+
reference_exchange_id: string | null;
|
|
36
|
+
exchanges: MassExchangeObservation[];
|
|
37
|
+
raw_input: number | null;
|
|
38
|
+
product: number | null;
|
|
39
|
+
byproduct: number | null;
|
|
40
|
+
waste: number | null;
|
|
41
|
+
other_output: number | null;
|
|
42
|
+
energy_excluded: null;
|
|
43
|
+
input_mass_kg: number | null;
|
|
44
|
+
output_mass_kg: number | null;
|
|
45
|
+
delta: number | null;
|
|
46
|
+
relative_deviation: number | null;
|
|
47
|
+
findings: {
|
|
48
|
+
code: string;
|
|
49
|
+
message: string;
|
|
50
|
+
exchange_index?: number;
|
|
51
|
+
}[];
|
|
52
|
+
};
|
|
53
|
+
export declare function assessProcessMassBalance(input: {
|
|
54
|
+
processFile: string;
|
|
55
|
+
processPayload: JsonObject;
|
|
56
|
+
exchanges: readonly JsonObject[];
|
|
57
|
+
referenceFlowId: string | null;
|
|
58
|
+
references: MassReferenceEvidence;
|
|
59
|
+
classify: (exchange: JsonObject) => {
|
|
60
|
+
classification: string;
|
|
61
|
+
uoms: readonly string[];
|
|
62
|
+
};
|
|
63
|
+
}): ProcessMassBalance;
|
|
64
|
+
export {};
|