@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,193 @@
|
|
|
1
|
+
import { createPortableLocalDraft } from './draft.create.js';
|
|
2
|
+
import { prepareEpistemicMaterialization } from '../materialization/epistemic.plan.js';
|
|
3
|
+
import { portableFinding, summarizePortableFindings } from '../findings.js';
|
|
4
|
+
import { normalizePortableInput } from '../input/portable.input.js';
|
|
5
|
+
import { resolveLineage } from '../../../lineage/lineage.resolve.js';
|
|
6
|
+
import { parseArtifactMarkdown } from '../../../artifacts/artifact.parse.js';
|
|
7
|
+
|
|
8
|
+
export const PORTABLE_ARTIFACT_SET_CREATION_SCHEMA_ID = 'tiinex.portable.artifact-set-creation.v1';
|
|
9
|
+
|
|
10
|
+
export function createPortableLocalArtifactSet(input = {}, options = {}) {
|
|
11
|
+
const planResult = input.plan?.schema === 'tiinex.portable.epistemic-materialization-plan.v1'
|
|
12
|
+
? input.plan
|
|
13
|
+
: prepareEpistemicMaterialization(input, options);
|
|
14
|
+
const findings = [...(planResult.findings || [])];
|
|
15
|
+
if (planResult.status !== 'ready') {
|
|
16
|
+
findings.push(portableFinding('error', 'portable.artifact-set.plan.not-ready', 'Artifact-set creation requires a ready epistemic materialization plan.', { planStatus: planResult.status }));
|
|
17
|
+
return finalize('blocked', planResult, [], findings, emptyLineageClosure());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const created = [];
|
|
21
|
+
const byProposal = new Map();
|
|
22
|
+
for (const proposal of planResult.proposals) {
|
|
23
|
+
const parentRecord = proposal.parentKind === 'proposal'
|
|
24
|
+
? createdParent(byProposal.get(proposal.parent?.proposalId), proposal.path, proposal.parent?.proposalId)
|
|
25
|
+
: proposal.parentKind === 'loaded-record'
|
|
26
|
+
? parentForChild(proposal.parent, proposal.path)
|
|
27
|
+
: {};
|
|
28
|
+
if (proposal.parentKind === 'proposal' && !parentRecord.id) {
|
|
29
|
+
findings.push(portableFinding('error', 'portable.artifact-set.parent.proposal-unavailable', 'An earlier proposal did not produce a usable Parent artifact.', { proposalId: proposal.id, parentProposalId: proposal.parent?.proposalId || '' }));
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
const result = createPortableLocalDraft({
|
|
33
|
+
...(input.materials ? { materials: input.materials } : input),
|
|
34
|
+
schemaId: proposal.schemaId,
|
|
35
|
+
id: proposal.id,
|
|
36
|
+
path: proposal.path,
|
|
37
|
+
title: proposal.title,
|
|
38
|
+
summary: proposal.summary,
|
|
39
|
+
why: proposal.why || proposal.rationale,
|
|
40
|
+
values: proposal.values,
|
|
41
|
+
sections: proposal.sections,
|
|
42
|
+
bodyMarkdown: proposal.bodyMarkdown,
|
|
43
|
+
createdAt: proposal.createdAt || input.createdAt || options.createdAt,
|
|
44
|
+
schemaReferences: proposal.schemaReferences || input.schemaReferences || null,
|
|
45
|
+
transitionType: proposal.creationContract?.transitionType || (proposal.parentKind ? 'continue-from-record' : 'create-artifact'),
|
|
46
|
+
parentRecord
|
|
47
|
+
}, options);
|
|
48
|
+
findings.push(...(result.findings || []));
|
|
49
|
+
const entry = Object.freeze({
|
|
50
|
+
proposalId: proposal.id,
|
|
51
|
+
parentProposalId: proposal.parentKind === 'proposal' ? proposal.parent?.proposalId || '' : '',
|
|
52
|
+
parentLoadedRef: proposal.parentKind === 'loaded-record' ? proposal.parent?.path || proposal.parent?.id || '' : '',
|
|
53
|
+
result
|
|
54
|
+
});
|
|
55
|
+
created.push(entry);
|
|
56
|
+
byProposal.set(proposal.id, entry);
|
|
57
|
+
if (!usableCreation(result)) {
|
|
58
|
+
findings.push(portableFinding('error', 'portable.artifact-set.creation.not-clean', 'Artifact-set creation stopped because one proposal did not produce a clean local artifact.', { proposalId: proposal.id, status: result.status }));
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const complete = created.length === planResult.proposals.length && created.every((entry) => usableCreation(entry.result));
|
|
64
|
+
const localContinuity = complete && created.some((entry) => entry.result.qualification?.localContinuityUsable === true);
|
|
65
|
+
const status = complete ? localContinuity ? 'created-local-continuity' : 'created-clean' : 'blocked';
|
|
66
|
+
return finalize(status, planResult, created, findings, buildLineageClosure(input, planResult, created));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function finalize(status, plan, created, findings, lineageClosure) {
|
|
70
|
+
const summary = summarizePortableFindings(findings);
|
|
71
|
+
return Object.freeze({
|
|
72
|
+
schema: PORTABLE_ARTIFACT_SET_CREATION_SCHEMA_ID,
|
|
73
|
+
status,
|
|
74
|
+
plan,
|
|
75
|
+
artifacts: Object.freeze(created.map((entry, index) => Object.freeze({
|
|
76
|
+
order: index + 1,
|
|
77
|
+
proposalId: entry.proposalId,
|
|
78
|
+
parentProposalId: entry.parentProposalId,
|
|
79
|
+
parentLoadedRef: entry.parentLoadedRef,
|
|
80
|
+
draft: entry.result.draft,
|
|
81
|
+
validation: entry.result.validation,
|
|
82
|
+
qualification: entry.result.qualification
|
|
83
|
+
}))),
|
|
84
|
+
lineageClosure,
|
|
85
|
+
boundary: Object.freeze({
|
|
86
|
+
localOutput: true,
|
|
87
|
+
sourceMutation: false,
|
|
88
|
+
remoteWrite: false,
|
|
89
|
+
parentFromLoadedOrEarlierProposalOnly: true,
|
|
90
|
+
schemaSelectionValidatedThroughSharedRegistry: true
|
|
91
|
+
}),
|
|
92
|
+
findings: Object.freeze(findings),
|
|
93
|
+
findingSummary: summary
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function createdParent(entry, childPath = '', proposalId = '') {
|
|
98
|
+
const draft = entry?.result?.draft;
|
|
99
|
+
if (!draft || !usableCreation(entry.result)) return {};
|
|
100
|
+
const parsed = safeParse(draft.markdown);
|
|
101
|
+
const currentSchema = parsed?.envelope?.current?.schema || {};
|
|
102
|
+
return parentForChild({
|
|
103
|
+
id: draft.id || proposalId,
|
|
104
|
+
path: draft.path,
|
|
105
|
+
kind: draft.schemaId,
|
|
106
|
+
schemaId: draft.schemaId,
|
|
107
|
+
createdAt: draft.createdAt,
|
|
108
|
+
schemaReferenceAuthority: currentSchema.target ? {
|
|
109
|
+
schemaId: currentSchema.id || draft.schemaId,
|
|
110
|
+
preferredTarget: currentSchema.target,
|
|
111
|
+
exactTargets: [currentSchema.target],
|
|
112
|
+
resolutionState: 'qualified',
|
|
113
|
+
evidence: { source: 'earlier-proposal-rendered-current-schema-reference' }
|
|
114
|
+
} : null,
|
|
115
|
+
boundary: 'portable local artifact set; no remote source provenance inferred',
|
|
116
|
+
sourceMode: draft.sourceMode,
|
|
117
|
+
source: null,
|
|
118
|
+
markdown: String(draft.markdown || ''),
|
|
119
|
+
integrity: parsed?.integrity || null
|
|
120
|
+
}, childPath);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function parentForChild(parent = {}, childPath = '') {
|
|
124
|
+
void childPath;
|
|
125
|
+
return Object.freeze({ ...parent, continuationTrace: '' });
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function usableCreation(result = {}) {
|
|
129
|
+
return Boolean(result?.draft && (result.status === 'created-clean' || result.qualification?.localContinuityUsable === true));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function safeParse(markdown = '') {
|
|
133
|
+
try { return parseArtifactMarkdown(markdown); }
|
|
134
|
+
catch { return null; }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
function buildLineageClosure(input = {}, plan = {}, created = []) {
|
|
139
|
+
const material = normalizePortableInput(input.materials || input);
|
|
140
|
+
const records = (material.records || []).filter((record) => record.path && record.markdown && (record.hasContinuityContext || record.schemaId || String(record.kind || '').startsWith('tiinex.')));
|
|
141
|
+
const lineage = resolveLineage(records, { depth: 'portable-artifact-set-closure' });
|
|
142
|
+
const nodeById = new Map((lineage.nodes || []).map((node) => [node.id, node]));
|
|
143
|
+
const nodesByPath = new Map((lineage.nodes || []).map((node) => [String(node.path || ''), node]));
|
|
144
|
+
const selected = new Set();
|
|
145
|
+
const queue = [];
|
|
146
|
+
for (const proposal of plan.proposals || []) {
|
|
147
|
+
if (proposal.parentKind !== 'loaded-record') continue;
|
|
148
|
+
const node = nodesByPath.get(String(proposal.parent?.path || '')) || nodeById.get(String(proposal.parent?.id || ''));
|
|
149
|
+
if (node) queue.push(node.id);
|
|
150
|
+
}
|
|
151
|
+
while (queue.length) {
|
|
152
|
+
const id = queue.shift();
|
|
153
|
+
if (!id || selected.has(id)) continue;
|
|
154
|
+
selected.add(id);
|
|
155
|
+
for (const edge of lineage.edges || []) if (edge.kind === 'parent' && edge.to === id && edge.from) queue.push(edge.from);
|
|
156
|
+
}
|
|
157
|
+
const context = [...selected].map((id) => nodeById.get(id)).filter(Boolean).map((node) => Object.freeze({
|
|
158
|
+
id: node.id,
|
|
159
|
+
path: node.path,
|
|
160
|
+
schemaId: node.schemaId,
|
|
161
|
+
markdown: String(node.record?.markdown || ''),
|
|
162
|
+
trace: String(node.trace || ''),
|
|
163
|
+
parentSchemaId: String(node.parentSchemaId || ''),
|
|
164
|
+
sourceMode: String(node.sourceMode || ''),
|
|
165
|
+
boundary: String(node.boundary || '')
|
|
166
|
+
})).sort((a, b) => a.path.localeCompare(b.path));
|
|
167
|
+
const createdByProposal = new Map(created.map((entry) => [entry.proposalId, entry.result?.draft]));
|
|
168
|
+
const edges = [];
|
|
169
|
+
for (const edge of lineage.edges || []) {
|
|
170
|
+
if (edge.kind !== 'parent' || !edge.from || !edge.to || !selected.has(edge.to) || !selected.has(edge.from)) continue;
|
|
171
|
+
const parent = nodeById.get(edge.from);
|
|
172
|
+
const child = nodeById.get(edge.to);
|
|
173
|
+
if (parent?.path && child?.path) edges.push(Object.freeze({ childPath: child.path, parentPath: parent.path, parentKind: 'loaded-context' }));
|
|
174
|
+
}
|
|
175
|
+
for (const proposal of plan.proposals || []) {
|
|
176
|
+
const child = createdByProposal.get(proposal.id);
|
|
177
|
+
if (!child?.path) continue;
|
|
178
|
+
if (proposal.parentKind === 'proposal') {
|
|
179
|
+
const parent = createdByProposal.get(proposal.parent?.proposalId);
|
|
180
|
+
if (parent?.path) edges.push(Object.freeze({ childPath: child.path, parentPath: parent.path, parentKind: 'created-in-set' }));
|
|
181
|
+
} else if (proposal.parentKind === 'loaded-record' && proposal.parent?.path) {
|
|
182
|
+
edges.push(Object.freeze({ childPath: child.path, parentPath: proposal.parent.path, parentKind: 'loaded-context' }));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return Object.freeze({
|
|
186
|
+
schema: 'tiinex.portable.lineage-closure.v1',
|
|
187
|
+
context: Object.freeze(context),
|
|
188
|
+
edges: Object.freeze(uniqueEdges(edges)),
|
|
189
|
+
boundary: 'Minimum loaded Parent closure for changed artifacts. Context remains unchanged and carries exact loaded Markdown bytes.'
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function emptyLineageClosure() { return Object.freeze({ schema: 'tiinex.portable.lineage-closure.v1', context: Object.freeze([]), edges: Object.freeze([]), boundary: 'No ready artifact plan.' }); }
|
|
193
|
+
function uniqueEdges(edges = []) { const map = new Map(); for (const edge of edges) map.set(`${edge.childPath}\0${edge.parentPath}`, edge); return [...map.values()].sort((a, b) => `${a.childPath}\0${a.parentPath}`.localeCompare(`${b.childPath}\0${b.parentPath}`)); }
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function creationSchemaReferenceValidationContext(exactContract = {}, parentRecord = null) {
|
|
2
|
+
return Object.freeze({
|
|
3
|
+
envelope: exactContract?.schemaReferences?.envelope || null,
|
|
4
|
+
current: exactContract?.schemaReferences?.current || null,
|
|
5
|
+
parent: parentRecord?.schemaReferenceAuthority || null
|
|
6
|
+
});
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { parseArtifactMarkdown } from '../../../artifacts/artifact.parse.js';
|
|
2
|
+
import { auditPortableRecord } from '../audit/audit.capability.js';
|
|
3
|
+
|
|
4
|
+
export const PORTABLE_AUTHORING_PARENT_SCHEMA_ID = 'tiinex.portable.authoring-parent.v1';
|
|
5
|
+
|
|
6
|
+
export function projectPortableAuthoringParent(input = {}) {
|
|
7
|
+
const records = normalizeRecords(input);
|
|
8
|
+
if (records.length !== 1) return freeze({ schema: PORTABLE_AUTHORING_PARENT_SCHEMA_ID, status: 'blocked', parentRecord: null, findings: [{ severity: 'error', code: 'portable.authoring-parent.exactly-one-required', message: 'Authoring Parent projection requires exactly one local text artifact.' }], operationBoundary: boundary() });
|
|
9
|
+
const record = records[0];
|
|
10
|
+
let parsed;
|
|
11
|
+
try { parsed = parseArtifactMarkdown(record.markdown); }
|
|
12
|
+
catch { return freeze({ schema: PORTABLE_AUTHORING_PARENT_SCHEMA_ID, status: 'blocked', parentRecord: null, findings: [{ severity: 'error', code: 'portable.authoring-parent.parse-failed', message: 'Selected Parent bytes are not a readable Tiinex artifact.' }], operationBoundary: boundary() }); }
|
|
13
|
+
const audit = auditPortableRecord({ ...record, title: parsed.title, schemaId: parsed.envelope?.current?.schema?.id, currentSchemaId: parsed.envelope?.current?.schema?.id, parent: parsed.envelope?.parent });
|
|
14
|
+
if (audit.status !== 'readable' || audit.qualification?.exact !== true || (audit.findings || []).some((item) => item.severity === 'error')) return freeze({ schema: PORTABLE_AUTHORING_PARENT_SCHEMA_ID, status: 'blocked', parentRecord: null, findings: [{ severity: 'error', code: 'portable.authoring-parent.unqualified', message: 'Selected Parent must pass exact shared audit before it can be used for native authoring.' }], operationBoundary: boundary() });
|
|
15
|
+
const schemaId = String(parsed.envelope?.current?.schema?.id || audit.schemaId || '');
|
|
16
|
+
const schemaTarget = String(parsed.envelope?.current?.schema?.target || '');
|
|
17
|
+
const createdAt = String(parsed.envelope?.current?.createdAt || audit.artifact?.createdAt || '');
|
|
18
|
+
return freeze({
|
|
19
|
+
schema: PORTABLE_AUTHORING_PARENT_SCHEMA_ID,
|
|
20
|
+
status: 'ready',
|
|
21
|
+
parentRecord: {
|
|
22
|
+
id: String(record.path || record.id || ''), path: String(record.path || record.id || ''), schemaId, currentSchemaId: schemaId, currentCreatedAt: createdAt,
|
|
23
|
+
markdown: record.markdown, sourceMode: String(record.sourceMode || 'portable-node-local'),
|
|
24
|
+
schemaReferenceAuthority: { schemaId, preferredTarget: schemaTarget, exactTargets: schemaTarget ? [schemaTarget] : [], resolutionState: 'unresolved', evidence: { basis: 'declared-current-schema-reference-only' } }
|
|
25
|
+
},
|
|
26
|
+
findings: [],
|
|
27
|
+
operationBoundary: boundary(),
|
|
28
|
+
boundary: 'Projects exact supplied Parent bytes and declared current schema locator into shared draft-authoring input. A declared schema locator remains unresolved and is not upgraded to publication or canonical reference authority.'
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function normalizeRecords(input = {}) {
|
|
33
|
+
if (Array.isArray(input.records)) return input.records;
|
|
34
|
+
return (Array.isArray(input.files) ? input.files : []).filter((item) => typeof item?.content === 'string').map((item) => ({ id: String(item.path || ''), path: String(item.path || ''), markdown: String(item.content || ''), sourceMode: item.sourceMode || '' }));
|
|
35
|
+
}
|
|
36
|
+
function boundary() { return { sourceMutation: false, remoteWrite: false, authoring: false }; }
|
|
37
|
+
function freeze(value) { if (Array.isArray(value)) return Object.freeze(value.map(freeze)); if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value; return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, freeze(item)]))); }
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { auditPortableRecord } from '../audit/audit.capability.js';
|
|
2
|
+
import { C14N_V2_METHOD_ID, canonicalC14nV2SelfState, sealC14nV2Self } from '../../../integrity/integrity.c14nV2.js';
|
|
3
|
+
import { sha256Hex } from '../../../export/package.bytes.js';
|
|
4
|
+
import { integrityMethodReferenceAuthorityForCreation } from '../../../integrity/integrity.methodReference.js';
|
|
5
|
+
import { inspectPortableLineageIntegrity } from '../lineage/lineage.integrity.plan.js';
|
|
6
|
+
import { portableFinding } from '../findings.js';
|
|
7
|
+
|
|
8
|
+
export const PORTABLE_EDITOR_ASSISTANCE_SCHEMA_ID = 'tiinex.portable.editor-assistance.v1';
|
|
9
|
+
|
|
10
|
+
export function projectPortableEditorAssistance(input = {}) {
|
|
11
|
+
const records = normalizeRecords(input);
|
|
12
|
+
const focusPath = norm(input.focusPath || input.focus || '');
|
|
13
|
+
const selectedRecords = focusPath ? records.filter((record) => norm(record.path || record.id || '') === focusPath) : records;
|
|
14
|
+
const lineageInspection = inspectPortableLineageIntegrity({ records });
|
|
15
|
+
const documents = selectedRecords.map((record) => projectDocument(record, records, lineageInspection));
|
|
16
|
+
const diagnostics = documents.flatMap((item) => item.diagnostics);
|
|
17
|
+
return freeze({
|
|
18
|
+
schema: PORTABLE_EDITOR_ASSISTANCE_SCHEMA_ID,
|
|
19
|
+
status: diagnostics.some((item) => item.severity === 'error') ? 'invalid' : diagnostics.some((item) => item.severity === 'warning') ? 'degraded' : 'clean',
|
|
20
|
+
documents,
|
|
21
|
+
operationBoundary: { sourceMutation: false, remoteWrite: false, automaticRepair: false },
|
|
22
|
+
boundary: 'Adapter-neutral projection of exact shared audit/validator findings plus only deterministic byte replacements. Presentation adapters must not invent finding severity, validator choice, source line, or repair content.'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function projectDocument(record = {}, records = [], lineageInspection = null) {
|
|
27
|
+
const audit = auditPortableRecord(record, { requireExactSchemaAuthority: true });
|
|
28
|
+
const markdown = String(record.markdown || '');
|
|
29
|
+
const recordPath = norm(record.path || record.id || '');
|
|
30
|
+
const lineageFindings = findingsForPath(lineageInspection?.findings || [], recordPath);
|
|
31
|
+
const referenceFindings = schemaReferenceCompositionFindings(audit, recordPath);
|
|
32
|
+
const sharedFindings = [...(audit.findings || []), ...lineageFindings, ...referenceFindings];
|
|
33
|
+
const diagnostics = sharedFindings
|
|
34
|
+
.filter((item) => item.severity === 'error' || item.severity === 'warning')
|
|
35
|
+
.map((finding) => projectDiagnostic(finding, markdown));
|
|
36
|
+
const actions = [];
|
|
37
|
+
const integrityRepair = deterministicIntegrityHygieneRepair(markdown, audit.findings || []);
|
|
38
|
+
const repairQualification = integrityRepair.state === 'ready'
|
|
39
|
+
? qualifyReplacementAgainstSharedGuardrails(record, records, integrityRepair.markdown)
|
|
40
|
+
: { state: 'unavailable' };
|
|
41
|
+
if (integrityRepair.state === 'ready' && integrityRepair.markdown !== markdown && repairQualification.state === 'qualified') actions.push(freeze({
|
|
42
|
+
id: 'refresh-primary-self-integrity',
|
|
43
|
+
title: integrityRepair.methodReferenceChanged ? 'Refresh Tiinex integrity references and self seal' : 'Refresh Tiinex c14n-v2 self integrity',
|
|
44
|
+
kind: 'replace-document',
|
|
45
|
+
qualification: 'deterministic-shared-core',
|
|
46
|
+
sourceSha256: sha256Hex(new TextEncoder().encode(markdown)),
|
|
47
|
+
replacementMarkdown: integrityRepair.markdown,
|
|
48
|
+
diagnosticCodes: integrityRepair.diagnosticCodes,
|
|
49
|
+
boundary: integrityRepair.methodReferenceChanged
|
|
50
|
+
? 'Rebinds only unqualified c14n-v2 footer method links to the shared qualified maintained target and reseals the existing primary self Value; the replacement is exposed only after the same shared audit and lineage guardrails re-qualify the focused artifact and every loaded digest-bound descendant.'
|
|
51
|
+
: 'Refreshes only the existing primary c14n-v2 self Value through the shared integrity algorithm; the replacement is exposed only after the same shared audit and lineage guardrails re-qualify the focused artifact and every loaded digest-bound descendant.'
|
|
52
|
+
}));
|
|
53
|
+
const validationAuthority = audit.schemaValidationAuthority || null;
|
|
54
|
+
return freeze({
|
|
55
|
+
path: String(record.path || record.id || ''),
|
|
56
|
+
schemaId: String(audit.schemaId || ''),
|
|
57
|
+
validator: {
|
|
58
|
+
state: audit.qualification?.exact && validationAuthority?.state === 'qualified' ? 'qualified-exact' : 'degraded',
|
|
59
|
+
requestedSchema: String(audit.qualification?.requestedSchema || audit.schemaId || ''),
|
|
60
|
+
resolvedThrough: String(audit.qualification?.resolvedThrough || ''),
|
|
61
|
+
fallbackUsed: Boolean(audit.qualification?.fallback?.used),
|
|
62
|
+
authorityState: String(validationAuthority?.state || 'unavailable'),
|
|
63
|
+
authorityBasis: String(validationAuthority?.currentReference?.basis || ''),
|
|
64
|
+
authorityFindings: [...(validationAuthority?.findings || [])]
|
|
65
|
+
},
|
|
66
|
+
diagnostics,
|
|
67
|
+
actions
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function schemaReferenceCompositionFindings(audit = {}, recordPath = '') {
|
|
72
|
+
const envelope = audit?.parsed?.envelope || {};
|
|
73
|
+
const references = [
|
|
74
|
+
{ field: 'Envelope Schema', value: envelope.envelopeSchema || {} },
|
|
75
|
+
{ field: 'Current Schema', value: envelope.current?.schema || {} },
|
|
76
|
+
{ field: 'Parent Schema', value: envelope.parent?.schema || {} }
|
|
77
|
+
].filter((entry) => String(entry.value?.id || '').trim());
|
|
78
|
+
const exactPublishedStyle = references.some((entry) => entry.value?.form === 'markdown-link' && /^https:\/\/github\.com\/[^/]+\/[^/]+\/blob\/[0-9a-f]{40}\//i.test(String(entry.value?.target || '')));
|
|
79
|
+
if (!exactPublishedStyle) return [];
|
|
80
|
+
const findings = [];
|
|
81
|
+
for (const entry of references) {
|
|
82
|
+
if (entry.value?.form !== 'plain-schema-id') continue;
|
|
83
|
+
const schemaId = String(entry.value?.id || '').trim();
|
|
84
|
+
findings.push(portableFinding('warning', 'portable.editor.schema-reference.canonical-target-available', `${entry.field} uses only a schema id while the same artifact otherwise uses exact immutable schema locators. This mixed representation requires explicit qualification instead of being treated as clean.`, {
|
|
85
|
+
ref: recordPath,
|
|
86
|
+
params: { field: entry.field, schemaId },
|
|
87
|
+
fixability: 'manual-or-holistic-repair-required'
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
return findings;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function findingsForPath(findings = [], path = '') {
|
|
94
|
+
const wanted = norm(path);
|
|
95
|
+
return (findings || []).filter((finding) => norm(finding?.evidencePath || finding?.ref || '') === wanted);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function qualifyReplacementAgainstSharedGuardrails(record = {}, records = [], replacementMarkdown = '') {
|
|
99
|
+
const focusPath = norm(record.path || record.id || '');
|
|
100
|
+
if (!focusPath || !replacementMarkdown) return freeze({ state: 'unavailable', reason: 'replacement-or-focus-unavailable' });
|
|
101
|
+
const replacedRecords = records.map((item) => norm(item.path || item.id || '') === focusPath ? { ...item, markdown: replacementMarkdown } : item);
|
|
102
|
+
const replacementRecord = replacedRecords.find((item) => norm(item.path || item.id || '') === focusPath);
|
|
103
|
+
if (!replacementRecord) return freeze({ state: 'unavailable', reason: 'focused-record-unavailable' });
|
|
104
|
+
const replacementAudit = auditPortableRecord(replacementRecord, { requireExactSchemaAuthority: true });
|
|
105
|
+
const auditBlockers = [...(replacementAudit.findings || []), ...schemaReferenceCompositionFindings(replacementAudit, focusPath)].filter((item) => item.severity === 'error' || item.severity === 'warning');
|
|
106
|
+
if (auditBlockers.length) return freeze({ state: 'blocked', reason: 'replacement-shared-audit-not-clean', blockerCodes: auditBlockers.map((item) => String(item.code || '')) });
|
|
107
|
+
|
|
108
|
+
const before = inspectPortableLineageIntegrity({ records });
|
|
109
|
+
const after = inspectPortableLineageIntegrity({ records: replacedRecords });
|
|
110
|
+
const beforeFocus = (before.artifacts || []).find((item) => norm(item.path || '') === focusPath);
|
|
111
|
+
const affectedPaths = new Set([focusPath, ...((beforeFocus?.downstreamDescendants || []).map((item) => norm(item.path || '')).filter(Boolean))]);
|
|
112
|
+
const lineageBlockers = (after.artifacts || []).filter((item) => affectedPaths.has(norm(item.path || '')) && item.state !== 'healthy');
|
|
113
|
+
if (lineageBlockers.length) return freeze({ state: 'blocked', reason: 'replacement-shared-lineage-not-clean', blockers: lineageBlockers.map((item) => ({ path: item.path, state: item.state })) });
|
|
114
|
+
return freeze({ state: 'qualified', affectedPaths: [...affectedPaths] });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function projectDiagnostic(finding = {}, markdown = '') {
|
|
118
|
+
const located = locateFindingLine(finding, markdown);
|
|
119
|
+
return freeze({
|
|
120
|
+
severity: String(finding.severity || 'warning'),
|
|
121
|
+
code: String(finding.code || 'tiinex.validation.finding'),
|
|
122
|
+
message: String(finding.message || 'Tiinex validation finding.'),
|
|
123
|
+
fixability: String(finding.fixability || 'unknown'),
|
|
124
|
+
line: located.line,
|
|
125
|
+
locationState: located.state,
|
|
126
|
+
locationBasis: located.basis
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function locateFindingLine(finding = {}, markdown = '') {
|
|
131
|
+
const lines = String(markdown || '').replace(/\r\n?/g, '\n').split('\n');
|
|
132
|
+
const params = finding.params || finding;
|
|
133
|
+
const field = String(params.field || '').trim();
|
|
134
|
+
const section = String(params.section || '').trim();
|
|
135
|
+
const heading = String(params.heading || '').replace(/^#{1,6}\s+/, '').trim();
|
|
136
|
+
const group = String(params.group || '').trim();
|
|
137
|
+
if (field) {
|
|
138
|
+
const index = lines.findIndex((line) => new RegExp(`^\\s*-\\s+${escapeRegExp(field)}\\s*:`).test(line));
|
|
139
|
+
if (index >= 0) return freeze({ state: 'deterministic', line: index + 1, basis: `field:${field}` });
|
|
140
|
+
}
|
|
141
|
+
for (const owner of [section, heading, group].filter(Boolean)) {
|
|
142
|
+
const sectionIndex = lines.findIndex((line) => new RegExp(`^#{2,6}\\s+${escapeRegExp(owner)}\\s*$`, 'i').test(line));
|
|
143
|
+
if (sectionIndex >= 0) return freeze({ state: section || heading ? 'deterministic' : 'deterministic-anchor', line: sectionIndex + 1, basis: `${section || heading ? 'section' : 'owning-section'}:${owner}` });
|
|
144
|
+
const envelopeIndex = lines.findIndex((line) => new RegExp(`^\\s*-\\s+${escapeRegExp(owner)}(?:\\s*:.*)?\\s*$`, 'i').test(line));
|
|
145
|
+
if (envelopeIndex >= 0) return freeze({ state: 'deterministic-anchor', line: envelopeIndex + 1, basis: `envelope-owner:${owner}` });
|
|
146
|
+
}
|
|
147
|
+
const code = String(finding.code || '');
|
|
148
|
+
if (code.includes('schema.') || code.endsWith('.schema.mismatch') || code === 'audit.schema-authority.unqualified') {
|
|
149
|
+
const index = lines.findIndex((line) => /^\s*-\s+Current Schema\s*:/.test(line));
|
|
150
|
+
if (index >= 0) return freeze({ state: 'deterministic', line: index + 1, basis: 'current-schema-field' });
|
|
151
|
+
}
|
|
152
|
+
if (code === 'integrity.method-reference.unqualified') {
|
|
153
|
+
const headingIndex = lines.findIndex((line) => line.trim() === '# Continuity Integrity');
|
|
154
|
+
const methodIndex = lines.findIndex((line, index) => index > headingIndex && /^\s*-\s+\[sha256-base64url-c14n-v2\]\([^)]+\)\s*$/.test(line));
|
|
155
|
+
if (methodIndex >= 0) return freeze({ state: 'deterministic', line: methodIndex + 1, basis: 'continuity-integrity-method-reference' });
|
|
156
|
+
}
|
|
157
|
+
if (code.includes('integrity') || /integrity|checksum|digest/i.test(String(finding.message || ''))) {
|
|
158
|
+
const headingIndex = lines.findIndex((line) => line.trim() === '# Continuity Integrity');
|
|
159
|
+
if (headingIndex >= 0) {
|
|
160
|
+
const index = lines.findIndex((line, i) => i > headingIndex && /^\s+-\s+Value\s*:/.test(line));
|
|
161
|
+
if (index >= 0) return freeze({ state: 'deterministic', line: index + 1, basis: 'continuity-integrity-value' });
|
|
162
|
+
return freeze({ state: 'deterministic-anchor', line: headingIndex + 1, basis: 'continuity-integrity-heading' });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (/^(portable\.contract\.|root\.|integrity\.)/i.test(code) && (/missing|required|incomplete/i.test(code) || /\bmissing\b|\brequired\b/i.test(String(finding.message || '')))) {
|
|
166
|
+
const bodyHeading = lines.findIndex((line) => /^#\s+\S/.test(line) && !/^#\s+Continuity (?:Context|Integrity)\s*$/.test(line));
|
|
167
|
+
if (bodyHeading >= 0) return freeze({ state: 'deterministic-anchor', line: bodyHeading + 1, basis: section ? `body-heading-for-missing-section:${section}` : field ? `body-heading-for-missing-field:${field}` : 'body-heading-for-missing-required-content' });
|
|
168
|
+
const contextHeading = lines.findIndex((line) => line.trim() === '# Continuity Context');
|
|
169
|
+
if (contextHeading >= 0) return freeze({ state: 'deterministic-anchor', line: contextHeading + 1, basis: 'continuity-context-for-missing-required-content' });
|
|
170
|
+
}
|
|
171
|
+
if (/\.body\.|body/i.test(code) || /\bbody\b/i.test(String(finding.message || ''))) {
|
|
172
|
+
const bodyHeading = lines.findIndex((line) => /^#\s+\S/.test(line) && !/^#\s+Continuity (?:Context|Integrity)\s*$/.test(line));
|
|
173
|
+
if (bodyHeading >= 0) return freeze({ state: 'deterministic-anchor', line: bodyHeading + 1, basis: 'body-heading-for-body-finding' });
|
|
174
|
+
}
|
|
175
|
+
return freeze({ state: 'unresolved', line: null, basis: 'shared-finding-has-no-deterministic-line-evidence' });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function deterministicIntegrityHygieneRepair(markdown = '', findings = []) {
|
|
179
|
+
const source = String(markdown || '');
|
|
180
|
+
const codes = new Set((findings || []).map((item) => String(item?.code || '')));
|
|
181
|
+
const authority = integrityMethodReferenceAuthorityForCreation(C14N_V2_METHOD_ID);
|
|
182
|
+
const preferredTarget = authority?.resolutionState === 'qualified' ? String(authority?.preferredTarget || '') : '';
|
|
183
|
+
const exactTargets = new Set((authority?.exactTargets || []).map((item) => String(item || '')));
|
|
184
|
+
let methodReferenceChanged = false;
|
|
185
|
+
let repaired = source;
|
|
186
|
+
if (codes.has('integrity.method-reference.unqualified') && preferredTarget) {
|
|
187
|
+
const lines = source.replace(/\r\n?/g, '\n').split('\n');
|
|
188
|
+
const heading = lines.findIndex((line) => line.trim() === '# Continuity Integrity');
|
|
189
|
+
if (heading >= 0) {
|
|
190
|
+
for (let index = heading + 1; index < lines.length; index += 1) {
|
|
191
|
+
if (/^#\s+/.test(lines[index])) break;
|
|
192
|
+
const match = lines[index].match(/^(\s*-\s+)\[sha256-base64url-c14n-v2\]\(([^)]+)\)(\s*)$/);
|
|
193
|
+
if (!match || exactTargets.has(match[2])) continue;
|
|
194
|
+
lines[index] = `${match[1]}[${C14N_V2_METHOD_ID}](${preferredTarget})${match[3]}`;
|
|
195
|
+
methodReferenceChanged = true;
|
|
196
|
+
}
|
|
197
|
+
if (methodReferenceChanged) repaired = lines.join('\n');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const integrity = canonicalC14nV2SelfState(repaired);
|
|
202
|
+
const requiresSeal = methodReferenceChanged || integrity.state === 'mismatch' || integrity.state === 'prepared';
|
|
203
|
+
if (!requiresSeal) return freeze({ state: 'unavailable', markdown: source, methodReferenceChanged: false, diagnosticCodes: [] });
|
|
204
|
+
const sealed = sealC14nV2Self(repaired);
|
|
205
|
+
if (sealed.state !== 'sealed') return freeze({ state: 'unavailable', markdown: source, methodReferenceChanged, diagnosticCodes: [] });
|
|
206
|
+
const diagnosticCodes = [
|
|
207
|
+
...(methodReferenceChanged ? ['integrity.method-reference.unqualified'] : []),
|
|
208
|
+
'integrity.c14n-v2.mismatch',
|
|
209
|
+
'integrity.c14n-v2.ambiguous'
|
|
210
|
+
];
|
|
211
|
+
return freeze({ state: 'ready', markdown: sealed.markdown, methodReferenceChanged, diagnosticCodes: [...new Set(diagnosticCodes)] });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function norm(value = '') { return String(value || '').replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+|\/+$/g, ''); }
|
|
215
|
+
function escapeRegExp(value = '') { return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
|
|
216
|
+
function freeze(value) { if (Array.isArray(value)) return Object.freeze(value.map(freeze)); if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value; return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, freeze(item)]))); }
|
|
217
|
+
|
|
218
|
+
function normalizeRecords(input = {}) {
|
|
219
|
+
if (Array.isArray(input.records)) return input.records;
|
|
220
|
+
return (Array.isArray(input.files) ? input.files : []).filter((item) => typeof item?.content === 'string').map((item) => Object.freeze({ id: String(item.path || ''), path: String(item.path || ''), markdown: String(item.content || ''), sourceMode: item.sourceMode || '' }));
|
|
221
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { parseArtifactMarkdown } from '../../../artifacts/artifact.parse.js';
|
|
3
|
+
import { projectPortableEditorAssistance } from './editor.assistance.js';
|
|
4
|
+
import { auditPortableRecord } from '../audit/audit.capability.js';
|
|
5
|
+
|
|
6
|
+
export const PORTABLE_STAGED_VALIDATION_SCHEMA_ID = 'tiinex.portable.staged-validation.v1';
|
|
7
|
+
|
|
8
|
+
export function projectPortableStagedValidation(input = {}) {
|
|
9
|
+
const records = normalizeRecords(input);
|
|
10
|
+
const byPath = new Map(records.map((record) => [norm(record.path), record]).filter(([recordPath]) => recordPath));
|
|
11
|
+
const stagedPaths = unique((input.stagedPaths || input.paths || []).map(norm).filter(Boolean));
|
|
12
|
+
const stagedTiinexPaths = [];
|
|
13
|
+
const ignoredStagedPaths = [];
|
|
14
|
+
|
|
15
|
+
for (const stagedPath of stagedPaths) {
|
|
16
|
+
const record = byPath.get(stagedPath);
|
|
17
|
+
if (record && isTiinexArtifact(record.markdown)) stagedTiinexPaths.push(stagedPath);
|
|
18
|
+
else ignoredStagedPaths.push(stagedPath);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const closure = new Set(stagedTiinexPaths);
|
|
22
|
+
const queue = [...stagedTiinexPaths];
|
|
23
|
+
while (queue.length) {
|
|
24
|
+
const currentPath = queue.shift();
|
|
25
|
+
const record = byPath.get(currentPath);
|
|
26
|
+
const parentPath = record ? localParentPath(currentPath, record.markdown) : '';
|
|
27
|
+
if (!parentPath || closure.has(parentPath) || !byPath.has(parentPath)) continue;
|
|
28
|
+
closure.add(parentPath);
|
|
29
|
+
queue.push(parentPath);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const validationRecords = records.filter((record) => closure.has(norm(record.path)) || /\.schema\.md$/i.test(norm(record.path)));
|
|
33
|
+
const documents = [];
|
|
34
|
+
const findings = [];
|
|
35
|
+
for (const focusPath of [...closure].sort()) {
|
|
36
|
+
const scope = stagedTiinexPaths.includes(focusPath) ? 'staged' : 'required-closure';
|
|
37
|
+
const record = byPath.get(focusPath);
|
|
38
|
+
let document;
|
|
39
|
+
if (/\.schema\.md$/i.test(focusPath) && record) {
|
|
40
|
+
const audit = auditPortableRecord(record);
|
|
41
|
+
document = {
|
|
42
|
+
path: focusPath,
|
|
43
|
+
schemaId: audit.schemaId || '',
|
|
44
|
+
validator: { state: audit.qualification?.exact === true ? 'qualified-exact-schema-definition' : 'unqualified-schema-definition' },
|
|
45
|
+
diagnostics: (audit.findings || []).filter((item) => item.severity !== 'info').map((item) => ({ ...item, line: null, locationState: 'unresolved', locationBasis: 'schema-definition-audit' }))
|
|
46
|
+
};
|
|
47
|
+
} else {
|
|
48
|
+
const projected = projectPortableEditorAssistance({ records: validationRecords, focusPath });
|
|
49
|
+
document = projected.documents?.[0];
|
|
50
|
+
}
|
|
51
|
+
if (!document) {
|
|
52
|
+
findings.push(finding('error', 'portable.staged-validation.document.unprojected', 'Shared validation could not project a staged or required-closure Tiinex artifact.', { path: focusPath, scope }));
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const diagnostics = (document.diagnostics || []).map((diagnostic) => freeze({ ...diagnostic, path: focusPath, scope }));
|
|
56
|
+
documents.push(freeze({ path: focusPath, scope, schemaId: document.schemaId || '', validator: document.validator || null, diagnostics }));
|
|
57
|
+
for (const diagnostic of diagnostics) findings.push(finding(diagnostic.severity || 'warning', diagnostic.code || 'portable.staged-validation.diagnostic', diagnostic.message || 'Shared validation finding.', { path: focusPath, scope, line: diagnostic.line ?? null, locationState: diagnostic.locationState || 'unresolved', locationBasis: diagnostic.locationBasis || '' }));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const blockingFindings = findings.filter((item) => item.severity === 'error' || item.severity === 'warning');
|
|
61
|
+
const state = stagedTiinexPaths.length === 0 ? 'no-staged-tiinex' : blockingFindings.length ? 'blocked' : 'clean';
|
|
62
|
+
return freeze({
|
|
63
|
+
schema: PORTABLE_STAGED_VALIDATION_SCHEMA_ID,
|
|
64
|
+
status: state === 'blocked' ? 'blocked' : 'ready',
|
|
65
|
+
state,
|
|
66
|
+
stagedPaths,
|
|
67
|
+
stagedTiinexPaths,
|
|
68
|
+
ignoredStagedPaths,
|
|
69
|
+
closurePaths: [...closure].sort(),
|
|
70
|
+
documents,
|
|
71
|
+
findings,
|
|
72
|
+
blockingFindingCount: blockingFindings.length,
|
|
73
|
+
operationBoundary: { sourceMutation: false, remoteWrite: false, gitMutation: false },
|
|
74
|
+
boundary: 'Validates only explicit staged Tiinex artifacts plus their required loaded local Parent closure. Unrelated non-staged defects are outside the gate; non-staged material may participate only as required validation authority or Parent closure.'
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function normalizeRecords(input = {}) {
|
|
79
|
+
if (Array.isArray(input.records)) return input.records.map((record) => freeze({ ...record, path: norm(record.path || record.id || ''), markdown: String(record.markdown || record.content || '') }));
|
|
80
|
+
return (Array.isArray(input.files) ? input.files : []).filter((item) => typeof item?.content === 'string').map((item) => freeze({ id: norm(item.path || ''), path: norm(item.path || ''), markdown: String(item.content || ''), sourceMode: item.sourceMode || '' }));
|
|
81
|
+
}
|
|
82
|
+
function isTiinexArtifact(markdown = '') {
|
|
83
|
+
try { return Boolean(String(parseArtifactMarkdown(markdown)?.envelope?.current?.schema?.id || '').trim()); }
|
|
84
|
+
catch { return false; }
|
|
85
|
+
}
|
|
86
|
+
function localParentPath(childPath = '', markdown = '') {
|
|
87
|
+
try {
|
|
88
|
+
const trace = String(parseArtifactMarkdown(markdown)?.envelope?.parent?.trace || '').trim();
|
|
89
|
+
if (!trace || /^(?:https?:|github:|raw:)/i.test(trace)) return '';
|
|
90
|
+
return norm(path.posix.join(path.posix.dirname(norm(childPath)), trace.replace(/\\/g, '/')));
|
|
91
|
+
} catch { return ''; }
|
|
92
|
+
}
|
|
93
|
+
function unique(values = []) { return [...new Set(values)]; }
|
|
94
|
+
function norm(value = '') { return String(value || '').replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+|\/+$/g, ''); }
|
|
95
|
+
function finding(severity, code, message, context = {}) { return freeze({ severity, code, message, context }); }
|
|
96
|
+
function freeze(value) { if (Array.isArray(value)) return Object.freeze(value.map(freeze)); if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value; return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, freeze(item)]))); }
|