@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,242 @@
1
+ import { isSchemaDefinitionPath as isWorkspaceSchemaDefinitionPath, isWorkspaceEntrypointArtifact } from './workspace.entrypointCapability.js';
2
+ export const MaterialRole = Object.freeze({
3
+ leaf: 'leaf',
4
+ schemaDefinition: 'schema-definition',
5
+ supporting: 'supporting',
6
+ workspaceArtifact: 'workspace-artifact',
7
+ asset: 'asset',
8
+ unknown: 'unknown'
9
+ });
10
+
11
+ export function sourceBoundaryClass(record = {}) {
12
+ const source = record.source || {};
13
+ const mode = String(record.sourceMode || '').toLowerCase();
14
+ if (source.adapterId === 'github' || source.kind === 'github-tree' || source.sourceKind === 'github.repo' || mode === 'source-backed') return 'source-backed';
15
+ if (source.adapterId === 'local' || source.kind === 'local-session' || mode.startsWith('local')) return 'local';
16
+ return 'unknown';
17
+ }
18
+
19
+ export function inferRecordMaterialRole(record = {}) {
20
+ const path = String(record.path || record.name || '').toLowerCase();
21
+ const kind = String(record.kind || '').toLowerCase();
22
+ const schema = String(record.schemaId || record.currentSchemaId || record.envelopeSchemaId || '').toLowerCase();
23
+ const markdown = String(record.markdown || '');
24
+ const hasBody = markdown.trim().length > 0 || String(record.body || record.raw || '').trim().length > 0;
25
+
26
+ // Schema/type information must never gain workspace-entrypoint capability merely
27
+ // because its schema id or kind contains the word "workspace".
28
+ if (isWorkspaceSchemaDefinitionPath(path) || isCanonicalSchemaArtifactPath(path) || kind.includes('schema module') || kind.includes('schema-definition')) return MaterialRole.schemaDefinition;
29
+
30
+ const declared = normalizeMaterialRole(record.materialRole || record.materialKind || record.artifactRole || record.presentationRole);
31
+ if (declared && declared !== MaterialRole.workspaceArtifact) return declared;
32
+ if (isWorkspaceEntrypointArtifact(record)) return MaterialRole.workspaceArtifact;
33
+
34
+ if (sourceBoundaryClass(record) === 'source-backed' && !hasBody) {
35
+ if (isRouteOnlyMaterialUnavailableShell(record)) return MaterialRole.unknown;
36
+ if (isKnownSupportSurfacePath(path) || isKnownSupportSchema(schema) || kind.includes('supporting') || schema.includes('tiinex.markdown.supporting')) return MaterialRole.supporting;
37
+ if (hasSourceBackedLeafEvidence(record, path, schema)) return MaterialRole.leaf;
38
+ return MaterialRole.unknown;
39
+ }
40
+ if (isKnownSupportSurfacePath(path) || isKnownSupportSchema(schema) || kind.includes('supporting') || schema.includes('tiinex.markdown.supporting')) return MaterialRole.supporting;
41
+ if (hasDeclaredTiinexLeaf(record, markdown)) return MaterialRole.leaf;
42
+ if (markdown.trim()) return MaterialRole.supporting;
43
+ if (sourceBoundaryClass(record) === 'source-backed' && (schema || record.hasContinuityContext || record.hasIntegrity)) return MaterialRole.leaf;
44
+ return MaterialRole.unknown;
45
+ }
46
+
47
+
48
+
49
+ export function isWorkLeafRecord(record = {}) {
50
+ return isDiscoveryWorkLeafEligible(record);
51
+ }
52
+
53
+ export function isDiscoveryWorkLeafEligible(record = {}) {
54
+ if (inferRecordMaterialRole(record) !== MaterialRole.leaf) return false;
55
+ if (isSchemaTypeDefinitionRecord(record)) return false;
56
+ if (isRouteOnlyMaterialUnavailableShell(record)) return false;
57
+ return true;
58
+ }
59
+
60
+
61
+ export function isSupportingRecord(record = {}) {
62
+ const role = inferRecordMaterialRole(record);
63
+ return role === MaterialRole.supporting || role === MaterialRole.schemaDefinition || role === MaterialRole.unknown;
64
+ }
65
+
66
+ export function isSchemaDefinitionRecord(record = {}) {
67
+ return inferRecordMaterialRole(record) === MaterialRole.schemaDefinition;
68
+ }
69
+
70
+ export function materialRoleLabel(role = '') {
71
+ const normalized = normalizeMaterialRole(role) || MaterialRole.unknown;
72
+ if (normalized === MaterialRole.leaf) return 'Leaves';
73
+ if (normalized === MaterialRole.schemaDefinition) return 'Schema definitions';
74
+ if (normalized === MaterialRole.supporting) return 'Supporting docs';
75
+ if (normalized === MaterialRole.workspaceArtifact) return 'Workspace artifacts';
76
+ if (normalized === MaterialRole.asset) return 'Assets';
77
+ return 'Unknown/supporting';
78
+ }
79
+
80
+ function normalizeMaterialRole(value = '') {
81
+ const role = String(value || '').trim().toLowerCase();
82
+ if (role === MaterialRole.leaf || role === 'work-leaf' || role === 'artifact-leaf') return MaterialRole.leaf;
83
+ if (role === MaterialRole.schemaDefinition || role === 'schema' || role === 'schema-definition') return MaterialRole.schemaDefinition;
84
+ if (role === MaterialRole.supporting || role === 'doc' || role === 'supporting-material') return MaterialRole.supporting;
85
+ if (role === MaterialRole.workspaceArtifact || role === 'workspace') return MaterialRole.workspaceArtifact;
86
+ if (role === MaterialRole.asset) return MaterialRole.asset;
87
+ if (role === MaterialRole.unknown) return MaterialRole.unknown;
88
+ return '';
89
+ }
90
+
91
+ function isRouteOnlyMaterialUnavailableShell(record = {}) {
92
+ const cacheState = String(record.cacheState || '').toLowerCase();
93
+ const availability = typeof record.materialAvailability === 'string'
94
+ ? record.materialAvailability
95
+ : record.materialAvailability?.status;
96
+ const materialAvailability = String(availability || '').toLowerCase();
97
+ return cacheState === 'route-shell-material-unavailable'
98
+ || materialAvailability === 'material-unavailable'
99
+ || materialAvailability === 'route-shell-material-unavailable';
100
+ }
101
+
102
+ function isSchemaTypeDefinitionRecord(record = {}) {
103
+ const path = String(record.path || record.name || '').toLowerCase();
104
+ const kind = String(record.kind || '').toLowerCase();
105
+ const schema = String(record.schemaId || record.currentSchemaId || record.envelopeSchemaId || '').toLowerCase();
106
+ if (isSchemaDefinitionPath(path) || isCanonicalSchemaArtifactPath(path)) return true;
107
+ if (kind.includes('schema-definition') || kind.includes('schema module')) return true;
108
+ if (schema === 'tiinex.schema.module.v1' || schema.startsWith('tiinex.schema.')) return true;
109
+ return false;
110
+ }
111
+
112
+ function hasSourceBackedLeafEvidence(record = {}, path = '', schema = '') {
113
+ if (path.endsWith('.trace.md')) return true;
114
+ if (isCanonicalSchemaArtifactPath(path) && (schema || record.hasContinuityContext || record.hasIntegrity || record.title || record.summary)) return true;
115
+ if (schema && isKnownWorkSchema(schema)) return true;
116
+ if (record.trace || record.parentSchemaId || record.hasContinuityContext || record.hasIntegrity) return true;
117
+ return false;
118
+ }
119
+
120
+ function hasDeclaredTiinexLeaf(record = {}, markdown = '') {
121
+ const path = String(record.path || record.name || '').toLowerCase();
122
+ const schema = String(record.schemaId || record.currentSchemaId || record.envelopeSchemaId || '').toLowerCase();
123
+ if (!isCanonicalSchemaArtifactPath(path) && (isKnownSupportSurfacePath(path) || isKnownSupportSchema(schema))) return false;
124
+ if (path.endsWith('.trace.md')) return true;
125
+ if (record.trace || record.parentSchemaId) return true;
126
+ const hasContinuity = record.hasContinuityContext || record.hasIntegrity || /^\s*#\s*Continuity Context\b/im.test(markdown);
127
+ if (isCanonicalSchemaArtifactPath(path) && hasContinuity) return true;
128
+ if (hasContinuity) {
129
+ return !isKnownSupportSchema(schema);
130
+ }
131
+ if (schema && !isKnownSupportSchema(schema) && isKnownWorkSchema(schema)) return true;
132
+ return false;
133
+ }
134
+
135
+ function isKnownSupportSchema(schema = '') {
136
+ const value = String(schema || '').toLowerCase();
137
+ if (!value) return false;
138
+ if (isKnownWorkSchema(value)) return false;
139
+ return value === 'tiinex.root.v1'
140
+ || value === 'tiinex.source.v1'
141
+ || value === 'tiinex.access.v1'
142
+ || value === 'tiinex.origin.v1'
143
+ || value === 'tiinex.digital.origin.v1'
144
+ || value === 'tiinex.natural.origin.v1'
145
+ || value === 'tiinex.tool.v1'
146
+ || value === 'tiinex.interface.v1'
147
+ || value === 'tiinex.adapter.v1'
148
+ || value === 'tiinex.digital.adapter.v1'
149
+ || value.startsWith('tiinex.source.')
150
+ || value.startsWith('tiinex.access.')
151
+ || value.startsWith('tiinex.origin.')
152
+ || value.startsWith('tiinex.digital.origin.')
153
+ || value.startsWith('tiinex.natural.origin.')
154
+ || value.startsWith('tiinex.tool.')
155
+ || value.startsWith('tiinex.interface.')
156
+ || value.startsWith('tiinex.schema.')
157
+ || value.startsWith('tiinex.presentation.surface.')
158
+ || value.startsWith('tiinex.validation.method.');
159
+ }
160
+
161
+ function isKnownWorkSchema(schema = '') {
162
+ const value = String(schema || '').toLowerCase();
163
+ if (!value) return false;
164
+ return value.startsWith('tiinex.topic.')
165
+ || value.startsWith('tiinex.task.')
166
+ || value.startsWith('tiinex.preservation.')
167
+ || value.startsWith('tiinex.evidence.')
168
+ || value.startsWith('tiinex.feedback.')
169
+ || value.startsWith('tiinex.decision.')
170
+ || value.startsWith('tiinex.pointer.')
171
+ || value.startsWith('tiinex.signal.')
172
+ || value.startsWith('tiinex.interpretation.')
173
+ || value.startsWith('tiinex.lineage.')
174
+ || value.startsWith('tiinex.party.')
175
+ || value.startsWith('tiinex.event.')
176
+ || value.startsWith('tiinex.project.')
177
+ || value.startsWith('tiinex.milestone.')
178
+ || value.startsWith('tiinex.schedule.')
179
+ || value.startsWith('tiinex.invitation.')
180
+ || value.startsWith('tiinex.availability.')
181
+ || value.startsWith('tiinex.discovery.')
182
+ || value.startsWith('tiinex.resource.')
183
+ || value.startsWith('tiinex.instrument.')
184
+ || value.startsWith('tiinex.transition.')
185
+ || value.startsWith('tiinex.relation.')
186
+ || value.startsWith('tiinex.validation.finding.')
187
+ || value.startsWith('tiinex.validation.report.')
188
+ || value.startsWith('tiinex.runtime.')
189
+ || value.startsWith('tiinex.ai.runtime.')
190
+ || value.startsWith('tiinex.machine.runtime.')
191
+ || value.startsWith('tiinex.reduction.')
192
+ || value.startsWith('tiinex.redaction.')
193
+ || value.startsWith('tiinex.privacy.')
194
+ || value.startsWith('tiinex.attestation.')
195
+ || value.startsWith('tiinex.external.')
196
+ || value.startsWith('tiinex.traversal.')
197
+ || value.startsWith('tiinex.quantum.')
198
+ || value.startsWith('tiinex.portal.')
199
+ || value.startsWith('tiinex.interaction.')
200
+ || value.startsWith('tiinex.question.')
201
+ || value.startsWith('tiinex.condition.')
202
+ || value.startsWith('tiinex.claim.')
203
+ || value.startsWith('tiinex.derivation.')
204
+ || value.startsWith('tiinex.annotation.')
205
+ || value.startsWith('tiinex.artifact.annotation.')
206
+ || value.startsWith('tiinex.spatial.annotation.')
207
+ || value.startsWith('tiinex.projection.annotation.')
208
+ || value.startsWith('tiinex.temporal.annotation.')
209
+ || value.startsWith('tiinex.semantic.annotation.')
210
+ || value.startsWith('tiinex.style.annotation.')
211
+ || value.startsWith('tiinex.validation.annotation.')
212
+ || value.startsWith('tiinex.adapter.annotation.');
213
+ }
214
+
215
+ function isCanonicalSchemaArtifactPath(path = '') {
216
+ const value = String(path || '').toLowerCase();
217
+ return (value.includes('/.topics/.schemas/') || value.startsWith('.topics/.schemas/'))
218
+ && value.endsWith('.schema.md');
219
+ }
220
+
221
+ function isKnownSupportSurfacePath(path = '') {
222
+ const value = String(path || '').toLowerCase();
223
+ return value.includes('/.schemas/')
224
+ || value.includes('/schemas/')
225
+ || value.includes('/schema/')
226
+ || value.includes('/.adapters/')
227
+ || value.includes('/adapters/')
228
+ || value.includes('/.tools/')
229
+ || value.includes('/tools/')
230
+ || value.includes('/.interfaces/')
231
+ || value.includes('/interfaces/')
232
+ || value.endsWith('/readme.md')
233
+ || value.endsWith('readme.md');
234
+ }
235
+
236
+ function isSchemaDefinitionPath(path = '') {
237
+ return /(?:^|\/)[^/]+\.schema\.md$/i.test(path)
238
+ || /(?:^|\/)[^/]+\.validator\.md$/i.test(path)
239
+ || path.includes('/schemas/')
240
+ || path.includes('/schema/')
241
+ || path.endsWith('schema.json');
242
+ }
@@ -0,0 +1,426 @@
1
+ import { schemaIdForRecord } from '../schemas/schema.identity.js';
2
+
3
+ export function recordLogicalPath(record = {}) {
4
+ const stripPackageEnvelope = recordHasPackageEnvelopeContext(record);
5
+ const explicit = firstNonEmpty(record.logicalPath, record.treePath, record.displayPath);
6
+ if (explicit) return normalizeRecordMaterialPath(explicit, { stripPackageEnvelope });
7
+ const issuePath = githubIssueLogicalPathForRecord(record);
8
+ if (issuePath) return issuePath;
9
+ return normalizeRecordMaterialPath(record.path || record.sourcePath || record.source?.path || '', { stripPackageEnvelope });
10
+ }
11
+
12
+
13
+ export function buildRecordLogicalPathMap(records = []) {
14
+ const items = Array.isArray(records) ? records : [];
15
+ const base = new Map();
16
+ const groups = new Map();
17
+
18
+ for (const record of items) {
19
+ const key = recordPathMapKey(record);
20
+ const path = recordLogicalPath(record);
21
+ base.set(key, path);
22
+ const info = githubIssuePathInfo(path, record);
23
+ if (!info.ok) continue;
24
+ if (!groups.has(info.folder)) groups.set(info.folder, []);
25
+ groups.get(info.folder).push({ record, key, path, info });
26
+ }
27
+
28
+ for (const [folder, group] of groups.entries()) {
29
+ const remapped = assignIssueDimensionPrefixes(folder, group);
30
+ for (const [key, path] of remapped.entries()) base.set(key, path);
31
+ }
32
+
33
+ return base;
34
+ }
35
+
36
+ export function recordLogicalPathFromMap(record = {}, pathMap = null) {
37
+ if (pathMap && typeof pathMap.get === 'function') {
38
+ const mapped = pathMap.get(recordPathMapKey(record));
39
+ if (mapped) return mapped;
40
+ }
41
+ return recordLogicalPath(record);
42
+ }
43
+
44
+ export function normalizeRecordMaterialPath(value = '', options = {}) {
45
+ const clean = normalizeWorkspacePath(value);
46
+ return options.stripPackageEnvelope ? stripPackageEnvelopePath(clean) : clean;
47
+ }
48
+
49
+ export function stripPackageEnvelopePath(path = '') {
50
+ const clean = normalizeWorkspacePath(path);
51
+ if (!clean) return '';
52
+ // Handoff/package exports intentionally use envelope folders such as
53
+ // artifacts/, sources/, and tiinex.package/. Those prefixes are package
54
+ // transport structure, not Tiinex logical tree structure. Only callers
55
+ // that have package-import context should strip them.
56
+ const artifact = clean.match(/^artifacts\/(.+)$/i);
57
+ if (artifact && looksLikeMaterialPath(artifact[1])) return artifact[1];
58
+ return clean;
59
+ }
60
+
61
+ export function normalizeWorkspacePath(value = '') {
62
+ let raw = String(value || '').trim();
63
+ if (!raw) return '';
64
+ raw = raw.replace(/^file:\/\/+/i, '').replace(/\\/g, '/').replace(/[#?].*$/, '');
65
+ try {
66
+ const url = new URL(raw);
67
+ raw = url.pathname.replace(/^\/+/, '');
68
+ } catch (_) {}
69
+ const out = [];
70
+ for (const part of raw.split('/')) {
71
+ const clean = part.trim();
72
+ if (!clean || clean === '.') continue;
73
+ if (clean === '..') { if (out.length) out.pop(); continue; }
74
+ out.push(clean);
75
+ }
76
+ return out.join('/');
77
+ }
78
+
79
+ export function githubIssueLogicalPathForRecord(record = {}) {
80
+ const current = normalizeRecordMaterialPath(record.path || '', { stripPackageEnvelope: recordHasPackageEnvelopeContext(record) });
81
+
82
+ const target = githubIssueTargetForRecord(record);
83
+ if (isCanonicalGithubIssueSidecarPath(current)) return canonicalizeGithubIssueSidecarPath(current, record, target);
84
+
85
+ const normalizedCurrent = normalizeLegacyGithubIssuePath(current, record, target);
86
+ if (normalizedCurrent) return normalizedCurrent;
87
+
88
+ if (!target.ok) return '';
89
+ const existingFile = current && !isGithubIssuePseudoPath(current) && !isUrlPathLike(record.path) && !isLegacyGithubIssueMaterialPath(current)
90
+ ? canonicalizeGithubIssueMaterialFilename(basename(current), record, target)
91
+ : '';
92
+ const filename = existingFile || issueMaterialFallbackFilename(record, target);
93
+ return `${githubIssueSidecarFolder(target)}/${filename}`;
94
+ }
95
+
96
+ function githubIssueTargetForRecord(record = {}) {
97
+ const values = [
98
+ record.recoveredFromUrl,
99
+ record.sourceTarget?.inputTarget,
100
+ record.sourceTarget?.url,
101
+ record.snapshot?.sourceUrl,
102
+ record.snapshot?.target?.canonicalUrl,
103
+ record.path
104
+ ];
105
+ for (const value of values) {
106
+ const parsed = githubIssueTargetParts(value);
107
+ if (parsed.ok) return parsed;
108
+ }
109
+ const current = normalizeRecordMaterialPath(record.path || '', { stripPackageEnvelope: recordHasPackageEnvelopeContext(record) });
110
+ const legacy = legacyIssuePathParts(current);
111
+ if (legacy.ok) {
112
+ const sourceRepo = repoPartsFromSource(record.source || {});
113
+ return Object.assign({}, legacy, sourceRepo.ok ? { owner: sourceRepo.owner, repo: sourceRepo.repo } : {});
114
+ }
115
+ return { ok: false };
116
+ }
117
+
118
+ function normalizeLegacyGithubIssuePath(path = '', record = {}, target = {}) {
119
+ const clean = normalizeWorkspacePath(path);
120
+ if (!clean || isCanonicalGithubIssueSidecarPath(clean)) return '';
121
+
122
+ const oldLogical = clean.match(/^\.topics\/\.issues\/github\/([^/]+)\/(\d+)\/(.+)$/i);
123
+ if (oldLogical) {
124
+ const owner = target?.owner || decomposeRepoSlug(oldLogical[1]).owner;
125
+ const repo = target?.repo || decomposeRepoSlug(oldLogical[1]).repo;
126
+ const canonicalFilename = canonicalizeGithubIssueMaterialFilename(oldLogical[3], record, target);
127
+ return `${githubIssueSidecarFolder({ owner, repo, number: oldLogical[2], surface: 'issues' })}/${canonicalFilename}`;
128
+ }
129
+
130
+ const legacy = clean.match(/^(?:\.topics\/)?\.github\/\.issues\/([^/]+)-issue-(\d+)\/(.+)$/i)
131
+ || clean.match(/(?:^|\/)\.github\/\.issues\/([^/]+)-issue-(\d+)\/(.+)$/i);
132
+ if (legacy) {
133
+ const owner = target?.owner || decomposeRepoSlug(legacy[1]).owner;
134
+ const repo = target?.repo || decomposeRepoSlug(legacy[1]).repo;
135
+ const canonicalFilename = canonicalizeGithubIssueMaterialFilename(legacy[3], record, target);
136
+ return `${githubIssueSidecarFolder({ owner, repo, number: legacy[2], surface: 'issues' })}/${canonicalFilename}`;
137
+ }
138
+ return '';
139
+ }
140
+
141
+ export function canonicalizeGithubIssueMaterialFilename(filename = '', record = {}, target = {}) {
142
+ const clean = basename(filename);
143
+ if (!clean) return '';
144
+ const extension = issueMaterialExtension(clean, record);
145
+
146
+ if (/^issue-snapshot\.(workspace\.md|trace\.md|markdown|md)$/i.test(clean)) return `000-${slugPart(record.title || record.name || 'issue-snapshot')}${extension}`;
147
+ const issueRoot = clean.match(/^issue-(?:root-)?(?:recovered-)?(.+?)\.(workspace\.md|trace\.md|markdown|md)$/i);
148
+ if (issueRoot) return `000-${slugPart(issueRoot[1] || record.title || 'issue-root')}${extension}`;
149
+
150
+ const commentWithOrdinal = clean.match(/^comment-(\d{1,4})-(?:\d{4,}-)?(?:recovered-)?(.+?)\.(workspace\.md|trace\.md|markdown|md)$/i);
151
+ if (commentWithOrdinal) return `${padOrdinal(commentWithOrdinal[1])}-${slugPart(commentWithOrdinal[2] || record.title || 'artifact')}${extension}`;
152
+
153
+ const commentWithId = clean.match(/^comment-(?:issuecomment-)?(\d{4,})-(?:recovered-)?(.+?)\.(workspace\.md|trace\.md|markdown|md)$/i);
154
+ if (commentWithId) {
155
+ const ordinal = recordIssueOrdinal(record) || target?.ordinal || target?.sourceOrdinal || '';
156
+ const prefix = ordinal ? padOrdinal(ordinal) : String(commentWithId[1]);
157
+ return `${prefix}-${slugPart(commentWithId[2] || record.title || 'artifact')}${extension}`;
158
+ }
159
+
160
+ return clean;
161
+ }
162
+
163
+ function canonicalizeGithubIssueSidecarPath(path = '', record = {}, target = {}) {
164
+ const clean = normalizeWorkspacePath(path);
165
+ const match = clean.match(/^(\.topics\/\.github\/[^/]+\/[^/]+\/(?:\.issues|\.discussions|\.pulls)\/\d+)\/(.+)$/i);
166
+ if (!match) return clean;
167
+ return `${match[1]}/${canonicalizeGithubIssueMaterialFilename(match[2], record, target)}`;
168
+ }
169
+
170
+ function issueMaterialFallbackFilename(record = {}, target = {}) {
171
+ const title = slugPart(record.title || record.name || (target.commentId ? 'comment' : 'issue-snapshot'));
172
+ const extension = issueMaterialExtension('', record);
173
+ if (target.commentId) {
174
+ const ordinal = recordIssueOrdinal(record) || target.ordinal || target.sourceOrdinal || '';
175
+ const prefix = ordinal ? padOrdinal(ordinal) : String(target.commentId);
176
+ return `${prefix}-${title}${extension}`;
177
+ }
178
+ const mode = String(record.sourceMode || record.sourceTarget?.targetKind || '').toLowerCase();
179
+ if (mode.includes('embedded')) return `000-${title}${extension}`;
180
+ return `000-${title || 'issue-snapshot'}${extension}`;
181
+ }
182
+
183
+
184
+ function issueMaterialExtension(filename = '', record = {}) {
185
+ const clean = String(filename || '').toLowerCase();
186
+ if (/\.workspace\.md$/i.test(clean)) return '.workspace.md';
187
+ const schema = schemaIdForRecord(record).toLowerCase();
188
+ if (schema === 'tiinex.workspace.v1' || schema.includes('.workspace.')) return '.workspace.md';
189
+ return '.trace.md';
190
+ }
191
+
192
+ function recordIssueOrdinal(record = {}) {
193
+ return firstNonEmpty(
194
+ record.sourceTarget?.sourceOrdinal,
195
+ record.sourceTarget?.ordinal,
196
+ record.snapshot?.sourceOrdinal,
197
+ record.snapshot?.ordinal,
198
+ record.publicationOrdinal,
199
+ record.issueOrdinal
200
+ );
201
+ }
202
+
203
+ function padOrdinal(value = '') {
204
+ const text = String(value ?? '').trim();
205
+ if (!/^\d+$/.test(text)) return text;
206
+ if (text.length >= 3) return text;
207
+ return text.padStart(3, '0');
208
+ }
209
+
210
+ function githubIssueSidecarFolder(target = {}) {
211
+ const owner = slugPart(target.owner || 'owner');
212
+ const repo = slugPart(target.repo || 'repo');
213
+ const surface = surfaceFolder(target.surface || 'issues');
214
+ const number = String(target.number || 'target').replace(/[^A-Za-z0-9_.-]+/g, '-') || 'target';
215
+ return `.topics/.github/${owner}/${repo}/${surface}/${number}`;
216
+ }
217
+
218
+ function surfaceFolder(surface = 'issues') {
219
+ const raw = String(surface || 'issues').toLowerCase();
220
+ if (raw.includes('discussion')) return '.discussions';
221
+ if (raw.includes('pull')) return '.pulls';
222
+ return '.issues';
223
+ }
224
+
225
+
226
+ function assignIssueDimensionPrefixes(folder = '', group = []) {
227
+ const used = new Set();
228
+ const fixed = new Map();
229
+ const remapped = new Map();
230
+ const sorted = Array.from(group || []).sort(compareIssueGroupItems);
231
+
232
+ for (const item of sorted) {
233
+ const ordinal = fixedIssueOrdinal(item.info.filename);
234
+ if (ordinal !== null) {
235
+ used.add(ordinal);
236
+ fixed.set(item.key, ordinal);
237
+ remapped.set(item.key, `${folder}/${filenameWithIssueOrdinal(item.info.filename, ordinal, item.record)}`);
238
+ }
239
+ }
240
+
241
+ let cursor = 1;
242
+ for (let index = 0; index < sorted.length; index += 1) {
243
+ const item = sorted[index];
244
+ if (fixed.has(item.key)) {
245
+ cursor = Math.max(cursor, fixed.get(item.key) + 1);
246
+ continue;
247
+ }
248
+ const appendFallback = isLongIssueFallbackFilename(item.info.filename);
249
+ const lower = appendFallback ? highestUsedOrdinal(used) : previousFixedOrdinal(sorted, fixed, index);
250
+ const upper = appendFallback ? Infinity : nextFixedOrdinal(sorted, fixed, index);
251
+ const assigned = chooseAvailableOrdinal(used, Math.max(cursor, lower + 1), upper);
252
+ used.add(assigned);
253
+ cursor = assigned + 1;
254
+ remapped.set(item.key, `${folder}/${filenameWithIssueOrdinal(item.info.filename, assigned, item.record)}`);
255
+ }
256
+ return remapped;
257
+ }
258
+
259
+ function githubIssuePathInfo(path = '', record = {}) {
260
+ const clean = normalizeWorkspacePath(path);
261
+ const sidecar = clean.match(/^(\.topics\/\.github\/[^/]+\/[^/]+\/(?:\.issues|\.discussions|\.pulls)\/\d+)\/(.+)$/i);
262
+ if (!sidecar) return { ok: false };
263
+ return {
264
+ ok: true,
265
+ folder: sidecar[1],
266
+ filename: sidecar[2],
267
+ commentId: issueCommentIdFromRecord(record) || issueCommentIdFromFilename(sidecar[2]) || ''
268
+ };
269
+ }
270
+
271
+ function fixedIssueOrdinal(filename = '') {
272
+ const match = basename(filename).match(/^(\d{3})(?:-|\.)/);
273
+ if (!match) return null;
274
+ const value = Number(match[1]);
275
+ return Number.isFinite(value) && value >= 0 && value < 1000 ? value : null;
276
+ }
277
+
278
+ function isLongIssueFallbackFilename(filename = '') {
279
+ const clean = basename(filename);
280
+ return /^\d{4,}-/.test(clean) || /^comment-(?:issuecomment-)?\d{4,}-/i.test(clean);
281
+ }
282
+
283
+ function highestUsedOrdinal(used = new Set()) {
284
+ let max = 0;
285
+ for (const value of used) if (Number.isFinite(value)) max = Math.max(max, value);
286
+ return max;
287
+ }
288
+
289
+ function filenameWithIssueOrdinal(filename = '', ordinal = 1, record = {}) {
290
+ const clean = basename(filename);
291
+ const extension = issueMaterialExtension(clean, record);
292
+ const stem = clean.replace(/\.(?:workspace\.md|trace\.md|markdown|md)$/i, '');
293
+ const hadCanonicalOrdinal = /^\d{3}-/.test(stem);
294
+ let slug = stem
295
+ .replace(/^comment-\d{1,4}-(?:\d{4,}-)?(?:recovered-)?/i, '')
296
+ .replace(/^comment-(?:issuecomment-)?\d{4,}-(?:recovered-)?/i, '')
297
+ .replace(/^\d{3,}-/i, '')
298
+ .replace(/^\d{4,}-/i, '');
299
+ if (!hadCanonicalOrdinal) slug = slug.replace(/^issue-(?:root-)?(?:recovered-)?/i, '');
300
+ slug = slug.replace(/^(?:recovered-)?/i, '');
301
+ slug = slugPart(slug || record.title || record.name || 'artifact');
302
+ return `${padOrdinal(ordinal)}-${slug}${extension}`;
303
+ }
304
+
305
+ function chooseAvailableOrdinal(used = new Set(), start = 1, upper = Infinity) {
306
+ let candidate = Math.max(1, Number(start || 1));
307
+ while (used.has(candidate) && candidate < upper) candidate += 1;
308
+ if (!used.has(candidate) && candidate < upper) return candidate;
309
+ candidate = 1;
310
+ while (used.has(candidate)) candidate += 1;
311
+ return candidate;
312
+ }
313
+
314
+ function previousFixedOrdinal(sorted = [], fixed = new Map(), index = 0) {
315
+ for (let i = index - 1; i >= 0; i -= 1) {
316
+ const value = fixed.get(sorted[i].key);
317
+ if (Number.isFinite(value)) return value;
318
+ }
319
+ return 0;
320
+ }
321
+
322
+ function nextFixedOrdinal(sorted = [], fixed = new Map(), index = 0) {
323
+ for (let i = index + 1; i < sorted.length; i += 1) {
324
+ const value = fixed.get(sorted[i].key);
325
+ if (Number.isFinite(value)) return value;
326
+ }
327
+ return Infinity;
328
+ }
329
+
330
+ function compareIssueGroupItems(a = {}, b = {}) {
331
+ const aComment = numericId(a.info?.commentId);
332
+ const bComment = numericId(b.info?.commentId);
333
+ if (aComment && bComment && aComment !== bComment) return aComment - bComment;
334
+ const timeDelta = dateValue(a.record?.sourceTarget?.sourceSortAt || a.record?.snapshot?.sourceSortAt || a.record?.currentCreatedAt || a.record?.createdAt) - dateValue(b.record?.sourceTarget?.sourceSortAt || b.record?.snapshot?.sourceSortAt || b.record?.currentCreatedAt || b.record?.createdAt);
335
+ if (timeDelta) return timeDelta;
336
+ const commentDelta = aComment - bComment;
337
+ if (commentDelta) return commentDelta;
338
+ return String(a.path || a.record?.title || '').localeCompare(String(b.path || b.record?.title || ''), undefined, { numeric: true, sensitivity: 'base' });
339
+ }
340
+
341
+ function issueCommentIdFromRecord(record = {}) {
342
+ const values = [record.sourceTarget?.inputTarget, record.sourceTarget?.url, record.recoveredFromUrl, record.snapshot?.sourceUrl, record.path];
343
+ for (const value of values) {
344
+ const id = String(value || '').match(/(?:issuecomment-|discussioncomment-|comments\/|comment-(?:\d+-)?)(\d{4,})/i)?.[1] || '';
345
+ if (id) return id;
346
+ }
347
+ return '';
348
+ }
349
+
350
+ function issueCommentIdFromFilename(filename = '') {
351
+ return String(filename || '').match(/(?:issuecomment-|discussioncomment-|comment-(?:\d+-)?)(\d{4,})/i)?.[1] || String(filename || '').match(/^(\d{4,})-/)?.[1] || '';
352
+ }
353
+
354
+ function dateValue(value = '') {
355
+ const n = Date.parse(String(value || '').trim());
356
+ return Number.isFinite(n) ? n : 0;
357
+ }
358
+ function numericId(value = '') { const n = Number(String(value || '').replace(/\D+/g, '')); return Number.isFinite(n) ? n : 0; }
359
+ function recordPathMapKey(record = {}) { return record.id || `${record.path || ''}\n${record.sourceTarget?.inputTarget || record.recoveredFromUrl || ''}\n${record.title || record.name || ''}`; }
360
+
361
+ function githubIssueTargetParts(value = '') {
362
+ const raw = String(value || '').trim();
363
+ if (!raw) return { ok: false };
364
+ const canonical = normalizeWorkspacePath(raw);
365
+ const canonicalSidecar = canonical.match(/^\.topics\/\.github\/([^/]+)\/([^/]+)\/(\.issues|\.discussions|\.pulls)\/(\d+)(?:\/.*?(?:issuecomment-|discussioncomment-|comment-(?:\d+-)?)(\d{4,}))?/i);
366
+ if (canonicalSidecar) return { ok: true, owner: canonicalSidecar[1], repo: canonicalSidecar[2], surface: canonicalSidecar[3].replace(/^\./, ''), number: canonicalSidecar[4], commentId: canonicalSidecar[5] || '' };
367
+ const pseudo = raw.match(/^([^/:?#]+)\/([^/:?#]+)\/(issues|discussions|pull)\/(\d+)(?:.*?(?:issuecomment-|discussioncomment-)(\d+))?/i);
368
+ if (pseudo) return { ok: true, owner: pseudo[1], repo: pseudo[2], surface: pseudo[3], number: pseudo[4], commentId: pseudo[5] || '' };
369
+ try {
370
+ const url = new URL(raw);
371
+ const host = url.hostname.toLowerCase();
372
+ const parts = url.pathname.split('/').filter(Boolean);
373
+ if ((host === 'github.com' || host.endsWith('.github.com')) && parts.length >= 4 && (parts[2] === 'issues' || parts[2] === 'discussions' || parts[2] === 'pull')) {
374
+ const commentId = (url.hash.match(/(?:issuecomment-|discussioncomment-)(\d+)/i) || [])[1] || '';
375
+ return { ok: true, owner: parts[0], repo: parts[1], surface: parts[2], number: parts[3], commentId };
376
+ }
377
+ } catch (_) {}
378
+ return { ok: false };
379
+ }
380
+
381
+ function legacyIssuePathParts(path = '') {
382
+ const clean = normalizeWorkspacePath(path);
383
+ const oldLogical = clean.match(/^\.topics\/\.issues\/github\/([^/]+)\/(\d+)\//i);
384
+ if (oldLogical) return Object.assign({ ok: true, number: oldLogical[2], surface: 'issues' }, decomposeRepoSlug(oldLogical[1]));
385
+ const legacy = clean.match(/(?:^|\/)\.github\/\.issues\/([^/]+)-issue-(\d+)\//i);
386
+ if (legacy) return Object.assign({ ok: true, number: legacy[2], surface: 'issues' }, decomposeRepoSlug(legacy[1]));
387
+ return { ok: false };
388
+ }
389
+
390
+ function repoPartsFromSource(source = {}) {
391
+ const repo = String(source.repo || source.repository || source.config?.repo || source.id || '').trim();
392
+ const parts = repo.split('/').filter(Boolean);
393
+ if (parts.length >= 2) return { ok: true, owner: parts[0], repo: parts[1] };
394
+ return { ok: false };
395
+ }
396
+
397
+ function decomposeRepoSlug(slug = '') {
398
+ const raw = String(slug || '').trim();
399
+ const parts = raw.split('-').filter(Boolean);
400
+ if (parts.length >= 2) return { owner: parts[0], repo: parts.slice(1).join('-') };
401
+ return { owner: raw || 'owner', repo: 'repo' };
402
+ }
403
+
404
+ function isCanonicalGithubIssueSidecarPath(path = '') {
405
+ return /^\.topics\/\.github\/[^/]+\/[^/]+\/(\.issues|\.discussions|\.pulls)\/\d+\//i.test(normalizeWorkspacePath(path));
406
+ }
407
+
408
+ function isLegacyGithubIssueMaterialPath(path = '') {
409
+ const clean = normalizeWorkspacePath(path);
410
+ return /^\.topics\/\.issues\/github\//i.test(clean) || /(?:^|\/)\.github\/\.issues\//i.test(clean);
411
+ }
412
+
413
+ function isGithubIssuePseudoPath(path = '') {
414
+ return /^[^/]+\/[^/]+\/(issues|discussions|pull)\/\d+/i.test(normalizeWorkspacePath(path));
415
+ }
416
+
417
+ function recordHasPackageEnvelopeContext(record = {}) {
418
+ const source = record.source || {};
419
+ const mode = String(record.sourceMode || record.importMode || '').toLowerCase();
420
+ return Boolean(record.packageImport || record.packagePath || mode.includes('package-import') || mode.includes('export-package') || source.adapterId === 'export-package' || source.sourceKind === 'export.package.import');
421
+ }
422
+ function isUrlPathLike(value = '') { return /^https?:\/\//i.test(String(value || '').trim()); }
423
+ function looksLikeMaterialPath(path = '') { return /(?:^|\/)(?:\.topics|topics|[^/]+\.(?:md|markdown))\//i.test(String(path || '') + '/') || /\.(?:md|markdown)$/i.test(String(path || '')); }
424
+ function basename(path = '') { return normalizeWorkspacePath(path).split('/').filter(Boolean).pop() || ''; }
425
+ function firstNonEmpty(...items) { return items.map((item) => String(item || '').trim()).find(Boolean) || ''; }
426
+ function slugPart(value = '') { return String(value || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'item'; }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { runPortableCli } from '../src/tooling/portable/adapters/cli/cli.run.js';
3
+ import { portableCanonicalBootstrapRuntime } from '../src/tooling/portable/schema/bootstrap/canonical.pack.js';
4
+
5
+ const exitCode = await runPortableCli(process.argv.slice(2), console, portableCanonicalBootstrapRuntime);
6
+ process.exitCode = exitCode;