@tiangong-lca/foundry 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/docs/architecture.md +5 -3
- package/docs/foundry-task-contracts.md +2 -0
- package/docs/package-distribution-contract.md +10 -8
- package/docs/public-runtime-contract.md +53 -3
- package/docs/runtime-context-contract.md +7 -3
- package/docs/task-authorization-contract.md +2 -0
- package/package-dist/assets/foundry-package-descriptor.json +374 -136
- package/package-dist/scripts/foundry-facade.d.ts +6 -0
- package/package-dist/scripts/foundry-facade.js +38 -0
- package/package-dist/scripts/foundry-runtime.d.ts +3 -2
- package/package-dist/scripts/lib/decision-owners/identity-preflight.js +3 -1
- package/package-dist/scripts/lib/final-delivery-manifest.d.ts +40 -0
- package/package-dist/scripts/lib/final-delivery-manifest.js +145 -0
- package/package-dist/scripts/lib/final-delivery-review.d.ts +37 -0
- package/package-dist/scripts/lib/final-delivery-review.js +108 -0
- 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/native-draft-handoff.js +4 -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 +24 -0
- package/package-dist/scripts/lib/foundry-edge-repair-preparation.js +209 -0
- package/package-dist/scripts/lib/foundry-edge-session.d.ts +32 -0
- package/package-dist/scripts/lib/foundry-edge-session.js +203 -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-interaction-input.js +2 -2
- package/package-dist/scripts/lib/foundry-managed-authentication.js +1 -1
- 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 +21 -0
- package/package-dist/scripts/lib/foundry-owner-readback.js +61 -0
- package/package-dist/scripts/lib/foundry-package-contract.d.ts +4 -4
- package/package-dist/scripts/lib/foundry-package-contract.js +8 -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-census.d.ts +82 -0
- package/package-dist/scripts/lib/foundry-repair-census.js +574 -0
- package/package-dist/scripts/lib/foundry-repair-execution.js +13 -2
- package/package-dist/scripts/lib/foundry-repair-scope.d.ts +15 -2
- package/package-dist/scripts/lib/foundry-repair-scope.js +62 -10
- 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-scientific-repair.d.ts +38 -0
- package/package-dist/scripts/lib/foundry-scientific-repair.js +438 -0
- package/package-dist/scripts/lib/foundry-semantic-input.js +1 -1
- package/package-dist/scripts/lib/foundry-task-input-preparation.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-task-input-preparation.js +160 -0
- package/package-dist/scripts/lib/foundry-task-registration.js +19 -1
- package/package-dist/scripts/lib/foundry-task-types.d.ts +2 -0
- 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 +57 -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.d.ts +5 -0
- package/package-dist/scripts/lib/foundry-workflow-repair.js +204 -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-dist/scripts/public-api.d.ts +6 -0
- package/package-dist/scripts/runtime-entry.js +15 -6
- package/package.json +5 -2
- package/specs/schemas/foundry-interaction-draft.schema.json +323 -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 +5 -2
- package/specs/schemas/foundry-scientific-repair.schema.json +66 -0
- package/specs/schemas/foundry-semantic-draft.schema.json +50 -0
- package/specs/schemas/foundry-task-start.schema.json +10 -2
- package/specs/schemas/runtime-qualification.schema.json +1 -1
|
@@ -4,8 +4,10 @@ import { sha256Json, sha256Text } from "./identity-preflight-proof.js";
|
|
|
4
4
|
import { datasetIdentity } from "./import-curation/internal/dataset-payload.js";
|
|
5
5
|
import { readRows } from "./import-curation/internal/runtime-io.js";
|
|
6
6
|
import { readNativeDraftHandoff } from "./finalize-owners/native-draft-handoff.js";
|
|
7
|
+
import { readScientificRepairEvidence, } from "./foundry-scientific-repair.js";
|
|
7
8
|
/** Phase 1 admits only Process, and only the two reviewed administrative display-text regions. */
|
|
8
9
|
export const FOUNDRY_REPAIR_SELECTION_KIND = "existing-owner-draft-metadata";
|
|
10
|
+
export const FOUNDRY_SCIENTIFIC_REPAIR_SELECTION_KIND = "existing-owner-draft-scientific";
|
|
9
11
|
export const FOUNDRY_REPAIR_ALLOWED_DATASET_TYPE = "process";
|
|
10
12
|
export const FOUNDRY_REPAIR_EDIT_PATHS = Object.freeze([
|
|
11
13
|
"processDataSet.modellingAndValidation.dataSourcesTreatmentAndRepresentativeness" +
|
|
@@ -31,6 +33,20 @@ export const FOUNDRY_REPAIR_SHARED_SCIENCE_PREFIXES = Object.freeze([
|
|
|
31
33
|
"flowPropertyDataSet",
|
|
32
34
|
"unitGroupDataSet",
|
|
33
35
|
]);
|
|
36
|
+
const scientificEditPrefixes = [
|
|
37
|
+
"processDataSet.exchanges",
|
|
38
|
+
"processDataSet.processInformation.quantitativeReference",
|
|
39
|
+
"processDataSet.processInformation.mathematicalRelations",
|
|
40
|
+
"processDataSet.processInformation.time",
|
|
41
|
+
"processDataSet.processInformation.geography",
|
|
42
|
+
"processDataSet.processInformation.technology",
|
|
43
|
+
"processDataSet.processInformation.dataSetInformation.name",
|
|
44
|
+
"processDataSet.processInformation.dataSetInformation.common:synonyms",
|
|
45
|
+
"processDataSet.processInformation.dataSetInformation.common:generalComment",
|
|
46
|
+
"processDataSet.processInformation.dataSetInformation.classificationInformation",
|
|
47
|
+
"processDataSet.modellingAndValidation.LCIMethod",
|
|
48
|
+
"processDataSet.modellingAndValidation.dataSourcesTreatmentAndRepresentativeness",
|
|
49
|
+
];
|
|
34
50
|
const idPattern = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,255}$/u;
|
|
35
51
|
const shaPattern = /^[0-9a-f]{64}$/u;
|
|
36
52
|
const blankTextSentinel = "FoundryRepairBlankLanguageText";
|
|
@@ -76,15 +92,21 @@ function selectionPath(value, code, label) {
|
|
|
76
92
|
/** Parse the optional repair selection of a task-start spec against the independently selected sources. */
|
|
77
93
|
export function parseFoundryRepairSelection(value, sources, resolveSelection = (file) => file) {
|
|
78
94
|
const item = record(value, "task_spec_repair_invalid", "Repair selection");
|
|
79
|
-
exact(item,
|
|
80
|
-
|
|
95
|
+
exact(item, item.kind === FOUNDRY_SCIENTIFIC_REPAIR_SELECTION_KIND
|
|
96
|
+
? ["kind", "contract", "before", "candidate", "predecessor", "scientific"]
|
|
97
|
+
: ["kind", "contract", "before", "candidate", "predecessor"], "task_spec_repair_invalid", "Repair selection");
|
|
98
|
+
if (item.kind !== FOUNDRY_REPAIR_SELECTION_KIND &&
|
|
99
|
+
item.kind !== FOUNDRY_SCIENTIFIC_REPAIR_SELECTION_KIND)
|
|
81
100
|
fail("task_spec_repair_invalid", "Repair selection kind is unsupported.");
|
|
82
101
|
const contract = resolveSelection(selectionPath(item.contract, "task_spec_repair_invalid", "Repair contract"));
|
|
83
102
|
const before = resolveSelection(selectionPath(item.before, "task_spec_repair_invalid", "Repair before rows"));
|
|
84
103
|
const candidate = resolveSelection(selectionPath(item.candidate, "task_spec_repair_invalid", "Repair candidate rows"));
|
|
104
|
+
const scientific = item.kind === FOUNDRY_SCIENTIFIC_REPAIR_SELECTION_KIND
|
|
105
|
+
? resolveSelection(selectionPath(item.scientific, "task_spec_repair_invalid", "Scientific repair evidence"))
|
|
106
|
+
: undefined;
|
|
85
107
|
if (new Set([contract, before, candidate]).size !== 3)
|
|
86
108
|
fail("task_spec_repair_invalid", "Repair selections must name three distinct files.");
|
|
87
|
-
for (const selected of [contract, before, candidate])
|
|
109
|
+
for (const selected of [contract, before, candidate, ...(scientific ? [scientific] : [])])
|
|
88
110
|
if (!sources.some((source) => source.path === selected))
|
|
89
111
|
fail("task_spec_repair_invalid", "Repair contract, before rows and candidate rows must each be independently selected sources.");
|
|
90
112
|
let predecessor = null;
|
|
@@ -98,11 +120,12 @@ export function parseFoundryRepairSelection(value, sources, resolveSelection = (
|
|
|
98
120
|
predecessor = Object.freeze({ task_id: taskId, receipt_sha256: receipt });
|
|
99
121
|
}
|
|
100
122
|
return Object.freeze({
|
|
101
|
-
kind:
|
|
123
|
+
kind: item.kind,
|
|
102
124
|
contract,
|
|
103
125
|
before,
|
|
104
126
|
candidate,
|
|
105
127
|
predecessor,
|
|
128
|
+
...(scientific ? { scientific } : {}),
|
|
106
129
|
});
|
|
107
130
|
}
|
|
108
131
|
function navigate(value, path) {
|
|
@@ -213,6 +236,14 @@ export function classifyRepairMetadataDiff(before, after) {
|
|
|
213
236
|
? { allowed: false, blockers }
|
|
214
237
|
: { allowed: false, blockers: [{ path: "<unclassified>", reason: "structure_change" }] };
|
|
215
238
|
}
|
|
239
|
+
/** Scientific review cannot widen administrative ownership, permissions or technical-header scope. */
|
|
240
|
+
export function assertScientificRepairPaths(before, candidate) {
|
|
241
|
+
const changes = collectRepairChangedPaths(blankRepairEditableText(before), blankRepairEditableText(candidate));
|
|
242
|
+
const blocked = changes.filter((changed) => changed.split(".").includes("common:other") ||
|
|
243
|
+
!scientificEditPrefixes.some((prefix) => changed === prefix || changed.startsWith(`${prefix}.`)));
|
|
244
|
+
if (blocked.length)
|
|
245
|
+
fail("repair_scientific_scope_unsupported", `Scientific repair changes protected identity, administrative or technical fields. Changed paths ${blocked.slice(0, 8).join(", ")}.`);
|
|
246
|
+
}
|
|
216
247
|
/**
|
|
217
248
|
* Validate one repair task: the CLI execution contract, the CLI-fresh before rows and the candidate rows
|
|
218
249
|
* must agree on the exact same Process identities, every action must be a save_draft against an existing
|
|
@@ -255,6 +286,17 @@ export function readFoundryRepairScope(input) {
|
|
|
255
286
|
if (beforeByIdentity.size !== candidateByIdentity.size ||
|
|
256
287
|
[...beforeByIdentity.keys()].some((key) => !candidateByIdentity.has(key)))
|
|
257
288
|
fail("repair_scope_identity_mismatch", "Repair candidate rows must cover exactly the selected before identities; versions are never minted.");
|
|
289
|
+
if (input.scientific)
|
|
290
|
+
for (const [key, candidate] of candidateByIdentity)
|
|
291
|
+
assertScientificRepairPaths(beforeByIdentity.get(key), candidate);
|
|
292
|
+
const scientific = input.scientific
|
|
293
|
+
? readScientificRepairEvidence({
|
|
294
|
+
...input.scientific,
|
|
295
|
+
beforeFile: input.beforeFile,
|
|
296
|
+
candidateFile: input.candidateFile,
|
|
297
|
+
userId: input.targetUserId,
|
|
298
|
+
})
|
|
299
|
+
: undefined;
|
|
258
300
|
const changedPaths = [];
|
|
259
301
|
const actions = native.contract.actions.map((action) => {
|
|
260
302
|
const key = JSON.stringify([action.id, action.version]);
|
|
@@ -275,13 +317,22 @@ export function readFoundryRepairScope(input) {
|
|
|
275
317
|
};
|
|
276
318
|
const changed = collectRepairChangedPaths(beforePayload, candidatePayload);
|
|
277
319
|
const verdict = classifyRepairMetadataDiff(beforePayload, candidatePayload);
|
|
278
|
-
if (!verdict.allowed) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
: "repair_metadata_scope_blocked", `Repair diff is outside the phase-1 metadata allowlist: ${verdict.blockers
|
|
320
|
+
if (!verdict.allowed && !scientific) {
|
|
321
|
+
const requiresProviderImpact = verdict.blockers.some((blocker) => blocker.reason === "provider_impact_diagnostics_missing");
|
|
322
|
+
const affectedPaths = verdict.blockers
|
|
282
323
|
.slice(0, 8)
|
|
283
324
|
.map((item) => item.path)
|
|
284
|
-
.join(", ")
|
|
325
|
+
.join(", ");
|
|
326
|
+
fail(requiresProviderImpact
|
|
327
|
+
? "repair_provider_impact_diagnostics_missing"
|
|
328
|
+
: "repair_metadata_scope_blocked", requiresProviderImpact
|
|
329
|
+
? `Scientific repair remains blocked for changed paths ${affectedPaths}. ` +
|
|
330
|
+
"Retain the exact before and candidate inputs for the Worker-owned frozen-input " +
|
|
331
|
+
"provider-impact diagnostic tracked at https://github.com/tiangong-lca/worker/issues/288, " +
|
|
332
|
+
"binding before/candidate content and affected provider/consumer closure. " +
|
|
333
|
+
"Foundry must separately verify field-bound source evidence, QA and curation " +
|
|
334
|
+
"before scientific repair can enter authorization."
|
|
335
|
+
: `Repair diff is outside the phase-1 metadata allowlist. Changed paths ${affectedPaths}.`);
|
|
285
336
|
}
|
|
286
337
|
changedPaths.push(...changed);
|
|
287
338
|
return {
|
|
@@ -294,7 +345,8 @@ export function readFoundryRepairScope(input) {
|
|
|
294
345
|
};
|
|
295
346
|
});
|
|
296
347
|
return Object.freeze({
|
|
297
|
-
kind: FOUNDRY_REPAIR_SELECTION_KIND,
|
|
348
|
+
kind: scientific ? FOUNDRY_SCIENTIFIC_REPAIR_SELECTION_KIND : FOUNDRY_REPAIR_SELECTION_KIND,
|
|
349
|
+
...(scientific ? { scientific } : {}),
|
|
298
350
|
status: changedPaths.length ? "dispatchable" : "satisfied",
|
|
299
351
|
contract_sha256: native.canonical_sha256,
|
|
300
352
|
rows_sha256: native.rows_sha256,
|
|
@@ -7,3 +7,5 @@ export interface FoundryIsolatedChildEnvironmentOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function copyFoundryIsolatedExecutable(sourcePath: string, targetPath: string): void;
|
|
9
9
|
export declare function createFoundryIsolatedChildEnvironment({ tempRoot, sourceEnv, overrides, }: FoundryIsolatedChildEnvironmentOptions): NodeJS.ProcessEnv;
|
|
10
|
+
/** Node 24 uses a fixed PATH_MAX buffer for os.homedir() on Windows. */
|
|
11
|
+
export declare function withFoundryIsolatedLocalCliEnvironment<T>(tempRoot: string, run: (environment: NodeJS.ProcessEnv) => T): T;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import process from "node:process";
|
|
4
5
|
export const runtimeEnvFilePolicyKey = "FOUNDRY_RUNTIME_ENV_FILE_POLICY";
|
|
@@ -88,3 +89,20 @@ export function createFoundryIsolatedChildEnvironment({ tempRoot, sourceEnv = pr
|
|
|
88
89
|
}
|
|
89
90
|
return environment;
|
|
90
91
|
}
|
|
92
|
+
/** Node 24 uses a fixed PATH_MAX buffer for os.homedir() on Windows. */
|
|
93
|
+
export function withFoundryIsolatedLocalCliEnvironment(tempRoot, run) {
|
|
94
|
+
const fitsWindowsHome = (root) => Buffer.byteLength(path.join(root, "home")) < 260;
|
|
95
|
+
if (process.platform !== "win32" || fitsWindowsHome(tempRoot))
|
|
96
|
+
return run(createFoundryIsolatedChildEnvironment({ tempRoot }));
|
|
97
|
+
const base = os.tmpdir();
|
|
98
|
+
const prefix = path.join(base, "foundry-cli-");
|
|
99
|
+
if (!fitsWindowsHome(`${prefix}XXXXXX`))
|
|
100
|
+
throw new Error("Windows temporary directory is too long for an isolated CLI user profile.");
|
|
101
|
+
const shortRoot = fs.mkdtempSync(prefix);
|
|
102
|
+
try {
|
|
103
|
+
return run(createFoundryIsolatedChildEnvironment({ tempRoot: shortRoot }));
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
fs.rmSync(shortRoot, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -3,6 +3,7 @@ import { type QualifiedFoundryRuntime } from "./foundry-runtime-qualification.ts
|
|
|
3
3
|
import { type AuthIdentityReceipt } from "./identity-preflight-proof.ts";
|
|
4
4
|
import { type FoundryAuthentication } from "./foundry-authentication-environment.ts";
|
|
5
5
|
export type { FoundryPublicOAuthConfiguration, FoundryAuthentication, } from "./foundry-authentication-environment.ts";
|
|
6
|
+
export declare function readFoundryCliIdentityResult(stdout: string, packageVersion: string): unknown;
|
|
6
7
|
export interface VerifiedFoundryIdentity {
|
|
7
8
|
readonly receipt: AuthIdentityReceipt;
|
|
8
9
|
readonly workspaceId: string;
|
|
@@ -7,6 +7,24 @@ import { assertQualifiedFoundryRuntime, } from "./foundry-runtime-qualification.
|
|
|
7
7
|
import { resolveInstalledTiangongLcaCliPackage } from "./foundry-runtime-utils.js";
|
|
8
8
|
import { parseFreshIntentBoundAuthReceipt, } from "./identity-preflight-proof.js";
|
|
9
9
|
import { createFoundryAuthenticationEnvironment, } from "./foundry-authentication-environment.js";
|
|
10
|
+
function resultRecord(value) {
|
|
11
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
12
|
+
throw new Error("CLI identity result must be an object.");
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
export function readFoundryCliIdentityResult(stdout, packageVersion) {
|
|
16
|
+
const value = JSON.parse(stdout);
|
|
17
|
+
if (packageVersion !== "0.4.0")
|
|
18
|
+
return value;
|
|
19
|
+
const envelope = resultRecord(value);
|
|
20
|
+
if (envelope.schemaVersion !== 1 ||
|
|
21
|
+
envelope.operation !== "auth identity-receipt" ||
|
|
22
|
+
envelope.status !== "completed" ||
|
|
23
|
+
envelope.outcome !== "identity_verified" ||
|
|
24
|
+
envelope.error !== null)
|
|
25
|
+
throw new Error("Expected a completed CLI identity receipt.");
|
|
26
|
+
return resultRecord(envelope.data).receipt;
|
|
27
|
+
}
|
|
10
28
|
const verifiedIdentities = new WeakSet();
|
|
11
29
|
const maxAgeMs = 60_000;
|
|
12
30
|
function reject(code, message) {
|
|
@@ -64,7 +82,7 @@ export function verifyFoundryRuntimeIdentity(context, authentication = { mode: "
|
|
|
64
82
|
reject("needs_auth", "The owner CLI could not verify the intended task account.");
|
|
65
83
|
let receipt;
|
|
66
84
|
try {
|
|
67
|
-
receipt = parseFreshIntentBoundAuthReceipt(
|
|
85
|
+
receipt = parseFreshIntentBoundAuthReceipt(readFoundryCliIdentityResult(result.stdout, cli.packageVersion), {
|
|
68
86
|
nowMs: Date.now(),
|
|
69
87
|
maxAgeMs,
|
|
70
88
|
expectedProjectRef: account.projectRef,
|
|
@@ -157,8 +157,8 @@ export function qualifyFoundryRuntime(context, options) {
|
|
|
157
157
|
catch {
|
|
158
158
|
return fail("runtime_cli_unqualified", "CLI runtime bytes do not match the independently selected C1 expectation.");
|
|
159
159
|
}
|
|
160
|
-
if (cli.package.version !== "0.
|
|
161
|
-
fail("runtime_cli_unqualified", "Foundry requires the exact CLI 0.
|
|
160
|
+
if (cli.package.version !== "0.4.0" || cli.platform !== context.platform)
|
|
161
|
+
fail("runtime_cli_unqualified", "Foundry requires the exact CLI 0.4.0 C1 runtime on the selected platform.");
|
|
162
162
|
const cliExpectation = Object.freeze({ ...options.cliExpectation });
|
|
163
163
|
if (cliExpectation.schema !== CLI_RUNTIME_EXPECTATION_SCHEMA)
|
|
164
164
|
fail("runtime_cli_unqualified", "CLI runtime expectation is not the supported schema.");
|
|
@@ -9,7 +9,7 @@ import { resolveFoundryRuntimePaths } from "./foundry-runtime-paths.js";
|
|
|
9
9
|
import { resolveTiangongLcaCliTidasSource, } from "./foundry-tidas-source.js";
|
|
10
10
|
const require = createRequire(import.meta.url);
|
|
11
11
|
const tiangongLcaCliPackageName = "@tiangong-lca/cli";
|
|
12
|
-
const tiangongLcaCliPackageVersion = "0.
|
|
12
|
+
export const tiangongLcaCliPackageVersion = "0.4.0";
|
|
13
13
|
const tiangongLcaCliBinName = "tiangong-lca";
|
|
14
14
|
const { repoRoot: foundryRepoRoot } = resolveFoundryRuntimePaths(import.meta.url);
|
|
15
15
|
function isRecord(value) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type FoundryInputFact } from "./foundry-runtime-context.ts";
|
|
2
|
+
import type { FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
3
|
+
import type { QualifiedFoundryRuntime } from "./foundry-runtime-qualification.ts";
|
|
4
|
+
type Json = Record<string, unknown>;
|
|
5
|
+
export interface ScientificRepairRuntime {
|
|
6
|
+
readonly configuration: FoundryInputFact;
|
|
7
|
+
readonly executable: FoundryInputFact;
|
|
8
|
+
}
|
|
9
|
+
/** Deployment configuration is outside every task selection and survives the managed CLI host. */
|
|
10
|
+
export declare function readScientificRepairRuntime(excludedRoots: readonly string[]): ScientificRepairRuntime;
|
|
11
|
+
export interface ScientificRepairEvidence {
|
|
12
|
+
readonly schema: "tiangong-foundry.scientific-repair-evidence.v1";
|
|
13
|
+
readonly descriptor: FoundryInputFact;
|
|
14
|
+
readonly worker_input: FoundryInputFact;
|
|
15
|
+
readonly worker_report: FoundryInputFact;
|
|
16
|
+
readonly changes: FoundryInputFact;
|
|
17
|
+
readonly review: FoundryInputFact;
|
|
18
|
+
readonly sources: readonly FoundryInputFact[];
|
|
19
|
+
readonly runtime: ScientificRepairRuntime;
|
|
20
|
+
}
|
|
21
|
+
/** Exact JSON Pointer differences, with arrays of changed length covered as one complete value. */
|
|
22
|
+
export declare function scientificRepairChanges(before: unknown, candidate: unknown, pointer?: string): string[];
|
|
23
|
+
export declare function readScientificRepairEvidence(input: {
|
|
24
|
+
descriptorFile: string;
|
|
25
|
+
beforeFile: string;
|
|
26
|
+
candidateFile: string;
|
|
27
|
+
actorId: string;
|
|
28
|
+
userId: string;
|
|
29
|
+
selectedFiles: readonly string[];
|
|
30
|
+
excludedRuntimeRoots: readonly string[];
|
|
31
|
+
read: (file: string) => Buffer;
|
|
32
|
+
}): ScientificRepairEvidence;
|
|
33
|
+
/** Recompute the independently reviewed report with the exact trusted native bytes. */
|
|
34
|
+
export declare function runScientificRepairDiagnostic(evidence: ScientificRepairEvidence, directory: string): Json;
|
|
35
|
+
export declare function assertScientificRepairDiagnosticReport(report: Json, evidence: ScientificRepairEvidence): void;
|
|
36
|
+
/** The published CLI applies the evidence-bound edit proposal to the complete before document. */
|
|
37
|
+
export declare function applyScientificRepairProposals(context: FoundryRuntimeContext, qualified: QualifiedFoundryRuntime, temporary: string, evidence: ScientificRepairEvidence, beforeFile: string, candidateFile: string, directory: string): void;
|
|
38
|
+
export {};
|