@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,247 @@
|
|
|
1
|
+
import { portableFinding } from '../findings.js';
|
|
2
|
+
import { qualifyResolvedMachineShape } from './contract.machine-shape.js';
|
|
3
|
+
|
|
4
|
+
export const PORTABLE_FIELD_DOMAIN_VALIDATION_SCHEMA_ID = 'tiinex.portable.field-domain-validation.v1';
|
|
5
|
+
|
|
6
|
+
export function validatePortableFieldDomains(input = {}) {
|
|
7
|
+
const constraints = (input.constraints || []).filter((item) => item?.kind === 'field-domain');
|
|
8
|
+
const parsedDeclarations = input.parsedDeclarations || [];
|
|
9
|
+
const ordinary = input.ordinary || { groups: [] };
|
|
10
|
+
const findings = [];
|
|
11
|
+
const groups = [];
|
|
12
|
+
|
|
13
|
+
for (const constraint of constraints) {
|
|
14
|
+
const qualification = String(constraint.authorityQualification || constraint.declarationQualification || 'unresolved');
|
|
15
|
+
if (qualification === 'valid') continue;
|
|
16
|
+
const state = qualification === 'structurally-invalid' ? 'structurally-invalid' : 'unresolved';
|
|
17
|
+
findings.push(fieldDomainFinding(
|
|
18
|
+
state === 'structurally-invalid' ? 'error' : 'warning',
|
|
19
|
+
state === 'structurally-invalid'
|
|
20
|
+
? 'portable.contract.field-domain.authority.invalid'
|
|
21
|
+
: 'portable.contract.field-domain.authority.unresolved',
|
|
22
|
+
`Field-domain authority is ${state} for ${constraint.sourceGroup || '(unknown group)'} / ${constraint.field || '(unknown field)'}.`,
|
|
23
|
+
state,
|
|
24
|
+
{ constraint, reasons: constraint.authorityFindings || constraint.declarationFindings || [] }
|
|
25
|
+
));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const valid = constraints.filter((item) => String(item.authorityQualification || item.declarationQualification || '') === 'valid' && item.targetGroup && item.field);
|
|
29
|
+
const byTarget = groupConstraints(valid);
|
|
30
|
+
for (const bucket of byTarget.values()) {
|
|
31
|
+
const conflict = detectDeterministicConflict(bucket.contributions);
|
|
32
|
+
if (conflict) {
|
|
33
|
+
findings.push(fieldDomainFinding(
|
|
34
|
+
'error',
|
|
35
|
+
'portable.contract.field-domain.authority.unsatisfiable',
|
|
36
|
+
`Field-domain authority is unsatisfiable for ${bucket.group}.${bucket.field}.`,
|
|
37
|
+
'contradictory',
|
|
38
|
+
{ group: bucket.group, field: bucket.field, contributions: bucket.contributions, conflict }
|
|
39
|
+
));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const occurrences = collectFieldOccurrences(bucket.group, bucket.field, parsedDeclarations, ordinary);
|
|
43
|
+
const projected = [];
|
|
44
|
+
for (const occurrence of occurrences) {
|
|
45
|
+
const results = bucket.contributions.map((contribution) => evaluateContribution(occurrence.value, contribution));
|
|
46
|
+
const qualification = summarizeContributionResults(results);
|
|
47
|
+
projected.push(Object.freeze({
|
|
48
|
+
owner: occurrence.owner,
|
|
49
|
+
value: occurrence.value,
|
|
50
|
+
qualification,
|
|
51
|
+
contributions: Object.freeze(results)
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
if (qualification === 'invalid') {
|
|
55
|
+
findings.push(fieldDomainFinding(
|
|
56
|
+
'error',
|
|
57
|
+
'portable.contract.field-domain.value.invalid',
|
|
58
|
+
`Value is outside the allowed field domain for ${bucket.group}.${bucket.field}: ${occurrence.value}.`,
|
|
59
|
+
'structurally-invalid',
|
|
60
|
+
{ group: bucket.group, field: bucket.field, value: occurrence.value, owner: occurrence.owner, contributions: results }
|
|
61
|
+
));
|
|
62
|
+
} else if (qualification === 'extension-candidate') {
|
|
63
|
+
findings.push(fieldDomainFinding(
|
|
64
|
+
'warning',
|
|
65
|
+
'portable.contract.field-domain.extension.unresolved',
|
|
66
|
+
`Value is an unresolved extension candidate for ${bucket.group}.${bucket.field}: ${occurrence.value}.`,
|
|
67
|
+
'unresolved',
|
|
68
|
+
{ group: bucket.group, field: bucket.field, value: occurrence.value, owner: occurrence.owner, contributions: results }
|
|
69
|
+
));
|
|
70
|
+
} else if (qualification === 'authority-unresolved') {
|
|
71
|
+
findings.push(fieldDomainFinding(
|
|
72
|
+
'warning',
|
|
73
|
+
'portable.contract.field-domain.shape.unresolved',
|
|
74
|
+
`Field-domain shape authority cannot be fully evaluated for ${bucket.group}.${bucket.field}: ${occurrence.value}.`,
|
|
75
|
+
'unresolved',
|
|
76
|
+
{ group: bucket.group, field: bucket.field, value: occurrence.value, owner: occurrence.owner, contributions: results }
|
|
77
|
+
));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
groups.push(Object.freeze({
|
|
82
|
+
group: bucket.group,
|
|
83
|
+
field: bucket.field,
|
|
84
|
+
contributions: Object.freeze(bucket.contributions),
|
|
85
|
+
authorityQualification: conflict ? 'contradictory' : 'valid',
|
|
86
|
+
occurrences: Object.freeze(projected)
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return Object.freeze({
|
|
91
|
+
schema: PORTABLE_FIELD_DOMAIN_VALIDATION_SCHEMA_ID,
|
|
92
|
+
constraints: Object.freeze([...constraints]),
|
|
93
|
+
groups: Object.freeze(groups),
|
|
94
|
+
findings: Object.freeze(findings)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function groupConstraints(constraints = []) {
|
|
99
|
+
const out = new Map();
|
|
100
|
+
for (const constraint of constraints) {
|
|
101
|
+
const key = `${exact(constraint.targetGroup)}\u0000${exact(constraint.field)}`;
|
|
102
|
+
if (!out.has(key)) out.set(key, { group: constraint.targetGroup, field: constraint.field, contributions: [] });
|
|
103
|
+
out.get(key).contributions.push(constraint);
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function collectFieldOccurrences(groupName, fieldName, parsedDeclarations = [], ordinary = {}) {
|
|
109
|
+
const out = [];
|
|
110
|
+
const declarationGroup = (parsedDeclarations || []).find((item) => exact(item.contract?.group) === exact(groupName));
|
|
111
|
+
if (declarationGroup) {
|
|
112
|
+
for (const section of declarationGroup.sections || []) {
|
|
113
|
+
if (!section.present) continue;
|
|
114
|
+
for (const entry of section.entries || []) {
|
|
115
|
+
if (entry.name === 'none') continue;
|
|
116
|
+
if (!Object.prototype.hasOwnProperty.call(entry.fields || {}, fieldName)) continue;
|
|
117
|
+
const value = String(entry.fields[fieldName] ?? '');
|
|
118
|
+
if (!value) continue;
|
|
119
|
+
out.push(Object.freeze({
|
|
120
|
+
value,
|
|
121
|
+
owner: Object.freeze({ kind: 'declaration', group: groupName, heading: section.heading, entry: entry.name, field: fieldName })
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const ordinaryGroup = (ordinary.groups || []).find((item) => exact(item.group) === exact(groupName));
|
|
129
|
+
if (ordinaryGroup) {
|
|
130
|
+
const field = (ordinaryGroup.fields || []).find((item) => exact(item.label) === exact(fieldName));
|
|
131
|
+
for (const occurrence of field?.occurrences || []) {
|
|
132
|
+
out.push(Object.freeze({
|
|
133
|
+
value: String(occurrence.value ?? ''),
|
|
134
|
+
owner: Object.freeze({ kind: 'ordinary', group: groupName, heading: ordinaryGroup.target?.heading || '', field: fieldName, line: Number(occurrence.line || 0) })
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function evaluateContribution(value, contribution) {
|
|
142
|
+
const text = String(value ?? '');
|
|
143
|
+
const allowedValues = contribution.allowedValues || [];
|
|
144
|
+
const shapeAuthorities = contribution.allowedShapeAuthorities || [];
|
|
145
|
+
const literalMatch = allowedValues.some((candidate) => String(candidate) === text);
|
|
146
|
+
if (literalMatch) return contributionResult(contribution, 'core', 'allowed-value', 'matched');
|
|
147
|
+
|
|
148
|
+
// `unknown` is an uncertainty sentinel, never an extension escape hatch and never
|
|
149
|
+
// rescued by shape authority when it is not explicitly allowed by every contribution.
|
|
150
|
+
if (text === 'unknown') return contributionResult(contribution, 'invalid', 'unknown-not-allowed', 'not-matched');
|
|
151
|
+
|
|
152
|
+
let supportedShapeSeen = false;
|
|
153
|
+
let unresolvedShapeSeen = false;
|
|
154
|
+
const shapeResults = [];
|
|
155
|
+
for (const authority of shapeAuthorities) {
|
|
156
|
+
const result = qualifyResolvedMachineShape(text, authority);
|
|
157
|
+
shapeResults.push(Object.freeze({
|
|
158
|
+
shapeLabel: authority.shapeLabel || '',
|
|
159
|
+
qualification: result.qualification,
|
|
160
|
+
authorityQualification: authority.qualification || 'unresolved',
|
|
161
|
+
resolvedDefinitionProvenance: authority.resolvedDefinitionProvenance || null,
|
|
162
|
+
findings: authority.findings || Object.freeze([])
|
|
163
|
+
}));
|
|
164
|
+
if (result.qualification === 'matched') return contributionResult(contribution, 'core', 'allowed-shape', 'matched', authority.shapeLabel, shapeResults);
|
|
165
|
+
if (result.qualification === 'not-matched') supportedShapeSeen = true;
|
|
166
|
+
else unresolvedShapeSeen = true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// A declared Allowed Shape with no compiled authority must never be treated as a
|
|
170
|
+
// closed no-match. This also protects callers carrying older/pre-resolution data.
|
|
171
|
+
if ((contribution.allowedShapes || []).length > shapeAuthorities.length) unresolvedShapeSeen = true;
|
|
172
|
+
if (unresolvedShapeSeen) return contributionResult(contribution, 'authority-unresolved', 'allowed-shape', 'unresolved', '', shapeResults);
|
|
173
|
+
if (contribution.domainPolicy === 'extension-authorized') return contributionResult(contribution, 'extension-candidate', 'extension-policy', 'unresolved', '', shapeResults);
|
|
174
|
+
return contributionResult(contribution, 'invalid', supportedShapeSeen ? 'allowed-shape' : 'allowed-value', 'not-matched', '', shapeResults);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function contributionResult(contribution, qualification, authority, match, shape = '', shapeResults = []) {
|
|
178
|
+
return Object.freeze({
|
|
179
|
+
qualification,
|
|
180
|
+
authority,
|
|
181
|
+
match,
|
|
182
|
+
matchedShape: shape,
|
|
183
|
+
shapeResults: Object.freeze([...shapeResults]),
|
|
184
|
+
sourceSchemaId: contribution.sourceSchemaId || '',
|
|
185
|
+
sourceGroup: contribution.sourceGroup || '',
|
|
186
|
+
targetGroup: contribution.targetGroup || '',
|
|
187
|
+
targetMode: contribution.targetMode || '',
|
|
188
|
+
targetOwnership: contribution.targetOwnership || '',
|
|
189
|
+
ownershipSourceSchemaIds: contribution.ownershipSourceSchemaIds || Object.freeze([]),
|
|
190
|
+
appliesToTarget: contribution.appliesToTarget || '',
|
|
191
|
+
field: contribution.field || '',
|
|
192
|
+
allowedValues: contribution.allowedValues || Object.freeze([]),
|
|
193
|
+
allowedShapes: contribution.allowedShapes || Object.freeze([]),
|
|
194
|
+
allowedShapeAuthorities: contribution.allowedShapeAuthorities || Object.freeze([]),
|
|
195
|
+
domainPolicy: contribution.domainPolicy || '',
|
|
196
|
+
declarationLine: Number(contribution.declarationLine || 0)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function summarizeContributionResults(results = []) {
|
|
201
|
+
if (results.some((item) => item.qualification === 'invalid')) return 'invalid';
|
|
202
|
+
if (results.some((item) => item.qualification === 'authority-unresolved')) return 'authority-unresolved';
|
|
203
|
+
if (results.some((item) => item.qualification === 'extension-candidate')) return 'extension-candidate';
|
|
204
|
+
return 'core';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function detectDeterministicConflict(contributions = []) {
|
|
208
|
+
const closed = contributions.filter((item) => item.domainPolicy === 'closed');
|
|
209
|
+
if (closed.length < 2) return null;
|
|
210
|
+
|
|
211
|
+
const literalCandidates = [...new Set(closed.flatMap((item) => item.allowedValues || []))];
|
|
212
|
+
for (const candidate of literalCandidates) {
|
|
213
|
+
const matches = closed.map((item) => coreMatch(candidate, item));
|
|
214
|
+
if (matches.every((item) => item === 'matched')) return null;
|
|
215
|
+
if (matches.some((item) => item === 'unresolved')) return null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Proving two arbitrary lexical languages disjoint is outside this bounded surface.
|
|
219
|
+
// If any contribution offers a machine shape, retain the obligations and validate
|
|
220
|
+
// concrete values instead of inventing an intersection theorem.
|
|
221
|
+
if (closed.some((item) => (item.allowedShapes || []).length)) return null;
|
|
222
|
+
return Object.freeze({
|
|
223
|
+
kind: 'empty-domain-intersection',
|
|
224
|
+
sourceGroups: Object.freeze(closed.map((item) => item.sourceGroup || ''))
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function coreMatch(value, contribution) {
|
|
229
|
+
if ((contribution.allowedValues || []).some((candidate) => String(candidate) === String(value))) return 'matched';
|
|
230
|
+
let unresolved = false;
|
|
231
|
+
const authorities = contribution.allowedShapeAuthorities || [];
|
|
232
|
+
if ((contribution.allowedShapes || []).length > authorities.length) unresolved = true;
|
|
233
|
+
for (const authority of authorities) {
|
|
234
|
+
const result = qualifyResolvedMachineShape(value, authority);
|
|
235
|
+
if (result.qualification === 'matched') return 'matched';
|
|
236
|
+
if (result.qualification === 'unresolved') unresolved = true;
|
|
237
|
+
}
|
|
238
|
+
return unresolved ? 'unresolved' : 'not-matched';
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function fieldDomainFinding(severity, code, message, state, extra = {}) {
|
|
242
|
+
return portableFinding(severity, code, message, { ...extra, state });
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function exact(value = '') {
|
|
246
|
+
return String(value || '').trim();
|
|
247
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { resolveFieldDomainShapeAuthoritiesAcrossChain } from './contract.machine-shape.js';
|
|
2
|
+
|
|
3
|
+
export function compileFieldShapeRequirements(document = {}) {
|
|
4
|
+
const sourceSchemaId = String(document?.schemaId || '').trim();
|
|
5
|
+
const out = [];
|
|
6
|
+
for (const group of document?.validation?.groups || []) {
|
|
7
|
+
const allowedShapes = unique(categoryItems(group, ['Allowed Shapes']).map(cleanToken));
|
|
8
|
+
if (!allowedShapes.length) continue;
|
|
9
|
+
let fields = unique(categoryItems(group, ['Fields']).map(cleanToken));
|
|
10
|
+
if (!fields.length && /\s+Field$/u.test(String(group?.name || ''))) fields = [String(group.name).replace(/\s+Field$/u, '').trim()];
|
|
11
|
+
if (!fields.length) continue;
|
|
12
|
+
for (const field of fields) out.push(Object.freeze({ kind: 'field-shape', sourceSchemaId, group: String(group.name || ''), field, allowedShapes: Object.freeze(allowedShapes) }));
|
|
13
|
+
}
|
|
14
|
+
return Object.freeze(out);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function resolveFieldShapeRequirements(requirements = [], compiledLineage = []) {
|
|
18
|
+
if (!requirements.length) return Object.freeze([]);
|
|
19
|
+
const faux = requirements.map((requirement) => Object.freeze({ ...requirement, kind: 'field-domain', policy: 'closed', allowedValues: Object.freeze([]) }));
|
|
20
|
+
const resolved = resolveFieldDomainShapeAuthoritiesAcrossChain(faux, compiledLineage);
|
|
21
|
+
return Object.freeze(resolved.map((item) => Object.freeze({
|
|
22
|
+
kind: 'field-shape', sourceSchemaId: item.sourceSchemaId, group: item.group, field: item.field,
|
|
23
|
+
allowedShapes: Object.freeze([...(item.allowedShapes || [])]),
|
|
24
|
+
allowedShapeAuthorities: Object.freeze([...(item.allowedShapeAuthorities || [])])
|
|
25
|
+
})));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function categoryItems(group = {}, names = []) {
|
|
29
|
+
const wanted = new Set(names.map(exactToken));
|
|
30
|
+
return (group.categories || []).flatMap((category) => wanted.has(exactToken(category.name)) ? category.items : []);
|
|
31
|
+
}
|
|
32
|
+
function cleanToken(value = '') { return String(value || '').trim().replace(/^`|`$/g, '').trim(); }
|
|
33
|
+
function exactToken(value = '') { return String(value || '').trim(); }
|
|
34
|
+
function unique(values = []) { return [...new Set(values.map((value) => String(value || '').trim()).filter(Boolean))]; }
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export const INLINE_INHERITANCE_OVERRIDE_CATEGORY = 'Inheritance Overrides';
|
|
2
|
+
export const INLINE_INHERITANCE_OVERRIDE_REQUIRED_FIELDS = Object.freeze(['Merge Operation', 'Parent Schema', 'Parent Node', 'Child Node']);
|
|
3
|
+
export const INLINE_INHERITANCE_OVERRIDE_OPTIONAL_FIELDS = Object.freeze(['Reason', 'Effective Result']);
|
|
4
|
+
|
|
5
|
+
export function compileInlineSchemaInheritanceOverrides(document = {}) {
|
|
6
|
+
const sourceSchemaId = String(document?.schemaId || '').trim();
|
|
7
|
+
const declarations = [];
|
|
8
|
+
const findings = [];
|
|
9
|
+
const seenNames = new Set();
|
|
10
|
+
|
|
11
|
+
for (const group of document?.validation?.groups || []) {
|
|
12
|
+
const categories = (group?.categories || []).filter((category) => exact(category?.name) === INLINE_INHERITANCE_OVERRIDE_CATEGORY);
|
|
13
|
+
if (categories.length > 1) findings.push(`Inheritance Overrides category appears ${categories.length} times in contract group ${group?.name || '(unnamed)'}.`);
|
|
14
|
+
for (const category of categories) {
|
|
15
|
+
if (!(category?.nodes || []).length) findings.push(`Inheritance Overrides in contract group ${group?.name || '(unnamed)'} must contain at least one Named Declaration.`);
|
|
16
|
+
for (const node of category?.nodes || []) {
|
|
17
|
+
const parsed = parseOverrideDeclaration(node, { sourceSchemaId, sourceGroup: String(group?.name || '') });
|
|
18
|
+
if (seenNames.has(parsed.name)) findings.push(`Inheritance Overrides declaration name is duplicated in ${sourceSchemaId || '(unknown schema)'}: ${parsed.name || '(unnamed)'}.`);
|
|
19
|
+
seenNames.add(parsed.name);
|
|
20
|
+
findings.push(...parsed.findings);
|
|
21
|
+
declarations.push(parsed.declaration);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return Object.freeze({
|
|
27
|
+
schema: 'tiinex.portable.inline-schema-inheritance-overrides.v1',
|
|
28
|
+
sourceSchemaId,
|
|
29
|
+
state: findings.length ? 'unresolved' : declarations.length ? 'declared' : 'not-declared',
|
|
30
|
+
declarations: Object.freeze(declarations),
|
|
31
|
+
findings: Object.freeze(findings)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function qualifyInlineInheritanceOverrideAuthority(rootCompiled = null) {
|
|
36
|
+
const findings = [];
|
|
37
|
+
if (!rootCompiled || String(rootCompiled.schemaId || '') !== 'tiinex.root.v1') return blockedAuthority('Compiled Root contract is unavailable for inline inheritance override authority.');
|
|
38
|
+
const syntax = exactGroups(rootCompiled?.validation?.groups || [], 'Contract Syntax');
|
|
39
|
+
if (syntax.length !== 1) findings.push(`Root Contract Syntax resolves to ${syntax.length} groups.`);
|
|
40
|
+
const known = syntax.length === 1 ? exactCategories(syntax[0], 'Known Category Labels') : [];
|
|
41
|
+
if (known.length !== 1) findings.push(`Root Known Category Labels resolves to ${known.length} categories.`);
|
|
42
|
+
if (known.length === 1 && !(known[0].items || []).some((item) => exact(item) === INLINE_INHERITANCE_OVERRIDE_CATEGORY)) findings.push('Root Known Category Labels does not declare Inheritance Overrides.');
|
|
43
|
+
|
|
44
|
+
const groups = exactGroups(rootCompiled?.validation?.groups || [], INLINE_INHERITANCE_OVERRIDE_CATEGORY);
|
|
45
|
+
if (groups.length !== 1) findings.push(`Root Inheritance Overrides authority resolves to ${groups.length} groups.`);
|
|
46
|
+
if (groups.length === 1) {
|
|
47
|
+
const group = groups[0];
|
|
48
|
+
const entryShape = categoryItems(group, 'Entry Shape');
|
|
49
|
+
const required = categoryItems(group, 'Required Fields');
|
|
50
|
+
const optional = categoryItems(group, 'Optional Fields');
|
|
51
|
+
if (!entryShape.includes('Named Declaration')) findings.push('Root Inheritance Overrides authority does not declare Entry Shape: Named Declaration.');
|
|
52
|
+
for (const field of INLINE_INHERITANCE_OVERRIDE_REQUIRED_FIELDS) if (!required.includes(field)) findings.push(`Root Inheritance Overrides authority is missing Required Field: ${field}.`);
|
|
53
|
+
for (const field of INLINE_INHERITANCE_OVERRIDE_OPTIONAL_FIELDS) if (!optional.includes(field)) findings.push(`Root Inheritance Overrides authority is missing Optional Field: ${field}.`);
|
|
54
|
+
}
|
|
55
|
+
return Object.freeze({ state: findings.length ? 'unresolved' : 'qualified', findings: Object.freeze(findings) });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function parseOverrideDeclaration(node = {}, context = {}) {
|
|
59
|
+
const name = exact(node?.value);
|
|
60
|
+
const findings = [];
|
|
61
|
+
const fields = {};
|
|
62
|
+
if (!name || /^.+:\s*/.test(name)) findings.push('Inheritance Overrides declaration must have one exact non-field declaration name.');
|
|
63
|
+
if (!(node?.children || []).length) findings.push(`Inheritance Overrides declaration ${name || '(unnamed)'} has no declaration fields.`);
|
|
64
|
+
for (const child of node?.children || []) {
|
|
65
|
+
if ((child?.children || []).length) findings.push(`Inheritance Overrides declaration ${name || '(unnamed)'} field nesting must be exactly one level.`);
|
|
66
|
+
const parsed = parseField(child?.value);
|
|
67
|
+
if (!parsed) {
|
|
68
|
+
findings.push(`Inheritance Overrides declaration ${name || '(unnamed)'} contains malformed field: ${exact(child?.value) || '(empty)'}.`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (Object.prototype.hasOwnProperty.call(fields, parsed.field)) findings.push(`Inheritance Overrides declaration ${name || '(unnamed)'} duplicates field ${parsed.field}.`);
|
|
72
|
+
fields[parsed.field] = parsed.value;
|
|
73
|
+
}
|
|
74
|
+
const allowed = new Set([...INLINE_INHERITANCE_OVERRIDE_REQUIRED_FIELDS, ...INLINE_INHERITANCE_OVERRIDE_OPTIONAL_FIELDS]);
|
|
75
|
+
for (const field of Object.keys(fields)) if (!allowed.has(field)) findings.push(`Inheritance Overrides declaration ${name || '(unnamed)'} uses undeclared field ${field}.`);
|
|
76
|
+
for (const field of INLINE_INHERITANCE_OVERRIDE_REQUIRED_FIELDS) if (!exact(fields[field])) findings.push(`Inheritance Overrides declaration ${name || '(unnamed)'} is missing ${field}.`);
|
|
77
|
+
|
|
78
|
+
const declaration = Object.freeze({
|
|
79
|
+
name,
|
|
80
|
+
sourceSchemaId: context.sourceSchemaId,
|
|
81
|
+
sourceGroup: context.sourceGroup,
|
|
82
|
+
declarationLine: Number(node?.line || 0),
|
|
83
|
+
operation: exact(fields['Merge Operation']),
|
|
84
|
+
parentSchemaId: exact(fields['Parent Schema']),
|
|
85
|
+
parentNode: exact(fields['Parent Node']),
|
|
86
|
+
childNode: exact(fields['Child Node']),
|
|
87
|
+
reason: exact(fields.Reason),
|
|
88
|
+
effectiveResult: exact(fields['Effective Result'])
|
|
89
|
+
});
|
|
90
|
+
return Object.freeze({ declaration, findings: Object.freeze(findings) });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function parseField(value = '') {
|
|
94
|
+
const match = String(value || '').match(/^([^:]+):\s*(.*?)\s*$/);
|
|
95
|
+
if (!match) return null;
|
|
96
|
+
return { field: exact(match[1]), value: exact(match[2]) };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function exactGroups(groups = [], name = '') { return (groups || []).filter((group) => exact(group?.name) === exact(name)); }
|
|
100
|
+
function exactCategories(group = {}, name = '') { return (group?.categories || []).filter((category) => exact(category?.name) === exact(name)); }
|
|
101
|
+
function categoryItems(group = {}, name = '') { return exactCategories(group, name).flatMap((category) => (category?.items || []).map(exact)); }
|
|
102
|
+
function exact(value = '') { return String(value || '').trim(); }
|
|
103
|
+
function blockedAuthority(message) { return Object.freeze({ state: 'unresolved', findings: Object.freeze([message]) }); }
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { compileOrdinaryGroupContribution } from './ordinary.contract.js';
|
|
2
|
+
import { qualifyInlineInheritanceOverrideAuthority } from './contract.inheritance.inline.js';
|
|
3
|
+
import { parseStandaloneInheritanceRecord } from './contract.inheritance.record.js';
|
|
4
|
+
|
|
5
|
+
export const PORTABLE_SCHEMA_INHERITANCE_RESOLUTION_SCHEMA_ID = 'tiinex.portable.schema-inheritance-resolution.v1';
|
|
6
|
+
|
|
7
|
+
export function applySchemaInheritanceOverrides(compiled = [], artifacts = []) {
|
|
8
|
+
const baseComposition = Object.freeze([...compiled]);
|
|
9
|
+
const declarations = compiled.flatMap((item) => item?.inheritanceOverrides?.declarations || []);
|
|
10
|
+
const findings = compiled.flatMap((item) => item?.inheritanceOverrides?.findings || []);
|
|
11
|
+
const standaloneInputs = (Array.isArray(artifacts) ? artifacts : [artifacts]).filter(Boolean);
|
|
12
|
+
const corroborations = [];
|
|
13
|
+
|
|
14
|
+
if (declarations.length) {
|
|
15
|
+
const authority = qualifyInlineInheritanceOverrideAuthority(compiled.find((item) => String(item?.schemaId || '') === 'tiinex.root.v1'));
|
|
16
|
+
findings.push(...authority.findings);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const qualified = declarations.map((declaration) => qualifyOverrideDeclaration(declaration, compiled));
|
|
20
|
+
for (const item of qualified) findings.push(...item.findings);
|
|
21
|
+
findings.push(...competingOverrideFindings(qualified));
|
|
22
|
+
findings.push(...compareStandaloneRecords(standaloneInputs, declarations, corroborations));
|
|
23
|
+
|
|
24
|
+
if (findings.length) return result(baseComposition, 'unresolved', declarations, [], findings, corroborations);
|
|
25
|
+
if (!declarations.length) return result(baseComposition, 'not-declared', declarations, [], [], corroborations);
|
|
26
|
+
|
|
27
|
+
let composition = [...compiled];
|
|
28
|
+
const applications = [];
|
|
29
|
+
for (const item of qualified) {
|
|
30
|
+
const applied = applyQualifiedOverride(composition, item);
|
|
31
|
+
if (applied.state !== 'qualified') return result(baseComposition, 'unresolved', declarations, [], applied.findings, corroborations);
|
|
32
|
+
composition = [...applied.composition];
|
|
33
|
+
applications.push(applied.application);
|
|
34
|
+
}
|
|
35
|
+
return result(Object.freeze(composition), 'qualified', declarations, applications, [], corroborations);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function qualifyOverrideDeclaration(declaration = {}, composition = []) {
|
|
39
|
+
const findings = [];
|
|
40
|
+
if (String(declaration.operation || '') !== 'override') findings.push(`Inheritance Overrides declaration ${label(declaration)} must use Merge Operation: override.`);
|
|
41
|
+
const childSchemaId = String(declaration.sourceSchemaId || '');
|
|
42
|
+
const parentSchemaId = String(declaration.parentSchemaId || '');
|
|
43
|
+
const parentIndexes = exactSchemaIndexes(composition, parentSchemaId);
|
|
44
|
+
const childIndexes = exactSchemaIndexes(composition, childSchemaId);
|
|
45
|
+
if (parentIndexes.length !== 1) findings.push(`Inheritance Overrides Parent Schema ${parentSchemaId || '(missing)'} resolves to ${parentIndexes.length} supplied lineage positions.`);
|
|
46
|
+
if (childIndexes.length !== 1) findings.push(`Inheritance Overrides declaring Child Schema ${childSchemaId || '(missing)'} resolves to ${childIndexes.length} supplied lineage positions.`);
|
|
47
|
+
const parentIndex = parentIndexes[0] ?? -1;
|
|
48
|
+
const childIndex = childIndexes[0] ?? -1;
|
|
49
|
+
if (parentIndex >= 0 && childIndex >= 0 && childIndex <= parentIndex) findings.push('Inheritance Overrides Parent Schema must be an actual ancestor of the declaring child schema.');
|
|
50
|
+
|
|
51
|
+
const parentNode = parseContractNode(declaration.parentNode);
|
|
52
|
+
const childNode = parseContractNode(declaration.childNode);
|
|
53
|
+
if (!parentNode) findings.push(`Parent Node is not one exact Schema Validation Contract / group / category path: ${declaration.parentNode || '(missing)'}.`);
|
|
54
|
+
if (!childNode) findings.push(`Child Node is not one exact Schema Validation Contract / group / category path: ${declaration.childNode || '(missing)'}.`);
|
|
55
|
+
|
|
56
|
+
const parent = parentIndex >= 0 ? composition[parentIndex] : null;
|
|
57
|
+
const child = childIndex >= 0 ? composition[childIndex] : null;
|
|
58
|
+
const parentMatch = parentNode && parent ? exactCategoryMatch(parent.validation?.groups || [], parentNode) : null;
|
|
59
|
+
const childMatch = childNode && child ? exactCategoryMatch(child.validation?.groups || [], childNode) : null;
|
|
60
|
+
if (parentMatch?.state === 'unresolved') findings.push(`Parent Node must resolve exactly once in ${parentSchemaId}: ${declaration.parentNode}; observed ${parentMatch.count}.`);
|
|
61
|
+
if (childMatch?.state === 'unresolved') findings.push(`Child Node must resolve exactly once in ${childSchemaId}: ${declaration.childNode}; observed ${childMatch.count}.`);
|
|
62
|
+
|
|
63
|
+
let suppressedGroups = Object.freeze([]);
|
|
64
|
+
if (!findings.length && parentNode.category === 'Required Shape' && childNode.category === 'Required Shape') {
|
|
65
|
+
const structural = qualifyRequiredShapeStructuralDeactivation(parent, child, parentMatch.category, childMatch.category, composition);
|
|
66
|
+
findings.push(...structural.findings);
|
|
67
|
+
suppressedGroups = structural.suppressedGroups;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Object.freeze({
|
|
71
|
+
state: findings.length ? 'unresolved' : 'qualified', findings: Object.freeze(findings), declaration,
|
|
72
|
+
parentSchemaId, childSchemaId, parentIndex, childIndex, parentNode, childNode,
|
|
73
|
+
parentContribution: parentMatch?.category || null, childContribution: childMatch?.category || null,
|
|
74
|
+
suppressedGroups
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function qualifyRequiredShapeStructuralDeactivation(parent = {}, child = {}, parentCategory = {}, childCategory = {}, composition = []) {
|
|
79
|
+
void child;
|
|
80
|
+
const findings = [];
|
|
81
|
+
const parentHeadings = headingRequirements(parentCategory.items || []);
|
|
82
|
+
const childHeadings = headingRequirements(childCategory.items || []);
|
|
83
|
+
if (!parentHeadings.length) findings.push('Required Shape Parent Node has no machine-readable heading requirements.');
|
|
84
|
+
if (!childHeadings.length) findings.push('Required Shape Child Node has no machine-readable heading requirements.');
|
|
85
|
+
const rootAuthority = composition.find((item) => item?.validation?.ordinaryFieldAuthority?.state === 'available')?.validation?.ordinaryFieldAuthority || null;
|
|
86
|
+
const replacement = new Set(childHeadings.map((item) => headingKey(item.level, item.title)));
|
|
87
|
+
const removedSecondLevel = new Set(parentHeadings.filter((item) => item.level === 2 && !replacement.has(headingKey(item.level, item.title))).map((item) => item.title));
|
|
88
|
+
if (removedSecondLevel.size && !rootAuthority) findings.push('Root ordinary instance-field target authority is unavailable for Required Shape structural deactivation.');
|
|
89
|
+
|
|
90
|
+
const suppressed = [];
|
|
91
|
+
if (rootAuthority) {
|
|
92
|
+
for (const group of parent?.validation?.groups || []) {
|
|
93
|
+
const contribution = compileOrdinaryGroupContribution(group, rootAuthority);
|
|
94
|
+
if (!contribution) continue;
|
|
95
|
+
if (contribution.target?.qualification !== 'valid') {
|
|
96
|
+
findings.push(`Parent ordinary group ${group.name || '(unnamed)'} has unresolved Instance Target ownership during Required Shape override.`);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (contribution.target.level === 2 && removedSecondLevel.has(contribution.target.title)) suppressed.push(group.name);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return Object.freeze({ state: findings.length ? 'unresolved' : 'qualified', findings: Object.freeze(findings), suppressedGroups: Object.freeze(unique(suppressed)) });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function competingOverrideFindings(qualified = []) {
|
|
106
|
+
const findings = [];
|
|
107
|
+
const byParent = new Map();
|
|
108
|
+
for (const item of qualified) {
|
|
109
|
+
if (item.state !== 'qualified') continue;
|
|
110
|
+
const key = `${item.parentSchemaId}\u0000${item.declaration.parentNode}`;
|
|
111
|
+
if (!byParent.has(key)) byParent.set(key, []);
|
|
112
|
+
byParent.get(key).push(item);
|
|
113
|
+
}
|
|
114
|
+
for (const items of byParent.values()) if (items.length > 1) findings.push(`Competing active Inheritance Overrides declarations target the same parent contribution: ${items.map((item) => label(item.declaration)).join(', ')}.`);
|
|
115
|
+
return findings;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function compareStandaloneRecords(inputs = [], declarations = [], corroborations = []) {
|
|
119
|
+
const findings = [];
|
|
120
|
+
for (const input of inputs) {
|
|
121
|
+
const record = parseStandaloneInheritanceRecord(input);
|
|
122
|
+
if (record.state !== 'qualified') { findings.push(...record.findings); continue; }
|
|
123
|
+
const matches = declarations.filter((declaration) => declaration.name === record.handle && declaration.sourceSchemaId === record.childSchemaId);
|
|
124
|
+
if (matches.length !== 1) {
|
|
125
|
+
findings.push(`Standalone inheritance record ${record.handle || '(unnamed)'} has ${matches.length} matching canonical inline declarations; standalone records cannot add schema-local override authority.`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const declaration = matches[0];
|
|
129
|
+
for (const rule of record.rules) {
|
|
130
|
+
const exact = rule.operation === declaration.operation
|
|
131
|
+
&& record.parentSchemaId === declaration.parentSchemaId
|
|
132
|
+
&& record.childSchemaId === declaration.sourceSchemaId
|
|
133
|
+
&& rule.parentNode === declaration.parentNode
|
|
134
|
+
&& rule.childNode === declaration.childNode;
|
|
135
|
+
if (!exact) findings.push(`Standalone inheritance record ${record.handle} disagrees with the canonical inline declaration.`);
|
|
136
|
+
else corroborations.push(Object.freeze({ handle: record.handle, source: 'tiinex.schema.inheritance.v1', state: 'corroborating-record' }));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return findings;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function applyQualifiedOverride(composition = [], qualified = {}) {
|
|
143
|
+
const parent = composition[qualified.parentIndex];
|
|
144
|
+
const transformedParent = deactivateParentContribution(parent, qualified.parentNode, new Set(qualified.suppressedGroups || []));
|
|
145
|
+
const next = [...composition];
|
|
146
|
+
next[qualified.parentIndex] = transformedParent;
|
|
147
|
+
const declaration = qualified.declaration;
|
|
148
|
+
const application = Object.freeze({
|
|
149
|
+
handle: declaration.name,
|
|
150
|
+
declaration: Object.freeze({ sourceSchemaId: declaration.sourceSchemaId, sourceGroup: declaration.sourceGroup, name: declaration.name, line: declaration.declarationLine, reason: declaration.reason, effectiveResult: declaration.effectiveResult }),
|
|
151
|
+
operation: declaration.operation,
|
|
152
|
+
parentSchemaId: qualified.parentSchemaId,
|
|
153
|
+
childSchemaId: qualified.childSchemaId,
|
|
154
|
+
parentNode: declaration.parentNode,
|
|
155
|
+
childNode: declaration.childNode,
|
|
156
|
+
state: 'applied',
|
|
157
|
+
deactivatedContributions: Object.freeze([
|
|
158
|
+
Object.freeze({ sourceSchemaId: qualified.parentSchemaId, group: qualified.parentNode.group, category: qualified.parentNode.category, state: 'inactive', items: Object.freeze([...(qualified.parentContribution?.items || [])]), declarationName: declaration.name }),
|
|
159
|
+
...(qualified.suppressedGroups || []).map((group) => Object.freeze({ sourceSchemaId: qualified.parentSchemaId, group, category: 'ordinary-instance-field-group', state: 'inactive', items: Object.freeze([]), declarationName: declaration.name }))
|
|
160
|
+
]),
|
|
161
|
+
replacementContribution: Object.freeze({ sourceSchemaId: qualified.childSchemaId, group: qualified.childNode.group, category: qualified.childNode.category, state: 'active', items: Object.freeze([...(qualified.childContribution?.items || [])]), declarationName: declaration.name })
|
|
162
|
+
});
|
|
163
|
+
return Object.freeze({ state: 'qualified', findings: Object.freeze([]), composition: Object.freeze(next), application });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function deactivateParentContribution(parent = {}, node = {}, suppressedGroups = new Set()) {
|
|
167
|
+
const groups = (parent.validation?.groups || []).flatMap((group) => {
|
|
168
|
+
if (suppressedGroups.has(String(group.name || ''))) return [];
|
|
169
|
+
if (String(group.name || '') !== node.group) return [group];
|
|
170
|
+
const categories = (group.categories || []).filter((category) => String(category.name || '') !== node.category);
|
|
171
|
+
return [Object.freeze({ ...group, categories: Object.freeze(categories) })];
|
|
172
|
+
});
|
|
173
|
+
const declarationNames = new Set((parent.declarations || []).map((item) => String(item.group || '')));
|
|
174
|
+
return Object.freeze({
|
|
175
|
+
...parent,
|
|
176
|
+
validation: Object.freeze({
|
|
177
|
+
...parent.validation,
|
|
178
|
+
groups: Object.freeze(groups),
|
|
179
|
+
requiredSections: Object.freeze(requiredSectionsFromGroups(groups)),
|
|
180
|
+
requiredHeadings: Object.freeze(requiredHeadingsFromGroups(groups)),
|
|
181
|
+
optionalSections: Object.freeze(optionalSectionsFromGroups(groups)),
|
|
182
|
+
requiredFields: Object.freeze(fieldsFromGroups(groups, declarationNames, 'Required Fields', true)),
|
|
183
|
+
optionalFields: Object.freeze(fieldsFromGroups(groups, declarationNames, 'Optional Fields', false)),
|
|
184
|
+
requiredEntries: Object.freeze((parent.validation?.requiredEntries || []).map((item) => Object.freeze({ ...item, targetHeadings: Object.freeze((item.targetHeadings || []).filter((heading) => !suppressedGroups.has(stripHeading(heading)))) })))
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function exactCategoryMatch(groups = [], node = {}) {
|
|
190
|
+
const groupMatches = (groups || []).filter((item) => String(item.name || '') === node.group);
|
|
191
|
+
if (groupMatches.length !== 1) return Object.freeze({ state: 'unresolved', count: groupMatches.length, category: null });
|
|
192
|
+
const categoryMatches = (groupMatches[0].categories || []).filter((item) => String(item.name || '') === node.category);
|
|
193
|
+
return categoryMatches.length === 1 ? Object.freeze({ state: 'qualified', count: 1, category: categoryMatches[0] }) : Object.freeze({ state: 'unresolved', count: categoryMatches.length, category: null });
|
|
194
|
+
}
|
|
195
|
+
function exactSchemaIndexes(composition = [], schemaId = '') { return composition.map((item, index) => String(item?.schemaId || '') === schemaId ? index : -1).filter((index) => index >= 0); }
|
|
196
|
+
function parseContractNode(value = '') { const parts = String(value || '').split('/').map((item) => item.trim()).filter(Boolean); return parts.length === 3 && parts[0] === 'Schema Validation Contract' ? Object.freeze({ contract: parts[0], group: parts[1], category: parts[2] }) : null; }
|
|
197
|
+
function result(composition, state, declarations, applications, findings, corroborations) { return Object.freeze({ composition, resolution: Object.freeze({ schema: PORTABLE_SCHEMA_INHERITANCE_RESOLUTION_SCHEMA_ID, state, declarations: Object.freeze((declarations || []).map((item) => Object.freeze({ ...item }))), applications: Object.freeze(applications), corroborations: Object.freeze(corroborations), findings: Object.freeze(findings) }) }); }
|
|
198
|
+
function requiredSectionsFromGroups(groups = []) { return unique(groups.filter(unconditional).flatMap((group) => group.categories || []).flatMap((category) => structuralSections(category))); }
|
|
199
|
+
function requiredHeadingsFromGroups(groups = []) { const seen = new Set(); return groups.filter(unconditional).flatMap((group) => group.categories || []).filter((category) => ['Required Shape', 'Required Heading'].includes(String(category.name || ''))).flatMap((category) => headingRequirements(category.items || [])).filter((item) => { const key = headingKey(item.level, item.title); if (seen.has(key)) return false; seen.add(key); return true; }).map((item) => Object.freeze({ ...item, source: item.source || '' })); }
|
|
200
|
+
function optionalSectionsFromGroups(groups = []) { return unique(groups.flatMap((group) => group.categories || []).filter((category) => String(category.name || '') === 'Optional Sections').flatMap((category) => category.items || []).map(cleanSection)); }
|
|
201
|
+
function structuralSections(category = {}) { const name = String(category.name || ''); if (['Required Sections', 'Header Sections', 'Footer Sections', 'Required Heading'].includes(name)) return (category.items || []).map(cleanSection); if (name === 'Required Shape') return headingRequirements(category.items || []).map((item) => item.title); return []; }
|
|
202
|
+
function fieldsFromGroups(groups = [], declarationNames = new Set(), categoryName = '', unconditionalOnly = false) { return unique(groups.filter((group) => !declarationNames.has(String(group.name || '')) && (!unconditionalOnly || unconditional(group))).flatMap((group) => group.categories || []).filter((category) => String(category.name || '') === categoryName).flatMap((category) => category.items || []).map(cleanField)); }
|
|
203
|
+
function headingRequirements(items = []) { return items.flatMap((value) => { const text = String(value || ''); const quoted = [...text.matchAll(/`(#{1,6})\s+([^`]+)`/g)].map((match) => ({ level: match[1].length, title: match[2].trim(), source: text })); if (quoted.length) return quoted; const plain = text.match(/^(#{1,6})\s+(.+)$/); return plain ? [{ level: plain[1].length, title: plain[2].trim(), source: text }] : []; }); }
|
|
204
|
+
function unconditional(group = {}) { return !(group.requiredWhen || []).length; }
|
|
205
|
+
function cleanSection(value = '') { return stripHeading(String(value || '').trim().replace(/^`|`$/g, '').replace(/\s+section$/i, '')); }
|
|
206
|
+
function cleanField(value = '') { return String(value || '').trim().replace(/^`|`$/g, '').trim(); }
|
|
207
|
+
function stripHeading(value = '') { return String(value || '').replace(/^#{1,6}\s+/, '').trim(); }
|
|
208
|
+
function headingKey(level, title) { return `${Number(level || 0)}\u0000${String(title || '')}`; }
|
|
209
|
+
function unique(values = []) { return [...new Set(values.map((value) => String(value || '').trim()).filter(Boolean))]; }
|
|
210
|
+
function label(declaration = {}) { return declaration.name || `${declaration.sourceSchemaId || '(unknown schema)'} declaration`; }
|