@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,364 @@
1
+ import { parseArtifactMarkdown } from '../../../artifacts/artifact.parse.js';
2
+ import { packageFileBytes, sha256Hex } from '../../../export/package.bytes.js';
3
+ import { portableFinding } from '../findings.js';
4
+ import { inspectStoredWorkspaceArchive } from './workspaceByteProvider.js';
5
+ import { recipientV2FactsIndex } from './recipientV2.transportManifest.js';
6
+ import { parseNamedDeclarationSection } from '../schema/named.declarations.js';
7
+ import { resolveColdStartRolePointerMaterial } from './coldStartRolePointers.js';
8
+ import {
9
+ decodeUtf8,
10
+ deepFreeze,
11
+ findFile,
12
+ normalizePath,
13
+ sectionField,
14
+ sectionReferenceTarget,
15
+ sectionText
16
+ } from './coldStartQualification.shared.js';
17
+
18
+
19
+ export function createColdStartMaterialContext() {
20
+ return {
21
+ workspaceArchives: new WeakMap(),
22
+ recipientFacts: new WeakMap()
23
+ };
24
+ }
25
+
26
+ export function recipientFactsIndexForColdStart(bundle = {}, context = null) {
27
+ if (!context?.recipientFacts || !bundle || typeof bundle !== 'object') return recipientV2FactsIndex(bundle);
28
+ const cached = context.recipientFacts.get(bundle);
29
+ if (cached) return cached;
30
+ const derived = recipientV2FactsIndex(bundle);
31
+ context.recipientFacts.set(bundle, derived);
32
+ return derived;
33
+ }
34
+
35
+ function inspectWorkspaceArchiveForColdStart(file, context = null) {
36
+ if (!file) return null;
37
+ if (!context?.workspaceArchives || typeof file !== 'object') {
38
+ return inspectStoredWorkspaceArchive(packageFileBytes(file), { ownedBytes: true });
39
+ }
40
+ const cached = context.workspaceArchives.get(file);
41
+ if (cached) return cached;
42
+ const inspected = inspectStoredWorkspaceArchive(packageFileBytes(file), { ownedBytes: true });
43
+ context.workspaceArchives.set(file, inspected);
44
+ return inspected;
45
+ }
46
+
47
+ export function collectPackageRoleMaterials(bundle = {}) {
48
+ if (!Array.isArray(bundle?.files)) return [];
49
+ const out = [];
50
+ for (const file of bundle.files) {
51
+ const path = String(file.path || '');
52
+ if (!/\.trace\.md$/i.test(path) || /\.schema\.md$/i.test(path) || path.startsWith('tiinex.package/') || path.startsWith('tiinex.bootstrap/')) continue;
53
+ const markdown = decodeUtf8(packageFileBytes(file));
54
+ if (!/Current Schema:\s*(?:\[)?tiinex\.party\.role\.v1\b/i.test(markdown)) continue;
55
+ out.push(Object.freeze({ path, markdown, explicit: false }));
56
+ }
57
+ return out;
58
+ }
59
+
60
+ export function resolveReferencedRoleMaterial(bundle = {}, handoff = {}, orientation = null, selectedRoute = null, findings = [], context = null) {
61
+ const reference = String(handoff.toReference || '').trim();
62
+ if (!reference) return null;
63
+ if (!isExternalReference(reference)) {
64
+ const workspaceZip = findFile(bundle, String(handoff.packagePath || ''));
65
+ if (workspaceZip && /\.zip$/i.test(String(workspaceZip.path || ''))) {
66
+ const archive = inspectWorkspaceArchiveForColdStart(workspaceZip, context);
67
+ if (archive.state === 'qualified') {
68
+ const resolvedPath = resolveRelativeArtifactPath(handoff.workspaceRelativePath || '', reference);
69
+ const matches = resolvedPath ? (archive.entries || []).filter((entry) => normalizePath(entry.path || '') === resolvedPath) : [];
70
+ if (matches.length === 1) {
71
+ const markdown = decodeUtf8(matches[0].data || new Uint8Array());
72
+ if (markdown) return Object.freeze({ path: `${workspaceZip.path}::${resolvedPath}`, markdown, explicit: false, exactReference: reference });
73
+ }
74
+ if (matches.length > 1) findings.push(portableFinding('error', 'portable.cold-start.role.reference-material.ambiguous', 'Handoff To Reference resolves to multiple entries in the selected Workspace archive.', { reference, resolvedPath }));
75
+ }
76
+ }
77
+ }
78
+ const endpointPointerMatches = [];
79
+ const factsIndex = recipientFactsIndexForColdStart(bundle, context).map;
80
+ for (const pointerPath of selectedRoute?.endpointRolePointers || []) {
81
+ const compatibilityFacts = factsIndex.get(String(pointerPath || '')) || null;
82
+ const projectedFacts = (orientation?.endpointRoles || []).find((item) => String(item.pointerPath || '') === String(pointerPath || '')) || null;
83
+ const facts = compatibilityFacts?.role === 'endpoint-role'
84
+ ? compatibilityFacts
85
+ : projectedFacts
86
+ ? { role: 'endpoint-role', ...projectedFacts }
87
+ : {};
88
+ if (facts.role !== 'endpoint-role' || String(facts.endpointParty || '').toLowerCase() !== 'to') continue;
89
+ if (facts.referenceTarget && String(facts.referenceTarget) !== reference) continue;
90
+ const material = resolveColdStartRolePointerMaterial(bundle, facts, findings, String(pointerPath || ''), 'endpoint-role');
91
+ if (material) endpointPointerMatches.push(Object.freeze({ ...material, exactReference: reference }));
92
+ }
93
+ if (endpointPointerMatches.length === 1) return endpointPointerMatches[0];
94
+ if (endpointPointerMatches.length > 1) {
95
+ findings.push(portableFinding('error', 'portable.cold-start.role.reference-material.ambiguous', 'Handoff To Reference resolves through multiple qualified endpoint Role Pointers.', { reference, count: endpointPointerMatches.length }));
96
+ return null;
97
+ }
98
+ const cacheMatches = [];
99
+ for (const file of bundle.files || []) {
100
+ if (!/\.trace\.md$/i.test(String(file.path || ''))) continue;
101
+ const markdown = decodeUtf8(packageFileBytes(file));
102
+ const facts = factsIndex.get(String(file.path || '')) || null;
103
+ if (facts?.role !== 'workspace-dependency-cache' && !/dependency cache/i.test(String(facts?.role || ''))) continue;
104
+ for (const material of facts.materials || []) {
105
+ if (String(material.referenceTarget || '') !== reference) continue;
106
+ const archiveFile = findFile(bundle, String(facts.archivePath || ''));
107
+ if (!archiveFile) continue;
108
+ const archive = inspectWorkspaceArchiveForColdStart(archiveFile, context);
109
+ if (archive.state !== 'qualified') continue;
110
+ const entries = (archive.entries || []).filter((entry) => String(entry.path || '') === String(material.archiveEntry || ''));
111
+ if (entries.length !== 1) continue;
112
+ const roleMarkdown = decodeUtf8(entries[0].data || new Uint8Array());
113
+ if (roleMarkdown) cacheMatches.push(Object.freeze({ path: `${archiveFile.path}::${material.archiveEntry}`, markdown: roleMarkdown, explicit: false, exactReference: reference }));
114
+ }
115
+ }
116
+ if (cacheMatches.length === 1) return cacheMatches[0];
117
+ if (cacheMatches.length > 1) findings.push(portableFinding('error', 'portable.cold-start.role.reference-material.ambiguous', 'Handoff To Reference resolves to multiple cached exact byte carriers.', { reference, count: cacheMatches.length }));
118
+ return null;
119
+ }
120
+
121
+ function resolveRelativeArtifactPath(basePath = '', reference = '') {
122
+ const target = String(reference || '').split('#')[0].trim().replace(/\\/g, '/');
123
+ if (!target || target.startsWith('/') || isExternalReference(target)) return '';
124
+ const base = normalizePath(basePath).split('/'); base.pop();
125
+ for (const part of target.split('/')) {
126
+ if (!part || part === '.') continue;
127
+ if (part === '..') { if (!base.length) return ''; base.pop(); }
128
+ else base.push(part);
129
+ }
130
+ return normalizePath(base.join('/'));
131
+ }
132
+
133
+ function isExternalReference(value = '') { return /^[a-z][a-z0-9+.-]*:\/\//i.test(String(value || '').trim()); }
134
+
135
+ export function normalizeRoleMaterials(value) {
136
+ const list = Array.isArray(value) ? value : value ? [value] : [];
137
+ return list.flatMap((item, index) => {
138
+ if (typeof item === 'string') return [Object.freeze({ path: `explicit-role-${index + 1}.trace.md`, markdown: item, explicit: true })];
139
+ const markdown = String(item?.markdown || item?.content || '');
140
+ if (!markdown) return [];
141
+ return [Object.freeze({ path: String(item.path || `explicit-role-${index + 1}.trace.md`), markdown, explicit: true })];
142
+ });
143
+ }
144
+
145
+ export function dedupeRoleMaterials(entries) {
146
+ const map = new Map();
147
+ for (const entry of entries) {
148
+ const markdown = String(entry.markdown || '');
149
+ const key = `${entry.path}\u0000${markdown}`;
150
+ if (!map.has(key)) map.set(key, entry);
151
+ }
152
+ return [...map.values()];
153
+ }
154
+
155
+ export function parseRoleMaterial(entry) {
156
+ try {
157
+ const parsed = parseArtifactMarkdown(entry.markdown || '');
158
+ const schemaId = String(parsed.envelope?.current?.schema?.id || '');
159
+ if (schemaId !== 'tiinex.party.role.v1') return null;
160
+ const roleSection = sectionText(parsed.body?.text || '', 'Role Identity');
161
+ const boundarySection = sectionText(parsed.body?.text || '', 'Role Boundary');
162
+ const authoritySection = sectionText(parsed.body?.text || '', 'Authority And Responsibility Boundary');
163
+ const limitsSection = sectionText(parsed.body?.text || '', 'Interpretation Limits');
164
+ const label = sectionField(roleSection, 'Role Label');
165
+ return deepFreeze({
166
+ path: entry.path,
167
+ explicit: Boolean(entry.explicit),
168
+ sha256: sha256Hex(new TextEncoder().encode(entry.markdown || '')),
169
+ schemaId,
170
+ title: parsed.title || '',
171
+ label,
172
+ roleKind: sectionField(roleSection, 'Role Kind'),
173
+ boundary: Object.freeze({ inScope: sectionField(boundarySection, 'In Scope'), outOfScope: sectionField(boundarySection, 'Out Of Scope'), context: sectionField(boundarySection, 'Context') }),
174
+ authorityBoundary: Object.freeze({ mayDo: sectionField(authoritySection, 'May Do'), doesNotAuthorize: sectionField(authoritySection, 'Does Not Authorize'), reviewBoundary: sectionField(authoritySection, 'Review Boundary') }),
175
+ interpretationLimits: Object.freeze({ doesNotProve: sectionField(limitsSection, 'Does Not Prove'), mustNotBeTreatedAs: sectionField(limitsSection, 'Must Not Be Treated As') }),
176
+ parentTrace: String(parsed.envelope?.parent?.trace || ''),
177
+ parentSchemaId: String(parsed.envelope?.parent?.schema?.id || '')
178
+ });
179
+ } catch {
180
+ return null;
181
+ }
182
+ }
183
+
184
+ export function projectGroundedContinuation({ bundle = {}, route = '', grounding = {}, qualification = {}, packageSourcePath = '' } = {}, context = null) {
185
+ const selectedRouteId = String(grounding.selectedRoute?.id || '');
186
+ const requiredContext = Object.freeze((grounding.selectedRoute?.requiredClosure?.requirements || []).map((entry) => hydrateRequiredContextEntry(bundle, entry, context)));
187
+ const unresolvedRequired = requiredContext.filter((entry) => entry.state !== 'qualified');
188
+ const groundingBlocked = String(grounding.status || '') === 'blocked';
189
+ const continuationReady = Boolean(selectedRouteId) && !groundingBlocked && unresolvedRequired.length === 0;
190
+ return deepFreeze({
191
+ state: continuationReady ? 'ready' : 'blocked',
192
+ substantiveWorkMayBegin: continuationReady,
193
+ qualificationState: String(qualification.status || ''),
194
+ selectedRoute: Object.freeze({
195
+ id: selectedRouteId,
196
+ selector: String(route || ''),
197
+ workspaceId: String(grounding.selectedRoute?.workspaceId || ''),
198
+ pointerPath: String(grounding.selectedRoute?.pointerPath || '')
199
+ }),
200
+ transfer: Object.freeze([...(grounding.handoff?.transfers || [])]),
201
+ requiredContext,
202
+ completionExpectation: grounding.handoff?.completionExpectation || Object.freeze({ signalKind: '', signalMeaning: '', returnTo: '' }),
203
+ returnPackage: projectReturnPackageContinuation(grounding, packageSourcePath),
204
+ next: continuationReady
205
+ ? 'Consume the qualified Required Context projection below, then continue substantive work within the grounded Handoff and Role boundaries. No Tooling API discovery is required.'
206
+ : 'Do not begin substantive work until the selected Handoff and every Required Context dependency are qualified.',
207
+ boundary: 'Grounded continuation projection only. Handoff Transfers and Completion Expectation come from exact selected Handoff bytes; Required Context comes from exact route closure and is not inferred from nearby Workspace material.'
208
+ });
209
+ }
210
+
211
+ function projectReturnPackageContinuation(grounding = {}, packageSourcePath = '') {
212
+ const lineage = grounding.orientation?.carrierLineage || {};
213
+ const dimension = String(lineage.dimension || '').trim();
214
+ const expectedChild = dimension ? `${dimension}-1` : '';
215
+ const returnTo = String(grounding.handoff?.completionExpectation?.returnTo || '').trim();
216
+ return Object.freeze({
217
+ expected: Boolean(returnTo),
218
+ returnTo,
219
+ parentDimension: dimension,
220
+ defaultMode: 'continue',
221
+ defaultNextDimension: expectedChild,
222
+ parentPackagePath: String(packageSourcePath || ''),
223
+ manufactureRule: packageSourcePath
224
+ ? `When manufacturing a return Handoff package derived from this carrier, pass --package-parent ${String(packageSourcePath)}. Tooling owns the next child dimension. Use --package-major --major-reason <milestone> only at an explicit self-contained checkpoint.`
225
+ : 'When manufacturing a return Handoff package, pass the received carrier as --package-parent. Tooling owns the next child dimension. Use --package-major --major-reason <milestone> only at an explicit self-contained checkpoint.',
226
+ boundary: 'Return carrier lineage is a human progress/retention projection only. The default is child continuation; major advancement is explicit and requires complete carried Workspace snapshots plus a meaningful closure reason.'
227
+ });
228
+ }
229
+
230
+ function hydrateRequiredContextEntry(bundle = {}, entry = {}, context = null) {
231
+ const resolution = entry.resolution || {};
232
+ const base = {
233
+ requirementId: String(entry.requirementId || ''),
234
+ name: String(entry.name || ''),
235
+ state: String(entry.state || resolution.state || 'unresolved'),
236
+ referenceTarget: String(entry.referenceTarget || ''),
237
+ kind: String(resolution.kind || ''),
238
+ workspaceId: String(resolution.workspaceId || ''),
239
+ archivePackagePath: String(resolution.archivePackagePath || resolution.packagePath || ''),
240
+ innerPath: String(resolution.innerPath || resolution.workspaceRelativePath || ''),
241
+ packagePath: String(resolution.packagePath || ''),
242
+ providerMode: String(resolution.providerMode || ''),
243
+ bytes: Number(resolution.bytes || 0),
244
+ sha256: String(resolution.sha256 || '')
245
+ };
246
+ if (base.state !== 'qualified') return Object.freeze({ ...base, contentState: 'unavailable', content: '' });
247
+ const hydrated = resolveQualifiedMaterialBytes(bundle, resolution, context);
248
+ if (!hydrated.bytes) return Object.freeze({ ...base, state: 'unresolved', contentState: 'unavailable', content: '' });
249
+ const actualSha256 = sha256Hex(hydrated.bytes);
250
+ const identityQualified = (!base.bytes || hydrated.bytes.byteLength === base.bytes) && (!base.sha256 || actualSha256 === base.sha256);
251
+ const text = identityQualified && hydrated.bytes.byteLength <= 65536 ? decodeUtf8(hydrated.bytes) : '';
252
+ return Object.freeze({
253
+ ...base,
254
+ state: identityQualified ? 'qualified' : 'identity-mismatch',
255
+ actualBytes: hydrated.bytes.byteLength,
256
+ actualSha256,
257
+ contentState: text ? 'hydrated-text' : identityQualified ? 'qualified-locator-only' : 'unavailable',
258
+ content: text
259
+ });
260
+ }
261
+
262
+ function resolveQualifiedMaterialBytes(bundle = {}, resolution = {}, context = null) {
263
+ const kind = String(resolution.kind || '');
264
+ if (kind === 'workspace-archive-entry' || kind === 'workspace-cache-entry') {
265
+ const archivePath = String(resolution.archivePackagePath || resolution.packagePath || '');
266
+ const innerPath = normalizePath(kind === 'workspace-cache-entry'
267
+ ? (resolution.archiveEntry || resolution.innerPath || '')
268
+ : (resolution.innerPath || resolution.workspaceRelativePath || ''));
269
+ const archiveFile = findFile(bundle, archivePath);
270
+ if (!archiveFile || !innerPath) return Object.freeze({ bytes: null });
271
+ const archive = inspectWorkspaceArchiveForColdStart(archiveFile, context);
272
+ if (archive.state !== 'qualified') return Object.freeze({ bytes: null });
273
+ const matches = (archive.entries || []).filter((candidate) => normalizePath(candidate.path || '') === innerPath);
274
+ return Object.freeze({ bytes: matches.length === 1 ? packageFileBytes({ data: matches[0].data }) : null });
275
+ }
276
+ const packagePath = String(resolution.packagePath || '');
277
+ const file = packagePath ? findFile(bundle, packagePath) : null;
278
+ return Object.freeze({ bytes: file ? packageFileBytes(file) : null });
279
+ }
280
+
281
+ export function parseHandoffGrounding(markdown, route) {
282
+ const parties = sectionText(markdown, 'Handoff Parties');
283
+ const transferSection = parseNamedDeclarationSection(markdown, '## Transfers');
284
+ const completion = sectionText(markdown, 'Completion Expectation');
285
+ const transfers = Object.freeze((transferSection.entries || []).filter((entry) => String(entry.name || '').trim().toLowerCase() !== 'none').map((entry) => Object.freeze({
286
+ id: String(entry.name || ''),
287
+ transferKind: String(entry.fields?.['Transfer Kind'] || ''),
288
+ description: String(entry.fields?.Description || ''),
289
+ boundary: String(entry.fields?.Boundary || '')
290
+ })));
291
+ return deepFreeze({
292
+ schemaId: /Current Schema:\s*(?:\[)?tiinex\.handoff\.v1\b/i.test(markdown) ? 'tiinex.handoff.v1' : '',
293
+ purpose: sectionField(parties, 'Purpose'),
294
+ from: sectionField(parties, 'From'),
295
+ fromKind: sectionField(parties, 'From Kind'),
296
+ to: sectionField(parties, 'To'),
297
+ toKind: sectionField(parties, 'To Kind'),
298
+ fromReference: sectionReferenceTarget(parties, 'From Reference'),
299
+ toReference: sectionReferenceTarget(parties, 'To Reference'),
300
+ transfers,
301
+ completionExpectation: Object.freeze({
302
+ signalKind: sectionField(completion, 'Signal Kind'),
303
+ signalMeaning: sectionField(completion, 'Signal Meaning'),
304
+ returnTo: sectionField(completion, 'Return To')
305
+ }),
306
+ routeId: String(route?.id || ''),
307
+ workspaceId: String(route?.workspaceId || ''),
308
+ workspaceRelativePath: String(route?.workspaceRelativeHandoffPath || route?.workspaceRelativePath || ''),
309
+ packagePath: String(route?.packagePath || ''),
310
+ sha256: String(route?.sha256 || ''),
311
+ boundary: 'Exact Handoff parties/purpose/work-transfer/completion expectation read from selected qualified Handoff bytes; transport route labels are not substituted for artifact semantics.'
312
+ });
313
+ }
314
+
315
+ export function emptyHandoffGrounding() {
316
+ return deepFreeze({ schemaId: '', purpose: '', from: '', fromKind: '', fromReference: '', to: '', toKind: '', toReference: '', transfers: Object.freeze([]), completionExpectation: Object.freeze({ signalKind: '', signalMeaning: '', returnTo: '' }), routeId: '', workspaceId: '', workspaceRelativePath: '', packagePath: '', sha256: '', boundary: 'No Handoff material supplied.' });
317
+ }
318
+
319
+ export function resolveGroundingRouteMarkdown(bundle = {}, selectedRoute = {}, findings = [], context = null) {
320
+ const packagePath = String(selectedRoute.packagePath || '');
321
+ const routeFile = findFile(bundle, packagePath);
322
+ if (!routeFile) {
323
+ findings.push(portableFinding('error', 'portable.cold-start.handoff.route-carrier.missing', 'Selected Handoff route carrier is missing from the received package.'));
324
+ return '';
325
+ }
326
+ const workspaceRelativePath = normalizePath(selectedRoute.workspaceRelativeHandoffPath || selectedRoute.workspaceRelativePath || '');
327
+ if (/\.zip$/i.test(packagePath) && workspaceRelativePath) {
328
+ const archive = inspectWorkspaceArchiveForColdStart(routeFile, context);
329
+ if (archive.state !== 'qualified') {
330
+ findings.push(portableFinding('error', 'portable.cold-start.handoff.route-workspace-archive.invalid', 'Selected recipient-v2 Workspace archive carrier is not a qualified readable ZIP.'));
331
+ return '';
332
+ }
333
+ const matches = (archive.entries || []).filter((entry) => normalizePath(entry.path || '') === workspaceRelativePath);
334
+ if (matches.length !== 1) {
335
+ findings.push(portableFinding('error', 'portable.cold-start.handoff.route-entry.unresolved', 'Selected recipient-v2 Handoff path does not resolve to exactly one entry inside the qualified Workspace archive.'));
336
+ return '';
337
+ }
338
+ const entry = matches[0];
339
+ const expectedSha256 = String(selectedRoute.sha256 || '').trim();
340
+ const observedSha256 = String(entry.sha256 || sha256Hex(entry.data || new Uint8Array())).trim();
341
+ if (expectedSha256 && expectedSha256 !== observedSha256) {
342
+ findings.push(portableFinding('error', 'portable.cold-start.handoff.route-bytes.integrity-mismatch', 'Selected recipient-v2 Handoff archive entry bytes do not match the qualified route digest.'));
343
+ return '';
344
+ }
345
+ const markdown = decodeUtf8(entry.data || new Uint8Array());
346
+ if (!markdown) findings.push(portableFinding('error', 'portable.cold-start.handoff.route-bytes.unreadable', 'Selected recipient-v2 Handoff archive entry is not readable UTF-8 Markdown.'));
347
+ return markdown;
348
+ }
349
+ const markdown = decodeUtf8(packageFileBytes(routeFile));
350
+ if (!markdown) findings.push(portableFinding('error', 'portable.cold-start.handoff.route-bytes.unreadable', 'Selected Handoff route bytes are missing or unreadable.'));
351
+ return markdown;
352
+ }
353
+
354
+ export function selectGroundingRoute(orientation = {}, selector = '') {
355
+ const routes = (orientation.routes || []).filter((route) => route.state === 'qualified');
356
+ const requested = String(selector || '').trim();
357
+ if (!requested) {
358
+ if (routes.length === 1) return Object.freeze({ state: 'qualified', route: routes[0] });
359
+ return Object.freeze({ state: routes.length > 1 ? 'selection-required' : 'unresolved', route: null });
360
+ }
361
+ const normalized = normalizePath(requested);
362
+ const matches = routes.filter((route) => route.id === requested || normalizePath(route.pointerPath || '') === normalized || normalizePath(route.workspaceRelativeHandoffPath || route.workspaceRelativePath || '') === normalized || `${route.workspaceId}:${normalizePath(route.workspaceRelativeHandoffPath || route.workspaceRelativePath || '')}` === requested);
363
+ return Object.freeze({ state: matches.length === 1 ? 'qualified' : matches.length > 1 ? 'ambiguous' : 'unresolved', route: matches.length === 1 ? matches[0] : null });
364
+ }
@@ -0,0 +1,220 @@
1
+ import { portableFinding, summarizePortableFindings } from '../findings.js';
2
+ import {
3
+ COLD_START_INGRESS_KINDS,
4
+ PORTABLE_COLD_START_QUALIFICATION_SCHEMA_ID,
5
+ describePortableColdStartIngress,
6
+ normalizeIngressKind
7
+ } from './coldStartQualification.contract.js';
8
+ import {
9
+ READY_OPERATION_STATES,
10
+ deepFreeze,
11
+ finiteOrNull,
12
+ normalizeSemanticClass,
13
+ normalizeToken,
14
+ parseTime
15
+ } from './coldStartQualification.shared.js';
16
+
17
+ export function qualifyPortableColdStartTrace(input = {}, options = {}) {
18
+ const ingressKind = normalizeIngressKind(input.ingressKind || input.kind || COLD_START_INGRESS_KINDS.HANDOFF);
19
+ const contract = describePortableColdStartIngress({ ingressKind });
20
+ const profile = contract.profile;
21
+ const events = normalizeObservationEvents(input.events || input.observations || input.trace || []);
22
+ const findings = [];
23
+ const tiinexEvents = events.filter((event) => event.mechanism === 'tiinex');
24
+ const firstTiinex = tiinexEvents[0] || null;
25
+ const firstTiinexIndex = firstTiinex?.index ?? Infinity;
26
+ const orientationEvent = findReadyOperationEvent(events, profile.orientationOperation);
27
+ const orientationIndex = orientationEvent?.index ?? Infinity;
28
+ const firstSubstantive = events.find((event) => event.semanticClass === 'substantive-work' || event.substantive) || null;
29
+ const groundingEvent = findReadyOperationEvent(events, 'ground-cold-consumer');
30
+ const availabilityObserved = input.toolingAvailable === true || Boolean(firstTiinex) || input.tooling?.available === true || input.bootstrap?.qualified === true;
31
+ const explicitlyUnavailable = input.toolingAvailable === false || input.tooling?.available === false;
32
+ const hostEvidenceState = normalizeToken(input.hostEvidence?.state || input.hostEvidenceState || '');
33
+ const hostEvidenceSource = String(input.hostEvidence?.source || input.hostEvidenceSource || '').trim();
34
+ const hostEvidenceRequired = input.requireHostEvidence === true;
35
+ const hostEvidenceQualified = !hostEvidenceRequired || ['provided', 'observed', 'external-observer', 'host-instrumented', 'self-reported'].includes(hostEvidenceState);
36
+
37
+ const preTakeoverNative = events.filter((event) => event.index < firstTiinexIndex && event.mechanism === 'native-host');
38
+ const minimalBootstrap = preTakeoverNative.filter((event) => event.semanticClass === 'minimal-bootstrap');
39
+ const unexpectedNative = ingressKind === COLD_START_INGRESS_KINDS.DEGRADED_CAPTURE
40
+ ? []
41
+ : preTakeoverNative.filter((event) => event.semanticClass !== 'minimal-bootstrap');
42
+ const arbitraryReadsBeforeOrientation = ingressKind === COLD_START_INGRESS_KINDS.DEGRADED_CAPTURE
43
+ ? []
44
+ : events.filter((event) => event.index < orientationIndex && event.mechanism === 'native-host' && event.read && event.arbitrary !== false);
45
+ const candidateArtifactsInspected = arbitraryReadsBeforeOrientation.reduce((sum, event) => sum + Math.max(0, Number(event.candidateArtifacts || (event.candidateArtifact ? 1 : 0) || 0)), 0);
46
+ const actionsToOrientation = Number.isFinite(orientationIndex) ? events.filter((event) => event.index <= orientationIndex) : events;
47
+ const tiinexCallsToOrientation = Number.isFinite(orientationIndex) ? tiinexEvents.filter((event) => event.index <= orientationIndex).length : tiinexEvents.length;
48
+ const bytesToOrientation = actionsToOrientation.reduce((sum, event) => sum + Math.max(0, Number(event.bytes || 0)), 0);
49
+ const timeToOrientationMs = computeTimeToOrientation(events, orientationEvent);
50
+ const fallback = qualifyFallback(input, events);
51
+
52
+ if (hostEvidenceRequired && !hostEvidenceQualified) findings.push(portableFinding('warning', 'portable.cold-start.host-evidence.unverified', 'Portable Tooling cannot independently observe pre-takeover native-host actions in this run; preferred-path qualification remains incomplete until bounded host evidence is supplied.', { source: hostEvidenceSource || 'unverified' }));
53
+ if (!explicitlyUnavailable && !availabilityObserved) findings.push(portableFinding('warning', 'portable.cold-start.tooling-availability.unqualified', 'Preferred-path qualification cannot pass without observed qualified Tiinex Tooling/bootstrap availability.'));
54
+ if (firstTiinex && profile.firstSemanticOperation && firstTiinex.operation !== profile.firstSemanticOperation) findings.push(portableFinding('error', 'portable.cold-start.first-semantic-operation.mismatch', 'The first observed Tiinex semantic operation does not match the ingress contract.', { expected: profile.firstSemanticOperation, actual: firstTiinex.operation }));
55
+ if (minimalBootstrap.length > profile.minimalNativeBootstrapActions) findings.push(portableFinding('error', 'portable.cold-start.minimal-bootstrap.exceeded', 'Native/bootstrap ingress exceeded the explicit minimal pre-Tiinex allowance.', { allowed: profile.minimalNativeBootstrapActions, actual: minimalBootstrap.length }));
56
+ if (unexpectedNative.length) findings.push(portableFinding('error', 'portable.cold-start.native-archaeology.pre-takeover', 'Native semantic/archive/filesystem archaeology occurred before Tiinex takeover.', { count: unexpectedNative.length }));
57
+ if (arbitraryReadsBeforeOrientation.length) findings.push(portableFinding('error', 'portable.cold-start.arbitrary-read.pre-orientation', 'Arbitrary files were read before qualified Tiinex orientation/frontier discovery.', { count: arbitraryReadsBeforeOrientation.length }));
58
+ if (profile.orientationOperation && !orientationEvent && !explicitlyUnavailable) findings.push(portableFinding('error', 'portable.cold-start.orientation.missing', 'The ingress trace does not contain a successful qualified orientation/frontier operation.', { operation: profile.orientationOperation }));
59
+
60
+ const orderedOperations = profile.requiredBeforeSubstantive.map((operation) => findReadyOperationEvent(events, operation));
61
+ const missingRequired = profile.requiredBeforeSubstantive.filter((operation, index) => !orderedOperations[index]);
62
+ if (missingRequired.length && !explicitlyUnavailable) findings.push(portableFinding('error', 'portable.cold-start.required-grounding-sequence.incomplete', 'Required Tiinex orientation/grounding operations are missing before substantive work.', { operations: missingRequired }));
63
+ if (!missingRequired.length && orderedOperations.length > 1) {
64
+ for (let index = 1; index < orderedOperations.length; index += 1) {
65
+ if (orderedOperations[index].index <= orderedOperations[index - 1].index) findings.push(portableFinding('error', 'portable.cold-start.required-grounding-sequence.order', 'Required Tiinex cold-start operations occurred out of order.', { previous: profile.requiredBeforeSubstantive[index - 1], current: profile.requiredBeforeSubstantive[index] }));
66
+ }
67
+ }
68
+ if (firstSubstantive && groundingEvent && groundingEvent.index > firstSubstantive.index) findings.push(portableFinding('error', 'portable.cold-start.grounding.after-substantive-work', 'Recipient/participant/interaction grounding occurred after substantive work began.'));
69
+ if (firstSubstantive && !groundingEvent && ingressKind !== COLD_START_INGRESS_KINDS.DEGRADED_CAPTURE && !explicitlyUnavailable) findings.push(portableFinding('error', 'portable.cold-start.grounding.missing-before-substantive-work', 'Substantive work began without an observed grounding operation.'));
70
+ if (input.grounding?.status === 'blocked') findings.push(portableFinding('error', 'portable.cold-start.grounding.blocked', 'Supplied consumer grounding is blocked and cannot support preferred-path qualification.'));
71
+ if (fallback.used && !fallback.justified) findings.push(portableFinding('error', 'portable.cold-start.fallback.unjustified', 'Native fallback was used without an explicit bounded reason.'));
72
+ if (fallback.used && availabilityObserved && fallback.beforeOrientation) findings.push(portableFinding('warning', 'portable.cold-start.fallback.available-tooling', 'Fallback was used before Tiinex orientation even though qualified Tooling availability was observed; recovery may still succeed but preferred-path qualification cannot pass.'));
73
+
74
+ const recoveryState = normalizeRecoveryState(input.outcome || input.recovery || {});
75
+ const blockingErrors = findings.filter((finding) => finding.severity === 'error');
76
+ const preferredPassed = !explicitlyUnavailable
77
+ && hostEvidenceQualified
78
+ && availabilityObserved
79
+ && Boolean(firstTiinex)
80
+ && (!profile.orientationOperation || Boolean(orientationEvent))
81
+ && minimalBootstrap.length <= profile.minimalNativeBootstrapActions
82
+ && unexpectedNative.length === 0
83
+ && arbitraryReadsBeforeOrientation.length === 0
84
+ && missingRequired.length === 0
85
+ && blockingErrors.length === 0
86
+ && !(fallback.used && fallback.beforeOrientation);
87
+
88
+ const state = preferredPassed
89
+ ? 'preferred-pass'
90
+ : hostEvidenceRequired && !hostEvidenceQualified
91
+ ? 'incomplete'
92
+ : recoveryState === 'recovered'
93
+ ? 'recovered-not-preferred'
94
+ : explicitlyUnavailable || (fallback.used && fallback.justified)
95
+ ? 'degraded-fallback'
96
+ : blockingErrors.length
97
+ ? 'failed'
98
+ : 'incomplete';
99
+
100
+ return deepFreeze({
101
+ schema: PORTABLE_COLD_START_QUALIFICATION_SCHEMA_ID,
102
+ version: 1,
103
+ status: state,
104
+ ingressKind,
105
+ contract,
106
+ qualification: Object.freeze({
107
+ state,
108
+ preferredPathPassed: preferredPassed,
109
+ recoveryState,
110
+ recoveryIsPreferredPathEvidence: false,
111
+ toolingAvailability: explicitlyUnavailable ? 'unavailable' : availabilityObserved ? 'observed-available' : 'unqualified',
112
+ firstSemanticOperation: firstTiinex?.operation || '',
113
+ expectedFirstSemanticOperation: profile.firstSemanticOperation,
114
+ orientationOperation: orientationEvent?.operation || '',
115
+ groundingState: input.grounding?.status || (groundingEvent ? String(groundingEvent.status || 'observed') : 'unobserved'),
116
+ hostEvidence: Object.freeze({ required: hostEvidenceRequired, state: hostEvidenceState || (hostEvidenceRequired ? 'unverified' : 'not-required'), source: hostEvidenceSource || '', mode: String(input.hostEvidence?.mode || ''), independentlyObservedByTooling: false }),
117
+ fallback
118
+ }),
119
+ metrics: Object.freeze({
120
+ nativeActionsBeforeTiinexTakeover: preTakeoverNative.length,
121
+ minimalBootstrapActionsBeforeTiinexTakeover: minimalBootstrap.length,
122
+ unexpectedNativeActionsBeforeTiinexTakeover: unexpectedNative.length,
123
+ arbitraryFilesReadBeforeOrientation: arbitraryReadsBeforeOrientation.length,
124
+ tiinexCallsToOrientation,
125
+ totalActionsToOrientation: actionsToOrientation.length,
126
+ bytesToOrientation,
127
+ timeToOrientationMs,
128
+ candidateArtifactsInspectedBeforeOrientation: candidateArtifactsInspected,
129
+ fallbackUsed: fallback.used,
130
+ fallbackJustified: fallback.justified
131
+ }),
132
+ evidence: Object.freeze({
133
+ events,
134
+ firstTiinexEvent: firstTiinex,
135
+ orientationEvent,
136
+ groundingEvent,
137
+ firstSubstantiveEvent: firstSubstantive,
138
+ unexpectedNativeEvents: Object.freeze(unexpectedNative),
139
+ arbitraryReadEvents: Object.freeze(arbitraryReadsBeforeOrientation)
140
+ }),
141
+ findings: Object.freeze(findings),
142
+ findingSummary: summarizePortableFindings(findings),
143
+ boundary: 'Preferred-path qualification is independent from final-answer correctness. Native host tools remain valid after Tiinex takeover and as explicit degraded fallback; this result does not authorize network access, authentication, source mutation, repository writes, or fabricated receipts.'
144
+ });
145
+ }
146
+
147
+ function normalizeObservationEvents(value) {
148
+ const list = Array.isArray(value) ? value : value ? [value] : [];
149
+ return Object.freeze(list.map((raw, index) => {
150
+ const operation = String(raw?.operation || raw?.tiinexOperation || '').trim();
151
+ const semanticClass = normalizeSemanticClass(raw?.semanticClass || raw?.class || raw?.boundary || raw?.kind || '');
152
+ const mechanism = operation || raw?.mechanism === 'tiinex' || raw?.tooling === true ? 'tiinex' : 'native-host';
153
+ const read = raw?.read === true || /read|open|extract|inspect|list|search/.test(String(raw?.action || raw?.name || raw?.kind || '').toLowerCase());
154
+ return deepFreeze({
155
+ index,
156
+ sequence: Number.isFinite(Number(raw?.sequence)) ? Number(raw.sequence) : index + 1,
157
+ mechanism,
158
+ operation,
159
+ action: String(raw?.action || raw?.name || raw?.kind || operation || '').trim(),
160
+ semanticClass,
161
+ status: String(raw?.status || raw?.result || raw?.state || '').trim(),
162
+ read,
163
+ arbitrary: raw?.arbitrary === false ? false : raw?.arbitrary === true ? true : read,
164
+ path: String(raw?.path || raw?.target || '').trim(),
165
+ bytes: Math.max(0, Number(raw?.bytes || raw?.byteCount || 0) || 0),
166
+ elapsedMs: finiteOrNull(raw?.elapsedMs ?? raw?.timeMs ?? raw?.t),
167
+ timestamp: String(raw?.timestamp || raw?.at || '').trim(),
168
+ candidateArtifact: Boolean(raw?.candidateArtifact),
169
+ candidateArtifacts: Math.max(0, Number(raw?.candidateArtifacts || 0) || 0),
170
+ fallback: Boolean(raw?.fallback || semanticClass === 'fallback'),
171
+ reason: String(raw?.reason || '').trim(),
172
+ substantive: Boolean(raw?.substantive || semanticClass === 'substantive-work')
173
+ });
174
+ }));
175
+ }
176
+
177
+ function findReadyOperationEvent(events, operation) {
178
+ if (!operation) return null;
179
+ return events.find((event) => event.mechanism === 'tiinex' && event.operation === operation && operationEventReady(event)) || null;
180
+ }
181
+
182
+ function operationEventReady(event) {
183
+ const status = normalizeToken(event.status);
184
+ return !status || READY_OPERATION_STATES.has(status) || status.startsWith('passed');
185
+ }
186
+
187
+ function qualifyFallback(input, events) {
188
+ const declared = input.fallback || {};
189
+ const fallbackEvents = events.filter((event) => event.fallback);
190
+ const used = declared.used === true || fallbackEvents.length > 0;
191
+ const reason = String(declared.reason || fallbackEvents.find((event) => event.reason)?.reason || '').trim();
192
+ const first = fallbackEvents[0] || null;
193
+ const orientationEvent = events.find((event) => event.mechanism === 'tiinex' && ['orient-handoff-package', 'search-lineage'].includes(event.operation) && operationEventReady(event)) || null;
194
+ return deepFreeze({
195
+ used,
196
+ justified: !used || Boolean(reason),
197
+ reason,
198
+ beforeOrientation: Boolean(used && first && (!orientationEvent || first.index < orientationEvent.index)),
199
+ hiddenNetworkAccess: false,
200
+ remoteWrite: false
201
+ });
202
+ }
203
+
204
+ function normalizeRecoveryState(value = {}) {
205
+ if (value === true) return 'recovered';
206
+ if (value === false) return 'failed';
207
+ const state = normalizeToken(value.state || value.status || '');
208
+ if (['recovered', 'correct', 'success', 'passed', 'ready'].includes(state) || value.correct === true || value.recovered === true) return 'recovered';
209
+ if (['failed', 'incorrect', 'error'].includes(state) || value.correct === false || value.recovered === false) return 'failed';
210
+ return 'unknown';
211
+ }
212
+
213
+ function computeTimeToOrientation(events, orientationEvent) {
214
+ if (!orientationEvent) return null;
215
+ if (orientationEvent.elapsedMs !== null) return orientationEvent.elapsedMs;
216
+ const firstTimestamp = parseTime(events[0]?.timestamp);
217
+ const orientationTimestamp = parseTime(orientationEvent.timestamp);
218
+ if (firstTimestamp !== null && orientationTimestamp !== null) return Math.max(0, orientationTimestamp - firstTimestamp);
219
+ return null;
220
+ }