@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,166 @@
1
+ import { finalizeFile } from '../../../export/package.fileMap.js';
2
+ import { packageFileBytes, sha256Hex } from '../../../export/package.bytes.js';
3
+ import { renderRecipientV2Pointer } from './recipientV2.artifacts.js';
4
+
5
+ export function buildPhase1RolePointers(input = {}) {
6
+ const kind = input.kind === 'endpoint' ? 'endpoint' : 'participant';
7
+ const expectedRole = `${kind}-role`;
8
+ const artifacts = [];
9
+ const projections = [];
10
+ const findings = [];
11
+ const workspaceById = new Map((input.workspaceCarriers || []).map((item) => [String(item.workspaceId || ''), item]));
12
+ for (const [index, sourcePointerPath] of [...(input.sourcePointerPaths || [])].entries()) {
13
+ const facts = input.sourceFactsByPath?.get(String(sourcePointerPath || '')) || null;
14
+ if (!facts || String(facts.role || '') !== expectedRole) {
15
+ findings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.source-unresolved`, `Selected-route ${kind} Role Pointer transport facts are unavailable in the qualified source carrier.`, { path: String(sourcePointerPath || '') }));
16
+ continue;
17
+ }
18
+ const targetCarrierKind = String(facts.targetCarrierKind || '');
19
+ const targetWorkspaceId = String(facts.targetWorkspaceId || '');
20
+ const workspaceCarrier = targetCarrierKind === 'workspace-archive-entry' ? workspaceById.get(targetWorkspaceId) || null : null;
21
+ const targetPayload = workspaceCarrier ? workspaceCarrier.payloadArtifactPath : targetCarrierKind === 'workspace-cache-entry' ? String(input.cacheArtifact?.path || '') : '';
22
+ if (!targetPayload) {
23
+ findings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.target-unresolved`, `Selected-route ${kind} Role target must resolve to an explicit carried Workspace or cache External Payload artifact.`, { path: String(sourcePointerPath || ''), targetCarrierKind, targetWorkspaceId }));
24
+ continue;
25
+ }
26
+ if (targetCarrierKind === 'workspace-cache-entry' && !(input.selectedCacheMaterials || []).some((item) => String(item.archiveEntry || '') === String(facts.targetArchiveEntry || ''))) {
27
+ findings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.cache-material-unresolved`, `${kind} Role cache target is not owned by the selected-route cache External Payload.`, { path: String(sourcePointerPath || ''), targetArchiveEntry: String(facts.targetArchiveEntry || '') }));
28
+ continue;
29
+ }
30
+ const roleLabel = String(facts.roleLabelHint || `${kind}-role`);
31
+ const pathPrefix = String(input.pathPrefix || '001-6').replace(/-+$/g, '') || '001-6';
32
+ const pointerPath = `${pathPrefix}-${kind === 'endpoint' ? 'e' : 'p'}-${index + 1}-${safeToken(roleLabel)}-role-pointer.trace.md`;
33
+ const requirementId = String(kind === 'endpoint' ? facts.endpointRequirementId : facts.participantRequirementId || '');
34
+ const currentRead = [
35
+ { label: 'Workspace Id', value: `\`${String(input.routeWorkspaceId || '')}\`` },
36
+ { label: 'Route Id', value: `\`${String(input.selectedRouteId || '')}\`` },
37
+ ...(kind === 'endpoint' ? [
38
+ { label: 'Endpoint Requirement Id', value: `\`${requirementId}\`` },
39
+ { label: 'Endpoint Party', value: String(facts.endpointParty || '') }
40
+ ] : [{ label: 'Participant Requirement Id', value: `\`${requirementId}\`` }]),
41
+ ...(facts.roleLabelHint ? [{ label: 'Role Label Hint', value: String(facts.roleLabelHint) }] : []),
42
+ { label: 'Role Reference', value: `\`${String(facts.referenceTarget || '')}\`` },
43
+ { label: 'Target Carrier Kind', value: targetCarrierKind },
44
+ { label: 'Target Payload', value: `[payload](${targetPayload})` },
45
+ ...(targetCarrierKind === 'workspace-archive-entry' ? [
46
+ { label: 'Target Workspace Id', value: `\`${targetWorkspaceId}\`` },
47
+ { label: 'Target Inner Path', value: `\`${String(facts.targetInnerPath || '')}\`` }
48
+ ] : []),
49
+ ...(targetCarrierKind === 'workspace-cache-entry' ? [{ label: 'Target Archive Entry', value: `\`${String(facts.targetArchiveEntry || '')}\`` }] : [])
50
+ ];
51
+ const pointer = finalizeFile({
52
+ path: pointerPath,
53
+ kind: `${kind}-role-pointer`,
54
+ logicalKind: `recipient-v2-phase1-${kind}-role-pointer`,
55
+ mediaType: 'text/markdown',
56
+ content: renderRecipientV2Pointer({
57
+ artifactFirst: true,
58
+ createdAt: input.createdAt,
59
+ role: expectedRole,
60
+ title: `${kind === 'endpoint' ? 'Endpoint' : 'Participant'} Role Pointer — ${roleLabel}`,
61
+ summary: `Artifact-first Pointer to one exact ${kind} Role artifact carried by an explicit Workspace or cache External Payload.`,
62
+ prose: kind === 'endpoint'
63
+ ? 'This Pointer grounds one exact Handoff From/To Role endpoint. It does not prove a human holder, consent, Handoff acceptance, or Role authority beyond the referenced Role artifact.'
64
+ : 'This Pointer contributes one additional participant Role to interaction grounding. It does not change Handoff From/To, prove a human holder, or create Role authority.',
65
+ currentRead,
66
+ destinations: [{ label: `Exact ${kind} Role payload owner`, target: targetPayload }]
67
+ })
68
+ });
69
+ artifacts.push(pointer);
70
+ projections.push(Object.freeze({
71
+ pointerPath,
72
+ workspaceId: String(input.routeWorkspaceId || ''),
73
+ routeId: String(input.selectedRouteId || ''),
74
+ requirementId,
75
+ ...(kind === 'endpoint' ? { endpointParty: String(facts.endpointParty || '') } : {}),
76
+ roleLabelHint: String(facts.roleLabelHint || ''),
77
+ referenceTarget: String(facts.referenceTarget || ''),
78
+ targetCarrierKind,
79
+ targetWorkspaceId,
80
+ targetInnerPath: String(facts.targetInnerPath || facts.targetArchiveEntry || ''),
81
+ targetSha256: String(facts.targetSha256 || '')
82
+ }));
83
+ }
84
+ return Object.freeze({ artifacts: Object.freeze(artifacts), projections: Object.freeze(projections), findings: Object.freeze(findings) });
85
+ }
86
+
87
+ export function qualifyPhase1RolePointer(pointer = null, context = {}, findings = []) {
88
+ const kind = context.kind === 'endpoint' ? 'endpoint' : 'participant';
89
+ const parsed = pointer?.parsed || {};
90
+ const localFindings = [];
91
+ const targetCarrierKind = String(parsed.targetCarrierKind || '');
92
+ if (String(parsed.workspaceId || '') !== String(context.routeWorkspaceId || '') || String(parsed.routeId || '') !== String(context.routeId || '')) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.route-binding-mismatch`, `${kind} Role Pointer must visibly bind the selected route Workspace and route id.`, { path: String(pointer?.path || '') }));
93
+ if (!['workspace-archive-entry', 'workspace-cache-entry'].includes(targetCarrierKind)) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.target-carrier-invalid`, `${kind} Role Pointer target carrier must be an explicit Workspace or selected-route cache payload.`, { path: String(pointer?.path || ''), targetCarrierKind }));
94
+ const targetPayload = String(parsed.targetPayload || '');
95
+ let targetArchive = null;
96
+ let archivePath = '';
97
+ let targetPath = '';
98
+ let targetWorkspaceId = String(parsed.targetWorkspaceId || '');
99
+ if (targetCarrierKind === 'workspace-archive-entry') {
100
+ const workspace = context.workspaceQualifications?.get(targetWorkspaceId) || null;
101
+ if (!workspace) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.workspace-unresolved`, `${kind} Role Pointer target Workspace is not carried as a qualified artifact-first Workspace payload.`, { targetWorkspaceId }));
102
+ else {
103
+ if (targetPayload !== String(workspace.payload?.path || '')) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.workspace-payload-mismatch`, `${kind} Role Pointer must target the explicit External Payload for its target Workspace.`, { targetWorkspaceId }));
104
+ targetArchive = workspace.archive;
105
+ archivePath = String(workspace.payload?.parsed?.location || '');
106
+ targetPath = String(parsed.targetInnerPath || '');
107
+ }
108
+ } else if (targetCarrierKind === 'workspace-cache-entry') {
109
+ const cacheIndex = (context.cachePayloads || []).findIndex((item) => String(item.path || '') === targetPayload);
110
+ if (cacheIndex < 0) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.cache-payload-unresolved`, `${kind} Role Pointer must target the explicit selected-route cache External Payload.`, { targetPayload }));
111
+ else {
112
+ const cacheQualification = context.cacheQualifications?.[cacheIndex] || null;
113
+ targetPath = String(parsed.targetArchiveEntry || '');
114
+ const material = (cacheQualification?.materials || []).find((item) => String(item.archiveEntry || '') === targetPath) || null;
115
+ if (!material) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.cache-entry-unowned`, `${kind} Role cache target must be one exact material explicitly owned by the selected-route cache External Payload.`, { targetPath }));
116
+ targetArchive = cacheQualification?.archive || null;
117
+ archivePath = String(cacheQualification?.payloadPath || '');
118
+ }
119
+ }
120
+ const matches = targetArchive?.state === 'qualified' ? targetArchive.entries.filter((entry) => String(entry.path || '') === targetPath) : [];
121
+ if (!targetPath || matches.length !== 1) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.target-unresolved`, `${kind} Role Pointer must resolve exactly one exact Role artifact inside its explicit payload owner.`, { targetPayload, targetPath, count: matches.length }));
122
+ let targetBytes = 0;
123
+ let targetSha256 = '';
124
+ if (matches.length === 1) {
125
+ const data = packageFileBytes({ data: matches[0].data });
126
+ targetBytes = data.byteLength;
127
+ targetSha256 = sha256Hex(data);
128
+ const markdown = decodeUtf8(data);
129
+ if (currentSchemaId(markdown) !== 'tiinex.party.role.v1') localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.schema-invalid`, `${kind} Role Pointer target must be one exact tiinex.party.role.v1 artifact.`, { targetPath }));
130
+ const roleLabel = fieldValue(sectionText(markdown, 'Role Identity'), 'Role Label');
131
+ if (!roleLabel) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.label-unresolved`, `${kind} Role target must visibly declare Role Label.`, { targetPath }));
132
+ if (parsed.roleLabelHint && roleLabel && normalizeToken(parsed.roleLabelHint) !== normalizeToken(roleLabel)) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.label-mismatch`, `${kind} Role Pointer label hint conflicts with the exact carried Role artifact.`, { hint: parsed.roleLabelHint, roleLabel }));
133
+ }
134
+ const requirementId = kind === 'endpoint' ? String(parsed.endpointRequirementId || '') : String(parsed.participantRequirementId || '');
135
+ if (!requirementId || !parsed.roleReference) localFindings.push(finding('error', `portable.handoff-v2-phase1.${kind}-role.binding-incomplete`, `${kind} Role Pointer must visibly preserve its requirement id and Role reference.`));
136
+ if (kind === 'endpoint' && !['from', 'to'].includes(String(parsed.endpointParty || '').toLowerCase())) localFindings.push(finding('error', 'portable.handoff-v2-phase1.endpoint-role.party-invalid', 'Endpoint Role Pointer must visibly declare endpoint party from or to.'));
137
+ findings.push(...localFindings);
138
+ return Object.freeze({
139
+ state: localFindings.some((item) => item.severity === 'error') ? 'blocked' : 'qualified',
140
+ pointerPath: String(pointer?.path || ''),
141
+ workspaceId: String(parsed.workspaceId || ''),
142
+ routeId: String(parsed.routeId || ''),
143
+ requirementId,
144
+ ...(kind === 'endpoint' ? { endpointParty: String(parsed.endpointParty || '') } : {}),
145
+ roleLabelHint: String(parsed.roleLabelHint || ''),
146
+ referenceTarget: String(parsed.roleReference || ''),
147
+ targetCarrierKind,
148
+ targetWorkspaceId,
149
+ archivePath,
150
+ targetInnerPath: targetPath,
151
+ targetArchiveEntry: targetCarrierKind === 'workspace-cache-entry' ? targetPath : '',
152
+ targetBytes,
153
+ targetSha256,
154
+ findings: Object.freeze(localFindings)
155
+ });
156
+ }
157
+
158
+ function currentSchemaId(markdown = '') { return String(String(markdown || '').match(/Current Schema:\s*(?:\[)?(tiinex\.[a-z0-9._-]+)(?:\])?/i)?.[1] || '').toLowerCase(); }
159
+ function sectionText(markdown = '', heading = '') { const re = new RegExp(`^##\\s+${escapeRe(heading)}\\s*$`, 'mi'); const match = re.exec(String(markdown || '')); if (!match) return ''; const rest = String(markdown || '').slice(match.index + match[0].length); const next = /^##\s+/m.exec(rest); return (next ? rest.slice(0, next.index) : rest).trim(); }
160
+ function fieldValue(section = '', name = '') { const m = String(section || '').match(new RegExp(`^\\s*-\\s+${escapeRe(name)}:\\s*(.+?)\\s*$`, 'mi')); return String(m?.[1] || '').trim(); }
161
+ function markdownTarget(value = '') { return String(value || '').match(/\[[^\]]*\]\(([^)]+)\)/)?.[1] || String(value || '').trim(); }
162
+ function escapeRe(value = '') { return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
163
+ function normalizeToken(value = '') { return String(value || '').trim().toLowerCase().replace(/[^a-z0-9]+/g, ''); }
164
+ function decodeUtf8(data) { try { return new TextDecoder('utf-8', { fatal: true }).decode(data); } catch { return ''; } }
165
+ function safeToken(value = '') { return String(value || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'role'; }
166
+ function finding(severity, code, message, extra = {}) { return Object.freeze({ severity, code, message, ...extra }); }
@@ -0,0 +1,113 @@
1
+ import { qualifySelectedHandoffArtifact } from './routeArtifactConformance.js';
2
+ import { qualifyPhase1RolePointer } from './recipientV2.artifactFirst.roles.js';
3
+ import { qualifyPhase1RequiredContextClosure, resolveArchiveParent, parseHandoffParties } from './recipientV2.artifactFirst.closure.js';
4
+ import { decodeUtf8, finding } from './recipientV2.artifactFirst.shared.js';
5
+
6
+ export function qualifyPhase1RouteBindings({ routes = [], workspaceQualifications = new Map(), findings = [], recoveryParentCandidates = [], selectedRouteIdFromIngress = '', cacheQualifications = [], rolePointers = [], endpointPointers = [], participantPointers = [], cachePayloads = [], endpointRoleQualifications = [], participantRoleQualifications = [], boundRolePaths = new Set(), routeQualifications = [] } = {}) {
7
+ for (const route of routes) {
8
+ const routeWorkspaceId = String(route.parsed.workspaceId || '');
9
+ const workspaceQualification = workspaceQualifications.get(routeWorkspaceId) || null;
10
+ if (!workspaceQualification && routeWorkspaceId) findings.push(finding('error', 'portable.handoff-v2-phase1.workspace.route-unresolved', 'Every visible route Workspace must resolve one qualified artifact-first Workspace payload/relation pair.', { workspaceId: routeWorkspaceId, pointerPath: route.path }));
11
+ const payload = workspaceQualification?.payload || null;
12
+ const relation = workspaceQualification?.relation || null;
13
+ const archive = workspaceQualification?.archive || null;
14
+ const archiveFile = workspaceQualification?.archiveFile || null;
15
+ const workspaceTargetQualification = workspaceQualification?.workspaceTargetQualification || null;
16
+ let routeEntry = null;
17
+ let routeConformance = null;
18
+ let routeParties = Object.freeze({ from: '', to: '' });
19
+ let requiredClosure = Object.freeze({ state: 'blocked', requiredCount: 0, qualifiedCount: 0, requirements: Object.freeze([]), boundary: 'Artifact-first Required Context qualification has not run.' });
20
+ const semanticRouteId = String(route.parsed.routeId || `handoff-route:${routeWorkspaceId}:${String(route.parsed.handoffWorkspacePath || '')}`);
21
+ const routeEndpointRoles = [];
22
+ const routeParticipantRoles = [];
23
+
24
+ if (route && payload) {
25
+ if (route.parsed.workspaceId !== payload.parsed.workspaceId || route.parsed.workspacePayload !== payload.path) findings.push(finding('error', 'portable.handoff-v2-phase1.route.workspace-mismatch', 'Route Pointer must visibly bind the same Workspace identity and External Payload artifact.', { routeId: semanticRouteId }));
26
+ if (!route.parsed.handoffWorkspacePath) findings.push(finding('error', 'portable.handoff-v2-phase1.route.path-missing', 'Route Pointer must visibly declare the Handoff Workspace Path.', { routeId: semanticRouteId }));
27
+ if (!route.parsed.routeId || route.parsed.routeId !== semanticRouteId) findings.push(finding('error', 'portable.handoff-v2-phase1.route.id-missing', 'Route Pointer must visibly bind one exact route identity.', { routeId: semanticRouteId }));
28
+ }
29
+ if (archive?.state === 'qualified' && route) {
30
+ const routeEntries = archive.entries.filter((entry) => String(entry.path || '') === String(route.parsed.handoffWorkspacePath || ''));
31
+ if (routeEntries.length !== 1) findings.push(finding('error', 'portable.handoff-v2-phase1.route.unresolved', 'Route Pointer Handoff Workspace Path must resolve exactly one exact artifact inside its Workspace payload.', { routeId: semanticRouteId, path: route.parsed.handoffWorkspacePath || '', count: routeEntries.length }));
32
+ else {
33
+ routeEntry = routeEntries[0];
34
+ const routeMarkdown = decodeUtf8(routeEntry.data);
35
+ routeConformance = qualifySelectedHandoffArtifact({ markdown: routeMarkdown, resolveParent: ({ parent, targetEntry }) => resolveArchiveParent(route.parsed.handoffWorkspacePath, archive.entries, parent, targetEntry, recoveryParentCandidates) });
36
+ if (routeConformance.status !== 'qualified') findings.push(...(routeConformance.findings || []).map((item) => finding(item.severity || 'error', item.code || 'portable.handoff-v2-phase1.route.unqualified', item.message || 'Exact Handoff route did not qualify.', { routeId: semanticRouteId })));
37
+ routeParties = parseHandoffParties(routeMarkdown);
38
+ if (!routeParties.from || !routeParties.to) findings.push(finding('error', 'portable.handoff-v2-phase1.route.parties-unresolved', 'Exact Handoff bytes must provide From and To parties; route Pointer does not duplicate them.', { routeId: semanticRouteId }));
39
+ requiredClosure = qualifyPhase1RequiredContextClosure({
40
+ markdown: routeMarkdown,
41
+ routePath: route.parsed.handoffWorkspacePath,
42
+ workspaceId: payload?.parsed?.workspaceId || routeWorkspaceId,
43
+ archivePath: payload?.parsed?.location || '',
44
+ entries: archive.entries,
45
+ workspaceArchives: [...workspaceQualifications.values()].filter((item) => item?.archive?.state === 'qualified').map((item) => Object.freeze({ workspaceId: String(item.workspaceId || item.payload?.parsed?.workspaceId || ''), archivePath: String(item.payload?.parsed?.location || ''), entries: Object.freeze([...(item.archive?.entries || [])]) })),
46
+ caches: semanticRouteId === selectedRouteIdFromIngress ? cacheQualifications : []
47
+ });
48
+ findings.push(...(requiredClosure.findings || []).map((item) => Object.freeze({ ...item, routeId: semanticRouteId })));
49
+ }
50
+ }
51
+
52
+ if (route && payload && archive?.state === 'qualified') {
53
+ const expectedRolePaths = route.parsed.destinations.filter((target) => String(target || '') !== String(payload.path || ''));
54
+ for (const expectedPath of expectedRolePaths) {
55
+ const matches = rolePointers.filter((item) => String(item.path || '') === String(expectedPath || ''));
56
+ if (matches.length !== 1) {
57
+ findings.push(finding('error', 'portable.handoff-v2-phase1.role.pointer-missing', 'Route Pointer must resolve every declared Role Pointer exactly once.', { routeId: semanticRouteId, path: String(expectedPath || ''), count: matches.length }));
58
+ if (!endpointPointers.length && !participantPointers.length) findings.push(finding('error', 'portable.handoff-v2-phase1.participant-role.pointer-missing', 'Route Pointer has an unresolved Role destination and no surviving explicit Role Pointer can classify it.', { routeId: semanticRouteId, path: String(expectedPath || ''), count: matches.length }));
59
+ continue;
60
+ }
61
+ const pointer = matches[0];
62
+ boundRolePaths.add(String(pointer.path || ''));
63
+ const kind = pointer.parsed.role === 'endpoint-role' ? 'endpoint' : 'participant';
64
+ const result = qualifyPhase1RolePointer(pointer, { kind, routeWorkspaceId, routeId: semanticRouteId, workspaceQualifications, cachePayloads, cacheQualifications }, findings);
65
+ if (kind === 'endpoint') { routeEndpointRoles.push(result); endpointRoleQualifications.push(result); }
66
+ else { routeParticipantRoles.push(result); participantRoleQualifications.push(result); }
67
+ }
68
+ } else if (route?.parsed?.destinations?.some((target) => rolePointers.some((pointer) => String(pointer.path || '') === String(target || '')))) {
69
+ findings.push(finding('error', 'portable.handoff-v2-phase1.role.route-unresolved', 'Role Pointers cannot qualify until their route and Workspace payload qualify.', { routeId: semanticRouteId }));
70
+ }
71
+
72
+ const routeReasons = [];
73
+ if (routeConformance?.status !== 'qualified') routeReasons.push('handoff-conformance-unqualified');
74
+ if (requiredClosure.state !== 'qualified') routeReasons.push('required-context-closure-unqualified');
75
+ if (routeEndpointRoles.some((item) => item.state !== 'qualified')) routeReasons.push('endpoint-role-grounding-unqualified');
76
+ if (routeParticipantRoles.some((item) => item.state !== 'qualified')) routeReasons.push('participant-role-grounding-unqualified');
77
+ routeQualifications.push(Object.freeze({
78
+ route,
79
+ routeId: semanticRouteId,
80
+ workspaceId: routeWorkspaceId,
81
+ workspaceQualification,
82
+ payload,
83
+ relation,
84
+ archive,
85
+ archiveFile,
86
+ workspaceTargetQualification,
87
+ routeEntry,
88
+ routeConformance,
89
+ routeParties,
90
+ requiredClosure,
91
+ endpointRoles: Object.freeze(routeEndpointRoles),
92
+ participantRoles: Object.freeze(routeParticipantRoles),
93
+ reasons: Object.freeze(routeReasons)
94
+ }));
95
+ }
96
+
97
+ }
98
+
99
+ export function validatePhase1IngressBindings({ workspaceQualificationList = [], ingressPointer = null, routes = [], bootstrapPayload = null, cachePayloads = [], rolePointers = [], boundRolePaths = new Set(), findings = [] } = {}) {
100
+ for (const item of workspaceQualificationList) {
101
+ if (ingressPointer && !ingressPointer.parsed.destinations.includes(item.payload.path)) findings.push(finding('error', 'portable.handoff-v2-phase1.ingress.payload-missing', 'Ingress Pointer must navigate to every carried Workspace External Payload artifact.', { workspaceId: item.workspaceId, path: item.payload.path }));
102
+ if (ingressPointer && !ingressPointer.parsed.destinations.includes(item.relation.path)) findings.push(finding('error', 'portable.handoff-v2-phase1.ingress.relation-missing', 'Ingress Pointer must navigate to every carried Workspace material-representation Relation.', { workspaceId: item.workspaceId, path: item.relation.path }));
103
+ }
104
+ for (const route of routes) if (ingressPointer && !ingressPointer.parsed.destinations.includes(route.path)) findings.push(finding('error', 'portable.handoff-v2-phase1.ingress.route-missing', 'Ingress Pointer must navigate to every Handoff route Pointer.', { path: route.path }));
105
+ if (ingressPointer && bootstrapPayload && !ingressPointer.parsed.destinations.includes(bootstrapPayload.path)) findings.push(finding('error', 'portable.handoff-v2-phase1.ingress.bootstrap-missing', 'Ingress Pointer must navigate to the visible portable Tooling bootstrap External Payload artifact when one is carried.'));
106
+ if (ingressPointer && !bootstrapPayload && ingressPointer.parsed.destinations.some((target) => /bootstrap/i.test(String(target || '')))) findings.push(finding('error', 'portable.handoff-v2-phase1.bootstrap.artifact-unresolved', 'Ingress Pointer declares a portable Tooling bootstrap destination but no owning External Payload artifact is present.'));
107
+ for (const cachePayload of cachePayloads) if (ingressPointer && !ingressPointer.parsed.destinations.includes(cachePayload.path)) findings.push(finding('error', 'portable.handoff-v2-phase1.ingress.cache-missing', 'Ingress Pointer must navigate to every selected-route cache External Payload artifact.', { path: cachePayload.path }));
108
+ for (const pointer of rolePointers) {
109
+ if (!boundRolePaths.has(String(pointer.path || ''))) findings.push(finding('error', 'portable.handoff-v2-phase1.role.unbound', 'Role Pointer must be explicitly bound by one visible route Pointer.', { path: String(pointer.path || '') }));
110
+ if (ingressPointer && !ingressPointer.parsed.destinations.includes(pointer.path)) findings.push(finding('error', pointer.parsed.role === 'endpoint-role' ? 'portable.handoff-v2-phase1.ingress.endpoint-role-missing' : 'portable.handoff-v2-phase1.ingress.participant-role-missing', 'Ingress Pointer must navigate to every visible Role Pointer.', { path: pointer.path }));
111
+ }
112
+
113
+ }
@@ -0,0 +1,87 @@
1
+ import { finalizeFile } from '../../../export/package.fileMap.js';
2
+ import { packageFileByteView, sha256Hex, utf8Bytes } from '../../../export/package.bytes.js';
3
+
4
+ export const RECIPIENT_V2_READ_PATH = '001-1-READ-BEFORE-PROCEEDING.trace.md';
5
+ const RECIPIENT_V2_BASE_FORMAT_ID = 'tiinex-recipient-facing-handoff-v2-flat';
6
+ export const RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID = `${RECIPIENT_V2_BASE_FORMAT_ID}-artifact-first-phase1`;
7
+ export const RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_SCHEMA_ID = 'tiinex.portable.handoff-recipient-v2-artifact-first-phase1.v1';
8
+ export const RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_FORMAT_ID = `${RECIPIENT_V2_BASE_FORMAT_ID}-artifact-first-clean-phase2`;
9
+ export const RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_SCHEMA_ID = 'tiinex.portable.handoff-recipient-v2-artifact-first-clean-phase2.v1';
10
+ export const PHASE2_CLEAN_PROFILE = 'artifact-first-clean-carrier-phase2';
11
+ export const PHASE2_COMPATIBILITY_TRANSPORT = 'omitted-derived-non-authoritative';
12
+ export const PHASE1_BOOTSTRAP_ROLE = 'portable Tooling bootstrap runtime for recipient orientation and verification';
13
+ export const PHASE1_CACHE_ROLE = 'workspace-scoped Handoff dependency cache';
14
+
15
+ export function normalizeRoutePath(value = '') { return String(value || '').trim().replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+/, ''); }
16
+
17
+ export function normalizePhase1Token(value = '') { return String(value || '').trim().toLowerCase().replace(/[^a-z0-9]+/g, ''); }
18
+
19
+ export function cacheMaterialBelongsToRoute(material = {}, workspaceId = '', routePath = '') {
20
+ return String(material.routeWorkspaceId || '') === String(workspaceId || '') && normalizeRoutePath(material.routePath || '') === normalizeRoutePath(routePath || '');
21
+ }
22
+
23
+ export function selectOne(items = [], selector = '', label = 'item', findings = [], selectorFn = (item) => String(item.workspaceId || '')) { const candidates = selector ? items.filter((item) => selectorFn(item) === String(selector)) : items; if (candidates.length !== 1) { findings.push(finding('error', `portable.handoff-v2-phase1.${label}.selection`, `Phase 1 specimen requires exactly one selected ${label}.`, { selector: String(selector || ''), count: candidates.length })); return null; } return candidates[0]; }
24
+
25
+ export function oneFile(files = [], path = '') { const matches = files.filter((file) => String(file.path || '') === String(path || '')); return matches.length === 1 ? matches[0] : null; }
26
+
27
+ export function repathFinalizedFile(file = {}, path = '', overrides = {}) { return finalizeFile({ ...overrides, path, requestedPath: path, data: packageFileByteView(file) }); }
28
+
29
+ export function currentSchemaId(markdown = '') { return String(String(markdown || '').match(/Current Schema:\s*(?:\[)?(tiinex\.[a-z0-9._-]+)(?:\])?/i)?.[1] || '').toLowerCase(); }
30
+
31
+ export function sectionText(markdown = '', heading = '') { const re = new RegExp(`^##\\s+${escapeRe(heading)}\\s*$`, 'mi'); const match = re.exec(String(markdown || '')); if (!match) return ''; const rest = String(markdown || '').slice(match.index + match[0].length); const next = /^##\s+/m.exec(rest); return (next ? rest.slice(0, next.index) : rest).trim(); }
32
+
33
+ export function fieldValue(section = '', name = '') { const m = String(section || '').match(new RegExp(`^\\s*-\\s+${escapeRe(name)}:\\s*(.+?)\\s*$`, 'mi')); return String(m?.[1] || '').trim(); }
34
+
35
+ export function markdownTarget(value = '') { return String(value || '').match(/\[[^\]]*\]\(([^)]+)\)/)?.[1] || String(value || '').trim(); }
36
+
37
+ export function escapeRe(value = '') { return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
38
+
39
+ export function decodeUtf8(data) { try { return new TextDecoder('utf-8', { fatal: true }).decode(data); } catch { return ''; } }
40
+
41
+ export function phase1RouteToken(route = {}) {
42
+ const workspaceId = String(route.workspaceId || 'workspace');
43
+ const routePath = String(route.workspaceRelativePath || 'route');
44
+ const routeId = String(route.id || '');
45
+ const human = safeToken(`${workspaceId}-${routePath}`).slice(0, 42) || 'route';
46
+ return `${human}-${sha256Hex(utf8Bytes(`${workspaceId}\0${routePath}\0${routeId}`)).slice(0, 12)}`;
47
+ }
48
+
49
+ export function phase1RoutePointerPath(route = {}, index = 0, count = 1, selectedRouteId = '') {
50
+ if (String(route.id || '') === String(selectedRouteId || '') || count <= 1) return '001-4-handoff-pointer.trace.md';
51
+ return `001-4-${index + 1}-${phase1RouteToken(route)}-handoff-pointer.trace.md`;
52
+ }
53
+
54
+ export function phase1RolePathPrefix(route = {}, index = 0, count = 1, selectedRouteId = '') {
55
+ if (String(route.id || '') === String(selectedRouteId || '') || count <= 1) return '001-6';
56
+ return `001-6-${index + 1}-${phase1RouteToken(route)}`;
57
+ }
58
+
59
+ export function artifactFirstCarrierFilename(workspaceId = '', dimension = '', from = '', to = '') {
60
+ const workspace = safeToken(workspaceId);
61
+ const dimensionToken = String(dimension || '').trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
62
+ const fromToken = String(from || '').trim().toLowerCase().normalize('NFKD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
63
+ const toToken = String(to || '').trim().toLowerCase().normalize('NFKD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
64
+ return workspace && dimensionToken && fromToken && toToken ? `${workspace}-${dimensionToken}-${fromToken}-to-${toToken}.handoff-package.zip` : '';
65
+ }
66
+
67
+ export function safeToken(value = '') { return String(value || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'workspace'; }
68
+
69
+ export function stableJson(value) { return JSON.stringify(sortJson(value)); }
70
+
71
+ export function sortJson(value) { if (Array.isArray(value)) return value.map(sortJson); if (!value || typeof value !== 'object') return value; return Object.fromEntries(Object.keys(value).sort().map((key) => [key, sortJson(value[key])])); }
72
+
73
+ export function blocked(reason, findings = []) { return deepFreeze({ schema: RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_SCHEMA_ID, status: 'blocked', files: Object.freeze([]), topology: deepFreeze({ root: null, read: null, workspaces: [], caches: [], participantRoles: [], routes: [], bootstrap: null }), findings: Object.freeze([finding('error', `portable.handoff-v2-phase1.${reason}`, 'Artifact-first Phase 1 specimen could not be built.'), ...findings]) }); }
74
+
75
+ export function finding(severity, code, message, extra = {}) { return Object.freeze({ severity, code, message, ...extra }); }
76
+
77
+ export function deepFreeze(value) { if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value; if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer || value instanceof Map) return value; for (const child of Object.values(value)) deepFreeze(child); return Object.freeze(value); }
78
+
79
+ export function sortedQualifiedCarrierRoutes(routes = [], selectedRouteId = '') {
80
+ return [...routes].filter((item) => String(item.state || '') === 'qualified').sort((a, b) => {
81
+ const aid = String(a.id || '');
82
+ const bid = String(b.id || '');
83
+ if (aid === selectedRouteId && bid !== selectedRouteId) return -1;
84
+ if (bid === selectedRouteId && aid !== selectedRouteId) return 1;
85
+ return `${String(a.workspaceId || '')}:${normalizeRoutePath(a.workspaceRelativePath || '')}`.localeCompare(`${String(b.workspaceId || '')}:${normalizeRoutePath(b.workspaceRelativePath || '')}`);
86
+ });
87
+ }
@@ -0,0 +1,160 @@
1
+ import { finalizeFile } from '../../../export/package.fileMap.js';
2
+ import { packageFileByteView, packageFileBytes, sha256Hex } from '../../../export/package.bytes.js';
3
+ import { inspectStoredWorkspaceArchive } from './workspaceByteProvider.js';
4
+ import { qualifyHandoffWorkspaceTarget } from './workspaceTargetConformance.js';
5
+ import { renderRecipientV2ExternalPayload, renderRecipientV2Relation } from './recipientV2.artifacts.js';
6
+
7
+ export const PHASE1_COMPLETE_WORKSPACE_ROLE = 'complete Workspace archive representation payload';
8
+ export const PHASE1_BOUNDED_WORKSPACE_ROLE = 'bounded Workspace archive representation payload';
9
+
10
+ export function buildPhase1WorkspaceCarriers(input = {}) {
11
+ const sourceInspection = input.sourceInspection || {};
12
+ const sourceBundle = input.sourceBundle || {};
13
+ const selectedWorkspaceId = String(input.selectedWorkspaceId || '');
14
+ const findings = [];
15
+ const ordered = [...(sourceInspection.workspaces || [])].sort((a, b) => {
16
+ const aid = String(a.workspaceId || '');
17
+ const bid = String(b.workspaceId || '');
18
+ if (aid === selectedWorkspaceId && bid !== selectedWorkspaceId) return -1;
19
+ if (bid === selectedWorkspaceId && aid !== selectedWorkspaceId) return 1;
20
+ return aid.localeCompare(bid);
21
+ });
22
+ const carriers = [];
23
+ const seen = new Set();
24
+ for (const [index, workspace] of ordered.entries()) {
25
+ const workspaceId = String(workspace.workspaceId || '');
26
+ if (!workspaceId || seen.has(workspaceId)) {
27
+ findings.push(finding('error', 'portable.handoff-v2-phase1.workspace.identity-ambiguous', 'Artifact-first full-source carriage requires one unique visible Workspace identity per carried Workspace.', { workspaceId }));
28
+ continue;
29
+ }
30
+ seen.add(workspaceId);
31
+ const sourceArchive = oneFile(sourceBundle.files || [], workspace.workspaceArchivePath);
32
+ if (!sourceArchive) {
33
+ findings.push(finding('error', 'portable.handoff-v2-phase1.archive.unresolved', 'Carried Workspace archive is unavailable in the qualified source carrier.', { workspaceId, path: workspace.workspaceArchivePath }));
34
+ continue;
35
+ }
36
+ const selected = workspaceId === selectedWorkspaceId;
37
+ const token = safeToken(workspaceId);
38
+ const ordinal = index + 1;
39
+ const archivePath = selected ? '001-2-workspace.zip' : `001-2-${ordinal}-${token}-workspace.zip`;
40
+ const payloadArtifactPath = selected ? '001-2-workspace-payload.trace.md' : `001-2-${ordinal}-${token}-workspace-payload.trace.md`;
41
+ const relationArtifactPath = selected ? '001-3-workspace-representation-relation.trace.md' : `001-3-${ordinal}-${token}-workspace-representation-relation.trace.md`;
42
+ const coverage = workspace.coverage === 'bounded' ? 'bounded' : 'complete';
43
+ const payloadRole = coverage === 'bounded' ? PHASE1_BOUNDED_WORKSPACE_ROLE : PHASE1_COMPLETE_WORKSPACE_ROLE;
44
+ const scope = coverage === 'bounded' ? 'bounded recipient-relative workspace materialization' : 'complete recipient-relative workspace materialization';
45
+ const archiveFile = finalizeFile({
46
+ path: archivePath,
47
+ requestedPath: archivePath,
48
+ kind: 'handoff-workspace-archive',
49
+ logicalKind: coverage === 'bounded' ? 'recipient-v2-phase1-bounded-workspace-archive' : 'recipient-v2-phase1-complete-workspace-archive',
50
+ mediaType: 'application/zip',
51
+ data: packageFileByteView(sourceArchive),
52
+ boundary: 'Exact Workspace archive bytes owned by the visible External Payload artifact; package placement is not semantic provider authority.'
53
+ });
54
+ const payloadArtifact = finalizeFile({
55
+ path: payloadArtifactPath,
56
+ kind: 'tiinex-external-payload-artifact',
57
+ logicalKind: 'recipient-v2-phase1-workspace-payload',
58
+ mediaType: 'text/markdown',
59
+ content: renderRecipientV2ExternalPayload({
60
+ artifactFirst: true,
61
+ createdAt: input.createdAt,
62
+ workspaceId,
63
+ title: `Workspace Payload — ${workspaceId}`,
64
+ summary: `Artifact-first Phase 1 exact ${coverage} Workspace archive payload.`,
65
+ label: `${workspaceId} ${coverage} Workspace archive`,
66
+ kind: 'zip export',
67
+ role: payloadRole,
68
+ location: archivePath,
69
+ bytes: archiveFile.bytes,
70
+ sha256: archiveFile.sha256
71
+ })
72
+ });
73
+ const relationArtifact = finalizeFile({
74
+ path: relationArtifactPath,
75
+ kind: 'tiinex-relation-artifact',
76
+ logicalKind: 'recipient-v2-phase1-workspace-representation-relation',
77
+ mediaType: 'text/markdown',
78
+ content: renderRecipientV2Relation({
79
+ artifactFirst: true,
80
+ createdAt: input.createdAt,
81
+ title: `Workspace Material Representation — ${workspaceId}`,
82
+ summary: 'Typed non-Parent material-representation relation from the External Payload artifact to the represented Workspace artifact.',
83
+ relationType: 'material representation',
84
+ direction: 'payload artifact -> represented artifact',
85
+ scope,
86
+ sourceLabel: `${workspaceId} Workspace payload artifact`,
87
+ source: payloadArtifactPath,
88
+ targetLabel: `${workspaceId} represented Workspace artifact`,
89
+ target: String(workspace.sourceWorkspaceTargetInnerPath || ''),
90
+ targetWorkspaceId: workspaceId,
91
+ targetWorkspaceInnerPath: String(workspace.sourceWorkspaceTargetInnerPath || '')
92
+ })
93
+ });
94
+ carriers.push(Object.freeze({ workspace, workspaceId, selected, coverage, archivePath, payloadArtifactPath, relationArtifactPath, archiveFile, payloadArtifact, relationArtifact }));
95
+ }
96
+ if (!carriers.some((item) => item.selected)) findings.push(finding('error', 'portable.handoff-v2-phase1.workspace.selection', 'Selected route Workspace is not present in the carried full-source Workspace set.', { workspaceId: selectedWorkspaceId }));
97
+ return Object.freeze({ state: findings.some((item) => item.severity === 'error') ? 'blocked' : 'qualified', carriers: Object.freeze(carriers), findings: Object.freeze(findings) });
98
+ }
99
+
100
+ export function qualifyPhase1WorkspaceCarriers(input = {}) {
101
+ const payloads = input.workspacePayloads || [];
102
+ const relations = input.relations || [];
103
+ const semanticFiles = input.semanticFiles || [];
104
+ const recoveryParentCandidates = input.recoveryParentCandidates || [];
105
+ const findings = input.findings || [];
106
+ const records = [];
107
+ const payloadByWorkspace = uniqueByWorkspace(payloads, (item) => item.parsed?.workspaceId, 'payload', findings);
108
+ const relationByWorkspace = uniqueByWorkspace(relations, (item) => item.parsed?.targetWorkspaceId, 'relation', findings);
109
+ const ids = new Set([...payloadByWorkspace.keys(), ...relationByWorkspace.keys()]);
110
+ for (const workspaceId of [...ids].sort()) {
111
+ const payload = payloadByWorkspace.get(workspaceId) || null;
112
+ const relation = relationByWorkspace.get(workspaceId) || null;
113
+ if (!payload || !relation) {
114
+ findings.push(finding('error', 'portable.handoff-v2-phase1.workspace.surface-incomplete', 'Every carried artifact-first Workspace requires one External Payload and one material-representation Relation.', { workspaceId, payload: Boolean(payload), relation: Boolean(relation) }));
115
+ continue;
116
+ }
117
+ const expectedScope = payload.parsed.payloadRole === PHASE1_BOUNDED_WORKSPACE_ROLE ? 'bounded recipient-relative workspace materialization' : 'complete recipient-relative workspace materialization';
118
+ if (relation.parsed.relationType !== 'material representation' || relation.parsed.direction !== 'payload artifact -> represented artifact' || relation.parsed.scope !== expectedScope) findings.push(finding('error', 'portable.handoff-v2-phase1.relation.semantic-contract-mismatch', 'Workspace representation Relation does not match the accepted artifact-first material-representation predicate/direction/scope.', { workspaceId }));
119
+ if (relation.parsed.source !== payload.path) findings.push(finding('error', 'portable.handoff-v2-phase1.relation.payload-mismatch', 'Material-representation Relation Source must be the explicit Workspace External Payload artifact.', { workspaceId }));
120
+ if (!relation.parsed.targetWorkspaceId || relation.parsed.targetWorkspaceId !== workspaceId) findings.push(finding('error', 'portable.handoff-v2-phase1.relation.workspace-id-mismatch', 'Relation and External Payload must visibly agree on represented Workspace identity.', { workspaceId }));
121
+ if (!relation.parsed.targetWorkspaceInnerPath || relation.parsed.target !== relation.parsed.targetWorkspaceInnerPath) findings.push(finding('error', 'portable.handoff-v2-phase1.relation.workspace-inner-path-missing', 'Material-representation Relation must visibly identify the represented Workspace inner path.', { workspaceId }));
122
+ const archiveFiles = semanticFiles.filter((file) => String(file.path || '') === String(payload.parsed.location || ''));
123
+ if (archiveFiles.length !== 1) {
124
+ findings.push(finding('error', 'portable.handoff-v2-phase1.payload.location-unresolved', 'Workspace External Payload Location must resolve exactly one exact payload file.', { workspaceId, path: payload.parsed.location || '', count: archiveFiles.length }));
125
+ continue;
126
+ }
127
+ const archiveFile = archiveFiles[0];
128
+ const bytes = packageFileBytes(archiveFile);
129
+ if (payload.parsed.bytes !== bytes.byteLength || payload.parsed.integrityMethod !== 'sha256' || payload.parsed.integrityValue !== sha256Hex(bytes)) findings.push(finding('error', 'portable.handoff-v2-phase1.payload.identity-mismatch', 'Visible Workspace External Payload byte identity diverges from exact payload bytes.', { workspaceId }));
130
+ const archive = inspectStoredWorkspaceArchive(bytes, { ownedBytes: true });
131
+ findings.push(...(archive.findings || []));
132
+ let workspaceTargetQualification = null;
133
+ if (archive.state === 'qualified') {
134
+ const targetEntries = archive.entries.filter((entry) => String(entry.path || '') === String(relation.parsed.targetWorkspaceInnerPath || ''));
135
+ if (targetEntries.length !== 1) findings.push(finding('error', 'portable.handoff-v2-phase1.workspace-target.unresolved', 'Relation target Workspace inner path must resolve exactly one Workspace artifact inside the payload.', { workspaceId, path: relation.parsed.targetWorkspaceInnerPath || '', count: targetEntries.length }));
136
+ else {
137
+ workspaceTargetQualification = qualifyHandoffWorkspaceTarget({ targetPath: targetEntries[0].path, targetData: targetEntries[0].data, entries: archive.entries, parentCandidates: recoveryParentCandidates });
138
+ if (workspaceTargetQualification.state !== 'qualified') findings.push(finding('error', 'portable.handoff-v2-phase1.workspace-target.unqualified', 'Relation-selected Workspace artifact inside the payload did not independently qualify.', { workspaceId, reasons: workspaceTargetQualification.reasons || [] }));
139
+ }
140
+ }
141
+ records.push(Object.freeze({ workspaceId, payload, relation, archiveFile, archive, workspaceTargetQualification }));
142
+ }
143
+ return Object.freeze(records);
144
+ }
145
+
146
+ function uniqueByWorkspace(items, idFn, label, findings) {
147
+ const map = new Map();
148
+ for (const item of items) {
149
+ const workspaceId = String(idFn(item) || '');
150
+ if (!workspaceId || map.has(workspaceId)) {
151
+ findings.push(finding('error', `portable.handoff-v2-phase1.${label}.workspace-ambiguous`, `Artifact-first Workspace ${label} must visibly bind one unique Workspace id.`, { workspaceId }));
152
+ continue;
153
+ }
154
+ map.set(workspaceId, item);
155
+ }
156
+ return map;
157
+ }
158
+ function oneFile(files = [], path = '') { const matches = files.filter((file) => String(file.path || '') === String(path || '')); return matches.length === 1 ? matches[0] : null; }
159
+ function safeToken(value = '') { return String(value || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'workspace'; }
160
+ function finding(severity, code, message, extra = {}) { return Object.freeze({ severity, code, message, ...extra }); }
@@ -0,0 +1,44 @@
1
+ import { buildRecipientV2ArtifactFirstPhase1Specimen } from './recipientV2.artifactFirst.build.js';
2
+ import { selectPhase1SourceRoute } from './recipientV2.artifactFirst.materials.js';
3
+ import { blocked, deepFreeze } from './recipientV2.artifactFirst.shared.js';
4
+
5
+ export { 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 } from './recipientV2.artifactFirst.shared.js';
6
+ export { buildRecipientV2ArtifactFirstPhase1Specimen } from './recipientV2.artifactFirst.build.js';
7
+ export { inspectRecipientV2ArtifactFirstPhase1Specimen } from './recipientV2.artifactFirst.inspect.js';
8
+ export { isRecipientV2ArtifactFirstPhase1Surface, inspectRecipientFacingV2ArtifactFirstPhase1 } from './recipientV2.artifactFirst.projection.js';
9
+ export { deriveRecipientV2ArtifactFirstPhase1Facts } from './recipientV2.artifactFirst.materials.js';
10
+ export { qualifyRecipientV2ArtifactFirstPhase1RequiredContextClosure } from './recipientV2.artifactFirst.closure.js';
11
+
12
+ export function buildRecipientFacingV2ArtifactFirstPhase1(input = {}) {
13
+ return buildRecipientFacingV2ArtifactFirst(input, false);
14
+ }
15
+
16
+ export function buildRecipientFacingV2ArtifactFirstPhase2Clean(input = {}) {
17
+ return buildRecipientFacingV2ArtifactFirst(input, true);
18
+ }
19
+
20
+ function buildRecipientFacingV2ArtifactFirst(input = {}, cleanCarrierPhase2 = false) {
21
+ const sourceSurface = input.sourceSurface || null;
22
+ const selectionFindings = [];
23
+ const routeSelection = selectPhase1SourceRoute(input.carrierProjection || sourceSurface?.carrierProjection || {}, input.routeSelector || input.routeId || '', selectionFindings);
24
+ if (routeSelection.state !== 'qualified') return blocked('route-selection-blocked', selectionFindings);
25
+ if (!sourceSurface || sourceSurface.status !== 'ready') return blocked('source-surface-unready', sourceSurface?.findings || []);
26
+ const specimen = buildRecipientV2ArtifactFirstPhase1Specimen({
27
+ bundle: { files: sourceSurface.files || [] },
28
+ createdAt: input.createdAt,
29
+ workspaceId: routeSelection.route.workspaceId || input.workspaceId || '',
30
+ routePath: routeSelection.route.workspaceRelativePath || '',
31
+ routeSelection,
32
+ bootstrap: sourceSurface.topology?.bootstrap || null,
33
+ cleanCarrierPhase2
34
+ });
35
+ if (specimen.status !== 'ready') return specimen;
36
+ return deepFreeze({
37
+ status: 'ready',
38
+ files: specimen.files,
39
+ topology: specimen.topology,
40
+ inspection: specimen.inspection,
41
+ findings: specimen.inspection.findings,
42
+ boundary: specimen.boundary
43
+ });
44
+ }