@tiinex/core 0.1.1

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 (517) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +31 -0
  3. package/README.md +45 -0
  4. package/package.json +176 -0
  5. package/src/actions/record.actions.js +312 -0
  6. package/src/adapters/adapter.contracts.js +143 -0
  7. package/src/adapters/archive/archive.adapter.js +502 -0
  8. package/src/adapters/archive/archive.portableChangeset.js +141 -0
  9. package/src/adapters/archive/archive.transport.js +124 -0
  10. package/src/artifacts/artifact.localDraft.js +27 -0
  11. package/src/artifacts/artifact.normalize.js +28 -0
  12. package/src/artifacts/artifact.parse.js +207 -0
  13. package/src/artifacts/artifact.record.js +83 -0
  14. package/src/audit/audit.run.js +103 -0
  15. package/src/audit/audit.summary.js +7 -0
  16. package/src/diagnostics/sourceBoundary.report.js +112 -0
  17. package/src/export/package.apply.js +349 -0
  18. package/src/export/package.builder.js +366 -0
  19. package/src/export/package.bytes.js +164 -0
  20. package/src/export/package.controlIntegrity.js +42 -0
  21. package/src/export/package.controlTopology.js +97 -0
  22. package/src/export/package.fileMap.js +174 -0
  23. package/src/export/package.manifest.js +401 -0
  24. package/src/export/package.preflight.js +204 -0
  25. package/src/export/package.sourceReference.js +81 -0
  26. package/src/export/package.workspaceContext.js +144 -0
  27. package/src/export/package.zip.js +128 -0
  28. package/src/export/tree.bundle.js +278 -0
  29. package/src/governance/governance.boundary.js +196 -0
  30. package/src/integrity/integrity.c14nV2.js +190 -0
  31. package/src/integrity/integrity.methodReference.js +73 -0
  32. package/src/integrity/integrity.validate.js +56 -0
  33. package/src/lineage/lineage.candidateResolution.js +46 -0
  34. package/src/lineage/lineage.githubIssueComment.js +106 -0
  35. package/src/lineage/lineage.githubIssueLocal.js +196 -0
  36. package/src/lineage/lineage.githubIssueTarget.js +89 -0
  37. package/src/lineage/lineage.integrity.js +133 -0
  38. package/src/lineage/lineage.materialPreference.js +26 -0
  39. package/src/lineage/lineage.model.js +63 -0
  40. package/src/lineage/lineage.parentAuthority.js +5 -0
  41. package/src/lineage/lineage.parentBinding.js +104 -0
  42. package/src/lineage/lineage.pathBasis.js +47 -0
  43. package/src/lineage/lineage.resolve.js +388 -0
  44. package/src/lineage/lineage.sourceScope.js +74 -0
  45. package/src/lineage/lineage.targetKeys.js +80 -0
  46. package/src/lineage/lineage.traverse.js +132 -0
  47. package/src/public/applicationProjection.js +236 -0
  48. package/src/public/companionResources.js +246 -0
  49. package/src/public/index.js +16 -0
  50. package/src/public/node.js +2 -0
  51. package/src/public/schemaAncestry.js +26 -0
  52. package/src/publication/publication.contract.js +196 -0
  53. package/src/publication/publication.preflight.js +159 -0
  54. package/src/publication/publication.targetContract.js +241 -0
  55. package/src/reingest/reingest.plan.js +162 -0
  56. package/src/release/plan.mjs +28 -0
  57. package/src/release/policy.mjs +100 -0
  58. package/src/release/run.mjs +74 -0
  59. package/src/schemas/capability.registry.js +226 -0
  60. package/src/schemas/companion.js +245 -0
  61. package/src/schemas/contracts.js +6 -0
  62. package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.js +14 -0
  63. package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.json +23 -0
  64. package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.runtime.json +4283 -0
  65. package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.source.js +9 -0
  66. package/src/schemas/coordination/project/tiinex.project.v1.schema.js +26 -0
  67. package/src/schemas/coordination/project/tiinex.project.v1.schema.json +23 -0
  68. package/src/schemas/coordination/project/tiinex.project.v1.schema.runtime.json +1985 -0
  69. package/src/schemas/coordination/project/tiinex.project.v1.schema.source.js +9 -0
  70. package/src/schemas/core/decision/tiinex.decision.v1.schema.js +14 -0
  71. package/src/schemas/core/decision/tiinex.decision.v1.schema.json +24 -0
  72. package/src/schemas/core/decision/tiinex.decision.v1.schema.runtime.json +1700 -0
  73. package/src/schemas/core/decision/tiinex.decision.v1.schema.source.js +9 -0
  74. package/src/schemas/core/evidence/tiinex.evidence.v1.capabilities.js +14 -0
  75. package/src/schemas/core/evidence/tiinex.evidence.v1.en.i18n.json +6 -0
  76. package/src/schemas/core/evidence/tiinex.evidence.v1.findings.js +9 -0
  77. package/src/schemas/core/evidence/tiinex.evidence.v1.presenter.js +1 -0
  78. package/src/schemas/core/evidence/tiinex.evidence.v1.schema.js +32 -0
  79. package/src/schemas/core/evidence/tiinex.evidence.v1.schema.json +24 -0
  80. package/src/schemas/core/evidence/tiinex.evidence.v1.schema.runtime.json +2184 -0
  81. package/src/schemas/core/evidence/tiinex.evidence.v1.schema.source.js +9 -0
  82. package/src/schemas/core/evidence/tiinex.evidence.v1.sv.i18n.json +6 -0
  83. package/src/schemas/core/evidence/tiinex.evidence.v1.transitions.js +1 -0
  84. package/src/schemas/core/evidence/tiinex.evidence.v1.validate.js +10 -0
  85. package/src/schemas/core/feedback/tiinex.feedback.v1.schema.js +14 -0
  86. package/src/schemas/core/feedback/tiinex.feedback.v1.schema.json +23 -0
  87. package/src/schemas/core/feedback/tiinex.feedback.v1.schema.runtime.json +1773 -0
  88. package/src/schemas/core/feedback/tiinex.feedback.v1.schema.source.js +9 -0
  89. package/src/schemas/core/interpretation/tiinex.interpretation.v1.capabilities.js +11 -0
  90. package/src/schemas/core/interpretation/tiinex.interpretation.v1.contract.js +40 -0
  91. package/src/schemas/core/interpretation/tiinex.interpretation.v1.en.i18n.json +9 -0
  92. package/src/schemas/core/interpretation/tiinex.interpretation.v1.findings.js +12 -0
  93. package/src/schemas/core/interpretation/tiinex.interpretation.v1.localMaterialization.js +89 -0
  94. package/src/schemas/core/interpretation/tiinex.interpretation.v1.presenter.js +8 -0
  95. package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.js +34 -0
  96. package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.json +23 -0
  97. package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.runtime.json +2029 -0
  98. package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.source.js +9 -0
  99. package/src/schemas/core/interpretation/tiinex.interpretation.v1.sv.i18n.json +9 -0
  100. package/src/schemas/core/interpretation/tiinex.interpretation.v1.transitions.js +1 -0
  101. package/src/schemas/core/interpretation/tiinex.interpretation.v1.validate.js +25 -0
  102. package/src/schemas/core/preservation/tiinex.preservation.v1.capabilities.js +14 -0
  103. package/src/schemas/core/preservation/tiinex.preservation.v1.en.i18n.json +6 -0
  104. package/src/schemas/core/preservation/tiinex.preservation.v1.findings.js +9 -0
  105. package/src/schemas/core/preservation/tiinex.preservation.v1.presenter.js +1 -0
  106. package/src/schemas/core/preservation/tiinex.preservation.v1.schema.js +31 -0
  107. package/src/schemas/core/preservation/tiinex.preservation.v1.schema.json +23 -0
  108. package/src/schemas/core/preservation/tiinex.preservation.v1.schema.runtime.json +2033 -0
  109. package/src/schemas/core/preservation/tiinex.preservation.v1.schema.source.js +9 -0
  110. package/src/schemas/core/preservation/tiinex.preservation.v1.sv.i18n.json +6 -0
  111. package/src/schemas/core/preservation/tiinex.preservation.v1.transitions.js +1 -0
  112. package/src/schemas/core/preservation/tiinex.preservation.v1.validate.js +10 -0
  113. package/src/schemas/core/relation/tiinex.relation.v1.capabilities.js +7 -0
  114. package/src/schemas/core/relation/tiinex.relation.v1.contract.js +3 -0
  115. package/src/schemas/core/relation/tiinex.relation.v1.en.i18n.json +4 -0
  116. package/src/schemas/core/relation/tiinex.relation.v1.findings.js +9 -0
  117. package/src/schemas/core/relation/tiinex.relation.v1.localMaterialization.js +153 -0
  118. package/src/schemas/core/relation/tiinex.relation.v1.presenter.js +3 -0
  119. package/src/schemas/core/relation/tiinex.relation.v1.schema.js +20 -0
  120. package/src/schemas/core/relation/tiinex.relation.v1.schema.json +23 -0
  121. package/src/schemas/core/relation/tiinex.relation.v1.schema.runtime.json +1668 -0
  122. package/src/schemas/core/relation/tiinex.relation.v1.schema.source.js +9 -0
  123. package/src/schemas/core/relation/tiinex.relation.v1.sv.i18n.json +4 -0
  124. package/src/schemas/core/relation/tiinex.relation.v1.transitions.js +1 -0
  125. package/src/schemas/core/relation/tiinex.relation.v1.validate.js +36 -0
  126. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.capabilities.js +14 -0
  127. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.contract.js +57 -0
  128. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.en.i18n.json +4 -0
  129. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.findings.js +13 -0
  130. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.presenter.js +3 -0
  131. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.js +20 -0
  132. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.json +24 -0
  133. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.runtime.json +3315 -0
  134. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.source.js +9 -0
  135. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.sv.i18n.json +4 -0
  136. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.transitions.js +1 -0
  137. package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.validate.js +78 -0
  138. package/src/schemas/core/signal/tiinex.signal.v1.schema.js +14 -0
  139. package/src/schemas/core/signal/tiinex.signal.v1.schema.json +23 -0
  140. package/src/schemas/core/signal/tiinex.signal.v1.schema.runtime.json +1733 -0
  141. package/src/schemas/core/signal/tiinex.signal.v1.schema.source.js +9 -0
  142. package/src/schemas/core/task/tiinex.task.v1.capabilities.js +11 -0
  143. package/src/schemas/core/task/tiinex.task.v1.contract.js +3 -0
  144. package/src/schemas/core/task/tiinex.task.v1.en.i18n.json +15 -0
  145. package/src/schemas/core/task/tiinex.task.v1.findings.js +18 -0
  146. package/src/schemas/core/task/tiinex.task.v1.localMaterialization.js +148 -0
  147. package/src/schemas/core/task/tiinex.task.v1.presenter.js +8 -0
  148. package/src/schemas/core/task/tiinex.task.v1.schema.js +35 -0
  149. package/src/schemas/core/task/tiinex.task.v1.schema.json +23 -0
  150. package/src/schemas/core/task/tiinex.task.v1.schema.runtime.json +1708 -0
  151. package/src/schemas/core/task/tiinex.task.v1.schema.source.js +9 -0
  152. package/src/schemas/core/task/tiinex.task.v1.sv.i18n.json +15 -0
  153. package/src/schemas/core/task/tiinex.task.v1.transitions.js +3 -0
  154. package/src/schemas/core/task/tiinex.task.v1.validate.js +41 -0
  155. package/src/schemas/core/topic/tiinex.topic.v1.capabilities.js +14 -0
  156. package/src/schemas/core/topic/tiinex.topic.v1.creation.js +46 -0
  157. package/src/schemas/core/topic/tiinex.topic.v1.en.i18n.json +8 -0
  158. package/src/schemas/core/topic/tiinex.topic.v1.findings.js +11 -0
  159. package/src/schemas/core/topic/tiinex.topic.v1.localMaterialization.js +135 -0
  160. package/src/schemas/core/topic/tiinex.topic.v1.presenter.js +1 -0
  161. package/src/schemas/core/topic/tiinex.topic.v1.schema.js +34 -0
  162. package/src/schemas/core/topic/tiinex.topic.v1.schema.json +23 -0
  163. package/src/schemas/core/topic/tiinex.topic.v1.schema.runtime.json +1699 -0
  164. package/src/schemas/core/topic/tiinex.topic.v1.schema.source.js +9 -0
  165. package/src/schemas/core/topic/tiinex.topic.v1.sv.i18n.json +8 -0
  166. package/src/schemas/core/topic/tiinex.topic.v1.transitions.js +31 -0
  167. package/src/schemas/core/topic/tiinex.topic.v1.validate.js +11 -0
  168. package/src/schemas/creation.capability.js +289 -0
  169. package/src/schemas/creation.contracts.js +334 -0
  170. package/src/schemas/creation.executionSnapshot.js +79 -0
  171. package/src/schemas/creation.factoryQualification.js +73 -0
  172. package/src/schemas/creation.renderer.js +244 -0
  173. package/src/schemas/creation.representation.js +279 -0
  174. package/src/schemas/creation.rootMetadata.js +6 -0
  175. package/src/schemas/creation.schemaReferences.js +65 -0
  176. package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.js +14 -0
  177. package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.json +23 -0
  178. package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.runtime.json +1873 -0
  179. package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.source.js +9 -0
  180. package/src/schemas/discovery/tiinex.discovery.v1.schema.js +14 -0
  181. package/src/schemas/discovery/tiinex.discovery.v1.schema.json +23 -0
  182. package/src/schemas/discovery/tiinex.discovery.v1.schema.runtime.json +1839 -0
  183. package/src/schemas/discovery/tiinex.discovery.v1.schema.source.js +9 -0
  184. package/src/schemas/generic.artifact.module.js +25 -0
  185. package/src/schemas/party/organization/tiinex.party.organization.v1.schema.js +26 -0
  186. package/src/schemas/party/organization/tiinex.party.organization.v1.schema.json +23 -0
  187. package/src/schemas/party/organization/tiinex.party.organization.v1.schema.runtime.json +2249 -0
  188. package/src/schemas/party/organization/tiinex.party.organization.v1.schema.source.js +9 -0
  189. package/src/schemas/party/role/tiinex.party.role.v1.schema.js +26 -0
  190. package/src/schemas/party/role/tiinex.party.role.v1.schema.json +24 -0
  191. package/src/schemas/party/role/tiinex.party.role.v1.schema.runtime.json +2091 -0
  192. package/src/schemas/party/role/tiinex.party.role.v1.schema.source.js +9 -0
  193. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.capabilities.js +14 -0
  194. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.en.i18n.json +4 -0
  195. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.findings.js +1 -0
  196. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.presenter.js +1 -0
  197. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.js +29 -0
  198. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.json +21 -0
  199. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.runtime.json +2180 -0
  200. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.source.js +9 -0
  201. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.sv.i18n.json +4 -0
  202. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.transitions.js +1 -0
  203. package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.validate.js +1 -0
  204. package/src/schemas/reduction/tiinex.reduction.v1.schema.js +26 -0
  205. package/src/schemas/reduction/tiinex.reduction.v1.schema.json +23 -0
  206. package/src/schemas/reduction/tiinex.reduction.v1.schema.runtime.json +1733 -0
  207. package/src/schemas/reduction/tiinex.reduction.v1.schema.source.js +9 -0
  208. package/src/schemas/reference.shapes.js +33 -0
  209. package/src/schemas/registry.js +36 -0
  210. package/src/schemas/resolver.js +13 -0
  211. package/src/schemas/schema/module/tiinex.schema.module.v1.capabilities.js +14 -0
  212. package/src/schemas/schema/module/tiinex.schema.module.v1.en.i18n.json +4 -0
  213. package/src/schemas/schema/module/tiinex.schema.module.v1.findings.js +1 -0
  214. package/src/schemas/schema/module/tiinex.schema.module.v1.presenter.js +1 -0
  215. package/src/schemas/schema/module/tiinex.schema.module.v1.schema.js +29 -0
  216. package/src/schemas/schema/module/tiinex.schema.module.v1.schema.json +21 -0
  217. package/src/schemas/schema/module/tiinex.schema.module.v1.schema.runtime.json +2093 -0
  218. package/src/schemas/schema/module/tiinex.schema.module.v1.schema.source.js +9 -0
  219. package/src/schemas/schema/module/tiinex.schema.module.v1.sv.i18n.json +4 -0
  220. package/src/schemas/schema/module/tiinex.schema.module.v1.transitions.js +1 -0
  221. package/src/schemas/schema/module/tiinex.schema.module.v1.validate.js +1 -0
  222. package/src/schemas/schema.factory.descriptor.js +104 -0
  223. package/src/schemas/schema.githubSourceTarget.js +131 -0
  224. package/src/schemas/schema.identity.js +10 -0
  225. package/src/schemas/schema.reference.js +133 -0
  226. package/src/schemas/schema.source.js +239 -0
  227. package/src/schemas/tiinex.root.v1.capabilities.js +14 -0
  228. package/src/schemas/tiinex.root.v1.classify.js +55 -0
  229. package/src/schemas/tiinex.root.v1.en.i18n.json +24 -0
  230. package/src/schemas/tiinex.root.v1.fallback.js +84 -0
  231. package/src/schemas/tiinex.root.v1.findings.js +19 -0
  232. package/src/schemas/tiinex.root.v1.presenter.js +5 -0
  233. package/src/schemas/tiinex.root.v1.schema.js +29 -0
  234. package/src/schemas/tiinex.root.v1.schema.json +24 -0
  235. package/src/schemas/tiinex.root.v1.schema.runtime.json +1574 -0
  236. package/src/schemas/tiinex.root.v1.schema.source.js +9 -0
  237. package/src/schemas/tiinex.root.v1.sv.i18n.json +24 -0
  238. package/src/schemas/tiinex.root.v1.transitions.js +1 -0
  239. package/src/schemas/tiinex.root.v1.validate.js +36 -0
  240. package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.js +14 -0
  241. package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.json +23 -0
  242. package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.runtime.json +2027 -0
  243. package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.source.js +9 -0
  244. package/src/schemas/validation/method/tiinex.validation.method.v1.schema.js +14 -0
  245. package/src/schemas/validation/method/tiinex.validation.method.v1.schema.json +23 -0
  246. package/src/schemas/validation/method/tiinex.validation.method.v1.schema.runtime.json +1848 -0
  247. package/src/schemas/validation/method/tiinex.validation.method.v1.schema.source.js +9 -0
  248. package/src/schemas/validation/report/tiinex.validation.report.v1.schema.js +14 -0
  249. package/src/schemas/validation/report/tiinex.validation.report.v1.schema.json +23 -0
  250. package/src/schemas/validation/report/tiinex.validation.report.v1.schema.runtime.json +2015 -0
  251. package/src/schemas/validation/report/tiinex.validation.report.v1.schema.source.js +9 -0
  252. package/src/schemas/workspace/tiinex.workspace.v1.capabilities.js +12 -0
  253. package/src/schemas/workspace/tiinex.workspace.v1.en.i18n.json +7 -0
  254. package/src/schemas/workspace/tiinex.workspace.v1.findings.js +5 -0
  255. package/src/schemas/workspace/tiinex.workspace.v1.presenter.js +27 -0
  256. package/src/schemas/workspace/tiinex.workspace.v1.schema.js +30 -0
  257. package/src/schemas/workspace/tiinex.workspace.v1.schema.json +23 -0
  258. package/src/schemas/workspace/tiinex.workspace.v1.schema.runtime.json +1596 -0
  259. package/src/schemas/workspace/tiinex.workspace.v1.schema.source.js +9 -0
  260. package/src/schemas/workspace/tiinex.workspace.v1.sv.i18n.json +7 -0
  261. package/src/schemas/workspace/tiinex.workspace.v1.transitions.js +10 -0
  262. package/src/schemas/workspace/tiinex.workspace.v1.validate.js +10 -0
  263. package/src/sources/github/github.issueTarget.js +127 -0
  264. package/src/sources/origin.references.js +249 -0
  265. package/src/sources/source.explicitTargets.js +49 -0
  266. package/src/sources/transport.levels.js +107 -0
  267. package/src/tooling/portable/adapters/cli/cli.cold-start-input.js +34 -0
  268. package/src/tooling/portable/adapters/cli/cli.command-input.js +455 -0
  269. package/src/tooling/portable/adapters/cli/cli.common-author.js +249 -0
  270. package/src/tooling/portable/adapters/cli/cli.common-output.js +330 -0
  271. package/src/tooling/portable/adapters/cli/cli.editor-assistance.js +13 -0
  272. package/src/tooling/portable/adapters/cli/cli.ground-materialize.js +96 -0
  273. package/src/tooling/portable/adapters/cli/cli.ground-recovery.js +99 -0
  274. package/src/tooling/portable/adapters/cli/cli.handoff-manufacture.js +345 -0
  275. package/src/tooling/portable/adapters/cli/cli.handoff-sibling-allocation.js +31 -0
  276. package/src/tooling/portable/adapters/cli/cli.help.js +80 -0
  277. package/src/tooling/portable/adapters/cli/cli.land.js +13 -0
  278. package/src/tooling/portable/adapters/cli/cli.local-output.js +72 -0
  279. package/src/tooling/portable/adapters/cli/cli.material-policy.js +6 -0
  280. package/src/tooling/portable/adapters/cli/cli.operator-bridge.js +18 -0
  281. package/src/tooling/portable/adapters/cli/cli.reduction-input.js +14 -0
  282. package/src/tooling/portable/adapters/cli/cli.run.js +434 -0
  283. package/src/tooling/portable/adapters/llm/llm.entrypoint.js +34 -0
  284. package/src/tooling/portable/adapters/node/checkpoint.verify.js +267 -0
  285. package/src/tooling/portable/adapters/node/handoff.manufacture.bootstrap.js +109 -0
  286. package/src/tooling/portable/adapters/node/handoff.manufacture.enumeration.js +94 -0
  287. package/src/tooling/portable/adapters/node/handoff.manufacture.js +193 -0
  288. package/src/tooling/portable/adapters/node/handoff.manufacture.multiRoot.js +49 -0
  289. package/src/tooling/portable/adapters/node/handoff.manufacture.packageParent.js +130 -0
  290. package/src/tooling/portable/adapters/node/handoff.manufacture.requirements.js +353 -0
  291. package/src/tooling/portable/adapters/node/handoff.manufacture.scope.js +147 -0
  292. package/src/tooling/portable/adapters/node/workspaceCarrier.manufacture.js +62 -0
  293. package/src/tooling/portable/assets/asset.operations.js +170 -0
  294. package/src/tooling/portable/audit/audit.capability.js +119 -0
  295. package/src/tooling/portable/bootstrap/artifact.result.selfverify.mjs +109 -0
  296. package/src/tooling/portable/bootstrap/bootstrap.case.mjs +43 -0
  297. package/src/tooling/portable/bootstrap/tiinex.llm.bootstrap.md +814 -0
  298. package/src/tooling/portable/bootstrap/tiinex.llm.bootstrap.pointer.json +25 -0
  299. package/src/tooling/portable/checkpoint/portable.checkpoint.js +89 -0
  300. package/src/tooling/portable/conformance/checkpoint.qualification.js +271 -0
  301. package/src/tooling/portable/draft/draft.create.js +389 -0
  302. package/src/tooling/portable/draft/draft.crud.js +175 -0
  303. package/src/tooling/portable/draft/draft.exact.js +173 -0
  304. package/src/tooling/portable/draft/draft.operations.js +265 -0
  305. package/src/tooling/portable/draft/draft.qualification.js +45 -0
  306. package/src/tooling/portable/draft/draft.set.js +193 -0
  307. package/src/tooling/portable/draft/draft.validation-context.js +7 -0
  308. package/src/tooling/portable/editor/authoring.parent.js +37 -0
  309. package/src/tooling/portable/editor/editor.assistance.js +221 -0
  310. package/src/tooling/portable/editor/staged.validation.js +96 -0
  311. package/src/tooling/portable/engine.facade.js +468 -0
  312. package/src/tooling/portable/findings.js +92 -0
  313. package/src/tooling/portable/grounding/grounding.capsule.js +128 -0
  314. package/src/tooling/portable/grounding/grounding.continuity.js +283 -0
  315. package/src/tooling/portable/grounding/grounding.participantAuthority.js +20 -0
  316. package/src/tooling/portable/grounding/grounding.planningContext.js +34 -0
  317. package/src/tooling/portable/grounding/grounding.readiness.authority.js +17 -0
  318. package/src/tooling/portable/grounding/grounding.readiness.js +316 -0
  319. package/src/tooling/portable/grounding/grounding.readiness.support.js +245 -0
  320. package/src/tooling/portable/grounding/grounding.sourceEvidence.js +71 -0
  321. package/src/tooling/portable/grounding/grounding.workContext.js +72 -0
  322. package/src/tooling/portable/grounding/grounding.workProvenance.js +153 -0
  323. package/src/tooling/portable/handoff/carrierLineage.js +214 -0
  324. package/src/tooling/portable/handoff/carrierProfile.js +54 -0
  325. package/src/tooling/portable/handoff/carrierProjection.js +193 -0
  326. package/src/tooling/portable/handoff/carrierProjection.routeQualification.js +228 -0
  327. package/src/tooling/portable/handoff/carrierProjection.shared.js +7 -0
  328. package/src/tooling/portable/handoff/carrierProjection.workspaces.js +54 -0
  329. package/src/tooling/portable/handoff/coldConsumerEntrypoint.js +185 -0
  330. package/src/tooling/portable/handoff/coldStartQualification.contract.js +184 -0
  331. package/src/tooling/portable/handoff/coldStartQualification.grounding.js +392 -0
  332. package/src/tooling/portable/handoff/coldStartQualification.js +22 -0
  333. package/src/tooling/portable/handoff/coldStartQualification.materials.js +364 -0
  334. package/src/tooling/portable/handoff/coldStartQualification.observation.js +220 -0
  335. package/src/tooling/portable/handoff/coldStartQualification.run.js +81 -0
  336. package/src/tooling/portable/handoff/coldStartQualification.shared.js +57 -0
  337. package/src/tooling/portable/handoff/coldStartRolePointers.js +39 -0
  338. package/src/tooling/portable/handoff/contextAudit.js +247 -0
  339. package/src/tooling/portable/handoff/contracts/tiinex.handoff.package.v1.schema.md +409 -0
  340. package/src/tooling/portable/handoff/handoffAuthoringPlan.js +35 -0
  341. package/src/tooling/portable/handoff/handoffEndpointProjection.js +61 -0
  342. package/src/tooling/portable/handoff/handoffLeafProjection.js +91 -0
  343. package/src/tooling/portable/handoff/humanOutputPresentation.js +21 -0
  344. package/src/tooling/portable/handoff/manufacture.js +84 -0
  345. package/src/tooling/portable/handoff/materialClosure.archiveV2.binding.js +72 -0
  346. package/src/tooling/portable/handoff/materialClosure.archiveV2.direct.js +160 -0
  347. package/src/tooling/portable/handoff/materialClosure.archiveV2.indexes.js +36 -0
  348. package/src/tooling/portable/handoff/materialClosure.archiveV2.js +247 -0
  349. package/src/tooling/portable/handoff/materialClosure.archiveV2.projectionProvider.js +44 -0
  350. package/src/tooling/portable/handoff/materialClosure.archiveV2.workspace.js +226 -0
  351. package/src/tooling/portable/handoff/materialClosure.descriptor.js +169 -0
  352. package/src/tooling/portable/handoff/materialClosure.inputBinding.js +372 -0
  353. package/src/tooling/portable/handoff/materialClosure.inputBinding.support.js +62 -0
  354. package/src/tooling/portable/handoff/materialClosure.materialized.js +143 -0
  355. package/src/tooling/portable/handoff/materialClosure.materials.js +116 -0
  356. package/src/tooling/portable/handoff/materialClosure.package.js +181 -0
  357. package/src/tooling/portable/handoff/materialClosure.plan.js +204 -0
  358. package/src/tooling/portable/handoff/materialClosure.readiness.js +36 -0
  359. package/src/tooling/portable/handoff/materialClosure.requirements.js +137 -0
  360. package/src/tooling/portable/handoff/operatorContextProjection.js +105 -0
  361. package/src/tooling/portable/handoff/pointerEntrypoint.js +138 -0
  362. package/src/tooling/portable/handoff/qualifiedHandoffFixture.js +34 -0
  363. package/src/tooling/portable/handoff/recipientV2.artifactFirst.build.js +321 -0
  364. package/src/tooling/portable/handoff/recipientV2.artifactFirst.closure.js +126 -0
  365. package/src/tooling/portable/handoff/recipientV2.artifactFirst.inspect.js +194 -0
  366. package/src/tooling/portable/handoff/recipientV2.artifactFirst.materials.js +207 -0
  367. package/src/tooling/portable/handoff/recipientV2.artifactFirst.projection.js +69 -0
  368. package/src/tooling/portable/handoff/recipientV2.artifactFirst.roles.js +166 -0
  369. package/src/tooling/portable/handoff/recipientV2.artifactFirst.routes.js +113 -0
  370. package/src/tooling/portable/handoff/recipientV2.artifactFirst.shared.js +87 -0
  371. package/src/tooling/portable/handoff/recipientV2.artifactFirst.workspaces.js +160 -0
  372. package/src/tooling/portable/handoff/recipientV2.artifactFirstPhase1.js +44 -0
  373. package/src/tooling/portable/handoff/recipientV2.artifactInspection.js +55 -0
  374. package/src/tooling/portable/handoff/recipientV2.artifacts.js +174 -0
  375. package/src/tooling/portable/handoff/recipientV2.coldProjection.js +24 -0
  376. package/src/tooling/portable/handoff/recipientV2.delivery.js +48 -0
  377. package/src/tooling/portable/handoff/recipientV2.endpointRolePointers.js +179 -0
  378. package/src/tooling/portable/handoff/recipientV2.entryContract.js +28 -0
  379. package/src/tooling/portable/handoff/recipientV2.humanOutput.js +78 -0
  380. package/src/tooling/portable/handoff/recipientV2.inspect.helpers.js +218 -0
  381. package/src/tooling/portable/handoff/recipientV2.inspect.js +194 -0
  382. package/src/tooling/portable/handoff/recipientV2.inspect.pathToken.js +9 -0
  383. package/src/tooling/portable/handoff/recipientV2.inspect.projection.js +58 -0
  384. package/src/tooling/portable/handoff/recipientV2.inspect.workspaces.js +177 -0
  385. package/src/tooling/portable/handoff/recipientV2.lineage.js +142 -0
  386. package/src/tooling/portable/handoff/recipientV2.packageV1.build.js +147 -0
  387. package/src/tooling/portable/handoff/recipientV2.packageV1.constants.js +4 -0
  388. package/src/tooling/portable/handoff/recipientV2.packageV1.contract.js +101 -0
  389. package/src/tooling/portable/handoff/recipientV2.packageV1.inspect.helpers.js +126 -0
  390. package/src/tooling/portable/handoff/recipientV2.packageV1.inspect.js +185 -0
  391. package/src/tooling/portable/handoff/recipientV2.packageV1.js +12 -0
  392. package/src/tooling/portable/handoff/recipientV2.packageV1.shared.js +24 -0
  393. package/src/tooling/portable/handoff/recipientV2.packageV1.workspaceProjection.js +22 -0
  394. package/src/tooling/portable/handoff/recipientV2.pointer.js +40 -0
  395. package/src/tooling/portable/handoff/recipientV2.routeSelection.js +16 -0
  396. package/src/tooling/portable/handoff/recipientV2.topology.helpers.js +20 -0
  397. package/src/tooling/portable/handoff/recipientV2.topology.js +320 -0
  398. package/src/tooling/portable/handoff/recipientV2.topology.materials.js +70 -0
  399. package/src/tooling/portable/handoff/recipientV2.topology.workspaces.js +193 -0
  400. package/src/tooling/portable/handoff/recipientV2.transportManifest.js +123 -0
  401. package/src/tooling/portable/handoff/recipientV2.workspaceRepresentation.js +163 -0
  402. package/src/tooling/portable/handoff/routeArtifactConformance.js +130 -0
  403. package/src/tooling/portable/handoff/toolingBootstrap.js +67 -0
  404. package/src/tooling/portable/handoff/transportCompanion.js +175 -0
  405. package/src/tooling/portable/handoff/workspaceByteProvider.archive.js +95 -0
  406. package/src/tooling/portable/handoff/workspaceByteProvider.js +271 -0
  407. package/src/tooling/portable/handoff/workspaceCarrier.manufacture.js +93 -0
  408. package/src/tooling/portable/handoff/workspaceLandingPlan.js +142 -0
  409. package/src/tooling/portable/handoff/workspacePackageSources.js +105 -0
  410. package/src/tooling/portable/handoff/workspaceQualifiedReference.js +10 -0
  411. package/src/tooling/portable/handoff/workspaceSourceIdentity.js +52 -0
  412. package/src/tooling/portable/handoff/workspaceTargetConformance.js +134 -0
  413. package/src/tooling/portable/host/host.capabilities.js +181 -0
  414. package/src/tooling/portable/host/tool.bindings.js +357 -0
  415. package/src/tooling/portable/host/tool.receiptNormalization.js +141 -0
  416. package/src/tooling/portable/index.js +52 -0
  417. package/src/tooling/portable/input/node.input.js +184 -0
  418. package/src/tooling/portable/input/portable.input.js +249 -0
  419. package/src/tooling/portable/lifecycle/lifecycle.action.js +11 -0
  420. package/src/tooling/portable/lifecycle/lifecycle.material.js +173 -0
  421. package/src/tooling/portable/lifecycle/lifecycle.operations.js +34 -0
  422. package/src/tooling/portable/lifecycle/lifecycle.readiness.js +247 -0
  423. package/src/tooling/portable/lineage/lineage.integrity.apply.audit.js +22 -0
  424. package/src/tooling/portable/lineage/lineage.integrity.apply.evidence.js +36 -0
  425. package/src/tooling/portable/lineage/lineage.integrity.apply.js +306 -0
  426. package/src/tooling/portable/lineage/lineage.integrity.apply.structure.js +178 -0
  427. package/src/tooling/portable/lineage/lineage.integrity.plan.js +377 -0
  428. package/src/tooling/portable/lineage/lineage.integrity.projection.human.js +82 -0
  429. package/src/tooling/portable/lineage/lineage.integrity.projection.js +349 -0
  430. package/src/tooling/portable/lineage/lineage.operations.js +32 -0
  431. package/src/tooling/portable/lineage/lineage.print.js +398 -0
  432. package/src/tooling/portable/lineage/lineage.print.render.js +88 -0
  433. package/src/tooling/portable/lineage/lineage.print.utils.js +58 -0
  434. package/src/tooling/portable/lineage/lineage.publicationProviderReceipts.js +141 -0
  435. package/src/tooling/portable/lineage/lineage.publicationQualification.js +183 -0
  436. package/src/tooling/portable/lineage/lineage.search.js +301 -0
  437. package/src/tooling/portable/live/live.artifact.js +192 -0
  438. package/src/tooling/portable/live/live.export.js +107 -0
  439. package/src/tooling/portable/live/live.lineage.closure.js +71 -0
  440. package/src/tooling/portable/live/live.lineage.js +338 -0
  441. package/src/tooling/portable/live/live.protocol.js +181 -0
  442. package/src/tooling/portable/materialization/durable.materialize.js +162 -0
  443. package/src/tooling/portable/materialization/epistemic.plan.js +239 -0
  444. package/src/tooling/portable/materialization/loaded.parent.js +54 -0
  445. package/src/tooling/portable/materialization/materialization.facade.js +30 -0
  446. package/src/tooling/portable/operation.catalog.js +393 -0
  447. package/src/tooling/portable/operation.catalog.package.js +183 -0
  448. package/src/tooling/portable/operation.result.js +25 -0
  449. package/src/tooling/portable/orchestration/task.prepare.js +191 -0
  450. package/src/tooling/portable/output/artifact.result.package.js +308 -0
  451. package/src/tooling/portable/output/deterministic.zip.js +88 -0
  452. package/src/tooling/portable/output/node.artifact-set.js +223 -0
  453. package/src/tooling/portable/output/node.draft.js +41 -0
  454. package/src/tooling/portable/output/node.zip.js +39 -0
  455. package/src/tooling/portable/output/recipientV2.zip.js +59 -0
  456. package/src/tooling/portable/overview/blockingCue.js +16 -0
  457. package/src/tooling/portable/overview/operatingOverview.js +413 -0
  458. package/src/tooling/portable/package/generation.binding.js +314 -0
  459. package/src/tooling/portable/package/generation.binding.projection.js +128 -0
  460. package/src/tooling/portable/package/material.graph.js +236 -0
  461. package/src/tooling/portable/package/runtime.package.js +321 -0
  462. package/src/tooling/portable/package/schema.transition.companion.js +196 -0
  463. package/src/tooling/portable/package/semantic.package.graph.js +272 -0
  464. package/src/tooling/portable/package/semantic.package.js +203 -0
  465. package/src/tooling/portable/package/semantic.package.schema-resolution.js +158 -0
  466. package/src/tooling/portable/package/semantic.package.transition-registry.js +189 -0
  467. package/src/tooling/portable/package/semantic.package.types.js +18 -0
  468. package/src/tooling/portable/providers/schema.bootstrap.provenance.js +10 -0
  469. package/src/tooling/portable/providers/schema.provider.qualification.js +52 -0
  470. package/src/tooling/portable/providers/schema.providers.js +458 -0
  471. package/src/tooling/portable/publication/runtime.publication.js +53 -0
  472. package/src/tooling/portable/qualification.js +150 -0
  473. package/src/tooling/portable/reduction/reduction.composition.js +229 -0
  474. package/src/tooling/portable/reduction/reduction.eligibility.helpers.js +258 -0
  475. package/src/tooling/portable/reduction/reduction.eligibility.js +191 -0
  476. package/src/tooling/portable/reduction/reduction.operations.js +30 -0
  477. package/src/tooling/portable/reduction/reduction.preflight.js +85 -0
  478. package/src/tooling/portable/reduction/reduction.shared.js +173 -0
  479. package/src/tooling/portable/schema/bootstrap/canonical.pack.js +24 -0
  480. package/src/tooling/portable/schema/bootstrap/docs-3988951208eb9a8926e84ab42625d4b42fa00c2d/party/role/tiinex.party.role.v1.schema.md +289 -0
  481. package/src/tooling/portable/schema/bootstrap/docs-3988951208eb9a8926e84ab42625d4b42fa00c2d/validation/report/tiinex.validation.report.v1.schema.md +300 -0
  482. package/src/tooling/portable/schema/bootstrap/qualified-local-root/tiinex.root.v1.runtime-projection.json +48 -0
  483. package/src/tooling/portable/schema/bootstrap/qualified-local-root/tiinex.root.v1.schema.md +865 -0
  484. package/src/tooling/portable/schema/contract.compile.js +406 -0
  485. package/src/tooling/portable/schema/contract.compile.utils.js +9 -0
  486. package/src/tooling/portable/schema/contract.constraints.js +117 -0
  487. package/src/tooling/portable/schema/contract.envelope.validate.js +177 -0
  488. package/src/tooling/portable/schema/contract.field-domain.compile.js +399 -0
  489. package/src/tooling/portable/schema/contract.field-domain.js +247 -0
  490. package/src/tooling/portable/schema/contract.field-shape.compile.js +34 -0
  491. package/src/tooling/portable/schema/contract.inheritance.inline.js +103 -0
  492. package/src/tooling/portable/schema/contract.inheritance.js +210 -0
  493. package/src/tooling/portable/schema/contract.inheritance.record.js +76 -0
  494. package/src/tooling/portable/schema/contract.machine-shape.js +309 -0
  495. package/src/tooling/portable/schema/contract.project.js +81 -0
  496. package/src/tooling/portable/schema/contract.semantic-resolution.js +82 -0
  497. package/src/tooling/portable/schema/contract.validate.js +0 -0
  498. package/src/tooling/portable/schema/lexical.shape.v1.js +338 -0
  499. package/src/tooling/portable/schema/llm.companion.js +108 -0
  500. package/src/tooling/portable/schema/named.declarations.js +162 -0
  501. package/src/tooling/portable/schema/ordinary.contract.js +193 -0
  502. package/src/tooling/portable/schema/ordinary.fields.js +205 -0
  503. package/src/tooling/portable/schema/qualifiedLocalRoot.projection.js +70 -0
  504. package/src/tooling/portable/schema/qualifiedLocalRoot.runtime.js +170 -0
  505. package/src/tooling/portable/schema/schema.contract.js +465 -0
  506. package/src/tooling/portable/schema/schema.guide.js +326 -0
  507. package/src/tooling/portable/schema/schema.snapshot.js +119 -0
  508. package/src/tooling/portable/session/portable.session.js +145 -0
  509. package/src/tooling/portable/transfer/transfer.plan.js +102 -0
  510. package/src/transitions/record.transitions.js +484 -0
  511. package/src/transitions/transition.validate.js +129 -0
  512. package/src/validation/findings.js +76 -0
  513. package/src/validation/validateArtifact.js +216 -0
  514. package/src/workspaces/workspace.entrypointCapability.js +44 -0
  515. package/src/workspaces/workspace.materialRole.js +242 -0
  516. package/src/workspaces/workspace.recordPaths.js +426 -0
  517. package/tools/tiinex-portable.mjs +6 -0
