@tiangong-lca/foundry 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) 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 +85 -5
  6. package/docs/runtime-context-contract.md +22 -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 +541 -177
  10. package/package-dist/scripts/foundry-facade.d.ts +5 -0
  11. package/package-dist/scripts/foundry-facade.js +261 -16
  12. package/package-dist/scripts/foundry-runtime.d.ts +2 -2
  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 +18 -6
  17. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.d.ts +72 -1
  18. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.js +123 -3
  19. package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +11 -1
  20. package/package-dist/scripts/lib/finalize-owners/post-authoring.js +65 -9
  21. package/package-dist/scripts/lib/foundry-assessment-producer.d.ts +6 -0
  22. package/package-dist/scripts/lib/foundry-assessment-producer.js +167 -0
  23. package/package-dist/scripts/lib/foundry-authentication-environment.js +1 -1
  24. package/package-dist/scripts/lib/foundry-command-metadata.js +6 -1
  25. package/package-dist/scripts/lib/foundry-curation-queue.d.ts +73 -0
  26. package/package-dist/scripts/lib/foundry-curation-queue.js +261 -0
  27. package/package-dist/scripts/lib/foundry-decision-owners.d.ts +1 -1
  28. package/package-dist/scripts/lib/foundry-decision-owners.js +15 -7
  29. package/package-dist/scripts/lib/foundry-edge-draft-admission.d.ts +17 -0
  30. package/package-dist/scripts/lib/foundry-edge-draft-admission.js +94 -0
  31. package/package-dist/scripts/lib/foundry-edge-identity-preflight.d.ts +47 -0
  32. package/package-dist/scripts/lib/foundry-edge-identity-preflight.js +268 -0
  33. package/package-dist/scripts/lib/foundry-edge-oauth.d.ts +4 -0
  34. package/package-dist/scripts/lib/foundry-edge-oauth.js +154 -0
  35. package/package-dist/scripts/lib/foundry-edge-reference-intent.d.ts +51 -0
  36. package/package-dist/scripts/lib/foundry-edge-reference-intent.js +184 -0
  37. package/package-dist/scripts/lib/foundry-edge-repair-preparation.d.ts +21 -0
  38. package/package-dist/scripts/lib/foundry-edge-repair-preparation.js +120 -0
  39. package/package-dist/scripts/lib/foundry-edge-session.d.ts +15 -0
  40. package/package-dist/scripts/lib/foundry-edge-session.js +69 -0
  41. package/package-dist/scripts/lib/foundry-edge-support-plan.d.ts +69 -0
  42. package/package-dist/scripts/lib/foundry-edge-support-plan.js +245 -0
  43. package/package-dist/scripts/lib/foundry-edge-support-planning.d.ts +115 -0
  44. package/package-dist/scripts/lib/foundry-edge-support-planning.js +259 -0
  45. package/package-dist/scripts/lib/foundry-edge-support.d.ts +19 -0
  46. package/package-dist/scripts/lib/foundry-edge-support.js +188 -0
  47. package/package-dist/scripts/lib/foundry-execution-admission.d.ts +4 -2
  48. package/package-dist/scripts/lib/foundry-execution-admission.js +28 -3
  49. package/package-dist/scripts/lib/foundry-finalize-edge-identity.d.ts +30 -0
  50. package/package-dist/scripts/lib/foundry-finalize-edge-identity.js +102 -0
  51. package/package-dist/scripts/lib/foundry-finalize-owners.d.ts +1 -0
  52. package/package-dist/scripts/lib/foundry-finalize-owners.js +126 -13
  53. package/package-dist/scripts/lib/foundry-identity-stage-input.d.ts +24 -0
  54. package/package-dist/scripts/lib/foundry-identity-stage-input.js +122 -0
  55. package/package-dist/scripts/lib/foundry-identity-stage-state.d.ts +17 -0
  56. package/package-dist/scripts/lib/foundry-identity-stage-state.js +48 -0
  57. package/package-dist/scripts/lib/foundry-installed-entry.d.ts +2 -0
  58. package/package-dist/scripts/lib/foundry-installed-entry.js +173 -0
  59. package/package-dist/scripts/lib/foundry-managed-adoption.d.ts +12 -0
  60. package/package-dist/scripts/lib/foundry-managed-adoption.js +108 -0
  61. package/package-dist/scripts/lib/foundry-managed-authentication.d.ts +4 -0
  62. package/package-dist/scripts/lib/foundry-managed-authentication.js +28 -0
  63. package/package-dist/scripts/lib/foundry-managed-host.js +14 -2
  64. package/package-dist/scripts/lib/foundry-migration-transfer-io.d.ts +2 -0
  65. package/package-dist/scripts/lib/foundry-migration-transfer-io.js +27 -3
  66. package/package-dist/scripts/lib/foundry-operation-result.d.ts +1 -1
  67. package/package-dist/scripts/lib/foundry-operation-result.js +1 -0
  68. package/package-dist/scripts/lib/foundry-owner-execution-store.d.ts +16 -16
  69. package/package-dist/scripts/lib/foundry-owner-execution-store.js +34 -7
  70. package/package-dist/scripts/lib/foundry-owner-readback.d.ts +20 -0
  71. package/package-dist/scripts/lib/foundry-owner-readback.js +42 -0
  72. package/package-dist/scripts/lib/foundry-package-contract.d.ts +4 -4
  73. package/package-dist/scripts/lib/foundry-package-contract.js +10 -2
  74. package/package-dist/scripts/lib/foundry-preparation-cli-validation.d.ts +2 -0
  75. package/package-dist/scripts/lib/foundry-preparation-cli-validation.js +96 -3
  76. package/package-dist/scripts/lib/foundry-process-mass-balance.d.ts +64 -0
  77. package/package-dist/scripts/lib/foundry-process-mass-balance.js +224 -0
  78. package/package-dist/scripts/lib/foundry-process-qa.d.ts +19 -0
  79. package/package-dist/scripts/lib/foundry-process-qa.js +423 -0
  80. package/package-dist/scripts/lib/foundry-quality-review-context.d.ts +3 -0
  81. package/package-dist/scripts/lib/foundry-quality-review-context.js +18 -0
  82. package/package-dist/scripts/lib/foundry-quality-review-input.d.ts +48 -0
  83. package/package-dist/scripts/lib/foundry-quality-review-input.js +284 -0
  84. package/package-dist/scripts/lib/foundry-quality-review-lineage.d.ts +13 -0
  85. package/package-dist/scripts/lib/foundry-quality-review-lineage.js +123 -0
  86. package/package-dist/scripts/lib/foundry-quality-review.d.ts +112 -0
  87. package/package-dist/scripts/lib/foundry-quality-review.js +487 -0
  88. package/package-dist/scripts/lib/foundry-repair-execution.js +13 -2
  89. package/package-dist/scripts/lib/foundry-runtime-environment.d.ts +2 -0
  90. package/package-dist/scripts/lib/foundry-runtime-environment.js +18 -0
  91. package/package-dist/scripts/lib/foundry-runtime-identity.d.ts +1 -0
  92. package/package-dist/scripts/lib/foundry-runtime-identity.js +22 -2
  93. package/package-dist/scripts/lib/foundry-runtime-qualification.js +2 -2
  94. package/package-dist/scripts/lib/foundry-runtime-utils.d.ts +1 -0
  95. package/package-dist/scripts/lib/foundry-runtime-utils.js +1 -1
  96. package/package-dist/scripts/lib/foundry-task-authorization.d.ts +2 -1
  97. package/package-dist/scripts/lib/foundry-task-authorization.js +32 -11
  98. package/package-dist/scripts/lib/foundry-task-registration.js +4 -5
  99. package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.d.ts +28 -0
  100. package/package-dist/scripts/lib/foundry-task-runtime-adoption-write.js +250 -0
  101. package/package-dist/scripts/lib/foundry-task-runtime-adoption.d.ts +60 -0
  102. package/package-dist/scripts/lib/foundry-task-runtime-adoption.js +549 -0
  103. package/package-dist/scripts/lib/foundry-task-store.d.ts +4 -1
  104. package/package-dist/scripts/lib/foundry-task-store.js +113 -4
  105. package/package-dist/scripts/lib/foundry-task-types.d.ts +2 -1
  106. package/package-dist/scripts/lib/foundry-typed-authoring-patch.d.ts +76 -0
  107. package/package-dist/scripts/lib/foundry-typed-authoring-patch.js +237 -0
  108. package/package-dist/scripts/lib/foundry-typed-context.d.ts +11 -0
  109. package/package-dist/scripts/lib/foundry-typed-context.js +79 -0
  110. package/package-dist/scripts/lib/foundry-typed-flow-qa.d.ts +166 -0
  111. package/package-dist/scripts/lib/foundry-typed-flow-qa.js +226 -0
  112. package/package-dist/scripts/lib/foundry-typed-model-write.d.ts +6 -0
  113. package/package-dist/scripts/lib/foundry-typed-model-write.js +59 -0
  114. package/package-dist/scripts/lib/foundry-validation-reference-context.d.ts +8 -0
  115. package/package-dist/scripts/lib/foundry-validation-reference-context.js +115 -0
  116. package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +1 -0
  117. package/package-dist/scripts/lib/foundry-workflow-assessment.js +165 -34
  118. package/package-dist/scripts/lib/foundry-workflow-authorization.js +99 -5
  119. package/package-dist/scripts/lib/foundry-workflow-child-failure.d.ts +44 -0
  120. package/package-dist/scripts/lib/foundry-workflow-child-failure.js +439 -0
  121. package/package-dist/scripts/lib/foundry-workflow-context.js +92 -22
  122. package/package-dist/scripts/lib/foundry-workflow-execution.js +54 -5
  123. package/package-dist/scripts/lib/foundry-workflow-finalize.js +64 -3
  124. package/package-dist/scripts/lib/foundry-workflow-identity-recovery.d.ts +6 -0
  125. package/package-dist/scripts/lib/foundry-workflow-identity-recovery.js +450 -0
  126. package/package-dist/scripts/lib/foundry-workflow-identity-stage.d.ts +9 -0
  127. package/package-dist/scripts/lib/foundry-workflow-identity-stage.js +717 -0
  128. package/package-dist/scripts/lib/foundry-workflow-identity.js +26 -11
  129. package/package-dist/scripts/lib/foundry-workflow-io.d.ts +7 -1
  130. package/package-dist/scripts/lib/foundry-workflow-io.js +102 -16
  131. package/package-dist/scripts/lib/foundry-workflow-reference-verify.js +102 -29
  132. package/package-dist/scripts/lib/foundry-workflow-repair.js +53 -2
  133. package/package-dist/scripts/lib/foundry-workflow-semantic.js +65 -31
  134. package/package-dist/scripts/lib/foundry-workflow-state.d.ts +4 -0
  135. package/package-dist/scripts/lib/foundry-workflow-state.js +165 -22
  136. package/package-dist/scripts/lib/identity-preflight-artifacts.d.ts +4 -7
  137. package/package-dist/scripts/lib/identity-preflight-artifacts.js +18 -5
  138. package/package-dist/scripts/lib/identity-preflight-proof.d.ts +6 -0
  139. package/package-dist/scripts/lib/identity-preflight-proof.js +92 -13
  140. package/package-dist/scripts/lib/identity-preflight-recovery-proof.d.ts +78 -0
  141. package/package-dist/scripts/lib/identity-preflight-recovery-proof.js +415 -0
  142. package/package-dist/scripts/lib/import-curation/curation-cleanup.d.ts +9 -1
  143. package/package-dist/scripts/lib/import-curation/curation-cleanup.js +39 -2
  144. package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +1 -0
  145. package/package-dist/scripts/lib/import-curation/curation-gate.js +19 -1
  146. package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +1 -1
  147. package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.js +11 -2
  148. package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.js +4 -1
  149. package/package-dist/scripts/package-entry.js +2 -3
  150. package/package-dist/scripts/public-api.d.ts +5 -0
  151. package/package-dist/scripts/public-api.js +2 -0
  152. package/package-dist/scripts/runtime-entry.d.ts +2 -0
  153. package/package-dist/scripts/runtime-entry.js +42 -15
  154. package/package.json +6 -2
  155. package/specs/schemas/foundry-identity-stage-input.schema.json +47 -0
  156. package/specs/schemas/foundry-managed-adoption.schema.json +40 -0
  157. package/specs/schemas/foundry-managed-runtime.schema.json +1 -1
  158. package/specs/schemas/foundry-operation-result.schema.json +1 -0
  159. package/specs/schemas/foundry-package-descriptor.schema.json +6 -2
  160. package/specs/schemas/foundry-quality-review-draft.schema.json +271 -0
  161. package/specs/schemas/foundry-quality-review-input.schema.json +271 -0
  162. package/specs/schemas/runtime-qualification.schema.json +1 -1
