@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,191 @@
|
|
|
1
|
+
import { portableFinding, summarizePortableFindings } from '../findings.js';
|
|
2
|
+
import { discoverPortableHostCapabilities, portableTaskRoute } from '../host/host.capabilities.js';
|
|
3
|
+
import { resolvePortableSchemaChainMaterial } from '../providers/schema.providers.js';
|
|
4
|
+
import { buildPortableSchemaGuide, planPortableArtifact } from '../schema/schema.guide.js';
|
|
5
|
+
import { validatePortableDraft } from '../draft/draft.operations.js';
|
|
6
|
+
import { searchPortableLineage } from '../lineage/lineage.search.js';
|
|
7
|
+
import { preparePortableAssetAnalysis } from '../assets/asset.operations.js';
|
|
8
|
+
import { planPortableHostAction } from '../host/tool.bindings.js';
|
|
9
|
+
import { describePortableCheckpointGate, qualifyPortableCheckpoint } from '../conformance/checkpoint.qualification.js';
|
|
10
|
+
|
|
11
|
+
export const PORTABLE_TASK_PREPARATION_SCHEMA_ID = 'tiinex.portable.task-preparation.v1';
|
|
12
|
+
|
|
13
|
+
export async function preparePortableTask(input = {}, options = {}) {
|
|
14
|
+
const task = normalizeTask(input.task || input.intent || input.goal || options.task || 'inspect');
|
|
15
|
+
const hostDiscovery = discoverPortableHostCapabilities(input.host || input, options.host || options);
|
|
16
|
+
const findings = [...(hostDiscovery.findings || [])];
|
|
17
|
+
const route = portableTaskRoute(routeTask(task), hostDiscovery.profile);
|
|
18
|
+
let result = null;
|
|
19
|
+
let status = 'ready';
|
|
20
|
+
let nextAction = null;
|
|
21
|
+
|
|
22
|
+
if (['read-schema', 'create-artifact', 'validate-draft'].includes(task)) {
|
|
23
|
+
const schemaId = String(input.schemaId || options.schemaId || '').trim();
|
|
24
|
+
if (!schemaId) findings.push(portableFinding('error', 'portable.task.schema.required', `Task ${task} requires a schema id.`));
|
|
25
|
+
if (schemaId) {
|
|
26
|
+
const chain = await resolvePortableSchemaChainMaterial({ ...input, schemaId }, options);
|
|
27
|
+
findings.push(...(chain.findings || []));
|
|
28
|
+
if (chain.status === 'provider-action-required') {
|
|
29
|
+
status = 'provider-action-required';
|
|
30
|
+
const hostActionPlan = planPortableHostAction({ ...input, action: 'repository-schema-resolution', request: chain.providerRequest, host: input.host || input }, options);
|
|
31
|
+
findings.push(...(hostActionPlan.findings || []));
|
|
32
|
+
nextAction = Object.freeze({ ...chain.providerRequest, hostActionPlan });
|
|
33
|
+
result = Object.freeze({ schemaChain: chain, hostActionPlan });
|
|
34
|
+
} else {
|
|
35
|
+
const context = { ...input, files: chain.materials.files, schemaCache: chain.materials.schemaCache, schemaId };
|
|
36
|
+
if (task === 'read-schema') {
|
|
37
|
+
const guide = buildPortableSchemaGuide({ ...context, task: input.schemaTask || 'read', detail: input.detail || 'compact' }, options);
|
|
38
|
+
findings.push(...(guide.findings || []));
|
|
39
|
+
result = Object.freeze({ schemaChain: chain, guide: guide.guide });
|
|
40
|
+
status = guide.findings.some((finding) => finding.severity === 'error') ? 'blocked' : 'ready';
|
|
41
|
+
nextAction = Object.freeze({ operation: 'schema-guide', reason: 'Readable schema material is resolved and a compact guide is available.' });
|
|
42
|
+
} else if (task === 'create-artifact') {
|
|
43
|
+
const plan = planPortableArtifact({ ...context, task: 'create', values: input.values || input.inputs || {} }, options);
|
|
44
|
+
findings.push(...(plan.findings || []));
|
|
45
|
+
result = Object.freeze({ schemaChain: chain, guide: plan.guide, plan: plan.plan });
|
|
46
|
+
status = plan.plan.readyToDraft ? 'ready-to-create-local-draft' : 'authoring-input-required';
|
|
47
|
+
nextAction = Object.freeze({
|
|
48
|
+
operation: plan.plan.readyToDraft ? 'create-local-draft' : 'collect-required-inputs',
|
|
49
|
+
missingInputs: plan.plan.missingInputs,
|
|
50
|
+
conditionReviewRequired: plan.plan.conditionReviewRequired
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
const validation = validatePortableDraft({ ...context, markdown: input.markdown || input.draft?.markdown || '', path: input.path || input.draft?.path || 'draft.md' }, options);
|
|
54
|
+
findings.push(...(validation.findings || []));
|
|
55
|
+
result = Object.freeze({ schemaChain: chain, validation });
|
|
56
|
+
status = validation.status;
|
|
57
|
+
nextAction = Object.freeze({ operation: validation.status === 'clean' ? 'stage-draft' : 'repair-plan' });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} else if (task === 'search-lineage') {
|
|
62
|
+
const search = searchPortableLineage(input, options);
|
|
63
|
+
findings.push(...(search.findings || []));
|
|
64
|
+
result = Object.freeze({ search });
|
|
65
|
+
status = 'ready';
|
|
66
|
+
nextAction = Object.freeze({ operation: 'search-lineage', returnedMatches: search.matches.length, totalMatches: search.page.total });
|
|
67
|
+
} else if (task === 'analyze-asset') {
|
|
68
|
+
const prepared = preparePortableAssetAnalysis(input, options);
|
|
69
|
+
findings.push(...(prepared.findings || []));
|
|
70
|
+
result = Object.freeze({ assetAnalysis: prepared });
|
|
71
|
+
status = prepared.status;
|
|
72
|
+
const action = prepared.request?.requiredCapability === 'multimodal.pdf' ? 'pdf-analysis' : 'image-analysis';
|
|
73
|
+
const hostActionPlan = prepared.request ? planPortableHostAction({ ...input, action, request: prepared.request, host: input.host || input }, options) : null;
|
|
74
|
+
if (hostActionPlan) findings.push(...(hostActionPlan.findings || []));
|
|
75
|
+
nextAction = prepared.request ? Object.freeze({ ...prepared.request.hostAction, hostActionPlan }) : null;
|
|
76
|
+
} else if (task === 'materialize-findings') {
|
|
77
|
+
const { planPortableDurableMaterialization } = await import('../materialization/durable.materialize.js');
|
|
78
|
+
const plan = planPortableDurableMaterialization(input);
|
|
79
|
+
findings.push(...(plan.findings || []));
|
|
80
|
+
result = Object.freeze({ materializationPlan: plan });
|
|
81
|
+
status = plan.status;
|
|
82
|
+
nextAction = Object.freeze({
|
|
83
|
+
operation: plan.status === 'ready' ? 'materialize-durable-findings' : 'collect-materialization-map',
|
|
84
|
+
unassignedFindings: plan.unassignedFindings?.length || 0
|
|
85
|
+
});
|
|
86
|
+
} else if (task === 'qualify-checkpoint') {
|
|
87
|
+
if (Array.isArray(input.receipts) && input.receipts.length) {
|
|
88
|
+
const qualification = qualifyPortableCheckpoint(input);
|
|
89
|
+
findings.push(...(qualification.findings || []));
|
|
90
|
+
result = Object.freeze({ qualification });
|
|
91
|
+
status = qualification.status;
|
|
92
|
+
nextAction = Object.freeze({
|
|
93
|
+
operation: qualification.status === 'qualified' || qualification.status === 'qualified-with-warnings' ? 'review-checkpoint-qualification' : 'run-or-repair-checkpoint-gates',
|
|
94
|
+
gateSummary: qualification.gateSummary
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
const checkpointGate = describePortableCheckpointGate({ profile: input.profile || 'source-clean' });
|
|
98
|
+
result = Object.freeze({ checkpointGate });
|
|
99
|
+
status = 'receipt-required';
|
|
100
|
+
nextAction = Object.freeze({
|
|
101
|
+
operation: 'run-checkpoint-gates',
|
|
102
|
+
adapter: 'tools/tiinex-portable-verify.mjs',
|
|
103
|
+
profile: checkpointGate.profile,
|
|
104
|
+
commandsExecutedByPortableCore: false
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
} else if (task === 'checkpoint') {
|
|
108
|
+
const session = input.session || input.snapshot || input;
|
|
109
|
+
result = Object.freeze({
|
|
110
|
+
sessionSummary: Object.freeze({
|
|
111
|
+
stagedArtifacts: session.stagedArtifacts?.length || 0,
|
|
112
|
+
durableFindings: session.durableFindings?.length || 0,
|
|
113
|
+
schemaCacheEntries: session.schemaCache?.length || 0
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
status = 'ready';
|
|
117
|
+
nextAction = Object.freeze({ operation: 'create-checkpoint', canonicalHandoffArtifact: false });
|
|
118
|
+
} else if (task === 'package') {
|
|
119
|
+
const session = input.session || input.snapshot || {};
|
|
120
|
+
const stagedCount = (input.stagedArtifacts || session.stagedArtifacts || []).length;
|
|
121
|
+
result = Object.freeze({ stagedArtifacts: stagedCount, runtimeContract: 'tiinex.export.package.bundle.v1', canonicalPackageSchemaLocked: false });
|
|
122
|
+
status = stagedCount ? 'ready' : 'material-required';
|
|
123
|
+
nextAction = Object.freeze({ operation: stagedCount ? 'build-runtime-package' : 'stage-draft', then: stagedCount ? 'roundtrip-runtime-package' : 'build-runtime-package' });
|
|
124
|
+
} else {
|
|
125
|
+
result = Object.freeze({
|
|
126
|
+
operations: Object.freeze(['inspect', 'audit', 'search-lineage', 'read-schema', 'create-artifact', 'validate-draft', 'analyze-asset', 'materialize-findings', 'qualify-checkpoint', 'checkpoint', 'package'])
|
|
127
|
+
});
|
|
128
|
+
status = task === 'inspect' ? 'ready' : 'unknown-task';
|
|
129
|
+
nextAction = Object.freeze({ operation: task === 'inspect' ? 'inspect' : 'discover-tooling' });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const summary = summarizePortableFindings(findings);
|
|
133
|
+
if (summary.counts.error && status !== 'provider-action-required') status = 'blocked';
|
|
134
|
+
return Object.freeze({
|
|
135
|
+
schema: PORTABLE_TASK_PREPARATION_SCHEMA_ID,
|
|
136
|
+
task,
|
|
137
|
+
status,
|
|
138
|
+
route,
|
|
139
|
+
host: hostDiscovery.profile,
|
|
140
|
+
result,
|
|
141
|
+
nextAction,
|
|
142
|
+
boundary: Object.freeze({
|
|
143
|
+
remoteFetch: 'host-mediated-only',
|
|
144
|
+
remoteWrite: false,
|
|
145
|
+
sourceMutation: false,
|
|
146
|
+
hiddenChatStateIsProvenance: false
|
|
147
|
+
}),
|
|
148
|
+
findings: Object.freeze(findings),
|
|
149
|
+
findingSummary: summary
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function normalizeTask(value = '') {
|
|
154
|
+
const task = String(value || '').trim().toLowerCase().replace(/[_\s]+/g, '-');
|
|
155
|
+
const aliases = {
|
|
156
|
+
create: 'create-artifact',
|
|
157
|
+
write: 'create-artifact',
|
|
158
|
+
'create-draft': 'create-artifact',
|
|
159
|
+
schema: 'read-schema',
|
|
160
|
+
'resolve-schema': 'read-schema',
|
|
161
|
+
validate: 'validate-draft',
|
|
162
|
+
repair: 'validate-draft',
|
|
163
|
+
search: 'search-lineage',
|
|
164
|
+
lineage: 'search-lineage',
|
|
165
|
+
image: 'analyze-asset',
|
|
166
|
+
asset: 'analyze-asset',
|
|
167
|
+
'analyze-image': 'analyze-asset',
|
|
168
|
+
materialize: 'materialize-findings',
|
|
169
|
+
'materialize-durable-findings': 'materialize-findings',
|
|
170
|
+
qualify: 'qualify-checkpoint',
|
|
171
|
+
verify: 'qualify-checkpoint',
|
|
172
|
+
'verify-checkpoint': 'qualify-checkpoint',
|
|
173
|
+
checkpoint: 'checkpoint',
|
|
174
|
+
package: 'package',
|
|
175
|
+
'build-package': 'package'
|
|
176
|
+
};
|
|
177
|
+
return aliases[task] || task || 'inspect';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function routeTask(task) {
|
|
181
|
+
if (task === 'read-schema') return 'resolve-unknown-schema';
|
|
182
|
+
if (task === 'create-artifact') return 'create-local-draft';
|
|
183
|
+
if (task === 'validate-draft') return 'create-local-draft';
|
|
184
|
+
if (task === 'search-lineage') return 'search-lineage';
|
|
185
|
+
if (task === 'analyze-asset') return 'analyze-image-asset';
|
|
186
|
+
if (task === 'materialize-findings') return 'materialize-durable-findings';
|
|
187
|
+
if (task === 'qualify-checkpoint') return 'qualify-checkpoint';
|
|
188
|
+
if (task === 'checkpoint') return 'create-checkpoint';
|
|
189
|
+
if (task === 'package') return 'build-runtime-package';
|
|
190
|
+
return 'load-material';
|
|
191
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createDeterministicStoredZip, safeZipPath } from './deterministic.zip.js';
|
|
6
|
+
|
|
7
|
+
export const PORTABLE_ARTIFACT_RESULT_PACKAGE_SCHEMA_ID = 'tiinex.portable.artifact-result-package.v1';
|
|
8
|
+
export const PORTABLE_ARTIFACT_CREATION_RECEIPT_SCHEMA_ID = 'tiinex.portable.artifact-creation-receipt.v1';
|
|
9
|
+
export const PORTABLE_ARTIFACT_INPUT_SNAPSHOT_SCHEMA_ID = 'tiinex.portable.artifact-input-snapshot.v1';
|
|
10
|
+
export const PORTABLE_ARTIFACT_OPERATION_RECEIPT_SCHEMA_ID = 'tiinex.portable.artifact-operation-receipt.v1';
|
|
11
|
+
export const PORTABLE_ARTIFACT_RESULT_CHECKSUM_SCHEMA_ID = 'tiinex.portable.artifact-result-checksums.v1';
|
|
12
|
+
export const PORTABLE_ARTIFACT_RESULT_WRITE_RECEIPT_SCHEMA_ID = 'tiinex.portable.artifact-result-package-write-receipt.v1';
|
|
13
|
+
|
|
14
|
+
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const RESULT_VERIFIER_SOURCE = path.resolve(MODULE_DIR, '../bootstrap/artifact.result.selfverify.mjs');
|
|
16
|
+
|
|
17
|
+
export async function writePortableArtifactResultPackage(result = {}, outputPath = '', context = {}) {
|
|
18
|
+
const target = path.resolve(String(outputPath || '').trim());
|
|
19
|
+
if (!String(outputPath || '').trim()) throw new Error('portable.artifact-result.path.required');
|
|
20
|
+
assertCleanCreation(result, context.writeReceipt);
|
|
21
|
+
|
|
22
|
+
const createdAt = normalizeCreatedAt(context.createdAt);
|
|
23
|
+
const artifact = normalizeMarkdown(result.draft.markdown);
|
|
24
|
+
const artifactSha256 = sha256(artifact);
|
|
25
|
+
const inputSnapshot = buildInputSnapshot(context.creationInput || {}, createdAt);
|
|
26
|
+
const inputSnapshotBytes = stableJson(inputSnapshot);
|
|
27
|
+
const inputSnapshotSha256 = sha256(inputSnapshotBytes);
|
|
28
|
+
const operationReceipt = buildOperationReceipt(result, artifactSha256, createdAt);
|
|
29
|
+
const operationReceiptBytes = stableJson(operationReceipt);
|
|
30
|
+
const writeReceipt = cloneJson(context.writeReceipt);
|
|
31
|
+
const writeReceiptBytes = stableJson(writeReceipt);
|
|
32
|
+
const transferManifest = requireObject(context.transferManifest, 'portable.artifact-result.transfer-manifest.required');
|
|
33
|
+
const bootstrapManifest = requireObject(context.bootstrapManifest, 'portable.artifact-result.bootstrap-manifest.required');
|
|
34
|
+
const transferVerification = requireValidVerification(context.transferVerification, 'tiinex.llm.transfer.verification.v1', 'portable.artifact-result.transfer-verification');
|
|
35
|
+
const bootstrapVerification = requireValidVerification(context.bootstrapVerification, ['tiinex.bootstrap.verification.v2', 'tiinex.bootstrap.archive-verification.v2'], 'portable.artifact-result.bootstrap-verification');
|
|
36
|
+
const taskRequest = normalizeMarkdown(String(context.taskRequest || '').trim());
|
|
37
|
+
if (!String(context.taskRequest || '').trim()) throw new Error('portable.artifact-result.task-request.required');
|
|
38
|
+
const transferManifestBytes = stableJson(transferManifest);
|
|
39
|
+
const bootstrapManifestBytes = stableJson(bootstrapManifest);
|
|
40
|
+
const transferVerificationBytes = exactJsonBytes(context.transferVerificationBytes, transferVerification, 'portable.artifact-result.transfer-verification-bytes');
|
|
41
|
+
const bootstrapVerificationBytes = exactJsonBytes(context.bootstrapVerificationBytes, bootstrapVerification, 'portable.artifact-result.bootstrap-verification-bytes');
|
|
42
|
+
const identities = qualifyContextIdentities({ transferManifest, bootstrapManifest, transferVerification, bootstrapVerification, transferVerificationBytes, bootstrapVerificationBytes, taskRequest });
|
|
43
|
+
|
|
44
|
+
const creationReceipt = Object.freeze({
|
|
45
|
+
schema: PORTABLE_ARTIFACT_CREATION_RECEIPT_SCHEMA_ID,
|
|
46
|
+
version: 1,
|
|
47
|
+
status: 'packaged-local-clean',
|
|
48
|
+
createdAt,
|
|
49
|
+
operation: 'create-local-draft',
|
|
50
|
+
artifact: Object.freeze({
|
|
51
|
+
packagePath: 'artifact.trace.md',
|
|
52
|
+
logicalPath: String(result.draft.path || ''),
|
|
53
|
+
schemaId: String(result.draft.schemaId || result.schemaId || ''),
|
|
54
|
+
bytes: Buffer.byteLength(artifact, 'utf8'),
|
|
55
|
+
sha256: artifactSha256,
|
|
56
|
+
validationStatus: String(result.validation?.status || '')
|
|
57
|
+
}),
|
|
58
|
+
inputSnapshot: Object.freeze({
|
|
59
|
+
packagePath: 'artifact.input.snapshot.json',
|
|
60
|
+
sha256: inputSnapshotSha256
|
|
61
|
+
}),
|
|
62
|
+
operationReceipt: Object.freeze({
|
|
63
|
+
packagePath: 'artifact.operation.receipt.json',
|
|
64
|
+
sha256: sha256(operationReceiptBytes),
|
|
65
|
+
status: operationReceipt.status
|
|
66
|
+
}),
|
|
67
|
+
writeReceipt: Object.freeze({
|
|
68
|
+
packagePath: 'artifact.write.receipt.json',
|
|
69
|
+
sha256: sha256(writeReceiptBytes),
|
|
70
|
+
status: String(writeReceipt.status || '')
|
|
71
|
+
}),
|
|
72
|
+
context: identities,
|
|
73
|
+
boundary: Object.freeze({
|
|
74
|
+
localDraft: true,
|
|
75
|
+
sourceBacked: false,
|
|
76
|
+
sourceMutation: false,
|
|
77
|
+
remoteWrite: false,
|
|
78
|
+
publication: false,
|
|
79
|
+
handoffAuthority: false
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
const creationReceiptBytes = stableJson(creationReceipt);
|
|
83
|
+
const verifier = await readFile(RESULT_VERIFIER_SOURCE);
|
|
84
|
+
|
|
85
|
+
const manifest = Object.freeze({
|
|
86
|
+
schema: PORTABLE_ARTIFACT_RESULT_PACKAGE_SCHEMA_ID,
|
|
87
|
+
version: 1,
|
|
88
|
+
boundary: 'Local Tiinex artifact plus durable creation evidence. This package is not publication, source authority, or a handoff claim.',
|
|
89
|
+
entrypoints: Object.freeze({
|
|
90
|
+
artifact: 'artifact.trace.md',
|
|
91
|
+
creationReceipt: 'artifact.creation.receipt.json',
|
|
92
|
+
inputSnapshot: 'artifact.input.snapshot.json',
|
|
93
|
+
operationReceipt: 'artifact.operation.receipt.json',
|
|
94
|
+
writeReceipt: 'artifact.write.receipt.json',
|
|
95
|
+
verifier: 'bin/verify-result.mjs',
|
|
96
|
+
checksums: 'checksums.json'
|
|
97
|
+
}),
|
|
98
|
+
artifact: creationReceipt.artifact,
|
|
99
|
+
evidence: Object.freeze({
|
|
100
|
+
creationReceipt: Object.freeze({ path: 'artifact.creation.receipt.json', sha256: sha256(creationReceiptBytes) }),
|
|
101
|
+
inputSnapshot: creationReceipt.inputSnapshot,
|
|
102
|
+
operationReceipt: creationReceipt.operationReceipt,
|
|
103
|
+
writeReceipt: creationReceipt.writeReceipt,
|
|
104
|
+
taskRequest: Object.freeze({ path: 'context/task.request.txt', sha256: sha256(taskRequest) }),
|
|
105
|
+
transferManifest: Object.freeze({ path: 'context/transfer.manifest.json', sha256: sha256(transferManifestBytes) }),
|
|
106
|
+
bootstrapManifest: Object.freeze({ path: 'context/bootstrap.manifest.json', sha256: sha256(bootstrapManifestBytes) }),
|
|
107
|
+
transferVerification: Object.freeze({ path: 'verification/transfer.json', sha256: sha256(transferVerificationBytes), status: transferVerification.status }),
|
|
108
|
+
bootstrapVerification: Object.freeze({ path: 'verification/bootstrap.json', sha256: sha256(bootstrapVerificationBytes), status: bootstrapVerification.status })
|
|
109
|
+
}),
|
|
110
|
+
context: identities,
|
|
111
|
+
trust: Object.freeze({
|
|
112
|
+
artifactCodeExecution: 'never-auto-execute',
|
|
113
|
+
verifierExecution: 'allowed',
|
|
114
|
+
sourceMutation: false,
|
|
115
|
+
remoteWrite: false
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const baseEntries = [
|
|
120
|
+
fileEntry('artifact.trace.md', artifact),
|
|
121
|
+
fileEntry('artifact.creation.receipt.json', creationReceiptBytes),
|
|
122
|
+
fileEntry('artifact.input.snapshot.json', inputSnapshotBytes),
|
|
123
|
+
fileEntry('artifact.operation.receipt.json', operationReceiptBytes),
|
|
124
|
+
fileEntry('artifact.write.receipt.json', writeReceiptBytes),
|
|
125
|
+
fileEntry('context/task.request.txt', taskRequest),
|
|
126
|
+
fileEntry('context/transfer.manifest.json', transferManifestBytes),
|
|
127
|
+
fileEntry('context/bootstrap.manifest.json', bootstrapManifestBytes),
|
|
128
|
+
fileEntry('verification/transfer.json', transferVerificationBytes),
|
|
129
|
+
fileEntry('verification/bootstrap.json', bootstrapVerificationBytes),
|
|
130
|
+
fileEntry('manifest.json', stableJson(manifest)),
|
|
131
|
+
fileEntry('bin/verify-result.mjs', verifier)
|
|
132
|
+
].sort((a, b) => a.path.localeCompare(b.path));
|
|
133
|
+
const checksums = Object.freeze({
|
|
134
|
+
schema: PORTABLE_ARTIFACT_RESULT_CHECKSUM_SCHEMA_ID,
|
|
135
|
+
version: 1,
|
|
136
|
+
algorithm: 'sha256',
|
|
137
|
+
files: Object.freeze(baseEntries.map(({ path: filePath, bytes, sha256: digest }) => Object.freeze({ path: filePath, bytes, sha256: digest })))
|
|
138
|
+
});
|
|
139
|
+
const entries = [...baseEntries, fileEntry('checksums.json', stableJson(checksums))].sort((a, b) => a.path.localeCompare(b.path));
|
|
140
|
+
const archive = createDeterministicStoredZip(entries.map((entry) => ({ name: entry.path, data: entry.content })));
|
|
141
|
+
|
|
142
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
143
|
+
await writeFile(target, archive, { flag: context.overwrite === true ? 'w' : 'wx' });
|
|
144
|
+
return Object.freeze({
|
|
145
|
+
schema: PORTABLE_ARTIFACT_RESULT_WRITE_RECEIPT_SCHEMA_ID,
|
|
146
|
+
version: 1,
|
|
147
|
+
status: 'written-local-result-package',
|
|
148
|
+
outputPath: target,
|
|
149
|
+
bytes: archive.length,
|
|
150
|
+
sha256: sha256(archive),
|
|
151
|
+
artifactSha256,
|
|
152
|
+
inputSnapshotSha256,
|
|
153
|
+
createdAt,
|
|
154
|
+
files: entries.length,
|
|
155
|
+
boundary: Object.freeze({
|
|
156
|
+
localOutput: true,
|
|
157
|
+
sourceMutation: false,
|
|
158
|
+
remoteWrite: false,
|
|
159
|
+
overwrite: context.overwrite === true
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function assertCleanCreation(result, writeReceipt) {
|
|
165
|
+
if (result?.status !== 'created-clean') throw new Error(`portable.artifact-result.not-clean:${result?.status || 'unknown'}`);
|
|
166
|
+
if (result?.validation?.status !== 'clean') throw new Error(`portable.artifact-result.validation-not-clean:${result?.validation?.status || 'unknown'}`);
|
|
167
|
+
if (!result?.draft?.markdown) throw new Error('portable.artifact-result.markdown.required');
|
|
168
|
+
if (!String(result.draft.sourceMode || '').startsWith('local-') || result.draft.source) throw new Error('portable.artifact-result.source-boundary.invalid');
|
|
169
|
+
if (!writeReceipt || writeReceipt.status !== 'written-local-clean') throw new Error(`portable.artifact-result.write-receipt.invalid:${writeReceipt?.status || 'missing'}`);
|
|
170
|
+
if (writeReceipt.sha256 !== sha256(normalizeMarkdown(result.draft.markdown))) throw new Error('portable.artifact-result.write-receipt.sha256-mismatch');
|
|
171
|
+
if (writeReceipt.validationStatus !== 'clean') throw new Error('portable.artifact-result.write-receipt.validation-not-clean');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function buildInputSnapshot(input = {}, createdAt = '') {
|
|
175
|
+
return Object.freeze({
|
|
176
|
+
schema: PORTABLE_ARTIFACT_INPUT_SNAPSHOT_SCHEMA_ID,
|
|
177
|
+
version: 1,
|
|
178
|
+
capturedAt: createdAt,
|
|
179
|
+
operation: 'create-local-draft',
|
|
180
|
+
request: Object.freeze({
|
|
181
|
+
schemaId: String(input.schemaId || ''),
|
|
182
|
+
path: String(input.path || ''),
|
|
183
|
+
title: String(input.title || ''),
|
|
184
|
+
summary: String(input.summary || ''),
|
|
185
|
+
why: String(input.why || ''),
|
|
186
|
+
values: cloneJson(input.values || {}),
|
|
187
|
+
sections: cloneJson(input.sections || {}),
|
|
188
|
+
parent: boundedParent(input.parent),
|
|
189
|
+
allowIncomplete: Boolean(input.allowIncomplete)
|
|
190
|
+
}),
|
|
191
|
+
boundary: Object.freeze({
|
|
192
|
+
dialogueOrHostInput: true,
|
|
193
|
+
sourceMutation: false,
|
|
194
|
+
remoteWrite: false,
|
|
195
|
+
omittedLoadedSchemaMaterial: true
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function buildOperationReceipt(result = {}, artifactSha256 = '', createdAt = '') {
|
|
201
|
+
return Object.freeze({
|
|
202
|
+
schema: PORTABLE_ARTIFACT_OPERATION_RECEIPT_SCHEMA_ID,
|
|
203
|
+
version: 1,
|
|
204
|
+
recordedAt: createdAt,
|
|
205
|
+
operation: String(result.operation || 'create-local-draft'),
|
|
206
|
+
status: String(result.status || ''),
|
|
207
|
+
schemaId: String(result.schemaId || result.draft?.schemaId || ''),
|
|
208
|
+
artifact: Object.freeze({
|
|
209
|
+
logicalPath: String(result.draft?.path || ''),
|
|
210
|
+
sha256: artifactSha256,
|
|
211
|
+
sourceMode: String(result.draft?.sourceMode || '')
|
|
212
|
+
}),
|
|
213
|
+
validation: cloneJson(result.validation || null),
|
|
214
|
+
qualification: cloneJson(result.qualification || null),
|
|
215
|
+
findingSummary: cloneJson(result.findingSummary || null),
|
|
216
|
+
findings: cloneJson(result.findings || [])
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function qualifyContextIdentities({ transferManifest, bootstrapManifest, transferVerification, bootstrapVerification, transferVerificationBytes, bootstrapVerificationBytes, taskRequest }) {
|
|
221
|
+
if (transferManifest.schema !== 'tiinex.llm.transfer.package.v1') throw new Error('portable.artifact-result.transfer-manifest.schema');
|
|
222
|
+
if (bootstrapManifest.schema !== 'tiinex.bootstrap.package.v1') throw new Error('portable.artifact-result.bootstrap-manifest.schema');
|
|
223
|
+
const expected = transferManifest.expectedBootstrap || {};
|
|
224
|
+
if (expected.bootstrapVersion !== bootstrapManifest.bootstrapVersion) throw new Error('portable.artifact-result.bootstrap-version-mismatch');
|
|
225
|
+
if (expected.sourceIdentity?.runtimeFingerprint !== bootstrapManifest.sourceIdentity?.runtimeFingerprint) throw new Error('portable.artifact-result.bootstrap-runtime-mismatch');
|
|
226
|
+
if (expected.canonicalMaterial?.ref !== bootstrapManifest.canonicalMaterial?.ref || expected.canonicalMaterial?.schemaPackFingerprint !== bootstrapManifest.canonicalMaterial?.schemaPackFingerprint) throw new Error('portable.artifact-result.bootstrap-canonical-mismatch');
|
|
227
|
+
if (transferVerification.transferVersion !== transferManifest.transferVersion) throw new Error('portable.artifact-result.transfer-verification-version-mismatch');
|
|
228
|
+
const verifiedBootstrapVersion = String(bootstrapVerification.packageVersion || bootstrapVerification.bootstrapVersion || '');
|
|
229
|
+
if (verifiedBootstrapVersion !== bootstrapManifest.bootstrapVersion) throw new Error('portable.artifact-result.bootstrap-verification-version-mismatch');
|
|
230
|
+
return Object.freeze({
|
|
231
|
+
task: Object.freeze({
|
|
232
|
+
packagePath: 'context/task.request.txt',
|
|
233
|
+
sha256: sha256(taskRequest)
|
|
234
|
+
}),
|
|
235
|
+
transfer: Object.freeze({
|
|
236
|
+
manifestSha256: sha256(stableJson(transferManifest)),
|
|
237
|
+
verificationSha256: sha256(transferVerificationBytes),
|
|
238
|
+
transferVersion: String(transferManifest.transferVersion || ''),
|
|
239
|
+
profileId: String(transferManifest.profile?.id || ''),
|
|
240
|
+
verificationStatus: transferVerification.status
|
|
241
|
+
}),
|
|
242
|
+
bootstrap: Object.freeze({
|
|
243
|
+
manifestSha256: sha256(stableJson(bootstrapManifest)),
|
|
244
|
+
verificationSha256: sha256(bootstrapVerificationBytes),
|
|
245
|
+
bootstrapVersion: String(bootstrapManifest.bootstrapVersion || ''),
|
|
246
|
+
sourceIdentity: cloneJson(bootstrapManifest.sourceIdentity || {}),
|
|
247
|
+
canonicalMaterial: Object.freeze({
|
|
248
|
+
repository: String(bootstrapManifest.canonicalMaterial?.repository || ''),
|
|
249
|
+
ref: String(bootstrapManifest.canonicalMaterial?.ref || ''),
|
|
250
|
+
schemaPackFingerprint: String(bootstrapManifest.canonicalMaterial?.schemaPackFingerprint || '')
|
|
251
|
+
}),
|
|
252
|
+
verificationStatus: bootstrapVerification.status
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function exactJsonBytes(raw, parsed, code) {
|
|
258
|
+
if (raw == null) return stableJson(parsed);
|
|
259
|
+
const bytes = Buffer.from(raw);
|
|
260
|
+
let value;
|
|
261
|
+
try { value = JSON.parse(bytes.toString('utf8')); }
|
|
262
|
+
catch { throw new Error(`${code}.json`); }
|
|
263
|
+
if (JSON.stringify(sortValue(value)) !== JSON.stringify(sortValue(parsed))) throw new Error(`${code}.mismatch`);
|
|
264
|
+
return bytes;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function requireValidVerification(value, schema, code) {
|
|
268
|
+
const verification = requireObject(value, `${code}.required`);
|
|
269
|
+
const allowed = Array.isArray(schema) ? schema : [schema];
|
|
270
|
+
if (!allowed.includes(verification.schema)) throw new Error(`${code}.schema`);
|
|
271
|
+
if (verification.status !== 'valid') throw new Error(`${code}.invalid:${verification.status || 'unknown'}`);
|
|
272
|
+
return cloneJson(verification);
|
|
273
|
+
}
|
|
274
|
+
function requireObject(value, code) {
|
|
275
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error(code);
|
|
276
|
+
return cloneJson(value);
|
|
277
|
+
}
|
|
278
|
+
function boundedParent(value) {
|
|
279
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
|
|
280
|
+
const parent = {};
|
|
281
|
+
for (const key of ['id', 'path', 'schemaId', 'parentSchemaId', 'trace', 'origin', 'boundary', 'sourceMode', 'title', 'summary']) {
|
|
282
|
+
if (value[key] !== undefined && value[key] !== null && value[key] !== '') parent[key] = value[key];
|
|
283
|
+
}
|
|
284
|
+
return Object.keys(parent).length ? Object.freeze(parent) : null;
|
|
285
|
+
}
|
|
286
|
+
function normalizeCreatedAt(value) {
|
|
287
|
+
const candidate = String(value || '').trim() || new Date().toISOString();
|
|
288
|
+
const parsed = new Date(candidate);
|
|
289
|
+
if (!Number.isFinite(parsed.getTime())) throw new Error(`portable.artifact-result.created-at.invalid:${candidate}`);
|
|
290
|
+
return parsed.toISOString();
|
|
291
|
+
}
|
|
292
|
+
function fileEntry(filePath, value) {
|
|
293
|
+
const clean = safeZipPath(filePath);
|
|
294
|
+
if (!clean || clean !== filePath) throw new Error(`portable.artifact-result.path.unsafe:${filePath}`);
|
|
295
|
+
const content = Buffer.isBuffer(value) ? Buffer.from(value) : Buffer.from(String(value ?? ''), 'utf8');
|
|
296
|
+
return Object.freeze({ path: clean, content, bytes: content.length, sha256: sha256(content) });
|
|
297
|
+
}
|
|
298
|
+
function normalizeMarkdown(value = '') { return `${String(value || '').replace(/\r\n/g, '\n').replace(/\s+$/u, '')}\n`; }
|
|
299
|
+
function stableJson(value) { return `${JSON.stringify(sortValue(value), null, 2)}\n`; }
|
|
300
|
+
function sortValue(value) {
|
|
301
|
+
if (Array.isArray(value)) return value.map(sortValue);
|
|
302
|
+
if (!value || typeof value !== 'object') return value;
|
|
303
|
+
const output = {};
|
|
304
|
+
for (const key of Object.keys(value).sort()) output[key] = sortValue(value[key]);
|
|
305
|
+
return output;
|
|
306
|
+
}
|
|
307
|
+
function cloneJson(value) { return value === undefined ? null : JSON.parse(JSON.stringify(value)); }
|
|
308
|
+
function sha256(value) { return createHash('sha256').update(value).digest('hex'); }
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { crc32 as nativeCrc32 } from 'node:zlib';
|
|
2
|
+
|
|
3
|
+
export function createDeterministicStoredZip(entries = []) {
|
|
4
|
+
const normalized = entries
|
|
5
|
+
.map((entry) => ({ name: safeZipPath(entry?.name || ''), data: bytesFrom(entry?.data) }))
|
|
6
|
+
.filter((entry) => entry.name)
|
|
7
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
8
|
+
const duplicate = normalized.find((entry, index) => index > 0 && entry.name === normalized[index - 1].name);
|
|
9
|
+
if (duplicate) throw new Error(`portable.zip.path.duplicate:${duplicate.name}`);
|
|
10
|
+
|
|
11
|
+
const localParts = [];
|
|
12
|
+
const centralParts = [];
|
|
13
|
+
let offset = 0;
|
|
14
|
+
for (const entry of normalized) {
|
|
15
|
+
const name = Buffer.from(entry.name, 'utf8');
|
|
16
|
+
const data = Buffer.isBuffer(entry.data) ? entry.data : entry.data instanceof Uint8Array ? Buffer.from(entry.data.buffer, entry.data.byteOffset, entry.data.byteLength) : Buffer.from(entry.data);
|
|
17
|
+
const crc = crc32(data);
|
|
18
|
+
const local = Buffer.alloc(30 + name.length);
|
|
19
|
+
local.writeUInt32LE(0x04034b50, 0);
|
|
20
|
+
local.writeUInt16LE(20, 4);
|
|
21
|
+
local.writeUInt16LE(0x0800, 6);
|
|
22
|
+
local.writeUInt16LE(0, 8);
|
|
23
|
+
local.writeUInt16LE(0, 10);
|
|
24
|
+
local.writeUInt16LE(0x0021, 12); // 1980-01-01 for deterministic archives.
|
|
25
|
+
local.writeUInt32LE(crc, 14);
|
|
26
|
+
local.writeUInt32LE(data.length, 18);
|
|
27
|
+
local.writeUInt32LE(data.length, 22);
|
|
28
|
+
local.writeUInt16LE(name.length, 26);
|
|
29
|
+
local.writeUInt16LE(0, 28);
|
|
30
|
+
name.copy(local, 30);
|
|
31
|
+
localParts.push(local, data);
|
|
32
|
+
|
|
33
|
+
const central = Buffer.alloc(46 + name.length);
|
|
34
|
+
central.writeUInt32LE(0x02014b50, 0);
|
|
35
|
+
central.writeUInt16LE(20, 4);
|
|
36
|
+
central.writeUInt16LE(20, 6);
|
|
37
|
+
central.writeUInt16LE(0x0800, 8);
|
|
38
|
+
central.writeUInt16LE(0, 10);
|
|
39
|
+
central.writeUInt16LE(0, 12);
|
|
40
|
+
central.writeUInt16LE(0x0021, 14);
|
|
41
|
+
central.writeUInt32LE(crc, 16);
|
|
42
|
+
central.writeUInt32LE(data.length, 20);
|
|
43
|
+
central.writeUInt32LE(data.length, 24);
|
|
44
|
+
central.writeUInt16LE(name.length, 28);
|
|
45
|
+
central.writeUInt16LE(0, 30);
|
|
46
|
+
central.writeUInt16LE(0, 32);
|
|
47
|
+
central.writeUInt16LE(0, 34);
|
|
48
|
+
central.writeUInt16LE(0, 36);
|
|
49
|
+
central.writeUInt32LE(0, 38);
|
|
50
|
+
central.writeUInt32LE(offset, 42);
|
|
51
|
+
name.copy(central, 46);
|
|
52
|
+
centralParts.push(central);
|
|
53
|
+
offset += local.length + data.length;
|
|
54
|
+
}
|
|
55
|
+
const centralDirectory = Buffer.concat(centralParts);
|
|
56
|
+
const end = Buffer.alloc(22);
|
|
57
|
+
end.writeUInt32LE(0x06054b50, 0);
|
|
58
|
+
end.writeUInt16LE(0, 4);
|
|
59
|
+
end.writeUInt16LE(0, 6);
|
|
60
|
+
end.writeUInt16LE(normalized.length, 8);
|
|
61
|
+
end.writeUInt16LE(normalized.length, 10);
|
|
62
|
+
end.writeUInt32LE(centralDirectory.length, 12);
|
|
63
|
+
end.writeUInt32LE(offset, 16);
|
|
64
|
+
end.writeUInt16LE(0, 20);
|
|
65
|
+
return Buffer.concat([...localParts, centralDirectory, end]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function safeZipPath(value = '') {
|
|
69
|
+
const input = String(value || '').replace(/\\/g, '/').replace(/^\/+/, '');
|
|
70
|
+
const parts = [];
|
|
71
|
+
for (const part of input.split('/')) {
|
|
72
|
+
if (!part || part === '.') continue;
|
|
73
|
+
if (part === '..') return '';
|
|
74
|
+
parts.push(part.replace(/[\u0000-\u001f<>:"|?*]/g, '_'));
|
|
75
|
+
}
|
|
76
|
+
return parts.join('/');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function bytesFrom(value) {
|
|
80
|
+
if (Buffer.isBuffer(value)) return value;
|
|
81
|
+
if (value instanceof Uint8Array) return value;
|
|
82
|
+
if (value instanceof ArrayBuffer) return new Uint8Array(value);
|
|
83
|
+
return Buffer.from(String(value ?? ''), 'utf8');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function crc32(buffer) {
|
|
87
|
+
return nativeCrc32(buffer) >>> 0;
|
|
88
|
+
}
|