@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.
- package/LICENSE +201 -0
- package/NOTICE +31 -0
- package/README.md +45 -0
- package/package.json +176 -0
- package/src/actions/record.actions.js +312 -0
- package/src/adapters/adapter.contracts.js +143 -0
- package/src/adapters/archive/archive.adapter.js +502 -0
- package/src/adapters/archive/archive.portableChangeset.js +141 -0
- package/src/adapters/archive/archive.transport.js +124 -0
- package/src/artifacts/artifact.localDraft.js +27 -0
- package/src/artifacts/artifact.normalize.js +28 -0
- package/src/artifacts/artifact.parse.js +207 -0
- package/src/artifacts/artifact.record.js +83 -0
- package/src/audit/audit.run.js +103 -0
- package/src/audit/audit.summary.js +7 -0
- package/src/diagnostics/sourceBoundary.report.js +112 -0
- package/src/export/package.apply.js +349 -0
- package/src/export/package.builder.js +366 -0
- package/src/export/package.bytes.js +164 -0
- package/src/export/package.controlIntegrity.js +42 -0
- package/src/export/package.controlTopology.js +97 -0
- package/src/export/package.fileMap.js +174 -0
- package/src/export/package.manifest.js +401 -0
- package/src/export/package.preflight.js +204 -0
- package/src/export/package.sourceReference.js +81 -0
- package/src/export/package.workspaceContext.js +144 -0
- package/src/export/package.zip.js +128 -0
- package/src/export/tree.bundle.js +278 -0
- package/src/governance/governance.boundary.js +196 -0
- package/src/integrity/integrity.c14nV2.js +190 -0
- package/src/integrity/integrity.methodReference.js +73 -0
- package/src/integrity/integrity.validate.js +56 -0
- package/src/lineage/lineage.candidateResolution.js +46 -0
- package/src/lineage/lineage.githubIssueComment.js +106 -0
- package/src/lineage/lineage.githubIssueLocal.js +196 -0
- package/src/lineage/lineage.githubIssueTarget.js +89 -0
- package/src/lineage/lineage.integrity.js +133 -0
- package/src/lineage/lineage.materialPreference.js +26 -0
- package/src/lineage/lineage.model.js +63 -0
- package/src/lineage/lineage.parentAuthority.js +5 -0
- package/src/lineage/lineage.parentBinding.js +104 -0
- package/src/lineage/lineage.pathBasis.js +47 -0
- package/src/lineage/lineage.resolve.js +388 -0
- package/src/lineage/lineage.sourceScope.js +74 -0
- package/src/lineage/lineage.targetKeys.js +80 -0
- package/src/lineage/lineage.traverse.js +132 -0
- package/src/public/applicationProjection.js +236 -0
- package/src/public/companionResources.js +246 -0
- package/src/public/index.js +16 -0
- package/src/public/node.js +2 -0
- package/src/public/schemaAncestry.js +26 -0
- package/src/publication/publication.contract.js +196 -0
- package/src/publication/publication.preflight.js +159 -0
- package/src/publication/publication.targetContract.js +241 -0
- package/src/reingest/reingest.plan.js +162 -0
- package/src/release/plan.mjs +28 -0
- package/src/release/policy.mjs +100 -0
- package/src/release/run.mjs +74 -0
- package/src/schemas/capability.registry.js +226 -0
- package/src/schemas/companion.js +245 -0
- package/src/schemas/contracts.js +6 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.js +14 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.json +23 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.runtime.json +4283 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.source.js +9 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.js +26 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.json +23 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.runtime.json +1985 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.source.js +9 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.js +14 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.json +24 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.runtime.json +1700 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.source.js +9 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.capabilities.js +14 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.en.i18n.json +6 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.findings.js +9 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.presenter.js +1 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.js +32 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.json +24 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.runtime.json +2184 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.source.js +9 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.sv.i18n.json +6 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.transitions.js +1 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.validate.js +10 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.js +14 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.json +23 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.runtime.json +1773 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.source.js +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.capabilities.js +11 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.contract.js +40 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.en.i18n.json +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.findings.js +12 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.localMaterialization.js +89 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.presenter.js +8 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.js +34 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.json +23 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.runtime.json +2029 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.source.js +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.sv.i18n.json +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.transitions.js +1 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.validate.js +25 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.capabilities.js +14 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.en.i18n.json +6 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.findings.js +9 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.presenter.js +1 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.js +31 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.json +23 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.runtime.json +2033 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.source.js +9 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.sv.i18n.json +6 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.transitions.js +1 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.validate.js +10 -0
- package/src/schemas/core/relation/tiinex.relation.v1.capabilities.js +7 -0
- package/src/schemas/core/relation/tiinex.relation.v1.contract.js +3 -0
- package/src/schemas/core/relation/tiinex.relation.v1.en.i18n.json +4 -0
- package/src/schemas/core/relation/tiinex.relation.v1.findings.js +9 -0
- package/src/schemas/core/relation/tiinex.relation.v1.localMaterialization.js +153 -0
- package/src/schemas/core/relation/tiinex.relation.v1.presenter.js +3 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.js +20 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.json +23 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.runtime.json +1668 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.source.js +9 -0
- package/src/schemas/core/relation/tiinex.relation.v1.sv.i18n.json +4 -0
- package/src/schemas/core/relation/tiinex.relation.v1.transitions.js +1 -0
- package/src/schemas/core/relation/tiinex.relation.v1.validate.js +36 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.capabilities.js +14 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.contract.js +57 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.en.i18n.json +4 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.findings.js +13 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.presenter.js +3 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.js +20 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.json +24 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.runtime.json +3315 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.source.js +9 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.sv.i18n.json +4 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.transitions.js +1 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.validate.js +78 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.js +14 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.json +23 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.runtime.json +1733 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.source.js +9 -0
- package/src/schemas/core/task/tiinex.task.v1.capabilities.js +11 -0
- package/src/schemas/core/task/tiinex.task.v1.contract.js +3 -0
- package/src/schemas/core/task/tiinex.task.v1.en.i18n.json +15 -0
- package/src/schemas/core/task/tiinex.task.v1.findings.js +18 -0
- package/src/schemas/core/task/tiinex.task.v1.localMaterialization.js +148 -0
- package/src/schemas/core/task/tiinex.task.v1.presenter.js +8 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.js +35 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.json +23 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.runtime.json +1708 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.source.js +9 -0
- package/src/schemas/core/task/tiinex.task.v1.sv.i18n.json +15 -0
- package/src/schemas/core/task/tiinex.task.v1.transitions.js +3 -0
- package/src/schemas/core/task/tiinex.task.v1.validate.js +41 -0
- package/src/schemas/core/topic/tiinex.topic.v1.capabilities.js +14 -0
- package/src/schemas/core/topic/tiinex.topic.v1.creation.js +46 -0
- package/src/schemas/core/topic/tiinex.topic.v1.en.i18n.json +8 -0
- package/src/schemas/core/topic/tiinex.topic.v1.findings.js +11 -0
- package/src/schemas/core/topic/tiinex.topic.v1.localMaterialization.js +135 -0
- package/src/schemas/core/topic/tiinex.topic.v1.presenter.js +1 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.js +34 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.json +23 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.runtime.json +1699 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.source.js +9 -0
- package/src/schemas/core/topic/tiinex.topic.v1.sv.i18n.json +8 -0
- package/src/schemas/core/topic/tiinex.topic.v1.transitions.js +31 -0
- package/src/schemas/core/topic/tiinex.topic.v1.validate.js +11 -0
- package/src/schemas/creation.capability.js +289 -0
- package/src/schemas/creation.contracts.js +334 -0
- package/src/schemas/creation.executionSnapshot.js +79 -0
- package/src/schemas/creation.factoryQualification.js +73 -0
- package/src/schemas/creation.renderer.js +244 -0
- package/src/schemas/creation.representation.js +279 -0
- package/src/schemas/creation.rootMetadata.js +6 -0
- package/src/schemas/creation.schemaReferences.js +65 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.js +14 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.json +23 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.runtime.json +1873 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.source.js +9 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.js +14 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.json +23 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.runtime.json +1839 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.source.js +9 -0
- package/src/schemas/generic.artifact.module.js +25 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.js +26 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.json +23 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.runtime.json +2249 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.source.js +9 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.js +26 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.json +24 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.runtime.json +2091 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.source.js +9 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.capabilities.js +14 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.en.i18n.json +4 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.findings.js +1 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.presenter.js +1 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.js +29 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.json +21 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.runtime.json +2180 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.source.js +9 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.sv.i18n.json +4 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.transitions.js +1 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.validate.js +1 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.js +26 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.json +23 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.runtime.json +1733 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.source.js +9 -0
- package/src/schemas/reference.shapes.js +33 -0
- package/src/schemas/registry.js +36 -0
- package/src/schemas/resolver.js +13 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.capabilities.js +14 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.en.i18n.json +4 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.findings.js +1 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.presenter.js +1 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.js +29 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.json +21 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.runtime.json +2093 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.source.js +9 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.sv.i18n.json +4 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.transitions.js +1 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.validate.js +1 -0
- package/src/schemas/schema.factory.descriptor.js +104 -0
- package/src/schemas/schema.githubSourceTarget.js +131 -0
- package/src/schemas/schema.identity.js +10 -0
- package/src/schemas/schema.reference.js +133 -0
- package/src/schemas/schema.source.js +239 -0
- package/src/schemas/tiinex.root.v1.capabilities.js +14 -0
- package/src/schemas/tiinex.root.v1.classify.js +55 -0
- package/src/schemas/tiinex.root.v1.en.i18n.json +24 -0
- package/src/schemas/tiinex.root.v1.fallback.js +84 -0
- package/src/schemas/tiinex.root.v1.findings.js +19 -0
- package/src/schemas/tiinex.root.v1.presenter.js +5 -0
- package/src/schemas/tiinex.root.v1.schema.js +29 -0
- package/src/schemas/tiinex.root.v1.schema.json +24 -0
- package/src/schemas/tiinex.root.v1.schema.runtime.json +1574 -0
- package/src/schemas/tiinex.root.v1.schema.source.js +9 -0
- package/src/schemas/tiinex.root.v1.sv.i18n.json +24 -0
- package/src/schemas/tiinex.root.v1.transitions.js +1 -0
- package/src/schemas/tiinex.root.v1.validate.js +36 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.js +14 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.json +23 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.runtime.json +2027 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.source.js +9 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.js +14 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.json +23 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.runtime.json +1848 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.source.js +9 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.js +14 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.json +23 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.runtime.json +2015 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.source.js +9 -0
- package/src/schemas/workspace/tiinex.workspace.v1.capabilities.js +12 -0
- package/src/schemas/workspace/tiinex.workspace.v1.en.i18n.json +7 -0
- package/src/schemas/workspace/tiinex.workspace.v1.findings.js +5 -0
- package/src/schemas/workspace/tiinex.workspace.v1.presenter.js +27 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.js +30 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.json +23 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.runtime.json +1596 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.source.js +9 -0
- package/src/schemas/workspace/tiinex.workspace.v1.sv.i18n.json +7 -0
- package/src/schemas/workspace/tiinex.workspace.v1.transitions.js +10 -0
- package/src/schemas/workspace/tiinex.workspace.v1.validate.js +10 -0
- package/src/sources/github/github.issueTarget.js +127 -0
- package/src/sources/origin.references.js +249 -0
- package/src/sources/source.explicitTargets.js +49 -0
- package/src/sources/transport.levels.js +107 -0
- package/src/tooling/portable/adapters/cli/cli.cold-start-input.js +34 -0
- package/src/tooling/portable/adapters/cli/cli.command-input.js +455 -0
- package/src/tooling/portable/adapters/cli/cli.common-author.js +249 -0
- package/src/tooling/portable/adapters/cli/cli.common-output.js +330 -0
- package/src/tooling/portable/adapters/cli/cli.editor-assistance.js +13 -0
- package/src/tooling/portable/adapters/cli/cli.ground-materialize.js +96 -0
- package/src/tooling/portable/adapters/cli/cli.ground-recovery.js +99 -0
- package/src/tooling/portable/adapters/cli/cli.handoff-manufacture.js +345 -0
- package/src/tooling/portable/adapters/cli/cli.handoff-sibling-allocation.js +31 -0
- package/src/tooling/portable/adapters/cli/cli.help.js +80 -0
- package/src/tooling/portable/adapters/cli/cli.land.js +13 -0
- package/src/tooling/portable/adapters/cli/cli.local-output.js +72 -0
- package/src/tooling/portable/adapters/cli/cli.material-policy.js +6 -0
- package/src/tooling/portable/adapters/cli/cli.operator-bridge.js +18 -0
- package/src/tooling/portable/adapters/cli/cli.reduction-input.js +14 -0
- package/src/tooling/portable/adapters/cli/cli.run.js +434 -0
- package/src/tooling/portable/adapters/llm/llm.entrypoint.js +34 -0
- package/src/tooling/portable/adapters/node/checkpoint.verify.js +267 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.bootstrap.js +109 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.enumeration.js +94 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.js +193 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.multiRoot.js +49 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.packageParent.js +130 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.requirements.js +353 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.scope.js +147 -0
- package/src/tooling/portable/adapters/node/workspaceCarrier.manufacture.js +62 -0
- package/src/tooling/portable/assets/asset.operations.js +170 -0
- package/src/tooling/portable/audit/audit.capability.js +119 -0
- package/src/tooling/portable/bootstrap/artifact.result.selfverify.mjs +109 -0
- package/src/tooling/portable/bootstrap/bootstrap.case.mjs +43 -0
- package/src/tooling/portable/bootstrap/tiinex.llm.bootstrap.md +814 -0
- package/src/tooling/portable/bootstrap/tiinex.llm.bootstrap.pointer.json +25 -0
- package/src/tooling/portable/checkpoint/portable.checkpoint.js +89 -0
- package/src/tooling/portable/conformance/checkpoint.qualification.js +271 -0
- package/src/tooling/portable/draft/draft.create.js +389 -0
- package/src/tooling/portable/draft/draft.crud.js +175 -0
- package/src/tooling/portable/draft/draft.exact.js +173 -0
- package/src/tooling/portable/draft/draft.operations.js +265 -0
- package/src/tooling/portable/draft/draft.qualification.js +45 -0
- package/src/tooling/portable/draft/draft.set.js +193 -0
- package/src/tooling/portable/draft/draft.validation-context.js +7 -0
- package/src/tooling/portable/editor/authoring.parent.js +37 -0
- package/src/tooling/portable/editor/editor.assistance.js +221 -0
- package/src/tooling/portable/editor/staged.validation.js +96 -0
- package/src/tooling/portable/engine.facade.js +468 -0
- package/src/tooling/portable/findings.js +92 -0
- package/src/tooling/portable/grounding/grounding.capsule.js +128 -0
- package/src/tooling/portable/grounding/grounding.continuity.js +283 -0
- package/src/tooling/portable/grounding/grounding.participantAuthority.js +20 -0
- package/src/tooling/portable/grounding/grounding.planningContext.js +34 -0
- package/src/tooling/portable/grounding/grounding.readiness.authority.js +17 -0
- package/src/tooling/portable/grounding/grounding.readiness.js +316 -0
- package/src/tooling/portable/grounding/grounding.readiness.support.js +245 -0
- package/src/tooling/portable/grounding/grounding.sourceEvidence.js +71 -0
- package/src/tooling/portable/grounding/grounding.workContext.js +72 -0
- package/src/tooling/portable/grounding/grounding.workProvenance.js +153 -0
- package/src/tooling/portable/handoff/carrierLineage.js +214 -0
- package/src/tooling/portable/handoff/carrierProfile.js +54 -0
- package/src/tooling/portable/handoff/carrierProjection.js +193 -0
- package/src/tooling/portable/handoff/carrierProjection.routeQualification.js +228 -0
- package/src/tooling/portable/handoff/carrierProjection.shared.js +7 -0
- package/src/tooling/portable/handoff/carrierProjection.workspaces.js +54 -0
- package/src/tooling/portable/handoff/coldConsumerEntrypoint.js +185 -0
- package/src/tooling/portable/handoff/coldStartQualification.contract.js +184 -0
- package/src/tooling/portable/handoff/coldStartQualification.grounding.js +392 -0
- package/src/tooling/portable/handoff/coldStartQualification.js +22 -0
- package/src/tooling/portable/handoff/coldStartQualification.materials.js +364 -0
- package/src/tooling/portable/handoff/coldStartQualification.observation.js +220 -0
- package/src/tooling/portable/handoff/coldStartQualification.run.js +81 -0
- package/src/tooling/portable/handoff/coldStartQualification.shared.js +57 -0
- package/src/tooling/portable/handoff/coldStartRolePointers.js +39 -0
- package/src/tooling/portable/handoff/contextAudit.js +247 -0
- package/src/tooling/portable/handoff/contracts/tiinex.handoff.package.v1.schema.md +409 -0
- package/src/tooling/portable/handoff/handoffAuthoringPlan.js +35 -0
- package/src/tooling/portable/handoff/handoffEndpointProjection.js +61 -0
- package/src/tooling/portable/handoff/handoffLeafProjection.js +91 -0
- package/src/tooling/portable/handoff/humanOutputPresentation.js +21 -0
- package/src/tooling/portable/handoff/manufacture.js +84 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.binding.js +72 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.direct.js +160 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.indexes.js +36 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.js +247 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.projectionProvider.js +44 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.workspace.js +226 -0
- package/src/tooling/portable/handoff/materialClosure.descriptor.js +169 -0
- package/src/tooling/portable/handoff/materialClosure.inputBinding.js +372 -0
- package/src/tooling/portable/handoff/materialClosure.inputBinding.support.js +62 -0
- package/src/tooling/portable/handoff/materialClosure.materialized.js +143 -0
- package/src/tooling/portable/handoff/materialClosure.materials.js +116 -0
- package/src/tooling/portable/handoff/materialClosure.package.js +181 -0
- package/src/tooling/portable/handoff/materialClosure.plan.js +204 -0
- package/src/tooling/portable/handoff/materialClosure.readiness.js +36 -0
- package/src/tooling/portable/handoff/materialClosure.requirements.js +137 -0
- package/src/tooling/portable/handoff/operatorContextProjection.js +105 -0
- package/src/tooling/portable/handoff/pointerEntrypoint.js +138 -0
- package/src/tooling/portable/handoff/qualifiedHandoffFixture.js +34 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.build.js +321 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.closure.js +126 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.inspect.js +194 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.materials.js +207 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.projection.js +69 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.roles.js +166 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.routes.js +113 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.shared.js +87 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.workspaces.js +160 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirstPhase1.js +44 -0
- package/src/tooling/portable/handoff/recipientV2.artifactInspection.js +55 -0
- package/src/tooling/portable/handoff/recipientV2.artifacts.js +174 -0
- package/src/tooling/portable/handoff/recipientV2.coldProjection.js +24 -0
- package/src/tooling/portable/handoff/recipientV2.delivery.js +48 -0
- package/src/tooling/portable/handoff/recipientV2.endpointRolePointers.js +179 -0
- package/src/tooling/portable/handoff/recipientV2.entryContract.js +28 -0
- package/src/tooling/portable/handoff/recipientV2.humanOutput.js +78 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.helpers.js +218 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.js +194 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.pathToken.js +9 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.projection.js +58 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.workspaces.js +177 -0
- package/src/tooling/portable/handoff/recipientV2.lineage.js +142 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.build.js +147 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.constants.js +4 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.contract.js +101 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.inspect.helpers.js +126 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.inspect.js +185 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.js +12 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.shared.js +24 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.workspaceProjection.js +22 -0
- package/src/tooling/portable/handoff/recipientV2.pointer.js +40 -0
- package/src/tooling/portable/handoff/recipientV2.routeSelection.js +16 -0
- package/src/tooling/portable/handoff/recipientV2.topology.helpers.js +20 -0
- package/src/tooling/portable/handoff/recipientV2.topology.js +320 -0
- package/src/tooling/portable/handoff/recipientV2.topology.materials.js +70 -0
- package/src/tooling/portable/handoff/recipientV2.topology.workspaces.js +193 -0
- package/src/tooling/portable/handoff/recipientV2.transportManifest.js +123 -0
- package/src/tooling/portable/handoff/recipientV2.workspaceRepresentation.js +163 -0
- package/src/tooling/portable/handoff/routeArtifactConformance.js +130 -0
- package/src/tooling/portable/handoff/toolingBootstrap.js +67 -0
- package/src/tooling/portable/handoff/transportCompanion.js +175 -0
- package/src/tooling/portable/handoff/workspaceByteProvider.archive.js +95 -0
- package/src/tooling/portable/handoff/workspaceByteProvider.js +271 -0
- package/src/tooling/portable/handoff/workspaceCarrier.manufacture.js +93 -0
- package/src/tooling/portable/handoff/workspaceLandingPlan.js +142 -0
- package/src/tooling/portable/handoff/workspacePackageSources.js +105 -0
- package/src/tooling/portable/handoff/workspaceQualifiedReference.js +10 -0
- package/src/tooling/portable/handoff/workspaceSourceIdentity.js +52 -0
- package/src/tooling/portable/handoff/workspaceTargetConformance.js +134 -0
- package/src/tooling/portable/host/host.capabilities.js +181 -0
- package/src/tooling/portable/host/tool.bindings.js +357 -0
- package/src/tooling/portable/host/tool.receiptNormalization.js +141 -0
- package/src/tooling/portable/index.js +52 -0
- package/src/tooling/portable/input/node.input.js +184 -0
- package/src/tooling/portable/input/portable.input.js +249 -0
- package/src/tooling/portable/lifecycle/lifecycle.action.js +11 -0
- package/src/tooling/portable/lifecycle/lifecycle.material.js +173 -0
- package/src/tooling/portable/lifecycle/lifecycle.operations.js +34 -0
- package/src/tooling/portable/lifecycle/lifecycle.readiness.js +247 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.audit.js +22 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.evidence.js +36 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.js +306 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.structure.js +178 -0
- package/src/tooling/portable/lineage/lineage.integrity.plan.js +377 -0
- package/src/tooling/portable/lineage/lineage.integrity.projection.human.js +82 -0
- package/src/tooling/portable/lineage/lineage.integrity.projection.js +349 -0
- package/src/tooling/portable/lineage/lineage.operations.js +32 -0
- package/src/tooling/portable/lineage/lineage.print.js +398 -0
- package/src/tooling/portable/lineage/lineage.print.render.js +88 -0
- package/src/tooling/portable/lineage/lineage.print.utils.js +58 -0
- package/src/tooling/portable/lineage/lineage.publicationProviderReceipts.js +141 -0
- package/src/tooling/portable/lineage/lineage.publicationQualification.js +183 -0
- package/src/tooling/portable/lineage/lineage.search.js +301 -0
- package/src/tooling/portable/live/live.artifact.js +192 -0
- package/src/tooling/portable/live/live.export.js +107 -0
- package/src/tooling/portable/live/live.lineage.closure.js +71 -0
- package/src/tooling/portable/live/live.lineage.js +338 -0
- package/src/tooling/portable/live/live.protocol.js +181 -0
- package/src/tooling/portable/materialization/durable.materialize.js +162 -0
- package/src/tooling/portable/materialization/epistemic.plan.js +239 -0
- package/src/tooling/portable/materialization/loaded.parent.js +54 -0
- package/src/tooling/portable/materialization/materialization.facade.js +30 -0
- package/src/tooling/portable/operation.catalog.js +393 -0
- package/src/tooling/portable/operation.catalog.package.js +183 -0
- package/src/tooling/portable/operation.result.js +25 -0
- package/src/tooling/portable/orchestration/task.prepare.js +191 -0
- package/src/tooling/portable/output/artifact.result.package.js +308 -0
- package/src/tooling/portable/output/deterministic.zip.js +88 -0
- package/src/tooling/portable/output/node.artifact-set.js +223 -0
- package/src/tooling/portable/output/node.draft.js +41 -0
- package/src/tooling/portable/output/node.zip.js +39 -0
- package/src/tooling/portable/output/recipientV2.zip.js +59 -0
- package/src/tooling/portable/overview/blockingCue.js +16 -0
- package/src/tooling/portable/overview/operatingOverview.js +413 -0
- package/src/tooling/portable/package/generation.binding.js +314 -0
- package/src/tooling/portable/package/generation.binding.projection.js +128 -0
- package/src/tooling/portable/package/material.graph.js +236 -0
- package/src/tooling/portable/package/runtime.package.js +321 -0
- package/src/tooling/portable/package/schema.transition.companion.js +196 -0
- package/src/tooling/portable/package/semantic.package.graph.js +272 -0
- package/src/tooling/portable/package/semantic.package.js +203 -0
- package/src/tooling/portable/package/semantic.package.schema-resolution.js +158 -0
- package/src/tooling/portable/package/semantic.package.transition-registry.js +189 -0
- package/src/tooling/portable/package/semantic.package.types.js +18 -0
- package/src/tooling/portable/providers/schema.bootstrap.provenance.js +10 -0
- package/src/tooling/portable/providers/schema.provider.qualification.js +52 -0
- package/src/tooling/portable/providers/schema.providers.js +458 -0
- package/src/tooling/portable/publication/runtime.publication.js +53 -0
- package/src/tooling/portable/qualification.js +150 -0
- package/src/tooling/portable/reduction/reduction.composition.js +229 -0
- package/src/tooling/portable/reduction/reduction.eligibility.helpers.js +258 -0
- package/src/tooling/portable/reduction/reduction.eligibility.js +191 -0
- package/src/tooling/portable/reduction/reduction.operations.js +30 -0
- package/src/tooling/portable/reduction/reduction.preflight.js +85 -0
- package/src/tooling/portable/reduction/reduction.shared.js +173 -0
- package/src/tooling/portable/schema/bootstrap/canonical.pack.js +24 -0
- package/src/tooling/portable/schema/bootstrap/docs-3988951208eb9a8926e84ab42625d4b42fa00c2d/party/role/tiinex.party.role.v1.schema.md +289 -0
- package/src/tooling/portable/schema/bootstrap/docs-3988951208eb9a8926e84ab42625d4b42fa00c2d/validation/report/tiinex.validation.report.v1.schema.md +300 -0
- package/src/tooling/portable/schema/bootstrap/qualified-local-root/tiinex.root.v1.runtime-projection.json +48 -0
- package/src/tooling/portable/schema/bootstrap/qualified-local-root/tiinex.root.v1.schema.md +865 -0
- package/src/tooling/portable/schema/contract.compile.js +406 -0
- package/src/tooling/portable/schema/contract.compile.utils.js +9 -0
- package/src/tooling/portable/schema/contract.constraints.js +117 -0
- package/src/tooling/portable/schema/contract.envelope.validate.js +177 -0
- package/src/tooling/portable/schema/contract.field-domain.compile.js +399 -0
- package/src/tooling/portable/schema/contract.field-domain.js +247 -0
- package/src/tooling/portable/schema/contract.field-shape.compile.js +34 -0
- package/src/tooling/portable/schema/contract.inheritance.inline.js +103 -0
- package/src/tooling/portable/schema/contract.inheritance.js +210 -0
- package/src/tooling/portable/schema/contract.inheritance.record.js +76 -0
- package/src/tooling/portable/schema/contract.machine-shape.js +309 -0
- package/src/tooling/portable/schema/contract.project.js +81 -0
- package/src/tooling/portable/schema/contract.semantic-resolution.js +82 -0
- package/src/tooling/portable/schema/contract.validate.js +0 -0
- package/src/tooling/portable/schema/lexical.shape.v1.js +338 -0
- package/src/tooling/portable/schema/llm.companion.js +108 -0
- package/src/tooling/portable/schema/named.declarations.js +162 -0
- package/src/tooling/portable/schema/ordinary.contract.js +193 -0
- package/src/tooling/portable/schema/ordinary.fields.js +205 -0
- package/src/tooling/portable/schema/qualifiedLocalRoot.projection.js +70 -0
- package/src/tooling/portable/schema/qualifiedLocalRoot.runtime.js +170 -0
- package/src/tooling/portable/schema/schema.contract.js +465 -0
- package/src/tooling/portable/schema/schema.guide.js +326 -0
- package/src/tooling/portable/schema/schema.snapshot.js +119 -0
- package/src/tooling/portable/session/portable.session.js +145 -0
- package/src/tooling/portable/transfer/transfer.plan.js +102 -0
- package/src/transitions/record.transitions.js +484 -0
- package/src/transitions/transition.validate.js +129 -0
- package/src/validation/findings.js +76 -0
- package/src/validation/validateArtifact.js +216 -0
- package/src/workspaces/workspace.entrypointCapability.js +44 -0
- package/src/workspaces/workspace.materialRole.js +242 -0
- package/src/workspaces/workspace.recordPaths.js +426 -0
- package/tools/tiinex-portable.mjs +6 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { parsePortableSchemaDocument } from '../schema/schema.contract.js';
|
|
2
|
+
|
|
3
|
+
export const PORTABLE_MATERIAL_GRAPH_SCHEMA_ID = 'tiinex.portable.material-graph.v1';
|
|
4
|
+
|
|
5
|
+
export function indexPortableMaterials(materials = []) {
|
|
6
|
+
const normalized = (Array.isArray(materials) ? materials : []).map((material, index) => normalizeMaterial(material, index));
|
|
7
|
+
const byKeyCandidates = new Map();
|
|
8
|
+
const byKey = new Map();
|
|
9
|
+
const byPath = new Map();
|
|
10
|
+
const byReference = new Map();
|
|
11
|
+
for (const material of normalized) {
|
|
12
|
+
pushIndex(byKeyCandidates, material.representationKey, material);
|
|
13
|
+
if (material.path) pushIndex(byPath, material.path, material);
|
|
14
|
+
for (const reference of material.referenceAliases) pushIndex(byReference, reference, material);
|
|
15
|
+
}
|
|
16
|
+
const representationKeyConflicts = [];
|
|
17
|
+
for (const [representationKey, candidates] of byKeyCandidates) {
|
|
18
|
+
if (candidates.length === 1) byKey.set(representationKey, candidates[0]);
|
|
19
|
+
else representationKeyConflicts.push(Object.freeze({
|
|
20
|
+
representationKey,
|
|
21
|
+
candidates: Object.freeze(candidates.map((material) => Object.freeze({
|
|
22
|
+
suppliedIndex: material.suppliedIndex,
|
|
23
|
+
path: material.path,
|
|
24
|
+
schemaId: material.schemaId,
|
|
25
|
+
source: material.source
|
|
26
|
+
})))
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
schema: PORTABLE_MATERIAL_GRAPH_SCHEMA_ID,
|
|
31
|
+
materials: Object.freeze(normalized),
|
|
32
|
+
byKey,
|
|
33
|
+
byKeyCandidates,
|
|
34
|
+
byPath,
|
|
35
|
+
byReference,
|
|
36
|
+
representationKeyConflicts: Object.freeze(representationKeyConflicts)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function resolvePortableMaterialReference(index = {}, fromMaterial = {}, target = '') {
|
|
41
|
+
const reference = String(target || '');
|
|
42
|
+
if (!reference) return resolution('unresolved', [], '', false, 'Reference target is empty.');
|
|
43
|
+
|
|
44
|
+
// Absolute references resolve only through exact explicitly supplied aliases.
|
|
45
|
+
// Relative references are always source-topology relative and must never be
|
|
46
|
+
// captured first by a repository/global alias with the same text.
|
|
47
|
+
if (isAbsoluteReference(reference)) {
|
|
48
|
+
const exact = index.byReference?.get(reference) || [];
|
|
49
|
+
if (exact.length) return exact.length === 1
|
|
50
|
+
? resolution('resolved', exact, reference, false, '')
|
|
51
|
+
: resolution('ambiguous', exact, reference, false, `Exact reference resolves to ${exact.length} material representations.`);
|
|
52
|
+
return resolution('unresolved', [], reference, false, 'Absolute reference is not present in the explicitly supplied material graph.');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!fromMaterial?.path) return resolution('unresolved', [], reference, false, 'Relative reference cannot resolve without a source material path.');
|
|
56
|
+
const joined = resolveRelativePath(dirname(fromMaterial.path), reference);
|
|
57
|
+
if (joined.escaped) return resolution('unresolved', [], joined.path, true, 'Relative reference escapes the available path root.');
|
|
58
|
+
const candidates = index.byPath?.get(joined.path) || [];
|
|
59
|
+
if (candidates.length === 1) return resolution('resolved', candidates, joined.path, false, '');
|
|
60
|
+
if (candidates.length > 1) return resolution('ambiguous', candidates, joined.path, false, `Relative reference resolves to ${candidates.length} material representations.`);
|
|
61
|
+
return resolution('unresolved', [], joined.path, false, 'Relative reference target is not present in the explicitly supplied material graph.');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function extractQualifiedMarkdownLinkTarget(value = '') {
|
|
65
|
+
const text = String(value || '');
|
|
66
|
+
// This is intentionally a decomposition helper, not a shape matcher. Callers must
|
|
67
|
+
// first prove the scalar matched canonical Machine Shape authority.
|
|
68
|
+
if (!text.startsWith('[') || !text.endsWith(')')) return '';
|
|
69
|
+
const separator = text.indexOf('](');
|
|
70
|
+
if (separator < 1) return '';
|
|
71
|
+
return text.slice(separator + 2, -1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export function portableFieldDomainOccurrenceQualification(projection = {}, group = '', field = '', value = '', entry = '') {
|
|
76
|
+
const bucket = (projection.fieldDomains?.groups || []).find((item) => exactToken(item.group) === exactToken(group) && exactToken(item.field) === exactToken(field));
|
|
77
|
+
if (!bucket) return 'unresolved';
|
|
78
|
+
const occurrence = (bucket.occurrences || []).find((item) => {
|
|
79
|
+
if (String(item.value ?? '') !== String(value ?? '')) return false;
|
|
80
|
+
if (entry && item.owner?.kind === 'declaration') return exactToken(item.owner.entry) === exactToken(entry);
|
|
81
|
+
return true;
|
|
82
|
+
});
|
|
83
|
+
return String(occurrence?.qualification || 'unresolved');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function normalizePortablePath(value = '') {
|
|
87
|
+
const text = String(value || '').replace(/\\/g, '/');
|
|
88
|
+
const absolute = text.startsWith('/');
|
|
89
|
+
const parts = [];
|
|
90
|
+
for (const raw of text.split('/')) {
|
|
91
|
+
const part = raw.trim() === '' ? '' : raw;
|
|
92
|
+
if (!part || part === '.') continue;
|
|
93
|
+
if (part === '..') {
|
|
94
|
+
if (parts.length && parts.at(-1) !== '..') parts.pop();
|
|
95
|
+
else if (!absolute) parts.push('..');
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
parts.push(part);
|
|
99
|
+
}
|
|
100
|
+
const joined = parts.join('/');
|
|
101
|
+
return absolute ? `/${joined}` : joined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function dirname(value = '') {
|
|
105
|
+
const path = normalizePortablePath(value);
|
|
106
|
+
const index = path.lastIndexOf('/');
|
|
107
|
+
if (index < 0) return '';
|
|
108
|
+
if (index === 0) return '/';
|
|
109
|
+
return path.slice(0, index);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function pathWithinBoundary(path = '', root = '') {
|
|
113
|
+
const candidate = normalizePortablePath(path);
|
|
114
|
+
const boundary = normalizePortablePath(root);
|
|
115
|
+
if (!boundary) return !candidate.startsWith('..') && !candidate.startsWith('/');
|
|
116
|
+
return candidate === boundary || candidate.startsWith(`${boundary}/`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function relativePathEscapesBoundary(fromMaterial = {}, target = '', boundaryRoot = '') {
|
|
120
|
+
if (isAbsoluteReference(target)) return false;
|
|
121
|
+
if (!fromMaterial?.path) return true;
|
|
122
|
+
const resolved = resolveRelativePath(dirname(fromMaterial.path), target);
|
|
123
|
+
return resolved.escaped || !pathWithinBoundary(resolved.path, boundaryRoot);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function isAbsoluteReference(value = '') {
|
|
127
|
+
const text = String(value || '');
|
|
128
|
+
const colon = text.indexOf(':');
|
|
129
|
+
if (colon <= 0) return text.startsWith('//');
|
|
130
|
+
const scheme = text.slice(0, colon);
|
|
131
|
+
if (!isAsciiLetter(scheme[0])) return false;
|
|
132
|
+
for (const char of scheme.slice(1)) {
|
|
133
|
+
if (!(isAsciiLetter(char) || isAsciiDigit(char) || char === '+' || char === '-' || char === '.')) return false;
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function materialIsSchemaDocument(material = {}) {
|
|
139
|
+
return Boolean(material.schemaDocument?.validation?.groups?.length);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function materialUnderAnyBoundary(material = {}, roots = []) {
|
|
143
|
+
return (roots || []).some((root) => pathWithinBoundary(material.path, root));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function normalizeMaterial(material = {}, index = 0) {
|
|
147
|
+
const markdown = String(material.markdown ?? material.content ?? material.text ?? '');
|
|
148
|
+
const path = normalizePortablePath(material.path || '');
|
|
149
|
+
const schemaDocument = safeParseSchema(markdown);
|
|
150
|
+
const explicitKey = String(material.representationId || material.representationKey || material.id || '').trim();
|
|
151
|
+
const representationKey = explicitKey || `supplied-material:${index}`;
|
|
152
|
+
const aliases = unique([
|
|
153
|
+
material.reference,
|
|
154
|
+
material.url,
|
|
155
|
+
material.href,
|
|
156
|
+
material.source?.reference,
|
|
157
|
+
material.source?.url,
|
|
158
|
+
material.source?.href
|
|
159
|
+
].filter((value) => value !== null && typeof value !== 'undefined' && String(value).trim().length > 0));
|
|
160
|
+
return Object.freeze({
|
|
161
|
+
representationKey,
|
|
162
|
+
path,
|
|
163
|
+
markdown,
|
|
164
|
+
schemaId: String(schemaDocument.schemaId || '').trim(),
|
|
165
|
+
parentSchemaId: String(schemaDocument.parentSchemaId || '').trim(),
|
|
166
|
+
title: String(schemaDocument.title || '').trim(),
|
|
167
|
+
schemaDocument,
|
|
168
|
+
referenceAliases: Object.freeze(aliases),
|
|
169
|
+
source: Object.freeze(serializableSource(material.source || {})),
|
|
170
|
+
suppliedIndex: index
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function resolveRelativePath(base = '', target = '') {
|
|
175
|
+
const targetText = String(target || '').replace(/\\/g, '/');
|
|
176
|
+
const baseParts = normalizePortablePath(base).split('/').filter(Boolean);
|
|
177
|
+
const absolute = normalizePortablePath(base).startsWith('/');
|
|
178
|
+
let escaped = false;
|
|
179
|
+
for (const part of targetText.split('/')) {
|
|
180
|
+
if (!part || part === '.') continue;
|
|
181
|
+
if (part === '..') {
|
|
182
|
+
if (baseParts.length) baseParts.pop();
|
|
183
|
+
else escaped = true;
|
|
184
|
+
} else {
|
|
185
|
+
baseParts.push(part);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const path = `${absolute ? '/' : ''}${baseParts.join('/')}`;
|
|
189
|
+
return { path: normalizePortablePath(path), escaped };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function resolution(qualification, candidates, target, escaped, finding) {
|
|
193
|
+
return Object.freeze({
|
|
194
|
+
qualification,
|
|
195
|
+
target,
|
|
196
|
+
escaped,
|
|
197
|
+
candidates: Object.freeze([...(candidates || [])]),
|
|
198
|
+
finding: String(finding || '')
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function pushIndex(map, key, value) {
|
|
203
|
+
const token = String(key || '');
|
|
204
|
+
if (!token) return;
|
|
205
|
+
if (!map.has(token)) map.set(token, []);
|
|
206
|
+
map.get(token).push(value);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function safeParseSchema(markdown) {
|
|
210
|
+
try { return parsePortableSchemaDocument(markdown); } catch { return { validation: { groups: [] }, creation: { groups: [] } }; }
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function serializableSource(source = {}) {
|
|
214
|
+
const out = {};
|
|
215
|
+
for (const [key, value] of Object.entries(source || {})) {
|
|
216
|
+
if (typeof value === 'function' || typeof value === 'undefined') continue;
|
|
217
|
+
out[key] = value;
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function unique(values = []) {
|
|
223
|
+
return [...new Set(values.map((value) => String(value || '')).filter(Boolean))];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function exactToken(value = '') { return String(value || '').trim(); }
|
|
227
|
+
|
|
228
|
+
function isAsciiLetter(char = '') {
|
|
229
|
+
const code = String(char || '').charCodeAt(0);
|
|
230
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function isAsciiDigit(char = '') {
|
|
234
|
+
const code = String(char || '').charCodeAt(0);
|
|
235
|
+
return code >= 48 && code <= 57;
|
|
236
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { buildExportPackageApplyResult, buildExportPackageImportPlan } from '../../../export/package.apply.js';
|
|
2
|
+
import { buildExportPackageBundle, inspectExportPackageBundle } from '../../../export/package.builder.js';
|
|
3
|
+
import { portableFinding, summarizePortableFindings } from '../findings.js';
|
|
4
|
+
import { packageFileBytes, sha256Hex, stableFingerprintBytes, utf8Text } from '../../../export/package.bytes.js';
|
|
5
|
+
import { EXPORT_PACKAGE_CONTROL_PATHS, exportPackageControlKindForPath } from '../../../export/package.controlTopology.js';
|
|
6
|
+
|
|
7
|
+
export const PORTABLE_RUNTIME_PACKAGE_SCHEMA_ID = 'tiinex.portable.runtime-package.v1';
|
|
8
|
+
export const PORTABLE_RUNTIME_PACKAGE_ROUNDTRIP_SCHEMA_ID = 'tiinex.portable.runtime-package.roundtrip.v1';
|
|
9
|
+
export const PORTABLE_RUNTIME_PACKAGE_REHYDRATION_SCHEMA_ID = 'tiinex.portable.runtime-package.rehydration.v1';
|
|
10
|
+
|
|
11
|
+
export function buildPortableRuntimePackage(input = {}, options = {}) {
|
|
12
|
+
const workspace = portableWorkspace(input);
|
|
13
|
+
const bundle = buildExportPackageBundle(workspace, {
|
|
14
|
+
records: workspace.records,
|
|
15
|
+
assets: workspace.assets,
|
|
16
|
+
workspaceCandidates: workspace.workspaceMergeCandidates,
|
|
17
|
+
allowBlocked: input.allowBlocked === true || options.allowBlocked === true,
|
|
18
|
+
includeDegraded: input.includeDegraded !== false && options.includeDegraded !== false,
|
|
19
|
+
builtAt: input.builtAt || options.builtAt,
|
|
20
|
+
clock: options.clock
|
|
21
|
+
});
|
|
22
|
+
const findings = [...(bundle.findings || [])];
|
|
23
|
+
return Object.freeze({
|
|
24
|
+
schema: PORTABLE_RUNTIME_PACKAGE_SCHEMA_ID,
|
|
25
|
+
status: bundle.status,
|
|
26
|
+
workspace: Object.freeze({ id: workspace.id, title: workspace.title, records: workspace.records.length, assets: workspace.assets.length, workspaceCandidates: workspace.workspaceMergeCandidates.length }),
|
|
27
|
+
bundle,
|
|
28
|
+
qualification: packageQualification(bundle),
|
|
29
|
+
findings: Object.freeze(findings),
|
|
30
|
+
findingSummary: summarizePortableFindings(findings)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function inspectPortableRuntimePackage(input = {}) {
|
|
35
|
+
const bundle = input.bundle || input;
|
|
36
|
+
const inspection = inspectExportPackageBundle(bundle);
|
|
37
|
+
return Object.freeze({
|
|
38
|
+
schema: 'tiinex.portable.runtime-package.inspection.v1',
|
|
39
|
+
status: inspection.status,
|
|
40
|
+
inspection,
|
|
41
|
+
qualification: packageQualification(bundle),
|
|
42
|
+
findings: inspection.findings,
|
|
43
|
+
findingSummary: summarizePortableFindings(inspection.findings || [])
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function rehydratePortableRuntimePackage(input = {}) {
|
|
48
|
+
const suppliedFiles = Array.isArray(input.files) ? input.files : [];
|
|
49
|
+
const findings = [];
|
|
50
|
+
const byPath = new Map(suppliedFiles.map((file) => [normalizePath(file.path || file.name || ''), file]));
|
|
51
|
+
const manifest = parseJsonContent(byPath.get(EXPORT_PACKAGE_CONTROL_PATHS.manifest));
|
|
52
|
+
const receipt = parseJsonContent(byPath.get(EXPORT_PACKAGE_CONTROL_PATHS.receipt));
|
|
53
|
+
const contract = parseJsonContent(byPath.get(EXPORT_PACKAGE_CONTROL_PATHS.contract));
|
|
54
|
+
const buildReceipt = parseJsonContent(byPath.get(EXPORT_PACKAGE_CONTROL_PATHS.buildReceipt));
|
|
55
|
+
const fileMap = parseJsonContent(byPath.get(EXPORT_PACKAGE_CONTROL_PATHS.fileMap));
|
|
56
|
+
if (!manifest) findings.push(portableFinding('error', 'portable.runtime-package.rehydrate.manifest-missing', 'Serialized runtime package files are missing a readable manifest control file.'));
|
|
57
|
+
const entryIndex = manifestEntryIndex(manifest || {});
|
|
58
|
+
const fileMapIndex = durableFileMapIndex(fileMap || {});
|
|
59
|
+
const files = suppliedFiles.map((file) => rehydratedFile(file, entryIndex, fileMapIndex)).filter((file) => file.path);
|
|
60
|
+
const bundle = Object.freeze({
|
|
61
|
+
schema: 'tiinex.export.package.bundle.v1',
|
|
62
|
+
packageId: String(manifest?.packageId || receipt?.packageId || ''),
|
|
63
|
+
builtAt: String(buildReceipt?.builtAt || receipt?.at || ''),
|
|
64
|
+
status: String(manifest?.status || 'degraded'),
|
|
65
|
+
boundary: 'Rehydrated from explicitly supplied serialized package files. No remote fetch, source mutation, or received-code execution occurred.',
|
|
66
|
+
packageFingerprint: '',
|
|
67
|
+
packageRepresentationSha256: String(fileMap?.representationSha256 || ''),
|
|
68
|
+
fileMap: fileMap || null,
|
|
69
|
+
contract: contract || {},
|
|
70
|
+
manifest: manifest || {},
|
|
71
|
+
receipt: receipt || {},
|
|
72
|
+
buildReceipt: buildReceipt || {},
|
|
73
|
+
counts: Object.freeze(packageFileCounts(files, findings)),
|
|
74
|
+
files: Object.freeze(files),
|
|
75
|
+
findings: Object.freeze(findings)
|
|
76
|
+
});
|
|
77
|
+
const inspection = inspectExportPackageBundle(bundle);
|
|
78
|
+
const combinedFindings = [...findings, ...(inspection.findings || [])];
|
|
79
|
+
return Object.freeze({
|
|
80
|
+
schema: PORTABLE_RUNTIME_PACKAGE_REHYDRATION_SCHEMA_ID,
|
|
81
|
+
status: inspection.status === 'valid' && !combinedFindings.some((finding) => finding.severity === 'error') ? 'rehydrated' : 'invalid',
|
|
82
|
+
bundle,
|
|
83
|
+
inspection,
|
|
84
|
+
qualification: packageQualification(bundle),
|
|
85
|
+
findings: Object.freeze(combinedFindings),
|
|
86
|
+
findingSummary: summarizePortableFindings(combinedFindings)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function roundTripPortableRuntimePackage(input = {}, options = {}) {
|
|
91
|
+
const rehydrated = !input.bundle && looksLikeSerializedPackage(input.files) ? rehydratePortableRuntimePackage(input) : null;
|
|
92
|
+
const built = input.bundle
|
|
93
|
+
? Object.freeze({ bundle: input.bundle, status: input.bundle.status, qualification: packageQualification(input.bundle), findings: Object.freeze([]) })
|
|
94
|
+
: rehydrated
|
|
95
|
+
? Object.freeze({ bundle: rehydrated.bundle, status: rehydrated.status, qualification: rehydrated.qualification, findings: rehydrated.findings })
|
|
96
|
+
: buildPortableRuntimePackage(input, options);
|
|
97
|
+
const bundle = built.bundle;
|
|
98
|
+
const inspection = inspectExportPackageBundle(bundle);
|
|
99
|
+
const importPlan = buildExportPackageImportPlan(bundle, { inspection });
|
|
100
|
+
const applyResult = buildExportPackageApplyResult(bundle, { importPlan });
|
|
101
|
+
const findings = [...(built.findings || []), ...(inspection.findings || []), ...(importPlan.findings || [])];
|
|
102
|
+
const comparisons = compareRoundTrip(bundle, importPlan);
|
|
103
|
+
findings.push(...comparisons.findings);
|
|
104
|
+
const errors = findings.filter((finding) => finding.severity === 'error').length;
|
|
105
|
+
const status = errors ? 'failed' : bundle.status === 'ready' && importPlan.status === 'ready' && comparisons.status === 'match' ? 'passed' : 'passed-degraded';
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
schema: PORTABLE_RUNTIME_PACKAGE_ROUNDTRIP_SCHEMA_ID,
|
|
108
|
+
status,
|
|
109
|
+
packageId: bundle.packageId || '',
|
|
110
|
+
bundle,
|
|
111
|
+
inspection,
|
|
112
|
+
importPlan,
|
|
113
|
+
applyResult,
|
|
114
|
+
comparison: comparisons,
|
|
115
|
+
qualification: packageQualification(bundle),
|
|
116
|
+
findings: Object.freeze(findings),
|
|
117
|
+
findingSummary: summarizePortableFindings(findings)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function portableWorkspace(input = {}) {
|
|
122
|
+
const session = input.session || input.snapshot || {};
|
|
123
|
+
const materials = session.materials || input.materials || input;
|
|
124
|
+
const staged = input.stagedArtifacts || session.stagedArtifacts || [];
|
|
125
|
+
const records = dedupeRecords([
|
|
126
|
+
...(materials.records || input.records || []),
|
|
127
|
+
...staged.map(stagedRecord)
|
|
128
|
+
]);
|
|
129
|
+
const assets = [...(materials.assets || input.assets || [])];
|
|
130
|
+
const workspaceCandidates = [...(input.workspaceCandidates || input.workspaceMergeCandidates || [])];
|
|
131
|
+
return Object.freeze({
|
|
132
|
+
id: String(input.workspaceId || session.workspaceId || 'portable-runtime-package'),
|
|
133
|
+
name: String(input.name || input.title || input.workspaceTitle || session.workspaceTitle || 'Portable runtime package'),
|
|
134
|
+
title: String(input.title || input.workspaceTitle || session.workspaceTitle || 'Portable runtime package'),
|
|
135
|
+
createdAt: String(input.createdAt || session.createdAt || ''),
|
|
136
|
+
records: Object.freeze(records),
|
|
137
|
+
assets: Object.freeze(assets),
|
|
138
|
+
workspaceMergeCandidates: Object.freeze(workspaceCandidates),
|
|
139
|
+
workspaceMarkdown: String(input.workspaceMarkdown || session.workspaceMarkdown || ''),
|
|
140
|
+
workspaceImport: Object.freeze({ ...(session.workspaceImport || {}), ...(input.workspaceImport || {}) }),
|
|
141
|
+
sources: Object.freeze([...(session.sources || input.sources || [])]),
|
|
142
|
+
sourceOrder: Object.freeze([...(session.sourceOrder || input.sourceOrder || [])]),
|
|
143
|
+
workspaceMemberBindings: Object.freeze([...(session.workspaceMemberBindings || input.workspaceMemberBindings || [])])
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function stagedRecord(artifact = {}) {
|
|
148
|
+
return Object.freeze({
|
|
149
|
+
id: artifact.id || artifact.path,
|
|
150
|
+
title: artifact.title || titleFromMarkdown(artifact.markdown) || artifact.path || 'Staged artifact',
|
|
151
|
+
path: artifact.path || 'draft.md',
|
|
152
|
+
markdown: artifact.markdown || '',
|
|
153
|
+
schemaId: artifact.schemaId || '',
|
|
154
|
+
lifecycleStatus: artifact.lifecycleStatus || 'draft',
|
|
155
|
+
sourceMode: artifact.sourceMode || 'local-portable-staged',
|
|
156
|
+
source: Object.freeze({
|
|
157
|
+
kind: 'local-session',
|
|
158
|
+
adapterId: 'local',
|
|
159
|
+
path: artifact.path || 'draft.md',
|
|
160
|
+
boundary: 'Portable staged local artifact; no GitHub provenance inferred.',
|
|
161
|
+
sourceBacked: false
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function dedupeRecords(records) {
|
|
167
|
+
const map = new Map();
|
|
168
|
+
for (const record of records) {
|
|
169
|
+
const key = String(record.id || record.path || `${record.title}:${map.size}`);
|
|
170
|
+
const existing = map.get(key);
|
|
171
|
+
if (!existing || (String(record.sourceMode || '').startsWith('local-portable-staged') && !String(existing.sourceMode || '').startsWith('local-portable-staged'))) map.set(key, Object.freeze({ ...record }));
|
|
172
|
+
}
|
|
173
|
+
return [...map.values()];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function compareRoundTrip(bundle, importPlan) {
|
|
177
|
+
const findings = [];
|
|
178
|
+
const artifactFiles = (bundle.files || []).filter((file) => file.kind === 'artifact-markdown');
|
|
179
|
+
const importedByEntry = new Map((importPlan.records || []).map((record) => [String(record.packageEntryId || '').trim(), record]));
|
|
180
|
+
for (const file of artifactFiles) {
|
|
181
|
+
const entryId = String(file.entryId || '').trim();
|
|
182
|
+
const imported = importedByEntry.get(entryId);
|
|
183
|
+
if (!imported) findings.push(portableFinding('error', 'portable.runtime-package.roundtrip.artifact.missing', 'A governed bundled local artifact did not materialize during import.', { ref: entryId || file.path || '' }));
|
|
184
|
+
else {
|
|
185
|
+
const expected = typeof file.content === 'string' ? file.content : utf8Text(packageFileBytes(file));
|
|
186
|
+
if (String(imported.markdown || '') !== expected) findings.push(portableFinding('error', 'portable.runtime-package.roundtrip.artifact.changed', 'A governed bundled local artifact changed during package import.', { ref: entryId || file.path || '' }));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if ((importPlan.records || []).length !== artifactFiles.length) findings.push(portableFinding('error', 'portable.runtime-package.roundtrip.artifact.count', 'Governed local artifact cardinality changed during package import.'));
|
|
190
|
+
const sourceFiles = (bundle.files || []).filter((file) => file.kind === 'source-reference' || file.kind === 'asset-source-reference');
|
|
191
|
+
if ((importPlan.sourceReferences || []).length !== sourceFiles.length) findings.push(portableFinding('error', 'portable.runtime-package.roundtrip.source-reference.count', 'Source reference cardinality changed during package import.'));
|
|
192
|
+
const assetFiles = (bundle.files || []).filter((file) => file.kind === 'asset-content' || file.kind === 'asset-metadata');
|
|
193
|
+
if ((importPlan.assets || []).length !== assetFiles.length) findings.push(portableFinding('error', 'portable.runtime-package.roundtrip.asset.count', 'Owned/metadata asset cardinality changed during package import.'));
|
|
194
|
+
for (const file of assetFiles.filter((item) => item.kind === 'asset-content')) {
|
|
195
|
+
const asset = (importPlan.assets || []).find((item) => String(item.packageEntryId || '') === String(file.entryId || ''));
|
|
196
|
+
if (!asset) continue;
|
|
197
|
+
const expected = packageFileBytes(file);
|
|
198
|
+
const actual = asset.bytes instanceof Uint8Array ? asset.bytes : packageFileBytes({ content: asset.content || '' });
|
|
199
|
+
if (expected.byteLength !== actual.byteLength || sha256Hex(expected) !== sha256Hex(actual)) findings.push(portableFinding('error', 'portable.runtime-package.roundtrip.asset.changed', 'Owned asset bytes changed during package import.', { ref: file.entryId || file.path || '' }));
|
|
200
|
+
}
|
|
201
|
+
if ((importPlan.records || []).some((record) => record.source?.adapterId === 'github')) findings.push(portableFinding('error', 'portable.runtime-package.roundtrip.github-inference', 'Package import incorrectly materialized a local record as GitHub-backed.'));
|
|
202
|
+
return Object.freeze({
|
|
203
|
+
schema: 'tiinex.portable.runtime-package.comparison.v2',
|
|
204
|
+
status: findings.some((finding) => finding.severity === 'error') ? 'mismatch' : 'match',
|
|
205
|
+
counts: Object.freeze({ artifacts: artifactFiles.length, importedRecords: importPlan.records?.length || 0, sourceReferences: importPlan.sourceReferences?.length || 0, assets: importPlan.assets?.length || 0, workspaceContext: importPlan.counts?.workspaceContext || 0 }),
|
|
206
|
+
findings: Object.freeze(findings)
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function packageQualification(bundle = {}) {
|
|
211
|
+
return Object.freeze({
|
|
212
|
+
sharedRuntimeContract: bundle.schema === 'tiinex.export.package.bundle.v1',
|
|
213
|
+
runtimeContractId: bundle.schema || 'tiinex.export.package.bundle.v1',
|
|
214
|
+
canonicalPackageSchemaLocked: false,
|
|
215
|
+
canonicalHandoffGenerated: true,
|
|
216
|
+
inMemoryFileMap: true,
|
|
217
|
+
durableSerializedFileMap: Boolean(bundle.fileMap || (bundle.files || []).some((file) => normalizePath(file.path) === EXPORT_PACKAGE_CONTROL_PATHS.fileMap)),
|
|
218
|
+
remoteFetch: false,
|
|
219
|
+
remoteWrite: false,
|
|
220
|
+
sourceMutation: false,
|
|
221
|
+
statement: 'Operational Tiinex handoff package with durable representation-level file-map integrity. It is not tiinex.semantic.package.v1 and does not claim semantic ownership or external provenance.'
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function looksLikeSerializedPackage(files = []) {
|
|
226
|
+
return Array.isArray(files) && files.some((file) => normalizePath(file.path || file.name || '') === EXPORT_PACKAGE_CONTROL_PATHS.manifest);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function parseJsonContent(file = null) {
|
|
230
|
+
if (!file) return null;
|
|
231
|
+
try { return JSON.parse(utf8Text(packageFileBytes(file))); }
|
|
232
|
+
catch { return null; }
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function manifestEntryIndex(manifest = {}) {
|
|
236
|
+
const index = new Map();
|
|
237
|
+
const groups = [
|
|
238
|
+
['localDrafts', 'artifact-markdown'],
|
|
239
|
+
['sourceReferences', 'source-reference'],
|
|
240
|
+
['assets', 'asset'],
|
|
241
|
+
['workspaceContextCandidates', 'workspace-candidate']
|
|
242
|
+
];
|
|
243
|
+
for (const [group, kind] of groups) {
|
|
244
|
+
for (const entry of manifest.material?.[group] || []) {
|
|
245
|
+
for (const packagePath of [entry.packagePath, ...(entry.packagePaths || [])].filter(Boolean)) index.set(normalizePath(packagePath), Object.freeze({ ...entry, inferredKind: kind }));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const context = manifest.material?.workspaceContext;
|
|
249
|
+
if (context) {
|
|
250
|
+
for (const packagePath of [context.packagePath, ...(context.packagePaths || [])].filter(Boolean)) index.set(normalizePath(packagePath), Object.freeze({ ...context, inferredKind: packagePath.endsWith('.md') ? 'workspace-context-markdown' : 'workspace-context' }));
|
|
251
|
+
}
|
|
252
|
+
return index;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function durableFileMapIndex(fileMap = {}) {
|
|
256
|
+
const index = new Map();
|
|
257
|
+
for (const entry of fileMap.entries || []) if (entry?.path) index.set(normalizePath(entry.path), entry);
|
|
258
|
+
return index;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function rehydratedFile(file = {}, entryIndex = new Map(), fileMapIndex = new Map()) {
|
|
262
|
+
const path = normalizePath(file.path || file.name || '');
|
|
263
|
+
const data = packageFileBytes(file);
|
|
264
|
+
const entry = entryIndex.get(path) || null;
|
|
265
|
+
const durable = fileMapIndex.get(path) || null;
|
|
266
|
+
let kind = exportPackageControlKindForPath(path) || durable?.kind || entry?.inferredKind || String(file.kind || 'unknown');
|
|
267
|
+
if (kind === 'asset') kind = entry?.status === 'source-reference' ? 'asset-source-reference' : entry?.content?.available ? 'asset-content' : 'asset-metadata';
|
|
268
|
+
const mediaType = String(durable?.mediaType || entry?.mediaType || file.mediaType || file.type || '');
|
|
269
|
+
const textual = kind.includes('json') || kind.includes('markdown') || /^text\//i.test(mediaType) || /json|markdown/i.test(mediaType);
|
|
270
|
+
return Object.freeze({
|
|
271
|
+
path,
|
|
272
|
+
requestedPath: String(durable?.requestedPath || path),
|
|
273
|
+
kind,
|
|
274
|
+
...(textual ? { content: typeof file.content === 'string' ? file.content : utf8Text(data) } : {}),
|
|
275
|
+
data,
|
|
276
|
+
bytes: data.byteLength,
|
|
277
|
+
sha256: sha256Hex(data),
|
|
278
|
+
fingerprint: stableFingerprintBytes(data),
|
|
279
|
+
entryId: String(durable?.entryId || entry?.id || file.entryId || ''),
|
|
280
|
+
logicalKind: String(durable?.logicalKind || ''),
|
|
281
|
+
title: String(entry?.title || file.title || ''),
|
|
282
|
+
mediaType,
|
|
283
|
+
boundary: String(durable?.boundary || entry?.boundary || file.boundary || ''),
|
|
284
|
+
sourceBoundary: String(durable?.sourceBoundary || '')
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function packageFileCounts(files = [], findings = []) {
|
|
289
|
+
return {
|
|
290
|
+
files: files.length,
|
|
291
|
+
controlFiles: files.filter((file) => file.path.startsWith('tiinex.package/')).length,
|
|
292
|
+
materialFiles: files.filter((file) => !file.path.startsWith('tiinex.package/')).length,
|
|
293
|
+
localDraftFiles: files.filter((file) => file.kind === 'artifact-markdown').length,
|
|
294
|
+
sourceReferenceFiles: files.filter((file) => file.kind === 'source-reference').length,
|
|
295
|
+
assetContentFiles: files.filter((file) => file.kind === 'asset-content').length,
|
|
296
|
+
assetMetadataFiles: files.filter((file) => file.kind === 'asset-metadata').length,
|
|
297
|
+
assetReferenceFiles: files.filter((file) => file.kind === 'asset-source-reference').length,
|
|
298
|
+
workspaceContextFiles: files.filter((file) => file.kind === 'workspace-context' || file.kind === 'workspace-context-markdown').length,
|
|
299
|
+
workspaceCandidateFiles: files.filter((file) => file.kind === 'workspace-candidate').length,
|
|
300
|
+
errors: findings.filter((finding) => finding.severity === 'error').length,
|
|
301
|
+
warnings: findings.filter((finding) => finding.severity === 'warning').length,
|
|
302
|
+
findings: findings.length
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function stableTextFingerprint(value = '') {
|
|
307
|
+
const text = String(value || '');
|
|
308
|
+
let hash = 2166136261;
|
|
309
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
310
|
+
hash ^= text.charCodeAt(index);
|
|
311
|
+
hash = Math.imul(hash, 16777619);
|
|
312
|
+
}
|
|
313
|
+
return `tixfp1-${(hash >>> 0).toString(16).padStart(8, '0')}`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function titleFromMarkdown(markdown = '') {
|
|
317
|
+
const match = String(markdown || '').match(/^#\s+(.+)$/m);
|
|
318
|
+
return match?.[1]?.trim() || '';
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function normalizePath(value = '') { return String(value || '').replace(/\\/g, '/').replace(/^\/+/, ''); }
|