@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,194 @@
1
+ import { packageFileBytes, sha256Hex } from '../../../export/package.bytes.js';
2
+ import { inspectRecipientV2Artifact, parseRecipientV2Pointer, parseRecipientV2Relation } from './recipientV2.artifacts.js';
3
+ import { inspectRecipientV2TransportManifest, RECIPIENT_V2_TRANSPORT_MANIFEST_PATH } from './recipientV2.transportManifest.js';
4
+ import { qualifyPhase1WorkspaceCarriers, PHASE1_COMPLETE_WORKSPACE_ROLE, PHASE1_BOUNDED_WORKSPACE_ROLE } from './recipientV2.artifactFirst.workspaces.js';
5
+ import { deriveRecipientV2ArtifactFirstPhase1Facts, parsePhase1Payload, qualifyPhase1BootstrapPayload, qualifyPhase1CachePayload } from './recipientV2.artifactFirst.materials.js';
6
+ import { phase1CacheParentCandidates } from './recipientV2.artifactFirst.closure.js';
7
+ import { qualifyPhase1RouteBindings, validatePhase1IngressBindings } from './recipientV2.artifactFirst.routes.js';
8
+ 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, artifactFirstCarrierFilename, safeToken, currentSchemaId, decodeUtf8, stableJson, deepFreeze, finding } from './recipientV2.artifactFirst.shared.js';
9
+
10
+ export function inspectRecipientV2ArtifactFirstPhase1Specimen(bundle = {}) {
11
+ const files = Array.isArray(bundle) ? bundle : (bundle.files || []);
12
+ const findings = [];
13
+ const semanticFiles = files.filter((file) => String(file.path || '') !== RECIPIENT_V2_TRANSPORT_MANIFEST_PATH);
14
+ const markdownFiles = semanticFiles.filter((file) => /\.md$/i.test(String(file.path || '')));
15
+ const workspaceWrappers = markdownFiles.filter((file) => currentSchemaId(decodeUtf8(packageFileBytes(file))) === 'tiinex.workspace.v1');
16
+ if (workspaceWrappers.length) findings.push(finding('error', 'portable.handoff-v2-phase1.workspace-wrapper.present', 'Phase 1 artifact-first specimen must not generate an outer Workspace wrapper.', { count: workspaceWrappers.length }));
17
+
18
+ const factsByPath = deriveRecipientV2ArtifactFirstPhase1Facts(semanticFiles);
19
+ const qualified = markdownFiles.map((file) => inspectRecipientV2Artifact(file, { facts: factsByPath.get(String(file.path || '')) || null }));
20
+ for (const item of qualified) findings.push(...(item.findings || []));
21
+
22
+ const pointers = qualified.filter((item) => item.schemaId === 'tiinex.pointer.v1').map((item) => ({ ...item, parsed: parseRecipientV2Pointer(item.markdown) }));
23
+ const payloads = qualified.filter((item) => item.schemaId === 'tiinex.external.payload.v1').map((item) => ({ ...item, parsed: parsePhase1Payload(item.markdown) }));
24
+ const relations = qualified.filter((item) => item.schemaId === 'tiinex.relation.v1').map((item) => ({ ...item, parsed: parseRecipientV2Relation(item.markdown) }));
25
+ const ingress = pointers.filter((item) => item.path === RECIPIENT_V2_READ_PATH && item.parsed.role === 'recovery-orientation');
26
+ const routes = pointers.filter((item) => item.parsed.role === 'handoff-route');
27
+ const endpointPointers = pointers.filter((item) => item.parsed.role === 'endpoint-role');
28
+ const participantPointers = pointers.filter((item) => item.parsed.role === 'participant-role');
29
+ const workspacePayloads = payloads.filter((item) => [PHASE1_COMPLETE_WORKSPACE_ROLE, PHASE1_BOUNDED_WORKSPACE_ROLE].includes(item.parsed.payloadRole));
30
+ const bootstrapPayloads = payloads.filter((item) => item.parsed.payloadRole === PHASE1_BOOTSTRAP_ROLE);
31
+ const cachePayloads = payloads.filter((item) => item.parsed.payloadRole === PHASE1_CACHE_ROLE);
32
+ const unknownPayloads = payloads.filter((item) => ![PHASE1_COMPLETE_WORKSPACE_ROLE, PHASE1_BOUNDED_WORKSPACE_ROLE, PHASE1_BOOTSTRAP_ROLE, PHASE1_CACHE_ROLE].includes(item.parsed.payloadRole));
33
+ if (ingress.length !== 1) findings.push(finding('error', 'portable.handoff-v2-phase1.ingress.count', 'Phase 1 specimen requires exactly one ingress Pointer.', { count: ingress.length }));
34
+ if (!routes.length) findings.push(finding('error', 'portable.handoff-v2-phase1.route.count', 'Artifact-first specimen requires at least one visible Handoff route Pointer.', { count: routes.length }));
35
+ if (!workspacePayloads.length) findings.push(finding('error', 'portable.handoff-v2-phase1.payload.workspace-count', 'Artifact-first full-source carriage requires at least one Workspace External Payload artifact.', { count: workspacePayloads.length }));
36
+ if (bootstrapPayloads.length > 1) findings.push(finding('error', 'portable.handoff-v2-phase1.bootstrap.count', 'A carried portable Tooling bootstrap must have exactly one owning External Payload artifact.', { count: bootstrapPayloads.length }));
37
+ if (cachePayloads.length > 1) findings.push(finding('error', 'portable.handoff-v2-phase1.cache.count', 'A selected Workspace may expose at most one selected-route dependency cache External Payload.', { count: cachePayloads.length }));
38
+ if (unknownPayloads.length) findings.push(finding('error', 'portable.handoff-v2-phase1.payload.unclassified', 'Phase 1 specimen contains an External Payload artifact outside the bounded Workspace/bootstrap/cache ownership subset.', { count: unknownPayloads.length }));
39
+ if (!relations.length) findings.push(finding('error', 'portable.handoff-v2-phase1.relation.count', 'Artifact-first full-source carriage requires a typed material-representation Relation for every carried Workspace.', { count: relations.length }));
40
+ if (markdownFiles.some((file) => factsByPath.get(String(file.path || ''))?.role === 'package-root')) findings.push(finding('error', 'portable.handoff-v2-phase1.package-root.present', 'Phase 1 specimen must not use a package-root Pointer as receiver semantic authority.'));
41
+
42
+ const bootstrapPayload = bootstrapPayloads[0] || null;
43
+ const ingressPointer = ingress[0];
44
+ const selectedRouteIdFromIngress = String(ingressPointer?.parsed?.selectedRouteId || '');
45
+ const bootstrapQualification = bootstrapPayload ? qualifyPhase1BootstrapPayload(bootstrapPayload, semanticFiles, findings) : null;
46
+ const cacheQualifications = cachePayloads.map((item) => qualifyPhase1CachePayload(item, semanticFiles, findings));
47
+ const recoveryParentCandidates = phase1CacheParentCandidates(cacheQualifications);
48
+ const workspaceQualificationList = qualifyPhase1WorkspaceCarriers({ workspacePayloads, relations, semanticFiles, recoveryParentCandidates, findings });
49
+ const workspaceQualifications = new Map(workspaceQualificationList.map((item) => [String(item.workspaceId || ''), item]));
50
+ const endpointRoleQualifications = [];
51
+ const participantRoleQualifications = [];
52
+ const rolePointers = [...endpointPointers, ...participantPointers];
53
+ const boundRolePaths = new Set();
54
+ const routeQualifications = [];
55
+
56
+ qualifyPhase1RouteBindings({
57
+ routes, workspaceQualifications, findings, recoveryParentCandidates, selectedRouteIdFromIngress, cacheQualifications, rolePointers, endpointPointers, participantPointers, cachePayloads, endpointRoleQualifications, participantRoleQualifications, boundRolePaths, routeQualifications
58
+ });
59
+
60
+ validatePhase1IngressBindings({ workspaceQualificationList, ingressPointer, routes, bootstrapPayload, cachePayloads, rolePointers, boundRolePaths, findings });
61
+
62
+ if (ingressPointer) {
63
+ const candidateCount = Number(ingressPointer.parsed.candidateRouteCount || 0);
64
+ const selectedRouteId = String(ingressPointer.parsed.selectedRouteId || '');
65
+ const mode = String(ingressPointer.parsed.routeSelection || '');
66
+ if (candidateCount < 1) findings.push(finding('error', 'portable.handoff-v2-phase1.route-selection.candidate-count-missing', 'Ingress Pointer must preserve the qualified candidate-route count used for artifact-first selection.'));
67
+ if (candidateCount !== routes.length) findings.push(finding('error', 'portable.handoff-v2-phase1.route-selection.candidate-count-mismatch', 'Ingress candidate-route count must equal the complete visible shared route set.', { candidateCount, visibleRouteCount: routes.length }));
68
+ if (candidateCount > 1 && mode !== 'explicit-qualified-route-selector') findings.push(finding('error', 'portable.handoff-v2-phase1.route-selection.explicit-required', 'More than one qualified source Handoff route requires one explicit default recipient route selector.'));
69
+ if (candidateCount === 1 && mode !== 'implicit-single-qualified-route' && mode !== 'explicit-qualified-route-selector') findings.push(finding('error', 'portable.handoff-v2-phase1.route-selection.mode-invalid', 'Single-route artifact-first selection mode is unsupported.', { mode }));
70
+ const selectedMatches = routeQualifications.filter((item) => item.routeId === selectedRouteId);
71
+ if (!selectedRouteId || selectedMatches.length !== 1) findings.push(finding('error', 'portable.handoff-v2-phase1.route-selection.binding-mismatch', 'Ingress route selection must bind exactly one member of the complete visible shared route set.', { selectedRouteId, matches: selectedMatches.length }));
72
+ }
73
+
74
+ const selectedRouteQualification = routeQualifications.find((item) => item.routeId === selectedRouteIdFromIngress) || routeQualifications[0] || null;
75
+ const payload = selectedRouteQualification?.payload || null;
76
+ const relation = selectedRouteQualification?.relation || null;
77
+ const route = selectedRouteQualification?.route || null;
78
+ const routeEntry = selectedRouteQualification?.routeEntry || null;
79
+ const routeConformance = selectedRouteQualification?.routeConformance || null;
80
+ const requiredClosure = selectedRouteQualification?.requiredClosure || Object.freeze({ state: 'blocked', requiredCount: 0, qualifiedCount: 0, requirements: Object.freeze([]) });
81
+ const workspaceTargetQualification = selectedRouteQualification?.workspaceTargetQualification || null;
82
+ const semanticStatus = findings.some((item) => item.severity === 'error') ? 'blocked' : 'qualified';
83
+ const cleanCarrierPhase2 = Boolean(
84
+ ingressPointer
85
+ && ingressPointer.parsed.carrierProfile === PHASE2_CLEAN_PROFILE
86
+ && ingressPointer.parsed.compatibilityTransport === PHASE2_COMPATIBILITY_TRANSPORT
87
+ );
88
+ if (ingressPointer && (Boolean(ingressPointer.parsed.carrierProfile) !== Boolean(ingressPointer.parsed.compatibilityTransport))) findings.push(finding('error', 'portable.handoff-v2-phase2.clean-profile.incomplete', 'Clean-carrier profile and compatibility-transport declaration must appear together on the visible ingress Pointer.'));
89
+ if (ingressPointer?.parsed?.carrierProfile && ingressPointer.parsed.carrierProfile !== PHASE2_CLEAN_PROFILE) findings.push(finding('error', 'portable.handoff-v2-phase2.clean-profile.unsupported', 'Artifact-first ingress declares an unsupported clean-carrier profile.', { profile: ingressPointer.parsed.carrierProfile }));
90
+ if (ingressPointer?.parsed?.compatibilityTransport && ingressPointer.parsed.compatibilityTransport !== PHASE2_COMPATIBILITY_TRANSPORT) findings.push(finding('error', 'portable.handoff-v2-phase2.compatibility-transport.unsupported', 'Artifact-first ingress declares an unsupported compatibility-transport mode.', { mode: ingressPointer.parsed.compatibilityTransport }));
91
+ const transport = inspectRecipientV2TransportManifest(files);
92
+ const compatibilityFindings = [...(transport.findings || [])];
93
+ let compatibilityStatus = transport.state;
94
+ if (cleanCarrierPhase2) {
95
+ if (transport.state !== 'absent') compatibilityFindings.push(finding('error', 'portable.handoff-v2-phase2.compatibility.present', 'Clean-carrier Phase 2 profile must omit stored compatibility JSON; visible semantic artifacts and exact payload bytes are the complete receiver truth surface.'));
96
+ compatibilityStatus = compatibilityFindings.some((item) => item.severity === 'error') ? 'invalid' : 'omitted-qualified';
97
+ } else if (transport.state === 'valid') {
98
+ if (String(transport.manifest?.format || '') !== RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID) compatibilityFindings.push(finding('error', 'portable.handoff-v2-phase1.compatibility.format-mismatch', 'Compatibility JSON format does not identify the Phase 1 artifact-first specimen.'));
99
+ const declaredFacts = transport.factsByPath || new Map();
100
+ for (const [path, facts] of factsByPath) if (stableJson(declaredFacts.get(path) || null) !== stableJson(facts)) compatibilityFindings.push(finding('error', 'portable.handoff-v2-phase1.compatibility.not-derived', 'Compatibility JSON facts diverge from facts re-derived from visible semantic artifacts.', { path }));
101
+ compatibilityStatus = compatibilityFindings.some((item) => item.severity === 'error') ? 'invalid' : 'valid';
102
+ }
103
+ const finalSemanticStatus = findings.some((item) => item.severity === 'error') ? 'blocked' : semanticStatus;
104
+ const status = finalSemanticStatus === 'qualified' && (cleanCarrierPhase2 ? compatibilityStatus === 'omitted-qualified' : compatibilityStatus === 'valid') ? 'ready' : 'blocked';
105
+ const workspaceId = String(selectedRouteQualification?.workspaceId || payload?.parsed?.workspaceId || relation?.parsed?.targetWorkspaceId || route?.parsed?.workspaceId || '');
106
+ const lineage = ingressPointer ? Object.freeze({
107
+ mode: ingressPointer.parsed.carrierDimension?.includes('-') ? 'continue' : 'root',
108
+ dimension: String(ingressPointer.parsed.carrierDimension || ''),
109
+ parentDimension: String(ingressPointer.parsed.parentCarrierDimension || ''),
110
+ checkpointKind: String(ingressPointer.parsed.carrierCheckpoint || '')
111
+ }) : Object.freeze({ mode: '', dimension: '', parentDimension: '', checkpointKind: '' });
112
+ const carrierRoutes = routeQualifications.map((item) => item.route && item.routeEntry ? Object.freeze({
113
+ id: item.routeId,
114
+ workspaceId: item.workspaceId,
115
+ state: item.reasons.length ? 'blocked' : 'qualified',
116
+ workspaceRelativePath: String(item.route.parsed.handoffWorkspacePath || ''),
117
+ packagePath: String(item.payload?.parsed?.location || ''),
118
+ providerMode: 'archive',
119
+ archivePackagePath: String(item.payload?.parsed?.location || ''),
120
+ sha256: String(item.routeEntry.sha256 || ''),
121
+ dimension: String(lineage.dimension || ''),
122
+ parties: item.routeParties,
123
+ purpose: '',
124
+ projectedFilename: artifactFirstCarrierFilename(item.workspaceId, lineage.dimension, item.routeParties.from, item.routeParties.to),
125
+ conformance: item.routeConformance,
126
+ requiredClosure: item.requiredClosure,
127
+ endpointRolePointers: Object.freeze(item.endpointRoles.filter((role) => role.state === 'qualified').map((role) => role.pointerPath)),
128
+ participantRolePointers: Object.freeze(item.participantRoles.filter((role) => role.state === 'qualified').map((role) => role.pointerPath)),
129
+ reasons: item.reasons,
130
+ authority: Object.freeze({ artifactPartiesAuthoritative: true, dimensionSemanticAuthority: false, filenameSemanticAuthority: false })
131
+ }) : null).filter(Boolean);
132
+ const selectedRouteId = String(selectedRouteIdFromIngress || selectedRouteQualification?.routeId || '');
133
+ const selectedCarrierRoute = carrierRoutes.find((item) => item.id === selectedRouteId) || null;
134
+ const selectedWorkspaceQualification = workspaceQualifications.get(workspaceId) || null;
135
+ const sourceCandidateRouteCount = Number(ingressPointer?.parsed?.candidateRouteCount || 0);
136
+ const sourceSelectionMode = String(ingressPointer?.parsed?.routeSelection || '');
137
+ const selectionPolicy = sourceCandidateRouteCount > 1 || sourceSelectionMode === 'explicit-qualified-route-selector'
138
+ ? 'explicit-qualified-route-bound'
139
+ : 'implicit-single-qualified-route';
140
+ const qualifiedRouteCount = carrierRoutes.filter((item) => item.state === 'qualified').length;
141
+ const allVisibleRoutesQualified = carrierRoutes.length === routeQualifications.length && qualifiedRouteCount === carrierRoutes.length;
142
+ const carrierProjection = deepFreeze({
143
+ schema: 'tiinex.portable.handoff-carrier-projection.v1',
144
+ version: 1,
145
+ status: finalSemanticStatus === 'qualified' && allVisibleRoutesQualified && selectedCarrierRoute?.state === 'qualified' ? 'ready' : 'blocked',
146
+ mode: routeQualifications.length > 1 ? 'shared' : 'single',
147
+ lineage,
148
+ workspaces: Object.freeze(workspaceQualificationList.map((item) => Object.freeze({ id: item.workspaceId, title: item.workspaceId, slug: safeToken(item.workspaceId), qualification: item.workspaceTargetQualification?.state === 'qualified' ? 'qualified' : 'blocked' }))),
149
+ workspace: workspaceId ? Object.freeze({ id: workspaceId, title: workspaceId, slug: safeToken(workspaceId), qualification: selectedWorkspaceQualification?.workspaceTargetQualification?.state === 'qualified' ? 'qualified' : 'blocked' }) : Object.freeze({ id: '', title: '', slug: '', qualification: 'unresolved' }),
150
+ selection: Object.freeze({ policy: selectionPolicy, qualifiedRouteCount, sourceCandidateRouteCount, selectedRouteId }),
151
+ routes: Object.freeze(carrierRoutes),
152
+ authority: Object.freeze({ semanticAuthority: 'none', filenameAuthority: false, dimensionalParentAuthority: false, routeSelectionAuthority: 'qualified-visible-route-pointer-plus-exact-handoff-bytes' }),
153
+ findings: Object.freeze([])
154
+ });
155
+ const coldConsumerProjection = deepFreeze({
156
+ schema: 'tiinex.portable.handoff-cold-consumer-projection.v1',
157
+ version: 1,
158
+ status: carrierProjection.status,
159
+ workspaces: carrierProjection.workspaces,
160
+ routes: Object.freeze(carrierProjection.routes.map((item) => Object.freeze({ id: item.id, state: item.state, workspaceId: item.workspaceId, workspaceRelativeHandoffPath: item.workspaceRelativePath, packagePath: item.packagePath, sha256: item.sha256, from: item.parties?.from || '', to: item.parties?.to || '', endpointRolePointers: Object.freeze(item.endpointRolePointers || []), participantRolePointers: Object.freeze(item.participantRolePointers || []) }))),
161
+ selection: Object.freeze({ policy: carrierProjection.selection.policy, qualifiedRouteCount: carrierProjection.selection.qualifiedRouteCount, implicitRouteId: carrierProjection.routes.length === 1 && carrierProjection.routes[0].state === 'qualified' ? carrierProjection.routes[0].id : '' }),
162
+ authority: Object.freeze({ semanticAuthority: 'none', packageTruthRequired: true, routeBindingAuthority: 'visible-route-pointer-plus-exact-payload-and-handoff-bytes' })
163
+ });
164
+ const format = cleanCarrierPhase2 ? RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_FORMAT_ID : RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID;
165
+ return deepFreeze({
166
+ schema: cleanCarrierPhase2 ? RECIPIENT_V2_ARTIFACT_FIRST_PHASE2_CLEAN_SCHEMA_ID : RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_SCHEMA_ID,
167
+ format,
168
+ cleanCarrierPhase2,
169
+ status,
170
+ semanticStatus: finalSemanticStatus,
171
+ compatibilityStatus,
172
+ workspaceId,
173
+ coverage: payload?.parsed?.payloadRole === PHASE1_BOUNDED_WORKSPACE_ROLE ? 'bounded' : 'complete',
174
+ handoffWorkspacePath: String(route?.parsed?.handoffWorkspacePath || ''),
175
+ workspaceTargetQualification,
176
+ routeEntry: routeEntry ? Object.freeze({ path: routeEntry.path, bytes: routeEntry.bytes, sha256: routeEntry.sha256 }) : null,
177
+ routeConformance,
178
+ requiredClosure,
179
+ bootstrapQualification,
180
+ workspaces: Object.freeze(workspaceQualificationList.map((item) => Object.freeze({ workspaceId: item.workspaceId, payloadArtifactPath: item.payload.path, representationArtifactPath: item.relation.path, archivePath: item.payload.parsed.location, coverage: item.payload.parsed.payloadRole === PHASE1_BOUNDED_WORKSPACE_ROLE ? 'bounded' : 'complete', workspaceTargetQualification: item.workspaceTargetQualification }))),
181
+ caches: Object.freeze(cacheQualifications.map((item) => Object.freeze({ workspaceId: item.workspaceId, artifactPath: item.artifactPath, archivePath: item.payloadPath, materials: item.materials }))),
182
+ endpointRoles: Object.freeze(endpointRoleQualifications.filter((item) => item.state === 'qualified').map((item) => Object.freeze({ pointerPath: item.pointerPath, workspaceId: item.workspaceId, routeId: item.routeId, requirementId: item.requirementId, endpointParty: item.endpointParty, roleLabelHint: item.roleLabelHint, referenceTarget: item.referenceTarget, targetCarrierKind: item.targetCarrierKind, targetWorkspaceId: item.targetWorkspaceId, archivePath: item.archivePath, targetInnerPath: item.targetInnerPath, targetArchiveEntry: item.targetArchiveEntry, targetBytes: item.targetBytes, targetSha256: item.targetSha256 }))),
183
+ participantRoles: Object.freeze(participantRoleQualifications.filter((item) => item.state === 'qualified').map((item) => Object.freeze({ pointerPath: item.pointerPath, workspaceId: item.workspaceId, routeId: item.routeId, requirementId: item.requirementId, roleLabelHint: item.roleLabelHint, referenceTarget: item.referenceTarget, targetCarrierKind: item.targetCarrierKind, targetWorkspaceId: item.targetWorkspaceId, archivePath: item.archivePath, targetInnerPath: item.targetInnerPath, targetArchiveEntry: item.targetArchiveEntry, targetBytes: item.targetBytes, targetSha256: item.targetSha256 }))),
184
+ routeSelection: ingressPointer ? Object.freeze({ mode: String(ingressPointer.parsed.routeSelection || ''), selectedRouteId: String(ingressPointer.parsed.selectedRouteId || ''), candidateCount: Number(ingressPointer.parsed.candidateRouteCount || 0) }) : null,
185
+ carrierProjection,
186
+ coldConsumerProjection,
187
+ transportManifest: transport.state === 'absent' ? null : Object.freeze({ state: transport.state, path: RECIPIENT_V2_TRANSPORT_MANIFEST_PATH, sha256: transport.file ? sha256Hex(packageFileBytes(transport.file)) : '' }),
188
+ semanticFactsByPath: factsByPath,
189
+ findings: Object.freeze([...findings, ...compatibilityFindings]),
190
+ boundary: cleanCarrierPhase2
191
+ ? 'Artifact-first Phase 2 clean-carrier qualification reconstructs receiver truth only from visible semantic artifacts plus exact payload bytes and requires stored compatibility JSON to be absent.'
192
+ : 'Artifact-first Phase 1 qualification keeps semantic receiver artifacts independently qualifiable from compatibility JSON. Phase 1 still requires the derived JSON projection for interoperability, but it is not receiver semantic authority.'
193
+ });
194
+ }
@@ -0,0 +1,207 @@
1
+ import { packageFileBytes, sha256Hex } from '../../../export/package.bytes.js';
2
+ import { inspectStoredWorkspaceArchive } from './workspaceByteProvider.js';
3
+ import { parseRecipientV2Pointer, parseRecipientV2Relation } from './recipientV2.artifacts.js';
4
+ import { recipientV2TransportFacts } from './recipientV2.transportManifest.js';
5
+ import { PHASE1_COMPLETE_WORKSPACE_ROLE, PHASE1_BOUNDED_WORKSPACE_ROLE } from './recipientV2.artifactFirst.workspaces.js';
6
+ import { PHASE1_BOOTSTRAP_ROLE, PHASE1_CACHE_ROLE, currentSchemaId, decodeUtf8, oneFile, sectionText, fieldValue, markdownTarget, normalizeRoutePath, deepFreeze, finding } from './recipientV2.artifactFirst.shared.js';
7
+
8
+ export function deriveRecipientV2ArtifactFirstPhase1Facts(files = []) {
9
+ const facts = new Map();
10
+ const payloadByPath = new Map();
11
+ const archiveByLocation = new Map();
12
+ const archiveIdentity = (location = '') => {
13
+ const key = String(location || '');
14
+ if (!key) return null;
15
+ if (archiveByLocation.has(key)) return archiveByLocation.get(key);
16
+ const file = oneFile(files, key);
17
+ if (!file) { archiveByLocation.set(key, null); return null; }
18
+ const bytes = packageFileBytes(file);
19
+ const identity = Object.freeze({ file, bytes, sha256: sha256Hex(bytes), archive: inspectStoredWorkspaceArchive(bytes, { ownedBytes: true }) });
20
+ archiveByLocation.set(key, identity);
21
+ return identity;
22
+ };
23
+ for (const file of files) {
24
+ const path = String(file.path || '');
25
+ if (!/\.md$/i.test(path)) continue;
26
+ const markdown = decodeUtf8(packageFileBytes(file));
27
+ if (currentSchemaId(markdown) === 'tiinex.external.payload.v1') payloadByPath.set(path, parsePhase1Payload(markdown));
28
+ }
29
+ for (const file of files) {
30
+ const path = String(file.path || '');
31
+ if (!/\.md$/i.test(path)) continue;
32
+ const markdown = decodeUtf8(packageFileBytes(file));
33
+ const schemaId = currentSchemaId(markdown);
34
+ if (schemaId === 'tiinex.pointer.v1') {
35
+ const parsed = parseRecipientV2Pointer(markdown);
36
+ if (parsed.role === 'participant-role' || parsed.role === 'endpoint-role') {
37
+ const roleKind = parsed.role === 'endpoint-role' ? 'endpoint-role' : 'participant-role';
38
+ const targetPayload = payloadByPath.get(String(parsed.targetPayload || '')) || null;
39
+ const targetArchiveIdentity = targetPayload ? archiveIdentity(targetPayload.location) : null;
40
+ const archive = targetArchiveIdentity?.archive || null;
41
+ const targetPath = parsed.targetCarrierKind === 'workspace-cache-entry' ? parsed.targetArchiveEntry : parsed.targetInnerPath;
42
+ const targetMatches = archive?.state === 'qualified' ? archive.entries.filter((entry) => String(entry.path || '') === String(targetPath || '')) : [];
43
+ const target = targetMatches.length === 1 ? targetMatches[0] : null;
44
+ const targetBytes = target ? packageFileBytes({ data: target.data }) : new Uint8Array();
45
+ facts.set(path, recipientV2TransportFacts(roleKind, {
46
+ workspaceId: parsed.workspaceId || '',
47
+ routeId: parsed.routeId || '',
48
+ ...(roleKind === 'endpoint-role' ? { endpointRequirementId: parsed.endpointRequirementId || '', endpointParty: parsed.endpointParty || '' } : { participantRequirementId: parsed.participantRequirementId || '' }),
49
+ roleLabelHint: parsed.roleLabelHint || '',
50
+ referenceTarget: parsed.roleReference || '',
51
+ targetCarrierKind: parsed.targetCarrierKind || '',
52
+ targetWorkspaceId: parsed.targetWorkspaceId || '',
53
+ archivePath: targetPayload?.location || '',
54
+ archiveSha256: targetArchiveIdentity?.sha256 || '',
55
+ targetInnerPath: parsed.targetInnerPath || '',
56
+ targetArchiveEntry: parsed.targetArchiveEntry || '',
57
+ targetBytes: targetBytes.byteLength,
58
+ targetSha256: targetBytes.byteLength ? sha256Hex(targetBytes) : ''
59
+ }));
60
+ } else facts.set(path, recipientV2TransportFacts(parsed.role || 'navigation', {
61
+ workspaceId: parsed.workspaceId || '',
62
+ payloadArtifactPath: parsed.workspacePayload || '',
63
+ workspaceRelativeHandoffPath: parsed.handoffWorkspacePath || '',
64
+ routeId: parsed.routeId || '',
65
+ routeSelection: parsed.role === 'recovery-orientation' ? Object.freeze({ mode: parsed.routeSelection || '', selectedRouteId: parsed.selectedRouteId || '', candidateCount: Number(parsed.candidateRouteCount || 0) }) : undefined,
66
+ carrierLineage: parsed.role === 'recovery-orientation' ? Object.freeze({ dimension: parsed.carrierDimension || '', parentDimension: parsed.parentCarrierDimension || '', checkpointKind: parsed.carrierCheckpoint || '' }) : undefined
67
+ }));
68
+ } else if (schemaId === 'tiinex.external.payload.v1') {
69
+ const parsed = parsePhase1Payload(markdown);
70
+ if ([PHASE1_COMPLETE_WORKSPACE_ROLE, PHASE1_BOUNDED_WORKSPACE_ROLE].includes(parsed.payloadRole)) facts.set(path, recipientV2TransportFacts('workspace-representation-payload', { workspaceId: parsed.workspaceId, coverage: parsed.payloadRole === PHASE1_BOUNDED_WORKSPACE_ROLE ? 'bounded' : 'complete', archivePath: parsed.location || '', archiveBytes: Number(parsed.bytes || 0), archiveSha256: parsed.integrityValue || '' }));
71
+ else if (parsed.payloadRole === PHASE1_BOOTSTRAP_ROLE) facts.set(path, recipientV2TransportFacts('tooling-bootstrap', { archivePath: parsed.location || '', archiveBytes: Number(parsed.bytes || 0), archiveSha256: parsed.integrityValue || '', payloadRole: parsed.payloadRole }));
72
+ else if (parsed.payloadRole === PHASE1_CACHE_ROLE) {
73
+ const archive = archiveIdentity(parsed.location)?.archive || null;
74
+ const materials = parsed.materials.map((material) => {
75
+ const matches = archive?.state === 'qualified' ? archive.entries.filter((entry) => String(entry.path || '') === String(material.archiveEntry || '')) : [];
76
+ const entry = matches.length === 1 ? matches[0] : null;
77
+ const bytes = entry ? packageFileBytes({ data: entry.data }) : new Uint8Array();
78
+ return Object.freeze({ requirementId: material.requirementId, classification: material.classification, referenceTarget: material.referenceTarget, routeWorkspaceId: parsed.workspaceId, routePath: '', sourceRequirementId: material.requirementId, originalPath: '', archiveEntry: material.archiveEntry, bytes: bytes.byteLength, sha256: bytes.byteLength ? sha256Hex(bytes) : '' });
79
+ });
80
+ facts.set(path, recipientV2TransportFacts('workspace-dependency-cache', { workspaceId: parsed.workspaceId, archivePath: parsed.location || '', archiveBytes: Number(parsed.bytes || 0), archiveSha256: parsed.integrityValue || '', materials: Object.freeze(materials) }));
81
+ }
82
+ } else if (schemaId === 'tiinex.relation.v1') {
83
+ const parsed = parseRecipientV2Relation(markdown);
84
+ facts.set(path, recipientV2TransportFacts('workspace-representation', {
85
+ workspaceId: parsed.targetWorkspaceId || '', coverage: parsed.scope === 'bounded recipient-relative workspace materialization' ? 'bounded' : 'complete', workspaceArtifactInnerPath: parsed.targetWorkspaceInnerPath || '', payloadArtifactPath: parsed.source || '', relationType: parsed.relationType || '', relationDirection: parsed.direction || '', relationScope: parsed.scope || ''
86
+ }));
87
+ }
88
+ }
89
+ return facts;
90
+ }
91
+
92
+ export function parsePhase1Payload(markdown = '') {
93
+ const identity = sectionText(markdown, 'Payload Identity');
94
+ const location = sectionText(markdown, 'Payload Location');
95
+ const integrity = sectionText(markdown, 'Integrity Reference');
96
+ return Object.freeze({
97
+ workspaceId: fieldValue(identity, 'Workspace Id'),
98
+ payloadRole: fieldValue(identity, 'Payload Role'),
99
+ bytes: Number(fieldValue(identity, 'Byte Size') || 0),
100
+ location: markdownTarget(fieldValue(location, 'Location')),
101
+ integrityStatus: fieldValue(integrity, 'Integrity Status'),
102
+ integrityMethod: fieldValue(integrity, 'Integrity Method'),
103
+ integrityValue: fieldValue(integrity, 'Integrity Value'),
104
+ integrityTarget: fieldValue(integrity, 'Integrity Target'),
105
+ materials: parsePhase1MaterialBindings(markdown)
106
+ });
107
+ }
108
+
109
+ function parsePhase1MaterialBindings(markdown = '') {
110
+ const section = sectionText(markdown, 'Payload Material Bindings');
111
+ if (!section) return Object.freeze([]);
112
+ const out = [];
113
+ let current = null;
114
+ for (const line of section.split(/\r?\n/)) {
115
+ const requirement = line.match(/^\s*-\s+Requirement Id:\s*(.*?)\s*$/i);
116
+ if (requirement) {
117
+ if (current) out.push(Object.freeze(current));
118
+ current = { requirementId: String(requirement[1] || '').trim(), classification: '', referenceTarget: '', archiveEntry: '' };
119
+ continue;
120
+ }
121
+ if (!current) continue;
122
+ const classification = line.match(/^\s+-\s+Classification:\s*(.*?)\s*$/i);
123
+ const reference = line.match(/^\s+-\s+Material Reference:\s*(.*?)\s*$/i);
124
+ const archiveEntry = line.match(/^\s+-\s+Archive Entry:\s*(.*?)\s*$/i);
125
+ if (classification) current.classification = String(classification[1] || '').trim();
126
+ else if (reference) current.referenceTarget = String(reference[1] || '').trim();
127
+ else if (archiveEntry) current.archiveEntry = String(archiveEntry[1] || '').trim();
128
+ }
129
+ if (current) out.push(Object.freeze(current));
130
+ return Object.freeze(out);
131
+ }
132
+
133
+ export function selectPhase1SourceRoute(carrierProjection = {}, selector = '', findings = []) {
134
+ const candidates = [...(carrierProjection.routes || [])].filter((route) => String(route.state || '') === 'qualified');
135
+ const requested = String(selector || '').trim();
136
+ if (!requested) {
137
+ if (candidates.length === 1) return deepFreeze({ state: 'qualified', mode: 'implicit-single-qualified-route', selector: '', candidateCount: 1, route: candidates[0] });
138
+ findings.push(finding('error', candidates.length > 1 ? 'portable.handoff-v2-phase1.route-selection.required' : 'portable.handoff-v2-phase1.route-selection.unresolved', candidates.length > 1 ? 'Phase 1 artifact-first manufacture requires an explicit route selector when more than one qualified Handoff candidate exists.' : 'Phase 1 artifact-first manufacture requires exactly one qualified Handoff route candidate.', { candidateCount: candidates.length }));
139
+ return deepFreeze({ state: 'blocked', mode: candidates.length > 1 ? 'selection-required' : 'unresolved', selector: '', candidateCount: candidates.length, route: null });
140
+ }
141
+ const normalized = normalizeRoutePath(requested);
142
+ const matches = candidates.filter((route) => String(route.id || '') === requested || normalizeRoutePath(route.workspaceRelativePath || '') === normalized || `${String(route.workspaceId || '')}:${normalizeRoutePath(route.workspaceRelativePath || '')}` === requested);
143
+ if (matches.length !== 1) {
144
+ findings.push(finding('error', matches.length > 1 ? 'portable.handoff-v2-phase1.route-selection.ambiguous' : 'portable.handoff-v2-phase1.route-selection.unresolved', 'Explicit Phase 1 route selector must bind exactly one qualified Handoff route candidate.', { selector: requested, matches: matches.length, candidateCount: candidates.length }));
145
+ return deepFreeze({ state: 'blocked', mode: matches.length > 1 ? 'ambiguous' : 'unresolved', selector: requested, candidateCount: candidates.length, route: null });
146
+ }
147
+ return deepFreeze({ state: 'qualified', mode: 'explicit-qualified-route-selector', selector: requested, candidateCount: candidates.length, route: matches[0] });
148
+ }
149
+
150
+ export function qualifyPhase1BootstrapPayload(bootstrapPayload = null, semanticFiles = [], findings = []) {
151
+ if (!bootstrapPayload) return null;
152
+ const localFindings = [];
153
+ if (String(bootstrapPayload.parsed?.payloadRole || '') !== PHASE1_BOOTSTRAP_ROLE) localFindings.push(finding('error', 'portable.handoff-v2-phase1.bootstrap.role-mismatch', 'Portable Tooling bootstrap External Payload must declare the accepted bootstrap payload role.'));
154
+ const location = String(bootstrapPayload.parsed?.location || '');
155
+ const matches = semanticFiles.filter((file) => String(file.path || '') === location);
156
+ if (!location || matches.length !== 1) localFindings.push(finding('error', 'portable.handoff-v2-phase1.bootstrap.location-unresolved', 'Portable Tooling bootstrap External Payload Location must resolve exactly one carried payload file.', { path: location, count: matches.length }));
157
+ let bytes = new Uint8Array();
158
+ if (matches.length === 1) {
159
+ bytes = packageFileBytes(matches[0]);
160
+ const digest = sha256Hex(bytes);
161
+ if (Number(bootstrapPayload.parsed?.bytes || 0) !== bytes.byteLength || String(bootstrapPayload.parsed?.integrityStatus || '') !== 'verified' || String(bootstrapPayload.parsed?.integrityMethod || '') !== 'sha256' || String(bootstrapPayload.parsed?.integrityValue || '') !== digest) localFindings.push(finding('error', 'portable.handoff-v2-phase1.bootstrap.identity-mismatch', 'Portable Tooling bootstrap visible byte identity diverges from the exact carried payload bytes.', { path: location }));
162
+ const archive = inspectStoredWorkspaceArchive(bytes, { ownedBytes: true });
163
+ if (archive.state !== 'qualified') localFindings.push(finding('error', 'portable.handoff-v2-phase1.bootstrap.archive-invalid', 'Portable Tooling bootstrap payload is not a qualified deterministic stored-ZIP representation.', { path: location, findings: archive.findings || [] }));
164
+ }
165
+ findings.push(...localFindings);
166
+ return deepFreeze({ state: localFindings.some((item) => item.severity === 'error') ? 'blocked' : 'qualified', artifactPath: String(bootstrapPayload.path || ''), payloadPath: location, payloadRole: String(bootstrapPayload.parsed?.payloadRole || ''), bytes: bytes.byteLength, sha256: bytes.byteLength ? sha256Hex(bytes) : '', findings: Object.freeze(localFindings), boundary: 'Visible External Payload ownership of exact portable Tooling bootstrap bytes. Ingress navigation and package placement create no Parent or package authority.' });
167
+ }
168
+
169
+ export function qualifyPhase1CachePayload(cachePayload = null, semanticFiles = [], findings = []) {
170
+ if (!cachePayload) return null;
171
+ const localFindings = [];
172
+ const location = String(cachePayload.parsed?.location || '');
173
+ const matches = semanticFiles.filter((file) => String(file.path || '') === location);
174
+ if (!location || matches.length !== 1) localFindings.push(finding('error', 'portable.handoff-v2-phase1.cache.location-unresolved', 'Selected-route cache External Payload Location must resolve exactly one carried payload file.', { path: location, count: matches.length }));
175
+ let bytes = new Uint8Array();
176
+ let archive = null;
177
+ const materialQualifications = [];
178
+ if (matches.length === 1) {
179
+ bytes = packageFileBytes(matches[0]);
180
+ const digest = sha256Hex(bytes);
181
+ if (Number(cachePayload.parsed?.bytes || 0) !== bytes.byteLength || String(cachePayload.parsed?.integrityStatus || '') !== 'verified' || String(cachePayload.parsed?.integrityMethod || '') !== 'sha256' || String(cachePayload.parsed?.integrityValue || '') !== digest) localFindings.push(finding('error', 'portable.handoff-v2-phase1.cache.identity-mismatch', 'Selected-route cache visible byte identity diverges from exact carried cache bytes.', { path: location }));
182
+ archive = inspectStoredWorkspaceArchive(bytes, { ownedBytes: true });
183
+ if (archive.state !== 'qualified') localFindings.push(finding('error', 'portable.handoff-v2-phase1.cache.archive-invalid', 'Selected-route cache payload is not a qualified deterministic stored-ZIP representation.', { path: location, findings: archive.findings || [] }));
184
+ }
185
+ const seenRequirements = new Set();
186
+ const seenReferences = new Set();
187
+ const seenEntries = new Set();
188
+ for (const material of cachePayload.parsed?.materials || []) {
189
+ const requirementId = String(material.requirementId || '');
190
+ const referenceTarget = String(material.referenceTarget || '');
191
+ const archiveEntry = String(material.archiveEntry || '');
192
+ if (!requirementId || !referenceTarget || !archiveEntry) {
193
+ localFindings.push(finding('error', 'portable.handoff-v2-phase1.cache.material-binding-incomplete', 'Every selected-route cache material binding must visibly declare requirement id, material reference, and archive entry.'));
194
+ continue;
195
+ }
196
+ if (seenRequirements.has(requirementId) || seenReferences.has(referenceTarget) || seenEntries.has(archiveEntry)) localFindings.push(finding('error', 'portable.handoff-v2-phase1.cache.material-binding-ambiguous', 'Selected-route cache material bindings must be one-to-one by requirement id, material reference, and archive entry.', { requirementId, referenceTarget, archiveEntry }));
197
+ seenRequirements.add(requirementId); seenReferences.add(referenceTarget); seenEntries.add(archiveEntry);
198
+ const entryMatches = archive?.state === 'qualified' ? archive.entries.filter((entry) => String(entry.path || '') === archiveEntry) : [];
199
+ if (archive?.state === 'qualified' && entryMatches.length !== 1) localFindings.push(finding('error', 'portable.handoff-v2-phase1.cache.material-entry-unresolved', 'Selected-route cache material binding must resolve exactly one exact cache entry.', { requirementId, referenceTarget, archiveEntry, count: entryMatches.length }));
200
+ const entry = entryMatches.length === 1 ? entryMatches[0] : null;
201
+ const entryBytes = entry ? packageFileBytes({ data: entry.data }) : new Uint8Array();
202
+ materialQualifications.push(deepFreeze({ requirementId, classification: String(material.classification || ''), referenceTarget, archiveEntry, bytes: entryBytes.byteLength, sha256: entryBytes.byteLength ? sha256Hex(entryBytes) : '' }));
203
+ }
204
+ if (!(cachePayload.parsed?.materials || []).length) localFindings.push(finding('error', 'portable.handoff-v2-phase1.cache.material-bindings-missing', 'Selected-route cache External Payload must visibly bind every owned detached material to one archive entry.'));
205
+ findings.push(...localFindings);
206
+ return deepFreeze({ state: localFindings.some((item) => item.severity === 'error') ? 'blocked' : 'qualified', workspaceId: String(cachePayload.parsed?.workspaceId || ''), artifactPath: String(cachePayload.path || ''), payloadPath: location, payloadRole: String(cachePayload.parsed?.payloadRole || ''), bytes: bytes.byteLength, sha256: bytes.byteLength ? sha256Hex(bytes) : '', archive, materials: Object.freeze(materialQualifications), findings: Object.freeze(localFindings), boundary: 'Visible cache External Payload ownership plus exact cache ZIP bytes and visible material-to-entry bindings. Cache location and compatibility JSON do not create material authority.' });
207
+ }
@@ -0,0 +1,69 @@
1
+ import { packageFileBytes, sha256Hex } from '../../../export/package.bytes.js';
2
+ import { inspectRecipientV2ArtifactFirstPhase1Specimen } from './recipientV2.artifactFirst.inspect.js';
3
+ import { RECIPIENT_V2_READ_PATH, RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID, PHASE2_CLEAN_PROFILE, decodeUtf8, deepFreeze } from './recipientV2.artifactFirst.shared.js';
4
+
5
+ export function isRecipientV2ArtifactFirstPhase1Surface(files = []) {
6
+ return files.some((file) => {
7
+ if (String(file.path || '') !== RECIPIENT_V2_READ_PATH) return false;
8
+ const markdown = decodeUtf8(packageFileBytes(file));
9
+ return markdown.includes('Artifact-First Phase 1 Specimen') || markdown.includes(`Carrier Profile: ${PHASE2_CLEAN_PROFILE}`);
10
+ });
11
+ }
12
+
13
+ export function inspectRecipientFacingV2ArtifactFirstPhase1(bundle = {}) {
14
+ const inspection = inspectRecipientV2ArtifactFirstPhase1Specimen(bundle);
15
+ const files = Array.isArray(bundle.files) ? bundle.files : [];
16
+ const facts = inspection.semanticFactsByPath || new Map();
17
+ const ingressFile = files.find((file) => String(file.path || '') === RECIPIENT_V2_READ_PATH) || null;
18
+ const payloadEntries = [...facts.entries()].filter(([, item]) => item?.role === 'workspace-representation-payload');
19
+ const relationEntries = [...facts.entries()].filter(([, item]) => item?.role === 'workspace-representation');
20
+ const relationByWorkspace = new Map(relationEntries.map((entry) => [String(entry[1]?.workspaceId || ''), entry]));
21
+ const routeEntries = [...facts.entries()].filter(([, item]) => item?.role === 'handoff-route');
22
+ const bootstrapEntry = [...facts.entries()].find(([, item]) => item?.role === 'tooling-bootstrap') || null;
23
+ const cacheEntries = [...facts.entries()].filter(([, item]) => item?.role === 'workspace-dependency-cache');
24
+ return deepFreeze({
25
+ schema: 'tiinex.portable.recipient-facing-handoff-v2.inspection.v1',
26
+ detected: true,
27
+ status: inspection.status === 'ready' ? 'valid' : 'invalid',
28
+ format: inspection.format || RECIPIENT_V2_ARTIFACT_FIRST_PHASE1_FORMAT_ID,
29
+ rootArtifact: null,
30
+ readArtifact: ingressFile ? Object.freeze({ path: RECIPIENT_V2_READ_PATH, schemaId: 'tiinex.pointer.v1', sha256: sha256Hex(packageFileBytes(ingressFile)), facts: facts.get(RECIPIENT_V2_READ_PATH) || null }) : null,
31
+ workspaces: Object.freeze(payloadEntries.map(([payloadPath, item]) => {
32
+ const relationEntry = relationByWorkspace.get(String(item?.workspaceId || '')) || null;
33
+ return Object.freeze({
34
+ workspaceId: String(item?.workspaceId || ''),
35
+ workspaceArtifactPath: '',
36
+ workspaceRepresentationArtifactPath: String(relationEntry?.[0] || ''),
37
+ workspacePayloadArtifactPath: payloadPath,
38
+ workspaceArchivePath: String(item?.archivePath || ''),
39
+ sourceWorkspaceTargetInnerPath: String(relationEntry?.[1]?.workspaceArtifactInnerPath || ''),
40
+ sourceWorkspaceTargetSha256: ''
41
+ });
42
+ })),
43
+ routes: Object.freeze(routeEntries.map(([pointerPath, item]) => {
44
+ const routeId = String(item?.routeId || `handoff-route:${String(item?.workspaceId || '')}:${String(item?.workspaceRelativeHandoffPath || '')}`);
45
+ return Object.freeze({
46
+ pointerPath,
47
+ routeId,
48
+ workspaceId: String(item?.workspaceId || ''),
49
+ workspaceRelativeHandoffPath: String(item?.workspaceRelativeHandoffPath || ''),
50
+ endpointRolePointers: Object.freeze((inspection.endpointRoles || []).filter((role) => String(role.routeId || '') === routeId).map((role) => role.pointerPath)),
51
+ participantRolePointers: Object.freeze((inspection.participantRoles || []).filter((role) => String(role.routeId || '') === routeId).map((role) => role.pointerPath))
52
+ });
53
+ })),
54
+ endpointRoles: Object.freeze(inspection.endpointRoles || []),
55
+ participantRoles: Object.freeze(inspection.participantRoles || []),
56
+ caches: Object.freeze(inspection.caches || cacheEntries.map(([artifactPath, item]) => Object.freeze({ workspaceId: String(item?.workspaceId || ''), artifactPath, archivePath: String(item?.archivePath || ''), materials: Object.freeze(item?.materials || []) }))),
57
+ bootstrapInspection: bootstrapEntry ? Object.freeze({ status: inspection.bootstrapQualification?.state === 'qualified' ? 'valid' : 'invalid', path: bootstrapEntry[0], state: inspection.bootstrapQualification?.state || 'blocked', archivePath: String(bootstrapEntry[1]?.archivePath || ''), bytes: Number(bootstrapEntry[1]?.archiveBytes || 0), sha256: String(bootstrapEntry[1]?.archiveSha256 || ''), findings: Object.freeze([...(inspection.bootstrapQualification?.findings || [])]) }) : null,
58
+ transportManifest: inspection.transportManifest,
59
+ artifactFacts: Object.freeze([...facts.entries()].map(([path, item]) => Object.freeze({ path, facts: item }))),
60
+ descriptor: null,
61
+ workspaceByteProvider: null,
62
+ carrierProjection: inspection.carrierProjection,
63
+ coldConsumerProjection: inspection.coldConsumerProjection,
64
+ findings: inspection.findings,
65
+ findingSummary: Object.freeze({ errors: inspection.findings.filter((item) => item.severity === 'error').length, findings: inspection.findings.length }),
66
+ boundary: inspection.boundary,
67
+ phase1: inspection
68
+ });
69
+ }