@tiangong-lca/foundry 0.1.17 → 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/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 +85 -5
- package/docs/runtime-context-contract.md +22 -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 +541 -177
- package/package-dist/scripts/foundry-facade.d.ts +5 -0
- package/package-dist/scripts/foundry-facade.js +261 -16
- package/package-dist/scripts/foundry-runtime.d.ts +2 -2
- 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 +18 -6
- 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 +11 -1
- package/package-dist/scripts/lib/finalize-owners/post-authoring.js +65 -9
- 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-authentication-environment.js +1 -1
- package/package-dist/scripts/lib/foundry-command-metadata.js +6 -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-decision-owners.d.ts +1 -1
- package/package-dist/scripts/lib/foundry-decision-owners.js +15 -7
- 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 +28 -3
- 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 +126 -13
- 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-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 +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 +96 -3
- 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-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-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 +22 -2
- 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-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-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-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 +165 -34
- package/package-dist/scripts/lib/foundry-workflow-authorization.js +99 -5
- 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 +92 -22
- package/package-dist/scripts/lib/foundry-workflow-execution.js +54 -5
- package/package-dist/scripts/lib/foundry-workflow-finalize.js +64 -3
- 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 +717 -0
- package/package-dist/scripts/lib/foundry-workflow-identity.js +26 -11
- package/package-dist/scripts/lib/foundry-workflow-io.d.ts +7 -1
- package/package-dist/scripts/lib/foundry-workflow-io.js +102 -16
- 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 +65 -31
- 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 +6 -0
- package/package-dist/scripts/lib/identity-preflight-proof.js +92 -13
- 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
|
@@ -22,6 +22,7 @@ export const foundryPublicOperations = Object.freeze([
|
|
|
22
22
|
"task.start",
|
|
23
23
|
"task.status",
|
|
24
24
|
"task.resume",
|
|
25
|
+
"task.adopt-runtime",
|
|
25
26
|
"workspace.migrate",
|
|
26
27
|
]);
|
|
27
28
|
export const FOUNDRY_COMMAND_NEXT_ACTION_BINDING_SCHEMA = "tiangong-foundry.command-next-action-binding.v1";
|
|
@@ -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 ||
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export declare const FOUNDRY_PACKAGE_DESCRIPTOR_SCHEMA: "tiangong-foundry.package-descriptor.v1";
|
|
2
2
|
export declare const foundryPackageDescriptorPath: "package-dist/assets/foundry-package-descriptor.json";
|
|
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-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/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"];
|
|
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";
|
|
11
11
|
declare const supportedPlatforms: readonly ["linux-x64", "linux-arm64", "darwin-arm64", "win32-x64"];
|
|
12
|
-
declare const protocolSchemas: readonly ["tiangong-foundry.operation-result.v1", "tiangong-foundry.task-start.v1", "tiangong-foundry.semantic-input.v1", "tiangong-foundry.interaction-input.v1", "tiangong-foundry.authorization-input.v1", "tiangong-foundry.reference-input.v1", "tiangong-foundry.facade-request-index.v1", "tiangong-foundry.workspace-migration-plan.v1", "tiangong-foundry.workspace-migration-transfer-plan.v2", "tiangong-foundry.migration-transfer-receipt.v1", "tiangong-foundry.workspace-migration-pending.v1", "tiangong-foundry.migration-adoption-plan.v1", "tiangong-foundry.migration-activation.v1", "tiangong-foundry.workspace.v2", "tiangong-foundry.workspace-runtime-selection.v1", "tiangong-foundry.managed-runtime.v1", "tiangong-foundry.runtime-qualification.v1", "tiangong-foundry.tidas-runtime-expectation.v1", "tiangong-foundry.execution-context.v1", "tiangong-foundry.authorization-derivation.v1", "tiangong-foundry.task-authorization.v1"];
|
|
12
|
+
declare const protocolSchemas: readonly ["tiangong-foundry.operation-result.v1", "tiangong-foundry.task-start.v1", "tiangong-foundry.semantic-input.v1", "tiangong-foundry.interaction-input.v1", "tiangong-foundry.authorization-input.v1", "tiangong-foundry.reference-input.v1", "tiangong-foundry.identity-stage-input.v1", "tiangong-foundry.quality-review-input.v1", "tiangong-foundry.quality-review-draft.v1", "tiangong-foundry.facade-request-index.v1", "tiangong-foundry.workspace-migration-plan.v1", "tiangong-foundry.workspace-migration-transfer-plan.v2", "tiangong-foundry.migration-transfer-receipt.v1", "tiangong-foundry.workspace-migration-pending.v1", "tiangong-foundry.migration-adoption-plan.v1", "tiangong-foundry.migration-activation.v1", "tiangong-foundry.workspace.v2", "tiangong-foundry.workspace-runtime-selection.v1", "tiangong-foundry.managed-runtime.v1", "tiangong-foundry.managed-adoption.v1", "tiangong-foundry.runtime-qualification.v1", "tiangong-foundry.tidas-runtime-expectation.v1", "tiangong-foundry.execution-context.v1", "tiangong-foundry.authorization-derivation.v1", "tiangong-foundry.task-authorization.v1"];
|
|
13
13
|
export interface FoundryPackageFileFact {
|
|
14
14
|
readonly path: string;
|
|
15
15
|
readonly bytes: number;
|
|
@@ -19,6 +19,9 @@ export const foundryPackageStaticFiles = Object.freeze([
|
|
|
19
19
|
"specs/schemas/foundry-interaction-input.schema.json",
|
|
20
20
|
"specs/schemas/foundry-authorization-input.schema.json",
|
|
21
21
|
"specs/schemas/foundry-reference-input.schema.json",
|
|
22
|
+
"specs/schemas/foundry-identity-stage-input.schema.json",
|
|
23
|
+
"specs/schemas/foundry-quality-review-input.schema.json",
|
|
24
|
+
"specs/schemas/foundry-quality-review-draft.schema.json",
|
|
22
25
|
"specs/schemas/foundry-workspace-migration-plan.schema.json",
|
|
23
26
|
"specs/schemas/foundry-workspace-migration-transfer-plan.schema.json",
|
|
24
27
|
"specs/schemas/foundry-migration-transfer-receipt.schema.json",
|
|
@@ -28,6 +31,7 @@ export const foundryPackageStaticFiles = Object.freeze([
|
|
|
28
31
|
"specs/schemas/foundry-workspace-v2.schema.json",
|
|
29
32
|
"specs/schemas/foundry-runtime-selection.schema.json",
|
|
30
33
|
"specs/schemas/foundry-managed-runtime.schema.json",
|
|
34
|
+
"specs/schemas/foundry-managed-adoption.schema.json",
|
|
31
35
|
"specs/schemas/runtime-qualification.schema.json",
|
|
32
36
|
"specs/schemas/task-authorization.schema.json",
|
|
33
37
|
"specs/schemas/tidas-runtime-expectation.schema.json",
|
|
@@ -53,10 +57,10 @@ export const foundryPackageStaticFiles = Object.freeze([
|
|
|
53
57
|
"LICENSE",
|
|
54
58
|
]);
|
|
55
59
|
const packageName = "@tiangong-lca/foundry";
|
|
56
|
-
const packageVersion = "0.1.
|
|
60
|
+
const packageVersion = "0.1.19";
|
|
57
61
|
const packageDescription = "Control plane for TianGong LCA external dataset import and TIDAS authoring work.";
|
|
58
62
|
const cliPackageName = "@tiangong-lca/cli";
|
|
59
|
-
const cliPackageVersion = "0.
|
|
63
|
+
const cliPackageVersion = "0.4.0";
|
|
60
64
|
const packageBin = "package-dist/scripts/package-entry.js";
|
|
61
65
|
const packageApi = "package-dist/scripts/public-api.js";
|
|
62
66
|
const packageTypes = "package-dist/scripts/public-api.d.ts";
|
|
@@ -73,6 +77,9 @@ const protocolSchemas = Object.freeze([
|
|
|
73
77
|
"tiangong-foundry.interaction-input.v1",
|
|
74
78
|
"tiangong-foundry.authorization-input.v1",
|
|
75
79
|
"tiangong-foundry.reference-input.v1",
|
|
80
|
+
"tiangong-foundry.identity-stage-input.v1",
|
|
81
|
+
"tiangong-foundry.quality-review-input.v1",
|
|
82
|
+
"tiangong-foundry.quality-review-draft.v1",
|
|
76
83
|
"tiangong-foundry.facade-request-index.v1",
|
|
77
84
|
"tiangong-foundry.workspace-migration-plan.v1",
|
|
78
85
|
"tiangong-foundry.workspace-migration-transfer-plan.v2",
|
|
@@ -83,6 +90,7 @@ const protocolSchemas = Object.freeze([
|
|
|
83
90
|
"tiangong-foundry.workspace.v2",
|
|
84
91
|
"tiangong-foundry.workspace-runtime-selection.v1",
|
|
85
92
|
"tiangong-foundry.managed-runtime.v1",
|
|
93
|
+
"tiangong-foundry.managed-adoption.v1",
|
|
86
94
|
"tiangong-foundry.runtime-qualification.v1",
|
|
87
95
|
"tiangong-foundry.tidas-runtime-expectation.v1",
|
|
88
96
|
"tiangong-foundry.execution-context.v1",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FoundryInputFact } from "./foundry-runtime-context.ts";
|
|
1
2
|
type Json = Record<string, unknown>;
|
|
2
3
|
/** Verify transport and content bindings; the CLI retains every scientific validation decision. */
|
|
3
4
|
export declare function parseFoundryPreparationCliReport(options: {
|
|
@@ -13,6 +14,7 @@ export declare function preparationValidationEvidence(row: Json, report: string,
|
|
|
13
14
|
export declare function readPreparationCliEvidence(receipt: {
|
|
14
15
|
report: string;
|
|
15
16
|
exit: number;
|
|
17
|
+
input?: FoundryInputFact;
|
|
16
18
|
}, rows: readonly unknown[], input: string): {
|
|
17
19
|
rows: Json[];
|
|
18
20
|
sha256: string;
|
|
@@ -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) {
|
|
@@ -44,6 +45,43 @@ function findings(value, statuses) {
|
|
|
44
45
|
/** Verify transport and content bindings; the CLI retains every scientific validation decision. */
|
|
45
46
|
export function parseFoundryPreparationCliReport(options) {
|
|
46
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
|
+
}
|
|
47
85
|
if (report.input_path !== options.input ||
|
|
48
86
|
report.requested_type !== "process" ||
|
|
49
87
|
object(report.files).report !==
|
|
@@ -149,6 +187,40 @@ export function preparationValidationActions(row, receipt) {
|
|
|
149
187
|
...layerNames.map((name) => ({ name, value: object(layers[name]) })),
|
|
150
188
|
{ name: "allocation_semantics", value: semantics },
|
|
151
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
|
+
}
|
|
152
224
|
return groups.flatMap(({ name, value }) => value.issues.map((issue) => ({
|
|
153
225
|
source: "cli_validation",
|
|
154
226
|
validation_layer: name,
|
|
@@ -177,12 +249,33 @@ export function preparationValidationEvidence(row, report, hash) {
|
|
|
177
249
|
};
|
|
178
250
|
}
|
|
179
251
|
export function readPreparationCliEvidence(receipt, rows, input) {
|
|
252
|
+
let validationRows = rows;
|
|
253
|
+
let validationInput = input;
|
|
254
|
+
if (receipt.input) {
|
|
255
|
+
const current = captureFoundryInput(receipt.input.path);
|
|
256
|
+
if (current.bytes > 8 * 1024 * 1024 || sha256Json(current) !== sha256Json(receipt.input))
|
|
257
|
+
fail();
|
|
258
|
+
validationRows = readRows(current.path);
|
|
259
|
+
if (validationRows.length !== rows.length ||
|
|
260
|
+
validationRows.some((row, index) => {
|
|
261
|
+
const original = datasetIdentity(rows[index], index, "process");
|
|
262
|
+
const derived = datasetIdentity(row, index, "process");
|
|
263
|
+
const source = record(rows[index]), wrapper = record(row);
|
|
264
|
+
return (original.id !== derived.id ||
|
|
265
|
+
original.version !== derived.version ||
|
|
266
|
+
sha256Json(original.payload) !== sha256Json(derived.payload) ||
|
|
267
|
+
source.id !== wrapper.id ||
|
|
268
|
+
source.version !== wrapper.version);
|
|
269
|
+
}))
|
|
270
|
+
fail();
|
|
271
|
+
validationInput = current.path;
|
|
272
|
+
}
|
|
180
273
|
const bytes = fs.readFileSync(receipt.report, "utf8");
|
|
181
274
|
return {
|
|
182
275
|
rows: parseFoundryPreparationCliReport({
|
|
183
276
|
report: JSON.parse(bytes),
|
|
184
|
-
rows,
|
|
185
|
-
input,
|
|
277
|
+
rows: validationRows,
|
|
278
|
+
input: validationInput,
|
|
186
279
|
outDir: path.dirname(path.dirname(receipt.report)),
|
|
187
280
|
exit: receipt.exit,
|
|
188
281
|
}),
|
|
@@ -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 {};
|