@@ -0,0 +1,229 @@
1
+ import { portableFinding } from '../findings.js';
2
+ import {
3
+ PORTABLE_REDUCTION_COMPOSITION_SCHEMA_ID,
4
+ identity,
5
+ linkPath,
6
+ locatorForRecord,
7
+ locatorFromValue,
8
+ markdownLinks,
9
+ normalizePath,
10
+ qualifyRecord,
11
+ qualifyReductionRecord,
12
+ resolveUniqueRecord,
13
+ safeCode,
14
+ sectionText,
15
+ sha256Text,
16
+ stableJson
17
+ } from './reduction.shared.js';
18
+
19
+ const MAX_COMPOSITION_NODES = 128;
20
+
21
+ export function projectReductionComposition(input = {}, material = {}) {
22
+ const records = material.records || [];
23
+ const requestedPath = normalizePath(input.reductionArtifactPath || input.reductionArtifact || input.reduction || '');
24
+ const rootResolution = resolveUniqueRecord(records, requestedPath);
25
+ const root = rootResolution.record;
26
+ const findings = [];
27
+ const blockers = [];
28
+ const missingEvidence = [];
29
+ const ambiguities = [];
30
+ const nodes = new Map();
31
+ const hops = [];
32
+ const sourceReferences = normalizeSourceReferences(input.compositionSources || input.sourceReferences || input.reductionSources || []);
33
+ const immutableSources = normalizeList(input.immutableSources || input.sources || []);
34
+ const lossFacts = normalizeList(input.lossFacts || input.loss || []);
35
+
36
+ if (!root) missingEvidence.push(issue(rootResolution.state === 'ambiguous' ? 'reduction-artifact-ambiguous' : 'reduction-artifact-missing', requestedPath || '(empty)'));
37
+ else if (String(root.schemaId || '') !== 'tiinex.reduction.v1') blockers.push(issue('reduction-schema-mismatch', String(root.schemaId || 'missing')));
38
+
39
+ const rootQualification = root ? qualifyReductionRecord(root, records) : null;
40
+ if (root && !rootQualification.qualified) missingEvidence.push(issue('reduction-unqualified', rootQualification.reasons.join(', ')));
41
+
42
+ if (root && rootQualification.qualified) visitReduction(root, [], 0);
43
+
44
+ const orderedNodes = [...nodes.values()].sort((a, b) => a.path.localeCompare(b.path));
45
+ const orderedHops = [...hops].sort((a, b) => `${a.from}|${a.to}`.localeCompare(`${b.from}|${b.to}`));
46
+ const inheritedLoss = inheritedLossProjection(root?.path || requestedPath, orderedNodes, orderedHops);
47
+ const rootLoss = root ? lossProjectionFor(root, lossFacts) : null;
48
+ const knownLoss = [rootLoss, ...inheritedLoss].filter((item) => item && item.state === 'known-irrecoverable');
49
+ const unresolvedLoss = [rootLoss, ...inheritedLoss].filter((item) => item && item.state === 'unresolved');
50
+ const terminalSources = orderedNodes.filter((node) => node.kind !== 'reduction' && !orderedHops.some((hop) => hop.from === node.path));
51
+ const unrecoverableTerminal = terminalSources.filter((node) => node.recovery?.qualified !== true);
52
+
53
+ if (unrecoverableTerminal.length) missingEvidence.push(issue('immutable-source-recovery-unresolved', unrecoverableTerminal.map((item) => item.path).join(', ')));
54
+ if (unresolvedLoss.length) ambiguities.push(issue('reduction-loss-unresolved', unresolvedLoss.map((item) => item.target).join(', ')));
55
+ if (nodes.size >= MAX_COMPOSITION_NODES) ambiguities.push(issue('composition-node-limit-reached', String(MAX_COMPOSITION_NODES)));
56
+
57
+ const state = blockers.length ? 'blocked'
58
+ : missingEvidence.length || ambiguities.length ? 'unresolved'
59
+ : knownLoss.length ? 'qualified-with-known-loss'
60
+ : rootQualification?.qualified ? 'qualified' : 'unresolved';
61
+ const expansionState = blockers.length ? 'blocked'
62
+ : missingEvidence.length || ambiguities.length ? 'unresolved'
63
+ : knownLoss.length ? 'known-loss'
64
+ : rootQualification?.qualified ? 'qualified-navigation' : 'unresolved';
65
+
66
+ for (const item of blockers) findings.push(portableFinding('error', `portable.reduction-composition.${safeCode(item.code)}`, item.detail, { ref: requestedPath }));
67
+ for (const item of missingEvidence) findings.push(portableFinding('warning', `portable.reduction-composition.${safeCode(item.code)}`, item.detail, { ref: requestedPath }));
68
+ for (const item of ambiguities) findings.push(portableFinding('warning', `portable.reduction-composition.${safeCode(item.code)}`, item.detail, { ref: requestedPath }));
69
+
70
+ const projection = Object.freeze({
71
+ schema: PORTABLE_REDUCTION_COMPOSITION_SCHEMA_ID,
72
+ state,
73
+ currentReduction: root ? Object.freeze({ ...identity(root), digest: sha256Text(root.markdown || ''), qualification: rootQualification }) : null,
74
+ immediateSources: Object.freeze(orderedHops.filter((hop) => hop.from === normalizePath(root?.path || requestedPath))),
75
+ hops: Object.freeze(orderedHops),
76
+ nodes: Object.freeze(orderedNodes),
77
+ carryForward: root ? Object.freeze({ local: sectionText(root.markdown || '', 'Carry-Forward State'), basis: 'exact-qualified-reduction-body-section' }) : null,
78
+ lossAndUncertainty: Object.freeze({ local: rootLoss, inherited: Object.freeze(inheritedLoss), knownIrrecoverable: Object.freeze(knownLoss), unresolved: Object.freeze(unresolvedLoss) }),
79
+ expansion: Object.freeze({
80
+ state: expansionState,
81
+ terminalSources: Object.freeze(terminalSources.map((item) => Object.freeze({ path: item.path, recovery: item.recovery }))),
82
+ knownLoss: Object.freeze(knownLoss),
83
+ ambiguities: Object.freeze(ambiguities),
84
+ missingEvidence: Object.freeze(missingEvidence),
85
+ boundary: 'Deterministic navigation follows explicit qualified Source Context/source-reference edges. It never reconstructs omitted bytes from a Reduction alone.'
86
+ }),
87
+ qualificationBasis: Object.freeze({ reduction: rootQualification, sourceEdges: 'explicit Source Context links or explicit qualified sourceReferences only', sourceQualification: 'each loaded source is independently audited; downstream qualification never repairs an upstream source' }),
88
+ blockers: Object.freeze(blockers),
89
+ missingEvidence: Object.freeze(missingEvidence),
90
+ ambiguities: Object.freeze(ambiguities),
91
+ fingerprint: sha256Text(stableJson({ root: root ? sha256Text(root.markdown || '') : '', hops: orderedHops.map((hop) => ({ from: hop.from, to: hop.to, relationQualification: hop.relationQualification })), nodes: orderedNodes.map((node) => ({ path: node.path, digest: node.digest, qualification: node.qualification?.state, recovery: node.recovery })) })),
92
+ boundary: Object.freeze({
93
+ adapterNeutral: true,
94
+ ordinaryReductionAuthorityOnly: true,
95
+ sourceMutation: false,
96
+ destructiveApplyAuthorized: false,
97
+ taskCompletionAuthority: false,
98
+ releaseReadinessAuthority: false,
99
+ placementIsNotSourceAuthority: true,
100
+ downstreamValidationRepairsUpstream: false
101
+ })
102
+ });
103
+ return Object.freeze({ ...projection, findings: Object.freeze(findings) });
104
+
105
+ function visitReduction(record, stack, depth) {
106
+ const recordPath = normalizePath(record.path || '');
107
+ if (depth >= MAX_COMPOSITION_NODES) return;
108
+ if (stack.includes(recordPath)) { ambiguities.push(issue('reduction-source-cycle', [...stack, recordPath].join(' -> '))); return; }
109
+ const qualification = qualifyReductionRecord(record, records);
110
+ const loss = lossProjectionFor(record, lossFacts);
111
+ const recovery = locatorForRecord(record, immutableSources);
112
+ putNode(record, 'reduction', qualification, recovery, loss);
113
+ if (!qualification.qualified) { missingEvidence.push(issue('upstream-reduction-unqualified', `${recordPath}: ${qualification.reasons.join(', ')}`)); return; }
114
+ const references = sourceReferencesFor(record, sourceReferences);
115
+ for (const reference of references) {
116
+ const targetPath = normalizePath(reference.path || linkPath(reference.target || ''));
117
+ const resolution = resolveUniqueRecord(records, targetPath);
118
+ if (resolution.state === 'ambiguous') { ambiguities.push(issue('immediate-source-ambiguous', `${recordPath} -> ${targetPath}`)); continue; }
119
+ if (!resolution.record) {
120
+ const locator = locatorFromValue(reference.target || reference.locator || reference);
121
+ if (!locator.qualified) { missingEvidence.push(issue('immediate-source-missing', `${recordPath} -> ${targetPath || reference.target || '(empty)'}`)); continue; }
122
+ const externalPath = normalizePath(locator.path);
123
+ putExternalNode(externalPath, locator, reference);
124
+ hops.push(hop(recordPath, externalPath, reference, 'material', 'qualified-external-immutable'));
125
+ continue;
126
+ }
127
+ const source = resolution.record;
128
+ const sourcePath = normalizePath(source.path || '');
129
+ const relationQualification = reference.qualification === 'unresolved' ? 'unresolved' : 'qualified';
130
+ if (relationQualification !== 'qualified') { ambiguities.push(issue('source-edge-unqualified', `${recordPath} -> ${sourcePath}`)); continue; }
131
+ const isReduction = String(source.schemaId || '') === 'tiinex.reduction.v1';
132
+ const qualificationResult = isReduction ? qualifyReductionRecord(source, records) : qualifyRecord(source);
133
+ const locator = locatorForRecord(source, immutableSources);
134
+ const sourceLoss = isReduction ? lossProjectionFor(source, lossFacts) : null;
135
+ putNode(source, isReduction ? 'reduction' : 'material', qualificationResult, locator, sourceLoss);
136
+ hops.push(hop(recordPath, sourcePath, reference, isReduction ? 'reduction' : 'material', qualificationResult.qualified ? 'qualified' : 'unresolved'));
137
+ if (!qualificationResult.qualified) {
138
+ missingEvidence.push(issue(isReduction ? 'upstream-reduction-unqualified' : 'immediate-source-unqualified', `${sourcePath}: ${(qualificationResult.reasons || []).join(', ')}`));
139
+ continue;
140
+ }
141
+ if (isReduction) visitReduction(source, [...stack, recordPath], depth + 1);
142
+ }
143
+ }
144
+
145
+ function putNode(record, kind, qualification, recovery, loss) {
146
+ const recordPath = normalizePath(record.path || '');
147
+ if (!recordPath || nodes.has(recordPath)) return;
148
+ nodes.set(recordPath, Object.freeze({
149
+ ...identity(record),
150
+ path: recordPath,
151
+ kind,
152
+ digest: sha256Text(record.markdown || ''),
153
+ qualification,
154
+ recovery,
155
+ carryForward: kind === 'reduction' ? sectionText(record.markdown || '', 'Carry-Forward State') : '',
156
+ lossAndUncertainty: kind === 'reduction' ? Object.freeze({ declared: sectionText(record.markdown || '', 'Loss And Uncertainty'), fact: loss }) : null
157
+ }));
158
+ }
159
+ function putExternalNode(externalPath, locator, reference) {
160
+ if (nodes.has(externalPath)) return;
161
+ nodes.set(externalPath, Object.freeze({ id: externalPath, path: externalPath, title: reference.label || externalPath, schemaId: '', kind: 'material', digest: locator.digest || '', qualification: Object.freeze({ state: 'qualified', qualified: true, reasons: Object.freeze([]) }), recovery: locator, carryForward: '', lossAndUncertainty: null }));
162
+ }
163
+ }
164
+
165
+ function sourceReferencesFor(record = {}, explicit = []) {
166
+ const recordPath = normalizePath(record.path || '');
167
+ const supplied = explicit.filter((item) => sameKey(item.from || item.reduction || item.currentReduction || '', recordPath));
168
+ const fromMarkdown = markdownLinks(sectionText(record.markdown || '', 'Source Context')).map((link) => Object.freeze({ ...link, from: recordPath, qualification: 'qualified', basis: 'explicit-qualified-reduction-source-context-link' }));
169
+ const merged = [...supplied, ...fromMarkdown];
170
+ const seen = new Set();
171
+ return merged.filter((item) => {
172
+ const key = `${normalizePath(item.path || linkPath(item.target || ''))}|${String(item.target || '')}`;
173
+ if (!key || seen.has(key)) return false;
174
+ seen.add(key); return true;
175
+ });
176
+ }
177
+
178
+ function normalizeSourceReferences(value) {
179
+ return normalizeList(value).map((item) => typeof item === 'string'
180
+ ? Object.freeze({ from: '', target: item, path: linkPath(item), qualification: 'unresolved', basis: '' })
181
+ : Object.freeze({
182
+ from: normalizePath(item.from || item.reduction || item.currentReduction || ''),
183
+ target: String(item.target || item.source || item.reference || item.path || ''),
184
+ path: normalizePath(item.path || linkPath(item.target || item.source || item.reference || '')),
185
+ label: String(item.label || ''),
186
+ qualification: String(item.qualification || item.semanticState || 'qualified'),
187
+ basis: item.basis || '',
188
+ locator: item.locator || null
189
+ }));
190
+ }
191
+
192
+ function lossProjectionFor(record = {}, facts = []) {
193
+ const target = normalizePath(record.path || '');
194
+ const matches = facts.filter((item) => sameKey(item.target || item.reduction || item.path || '', target));
195
+ const declared = sectionText(record.markdown || '', 'Loss And Uncertainty');
196
+ if (matches.length !== 1) return Object.freeze({ target, state: matches.length > 1 ? 'unresolved' : 'declared-unclassified', qualification: matches.length > 1 ? 'unresolved' : 'declared-only', detail: declared, basis: matches.length > 1 ? 'multiple normalized loss facts' : 'exact Reduction Loss And Uncertainty body retained without lexical interpretation' });
197
+ const fact = matches[0];
198
+ const state = String(fact.state || fact.lossState || 'unresolved');
199
+ const qualified = String(fact.qualification || fact.semanticState || '') === 'qualified' && nonEmptyBasis(fact.basis);
200
+ return Object.freeze({ target, state: qualified ? state : 'unresolved', qualification: qualified ? 'qualified' : 'unresolved', detail: String(fact.detail || declared), basis: fact.basis || '' });
201
+ }
202
+
203
+ function inheritedLossProjection(rootPath, nodes, hops) {
204
+ const descendants = new Set();
205
+ const queue = [normalizePath(rootPath)];
206
+ while (queue.length) {
207
+ const current = queue.shift();
208
+ for (const hop of hops.filter((item) => item.from === current)) {
209
+ if (descendants.has(hop.to)) continue;
210
+ descendants.add(hop.to); queue.push(hop.to);
211
+ }
212
+ }
213
+ return nodes.filter((node) => descendants.has(node.path) && node.kind === 'reduction' && node.lossAndUncertainty?.fact).map((node) => node.lossAndUncertainty.fact);
214
+ }
215
+
216
+ function hop(from, to, reference, kind, sourceQualification) {
217
+ return Object.freeze({
218
+ from: normalizePath(from), to: normalizePath(to), sourceKind: kind,
219
+ relationQualification: String(reference.qualification || 'qualified') === 'qualified' ? 'qualified' : 'unresolved',
220
+ sourceQualification,
221
+ basis: reference.basis || 'explicit qualified Source Context link',
222
+ target: String(reference.target || reference.path || '')
223
+ });
224
+ }
225
+
226
+ function issue(code, detail) { return Object.freeze({ code: String(code), detail: String(detail || '') }); }
227
+ function normalizeList(value) { return Array.isArray(value) ? value : value && typeof value === 'object' ? Object.entries(value).map(([target, item]) => typeof item === 'object' && item !== null ? ({ target, ...item }) : ({ target, state: item })) : []; }
228
+ function sameKey(a, b) { const left = normalizePath(a); const right = normalizePath(b); return Boolean(left && right && (left === right || left.endsWith(`/${right}`) || right.endsWith(`/${left}`))); }
229
+ function nonEmptyBasis(value) { return Array.isArray(value) ? value.length > 0 : typeof value === 'string' ? Boolean(value.trim()) : Boolean(value && typeof value === 'object' && Object.keys(value).length); }
@@ -0,0 +1,258 @@
1
+ import { inferRecordMaterialRole, isDiscoveryWorkLeafEligible, MaterialRole } from '../../../workspaces/workspace.materialRole.js';
2
+ import {
3
+ PORTABLE_REDUCTION_DESTRUCTIVE_CONTRACT, identity,
4
+ locatorForRecord, locatorFromValue, normalizePath, resolveUniqueRecord, samePath, sha256Text, stableJson
5
+ } from './reduction.shared.js';
6
+
7
+ const FIXTURE_RE = /(^|\/)(?:fixtures?|test-fixtures?|__fixtures__)(\/|$)|\.fixture\./i;
8
+ const SHA256_RE = /^[0-9a-f]{64}$/i;
9
+ const GIT_COMMIT_RE = /^[0-9a-f]{40}$/i;
10
+ const CLEAR_CURRENTNESS = new Set(['closed', 'resolved', 'historical-closed', 'superseded-resolved']);
11
+ const OPERATIVE_CURRENTNESS = new Set(['operative', 'open', 'active', 'blocked', 'incomplete', 'disputed']);
12
+
13
+ export function assessCandidateIdentity(candidate, records, immutableSources, snapshots) {
14
+ const resolution = resolveUniqueRecord(records, candidate.path);
15
+ const record = resolution.record;
16
+ const classification = classifyCandidate(candidate, record);
17
+ let repository = candidate.repository;
18
+ let workspace = candidate.workspace;
19
+ let locator = record ? locatorForRecord(record, immutableSources) : locatorFromValue(candidate.immutableSource || {});
20
+ if (!locator.qualified && record && candidate.repository) {
21
+ const snapshot = snapshots.find((item) => item.qualified && item.repository === candidate.repository && (!candidate.workspace || item.workspace === candidate.workspace));
22
+ if (snapshot?.commit) locator = locatorFromValue({ repository: candidate.repository, commit: snapshot.commit, workspace: candidate.workspace, path: record.path, immutable: true, basis: 'candidate identity plus exact bound snapshot' });
23
+ }
24
+ if (!repository && locator.qualified) repository = locator.repository;
25
+ if (!workspace && locator.qualified) workspace = locator.workspace;
26
+ const actualDigest = record ? sha256Text(record.markdown || '') : '';
27
+ const expectedDigest = String(candidate.expectedDigest || '').replace(/^sha256:/, '').toLowerCase();
28
+ const preimage = !expectedDigest ? Object.freeze({ state: 'not-supplied', expectedDigest: '', actualDigest })
29
+ : !record ? Object.freeze({ state: 'unresolved', expectedDigest, actualDigest: '' })
30
+ : expectedDigest === actualDigest ? Object.freeze({ state: 'matched', expectedDigest, actualDigest })
31
+ : Object.freeze({ state: 'mismatch', expectedDigest, actualDigest });
32
+ return Object.freeze({ ...candidate, repository, workspace, identityState: resolution.state, record: record ? identity(record) : null, classification, immutableLocator: locator, preimage });
33
+ }
34
+
35
+ function classifyCandidate(candidate, record) {
36
+ const explicitKind = String(candidate.classification || candidate.kind || '').toLowerCase();
37
+ const explicitQualified = String(candidate.classificationQualification || candidate.qualification || '') === 'qualified' && nonEmptyBasis(candidate.classificationBasis || candidate.basis);
38
+ const fixture = candidate.fixture === true || candidate.fixtureRequired === true || FIXTURE_RE.test(candidate.path);
39
+ const inferredSemantic = Boolean(record && isDiscoveryWorkLeafEligible(record));
40
+ if (explicitKind) {
41
+ if (!explicitQualified) return Object.freeze({ state: 'unresolved', kind: explicitKind, basis: 'explicit classification is not qualified' });
42
+ if (record && explicitKind === 'semantic' && !inferredSemantic) return Object.freeze({ state: 'unresolved', kind: explicitKind, basis: 'explicit semantic classification conflicts with loaded material role' });
43
+ if (record && explicitKind === 'fixture' && !fixture) return Object.freeze({ state: 'unresolved', kind: explicitKind, basis: 'explicit fixture classification conflicts with loaded material' });
44
+ return Object.freeze({ state: 'qualified', kind: explicitKind === 'transport' ? 'transport' : explicitKind === 'fixture' ? 'fixture' : explicitKind === 'semantic' ? 'semantic' : 'nonsemantic', basis: candidate.classificationBasis || candidate.basis });
45
+ }
46
+ if (fixture) return Object.freeze({ state: 'qualified', kind: 'fixture', basis: 'declared fixture flag/path classification' });
47
+ if (inferredSemantic) return Object.freeze({ state: 'qualified', kind: 'semantic', basis: 'loaded qualified semantic-work material role' });
48
+ if (record) {
49
+ const role = inferRecordMaterialRole(record);
50
+ if ([MaterialRole.schemaDefinition, MaterialRole.supporting, MaterialRole.workspaceArtifact].includes(role)) return Object.freeze({ state: 'qualified', kind: 'nonsemantic', basis: `loaded material role:${role}` });
51
+ }
52
+ return Object.freeze({ state: 'unresolved', kind: 'unknown', basis: 'semantic/transport/fixture classification is unresolved' });
53
+ }
54
+
55
+ export function parentGraph(records, lineage, proofs) {
56
+ const byId = new Map(records.map((record) => [String(record.id || record.path || ''), record]));
57
+ const parentsByChild = new Map();
58
+ for (const edge of lineage.edges || []) {
59
+ if (edge.kind !== 'parent' || edge.status !== 'verified' || !edge.from || !edge.to) continue;
60
+ const parent = byId.get(String(edge.from)); const child = byId.get(String(edge.to));
61
+ if (!parent || !child) continue;
62
+ addParentEdge(parentsByChild, normalizePath(child.path), Object.freeze({ child: normalizePath(child.path), parent: normalizePath(parent.path), state: 'qualified', basis: 'verified loaded declared Parent edge', source: 'loaded-lineage' }));
63
+ }
64
+ for (const proof of proofs) if (proof.qualified) addParentEdge(parentsByChild, proof.child, Object.freeze({ child: proof.child, parent: proof.parent, state: 'qualified', basis: proof.basis, source: 'explicit-qualified-parent-proof' }));
65
+ return Object.freeze({ parentsByChild });
66
+ }
67
+
68
+ function addParentEdge(map, child, edge) { const list = map.get(child) || []; list.push(edge); map.set(child, list); }
69
+ export function hasDisappearingChild(record, graph, disappearingPaths) {
70
+ const parentPath = normalizePath(record.path || '');
71
+ for (const [child, edges] of graph.parentsByChild.entries()) if (disappearingPaths.has(child) && edges.some((edge) => samePath(edge.parent, parentPath))) return true;
72
+ return false;
73
+ }
74
+
75
+ export function proveParentClosure({ leaf, boundaryPath, graph, disappearingPaths, records, sourceLocators, endpointProofs, snapshots }) {
76
+ const start = normalizePath(leaf.path || ''); const boundary = normalizePath(boundaryPath || '');
77
+ if (!boundary) return unresolvedProof('historical-closure-endpoint-required');
78
+ if (disappearingPaths.has(boundary)) return blockedProof('closure-endpoint-does-not-survive');
79
+ const pathItems = [start]; const seen = new Set([start]); let current = start;
80
+ while (!samePath(current, boundary)) {
81
+ const edges = (graph.parentsByChild.get(current) || []).filter((edge) => edge.state === 'qualified');
82
+ const distinct = uniqueBy(edges, (edge) => normalizePath(edge.parent));
83
+ if (!distinct.length) return unresolvedProof('parent-hop-missing-or-unqualified', pathItems);
84
+ if (distinct.length > 1) return ambiguousProof('parent-hop-ambiguous', pathItems);
85
+ const parent = normalizePath(distinct[0].parent);
86
+ if (!parent || seen.has(parent)) return ambiguousProof('parent-closure-cycle-or-ambiguity', pathItems);
87
+ pathItems.push(parent); seen.add(parent);
88
+ if (!samePath(parent, boundary) && !disappearingPaths.has(parent)) return blockedProof('closure-endpoint-not-nearest-surviving-boundary', pathItems);
89
+ current = parent;
90
+ if (pathItems.length > 128) return ambiguousProof('parent-closure-limit-reached', pathItems);
91
+ }
92
+ const locatorItems = [];
93
+ for (const itemPath of pathItems) {
94
+ const record = resolveUniqueRecord(records, itemPath).record;
95
+ let locator = record ? locatorForRecord(record, sourceLocators) : locatorForExternal(itemPath, sourceLocators, endpointProofs);
96
+ if (!locator.qualified) return unresolvedProof('parent-hop-immutable-source-unresolved', pathItems);
97
+ const snapshotMatches = snapshots.filter((snapshot) => snapshot.qualified && snapshotMatchesScope(snapshot, locator));
98
+ if (!snapshotMatches.length) return unresolvedProof('parent-hop-snapshot-unresolved', pathItems);
99
+ if (snapshotMatches.length > 1) return ambiguousProof('parent-hop-snapshot-ambiguous', pathItems);
100
+ if (snapshotMatches[0].commit && locator.commit && snapshotMatches[0].commit !== locator.commit) return unresolvedProof('parent-hop-snapshot-ref-mismatch', pathItems);
101
+ locatorItems.push(locator);
102
+ }
103
+ const repositories = [...new Set(locatorItems.map((item) => item.repository).filter(Boolean))];
104
+ return Object.freeze({ state: 'qualified', qualified: true, code: '', path: Object.freeze(pathItems), locators: Object.freeze(locatorItems), repositories: Object.freeze(repositories), crossRepository: repositories.length > 1, nearestSurvivingBoundary: boundary });
105
+ }
106
+
107
+ function locatorForExternal(itemPath, sources, endpoints) {
108
+ const source = sources.find((item) => samePath(item.path || item.target || '', itemPath));
109
+ if (source) return locatorFromValue(source);
110
+ const endpoint = endpoints.find((item) => samePath(item.path || item.target || '', itemPath));
111
+ return endpoint ? locatorFromValue(endpoint.locator || endpoint) : locatorFromValue({});
112
+ }
113
+ function unresolvedProof(code, pathItems = []) { return Object.freeze({ state: 'unresolved', qualified: false, code, path: Object.freeze([...pathItems]), locators: Object.freeze([]), repositories: Object.freeze([]), crossRepository: false }); }
114
+ function ambiguousProof(code, pathItems = []) { return Object.freeze({ state: 'ambiguous', qualified: false, code, path: Object.freeze([...pathItems]), locators: Object.freeze([]), repositories: Object.freeze([]), crossRepository: false }); }
115
+ function blockedProof(code, pathItems = []) { return Object.freeze({ state: 'blocked', qualified: false, code, path: Object.freeze([...pathItems]), locators: Object.freeze([]), repositories: Object.freeze([]), crossRepository: false }); }
116
+
117
+ export function assessCurrentness(candidate, facts, records, disappearingPaths, blockers, missingEvidence, ambiguities) {
118
+ const target = normalizePath(candidate.currentnessTarget || candidate.path || candidate.record?.path || '');
119
+ const matches = facts.filter((fact) => samePath(fact.target || fact.path || fact.obligation || '', target));
120
+ if (!matches.length) { missingEvidence.push(issue('currentness-evidence-missing', target)); return; }
121
+ if (matches.length > 1) { ambiguities.push(issue('currentness-evidence-ambiguous', target)); return; }
122
+ const fact = matches[0];
123
+ const qualified = String(fact.qualification || fact.semanticState || '') === 'qualified' && String(fact.currentness || '') === 'current' && nonEmptyBasis(fact.basis);
124
+ if (!qualified) { ambiguities.push(issue('currentness-evidence-unqualified', target)); return; }
125
+ const state = String(fact.state || fact.operativeState || '').toLowerCase();
126
+ if (CLEAR_CURRENTNESS.has(state)) return;
127
+ if (OPERATIVE_CURRENTNESS.has(state)) {
128
+ const reissue = normalizeReissue(fact.reissue || fact.retainedReissue || {});
129
+ if (!reissue.qualified) { blockers.push(issue('operative-obligation-disappearing', target)); return; }
130
+ const surviving = resolveUniqueRecord(records, reissue.survivingArtifact).record;
131
+ if (!surviving || disappearingPaths.has(normalizePath(surviving.path))) { blockers.push(issue('operative-obligation-reissue-not-surviving', target)); return; }
132
+ return;
133
+ }
134
+ ambiguities.push(issue('currentness-state-unresolved', target));
135
+ }
136
+
137
+ export function assessSurvivingDependencies(records, graph, disappearingPaths, currentnessFacts, blockers, ambiguities) {
138
+ for (const record of records) {
139
+ const recordPath = normalizePath(record.path || '');
140
+ if (disappearingPaths.has(recordPath) || !isDiscoveryWorkLeafEligible(record)) continue;
141
+ const parents = graph.parentsByChild.get(recordPath) || [];
142
+ const disappearingParents = parents.filter((edge) => disappearingPaths.has(normalizePath(edge.parent)));
143
+ if (!disappearingParents.length) continue;
144
+ const fact = currentnessFacts.find((item) => samePath(item.target || item.path || '', recordPath));
145
+ const reissue = normalizeReissue(fact?.reissue || {});
146
+ if (!reissue.qualified) blockers.push(issue('surviving-material-parent-depends-on-disappearing-material', recordPath));
147
+ else if (!nonEmptyBasis(reissue.basis)) ambiguities.push(issue('surviving-material-reissue-basis-unresolved', recordPath));
148
+ }
149
+ }
150
+
151
+ export function currentnessReissueFor(target, facts) { const fact = facts.find((item) => samePath(item.target || item.path || '', target)); return normalizeReissue(fact?.reissue || {}); }
152
+ function normalizeReissue(value = {}) {
153
+ const qualified = String(value.qualification || value.semanticState || '') === 'qualified' && nonEmptyBasis(value.basis) && Boolean(value.survivingArtifact || value.target) && Boolean(value.mapping || value.obligationMapping);
154
+ return Object.freeze({ qualified, state: qualified ? 'qualified' : 'unresolved', survivingArtifact: normalizePath(value.survivingArtifact || value.target || ''), mapping: String(value.mapping || value.obligationMapping || ''), basis: value.basis || '' });
155
+ }
156
+
157
+ export function immutableLocatorForLeaf(record, entry, sources) {
158
+ const fromEntry = locatorFromValue(entry.leafTarget || '');
159
+ if (fromEntry.qualified && samePath(fromEntry.path, record.path)) return fromEntry;
160
+ return locatorForRecord(record, sources);
161
+ }
162
+
163
+ export function proofSnapshotScopes(candidates, leafProofs) {
164
+ const scopes = [];
165
+ for (const candidate of candidates) if (candidate.immutableLocator?.qualified) scopes.push(candidate.immutableLocator);
166
+ for (const proof of leafProofs) for (const locator of proof.parentSpan?.locators || []) scopes.push(locator);
167
+ return uniqueBy(scopes.filter((item) => item.repository || item.workspace), (item) => `${item.repository}|${item.workspace}|${item.commit}`);
168
+ }
169
+ export function snapshotMatchesScope(snapshot, scope) { return Boolean((scope.repository && snapshot.repository === scope.repository) || (scope.workspace && snapshot.workspace === scope.workspace)); }
170
+ export function scopeLabel(scope) { return `${scope.repository || '(no-repository)'}${scope.workspace ? `/${scope.workspace}` : ''}${scope.commit ? `@${scope.commit}` : ''}`; }
171
+
172
+ export function normalizeCandidateSet(value) {
173
+ const list = Array.isArray(value) ? value : typeof value === 'string' ? value.split(',') : value && typeof value === 'object' ? Object.entries(value).map(([candidatePath, item]) => typeof item === 'object' && item !== null ? ({ candidatePath, ...item }) : ({ candidatePath, action: item })) : [];
174
+ return Object.freeze(list.map((item) => typeof item === 'string'
175
+ ? Object.freeze({ path: normalizePath(item), action: 'delete', repository: '', workspace: '', expectedDigest: '', classification: '', classificationQualification: '', classificationBasis: '', basis: '', fixture: false, fixtureRequired: false, currentnessTarget: '', immutableSource: null })
176
+ : Object.freeze({
177
+ path: normalizePath(item.path || item.candidatePath || item.candidate || item.artifact || ''),
178
+ action: String(item.action || item.destructiveAction || 'delete').toLowerCase(),
179
+ repository: String(item.repository || item.repo || ''),
180
+ workspace: String(item.workspace || item.workspaceId || ''),
181
+ expectedDigest: String(item.expectedDigest || item.preimageDigest || item.sha256 || ''),
182
+ classification: String(item.classification || item.kind || ''),
183
+ classificationQualification: String(item.classificationQualification || item.qualification || ''),
184
+ classificationBasis: item.classificationBasis || item.basis || '',
185
+ basis: item.basis || '',
186
+ fixture: item.fixture === true,
187
+ fixtureRequired: item.fixtureRequired === true,
188
+ currentnessTarget: normalizePath(item.currentnessTarget || item.obligation || ''),
189
+ immutableSource: item.immutableSource || item.locator || null
190
+ })).filter((item) => item.path));
191
+ }
192
+
193
+ export function normalizeSnapshots(value) {
194
+ return Object.freeze(normalizeList(value).map((item) => {
195
+ const repository = String(item.repository || item.repo || '');
196
+ const workspace = String(item.workspace || item.workspaceId || '');
197
+ const commit = String(item.commit || item.sha || item.ref || '').toLowerCase();
198
+ const manifestDigest = String(item.manifestDigest || item.contentDigest || item.sha256 || '').replace(/^sha256:/, '').toLowerCase();
199
+ const localState = item.localState === true || item.uncommitted === true;
200
+ const qualified = Boolean((repository && GIT_COMMIT_RE.test(commit) || workspace && SHA256_RE.test(manifestDigest)) && (!localState || SHA256_RE.test(manifestDigest)) && String(item.qualification || item.semanticState || 'qualified') === 'qualified');
201
+ return Object.freeze({ repository, workspace, commit, manifestDigest, localState, qualified, state: qualified ? 'qualified' : 'unresolved', basis: item.basis || '' });
202
+ }));
203
+ }
204
+
205
+ export function normalizeParentProofs(value) {
206
+ return Object.freeze(normalizeList(value).map((item) => {
207
+ const childLocator = locatorFromValue(item.childLocator || item.childSource || {});
208
+ const parentLocator = locatorFromValue(item.parentLocator || item.parentSource || {});
209
+ const child = normalizePath(item.child || childLocator.path || '');
210
+ const parent = normalizePath(item.parent || parentLocator.path || '');
211
+ const qualified = String(item.kind || 'parent') === 'parent' && String(item.qualification || item.semanticState || '') === 'qualified' && nonEmptyBasis(item.basis) && child && parent && childLocator.qualified && parentLocator.qualified;
212
+ return Object.freeze({ child, parent, childLocator, parentLocator, qualified, basis: item.basis || '' });
213
+ }));
214
+ }
215
+
216
+ export function normalizeContract(value) {
217
+ const raw = typeof value === 'string' ? { id: value, version: 1 } : value || {};
218
+ const id = String(raw.id || PORTABLE_REDUCTION_DESTRUCTIVE_CONTRACT.id);
219
+ const version = Number(raw.version || PORTABLE_REDUCTION_DESTRUCTIVE_CONTRACT.version);
220
+ const qualified = id === PORTABLE_REDUCTION_DESTRUCTIVE_CONTRACT.id && version === PORTABLE_REDUCTION_DESTRUCTIVE_CONTRACT.version;
221
+ return Object.freeze({ id, version, qualified, bound: Object.freeze({ id, version, implementation: 'shared-portable-tooling', canonicalSchemaAuthorityChanged: false }) });
222
+ }
223
+
224
+ export function fixtureRetired(candidate, values) {
225
+ const matches = normalizeList(values).filter((item) => samePath(item.target || item.path || '', candidate.path));
226
+ return matches.length === 1 && String(matches[0].qualification || matches[0].semanticState || '') === 'qualified' && String(matches[0].state || '') === 'retired' && nonEmptyBasis(matches[0].basis);
227
+ }
228
+
229
+ export function boundCandidate(candidate) { return Object.freeze({ path: candidate.path, action: candidate.action, repository: candidate.repository || candidate.immutableLocator?.repository || '', workspace: candidate.workspace || candidate.immutableLocator?.workspace || '', expectedDigest: String(candidate.expectedDigest || '').replace(/^sha256:/, '').toLowerCase(), classification: candidate.classification.kind, currentnessTarget: candidate.currentnessTarget || candidate.path }); }
230
+ export function boundSnapshot(snapshot) { return Object.freeze({ repository: snapshot.repository, workspace: snapshot.workspace, commit: snapshot.commit, manifestDigest: snapshot.manifestDigest, localState: snapshot.localState, qualified: snapshot.qualified }); }
231
+ export function boundCurrentnessFact(fact) { return Object.freeze({ target: normalizePath(fact.target || fact.path || fact.obligation || ''), state: String(fact.state || fact.operativeState || ''), currentness: String(fact.currentness || ''), qualification: String(fact.qualification || fact.semanticState || ''), basis: compactBasis(fact.basis), reissue: normalizeReissue(fact.reissue || {}) }); }
232
+ export function boundParentProof(proof) { return Object.freeze({ child: proof.child, parent: proof.parent, qualified: proof.qualified, childLocator: boundLocator(proof.childLocator), parentLocator: boundLocator(proof.parentLocator) }); }
233
+ export function boundLocator(locator) { const value = locatorFromValue(locator); return Object.freeze({ repository: value.repository, commit: value.commit, workspace: value.workspace, path: value.path, digest: value.digest, qualified: value.qualified }); }
234
+ export function priorReceiptFingerprint(value = {}) { return String(value?.receipt?.inputFingerprint || value?.inputFingerprint || value?.boundInputFingerprint || ''); }
235
+
236
+ export function projectPostApply(value, candidateSetDigest) {
237
+ if (!value) return Object.freeze({ state: 'not-requested', expectedCandidateSetDigest: candidateSetDigest, actualCandidateSetDigest: '', sourceMutation: false, boundary: 'Simulation only; no source mutation is performed.' });
238
+ const actual = normalizeCandidateSet(value.actualCandidateSet || value.candidateSet || value.actualCandidates || []);
239
+ const actualDigest = sha256Text(stableJson(actual.map((item) => ({ path: item.path, action: item.action, repository: item.repository, workspace: item.workspace, expectedDigest: String(item.expectedDigest || '').replace(/^sha256:/, '').toLowerCase(), classification: item.classification }))));
240
+ return Object.freeze({ state: actualDigest === candidateSetDigest ? 'matched' : 'mismatch', expectedCandidateSetDigest: candidateSetDigest, actualCandidateSetDigest: actualDigest, sourceMutation: false, boundary: 'Separately simulated post-apply comparison only. It cannot repair a missing pre-delete qualification and performs no mutation.' });
241
+ }
242
+
243
+ export function sharedClosureMaterial(proofs) {
244
+ const items = new Map();
245
+ for (const proof of proofs) for (let index = 1; index < (proof.parentSpan?.path || []).length; index += 1) {
246
+ const itemPath = normalizePath(proof.parentSpan.path[index]);
247
+ if (!items.has(itemPath)) items.set(itemPath, Object.freeze({ path: itemPath, reachableFrom: [] }));
248
+ items.get(itemPath).reachableFrom.push(normalizePath(proof.leaf.path));
249
+ }
250
+ return [...items.values()].map((item) => Object.freeze({ path: item.path, reachableFrom: Object.freeze([...new Set(item.reachableFrom)].sort()) })).sort((a, b) => a.path.localeCompare(b.path));
251
+ }
252
+
253
+ export function normalizeList(value) { return Array.isArray(value) ? value : value && typeof value === 'object' ? Object.entries(value).map(([target, item]) => typeof item === 'object' && item !== null ? ({ target, ...item }) : ({ target, state: item })) : []; }
254
+ function nonEmptyBasis(value) { return Array.isArray(value) ? value.length > 0 : typeof value === 'string' ? Boolean(value.trim()) : Boolean(value && typeof value === 'object' && Object.keys(value).length); }
255
+ function compactBasis(value) { return typeof value === 'string' ? value.slice(0, 720) : Array.isArray(value) ? value.slice(0, 8) : value && typeof value === 'object' ? value : null; }
256
+ function uniqueBy(values, keyFn) { const seen = new Set(); return values.filter((value) => { const key = keyFn(value); if (seen.has(key)) return false; seen.add(key); return true; }); }
257
+ export function uniqueIssues(values) { return uniqueBy(values, (item) => `${item.code}|${item.detail}`); }
258
+ export function issue(code, detail) { return Object.freeze({ code: String(code), detail: String(detail || '') }); }