@tiangong-lca/foundry 0.1.17 → 0.1.18

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.
Files changed (111) hide show
  1. package/README.md +23 -7
  2. package/docs/architecture.md +15 -3
  3. package/docs/foundry-task-contracts.md +27 -3
  4. package/docs/package-distribution-contract.md +45 -13
  5. package/docs/public-runtime-contract.md +73 -5
  6. package/docs/runtime-context-contract.md +20 -4
  7. package/docs/task-authorization-contract.md +15 -3
  8. package/docs/workspace-migration-contract.md +5 -3
  9. package/package-dist/assets/foundry-package-descriptor.json +333 -139
  10. package/package-dist/scripts/foundry-facade.d.ts +5 -0
  11. package/package-dist/scripts/foundry-facade.js +258 -16
  12. package/package-dist/scripts/foundry-runtime.d.ts +1 -1
  13. package/package-dist/scripts/lib/bundle-sample-utils.d.ts +4 -4
  14. package/package-dist/scripts/lib/bundle-source-context.d.ts +6 -4
  15. package/package-dist/scripts/lib/bundle-source-context.js +10 -8
  16. package/package-dist/scripts/lib/decision-owners/identity-preflight.js +16 -6
  17. package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +2 -1
  18. package/package-dist/scripts/lib/finalize-owners/post-authoring.js +28 -1
  19. package/package-dist/scripts/lib/foundry-assessment-producer.d.ts +6 -0
  20. package/package-dist/scripts/lib/foundry-assessment-producer.js +167 -0
  21. package/package-dist/scripts/lib/foundry-command-metadata.js +6 -1
  22. package/package-dist/scripts/lib/foundry-decision-owners.d.ts +1 -1
  23. package/package-dist/scripts/lib/foundry-decision-owners.js +15 -7
  24. package/package-dist/scripts/lib/foundry-execution-admission.js +4 -1
  25. package/package-dist/scripts/lib/foundry-finalize-owners.js +64 -17
  26. package/package-dist/scripts/lib/foundry-identity-stage-input.d.ts +24 -0
  27. package/package-dist/scripts/lib/foundry-identity-stage-input.js +122 -0
  28. package/package-dist/scripts/lib/foundry-identity-stage-state.d.ts +17 -0
  29. package/package-dist/scripts/lib/foundry-identity-stage-state.js +48 -0
  30. package/package-dist/scripts/lib/foundry-installed-entry.d.ts +2 -0
  31. package/package-dist/scripts/lib/foundry-installed-entry.js +173 -0
  32. package/package-dist/scripts/lib/foundry-managed-adoption.d.ts +12 -0
  33. package/package-dist/scripts/lib/foundry-managed-adoption.js +108 -0
  34. package/package-dist/scripts/lib/foundry-managed-authentication.d.ts +4 -0
  35. package/package-dist/scripts/lib/foundry-managed-authentication.js +28 -0
  36. package/package-dist/scripts/lib/foundry-managed-host.js +14 -2
  37. package/package-dist/scripts/lib/foundry-migration-transfer-io.d.ts +2 -0
  38. package/package-dist/scripts/lib/foundry-migration-transfer-io.js +27 -3
  39. package/package-dist/scripts/lib/foundry-operation-result.d.ts +1 -1
  40. package/package-dist/scripts/lib/foundry-operation-result.js +1 -0
  41. package/package-dist/scripts/lib/foundry-package-contract.d.ts +4 -4
  42. package/package-dist/scripts/lib/foundry-package-contract.js +10 -2
  43. package/package-dist/scripts/lib/foundry-preparation-cli-validation.d.ts +2 -0
  44. package/package-dist/scripts/lib/foundry-preparation-cli-validation.js +25 -3
  45. package/package-dist/scripts/lib/foundry-quality-review-context.d.ts +3 -0
  46. package/package-dist/scripts/lib/foundry-quality-review-context.js +18 -0
  47. package/package-dist/scripts/lib/foundry-quality-review-input.d.ts +48 -0
  48. package/package-dist/scripts/lib/foundry-quality-review-input.js +284 -0
  49. package/package-dist/scripts/lib/foundry-quality-review-lineage.d.ts +13 -0
  50. package/package-dist/scripts/lib/foundry-quality-review-lineage.js +123 -0
  51. package/package-dist/scripts/lib/foundry-quality-review.d.ts +112 -0
  52. package/package-dist/scripts/lib/foundry-quality-review.js +487 -0
  53. package/package-dist/scripts/lib/foundry-runtime-identity.js +3 -1
  54. package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
  55. package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
  56. package/package-dist/scripts/lib/foundry-task-authorization.d.ts +2 -1
  57. package/package-dist/scripts/lib/foundry-task-authorization.js +32 -11
  58. package/package-dist/scripts/lib/foundry-task-registration.js +4 -5
  59. package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.d.ts +28 -0
  60. package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.js +250 -0
  61. package/package-dist/scripts/lib/foundry-task-runtime-adoption.d.ts +60 -0
  62. package/package-dist/scripts/lib/foundry-task-runtime-adoption.js +549 -0
  63. package/package-dist/scripts/lib/foundry-task-store.d.ts +4 -1
  64. package/package-dist/scripts/lib/foundry-task-store.js +113 -4
  65. package/package-dist/scripts/lib/foundry-task-types.d.ts +2 -1
  66. package/package-dist/scripts/lib/foundry-validation-reference-context.d.ts +8 -0
  67. package/package-dist/scripts/lib/foundry-validation-reference-context.js +115 -0
  68. package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +1 -0
  69. package/package-dist/scripts/lib/foundry-workflow-assessment.js +115 -22
  70. package/package-dist/scripts/lib/foundry-workflow-authorization.js +17 -4
  71. package/package-dist/scripts/lib/foundry-workflow-child-failure.d.ts +44 -0
  72. package/package-dist/scripts/lib/foundry-workflow-child-failure.js +439 -0
  73. package/package-dist/scripts/lib/foundry-workflow-context.js +37 -8
  74. package/package-dist/scripts/lib/foundry-workflow-finalize.js +37 -0
  75. package/package-dist/scripts/lib/foundry-workflow-identity-recovery.d.ts +6 -0
  76. package/package-dist/scripts/lib/foundry-workflow-identity-recovery.js +450 -0
  77. package/package-dist/scripts/lib/foundry-workflow-identity-stage.d.ts +9 -0
  78. package/package-dist/scripts/lib/foundry-workflow-identity-stage.js +676 -0
  79. package/package-dist/scripts/lib/foundry-workflow-identity.js +10 -1
  80. package/package-dist/scripts/lib/foundry-workflow-io.d.ts +7 -1
  81. package/package-dist/scripts/lib/foundry-workflow-io.js +76 -11
  82. package/package-dist/scripts/lib/foundry-workflow-semantic.js +27 -13
  83. package/package-dist/scripts/lib/foundry-workflow-state.d.ts +4 -0
  84. package/package-dist/scripts/lib/foundry-workflow-state.js +165 -22
  85. package/package-dist/scripts/lib/identity-preflight-artifacts.d.ts +4 -7
  86. package/package-dist/scripts/lib/identity-preflight-artifacts.js +18 -5
  87. package/package-dist/scripts/lib/identity-preflight-proof.d.ts +5 -0
  88. package/package-dist/scripts/lib/identity-preflight-proof.js +73 -1
  89. package/package-dist/scripts/lib/identity-preflight-recovery-proof.d.ts +78 -0
  90. package/package-dist/scripts/lib/identity-preflight-recovery-proof.js +415 -0
  91. package/package-dist/scripts/lib/import-curation/curation-cleanup.d.ts +9 -1
  92. package/package-dist/scripts/lib/import-curation/curation-cleanup.js +39 -2
  93. package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +1 -0
  94. package/package-dist/scripts/lib/import-curation/curation-gate.js +19 -1
  95. package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
  96. package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.js +11 -2
  97. package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.js +4 -1
  98. package/package-dist/scripts/package-entry.js +2 -3
  99. package/package-dist/scripts/public-api.d.ts +5 -0
  100. package/package-dist/scripts/public-api.js +2 -0
  101. package/package-dist/scripts/runtime-entry.d.ts +2 -0
  102. package/package-dist/scripts/runtime-entry.js +42 -15
  103. package/package.json +6 -2
  104. package/specs/schemas/foundry-identity-stage-input.schema.json +47 -0
  105. package/specs/schemas/foundry-managed-adoption.schema.json +40 -0
  106. package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
  107. package/specs/schemas/foundry-operation-result.schema.json +1 -0
  108. package/specs/schemas/foundry-package-descriptor.schema.json +6 -2
  109. package/specs/schemas/foundry-quality-review-draft.schema.json +271 -0
  110. package/specs/schemas/foundry-quality-review-input.schema.json +271 -0
  111. package/specs/schemas/runtime-qualification.schema.json +1 -1