@@ -0,0 +1,487 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+ import { captureFoundryInput, FoundryContextError, } from "./foundry-runtime-context.js";
5
+ import { assertQualifiedFoundryRuntime, } from "./foundry-runtime-qualification.js";
6
+ import { assertSelectedFoundryQualityReviewInput, parseFoundryQualityReviewInput, materializeFoundryQualityReviewInput, FOUNDRY_QUALITY_REVIEW_DRAFT_SCHEMA, } from "./foundry-quality-review-input.js";
7
+ import { readSelectedSemanticBytes } from "./foundry-semantic-input.js";
8
+ import { currentWorkflowState, readWorkflowArtifact, workflowObject, } from "./foundry-workflow-state.js";
9
+ import { runFoundryTaskOperation } from "./foundry-task-store.js";
10
+ import { readTaskBytes } from "./foundry-task-io.js";
11
+ import { canonicalPayloadSha256 } from "./post-write-root-proof.js";
12
+ import { readRows } from "./import-curation/internal/runtime-io.js";
13
+ import { datasetIdentity, unwrapDatasetPayload, } from "./import-curation/internal/dataset-payload.js";
14
+ import { readQaFindings } from "./import-curation/internal/artifact-inputs.js";
15
+ import { unchangedQualityReviewRows } from "./foundry-quality-review-lineage.js";
16
+ import { qualityReviewInteractionDigest } from "./foundry-quality-review-context.js";
17
+ import { currentFoundryInteractionState } from "./foundry-interaction-input.js";
18
+ const code = "process_material_balance_deviation";
19
+ const command = "dataset-workflow-quality-review";
20
+ const receiptName = "foundry-quality-review.json";
21
+ function invalid(message) {
22
+ throw new FoundryContextError("quality_review_scope_invalid", message);
23
+ }
24
+ function fingerprint(value) {
25
+ return canonicalPayloadSha256(value);
26
+ }
27
+ function live(spec) {
28
+ const now = Date.now();
29
+ if (Date.parse(spec.issued_at_utc) > now || Date.parse(spec.expires_at_utc) <= now)
30
+ invalid("Quality review authority is not current.");
31
+ }
32
+ /** Full JSON rows and ordered identities stay bound; serialization whitespace is not a row change. */
33
+ function rowScope(file) {
34
+ const rows = readRows(file);
35
+ const objects = rows.map((row, row_index) => {
36
+ const identity = datasetIdentity(row, row_index, "process");
37
+ const payloadIdentity = datasetIdentity(unwrapDatasetPayload(row, "process"), row_index, "process");
38
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(identity.id) ||
39
+ identity.id !== payloadIdentity.id ||
40
+ identity.version !== payloadIdentity.version ||
41
+ identity.dataset_type !== "process")
42
+ invalid("Quality review requires identified Process rows.");
43
+ return {
44
+ row_index,
45
+ id: identity.id,
46
+ version: identity.version,
47
+ payload_sha256: fingerprint(identity.payload),
48
+ };
49
+ });
50
+ // CLI finding attribution uses a process filename. An ID occurring twice cannot be reviewed
51
+ // through the existing ID-keyed curation report, even when the versions differ.
52
+ if (new Set(objects.map((item) => item.id)).size !== objects.length)
53
+ invalid("Quality review cannot select ambiguous or duplicated Process identities.");
54
+ return { rows, objects, sha256: fingerprint(rows) };
55
+ }
56
+ function reportObservation(report, findings) {
57
+ if (report.status !== "completed_local_process_qa" ||
58
+ report.policy_decision_owner !== "foundry" ||
59
+ report.qa_mode !== "deterministic_qa_report" ||
60
+ !Array.isArray(report.mass_balance) ||
61
+ !Array.isArray(report.reference_evidence))
62
+ invalid("Quality review requires the completed deterministic Process QA observation.");
63
+ const value = { ...report };
64
+ // Only named run metadata and artifact locations vary across a deterministic rerun. All
65
+ // remaining fields, including unknown future QA fields and the complete findings, are bound.
66
+ for (const key of [
67
+ "generated_at_utc",
68
+ "run_id",
69
+ "run_root",
70
+ "rows_file",
71
+ "out_dir",
72
+ "effective_processes_dir",
73
+ "files",
74
+ ])
75
+ delete value[key];
76
+ value.reference_evidence = report.reference_evidence.map((raw) => {
77
+ const fact = workflowObject(raw);
78
+ const { path: _location, ...content } = fact;
79
+ return content;
80
+ });
81
+ return fingerprint({ report: value, findings });
82
+ }
83
+ function binding(context, rows) {
84
+ if (!context.accountIntent || !context.workspaceId || !context.taskId || !context.actorId)
85
+ invalid("Select explicit current task and account intent before reviewing a QA observation.");
86
+ const profile = workflowObject(JSON.parse(readTaskBytes(context, "profile-lock.json").toString("utf8")));
87
+ return {
88
+ workspace_id: context.workspaceId,
89
+ task_id: context.taskId,
90
+ actor_id: context.actorId,
91
+ project_ref: context.accountIntent.projectRef,
92
+ user_id: context.accountIntent.userId,
93
+ profile_id: String(profile.profile_id),
94
+ profile_sha256: String(profile.profile_sha256),
95
+ input_scope_sha256: rows.sha256,
96
+ };
97
+ }
98
+ function assertUnsealed(context, entries) {
99
+ if (fs.existsSync(path.join(context.taskRoot, "authorization.json")) ||
100
+ entries.some((entry) => [
101
+ "dataset-workflow-authorization",
102
+ "dataset-workflow-native-contract",
103
+ "dataset-workflow-execution-prepare",
104
+ "dataset-workflow-execution-result",
105
+ "dataset-workflow-execution-consume",
106
+ "dataset-workflow-execution-observation",
107
+ ].includes(entry.command)) ||
108
+ (fs.existsSync(path.join(context.taskRoot, "attempts")) &&
109
+ fs.readdirSync(path.join(context.taskRoot, "attempts")).length))
110
+ throw new FoundryContextError("quality_review_scope_frozen", "Retain authorized, prepared or consumed scope evidence; quality review cannot change its authority.");
111
+ }
112
+ function registered(context, entries, file) {
113
+ const fact = captureFoundryInput(file);
114
+ if (!entries.some((entry) => path.resolve(context.taskRoot, entry.path) === fact.path &&
115
+ entry.bytes === fact.bytes &&
116
+ entry.sha256 === fact.sha256))
117
+ invalid("Quality review requires current indexed evidence with unchanged bytes.");
118
+ readSelectedSemanticBytes(fact);
119
+ return fact;
120
+ }
121
+ function registeredQa(context, entries, file) {
122
+ const fact = registered(context, entries, file);
123
+ const report = workflowObject(JSON.parse(readSelectedSemanticBytes(fact).toString("utf8")));
124
+ const files = workflowObject(report.files);
125
+ for (const key of ["rule_findings", "findings", "llm_findings"]) {
126
+ if (files[key] === undefined)
127
+ continue;
128
+ if (typeof files[key] !== "string")
129
+ invalid("Process QA finding evidence is invalid.");
130
+ const locator = String(files[key]);
131
+ const target = path.isAbsolute(locator) ? locator : path.resolve(path.dirname(file), locator);
132
+ registered(context, entries, target);
133
+ }
134
+ if (!Array.isArray(report.reference_evidence))
135
+ invalid("Process QA reference evidence is missing.");
136
+ const references = report.reference_evidence.map((raw) => {
137
+ const expected = workflowObject(raw);
138
+ if (typeof expected.path !== "string")
139
+ invalid("Process QA reference path is invalid.");
140
+ const actual = registered(context, entries, expected.path);
141
+ if (actual.bytes !== expected.bytes || actual.sha256 !== expected.sha256)
142
+ invalid("Process QA reference evidence changed after observation.");
143
+ return actual;
144
+ });
145
+ return {
146
+ fact,
147
+ report,
148
+ references,
149
+ findings: readQaFindings(context.assetRoot, report, file, "process"),
150
+ };
151
+ }
152
+ function processContext(context, entries) {
153
+ const entry = entries.findLast((item) => item.command === "dataset-context-pack" &&
154
+ path.basename(item.path) === "contract-report.json" &&
155
+ readWorkflowArtifact(context, item).value.type === "process");
156
+ if (!entry)
157
+ invalid("The Process context must be registered before quality review.");
158
+ const report = readWorkflowArtifact(context, entry);
159
+ const files = workflowObject(report.value.files);
160
+ for (const key of ["schema", "methodology", "ruleset"]) {
161
+ if (typeof files[key] !== "string" || !path.isAbsolute(files[key]))
162
+ invalid("Quality review requires the complete registered Process context.");
163
+ registered(context, entries, files[key]);
164
+ }
165
+ return entry;
166
+ }
167
+ /** Read-only scope projection, not a review decision or an approval template with default consent. */
168
+ export function foundryQualityReviewScope(context, qualificationSha256, entries, state = currentWorkflowState(context, entries)) {
169
+ if (state.qualityReviewSha256)
170
+ verifyQualityReviewEvidence(context, qualificationSha256, entries);
171
+ const set = state.assessment?.value.sets.find((item) => item.type === "process");
172
+ const rows = state.rows?.value.sets.find((item) => item.type === "process");
173
+ if (!set || !rows || !state.rows || !state.assessment || !context.accountIntent)
174
+ return null;
175
+ if (set.runtime_qualification_sha256 !== qualificationSha256)
176
+ return null;
177
+ if (typeof set.qa_report !== "string")
178
+ invalid("The current Process assessment has no QA report.");
179
+ const input = registered(context, entries, rows.file);
180
+ const { fact: qa, report, findings } = registeredQa(context, entries, set.qa_report);
181
+ const scope = rowScope(input.path);
182
+ const contextEntry = processContext(context, entries);
183
+ const candidates = scope.objects.flatMap((object) => findings
184
+ .filter((finding) => finding.code === code &&
185
+ finding.severity === "warning" &&
186
+ finding.process_file === `${object.id}__${object.version}.json` &&
187
+ finding.evidence !== null &&
188
+ typeof finding.evidence === "object" &&
189
+ !Array.isArray(finding.evidence) &&
190
+ finding.evidence.policy_decision_owner === "foundry")
191
+ .map((finding) => ({ ...object, code, finding_sha256: fingerprint(finding), finding })));
192
+ if (!candidates.length)
193
+ return null;
194
+ return {
195
+ binding: binding(context, input),
196
+ runtime_qualification_sha256: qualificationSha256,
197
+ rows_manifest_sha256: state.rows.entry.sha256,
198
+ assessment_sha256: state.assessment.entry.sha256,
199
+ context_sha256: contextEntry.sha256,
200
+ reference_inputs_sha256: state.referenceInputsSha256,
201
+ interaction_context_sha256: qualityReviewInteractionDigest(currentFoundryInteractionState(context, entries)?.state ?? null, scope.rows),
202
+ qa_report_sha256: qa.sha256,
203
+ qa_findings_sha256: fingerprint(findings),
204
+ expected_previous_sha256: state.qualityReview?.entry.sha256 ?? null,
205
+ candidates,
206
+ input,
207
+ qa,
208
+ rows_content_sha256: scope.sha256,
209
+ qa_observation_sha256: reportObservation(report, findings),
210
+ };
211
+ }
212
+ /** Mechanical selection material; an untouched draft is deliberately not an accepted input. */
213
+ export function createFoundryQualityReviewTemplate(scope) {
214
+ const issued = Date.now();
215
+ return {
216
+ schema: FOUNDRY_QUALITY_REVIEW_DRAFT_SCHEMA,
217
+ binding: scope.binding,
218
+ runtime_qualification_sha256: scope.runtime_qualification_sha256,
219
+ rows_manifest_sha256: scope.rows_manifest_sha256,
220
+ assessment_sha256: scope.assessment_sha256,
221
+ context_sha256: scope.context_sha256,
222
+ reference_inputs_sha256: scope.reference_inputs_sha256,
223
+ interaction_context_sha256: scope.interaction_context_sha256,
224
+ qa_report_sha256: scope.qa_report_sha256,
225
+ qa_findings_sha256: scope.qa_findings_sha256,
226
+ expected_previous_sha256: scope.expected_previous_sha256,
227
+ issued_at_utc: new Date(issued).toISOString(),
228
+ expires_at_utc: new Date(issued + 3600_000).toISOString(),
229
+ reviews: scope.candidates.map(({ finding: _finding, ...selection }) => ({
230
+ ...selection,
231
+ disposition: null,
232
+ evidence_ids: [],
233
+ rationale: "",
234
+ })),
235
+ evidence: [],
236
+ };
237
+ }
238
+ export async function recordFoundryQualityReview(context, qualified, entries, selected) {
239
+ assertSelectedFoundryQualityReviewInput(selected);
240
+ assertQualifiedFoundryRuntime(context, qualified);
241
+ const spec = selected.spec;
242
+ live(spec);
243
+ assertUnsealed(context, entries);
244
+ const state = currentWorkflowState(context, entries);
245
+ if (state.qualityReview?.value.source_sha256 === selected.descriptor.sha256) {
246
+ if (!state.qualityReviewSha256)
247
+ invalid("The previously accepted review is no longer current.");
248
+ if (fingerprint(parseFoundryQualityReviewInput(state.qualityReview.value.input)) !==
249
+ fingerprint(spec))
250
+ invalid("The accepted draft now selects different evidence; retain its original review and select the current scope explicitly.");
251
+ loadFoundryQualityReview(context, qualified, entries);
252
+ return state.qualityReview.value;
253
+ }
254
+ const scope = foundryQualityReviewScope(context, qualified.qualification_sha256, entries);
255
+ if (!scope)
256
+ invalid("Assess the current Process rows and exact mass observation before reviewing it.");
257
+ for (const key of [
258
+ "runtime_qualification_sha256",
259
+ "rows_manifest_sha256",
260
+ "assessment_sha256",
261
+ "context_sha256",
262
+ "reference_inputs_sha256",
263
+ "interaction_context_sha256",
264
+ "qa_report_sha256",
265
+ "qa_findings_sha256",
266
+ "expected_previous_sha256",
267
+ ])
268
+ if (spec[key] !== scope[key])
269
+ invalid(`Quality review does not match the current ${key}.`);
270
+ if (fingerprint(spec.binding) !== fingerprint(scope.binding))
271
+ invalid("Quality review is for another task, account, profile or current row scope.");
272
+ for (const review of spec.reviews) {
273
+ const candidate = scope.candidates.find((item) => item.row_index === review.row_index &&
274
+ item.id === review.id &&
275
+ item.version === review.version &&
276
+ item.payload_sha256 === review.payload_sha256 &&
277
+ item.finding_sha256 === review.finding_sha256);
278
+ if (!candidate)
279
+ invalid("Each decision must select an exact current Process and warning.");
280
+ }
281
+ const output = path.join(context.taskRoot, "outputs", "quality-review", randomUUID());
282
+ return runFoundryTaskOperation(context, {
283
+ command,
284
+ options: { descriptor: selected.descriptor, scope },
285
+ validateCurrent(index) {
286
+ assertSelectedFoundryQualityReviewInput(selected);
287
+ live(spec);
288
+ assertUnsealed(context, index);
289
+ const current = foundryQualityReviewScope(context, qualified.qualification_sha256, index);
290
+ if (!current || fingerprint(current) !== fingerprint(scope))
291
+ invalid("Quality review scope or predecessor changed before registration.");
292
+ },
293
+ }, (operation) => {
294
+ const snapshot = (fact, name) => {
295
+ const target = path.join(output, name);
296
+ operation.writeText(target, readSelectedSemanticBytes(fact));
297
+ const captured = captureFoundryInput(target);
298
+ if (captured.sha256 !== fact.sha256 || captured.bytes !== fact.bytes)
299
+ invalid("Quality-review snapshot differs from selected bytes.");
300
+ return captured;
301
+ };
302
+ const descriptor = snapshot(selected.descriptor, "descriptor.json");
303
+ const evidence = selected.evidence.map((fact, index) => ({
304
+ id: spec.evidence[index].id,
305
+ kind: spec.evidence[index].kind,
306
+ ...snapshot(fact, `evidence-${index}.txt`),
307
+ }));
308
+ const result = {
309
+ schema: "tiangong-foundry.quality-review-receipt.v1",
310
+ status: "accepted",
311
+ source_sha256: selected.descriptor.sha256,
312
+ descriptor,
313
+ input: spec,
314
+ runtime: context.runtime,
315
+ rows: scope.input,
316
+ qa: scope.qa,
317
+ rows_content_sha256: scope.rows_content_sha256,
318
+ qa_observation_sha256: scope.qa_observation_sha256,
319
+ evidence,
320
+ grants_permission: false,
321
+ };
322
+ operation.writeText(path.join(output, "reviewed-findings.jsonl"), spec.reviews
323
+ .map((review) => JSON.stringify({
324
+ ...review,
325
+ finding: scope.candidates.find((item) => item.finding_sha256 === review.finding_sha256).finding,
326
+ }))
327
+ .join("\n") + "\n");
328
+ operation.writeText(path.join(output, "quality-review-report.md"), [
329
+ "# Preparation quality review",
330
+ "",
331
+ "Raw Process QA is retained. This receipt grants no write permission.",
332
+ ``,
333
+ `Expires: ${spec.expires_at_utc}`,
334
+ ``,
335
+ ...spec.reviews.map((review) => `- ${review.id}@${review.version}, row ${review.row_index}: ${review.rationale}`),
336
+ "",
337
+ "Rerun the same task. Changed rows, QA, references, context or authority require a fresh review.",
338
+ "",
339
+ ].join("\n"));
340
+ operation.writeJson(path.join(output, receiptName), result);
341
+ return result;
342
+ });
343
+ }
344
+ const validated = new WeakSet();
345
+ function verifyQualityReviewEvidence(context, qualificationSha256, entries) {
346
+ const state = currentWorkflowState(context, entries);
347
+ const found = state.qualityReview;
348
+ if (!found || !state.qualityReviewSha256)
349
+ return null;
350
+ const spec = parseFoundryQualityReviewInput(found.value.input);
351
+ live(spec);
352
+ if (spec.runtime_qualification_sha256 !== qualificationSha256)
353
+ invalid("Quality review belongs to a different qualified runtime.");
354
+ const rows = state.rows?.value.sets.find((set) => set.type === "process");
355
+ if (!rows ||
356
+ fingerprint(binding(context, registered(context, entries, rows.file))) !==
357
+ fingerprint(spec.binding))
358
+ invalid("Quality review current rows, account or profile changed.");
359
+ const descriptor = workflowObject(found.value.descriptor);
360
+ if (typeof descriptor.path !== "string" ||
361
+ registered(context, entries, descriptor.path).sha256 !== found.value.source_sha256 ||
362
+ fingerprint(materializeFoundryQualityReviewInput(JSON.parse(readSelectedSemanticBytes(registered(context, entries, descriptor.path)).toString("utf8")), (file) => {
363
+ const index = spec.evidence.findIndex((item) => item.file === file);
364
+ const evidence = found.value.evidence;
365
+ if (index < 0 || !Array.isArray(evidence))
366
+ invalid("Generated quality review has no retained selected evidence.");
367
+ const snapshot = workflowObject(evidence[index]);
368
+ if (typeof snapshot.path !== "string")
369
+ invalid("Generated quality review evidence snapshot is missing.");
370
+ return registered(context, entries, snapshot.path);
371
+ })) !== fingerprint(spec))
372
+ invalid("Quality review descriptor is not the indexed selected input.");
373
+ if (!Array.isArray(found.value.evidence) || found.value.evidence.length !== spec.evidence.length)
374
+ invalid("Quality review evidence is incomplete.");
375
+ found.value.evidence.forEach((raw, index) => {
376
+ const fact = workflowObject(raw), expected = spec.evidence[index];
377
+ if (fact.id !== expected.id ||
378
+ fact.kind !== expected.kind ||
379
+ typeof fact.path !== "string" ||
380
+ registered(context, entries, fact.path).sha256 !== expected.sha256)
381
+ invalid("Quality review authority or source-model evidence changed.");
382
+ });
383
+ if (processContext(context, entries).sha256 !== spec.context_sha256)
384
+ invalid("Quality review contract context changed.");
385
+ const originalQa = workflowObject(found.value.qa);
386
+ if (typeof originalQa.path !== "string" ||
387
+ registered(context, entries, originalQa.path).sha256 !== spec.qa_report_sha256)
388
+ invalid("Quality review original QA evidence changed.");
389
+ const originalObservation = registeredQa(context, entries, originalQa.path);
390
+ if (fingerprint(originalObservation.findings) !== spec.qa_findings_sha256 ||
391
+ reportObservation(originalObservation.report, originalObservation.findings) !==
392
+ found.value.qa_observation_sha256)
393
+ invalid("Quality review original finding evidence changed.");
394
+ if (typeof found.value.rows_content_sha256 !== "string" ||
395
+ typeof found.value.qa_observation_sha256 !== "string")
396
+ invalid("Quality review has no complete row and observation binding.");
397
+ return { state, found, spec, references: originalObservation.references };
398
+ }
399
+ export function loadFoundryQualityReview(context, qualified, entries) {
400
+ assertQualifiedFoundryRuntime(context, qualified);
401
+ const observed = verifyQualityReviewEvidence(context, qualified.qualification_sha256, entries);
402
+ if (!observed)
403
+ return null;
404
+ const { state, found, spec, references } = observed;
405
+ const verify = () => {
406
+ assertQualifiedFoundryRuntime(context, qualified);
407
+ const current = verifyQualityReviewEvidence(context, qualified.qualification_sha256, entries);
408
+ if (current?.found.entry.sha256 !== found.entry.sha256)
409
+ invalid("Quality review is no longer current.");
410
+ };
411
+ verify();
412
+ const result = Object.freeze({
413
+ receipt_sha256: found.entry.sha256,
414
+ expires_at_utc: spec.expires_at_utc,
415
+ spec,
416
+ rows_content_sha256: String(found.value.rows_content_sha256),
417
+ qa_observation_sha256: String(found.value.qa_observation_sha256),
418
+ qaReferenceRows: Object.freeze(references.map((fact) => fact.path)),
419
+ validate: verify,
420
+ rowsMatch: (rowsFile, cleanupReport) => {
421
+ const original = state.rows.value.sets.find((set) => set.type === "process");
422
+ return unchangedQualityReviewRows({
423
+ originalRows: rowScope(original.file).rows,
424
+ finalRowsFile: rowsFile,
425
+ taskRoot: context.taskRoot,
426
+ assetRoot: context.assetRoot,
427
+ cleanupReport,
428
+ referenceFiles: references,
429
+ });
430
+ },
431
+ });
432
+ validated.add(result);
433
+ return result;
434
+ }
435
+ /** Called by the existing curation owner after fresh QA, including on cleaned final rows. */
436
+ export function reviewedFoundryQualityFindings(review, rowsFile, qaReport, findings, cleanupReport) {
437
+ if (!review || typeof review !== "object" || !validated.has(review))
438
+ invalid("A serialized decision cannot replace indexed quality-review admission.");
439
+ const selected = review;
440
+ selected.validate();
441
+ const scope = rowScope(rowsFile);
442
+ if (!selected.rowsMatch(rowsFile, cleanupReport) ||
443
+ fingerprint(findings) !== selected.spec.qa_findings_sha256 ||
444
+ reportObservation(qaReport, findings) !== selected.qa_observation_sha256)
445
+ invalid("Rows, references or the deterministic QA observation changed after quality review.");
446
+ return selected.spec.reviews.map((item) => {
447
+ const row = scope.objects[item.row_index];
448
+ const finding = findings.find((value) => fingerprint(value) === item.finding_sha256);
449
+ if (!row ||
450
+ row.id !== item.id ||
451
+ row.version !== item.version ||
452
+ row.payload_sha256 !== item.payload_sha256 ||
453
+ !finding ||
454
+ finding.code !== code ||
455
+ finding.process_file !== `${item.id}__${item.version}.json`)
456
+ invalid("The quality review no longer matches its exact Process finding.");
457
+ return { ...item, finding, receipt_sha256: selected.receipt_sha256 };
458
+ });
459
+ }
460
+ /** Recheck local review evidence at write admission; this function grants no write capability. */
461
+ export function assertFoundryQualityReviewForExecution(context, qualified, entries, finalRowsFile) {
462
+ for (const entry of [...entries].reverse()) {
463
+ if (entry.command !== "dataset-workflow-finalize" ||
464
+ path.basename(entry.path) !== "foundry-finalize.json")
465
+ continue;
466
+ const found = readWorkflowArtifact(context, entry);
467
+ const sets = Array.isArray(found.value.sets) ? found.value.sets.map(workflowObject) : [];
468
+ const scope = sets.find((set) => set.type === "process" && set.final_rows === finalRowsFile);
469
+ if (!scope)
470
+ continue;
471
+ if (found.value.quality_review_sha256 === undefined)
472
+ return;
473
+ const review = loadFoundryQualityReview(context, qualified, entries);
474
+ if (!review || review.receipt_sha256 !== found.value.quality_review_sha256)
475
+ invalid("Final rows require the same current preparation quality review before write admission.");
476
+ if (typeof scope.report !== "string")
477
+ invalid("Final quality-review evidence is missing.");
478
+ const owner = workflowObject(JSON.parse(readSelectedSemanticBytes(registered(context, entries, scope.report)).toString("utf8")));
479
+ const files = workflowObject(owner.files);
480
+ if (typeof files.qa_report !== "string" || typeof files.cleanup_report !== "string")
481
+ invalid("Final quality-review QA and cleanup evidence is missing.");
482
+ const qa = registeredQa(context, entries, path.resolve(context.assetRoot, files.qa_report));
483
+ const cleanup = registered(context, entries, path.resolve(context.assetRoot, files.cleanup_report));
484
+ reviewedFoundryQualityFindings(review, finalRowsFile, qa.report, qa.findings, cleanup.path);
485
+ return;
486
+ }
487
+ }
@@ -1,4 +1,6 @@
1
1
  import path from "node:path";
