onto-mcp 0.3.2 → 0.4.0
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/.onto/processes/reconstruct/actionable-ontology-seed-recomposition-design.md +447 -0
- package/.onto/processes/reconstruct/foundry-style-ontology-seed-contract.md +934 -0
- package/.onto/processes/reconstruct/reconstruct-boundary-contract.md +303 -725
- package/.onto/processes/reconstruct/reconstruct-contract-registry.yaml +1645 -0
- package/.onto/processes/reconstruct/reconstruct-execution-ux-contract.md +26 -22
- package/.onto/processes/reconstruct/source-profile-contract.md +49 -23
- package/.onto/processes/reconstruct/source-profiles/code.md +6 -3
- package/.onto/processes/reconstruct/source-profiles/database.md +5 -2
- package/.onto/processes/reconstruct/source-profiles/document.md +5 -2
- package/.onto/processes/reconstruct/source-profiles/spreadsheet.md +5 -4
- package/.onto/processes/review/review-execution-ux-contract.md +40 -0
- package/.onto/processes/shared/pipeline-execution-ledger-contract.md +26 -10
- package/.onto/processes/shared/target-material-kind-contract.md +29 -16
- package/AGENTS.md +6 -4
- package/README.md +135 -76
- package/dist/cli.js +8 -8
- package/dist/core-api/reconstruct-api.js +117 -31
- package/dist/core-api/review-api.js +47 -0
- package/dist/core-runtime/cli/codex-review-unit-executor.js +39 -2
- package/dist/core-runtime/cli/complete-review-session.js +2 -2
- package/dist/core-runtime/cli/mock-review-unit-executor.js +1 -1
- package/dist/core-runtime/cli/review-invoke.js +9 -9
- package/dist/core-runtime/cli/run-review-prompt-execution.js +39 -5
- package/dist/core-runtime/cli/spawn-watcher.js +266 -47
- package/dist/core-runtime/cli/start-review-session.js +3 -3
- package/dist/core-runtime/llm/llm-caller.js +11 -0
- package/dist/core-runtime/llm/llm-tool-loop.js +2 -0
- package/dist/core-runtime/observability/runtime-stream-observation.js +118 -0
- package/dist/core-runtime/onboard/cli-host.js +149 -0
- package/dist/core-runtime/onboard/host-target.js +22 -0
- package/dist/core-runtime/onboard/json-config-host.js +122 -0
- package/dist/core-runtime/onboard/path-scan.js +26 -0
- package/dist/core-runtime/onboard/prompt.js +51 -0
- package/dist/core-runtime/onboard/register.js +207 -0
- package/dist/core-runtime/onboard/types.js +27 -0
- package/dist/core-runtime/reconstruct/actionable-seed-validation.js +1777 -0
- package/dist/core-runtime/reconstruct/artifact-types.js +10 -4
- package/dist/core-runtime/reconstruct/contract-registry.js +623 -0
- package/dist/core-runtime/reconstruct/domain-id.js +10 -0
- package/dist/core-runtime/reconstruct/governing-snapshot.js +716 -0
- package/dist/core-runtime/reconstruct/material-profile-validation.js +191 -0
- package/dist/core-runtime/reconstruct/materialize-preparation.js +49 -11
- package/dist/core-runtime/reconstruct/pipeline-execution-ledger.js +269 -79
- package/dist/core-runtime/reconstruct/post-seed-validation.js +1194 -51
- package/dist/core-runtime/reconstruct/record.js +104 -20
- package/dist/core-runtime/reconstruct/run.js +2107 -413
- package/dist/core-runtime/reconstruct/seed-claim-projections.js +268 -0
- package/dist/core-runtime/reconstruct/source-profiles.js +93 -4
- package/dist/core-runtime/reconstruct/terminal-validation.js +807 -0
- package/dist/core-runtime/review/review-invocation-runner.js +4 -4
- package/dist/mcp/server.js +110 -38
- package/dist/mcp/tool-schemas.js +20 -6
- package/package.json +8 -17
- package/scripts/onto-review-watch.sh +486 -0
- package/scripts/onto-runtime-watch.sh +122 -0
- package/scripts/postinstall-hint.js +22 -0
- package/.onto/processes/reconstruct/top-level-concept-discovery-contract.md +0 -387
- package/dist/core-runtime/cli/bootstrap-review-binding.js +0 -186
- package/dist/core-runtime/cli/codex-nested-dispatch.test.js +0 -390
- package/dist/core-runtime/cli/codex-nested-teamlead-executor.test.js +0 -335
- package/dist/core-runtime/cli/coordinator-helpers.js +0 -583
- package/dist/core-runtime/cli/coordinator-state-machine-deliberation.test.js +0 -167
- package/dist/core-runtime/cli/coordinator-state-machine.js +0 -794
- package/dist/core-runtime/cli/e2e-codex-multi-agent-fixes.test.js +0 -615
- package/dist/core-runtime/cli/e2e-start-review-session.test.js +0 -312
- package/dist/core-runtime/cli/health.js +0 -44
- package/dist/core-runtime/cli/inline-http-review-unit-executor.test.js +0 -567
- package/dist/core-runtime/cli/materialize-review-execution-preparation.js +0 -104
- package/dist/core-runtime/cli/migrate-session-roots.js +0 -118
- package/dist/core-runtime/cli/repo-layout-migration-replace.smoke.test.js +0 -106
- package/dist/core-runtime/cli/review-invoke-auto-resolution.test.js +0 -268
- package/dist/core-runtime/cli/review-invoke-coordinator-topology.test.js +0 -136
- package/dist/core-runtime/cli/review-invoke-resolver-caching.test.js +0 -201
- package/dist/core-runtime/cli/review-invoke-topology-dispatch.test.js +0 -192
- package/dist/core-runtime/cli/session-root-guard.js +0 -168
- package/dist/core-runtime/cli/spawn-watcher.test.js +0 -457
- package/dist/core-runtime/cli/strip-wrapping-code-fence.test.js +0 -79
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.js +0 -412
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.test.js +0 -351
- package/dist/core-runtime/cli/topology-executor-mapping.js +0 -139
- package/dist/core-runtime/cli/topology-executor-mapping.test.js +0 -173
- package/dist/core-runtime/cli/write-review-interpretation.js +0 -81
- package/dist/core-runtime/config/onto-config-cli.js +0 -278
- package/dist/core-runtime/config/onto-config-key-path.js +0 -288
- package/dist/core-runtime/config/onto-config-key-path.test.js +0 -195
- package/dist/core-runtime/config/onto-config-preview.js +0 -108
- package/dist/core-runtime/config/onto-config-preview.test.js +0 -132
- package/dist/core-runtime/discovery/config-chain.js +0 -118
- package/dist/core-runtime/discovery/config-chain.test.js +0 -103
- package/dist/core-runtime/discovery/config-profile.js +0 -199
- package/dist/core-runtime/discovery/config-profile.test.js +0 -233
- package/dist/core-runtime/discovery/host-detection.test.js +0 -186
- package/dist/core-runtime/discovery/installation-paths.test.js +0 -65
- package/dist/core-runtime/discovery/lens-registry.test.js +0 -81
- package/dist/core-runtime/discovery/path-normalization.test.js +0 -22
- package/dist/core-runtime/discovery/plugin-path.js +0 -72
- package/dist/core-runtime/discovery/plugin-path.test.js +0 -95
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.js +0 -344
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.test.js +0 -915
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.js +0 -564
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.test.js +0 -708
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.js +0 -165
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.test.js +0 -227
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.js +0 -59
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.test.js +0 -205
- package/dist/core-runtime/evolve/adapters/methodology/adapter.js +0 -16
- package/dist/core-runtime/evolve/adapters/methodology/adapter.test.js +0 -9
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.js +0 -298
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.test.js +0 -70
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.js +0 -46
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.test.js +0 -73
- package/dist/core-runtime/evolve/adapters/registry.js +0 -47
- package/dist/core-runtime/evolve/adapters/registry.test.js +0 -67
- package/dist/core-runtime/evolve/cli.js +0 -256
- package/dist/core-runtime/evolve/commands/align.js +0 -194
- package/dist/core-runtime/evolve/commands/align.test.js +0 -82
- package/dist/core-runtime/evolve/commands/apply.js +0 -161
- package/dist/core-runtime/evolve/commands/apply.test.js +0 -138
- package/dist/core-runtime/evolve/commands/close.js +0 -39
- package/dist/core-runtime/evolve/commands/close.test.js +0 -99
- package/dist/core-runtime/evolve/commands/defer.js +0 -40
- package/dist/core-runtime/evolve/commands/defer.test.js +0 -134
- package/dist/core-runtime/evolve/commands/draft.js +0 -323
- package/dist/core-runtime/evolve/commands/draft.test.js +0 -178
- package/dist/core-runtime/evolve/commands/e2e-evolve-full-cycle.test.js +0 -208
- package/dist/core-runtime/evolve/commands/error-messages.js +0 -125
- package/dist/core-runtime/evolve/commands/error-messages.test.js +0 -167
- package/dist/core-runtime/evolve/commands/propose-align.js +0 -222
- package/dist/core-runtime/evolve/commands/propose-align.test.js +0 -136
- package/dist/core-runtime/evolve/commands/reconstruct.js +0 -330
- package/dist/core-runtime/evolve/commands/reconstruct.test.js +0 -278
- package/dist/core-runtime/evolve/commands/shared.js +0 -22
- package/dist/core-runtime/evolve/commands/stale-check.js +0 -103
- package/dist/core-runtime/evolve/commands/stale-check.test.js +0 -84
- package/dist/core-runtime/evolve/commands/start.js +0 -887
- package/dist/core-runtime/evolve/commands/start.test.js +0 -396
- package/dist/core-runtime/evolve/config/project-config.js +0 -99
- package/dist/core-runtime/evolve/config/project-config.test.js +0 -170
- package/dist/core-runtime/evolve/renderers/align-packet.js +0 -280
- package/dist/core-runtime/evolve/renderers/align-packet.test.js +0 -332
- package/dist/core-runtime/evolve/renderers/draft-packet.js +0 -303
- package/dist/core-runtime/evolve/renderers/draft-packet.test.js +0 -377
- package/dist/core-runtime/evolve/renderers/format.js +0 -5
- package/dist/core-runtime/evolve/renderers/scope-md.js +0 -237
- package/dist/core-runtime/evolve/renderers/scope-md.test.js +0 -306
- package/dist/core-runtime/govern/cli.js +0 -369
- package/dist/core-runtime/govern/cli.test.js +0 -314
- package/dist/core-runtime/govern/drift-engine.js +0 -103
- package/dist/core-runtime/govern/drift-engine.test.js +0 -319
- package/dist/core-runtime/govern/promote-principle.js +0 -206
- package/dist/core-runtime/govern/promote-principle.test.js +0 -368
- package/dist/core-runtime/govern/queue.js +0 -81
- package/dist/core-runtime/govern/types.js +0 -16
- package/dist/core-runtime/install/cli.js +0 -530
- package/dist/core-runtime/install/detect.js +0 -128
- package/dist/core-runtime/install/detect.test.js +0 -155
- package/dist/core-runtime/install/gitignore-update.js +0 -74
- package/dist/core-runtime/install/gitignore-update.test.js +0 -64
- package/dist/core-runtime/install/install-integration.test.js +0 -373
- package/dist/core-runtime/install/prompts.js +0 -389
- package/dist/core-runtime/install/prompts.test.js +0 -293
- package/dist/core-runtime/install/types.js +0 -26
- package/dist/core-runtime/install/validation.js +0 -295
- package/dist/core-runtime/install/validation.test.js +0 -313
- package/dist/core-runtime/install/writer.js +0 -254
- package/dist/core-runtime/install/writer.test.js +0 -218
- package/dist/core-runtime/learning/extractor.js +0 -461
- package/dist/core-runtime/learning/feedback.js +0 -179
- package/dist/core-runtime/learning/health-report.js +0 -165
- package/dist/core-runtime/learning/health-report.test.js +0 -169
- package/dist/core-runtime/learning/loader.js +0 -388
- package/dist/core-runtime/learning/loader.test.js +0 -102
- package/dist/core-runtime/learning/promote/apply-state.js +0 -240
- package/dist/core-runtime/learning/promote/audit-obligation.js +0 -195
- package/dist/core-runtime/learning/promote/collector.js +0 -432
- package/dist/core-runtime/learning/promote/degraded-state.js +0 -125
- package/dist/core-runtime/learning/promote/domain-doc-proposer.js +0 -166
- package/dist/core-runtime/learning/promote/e2e-promote.test.js +0 -6385
- package/dist/core-runtime/learning/promote/health-snapshot.js +0 -150
- package/dist/core-runtime/learning/promote/insight-reclassifier.js +0 -544
- package/dist/core-runtime/learning/promote/judgment-auditor.js +0 -517
- package/dist/core-runtime/learning/promote/panel-reviewer.js +0 -1158
- package/dist/core-runtime/learning/promote/promote-executor.js +0 -1675
- package/dist/core-runtime/learning/promote/promoter.js +0 -307
- package/dist/core-runtime/learning/promote/retirement.js +0 -122
- package/dist/core-runtime/learning/promote/types.js +0 -23
- package/dist/core-runtime/learning/prompt-sections.js +0 -51
- package/dist/core-runtime/learning/shared/artifact-registry-init.js +0 -45
- package/dist/core-runtime/learning/shared/artifact-registry.js +0 -254
- package/dist/core-runtime/learning/shared/audit-obligation-kernel.js +0 -73
- package/dist/core-runtime/learning/shared/audit-state.js +0 -99
- package/dist/core-runtime/learning/shared/duplicate-check.js +0 -28
- package/dist/core-runtime/learning/shared/llm-caller.js +0 -831
- package/dist/core-runtime/learning/shared/llm-caller.test.js +0 -601
- package/dist/core-runtime/learning/shared/llm-tool-loop.js +0 -393
- package/dist/core-runtime/learning/shared/mode.js +0 -25
- package/dist/core-runtime/learning/shared/paths.js +0 -84
- package/dist/core-runtime/learning/shared/paths.test.js +0 -79
- package/dist/core-runtime/learning/shared/patterns.js +0 -37
- package/dist/core-runtime/learning/shared/recoverability.js +0 -355
- package/dist/core-runtime/learning/shared/recovery-context.js +0 -374
- package/dist/core-runtime/learning/shared/scope.js +0 -1
- package/dist/core-runtime/learning/shared/semantic-classifier.js +0 -94
- package/dist/core-runtime/learning/shared/specs/apply-execution-state-spec.js +0 -42
- package/dist/core-runtime/learning/shared/specs/audit-state-spec.js +0 -37
- package/dist/core-runtime/learning/shared/specs/backup-metadata-spec.js +0 -39
- package/dist/core-runtime/learning/shared/specs/emergency-log-spec.js +0 -41
- package/dist/core-runtime/learning/shared/specs/layout-version-spec.js +0 -38
- package/dist/core-runtime/learning/shared/specs/promote-decisions-spec.js +0 -43
- package/dist/core-runtime/learning/shared/specs/promote-report-spec.js +0 -113
- package/dist/core-runtime/learning/shared/specs/prune-log-spec.js +0 -36
- package/dist/core-runtime/learning/shared/specs/recovery-resolution-spec.js +0 -48
- package/dist/core-runtime/learning/shared/specs/restore-manifest-spec.js +0 -43
- package/dist/core-runtime/learning/shared/specs/spec-helpers.js +0 -64
- package/dist/core-runtime/learning/usage-tracker.js +0 -190
- package/dist/core-runtime/learning/usage-tracker.test.js +0 -176
- package/dist/core-runtime/onboard/detect-review-axes.js +0 -122
- package/dist/core-runtime/onboard/detect-review-axes.test.js +0 -127
- package/dist/core-runtime/onboard/write-review-block.js +0 -188
- package/dist/core-runtime/onboard/write-review-block.test.js +0 -240
- package/dist/core-runtime/readers/brownfield-builder.js +0 -150
- package/dist/core-runtime/readers/brownfield-builder.test.js +0 -136
- package/dist/core-runtime/readers/code-chunk-collector.js +0 -53
- package/dist/core-runtime/readers/code-chunk-collector.test.js +0 -136
- package/dist/core-runtime/readers/file-utils.js +0 -240
- package/dist/core-runtime/readers/file-utils.test.js +0 -146
- package/dist/core-runtime/readers/lexicon-citation-check.js +0 -93
- package/dist/core-runtime/readers/lexicon-citation-check.test.js +0 -77
- package/dist/core-runtime/readers/mcp-figma.js +0 -30
- package/dist/core-runtime/readers/mcp-figma.test.js +0 -82
- package/dist/core-runtime/readers/mcp-generic.js +0 -31
- package/dist/core-runtime/readers/mcp-generic.test.js +0 -76
- package/dist/core-runtime/readers/ontology-index.js +0 -148
- package/dist/core-runtime/readers/ontology-index.test.js +0 -245
- package/dist/core-runtime/readers/ontology-query.js +0 -168
- package/dist/core-runtime/readers/ontology-query.test.js +0 -311
- package/dist/core-runtime/readers/ontology-resolve.js +0 -48
- package/dist/core-runtime/readers/ontology-resolve.test.js +0 -48
- package/dist/core-runtime/readers/patterns/index.js +0 -7
- package/dist/core-runtime/readers/review-log.js +0 -213
- package/dist/core-runtime/readers/review-log.test.js +0 -313
- package/dist/core-runtime/readers/scan-local.js +0 -102
- package/dist/core-runtime/readers/scan-local.test.js +0 -102
- package/dist/core-runtime/readers/scan-tarball.js +0 -121
- package/dist/core-runtime/readers/scan-tarball.test.js +0 -283
- package/dist/core-runtime/readers/scan-vault.js +0 -34
- package/dist/core-runtime/readers/scan-vault.test.js +0 -81
- package/dist/core-runtime/readers/types.js +0 -42
- package/dist/core-runtime/readers/types.test.js +0 -94
- package/dist/core-runtime/readers/viewpoint-collectors.js +0 -229
- package/dist/core-runtime/reconstruct/seed-candidate-validation.js +0 -385
- package/dist/core-runtime/review/citation-audit.test.js +0 -165
- package/dist/core-runtime/review/execution-plan-resolver.js +0 -247
- package/dist/core-runtime/review/execution-plan-resolver.test.js +0 -243
- package/dist/core-runtime/review/execution-topology-resolver-axis-first.test.js +0 -246
- package/dist/core-runtime/review/execution-topology-resolver.js +0 -401
- package/dist/core-runtime/review/execution-topology-resolver.test.js +0 -315
- package/dist/core-runtime/review/inline-context-embedder.test.js +0 -154
- package/dist/core-runtime/review/legacy-mode-policy.js +0 -88
- package/dist/core-runtime/review/materializers-effort-persist.test.js +0 -79
- package/dist/core-runtime/review/ontology-path-classifier.js +0 -179
- package/dist/core-runtime/review/ontology-path-classifier.test.js +0 -216
- package/dist/core-runtime/review/packet-boundary-policy.test.js +0 -107
- package/dist/core-runtime/review/participating-lens-paths.test.js +0 -73
- package/dist/core-runtime/review/review-config-legacy-translate.js +0 -244
- package/dist/core-runtime/review/review-config-legacy-translate.test.js +0 -161
- package/dist/core-runtime/review/review-config-validator.js +0 -289
- package/dist/core-runtime/review/review-config-validator.test.js +0 -236
- package/dist/core-runtime/review/shape-pipeline-audit.test.js +0 -311
- package/dist/core-runtime/review/shape-to-topology-id.js +0 -117
- package/dist/core-runtime/review/shape-to-topology-id.test.js +0 -132
- package/dist/core-runtime/review/topology-shape-derivation.js +0 -155
- package/dist/core-runtime/review/topology-shape-derivation.test.js +0 -195
- package/dist/core-runtime/scope-runtime/constants.js +0 -12
- package/dist/core-runtime/scope-runtime/constraint-pool.js +0 -166
- package/dist/core-runtime/scope-runtime/constraint-pool.test.js +0 -674
- package/dist/core-runtime/scope-runtime/domain-validation-log.js +0 -135
- package/dist/core-runtime/scope-runtime/domain-validation-log.test.js +0 -156
- package/dist/core-runtime/scope-runtime/eval-persistence.js +0 -65
- package/dist/core-runtime/scope-runtime/eval-persistence.test.js +0 -84
- package/dist/core-runtime/scope-runtime/event-pipeline.js +0 -64
- package/dist/core-runtime/scope-runtime/event-pipeline.test.js +0 -450
- package/dist/core-runtime/scope-runtime/event-store.js +0 -39
- package/dist/core-runtime/scope-runtime/event-store.test.js +0 -95
- package/dist/core-runtime/scope-runtime/gate-guard.js +0 -348
- package/dist/core-runtime/scope-runtime/gate-guard.test.js +0 -1047
- package/dist/core-runtime/scope-runtime/hash.js +0 -4
- package/dist/core-runtime/scope-runtime/hash.test.js +0 -33
- package/dist/core-runtime/scope-runtime/id.js +0 -4
- package/dist/core-runtime/scope-runtime/id.test.js +0 -17
- package/dist/core-runtime/scope-runtime/reducer.js +0 -297
- package/dist/core-runtime/scope-runtime/reducer.test.js +0 -759
- package/dist/core-runtime/scope-runtime/scope-manager.js +0 -161
- package/dist/core-runtime/scope-runtime/state-machine.js +0 -309
- package/dist/core-runtime/scope-runtime/state-machine.test.js +0 -704
- package/dist/core-runtime/scope-runtime/types.js +0 -116
- package/dist/core-runtime/scope-runtime/types.test.js +0 -69
- package/dist/core-runtime/translate/render-for-user.js +0 -169
- package/dist/core-runtime/translate/render-for-user.test.js +0 -122
- package/dist/providers/capability-contract.js +0 -1
|
@@ -0,0 +1,1777 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
4
|
+
import { loadReconstructContractRegistry, } from "./contract-registry.js";
|
|
5
|
+
function isoNow() {
|
|
6
|
+
return new Date().toISOString();
|
|
7
|
+
}
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
function readRecord(value, fieldPath, addViolation) {
|
|
12
|
+
if (!isRecord(value)) {
|
|
13
|
+
addViolation("schema_shape_invalid", `${fieldPath} must be an object`);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function readArray(value, fieldPath, addViolation) {
|
|
19
|
+
if (!Array.isArray(value)) {
|
|
20
|
+
addViolation("schema_shape_invalid", `${fieldPath} must be an array`);
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function optionalString(value) {
|
|
26
|
+
return typeof value === "string" && value.trim().length > 0
|
|
27
|
+
? value.trim()
|
|
28
|
+
: null;
|
|
29
|
+
}
|
|
30
|
+
function stringArray(value) {
|
|
31
|
+
return Array.isArray(value)
|
|
32
|
+
? value.filter((item) => typeof item === "string")
|
|
33
|
+
: [];
|
|
34
|
+
}
|
|
35
|
+
const ACTIONABLE_ONTOLOGY_SEED_ID_KEYS = new Set([
|
|
36
|
+
"seed_id",
|
|
37
|
+
"concept_id",
|
|
38
|
+
"association_id",
|
|
39
|
+
"object_type_id",
|
|
40
|
+
"property_id",
|
|
41
|
+
"link_type_id",
|
|
42
|
+
"value_type_id",
|
|
43
|
+
"constraint_id",
|
|
44
|
+
"actor_type_id",
|
|
45
|
+
"role_id",
|
|
46
|
+
"action_type_id",
|
|
47
|
+
"parameter_id",
|
|
48
|
+
"precondition_id",
|
|
49
|
+
"postcondition_id",
|
|
50
|
+
"side_effect_id",
|
|
51
|
+
"function_id",
|
|
52
|
+
"workflow_id",
|
|
53
|
+
"policy_id",
|
|
54
|
+
"permission_policy_id",
|
|
55
|
+
"state_model_id",
|
|
56
|
+
"transition_id",
|
|
57
|
+
"rule_id",
|
|
58
|
+
"binding_id",
|
|
59
|
+
"read_model_id",
|
|
60
|
+
"writeback_id",
|
|
61
|
+
"provenance_id",
|
|
62
|
+
"limitation_id",
|
|
63
|
+
"candidate_id",
|
|
64
|
+
]);
|
|
65
|
+
export function collectActionableOntologySeedRefs(seed) {
|
|
66
|
+
const refs = new Set();
|
|
67
|
+
const visit = (value) => {
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
for (const item of value)
|
|
70
|
+
visit(item);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!isRecord(value))
|
|
74
|
+
return;
|
|
75
|
+
for (const [key, child] of Object.entries(value)) {
|
|
76
|
+
if (ACTIONABLE_ONTOLOGY_SEED_ID_KEYS.has(key) &&
|
|
77
|
+
typeof child === "string" &&
|
|
78
|
+
child.trim().length > 0) {
|
|
79
|
+
refs.add(child.trim());
|
|
80
|
+
}
|
|
81
|
+
visit(child);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
visit(seed);
|
|
85
|
+
return refs;
|
|
86
|
+
}
|
|
87
|
+
function normalizeSourceRef(ref) {
|
|
88
|
+
return path.resolve(ref);
|
|
89
|
+
}
|
|
90
|
+
function evidenceObservationById(sourceObservations) {
|
|
91
|
+
return new Map(sourceObservations.observations.map((observation) => [
|
|
92
|
+
observation.observation_id,
|
|
93
|
+
observation,
|
|
94
|
+
]));
|
|
95
|
+
}
|
|
96
|
+
function readEvidenceRefs(args) {
|
|
97
|
+
if (!Array.isArray(args.value)) {
|
|
98
|
+
args.addViolation({
|
|
99
|
+
code: args.required ? "evidence_ref_missing" : "evidence_ref_shape_invalid",
|
|
100
|
+
message: `${args.fieldPath} must be an evidence_refs array`,
|
|
101
|
+
subjectId: args.subjectId,
|
|
102
|
+
});
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
if (args.required && args.value.length === 0) {
|
|
106
|
+
args.addViolation({
|
|
107
|
+
code: "evidence_ref_missing",
|
|
108
|
+
message: `${args.fieldPath} must include at least one evidence ref`,
|
|
109
|
+
subjectId: args.subjectId,
|
|
110
|
+
});
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
const byObservationId = evidenceObservationById(args.sourceObservations);
|
|
114
|
+
const evidenceRefs = [];
|
|
115
|
+
for (const [index, item] of args.value.entries()) {
|
|
116
|
+
const itemPath = `${args.fieldPath}[${index}]`;
|
|
117
|
+
if (!isRecord(item)) {
|
|
118
|
+
args.addViolation({
|
|
119
|
+
code: "evidence_ref_shape_invalid",
|
|
120
|
+
message: `${itemPath} must be an object`,
|
|
121
|
+
subjectId: args.subjectId,
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const observationId = optionalString(item.observation_id);
|
|
126
|
+
const targetMaterialKind = optionalString(item.target_material_kind);
|
|
127
|
+
const sourceRef = optionalString(item.source_ref);
|
|
128
|
+
const location = optionalString(item.location);
|
|
129
|
+
if (!observationId || !targetMaterialKind || !sourceRef || !location) {
|
|
130
|
+
args.addViolation({
|
|
131
|
+
code: "evidence_ref_shape_invalid",
|
|
132
|
+
message: `${itemPath} must include observation_id, target_material_kind, source_ref, and location`,
|
|
133
|
+
subjectId: args.subjectId,
|
|
134
|
+
observationId,
|
|
135
|
+
});
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const observation = byObservationId.get(observationId);
|
|
139
|
+
if (!observation) {
|
|
140
|
+
args.addViolation({
|
|
141
|
+
code: "unknown_observation_ref",
|
|
142
|
+
message: `${itemPath} references unknown observation_id ${observationId}`,
|
|
143
|
+
subjectId: args.subjectId,
|
|
144
|
+
observationId,
|
|
145
|
+
});
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (targetMaterialKind !== observation.target_material_kind) {
|
|
149
|
+
args.addViolation({
|
|
150
|
+
code: "material_kind_mismatch",
|
|
151
|
+
message: `${itemPath}.target_material_kind does not match source observation`,
|
|
152
|
+
subjectId: args.subjectId,
|
|
153
|
+
observationId,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (normalizeSourceRef(sourceRef) !== normalizeSourceRef(observation.source_ref)) {
|
|
157
|
+
args.addViolation({
|
|
158
|
+
code: "source_ref_mismatch",
|
|
159
|
+
message: `${itemPath}.source_ref does not match source observation`,
|
|
160
|
+
subjectId: args.subjectId,
|
|
161
|
+
observationId,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (location !== observation.location) {
|
|
165
|
+
args.addViolation({
|
|
166
|
+
code: "location_mismatch",
|
|
167
|
+
message: `${itemPath}.location does not match source observation`,
|
|
168
|
+
subjectId: args.subjectId,
|
|
169
|
+
observationId,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
evidenceRefs.push({
|
|
173
|
+
observation_id: observationId,
|
|
174
|
+
target_material_kind: observation.target_material_kind,
|
|
175
|
+
source_ref: sourceRef,
|
|
176
|
+
location,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return evidenceRefs;
|
|
180
|
+
}
|
|
181
|
+
function registryCandidateKindIds(registry) {
|
|
182
|
+
return new Set(registry.candidate_kind_registry.map((record) => record.candidate_kind_id));
|
|
183
|
+
}
|
|
184
|
+
function registryCandidateDispositionIds(registry) {
|
|
185
|
+
return new Set(registry.candidate_disposition_registry.map((record) => record.disposition_id));
|
|
186
|
+
}
|
|
187
|
+
function candidateValidationViolation(args) {
|
|
188
|
+
return {
|
|
189
|
+
code: args.code,
|
|
190
|
+
message: args.message,
|
|
191
|
+
candidate_id: args.candidateId ?? null,
|
|
192
|
+
observation_id: args.observationId ?? null,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export function validateCandidateDisposition(args) {
|
|
196
|
+
const violations = [];
|
|
197
|
+
const addShapeViolation = (_code, message) => {
|
|
198
|
+
violations.push(candidateValidationViolation({
|
|
199
|
+
code: "schema_shape_invalid",
|
|
200
|
+
message,
|
|
201
|
+
}));
|
|
202
|
+
};
|
|
203
|
+
const addEvidenceViolation = (violation) => {
|
|
204
|
+
violations.push(candidateValidationViolation({
|
|
205
|
+
code: violation.code,
|
|
206
|
+
message: violation.message,
|
|
207
|
+
candidateId: violation.subjectId ?? null,
|
|
208
|
+
observationId: violation.observationId ?? null,
|
|
209
|
+
}));
|
|
210
|
+
};
|
|
211
|
+
const inventory = readRecord(args.candidateInventory, "candidate_inventory", addShapeViolation);
|
|
212
|
+
const disposition = readRecord(args.candidateDisposition, "candidate_disposition", addShapeViolation);
|
|
213
|
+
const sessionId = optionalString(inventory?.session_id) ??
|
|
214
|
+
optionalString(disposition?.session_id) ??
|
|
215
|
+
args.sourceObservations.session_id;
|
|
216
|
+
if (optionalString(inventory?.session_id) &&
|
|
217
|
+
optionalString(disposition?.session_id) &&
|
|
218
|
+
optionalString(inventory?.session_id) !== optionalString(disposition?.session_id)) {
|
|
219
|
+
violations.push(candidateValidationViolation({
|
|
220
|
+
code: "session_id_mismatch",
|
|
221
|
+
message: "candidate inventory and disposition session_id values must match",
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
const allowedKinds = registryCandidateKindIds(args.registry);
|
|
225
|
+
const allowedDispositions = registryCandidateDispositionIds(args.registry);
|
|
226
|
+
const candidateIds = new Set();
|
|
227
|
+
const candidateEvidenceObservationIds = new Set();
|
|
228
|
+
const candidateRows = readArray(inventory?.candidates, "candidate_inventory.candidates", addShapeViolation);
|
|
229
|
+
for (const [index, candidateValue] of candidateRows.entries()) {
|
|
230
|
+
if (!isRecord(candidateValue)) {
|
|
231
|
+
violations.push(candidateValidationViolation({
|
|
232
|
+
code: "schema_shape_invalid",
|
|
233
|
+
message: `candidate_inventory.candidates[${index}] must be an object`,
|
|
234
|
+
}));
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const candidateId = optionalString(candidateValue.candidate_id);
|
|
238
|
+
if (!candidateId) {
|
|
239
|
+
violations.push(candidateValidationViolation({
|
|
240
|
+
code: "schema_shape_invalid",
|
|
241
|
+
message: `candidate_inventory.candidates[${index}].candidate_id is required`,
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
else if (candidateIds.has(candidateId)) {
|
|
245
|
+
violations.push(candidateValidationViolation({
|
|
246
|
+
code: "duplicate_candidate_id",
|
|
247
|
+
message: `duplicate candidate_id ${candidateId}`,
|
|
248
|
+
candidateId,
|
|
249
|
+
}));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
candidateIds.add(candidateId);
|
|
253
|
+
}
|
|
254
|
+
const kind = optionalString(candidateValue.candidate_kind);
|
|
255
|
+
if (!kind || !allowedKinds.has(kind)) {
|
|
256
|
+
violations.push(candidateValidationViolation({
|
|
257
|
+
code: "invalid_candidate_kind",
|
|
258
|
+
message: `candidate ${candidateId ?? index} uses an unknown candidate_kind`,
|
|
259
|
+
candidateId,
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
const candidateEvidenceRefs = readEvidenceRefs({
|
|
263
|
+
value: candidateValue.evidence_refs,
|
|
264
|
+
fieldPath: `candidate_inventory.candidates[${index}].evidence_refs`,
|
|
265
|
+
subjectId: candidateId,
|
|
266
|
+
required: true,
|
|
267
|
+
sourceObservations: args.sourceObservations,
|
|
268
|
+
addViolation: addEvidenceViolation,
|
|
269
|
+
});
|
|
270
|
+
for (const evidenceRef of candidateEvidenceRefs) {
|
|
271
|
+
candidateEvidenceObservationIds.add(evidenceRef.observation_id);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
for (const observation of args.sourceObservations.observations) {
|
|
275
|
+
if (!candidateEvidenceObservationIds.has(observation.observation_id)) {
|
|
276
|
+
violations.push(candidateValidationViolation({
|
|
277
|
+
code: "source_observation_coverage_missing",
|
|
278
|
+
message: `source observation has no candidate inventory coverage: ${observation.observation_id}`,
|
|
279
|
+
observationId: observation.observation_id,
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const dispositionIds = new Set();
|
|
284
|
+
let promotedCandidateCount = 0;
|
|
285
|
+
const dispositionRows = readArray(disposition?.dispositions, "candidate_disposition.dispositions", addShapeViolation);
|
|
286
|
+
for (const [index, dispositionValue] of dispositionRows.entries()) {
|
|
287
|
+
if (!isRecord(dispositionValue)) {
|
|
288
|
+
violations.push(candidateValidationViolation({
|
|
289
|
+
code: "schema_shape_invalid",
|
|
290
|
+
message: `candidate_disposition.dispositions[${index}] must be an object`,
|
|
291
|
+
}));
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const candidateId = optionalString(dispositionValue.candidate_id);
|
|
295
|
+
if (!candidateId) {
|
|
296
|
+
violations.push(candidateValidationViolation({
|
|
297
|
+
code: "schema_shape_invalid",
|
|
298
|
+
message: `candidate_disposition.dispositions[${index}].candidate_id is required`,
|
|
299
|
+
}));
|
|
300
|
+
}
|
|
301
|
+
else if (dispositionIds.has(candidateId)) {
|
|
302
|
+
violations.push(candidateValidationViolation({
|
|
303
|
+
code: "duplicate_disposition",
|
|
304
|
+
message: `duplicate disposition for candidate_id ${candidateId}`,
|
|
305
|
+
candidateId,
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
dispositionIds.add(candidateId);
|
|
310
|
+
}
|
|
311
|
+
if (candidateId && !candidateIds.has(candidateId)) {
|
|
312
|
+
violations.push(candidateValidationViolation({
|
|
313
|
+
code: "unknown_candidate_id",
|
|
314
|
+
message: `disposition references unknown candidate_id ${candidateId}`,
|
|
315
|
+
candidateId,
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
const dispositionId = optionalString(dispositionValue.disposition_id);
|
|
319
|
+
if (!dispositionId || !allowedDispositions.has(dispositionId)) {
|
|
320
|
+
violations.push(candidateValidationViolation({
|
|
321
|
+
code: "invalid_disposition",
|
|
322
|
+
message: `candidate ${candidateId ?? index} uses an unknown disposition_id`,
|
|
323
|
+
candidateId,
|
|
324
|
+
}));
|
|
325
|
+
}
|
|
326
|
+
const targetSeedRefs = stringArray(dispositionValue.target_seed_refs);
|
|
327
|
+
const targetRefRequired = dispositionId === "promoted_to_seed_layer" ||
|
|
328
|
+
dispositionId?.startsWith("represented_as_") === true;
|
|
329
|
+
if (dispositionId === "promoted_to_seed_layer") {
|
|
330
|
+
promotedCandidateCount += 1;
|
|
331
|
+
}
|
|
332
|
+
if (targetRefRequired && targetSeedRefs.length === 0) {
|
|
333
|
+
violations.push(candidateValidationViolation({
|
|
334
|
+
code: dispositionId === "promoted_to_seed_layer"
|
|
335
|
+
? "promoted_target_missing"
|
|
336
|
+
: "target_ref_missing",
|
|
337
|
+
message: `candidate ${candidateId ?? index} uses ${dispositionId} but has no target_seed_refs`,
|
|
338
|
+
candidateId,
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
if (!optionalString(dispositionValue.rationale)) {
|
|
342
|
+
violations.push(candidateValidationViolation({
|
|
343
|
+
code: "rationale_missing",
|
|
344
|
+
message: `candidate ${candidateId ?? index} disposition rationale is required`,
|
|
345
|
+
candidateId,
|
|
346
|
+
}));
|
|
347
|
+
}
|
|
348
|
+
readEvidenceRefs({
|
|
349
|
+
value: dispositionValue.evidence_refs,
|
|
350
|
+
fieldPath: `candidate_disposition.dispositions[${index}].evidence_refs`,
|
|
351
|
+
subjectId: candidateId,
|
|
352
|
+
required: true,
|
|
353
|
+
sourceObservations: args.sourceObservations,
|
|
354
|
+
addViolation: addEvidenceViolation,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
for (const candidateId of candidateIds) {
|
|
358
|
+
if (!dispositionIds.has(candidateId)) {
|
|
359
|
+
violations.push(candidateValidationViolation({
|
|
360
|
+
code: "missing_candidate_disposition",
|
|
361
|
+
message: `candidate ${candidateId} has no disposition row`,
|
|
362
|
+
candidateId,
|
|
363
|
+
}));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
schema_version: "1",
|
|
368
|
+
session_id: sessionId,
|
|
369
|
+
created_at: isoNow(),
|
|
370
|
+
candidate_inventory_ref: args.candidateInventoryRef ?? null,
|
|
371
|
+
candidate_disposition_ref: args.candidateDispositionRef ?? null,
|
|
372
|
+
source_observations_ref: args.sourceObservationsRef ?? null,
|
|
373
|
+
registry_ref: args.registryRef ?? null,
|
|
374
|
+
validation_status: violations.length === 0 ? "valid" : "invalid",
|
|
375
|
+
candidate_count: candidateIds.size,
|
|
376
|
+
disposition_count: dispositionIds.size,
|
|
377
|
+
promoted_candidate_count: promotedCandidateCount,
|
|
378
|
+
validation_results: violations.length === 0
|
|
379
|
+
? ["candidate_disposition_valid"]
|
|
380
|
+
: ["candidate_disposition_invalid"],
|
|
381
|
+
violations,
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
function seedValidationViolation(args) {
|
|
385
|
+
return {
|
|
386
|
+
code: args.code,
|
|
387
|
+
message: args.message,
|
|
388
|
+
subject_id: args.subjectId ?? null,
|
|
389
|
+
observation_id: args.observationId ?? null,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
const SEED_DECLARED_STATUS_VALUES = ["confirmed", "provisional", "deferred"];
|
|
393
|
+
const INSTANCE_AVAILABILITY_STATUS_VALUES = [
|
|
394
|
+
"present",
|
|
395
|
+
"absent",
|
|
396
|
+
"unknown",
|
|
397
|
+
"not_applicable",
|
|
398
|
+
];
|
|
399
|
+
const READY_HANDOFF_MAPPING_KEYS = [
|
|
400
|
+
"classification_mapping",
|
|
401
|
+
"entity_identity_mapping",
|
|
402
|
+
"instance_assertion_mapping",
|
|
403
|
+
"terminology_mapping",
|
|
404
|
+
"relation_type_mapping",
|
|
405
|
+
"constraint_mapping",
|
|
406
|
+
"modularity_boundary",
|
|
407
|
+
"reasoning_or_formalism_profile",
|
|
408
|
+
"application_context_mapping",
|
|
409
|
+
"metadata_mapping",
|
|
410
|
+
"provenance_mapping",
|
|
411
|
+
"change_tracking_mapping",
|
|
412
|
+
"competency_scope_mapping",
|
|
413
|
+
"alignment_mapping",
|
|
414
|
+
"modeling_concern_applicability",
|
|
415
|
+
"reference_standard_mapping",
|
|
416
|
+
"pattern_catalog_mapping",
|
|
417
|
+
"graph_connectivity",
|
|
418
|
+
];
|
|
419
|
+
const NON_SUBSTANTIVE_HANDOFF_KEYS = new Set([
|
|
420
|
+
"limitation_refs",
|
|
421
|
+
"evidence_refs",
|
|
422
|
+
"rationale",
|
|
423
|
+
]);
|
|
424
|
+
const NON_SUBSTANTIVE_HANDOFF_STRING_VALUES = new Set([
|
|
425
|
+
"",
|
|
426
|
+
"unknown",
|
|
427
|
+
"none",
|
|
428
|
+
"not_applicable",
|
|
429
|
+
]);
|
|
430
|
+
function hasNestedLimitationRefs(value) {
|
|
431
|
+
if (Array.isArray(value))
|
|
432
|
+
return value.some((item) => hasNestedLimitationRefs(item));
|
|
433
|
+
if (!isRecord(value))
|
|
434
|
+
return false;
|
|
435
|
+
for (const [key, child] of Object.entries(value)) {
|
|
436
|
+
if (key === "limitation_refs" && stringArray(child).length > 0)
|
|
437
|
+
return true;
|
|
438
|
+
if (hasNestedLimitationRefs(child))
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
function hasSubstantiveHandoffContent(value) {
|
|
444
|
+
if (typeof value === "boolean")
|
|
445
|
+
return true;
|
|
446
|
+
if (typeof value === "number")
|
|
447
|
+
return Number.isFinite(value);
|
|
448
|
+
if (typeof value === "string") {
|
|
449
|
+
return !NON_SUBSTANTIVE_HANDOFF_STRING_VALUES.has(value.trim());
|
|
450
|
+
}
|
|
451
|
+
if (Array.isArray(value)) {
|
|
452
|
+
return value.some((item) => hasSubstantiveHandoffContent(item));
|
|
453
|
+
}
|
|
454
|
+
if (!isRecord(value))
|
|
455
|
+
return false;
|
|
456
|
+
return Object.entries(value).some(([key, child]) => !NON_SUBSTANTIVE_HANDOFF_KEYS.has(key) && hasSubstantiveHandoffContent(child));
|
|
457
|
+
}
|
|
458
|
+
function validateReadyHandoffMappings(args) {
|
|
459
|
+
for (const key of READY_HANDOFF_MAPPING_KEYS) {
|
|
460
|
+
const mapping = args.ontologyHandoff?.[key];
|
|
461
|
+
if (!isRecord(mapping)) {
|
|
462
|
+
args.violations.push(seedValidationViolation({
|
|
463
|
+
code: "missing_required_field",
|
|
464
|
+
message: `ontology_handoff.${key} must be an object when readiness_claim is ready`,
|
|
465
|
+
subjectId: key,
|
|
466
|
+
}));
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
if (!hasSubstantiveHandoffContent(mapping) &&
|
|
470
|
+
!hasNestedLimitationRefs(mapping)) {
|
|
471
|
+
args.violations.push(seedValidationViolation({
|
|
472
|
+
code: "missing_required_field",
|
|
473
|
+
message: `ontology_handoff.${key} must include substantive mapping content or limitation_refs when readiness_claim is ready`,
|
|
474
|
+
subjectId: key,
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function validateOptionalEnum(args) {
|
|
480
|
+
const value = optionalString(args.value);
|
|
481
|
+
if (!value) {
|
|
482
|
+
args.violations.push(seedValidationViolation({
|
|
483
|
+
code: "missing_required_field",
|
|
484
|
+
message: `${args.fieldPath} must be a non-empty string`,
|
|
485
|
+
subjectId: args.subjectId ?? null,
|
|
486
|
+
}));
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
if (!args.allowed.includes(value)) {
|
|
490
|
+
args.violations.push(seedValidationViolation({
|
|
491
|
+
code: "invalid_enum",
|
|
492
|
+
message: `${args.fieldPath} has invalid value ${value}`,
|
|
493
|
+
subjectId: args.subjectId ?? value,
|
|
494
|
+
}));
|
|
495
|
+
}
|
|
496
|
+
return value;
|
|
497
|
+
}
|
|
498
|
+
function validateEnumArray(args) {
|
|
499
|
+
const values = readArray(args.value, args.fieldPath, (code, message) => args.violations.push(seedValidationViolation({ code, message }))).filter((item) => typeof item === "string" && item.trim().length > 0);
|
|
500
|
+
for (const value of values) {
|
|
501
|
+
if (!args.allowed.includes(value)) {
|
|
502
|
+
args.violations.push(seedValidationViolation({
|
|
503
|
+
code: "invalid_enum",
|
|
504
|
+
message: `${args.fieldPath} contains invalid value ${value}`,
|
|
505
|
+
subjectId: args.subjectId ?? value,
|
|
506
|
+
}));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return values;
|
|
510
|
+
}
|
|
511
|
+
function recordsFromSeed(args) {
|
|
512
|
+
const value = args.owner?.[args.key];
|
|
513
|
+
if (!Array.isArray(value)) {
|
|
514
|
+
args.violations.push(seedValidationViolation({
|
|
515
|
+
code: "missing_required_field",
|
|
516
|
+
message: `${args.path}.${args.key} must be an array`,
|
|
517
|
+
}));
|
|
518
|
+
return [];
|
|
519
|
+
}
|
|
520
|
+
const records = [];
|
|
521
|
+
for (const [index, item] of value.entries()) {
|
|
522
|
+
if (!isRecord(item)) {
|
|
523
|
+
args.violations.push(seedValidationViolation({
|
|
524
|
+
code: "schema_shape_invalid",
|
|
525
|
+
message: `${args.path}.${args.key}[${index}] must be an object`,
|
|
526
|
+
}));
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
records.push(item);
|
|
530
|
+
}
|
|
531
|
+
return records;
|
|
532
|
+
}
|
|
533
|
+
function addSeedId(args) {
|
|
534
|
+
if (!args.id) {
|
|
535
|
+
args.violations.push(seedValidationViolation({
|
|
536
|
+
code: "missing_required_field",
|
|
537
|
+
message: `${args.fieldPath} is required`,
|
|
538
|
+
}));
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (args.seedRefs.has(args.id)) {
|
|
542
|
+
args.violations.push(seedValidationViolation({
|
|
543
|
+
code: "duplicate_id",
|
|
544
|
+
message: `duplicate seed ref id ${args.id}`,
|
|
545
|
+
subjectId: args.id,
|
|
546
|
+
}));
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
args.seedRefs.add(args.id);
|
|
550
|
+
}
|
|
551
|
+
function addRequiredString(args) {
|
|
552
|
+
const value = optionalString(args.owner?.[args.key]);
|
|
553
|
+
if (!value) {
|
|
554
|
+
args.violations.push(seedValidationViolation({
|
|
555
|
+
code: "missing_required_field",
|
|
556
|
+
message: `${args.fieldPath}.${args.key} is required`,
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
return value;
|
|
560
|
+
}
|
|
561
|
+
function checkKnownRefs(args) {
|
|
562
|
+
for (const ref of args.refs) {
|
|
563
|
+
if (!args.knownRefs.has(ref)) {
|
|
564
|
+
args.violations.push(seedValidationViolation({
|
|
565
|
+
code: "unknown_ref",
|
|
566
|
+
message: `${args.fieldPath} references unknown seed ref ${ref}`,
|
|
567
|
+
subjectId: args.subjectId ?? ref,
|
|
568
|
+
}));
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function addSeedRefFamily(families, familyId, ref) {
|
|
573
|
+
if (!ref)
|
|
574
|
+
return;
|
|
575
|
+
const family = families.get(familyId) ?? new Set();
|
|
576
|
+
family.add(ref);
|
|
577
|
+
families.set(familyId, family);
|
|
578
|
+
}
|
|
579
|
+
function seedRefsForFamilies(families, familyIds) {
|
|
580
|
+
const refs = new Set();
|
|
581
|
+
for (const familyId of familyIds) {
|
|
582
|
+
for (const ref of families.get(familyId) ?? [])
|
|
583
|
+
refs.add(ref);
|
|
584
|
+
}
|
|
585
|
+
return refs;
|
|
586
|
+
}
|
|
587
|
+
function allowedCandidateTargetFamilies(dispositionId) {
|
|
588
|
+
switch (dispositionId) {
|
|
589
|
+
case "promoted_to_seed_layer":
|
|
590
|
+
return [
|
|
591
|
+
"conceptual_frame.concepts",
|
|
592
|
+
"semantic_layer.object_types",
|
|
593
|
+
"semantic_layer.constraints",
|
|
594
|
+
"dynamic_layer.actor_types",
|
|
595
|
+
"dynamic_layer.permission_policies",
|
|
596
|
+
"kinetic_layer.action_types",
|
|
597
|
+
"kinetic_layer.workflows",
|
|
598
|
+
"data_binding_layer.source_bindings",
|
|
599
|
+
"data_binding_layer.read_models",
|
|
600
|
+
"data_binding_layer.writebacks",
|
|
601
|
+
"data_binding_layer.provenance_bindings",
|
|
602
|
+
];
|
|
603
|
+
case "represented_as_property":
|
|
604
|
+
return ["semantic_layer.object_type_properties"];
|
|
605
|
+
case "represented_as_link":
|
|
606
|
+
return ["semantic_layer.link_types"];
|
|
607
|
+
case "represented_as_actor_role":
|
|
608
|
+
return ["dynamic_layer.actor_roles"];
|
|
609
|
+
case "represented_as_permission_rule":
|
|
610
|
+
return ["dynamic_layer.permission_policies"];
|
|
611
|
+
case "represented_as_data_binding":
|
|
612
|
+
return [
|
|
613
|
+
"data_binding_layer.source_bindings",
|
|
614
|
+
"data_binding_layer.read_models",
|
|
615
|
+
"data_binding_layer.writebacks",
|
|
616
|
+
"data_binding_layer.provenance_bindings",
|
|
617
|
+
];
|
|
618
|
+
case "represented_as_validation_question":
|
|
619
|
+
return ["validation_layer.unsupported_question_candidates"];
|
|
620
|
+
default:
|
|
621
|
+
return [];
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function collectNestedEvidenceRefs(args) {
|
|
625
|
+
let count = 0;
|
|
626
|
+
if (Array.isArray(args.value)) {
|
|
627
|
+
for (const [index, item] of args.value.entries()) {
|
|
628
|
+
count += collectNestedEvidenceRefs({
|
|
629
|
+
...args,
|
|
630
|
+
value: item,
|
|
631
|
+
path: `${args.path}[${index}]`,
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
return count;
|
|
635
|
+
}
|
|
636
|
+
if (!isRecord(args.value))
|
|
637
|
+
return 0;
|
|
638
|
+
for (const [key, value] of Object.entries(args.value)) {
|
|
639
|
+
if (key === "evidence_refs") {
|
|
640
|
+
count += readEvidenceRefs({
|
|
641
|
+
value,
|
|
642
|
+
fieldPath: `${args.path}.evidence_refs`,
|
|
643
|
+
subjectId: optionalString(args.value[`${key.slice(0, -1)}_id`]),
|
|
644
|
+
required: false,
|
|
645
|
+
sourceObservations: args.sourceObservations,
|
|
646
|
+
addViolation: (violation) => {
|
|
647
|
+
args.violations.push(seedValidationViolation({
|
|
648
|
+
code: violation.code,
|
|
649
|
+
message: violation.message,
|
|
650
|
+
subjectId: violation.subjectId ?? null,
|
|
651
|
+
observationId: violation.observationId ?? null,
|
|
652
|
+
}));
|
|
653
|
+
},
|
|
654
|
+
}).length;
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
count += collectNestedEvidenceRefs({
|
|
658
|
+
...args,
|
|
659
|
+
value,
|
|
660
|
+
path: `${args.path}.${key}`,
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
return count;
|
|
664
|
+
}
|
|
665
|
+
function collectNestedLimitationRefs(args) {
|
|
666
|
+
if (Array.isArray(args.value)) {
|
|
667
|
+
for (const [index, item] of args.value.entries()) {
|
|
668
|
+
collectNestedLimitationRefs({
|
|
669
|
+
...args,
|
|
670
|
+
value: item,
|
|
671
|
+
path: `${args.path}[${index}]`,
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
if (!isRecord(args.value))
|
|
677
|
+
return;
|
|
678
|
+
for (const [key, value] of Object.entries(args.value)) {
|
|
679
|
+
if (key === "limitation_refs") {
|
|
680
|
+
for (const ref of stringArray(value)) {
|
|
681
|
+
if (!args.limitationIds.has(ref)) {
|
|
682
|
+
args.violations.push(seedValidationViolation({
|
|
683
|
+
code: "limitation_ref_unknown",
|
|
684
|
+
message: `${args.path}.limitation_refs references unknown limitation ${ref}`,
|
|
685
|
+
subjectId: ref,
|
|
686
|
+
}));
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
collectNestedLimitationRefs({
|
|
692
|
+
...args,
|
|
693
|
+
value,
|
|
694
|
+
path: `${args.path}.${key}`,
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function hasLimitationForRef(limitations, ref) {
|
|
699
|
+
return limitations.some((limitation) => stringArray(limitation.affected_refs).includes(ref));
|
|
700
|
+
}
|
|
701
|
+
function checkSourceRefs(args) {
|
|
702
|
+
for (const ref of args.refs) {
|
|
703
|
+
if (!args.observedSourceRefs.has(normalizeSourceRef(ref))) {
|
|
704
|
+
args.violations.push(seedValidationViolation({
|
|
705
|
+
code: "source_ref_unknown",
|
|
706
|
+
message: `${args.fieldPath} references unobserved source_ref ${ref}`,
|
|
707
|
+
subjectId: ref,
|
|
708
|
+
}));
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
export function validateActionableOntologySeed(args) {
|
|
713
|
+
const violations = [];
|
|
714
|
+
const addShapeViolation = (_code, message) => {
|
|
715
|
+
violations.push(seedValidationViolation({ code: "schema_shape_invalid", message }));
|
|
716
|
+
};
|
|
717
|
+
const seed = readRecord(args.ontologySeed, "ontology_seed", addShapeViolation);
|
|
718
|
+
const disposition = readRecord(args.candidateDisposition, "candidate_disposition", addShapeViolation);
|
|
719
|
+
const sessionId = optionalString(disposition?.session_id) ??
|
|
720
|
+
args.sourceObservations.session_id;
|
|
721
|
+
if (optionalString(disposition?.session_id) &&
|
|
722
|
+
optionalString(disposition?.session_id) !== args.sourceObservations.session_id) {
|
|
723
|
+
violations.push(seedValidationViolation({
|
|
724
|
+
code: "session_id_mismatch",
|
|
725
|
+
message: "candidate disposition and source observations session_id values must match",
|
|
726
|
+
}));
|
|
727
|
+
}
|
|
728
|
+
const rootObjects = [
|
|
729
|
+
"seed_identity",
|
|
730
|
+
"purpose",
|
|
731
|
+
"decision_context",
|
|
732
|
+
"conceptual_frame",
|
|
733
|
+
"semantic_layer",
|
|
734
|
+
"kinetic_layer",
|
|
735
|
+
"dynamic_layer",
|
|
736
|
+
"data_binding_layer",
|
|
737
|
+
"validation_layer",
|
|
738
|
+
"candidate_disposition_authority_ref",
|
|
739
|
+
"ontology_handoff",
|
|
740
|
+
"source_authority",
|
|
741
|
+
];
|
|
742
|
+
const root = new Map();
|
|
743
|
+
for (const key of rootObjects) {
|
|
744
|
+
const record = readRecord(seed?.[key], `ontology_seed.${key}`, (code, message) => {
|
|
745
|
+
violations.push(seedValidationViolation({ code, message }));
|
|
746
|
+
});
|
|
747
|
+
root.set(key, record);
|
|
748
|
+
}
|
|
749
|
+
const limitations = recordsFromSeed({
|
|
750
|
+
owner: seed,
|
|
751
|
+
key: "handoff_limitations",
|
|
752
|
+
path: "ontology_seed",
|
|
753
|
+
violations,
|
|
754
|
+
});
|
|
755
|
+
const seedIdentity = root.get("seed_identity") ?? null;
|
|
756
|
+
const seedId = addRequiredString({
|
|
757
|
+
owner: seedIdentity,
|
|
758
|
+
key: "seed_id",
|
|
759
|
+
fieldPath: "ontology_seed.seed_identity",
|
|
760
|
+
violations,
|
|
761
|
+
});
|
|
762
|
+
addRequiredString({
|
|
763
|
+
owner: seedIdentity,
|
|
764
|
+
key: "schema_version",
|
|
765
|
+
fieldPath: "ontology_seed.seed_identity",
|
|
766
|
+
violations,
|
|
767
|
+
});
|
|
768
|
+
addRequiredString({
|
|
769
|
+
owner: seedIdentity,
|
|
770
|
+
key: "title",
|
|
771
|
+
fieldPath: "ontology_seed.seed_identity",
|
|
772
|
+
violations,
|
|
773
|
+
});
|
|
774
|
+
addRequiredString({
|
|
775
|
+
owner: seedIdentity,
|
|
776
|
+
key: "generated_at",
|
|
777
|
+
fieldPath: "ontology_seed.seed_identity",
|
|
778
|
+
violations,
|
|
779
|
+
});
|
|
780
|
+
addRequiredString({
|
|
781
|
+
owner: seedIdentity,
|
|
782
|
+
key: "authoring_profile",
|
|
783
|
+
fieldPath: "ontology_seed.seed_identity",
|
|
784
|
+
violations,
|
|
785
|
+
});
|
|
786
|
+
if (!Array.isArray(seedIdentity?.target_refs)) {
|
|
787
|
+
violations.push(seedValidationViolation({
|
|
788
|
+
code: "missing_required_field",
|
|
789
|
+
message: "ontology_seed.seed_identity.target_refs must be an array",
|
|
790
|
+
}));
|
|
791
|
+
}
|
|
792
|
+
const purpose = root.get("purpose") ?? null;
|
|
793
|
+
addRequiredString({
|
|
794
|
+
owner: purpose,
|
|
795
|
+
key: "declared_purpose",
|
|
796
|
+
fieldPath: "ontology_seed.purpose",
|
|
797
|
+
violations,
|
|
798
|
+
});
|
|
799
|
+
for (const key of ["intended_decisions", "intended_actions", "non_goals"]) {
|
|
800
|
+
if (!Array.isArray(purpose?.[key])) {
|
|
801
|
+
violations.push(seedValidationViolation({
|
|
802
|
+
code: "missing_required_field",
|
|
803
|
+
message: `ontology_seed.purpose.${key} must be an array`,
|
|
804
|
+
}));
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
readEvidenceRefs({
|
|
808
|
+
value: purpose?.evidence_refs,
|
|
809
|
+
fieldPath: "ontology_seed.purpose.evidence_refs",
|
|
810
|
+
subjectId: seedId,
|
|
811
|
+
required: true,
|
|
812
|
+
sourceObservations: args.sourceObservations,
|
|
813
|
+
addViolation: (violation) => {
|
|
814
|
+
violations.push(seedValidationViolation({
|
|
815
|
+
code: violation.code,
|
|
816
|
+
message: violation.message,
|
|
817
|
+
subjectId: violation.subjectId ?? null,
|
|
818
|
+
observationId: violation.observationId ?? null,
|
|
819
|
+
}));
|
|
820
|
+
},
|
|
821
|
+
});
|
|
822
|
+
const seedRefs = new Set();
|
|
823
|
+
if (seedId)
|
|
824
|
+
seedRefs.add(seedId);
|
|
825
|
+
const seedRefFamilies = new Map();
|
|
826
|
+
const conceptIds = new Set();
|
|
827
|
+
const objectTypeIds = new Set();
|
|
828
|
+
const actorTypeIds = new Set();
|
|
829
|
+
const roleIds = new Set();
|
|
830
|
+
const actionTypeIds = new Set();
|
|
831
|
+
const valueTypeIds = new Set();
|
|
832
|
+
const conceptualFrame = root.get("conceptual_frame") ?? null;
|
|
833
|
+
const concepts = recordsFromSeed({
|
|
834
|
+
owner: conceptualFrame,
|
|
835
|
+
key: "concepts",
|
|
836
|
+
path: "ontology_seed.conceptual_frame",
|
|
837
|
+
violations,
|
|
838
|
+
});
|
|
839
|
+
for (const [index, concept] of concepts.entries()) {
|
|
840
|
+
const conceptId = optionalString(concept.concept_id);
|
|
841
|
+
addSeedId({
|
|
842
|
+
id: conceptId,
|
|
843
|
+
fieldPath: `ontology_seed.conceptual_frame.concepts[${index}].concept_id`,
|
|
844
|
+
seedRefs,
|
|
845
|
+
violations,
|
|
846
|
+
});
|
|
847
|
+
if (conceptId) {
|
|
848
|
+
conceptIds.add(conceptId);
|
|
849
|
+
addSeedRefFamily(seedRefFamilies, "conceptual_frame.concepts", conceptId);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
const associations = recordsFromSeed({
|
|
853
|
+
owner: conceptualFrame,
|
|
854
|
+
key: "associations",
|
|
855
|
+
path: "ontology_seed.conceptual_frame",
|
|
856
|
+
violations,
|
|
857
|
+
});
|
|
858
|
+
for (const [index, association] of associations.entries()) {
|
|
859
|
+
const associationId = optionalString(association.association_id);
|
|
860
|
+
addSeedId({
|
|
861
|
+
id: associationId,
|
|
862
|
+
fieldPath: `ontology_seed.conceptual_frame.associations[${index}].association_id`,
|
|
863
|
+
seedRefs,
|
|
864
|
+
violations,
|
|
865
|
+
});
|
|
866
|
+
addSeedRefFamily(seedRefFamilies, "conceptual_frame.associations", associationId);
|
|
867
|
+
checkKnownRefs({
|
|
868
|
+
refs: [
|
|
869
|
+
optionalString(association.source_concept_id),
|
|
870
|
+
optionalString(association.target_concept_id),
|
|
871
|
+
].filter((ref) => ref !== null),
|
|
872
|
+
knownRefs: conceptIds,
|
|
873
|
+
fieldPath: `ontology_seed.conceptual_frame.associations[${index}]`,
|
|
874
|
+
violations,
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
const semanticLayer = root.get("semantic_layer") ?? null;
|
|
878
|
+
const objectTypes = recordsFromSeed({
|
|
879
|
+
owner: semanticLayer,
|
|
880
|
+
key: "object_types",
|
|
881
|
+
path: "ontology_seed.semantic_layer",
|
|
882
|
+
violations,
|
|
883
|
+
});
|
|
884
|
+
for (const [index, objectType] of objectTypes.entries()) {
|
|
885
|
+
const objectTypeId = optionalString(objectType.object_type_id);
|
|
886
|
+
addSeedId({
|
|
887
|
+
id: objectTypeId,
|
|
888
|
+
fieldPath: `ontology_seed.semantic_layer.object_types[${index}].object_type_id`,
|
|
889
|
+
seedRefs,
|
|
890
|
+
violations,
|
|
891
|
+
});
|
|
892
|
+
if (objectTypeId) {
|
|
893
|
+
objectTypeIds.add(objectTypeId);
|
|
894
|
+
addSeedRefFamily(seedRefFamilies, "semantic_layer.object_types", objectTypeId);
|
|
895
|
+
}
|
|
896
|
+
validateOptionalEnum({
|
|
897
|
+
value: objectType.status,
|
|
898
|
+
allowed: SEED_DECLARED_STATUS_VALUES,
|
|
899
|
+
fieldPath: `ontology_seed.semantic_layer.object_types[${index}].status`,
|
|
900
|
+
subjectId: objectTypeId,
|
|
901
|
+
violations,
|
|
902
|
+
});
|
|
903
|
+
const primaryKey = isRecord(objectType.primary_key) ? objectType.primary_key : null;
|
|
904
|
+
const primaryKeyId = optionalString(primaryKey?.property_id);
|
|
905
|
+
const propertyRows = recordsFromSeed({
|
|
906
|
+
owner: objectType,
|
|
907
|
+
key: "properties",
|
|
908
|
+
path: `ontology_seed.semantic_layer.object_types[${index}]`,
|
|
909
|
+
violations,
|
|
910
|
+
});
|
|
911
|
+
const propertyIds = new Set(propertyRows
|
|
912
|
+
.map((property) => optionalString(property.property_id))
|
|
913
|
+
.filter((propertyId) => propertyId !== null));
|
|
914
|
+
if (primaryKeyId && !propertyIds.has(primaryKeyId)) {
|
|
915
|
+
addSeedId({
|
|
916
|
+
id: primaryKeyId,
|
|
917
|
+
fieldPath: `ontology_seed.semantic_layer.object_types[${index}].primary_key.property_id`,
|
|
918
|
+
seedRefs,
|
|
919
|
+
violations,
|
|
920
|
+
});
|
|
921
|
+
addSeedRefFamily(seedRefFamilies, "semantic_layer.object_type_properties", primaryKeyId);
|
|
922
|
+
}
|
|
923
|
+
for (const [propertyIndex, property] of propertyRows.entries()) {
|
|
924
|
+
const propertyId = optionalString(property.property_id);
|
|
925
|
+
addSeedId({
|
|
926
|
+
id: propertyId,
|
|
927
|
+
fieldPath: `ontology_seed.semantic_layer.object_types[${index}].properties[${propertyIndex}].property_id`,
|
|
928
|
+
seedRefs,
|
|
929
|
+
violations,
|
|
930
|
+
});
|
|
931
|
+
addSeedRefFamily(seedRefFamilies, "semantic_layer.object_type_properties", propertyId);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
const linkTypes = recordsFromSeed({
|
|
935
|
+
owner: semanticLayer,
|
|
936
|
+
key: "link_types",
|
|
937
|
+
path: "ontology_seed.semantic_layer",
|
|
938
|
+
violations,
|
|
939
|
+
});
|
|
940
|
+
for (const [index, linkType] of linkTypes.entries()) {
|
|
941
|
+
const linkTypeId = optionalString(linkType.link_type_id);
|
|
942
|
+
addSeedId({
|
|
943
|
+
id: linkTypeId,
|
|
944
|
+
fieldPath: `ontology_seed.semantic_layer.link_types[${index}].link_type_id`,
|
|
945
|
+
seedRefs,
|
|
946
|
+
violations,
|
|
947
|
+
});
|
|
948
|
+
addSeedRefFamily(seedRefFamilies, "semantic_layer.link_types", linkTypeId);
|
|
949
|
+
checkKnownRefs({
|
|
950
|
+
refs: [
|
|
951
|
+
optionalString(linkType.source_object_type_id),
|
|
952
|
+
optionalString(linkType.target_object_type_id),
|
|
953
|
+
].filter((ref) => ref !== null),
|
|
954
|
+
knownRefs: objectTypeIds,
|
|
955
|
+
fieldPath: `ontology_seed.semantic_layer.link_types[${index}]`,
|
|
956
|
+
violations,
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
for (const [index, valueType] of recordsFromSeed({
|
|
960
|
+
owner: semanticLayer,
|
|
961
|
+
key: "value_types",
|
|
962
|
+
path: "ontology_seed.semantic_layer",
|
|
963
|
+
violations,
|
|
964
|
+
}).entries()) {
|
|
965
|
+
const valueTypeId = optionalString(valueType.value_type_id);
|
|
966
|
+
addSeedId({
|
|
967
|
+
id: valueTypeId,
|
|
968
|
+
fieldPath: `ontology_seed.semantic_layer.value_types[${index}].value_type_id`,
|
|
969
|
+
seedRefs,
|
|
970
|
+
violations,
|
|
971
|
+
});
|
|
972
|
+
if (valueTypeId) {
|
|
973
|
+
valueTypeIds.add(valueTypeId);
|
|
974
|
+
addSeedRefFamily(seedRefFamilies, "semantic_layer.value_types", valueTypeId);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
for (const [index, constraint] of recordsFromSeed({
|
|
978
|
+
owner: semanticLayer,
|
|
979
|
+
key: "constraints",
|
|
980
|
+
path: "ontology_seed.semantic_layer",
|
|
981
|
+
violations,
|
|
982
|
+
}).entries()) {
|
|
983
|
+
const constraintId = optionalString(constraint.constraint_id);
|
|
984
|
+
addSeedId({
|
|
985
|
+
id: constraintId,
|
|
986
|
+
fieldPath: `ontology_seed.semantic_layer.constraints[${index}].constraint_id`,
|
|
987
|
+
seedRefs,
|
|
988
|
+
violations,
|
|
989
|
+
});
|
|
990
|
+
addSeedRefFamily(seedRefFamilies, "semantic_layer.constraints", constraintId);
|
|
991
|
+
}
|
|
992
|
+
const dynamicLayer = root.get("dynamic_layer") ?? null;
|
|
993
|
+
const actorTypes = recordsFromSeed({
|
|
994
|
+
owner: dynamicLayer,
|
|
995
|
+
key: "actor_types",
|
|
996
|
+
path: "ontology_seed.dynamic_layer",
|
|
997
|
+
violations,
|
|
998
|
+
});
|
|
999
|
+
for (const [index, actorType] of actorTypes.entries()) {
|
|
1000
|
+
const actorTypeId = optionalString(actorType.actor_type_id);
|
|
1001
|
+
addSeedId({
|
|
1002
|
+
id: actorTypeId,
|
|
1003
|
+
fieldPath: `ontology_seed.dynamic_layer.actor_types[${index}].actor_type_id`,
|
|
1004
|
+
seedRefs,
|
|
1005
|
+
violations,
|
|
1006
|
+
});
|
|
1007
|
+
if (actorTypeId) {
|
|
1008
|
+
actorTypeIds.add(actorTypeId);
|
|
1009
|
+
addSeedRefFamily(seedRefFamilies, "dynamic_layer.actor_types", actorTypeId);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
const actorRoles = recordsFromSeed({
|
|
1013
|
+
owner: dynamicLayer,
|
|
1014
|
+
key: "actor_roles",
|
|
1015
|
+
path: "ontology_seed.dynamic_layer",
|
|
1016
|
+
violations,
|
|
1017
|
+
});
|
|
1018
|
+
for (const [index, actorRole] of actorRoles.entries()) {
|
|
1019
|
+
const roleId = optionalString(actorRole.role_id);
|
|
1020
|
+
addSeedId({
|
|
1021
|
+
id: roleId,
|
|
1022
|
+
fieldPath: `ontology_seed.dynamic_layer.actor_roles[${index}].role_id`,
|
|
1023
|
+
seedRefs,
|
|
1024
|
+
violations,
|
|
1025
|
+
});
|
|
1026
|
+
if (roleId) {
|
|
1027
|
+
roleIds.add(roleId);
|
|
1028
|
+
addSeedRefFamily(seedRefFamilies, "dynamic_layer.actor_roles", roleId);
|
|
1029
|
+
}
|
|
1030
|
+
checkKnownRefs({
|
|
1031
|
+
refs: stringArray(actorRole.holder_actor_type_ids),
|
|
1032
|
+
knownRefs: actorTypeIds,
|
|
1033
|
+
fieldPath: `ontology_seed.dynamic_layer.actor_roles[${index}].holder_actor_type_ids`,
|
|
1034
|
+
violations,
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
for (const [index, actorType] of actorTypes.entries()) {
|
|
1038
|
+
checkKnownRefs({
|
|
1039
|
+
refs: stringArray(actorType.role_refs),
|
|
1040
|
+
knownRefs: roleIds,
|
|
1041
|
+
fieldPath: `ontology_seed.dynamic_layer.actor_types[${index}].role_refs`,
|
|
1042
|
+
violations,
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
const kineticLayer = root.get("kinetic_layer") ?? null;
|
|
1046
|
+
const actionTypes = recordsFromSeed({
|
|
1047
|
+
owner: kineticLayer,
|
|
1048
|
+
key: "action_types",
|
|
1049
|
+
path: "ontology_seed.kinetic_layer",
|
|
1050
|
+
violations,
|
|
1051
|
+
});
|
|
1052
|
+
for (const [index, actionType] of actionTypes.entries()) {
|
|
1053
|
+
const actionTypeId = optionalString(actionType.action_type_id);
|
|
1054
|
+
addSeedId({
|
|
1055
|
+
id: actionTypeId,
|
|
1056
|
+
fieldPath: `ontology_seed.kinetic_layer.action_types[${index}].action_type_id`,
|
|
1057
|
+
seedRefs,
|
|
1058
|
+
violations,
|
|
1059
|
+
});
|
|
1060
|
+
if (actionTypeId) {
|
|
1061
|
+
actionTypeIds.add(actionTypeId);
|
|
1062
|
+
addSeedRefFamily(seedRefFamilies, "kinetic_layer.action_types", actionTypeId);
|
|
1063
|
+
}
|
|
1064
|
+
validateOptionalEnum({
|
|
1065
|
+
value: actionType.status,
|
|
1066
|
+
allowed: SEED_DECLARED_STATUS_VALUES,
|
|
1067
|
+
fieldPath: `ontology_seed.kinetic_layer.action_types[${index}].status`,
|
|
1068
|
+
subjectId: actionTypeId,
|
|
1069
|
+
violations,
|
|
1070
|
+
});
|
|
1071
|
+
const actorRefs = stringArray(actionType.actor_type_ids);
|
|
1072
|
+
const targetRefs = stringArray(actionType.target_object_type_ids);
|
|
1073
|
+
const affectedRefs = stringArray(actionType.affected_object_type_ids);
|
|
1074
|
+
checkKnownRefs({
|
|
1075
|
+
refs: actorRefs,
|
|
1076
|
+
knownRefs: actorTypeIds,
|
|
1077
|
+
fieldPath: `ontology_seed.kinetic_layer.action_types[${index}].actor_type_ids`,
|
|
1078
|
+
subjectId: actionTypeId,
|
|
1079
|
+
violations,
|
|
1080
|
+
});
|
|
1081
|
+
checkKnownRefs({
|
|
1082
|
+
refs: [...targetRefs, ...affectedRefs],
|
|
1083
|
+
knownRefs: objectTypeIds,
|
|
1084
|
+
fieldPath: `ontology_seed.kinetic_layer.action_types[${index}].object_type_ids`,
|
|
1085
|
+
subjectId: actionTypeId,
|
|
1086
|
+
violations,
|
|
1087
|
+
});
|
|
1088
|
+
if (actionTypeId && (actorRefs.length === 0 || targetRefs.length + affectedRefs.length === 0)) {
|
|
1089
|
+
if (!hasLimitationForRef(limitations, actionTypeId)) {
|
|
1090
|
+
violations.push(seedValidationViolation({
|
|
1091
|
+
code: "action_binding_missing",
|
|
1092
|
+
message: `action_type ${actionTypeId} needs actor and object bindings or a handoff limitation`,
|
|
1093
|
+
subjectId: actionTypeId,
|
|
1094
|
+
}));
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
for (const [parameterIndex, parameter] of recordsFromSeed({
|
|
1098
|
+
owner: actionType,
|
|
1099
|
+
key: "parameters",
|
|
1100
|
+
path: `ontology_seed.kinetic_layer.action_types[${index}]`,
|
|
1101
|
+
violations,
|
|
1102
|
+
}).entries()) {
|
|
1103
|
+
addSeedId({
|
|
1104
|
+
id: optionalString(parameter.parameter_id),
|
|
1105
|
+
fieldPath: `ontology_seed.kinetic_layer.action_types[${index}].parameters[${parameterIndex}].parameter_id`,
|
|
1106
|
+
seedRefs,
|
|
1107
|
+
violations,
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
for (const key of ["preconditions", "postconditions", "side_effects"]) {
|
|
1111
|
+
const idKey = key === "preconditions"
|
|
1112
|
+
? "precondition_id"
|
|
1113
|
+
: key === "postconditions"
|
|
1114
|
+
? "postcondition_id"
|
|
1115
|
+
: "side_effect_id";
|
|
1116
|
+
for (const [nestedIndex, nested] of recordsFromSeed({
|
|
1117
|
+
owner: actionType,
|
|
1118
|
+
key,
|
|
1119
|
+
path: `ontology_seed.kinetic_layer.action_types[${index}]`,
|
|
1120
|
+
violations,
|
|
1121
|
+
}).entries()) {
|
|
1122
|
+
addSeedId({
|
|
1123
|
+
id: optionalString(nested[idKey]),
|
|
1124
|
+
fieldPath: `ontology_seed.kinetic_layer.action_types[${index}].${key}[${nestedIndex}].${idKey}`,
|
|
1125
|
+
seedRefs,
|
|
1126
|
+
violations,
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
for (const [index, fn] of recordsFromSeed({
|
|
1132
|
+
owner: kineticLayer,
|
|
1133
|
+
key: "functions",
|
|
1134
|
+
path: "ontology_seed.kinetic_layer",
|
|
1135
|
+
violations,
|
|
1136
|
+
}).entries()) {
|
|
1137
|
+
const functionId = optionalString(fn.function_id);
|
|
1138
|
+
addSeedId({
|
|
1139
|
+
id: functionId,
|
|
1140
|
+
fieldPath: `ontology_seed.kinetic_layer.functions[${index}].function_id`,
|
|
1141
|
+
seedRefs,
|
|
1142
|
+
violations,
|
|
1143
|
+
});
|
|
1144
|
+
addSeedRefFamily(seedRefFamilies, "kinetic_layer.functions", functionId);
|
|
1145
|
+
}
|
|
1146
|
+
for (const [index, workflow] of recordsFromSeed({
|
|
1147
|
+
owner: kineticLayer,
|
|
1148
|
+
key: "workflows",
|
|
1149
|
+
path: "ontology_seed.kinetic_layer",
|
|
1150
|
+
violations,
|
|
1151
|
+
}).entries()) {
|
|
1152
|
+
const workflowId = optionalString(workflow.workflow_id);
|
|
1153
|
+
addSeedId({
|
|
1154
|
+
id: workflowId,
|
|
1155
|
+
fieldPath: `ontology_seed.kinetic_layer.workflows[${index}].workflow_id`,
|
|
1156
|
+
seedRefs,
|
|
1157
|
+
violations,
|
|
1158
|
+
});
|
|
1159
|
+
addSeedRefFamily(seedRefFamilies, "kinetic_layer.workflows", workflowId);
|
|
1160
|
+
checkKnownRefs({
|
|
1161
|
+
refs: stringArray(workflow.ordered_action_type_ids),
|
|
1162
|
+
knownRefs: actionTypeIds,
|
|
1163
|
+
fieldPath: `ontology_seed.kinetic_layer.workflows[${index}].ordered_action_type_ids`,
|
|
1164
|
+
violations,
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
const permissionPolicies = recordsFromSeed({
|
|
1168
|
+
owner: dynamicLayer,
|
|
1169
|
+
key: "permission_policies",
|
|
1170
|
+
path: "ontology_seed.dynamic_layer",
|
|
1171
|
+
violations,
|
|
1172
|
+
});
|
|
1173
|
+
const permissionPolicyActionIds = new Set();
|
|
1174
|
+
for (const [index, policy] of permissionPolicies.entries()) {
|
|
1175
|
+
const policyId = optionalString(policy.policy_id);
|
|
1176
|
+
addSeedId({
|
|
1177
|
+
id: policyId,
|
|
1178
|
+
fieldPath: `ontology_seed.dynamic_layer.permission_policies[${index}].policy_id`,
|
|
1179
|
+
seedRefs,
|
|
1180
|
+
violations,
|
|
1181
|
+
});
|
|
1182
|
+
addSeedRefFamily(seedRefFamilies, "dynamic_layer.permission_policies", policyId);
|
|
1183
|
+
const actionTypeId = optionalString(policy.action_type_id);
|
|
1184
|
+
if (actionTypeId)
|
|
1185
|
+
permissionPolicyActionIds.add(actionTypeId);
|
|
1186
|
+
checkKnownRefs({
|
|
1187
|
+
refs: [
|
|
1188
|
+
optionalString(policy.actor_type_id),
|
|
1189
|
+
].filter((ref) => ref !== null),
|
|
1190
|
+
knownRefs: actorTypeIds,
|
|
1191
|
+
fieldPath: `ontology_seed.dynamic_layer.permission_policies[${index}].actor_type_id`,
|
|
1192
|
+
violations,
|
|
1193
|
+
});
|
|
1194
|
+
checkKnownRefs({
|
|
1195
|
+
refs: [
|
|
1196
|
+
actionTypeId,
|
|
1197
|
+
].filter((ref) => ref !== null),
|
|
1198
|
+
knownRefs: actionTypeIds,
|
|
1199
|
+
fieldPath: `ontology_seed.dynamic_layer.permission_policies[${index}].action_type_id`,
|
|
1200
|
+
violations,
|
|
1201
|
+
});
|
|
1202
|
+
checkKnownRefs({
|
|
1203
|
+
refs: [
|
|
1204
|
+
optionalString(policy.object_type_id),
|
|
1205
|
+
].filter((ref) => ref !== null),
|
|
1206
|
+
knownRefs: objectTypeIds,
|
|
1207
|
+
fieldPath: `ontology_seed.dynamic_layer.permission_policies[${index}].object_type_id`,
|
|
1208
|
+
violations,
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
for (const actionTypeId of actionTypeIds) {
|
|
1212
|
+
if (!permissionPolicyActionIds.has(actionTypeId) && !hasLimitationForRef(limitations, actionTypeId)) {
|
|
1213
|
+
violations.push(seedValidationViolation({
|
|
1214
|
+
code: "permission_missing",
|
|
1215
|
+
message: `action_type ${actionTypeId} needs permission policy coverage or a handoff limitation`,
|
|
1216
|
+
subjectId: actionTypeId,
|
|
1217
|
+
}));
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
for (const [index, stateModel] of recordsFromSeed({
|
|
1221
|
+
owner: dynamicLayer,
|
|
1222
|
+
key: "state_models",
|
|
1223
|
+
path: "ontology_seed.dynamic_layer",
|
|
1224
|
+
violations,
|
|
1225
|
+
}).entries()) {
|
|
1226
|
+
const stateModelId = optionalString(stateModel.state_model_id);
|
|
1227
|
+
addSeedId({
|
|
1228
|
+
id: stateModelId,
|
|
1229
|
+
fieldPath: `ontology_seed.dynamic_layer.state_models[${index}].state_model_id`,
|
|
1230
|
+
seedRefs,
|
|
1231
|
+
violations,
|
|
1232
|
+
});
|
|
1233
|
+
addSeedRefFamily(seedRefFamilies, "dynamic_layer.state_models", stateModelId);
|
|
1234
|
+
checkKnownRefs({
|
|
1235
|
+
refs: [optionalString(stateModel.object_type_id)]
|
|
1236
|
+
.filter((ref) => ref !== null),
|
|
1237
|
+
knownRefs: objectTypeIds,
|
|
1238
|
+
fieldPath: `ontology_seed.dynamic_layer.state_models[${index}].object_type_id`,
|
|
1239
|
+
violations,
|
|
1240
|
+
});
|
|
1241
|
+
for (const [transitionIndex, transition] of recordsFromSeed({
|
|
1242
|
+
owner: stateModel,
|
|
1243
|
+
key: "transitions",
|
|
1244
|
+
path: `ontology_seed.dynamic_layer.state_models[${index}]`,
|
|
1245
|
+
violations,
|
|
1246
|
+
}).entries()) {
|
|
1247
|
+
const transitionId = optionalString(transition.transition_id);
|
|
1248
|
+
addSeedId({
|
|
1249
|
+
id: transitionId,
|
|
1250
|
+
fieldPath: `ontology_seed.dynamic_layer.state_models[${index}].transitions[${transitionIndex}].transition_id`,
|
|
1251
|
+
seedRefs,
|
|
1252
|
+
violations,
|
|
1253
|
+
});
|
|
1254
|
+
addSeedRefFamily(seedRefFamilies, "dynamic_layer.state_transitions", transitionId);
|
|
1255
|
+
checkKnownRefs({
|
|
1256
|
+
refs: [optionalString(transition.action_type_id)]
|
|
1257
|
+
.filter((ref) => ref !== null),
|
|
1258
|
+
knownRefs: actionTypeIds,
|
|
1259
|
+
fieldPath: `ontology_seed.dynamic_layer.state_models[${index}].transitions[${transitionIndex}].action_type_id`,
|
|
1260
|
+
violations,
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
for (const [index, lifecycleRule] of recordsFromSeed({
|
|
1265
|
+
owner: dynamicLayer,
|
|
1266
|
+
key: "lifecycle_rules",
|
|
1267
|
+
path: "ontology_seed.dynamic_layer",
|
|
1268
|
+
violations,
|
|
1269
|
+
}).entries()) {
|
|
1270
|
+
const lifecycleRuleId = optionalString(lifecycleRule.rule_id);
|
|
1271
|
+
addSeedId({
|
|
1272
|
+
id: lifecycleRuleId,
|
|
1273
|
+
fieldPath: `ontology_seed.dynamic_layer.lifecycle_rules[${index}].rule_id`,
|
|
1274
|
+
seedRefs,
|
|
1275
|
+
violations,
|
|
1276
|
+
});
|
|
1277
|
+
addSeedRefFamily(seedRefFamilies, "dynamic_layer.lifecycle_rules", lifecycleRuleId);
|
|
1278
|
+
}
|
|
1279
|
+
const observedSourceRefs = new Set(args.sourceObservations.observations.map((observation) => normalizeSourceRef(observation.source_ref)));
|
|
1280
|
+
const dataBindingLayer = root.get("data_binding_layer") ?? null;
|
|
1281
|
+
const sourceBindings = recordsFromSeed({
|
|
1282
|
+
owner: dataBindingLayer,
|
|
1283
|
+
key: "source_bindings",
|
|
1284
|
+
path: "ontology_seed.data_binding_layer",
|
|
1285
|
+
violations,
|
|
1286
|
+
});
|
|
1287
|
+
const dataBoundSeedRefs = new Set();
|
|
1288
|
+
for (const [index, binding] of sourceBindings.entries()) {
|
|
1289
|
+
const bindingId = optionalString(binding.binding_id);
|
|
1290
|
+
addSeedId({
|
|
1291
|
+
id: bindingId,
|
|
1292
|
+
fieldPath: `ontology_seed.data_binding_layer.source_bindings[${index}].binding_id`,
|
|
1293
|
+
seedRefs,
|
|
1294
|
+
violations,
|
|
1295
|
+
});
|
|
1296
|
+
addSeedRefFamily(seedRefFamilies, "data_binding_layer.source_bindings", bindingId);
|
|
1297
|
+
const seedRef = optionalString(binding.seed_ref);
|
|
1298
|
+
if (seedRef)
|
|
1299
|
+
dataBoundSeedRefs.add(seedRef);
|
|
1300
|
+
checkSourceRefs({
|
|
1301
|
+
refs: [optionalString(binding.source_ref)]
|
|
1302
|
+
.filter((ref) => ref !== null),
|
|
1303
|
+
observedSourceRefs,
|
|
1304
|
+
fieldPath: `ontology_seed.data_binding_layer.source_bindings[${index}].source_ref`,
|
|
1305
|
+
violations,
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
for (const [index, readModel] of recordsFromSeed({
|
|
1309
|
+
owner: dataBindingLayer,
|
|
1310
|
+
key: "read_models",
|
|
1311
|
+
path: "ontology_seed.data_binding_layer",
|
|
1312
|
+
violations,
|
|
1313
|
+
}).entries()) {
|
|
1314
|
+
const readModelId = optionalString(readModel.read_model_id);
|
|
1315
|
+
addSeedId({
|
|
1316
|
+
id: readModelId,
|
|
1317
|
+
fieldPath: `ontology_seed.data_binding_layer.read_models[${index}].read_model_id`,
|
|
1318
|
+
seedRefs,
|
|
1319
|
+
violations,
|
|
1320
|
+
});
|
|
1321
|
+
addSeedRefFamily(seedRefFamilies, "data_binding_layer.read_models", readModelId);
|
|
1322
|
+
checkKnownRefs({
|
|
1323
|
+
refs: stringArray(readModel.object_type_ids),
|
|
1324
|
+
knownRefs: objectTypeIds,
|
|
1325
|
+
fieldPath: `ontology_seed.data_binding_layer.read_models[${index}].object_type_ids`,
|
|
1326
|
+
violations,
|
|
1327
|
+
});
|
|
1328
|
+
for (const objectTypeId of stringArray(readModel.object_type_ids)) {
|
|
1329
|
+
dataBoundSeedRefs.add(objectTypeId);
|
|
1330
|
+
}
|
|
1331
|
+
checkSourceRefs({
|
|
1332
|
+
refs: stringArray(readModel.source_refs),
|
|
1333
|
+
observedSourceRefs,
|
|
1334
|
+
fieldPath: `ontology_seed.data_binding_layer.read_models[${index}].source_refs`,
|
|
1335
|
+
violations,
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
const writebackActionIds = new Set();
|
|
1339
|
+
for (const [index, writeback] of recordsFromSeed({
|
|
1340
|
+
owner: dataBindingLayer,
|
|
1341
|
+
key: "writebacks",
|
|
1342
|
+
path: "ontology_seed.data_binding_layer",
|
|
1343
|
+
violations,
|
|
1344
|
+
}).entries()) {
|
|
1345
|
+
const writebackId = optionalString(writeback.writeback_id);
|
|
1346
|
+
addSeedId({
|
|
1347
|
+
id: writebackId,
|
|
1348
|
+
fieldPath: `ontology_seed.data_binding_layer.writebacks[${index}].writeback_id`,
|
|
1349
|
+
seedRefs,
|
|
1350
|
+
violations,
|
|
1351
|
+
});
|
|
1352
|
+
addSeedRefFamily(seedRefFamilies, "data_binding_layer.writebacks", writebackId);
|
|
1353
|
+
const actionTypeId = optionalString(writeback.action_type_id);
|
|
1354
|
+
if (actionTypeId)
|
|
1355
|
+
writebackActionIds.add(actionTypeId);
|
|
1356
|
+
checkKnownRefs({
|
|
1357
|
+
refs: [actionTypeId].filter((ref) => ref !== null),
|
|
1358
|
+
knownRefs: actionTypeIds,
|
|
1359
|
+
fieldPath: `ontology_seed.data_binding_layer.writebacks[${index}].action_type_id`,
|
|
1360
|
+
violations,
|
|
1361
|
+
});
|
|
1362
|
+
checkSourceRefs({
|
|
1363
|
+
refs: stringArray(writeback.target_source_refs),
|
|
1364
|
+
observedSourceRefs,
|
|
1365
|
+
fieldPath: `ontology_seed.data_binding_layer.writebacks[${index}].target_source_refs`,
|
|
1366
|
+
violations,
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
for (const [index, provenance] of recordsFromSeed({
|
|
1370
|
+
owner: dataBindingLayer,
|
|
1371
|
+
key: "provenance_bindings",
|
|
1372
|
+
path: "ontology_seed.data_binding_layer",
|
|
1373
|
+
violations,
|
|
1374
|
+
}).entries()) {
|
|
1375
|
+
const provenanceId = optionalString(provenance.provenance_id);
|
|
1376
|
+
addSeedId({
|
|
1377
|
+
id: provenanceId,
|
|
1378
|
+
fieldPath: `ontology_seed.data_binding_layer.provenance_bindings[${index}].provenance_id`,
|
|
1379
|
+
seedRefs,
|
|
1380
|
+
violations,
|
|
1381
|
+
});
|
|
1382
|
+
addSeedRefFamily(seedRefFamilies, "data_binding_layer.provenance_bindings", provenanceId);
|
|
1383
|
+
const seedRef = optionalString(provenance.seed_ref);
|
|
1384
|
+
if (seedRef)
|
|
1385
|
+
dataBoundSeedRefs.add(seedRef);
|
|
1386
|
+
checkSourceRefs({
|
|
1387
|
+
refs: [optionalString(provenance.source_ref)]
|
|
1388
|
+
.filter((ref) => ref !== null),
|
|
1389
|
+
observedSourceRefs,
|
|
1390
|
+
fieldPath: `ontology_seed.data_binding_layer.provenance_bindings[${index}].source_ref`,
|
|
1391
|
+
violations,
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
for (const objectTypeId of objectTypeIds) {
|
|
1395
|
+
if (!dataBoundSeedRefs.has(objectTypeId) && !hasLimitationForRef(limitations, objectTypeId)) {
|
|
1396
|
+
violations.push(seedValidationViolation({
|
|
1397
|
+
code: "data_binding_missing",
|
|
1398
|
+
message: `object_type ${objectTypeId} needs data binding coverage or a handoff limitation`,
|
|
1399
|
+
subjectId: objectTypeId,
|
|
1400
|
+
}));
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
const limitationIds = new Set();
|
|
1404
|
+
for (const [index, limitation] of limitations.entries()) {
|
|
1405
|
+
const limitationId = optionalString(limitation.limitation_id);
|
|
1406
|
+
addSeedId({
|
|
1407
|
+
id: limitationId,
|
|
1408
|
+
fieldPath: `ontology_seed.handoff_limitations[${index}].limitation_id`,
|
|
1409
|
+
seedRefs,
|
|
1410
|
+
violations,
|
|
1411
|
+
});
|
|
1412
|
+
if (limitationId)
|
|
1413
|
+
limitationIds.add(limitationId);
|
|
1414
|
+
}
|
|
1415
|
+
collectNestedLimitationRefs({
|
|
1416
|
+
value: seed,
|
|
1417
|
+
path: "ontology_seed",
|
|
1418
|
+
limitationIds,
|
|
1419
|
+
violations,
|
|
1420
|
+
});
|
|
1421
|
+
const validationLayer = root.get("validation_layer") ?? null;
|
|
1422
|
+
for (const [index, unsupportedQuestion] of recordsFromSeed({
|
|
1423
|
+
owner: validationLayer,
|
|
1424
|
+
key: "unsupported_question_candidates",
|
|
1425
|
+
path: "ontology_seed.validation_layer",
|
|
1426
|
+
violations,
|
|
1427
|
+
}).entries()) {
|
|
1428
|
+
const candidateId = optionalString(unsupportedQuestion.candidate_id);
|
|
1429
|
+
addSeedId({
|
|
1430
|
+
id: candidateId,
|
|
1431
|
+
fieldPath: `ontology_seed.validation_layer.unsupported_question_candidates[${index}].candidate_id`,
|
|
1432
|
+
seedRefs,
|
|
1433
|
+
violations,
|
|
1434
|
+
});
|
|
1435
|
+
addSeedRefFamily(seedRefFamilies, "validation_layer.unsupported_question_candidates", candidateId);
|
|
1436
|
+
}
|
|
1437
|
+
const allowedCoverageAxes = new Set(args.registry.coverage_axis_registry.map((record) => record.axis_id));
|
|
1438
|
+
for (const axis of stringArray(validationLayer?.coverage_axes)) {
|
|
1439
|
+
if (!allowedCoverageAxes.has(axis)) {
|
|
1440
|
+
violations.push(seedValidationViolation({
|
|
1441
|
+
code: "invalid_enum",
|
|
1442
|
+
message: `validation_layer.coverage_axes contains unknown axis ${axis}`,
|
|
1443
|
+
subjectId: axis,
|
|
1444
|
+
}));
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
const authorityRef = root.get("candidate_disposition_authority_ref") ?? null;
|
|
1448
|
+
const expectedAuthorityRefs = {
|
|
1449
|
+
authority_scope: "external_candidate_disposition",
|
|
1450
|
+
projection_policy: "reference_only",
|
|
1451
|
+
};
|
|
1452
|
+
for (const [key, expected] of Object.entries(expectedAuthorityRefs)) {
|
|
1453
|
+
if (optionalString(authorityRef?.[key]) !== expected) {
|
|
1454
|
+
violations.push(seedValidationViolation({
|
|
1455
|
+
code: "candidate_authority_ref_invalid",
|
|
1456
|
+
message: `candidate_disposition_authority_ref.${key} must be ${expected}`,
|
|
1457
|
+
subjectId: key,
|
|
1458
|
+
}));
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
const ontologyHandoff = root.get("ontology_handoff") ?? null;
|
|
1462
|
+
const readinessClaim = optionalString(ontologyHandoff?.readiness_claim);
|
|
1463
|
+
if (!["ready", "limited", "not_ready", "blocked"].includes(readinessClaim ?? "")) {
|
|
1464
|
+
violations.push(seedValidationViolation({
|
|
1465
|
+
code: "invalid_enum",
|
|
1466
|
+
message: "ontology_handoff.readiness_claim must be ready, limited, not_ready, or blocked",
|
|
1467
|
+
subjectId: readinessClaim,
|
|
1468
|
+
}));
|
|
1469
|
+
}
|
|
1470
|
+
else if (readinessClaim !== "ready" && limitationIds.size === 0) {
|
|
1471
|
+
violations.push(seedValidationViolation({
|
|
1472
|
+
code: "missing_required_field",
|
|
1473
|
+
message: "non-ready ontology handoff readiness must cite explicit handoff limitations",
|
|
1474
|
+
subjectId: readinessClaim,
|
|
1475
|
+
}));
|
|
1476
|
+
}
|
|
1477
|
+
else if (readinessClaim === "ready") {
|
|
1478
|
+
validateReadyHandoffMappings({ ontologyHandoff, violations });
|
|
1479
|
+
}
|
|
1480
|
+
const reasoningProfile = isRecord(ontologyHandoff?.reasoning_or_formalism_profile)
|
|
1481
|
+
? ontologyHandoff?.reasoning_or_formalism_profile
|
|
1482
|
+
: null;
|
|
1483
|
+
const reasoningValues = args.registry.reasoning_or_formalism_profile_values;
|
|
1484
|
+
if (reasoningProfile) {
|
|
1485
|
+
validateOptionalEnum({
|
|
1486
|
+
value: reasoningProfile.representation_formalism,
|
|
1487
|
+
allowed: reasoningValues.representation_formalism_values,
|
|
1488
|
+
fieldPath: "ontology_seed.ontology_handoff.reasoning_or_formalism_profile.representation_formalism",
|
|
1489
|
+
violations,
|
|
1490
|
+
});
|
|
1491
|
+
validateEnumArray({
|
|
1492
|
+
value: reasoningProfile.vocabulary_systems,
|
|
1493
|
+
allowed: reasoningValues.vocabulary_system_values,
|
|
1494
|
+
fieldPath: "ontology_seed.ontology_handoff.reasoning_or_formalism_profile.vocabulary_systems",
|
|
1495
|
+
violations,
|
|
1496
|
+
});
|
|
1497
|
+
validateEnumArray({
|
|
1498
|
+
value: reasoningProfile.validation_formalisms,
|
|
1499
|
+
allowed: reasoningValues.validation_formalism_values,
|
|
1500
|
+
fieldPath: "ontology_seed.ontology_handoff.reasoning_or_formalism_profile.validation_formalisms",
|
|
1501
|
+
violations,
|
|
1502
|
+
});
|
|
1503
|
+
validateOptionalEnum({
|
|
1504
|
+
value: reasoningProfile.ontology_type,
|
|
1505
|
+
allowed: reasoningValues.ontology_type_values,
|
|
1506
|
+
fieldPath: "ontology_seed.ontology_handoff.reasoning_or_formalism_profile.ontology_type",
|
|
1507
|
+
violations,
|
|
1508
|
+
});
|
|
1509
|
+
validateOptionalEnum({
|
|
1510
|
+
value: reasoningProfile.owl_profile,
|
|
1511
|
+
allowed: reasoningValues.owl_profile_values,
|
|
1512
|
+
fieldPath: "ontology_seed.ontology_handoff.reasoning_or_formalism_profile.owl_profile",
|
|
1513
|
+
violations,
|
|
1514
|
+
});
|
|
1515
|
+
validateOptionalEnum({
|
|
1516
|
+
value: reasoningProfile.alignment_posture,
|
|
1517
|
+
allowed: reasoningValues.alignment_posture_values,
|
|
1518
|
+
fieldPath: "ontology_seed.ontology_handoff.reasoning_or_formalism_profile.alignment_posture",
|
|
1519
|
+
violations,
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
else {
|
|
1523
|
+
violations.push(seedValidationViolation({
|
|
1524
|
+
code: "missing_required_field",
|
|
1525
|
+
message: "ontology_handoff.reasoning_or_formalism_profile must be an object",
|
|
1526
|
+
subjectId: "reasoning_or_formalism_profile",
|
|
1527
|
+
}));
|
|
1528
|
+
}
|
|
1529
|
+
const instanceAssertionMapping = isRecord(ontologyHandoff?.instance_assertion_mapping)
|
|
1530
|
+
? ontologyHandoff?.instance_assertion_mapping
|
|
1531
|
+
: null;
|
|
1532
|
+
const instanceAvailabilityStatus = instanceAssertionMapping
|
|
1533
|
+
? validateOptionalEnum({
|
|
1534
|
+
value: instanceAssertionMapping.instance_availability_status,
|
|
1535
|
+
allowed: INSTANCE_AVAILABILITY_STATUS_VALUES,
|
|
1536
|
+
fieldPath: "ontology_seed.ontology_handoff.instance_assertion_mapping.instance_availability_status",
|
|
1537
|
+
violations,
|
|
1538
|
+
})
|
|
1539
|
+
: null;
|
|
1540
|
+
if (!instanceAssertionMapping) {
|
|
1541
|
+
violations.push(seedValidationViolation({
|
|
1542
|
+
code: "missing_required_field",
|
|
1543
|
+
message: "ontology_handoff.instance_assertion_mapping must be an object",
|
|
1544
|
+
subjectId: "instance_assertion_mapping",
|
|
1545
|
+
}));
|
|
1546
|
+
}
|
|
1547
|
+
else if ((instanceAvailabilityStatus === "absent" || instanceAvailabilityStatus === "unknown") &&
|
|
1548
|
+
stringArray(instanceAssertionMapping.limitation_refs).length === 0) {
|
|
1549
|
+
violations.push(seedValidationViolation({
|
|
1550
|
+
code: "missing_required_field",
|
|
1551
|
+
message: "absent or unknown instance availability must cite instance_assertion_mapping.limitation_refs",
|
|
1552
|
+
subjectId: "instance_assertion_mapping",
|
|
1553
|
+
}));
|
|
1554
|
+
}
|
|
1555
|
+
for (const key of [
|
|
1556
|
+
"query_access_contract",
|
|
1557
|
+
"visualization_contract",
|
|
1558
|
+
"graph_exploration_contract",
|
|
1559
|
+
]) {
|
|
1560
|
+
const contract = isRecord(ontologyHandoff?.[key])
|
|
1561
|
+
? ontologyHandoff?.[key]
|
|
1562
|
+
: null;
|
|
1563
|
+
const applies = contract?.applies;
|
|
1564
|
+
if (applies !== true &&
|
|
1565
|
+
applies !== false &&
|
|
1566
|
+
applies !== "unknown" &&
|
|
1567
|
+
applies !== "not_applicable") {
|
|
1568
|
+
violations.push(seedValidationViolation({
|
|
1569
|
+
code: "invalid_enum",
|
|
1570
|
+
message: `ontology_handoff.${key}.applies must be true, false, unknown, or not_applicable`,
|
|
1571
|
+
subjectId: key,
|
|
1572
|
+
}));
|
|
1573
|
+
continue;
|
|
1574
|
+
}
|
|
1575
|
+
const limitationRefs = stringArray(contract?.limitation_refs);
|
|
1576
|
+
if ((applies === true || applies === "unknown") && limitationRefs.length === 0) {
|
|
1577
|
+
violations.push(seedValidationViolation({
|
|
1578
|
+
code: "missing_required_field",
|
|
1579
|
+
message: `ontology_handoff.${key} with applies=${String(applies)} must cite limitation_refs until runtime proof validation is active`,
|
|
1580
|
+
subjectId: key,
|
|
1581
|
+
}));
|
|
1582
|
+
}
|
|
1583
|
+
checkKnownRefs({
|
|
1584
|
+
refs: limitationRefs,
|
|
1585
|
+
knownRefs: limitationIds,
|
|
1586
|
+
fieldPath: `ontology_seed.ontology_handoff.${key}.limitation_refs`,
|
|
1587
|
+
subjectId: key,
|
|
1588
|
+
violations,
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
const modelingConcerns = isRecord(ontologyHandoff?.modeling_concern_applicability)
|
|
1592
|
+
? ontologyHandoff?.modeling_concern_applicability
|
|
1593
|
+
: null;
|
|
1594
|
+
for (const [index, row] of readArray(modelingConcerns?.rows, "ontology_handoff.modeling_concern_applicability.rows", (code, message) => violations.push(seedValidationViolation({ code, message }))).entries()) {
|
|
1595
|
+
if (!isRecord(row))
|
|
1596
|
+
continue;
|
|
1597
|
+
const applies = row.applies;
|
|
1598
|
+
if (applies !== true &&
|
|
1599
|
+
applies !== false &&
|
|
1600
|
+
applies !== "unknown" &&
|
|
1601
|
+
applies !== "not_applicable") {
|
|
1602
|
+
violations.push(seedValidationViolation({
|
|
1603
|
+
code: "invalid_enum",
|
|
1604
|
+
message: `ontology_handoff.modeling_concern_applicability.rows[${index}].applies must be true, false, unknown, or not_applicable`,
|
|
1605
|
+
subjectId: optionalString(row.concern_id),
|
|
1606
|
+
}));
|
|
1607
|
+
continue;
|
|
1608
|
+
}
|
|
1609
|
+
const limitationRefs = stringArray(row.limitation_refs);
|
|
1610
|
+
if (applies === "unknown" && limitationRefs.length === 0) {
|
|
1611
|
+
violations.push(seedValidationViolation({
|
|
1612
|
+
code: "missing_required_field",
|
|
1613
|
+
message: `ontology_handoff.modeling_concern_applicability.rows[${index}] with applies=unknown must cite limitation_refs`,
|
|
1614
|
+
subjectId: optionalString(row.concern_id),
|
|
1615
|
+
}));
|
|
1616
|
+
}
|
|
1617
|
+
checkKnownRefs({
|
|
1618
|
+
refs: limitationRefs,
|
|
1619
|
+
knownRefs: limitationIds,
|
|
1620
|
+
fieldPath: `ontology_seed.ontology_handoff.modeling_concern_applicability.rows[${index}].limitation_refs`,
|
|
1621
|
+
subjectId: optionalString(row.concern_id),
|
|
1622
|
+
violations,
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
const dispositionRows = readArray(disposition?.dispositions, "candidate_disposition.dispositions", (code, message) => violations.push(seedValidationViolation({ code, message })));
|
|
1626
|
+
for (const [index, dispositionValue] of dispositionRows.entries()) {
|
|
1627
|
+
if (!isRecord(dispositionValue))
|
|
1628
|
+
continue;
|
|
1629
|
+
const dispositionId = optionalString(dispositionValue.disposition_id);
|
|
1630
|
+
if (!dispositionId) {
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
const targetSeedRefs = stringArray(dispositionValue.target_seed_refs);
|
|
1634
|
+
const allowedFamilies = allowedCandidateTargetFamilies(dispositionId);
|
|
1635
|
+
const allowedRefs = seedRefsForFamilies(seedRefFamilies, allowedFamilies);
|
|
1636
|
+
if (allowedFamilies.length > 0 && targetSeedRefs.length === 0) {
|
|
1637
|
+
violations.push(seedValidationViolation({
|
|
1638
|
+
code: "candidate_target_ref_invalid",
|
|
1639
|
+
message: `candidate_disposition.dispositions[${index}].target_seed_refs is required for ${dispositionId}`,
|
|
1640
|
+
subjectId: optionalString(dispositionValue.candidate_id),
|
|
1641
|
+
}));
|
|
1642
|
+
}
|
|
1643
|
+
for (const targetSeedRef of targetSeedRefs) {
|
|
1644
|
+
if (!seedRefs.has(targetSeedRef)) {
|
|
1645
|
+
violations.push(seedValidationViolation({
|
|
1646
|
+
code: "promoted_candidate_ref_unknown",
|
|
1647
|
+
message: `candidate_disposition.dispositions[${index}].target_seed_refs references unknown seed ref ${targetSeedRef}`,
|
|
1648
|
+
subjectId: optionalString(dispositionValue.candidate_id),
|
|
1649
|
+
}));
|
|
1650
|
+
}
|
|
1651
|
+
else if (allowedFamilies.length > 0 && !allowedRefs.has(targetSeedRef)) {
|
|
1652
|
+
violations.push(seedValidationViolation({
|
|
1653
|
+
code: "candidate_target_ref_invalid",
|
|
1654
|
+
message: `candidate_disposition.dispositions[${index}].target_seed_refs ${targetSeedRef} is not valid for ${dispositionId}; expected one of ${allowedFamilies.join(", ")}`,
|
|
1655
|
+
subjectId: optionalString(dispositionValue.candidate_id),
|
|
1656
|
+
}));
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
const evidenceRefCount = collectNestedEvidenceRefs({
|
|
1661
|
+
value: seed,
|
|
1662
|
+
path: "ontology_seed",
|
|
1663
|
+
sourceObservations: args.sourceObservations,
|
|
1664
|
+
violations,
|
|
1665
|
+
});
|
|
1666
|
+
const sourceAuthority = root.get("source_authority") ?? null;
|
|
1667
|
+
for (const key of [
|
|
1668
|
+
"evidence_scope",
|
|
1669
|
+
"permission_scope",
|
|
1670
|
+
"trust_boundary",
|
|
1671
|
+
"instruction_authority",
|
|
1672
|
+
"external_content_handling",
|
|
1673
|
+
"rationale",
|
|
1674
|
+
]) {
|
|
1675
|
+
addRequiredString({
|
|
1676
|
+
owner: sourceAuthority,
|
|
1677
|
+
key,
|
|
1678
|
+
fieldPath: "ontology_seed.source_authority",
|
|
1679
|
+
violations,
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
for (const key of [
|
|
1683
|
+
"included_source_refs",
|
|
1684
|
+
"excluded_source_refs",
|
|
1685
|
+
"restricted_source_refs",
|
|
1686
|
+
"source_gaps",
|
|
1687
|
+
]) {
|
|
1688
|
+
if (!Array.isArray(sourceAuthority?.[key])) {
|
|
1689
|
+
violations.push(seedValidationViolation({
|
|
1690
|
+
code: "missing_required_field",
|
|
1691
|
+
message: `ontology_seed.source_authority.${key} must be an array`,
|
|
1692
|
+
}));
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
checkSourceRefs({
|
|
1696
|
+
refs: stringArray(sourceAuthority?.included_source_refs),
|
|
1697
|
+
observedSourceRefs,
|
|
1698
|
+
fieldPath: "ontology_seed.source_authority.included_source_refs",
|
|
1699
|
+
violations,
|
|
1700
|
+
});
|
|
1701
|
+
checkSourceRefs({
|
|
1702
|
+
refs: stringArray(sourceAuthority?.excluded_source_refs),
|
|
1703
|
+
observedSourceRefs,
|
|
1704
|
+
fieldPath: "ontology_seed.source_authority.excluded_source_refs",
|
|
1705
|
+
violations,
|
|
1706
|
+
});
|
|
1707
|
+
checkSourceRefs({
|
|
1708
|
+
refs: stringArray(sourceAuthority?.restricted_source_refs),
|
|
1709
|
+
observedSourceRefs,
|
|
1710
|
+
fieldPath: "ontology_seed.source_authority.restricted_source_refs",
|
|
1711
|
+
violations,
|
|
1712
|
+
});
|
|
1713
|
+
return {
|
|
1714
|
+
schema_version: "1",
|
|
1715
|
+
session_id: sessionId,
|
|
1716
|
+
created_at: isoNow(),
|
|
1717
|
+
ontology_seed_ref: args.ontologySeedRef ?? null,
|
|
1718
|
+
candidate_disposition_ref: args.candidateDispositionRef ?? null,
|
|
1719
|
+
source_observations_ref: args.sourceObservationsRef ?? null,
|
|
1720
|
+
registry_ref: args.registryRef ?? null,
|
|
1721
|
+
validation_status: violations.length === 0 ? "valid" : "invalid",
|
|
1722
|
+
seed_ref_count: seedRefs.size,
|
|
1723
|
+
evidence_ref_count: evidenceRefCount,
|
|
1724
|
+
limitation_count: limitationIds.size,
|
|
1725
|
+
validation_results: violations.length === 0
|
|
1726
|
+
? ["ontology_seed_valid"]
|
|
1727
|
+
: ["ontology_seed_invalid"],
|
|
1728
|
+
violations,
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
async function readYamlDocument(filePath) {
|
|
1732
|
+
return parseYaml(await fs.readFile(filePath, "utf8"));
|
|
1733
|
+
}
|
|
1734
|
+
async function writeYamlDocument(filePath, value) {
|
|
1735
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
1736
|
+
await fs.writeFile(filePath, stringifyYaml(value), "utf8");
|
|
1737
|
+
}
|
|
1738
|
+
export async function writeCandidateDispositionValidationArtifact(args) {
|
|
1739
|
+
const [candidateInventory, candidateDisposition, sourceObservations, registry] = await Promise.all([
|
|
1740
|
+
readYamlDocument(args.candidateInventoryPath),
|
|
1741
|
+
readYamlDocument(args.candidateDispositionPath),
|
|
1742
|
+
readYamlDocument(args.sourceObservationsPath),
|
|
1743
|
+
loadReconstructContractRegistry({ registryPath: args.registryPath }),
|
|
1744
|
+
]);
|
|
1745
|
+
const validation = validateCandidateDisposition({
|
|
1746
|
+
candidateInventory,
|
|
1747
|
+
candidateDisposition,
|
|
1748
|
+
sourceObservations,
|
|
1749
|
+
registry,
|
|
1750
|
+
candidateInventoryRef: path.resolve(args.candidateInventoryPath),
|
|
1751
|
+
candidateDispositionRef: path.resolve(args.candidateDispositionPath),
|
|
1752
|
+
sourceObservationsRef: path.resolve(args.sourceObservationsPath),
|
|
1753
|
+
registryRef: path.resolve(args.registryPath),
|
|
1754
|
+
});
|
|
1755
|
+
await writeYamlDocument(args.outputPath, validation);
|
|
1756
|
+
return validation;
|
|
1757
|
+
}
|
|
1758
|
+
export async function writeActionableOntologySeedValidationArtifact(args) {
|
|
1759
|
+
const [ontologySeed, candidateDisposition, sourceObservations, registry] = await Promise.all([
|
|
1760
|
+
readYamlDocument(args.ontologySeedPath),
|
|
1761
|
+
readYamlDocument(args.candidateDispositionPath),
|
|
1762
|
+
readYamlDocument(args.sourceObservationsPath),
|
|
1763
|
+
loadReconstructContractRegistry({ registryPath: args.registryPath }),
|
|
1764
|
+
]);
|
|
1765
|
+
const validation = validateActionableOntologySeed({
|
|
1766
|
+
ontologySeed,
|
|
1767
|
+
candidateDisposition,
|
|
1768
|
+
sourceObservations,
|
|
1769
|
+
registry,
|
|
1770
|
+
ontologySeedRef: path.resolve(args.ontologySeedPath),
|
|
1771
|
+
candidateDispositionRef: path.resolve(args.candidateDispositionPath),
|
|
1772
|
+
sourceObservationsRef: path.resolve(args.sourceObservationsPath),
|
|
1773
|
+
registryRef: path.resolve(args.registryPath),
|
|
1774
|
+
});
|
|
1775
|
+
await writeYamlDocument(args.outputPath, validation);
|
|
1776
|
+
return validation;
|
|
1777
|
+
}
|