@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
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { bundleRowTypes } from "./bundle-row-types.js";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { FoundryContextError } from "./foundry-runtime-context.js";
|
|
4
|
+
import { sha256Json } from "./identity-preflight-proof.js";
|
|
5
|
+
import { dataSetInformation, datasetRoot, unwrapDatasetPayload, } from "./import-curation/internal/dataset-payload.js";
|
|
6
|
+
import { collectDatasetReferences } from "./import-curation/internal/workflow-reference-closure.js";
|
|
7
|
+
import { edgeReferenceKey, readEdgeReferenceSnapshot, } from "./foundry-edge-reference-intent.js";
|
|
8
|
+
const schema = "tiangong-foundry.edge-support-create.v1";
|
|
9
|
+
const uuid = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/u;
|
|
10
|
+
const versionPattern = /^\d{2}\.\d{2}\.\d{3}$/u;
|
|
11
|
+
const hash = /^[a-f0-9]{64}$/u;
|
|
12
|
+
const referenceTables = [
|
|
13
|
+
"contacts",
|
|
14
|
+
"sources",
|
|
15
|
+
"unitgroups",
|
|
16
|
+
"flowproperties",
|
|
17
|
+
"flows",
|
|
18
|
+
"processes",
|
|
19
|
+
"lifecyclemodels",
|
|
20
|
+
"lciamethods",
|
|
21
|
+
];
|
|
22
|
+
const edgeDraftTypes = [
|
|
23
|
+
"unitgroup",
|
|
24
|
+
"flowproperty",
|
|
25
|
+
"process",
|
|
26
|
+
"contact",
|
|
27
|
+
"source",
|
|
28
|
+
"flow",
|
|
29
|
+
"lifecyclemodel",
|
|
30
|
+
];
|
|
31
|
+
export const isFoundryEdgeDraftType = (value) => edgeDraftTypes.some((type) => type === value);
|
|
32
|
+
function invalid(message) {
|
|
33
|
+
throw new FoundryContextError("edge_support_plan_invalid", message);
|
|
34
|
+
}
|
|
35
|
+
function object(value) {
|
|
36
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
37
|
+
return invalid("Edge draft plan requires structured objects.");
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function exactKey(table, id, version) {
|
|
41
|
+
if (typeof table !== "string" ||
|
|
42
|
+
!referenceTables.includes(table) ||
|
|
43
|
+
typeof id !== "string" ||
|
|
44
|
+
!uuid.test(id) ||
|
|
45
|
+
typeof version !== "string" ||
|
|
46
|
+
!versionPattern.test(version))
|
|
47
|
+
return invalid("Every draft and dependency must select an exact UUID and version.");
|
|
48
|
+
return { table, id, version };
|
|
49
|
+
}
|
|
50
|
+
function rootsFor(type, rows) {
|
|
51
|
+
if (!rows.length)
|
|
52
|
+
return invalid("Edge draft plan requires at least one approved dataset row.");
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
const table = bundleRowTypes[type].plural;
|
|
55
|
+
return rows.map((row) => {
|
|
56
|
+
const content = object(unwrapDatasetPayload(row, type));
|
|
57
|
+
const root = datasetRoot(content, type);
|
|
58
|
+
const own = object(object(root.administrativeInformation).publicationAndOwnership);
|
|
59
|
+
const key = exactKey(table, dataSetInformation(root, type)["common:UUID"], own["common:dataSetVersion"]);
|
|
60
|
+
const envelope = object(row);
|
|
61
|
+
if ((envelope.id !== undefined && envelope.id !== key.id) ||
|
|
62
|
+
(envelope.version !== undefined && envelope.version !== key.version) ||
|
|
63
|
+
seen.has(key.id))
|
|
64
|
+
return invalid("The approved rows contain an ambiguous identity or multiple versions.");
|
|
65
|
+
seen.add(key.id);
|
|
66
|
+
const refs = collectDatasetReferences(content);
|
|
67
|
+
if (type === "flowproperty") {
|
|
68
|
+
const unitGroup = refs.filter((ref) => ref.path.endsWith("/quantitativeReference/referenceToReferenceUnitGroup"));
|
|
69
|
+
if (unitGroup.length !== 1 || unitGroup[0].table !== "unitgroups")
|
|
70
|
+
return invalid("FlowProperty creation requires one exact reference UnitGroup.");
|
|
71
|
+
}
|
|
72
|
+
const references = new Map();
|
|
73
|
+
for (const ref of refs) {
|
|
74
|
+
const exact = exactKey(ref.table, ref.id, ref.version);
|
|
75
|
+
references.set(`${exact.table}:${exact.id}@${exact.version}`, exact);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
root: { ...key, payload_sha256: sha256Json(content), references: [...references.values()] },
|
|
79
|
+
content,
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export function buildEdgeSupportPlan(type, input, target, rows, evidence, update, insertContract) {
|
|
84
|
+
if (!isAbsolute(input.path) ||
|
|
85
|
+
!hash.test(input.sha256) ||
|
|
86
|
+
!Number.isSafeInteger(input.bytes) ||
|
|
87
|
+
input.bytes < 1)
|
|
88
|
+
return invalid("The Edge draft plan requires exact approved input bytes.");
|
|
89
|
+
if (!target.project_ref || !uuid.test(target.user_id))
|
|
90
|
+
return invalid("The Edge draft plan requires an exact project and owner.");
|
|
91
|
+
const documents = rootsFor(type, rows);
|
|
92
|
+
const payload = {
|
|
93
|
+
schema,
|
|
94
|
+
dataset_type: type,
|
|
95
|
+
input,
|
|
96
|
+
project_ref: target.project_ref,
|
|
97
|
+
user_id: target.user_id,
|
|
98
|
+
state_code: 0,
|
|
99
|
+
roots: documents.map(({ root }) => root),
|
|
100
|
+
};
|
|
101
|
+
if (evidence) {
|
|
102
|
+
const report = object(evidence.report);
|
|
103
|
+
if (report.schema !== "tiangong-foundry.edge-support-precommit.v1" ||
|
|
104
|
+
report.status !== "passed_remote_verification" ||
|
|
105
|
+
report.input_path !== input.path ||
|
|
106
|
+
report.edge_plan_sha256 !== sha256Json(payload) ||
|
|
107
|
+
!Array.isArray(report.checks))
|
|
108
|
+
return invalid("Reference evidence must verify all dependencies for these final rows.");
|
|
109
|
+
const checks = report.checks.map(object);
|
|
110
|
+
if (type === "flow") {
|
|
111
|
+
const heads = report.flow_heads;
|
|
112
|
+
if (!Array.isArray(heads) || heads.length !== payload.roots.length)
|
|
113
|
+
return invalid("Flow planning requires one observed head for every approved identity.");
|
|
114
|
+
payload.roots.forEach((root, index) => {
|
|
115
|
+
const observed = object(heads[index]);
|
|
116
|
+
if (observed.id !== root.id)
|
|
117
|
+
invalid("The observed Flow head belongs to another identity.");
|
|
118
|
+
root.flow_head =
|
|
119
|
+
observed.head === null ? null : readEdgeReferenceSnapshot(observed.head, target.user_id);
|
|
120
|
+
if (root.flow_head &&
|
|
121
|
+
(root.flow_head.table !== root.table ||
|
|
122
|
+
root.flow_head.id !== root.id ||
|
|
123
|
+
!isNextFlowVersion(root.flow_head.version, root.version)))
|
|
124
|
+
invalid("A new Flow version must immediately follow its verified current head.");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const reviewed = new Map();
|
|
128
|
+
if (report.reference_intent) {
|
|
129
|
+
const intent = object(report.reference_intent);
|
|
130
|
+
if (!Array.isArray(intent.references) ||
|
|
131
|
+
!intent.references.length ||
|
|
132
|
+
!Array.isArray(intent.review_files) ||
|
|
133
|
+
!intent.review_files.length)
|
|
134
|
+
return invalid("Explicit reference intent requires the selected review artifacts.");
|
|
135
|
+
for (const raw of intent.references) {
|
|
136
|
+
const reference = object(raw);
|
|
137
|
+
const selected = readEdgeReferenceSnapshot(reference.selected, target.user_id);
|
|
138
|
+
const latest = readEdgeReferenceSnapshot(object(reference.review).latest, target.user_id);
|
|
139
|
+
reviewed.set(edgeReferenceKey(selected), { selected, latest });
|
|
140
|
+
}
|
|
141
|
+
payload.reference_intent = [intent.file, ...intent.review_files].map((raw) => {
|
|
142
|
+
const fact = object(raw);
|
|
143
|
+
if (typeof fact.path !== "string" ||
|
|
144
|
+
!isAbsolute(fact.path) ||
|
|
145
|
+
typeof fact.sha256 !== "string" ||
|
|
146
|
+
!hash.test(fact.sha256) ||
|
|
147
|
+
typeof fact.bytes !== "number" ||
|
|
148
|
+
!Number.isSafeInteger(fact.bytes) ||
|
|
149
|
+
fact.bytes < 1)
|
|
150
|
+
return invalid("Explicit reference artifacts require exact file facts.");
|
|
151
|
+
return { path: fact.path, sha256: fact.sha256, bytes: fact.bytes };
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
for (const root of payload.roots) {
|
|
155
|
+
root.references = root.references.map((reference) => {
|
|
156
|
+
const selected = checks.filter((check) => check.table === reference.table &&
|
|
157
|
+
check.id === reference.id &&
|
|
158
|
+
check.version === reference.version);
|
|
159
|
+
const check = selected[0];
|
|
160
|
+
const review = reviewed.get(edgeReferenceKey(reference));
|
|
161
|
+
if (selected.length !== 1 ||
|
|
162
|
+
check.role !== "reference" ||
|
|
163
|
+
check.status !== "ok" ||
|
|
164
|
+
typeof check.remote_payload_sha256 !== "string" ||
|
|
165
|
+
!hash.test(check.remote_payload_sha256) ||
|
|
166
|
+
!([100, 200].includes(Number(check.remote_state_code)) ||
|
|
167
|
+
(check.remote_state_code === 0 && check.remote_user_id === target.user_id)))
|
|
168
|
+
return invalid("A sealed draft dependency lacks exact owner and content evidence.");
|
|
169
|
+
if (review &&
|
|
170
|
+
(sha256Json(check.reviewed_latest) !== sha256Json(review.latest) ||
|
|
171
|
+
check.remote_payload_sha256 !== review.selected.payload_sha256 ||
|
|
172
|
+
check.remote_state_code !== review.selected.state_code ||
|
|
173
|
+
check.remote_user_id !== review.selected.user_id))
|
|
174
|
+
return invalid("Reviewed dependency evidence differs from the selected and latest snapshots.");
|
|
175
|
+
return {
|
|
176
|
+
...reference,
|
|
177
|
+
payload_sha256: check.remote_payload_sha256,
|
|
178
|
+
expected_state_code: Number(check.remote_state_code),
|
|
179
|
+
expected_owner: typeof check.remote_user_id === "string" ? check.remote_user_id : null,
|
|
180
|
+
...(review ? { reviewed_latest: review.latest } : {}),
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
payload.reference_evidence = evidence.fact;
|
|
185
|
+
}
|
|
186
|
+
if (update) {
|
|
187
|
+
if (type !== "process")
|
|
188
|
+
return invalid("Guarded Edge updates require a Process repair scope.");
|
|
189
|
+
const before = beforeFor(documents, update.rows);
|
|
190
|
+
payload.roots.forEach((root, index) => {
|
|
191
|
+
root.before_sha256 = sha256Json(before[index].content);
|
|
192
|
+
if (typeof update.binding.rule_verification[root.payload_sha256] !== "boolean")
|
|
193
|
+
invalid("Every update must preserve its approved validation result.");
|
|
194
|
+
});
|
|
195
|
+
if (payload.roots.every((root) => root.before_sha256 === root.payload_sha256))
|
|
196
|
+
return invalid("An unchanged draft does not require a guarded update.");
|
|
197
|
+
payload.update = update.binding;
|
|
198
|
+
}
|
|
199
|
+
if (insertContract) {
|
|
200
|
+
if (update || !["flow", "process", "source"].includes(type))
|
|
201
|
+
return invalid("An explicit insert contract must select eligible final rows.");
|
|
202
|
+
payload.insert_contract = insertContract;
|
|
203
|
+
}
|
|
204
|
+
return { ...payload, sha256: sha256Json(payload) };
|
|
205
|
+
}
|
|
206
|
+
export function isNextFlowVersion(current, desired) {
|
|
207
|
+
if (!versionPattern.test(current) || !versionPattern.test(desired))
|
|
208
|
+
return false;
|
|
209
|
+
const sequence = (value) => Number(value.replaceAll(".", ""));
|
|
210
|
+
return sequence(desired) === sequence(current) + 1;
|
|
211
|
+
}
|
|
212
|
+
function beforeFor(documents, rows) {
|
|
213
|
+
const previous = rootsFor("process", rows);
|
|
214
|
+
if (previous.length !== documents.length)
|
|
215
|
+
return invalid("Guarded update requires one before document for every exact target.");
|
|
216
|
+
const occurrences = (content) => collectDatasetReferences(content)
|
|
217
|
+
.map(({ table, id, version, path }) => sha256Json({ table, id, version, path }))
|
|
218
|
+
.sort();
|
|
219
|
+
return documents.map(({ root, content }) => {
|
|
220
|
+
const selected = previous.find((item) => item.root.id === root.id && item.root.version === root.version);
|
|
221
|
+
if (!selected || sha256Json(occurrences(selected.content)) !== sha256Json(occurrences(content)))
|
|
222
|
+
return invalid("Before and desired draft references must select the same exact dependencies.");
|
|
223
|
+
return selected;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
export function isEdgeSupportPlan(value) {
|
|
227
|
+
if (!value || typeof value !== "object" || !("schema" in value))
|
|
228
|
+
return false;
|
|
229
|
+
return value.schema === schema;
|
|
230
|
+
}
|
|
231
|
+
export function verifyEdgeSupportPlan(plan, approved, target, rows, evidence, update, insertContract) {
|
|
232
|
+
if (!evidence || !plan.reference_evidence)
|
|
233
|
+
return invalid("Edge draft execution requires sealed exact dependency evidence.");
|
|
234
|
+
if (!isFoundryEdgeDraftType(plan.dataset_type))
|
|
235
|
+
return invalid("Edge creation requires a supported dataset scope.");
|
|
236
|
+
const current = buildEdgeSupportPlan(plan.dataset_type, approved, target, rows, evidence, update, insertContract);
|
|
237
|
+
if (sha256Json(current) !== sha256Json(plan))
|
|
238
|
+
return invalid("The sealed Edge draft plan disagrees with the task approval or final rows.");
|
|
239
|
+
const documents = rootsFor(plan.dataset_type, rows);
|
|
240
|
+
const before = update && beforeFor(documents, update.rows);
|
|
241
|
+
return documents.map((item, index) => ({
|
|
242
|
+
...item,
|
|
243
|
+
...(before ? { beforeContent: before[index].content } : {}),
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { type EdgeDraftType } from "./foundry-edge-support-plan.ts";
|
|
2
|
+
import { type FoundryInputFact, type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
3
|
+
import type { QualifiedFoundryRuntime } from "./foundry-runtime-qualification.ts";
|
|
4
|
+
export declare function planFoundryEdgeSupportStage(context: FoundryRuntimeContext, qualified: QualifiedFoundryRuntime, environment: NodeJS.ProcessEnv, type: EdgeDraftType, stage: string, source: readonly string[], verifyDependencies: boolean, receiptFile: string | undefined, selectedInput?: FoundryInputFact): {
|
|
5
|
+
stage: string;
|
|
6
|
+
status: string;
|
|
7
|
+
report: {
|
|
8
|
+
schema: string;
|
|
9
|
+
status: string;
|
|
10
|
+
mode: string;
|
|
11
|
+
dry_run: boolean;
|
|
12
|
+
commit: boolean;
|
|
13
|
+
input_path: string;
|
|
14
|
+
counts: {
|
|
15
|
+
selected: number;
|
|
16
|
+
executed: number;
|
|
17
|
+
failed: number;
|
|
18
|
+
};
|
|
19
|
+
files: {
|
|
20
|
+
summary_json: string;
|
|
21
|
+
progress_jsonl: string;
|
|
22
|
+
report?: string | undefined;
|
|
23
|
+
success_list?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exit_code: number;
|
|
27
|
+
command: string;
|
|
28
|
+
args: never[];
|
|
29
|
+
stderr: string;
|
|
30
|
+
referenceDocuments?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
stage: string;
|
|
33
|
+
status: string;
|
|
34
|
+
report: {
|
|
35
|
+
schema: string;
|
|
36
|
+
status: string;
|
|
37
|
+
input_path: string;
|
|
38
|
+
edge_plan_sha256: string;
|
|
39
|
+
checks: {
|
|
40
|
+
table: string;
|
|
41
|
+
id: string;
|
|
42
|
+
version: string;
|
|
43
|
+
payload_sha256?: string;
|
|
44
|
+
expected_state_code?: number;
|
|
45
|
+
expected_owner?: string | null;
|
|
46
|
+
reviewed_latest?: import("./foundry-edge-reference-intent.ts").EdgeReferenceSnapshot;
|
|
47
|
+
role: string;
|
|
48
|
+
status: string;
|
|
49
|
+
}[];
|
|
50
|
+
blockers: {
|
|
51
|
+
table: string;
|
|
52
|
+
id: string;
|
|
53
|
+
version: string;
|
|
54
|
+
payload_sha256?: string;
|
|
55
|
+
expected_state_code?: number;
|
|
56
|
+
expected_owner?: string | null;
|
|
57
|
+
reviewed_latest?: import("./foundry-edge-reference-intent.ts").EdgeReferenceSnapshot;
|
|
58
|
+
role: string;
|
|
59
|
+
status: string;
|
|
60
|
+
code: string;
|
|
61
|
+
}[];
|
|
62
|
+
counts: {
|
|
63
|
+
rows: number;
|
|
64
|
+
blockers: number;
|
|
65
|
+
};
|
|
66
|
+
reference_intent?: {
|
|
67
|
+
file: {
|
|
68
|
+
path: string;
|
|
69
|
+
sha256: string;
|
|
70
|
+
bytes: number;
|
|
71
|
+
};
|
|
72
|
+
project_ref: string;
|
|
73
|
+
actor_user_id: string;
|
|
74
|
+
consumers: {
|
|
75
|
+
row_index: number;
|
|
76
|
+
table: string;
|
|
77
|
+
id: string;
|
|
78
|
+
version: string;
|
|
79
|
+
payload_sha256: string;
|
|
80
|
+
}[];
|
|
81
|
+
references: {
|
|
82
|
+
row_index: number;
|
|
83
|
+
path: string;
|
|
84
|
+
selected: import("./foundry-edge-reference-intent.ts").EdgeReferenceSnapshot;
|
|
85
|
+
review: {
|
|
86
|
+
file: FoundryInputFact;
|
|
87
|
+
latest: import("./foundry-edge-reference-intent.ts").EdgeReferenceSnapshot;
|
|
88
|
+
};
|
|
89
|
+
}[];
|
|
90
|
+
review_files: FoundryInputFact[];
|
|
91
|
+
} | undefined;
|
|
92
|
+
flow_heads?: ({
|
|
93
|
+
id: string;
|
|
94
|
+
head: null;
|
|
95
|
+
} | {
|
|
96
|
+
id: string;
|
|
97
|
+
head: {
|
|
98
|
+
table: string;
|
|
99
|
+
id: string;
|
|
100
|
+
version: string;
|
|
101
|
+
user_id: string;
|
|
102
|
+
state_code: number;
|
|
103
|
+
payload_sha256: string;
|
|
104
|
+
};
|
|
105
|
+
})[] | undefined;
|
|
106
|
+
files: {
|
|
107
|
+
report: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
exit_code: number;
|
|
111
|
+
referenceDocuments: unknown[];
|
|
112
|
+
command: string;
|
|
113
|
+
args: never[];
|
|
114
|
+
stderr: string;
|
|
115
|
+
};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { parseAuthIdentityReceipt } from "@tiangong-lca/cli/auth-identity-receipt";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { bundleRowTypes } from "./bundle-row-types.js";
|
|
6
|
+
import { buildEdgeSupportPlan, isNextFlowVersion, } from "./foundry-edge-support-plan.js";
|
|
7
|
+
import { FoundryContextError, captureFoundryInput, readFoundryInput, resolveFoundryOutput, writeFoundryArtifact, } from "./foundry-runtime-context.js";
|
|
8
|
+
import { resolveInstalledTiangongLcaCliPackage } from "./foundry-runtime-utils.js";
|
|
9
|
+
import { bindWorkflowChildExecution, workflowChildFailure, } from "./foundry-workflow-child-failure.js";
|
|
10
|
+
import { workflowObject } from "./foundry-workflow-state.js";
|
|
11
|
+
import { datasetIdentity } from "./import-curation/internal/dataset-payload.js";
|
|
12
|
+
import { readRows } from "./import-curation/internal/runtime-io.js";
|
|
13
|
+
import { sha256Json } from "./identity-preflight-proof.js";
|
|
14
|
+
import { edgeReferenceKey, readEdgeReferenceIntent } from "./foundry-edge-reference-intent.js";
|
|
15
|
+
export function planFoundryEdgeSupportStage(context, qualified, environment, type, stage, source, verifyDependencies, receiptFile, selectedInput) {
|
|
16
|
+
const inputOption = source.indexOf(source.includes("--input-file") ? "--input-file" : "--input");
|
|
17
|
+
const input = selectedInput?.path ?? resolveFoundryOutput(context, source[inputOption + 1]);
|
|
18
|
+
const output = resolveFoundryOutput(context, source[source.indexOf("--out-dir") + 1]);
|
|
19
|
+
const account = context.accountIntent;
|
|
20
|
+
if (!account)
|
|
21
|
+
throw new FoundryContextError("needs_auth", "Edge support planning requires task account intent.");
|
|
22
|
+
const rows = selectedInput
|
|
23
|
+
? readRows(input, (file) => readFoundryInput(context, file).toString("utf8"))
|
|
24
|
+
: readRows(input);
|
|
25
|
+
const target = { project_ref: account.projectRef, user_id: account.userId };
|
|
26
|
+
const plan = buildEdgeSupportPlan(type, captureFoundryInput(input), target, rows);
|
|
27
|
+
const intentOption = source.indexOf("--reference-intent-file");
|
|
28
|
+
const intent = intentOption < 0
|
|
29
|
+
? null
|
|
30
|
+
: readEdgeReferenceIntent(context, source[intentOption + 1], type, target, rows);
|
|
31
|
+
const save = (name, value) => {
|
|
32
|
+
const file = path.join(output, name);
|
|
33
|
+
writeFoundryArtifact(context, file, JSON.stringify(value, null, 2) + "\n");
|
|
34
|
+
return file;
|
|
35
|
+
};
|
|
36
|
+
if (!verifyDependencies) {
|
|
37
|
+
const reportFile = path.join(output, "edge-support-dry-run.json");
|
|
38
|
+
const progress = path.join(output, "edge-support-progress.jsonl");
|
|
39
|
+
const builds = plan.roots.map(({ id, version }) => ({
|
|
40
|
+
id,
|
|
41
|
+
version,
|
|
42
|
+
status: "prepared",
|
|
43
|
+
operation: "would_insert",
|
|
44
|
+
}));
|
|
45
|
+
writeFoundryArtifact(context, progress, builds.map((row) => JSON.stringify(row)).join("\n") + "\n");
|
|
46
|
+
const successFile = type === "flow" ? save("edge-flow-dry-run-rows.json", builds) : null;
|
|
47
|
+
const report = {
|
|
48
|
+
schema: "tiangong-foundry.edge-support-dry-run.v1",
|
|
49
|
+
status: "completed_dataset_save_draft",
|
|
50
|
+
mode: "dry_run",
|
|
51
|
+
dry_run: true,
|
|
52
|
+
commit: false,
|
|
53
|
+
input_path: input,
|
|
54
|
+
counts: { selected: plan.roots.length, executed: 0, failed: 0 },
|
|
55
|
+
files: {
|
|
56
|
+
summary_json: reportFile,
|
|
57
|
+
progress_jsonl: progress,
|
|
58
|
+
...(successFile ? { report: reportFile, success_list: successFile } : {}),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
save("edge-support-dry-run.json", report);
|
|
62
|
+
return {
|
|
63
|
+
stage,
|
|
64
|
+
status: report.status,
|
|
65
|
+
report,
|
|
66
|
+
exit_code: 0,
|
|
67
|
+
command: "foundry-edge-support-plan",
|
|
68
|
+
args: [],
|
|
69
|
+
stderr: "",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const cli = resolveInstalledTiangongLcaCliPackage();
|
|
73
|
+
const references = new Map(plan.roots.flatMap((root) => root.references).map((ref) => [edgeReferenceKey(ref), ref]));
|
|
74
|
+
const assessedFlowHashes = new Map();
|
|
75
|
+
if (type === "process") {
|
|
76
|
+
for (const row of rows) {
|
|
77
|
+
const documents = workflowObject(workflowObject(row).semantic_context ?? {}).flow_documents;
|
|
78
|
+
if (!Array.isArray(documents))
|
|
79
|
+
continue;
|
|
80
|
+
for (const document of documents) {
|
|
81
|
+
const flow = datasetIdentity(document, 0, "flow");
|
|
82
|
+
const key = `flows:${flow.id}@${flow.version}`;
|
|
83
|
+
const hash = sha256Json(flow.payload);
|
|
84
|
+
if (assessedFlowHashes.has(key) && assessedFlowHashes.get(key) !== hash)
|
|
85
|
+
throw new FoundryContextError("edge_draft_flow_conflict", "Final rows carry competing exact Flow reference evidence.");
|
|
86
|
+
assessedFlowHashes.set(key, hash);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const types = Object.keys(bundleRowTypes);
|
|
91
|
+
if (!receiptFile)
|
|
92
|
+
throw new FoundryContextError("needs_auth", "Exact support dependency lookup requires the verified project receipt.");
|
|
93
|
+
const receipt = parseAuthIdentityReceipt(JSON.parse(fs.readFileSync(receiptFile, "utf8")));
|
|
94
|
+
if (receipt.project.project_ref !== account.projectRef ||
|
|
95
|
+
receipt.identity.user_id !== account.userId)
|
|
96
|
+
throw new FoundryContextError("edge_support_account_mismatch", "The selected dependency receipt belongs to a different account.");
|
|
97
|
+
const expectedOrigin = new URL(receipt.project.project_base_url).origin;
|
|
98
|
+
const referenceDocuments = [];
|
|
99
|
+
const observe = (reference, requestedVersion, observeHead = false) => {
|
|
100
|
+
const key = edgeReferenceKey(reference);
|
|
101
|
+
const dataset = types.find((kind) => bundleRowTypes[kind].plural === reference.table);
|
|
102
|
+
const cliType = dataset === "lifecyclemodel"
|
|
103
|
+
? "model"
|
|
104
|
+
: (dataset ?? (reference.table === "lciamethods" ? "lciamethod" : null));
|
|
105
|
+
if (!cliType)
|
|
106
|
+
throw new FoundryContextError("edge_support_reference_invalid", "Unsupported exact support reference type.");
|
|
107
|
+
const argv = [
|
|
108
|
+
"dataset",
|
|
109
|
+
cliType,
|
|
110
|
+
"get",
|
|
111
|
+
"--id",
|
|
112
|
+
reference.id,
|
|
113
|
+
"--version",
|
|
114
|
+
requestedVersion,
|
|
115
|
+
"--json",
|
|
116
|
+
];
|
|
117
|
+
const execution = bindWorkflowChildExecution(context, qualified, cli.binPath, argv);
|
|
118
|
+
const child = spawnSync(process.execPath, [cli.binPath, ...argv], {
|
|
119
|
+
cwd: path.dirname(input),
|
|
120
|
+
env: environment,
|
|
121
|
+
encoding: "utf8",
|
|
122
|
+
shell: false,
|
|
123
|
+
timeout: 30_000,
|
|
124
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
125
|
+
});
|
|
126
|
+
const reject = (error) => {
|
|
127
|
+
throw workflowChildFailure(execution, child, "stage_rejected", error);
|
|
128
|
+
};
|
|
129
|
+
if (child.error || child.signal || child.stderr || ![0, 1].includes(child.status ?? -1))
|
|
130
|
+
reject();
|
|
131
|
+
try {
|
|
132
|
+
const envelope = workflowObject(JSON.parse(child.stdout));
|
|
133
|
+
const observed = workflowObject(envelope.context);
|
|
134
|
+
const selected = workflowObject(observed.effectiveInput);
|
|
135
|
+
if (envelope.schemaVersion !== 1 ||
|
|
136
|
+
envelope.operation !== `dataset ${cliType} get` ||
|
|
137
|
+
typeof observed.environment !== "string" ||
|
|
138
|
+
new URL(observed.environment).origin !== expectedOrigin ||
|
|
139
|
+
selected.id !== reference.id ||
|
|
140
|
+
selected.version !== requestedVersion)
|
|
141
|
+
throw new Error("Typed reference result has a different project, UUID or version.");
|
|
142
|
+
save(`reference-${sha256Json([key, requestedVersion])}.json`, envelope);
|
|
143
|
+
if (envelope.status === "failed" &&
|
|
144
|
+
envelope.outcome === "not_found_or_not_visible" &&
|
|
145
|
+
workflowObject(envelope.error).code === "DATASET_NOT_FOUND") {
|
|
146
|
+
return { ...reference, role: "reference", status: "missing_dataset" };
|
|
147
|
+
}
|
|
148
|
+
const data = workflowObject(envelope.data);
|
|
149
|
+
const subject = workflowObject(data.subject);
|
|
150
|
+
const states = [100, 200];
|
|
151
|
+
const visible = typeof subject.stateCode === "number" &&
|
|
152
|
+
(states.includes(subject.stateCode) ||
|
|
153
|
+
(subject.stateCode === 0 && subject.owner === account.userId));
|
|
154
|
+
if (child.status !== 0 ||
|
|
155
|
+
envelope.status !== "completed" ||
|
|
156
|
+
envelope.error !== null ||
|
|
157
|
+
envelope.outcome !== "dataset_read" ||
|
|
158
|
+
subject.type !== cliType ||
|
|
159
|
+
subject.id !== reference.id ||
|
|
160
|
+
typeof subject.version !== "string")
|
|
161
|
+
throw new Error("Typed reference result does not prove the exact visible version.");
|
|
162
|
+
const content = workflowObject(data.content);
|
|
163
|
+
const observedHash = sha256Json(content);
|
|
164
|
+
if (requestedVersion !== "latest" &&
|
|
165
|
+
(dataset === "flow" || dataset === "flowproperty" || dataset === "unitgroup"))
|
|
166
|
+
referenceDocuments.push(content);
|
|
167
|
+
const expectedHash = requestedVersion === "latest" ? undefined : assessedFlowHashes.get(key);
|
|
168
|
+
return {
|
|
169
|
+
...reference,
|
|
170
|
+
role: "reference",
|
|
171
|
+
status: expectedHash && expectedHash !== observedHash
|
|
172
|
+
? "payload_mismatch"
|
|
173
|
+
: visible && (observeHead || subject.version === reference.version)
|
|
174
|
+
? "ok"
|
|
175
|
+
: "state_code_mismatch",
|
|
176
|
+
remote_user_id: subject.owner,
|
|
177
|
+
remote_state_code: subject.stateCode,
|
|
178
|
+
remote_payload_sha256: observedHash,
|
|
179
|
+
observed_version: subject.version,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
return reject(error);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const matchesReview = (observed, expected) => observed.status === "ok" &&
|
|
187
|
+
"remote_payload_sha256" in observed &&
|
|
188
|
+
observed.remote_payload_sha256 === expected.payload_sha256 &&
|
|
189
|
+
observed.remote_user_id === expected.user_id &&
|
|
190
|
+
observed.remote_state_code === expected.state_code;
|
|
191
|
+
const checks = [...references].map(([key, reference]) => {
|
|
192
|
+
const observed = observe(reference, reference.version);
|
|
193
|
+
const review = intent?.reviewed.get(key);
|
|
194
|
+
if (!review)
|
|
195
|
+
return observed;
|
|
196
|
+
const latest = observe(review.latest, "latest");
|
|
197
|
+
return {
|
|
198
|
+
...observed,
|
|
199
|
+
status: matchesReview(observed, review.selected) && matchesReview(latest, review.latest)
|
|
200
|
+
? "ok"
|
|
201
|
+
: "reference_intent_drift",
|
|
202
|
+
reviewed_latest: review.latest,
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
const blockers = checks
|
|
206
|
+
.filter((check) => check.status !== "ok")
|
|
207
|
+
.map((check) => ({ ...check, code: check.status }));
|
|
208
|
+
const flowHeads = type === "flow"
|
|
209
|
+
? plan.roots.map((root) => {
|
|
210
|
+
const observed = observe(root, "latest", true);
|
|
211
|
+
if (observed.status === "missing_dataset")
|
|
212
|
+
return { id: root.id, head: null };
|
|
213
|
+
if (observed.status === "ok" &&
|
|
214
|
+
"observed_version" in observed &&
|
|
215
|
+
isNextFlowVersion(observed.observed_version, root.version) &&
|
|
216
|
+
typeof observed.remote_user_id === "string" &&
|
|
217
|
+
(observed.remote_state_code === 100 ||
|
|
218
|
+
(observed.remote_state_code === 0 && observed.remote_user_id === account.userId))) {
|
|
219
|
+
return {
|
|
220
|
+
id: root.id,
|
|
221
|
+
head: {
|
|
222
|
+
table: root.table,
|
|
223
|
+
id: root.id,
|
|
224
|
+
version: observed.observed_version,
|
|
225
|
+
user_id: observed.remote_user_id,
|
|
226
|
+
state_code: observed.remote_state_code,
|
|
227
|
+
payload_sha256: observed.remote_payload_sha256,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
blockers.push({ ...observed, code: "flow_target_not_next_version" });
|
|
232
|
+
return { id: root.id, head: null };
|
|
233
|
+
})
|
|
234
|
+
: null;
|
|
235
|
+
const reportFile = path.join(output, "edge-support-precommit.json");
|
|
236
|
+
const report = {
|
|
237
|
+
schema: "tiangong-foundry.edge-support-precommit.v1",
|
|
238
|
+
status: blockers.length ? "blocked_remote_verification" : "passed_remote_verification",
|
|
239
|
+
input_path: input,
|
|
240
|
+
edge_plan_sha256: plan.sha256,
|
|
241
|
+
checks,
|
|
242
|
+
blockers,
|
|
243
|
+
counts: { rows: rows.length, blockers: blockers.length },
|
|
244
|
+
...(intent ? { reference_intent: intent.binding } : {}),
|
|
245
|
+
...(flowHeads ? { flow_heads: flowHeads } : {}),
|
|
246
|
+
files: { report: reportFile },
|
|
247
|
+
};
|
|
248
|
+
save("edge-support-precommit.json", report);
|
|
249
|
+
return {
|
|
250
|
+
stage,
|
|
251
|
+
status: report.status,
|
|
252
|
+
report,
|
|
253
|
+
exit_code: blockers.length ? 1 : 0,
|
|
254
|
+
referenceDocuments,
|
|
255
|
+
command: "foundry-edge-support-dependency-read",
|
|
256
|
+
args: [],
|
|
257
|
+
stderr: "",
|
|
258
|
+
};
|
|
259
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { createFoundryEdgeActor } from "./foundry-edge-session.ts";
|
|
2
|
+
import type { EdgeSupportPlan, EdgeSupportRoot } from "./foundry-edge-support-plan.ts";
|
|
3
|
+
type Actor = Awaited<ReturnType<typeof createFoundryEdgeActor>>;
|
|
4
|
+
type RootContent = {
|
|
5
|
+
root: EdgeSupportRoot;
|
|
6
|
+
content: Record<string, unknown>;
|
|
7
|
+
beforeContent?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export declare function verifyFoundryEdgeSupport(actor: Actor, plan: EdgeSupportPlan, phase: "before" | "after", retainRepairReferences?: boolean): Promise<{
|
|
10
|
+
responses: unknown[];
|
|
11
|
+
blockers: {
|
|
12
|
+
table: string;
|
|
13
|
+
id: string;
|
|
14
|
+
version: string;
|
|
15
|
+
role: string;
|
|
16
|
+
}[];
|
|
17
|
+
}>;
|
|
18
|
+
export declare function dispatchFoundryEdgeSupport(actor: Actor, plan: EdgeSupportPlan, rows: RootContent[], createModel?: (root: EdgeSupportRoot, content: Record<string, unknown>) => unknown): Promise<unknown[]>;
|
|
19
|
+
export {};
|