@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,321 @@
1
+ import { finalizeFile } from '../../../export/package.fileMap.js';
2
+ import { packageFileBytes } from '../../../export/package.bytes.js';
3
+ import { exportFileMapZipUint8Array } from '../../../export/package.zip.js';
4
+ import { inspectStoredWorkspaceArchive } from './workspaceByteProvider.js';
5
+ import { renderRecipientV2ExternalPayload, renderRecipientV2Pointer } from './recipientV2.artifacts.js';
6
+ import { inspectRecipientFacingV2Topology } from './recipientV2.inspect.js';
7
+ import { buildRecipientV2TransportManifestFile } from './recipientV2.transportManifest.js';
8
+ import { buildPhase1WorkspaceCarriers } from './recipientV2.artifactFirst.workspaces.js';
9
+ import { buildPhase1RolePointers } from './recipientV2.artifactFirst.roles.js';
10
+ import { deriveRecipientV2ArtifactFirstPhase1Facts } from './recipientV2.artifactFirst.materials.js';
11
+ import { inspectRecipientV2ArtifactFirstPhase1Specimen } from './recipientV2.artifactFirst.inspect.js';
12
+ import { RECIPIENT_V2_READ_PATH, RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID, RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_SCHEMA_ID, RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_FORMAT_ID, RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_SCHEMA_ID, PHASE2_CLEAN_PROFILE, PHASE2_COMPATIBILITY_TRANSPORT, PHASE1_BOOTSTRAP_ROLE, PHASE1_CACHE_ROLE, normalizeRoutePath, cacheMaterialBelongsToRoute, sortedQualifiedCarrierRoutes, selectOne, oneFile, repathFinalizedFile, phase1RoutePointerPath, phase1RolePathPrefix, blocked, finding, deepFreeze } from './recipientV2.artifactFirst.shared.js';
13
+
14
+ export function buildRecipientV2ArtifactFirstPhase1Specimen(input = {}) {
15
+ const cleanCarrierPhase2 = input.cleanCarrierPhase2 === true;
16
+ const formatId = cleanCarrierPhase2 ? RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_FORMAT_ID : RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID;
17
+ const resultSchemaId = cleanCarrierPhase2 ? RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_SCHEMA_ID : RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_SCHEMA_ID;
18
+ const sourceBundle = input.bundle || {};
19
+ const sourceInspection = input.inspection || inspectRecipientFacingV2Topology(sourceBundle);
20
+ const findings = [];
21
+ if (sourceInspection.status !== 'valid') return blocked('source-recipient-unqualified', sourceInspection.findings || []);
22
+
23
+ const workspace = selectOne(sourceInspection.workspaces || [], input.workspaceId, 'workspace', findings);
24
+ if (!workspace) return blocked('workspace-selection-blocked', findings);
25
+ const routes = (sourceInspection.routes || []).filter((item) => String(item.workspaceId || '') === String(workspace.workspaceId || ''));
26
+ const route = selectOne(routes, input.routePath || '', 'route', findings, (item) => String(item.workspaceRelativeHandoffPath || ''));
27
+ if (!route) return blocked('route-selection-blocked', findings);
28
+
29
+ const sourceCarrierRoute = (sourceInspection.carrierProjection?.routes || []).find((item) => String(item.workspaceId || '') === String(workspace.workspaceId || '') && String(item.workspaceRelativePath || '') === String(route.workspaceRelativeHandoffPath || '')) || null;
30
+ const sourceRouteInspection = (sourceInspection.routes || []).find((item) => String(item.workspaceId || '') === String(workspace.workspaceId || '') && String(item.workspaceRelativeHandoffPath || '') === String(route.workspaceRelativeHandoffPath || '')) || null;
31
+ const sourceFactsByPath = new Map((sourceInspection.artifactFacts || []).map((item) => [String(item.path || ''), item.facts || null]));
32
+ const selectedRouteId = String(input.routeSelection?.route?.id || sourceCarrierRoute?.id || `handoff-route:${String(workspace.workspaceId || '')}:${String(route.workspaceRelativeHandoffPath || '')}`);
33
+ const routeSelection = Object.freeze({
34
+ mode: String(input.routeSelection?.mode || 'implicit-single-qualified-route'),
35
+ selector: String(input.routeSelection?.selector || ''),
36
+ candidateCount: Number(input.routeSelection?.candidateCount || 1),
37
+ selectedRouteId
38
+ });
39
+ const lineage = sourceInspection.carrierProjection?.lineage || {};
40
+ const createdAt = input.createdAt || sourceBundle.manifest?.createdAt || sourceBundle.builtAt || '1970-01-01T00:00:00.000Z';
41
+ const workspaceId = String(workspace.workspaceId || 'workspace');
42
+ const workspaceBuild = buildPhase1WorkspaceCarriers({
43
+ sourceInspection,
44
+ sourceBundle,
45
+ selectedWorkspaceId: workspaceId,
46
+ createdAt
47
+ });
48
+ if (workspaceBuild.state !== 'qualified') return blocked('workspace-carriage-blocked', workspaceBuild.findings || []);
49
+ const workspaceCarriers = [...workspaceBuild.carriers];
50
+ const selectedWorkspaceCarrier = workspaceCarriers.find((item) => item.selected) || null;
51
+ if (!selectedWorkspaceCarrier) return blocked('workspace-selection-blocked', [finding('error', 'portable.handoff-v2-phase1.workspace.selection', 'Selected route Workspace has no artifact-first carrier representation.', { workspaceId })]);
52
+ const { archivePath, payloadArtifactPath, relationArtifactPath, archiveFile, payloadArtifact, relationArtifact } = selectedWorkspaceCarrier;
53
+ const sourceCarrierRoutes = sortedQualifiedCarrierRoutes(sourceInspection.carrierProjection?.routes || [], selectedRouteId);
54
+ const routePlans = sourceCarrierRoutes.map((carrierRoute, index) => {
55
+ const routeWorkspaceId = String(carrierRoute.workspaceId || '');
56
+ const workspaceRelativeHandoffPath = String(carrierRoute.workspaceRelativePath || '');
57
+ const routeId = String(carrierRoute.id || `handoff-route:${routeWorkspaceId}:${workspaceRelativeHandoffPath}`);
58
+ const sourceRoute = (sourceInspection.routes || []).find((item) => String(item.workspaceId || '') === routeWorkspaceId && normalizeRoutePath(item.workspaceRelativeHandoffPath || '') === normalizeRoutePath(workspaceRelativeHandoffPath)) || null;
59
+ const workspaceCarrier = workspaceCarriers.find((item) => String(item.workspaceId || '') === routeWorkspaceId) || null;
60
+ return Object.freeze({
61
+ routeId,
62
+ carrierRoute,
63
+ sourceRoute,
64
+ workspaceCarrier,
65
+ workspaceId: routeWorkspaceId,
66
+ workspaceRelativeHandoffPath,
67
+ pointerPath: phase1RoutePointerPath(carrierRoute, index, sourceCarrierRoutes.length, selectedRouteId),
68
+ rolePathPrefix: phase1RolePathPrefix(carrierRoute, index, sourceCarrierRoutes.length, selectedRouteId)
69
+ });
70
+ });
71
+ const unresolvedRoutePlans = routePlans.filter((plan) => !plan.sourceRoute || !plan.workspaceCarrier);
72
+ if (!routePlans.length || unresolvedRoutePlans.length) return blocked('shared-route-source-unresolved', [finding('error', 'portable.handoff-v2-phase1.shared-route.source-unresolved', 'Every qualified source route must resolve one exact source route inspection and one carried Workspace payload.', { routeCount: routePlans.length, unresolvedRouteIds: unresolvedRoutePlans.map((item) => item.routeId) })]);
73
+ const selectedRoutePlan = routePlans.find((plan) => plan.routeId === selectedRouteId) || null;
74
+ if (!selectedRoutePlan) return blocked('route-selection-blocked', [finding('error', 'portable.handoff-v2-phase1.route-selection.binding-unresolved', 'Selected artifact-first route must remain one exact member of the carried shared route set.', { selectedRouteId })]);
75
+
76
+ const bootstrapSourcePath = String(input.bootstrap?.payloadPath || '');
77
+ const bootstrapSource = bootstrapSourcePath ? oneFile(sourceBundle.files || [], bootstrapSourcePath) : null;
78
+ if (bootstrapSourcePath && !bootstrapSource) return blocked('bootstrap-payload-unresolved', [finding('error', 'portable.handoff-v2-phase1.bootstrap.source-unresolved', 'Carried portable Tooling bootstrap payload is unavailable in the qualified source carrier.', { path: bootstrapSourcePath })]);
79
+ const bootstrapArchivePath = bootstrapSource ? '001-2-bootstrap.zip' : '';
80
+ const bootstrapArtifactPath = bootstrapSource ? '001-2-bootstrap.trace.md' : '';
81
+ const bootstrapArchiveFile = bootstrapSource ? repathFinalizedFile(bootstrapSource, bootstrapArchivePath, {
82
+ kind: 'handoff-tooling-bootstrap-archive',
83
+ logicalKind: 'recipient-v2-phase1-tooling-bootstrap-payload',
84
+ mediaType: 'application/zip',
85
+ boundary: 'Exact portable Tooling bootstrap bytes owned by one visible External Payload artifact; navigation and package placement create no Parent or package authority.'
86
+ }) : null;
87
+ const bootstrapArtifact = bootstrapArchiveFile ? finalizeFile({
88
+ path: bootstrapArtifactPath,
89
+ kind: 'tiinex-external-payload-artifact',
90
+ logicalKind: 'recipient-v2-phase1-tooling-bootstrap-reference',
91
+ mediaType: 'text/markdown',
92
+ content: renderRecipientV2ExternalPayload({
93
+ artifactFirst: true,
94
+ createdAt,
95
+ title: 'Portable Tooling Bootstrap Payload',
96
+ summary: 'Artifact-first Phase 1 exact portable Tooling bootstrap payload.',
97
+ label: 'portable Tooling bootstrap runtime',
98
+ kind: 'zip export',
99
+ role: PHASE1_BOOTSTRAP_ROLE,
100
+ location: bootstrapArchivePath,
101
+ bytes: bootstrapArchiveFile.bytes,
102
+ sha256: bootstrapArchiveFile.sha256
103
+ })
104
+ }) : null;
105
+
106
+ const sourceCache = (sourceInspection.caches || []).find((item) => String(item.workspaceId || '') === workspaceId) || null;
107
+ const selectedCacheMaterials = sourceCache ? (sourceCache.materials || []).filter((item) => cacheMaterialBelongsToRoute(item, workspaceId, route.workspaceRelativeHandoffPath)) : [];
108
+ const siblingDetachedMaterials = routePlans
109
+ .filter((plan) => plan.routeId !== selectedRouteId)
110
+ .flatMap((plan) => (sourceInspection.caches || []).flatMap((cache) => (cache.materials || []).filter((item) => cacheMaterialBelongsToRoute(item, plan.workspaceId, plan.workspaceRelativeHandoffPath))));
111
+ if (siblingDetachedMaterials.length) return blocked('shared-route-detached-cache-unsupported', [finding('error', 'portable.handoff-v2-phase1.shared-route.detached-cache-unsupported', 'Shared artifact-first carriage currently supports detached cache material only for the explicitly selected route; sibling routes must resolve closure from carried Workspace source.', { count: siblingDetachedMaterials.length })]);
112
+ let cacheArtifact = null;
113
+ let cacheArchiveFile = null;
114
+ let cacheProjection = null;
115
+ if (selectedCacheMaterials.length) {
116
+ const sourceCacheArchive = oneFile(sourceBundle.files || [], sourceCache.archivePath);
117
+ if (!sourceCacheArchive) return blocked('cache-source-unresolved', [finding('error', 'portable.handoff-v2-phase1.cache.source-unresolved', 'Selected-route detached cache archive is unavailable in the qualified source carrier.', { path: sourceCache.archivePath })]);
118
+ const sourceCacheInspection = inspectStoredWorkspaceArchive(packageFileBytes(sourceCacheArchive), { ownedBytes: true });
119
+ if (sourceCacheInspection.state !== 'qualified') return blocked('cache-source-invalid', [finding('error', 'portable.handoff-v2-phase1.cache.source-invalid', 'Selected-route detached cache archive did not independently qualify.', { path: sourceCache.archivePath, findings: sourceCacheInspection.findings || [] })]);
120
+ const selectedEntries = [];
121
+ const materialBindings = [];
122
+ for (const material of selectedCacheMaterials) {
123
+ const archiveEntry = String(material.archiveEntry || '');
124
+ const matches = sourceCacheInspection.entries.filter((entry) => String(entry.path || '') === archiveEntry);
125
+ if (matches.length !== 1) return blocked('cache-material-unresolved', [finding('error', 'portable.handoff-v2-phase1.cache.material-unresolved', 'Selected-route cache material must resolve exactly one source cache entry.', { requirementId: String(material.requirementId || ''), referenceTarget: String(material.referenceTarget || ''), archiveEntry, count: matches.length })]);
126
+ selectedEntries.push({ path: archiveEntry, data: matches[0].data });
127
+ materialBindings.push(Object.freeze({ requirementId: String(material.requirementId || ''), classification: String(material.classification || ''), referenceTarget: String(material.referenceTarget || ''), archiveEntry }));
128
+ }
129
+ const cacheArchivePath = '001-5-cache.zip';
130
+ const cacheArtifactPath = '001-5-cache.trace.md';
131
+ cacheArchiveFile = finalizeFile({
132
+ path: cacheArchivePath,
133
+ kind: 'handoff-material-cache',
134
+ logicalKind: 'recipient-v2-phase1-workspace-dependency-cache',
135
+ mediaType: 'application/zip',
136
+ data: exportFileMapZipUint8Array(selectedEntries, 'portable.handoff-v2-phase1.cache.path.invalid'),
137
+ boundary: 'Exact selected-route detached dependency bytes owned by the visible cache External Payload artifact. Cache location and compatibility JSON are not semantic authority.'
138
+ });
139
+ cacheArtifact = finalizeFile({
140
+ path: cacheArtifactPath,
141
+ kind: 'tiinex-external-payload-artifact',
142
+ logicalKind: 'recipient-v2-phase1-workspace-dependency-cache-reference',
143
+ mediaType: 'text/markdown',
144
+ content: renderRecipientV2ExternalPayload({
145
+ artifactFirst: true,
146
+ createdAt,
147
+ workspaceId,
148
+ title: `Workspace Dependency Cache — ${workspaceId}`,
149
+ summary: 'Artifact-first Phase 1 exact selected-route dependency bytes absent from the qualified Workspace payload.',
150
+ label: `${workspaceId} selected-route Handoff dependency cache`,
151
+ kind: 'zip export',
152
+ role: PHASE1_CACHE_ROLE,
153
+ location: cacheArchivePath,
154
+ bytes: cacheArchiveFile.bytes,
155
+ sha256: cacheArchiveFile.sha256,
156
+ materials: materialBindings
157
+ })
158
+ });
159
+ cacheProjection = Object.freeze({ workspaceId, artifactPath: cacheArtifactPath, archivePath: cacheArchivePath, materials: Object.freeze(materialBindings) });
160
+ }
161
+
162
+ const endpointRoleArtifacts = [];
163
+ const participantRoleArtifacts = [];
164
+ const endpointRoleProjections = [];
165
+ const participantRoleProjections = [];
166
+ const routePointers = [];
167
+ const routeTopology = [];
168
+ for (const plan of routePlans) {
169
+ const ownsSelectedCache = plan.routeId === selectedRouteId;
170
+ const endpointRoleBuild = buildPhase1RolePointers({
171
+ kind: 'endpoint',
172
+ sourcePointerPaths: plan.sourceRoute?.endpointRolePointers || [],
173
+ sourceFactsByPath,
174
+ workspaceCarriers,
175
+ cacheArtifact: ownsSelectedCache ? cacheArtifact : null,
176
+ selectedCacheMaterials: ownsSelectedCache ? selectedCacheMaterials : [],
177
+ routeWorkspaceId: plan.workspaceId,
178
+ selectedRouteId: plan.routeId,
179
+ pathPrefix: plan.rolePathPrefix,
180
+ createdAt
181
+ });
182
+ const participantRoleBuild = buildPhase1RolePointers({
183
+ kind: 'participant',
184
+ sourcePointerPaths: plan.sourceRoute?.participantRolePointers || [],
185
+ sourceFactsByPath,
186
+ workspaceCarriers,
187
+ cacheArtifact: ownsSelectedCache ? cacheArtifact : null,
188
+ selectedCacheMaterials: ownsSelectedCache ? selectedCacheMaterials : [],
189
+ routeWorkspaceId: plan.workspaceId,
190
+ selectedRouteId: plan.routeId,
191
+ pathPrefix: plan.rolePathPrefix,
192
+ createdAt
193
+ });
194
+ const roleBuildFindings = [...endpointRoleBuild.findings, ...participantRoleBuild.findings];
195
+ if (roleBuildFindings.some((item) => item.severity === 'error')) return blocked('role-pointer-build-blocked', roleBuildFindings);
196
+ endpointRoleArtifacts.push(...endpointRoleBuild.artifacts);
197
+ participantRoleArtifacts.push(...participantRoleBuild.artifacts);
198
+ endpointRoleProjections.push(...endpointRoleBuild.projections);
199
+ participantRoleProjections.push(...participantRoleBuild.projections);
200
+ const routePointer = finalizeFile({
201
+ path: plan.pointerPath,
202
+ kind: 'handoff-route-pointer',
203
+ logicalKind: 'recipient-v2-phase1-handoff-route-pointer',
204
+ mediaType: 'text/markdown',
205
+ content: renderRecipientV2Pointer({
206
+ artifactFirst: true,
207
+ createdAt,
208
+ role: 'handoff-route',
209
+ title: `Handoff Route Pointer — ${plan.workspaceId}`,
210
+ summary: 'Artifact-first navigation pointer to one exact Handoff path inside an explicitly owned Workspace payload.',
211
+ prose: 'This Pointer identifies navigation coordinates only. The exact Handoff artifact inside the Workspace payload remains the Handoff authority.',
212
+ currentRead: [
213
+ { label: 'Workspace Id', value: `\`${plan.workspaceId}\`` },
214
+ { label: 'Workspace Payload', value: `[payload](${plan.workspaceCarrier.payloadArtifactPath})` },
215
+ { label: 'Handoff Workspace Path', value: `\`${plan.workspaceRelativeHandoffPath}\`` },
216
+ { label: 'Route Id', value: `\`${plan.routeId}\`` }
217
+ ],
218
+ destinations: [
219
+ { label: 'Workspace payload artifact', target: plan.workspaceCarrier.payloadArtifactPath },
220
+ ...endpointRoleBuild.artifacts.map((item) => ({ label: 'Endpoint Role pointer', target: item.path })),
221
+ ...participantRoleBuild.artifacts.map((item) => ({ label: 'Participant Role pointer', target: item.path }))
222
+ ]
223
+ })
224
+ });
225
+ routePointers.push(routePointer);
226
+ routeTopology.push(Object.freeze({ pointerPath: plan.pointerPath, workspaceId: plan.workspaceId, workspaceRelativeHandoffPath: plan.workspaceRelativeHandoffPath, routeId: plan.routeId, endpointRolePointers: Object.freeze(endpointRoleBuild.projections.map((item) => item.pointerPath)), participantRolePointers: Object.freeze(participantRoleBuild.projections.map((item) => item.pointerPath)) }));
227
+ }
228
+ const selectedRoutePointerPath = selectedRoutePlan.pointerPath;
229
+
230
+ const ingressCurrentRead = [
231
+ { label: 'Workspace Id', value: `\`${workspaceId}\`` },
232
+ { label: 'Workspace Payload', value: `[payload](${payloadArtifactPath})` },
233
+ ...(cleanCarrierPhase2 ? [
234
+ { label: 'Carrier Profile', value: PHASE2_CLEAN_PROFILE },
235
+ { label: 'Compatibility Transport', value: PHASE2_COMPATIBILITY_TRANSPORT }
236
+ ] : []),
237
+ { label: 'Route Selection', value: routeSelection.mode },
238
+ { label: 'Selected Route Id', value: `\`${selectedRouteId}\`` },
239
+ { label: 'Candidate Route Count', value: `\`${routeSelection.candidateCount}\`` },
240
+ ...(lineage.dimension ? [{ label: 'Carrier Dimension', value: `\`${String(lineage.dimension)}\`` }] : []),
241
+ ...(lineage.parentDimension ? [{ label: 'Parent Carrier Dimension', value: `\`${String(lineage.parentDimension)}\`` }] : []),
242
+ ...(lineage.checkpointKind ? [{ label: 'Carrier Checkpoint', value: String(lineage.checkpointKind) }] : [])
243
+ ];
244
+ const ingressPointer = finalizeFile({
245
+ path: RECIPIENT_V2_READ_PATH,
246
+ kind: 'handoff-recovery-pointer',
247
+ logicalKind: 'recipient-v2-phase1-ingress-pointer',
248
+ mediaType: 'text/markdown',
249
+ content: renderRecipientV2Pointer({
250
+ artifactFirst: true,
251
+ createdAt,
252
+ role: 'recovery-orientation',
253
+ title: cleanCarrierPhase2 ? 'READ BEFORE PROCEEDING — Artifact-First Clean Carrier Phase 2' : 'READ BEFORE PROCEEDING — Artifact-First Phase 1 Specimen',
254
+ summary: cleanCarrierPhase2 ? 'Single ingress Pointer for the bounded artifact-first recipient-v2 clean-carrier specimen.' : 'Single ingress Pointer for the bounded artifact-first recipient-v2 specimen.',
255
+ prose: cleanCarrierPhase2 ? 'Use the visible semantic artifacts and exact payload bytes for receiver meaning. This clean-carrier profile intentionally omits stored compatibility JSON; no receiver truth may be reconstructed from its absence.' : 'Use the visible semantic artifacts and exact payload bytes for receiver meaning. Compatibility JSON is a derived projection only.',
256
+ currentRead: ingressCurrentRead,
257
+ destinations: [
258
+ ...(bootstrapArtifact ? [{ label: 'Portable Tooling bootstrap payload', target: bootstrapArtifactPath }] : []),
259
+ ...workspaceCarriers.map((item) => ({ label: `${item.workspaceId} Workspace payload`, target: item.payloadArtifactPath })),
260
+ ...(cacheArtifact ? [{ label: 'Selected-route dependency cache payload', target: cacheArtifact.path }] : []),
261
+ ...workspaceCarriers.map((item) => ({ label: `${item.workspaceId} Workspace material representation`, target: item.relationArtifactPath })),
262
+ ...endpointRoleArtifacts.map((item) => ({ label: 'Endpoint Role pointer', target: item.path })),
263
+ ...participantRoleArtifacts.map((item) => ({ label: 'Participant Role pointer', target: item.path })),
264
+ ...routePointers.map((item) => ({ label: 'Handoff route', target: item.path }))
265
+ ]
266
+ })
267
+ });
268
+
269
+ const workspaceFiles = workspaceCarriers.flatMap((item) => [item.payloadArtifact, item.archiveFile, item.relationArtifact]);
270
+ const semanticFiles = Object.freeze([ingressPointer, ...(bootstrapArtifact && bootstrapArchiveFile ? [bootstrapArtifact, bootstrapArchiveFile] : []), ...workspaceFiles, ...(cacheArtifact && cacheArchiveFile ? [cacheArtifact, cacheArchiveFile] : []), ...endpointRoleArtifacts, ...participantRoleArtifacts, ...routePointers]);
271
+ const factsByPath = deriveRecipientV2ArtifactFirstPhase1Facts(semanticFiles);
272
+ const manifestInputs = semanticFiles.map((file) => {
273
+ const facts = factsByPath.get(String(file.path || '')) || null;
274
+ return facts ? Object.freeze({ ...file, transportFacts: facts }) : file;
275
+ });
276
+ const transportManifest = cleanCarrierPhase2 ? null : buildRecipientV2TransportManifestFile(manifestInputs, {
277
+ format: RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID,
278
+ packageRootPath: RECIPIENT_V2_READ_PATH,
279
+ entryArtifactPath: RECIPIENT_V2_READ_PATH
280
+ });
281
+ const files = Object.freeze([...semanticFiles, ...(transportManifest ? [transportManifest] : [])].sort((a, b) => String(a.path || '').localeCompare(String(b.path || ''))));
282
+ const inspection = inspectRecipientV2ArtifactFirstPhase1Specimen({ files });
283
+ const topology = deepFreeze({
284
+ root: null,
285
+ read: Object.freeze({ path: RECIPIENT_V2_READ_PATH, sha256: ingressPointer.sha256 }),
286
+ workspaces: Object.freeze(workspaceCarriers.map((item) => Object.freeze({
287
+ workspaceId: item.workspaceId,
288
+ workspacePath: '',
289
+ payloadArtifactPath: item.payloadArtifactPath,
290
+ representationArtifactPath: item.relationArtifactPath,
291
+ archivePath: item.archivePath,
292
+ archiveSha256: item.archiveFile.sha256,
293
+ sourceWorkspaceTargetInnerPath: String(item.workspace.sourceWorkspaceTargetInnerPath || ''),
294
+ sourceWorkspaceTargetSha256: String(item.workspace.sourceWorkspaceTargetSha256 || '')
295
+ }))),
296
+ caches: Object.freeze(cacheProjection ? [cacheProjection] : []),
297
+ endpointRoles: Object.freeze(endpointRoleProjections),
298
+ participantRoles: Object.freeze(participantRoleProjections),
299
+ routes: Object.freeze(routeTopology),
300
+ bootstrap: bootstrapArtifact && bootstrapArchiveFile ? Object.freeze({ artifactPath: bootstrapArtifactPath, payloadPath: bootstrapArchivePath, payloadSha256: bootstrapArchiveFile.sha256, payloadBytes: bootstrapArchiveFile.bytes }) : null,
301
+ transportManifest: transportManifest ? Object.freeze({ path: transportManifest.path, sha256: transportManifest.sha256 }) : null
302
+ });
303
+ return deepFreeze({
304
+ schema: resultSchemaId,
305
+ format: formatId,
306
+ cleanCarrierPhase2,
307
+ status: inspection.status === 'ready' ? 'ready' : 'blocked',
308
+ files,
309
+ topology,
310
+ workspaceId,
311
+ routePath: String(route.workspaceRelativeHandoffPath || ''),
312
+ routePointerPath: selectedRoutePointerPath,
313
+ routeSelection,
314
+ semanticFactsByPath: factsByPath,
315
+ inspection,
316
+ findings: inspection.findings,
317
+ boundary: cleanCarrierPhase2
318
+ ? 'Phase 2 clean-carrier qualification specimen only. Receiver truth is visible Pointer + External Payload + typed non-Parent Relation + exact payload bytes; stored compatibility JSON is intentionally absent and cannot be recreated as hidden authority.'
319
+ : 'Phase 1 dual projection specimen only. Receiver semantic authority is visible Pointer + External Payload + typed non-Parent Relation + exact payload bytes; compatibility JSON is derived and remains required only for Phase 1 interoperability.'
320
+ });
321
+ }
@@ -0,0 +1,126 @@
1
+ import { packageFileBytes, sha256Hex } from '../../../export/package.bytes.js';
2
+ import { validatedC14nV2PrimarySelfDigest } from '../../../integrity/integrity.c14nV2.js';
3
+ import { projectHandoffMaterialRequirements } from './materialClosure.requirements.js';
4
+ import { deepFreeze, finding, normalizeRoutePath, sectionText, fieldValue, decodeUtf8 } from './recipientV2.artifactFirst.shared.js';
5
+ import { parseWorkspaceQualifiedReference } from './workspaceQualifiedReference.js';
6
+
7
+ export function qualifyRecipientV2ArtifactFirstPhase1RequiredContextClosure(input = {}) {
8
+ return qualifyPhase1RequiredContextClosure(input);
9
+ }
10
+
11
+ export function qualifyPhase1RequiredContextClosure({ markdown = '', routePath = '', workspaceId = '', archivePath = '', entries = [], workspaceArchives = [], caches = [] } = {}) {
12
+ const projected = projectHandoffMaterialRequirements({ path: routePath, markdown });
13
+ const findings = [];
14
+ const requirements = (projected.required || []).map((requirement) => {
15
+ const target = String(requirement.reference?.target || '').trim();
16
+ const reasons = [];
17
+ let resolution = null;
18
+ if (!target || target.startsWith('#') || !requirement.reference?.exactTargetDeclared) reasons.push('exact-required-material-reference-unresolved');
19
+ else if (parseWorkspaceQualifiedReference(target)) {
20
+ const qualified = parseWorkspaceQualifiedReference(target);
21
+ const candidates = (workspaceArchives || []).filter((item) => String(item.workspaceId || '') === qualified.workspaceId);
22
+ if (candidates.length !== 1) reasons.push(candidates.length > 1 ? 'required-workspace-qualified-ambiguous' : 'required-workspace-qualified-workspace-missing');
23
+ else {
24
+ const candidate = candidates[0];
25
+ const matches = (candidate.entries || []).filter((entry) => String(entry.path || '') === qualified.path);
26
+ if (matches.length > 1) reasons.push('required-workspace-qualified-entry-ambiguous');
27
+ else if (matches.length < 1) reasons.push('required-workspace-qualified-entry-missing');
28
+ else {
29
+ const entry = matches[0];
30
+ const data = packageFileBytes({ data: entry.data });
31
+ const digest = sha256Hex(data);
32
+ if (Number(entry.bytes || 0) !== data.byteLength || String(entry.sha256 || '') !== digest) reasons.push('required-workspace-qualified-byte-mismatch');
33
+ else resolution = deepFreeze({ state: 'qualified', kind: 'workspace-archive-entry', workspaceId: qualified.workspaceId, workspaceRelativePath: qualified.path, providerMode: 'archive', packagePath: String(candidate.archivePath || ''), archivePackagePath: String(candidate.archivePath || ''), innerPath: qualified.path, bytes: data.byteLength, sha256: digest });
34
+ }
35
+ }
36
+ }
37
+ else if (/^[a-z][a-z0-9+.-]*:/i.test(target) || target.startsWith('//')) {
38
+ const matches = caches.flatMap((cache) => (cache?.state === 'qualified' ? (cache.materials || []).filter((material) => String(material.referenceTarget || '') === target && (!requirement.id || String(material.requirementId || '') === String(requirement.id || ''))).map((material) => ({ cache, material })) : []));
39
+ if (matches.length > 1) reasons.push('required-cache-material-ambiguous');
40
+ else if (matches.length < 1) reasons.push('required-cache-material-missing');
41
+ else {
42
+ const { cache, material } = matches[0];
43
+ if (!material.sha256 || !material.bytes) reasons.push('required-cache-material-byte-identity-unresolved');
44
+ else resolution = deepFreeze({ state: 'qualified', kind: 'workspace-cache-entry', workspaceId: String(cache.workspaceId || workspaceId || ''), workspaceRelativePath: '', providerMode: 'cache', packagePath: String(cache.payloadPath || ''), archivePackagePath: String(cache.payloadPath || ''), innerPath: String(material.archiveEntry || ''), archiveEntry: String(material.archiveEntry || ''), bytes: Number(material.bytes || 0), sha256: String(material.sha256 || '') });
45
+ }
46
+ }
47
+ else {
48
+ const resolvedPath = resolveRelativeWorkspacePath(routePath, target);
49
+ if (!resolvedPath) reasons.push('workspace-reference-outside-or-invalid');
50
+ else {
51
+ const matches = entries.filter((entry) => String(entry.path || '') === resolvedPath);
52
+ if (matches.length > 1) reasons.push('required-workspace-entry-ambiguous');
53
+ else if (matches.length < 1) reasons.push('required-workspace-entry-missing');
54
+ else {
55
+ const entry = matches[0];
56
+ const data = packageFileBytes({ data: entry.data });
57
+ const digest = sha256Hex(data);
58
+ if (Number(entry.bytes || 0) !== data.byteLength || String(entry.sha256 || '') !== digest) reasons.push('required-workspace-package-byte-mismatch');
59
+ else resolution = deepFreeze({ state: 'qualified', kind: 'workspace-archive-entry', workspaceId: String(workspaceId || ''), workspaceRelativePath: resolvedPath, providerMode: 'archive', packagePath: String(archivePath || ''), archivePackagePath: String(archivePath || ''), innerPath: resolvedPath, bytes: data.byteLength, sha256: digest });
60
+ }
61
+ }
62
+ }
63
+ const state = reasons.length || !resolution ? 'blocked' : 'qualified';
64
+ if (state !== 'qualified') findings.push(finding('error', `portable.handoff-v2-phase1.required-context.${reasons[0] || 'unresolved'}`, 'Required Context must resolve to one exact inner artifact carried by the selected Workspace payload or qualified selected-route cache; compatibility JSON cannot supply missing receiver truth.', { requirementId: String(requirement.id || ''), name: String(requirement.name || ''), referenceTarget: target, reasons: Object.freeze([...new Set(reasons)]) }));
65
+ return deepFreeze({ requirementId: String(requirement.id || ''), name: String(requirement.name || ''), referenceTarget: target, state, resolution: state === 'qualified' ? resolution : null, reasons: Object.freeze([...new Set(reasons)]) });
66
+ });
67
+ const qualifiedCount = requirements.filter((entry) => entry.state === 'qualified').length;
68
+ return deepFreeze({ state: qualifiedCount === requirements.length ? 'qualified' : 'blocked', requiredCount: requirements.length, qualifiedCount, requirements: Object.freeze(requirements), findings: Object.freeze(findings), boundary: 'Artifact-first Phase 1 Required Context closure. Every Required Context item must resolve to exact inner bytes of the selected qualified Workspace, an explicitly workspace-qualified already-carried Workspace, or qualified selected-route cache; Reference Context and compatibility JSON are intentionally excluded from blocking receiver truth.' });
69
+ }
70
+
71
+ export function resolveArchiveParent(routePath = '', entries = [], parent = {}, targetEntry = {}, parentCandidates = []) {
72
+ const refs = [String(parent.trace || ''), ...(parent.originEntries || []).map((item) => String(item.target || '')), String(targetEntry.towards || '')].filter(Boolean);
73
+ for (const ref of refs) {
74
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(ref)) continue;
75
+ const resolved = resolveRelativeWorkspacePath(routePath, ref);
76
+ if (!resolved) continue;
77
+ const matches = entries.filter((entry) => String(entry.path || '') === resolved);
78
+ if (matches.length === 1) return Object.freeze({ state: 'qualified', markdown: decodeUtf8(matches[0].data), basis: 'artifact-first-workspace-archive', workspaceRelativePath: resolved, sha256: String(matches[0].sha256 || '') });
79
+ }
80
+ const expectedDigest = String(targetEntry?.value || '').trim();
81
+ if (!expectedDigest) return Object.freeze({ state: 'unresolved', reason: 'parent-target-digest-missing' });
82
+ const digestMatches = new Map();
83
+ for (const candidate of parentCandidates || []) {
84
+ const data = packageFileBytes({ data: candidate.data });
85
+ if (!data.byteLength) continue;
86
+ if (Number(candidate.bytes || data.byteLength) !== data.byteLength || (candidate.sha256 && String(candidate.sha256) !== sha256Hex(data))) continue;
87
+ const markdown = decodeUtf8(data);
88
+ if (!markdown) continue;
89
+ const self = validatedC14nV2PrimarySelfDigest(markdown);
90
+ if (self.state !== 'verified' || self.value !== expectedDigest) continue;
91
+ const key = `${String(candidate.workspaceId || '')}\u0000${String(candidate.workspaceRelativePath || '')}\u0000${String(candidate.archiveEntry || '')}`;
92
+ digestMatches.set(key, Object.freeze({ state: 'qualified', markdown, basis: 'artifact-first-detached-parent-target-digest-candidate', workspaceRelativePath: String(candidate.workspaceRelativePath || ''), archiveEntry: String(candidate.archiveEntry || ''), sha256: sha256Hex(data) }));
93
+ }
94
+ if (digestMatches.size === 1) return [...digestMatches.values()][0];
95
+ if (digestMatches.size > 1) return Object.freeze({ state: 'ambiguous', reason: 'multiple-parent-target-digest-candidates' });
96
+ return Object.freeze({ state: 'unresolved', reason: 'parent-entry-unresolved' });
97
+ }
98
+
99
+ export function phase1CacheParentCandidates(cacheQualifications = []) {
100
+ const candidates = [];
101
+ for (const cache of cacheQualifications || []) {
102
+ if (cache?.state !== 'qualified' || cache.archive?.state !== 'qualified') continue;
103
+ for (const material of cache.materials || []) {
104
+ if (String(material.classification || '') !== 'parent-boundary') continue;
105
+ const matches = (cache.archive.entries || []).filter((entry) => String(entry.path || '') === String(material.archiveEntry || ''));
106
+ if (matches.length !== 1) continue;
107
+ const entry = matches[0];
108
+ const data = packageFileBytes({ data: entry.data });
109
+ if (Number(material.bytes || 0) !== data.byteLength || String(material.sha256 || '') !== sha256Hex(data)) continue;
110
+ candidates.push(Object.freeze({ workspaceId: String(cache.workspaceId || ''), workspaceRelativePath: normalizeRoutePath(material.referenceTarget || ''), archiveEntry: String(material.archiveEntry || ''), bytes: data.byteLength, sha256: sha256Hex(data), data }));
111
+ }
112
+ }
113
+ return Object.freeze(candidates);
114
+ }
115
+
116
+ export function resolveRelativeWorkspacePath(fromPath = '', ref = '') {
117
+ const value = String(ref || '').split('#')[0].replace(/\\/g, '/');
118
+ if (!value || value.startsWith('/') || /^[A-Za-z]:\//.test(value)) return '';
119
+ const base = String(fromPath || '').replace(/\\/g, '/').split('/'); base.pop();
120
+ const parts = value.startsWith('./') || value.startsWith('../') ? [...base, ...value.split('/')] : [...base, ...value.split('/')];
121
+ const out = [];
122
+ for (const part of parts) { if (!part || part === '.') continue; if (part === '..') { if (!out.length) return ''; out.pop(); } else out.push(part); }
123
+ return out.join('/');
124
+ }
125
+
126
+ export function parseHandoffParties(markdown = '') { const section = sectionText(markdown, 'Handoff Parties'); return Object.freeze({ from: fieldValue(section, 'From'), to: fieldValue(section, 'To') }); }