@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,102 @@
1
+ export const TIINEX_TRANSFER_PROFILE_SCHEMA_ID = 'tiinex.llm.transfer.profile.v1';
2
+ export const TIINEX_TRANSFER_PACKAGE_SCHEMA_ID = 'tiinex.llm.transfer.package.v1';
3
+ export const TIINEX_ACTIVATION_RECEIPT_SCHEMA_ID = 'tiinex.llm.activation-receipt.v1';
4
+ export const TIINEX_TRANSFER_VERSION = '1.0.0-rc.12';
5
+
6
+ export const BootstrapDelivery = Object.freeze({ embedded: 'embedded', persistentSource: 'persistent-source' });
7
+ export const ActivationStatus = Object.freeze({ activated: 'activated', archiveUnavailable: 'archive-unavailable', bootstrapMissing: 'bootstrap-missing', bootstrapMismatch: 'bootstrap-mismatch', verificationFailed: 'verification-failed' });
8
+
9
+ export function createTiinexTransferPlan(input = {}) {
10
+ const bootstrapDelivery = normalizeBootstrapDelivery(input.bootstrapDelivery);
11
+ const prePromptPresent = Boolean(input.prePromptPresent);
12
+ const task = String(input.task || '').trim();
13
+ const artifactCount = nonNegativeInteger(input.artifactCount);
14
+ const handoffCount = nonNegativeInteger(input.handoffCount);
15
+ const provider = normalizeProvider(input.provider);
16
+ const profileId = `${bootstrapDelivery}.${prePromptPresent ? 'with-pre-prompt' : 'without-pre-prompt'}`;
17
+ const roles = Object.freeze([
18
+ Object.freeze({ role: 'bootstrap', delivery: bootstrapDelivery, required: true }),
19
+ Object.freeze({ role: 'artifacts', delivery: artifactCount ? 'attachment' : 'absent', required: false, count: artifactCount }),
20
+ Object.freeze({ role: 'handoff', delivery: handoffCount ? 'attachment' : 'absent', required: false, count: handoffCount, authority: false }),
21
+ Object.freeze({ role: 'task', delivery: task ? 'attachment' : 'prompt', required: true })
22
+ ]);
23
+ const activationReceipt = createActivationReceiptContract({ bootstrapDelivery });
24
+ return Object.freeze({
25
+ schema: TIINEX_TRANSFER_PROFILE_SCHEMA_ID,
26
+ version: 1,
27
+ transferVersion: TIINEX_TRANSFER_VERSION,
28
+ profileId,
29
+ interactionContract: Object.freeze({ maximumAttachments: 1, copyPasteBlocks: 1 }),
30
+ activationReceipt,
31
+ bootstrapDelivery,
32
+ prePromptPresent,
33
+ provider,
34
+ task,
35
+ roles,
36
+ prompt: renderTiinexTransferPrompt({ bootstrapDelivery, prePromptPresent, task, artifactCount, handoffCount, activationReceipt }),
37
+ start: renderTiinexTransferStart({ bootstrapDelivery, task, artifactCount, handoffCount, activationReceipt }),
38
+ readme: renderTiinexTransferReadme({ bootstrapDelivery, prePromptPresent, artifactCount, handoffCount, provider, activationReceipt })
39
+ });
40
+ }
41
+
42
+ export function createActivationReceiptContract(input = {}) {
43
+ const bootstrapDelivery = normalizeBootstrapDelivery(input.bootstrapDelivery);
44
+ return Object.freeze({
45
+ schema: TIINEX_ACTIVATION_RECEIPT_SCHEMA_ID,
46
+ required: true,
47
+ firstNonEmptyLine: 'TIINEX_ACTIVATION: <status>',
48
+ successStatus: ActivationStatus.activated,
49
+ allowedStatuses: Object.freeze(Object.values(ActivationStatus)),
50
+ requiredBeforeSuccess: Object.freeze([
51
+ 'archive contents exposed',
52
+ '.bootstrap/START.md read',
53
+ '.bootstrap/manifest.json read',
54
+ bootstrapDelivery === BootstrapDelivery.embedded ? 'embedded bootstrap route verified or qualified readable fallback used' : 'persistent Source bootstrap identity matched to .bootstrap/manifest.json.expectedBootstrap'
55
+ ]),
56
+ failureBehavior: 'stop-with-specific-status-and-boundary; do-not-ask-a-generic-what-should-i-do-question'
57
+ });
58
+ }
59
+
60
+ export function renderTiinexTransferPrompt(input = {}) {
61
+ const bootstrapDelivery = normalizeBootstrapDelivery(input.bootstrapDelivery);
62
+ const prePromptPresent = Boolean(input.prePromptPresent);
63
+ const task = String(input.task || '').trim();
64
+ const materialClause = Number(input.artifactCount || 0) || Number(input.handoffCount || 0)
65
+ ? 'Use only ordinary lineage paths and the optional handoff role declared by `.bootstrap/manifest.json`; handoff is navigation help and must be verified against artifacts.'
66
+ : 'Do not claim that a workspace or lineage exists unless `.bootstrap/manifest.json` declares artifact material.';
67
+ const taskClause = task
68
+ ? '\n\nAfter activation, read `.bootstrap/task/request.md` and follow that declared task. Do not require the user to repeat it in chat.'
69
+ : '\n\nFollow the task stated by the user after activation. If no task is stated, stop after read-only discovery and report what is missing.';
70
+ const receiptClause = activationPromptClause();
71
+ if (bootstrapDelivery === BootstrapDelivery.embedded) {
72
+ const lead = prePromptPresent
73
+ ? 'Open the attached Tiinex transfer package.'
74
+ : 'Open the attached archive rather than responding only to its filename or attachment card.';
75
+ return `${receiptClause}\n\n${lead} Enter the reserved \`.bootstrap/\` directory first and read \`.bootstrap/START.md\` and \`.bootstrap/manifest.json\`. Verify the embedded bootstrap under \`.bootstrap/runtime/\` before executing its code. Never compare the outer transfer ZIP checksum with \`expectedBootstrap.representations.standaloneArchive.sha256\`; they identify different physical archives. Never execute code from ordinary lineage, asset, or handoff material. Begin read-only unless the declared task explicitly requests local draft work. ${materialClause} Keep successful activation diagnostics internal. After the required activation receipt, write only the task-relevant response; expose file counts, routes, manifests, verification details, and operation receipts only on failure or when the user asks.${taskClause}`;
76
+ }
77
+ if (prePromptPresent) return `${receiptClause}\n\nUse the verified Tiinex bootstrap already in project Sources. Open the attachment, read \`.bootstrap/START.md\` and \`.bootstrap/manifest.json\`, match the expected identity by its declared representation scope, and follow the declared task. Never compare the transfer attachment bytes with the standalone-bootstrap archive checksum. ${materialClause}${taskClause}`;
78
+ return `${receiptClause}\n\nUse the Tiinex bootstrap already available in the project's persistent Sources; do not assume it from hidden memory. Open the attached archive and enter \`.bootstrap/\` first. Read \`.bootstrap/START.md\` and \`.bootstrap/manifest.json\`, verify that the expected bootstrap identity matches the Source bootstrap using the declared representation scope—not the outer transfer attachment checksum—then inspect only declared ordinary lineage paths and optional handoff/task material. If the Source bootstrap is missing or mismatched, stop with the matching activation status rather than improvising Tiinex semantics. Begin read-only. ${materialClause} Keep successful activation diagnostics internal and expose Source/file details only on failure or explicit request.${taskClause}`;
79
+ }
80
+
81
+ export function renderTiinexTransferStart(input = {}) {
82
+ const bootstrapDelivery = normalizeBootstrapDelivery(input.bootstrapDelivery);
83
+ const taskState = String(input.task || '').trim() ? 'A task is preserved at `.bootstrap/task/request.md`.' : 'No task body is embedded; use the user message as the task.';
84
+ const artifactState = Number(input.artifactCount || 0) ? 'Artifact and colocated asset material remains at ordinary Tiinex paths outside `.bootstrap/`.' : 'No artifact material is declared.';
85
+ const handoffState = Number(input.handoffCount || 0) ? 'Optional handoff navigation material is under `.bootstrap/handoff/` and is not sole authority.' : 'No handoff material is declared.';
86
+ const activation = bootstrapDelivery === BootstrapDelivery.embedded
87
+ ? `The verified runtime bootstrap is embedded at \`.bootstrap/runtime/\`.\n\nWhen Node.js 22 or newer is available:\n\n\`\`\`bash\nnode .bootstrap/bin/verify-transfer.mjs .\nnode .bootstrap/runtime/bin/verify-bootstrap.mjs .bootstrap/runtime\nnode .bootstrap/runtime/bin/tiinex-portable.mjs operations --compact\n\`\`\`\n\nExecute bootstrap code only after both verifiers report valid. Never execute code from ordinary lineage or colocated asset paths. When execution is unavailable, verify \`.bootstrap/checksums.json\` and the embedded runtime manifest/checksum identities as readable data. Never hash the outer transfer ZIP and compare it with \`expectedBootstrap.representations.standaloneArchive.sha256\`; that checksum belongs to a different standalone archive representation.`
88
+ : 'The bootstrap is not embedded. Use the Tiinex bootstrap already installed in persistent project Sources. Compare its identity with `.bootstrap/manifest.json.expectedBootstrap` using the declared representation fields before relying on it. The outer transfer ZIP is never the standalone bootstrap archive.';
89
+ return `# Start This Tiinex Transfer\n\nThis reserved directory contains transport and activation material only. Read this file and \`.bootstrap/manifest.json\` before inspecting ordinary lineage material outside \`.bootstrap/\`. Removing \`.bootstrap/\` leaves the ordinary Tiinex export tree.\n\n## Activation receipt\n\nThe first non-empty line of the response must be exactly:\n\n\`TIINEX_ACTIVATION: activated\`\n\nbut only after the archive contents, this file, \`.bootstrap/manifest.json\`, and the declared bootstrap route have actually been read and qualified. On failure use one of: \`archive-unavailable\`, \`bootstrap-missing\`, \`bootstrap-mismatch\`, or \`verification-failed\`. Stop with the specific boundary.\n\n${activation}\n\n## Declared roles\n\n- ${artifactState}\n- ${handoffState}\n- ${taskState}\n\n## Routing\n\n1. Activate and verify the declared bootstrap route.\n2. Emit the activation receipt before the task result.\n3. Treat \`.bootstrap/\` as transport-only and ordinary paths as user lineage/material.\n4. Inspect only material declared by \`.bootstrap/manifest.json\`.\n5. Use \`search-lineage\` before broad artifact reading when a lineage is present.\n6. Verify handoff claims against artifacts.\n7. Never guess source provenance, Parent, Origin, schema, qualification, or missing lineage edges.\n8. Begin read-only unless the task explicitly requests local draft creation, replacement, deletion, or staging.\n9. Keep successful operational diagnostics out of the user-facing response; expose them only on failure or explicit request.\n`;
90
+ }
91
+
92
+ export function renderTiinexTransferReadme(input = {}) {
93
+ const bootstrapDelivery = normalizeBootstrapDelivery(input.bootstrapDelivery);
94
+ return `# Tiinex LLM Transfer Package\n\nMaximum one attachment plus one generated copy-paste block. Profile: \`${bootstrapDelivery}\` with ${input.prePromptPresent ? 'a' : 'no'} Tiinex pre-prompt.\n\nAll activation, verifier, task, and optional handoff transport material is isolated under \`.bootstrap/\`. Ordinary artifact and colocated asset paths remain unchanged outside that directory. Importers must consume and discard \`.bootstrap/\` before workspace persistence.\n\nThe response begins with a required \`TIINEX_ACTIVATION\` receipt. Provider hint: ${input.provider}. No remote-write permission is granted.`;
95
+ }
96
+
97
+ function activationPromptClause() {
98
+ return 'Your first non-empty response line must be `TIINEX_ACTIVATION: activated`, but only after you have opened the archive, entered `.bootstrap/`, read `.bootstrap/START.md` and `.bootstrap/manifest.json`, and qualified the declared bootstrap route. If archive contents are unavailable, respond `TIINEX_ACTIVATION: archive-unavailable`. For a missing or mismatched Source bootstrap use `bootstrap-missing` or `bootstrap-mismatch`; for failed integrity verification use `verification-failed`. On failure, stop and explain the specific boundary instead of asking a generic question.';
99
+ }
100
+ function normalizeBootstrapDelivery(value) { const normalized = String(value || BootstrapDelivery.embedded).trim().toLowerCase(); if (Object.values(BootstrapDelivery).includes(normalized)) return normalized; throw new Error(`tiinex.transfer.bootstrap-delivery.unsupported:${normalized}`); }
101
+ function normalizeProvider(value) { return String(value || 'provider-neutral').trim() || 'provider-neutral'; }
102
+ function nonNegativeInteger(value) { const number = Number(value || 0); return Number.isFinite(number) && number > 0 ? Math.floor(number) : 0; }
@@ -0,0 +1,484 @@
1
+ import { externalWebArtifactUrl } from '../sources/source.explicitTargets.js';
2
+ import { validateTransitionDraft } from './transition.validate.js';
3
+ import { parseArtifactMarkdown } from '../artifacts/artifact.parse.js';
4
+ import { buildArtifactCreationContract, createArtifactDraftMarkdown, validateArtifactCreationResult } from '../schemas/creation.contracts.js';
5
+
6
+ export const RECORD_TRANSITION_CONTRACT_ID = 'tiinex.record.transitions.v1';
7
+ export const RECORD_TRANSITION_RESULT_SCHEMA_ID = 'tiinex.record.transition.result.v1';
8
+ export const ROOT_SCHEMA_ID = 'tiinex.root.v1';
9
+
10
+ export function listContinuationTargets(schemaRegistry = {}) {
11
+ const modules = Array.isArray(schemaRegistry.modules) ? schemaRegistry.modules : [];
12
+ return modules
13
+ .filter((module) => module && module.kind === 'concrete' && module.role === 'core-artifact' && module.id === 'tiinex.task.v1')
14
+ .map((module) => ({
15
+ id: module.id,
16
+ label: module.label || labelFromSchemaId(module.id),
17
+ summary: module.summary || 'Schema-backed Tiinex leaf.',
18
+ parentSchemaId: module.parentSchemaId || '',
19
+ contract: RECORD_TRANSITION_CONTRACT_ID,
20
+ creationContract: `creation:continue-from-record:${module.id}`,
21
+ creationStatus: 'implemented',
22
+ boundary: 'Only schema-honest Topic continuation is exposed until additional schema create renderers are implemented.'
23
+ }));
24
+ }
25
+
26
+ export function createContinuationDraft(parentRecord = {}, target = {}, input = {}, options = {}) {
27
+ const targetId = String(target.id || input.targetSchemaId || 'tiinex.task.v1').trim();
28
+ const targetLabel = String(target.label || labelFromSchemaId(targetId)).trim();
29
+ const parentTitle = String(parentRecord.title || 'artifact').trim();
30
+ const title = normalizeTitle(input.title || `Continue · ${parentTitle}`, parentTitle);
31
+ const summary = normalizeSummary(input.summary || `Continuation leaf drafted from ${parentTitle}.`);
32
+ const pathTitle = input.title ? title : parentTitle;
33
+ const allocation = allocateContinuationPath({ parentRecord, targetId, targetLabel, title: pathTitle }, options);
34
+ const path = allocation.path;
35
+ const createdAt = nowIso(options);
36
+ const creationContract = buildArtifactCreationContract({ schemaId: targetId, transitionType: 'continue-from-record' });
37
+ const markdown = createContinuationMarkdown({ parentRecord, targetId, targetLabel, title, summary, createdAt, creationContract, childPath: path });
38
+ const envelopeMetadata = draftEnvelopeMetadata(markdown, targetId);
39
+ const draft = {
40
+ schema: RECORD_TRANSITION_RESULT_SCHEMA_ID,
41
+ schemaId: targetId,
42
+ title,
43
+ summary,
44
+ kind: targetId,
45
+ status: 'local',
46
+ path,
47
+ markdown,
48
+ sourceMode: 'local-transition',
49
+ hasContinuityContext: true,
50
+ hasIntegrity: true,
51
+ creationContract,
52
+ ...envelopeMetadata,
53
+ transition: {
54
+ schema: RECORD_TRANSITION_RESULT_SCHEMA_ID,
55
+ contract: RECORD_TRANSITION_CONTRACT_ID,
56
+ type: 'continue-from-record',
57
+ intent: String(input.intent || target.intent || 'continue'),
58
+ definitionId: String(input.transitionDefinitionId || target.transitionDefinitionId || target.contract || ''),
59
+ parentRecordId: parentRecord.id || '',
60
+ parentPath: parentRecord.path || '',
61
+ parentBoundary: boundaryForRecord(parentRecord),
62
+ targetSchemaId: targetId,
63
+ createdAt,
64
+ creationContractId: creationContract.id,
65
+ pathPolicy: allocation.policy
66
+ }
67
+ };
68
+ draft.creationValidation = validateArtifactCreationResult(draft, parentRecord, { contract: creationContract });
69
+ draft.validation = validateTransitionDraft(draft, parentRecord);
70
+ return draft;
71
+ }
72
+
73
+
74
+ export function ensureUniqueTransitionPath(draft = {}, existingRecords = []) {
75
+ const currentPath = String(draft.path || '').trim();
76
+ if (!currentPath) return Object.assign({}, draft);
77
+ const occupied = existingTransitionPaths({ existingRecords });
78
+ let nextPath = currentPath;
79
+ const policy = draft.transition?.pathPolicy || null;
80
+ if (occupied.has(canonicalLocalPath(currentPath)) && policy?.kind === 'same-parent-directory') nextPath = pathFromPolicy(policy, occupied);
81
+ else nextPath = uniqueTransitionPath(currentPath, occupied);
82
+ if (nextPath === currentPath) return Object.assign({}, draft);
83
+ const nextTransition = draft.transition ? Object.assign({}, draft.transition) : draft.transition;
84
+ return Object.assign({}, draft, { path: nextPath, id: '', transition: nextTransition });
85
+ }
86
+
87
+ export function createReferenceDraft(parentRecord = {}, input = {}, options = {}) {
88
+ const parentTitle = String(parentRecord.title || 'artifact').trim();
89
+ const title = normalizeTitle(input.title || `Reference · ${parentTitle}`, parentTitle);
90
+ const summary = normalizeSummary(input.summary || `Reference leaf preserving ${parentTitle}.`);
91
+ const path = `references/${slugify(parentTitle)}.md`;
92
+ const createdAt = nowIso(options);
93
+ const creationContract = buildArtifactCreationContract({ schemaId: 'tiinex.evidence.v1', transitionType: 'reference-record' });
94
+ const referenceBody = createEvidenceReferenceBody({ parentRecord, title, summary });
95
+ const exactMarkdown = exactCreationParentEligible(parentRecord) ? createArtifactDraftMarkdown(creationContract, {
96
+ parentRecord,
97
+ childPath: path,
98
+ title,
99
+ summary,
100
+ createdAt,
101
+ status: 'draft/local',
102
+ why: 'Created as a browser-local reference draft from an existing Tiinex record.',
103
+ bodyMarkdown: referenceBody
104
+ }) : '';
105
+ const markdown = exactMarkdown || [
106
+ createRootEnvelope({ parentRecord, currentSchemaId: 'tiinex.evidence.v1', createdAt, summary, status: 'draft/local', why: 'Created as a browser-local reference draft from an existing Tiinex record.' }),
107
+ '', '---', '', referenceBody, '', createDraftIntegrity()
108
+ ].join('\n');
109
+ const envelopeMetadata = draftEnvelopeMetadata(markdown, 'tiinex.evidence.v1');
110
+ const draft = {
111
+ schema: RECORD_TRANSITION_RESULT_SCHEMA_ID,
112
+ schemaId: 'tiinex.evidence.v1',
113
+ title,
114
+ summary,
115
+ kind: 'tiinex.evidence.v1',
116
+ status: 'local',
117
+ path,
118
+ markdown,
119
+ sourceMode: 'local-reference',
120
+ hasContinuityContext: true,
121
+ hasIntegrity: true,
122
+ creationContract,
123
+ ...envelopeMetadata,
124
+ transition: {
125
+ schema: RECORD_TRANSITION_RESULT_SCHEMA_ID,
126
+ contract: RECORD_TRANSITION_CONTRACT_ID,
127
+ type: 'reference-record',
128
+ parentRecordId: parentRecord.id || '',
129
+ parentPath: parentRecord.path || '',
130
+ parentBoundary: boundaryForRecord(parentRecord),
131
+ targetSchemaId: 'tiinex.evidence.v1',
132
+ createdAt,
133
+ creationContractId: creationContract.id
134
+ }
135
+ };
136
+ draft.creationValidation = validateArtifactCreationResult(draft, parentRecord, { contract: creationContract });
137
+ draft.validation = validateTransitionDraft(draft, parentRecord);
138
+ return draft;
139
+ }
140
+
141
+
142
+
143
+
144
+ export function allocateRootArtifactPath({ targetId = '', targetLabel = '', title = '' } = {}, options = {}) {
145
+ const occupied = existingTransitionPaths(options);
146
+ const explicitPath = canonicalLocalPath(options.path || options.draftPath || '');
147
+ if (explicitPath) return { path: uniqueTransitionPath(explicitPath, occupied), policy: pathPolicyForExplicit(explicitPath) };
148
+ const labelSlug = slugify(title || targetLabel || labelFromSchemaId(targetId) || 'artifact');
149
+ const targetSlug = slugify(targetLabel || labelFromSchemaId(targetId) || 'artifact');
150
+ const basePath = `.topics/${labelSlug}--${targetSlug}.trace.md`;
151
+ return {
152
+ path: uniqueTransitionPath(basePath, occupied),
153
+ policy: {
154
+ schema: 'tiinex.transition.path-policy.v1',
155
+ kind: 'standalone-root',
156
+ parentDirectory: '.topics',
157
+ labelSlug,
158
+ targetSlug,
159
+ extension: '.trace.md'
160
+ }
161
+ };
162
+ }
163
+
164
+ export function allocateContinuationPath({ parentRecord = {}, targetId = '', targetLabel = '', title = '' } = {}, options = {}) {
165
+ const occupied = existingTransitionPaths(options);
166
+ const explicitPath = canonicalLocalPath(options.path || options.draftPath || '');
167
+ if (explicitPath) return { path: uniqueTransitionPath(explicitPath, occupied), policy: pathPolicyForExplicit(explicitPath) };
168
+ const parentPath = externalWebArtifactUrl(parentRecord) ? '' : canonicalLocalPath(parentRecord.path || parentRecord.sourcePath || parentRecord.sourceTarget?.sourceArtifactPath || '');
169
+ const parentDir = parentDirectory(parentPath) || '.topics';
170
+ const parentPrefix = lineagePrefixFromPath(parentPath);
171
+ const labelSlug = slugify(title || parentRecord.title || targetLabel || 'continuation');
172
+ const targetSlug = slugify(targetLabel || labelFromSchemaId(targetId) || 'leaf');
173
+ const extension = '.trace.md';
174
+ const policy = {
175
+ schema: 'tiinex.transition.path-policy.v1',
176
+ kind: 'same-parent-directory',
177
+ parentDirectory: parentDir,
178
+ parentPath,
179
+ parentLineagePrefix: parentPrefix,
180
+ labelSlug,
181
+ targetSlug,
182
+ extension
183
+ };
184
+ return { path: pathFromPolicy(policy, occupied), policy };
185
+ }
186
+
187
+ function pathFromPolicy(policy = {}, occupied = new Set()) {
188
+ const dir = canonicalLocalPath(policy.parentDirectory || '.topics') || '.topics';
189
+ const extension = String(policy.extension || '.trace.md').startsWith('.') ? String(policy.extension || '.trace.md') : `.${policy.extension}`;
190
+ const labelSlug = slugify(policy.labelSlug || 'continuation');
191
+ const targetSlug = slugify(policy.targetSlug || 'leaf');
192
+ const parentPrefix = String(policy.parentLineagePrefix || '').trim();
193
+ if (parentPrefix) {
194
+ const childPrefix = nextChildLineagePrefix(parentPrefix, dir, occupied);
195
+ return `${dir}/${childPrefix}-${labelSlug}.${extension.replace(/^\./, '')}`;
196
+ }
197
+ return uniqueTransitionPath(`${dir}/${labelSlug}--${targetSlug}${extension}`, occupied);
198
+ }
199
+
200
+ function pathPolicyForExplicit(path = '') {
201
+ const canonical = canonicalLocalPath(path);
202
+ return {
203
+ schema: 'tiinex.transition.path-policy.v1',
204
+ kind: 'explicit-path',
205
+ parentDirectory: parentDirectory(canonical) || '',
206
+ explicitPath: canonical
207
+ };
208
+ }
209
+
210
+ function parentDirectory(path = '') {
211
+ const raw = String(path || '').trim();
212
+ if (/^https?:\/\//i.test(raw)) return '';
213
+ const canonical = canonicalLocalPath(raw);
214
+ if (!canonical) return '';
215
+ const index = canonical.lastIndexOf('/');
216
+ return index > -1 ? canonical.slice(0, index) || '.' : '';
217
+ }
218
+
219
+ function lineagePrefixFromPath(path = '') {
220
+ const name = basenameWithoutKnownMarkdownExtension(path);
221
+ if (!name) return '';
222
+ const recoveredComment = name.match(/^comment-(\d{3})(?:-|$)/i);
223
+ if (recoveredComment) return recoveredComment[1];
224
+ const numeric = name.match(/^(\d+(?:-\d+)*)(?:-|$)/);
225
+ if (numeric && !/^20\d{2}$/.test(numeric[1])) return numeric[1];
226
+ return '';
227
+ }
228
+
229
+ function nextChildLineagePrefix(parentPrefix = '', dir = '', occupied = new Set()) {
230
+ const prefix = String(parentPrefix || '').trim();
231
+ const width = childOrdinalWidth(prefix);
232
+ const numbers = [];
233
+ for (const path of occupied || []) {
234
+ const canonical = canonicalLocalPath(path);
235
+ if (parentDirectory(canonical) !== dir) continue;
236
+ const name = basenameWithoutKnownMarkdownExtension(canonical);
237
+ const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
238
+ const match = name.match(new RegExp(`^${escaped}-(\\d+)(?:-|$)`));
239
+ if (!match || !isChildOrdinalSegment(prefix, match[1])) continue;
240
+ numbers.push(Number(match[1]));
241
+ }
242
+ const next = numbers.length ? Math.max(...numbers) + 1 : 1;
243
+ return `${prefix}-${String(next).padStart(width, '0')}`;
244
+ }
245
+
246
+ function isChildOrdinalSegment(prefix = '', value = '') {
247
+ const raw = String(value || '').trim();
248
+ if (!/^\d+$/.test(raw)) return false;
249
+ return true;
250
+ }
251
+
252
+ function childOrdinalWidth(prefix = '') {
253
+ const parts = String(prefix || '').split('-').filter(Boolean);
254
+ if (parts.length >= 2 && parts.every((part) => /^\d{2}$/.test(part))) return 2;
255
+ return 1;
256
+ }
257
+
258
+ function basenameWithoutKnownMarkdownExtension(path = '') {
259
+ const canonical = canonicalLocalPath(path);
260
+ const base = canonical.split('/').filter(Boolean).pop() || '';
261
+ return base.replace(/\.trace\.md$/i, '').replace(/\.workspace\.md$/i, '').replace(/\.md$/i, '');
262
+ }
263
+
264
+ function draftEnvelopeMetadata(markdown = '', fallbackSchemaId = '') {
265
+ const parsed = parseArtifactMarkdown(markdown);
266
+ const parent = parsed.envelope?.parent || {};
267
+ const current = parsed.envelope?.current || {};
268
+ return {
269
+ schemaId: current.schema?.id || fallbackSchemaId || '',
270
+ parentSchemaId: parent.schema?.id || '',
271
+ trace: parent.trace || '',
272
+ traceLabel: parent.traceLabel || '',
273
+ origin: parent.origin || '',
274
+ boundary: parent.boundary || '',
275
+ createdAt: current.createdAt || '',
276
+ currentCreatedAt: current.createdAt || '',
277
+ currentStatus: current.status || '',
278
+ currentWhy: current.why || ''
279
+ };
280
+ }
281
+
282
+ function createEvidenceReferenceBody({ parentRecord = {}, title = 'Reference', summary = '' }) {
283
+ const boundary = boundaryForRecord(parentRecord);
284
+ const sourceLabel = parentRecord.source?.label || parentRecord.source?.repo || parentRecord.source?.id || '';
285
+ const excerpt = truncate(String(parentRecord.markdown || parentRecord.summary || '').trim(), 1800) || '_No embedded source material was available._';
286
+ return [
287
+ `# ${title}`,
288
+ '',
289
+ '## Reference',
290
+ '',
291
+ 'This browser-local Evidence draft preserves the selected record as bounded reference material.',
292
+ '',
293
+ '## Supported Claim Or Question',
294
+ '',
295
+ summary || `Preserves ${parentRecord.title || 'the selected artifact'} as supporting material for later review or continuation.`,
296
+ '',
297
+ '## Provenance',
298
+ '',
299
+ `- Parent Trace: ${parentRecord.id ? `record:${parentRecord.id}` : 'record:unassigned'}`,
300
+ parentRecord.path ? `- Parent path: ${parentRecord.path}` : '',
301
+ sourceLabel ? `- Parent source: ${sourceLabel}` : '',
302
+ `- Boundary: ${boundary}`,
303
+ '',
304
+ '## Evidence Material',
305
+ '',
306
+ '```markdown',
307
+ excerpt,
308
+ '```',
309
+ '',
310
+ '## Preservation And Fidelity',
311
+ '',
312
+ '- Method: browser-local reference draft from loaded material.',
313
+ '- Fidelity: excerpted material is bounded to the currently loaded record; remote parents are not fetched or completed silently.',
314
+ '- Mutation: no source mutation; no publication occurred.',
315
+ '',
316
+ '## Interpretation Limits',
317
+ '',
318
+ '- This Evidence draft preserves material for review; it does not validate, endorse, attest, or make the supported claim true.',
319
+ '- Missing parent, source, or remote material must remain explicit until loaded or resolved through a separate audit/lineage traversal.'
320
+ ].filter(Boolean).join('\n');
321
+ }
322
+
323
+
324
+ function exactCreationParentEligible(record = {}) {
325
+ const published = record.publishedReference || record.browseGitReference || record.browseGit || null;
326
+ const publishedTarget = typeof published === 'string' ? published : String(published?.target || published?.url || '');
327
+ const publishedState = typeof published === 'string' ? 'unresolved' : String(published?.state || published?.resolutionState || 'unresolved');
328
+ const schemaReference = record.schemaReferenceAuthority || record.parentSchemaReferenceAuthority || null;
329
+ const schemaTarget = typeof schemaReference === 'string' ? schemaReference : String(schemaReference?.preferredTarget || schemaReference?.target || '');
330
+ const schemaState = typeof schemaReference === 'string' ? 'unresolved' : String(schemaReference?.resolutionState || schemaReference?.state || 'unresolved');
331
+ return Boolean(publishedTarget && publishedState === 'qualified' && schemaTarget && schemaState === 'qualified');
332
+ }
333
+
334
+ function createContinuationMarkdown({ parentRecord, targetId, targetLabel, title, summary, createdAt, creationContract, childPath = '' }) {
335
+ const bodyMarkdown = [
336
+ `# ${title}`,
337
+ '',
338
+ `## ${targetLabel} Draft`,
339
+ '',
340
+ summary,
341
+ '',
342
+ '## Source Boundary',
343
+ '',
344
+ `- ${boundaryForRecord(parentRecord)}`,
345
+ parentRecord.path ? `- Parent path: ${parentRecord.path}` : '',
346
+ parentRecord.source?.label ? `- Parent source: ${parentRecord.source.label}` : '',
347
+ '',
348
+ '## Next Step',
349
+ '',
350
+ '- Review and refine this task draft before export/publication.',
351
+ '',
352
+ '## Source Excerpt',
353
+ '',
354
+ truncate(String(parentRecord.markdown || parentRecord.summary || '').trim(), 1800) || '_No embedded source material was available._'
355
+ ].filter(Boolean).join('\n');
356
+ const exact = exactCreationParentEligible(parentRecord) ? createArtifactDraftMarkdown(creationContract, {
357
+ parentRecord,
358
+ childPath,
359
+ currentSchemaId: targetId,
360
+ title,
361
+ summary,
362
+ createdAt,
363
+ status: 'draft/local',
364
+ why: 'Created as a browser-local continuation draft. No source provenance is inferred.',
365
+ bodyMarkdown
366
+ }) : '';
367
+ if (exact) return exact;
368
+ // Preserve the pre-existing Site transition draft as explicitly non-exact
369
+ // local material when no qualified published Parent representation exists.
370
+ // v475 exact creation validation rejects this legacy envelope/footer; this
371
+ // compatibility path never upgrades it to canonical authority.
372
+ return [
373
+ createRootEnvelope({ parentRecord, currentSchemaId: targetId, createdAt, summary, status: 'draft/local', why: 'Created as a browser-local continuation draft. No source provenance is inferred.' }),
374
+ '', '---', '', bodyMarkdown, '', createDraftIntegrity()
375
+ ].join('\n');
376
+ }
377
+
378
+ function createRootEnvelope({ parentRecord, currentSchemaId, createdAt, summary, status, why }) {
379
+ const parentSchemaId = parentSchemaForRecord(parentRecord);
380
+ return [
381
+ '# Continuity Context',
382
+ '',
383
+ `- Envelope Schema: [${ROOT_SCHEMA_ID}](${ROOT_SCHEMA_ID}.schema.md)`,
384
+ '- Parent',
385
+ ` - Parent Schema: [${parentSchemaId}](${parentSchemaId}.schema.md)`,
386
+ ` - Created At: ${parentRecord.createdAt || 'unknown'}`,
387
+ ` - Trace: ${parentRecord.id ? `record:${parentRecord.id}` : 'record:unassigned'}`,
388
+ parentRecord.path ? ` - Origin: ${parentRecord.path}` : '',
389
+ ` - Boundary: ${boundaryForRecord(parentRecord)}`,
390
+ '- Current',
391
+ ` - Current Schema: [${currentSchemaId}](${currentSchemaId}.schema.md)`,
392
+ ` - Created At: ${createdAt}`,
393
+ ` - Summary: ${summary}`,
394
+ ` - Status: ${status}`,
395
+ ` - Why: ${why}`
396
+ ].filter(Boolean).join('\n');
397
+ }
398
+
399
+ function createDraftIntegrity() {
400
+ return [
401
+ '# Continuity Integrity',
402
+ '',
403
+ '- Draft Local Integrity',
404
+ ' - Method: browser-local-draft',
405
+ ' - Value: pending-publication-or-export'
406
+ ].join('\n');
407
+ }
408
+
409
+ function parentSchemaForRecord(record = {}) {
410
+ const schemaId = String(record.schemaId || record.currentSchemaId || '').trim();
411
+ return schemaId || ROOT_SCHEMA_ID;
412
+ }
413
+
414
+ function boundaryForRecord(record = {}) {
415
+ const source = record.source || {};
416
+ if (source.adapterId === 'github') return 'source-backed github material';
417
+ if (source.adapterId === 'local' || source.kind === 'local-session' || record.sourceMode?.startsWith?.('local')) return 'browser-local session material; no GitHub provenance inferred';
418
+ return 'explicit record boundary';
419
+ }
420
+
421
+ function normalizeTitle(value, fallback = 'artifact') {
422
+ const text = String(value || '').replace(/\s+/g, ' ').trim();
423
+ return text.slice(0, 96) || `Continue · ${fallback}`.slice(0, 96);
424
+ }
425
+
426
+ function normalizeSummary(value) {
427
+ return String(value || '').replace(/\s+/g, ' ').trim().slice(0, 280) || 'Continuation drafted in Tiinex.';
428
+ }
429
+
430
+ function labelFromSchemaId(id = '') {
431
+ const tail = String(id || '').split('.').filter(Boolean).slice(-2, -1)[0] || String(id || 'leaf');
432
+ return tail.charAt(0).toUpperCase() + tail.slice(1);
433
+ }
434
+
435
+ function existingTransitionPaths(options = {}) {
436
+ const inputs = [];
437
+ if (Array.isArray(options.existingRecords)) inputs.push(...options.existingRecords);
438
+ if (Array.isArray(options.workspaceRecords)) inputs.push(...options.workspaceRecords);
439
+ if (Array.isArray(options.existingPaths)) inputs.push(...options.existingPaths.map((path) => ({ path })));
440
+ return new Set(inputs.map((item) => canonicalLocalPath(typeof item === 'string' ? item : item?.path || '')).filter(Boolean));
441
+ }
442
+
443
+ function uniqueTransitionPath(basePath = '', occupied = new Set()) {
444
+ const canonical = canonicalLocalPath(basePath || 'continuations/continuation.md') || 'continuations/continuation.md';
445
+ if (!occupied.has(canonical)) return canonical;
446
+ const compound = canonical.match(/^(.*?)(\.trace\.md|\.workspace\.md|\.schema\.md|\.md)$/i);
447
+ const stem = compound ? compound[1] : (canonical.lastIndexOf('.') > -1 ? canonical.slice(0, canonical.lastIndexOf('.')) : canonical);
448
+ const ext = compound ? compound[2] : (canonical.lastIndexOf('.') > -1 ? canonical.slice(canonical.lastIndexOf('.')) : '');
449
+ for (let index = 2; index < 10000; index += 1) {
450
+ const candidate = `${stem}-${index}${ext}`;
451
+ if (!occupied.has(candidate)) return candidate;
452
+ }
453
+ return `${stem}-${Date.now().toString(36)}${ext}`;
454
+ }
455
+
456
+ function canonicalLocalPath(value = '') {
457
+ const raw = String(value || '').trim().replace(/\\/g, '/').replace(/\/+/g, '/');
458
+ if (!raw) return '';
459
+ const parts = [];
460
+ for (const part of raw.split('/')) {
461
+ if (!part || part === '.') continue;
462
+ if (part === '..') {
463
+ parts.pop();
464
+ continue;
465
+ }
466
+ parts.push(part);
467
+ }
468
+ return parts.join('/');
469
+ }
470
+
471
+
472
+ function slugify(value = '') {
473
+ return String(value || 'artifact').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 64) || 'artifact';
474
+ }
475
+
476
+ function truncate(value = '', limit = 1800) {
477
+ const text = String(value || '').trim();
478
+ return text.length > limit ? `${text.slice(0, limit)}\n…` : text;
479
+ }
480
+
481
+ function nowIso(options = {}) {
482
+ if (typeof options.clock === 'function') return options.clock();
483
+ return new Date().toISOString();
484
+ }