@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,458 @@
1
+ import { parseArtifactMarkdown } from '../../../artifacts/artifact.parse.js';
2
+ import { schemaRegistry } from '../../../schemas/registry.js';
3
+ import { portableFinding } from '../findings.js';
4
+ import { discoverPortableHostCapabilities } from '../host/host.capabilities.js';
5
+ import { qualifyPortableSchemaMaterial } from './schema.provider.qualification.js';
6
+ import { hasPortableBootstrapCanonicalProvenance } from './schema.bootstrap.provenance.js';
7
+
8
+ export const PORTABLE_PROVIDER_CATALOG_SCHEMA_ID = 'tiinex.portable.provider-catalog.v1';
9
+ export const PORTABLE_SCHEMA_MATERIAL_RESOLUTION_SCHEMA_ID = 'tiinex.portable.schema-material-resolution.v1';
10
+ export const PORTABLE_SCHEMA_CHAIN_MATERIAL_SCHEMA_ID = 'tiinex.portable.schema-chain-material.v1';
11
+ export const PORTABLE_SCHEMA_CACHE_ENTRY_SCHEMA_ID = 'tiinex.portable.schema-cache-entry.v1';
12
+
13
+ export function listPortableMaterialProviders(input = {}, options = {}) {
14
+ const discovery = discoverPortableHostCapabilities(input.host || input, options.host || options);
15
+ const capabilities = discovery.profile.capabilities;
16
+ const runtimeProviders = normalizeRuntimeProviders(options.providers || []);
17
+ const loadedFiles = collectExplicitFiles(input);
18
+ const hasLocalMaterial = loadedFiles.some((file) => String(file?.sourceMode || '').includes('node-local') || file?.locator?.kind === 'node-file');
19
+ const hasArchiveMaterial = loadedFiles.some((file) => String(file?.sourceMode || '').includes('zip') || String(file?.locator?.kind || '').includes('zip'));
20
+ const descriptors = [
21
+ providerDescriptor('loaded-material', 'supplied-material', loadedFiles.length > 0, 100, 'Explicit files, records, project sources, or attachments already supplied to the operation.', false),
22
+ providerDescriptor('schema-cache', 'explicit-cache', hasCacheEntries(input.schemaCache), 90, 'Serializable schema cache entries supplied by the caller or session.', false),
23
+ providerDescriptor('provider-responses', 'host-response', hasProviderResponses(input.providerResponses), 85, 'Repository or host material already fetched outside the portable core and supplied as an explicit response.', false),
24
+ providerDescriptor('local-directory-or-checkout', 'filesystem', capabilities.materialAccess.filesystemRead || hasLocalMaterial, 70, 'Local directory or Git checkout materialized by a Node/IDE host.', false),
25
+ providerDescriptor('archive', 'archive', capabilities.materialAccess.archiveRead || hasArchiveMaterial, 65, 'Zip or archive material exposed by the host.', false),
26
+ providerDescriptor('host-repository', 'repository', capabilities.materialAccess.repositorySearch && capabilities.materialAccess.repositoryRead, 60, 'Host-managed repository connector such as GitHub search + file read.', true),
27
+ providerDescriptor('explicit-http', 'http', capabilities.materialAccess.httpRead, 40, 'Explicit HTTP/raw content provider. Authority must be qualified from source metadata.', true),
28
+ ...runtimeProviders.map((provider, index) => providerDescriptor(provider.id, provider.kind || 'runtime-provider', true, Number(provider.priority ?? 80 - index), provider.description || 'Executable provider supplied by the host adapter.', Boolean(provider.remoteFetch)))
29
+ ];
30
+ descriptors.sort((a, b) => b.priority - a.priority || a.id.localeCompare(b.id));
31
+ return Object.freeze({
32
+ schema: PORTABLE_PROVIDER_CATALOG_SCHEMA_ID,
33
+ providers: Object.freeze(descriptors),
34
+ host: discovery.profile,
35
+ findings: discovery.findings
36
+ });
37
+ }
38
+
39
+ export async function resolvePortableSchemaMaterial(input = {}, options = {}) {
40
+ const schemaId = String(input.schemaId || options.schemaId || '').trim();
41
+ const findings = [];
42
+ const providerCatalog = listPortableMaterialProviders(input, options);
43
+ if (!schemaId) {
44
+ findings.push(portableFinding('error', 'portable.schema-provider.schema.required', 'Schema material resolution requires a schema id.'));
45
+ return resolutionResult(schemaId, null, providerCatalog, findings, null);
46
+ }
47
+
48
+ const localSelection = selectPortableLoadedSchemaMaterial(input, { schemaId });
49
+ findings.push(...localSelection.findings);
50
+ if (localSelection.status === 'ambiguous') return resolutionResult(schemaId, null, providerCatalog, findings, null, 'ambiguous');
51
+ if (localSelection.material) return resolutionResult(schemaId, localSelection.material, providerCatalog, findings, null);
52
+
53
+ const runtimeProviders = normalizeRuntimeProviders(options.providers || []);
54
+ for (const provider of runtimeProviders.sort((a, b) => Number(b.priority || 0) - Number(a.priority || 0))) {
55
+ if (typeof provider.resolveSchema !== 'function') continue;
56
+ let response;
57
+ try {
58
+ response = await provider.resolveSchema(Object.freeze({
59
+ schemaId,
60
+ ...providerSource(input, options),
61
+ expectedPaths: expectedSchemaPaths(schemaId)
62
+ }));
63
+ } catch (error) {
64
+ findings.push(portableFinding('warning', 'portable.schema-provider.runtime.failed', 'A runtime schema provider failed and resolution continued with remaining providers.', {
65
+ providerId: provider.id,
66
+ detail: String(error?.message || error)
67
+ }));
68
+ continue;
69
+ }
70
+ const providerSelection = selectSchemaCandidate(normalizeProviderResponse(response, provider), schemaId);
71
+ findings.push(...providerSelection.findings);
72
+ if (providerSelection.status === 'ambiguous') return resolutionResult(schemaId, null, providerCatalog, findings, null, 'ambiguous');
73
+ if (providerSelection.material) return resolutionResult(schemaId, providerSelection.material, providerCatalog, findings, null);
74
+ }
75
+
76
+ const request = buildProviderRequest(schemaId, providerCatalog, input, options);
77
+ findings.push(portableFinding('warning', 'portable.schema-provider.material.unresolved', 'Readable schema material was not found in loaded material, cache, provider responses, or executable providers.', { schemaId }));
78
+ return resolutionResult(schemaId, null, providerCatalog, findings, request);
79
+ }
80
+
81
+
82
+ export function selectPortableLoadedSchemaMaterial(input = {}, options = {}) {
83
+ const schemaId = String(input.schemaId || options.schemaId || '').trim();
84
+ if (!schemaId) return Object.freeze({ status: 'unresolved', material: null, findings: Object.freeze([portableFinding('error', 'portable.schema-provider.schema.required', 'Schema material selection requires a schema id.')]) });
85
+ return selectSchemaCandidate(collectSchemaCandidates(input), schemaId);
86
+ }
87
+
88
+ export async function resolvePortableSchemaChainMaterial(input = {}, options = {}) {
89
+ const schemaId = String(input.schemaId || options.schemaId || '').trim();
90
+ const maxDepth = normalizePositiveInteger(input.maxDepth ?? options.maxDepth, 16, 1, 64);
91
+ const findings = [];
92
+ const nodes = [];
93
+ const sourceFiles = [...collectExplicitFiles(input)];
94
+ const resolvedFiles = [];
95
+ const availableCacheEntries = normalizeCacheEntries(input.schemaCache);
96
+ const resolvedCacheEntries = [];
97
+ const seen = new Set();
98
+ let current = schemaId;
99
+ let status = 'partial';
100
+ let pendingRequest = null;
101
+
102
+ if (!schemaId) findings.push(portableFinding('error', 'portable.schema-chain-material.schema.required', 'Schema chain material resolution requires a schema id.'));
103
+ while (current && nodes.length < maxDepth) {
104
+ if (seen.has(current)) {
105
+ findings.push(portableFinding('error', 'portable.schema-chain-material.cycle', 'Schema material parent chain contains a cycle.', { schemaId: current }));
106
+ status = 'cycle';
107
+ break;
108
+ }
109
+ seen.add(current);
110
+ const resolution = await resolvePortableSchemaMaterial({
111
+ ...input,
112
+ files: [...sourceFiles, ...resolvedFiles],
113
+ schemaCache: availableCacheEntries,
114
+ schemaId: current
115
+ }, options);
116
+ findings.push(...(resolution.findings || []));
117
+ if (!resolution.material) {
118
+ pendingRequest = resolution.providerRequest || null;
119
+ status = resolution.status === 'provider-action-required' ? 'provider-action-required' : resolution.status || 'unresolved';
120
+ break;
121
+ }
122
+ nodes.push(Object.freeze({
123
+ schemaId: current,
124
+ parentSchemaId: resolution.material.parentSchemaId || '',
125
+ path: resolution.material.path,
126
+ providerId: resolution.material.providerId,
127
+ authority: resolution.material.qualification.authority,
128
+ cacheKey: resolution.material.cacheEntry?.cacheKey || '',
129
+ bindingMatch: resolution.material.qualification.bindingMatch
130
+ }));
131
+ resolvedFiles.push(materialAsFile(resolution.material));
132
+ if (resolution.material.cacheEntry) {
133
+ upsertCacheEntry(availableCacheEntries, resolution.material.cacheEntry);
134
+ upsertCacheEntry(resolvedCacheEntries, resolution.material.cacheEntry);
135
+ }
136
+ if (current === 'tiinex.root.v1' || !resolution.material.parentSchemaId) {
137
+ status = current === 'tiinex.root.v1' ? 'complete-to-root' : 'partial-no-parent';
138
+ break;
139
+ }
140
+ current = resolution.material.parentSchemaId;
141
+ }
142
+ if (current && nodes.length >= maxDepth && status === 'partial') {
143
+ status = 'depth-limit';
144
+ findings.push(portableFinding('warning', 'portable.schema-chain-material.depth-limit', 'Schema chain material resolution stopped at the configured depth limit.', { maxDepth }));
145
+ }
146
+
147
+ return Object.freeze({
148
+ schema: PORTABLE_SCHEMA_CHAIN_MATERIAL_SCHEMA_ID,
149
+ requestedSchema: schemaId,
150
+ status,
151
+ maxDepth,
152
+ nodes: Object.freeze(nodes),
153
+ materials: Object.freeze({
154
+ files: Object.freeze(dedupeFiles(resolvedFiles)),
155
+ schemaCache: Object.freeze(resolvedCacheEntries)
156
+ }),
157
+ providerRequest: pendingRequest,
158
+ findings: Object.freeze(findings)
159
+ });
160
+ }
161
+
162
+ function collectSchemaCandidates(input = {}) {
163
+ const out = [];
164
+ for (const file of collectExplicitFiles(input)) out.push(candidate(file, 'loaded-material', 100, false, false));
165
+ for (const entry of normalizeCacheEntries(input.schemaCache)) out.push(candidate({
166
+ path: entry.path,
167
+ content: entry.markdown,
168
+ source: mergeSource(entry.source, { authority: entry.authority }),
169
+ schemaId: entry.schemaId,
170
+ checksum: entry.checksum
171
+ }, 'schema-cache', 90, false, true));
172
+ for (const response of normalizeProviderResponses(input.providerResponses)) {
173
+ for (const file of response.files) out.push(candidate({ ...file, source: mergeSource(file.source, response.source) }, response.providerId || 'provider-response', Number(response.priority || 85), Boolean(response.remoteFetch), false));
174
+ }
175
+ out.sort((a, b) => b.priority - a.priority);
176
+ return out;
177
+ }
178
+
179
+ function selectSchemaCandidate(candidates = [], schemaId = '') {
180
+ const findings = [];
181
+ const materials = [];
182
+ for (const candidateValue of candidates) {
183
+ const inspected = inspectSchemaCandidate(candidateValue, schemaId);
184
+ findings.push(...inspected.findings);
185
+ if (inspected.material) materials.push(inspected.material);
186
+ }
187
+ if (!materials.length) return Object.freeze({ status: 'unresolved', material: null, findings: Object.freeze(findings) });
188
+ const ranked = materials.map((material) => Object.freeze({ material, rank: materialAuthorityRank(material.qualification), digest: stableHash(material.markdown || '') }));
189
+ const topRank = Math.max(...ranked.map((entry) => entry.rank));
190
+ const top = ranked.filter((entry) => entry.rank === topRank);
191
+ const distinct = new Map();
192
+ for (const entry of top) if (!distinct.has(entry.digest)) distinct.set(entry.digest, entry.material);
193
+ if (distinct.size > 1) {
194
+ findings.push(portableFinding('error', 'portable.schema-provider.material.ambiguous', 'Multiple equally qualified schema representations disagree on bytes; resolution failed closed.', { schemaId, authorityRank: topRank, candidates: [...distinct.values()].map((material) => ({ path: material.path, providerId: material.providerId, authority: material.qualification.authority })) }));
195
+ return Object.freeze({ status: 'ambiguous', material: null, findings: Object.freeze(findings) });
196
+ }
197
+ return Object.freeze({ status: 'resolved', material: top[0].material, findings: Object.freeze(findings) });
198
+ }
199
+
200
+ function materialAuthorityRank(qualification = {}) {
201
+ if (qualification.bindingMatch) return 400;
202
+ if (qualification.authority === 'bundled-canonical-self-verified' && qualification.sourceQualified) return 350;
203
+ if (qualification.authority === 'provider-declared-canonical-unverified') return 250;
204
+ if (qualification.authority === 'cache-preserved-source-qualification') return 200;
205
+ return 100;
206
+ }
207
+
208
+ function inspectSchemaCandidate(candidateValue, schemaId) {
209
+ const findings = [];
210
+ const file = candidateValue.file || {};
211
+ const markdown = textContent(file);
212
+ const path = normalizePath(file.path || file.name || '');
213
+ if (!markdown || !looksLikeSchemaPath(path, schemaId, markdown)) return { material: null, findings };
214
+ let parsed;
215
+ try { parsed = parseArtifactMarkdown(markdown); }
216
+ catch (error) {
217
+ findings.push(portableFinding('warning', 'portable.schema-provider.parse.failed', 'A candidate schema file could not be parsed and was ignored.', { ref: path, detail: String(error?.message || error) }));
218
+ return { material: null, findings };
219
+ }
220
+ const declaredSchemaId = String(parsed.envelope?.current?.schema?.id || '').trim();
221
+ if (declaredSchemaId !== schemaId) {
222
+ if (path.toLowerCase().endsWith(`${schemaId}.schema.md`.toLowerCase())) {
223
+ findings.push(portableFinding('error', 'portable.schema-provider.identity.mismatch', 'A filename-matching schema candidate declared a different Current Schema and was rejected.', {
224
+ ref: path,
225
+ requestedSchemaId: schemaId,
226
+ declaredSchemaId
227
+ }));
228
+ }
229
+ return { material: null, findings };
230
+ }
231
+ const source = normalizeSource(file.source || {}, candidateValue.providerId, candidateValue.remoteFetch, candidateValue.cached);
232
+ const binding = schemaRegistry.byId.get(schemaId)?.binding || null;
233
+ const qualification = qualifyPortableSchemaMaterial({ path, source, binding, checksum: file.checksum || source.checksum || '', markdown, runtimeBootstrapProvenance: candidateValue.runtimeBootstrapProvenance });
234
+ if (candidateValue.runtimeBootstrapProvenance && (qualification.representationIntegrity !== 'verified' || qualification.authority !== 'bundled-canonical-self-verified')) {
235
+ findings.push(portableFinding('error', 'portable.schema-provider.bootstrap.integrity.invalid', 'Runtime-owned canonical bootstrap schema material failed exact self-integrity/source qualification and was rejected.', {
236
+ ref: path,
237
+ schemaId,
238
+ representationIntegrity: qualification.representationIntegrity,
239
+ authority: qualification.authority
240
+ }));
241
+ return { material: null, findings };
242
+ }
243
+ const material = Object.freeze({
244
+ schema: PORTABLE_SCHEMA_MATERIAL_RESOLUTION_SCHEMA_ID,
245
+ schemaId,
246
+ parentSchemaId: String(parsed.envelope?.parent?.schema?.id || '').trim(),
247
+ path,
248
+ markdown,
249
+ providerId: candidateValue.providerId,
250
+ source,
251
+ qualification,
252
+ cacheEntry: buildCacheEntry({ schemaId, path, markdown, source, qualification, checksum: file.checksum || source.checksum || '' })
253
+ });
254
+ return { material, findings };
255
+ }
256
+
257
+ function resolutionResult(schemaId, material, providerCatalog, findings, providerRequest, statusOverride = '') {
258
+ return Object.freeze({
259
+ schema: PORTABLE_SCHEMA_MATERIAL_RESOLUTION_SCHEMA_ID,
260
+ requestedSchema: schemaId,
261
+ status: statusOverride || (material ? 'resolved' : providerRequest ? 'provider-action-required' : 'unresolved'),
262
+ material,
263
+ providerCatalog,
264
+ providerRequest,
265
+ findings: Object.freeze(findings)
266
+ });
267
+ }
268
+
269
+ function providerSource(input = {}, options = {}) {
270
+ const profile = input.sourceProfile || input.schemaProviderSource || options.sourceProfile || options.schemaProviderSource || {};
271
+ return Object.freeze({
272
+ repository: String(input.repository || options.repository || profile.repository || '').trim(),
273
+ ref: String(input.ref || options.ref || profile.ref || '').trim()
274
+ });
275
+ }
276
+
277
+ function buildProviderRequest(schemaId, catalog, input, options) {
278
+ const { repository, ref } = providerSource(input, options);
279
+ const repositoryProvider = catalog.providers.find((provider) => provider.id === 'host-repository' && provider.available);
280
+ const httpProvider = catalog.providers.find((provider) => provider.id === 'explicit-http' && provider.available);
281
+ const capability = repository && repositoryProvider ? 'repository-search-and-read' : httpProvider ? 'explicit-http-read' : 'supply-schema-material';
282
+ return Object.freeze({
283
+ schema: 'tiinex.portable.provider-request.v1',
284
+ capability,
285
+ purpose: 'Resolve readable schema material without guessing schema meaning.',
286
+ schemaId,
287
+ repository,
288
+ ref,
289
+ searchQueries: Object.freeze([
290
+ `${schemaId}.schema.md`,
291
+ `Current Schema ${schemaId}`
292
+ ]),
293
+ expectedPaths: Object.freeze(expectedSchemaPaths(schemaId)),
294
+ requiredResponse: Object.freeze({
295
+ providerId: 'host-selected-provider',
296
+ files: Object.freeze([{ path: '<repository path>', content: '<UTF-8 schema Markdown>', source: Object.freeze({ repository, ref, commit: '<resolved commit>', path: '<repository path>', authority: 'canonical-core' }) }])
297
+ }),
298
+ nextOperation: 'resolve-schema-material',
299
+ boundary: Object.freeze({
300
+ remoteFetchMustBeHostMediated: true,
301
+ sourceMutation: false,
302
+ remoteWrite: false,
303
+ doNotExecuteReceivedCode: true
304
+ })
305
+ });
306
+ }
307
+
308
+ function buildCacheEntry({ schemaId, path, markdown, source, qualification, checksum }) {
309
+ const basis = [schemaId, source.repository, source.commit || source.ref, path, checksum || stableHash(markdown)].join(':');
310
+ return Object.freeze({
311
+ schema: PORTABLE_SCHEMA_CACHE_ENTRY_SCHEMA_ID,
312
+ cacheKey: `schema:${stableHash(basis)}:${schemaId}`,
313
+ schemaId,
314
+ path,
315
+ markdown,
316
+ checksum: String(checksum || ''),
317
+ source: Object.freeze({ ...source }),
318
+ authority: qualification.authority
319
+ });
320
+ }
321
+
322
+ function normalizeProviderResponses(value) {
323
+ const list = Array.isArray(value) ? value : value ? [value] : [];
324
+ return list.map((response) => Object.freeze({
325
+ providerId: String(response?.providerId || response?.id || 'provider-response'),
326
+ priority: Number(response?.priority || 85),
327
+ remoteFetch: response?.remoteFetch !== false,
328
+ source: response?.source || {},
329
+ files: Object.freeze((response?.files || (response?.file ? [response.file] : [])).map((file) => Object.freeze({ ...file })))
330
+ }));
331
+ }
332
+
333
+ function normalizeProviderResponse(response, provider) {
334
+ if (!response) return [];
335
+ const list = Array.isArray(response) ? response : response.files ? response.files : response.file ? [response.file] : [response];
336
+ return list.map((file) => candidate({ ...file, source: mergeSource(file.source, response.source || provider.source) }, provider.id, Number(provider.priority || 80), Boolean(provider.remoteFetch), false));
337
+ }
338
+
339
+ function normalizeRuntimeProviders(value) {
340
+ const list = Array.isArray(value) ? value : value ? [value] : [];
341
+ return list.filter(Boolean).map((provider, index) => ({
342
+ ...provider,
343
+ id: String(provider.id || provider.name || `runtime-provider-${index + 1}`),
344
+ priority: Number(provider.priority ?? 80 - index)
345
+ }));
346
+ }
347
+
348
+ function collectExplicitFiles(input = {}) {
349
+ const files = [...(Array.isArray(input.files) ? input.files : [])];
350
+ if (typeof input.markdown === 'string') files.push({ path: input.path || 'attachment.md', content: input.markdown, source: input.source });
351
+ for (const record of Array.isArray(input.records) ? input.records : []) {
352
+ if (typeof record?.markdown === 'string') files.push({ path: record.path || record.name || '', content: record.markdown, source: record.source });
353
+ }
354
+ return files;
355
+ }
356
+
357
+ function normalizeCacheEntries(value) {
358
+ const list = value instanceof Map ? [...value.values()] : Array.isArray(value) ? value : value && typeof value === 'object' ? Object.values(value) : [];
359
+ return list.filter((entry) => entry?.schemaId && typeof entry?.markdown === 'string').map((entry) => Object.freeze({ ...entry }));
360
+ }
361
+
362
+ function hasCacheEntries(value) { return normalizeCacheEntries(value).length > 0; }
363
+ function hasProviderResponses(value) { return normalizeProviderResponses(value).some((response) => response.files.length); }
364
+
365
+ function providerDescriptor(id, kind, available, priority, description, remoteFetch) {
366
+ return Object.freeze({ id, kind, available: Boolean(available), priority, description, remoteFetch: Boolean(remoteFetch), remoteWrite: false, sourceMutation: false });
367
+ }
368
+
369
+ function candidate(file, providerId, priority, remoteFetch, cached) {
370
+ return { file, providerId, priority, remoteFetch, cached, runtimeBootstrapProvenance: hasPortableBootstrapCanonicalProvenance(file?.source) };
371
+ }
372
+
373
+ function normalizeSource(source = {}, providerId = '', remoteFetch = false, cached = false) {
374
+ return Object.freeze({
375
+ providerId: String(source.providerId || providerId || 'loaded-material'),
376
+ repository: String(source.repository || source.sourceRepository || ''),
377
+ ref: String(source.ref || ''),
378
+ commit: String(source.commit || source.sourceCommit || ''),
379
+ path: normalizePath(source.path || source.sourcePath || ''),
380
+ authority: String(source.authority || source.originTrustRole || ''),
381
+ checksum: String(source.checksum?.value || source.checksum || ''),
382
+ remoteFetch: Boolean(remoteFetch || source.remoteFetch),
383
+ cached: Boolean(cached || source.cached),
384
+ qualification: String(source.qualification || 'explicit-supplied')
385
+ });
386
+ }
387
+
388
+ function mergeSource(primary = {}, fallback = {}) { return { ...(fallback || {}), ...(primary || {}) }; }
389
+
390
+ function materialAsFile(material) {
391
+ return Object.freeze({
392
+ path: material.path,
393
+ content: material.markdown,
394
+ sourceMode: material.source.remoteFetch ? 'portable-host-remote' : material.source.cached ? 'portable-cache' : 'portable-supplied',
395
+ source: material.source
396
+ });
397
+ }
398
+
399
+ function upsertCacheEntry(entries, entry) {
400
+ const index = entries.findIndex((item) => item.schemaId === entry.schemaId && item.cacheKey === entry.cacheKey);
401
+ if (index === -1) entries.push(entry);
402
+ else entries[index] = entry;
403
+ }
404
+
405
+ function dedupeFiles(files) {
406
+ const map = new Map();
407
+ for (const file of files) {
408
+ const key = `${normalizePath(file.path || file.name || '')}:${stableHash(textContent(file))}`;
409
+ if (!map.has(key)) map.set(key, Object.freeze({ ...file }));
410
+ }
411
+ return [...map.values()];
412
+ }
413
+
414
+ function expectedSchemaPaths(schemaId) {
415
+ return [
416
+ `.topics/.schemas/${schemaId}.schema.md`,
417
+ `.topics/.schemas/core/${schemaFamily(schemaId)}/${schemaId}.schema.md`,
418
+ `.topics/.schemas/**/${schemaId}.schema.md`
419
+ ];
420
+ }
421
+
422
+ function schemaFamily(schemaId = '') {
423
+ const parts = String(schemaId).split('.');
424
+ return parts.length >= 3 ? parts[1] : 'unknown';
425
+ }
426
+
427
+ function looksLikeSchemaPath(path, schemaId, markdown) {
428
+ const lower = path.toLowerCase();
429
+ if (lower.endsWith(`${schemaId}.schema.md`.toLowerCase())) return true;
430
+ if (!lower.endsWith('.schema.md')) return false;
431
+ return markdown.includes(schemaId);
432
+ }
433
+
434
+ function textContent(file = {}) {
435
+ if (typeof file.content === 'string') return file.content;
436
+ if (typeof file.markdown === 'string') return file.markdown;
437
+ return '';
438
+ }
439
+
440
+ function normalizePath(value = '') {
441
+ return String(value || '').replace(/\\/g, '/').replace(/^\/+/, '').replace(/\/+/g, '/').trim();
442
+ }
443
+
444
+ function stableHash(value = '') {
445
+ const text = String(value || '');
446
+ let hash = 2166136261;
447
+ for (let index = 0; index < text.length; index += 1) {
448
+ hash ^= text.charCodeAt(index);
449
+ hash = Math.imul(hash, 16777619);
450
+ }
451
+ return (hash >>> 0).toString(16).padStart(8, '0');
452
+ }
453
+
454
+ function normalizePositiveInteger(value, fallback, min, max) {
455
+ const number = Number(value);
456
+ if (!Number.isFinite(number)) return fallback;
457
+ return Math.max(min, Math.min(max, Math.floor(number)));
458
+ }
@@ -0,0 +1,53 @@
1
+ import { buildPublicationPlan, buildPublicationResult } from '../../../publication/publication.contract.js';
2
+ import { summarizePortableFindings } from '../findings.js';
3
+
4
+ export const PORTABLE_PUBLICATION_PLAN_SCHEMA_ID = 'tiinex.portable.publication.plan.v1';
5
+ export const PORTABLE_PUBLICATION_RESULT_SCHEMA_ID = 'tiinex.portable.publication.result.v1';
6
+
7
+ export function planPortablePublication(input = {}) {
8
+ const workspace = input.workspace || input.session || input;
9
+ const plan = buildPublicationPlan(workspace, input);
10
+ return Object.freeze({
11
+ schema: PORTABLE_PUBLICATION_PLAN_SCHEMA_ID,
12
+ status: plan.status,
13
+ boundary: 'Portable facade over the shared platform-neutral publication plan. It performs no host write, credential lookup, UI action, or source mutation.',
14
+ plan,
15
+ qualification: qualification(plan),
16
+ findings: plan.findings || Object.freeze([]),
17
+ findingSummary: summarizePortableFindings(plan.findings || [])
18
+ });
19
+ }
20
+
21
+ export function acceptPortablePublicationResult(input = {}) {
22
+ const plan = input.plan?.plan || input.plan || {};
23
+ const execution = input.execution || input.receipt || {};
24
+ const result = buildPublicationResult(plan, execution);
25
+ return Object.freeze({
26
+ schema: PORTABLE_PUBLICATION_RESULT_SCHEMA_ID,
27
+ status: result.status,
28
+ boundary: 'Portable facade over supplied host execution evidence. It validates result/receipt truth but never executes a remote write.',
29
+ result,
30
+ qualification: qualification(plan, result),
31
+ findings: result.findings || Object.freeze([]),
32
+ findingSummary: summarizePortableFindings(result.findings || [])
33
+ });
34
+ }
35
+
36
+ function qualification(plan = {}, result = null) {
37
+ const bindingMutability = String(result?.sourceBinding?.mutability || '');
38
+ const exactSourceBinding = Boolean(result?.sourceBinding?.verified);
39
+ const immutableSourceBinding = exactSourceBinding && bindingMutability === 'immutable-materialized-representation';
40
+ return Object.freeze({
41
+ sharedPublicationContract: plan.schema === 'tiinex.publication.plan.v1',
42
+ remoteFetch: false,
43
+ remoteWrite: false,
44
+ sourceMutation: false,
45
+ exactPayloadIdentity: Boolean(plan.outboundPayload?.sha256),
46
+ verificationRequired: plan.verification?.required === true,
47
+ exactSourceBinding,
48
+ bindingMutability,
49
+ immutableSourceBinding,
50
+ durableSourceBinding: immutableSourceBinding,
51
+ statement: 'Publication planning/result qualification is shared contract truth; exact mutable social bindings stay distinct from immutable repo-file bindings, and provider execution/product UX remain adapter/Site responsibilities.'
52
+ });
53
+ }
@@ -0,0 +1,150 @@
1
+ import { CapabilityStatus } from '../../schemas/capability.registry.js';
2
+
3
+ export const PORTABLE_QUALIFICATION_SCHEMA_ID = 'tiinex.portable.qualification.v1';
4
+
5
+ export function qualifyCapabilityResolution(resolution = {}, capabilityName = '') {
6
+ const requestedSchema = String(resolution.requested?.schemaId || resolution.unresolvedSchemaId || '').trim();
7
+ const resolvedThrough = String(resolution.descriptor?.moduleId || 'tiinex.root.v1').trim();
8
+ const capability = resolution.capability || resolution.descriptor?.actions?.[capabilityName] || resolution.descriptor?.surfaces?.[capabilityName] || null;
9
+ const moduleExact = Boolean(requestedSchema && requestedSchema === resolvedThrough && !resolution.fallbackUsed);
10
+ const capabilityImplemented = capabilityName ? capability?.status === CapabilityStatus.implemented : null;
11
+ const exact = capabilityName ? moduleExact && capabilityImplemented : moduleExact;
12
+ const limitations = [];
13
+ if (resolution.fallbackUsed) limitations.push(`Requested schema ${requestedSchema || 'unknown'} is not registered; the current site runtime resolved directly through Root fallback.`);
14
+ if (capabilityName && !capabilityImplemented) limitations.push(`${capabilityName} is not implemented for the resolved schema module.`);
15
+ if (!capabilityName) limitations.push('No individual capability was selected; this result describes exact module resolution only.');
16
+ if (resolution.fallbackUsed) limitations.push('Semantic-parent capability fallback was not evaluated by the current shared-core resolver.');
17
+ return makePortableQualification({
18
+ requestedSchema,
19
+ capability: capabilityName || '',
20
+ resolvedThrough,
21
+ exact,
22
+ moduleExact,
23
+ capabilityStatus: capability?.status || '',
24
+ resolutionStatus: resolution.status || '',
25
+ outcome: capability?.status || resolution.status || '',
26
+ fallbackUsed: Boolean(resolution.fallbackUsed),
27
+ fallbackMode: resolution.fallbackUsed ? 'direct-root' : 'none',
28
+ fallbackDepth: resolution.fallbackUsed ? null : 0,
29
+ parentCapabilitiesEvaluated: false,
30
+ limitations,
31
+ safeActions: capabilitySafeActions(capabilityName, capability, exact),
32
+ blockedActions: capabilityBlockedActions(capabilityName, capability, exact)
33
+ });
34
+ }
35
+
36
+ export function qualifyAuditResult(result = {}) {
37
+ const requestedSchema = String(result.parsed?.envelope?.current?.schema?.id || result.artifact?.schemaId || '').trim();
38
+ const resolvedThrough = String(result.resolution?.module?.id || result.artifact?.moduleId || 'tiinex.root.v1').trim();
39
+ const fallbackUsed = Boolean(result.resolution?.fallbackUsed || result.artifact?.fallbackUsed);
40
+ const limitations = [];
41
+ if (fallbackUsed) limitations.push('Schema-specific validation was unavailable; Root validation was used.');
42
+ if (fallbackUsed) limitations.push('Semantic-parent validator fallback was not evaluated by the current shared-core audit resolver.');
43
+ if (result.status === 'supporting-material') limitations.push('Plain Markdown was retained as supporting material, not qualified as a Tiinex leaf.');
44
+ if (result.status === 'pending-unavailable') limitations.push('Material was not loaded; validation remains pending.');
45
+ const moduleExact = Boolean(requestedSchema && requestedSchema === resolvedThrough && !fallbackUsed);
46
+ const schemaAuthorityUnqualified = Boolean(result.schemaValidationAuthority && result.schemaValidationAuthority.state !== 'qualified');
47
+ if (schemaAuthorityUnqualified) limitations.push('Exact schema validation authority is unresolved; schema-specific contract and companion validation were withheld rather than projected from a same-id runtime module.');
48
+ return makePortableQualification({
49
+ requestedSchema,
50
+ capability: 'validate',
51
+ resolvedThrough,
52
+ exact: moduleExact && !schemaAuthorityUnqualified && result.status !== 'pending-unavailable' && result.status !== 'supporting-material',
53
+ moduleExact,
54
+ capabilityStatus: result.status === 'pending-unavailable' ? 'pending' : 'implemented',
55
+ resolutionStatus: result.resolution?.status || '',
56
+ outcome: result.status || '',
57
+ fallbackUsed,
58
+ fallbackMode: fallbackUsed ? 'direct-root' : 'none',
59
+ fallbackDepth: fallbackUsed ? null : 0,
60
+ parentCapabilitiesEvaluated: false,
61
+ limitations,
62
+ safeActions: ['preserve', 'inspect', 'traverse-loaded-parent'].filter((action) => result.status !== 'pending-unavailable' || action !== 'traverse-loaded-parent'),
63
+ blockedActions: fallbackUsed || schemaAuthorityUnqualified ? ['claim-exact-schema-valid'] : []
64
+ });
65
+ }
66
+
67
+ export function qualifyCreationContract(contract = {}) {
68
+ const exact = contract.status === 'ready' && contract.target?.fallbackUsed !== true && contract.capabilities?.create === CapabilityStatus.implemented;
69
+ const limitations = (contract.findings || []).map((finding) => finding.message).filter(Boolean);
70
+ if (!exact && !limitations.length) limitations.push('Exact creation tooling is not ready for the requested schema and transition.');
71
+ if (contract.target?.fallbackUsed) limitations.push('Creation through Root fallback is blocked; parent tooling must not fabricate a child artifact.');
72
+ return makePortableQualification({
73
+ requestedSchema: contract.target?.schemaId || '',
74
+ capability: 'create',
75
+ resolvedThrough: contract.target?.moduleId || 'tiinex.root.v1',
76
+ exact,
77
+ moduleExact: Boolean(contract.target?.schemaId && contract.target?.schemaId === contract.target?.moduleId && !contract.target?.fallbackUsed),
78
+ capabilityStatus: contract.capabilities?.create || '',
79
+ resolutionStatus: contract.status || '',
80
+ outcome: contract.status || '',
81
+ fallbackUsed: Boolean(contract.target?.fallbackUsed),
82
+ fallbackMode: contract.target?.fallbackUsed ? 'direct-root-blocked-for-creation' : 'none',
83
+ fallbackDepth: contract.target?.fallbackUsed ? null : 0,
84
+ parentCapabilitiesEvaluated: false,
85
+ limitations,
86
+ safeActions: exact ? ['create-local-draft', 'validate-created-draft'] : ['inspect-schema', 'request-writer-brief', 'preserve-intent'],
87
+ blockedActions: exact ? ['remote-write', 'inherit-parent-source'] : ['claim-exact-create-tooling', 'create-child-through-parent-fallback']
88
+ });
89
+ }
90
+
91
+ export function qualifyWriterBrief({ mode = '', base = {}, requestedSchema = '' } = {}) {
92
+ const limitations = [...(base.limitations || [])];
93
+ const safeActions = [...(base.safeActions || [])];
94
+ const blockedActions = [...(base.blockedActions || [])];
95
+ if (mode === 'llm-writer-fallback') {
96
+ limitations.push('Child-specific create tooling is unavailable; a writer must interpret supplied readable schema material.');
97
+ safeActions.push('write-local-draft-from-supplied-schema', 'run-available-validation', 'preserve-unqualified-child-semantics');
98
+ blockedActions.push('claim-exact-create-tooling', 'claim-full-child-semantic-qualification');
99
+ }
100
+ if (mode === 'parent-or-root-artifact-only') {
101
+ limitations.push(`Readable schema material for ${requestedSchema || 'the requested child schema'} is unavailable.`);
102
+ safeActions.push('preserve-intent', 'create-genuine-supported-parent-or-root-artifact');
103
+ blockedActions.push('create-requested-child', 'guess-child-format');
104
+ }
105
+ return makePortableQualification({
106
+ ...base,
107
+ exact: mode === 'exact-create-tooling-available' && Boolean(base.exact),
108
+ outcome: mode,
109
+ limitations,
110
+ safeActions,
111
+ blockedActions
112
+ });
113
+ }
114
+
115
+ export function makePortableQualification(input = {}) {
116
+ return Object.freeze({
117
+ schema: PORTABLE_QUALIFICATION_SCHEMA_ID,
118
+ requestedSchema: String(input.requestedSchema || ''),
119
+ capability: String(input.capability || ''),
120
+ resolvedThrough: String(input.resolvedThrough || 'tiinex.root.v1'),
121
+ exact: Boolean(input.exact),
122
+ moduleExact: Boolean(input.moduleExact),
123
+ capabilityStatus: String(input.capabilityStatus || ''),
124
+ resolutionStatus: String(input.resolutionStatus || ''),
125
+ outcome: String(input.outcome || ''),
126
+ fallback: Object.freeze({
127
+ used: Boolean(input.fallbackUsed),
128
+ mode: String(input.fallbackMode || (input.fallbackUsed ? 'unspecified' : 'none')),
129
+ depth: Number.isFinite(input.fallbackDepth) ? Number(input.fallbackDepth) : null,
130
+ parentCapabilitiesEvaluated: Boolean(input.parentCapabilitiesEvaluated)
131
+ }),
132
+ limitations: Object.freeze(uniqueStrings(input.limitations)),
133
+ safeActions: Object.freeze(uniqueStrings(input.safeActions)),
134
+ blockedActions: Object.freeze(uniqueStrings(input.blockedActions))
135
+ });
136
+ }
137
+
138
+ function capabilitySafeActions(name, capability, exact) {
139
+ if (capability?.status === CapabilityStatus.implemented && exact) return [name || 'inspect'];
140
+ return ['preserve', 'inspect-schema', 'inspect-root-envelope'];
141
+ }
142
+
143
+ function capabilityBlockedActions(name, capability, exact) {
144
+ if (!name || (capability?.status === CapabilityStatus.implemented && exact)) return [];
145
+ return [`claim-exact-${name}`];
146
+ }
147
+
148
+ function uniqueStrings(values = []) {
149
+ return [...new Set((Array.isArray(values) ? values : []).map((value) => String(value || '').trim()).filter(Boolean))];
150
+ }