@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,389 @@
|
|
|
1
|
+
import { buildArtifactCreationContract } from '../../../schemas/creation.contracts.js';
|
|
2
|
+
import { portableFinding, summarizePortableFindings } from '../findings.js';
|
|
3
|
+
import { findSchemaMaterial } from '../input/portable.input.js';
|
|
4
|
+
import { buildPortableSchemaGuide, planPortableArtifact } from '../schema/schema.guide.js';
|
|
5
|
+
import { parsePortableSchemaDocument } from '../schema/schema.contract.js';
|
|
6
|
+
import { validatePortableDraft } from './draft.operations.js';
|
|
7
|
+
import { normalizePortableParentRecord, qualifyPortableExactParent, renderPortableLocalContinuityDraft, renderQualifiedPortableExactDraft } from './draft.exact.js';
|
|
8
|
+
import { buildPortableCreationQualification, portableParentRecordHasAnyValue, portableParentRecordIsComplete } from './draft.qualification.js';
|
|
9
|
+
import { creationSchemaReferenceValidationContext } from './draft.validation-context.js';
|
|
10
|
+
export const PORTABLE_DRAFT_CREATION_SCHEMA_ID = 'tiinex.portable.draft-creation.v1';
|
|
11
|
+
export const PORTABLE_STAGED_ARTIFACT_SCHEMA_ID = 'tiinex.portable.staged-artifact.v1';
|
|
12
|
+
export function createPortableLocalDraft(input = {}, options = {}) {
|
|
13
|
+
const schemaId = String(input.schemaId || options.schemaId || '').trim();
|
|
14
|
+
const allowIncomplete = input.allowIncomplete === true || options.allowIncomplete === true;
|
|
15
|
+
const values = normalizeValues(input.values || input.inputs || {});
|
|
16
|
+
const planResult = planPortableArtifact({ ...input, schemaId, values }, options);
|
|
17
|
+
const guideResult = buildPortableSchemaGuide({ ...input, schemaId, task: 'create', detail: input.detail || options.detail || 'standard' }, options);
|
|
18
|
+
const findings = [...(planResult.findings || []), ...(guideResult.findings || [])];
|
|
19
|
+
const schemaMaterial = findSchemaMaterial(schemaId, input.materials || input);
|
|
20
|
+
const document = schemaMaterial?.markdown ? parsePortableSchemaDocument(schemaMaterial.markdown) : null;
|
|
21
|
+
const transitionType = String(input.transitionType || options.transitionType || 'create-artifact').trim() || 'create-artifact';
|
|
22
|
+
const exactContract = buildArtifactCreationContract({ schemaId, transitionType, schemaReferences: input.schemaReferences || null });
|
|
23
|
+
const parentRecord = normalizePortableParentRecord(input.parentRecord || input.parent || {});
|
|
24
|
+
const hasDeclaredParent = portableParentRecordHasAnyValue(parentRecord);
|
|
25
|
+
const hasCompleteParent = portableParentRecordIsComplete(parentRecord);
|
|
26
|
+
const exactParentQualification = qualifyPortableExactParent(parentRecord, transitionType);
|
|
27
|
+
const localContinuityParentCompatible = exactParentQualification.state === 'qualified-local-continuity';
|
|
28
|
+
const parentRenderable = exactParentQualification.state === 'qualified' || localContinuityParentCompatible;
|
|
29
|
+
const qualifiedParentRecord = parentRenderable ? exactParentQualification.snapshot : null;
|
|
30
|
+
const genericParentRecord = transitionType === 'create-artifact' ? parentRecord : qualifiedParentRecord;
|
|
31
|
+
const exactRendererParentCompatible = exactParentQualification.state === 'qualified';
|
|
32
|
+
const exactRendererEligible = exactContract.status === 'ready' && exactRendererParentCompatible;
|
|
33
|
+
const localContinuityRendererEligible = exactContract.status === 'ready' && localContinuityParentCompatible;
|
|
34
|
+
if (!schemaId) findings.push(portableFinding('error', 'portable.draft-create.schema.required', 'Local draft creation requires a target schema id.'));
|
|
35
|
+
if (hasDeclaredParent && !hasCompleteParent) findings.push(portableFinding('error', 'portable.draft-create.parent.incomplete', 'A declared Parent must provide explicit Parent Schema authority, Trace (or an explicit parent id), and a recoverable Origin path. A kind label is not Parent Schema authority.', {
|
|
36
|
+
hasParentSchema: Boolean(parentRecord.schemaId || parentRecord.currentSchemaId),
|
|
37
|
+
hasTrace: Boolean(parentRecord.continuationTrace || parentRecord.id),
|
|
38
|
+
hasOrigin: Boolean(parentRecord.path)
|
|
39
|
+
}));
|
|
40
|
+
if ((exactContract.status === 'ready' || (hasDeclaredParent && transitionType !== 'create-artifact')) && !parentRenderable) findings.push(portableFinding('error', `portable.draft-create.parent.${exactParentQualification.reason || 'unqualified'}`, 'Creation requires one coherent Parent identity for the requested continuity mode; portable tooling will not rewrite or synthesize Parent authority.', exactParentQualification.evidence || {}));
|
|
41
|
+
if (localContinuityParentCompatible) {
|
|
42
|
+
const reason = exactParentQualification.reason || 'continuation-parent-exact-authority-unresolved';
|
|
43
|
+
const browseConflict = reason === 'continuation-parent-browse-git-root-contract-conflict';
|
|
44
|
+
findings.push(portableFinding('warning', browseConflict ? 'portable.draft-create.parent.root-browse-git-authority-conflict' : `portable.draft-create.parent.${reason}`, browseConflict
|
|
45
|
+
? 'The Parent is a coherent unpublished local artifact. Portable tooling will preserve relative Trace/Origin continuity without inventing browse + git authority, but current Root exact qualification remains unavailable because Parent Origin currently requires browse + git.'
|
|
46
|
+
: 'The Parent is coherent enough for local relative continuity, but one exact Parent authority dimension remains unresolved. Portable tooling preserves the supplied representation/evidence without upgrading it to exact qualification.', exactParentQualification.evidence || {}));
|
|
47
|
+
}
|
|
48
|
+
if (!schemaMaterial && exactContract.status !== 'ready') findings.push(portableFinding('error', 'portable.draft-create.schema-material.required', 'Readable child schema material or exact creation tooling is required; schema meaning will not be guessed.', { schemaId }));
|
|
49
|
+
if (planResult.plan.missingInputs.length && !allowIncomplete) {
|
|
50
|
+
findings.push(portableFinding('error', 'portable.draft-create.inputs.blocked', 'Draft creation is blocked until required authoring inputs are supplied or allowIncomplete is explicitly enabled.', {
|
|
51
|
+
schemaId,
|
|
52
|
+
missingInputs: planResult.plan.missingInputs
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
if (findings.some((finding) => finding.severity === 'error')) {
|
|
56
|
+
const summary = summarizePortableFindings(findings);
|
|
57
|
+
return Object.freeze({
|
|
58
|
+
schema: PORTABLE_DRAFT_CREATION_SCHEMA_ID,
|
|
59
|
+
status: 'blocked',
|
|
60
|
+
schemaId,
|
|
61
|
+
draft: null,
|
|
62
|
+
plan: planResult.plan,
|
|
63
|
+
guide: guideResult.guide,
|
|
64
|
+
qualification: buildPortableCreationQualification({ schemaId, exactContract, exactRendererApplied: false, exactRendererParentCompatible, exactResultQualification: null, exactParentQualification, hasDeclaredParent, hasCompleteParent, schemaMaterial, validation: null, allowIncomplete, blocked: true }),
|
|
65
|
+
findings: Object.freeze(findings),
|
|
66
|
+
findingSummary: summary
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const path = normalizeDraftPath(input.path || `drafts/${slug(input.title || values.Title || values.title || values.Summary || values.summary || schemaLabel(schemaId))}.md`);
|
|
70
|
+
const title = cleanSingleLine(input.title || values.Title || values.title || values.Summary || values.summary || `${schemaLabel(schemaId)} Draft`, 120);
|
|
71
|
+
const summary = cleanSingleLine(input.summary || values.Summary || values.summary || title || `${schemaLabel(schemaId)} local draft.`, 360);
|
|
72
|
+
const createdAt = normalizeArtifactTimestamp(input.createdAt || options.createdAt || new Date());
|
|
73
|
+
const explicitBodyMarkdown = typeof input.bodyMarkdown === 'string' && input.bodyMarkdown.trim() ? input.bodyMarkdown.trim() : '';
|
|
74
|
+
const exactRendererInput = {
|
|
75
|
+
values,
|
|
76
|
+
createdAt,
|
|
77
|
+
status: input.currentStatus || 'draft/local',
|
|
78
|
+
...(Object.prototype.hasOwnProperty.call(input, 'why') ? { why: input.why } : {}),
|
|
79
|
+
...(Object.prototype.hasOwnProperty.call(input, 'authors') ? { authors: input.authors } : {}),
|
|
80
|
+
childPath: path,
|
|
81
|
+
...(Object.prototype.hasOwnProperty.call(input, 'title') ? { title: input.title } : {}),
|
|
82
|
+
...(Object.prototype.hasOwnProperty.call(input, 'summary') ? { summary: input.summary } : {}),
|
|
83
|
+
...(typeof input.bodyMarkdown === 'string' && input.bodyMarkdown.trim() ? { bodyMarkdown: input.bodyMarkdown } : {})
|
|
84
|
+
};
|
|
85
|
+
const exactResult = exactRendererEligible
|
|
86
|
+
? renderQualifiedPortableExactDraft({ contract: exactContract, schemaId, transitionType, parentSnapshot: exactParentQualification.snapshot, rendererInput: exactRendererInput })
|
|
87
|
+
: null;
|
|
88
|
+
const localContinuityResult = localContinuityRendererEligible
|
|
89
|
+
? renderPortableLocalContinuityDraft({ contract: exactContract, schemaId, transitionType, parentSnapshot: exactParentQualification.snapshot, rendererInput: exactRendererInput })
|
|
90
|
+
: null;
|
|
91
|
+
const exactRendererApplied = exactResult?.state === 'qualified';
|
|
92
|
+
const localApplied = localContinuityResult?.state === 'qualified-local-continuity';
|
|
93
|
+
if (exactRendererEligible && !exactRendererApplied) {
|
|
94
|
+
findings.push(portableFinding('error', 'portable.draft-create.exact-result.unqualified', 'Exact Site creation tooling did not produce a qualified concrete artifact; portable tooling will not claim exact creation or fall back to rewritten bytes.', { reason: exactResult?.reason || 'unknown' }));
|
|
95
|
+
const blockedSummary = summarizePortableFindings(findings);
|
|
96
|
+
return Object.freeze({
|
|
97
|
+
schema: PORTABLE_DRAFT_CREATION_SCHEMA_ID, status: 'blocked', schemaId, draft: null, plan: planResult.plan, guide: guideResult.guide,
|
|
98
|
+
qualification: buildPortableCreationQualification({ schemaId, exactContract, exactRendererApplied: false, exactRendererParentCompatible, exactResultQualification: exactResult, exactParentQualification, hasDeclaredParent, hasCompleteParent, schemaMaterial, validation: null, allowIncomplete, blocked: true }),
|
|
99
|
+
findings: Object.freeze(findings), findingSummary: blockedSummary
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (localContinuityRendererEligible && !localApplied) {
|
|
103
|
+
findings.push(portableFinding('error', 'portable.draft-create.local-continuity.unqualified', 'The local Parent could not be rendered with exact relative Trace/Origin continuity. Portable tooling will not fall back to legacy record tokens, scalar Origin, or fabricated publication authority.', { reason: localContinuityResult?.reason || 'unknown' }));
|
|
104
|
+
const blockedSummary = summarizePortableFindings(findings);
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
schema: PORTABLE_DRAFT_CREATION_SCHEMA_ID, status: 'blocked', schemaId, draft: null, plan: planResult.plan, guide: guideResult.guide,
|
|
107
|
+
qualification: buildPortableCreationQualification({ schemaId, exactContract, exactRendererApplied: false, localContinuityRendererApplied: false, exactRendererParentCompatible, localContinuityParentCompatible, exactResultQualification: localContinuityResult, exactParentQualification, hasDeclaredParent, hasCompleteParent, schemaMaterial, validation: null, allowIncomplete, blocked: true }),
|
|
108
|
+
findings: Object.freeze(findings), findingSummary: blockedSummary
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const bodyMarkdown = exactRendererApplied
|
|
112
|
+
? explicitBodyMarkdown
|
|
113
|
+
: localApplied
|
|
114
|
+
? explicitBodyMarkdown
|
|
115
|
+
: String(explicitBodyMarkdown || renderBody({
|
|
116
|
+
title,
|
|
117
|
+
plan: planResult.plan,
|
|
118
|
+
document,
|
|
119
|
+
values,
|
|
120
|
+
sections: input.sections || {},
|
|
121
|
+
allowIncomplete
|
|
122
|
+
})).trim();
|
|
123
|
+
const markdown = exactRendererApplied
|
|
124
|
+
? exactResult.markdown
|
|
125
|
+
: localApplied
|
|
126
|
+
? localContinuityResult.markdown
|
|
127
|
+
: renderGenericDraft({
|
|
128
|
+
schemaId,
|
|
129
|
+
title,
|
|
130
|
+
summary,
|
|
131
|
+
createdAt,
|
|
132
|
+
why: input.why,
|
|
133
|
+
currentStatus: input.currentStatus,
|
|
134
|
+
parentRecord: hasCompleteParent && genericParentRecord ? genericParentRecord : {},
|
|
135
|
+
bodyMarkdown
|
|
136
|
+
});
|
|
137
|
+
const draft = Object.freeze({
|
|
138
|
+
id: String(input.id || path),
|
|
139
|
+
path,
|
|
140
|
+
schemaId,
|
|
141
|
+
markdown,
|
|
142
|
+
status: 'local',
|
|
143
|
+
lifecycleStatus: 'draft',
|
|
144
|
+
sourceMode: 'local-portable-draft',
|
|
145
|
+
source: null,
|
|
146
|
+
creationMode: exactRendererApplied ? 'exact-site-creation-contract' : localApplied ? 'local-relative-continuity-authority-conflict' : hasCompleteParent ? 'readable-schema-llm-writer' : 'readable-schema-root-writer',
|
|
147
|
+
createdAt
|
|
148
|
+
});
|
|
149
|
+
const schemaReferenceAuthorities = creationSchemaReferenceValidationContext(exactContract, qualifiedParentRecord || parentRecord);
|
|
150
|
+
const validation = validatePortableDraft({ ...input, ...draft, schemaReferenceAuthorities, exactCreationValidation: exactResult?.validation || localContinuityResult?.validation || null, files: mergeSchemaFiles(input, schemaMaterial) }, options);
|
|
151
|
+
findings.push(...(validation.findings || []).filter((finding) => !findings.some((existing) => existing.code === finding.code && existing.message === finding.message)));
|
|
152
|
+
const status = exactRendererApplied && validation.status === 'clean'
|
|
153
|
+
? 'created-clean'
|
|
154
|
+
: localApplied
|
|
155
|
+
? 'created-local-continuity'
|
|
156
|
+
: validation.status === 'clean'
|
|
157
|
+
? 'created-clean'
|
|
158
|
+
: validation.status === 'degraded'
|
|
159
|
+
? 'created-degraded'
|
|
160
|
+
: allowIncomplete ? 'created-incomplete' : 'created-invalid';
|
|
161
|
+
const summaryResult = summarizePortableFindings(findings);
|
|
162
|
+
return Object.freeze({
|
|
163
|
+
schema: PORTABLE_DRAFT_CREATION_SCHEMA_ID,
|
|
164
|
+
status,
|
|
165
|
+
schemaId,
|
|
166
|
+
draft,
|
|
167
|
+
plan: planResult.plan,
|
|
168
|
+
guide: guideResult.guide,
|
|
169
|
+
validation,
|
|
170
|
+
qualification: buildPortableCreationQualification({ schemaId, exactContract, exactRendererApplied, localContinuityRendererApplied: localApplied, exactRendererParentCompatible, localContinuityParentCompatible, exactResultQualification: exactResult || localContinuityResult, exactParentQualification, hasDeclaredParent, hasCompleteParent, schemaMaterial, validation, allowIncomplete, blocked: false }),
|
|
171
|
+
findings: Object.freeze(findings),
|
|
172
|
+
findingSummary: summaryResult
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
export function stagePortableDraft(input = {}, options = {}) {
|
|
176
|
+
const draft = normalizeDraftInput(input.draft || input);
|
|
177
|
+
const allowInvalid = input.allowInvalid === true || options.allowInvalid === true;
|
|
178
|
+
const validation = input.validation?.schema === 'tiinex.portable.draft-validation.v1'
|
|
179
|
+
? input.validation
|
|
180
|
+
: validatePortableDraft({ ...input, ...draft }, options);
|
|
181
|
+
const findings = [...(validation.findings || [])];
|
|
182
|
+
if (!draft.markdown) findings.push(portableFinding('error', 'portable.stage-draft.markdown.required', 'Staging requires a local draft with Markdown content.'));
|
|
183
|
+
if (!String(draft.sourceMode || '').startsWith('local-')) findings.push(portableFinding('error', 'portable.stage-draft.source-mode.invalid', 'Only local draft material may be staged through portable tooling.', { sourceMode: draft.sourceMode }));
|
|
184
|
+
if (draft.source) findings.push(portableFinding('error', 'portable.stage-draft.source-object.blocked', 'A portable staged draft must not inherit a source adapter object.'));
|
|
185
|
+
if (validation.findingSummary?.counts?.error && !allowInvalid) findings.push(portableFinding('error', 'portable.stage-draft.validation.blocked', 'Draft staging is blocked while validation errors remain. Set allowInvalid only for an explicitly incomplete local checkpoint.'));
|
|
186
|
+
const blocked = findings.some((finding) => finding.severity === 'error');
|
|
187
|
+
const stagedArtifact = blocked ? null : Object.freeze({
|
|
188
|
+
schema: PORTABLE_STAGED_ARTIFACT_SCHEMA_ID,
|
|
189
|
+
id: draft.id || draft.path,
|
|
190
|
+
path: draft.path,
|
|
191
|
+
schemaId: draft.schemaId || validation.declaredSchema || validation.requestedSchema,
|
|
192
|
+
markdown: draft.markdown,
|
|
193
|
+
state: 'staged-local',
|
|
194
|
+
lifecycleStatus: validation.findingSummary?.counts?.error ? 'incomplete' : 'draft',
|
|
195
|
+
sourceMode: 'local-portable-staged',
|
|
196
|
+
source: null,
|
|
197
|
+
stagedAt: String(input.stagedAt || options.stagedAt || new Date().toISOString()),
|
|
198
|
+
qualification: Object.freeze({
|
|
199
|
+
validationStatus: validation.status,
|
|
200
|
+
exactRuntimeValidation: Boolean(validation.qualification?.exactRuntimeValidation),
|
|
201
|
+
contractDrivenStructuralValidation: Boolean(validation.qualification?.contractDrivenStructuralValidation),
|
|
202
|
+
exportReady: validation.status === 'clean' && Boolean(validation.qualification?.exactRuntimeValidation),
|
|
203
|
+
limitations: Object.freeze(validation.qualification?.limitations || [])
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
const findingSummary = summarizePortableFindings(findings);
|
|
207
|
+
return Object.freeze({
|
|
208
|
+
schema: 'tiinex.portable.stage-result.v1',
|
|
209
|
+
status: blocked ? 'blocked' : 'staged',
|
|
210
|
+
stagedArtifact,
|
|
211
|
+
validation,
|
|
212
|
+
findings: Object.freeze(findings),
|
|
213
|
+
findingSummary
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function renderBody({ title, plan, document, values, sections, allowIncomplete }) {
|
|
217
|
+
const lines = [`# ${title}`];
|
|
218
|
+
const usedFields = new Set();
|
|
219
|
+
const sectionMap = normalizeSections(sections);
|
|
220
|
+
const contractGroups = new Map((document?.validation?.groups || []).map((group) => [normalizeKey(group.name), group]));
|
|
221
|
+
const requiredSections = (plan.structure || []).map((item) => item.section).filter((section) => !isEnvelopeSection(section));
|
|
222
|
+
for (const sectionName of requiredSections) {
|
|
223
|
+
lines.push('', `## ${sectionName}`, '');
|
|
224
|
+
const explicit = sectionMap.get(normalizeKey(sectionName));
|
|
225
|
+
if (typeof explicit === 'string') lines.push(explicit.trim());
|
|
226
|
+
else {
|
|
227
|
+
const fields = fieldsForGroup(contractGroups.get(normalizeKey(sectionName)));
|
|
228
|
+
const rendered = [];
|
|
229
|
+
if (!fields.length) {
|
|
230
|
+
const sectionValue = valueFor(values, sectionName);
|
|
231
|
+
if (sectionValue !== undefined) {
|
|
232
|
+
rendered.push(formatFieldValue(sectionValue));
|
|
233
|
+
usedFields.add(normalizeKey(sectionName));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
for (const field of fields) {
|
|
237
|
+
const value = valueFor(values, field);
|
|
238
|
+
if (value !== undefined) {
|
|
239
|
+
rendered.push(`- ${field}: ${formatFieldValue(value)}`);
|
|
240
|
+
usedFields.add(normalizeKey(field));
|
|
241
|
+
} else if (allowIncomplete) rendered.push(`- ${field}: TODO`);
|
|
242
|
+
}
|
|
243
|
+
if (explicit && typeof explicit === 'object') {
|
|
244
|
+
for (const [field, value] of Object.entries(explicit)) {
|
|
245
|
+
rendered.push(`- ${field}: ${formatFieldValue(value)}`);
|
|
246
|
+
usedFields.add(normalizeKey(field));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
lines.push(...(rendered.length ? rendered : [allowIncomplete ? '- TODO: complete this required section.' : '']));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
for (const [sectionName, content] of sectionMap.entries()) {
|
|
253
|
+
if (requiredSections.some((required) => normalizeKey(required) === sectionName)) continue;
|
|
254
|
+
lines.push('', `## ${displayKey(sectionName)}`, '');
|
|
255
|
+
if (typeof content === 'string') lines.push(content.trim());
|
|
256
|
+
else for (const [field, value] of Object.entries(content || {})) lines.push(`- ${field}: ${formatFieldValue(value)}`);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const unassigned = Object.entries(values).filter(([field]) => !['title', 'summary'].includes(normalizeKey(field)) && !usedFields.has(normalizeKey(field)));
|
|
260
|
+
if (unassigned.length) {
|
|
261
|
+
lines.push('', '## Additional Declared Inputs', '');
|
|
262
|
+
for (const [field, value] of unassigned) lines.push(`- ${field}: ${formatFieldValue(value)}`);
|
|
263
|
+
}
|
|
264
|
+
return lines.filter((line, index, all) => line !== '' || all[index - 1] !== '').join('\n').trim();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function renderGenericDraft({ schemaId, title, summary, createdAt, why, currentStatus, parentRecord, bodyMarkdown }) {
|
|
268
|
+
const lines = [
|
|
269
|
+
'# Continuity Context',
|
|
270
|
+
'',
|
|
271
|
+
'- Envelope Schema: [tiinex.root.v1](tiinex.root.v1.schema.md)'
|
|
272
|
+
];
|
|
273
|
+
if (parentRecord.id || parentRecord.path || parentRecord.schemaId) {
|
|
274
|
+
lines.push(
|
|
275
|
+
'- Parent',
|
|
276
|
+
` - Parent Schema: [${parentRecord.schemaId}](${parentRecord.schemaId}.schema.md)`,
|
|
277
|
+
...(parentRecord.createdAt ? [` - Created At: ${normalizeArtifactTimestamp(parentRecord.createdAt)}`] : []),
|
|
278
|
+
` - Trace: ${parentRecord.continuationTrace || `record:${parentRecord.id}`}`,
|
|
279
|
+
` - Origin: ${parentRecord.path}`,
|
|
280
|
+
` - Boundary: ${parentRecord.boundary || 'portable local material; no source provenance inferred'}`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
lines.push(
|
|
284
|
+
'- Current',
|
|
285
|
+
` - Current Schema: [${schemaId}](${schemaId}.schema.md)`,
|
|
286
|
+
` - Created At: ${createdAt}`,
|
|
287
|
+
` - Summary: ${summary}`,
|
|
288
|
+
` - Status: ${currentStatus || 'draft/local'}`,
|
|
289
|
+
` - Why: ${cleanSingleLine(why || 'Created from explicitly supplied readable schema material as a portable local draft.', 360)}`,
|
|
290
|
+
'',
|
|
291
|
+
'---',
|
|
292
|
+
'',
|
|
293
|
+
bodyMarkdown,
|
|
294
|
+
'',
|
|
295
|
+
'# Continuity Integrity',
|
|
296
|
+
'',
|
|
297
|
+
'- Draft Local Integrity',
|
|
298
|
+
' - Method: portable-readable-schema-draft',
|
|
299
|
+
' - Value: pending-validation-and-explicit-export'
|
|
300
|
+
);
|
|
301
|
+
return lines.join('\n');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function normalizeArtifactTimestamp(value) {
|
|
305
|
+
const text = String(value instanceof Date ? value.toISOString() : value || '').trim();
|
|
306
|
+
if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(text)) return text;
|
|
307
|
+
const date = value instanceof Date ? value : new Date(text);
|
|
308
|
+
if (Number.isNaN(date.getTime())) return text;
|
|
309
|
+
return date.toISOString().slice(0, 19).replace('T', ' ');
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function mergeSchemaFiles(input, schemaMaterial) {
|
|
313
|
+
const files = [...(Array.isArray(input.files) ? input.files : [])];
|
|
314
|
+
if (schemaMaterial && !files.some((file) => file.path === schemaMaterial.path && String(file.content || file.markdown || '') === schemaMaterial.markdown)) {
|
|
315
|
+
files.push({ path: schemaMaterial.path, content: schemaMaterial.markdown });
|
|
316
|
+
}
|
|
317
|
+
return files;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
function normalizeDraftInput(draft = {}) {
|
|
322
|
+
return Object.freeze({
|
|
323
|
+
id: String(draft.id || draft.path || ''),
|
|
324
|
+
path: normalizeDraftPath(draft.path || 'draft.md'),
|
|
325
|
+
schemaId: String(draft.schemaId || draft.kind || ''),
|
|
326
|
+
markdown: String(draft.markdown || ''),
|
|
327
|
+
sourceMode: String(draft.sourceMode || 'local-portable-draft'),
|
|
328
|
+
source: draft.source || null
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function normalizeValues(value) {
|
|
333
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return {};
|
|
334
|
+
return Object.fromEntries(Object.entries(value).filter(([, fieldValue]) => fieldValue !== undefined && fieldValue !== null && fieldValue !== ''));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function normalizeSections(value) {
|
|
338
|
+
const map = new Map();
|
|
339
|
+
if (!value || typeof value !== 'object') return map;
|
|
340
|
+
for (const [name, content] of Object.entries(value)) map.set(normalizeKey(name), content);
|
|
341
|
+
return map;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function fieldsForGroup(group = {}) {
|
|
345
|
+
const names = new Set(['required fields', 'required entries']);
|
|
346
|
+
const fields = [];
|
|
347
|
+
for (const category of group?.categories || []) {
|
|
348
|
+
if (!names.has(normalizeKey(category.name))) continue;
|
|
349
|
+
for (const item of category.items || []) fields.push(cleanContractToken(item));
|
|
350
|
+
}
|
|
351
|
+
return [...new Set(fields.filter(Boolean))];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function valueFor(values, field) {
|
|
355
|
+
const wanted = normalizeKey(field);
|
|
356
|
+
for (const [name, value] of Object.entries(values)) if (normalizeKey(name) === wanted) return value;
|
|
357
|
+
return undefined;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function cleanContractToken(value = '') {
|
|
361
|
+
return String(value || '').replace(/`/g, '').replace(/\s+—.*$/, '').replace(/\s+-\s+.*$/, '').replace(/\.$/, '').trim();
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function isEnvelopeSection(section = '') {
|
|
365
|
+
const key = normalizeKey(section);
|
|
366
|
+
return key === 'continuity context' || key === 'continuity integrity';
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function formatFieldValue(value) {
|
|
370
|
+
if (Array.isArray(value)) return value.join('; ');
|
|
371
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
372
|
+
return String(value).replace(/\r?\n/g, ' ').trim();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function normalizeDraftPath(value = '') {
|
|
376
|
+
const path = String(value || '').replace(/\\/g, '/').replace(/^\/+/, '').replace(/\.\.(?:\/|$)/g, '').trim();
|
|
377
|
+
return path.toLowerCase().endsWith('.md') ? path : `${path || 'draft'}.md`;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function schemaLabel(schemaId = '') {
|
|
381
|
+
const parts = String(schemaId || 'artifact').split('.').filter(Boolean);
|
|
382
|
+
const value = parts.length >= 3 ? parts[parts.length - 2] : parts.at(-1) || 'artifact';
|
|
383
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function cleanSingleLine(value, max) { return String(value || '').replace(/\s+/g, ' ').trim().slice(0, max); }
|
|
387
|
+
function slug(value = '') { return String(value || 'artifact').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 80) || 'artifact'; }
|
|
388
|
+
function normalizeKey(value = '') { return String(value || '').toLowerCase().replace(/[`*_#]/g, '').replace(/[^a-z0-9]+/g, ' ').trim(); }
|
|
389
|
+
function displayKey(value = '') { return String(value || '').split(' ').map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(' '); }
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { parseArtifactMarkdown } from '../../../artifacts/artifact.parse.js';
|
|
2
|
+
import { portableFinding, summarizePortableFindings } from '../findings.js';
|
|
3
|
+
import { validatePortableDraft } from './draft.operations.js';
|
|
4
|
+
|
|
5
|
+
export const PORTABLE_DRAFT_UPDATE_SCHEMA_ID = 'tiinex.portable.draft-update.v1';
|
|
6
|
+
export const PORTABLE_DRAFT_DELETE_SCHEMA_ID = 'tiinex.portable.draft-delete.v1';
|
|
7
|
+
|
|
8
|
+
export function updatePortableLocalDraft(input = {}, options = {}) {
|
|
9
|
+
const current = normalizeDraft(input.draft || input.currentDraft || {});
|
|
10
|
+
const replacementMarkdown = String(input.replacementMarkdown || input.markdown || '').trim();
|
|
11
|
+
const allowInvalid = input.allowInvalid === true || options.allowInvalid === true;
|
|
12
|
+
const allowSchemaChange = input.allowSchemaChange === true || options.allowSchemaChange === true;
|
|
13
|
+
const allowContinuityChange = input.allowContinuityChange === true || options.allowContinuityChange === true;
|
|
14
|
+
const findings = [];
|
|
15
|
+
|
|
16
|
+
validateLocalDraftBoundary(current, findings, 'update');
|
|
17
|
+
if (!replacementMarkdown) findings.push(portableFinding('error', 'portable.draft-update.replacement.required', 'Updating a local draft requires complete replacement Markdown. Use schema guidance first; partial hidden patch semantics are not inferred.'));
|
|
18
|
+
if (findings.some((entry) => entry.severity === 'error')) return updateResult('blocked', null, null, findings);
|
|
19
|
+
|
|
20
|
+
const before = parseArtifactMarkdown(current.markdown);
|
|
21
|
+
const after = safeParse(replacementMarkdown, findings);
|
|
22
|
+
if (!after) return updateResult('blocked', null, null, findings);
|
|
23
|
+
const beforeIdentity = artifactIdentity(before);
|
|
24
|
+
const afterIdentity = artifactIdentity(after);
|
|
25
|
+
if (!afterIdentity.schemaId) findings.push(portableFinding('error', 'portable.draft-update.schema.required', 'Replacement Markdown must declare Current Schema.'));
|
|
26
|
+
if (!allowSchemaChange && beforeIdentity.schemaId !== afterIdentity.schemaId) findings.push(portableFinding('error', 'portable.draft-update.schema-change.blocked', 'Local draft update cannot silently change Current Schema. Create a new draft or explicitly allow a schema migration.', { before: beforeIdentity.schemaId, after: afterIdentity.schemaId }));
|
|
27
|
+
if (!allowContinuityChange && !sameContinuity(beforeIdentity, afterIdentity)) findings.push(portableFinding('error', 'portable.draft-update.continuity-change.blocked', 'Local draft update cannot silently change Parent, Trace, or Origin. Create a new lineage child or explicitly allow a continuity repair.', { before: beforeIdentity.parent, after: afterIdentity.parent }));
|
|
28
|
+
|
|
29
|
+
const validation = validatePortableDraft({
|
|
30
|
+
...input,
|
|
31
|
+
id: current.id,
|
|
32
|
+
path: current.path,
|
|
33
|
+
schemaId: afterIdentity.schemaId || current.schemaId || beforeIdentity.schemaId,
|
|
34
|
+
markdown: replacementMarkdown,
|
|
35
|
+
sourceMode: 'local-portable-draft',
|
|
36
|
+
source: null
|
|
37
|
+
}, options);
|
|
38
|
+
findings.push(...(validation.findings || []));
|
|
39
|
+
const hasErrors = findings.some((entry) => entry.severity === 'error');
|
|
40
|
+
if (hasErrors && !allowInvalid) return updateResult('blocked', null, validation, findings);
|
|
41
|
+
|
|
42
|
+
const updatedAt = String(input.updatedAt || options.updatedAt || new Date().toISOString());
|
|
43
|
+
const revision = Math.max(0, Number(current.revision || 0)) + 1;
|
|
44
|
+
const draft = Object.freeze({
|
|
45
|
+
...current,
|
|
46
|
+
schemaId: afterIdentity.schemaId || current.schemaId || beforeIdentity.schemaId,
|
|
47
|
+
markdown: replacementMarkdown,
|
|
48
|
+
sourceMode: 'local-portable-draft',
|
|
49
|
+
source: null,
|
|
50
|
+
lifecycleStatus: validation.findingSummary?.counts?.error ? 'incomplete' : 'draft',
|
|
51
|
+
revision,
|
|
52
|
+
updatedAt
|
|
53
|
+
});
|
|
54
|
+
const status = validation.status === 'clean' ? 'updated-clean' : validation.status === 'degraded' ? 'updated-degraded' : 'updated-invalid';
|
|
55
|
+
return updateResult(status, draft, validation, findings, {
|
|
56
|
+
previous: Object.freeze({ id: current.id, path: current.path, schemaId: beforeIdentity.schemaId, revision: current.revision || 0 }),
|
|
57
|
+
qualification: Object.freeze({
|
|
58
|
+
localOnly: true,
|
|
59
|
+
sourceMutation: false,
|
|
60
|
+
remoteWrite: false,
|
|
61
|
+
schemaChangeAllowed: allowSchemaChange,
|
|
62
|
+
continuityChangeAllowed: allowContinuityChange,
|
|
63
|
+
completeReplacementRequired: true
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function deletePortableLocalDraft(input = {}, options = {}) {
|
|
69
|
+
const current = normalizeDraft(input.draft || input.currentDraft || input);
|
|
70
|
+
const findings = [];
|
|
71
|
+
validateLocalDraftBoundary(current, findings, 'delete');
|
|
72
|
+
const expected = String(input.confirmId || input.confirm || options.confirmId || '').trim();
|
|
73
|
+
const actual = String(current.id || current.path || '').trim();
|
|
74
|
+
if (!expected) findings.push(portableFinding('error', 'portable.draft-delete.confirmation.required', 'Deleting local draft state requires an explicit confirmation id or path.'));
|
|
75
|
+
else if (expected !== actual && expected !== current.path) findings.push(portableFinding('error', 'portable.draft-delete.confirmation.mismatch', 'Deletion confirmation does not match the local draft id or path.', { expected, actual, path: current.path }));
|
|
76
|
+
if (findings.some((entry) => entry.severity === 'error')) return deleteResult('blocked', null, findings);
|
|
77
|
+
|
|
78
|
+
const deletion = Object.freeze({
|
|
79
|
+
schema: PORTABLE_DRAFT_DELETE_SCHEMA_ID,
|
|
80
|
+
status: 'deleted-local',
|
|
81
|
+
id: actual,
|
|
82
|
+
path: current.path,
|
|
83
|
+
schemaId: current.schemaId || safeParse(current.markdown)?.envelope?.current?.schema?.id || '',
|
|
84
|
+
reason: String(input.reason || options.reason || 'Explicit local draft removal.').trim(),
|
|
85
|
+
deletedAt: String(input.deletedAt || options.deletedAt || new Date().toISOString()),
|
|
86
|
+
retainedContent: false,
|
|
87
|
+
boundary: Object.freeze({
|
|
88
|
+
localStateOnly: true,
|
|
89
|
+
sourceMutation: false,
|
|
90
|
+
remoteWrite: false,
|
|
91
|
+
filesystemWritePerformed: false,
|
|
92
|
+
callerMustApplyRemovalToItsOwnExplicitLocalState: true
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
return deleteResult('deleted-local', deletion, findings);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function validateLocalDraftBoundary(draft, findings, action) {
|
|
99
|
+
if (!draft.markdown) findings.push(portableFinding('error', `portable.draft-${action}.markdown.required`, `${capitalize(action)} requires local draft Markdown.`));
|
|
100
|
+
if (!String(draft.sourceMode || '').startsWith('local-')) findings.push(portableFinding('error', `portable.draft-${action}.source-mode.invalid`, `${capitalize(action)} is allowed only for explicitly local draft state.`, { sourceMode: draft.sourceMode }));
|
|
101
|
+
if (draft.source) findings.push(portableFinding('error', `portable.draft-${action}.source-object.blocked`, `${capitalize(action)} must not mutate or inherit a source adapter object.`));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function artifactIdentity(parsed = {}) {
|
|
105
|
+
const parent = parsed.envelope?.parent || {};
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
schemaId: String(parsed.envelope?.current?.schema?.id || ''),
|
|
108
|
+
parent: Object.freeze({
|
|
109
|
+
schemaId: String(parent.schema?.id || ''),
|
|
110
|
+
trace: String(parent.trace || ''),
|
|
111
|
+
origin: String(parent.origin || '')
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function sameContinuity(before, after) {
|
|
117
|
+
return before.parent.schemaId === after.parent.schemaId
|
|
118
|
+
&& before.parent.trace === after.parent.trace
|
|
119
|
+
&& before.parent.origin === after.parent.origin;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function safeParse(markdown, findings = null) {
|
|
123
|
+
try { return parseArtifactMarkdown(String(markdown || '')); }
|
|
124
|
+
catch (error) {
|
|
125
|
+
findings?.push(portableFinding('error', 'portable.draft-update.markdown.invalid', 'Replacement Markdown could not be parsed as a Tiinex artifact.', { detail: String(error?.message || error) }));
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function normalizeDraft(draft = {}) {
|
|
131
|
+
return Object.freeze({
|
|
132
|
+
id: String(draft.id || draft.path || ''),
|
|
133
|
+
path: normalizePath(draft.path || draft.id || 'draft.md'),
|
|
134
|
+
schemaId: String(draft.schemaId || draft.kind || ''),
|
|
135
|
+
markdown: String(draft.markdown || ''),
|
|
136
|
+
status: String(draft.status || 'local'),
|
|
137
|
+
lifecycleStatus: String(draft.lifecycleStatus || 'draft'),
|
|
138
|
+
sourceMode: String(draft.sourceMode || 'local-portable-draft'),
|
|
139
|
+
source: draft.source || null,
|
|
140
|
+
creationMode: String(draft.creationMode || ''),
|
|
141
|
+
createdAt: String(draft.createdAt || ''),
|
|
142
|
+
revision: Math.max(0, Number(draft.revision || 0) || 0)
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function updateResult(status, draft, validation, findings, extra = {}) {
|
|
147
|
+
const normalized = Object.freeze([...findings]);
|
|
148
|
+
return Object.freeze({
|
|
149
|
+
schema: PORTABLE_DRAFT_UPDATE_SCHEMA_ID,
|
|
150
|
+
status,
|
|
151
|
+
draft,
|
|
152
|
+
validation,
|
|
153
|
+
...extra,
|
|
154
|
+
findings: normalized,
|
|
155
|
+
findingSummary: summarizePortableFindings(normalized)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function deleteResult(status, deletion, findings) {
|
|
160
|
+
const normalized = Object.freeze([...findings]);
|
|
161
|
+
return Object.freeze({
|
|
162
|
+
schema: PORTABLE_DRAFT_DELETE_SCHEMA_ID,
|
|
163
|
+
status,
|
|
164
|
+
deletion,
|
|
165
|
+
findings: normalized,
|
|
166
|
+
findingSummary: summarizePortableFindings(normalized)
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function normalizePath(value = '') {
|
|
171
|
+
const path = String(value || '').replace(/\\/g, '/').replace(/^\/+/, '').replace(/\.\.(?:\/|$)/g, '').trim();
|
|
172
|
+
return path.toLowerCase().endsWith('.md') ? path : `${path || 'draft'}.md`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function capitalize(value = '') { return value.charAt(0).toUpperCase() + value.slice(1); }
|