2
+ import { isEdgeSupportPlan } from "./foundry-edge-support-plan.js";
3
+ import { sha256Json } from "./identity-preflight-proof.js";
2
4
  import { commandSpecOptionValue } from "@tiangong-lca/cli/command-spec";
3
5
  import { captureFoundryInput, FoundryContextError, resolveFoundryInputPath, } from "./foundry-runtime-context.js";
4
6
  import { readTaskJson } from "./foundry-task-io.js";
@@ -28,11 +30,20 @@ export function assertFoundryRepairExecution(context, entries, request) {
28
30
  const approval = readWorkflowArtifact(context, approvalEntry).value;
29
31
  const selection = foundryRepairSelection(context);
30
32
  const candidate = captureFoundryInput(resolveFoundryInputPath(context, selection.candidate));
31
- const contractFile = commandSpecOptionValue(request.content.commit, "--execution-contract");
33
+ const edge = isEdgeSupportPlan(request.content.commit) ? request.content.commit : null;
34
+ const contractFile = edge
35
+ ? edge.update?.contract.path
36
+ : commandSpecOptionValue(request.content.commit, "--execution-contract");
32
37
  if (!contractFile)
33
38
  return fail();
34
39
  const contract = captureFoundryInput(contractFile);
35
- const expectedContract = workflowObject(workflowObject(preparation.value.inputs).contract);
40
+ const inputs = workflowObject(preparation.value.inputs);
41
+ const expectedContract = workflowObject(inputs.contract);
42
+ if (edge &&
43
+ (!edge.update ||
44
+ sha256Json(edge.update.preparation) !== sha256Json(captureFoundryInput(preparation.file)) ||
45
+ sha256Json(edge.update.before) !== sha256Json(inputs.before)))
46
+ return fail();
36
47
  if (job.target_profile !== "generic" ||
37
48
  handoff.repair_scope !== true ||
38
49
  preparation.value.status !== "prepared" ||
@@ -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(JSON.parse(result.stdout), {
85
+ receipt = parseFreshIntentBoundAuthReceipt(readFoundryCliIdentityResult(result.stdout, cli.packageVersion), {
68
86
  nowMs: Date.now(),
69
87
  maxAgeMs,
70
88
  expectedProjectRef: account.projectRef,
@@ -110,7 +128,9 @@ export function assertVerifiedFoundryIdentity(context, identity, qualification)
110
128
  identity.runtimeEntrySha256 !== context.runtime.entrySha256 ||
111
129
  (qualification !== undefined &&
112
130
  identity.runtimeQualificationSha256 !== qualification.qualification_sha256) ||
113
- !context.accountIntent)
131
+ !context.accountIntent ||
132
+ identity.receipt.project.project_ref !== context.accountIntent.projectRef ||
133
+ identity.receipt.identity.user_id !== context.accountIntent.userId)
114
134
  reject("identity_context_mismatch", "Identity proof is not bound to the current task context.");
115
135
  try {
116
136
  parseFreshIntentBoundAuthReceipt(identity.receipt, {
@@ -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.1.27" || cli.platform !== context.platform)
161
- fail("runtime_cli_unqualified", "Foundry requires the exact CLI 0.1.27 C1 runtime on the selected platform.");
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.");
@@ -1,4 +1,5 @@
1
1
  import { type TiangongLcaCliTidasSchemaSource } from "./foundry-tidas-source.ts";
2
+ export declare const tiangongLcaCliPackageVersion = "0.4.0";
2
3
  export interface InstalledTiangongLcaCliPackage {
3
4
  packageName: string;
4
5
  packageVersion: string;
@@ -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.1.27";
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) {
@@ -19,11 +19,12 @@ export declare function registerFoundryTaskAuthorization(context: FoundryRuntime
19
19
  evidence: readonly TaskApprovalEvidence[];
20
20
  expectedPreviousSha256?: string | null;
21
21
  validateCurrent?: (task: LoadedTask, index: readonly ArtifactEntry[]) => void;
22
+ refreshIdentity?: () => VerifiedFoundryIdentity;
22
23
  }, qualification?: QualifiedFoundryRuntime): Promise<{
23
24
  authorization_sha256: string;
24
25
  pointer_sha256: string;
25
26
  }>;
26
- export declare function loadFoundryTaskAuthorization(context: FoundryRuntimeContext, identity: VerifiedFoundryIdentity, inputFile: string, qualification?: QualifiedFoundryRuntime): Promise<ValidatedTaskAuthorization>;
27
+ export declare function loadFoundryTaskAuthorization(context: FoundryRuntimeContext, identity: VerifiedFoundryIdentity, inputFile: string, qualification?: QualifiedFoundryRuntime, refreshIdentity?: () => VerifiedFoundryIdentity): Promise<ValidatedTaskAuthorization>;
27
28
  /** Prepare, but do not activate, an exact successor grant for a verified derived task artifact. */
28
29
  export declare function prepareDerivedFoundryTaskAuthorization(context: FoundryRuntimeContext, qualification: QualifiedFoundryRuntime, identity: VerifiedFoundryIdentity, options: PrepareDerivedFoundryTaskAuthorizationOptions): Promise<Readonly<{
29
30
  grant: Readonly<{