@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,124 @@
1
+ const BOOTSTRAP_ROOT = '.bootstrap/';
2
+ const PORTABLE_MANIFEST_SCHEMAS = new Set([
3
+ 'tiinex.portable.artifact-set.manifest.v1',
4
+ 'tiinex.portable.changeset.manifest.v1'
5
+ ]);
6
+ const PORTABLE_CHECKSUM_SCHEMAS = new Set([
7
+ 'tiinex.portable.artifact-set.checksums.v1',
8
+ 'tiinex.portable.changeset.checksums.v1'
9
+ ]);
10
+
11
+ export function isBootstrapTransportPath(value = '') {
12
+ const path = cleanPath(value);
13
+ return path === '.bootstrap' || path.startsWith(BOOTSTRAP_ROOT);
14
+ }
15
+
16
+ export async function filterArchiveTransportEntries(entries = [], options = {}) {
17
+ const source = Array.isArray(entries) ? entries : [];
18
+ const bootstrap = source.filter((entry) => isBootstrapTransportPath(entry.path));
19
+ const ordinary = source.filter((entry) => !isBootstrapTransportPath(entry.path));
20
+ const manifestEntry = ordinary.find((entry) => entry.path === 'manifest.json');
21
+ const checksumsEntry = ordinary.find((entry) => entry.path === 'checksums.json');
22
+ const manifest = parseJson(manifestEntry?.content);
23
+ const checksums = parseJson(checksumsEntry?.content);
24
+ const portableControl = Boolean(PORTABLE_MANIFEST_SCHEMAS.has(manifest?.schema) && PORTABLE_CHECKSUM_SCHEMAS.has(checksums?.schema));
25
+ const stripBootstrap = options.stripBootstrapTransport !== false;
26
+ const stripPortableControl = options.stripPortableControl !== false;
27
+ const filtered = source.filter((entry) => {
28
+ if (stripBootstrap && isBootstrapTransportPath(entry.path)) return false;
29
+ if (stripPortableControl && portableControl && (entry.path === 'manifest.json' || entry.path === 'checksums.json')) return false;
30
+ return true;
31
+ });
32
+ const mergePreflight = portableControl
33
+ ? await preflightPortableChangeset(manifest, ordinary, options.existingRecords || [])
34
+ : neutralMergePreflight();
35
+ return Object.freeze({
36
+ entries: Object.freeze(filtered),
37
+ manifest,
38
+ checksums,
39
+ portableControl,
40
+ mergePreflight,
41
+ diagnostics: Object.freeze({
42
+ bootstrapDetected: bootstrap.length > 0,
43
+ bootstrapStrippedCount: stripBootstrap ? bootstrap.length : 0,
44
+ bootstrapManifestSchema: parseJson(bootstrap.find((entry) => entry.path === '.bootstrap/manifest.json')?.content)?.schema || '',
45
+ portableControlDetected: portableControl,
46
+ portableControlStrippedCount: stripPortableControl && portableControl ? Number(Boolean(manifestEntry)) + Number(Boolean(checksumsEntry)) : 0,
47
+ mergePreflight
48
+ })
49
+ });
50
+ }
51
+
52
+ export async function preflightPortableChangeset(manifest = {}, entries = [], existingRecords = []) {
53
+ if (!PORTABLE_MANIFEST_SCHEMAS.has(manifest?.schema)) return neutralMergePreflight();
54
+ const existing = indexExistingRecords(existingRecords);
55
+ const included = new Map((entries || []).map((entry) => [cleanPath(entry.path), entry]));
56
+ const conflicts = [];
57
+ const matched = [];
58
+ const availableContext = [];
59
+ const missing = [];
60
+
61
+ for (const parent of manifest.lineage?.knownParents || []) {
62
+ const path = cleanPath(parent.path);
63
+ const expected = String(parent.sha256 || '').trim().toLowerCase();
64
+ const current = existing.get(path) || existing.get(String(parent.id || '').trim());
65
+ if (current) {
66
+ const digest = await sha256Hex(String(current.markdown || current.content || ''));
67
+ if (expected && digest !== expected) conflicts.push(conflict('archive.merge.parent-drift', path, expected, digest));
68
+ else matched.push(path);
69
+ continue;
70
+ }
71
+ const packaged = included.get(path);
72
+ if (packaged && parent.included !== false) {
73
+ const digest = await sha256Hex(packaged.bytes || packaged.content || '');
74
+ if (expected && digest !== expected) conflicts.push(conflict('archive.merge.context-checksum-mismatch', path, expected, digest));
75
+ else availableContext.push(path);
76
+ continue;
77
+ }
78
+ missing.push(path);
79
+ conflicts.push(conflict('archive.merge.parent-missing', path, expected, 'missing'));
80
+ }
81
+
82
+ for (const material of manifest.material || []) {
83
+ if (material.role !== 'modified') continue;
84
+ const path = cleanPath(material.path);
85
+ const current = existing.get(path);
86
+ const expectedBase = String(material.baseSha256 || '').trim().toLowerCase();
87
+ if (!current) conflicts.push(conflict('archive.merge.modified-base-missing', path, expectedBase, 'missing'));
88
+ else {
89
+ const digest = await sha256Hex(String(current.markdown || current.content || ''));
90
+ if (expectedBase && digest !== expectedBase) conflicts.push(conflict('archive.merge.modified-base-drift', path, expectedBase, digest));
91
+ }
92
+ }
93
+
94
+ return Object.freeze({
95
+ schema: 'tiinex.archive.merge-preflight.v1',
96
+ status: conflicts.length ? 'blocked' : 'ready',
97
+ checkedParents: (manifest.lineage?.knownParents || []).length,
98
+ matchedParents: matched.length,
99
+ availableContext: availableContext.length,
100
+ missingParents: missing.length,
101
+ conflicts: Object.freeze(conflicts)
102
+ });
103
+ }
104
+
105
+ function neutralMergePreflight() {
106
+ return Object.freeze({ schema: 'tiinex.archive.merge-preflight.v1', status: 'not-applicable', checkedParents: 0, matchedParents: 0, availableContext: 0, missingParents: 0, conflicts: Object.freeze([]) });
107
+ }
108
+ function conflict(code, path, expected, actual) { return Object.freeze({ code, path, expected, actual }); }
109
+ function parseJson(value) { try { return value ? JSON.parse(String(value)) : null; } catch { return null; } }
110
+ function cleanPath(value = '') { return String(value || '').replace(/\\/g, '/').replace(/^\.\//, '').replace(/\/{2,}/g, '/').replace(/^\/+|\/+$/g, ''); }
111
+ function indexExistingRecords(records = []) {
112
+ const map = new Map();
113
+ for (const record of Array.isArray(records) ? records : []) {
114
+ const path = cleanPath(record.path);
115
+ if (path) map.set(path, record);
116
+ if (record.id) map.set(String(record.id), record);
117
+ }
118
+ return map;
119
+ }
120
+ async function sha256Hex(value) {
121
+ const bytes = value instanceof Uint8Array ? value : value instanceof ArrayBuffer ? new Uint8Array(value) : new TextEncoder().encode(String(value || ''));
122
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);
123
+ return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, '0')).join('');
124
+ }
@@ -0,0 +1,27 @@
1
+ import { schemaIdForRecord } from '../schemas/schema.identity.js';
2
+
3
+ export const LOCAL_DRAFT_ARTIFACT_POLICY_ID = 'tiinex.artifact.local-draft-policy.v1';
4
+ export const EDITABLE_LOCAL_DRAFT_SCHEMA_IDS = Object.freeze(['tiinex.task.v1']);
5
+
6
+ export function localDraftArtifactPolicy(record = {}) {
7
+ const source = record?.source || {};
8
+ const sourceMode = String(record?.sourceMode || '').trim().toLowerCase();
9
+ const status = String(record?.status || record?.lifecycleStatus || record?.currentStatus || record?.envelope?.current?.status || '').trim().toLowerCase();
10
+ const schemaId = artifactSchemaId(record);
11
+ const localSource = source.adapterId === 'local' || source.kind === 'local-session' || source.kind === 'local' || source.sourceKind === 'local.session';
12
+ const draftLike = sourceMode.startsWith('local-transition') || sourceMode.startsWith('local-reference') || sourceMode.startsWith('local-draft') || status === 'draft' || status === 'local' || status === 'draft/local';
13
+ const localDraft = Boolean(localSource && draftLike && record?.id);
14
+ return Object.freeze({
15
+ schema: LOCAL_DRAFT_ARTIFACT_POLICY_ID,
16
+ localDraft,
17
+ schemaId,
18
+ editLocalDraft: Boolean(localDraft && EDITABLE_LOCAL_DRAFT_SCHEMA_IDS.includes(schemaId)),
19
+ discardLocalDraft: localDraft,
20
+ sourceBacked: !localSource
21
+ });
22
+ }
23
+
24
+ export function canEditLocalDraft(record = {}) { return localDraftArtifactPolicy(record).editLocalDraft; }
25
+ export function canDiscardLocalDraft(record = {}) { return localDraftArtifactPolicy(record).discardLocalDraft; }
26
+
27
+ export function artifactSchemaId(record = {}) { return schemaIdForRecord(record); }
@@ -0,0 +1,28 @@
1
+ import { createRootFallbackModel } from '../schemas/tiinex.root.v1.fallback.js';
2
+ import { schemaBadgeClass, schemaKey } from '../schemas/tiinex.root.v1.classify.js';
3
+
4
+ export function normalizeArtifact(parsedArtifact, schemaResolution, validation = []) {
5
+ const currentSchemaId = parsedArtifact.envelope.current.schema.id || 'unknown';
6
+ const fallbackModel = createRootFallbackModel(parsedArtifact, schemaResolution, validation);
7
+ return {
8
+ title: parsedArtifact.title,
9
+ schemaId: currentSchemaId,
10
+ envelopeSchemaId: parsedArtifact.envelope.envelopeSchema.id || 'unknown',
11
+ moduleId: schemaResolution.module.id,
12
+ resolutionStatus: schemaResolution.status,
13
+ fallbackUsed: schemaResolution.fallbackUsed,
14
+ createdAt: parsedArtifact.envelope.current.createdAt || 'unknown',
15
+ parentSchemaId: parsedArtifact.envelope.parent.schema.id || null,
16
+ trace: parsedArtifact.envelope.parent.trace || '',
17
+ traceLabel: parsedArtifact.envelope.parent.traceLabel || '',
18
+ origin: parsedArtifact.envelope.parent.origin || parsedArtifact.envelope.origin || '',
19
+ boundary: parsedArtifact.envelope.parent.boundary || parsedArtifact.envelope.boundary || '',
20
+ schemaKey: schemaKey(currentSchemaId),
21
+ badgeClass: schemaBadgeClass(currentSchemaId),
22
+ rootReadable: fallbackModel.rootReadable,
23
+ rootDisclosure: fallbackModel.disclosure,
24
+ fallbackModel,
25
+ sections: parsedArtifact.body.sections,
26
+ validation
27
+ };
28
+ }
@@ -0,0 +1,207 @@
1
+ export function parseArtifactMarkdown(markdown = '') {
2
+ const text = normalizeLineEndings(markdown);
3
+ const envelopeBoundary = findFirstHorizontalRule(text);
4
+ const envelopeText = envelopeBoundary === -1 ? text : text.slice(0, envelopeBoundary).trimEnd();
5
+ const remainder = envelopeBoundary === -1 ? '' : text.slice(envelopeBoundary).replace(/^---\s*\n?/, '');
6
+ const integrityIndex = remainder.search(/^# Continuity Integrity\s*$/m);
7
+ const bodySlice = integrityIndex === -1 ? remainder : remainder.slice(0, integrityIndex);
8
+ const bodyText = stripCanonicalFooterDivider(bodySlice).trim();
9
+ const integrityText = integrityIndex === -1 ? '' : remainder.slice(integrityIndex).trim();
10
+
11
+ const envelope = parseContinuityEnvelope(envelopeText);
12
+ const body = parseBody(bodyText);
13
+ const integrity = parseIntegrity(integrityText);
14
+
15
+ return {
16
+ markdown: text,
17
+ title: body.title || envelope.current.summary || 'Untitled artifact',
18
+ envelope,
19
+ body,
20
+ integrity,
21
+ hasContinuityContext: /^# Continuity Context\s*$/m.test(envelopeText),
22
+ hasIntegrity: integrity.methods.length > 0
23
+ };
24
+ }
25
+
26
+ export function parseContinuityEnvelope(envelopeText = '') {
27
+ const parentBlock = blockAfterTopLevelList(envelopeText, 'Parent');
28
+ const currentBlock = blockAfterTopLevelList(envelopeText, 'Current');
29
+ return {
30
+ envelopeSchema: extractSchemaField(envelopeText, 'Envelope Schema'),
31
+ parent: {
32
+ schema: extractSchemaField(parentBlock, 'Parent Schema'),
33
+ createdAt: extractListField(parentBlock, 'Created At'),
34
+ trace: extractListField(parentBlock, 'Trace', { preferLinkTarget: true }),
35
+ traceLabel: extractListField(parentBlock, 'Trace'),
36
+ traceRaw: extractListField(parentBlock, 'Trace', { preserveRaw: true }),
37
+ origin: extractListField(parentBlock, 'Origin', { preferLinkTarget: true }),
38
+ originEntries: Object.freeze(extractNestedLinkEntries(parentBlock, 'Origin')),
39
+ boundary: extractListField(parentBlock, 'Boundary')
40
+ },
41
+ current: {
42
+ schema: extractSchemaField(currentBlock, 'Current Schema'),
43
+ createdAt: extractListField(currentBlock, 'Created At'),
44
+ summary: extractListField(currentBlock, 'Summary'),
45
+ authors: extractListField(currentBlock, 'Authors'),
46
+ status: extractListField(currentBlock, 'Status'),
47
+ why: extractListField(currentBlock, 'Why')
48
+ },
49
+ repairsDeclared: /^\s*-\s*Repairs:/m.test(envelopeText),
50
+ origin: extractListField(envelopeText, 'Origin', { preferLinkTarget: true }),
51
+ boundary: extractListField(envelopeText, 'Boundary')
52
+ };
53
+ }
54
+
55
+ export function parseBody(bodyText = '') {
56
+ const headings = [...bodyText.matchAll(/^(#{1,6})\s+(.+)\s*$/gm)].map((match) => ({ level: match[1].length, text: match[2].trim() }));
57
+ const firstHeading = headings.find((heading) => heading.level === 1 && heading.text !== 'Continuity Context' && heading.text !== 'Continuity Integrity');
58
+ return {
59
+ title: firstHeading?.text || '',
60
+ headings,
61
+ sections: headings.filter((heading) => heading.level === 2).map((heading) => heading.text),
62
+ text: bodyText
63
+ };
64
+ }
65
+
66
+ export function parseIntegrity(integrityText = '') {
67
+ const entries = parseIntegrityEntries(integrityText);
68
+ const methods = entries.flatMap((entry) => [entry.method, entry.declaredMethod]).filter(Boolean);
69
+ const values = entries.map((entry) => entry.value).filter(Boolean);
70
+ return { methods, values, entries, text: integrityText };
71
+ }
72
+
73
+ function parseIntegrityEntries(integrityText = '') {
74
+ const lines = String(integrityText || '').split('\n');
75
+ const entries = [];
76
+ let current = null;
77
+ const flush = () => {
78
+ if (!current) return;
79
+ const method = current.label || '';
80
+ const declaredMethod = current.fields.Method || '';
81
+ entries.push({
82
+ method: stripMarkdown(method),
83
+ declaredMethod: stripMarkdown(declaredMethod),
84
+ methodRaw: method,
85
+ towards: normalizeFieldValue(current.fields.Towards || '', { preferLinkTarget: true }),
86
+ towardsLabel: normalizeFieldValue(current.fields.Towards || ''),
87
+ value: stripMarkdown(current.fields.Value || ''),
88
+ raw: current.lines.join('\n')
89
+ });
90
+ current = null;
91
+ };
92
+ for (const line of lines) {
93
+ const top = line.match(/^-\s+(.+?)\s*$/);
94
+ if (top) {
95
+ flush();
96
+ current = { label: top[1].trim(), fields: {}, lines: [line] };
97
+ continue;
98
+ }
99
+ if (!current) continue;
100
+ current.lines.push(line);
101
+ const field = line.match(/^\s+-\s*([A-Za-z][A-Za-z0-9 _+-]{0,40}):\s*(.+?)\s*$/);
102
+ if (!field) continue;
103
+ current.fields[field[1].trim()] = field[2].trim();
104
+ }
105
+ flush();
106
+ return entries.filter((entry) => entry.method || entry.value || entry.towards);
107
+ }
108
+
109
+ function extractSchemaField(text, label) {
110
+ const raw = extractListField(text, label, { preserveRaw: true });
111
+ const link = markdownLink(raw);
112
+ return { raw, id: link?.label || raw, target: link?.href || '', form: link ? 'markdown-link' : raw ? 'plain-schema-id' : 'empty' };
113
+ }
114
+
115
+
116
+ function extractListField(text, label, options = {}) {
117
+ const lines = String(text || '').split('\n');
118
+ const escaped = escapeRegExp(label);
119
+ for (let i = 0; i < lines.length; i += 1) {
120
+ const match = lines[i].match(new RegExp(`^(\\s*)-\\s*${escaped}:\\s*(.*)$`));
121
+ if (!match) continue;
122
+ const parentIndent = match[1].length;
123
+ const inline = match[2].trim();
124
+ if (inline) return normalizeFieldValue(inline, options);
125
+ const nested = firstNestedListValue(lines, i + 1, parentIndent);
126
+ if (nested) return normalizeFieldValue(nested, options);
127
+ return '';
128
+ }
129
+ return '';
130
+ }
131
+
132
+ function firstNestedListValue(lines, start, parentIndent) {
133
+ for (let i = start; i < lines.length; i += 1) {
134
+ const line = lines[i];
135
+ const indent = leadingSpaces(line);
136
+ if (/^\s*-\s+\S/.test(line) && indent <= parentIndent) return '';
137
+ const item = line.match(/^\s*-\s+(.+?)\s*$/);
138
+ if (!item) continue;
139
+ const raw = item[1].trim();
140
+ // Origin blocks commonly use labelled nested entries, e.g.
141
+ // - relative: ../parent.trace.md
142
+ // - [github git file](https://github.com/...)
143
+ // Returning the value portion keeps parent/origin resolution from treating
144
+ // the label as part of the path while still preserving markdown links for
145
+ // normalizeFieldValue(..., { preferLinkTarget: true }).
146
+ const labelled = raw.match(/^([A-Za-z][A-Za-z0-9 _+-]{0,40}):\s*(.+)$/);
147
+ return (labelled ? labelled[2] : raw).trim();
148
+ }
149
+ return '';
150
+ }
151
+
152
+ function extractNestedLinkEntries(text, label) {
153
+ const lines = String(text || '').split('\n');
154
+ const escaped = escapeRegExp(label);
155
+ const start = lines.findIndex((line) => line.match(new RegExp(`^(\\s*)-\\s*${escaped}:\\s*$`)));
156
+ if (start < 0) return [];
157
+ const parentIndent = leadingSpaces(lines[start]);
158
+ const out = [];
159
+ for (let i = start + 1; i < lines.length; i += 1) {
160
+ const line = lines[i];
161
+ const indent = leadingSpaces(line);
162
+ if (/^\s*-\s+\S/.test(line) && indent <= parentIndent) break;
163
+ const item = line.match(/^\s*-\s+(\[[^\]]+\]\([^)]+\))\s*$/);
164
+ if (!item) continue;
165
+ const link = markdownLink(item[1]);
166
+ if (!link) continue;
167
+ out.push(Object.freeze({ label: link.label, target: link.href, raw: item[1] }));
168
+ }
169
+ return out;
170
+ }
171
+
172
+ function normalizeFieldValue(value, options = {}) {
173
+ const raw = String(value || '').trim();
174
+ if (options.preserveRaw) return raw;
175
+ const link = markdownLink(raw);
176
+ if (link && options.preferLinkTarget) return link.href || link.label || raw;
177
+ return link?.label || stripMarkdown(raw);
178
+ }
179
+
180
+ function blockAfterTopLevelList(text, label) {
181
+ const lines = String(text || '').split('\n');
182
+ const start = lines.findIndex((line) => line.trim() === `- ${label}`);
183
+ if (start === -1) return '';
184
+ const out = [];
185
+ for (let i = start + 1; i < lines.length; i += 1) {
186
+ if (/^-\s+\S/.test(lines[i])) break;
187
+ out.push(lines[i]);
188
+ }
189
+ return out.join('\n');
190
+ }
191
+
192
+
193
+ function stripCanonicalFooterDivider(value) {
194
+ const text = String(value || '').replace(/\s+$/, '');
195
+ return text.replace(/(?:^|\n)---\s*$/, '');
196
+ }
197
+ function normalizeLineEndings(value) { return String(value || '').replace(/\r\n?/g, '\n'); }
198
+ function findFirstHorizontalRule(text) { const match = /^---\s*$/m.exec(text); return match ? match.index : -1; }
199
+ function markdownLink(value) {
200
+ const match = String(value || '').match(/^\[([^\]]+)\]\(([^)]+)\)$/);
201
+ if (!match) return null;
202
+ return { label: match[1].trim(), href: match[2].trim() };
203
+ }
204
+ function markdownLabel(value) { return markdownLink(value)?.label || ''; }
205
+ function stripMarkdown(value) { return String(value || '').replace(/^\[([^\]]+)\]\([^)]+\)$/, '$1').trim(); }
206
+ function leadingSpaces(value) { return String(value || '').match(/^\s*/)?.[0]?.length || 0; }
207
+ function escapeRegExp(value) { return String(value || '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
@@ -0,0 +1,83 @@
1
+ import { parseArtifactMarkdown } from './artifact.parse.js';
2
+ import { schemaBadgeClass, schemaKey } from '../schemas/tiinex.root.v1.classify.js';
3
+ import { createRootFallbackModel } from '../schemas/tiinex.root.v1.fallback.js';
4
+ import { inferRecordMaterialRole } from '../workspaces/workspace.materialRole.js';
5
+ import { collectOriginReferencesFromMarkdown } from '../sources/origin.references.js';
6
+
7
+ export function createRecordFromMarkdown(markdown = '', meta = {}) {
8
+ const parsed = parseArtifactMarkdown(markdown || '');
9
+ const title = bestRecordTitle(parsed, meta);
10
+ const envelope = parsed.envelope || {};
11
+ const current = envelope.current || {};
12
+ const parent = envelope.parent || {};
13
+ const schemaId = current.schema?.id || '';
14
+ const resolvedKind = schemaId || (parsed.hasContinuityContext ? 'tiinex.root.v1' : 'markdown');
15
+ const fallbackModel = createRootFallbackModel(parsed, meta.schemaResolution || { status: schemaId ? 'declared' : 'unknown', fallbackUsed: !schemaId }, meta.findings || []);
16
+ const originReferences = collectOriginReferencesFromMarkdown(markdown || '');
17
+ return {
18
+ title,
19
+ summary: current.summary || parsed.body?.sections?.slice(0, 3).join(' · ') || meta.path || 'Local Markdown artifact.',
20
+ kind: resolvedKind,
21
+ schemaId: schemaId || '',
22
+ envelopeSchemaId: envelope.envelopeSchema?.id || '',
23
+ schemaKey: schemaKey(schemaId),
24
+ schemaBadgeClass: schemaBadgeClass(schemaId),
25
+ status: parsed.hasIntegrity ? 'schema ok' : 'local',
26
+ lifecycleStatus: current.status || meta.lifecycleStatus || '',
27
+ currentCreatedAt: current.createdAt || '',
28
+ path: meta.path || meta.name || '',
29
+ markdown,
30
+ sourceMode: meta.sourceMode || 'local-manual',
31
+ hasContinuityContext: parsed.hasContinuityContext,
32
+ hasIntegrity: parsed.hasIntegrity,
33
+ integrity: parsed.integrity || { methods: [], values: [], entries: [], text: '' },
34
+ parentSchemaId: parent.schema?.id || '',
35
+ parentCreatedAt: parent.createdAt || '',
36
+ trace: parent.trace || '',
37
+ traceLabel: parent.traceLabel || '',
38
+ origin: parent.origin || envelope.origin || '',
39
+ originReferences,
40
+ boundary: parent.boundary || envelope.boundary || '',
41
+ repairsDeclared: Boolean(envelope.repairsDeclared),
42
+ rootReadable: fallbackModel.rootReadable,
43
+ rootDisclosure: fallbackModel.disclosure,
44
+ rootFallback: fallbackModel,
45
+ materialRole: inferRecordMaterialRole({
46
+ path: meta.path || meta.name || '',
47
+ kind: resolvedKind,
48
+ schemaId: schemaId || '',
49
+ envelopeSchemaId: envelope.envelopeSchema?.id || '',
50
+ hasContinuityContext: parsed.hasContinuityContext,
51
+ hasIntegrity: parsed.hasIntegrity,
52
+ parentSchemaId: parent.schema?.id || '',
53
+ trace: parent.trace || '',
54
+ origin: parent.origin || envelope.origin || '',
55
+ markdown
56
+ })
57
+ };
58
+ }
59
+
60
+ function bestRecordTitle(parsed = {}, meta = {}) {
61
+ const parsedTitle = String(parsed.title || '').trim();
62
+ if (parsedTitle && parsedTitle !== 'Untitled artifact') return parsedTitle;
63
+ const fallback = titleFromPath(meta.path || meta.name || '');
64
+ return fallback || parsedTitle || 'Untitled artifact';
65
+ }
66
+
67
+ function titleFromPath(path = '') {
68
+ const name = String(path || '').split('/').filter(Boolean).pop() || '';
69
+ const withoutKnownSuffix = name
70
+ .replace(/\.trace\.md$/i, '')
71
+ .replace(/\.schema\.md$/i, '')
72
+ .replace(/\.validator\.md$/i, '')
73
+ .replace(/\.workspace\.md$/i, '')
74
+ .replace(/\.(?:md|markdown)$/i, '');
75
+ const cleaned = withoutKnownSuffix
76
+ .replace(/^\d+[-_\s.]*/, '')
77
+ .replace(/[-_.]+/g, ' ')
78
+ .replace(/\s+/g, ' ')
79
+ .trim();
80
+ if (!cleaned) return '';
81
+ return cleaned.replace(/\b[a-zåäö]/gi, (m) => m.toUpperCase()).slice(0, 96);
82
+ }
83
+
@@ -0,0 +1,103 @@
1
+ import { parseArtifactMarkdown } from '../artifacts/artifact.parse.js';
2
+ import { resolveSchemaModule } from '../schemas/resolver.js';
3
+ import { validateArtifact, validationTruthFor } from '../validation/validateArtifact.js';
4
+ import { summarizeFindings } from './audit.summary.js';
5
+
6
+ export function runAudit(scope = {}) {
7
+ const record = scope.record || null;
8
+ const markdown = typeof scope.markdown === 'string' ? scope.markdown : (typeof record?.markdown === 'string' ? record.markdown : '');
9
+ const availability = materialAvailabilityFor(scope, record, markdown);
10
+ if (!availability.available) return unavailableAuditResult(record, availability);
11
+
12
+ const parsed = parseArtifactMarkdown(markdown);
13
+ if (isPlainSupportingMarkdown(parsed, record)) return supportingMarkdownAuditResult(record, parsed, availability);
14
+
15
+ const schemaId = parsed.envelope.current.schema.id || record?.schemaId || record?.currentSchemaId || '';
16
+ const validationResult = validateArtifact({ parsed, schemaId, record, markdown, schemaReferenceAuthorities: scope.schemaReferenceAuthorities || null, validationContractOverride: scope.validationContractOverride || null, schemaValidationAuthority: scope.schemaValidationAuthority || null });
17
+ const findings = validationResult.findings;
18
+ return {
19
+ status: findings.some((finding) => finding.severity === 'error') ? 'invalid-or-incomplete' : validationResult.resolution.fallbackUsed ? 'degraded' : 'readable',
20
+ parsed,
21
+ resolution: validationResult.resolution,
22
+ artifact: validationResult.artifact,
23
+ findings,
24
+ summary: summarizeFindings(findings),
25
+ materialAvailability: availability,
26
+ contractValidation: validationResult.contractValidation,
27
+ schemaValidationAuthority: validationResult.schemaValidationAuthority || null,
28
+ validation: validationResult.validation
29
+ };
30
+ }
31
+
32
+
33
+ function isPlainSupportingMarkdown(parsed = {}, record = {}) {
34
+ const declaredSchema = parsed?.envelope?.current?.schema?.id || record?.schemaId || '';
35
+ const kind = String(record?.kind || '').trim().toLowerCase();
36
+ return !parsed?.hasContinuityContext && !declaredSchema && (!kind || kind === 'markdown');
37
+ }
38
+
39
+ function supportingMarkdownAuditResult(record = {}, parsed = {}, availability = {}) {
40
+ const finding = {
41
+ severity: 'info',
42
+ code: 'audit.markdown.supporting-material',
43
+ message: 'Plain Markdown is retained as supporting local material; it is not classified as an invalid Tiinex leaf.',
44
+ source: 'tiinex.audit.v1'
45
+ };
46
+ return {
47
+ status: 'supporting-material',
48
+ parsed,
49
+ resolution: {
50
+ schemaId: 'markdown',
51
+ module: { id: 'tiinex.markdown.supporting.v1' },
52
+ fallbackUsed: false
53
+ },
54
+ artifact: {
55
+ title: record?.title || parsed?.title || 'Markdown material',
56
+ summary: record?.summary || parsed?.body?.sections?.slice(0, 3).join(' · ') || '',
57
+ schemaId: 'markdown',
58
+ moduleId: 'tiinex.markdown.supporting.v1',
59
+ fallbackUsed: false
60
+ },
61
+ findings: [finding],
62
+ summary: summarizeFindings([finding]),
63
+ materialAvailability: availability,
64
+ validation: validationTruthFor({ parsed, schemaId: 'markdown', resolution: { module: { id: 'tiinex.markdown.supporting.v1' }, fallbackUsed: false }, validator: null, availability, supporting: true })
65
+ };
66
+ }
67
+
68
+ function materialAvailabilityFor(scope = {}, record = {}, markdown = '') {
69
+ const sourceBacked = Boolean(scope.sourceBacked || record?.sourceBacked || (record?.source?.adapterId && record.source.adapterId !== 'local'));
70
+ const cacheState = String(scope.cacheState || record?.cacheState || '').trim();
71
+ const materialAvailability = String(scope.materialAvailability || record?.materialAvailability || '').trim();
72
+ const metadataOnly = cacheState === 'metadata-only' || materialAvailability === 'metadata-only' || materialAvailability === 'unavailable' || materialAvailability === 'material-unavailable';
73
+ if (String(markdown || '').trim()) return { status: 'available', available: true, sourceBacked, cacheState, materialAvailability };
74
+ if (sourceBacked || metadataOnly) return { status: 'pending-unavailable', available: false, sourceBacked, cacheState: cacheState || 'metadata-only', materialAvailability: materialAvailability || 'material-unavailable' };
75
+ return { status: 'empty-invalid', available: true, sourceBacked, cacheState, materialAvailability };
76
+ }
77
+
78
+ function unavailableAuditResult(record = {}, availability = {}) {
79
+ const schemaId = record?.schemaId || record?.currentSchemaId || '';
80
+ const resolution = resolveSchemaModule({ schemaId });
81
+ const finding = {
82
+ severity: 'info',
83
+ code: 'audit.material.unavailable',
84
+ message: 'Material is metadata-only or not loaded in this session; audit is pending and must not classify it as invalid.',
85
+ source: 'tiinex.audit.v1'
86
+ };
87
+ return {
88
+ status: 'pending-unavailable',
89
+ parsed: null,
90
+ resolution,
91
+ artifact: {
92
+ title: record?.title || 'Unavailable material',
93
+ summary: record?.summary || '',
94
+ schemaId,
95
+ moduleId: resolution.module?.id || 'tiinex.root.v1',
96
+ fallbackUsed: Boolean(resolution.fallbackUsed)
97
+ },
98
+ findings: [finding],
99
+ summary: summarizeFindings([finding]),
100
+ materialAvailability: availability,
101
+ validation: validationTruthFor({ parsed: null, schemaId, resolution, validator: null, availability })
102
+ };
103
+ }
@@ -0,0 +1,7 @@
1
+ export function summarizeFindings(findings = []) {
2
+ const summary = { error: 0, warning: 0, info: 0, preserve: 0 };
3
+ for (const finding of findings) {
4
+ if (Object.hasOwn(summary, finding.severity)) summary[finding.severity] += 1;
5
+ }
6
+ return summary;
7
+ }