@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,406 @@
|
|
|
1
|
+
import {
|
|
2
|
+
conditionalContractGroups,
|
|
3
|
+
contractRules,
|
|
4
|
+
creationToolingConfigurationFields,
|
|
5
|
+
optionalCreationInputFields,
|
|
6
|
+
optionalSchemaSections,
|
|
7
|
+
parsePortableSchemaDocument,
|
|
8
|
+
requiredCreationContentInputs,
|
|
9
|
+
requiredCreationInputFields,
|
|
10
|
+
requiredCreationSections,
|
|
11
|
+
requiredSchemaEntries,
|
|
12
|
+
requiredSchemaHeadings,
|
|
13
|
+
requiredSchemaSections
|
|
14
|
+
} from './schema.contract.js';
|
|
15
|
+
import { compileNamedDeclarationContracts } from './named.declarations.js';
|
|
16
|
+
import { compileOrdinaryFieldAuthority, compileOrdinaryInstanceFieldGroups, mergeOrdinaryFieldAuthorities } from './ordinary.contract.js';
|
|
17
|
+
import { compileFieldValueConstraints, resolveFieldDomainConstraintsAcrossChain } from './contract.field-domain.compile.js';
|
|
18
|
+
import { compileMachineShapeDefinitions as compileShapes, resolveFieldDomainShapeAuthoritiesAcrossChain as resolveShapeAuthorities, summarizeMachineShapeAuthority as summarizeShapeAuthority } from './contract.machine-shape.js';
|
|
19
|
+
import { compileFieldShapeRequirements, resolveFieldShapeRequirements } from './contract.field-shape.compile.js';
|
|
20
|
+
import { compileContractConstraints } from './contract.constraints.js';
|
|
21
|
+
import { applySchemaInheritanceOverrides } from './contract.inheritance.js';
|
|
22
|
+
import { compileInlineSchemaInheritanceOverrides } from './contract.inheritance.inline.js';
|
|
23
|
+
|
|
24
|
+
export const PORTABLE_COMPILED_CONTRACT_SCHEMA_ID = 'tiinex.portable.compiled-schema-contract.v1';
|
|
25
|
+
|
|
26
|
+
const STRING_CONTRACT_CACHE_LIMIT = 64;
|
|
27
|
+
const stringContractCache = new Map();
|
|
28
|
+
|
|
29
|
+
function compilePortableSchemaContractForChain(input = '') {
|
|
30
|
+
if (typeof input !== 'string') return compilePortableSchemaContract(input);
|
|
31
|
+
const cached = stringContractCache.get(input);
|
|
32
|
+
if (cached) {
|
|
33
|
+
stringContractCache.delete(input);
|
|
34
|
+
stringContractCache.set(input, cached);
|
|
35
|
+
return cached;
|
|
36
|
+
}
|
|
37
|
+
const compiled = compilePortableSchemaContract(input);
|
|
38
|
+
stringContractCache.set(input, compiled);
|
|
39
|
+
if (stringContractCache.size > STRING_CONTRACT_CACHE_LIMIT) stringContractCache.delete(stringContractCache.keys().next().value);
|
|
40
|
+
return compiled;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function compilePortableSchemaContract(input = '') {
|
|
44
|
+
const document = typeof input === 'string' ? parsePortableSchemaDocument(input) : input;
|
|
45
|
+
const sourceSchemaId = document?.schemaId || '';
|
|
46
|
+
const requiredEntries = requiredSchemaEntries(document);
|
|
47
|
+
const declarations = bindRequiredEntryTargets(compileNamedDeclarationContracts(document?.validation || {}), requiredEntries);
|
|
48
|
+
const bodyRequiredFields = schemaFieldsByContractOwner(document, declarations, 'Required Fields', { unconditionalOnly: true });
|
|
49
|
+
const bodyOptionalFields = schemaFieldsByContractOwner(document, declarations, 'Optional Fields');
|
|
50
|
+
const machineShapeDefinitions = compileShapes(document);
|
|
51
|
+
const rawFieldShapes = compileFieldShapeRequirements(document);
|
|
52
|
+
const inheritanceOverrides = compileInlineSchemaInheritanceOverrides(document);
|
|
53
|
+
const rawConstraints = [
|
|
54
|
+
...compileFieldValueConstraints(document),
|
|
55
|
+
...compileContractConstraints(document, declarations)
|
|
56
|
+
];
|
|
57
|
+
const shapeLineage = [Object.freeze({
|
|
58
|
+
schemaId: sourceSchemaId,
|
|
59
|
+
machineShapes: Object.freeze({ definitions: machineShapeDefinitions })
|
|
60
|
+
})];
|
|
61
|
+
const constraints = resolveShapeAuthorities(rawConstraints, shapeLineage);
|
|
62
|
+
const fieldShapes = resolveFieldShapeRequirements(rawFieldShapes, shapeLineage);
|
|
63
|
+
const compiledRuleKeys = new Set(constraints.flatMap((constraint) => constraint.rule ? [constraint.rule] : []));
|
|
64
|
+
return Object.freeze({
|
|
65
|
+
schema: PORTABLE_COMPILED_CONTRACT_SCHEMA_ID,
|
|
66
|
+
schemaId: document?.schemaId || '',
|
|
67
|
+
parentSchemaId: document?.parentSchemaId || '',
|
|
68
|
+
envelopeSchemaId: document?.envelopeSchemaId || '',
|
|
69
|
+
validation: Object.freeze({
|
|
70
|
+
groups: summarizeGroups(document?.validation || {}, sourceSchemaId),
|
|
71
|
+
requiredSections: Object.freeze(requiredSchemaSections(document)),
|
|
72
|
+
requiredHeadings: requiredSchemaHeadings(document),
|
|
73
|
+
optionalSections: Object.freeze(optionalSchemaSections(document)),
|
|
74
|
+
requiredFields: Object.freeze(bodyRequiredFields),
|
|
75
|
+
optionalFields: Object.freeze(bodyOptionalFields),
|
|
76
|
+
requiredEntries,
|
|
77
|
+
conditionalRequirements: conditionalContractGroups(document?.validation || {}),
|
|
78
|
+
ordinaryFieldAuthority: compileOrdinaryFieldAuthority(document),
|
|
79
|
+
fieldShapes
|
|
80
|
+
}),
|
|
81
|
+
creation: Object.freeze({
|
|
82
|
+
groups: summarizeGroups(document?.creation || {}, sourceSchemaId),
|
|
83
|
+
requiredInputs: Object.freeze(unique([
|
|
84
|
+
...requiredCreationInputFields(document),
|
|
85
|
+
...requiredCreationContentInputs(document)
|
|
86
|
+
])),
|
|
87
|
+
optionalInputs: Object.freeze(optionalCreationInputFields(document)),
|
|
88
|
+
requiredSections: Object.freeze(requiredCreationSections(document)),
|
|
89
|
+
toolingConfigurationFields: Object.freeze(creationToolingConfigurationFields(document))
|
|
90
|
+
}),
|
|
91
|
+
declarations,
|
|
92
|
+
inheritanceOverrides,
|
|
93
|
+
machineShapes: Object.freeze({
|
|
94
|
+
schema: 'tiinex.portable.machine-shape-authority.v1',
|
|
95
|
+
definitions: machineShapeDefinitions
|
|
96
|
+
}),
|
|
97
|
+
constraints: Object.freeze(constraints),
|
|
98
|
+
guidance: Object.freeze({
|
|
99
|
+
validationRules: Object.freeze(contractRules(document?.validation || {}).filter((rule) => !compiledRuleKeys.has(rule))),
|
|
100
|
+
creationRules: Object.freeze(contractRules(document?.creation || {}))
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
export function compilePortableSchemaContractChain(inputs = [], options = {}) {
|
|
107
|
+
const compiled = (Array.isArray(inputs) ? inputs : [inputs]).filter(Boolean).map((input) => compilePortableSchemaContractForChain(input));
|
|
108
|
+
const lineageQualification = qualifyContractChain(compiled);
|
|
109
|
+
const leaf = compiled.at(-1) || compilePortableSchemaContract('');
|
|
110
|
+
const baseComposition = lineageQualification.state === 'contradictory' ? [leaf] : compiled;
|
|
111
|
+
const inheritance = lineageQualification.state === 'valid'
|
|
112
|
+
? applySchemaInheritanceOverrides(baseComposition, options.inheritanceArtifacts || [])
|
|
113
|
+
: Object.freeze({ composition: Object.freeze(baseComposition), resolution: Object.freeze({ schema: 'tiinex.portable.schema-inheritance-resolution.v1', state: 'unresolved', applications: Object.freeze([]), findings: Object.freeze(['Schema inheritance overrides cannot be applied until lineage is valid.']) }) });
|
|
114
|
+
const composition = [...inheritance.composition];
|
|
115
|
+
const qualification = inheritance.resolution.state === 'unresolved'
|
|
116
|
+
? Object.freeze({ state: 'unresolved', complete: false, lineage: Object.freeze([...lineageQualification.lineage]), findings: Object.freeze([...(lineageQualification.findings || []), ...(inheritance.resolution.findings || [])]) })
|
|
117
|
+
: lineageQualification;
|
|
118
|
+
const requiredFields = unique(composition.flatMap((item) => item.validation.requiredFields || []));
|
|
119
|
+
const requiredFieldKeys = new Set(requiredFields.map(exactToken));
|
|
120
|
+
const optionalFields = unique(composition.flatMap((item) => item.validation.optionalFields || []))
|
|
121
|
+
.filter((field) => !requiredFieldKeys.has(exactToken(field)));
|
|
122
|
+
const mergedValidationGroups = mergeGroups(composition.flatMap((item) => item.validation.groups || []));
|
|
123
|
+
const requiredSections = Object.freeze(unique(composition.flatMap((item) => item.validation.requiredSections || [])));
|
|
124
|
+
const optionalSections = Object.freeze(unique(composition.flatMap((item) => item.validation.optionalSections || [])));
|
|
125
|
+
const declarations = mergeDeclarationContracts(composition.flatMap((item) => item.declarations || []));
|
|
126
|
+
const ordinaryFieldAuthority = mergeOrdinaryFieldAuthorities(composition.map((item) => item.validation.ordinaryFieldAuthority).filter(Boolean));
|
|
127
|
+
const ordinaryGroups = compileOrdinaryInstanceFieldGroups({
|
|
128
|
+
groups: mergedValidationGroups,
|
|
129
|
+
declarations,
|
|
130
|
+
requiredSections,
|
|
131
|
+
requiredHeadings: mergeHeadingRequirements(composition.flatMap((item) => item.validation.requiredHeadings || [])),
|
|
132
|
+
optionalSections,
|
|
133
|
+
authority: ordinaryFieldAuthority
|
|
134
|
+
});
|
|
135
|
+
const ownedConstraints = resolveFieldDomainConstraintsAcrossChain(
|
|
136
|
+
composition.flatMap((item) => item.constraints || []),
|
|
137
|
+
mergedValidationGroups,
|
|
138
|
+
composition
|
|
139
|
+
);
|
|
140
|
+
const constraints = resolveShapeAuthorities(ownedConstraints, composition);
|
|
141
|
+
const machineShapes = summarizeShapeAuthority(composition);
|
|
142
|
+
const fieldShapes = Object.freeze(composition.flatMap((item) => item.validation.fieldShapes || []));
|
|
143
|
+
return Object.freeze({
|
|
144
|
+
schema: 'tiinex.portable.compiled-schema-contract-chain.v1',
|
|
145
|
+
schemaId: leaf.schemaId,
|
|
146
|
+
lineage: Object.freeze(qualification.lineage),
|
|
147
|
+
suppliedLineage: Object.freeze(compiled.map((item) => item.schemaId).filter(Boolean)),
|
|
148
|
+
lineageQualification: qualification,
|
|
149
|
+
inheritanceResolution: inheritance.resolution,
|
|
150
|
+
validation: Object.freeze({
|
|
151
|
+
groups: mergedValidationGroups,
|
|
152
|
+
requiredSections,
|
|
153
|
+
requiredHeadings: mergeHeadingRequirements(composition.flatMap((item) => item.validation.requiredHeadings || [])),
|
|
154
|
+
optionalSections,
|
|
155
|
+
requiredFields: Object.freeze(requiredFields),
|
|
156
|
+
optionalFields: Object.freeze(optionalFields),
|
|
157
|
+
requiredEntries: mergeRequiredEntryRequirements(composition.flatMap((item) => item.validation.requiredEntries || [])),
|
|
158
|
+
conditionalRequirements: Object.freeze(composition.flatMap((item) => item.validation.conditionalRequirements || [])),
|
|
159
|
+
ordinaryFieldAuthority,
|
|
160
|
+
ordinaryGroups,
|
|
161
|
+
fieldShapes
|
|
162
|
+
}),
|
|
163
|
+
creation: mergeCreationContracts(composition),
|
|
164
|
+
declarations,
|
|
165
|
+
machineShapes,
|
|
166
|
+
constraints,
|
|
167
|
+
guidance: Object.freeze({
|
|
168
|
+
validationRules: Object.freeze(unique(composition.flatMap((item) => item.guidance.validationRules || []))),
|
|
169
|
+
creationRules: Object.freeze(unique(composition.flatMap((item) => item.guidance.creationRules || [])))
|
|
170
|
+
}),
|
|
171
|
+
limitations: Object.freeze([
|
|
172
|
+
'Inheritance is additive except where a Root-qualified inline Inheritance Overrides declaration deactivates one exact parent contribution.',
|
|
173
|
+
'Standalone tiinex.schema.inheritance.v1 records are evidence/audit inputs only and do not silently add schema-local compilation authority.',
|
|
174
|
+
'Callers must inspect lineageQualification before treating a compiled chain as complete lineage truth.'
|
|
175
|
+
])
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function qualifyContractChain(compiled = []) {
|
|
180
|
+
const supplied = compiled.map((item) => item.schemaId).filter(Boolean);
|
|
181
|
+
const findings = [];
|
|
182
|
+
if (!compiled.length) {
|
|
183
|
+
return Object.freeze({ state: 'unresolved', complete: false, lineage: Object.freeze([]), findings: Object.freeze(['No schema contracts were supplied.']) });
|
|
184
|
+
}
|
|
185
|
+
if (compiled.length === 1) {
|
|
186
|
+
const only = compiled[0];
|
|
187
|
+
if (only.parentSchemaId) {
|
|
188
|
+
findings.push(`Declared parent schema is not supplied: ${only.parentSchemaId}.`);
|
|
189
|
+
return Object.freeze({ state: 'unresolved', complete: false, lineage: Object.freeze(supplied), findings: Object.freeze(findings) });
|
|
190
|
+
}
|
|
191
|
+
return Object.freeze({ state: 'valid', complete: true, lineage: Object.freeze(supplied), findings: Object.freeze([]) });
|
|
192
|
+
}
|
|
193
|
+
if (compiled[0].parentSchemaId) findings.push(`First supplied schema declares an unsupplied parent: ${compiled[0].parentSchemaId}.`);
|
|
194
|
+
for (let index = 1; index < compiled.length; index += 1) {
|
|
195
|
+
const parent = compiled[index - 1];
|
|
196
|
+
const child = compiled[index];
|
|
197
|
+
if (!child.parentSchemaId || child.parentSchemaId !== parent.schemaId) {
|
|
198
|
+
const declared = child.parentSchemaId || '(none)';
|
|
199
|
+
const message = `Lineage edge mismatch: ${child.schemaId || '(unknown child)'} declares parent ${declared}, but preceding schema is ${parent.schemaId || '(unknown parent)'}.`;
|
|
200
|
+
return Object.freeze({ state: 'contradictory', complete: false, lineage: Object.freeze([]), findings: Object.freeze([...findings, message]) });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (findings.length) return Object.freeze({ state: 'unresolved', complete: false, lineage: Object.freeze(supplied), findings: Object.freeze(findings) });
|
|
204
|
+
return Object.freeze({ state: 'valid', complete: true, lineage: Object.freeze(supplied), findings: Object.freeze([]) });
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function mergeHeadingRequirements(requirements = []) {
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
const out = [];
|
|
210
|
+
for (const requirement of requirements) {
|
|
211
|
+
const title = String(requirement?.title || '').trim();
|
|
212
|
+
const level = Number(requirement?.level || 0);
|
|
213
|
+
if (!title || !level) continue;
|
|
214
|
+
const key = `${level}\u0000${title}`;
|
|
215
|
+
if (seen.has(key)) continue;
|
|
216
|
+
seen.add(key);
|
|
217
|
+
out.push(Object.freeze({ level, title, source: String(requirement?.source || '') }));
|
|
218
|
+
}
|
|
219
|
+
return Object.freeze(out);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function mergeCreationContracts(compiled = []) {
|
|
223
|
+
const requiredInputs = unique(compiled.flatMap((item) => item.creation?.requiredInputs || []));
|
|
224
|
+
const requiredInputKeys = new Set(requiredInputs.map(exactToken));
|
|
225
|
+
const optionalInputs = unique(compiled.flatMap((item) => item.creation?.optionalInputs || []))
|
|
226
|
+
.filter((field) => !requiredInputKeys.has(exactToken(field)));
|
|
227
|
+
return Object.freeze({
|
|
228
|
+
groups: mergeGroups(compiled.flatMap((item) => item.creation?.groups || [])),
|
|
229
|
+
requiredInputs: Object.freeze(requiredInputs),
|
|
230
|
+
optionalInputs: Object.freeze(optionalInputs),
|
|
231
|
+
requiredSections: Object.freeze(unique(compiled.flatMap((item) => item.creation?.requiredSections || []))),
|
|
232
|
+
toolingConfigurationFields: Object.freeze(unique(compiled.flatMap((item) => item.creation?.toolingConfigurationFields || [])))
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function schemaFieldsByContractOwner(document = {}, declarations = [], categoryName = '', options = {}) {
|
|
237
|
+
const declarationGroups = new Set((declarations || []).map((declaration) => exactToken(declaration.group)));
|
|
238
|
+
const fields = [];
|
|
239
|
+
for (const group of document.validation?.groups || []) {
|
|
240
|
+
if (declarationGroups.has(exactToken(group.name))) continue;
|
|
241
|
+
if (options.unconditionalOnly && categoryItems(group, ['Required When']).length) continue;
|
|
242
|
+
fields.push(...categoryItems(group, [categoryName]).map(cleanToken));
|
|
243
|
+
}
|
|
244
|
+
return Object.freeze(unique(fields));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function summarizeGroups(contract = {}, sourceSchemaId = '') {
|
|
248
|
+
return Object.freeze((contract.groups || []).map((group) => Object.freeze({
|
|
249
|
+
name: group.name,
|
|
250
|
+
sourceSchemaId,
|
|
251
|
+
requiredWhen: Object.freeze(categoryItems(group, ['Required When']).map(cleanToken)),
|
|
252
|
+
labelCandidates: Object.freeze([...(group.labelCandidates || [])]),
|
|
253
|
+
categories: Object.freeze((group.categories || []).map((category) => Object.freeze({
|
|
254
|
+
name: category.name,
|
|
255
|
+
items: Object.freeze([...category.items]),
|
|
256
|
+
nodes: freezeCategoryNodes(category.nodes || [])
|
|
257
|
+
})))
|
|
258
|
+
})));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function mergeGroups(groups = []) {
|
|
262
|
+
const order = [];
|
|
263
|
+
const byName = new Map();
|
|
264
|
+
for (const group of groups) {
|
|
265
|
+
const key = exactToken(group.name);
|
|
266
|
+
if (!byName.has(key)) {
|
|
267
|
+
order.push(key);
|
|
268
|
+
byName.set(key, { name: group.name, requiredWhen: [], categories: [], categoryIndex: new Map(), contributors: [] });
|
|
269
|
+
}
|
|
270
|
+
const target = byName.get(key);
|
|
271
|
+
target.contributors.push(Object.freeze({
|
|
272
|
+
sourceSchemaId: String(group.sourceSchemaId || ''),
|
|
273
|
+
name: group.name,
|
|
274
|
+
requiredWhen: Object.freeze([...(group.requiredWhen || [])]),
|
|
275
|
+
labelCandidates: Object.freeze([...(group.labelCandidates || [])]),
|
|
276
|
+
categories: Object.freeze((group.categories || []).map((category) => Object.freeze({
|
|
277
|
+
name: category.name,
|
|
278
|
+
items: Object.freeze([...(category.items || [])]),
|
|
279
|
+
nodes: freezeCategoryNodes(category.nodes || [])
|
|
280
|
+
})))
|
|
281
|
+
}));
|
|
282
|
+
target.requiredWhen = unique([...target.requiredWhen, ...(group.requiredWhen || [])]);
|
|
283
|
+
for (const category of group.categories || []) {
|
|
284
|
+
const categoryKey = exactToken(category.name);
|
|
285
|
+
if (!target.categoryIndex.has(categoryKey)) {
|
|
286
|
+
target.categoryIndex.set(categoryKey, target.categories.length);
|
|
287
|
+
target.categories.push({ name: category.name, items: [], nodes: [] });
|
|
288
|
+
}
|
|
289
|
+
const mergedCategory = target.categories[target.categoryIndex.get(categoryKey)];
|
|
290
|
+
mergedCategory.items = unique([...mergedCategory.items, ...(category.items || [])]);
|
|
291
|
+
mergedCategory.nodes.push(...(category.nodes || []));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return Object.freeze(order.map((key) => {
|
|
295
|
+
const group = byName.get(key);
|
|
296
|
+
return Object.freeze({
|
|
297
|
+
name: group.name,
|
|
298
|
+
requiredWhen: Object.freeze([...group.requiredWhen]),
|
|
299
|
+
labelCandidates: Object.freeze(unique(group.contributors.flatMap((contribution) => contribution.labelCandidates || []))),
|
|
300
|
+
contributors: Object.freeze([...group.contributors]),
|
|
301
|
+
categories: Object.freeze(group.categories.map((category) => Object.freeze({
|
|
302
|
+
name: category.name,
|
|
303
|
+
items: Object.freeze([...category.items]),
|
|
304
|
+
nodes: freezeCategoryNodes(category.nodes || [])
|
|
305
|
+
})))
|
|
306
|
+
});
|
|
307
|
+
}));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function bindRequiredEntryTargets(declarations = [], requirements = []) {
|
|
311
|
+
return Object.freeze((declarations || []).map((declaration) => {
|
|
312
|
+
const inferredTargets = requirements
|
|
313
|
+
.filter((requirement) => (requirement.entries || []).some((entry) => exactToken(entry) === exactToken(declaration.group)))
|
|
314
|
+
.flatMap((requirement) => requirement.targetHeadings || []);
|
|
315
|
+
if (!inferredTargets.length) return declaration;
|
|
316
|
+
return Object.freeze({
|
|
317
|
+
...declaration,
|
|
318
|
+
targetHeadings: Object.freeze(unique([...(declaration.targetHeadings || []), ...inferredTargets]))
|
|
319
|
+
});
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function mergeRequiredEntryRequirements(requirements = []) {
|
|
324
|
+
const order = [];
|
|
325
|
+
const byKey = new Map();
|
|
326
|
+
for (const requirement of requirements) {
|
|
327
|
+
const key = exactToken(requirement.group);
|
|
328
|
+
if (!byKey.has(key)) {
|
|
329
|
+
order.push(key);
|
|
330
|
+
byKey.set(key, { group: requirement.group, entries: [], targetHeadings: [] });
|
|
331
|
+
}
|
|
332
|
+
const target = byKey.get(key);
|
|
333
|
+
target.entries = unique([...target.entries, ...(requirement.entries || [])]);
|
|
334
|
+
target.targetHeadings = unique([...target.targetHeadings, ...(requirement.targetHeadings || [])]);
|
|
335
|
+
}
|
|
336
|
+
return Object.freeze(order.map((key) => {
|
|
337
|
+
const item = byKey.get(key);
|
|
338
|
+
return Object.freeze({
|
|
339
|
+
group: item.group,
|
|
340
|
+
entries: Object.freeze([...item.entries]),
|
|
341
|
+
targetHeadings: Object.freeze([...item.targetHeadings])
|
|
342
|
+
});
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function mergeDeclarationContracts(declarations = []) {
|
|
347
|
+
const order = [];
|
|
348
|
+
const byKey = new Map();
|
|
349
|
+
for (const declaration of declarations) {
|
|
350
|
+
const key = exactToken(declaration.group);
|
|
351
|
+
if (!byKey.has(key)) {
|
|
352
|
+
order.push(key);
|
|
353
|
+
byKey.set(key, {
|
|
354
|
+
...declaration,
|
|
355
|
+
entryShape: [...(declaration.entryShape || [])],
|
|
356
|
+
requiredFields: [...(declaration.requiredFields || [])],
|
|
357
|
+
optionalFields: [...(declaration.optionalFields || [])],
|
|
358
|
+
declarationFields: [...(declaration.declarationFields || [])],
|
|
359
|
+
allowedLabels: [...(declaration.allowedLabels || [])],
|
|
360
|
+
allowedShapes: [...(declaration.allowedShapes || [])],
|
|
361
|
+
targetHeadings: [...(declaration.targetHeadings || [])],
|
|
362
|
+
rules: [...(declaration.rules || [])]
|
|
363
|
+
});
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
const target = byKey.get(key);
|
|
367
|
+
for (const field of ['entryShape', 'requiredFields', 'optionalFields', 'declarationFields', 'allowedLabels', 'allowedShapes', 'targetHeadings', 'rules']) {
|
|
368
|
+
target[field] = unique([...(target[field] || []), ...(declaration[field] || [])]);
|
|
369
|
+
}
|
|
370
|
+
target.allowLiteralNone = Boolean(target.allowLiteralNone || declaration.allowLiteralNone);
|
|
371
|
+
}
|
|
372
|
+
return Object.freeze(order.map((key) => {
|
|
373
|
+
const declaration = byKey.get(key);
|
|
374
|
+
return Object.freeze({
|
|
375
|
+
...declaration,
|
|
376
|
+
entryShape: Object.freeze([...declaration.entryShape]),
|
|
377
|
+
requiredFields: Object.freeze([...declaration.requiredFields]),
|
|
378
|
+
optionalFields: Object.freeze([...declaration.optionalFields]),
|
|
379
|
+
declarationFields: Object.freeze([...declaration.declarationFields]),
|
|
380
|
+
allowedLabels: Object.freeze([...declaration.allowedLabels]),
|
|
381
|
+
allowedShapes: Object.freeze([...declaration.allowedShapes]),
|
|
382
|
+
targetHeadings: Object.freeze([...declaration.targetHeadings]),
|
|
383
|
+
rules: Object.freeze([...declaration.rules])
|
|
384
|
+
});
|
|
385
|
+
}));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
function freezeCategoryNodes(nodes = []) {
|
|
390
|
+
return Object.freeze((nodes || []).map((node) => Object.freeze({
|
|
391
|
+
value: String(node.value || ''),
|
|
392
|
+
line: Number(node.line || 0),
|
|
393
|
+
indent: Number(node.indent || 0),
|
|
394
|
+
children: freezeCategoryNodes(node.children || [])
|
|
395
|
+
})));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function categoryItems(group = {}, names = []) {
|
|
399
|
+
const wanted = new Set(names.map(exactToken));
|
|
400
|
+
return (group.categories || []).flatMap((category) => wanted.has(exactToken(category.name)) ? category.items : []);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function cleanToken(value = '') { return String(value || '').trim().replace(/^`|`$/g, '').trim(); }
|
|
404
|
+
function exactToken(value = '') { return String(value || '').trim(); }
|
|
405
|
+
function normalizeKey(value = '') { return String(value || '').toLowerCase().replace(/[`*_#]/g, '').replace(/[^a-z0-9]+/g, ' ').trim(); }
|
|
406
|
+
function unique(values = []) { return [...new Set(values.map((value) => String(value || '').trim()).filter(Boolean))]; }
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { declarationTargetKey } from './named.declarations.js';
|
|
2
|
+
import { dedupeConstraints } from './contract.compile.utils.js';
|
|
3
|
+
|
|
4
|
+
export function compileContractConstraints(document = {}, declarations = []) {
|
|
5
|
+
const constraints = [];
|
|
6
|
+
const declarationByGroup = new Map(declarations.map((contract) => [exactToken(contract.group), contract]));
|
|
7
|
+
const declarationTargets = new Map();
|
|
8
|
+
for (const contract of declarations) {
|
|
9
|
+
for (const heading of contract.targetHeadings) declarationTargets.set(declarationTargetKey(heading), contract.group);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
for (const group of document.validation?.groups || []) {
|
|
13
|
+
const rules = categoryItems(group, ['Rules']);
|
|
14
|
+
const appliesTo = categoryItems(group, ['Applies To']).map(cleanToken);
|
|
15
|
+
const currentDeclaration = declarationByGroup.get(exactToken(group.name)) || null;
|
|
16
|
+
const appliedGroups = appliesTo.filter((name) => declarationByGroup.has(exactToken(name)));
|
|
17
|
+
for (const rule of rules) {
|
|
18
|
+
constraints.push(...compileReferenceRule(rule, currentDeclaration, declarationTargets));
|
|
19
|
+
const cardinality = compileCardinalityRule(rule, currentDeclaration);
|
|
20
|
+
if (cardinality) constraints.push(cardinality);
|
|
21
|
+
const generation = compileTargetSchemaAuthorityRule(rule, currentDeclaration);
|
|
22
|
+
if (generation) constraints.push(generation);
|
|
23
|
+
const naming = compileNamingAuthorityRule(rule, currentDeclaration);
|
|
24
|
+
if (naming) constraints.push(naming);
|
|
25
|
+
const agreement = compileClassificationAgreementRule(rule, appliedGroups);
|
|
26
|
+
if (agreement) constraints.push(agreement);
|
|
27
|
+
const mapping = compileMemberMappingRule(rule, currentDeclaration);
|
|
28
|
+
if (mapping) constraints.push(mapping);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return dedupeConstraints(constraints);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function compileReferenceRule(rule, declaration, declarationTargets) {
|
|
35
|
+
if (!declaration || !/must resolve to (?:a )?declared/i.test(rule)) return [];
|
|
36
|
+
const before = rule.split(/must resolve to/i)[0];
|
|
37
|
+
const fields = [...before.matchAll(/`([^`]+)`/g)].map((match) => cleanToken(match[1])).filter((field) => field !== 'when present');
|
|
38
|
+
if (!fields.length) return [];
|
|
39
|
+
const after = rule.split(/must resolve to/i)[1] || '';
|
|
40
|
+
const phrase = after.split(/[.;]/)[0].replace(/\bthat\b.*$/i, '').replace(/\band is\b.*$/i, '').trim();
|
|
41
|
+
const targets = [];
|
|
42
|
+
for (const [targetKey, group] of declarationTargets.entries()) {
|
|
43
|
+
const singular = targetKey.replace(/\brole\b/g, 'role').replace(/\bbinding\b/g, 'binding').replace(/\beffect\b/g, 'effect');
|
|
44
|
+
const haystack = normalizeKey(phrase).replace(/\broles\b/g, 'role').replace(/\bbindings\b/g, 'binding').replace(/\beffects\b/g, 'effect');
|
|
45
|
+
if (haystack.includes(singular)) targets.push(group);
|
|
46
|
+
}
|
|
47
|
+
return fields.map((field) => Object.freeze({
|
|
48
|
+
kind: 'declaration-reference',
|
|
49
|
+
group: declaration.group,
|
|
50
|
+
field,
|
|
51
|
+
targets: Object.freeze(unique(targets)),
|
|
52
|
+
optional: /when present/i.test(before) || declaration.optionalFields.includes(field),
|
|
53
|
+
rule
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function compileCardinalityRule(rule, declaration) {
|
|
58
|
+
if (!declaration) return null;
|
|
59
|
+
if (!/Maximum count must not be lower than minimum count/i.test(rule)) return null;
|
|
60
|
+
if (!declaration.requiredFields.includes('Minimum Count') || !declaration.requiredFields.includes('Maximum Count')) return null;
|
|
61
|
+
return Object.freeze({ kind: 'cardinality-order', group: declaration.group, minimumField: 'Minimum Count', maximumField: 'Maximum Count', rule });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function compileTargetSchemaAuthorityRule(rule, declaration) {
|
|
65
|
+
if (!declaration || !/is unresolved when/i.test(rule) || !/target schema exposes no resolvable generation\/creation authority/i.test(rule)) return null;
|
|
66
|
+
const binding = rule.match(/`([^`:]+):\s*([^`]+)`\s+is unresolved when\s+`([^`]+)`/i);
|
|
67
|
+
if (!binding) return null;
|
|
68
|
+
return Object.freeze({
|
|
69
|
+
kind: 'target-schema-authority',
|
|
70
|
+
group: declaration.group,
|
|
71
|
+
field: cleanToken(binding[1]),
|
|
72
|
+
value: cleanToken(binding[2]),
|
|
73
|
+
schemaField: cleanToken(binding[3]),
|
|
74
|
+
capability: 'generation',
|
|
75
|
+
rule
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function compileNamingAuthorityRule(rule, declaration) {
|
|
80
|
+
if (!declaration || !/Naming Authority:\s*target-schema/i.test(rule) || !/File Naming authority/i.test(rule) || !/Schema Constraint/i.test(rule)) return null;
|
|
81
|
+
return Object.freeze({
|
|
82
|
+
kind: 'target-schema-authority-via-reference',
|
|
83
|
+
group: declaration.group,
|
|
84
|
+
field: 'Naming Authority',
|
|
85
|
+
value: 'target-schema',
|
|
86
|
+
referenceField: 'Output Binding',
|
|
87
|
+
referencedSchemaField: 'Schema Constraint',
|
|
88
|
+
capability: 'fileNaming',
|
|
89
|
+
rule
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function compileClassificationAgreementRule(rule, appliedGroups) {
|
|
94
|
+
if (!appliedGroups.length || !/explicit `Target Kind`/i.test(rule) || !/`Schema Constraint`\/authority/i.test(rule) || !/must agree/i.test(rule)) return null;
|
|
95
|
+
return Object.freeze({
|
|
96
|
+
kind: 'classification-agreement',
|
|
97
|
+
groups: Object.freeze([...appliedGroups]),
|
|
98
|
+
explicitField: 'Target Kind',
|
|
99
|
+
schemaField: 'Schema Constraint',
|
|
100
|
+
rule
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function compileMemberMappingRule(rule, declaration) {
|
|
105
|
+
if (!declaration || !/`Member Mapping` is required when multiplicity/i.test(rule)) return null;
|
|
106
|
+
return Object.freeze({ kind: 'member-mapping-when-ambiguous', group: declaration.group, field: 'Member Mapping', rule });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function categoryItems(group = {}, names = []) {
|
|
110
|
+
const wanted = new Set(names.map(exactToken));
|
|
111
|
+
return (group.categories || []).flatMap((category) => wanted.has(exactToken(category.name)) ? category.items : []);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function cleanToken(value = '') { return String(value || '').trim().replace(/^`|`$/g, '').trim(); }
|
|
115
|
+
function exactToken(value = '') { return String(value || '').trim(); }
|
|
116
|
+
function normalizeKey(value = '') { return String(value || '').toLowerCase().replace(/[`*_#]/g, '').replace(/[^a-z0-9]+/g, ' ').trim(); }
|
|
117
|
+
function unique(values = []) { return [...new Set(values.map((value) => String(value || '').trim()).filter(Boolean))]; }
|