@@ -0,0 +1,17 @@
1
+ import { type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
2
+ import type { ArtifactEntry } from "./foundry-task-types.ts";
3
+ /** Native indexed admissions remain visible even when result capture was interrupted. */
4
+ export declare function pendingFoundryIdentityStage(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): Readonly<{
5
+ stage_id: string;
6
+ intent_id: unknown;
7
+ preparation: {
8
+ path: string;
9
+ bytes: number;
10
+ sha256: string;
11
+ };
12
+ indexed_dispatch_artifacts: number;
13
+ disposition: string;
14
+ new_cli_execution: null;
15
+ result_registered: boolean;
16
+ }> | null;
17
+ export declare function assertNoPendingFoundryIdentityStage(context: FoundryRuntimeContext, entries: readonly ArtifactEntry[]): void;
@@ -0,0 +1,48 @@
1
+ import path from "node:path";
2
+ import { FoundryContextError } from "./foundry-runtime-context.js";
3
+ import { readWorkflowArtifact } from "./foundry-workflow-state.js";
4
+ /** Native indexed admissions remain visible even when result capture was interrupted. */
5
+ export function pendingFoundryIdentityStage(context, entries) {
6
+ for (const entry of [...entries].reverse()) {
7
+ if (entry.command !== "dataset-workflow-identity-stage-prepare" ||
8
+ path.basename(entry.path) !== "identity-stage-preparation.json")
9
+ continue;
10
+ const prepared = readWorkflowArtifact(context, entry);
11
+ const stageId = prepared.value.stage_id;
12
+ if (prepared.value.schema !== "tiangong-foundry.identity-stage-preparation.v1" ||
13
+ typeof stageId !== "string" ||
14
+ !/^[a-f0-9]{64}$/u.test(stageId) ||
15
+ prepared.value.task_id !== context.taskId ||
16
+ prepared.value.actor_id !== context.actorId)
17
+ throw new FoundryContextError("identity_stage_unproven", "Indexed read-only stage admission is invalid; preserve its evidence without replay.");
18
+ const resultEntry = entries.findLast((candidate) => {
19
+ if (candidate.command !== "dataset-workflow-identity" ||
20
+ path.basename(candidate.path) !== "foundry-identity.json" ||
21
+ candidate.sequence <= entry.sequence)
22
+ return false;
23
+ return readWorkflowArtifact(context, candidate).value.stage_id === stageId;
24
+ });
25
+ const result = resultEntry ? readWorkflowArtifact(context, resultEntry).value : null;
26
+ if (result?.schema === "tiangong-foundry.identity-stage.v1" &&
27
+ result.explicit_new_stage === true &&
28
+ result.status === "completed")
29
+ continue;
30
+ const claims = entries.filter((candidate) => candidate.command === "dataset-workflow-identity-stage-dispatch" &&
31
+ candidate.sequence > entry.sequence &&
32
+ candidate.path.startsWith(path.dirname(path.dirname(entry.path)) + "/"));
33
+ return Object.freeze({
34
+ stage_id: stageId,
35
+ intent_id: prepared.value.intent_id,
36
+ preparation: { path: prepared.file, bytes: entry.bytes, sha256: entry.sha256 },
37
+ indexed_dispatch_artifacts: claims.length,
38
+ disposition: claims.length ? "CLAIMED_OUTCOME_UNPROVEN" : "PREPARED_OUTCOME_UNPROVEN",
39
+ new_cli_execution: null,
40
+ result_registered: result !== null,
41
+ });
42
+ }
43
+ return null;
44
+ }
45
+ export function assertNoPendingFoundryIdentityStage(context, entries) {
46
+ if (pendingFoundryIdentityStage(context, entries))
47
+ throw new FoundryContextError("identity_stage_unproven", "The indexed explicit read-only stage has no proven completed result. Inspect its admission and retained claims; ordinary resume cannot dispatch another query.");
48
+ }
@@ -0,0 +1,2 @@
1
+ /** Deployment selection happens before managed IPC. Existing returned actions enter IPC directly. */
2
+ export declare function runFoundryInstalledCommand(argv?: string[]): Promise<void>;
@@ -0,0 +1,173 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { parseArgs } from "node:util";
4
+ import { executeRuntimeLaunch, inspectRuntimeComponents, loadTrustedRuntimeManifest, RUNTIME_HOST_CONTEXT_PROTOCOL, } from "@tiangong-lca/cli/runtime";
5
+ import { runFoundryPublicCommand } from "../runtime-entry.js";
6
+ import { receiveFoundryManagedHost } from "./foundry-managed-host.js";
7
+ import { FoundryContextError } from "./foundry-runtime-error.js";
8
+ import { transferHash, transferRead } from "./foundry-migration-transfer-io.js";
9
+ const help = `Usage: tiangong-foundry runtime describe --json [--require-protocol <schema>]
10
+ tiangong-foundry <workspace|task|doctor> <public arguments>
11
+
12
+ Configure the installed entry with TIANGONG_FOUNDRY_MANIFEST and
13
+ TIANGONG_FOUNDRY_MANIFEST_SHA256 from a verified Foundry release.
14
+ TIANGONG_FOUNDRY_CACHE_DIR selects an existing absolute component cache.
15
+ TIANGONG_FOUNDRY_ENTRY optionally selects a declared launch (default: foundry).
16
+
17
+ runtime describe reads local identity, protocols and cache readiness without
18
+ authentication, downloads or workspace changes. Missing configuration/assets or
19
+ unsupported required protocols exit nonzero. Install the selected release with
20
+ the existing CLI runtime ensure command, then repeat runtime describe.
21
+
22
+ Configured operations use the selected verified managed runtime. Continue an
23
+ existing task through its returned executable/argv/cwd to retain its binding.
24
+ `;
25
+ function fail(code, message) {
26
+ throw new FoundryContextError(code, message);
27
+ }
28
+ function configuration(env) {
29
+ const manifest = env.TIANGONG_FOUNDRY_MANIFEST;
30
+ const digest = env.TIANGONG_FOUNDRY_MANIFEST_SHA256;
31
+ const cacheDir = env.TIANGONG_FOUNDRY_CACHE_DIR;
32
+ const entry = env.TIANGONG_FOUNDRY_ENTRY ?? "foundry";
33
+ if ([manifest, digest, cacheDir, env.TIANGONG_FOUNDRY_ENTRY].every((item) => item === undefined))
34
+ return null;
35
+ if (!manifest || !path.isAbsolute(manifest) || !digest || !/^[a-f0-9]{64}$/u.test(digest))
36
+ fail("runtime_configuration_invalid", "Set an absolute TIANGONG_FOUNDRY_MANIFEST and its independently verified TIANGONG_FOUNDRY_MANIFEST_SHA256 together.");
37
+ if (cacheDir !== undefined && (!cacheDir || !path.isAbsolute(cacheDir)))
38
+ fail("runtime_configuration_invalid", "TIANGONG_FOUNDRY_CACHE_DIR must be an absolute directory.");
39
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/u.test(entry))
40
+ fail("runtime_configuration_invalid", "TIANGONG_FOUNDRY_ENTRY must name a declared launch.");
41
+ if (!fs.existsSync(manifest))
42
+ fail("runtime_manifest_missing", "The configured manifest is missing. Install the selected release manifest before invoking Foundry.");
43
+ const trusted = loadTrustedRuntimeManifest(manifest, digest);
44
+ if (trusted.manifest.product.id !== "tiangong-foundry")
45
+ fail("runtime_product_unsupported", "The configured manifest must declare the tiangong-foundry product.");
46
+ const report = inspectRuntimeComponents(trusted, { cacheDir });
47
+ const launch = trusted.manifest.launches.find((item) => item.id === entry && item.platform === report.platform);
48
+ if (!launch ||
49
+ launch.context_protocol !== RUNTIME_HOST_CONTEXT_PROTOCOL ||
50
+ launch.argv.length !== 1 ||
51
+ !("component" in launch.argv[0]))
52
+ fail("runtime_launch_unsupported", "Select a declared Foundry managed launch with the runtime host protocol.");
53
+ return { trusted, report, launch, cacheDir, entry, manifest };
54
+ }
55
+ function describe(selection, required) {
56
+ const { trusted, report, launch } = selection;
57
+ const application = launch.argv[0];
58
+ if (!("component" in application))
59
+ fail("runtime_launch_unsupported", "Managed launch requires a package entry.");
60
+ let cliVersion = null;
61
+ let protocols = [];
62
+ if (report.status === "ready") {
63
+ const component = trusted.manifest.components.find((item) => item.id === application.component && item.platform === report.platform);
64
+ const installed = report.components.find((item) => item.id === application.component);
65
+ const descriptorPath = path.posix.join(path.posix.dirname(application.path), "../assets/foundry-package-descriptor.json");
66
+ const fact = component.files.find((item) => item.path === descriptorPath);
67
+ if (!fact)
68
+ fail("runtime_descriptor_missing", "Selected release does not bind a public Foundry package descriptor.");
69
+ const bytes = transferRead(path.join(installed.root, descriptorPath), 8 * 1024 * 1024);
70
+ if (bytes.length !== fact.bytes || transferHash(bytes) !== fact.sha256)
71
+ fail("runtime_descriptor_changed", "Selected package descriptor differs from the verified manifest.");
72
+ const value = JSON.parse(bytes.toString("utf8"));
73
+ if (value?.schema !== "tiangong-foundry.package-descriptor.v1" ||
74
+ value.package?.name !== "@tiangong-lca/foundry" ||
75
+ value.package.version !== trusted.manifest.product.version ||
76
+ value.package.cli_dependency?.name !== "@tiangong-lca/cli" ||
77
+ typeof value.package.cli_dependency.version !== "string" ||
78
+ !Array.isArray(value.runtime?.protocol_schemas) ||
79
+ !value.runtime.protocol_schemas.every((item) => typeof item === "string"))
80
+ fail("runtime_descriptor_unsupported", "Selected release has an unsupported or inconsistent package descriptor.");
81
+ cliVersion = value.package.cli_dependency.version;
82
+ protocols = value.runtime.protocol_schemas;
83
+ }
84
+ const missing = required.filter((protocol) => !protocols.includes(protocol));
85
+ const status = report.status === "ready" && missing.length ? "unsupported" : report.status;
86
+ return {
87
+ schema: "tiangong-foundry.runtime-description.v1",
88
+ status,
89
+ product: trusted.manifest.product,
90
+ cli_version: cliVersion,
91
+ manifest_sha256: trusted.sha256,
92
+ entry: selection.entry,
93
+ platform: report.platform,
94
+ components: report.components,
95
+ protocols,
96
+ protocol_assessment: report.status === "ready" ? "checked" : "not_checked",
97
+ unsupported_protocols: report.status === "ready" ? missing : [],
98
+ next: status === "missing"
99
+ ? "Install the selected components with tiangong-lca runtime ensure using this manifest and digest."
100
+ : status === "ready"
101
+ ? "Use the public task commands; retain returned actions for existing tasks."
102
+ : "Select a compatible verified release or repair its installation, then repeat runtime describe.",
103
+ };
104
+ }
105
+ /** Deployment selection happens before managed IPC. Existing returned actions enter IPC directly. */
106
+ export async function runFoundryInstalledCommand(argv = process.argv) {
107
+ if (typeof process.send === "function") {
108
+ await runFoundryPublicCommand(argv, {}, receiveFoundryManagedHost);
109
+ return;
110
+ }
111
+ const args = argv.slice(2);
112
+ if ((args.length === 1 && ["--help", "-h"].includes(args[0])) ||
113
+ (args[0] === "runtime" && args.includes("--help"))) {
114
+ process.stdout.write(help);
115
+ return;
116
+ }
117
+ const controller = new AbortController();
118
+ const interrupt = () => controller.abort();
119
+ try {
120
+ const selected = configuration(process.env);
121
+ if (args[0] === "runtime") {
122
+ if (args[1] !== "describe")
123
+ fail("runtime_operation_unsupported", "Use tiangong-foundry runtime describe --json.");
124
+ const { values } = parseArgs({
125
+ args: args.slice(2),
126
+ strict: true,
127
+ allowPositionals: false,
128
+ options: {
129
+ json: { type: "boolean" },
130
+ "require-protocol": { type: "string", multiple: true },
131
+ },
132
+ });
133
+ if (!values.json)
134
+ fail("argument_json_required", "runtime describe requires --json.");
135
+ if (!selected)
136
+ fail("runtime_not_configured", "Configure TIANGONG_FOUNDRY_MANIFEST and TIANGONG_FOUNDRY_MANIFEST_SHA256 from the installed release, then repeat runtime describe --json.");
137
+ const result = describe(selected, values["require-protocol"] ?? []);
138
+ process.stdout.write(`${JSON.stringify(result)}\n`);
139
+ process.exitCode = result.status === "ready" ? 0 : 4;
140
+ return;
141
+ }
142
+ if (!selected) {
143
+ await runFoundryPublicCommand(argv, {}, receiveFoundryManagedHost);
144
+ return;
145
+ }
146
+ if (selected.report.status !== "ready")
147
+ fail("runtime_not_ready", "Selected runtime components are missing or invalid. Inspect tiangong-foundry runtime describe --json, then install the selected release with runtime ensure.");
148
+ process.once("SIGINT", interrupt);
149
+ process.once("SIGTERM", interrupt);
150
+ const result = await executeRuntimeLaunch(selected.trusted, {
151
+ cacheDir: selected.cacheDir,
152
+ entry: selected.entry,
153
+ cwd: process.cwd(),
154
+ argv: args,
155
+ env: process.env,
156
+ signal: controller.signal,
157
+ fetchImpl: async () => fail("runtime_installation_required", "A selected component disappeared before launch. Install it explicitly with runtime ensure, then inspect readiness before continuing."),
158
+ });
159
+ process.stdout.write(result.stdout);
160
+ process.stderr.write(result.stderr);
161
+ if (result.error && !result.stderr)
162
+ process.stderr.write("Foundry managed launch failed; inspect the selected runtime before recovery.\n");
163
+ process.exitCode = controller.signal.aborted ? 130 : result.error ? 1 : (result.status ?? 1);
164
+ }
165
+ catch (error) {
166
+ process.stdout.write(`${JSON.stringify({ schema: "tiangong-foundry.runtime-description.v1", status: "blocked", error: { code: error instanceof FoundryContextError ? error.code : "runtime_selection_failed", message: error instanceof FoundryContextError ? error.message : "Runtime selection failed. Check configuration, manifest integrity and installed components with runtime describe --json." } })}\n`);
167
+ process.exitCode = 4;
168
+ }
169
+ finally {
170
+ process.removeListener("SIGINT", interrupt);
171
+ process.removeListener("SIGTERM", interrupt);
172
+ }
173
+ }
@@ -0,0 +1,12 @@
1
+ import { type RuntimeHostContext, type RuntimeLaunch, type TrustedRuntimeManifest } from "@tiangong-lca/cli/runtime";
2
+ import { type TrustedFoundryRuntimeAdoptionQualification } from "./foundry-task-runtime-adoption.ts";
3
+ export declare const FOUNDRY_MANAGED_ADOPTION_SCHEMA: "tiangong-foundry.managed-adoption.v1";
4
+ export declare const FOUNDRY_MANAGED_ADOPTION_PATH: "metadata/foundry-adoption.json";
5
+ type Reference = RuntimeLaunch["executable"];
6
+ export interface ManagedFoundryAdoption {
7
+ readonly manifest: TrustedRuntimeManifest;
8
+ readonly qualification?: TrustedFoundryRuntimeAdoptionQualification;
9
+ }
10
+ /** Admit only an independently trusted carrier; task, environment and argv bytes are not inputs. */
11
+ export declare function prepareFoundryManagedAdoption(context: RuntimeHostContext, read: (reference: Reference, limit: number) => Uint8Array, target?: Reference | null): ManagedFoundryAdoption | null;
12
+ export {};
@@ -0,0 +1,108 @@
1
+ import { RUNTIME_HOST_CONTEXT_PROTOCOL, copyTrustedRuntimeManifestBytes, trustRuntimeManifest, } from "@tiangong-lca/cli/runtime";
2
+ import { createFoundryRuntimeAdoptionQualification, } from "./foundry-task-runtime-adoption.js";
3
+ import { FoundryContextError } from "./foundry-runtime-error.js";
4
+ import { transferHash } from "./foundry-migration-transfer-io.js";
5
+ import { sha256Json } from "./identity-preflight-proof.js";
6
+ export const FOUNDRY_MANAGED_ADOPTION_SCHEMA = "tiangong-foundry.managed-adoption.v1";
7
+ export const FOUNDRY_MANAGED_ADOPTION_PATH = "metadata/foundry-adoption.json";
8
+ const protocolPrefix = "tiangong-foundry.managed-adoption.";
9
+ function fail(message) {
10
+ throw new FoundryContextError("managed_runtime_invalid", message);
11
+ }
12
+ function object(value, keys) {
13
+ if (!value || typeof value !== "object" || Array.isArray(value))
14
+ fail("Managed adoption control metadata must be an object.");
15
+ const record = value;
16
+ if (Object.keys(record).length !== keys.length || keys.some((key) => !Object.hasOwn(record, key)))
17
+ fail("Managed adoption control metadata has missing or unsupported fields.");
18
+ return record;
19
+ }
20
+ /** Admit only an independently trusted carrier; task, environment and argv bytes are not inputs. */
21
+ export function prepareFoundryManagedAdoption(context, read, target = null) {
22
+ // The public CLI's brand prevents a serialized carrier from issuing host authority.
23
+ copyTrustedRuntimeManifestBytes(context.manifest);
24
+ const carrier = context.manifest.manifest;
25
+ const controls = carrier.components.filter((component) => component.protocols.some((protocol) => protocol.startsWith(protocolPrefix)) ||
26
+ component.files.some((file) => file.path === FOUNDRY_MANAGED_ADOPTION_PATH));
27
+ if (!controls.length)
28
+ return null;
29
+ if (controls.length !== 1)
30
+ fail("Managed adoption requires exactly one control component.");
31
+ const control = controls[0];
32
+ const protocols = control.protocols.filter((protocol) => protocol.startsWith(protocolPrefix));
33
+ if (protocols.some((protocol) => protocol !== FOUNDRY_MANAGED_ADOPTION_SCHEMA))
34
+ throw new FoundryContextError("managed_runtime_unsupported", "This Foundry package cannot read the selected managed adoption protocol.");
35
+ if (protocols.length !== 1 ||
36
+ control.protocols.length !== 1 ||
37
+ control.platform !== context.host.platform ||
38
+ control.files.some((file) => file.mode !== 0o644))
39
+ fail("Managed adoption control must use one supported protocol and non-executable files.");
40
+ if (target !== null)
41
+ fail("Managed adoption cannot be mixed with a rollback target policy.");
42
+ if (carrier.launches.some((launch) => launch.executable.component === control.id ||
43
+ launch.argv.some((argument) => "component" in argument && argument.component === control.id)))
44
+ fail("Managed adoption control cannot be referenced by a runtime launch.");
45
+ const reference = (value) => {
46
+ const item = object(value, ["component", "path"]);
47
+ if (item.component !== control.id ||
48
+ typeof item.path !== "string" ||
49
+ !control.files.some((file) => file.path === item.path))
50
+ fail("Managed adoption references must name files in the same control component.");
51
+ return { component: control.id, path: item.path };
52
+ };
53
+ const bound = (ref, limit) => {
54
+ const fact = control.files.find((file) => file.path === ref.path);
55
+ if (ref.component !== control.id || !fact || fact.bytes > limit)
56
+ fail("Managed adoption control file is missing or exceeds its inventory bound.");
57
+ const data = Buffer.from(read(ref, limit));
58
+ if (data.length !== fact.bytes || transferHash(data) !== fact.sha256)
59
+ fail("Managed adoption control bytes changed after inventory admission.");
60
+ return { data, sha256: fact.sha256 };
61
+ };
62
+ const metadata = object(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bound({ component: control.id, path: FOUNDRY_MANAGED_ADOPTION_PATH }, 256 * 1024).data)), ["schema", "platform", "successor_manifest", "launches"]);
63
+ if (metadata.schema !== FOUNDRY_MANAGED_ADOPTION_SCHEMA ||
64
+ metadata.platform !== context.host.platform)
65
+ fail("Managed adoption control metadata must match its protocol and current platform.");
66
+ const successorFile = bound(reference(metadata.successor_manifest), 32 * 1024 * 1024);
67
+ const manifest = trustRuntimeManifest(successorFile.data, successorFile.sha256);
68
+ const { components: runtimeComponents, ...runtimeFields } = manifest.manifest;
69
+ const { components: carrierComponents, ...carrierFields } = carrier;
70
+ if (runtimeComponents.some((component) => component.id === control.id) ||
71
+ sha256Json(runtimeFields) !== sha256Json(carrierFields) ||
72
+ sha256Json(runtimeComponents) !==
73
+ sha256Json(carrierComponents.filter((component) => component !== control)))
74
+ fail("Managed adoption carrier must preserve every runtime component and execution binding.");
75
+ if (!Array.isArray(metadata.launches) ||
76
+ !metadata.launches.length ||
77
+ metadata.launches.length > 16)
78
+ fail("Managed adoption requires bounded explicit launch policies.");
79
+ const seen = new Set();
80
+ const policies = metadata.launches.map((value) => {
81
+ const item = object(value, ["id", "qualification"]);
82
+ if (typeof item.id !== "string" ||
83
+ !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/u.test(item.id) ||
84
+ seen.has(item.id) ||
85
+ !carrier.launches.some((launch) => launch.platform === context.host.platform &&
86
+ launch.id === item.id &&
87
+ launch.context_protocol === RUNTIME_HOST_CONTEXT_PROTOCOL))
88
+ fail("Managed adoption policies require unique declared managed launch ids.");
89
+ seen.add(item.id);
90
+ return {
91
+ id: item.id,
92
+ qualification: item.qualification === null ? null : reference(item.qualification),
93
+ };
94
+ });
95
+ const selected = policies.find((policy) => policy.id === context.entry);
96
+ if (!selected)
97
+ fail("The selected managed launch requires an explicit adoption policy.");
98
+ if (selected.qualification === null)
99
+ return Object.freeze({ manifest });
100
+ const qualificationFile = bound(selected.qualification, 8 * 1024 * 1024);
101
+ const qualification = createFoundryRuntimeAdoptionQualification({
102
+ bytes: qualificationFile.data,
103
+ expectedSha256: qualificationFile.sha256,
104
+ });
105
+ if (qualification.value.successor_manifest_sha256 !== manifest.sha256)
106
+ fail("Managed adoption qualification must bind the exact successor runtime manifest.");
107
+ return Object.freeze({ manifest, qualification });
108
+ }
@@ -0,0 +1,4 @@
1
+ import type { RuntimeLaunch } from "@tiangong-lca/cli/runtime";
2
+ import type { FoundryAuthentication } from "./foundry-authentication-environment.ts";
3
+ /** The verified carrier and CLI launch policy select this existing credential channel. */
4
+ export declare function createManagedFoundryAuthentication(environment: RuntimeLaunch["environment"], carrierAdmitted: boolean, source: NodeJS.ProcessEnv): FoundryAuthentication | undefined;
@@ -0,0 +1,28 @@
1
+ import { FoundryContextError } from "./foundry-runtime-error.js";
2
+ /** The verified carrier and CLI launch policy select this existing credential channel. */
3
+ export function createManagedFoundryAuthentication(environment, carrierAdmitted, source) {
4
+ if (!carrierAdmitted || environment !== "cli-auth")
5
+ return undefined;
6
+ const mode = source.TIANGONG_LCA_AUTH_MODE || "oauth";
7
+ if (mode === "access_token") {
8
+ const accessToken = source.TIANGONG_LCA_ACCESS_TOKEN;
9
+ const apiBaseUrl = source.TIANGONG_LCA_API_BASE_URL;
10
+ const publishableKey = source.TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY;
11
+ if (!accessToken || !apiBaseUrl || !publishableKey)
12
+ throw new FoundryContextError("managed_authentication_invalid", "Managed headless authentication requires the existing CLI explicit public target and process-only token.");
13
+ return Object.freeze({ mode: "headless", accessToken, apiBaseUrl, publishableKey });
14
+ }
15
+ if (mode !== "oauth")
16
+ throw new FoundryContextError("managed_authentication_invalid", "The selected managed authentication mode is unsupported.");
17
+ const fields = [
18
+ ["apiBaseUrl", "TIANGONG_LCA_API_BASE_URL"],
19
+ ["publishableKey", "TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY"],
20
+ ["oauthClientId", "TIANGONG_LCA_OAUTH_CLIENT_ID"],
21
+ ["oauthRedirectUri", "TIANGONG_LCA_OAUTH_REDIRECT_URI"],
22
+ ];
23
+ const configuration = {};
24
+ for (const [key, variable] of fields)
25
+ if (source[variable])
26
+ configuration[key] = source[variable];
27
+ return Object.freeze({ mode: "oauth", configuration: Object.freeze(configuration) });
28
+ }
@@ -2,6 +2,8 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { RUNTIME_HOST_CONTEXT_PROTOCOL, assertCliRuntimeMatches, inspectRuntimeComponents, receiveRuntimeHostContext, trustRuntimeManifest, } from "@tiangong-lca/cli/runtime";
4
4
  import { createManagedFoundryActionProjector } from "./foundry-managed-actions.js";
