@tiangong-lca/foundry 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/docs/package-distribution-contract.md +5 -5
  2. package/docs/public-runtime-contract.md +12 -0
  3. package/docs/runtime-context-contract.md +2 -0
  4. package/package-dist/assets/foundry-package-descriptor.json +268 -98
  5. package/package-dist/scripts/foundry-facade.js +3 -0
  6. package/package-dist/scripts/foundry-runtime.d.ts +1 -1
  7. package/package-dist/scripts/lib/decision-owners/identity-preflight.js +3 -1
  8. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.d.ts +72 -1
  9. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.js +123 -3
  10. package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +9 -0
  11. package/package-dist/scripts/lib/finalize-owners/post-authoring.js +37 -8
  12. package/package-dist/scripts/lib/foundry-authentication-environment.js +1 -1
  13. package/package-dist/scripts/lib/foundry-curation-queue.d.ts +73 -0
  14. package/package-dist/scripts/lib/foundry-curation-queue.js +261 -0
  15. package/package-dist/scripts/lib/foundry-edge-draft-admission.d.ts +17 -0
  16. package/package-dist/scripts/lib/foundry-edge-draft-admission.js +94 -0
  17. package/package-dist/scripts/lib/foundry-edge-identity-preflight.d.ts +47 -0
  18. package/package-dist/scripts/lib/foundry-edge-identity-preflight.js +268 -0
  19. package/package-dist/scripts/lib/foundry-edge-oauth.d.ts +4 -0
  20. package/package-dist/scripts/lib/foundry-edge-oauth.js +154 -0
  21. package/package-dist/scripts/lib/foundry-edge-reference-intent.d.ts +51 -0
  22. package/package-dist/scripts/lib/foundry-edge-reference-intent.js +184 -0
  23. package/package-dist/scripts/lib/foundry-edge-repair-preparation.d.ts +21 -0
  24. package/package-dist/scripts/lib/foundry-edge-repair-preparation.js +120 -0
  25. package/package-dist/scripts/lib/foundry-edge-session.d.ts +15 -0
  26. package/package-dist/scripts/lib/foundry-edge-session.js +69 -0
  27. package/package-dist/scripts/lib/foundry-edge-support-plan.d.ts +69 -0
  28. package/package-dist/scripts/lib/foundry-edge-support-plan.js +245 -0
  29. package/package-dist/scripts/lib/foundry-edge-support-planning.d.ts +115 -0
  30. package/package-dist/scripts/lib/foundry-edge-support-planning.js +259 -0
  31. package/package-dist/scripts/lib/foundry-edge-support.d.ts +19 -0
  32. package/package-dist/scripts/lib/foundry-edge-support.js +188 -0
  33. package/package-dist/scripts/lib/foundry-execution-admission.d.ts +4 -2
  34. package/package-dist/scripts/lib/foundry-execution-admission.js +24 -2
  35. package/package-dist/scripts/lib/foundry-finalize-edge-identity.d.ts +30 -0
  36. package/package-dist/scripts/lib/foundry-finalize-edge-identity.js +102 -0
  37. package/package-dist/scripts/lib/foundry-finalize-owners.d.ts +1 -0
  38. package/package-dist/scripts/lib/foundry-finalize-owners.js +68 -2
  39. package/package-dist/scripts/lib/foundry-managed-authentication.js +1 -1
  40. package/package-dist/scripts/lib/foundry-owner-execution-store.d.ts +16 -16
  41. package/package-dist/scripts/lib/foundry-owner-execution-store.js +34 -7
  42. package/package-dist/scripts/lib/foundry-owner-readback.d.ts +20 -0
  43. package/package-dist/scripts/lib/foundry-owner-readback.js +42 -0
  44. package/package-dist/scripts/lib/foundry-package-contract.d.ts +2 -2
  45. package/package-dist/scripts/lib/foundry-package-contract.js +2 -2
  46. package/package-dist/scripts/lib/foundry-preparation-cli-validation.js +71 -0
  47. package/package-dist/scripts/lib/foundry-process-mass-balance.d.ts +64 -0
  48. package/package-dist/scripts/lib/foundry-process-mass-balance.js +224 -0
  49. package/package-dist/scripts/lib/foundry-process-qa.d.ts +19 -0
  50. package/package-dist/scripts/lib/foundry-process-qa.js +423 -0
  51. package/package-dist/scripts/lib/foundry-repair-execution.js +13 -2
  52. package/package-dist/scripts/lib/foundry-runtime-environment.d.ts +2 -0
  53. package/package-dist/scripts/lib/foundry-runtime-environment.js +18 -0
  54. package/package-dist/scripts/lib/foundry-runtime-identity.d.ts +1 -0
  55. package/package-dist/scripts/lib/foundry-runtime-identity.js +19 -1
  56. package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
  57. package/package-dist/scripts/lib/foundry-runtime-utils.d.ts +1 -0
  58. package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
  59. package/package-dist/scripts/lib/foundry-typed-authoring-patch.d.ts +76 -0
  60. package/package-dist/scripts/lib/foundry-typed-authoring-patch.js +237 -0
  61. package/package-dist/scripts/lib/foundry-typed-context.d.ts +11 -0
  62. package/package-dist/scripts/lib/foundry-typed-context.js +79 -0
  63. package/package-dist/scripts/lib/foundry-typed-flow-qa.d.ts +166 -0
  64. package/package-dist/scripts/lib/foundry-typed-flow-qa.js +226 -0
  65. package/package-dist/scripts/lib/foundry-typed-model-write.d.ts +6 -0
  66. package/package-dist/scripts/lib/foundry-typed-model-write.js +59 -0
  67. package/package-dist/scripts/lib/foundry-workflow-assessment.js +67 -29
  68. package/package-dist/scripts/lib/foundry-workflow-authorization.js +82 -1
  69. package/package-dist/scripts/lib/foundry-workflow-context.js +59 -18
  70. package/package-dist/scripts/lib/foundry-workflow-execution.js +54 -5
  71. package/package-dist/scripts/lib/foundry-workflow-finalize.js +27 -3
  72. package/package-dist/scripts/lib/foundry-workflow-identity-stage.js +202 -161
  73. package/package-dist/scripts/lib/foundry-workflow-identity.js +16 -10
  74. package/package-dist/scripts/lib/foundry-workflow-io.js +27 -6
  75. package/package-dist/scripts/lib/foundry-workflow-reference-verify.js +102 -29
  76. package/package-dist/scripts/lib/foundry-workflow-repair.js +53 -2
  77. package/package-dist/scripts/lib/foundry-workflow-semantic.js +41 -21
  78. package/package-dist/scripts/lib/identity-preflight-proof.d.ts +1 -0
  79. package/package-dist/scripts/lib/identity-preflight-proof.js +19 -12
  80. package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
  81. package/package.json +2 -2
  82. package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
  83. package/specs/schemas/foundry-package-descriptor.schema.json +2 -2
  84. package/specs/schemas/runtime-qualification.schema.json +1 -1