5
+ import { prepareFoundryManagedAdoption } from "./foundry-managed-adoption.js";
6
+ import { createManagedFoundryAuthentication } from "./foundry-managed-authentication.js";
5
7
  import { FoundryContextError } from "./foundry-runtime-error.js";
6
8
  import { describeFoundryRuntime } from "./foundry-runtime-paths.js";
7
9
  import { assertFoundryPackage } from "./foundry-package-contract.js";
@@ -129,20 +131,30 @@ function prepare(context) {
129
131
  const policy = policies.find((item) => item.id === context.entry);
130
132
  if (!policy)
131
133
  fail("The selected launch has no Foundry access policy.");
134
+ const adoption = prepareFoundryManagedAdoption(context, bytes, policy.target);
135
+ if (adoption &&
136
+ inspectRuntimeComponents(adoption.manifest, {
137
+ cacheDir: context.cacheDir,
138
+ host: context.host,
139
+ }).status !== "ready")
140
+ fail("The independently bound successor runtime changed before Foundry admission.");
141
+ const workspaceManifest = adoption?.manifest ?? context.manifest;
132
142
  const target = policy.target
133
143
  ? trustRuntimeManifest(bytes(policy.target, 32 * 1024 * 1024), file(policy.target).fact.sha256)
134
- : context.manifest;
144
+ : workspaceManifest;
135
145
  if (target.manifest.product.id !== "tiangong-foundry")
136
146
  fail("Runtime selection targets must be Foundry manifests.");
137
147
  return Object.freeze({
138
148
  projectNextActions: createManagedFoundryActionProjector(context, observedCli, runtime.entryPath),
139
- workspaceAccess: Object.freeze({ manifest: context.manifest, access: policy.access }),
149
+ workspaceAccess: Object.freeze({ manifest: workspaceManifest, access: policy.access }),
140
150
  runtimeSelection: Object.freeze({
141
151
  cliExpectation: Object.freeze(cli),
142
152
  tidasExpectation,
143
153
  tidasExecutable: tidasFile.absolute,
144
154
  }),
145
155
  runtimeTarget: target,
156
+ runtimeAdoptionQualification: adoption?.qualification,
157
+ authentication: createManagedFoundryAuthentication(selected.environment, adoption !== null, process.env),
146
158
  runtimeManager: Object.freeze({ cacheDir: context.cacheDir, host: context.host }),
147
159
  cacheBase: path.join(context.cacheDir, "foundry-workspaces"),
148
160
  });
@@ -6,6 +6,8 @@ export declare function transferPath(root: string, relative: string): string;
6
6
  export declare function transferRead(file: string, limit?: number): Buffer;
7
7
  export declare function transferWriteOnce(root: string, relative: string, bytes: Buffer, scratchRelative?: string): void;
8
8
  export declare function transferFileFact(file: string): FoundryInputFact;
9
+ /** Verify retained inventory content without constructing an unused canonical locator. */
10
+ export declare function transferFileContentFact(file: string): Pick<FoundryInputFact, "bytes" | "sha256">;
9
11
  export declare function transferCopy(root: string, relative: string, source: FoundryInputFact, scratch: string): void;
10
12
  export declare function transferTree(root: string): {
11
13
  files: string[];
@@ -99,7 +99,20 @@ export function transferWriteOnce(root, relative, bytes, scratchRelative) {
99
99
  fs.unlinkSync(temp);
100
100
  }
101
101
  }
102
- export function transferFileFact(file) {
102
+ function transferCanonicalPath(file) {
103
+ // Canonical retained paths can avoid the interpreted absolute-ancestor walk.
104
+ // Other spellings and native failures retain the existing resolver behavior.
105
+ try {
106
+ const resolved = fs.realpathSync.native(file);
107
+ if (resolved === path.resolve(file))
108
+ return resolved;
109
+ }
110
+ catch {
111
+ // The generic resolver also supports filesystems without native resolution.
112
+ }
113
+ return fs.realpathSync(file);
114
+ }
115
+ function transferVerifiedFile(file, capture) {
103
116
  const before = fs.lstatSync(file, { bigint: true });
104
117
  if (!before.isFile() || before.isSymbolicLink() || before.size > 64n * 1024n * 1024n)
105
118
  transferFail("migration_file_invalid", "Transfer file must be bounded and regular.");
@@ -108,7 +121,7 @@ export function transferFileFact(file) {
108
121
  const opened = fs.fstatSync(fd, { bigint: true });
109
122
  if (opened.ino !== before.ino || opened.dev !== before.dev)
110
123
  transferFail("migration_source_changed", "Transfer file identity changed.");
111
- const hash = createHash("sha256"), buffer = Buffer.alloc(1024 * 1024);
124
+ const hash = createHash("sha256"), buffer = Buffer.alloc(Math.max(1, Math.min(1024 * 1024, Number(before.size))));
112
125
  let bytes = 0;
113
126
  while (true) {
114
127
  const count = fs.readSync(fd, buffer, 0, buffer.length, null);
@@ -129,12 +142,23 @@ export function transferFileFact(file) {
129
142
  linked.ino !== before.ino ||
130
143
  linked.dev !== before.dev)
131
144
  transferFail("migration_source_changed", "Transfer file changed during hashing.");
132
- return { path: fs.realpathSync(file), bytes, sha256: hash.digest("hex") };
145
+ return capture(bytes, hash);
133
146
  }
134
147
  finally {
135
148
  fs.closeSync(fd);
136
149
  }
137
150
  }
151
+ export function transferFileFact(file) {
152
+ return transferVerifiedFile(file, (bytes, hash) => ({
153
+ path: transferCanonicalPath(file),
154
+ bytes,
155
+ sha256: hash.digest("hex"),
156
+ }));
157
+ }
158
+ /** Verify retained inventory content without constructing an unused canonical locator. */
159
+ export function transferFileContentFact(file) {
160
+ return transferVerifiedFile(file, (bytes, hash) => ({ bytes, sha256: hash.digest("hex") }));
161
+ }
138
162
  export function transferCopy(root, relative, source, scratch) {
139
163
  const file = transferPath(root, relative);
140
164
  if (fs.existsSync(file)) {
@@ -1,7 +1,7 @@
1
1
  export declare const FOUNDRY_OPERATION_RESULT_SCHEMA: "tiangong-foundry.operation-result.v1";
2
2
  export declare const foundryOperationStatuses: readonly ["ready", "running", "needs_auth", "needs_input", "blocked", "completed", "failed"];
3
3
  export declare const foundryOperationPermissionStates: readonly ["not_required", "required", "granted", "invalid"];
4
- export declare const foundryPublicOperations: readonly ["workspace.init", "doctor", "task.start", "task.status", "task.resume", "workspace.migrate"];
4
+ export declare const foundryPublicOperations: readonly ["workspace.init", "doctor", "task.start", "task.status", "task.resume", "task.adopt-runtime", "workspace.migrate"];
5
5
  export type FoundryOperationStatus = (typeof foundryOperationStatuses)[number];
6
6
  export type FoundryOperationPermissionState = (typeof foundryOperationPermissionStates)[number];
7
7
  export type FoundryPublicOperation = "unknown" | (typeof foundryPublicOperations)[number];
@@ -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";
@@ -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.17";
5
+ declare const packageVersion = "0.1.18";
6
6
  declare const cliPackageName = "@tiangong-lca/cli";
7
- declare const cliPackageVersion = "0.1.27";
7
+ declare const cliPackageVersion = "0.1.28";
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.17";
60
+ const packageVersion = "0.1.18";
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.1.27";
63
+ const cliPackageVersion = "0.1.28";
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;