@@ -15,6 +15,7 @@ import { sha256Json } from "./identity-preflight-proof.js";
15
15
  import { readRows } from "./import-curation/internal/runtime-io.js";
16
16
  import { datasetIdentity, unwrapDatasetPayload, } from "./import-curation/internal/dataset-payload.js";
17
17
  import { bundleRowTypes } from "./bundle-row-types.js";
18
+ import { createFoundryEdgeActor } from "./foundry-edge-session.js";
18
19
  function invalid(message) {
19
20
  throw new FoundryContextError("reference_evidence_invalid", message);
20
21
  }
@@ -133,7 +134,10 @@ export async function verifyFoundryReferences(context, qualified, entries, authe
133
134
  const scope = current.scope;
134
135
  if (!scope)
135
136
  invalid("No current canonical reference partition exists.");
136
- verifyFoundryRuntimeIdentity(context, authentication, process.env, qualified);
137
+ const typed = qualified.cli.expectation.package_version === "0.4.0";
138
+ const actor = typed ? await createFoundryEdgeActor(context, qualified, authentication) : null;
139
+ if (!actor)
140
+ verifyFoundryRuntimeIdentity(context, authentication, process.env, qualified);
137
141
  for (const fact of scope.sources)
138
142
  readFoundryInput(context, fact.path);
139
143
  const output = resolveFoundryOutput(context, `outputs/reference-verification/${randomUUID()}`);
@@ -142,7 +146,102 @@ export async function verifyFoundryReferences(context, qualified, entries, authe
142
146
  fs.writeFileSync(input, scope.targets
143
147
  .map((item) => JSON.stringify({ "@type": item.table, "@refObjectId": item.id, "@version": item.version }))
144
148
  .join("\n") + "\n", { mode: 0o600 });
145
- const inputFact = captureFoundryInput(input), cli = resolveInstalledTiangongLcaCliPackage();
149
+ const inputFact = captureFoundryInput(input);
150
+ const publish = (command, blockers, reportFact, checksFact) => {
151
+ if (captureFoundryInput(input).sha256 !== inputFact.sha256)
152
+ invalid("Reference query changed during verification.");
153
+ for (const fact of scope.sources)
154
+ readFoundryInput(context, fact.path);
155
+ return runFoundryTaskOperation(context, {
156
+ command: "dataset-workflow-reference-verify",
157
+ options: { scope: scope.sha256, nonce: path.basename(output) },
158
+ validateCurrent(index) {
159
+ if (foundryReferenceScope(context, index)?.sha256 !== scope.sha256)
160
+ invalid("Reference scope changed during verification.");
161
+ },
162
+ }, (operation) => {
163
+ registerWorkflowStageFiles(context, operation, output);
164
+ const result = {
165
+ schema: "tiangong-foundry.reference-verification.v1",
166
+ status: blockers.length ? "unresolved" : "verified",
167
+ scope_sha256: scope.sha256,
168
+ targets: scope.targets,
169
+ input: inputFact,
170
+ report: reportFact,
171
+ checks: checksFact,
172
+ command,
173
+ blockers,
174
+ };
175
+ operation.writeJson(path.join(output, "foundry-reference-verification.json"), result);
176
+ return result;
177
+ });
178
+ };
179
+ if (actor) {
180
+ const endpoint = "app_dataset_verify_remote";
181
+ const requests = [];
182
+ const checks = [];
183
+ const blockers = [];
184
+ for (let offset = 0; offset < scope.targets.length; offset += 200) {
185
+ const targets = scope.targets.slice(offset, offset + 200);
186
+ const request = {
187
+ rootPolicy: "existing",
188
+ references: targets.map((target) => ({
189
+ ...target,
190
+ role: "reference",
191
+ requirePayload: true,
192
+ })),
193
+ };
194
+ try {
195
+ const response = workflowObject(await actor.post(endpoint, request));
196
+ requests.push({ request, response });
197
+ const report = workflowObject(response.data);
198
+ const counts = workflowObject(report.counts);
199
+ const rows = Array.isArray(report.checks) ? report.checks.map(workflowObject) : [];
200
+ if (response.command !== "dataset_verify_remote" ||
201
+ response.ok !== true ||
202
+ report.status !== "passed_remote_verification" ||
203
+ report.root_policy !== request.rootPolicy ||
204
+ !Array.isArray(report.blockers) ||
205
+ report.blockers.length ||
206
+ counts.blockers !== 0 ||
207
+ counts.references !== targets.length ||
208
+ rows.length !== targets.length)
209
+ blockers.push({ code: "reference_verification_incomplete", offset });
210
+ targets.forEach((target, index) => {
211
+ const check = rows[index];
212
+ if (!check ||
213
+ check.index !== index ||
214
+ check.role !== "reference" ||
215
+ check.id !== target.id ||
216
+ check.table !== target.table ||
217
+ check.version !== target.version ||
218
+ check.status !== "ok" ||
219
+ check.exact_version !== target.version ||
220
+ check.latest_version !== target.version ||
221
+ check.payload_present !== true)
222
+ blockers.push({ code: "canonical_reference_not_verified", target });
223
+ });
224
+ checks.push(...rows);
225
+ }
226
+ catch (error) {
227
+ blockers.push({
228
+ code: error instanceof FoundryContextError ? error.code : "reference_edge_failed",
229
+ offset,
230
+ });
231
+ break;
232
+ }
233
+ }
234
+ const report = path.join(output, "edge-reference-verification.json");
235
+ const checksFile = path.join(output, "checks.jsonl");
236
+ fs.writeFileSync(report, JSON.stringify({ identity: actor.receipt, requests }) + "\n", {
237
+ mode: 0o600,
238
+ });
239
+ fs.writeFileSync(checksFile, checks.map((check) => JSON.stringify(check) + "\n").join(""), {
240
+ mode: 0o600,
241
+ });
242
+ return publish({ transport: "edge", endpoint }, blockers, captureFoundryInput(report), captureFoundryInput(checksFile));
243
+ }
244
+ const cli = resolveInstalledTiangongLcaCliPackage();
146
245
  const command = createFoundryCommandSpec({
147
246
  executable: process.execPath,
148
247
  argv: [
@@ -232,33 +331,7 @@ export async function verifyFoundryReferences(context, qualified, entries, authe
232
331
  }
233
332
  if (run.error || run.signal || run.status !== 0)
234
333
  blockers.push({ code: "reference_cli_failed", exit_code: run.status });
235
- if (captureFoundryInput(input).sha256 !== inputFact.sha256)
236
- invalid("Reference query changed during verification.");
237
- for (const fact of scope.sources)
238
- readFoundryInput(context, fact.path);
239
- return runFoundryTaskOperation(context, {
240
- command: "dataset-workflow-reference-verify",
241
- options: { scope: scope.sha256, nonce: path.basename(output) },
242
- validateCurrent(index) {
243
- if (foundryReferenceScope(context, index)?.sha256 !== scope.sha256)
244
- invalid("Reference scope changed during verification.");
245
- },
246
- }, (operation) => {
247
- registerWorkflowStageFiles(context, operation, output);
248
- const result = {
249
- schema: "tiangong-foundry.reference-verification.v1",
250
- status: blockers.length ? "unresolved" : "verified",
251
- scope_sha256: scope.sha256,
252
- targets: scope.targets,
253
- input: inputFact,
254
- report: reportFact,
255
- checks: checksFact,
256
- command,
257
- blockers,
258
- };
259
- operation.writeJson(path.join(output, "foundry-reference-verification.json"), result);
260
- return result;
261
- });
334
+ return publish(command, blockers, reportFact, checksFact);
262
335
  }
263
336
  finally {
264
337
  delete environment.TIANGONG_LCA_ACCESS_TOKEN;
@@ -1,3 +1,4 @@
1
+ import { prepareEdgeProcessRepair, readEdgeRepairValidation, } from "./foundry-edge-repair-preparation.js";
1
2
  import { proveFoundryRepairRemoteIntegrity } from "./foundry-repair-reference-binding.js";
2
3
  import { readRows } from "./import-curation/internal/runtime-io.js";
3
4
  import childProcess from "node:child_process";
@@ -11,7 +12,7 @@ import { createFoundryAuthenticationEnvironment, } from "./foundry-authenticatio
11
12
  import { resolveInstalledTiangongLcaCliPackage } from "./foundry-runtime-utils.js";
12
13
  import { runFoundryTaskOperation, withFoundryTaskMetadata } from "./foundry-task-store.js";
13
14
  import { createWorkflowDirectory, createWorkflowStageDirectory } from "./foundry-workflow-io.js";
14
- import { readWorkflowArtifact } from "./foundry-workflow-state.js";
15
+ import { readWorkflowArtifact, workflowObject } from "./foundry-workflow-state.js";
15
16
  import { readFoundryRepairScope } from "./foundry-repair-scope.js";
16
17
  import { FOUNDRY_REPAIR_PREPARATION_SCHEMA, parseFoundryRepairDryRunReport, parseFoundryRepairValidateReport, } from "./foundry-repair-preflight.js";
17
18
  import { readTaskJson, relative as taskRelative } from "./foundry-task-io.js";
@@ -270,6 +271,43 @@ export function readFoundryRepairPreparation(context, entries) {
270
271
  content: role,
271
272
  });
272
273
  };
274
+ if (value.status !== "blocked" && verified.has("edge-repair:out/owner-report.json")) {
275
+ const report = ownerReport("edge-repair", currentScope.candidateFile);
276
+ const artifact = (role) => {
277
+ const entry = verified.get(`edge-repair:out/${role}`);
278
+ if (!entry)
279
+ fail("repair_report_invalid", "Guarded Edge repair requires complete indexed evidence.");
280
+ return JSON.parse(fs.readFileSync(resolveFoundryOutput(context, entry.path), "utf8"));
281
+ };
282
+ const typed = artifact("validation/outputs/validation-report.json");
283
+ const reference = artifact("references/edge-support-precommit.json");
284
+ const before = artifact("edge-before.json");
285
+ const rules = readEdgeRepairValidation(typed, expected);
286
+ const beforeValidation = Object.values(rules).includes(false)
287
+ ? artifact("before-validation/outputs/validation-report.json")
288
+ : null;
289
+ const detail = Array.isArray(evidence.detail)
290
+ ? evidence.detail.map(workflowObject).find((item) => item.role === "edge_preflight")
291
+ : null;
292
+ const referenceEntry = verified.get("edge-repair:out/references/edge-support-precommit.json");
293
+ const referenceFact = record(report.reference_evidence, "repair_report_invalid", "Dependency report fact");
294
+ if (report.schema !== "tiangong-foundry.edge-repair-preflight.v1" ||
295
+ report.contract_sha256 !== expected.contract_sha256 ||
296
+ !sameFact(report.before, inputs.before, "repair_report_invalid", "Edge before rows") ||
297
+ report.validation_sha256 !== sha256Json(typed) ||
298
+ report.before_validation_sha256 !==
299
+ (beforeValidation ? sha256Json(beforeValidation) : null) ||
300
+ sha256Json(report.rule_verification) !== sha256Json(rules) ||
301
+ !detail ||
302
+ sha256Json(detail.report) !== sha256Json(report) ||
303
+ report.remote_before_sha256 !== sha256Json(before) ||
304
+ referenceFact.sha256 !== referenceEntry.sha256 ||
305
+ referenceFact.bytes !== referenceEntry.bytes ||
306
+ reference.status !== "passed_remote_verification" ||
307
+ (value.status === "prepared") !== (currentScope.scope.status === "dispatchable"))
308
+ fail("repair_report_invalid", "Guarded Edge repair proof differs from the registered scope.");
309
+ return Object.freeze({ entry, file: resolveFoundryOutput(context, entry.path), value });
310
+ }
273
311
  if (value.status === "prepared") {
274
312
  if (currentScope.scope.status !== "dispatchable")
275
313
  fail("repair_report_invalid", "A no-op is not a write preparation.");
@@ -317,7 +355,20 @@ export async function prepareFoundryRepair(context, qualified, _entries, authent
317
355
  verifyCommands: [FOUNDRY_REPAIR_PREFLIGHT_COMMAND],
318
356
  });
319
357
  try {
320
- if (scope.status === "dispatchable") {
358
+ if (qualified.cli.expectation.package_version === "0.4.0") {
359
+ const root = path.join(temporary, "edge-repair");
360
+ fs.mkdirSync(root, { mode: 0o700 });
361
+ stagedTrees.push({ name: "edge-repair", directory: root });
362
+ const report = await prepareEdgeProcessRepair(context, qualified, authentication, expectation, {
363
+ before: beforeFile,
364
+ candidate: candidateFile,
365
+ temporary,
366
+ directory: path.join(root, "out"),
367
+ });
368
+ evidenceDetails.push({ role: "edge_preflight", report });
369
+ status = scope.status === "dispatchable" ? "prepared" : "no_change_verified";
370
+ }
371
+ else if (scope.status === "dispatchable") {
321
372
  const outDir = path.join(temporary, "dry-run", "out");
322
373
  fs.mkdirSync(outDir, { recursive: true, mode: 0o700 });
323
374
  stagedTrees.push({ name: "dry-run", directory: path.join(temporary, "dry-run") });
@@ -8,6 +8,7 @@ import { assertSelectedSemanticInput, readSelectedSemanticBytes, } from "./found
8
8
  import { currentWorkflowState, readWorkflowArtifact, workflowObject, } from "./foundry-workflow-state.js";
9
9
  import { runFoundryTaskOperation } from "./foundry-task-store.js";
10
10
  import { createWorkflowStageDirectory, createWorkflowDirectory, registerWorkflowStageFiles, runWorkflowLocalCliResult, } from "./foundry-workflow-io.js";
11
+ import { applyFoundryTypedAuthoringPatch } from "./foundry-typed-authoring-patch.js";
11
12
  import { runDatasetAuthoringPatchCollect } from "./import-curation/patch-collect.js";
12
13
  import { readJsonOrJsonl, ensureArray, readRows } from "./import-curation/internal/runtime-io.js";
13
14
  import { createFoundryDecisionOwners } from "./foundry-decision-owners.js";
@@ -345,33 +346,51 @@ export async function applyFoundrySemanticInput(context, qualified, entries, sub
345
346
  if (packageDirectories.size !== 1)
346
347
  fail("semantic_work_invalid", "Selected work must share its registered package snapshot directory.");
347
348
  const repaired = path.join(output, type, "repaired.rows.jsonl");
348
- const applied = runWorkflowLocalCliResult(context, qualified, temporary, [
349
- "dataset",
350
- "patch",
351
- "apply",
352
- "--input",
353
- originalRows,
354
- "--patch",
355
- path.join(output, type, "collected-patches.json"),
356
- "--out",
357
- repaired,
358
- "--out-dir",
359
- path.join(output, type, "apply"),
360
- "--authoring-package-dir",
361
- [...packageDirectories][0],
362
- "--require-authoring-package",
363
- "--require-action-item-closure",
364
- "--json",
365
- ]);
349
+ const patch = path.join(output, type, "collected-patches.json");
350
+ const directory = path.join(output, type, "apply");
351
+ const typed = qualified.cli.expectation.package_version === "0.4.0";
352
+ const typedResult = typed
353
+ ? applyFoundryTypedAuthoringPatch(context, qualified, temporary, {
354
+ type,
355
+ input: originalRows,
356
+ patch,
357
+ directory,
358
+ output: repaired,
359
+ packageDirectory: [...packageDirectories][0],
360
+ writeJson: (file, value) => operation.writeJson(file, value),
361
+ writeText: (file, value) => operation.writeText(file, value),
362
+ })
363
+ : null;
364
+ const legacyResult = typed
365
+ ? null
366
+ : runWorkflowLocalCliResult(context, qualified, temporary, [
367
+ "dataset",
368
+ "patch",
369
+ "apply",
370
+ "--input",
371
+ originalRows,
372
+ "--patch",
373
+ patch,
374
+ "--out",
375
+ repaired,
376
+ "--out-dir",
377
+ directory,
378
+ "--authoring-package-dir",
379
+ [...packageDirectories][0],
380
+ "--require-authoring-package",
381
+ "--require-action-item-closure",
382
+ "--json",
383
+ ]);
384
+ const applied = typedResult ?? legacyResult;
366
385
  const original = rows.value.sets.find((set) => set.type === type && set.file === originalRows);
367
- const completed = applied.validate(() => {
386
+ const check = () => {
368
387
  if (!["completed", "blocked"].includes(String(applied.report.status)) ||
369
388
  !Array.isArray(applied.report.blockers))
370
389
  fail("semantic_apply_invalid", "Patch application returned no completed or blocked owner report.");
371
390
  const reportFile = workflowObject(applied.report.files).report;
372
391
  if (typeof reportFile !== "string")
373
392
  fail("semantic_apply_invalid", "Patch application returned no report locator.");
374
- applied.verifyReportFile(reportFile);
393
+ legacyResult?.verifyReportFile(reportFile);
375
394
  if (applied.exit !== 0 ||
376
395
  applied.report.status !== "completed" ||
377
396
  applied.report.blockers.length)
@@ -380,7 +399,8 @@ export async function applyFoundrySemanticInput(context, qualified, entries, sub
380
399
  fail("semantic_row_scope_changed", "Patch application changed the assessed row scope.");
381
400
  captureFoundryInput(repaired);
382
401
  return original;
383
- });
402
+ };
403
+ const completed = legacyResult ? legacyResult.validate(check) : check();
384
404
  if (!completed) {
385
405
  blockers.push({ code: "semantic_apply_blocked", type, report: applied.report });
386
406
  continue;
@@ -101,6 +101,7 @@ export declare function validateIdentityPreflightExecution(input: {
101
101
  stderrText?: string;
102
102
  signal?: string | null;
103
103
  }): ValidationFailure | ValidationSuccess;
104
+ export declare function createIdentityPreflightExecutionManifest(binding: IdentityPreflightBinding, reportText: string, completedAtUtc: string): ExecutionManifest;
104
105
  export declare function validateBoundExecutionManifest(value: unknown, binding: IdentityPreflightBinding, reportText: string | null): {
105
106
  ok: boolean;
106
107
  code?: string;
@@ -245,10 +245,21 @@ export function validateIdentityPreflightExecution(input) {
245
245
  if (!authReceipt || !input.binding.account) {
246
246
  return failure("identity_preflight_auth_receipt_missing", "Identity-preflight execution requires account receipt evidence.");
247
247
  }
248
+ return {
249
+ ok: true,
250
+ report: diskReport,
251
+ manifest: createIdentityPreflightExecutionManifest(input.binding, input.diskReportText, input.completedAtUtc),
252
+ };
253
+ }
254
+ export function createIdentityPreflightExecutionManifest(binding, reportText, completedAtUtc) {
255
+ const report = exactRecord(JSON.parse(reportText), "Identity-preflight report");
256
+ const authReceipt = binding.inputs.authReceipt;
257
+ if (!authReceipt || !binding.account || !ALLOWED_REPORT_STATUSES.has(String(report.status)))
258
+ throw new Error("Identity-preflight report needs current account evidence and an accepted status.");
248
259
  const manifestScope = {
249
260
  schema: "tiangong-foundry.identity-preflight-execution.v1",
250
- binding_sha256: input.binding.binding_sha256,
251
- binding: bindingEvidence(input.binding),
261
+ binding_sha256: binding.binding_sha256,
262
+ binding: bindingEvidence(binding),
252
263
  producer_auth: {
253
264
  project_ref: authReceipt.project.project_ref,
254
265
  user_id: authReceipt.identity.user_id,
@@ -256,18 +267,14 @@ export function validateIdentityPreflightExecution(input) {
256
267
  captured_at_utc: authReceipt.captured_at_utc,
257
268
  },
258
269
  report: {
259
- bytes_sha256: sha256Text(input.diskReportText ?? ""),
260
- canonical_sha256: sha256Json(diskReport),
261
- status,
262
- decision: typeof diskReport.decision === "string" ? diskReport.decision : null,
270
+ bytes_sha256: sha256Text(reportText),
271
+ canonical_sha256: sha256Json(report),
272
+ status: String(report.status),
273
+ decision: typeof report.decision === "string" ? report.decision : null,
263
274
  },
264
- completed_at_utc: input.completedAtUtc,
265
- };
266
- return {
267
- ok: true,
268
- report: diskReport,
269
- manifest: { ...manifestScope, manifest_sha256: sha256Json(manifestScope) },
275
+ completed_at_utc: completedAtUtc,
270
276
  };
277
+ return { ...manifestScope, manifest_sha256: sha256Json(manifestScope) };
271
278
  }
272
279
  export function validateBoundExecutionManifest(value, binding, reportText) {
273
280
  if (!isRecord(value) || value.schema !== "tiangong-foundry.identity-preflight-execution.v1") {
@@ -6,7 +6,7 @@ import { asText, directoryExists, ensureArray, fileExists, readJson, readText, r
6
6
  function asJsonRecord(value) {
7
7
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
8
8
  }
9
- export const tidasSchemaSearchRoots = ["@tiangong-lca/cli@0.1.28/assets/tidas-schemas"];
9
+ export const tidasSchemaSearchRoots = ["@tiangong-lca/cli@0.4.0/assets/tidas-schemas"];
10
10
  export function tidasSchemaPath(repoRoot, schemaFile) {
11
11
  void repoRoot;
12
12
  const candidate = path.join(resolveInstalledTiangongLcaCliPackage().schemaDir, schemaFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiangong-lca/foundry",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "type": "module",
5
5
  "description": "Control plane for TianGong LCA external dataset import and TIDAS authoring work.",
6
6
  "repository": {
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "license": "MIT",
88
88
  "dependencies": {
89
- "@tiangong-lca/cli": "0.1.28"
89
+ "@tiangong-lca/cli": "0.4.0"
90
90
  },
91
91
  "foundryRuntime": {
92
92
  "schema": "tiangong-foundry.runtime-layout.v2",
@@ -29,7 +29,7 @@
29
29
  "const": "tiangong-lca.cli-runtime-expectation.v1"
30
30
  },
31
31
  "package_version": {
32
- "const": "0.1.28"
32
+ "const": "0.4.0"
33
33
  },
34
34
  "platform": {
35
35
  "$ref": "#/$defs/platform"
@@ -18,7 +18,7 @@
18
18
  "const": "@tiangong-lca/foundry"
19
19
  },
20
20
  "version": {
21
- "const": "0.1.18"
21
+ "const": "0.1.19"
22
22
  },
23
23
  "cli_dependency": {
24
24
  "type": "object",
@@ -29,7 +29,7 @@
29
29
  "const": "@tiangong-lca/cli"
30
30
  },
31
31
  "version": {
32
- "const": "0.1.28"
32
+ "const": "0.4.0"
33
33
  }
34
34
  }
35
35
  },
@@ -14,7 +14,7 @@
14
14
  "additionalProperties": false,
15
15
  "required": ["package_version", "platform", "content_sha256", "node_version", "node_sha256"],
16
16
  "properties": {
17
- "package_version": { "const": "0.1.28" },
17
+ "package_version": { "const": "0.4.0" },
18
18
  "platform": {
19
19
  "enum": ["linux-x64", "linux-arm64", "darwin-arm64", "win32-x64"]
20
20
  },