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,268 @@
|
|
|
1
|
+
function uniqueEvidenceRefs(refs) {
|
|
2
|
+
const byKey = new Map();
|
|
3
|
+
for (const ref of refs) {
|
|
4
|
+
byKey.set(`${ref.observation_id}\u0000${ref.target_material_kind}\u0000${ref.source_ref}\u0000${ref.location}`, ref);
|
|
5
|
+
}
|
|
6
|
+
return [...byKey.values()];
|
|
7
|
+
}
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
function recordValue(value) {
|
|
12
|
+
return isRecord(value) ? value : null;
|
|
13
|
+
}
|
|
14
|
+
function recordArray(owner, key) {
|
|
15
|
+
const value = owner?.[key];
|
|
16
|
+
return Array.isArray(value) ? value.filter(isRecord) : [];
|
|
17
|
+
}
|
|
18
|
+
function stringValue(value) {
|
|
19
|
+
return typeof value === "string" && value.trim().length > 0
|
|
20
|
+
? value
|
|
21
|
+
: null;
|
|
22
|
+
}
|
|
23
|
+
function stringArray(value) {
|
|
24
|
+
return Array.isArray(value)
|
|
25
|
+
? value.filter((item) => typeof item === "string" && item.trim().length > 0)
|
|
26
|
+
: [];
|
|
27
|
+
}
|
|
28
|
+
function evidenceRefs(value) {
|
|
29
|
+
if (!Array.isArray(value))
|
|
30
|
+
return [];
|
|
31
|
+
return value.filter((item) => isRecord(item) &&
|
|
32
|
+
typeof item.observation_id === "string" &&
|
|
33
|
+
typeof item.target_material_kind === "string" &&
|
|
34
|
+
typeof item.source_ref === "string" &&
|
|
35
|
+
typeof item.location === "string");
|
|
36
|
+
}
|
|
37
|
+
function directEvidence(record) {
|
|
38
|
+
return record ? uniqueEvidenceRefs(evidenceRefs(record.evidence_refs)) : [];
|
|
39
|
+
}
|
|
40
|
+
function purposeClaimId(seedId) {
|
|
41
|
+
return seedId ? `${seedId}#purpose` : "ontology-seed-purpose";
|
|
42
|
+
}
|
|
43
|
+
function claim(args) {
|
|
44
|
+
if (!args.id)
|
|
45
|
+
return null;
|
|
46
|
+
return {
|
|
47
|
+
claim_id: args.id,
|
|
48
|
+
seed_ref_path: args.seed_ref_path,
|
|
49
|
+
projection_source: "actionable_ontology_seed",
|
|
50
|
+
evidence_policy: "direct_evidence_only",
|
|
51
|
+
name: args.name ?? args.fallbackName,
|
|
52
|
+
statement: args.statement ?? args.name ?? args.fallbackName,
|
|
53
|
+
evidence_refs: args.evidence_refs,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function collectRecordClaims(args) {
|
|
57
|
+
return args.records
|
|
58
|
+
.map((record, index) => claim({
|
|
59
|
+
id: stringValue(record[args.idKey]),
|
|
60
|
+
seed_ref_path: `${args.pathPrefix}[${index}].${args.idKey}`,
|
|
61
|
+
name: args.nameKeys.map((key) => stringValue(record[key])).find(Boolean) ?? null,
|
|
62
|
+
statement: args.statementKeys.map((key) => stringValue(record[key])).find(Boolean) ?? null,
|
|
63
|
+
evidence_refs: directEvidence(record),
|
|
64
|
+
fallbackName: `${args.fallbackPrefix} ${index + 1}`,
|
|
65
|
+
}))
|
|
66
|
+
.filter((item) => item !== null);
|
|
67
|
+
}
|
|
68
|
+
export function ontologySeedClaimProjections(ontologySeed) {
|
|
69
|
+
const seed = recordValue(ontologySeed) ?? {};
|
|
70
|
+
const seedIdentity = recordValue(seed.seed_identity);
|
|
71
|
+
const purpose = recordValue(seed.purpose);
|
|
72
|
+
const conceptualFrame = recordValue(seed.conceptual_frame);
|
|
73
|
+
const semanticLayer = recordValue(seed.semantic_layer);
|
|
74
|
+
const kineticLayer = recordValue(seed.kinetic_layer);
|
|
75
|
+
const dynamicLayer = recordValue(seed.dynamic_layer);
|
|
76
|
+
const dataBindingLayer = recordValue(seed.data_binding_layer);
|
|
77
|
+
const purposeClaim = claim({
|
|
78
|
+
id: purposeClaimId(stringValue(seedIdentity?.seed_id)),
|
|
79
|
+
seed_ref_path: "purpose.declared_purpose",
|
|
80
|
+
name: stringValue(seedIdentity?.title) ?? "Ontology Seed Purpose",
|
|
81
|
+
statement: stringValue(purpose?.declared_purpose),
|
|
82
|
+
evidence_refs: directEvidence(purpose),
|
|
83
|
+
fallbackName: "Ontology Seed Purpose",
|
|
84
|
+
});
|
|
85
|
+
return [
|
|
86
|
+
...(purposeClaim ? [purposeClaim] : []),
|
|
87
|
+
...collectRecordClaims({
|
|
88
|
+
records: recordArray(conceptualFrame, "concepts"),
|
|
89
|
+
idKey: "concept_id",
|
|
90
|
+
nameKeys: ["name"],
|
|
91
|
+
statementKeys: ["definition", "purpose_role"],
|
|
92
|
+
fallbackPrefix: "Concept",
|
|
93
|
+
pathPrefix: "conceptual_frame.concepts",
|
|
94
|
+
}),
|
|
95
|
+
...collectRecordClaims({
|
|
96
|
+
records: recordArray(conceptualFrame, "associations"),
|
|
97
|
+
idKey: "association_id",
|
|
98
|
+
nameKeys: ["association_kind"],
|
|
99
|
+
statementKeys: ["statement"],
|
|
100
|
+
fallbackPrefix: "Association",
|
|
101
|
+
pathPrefix: "conceptual_frame.associations",
|
|
102
|
+
}),
|
|
103
|
+
...collectRecordClaims({
|
|
104
|
+
records: recordArray(semanticLayer, "object_types"),
|
|
105
|
+
idKey: "object_type_id",
|
|
106
|
+
nameKeys: ["name"],
|
|
107
|
+
statementKeys: ["description"],
|
|
108
|
+
fallbackPrefix: "Object Type",
|
|
109
|
+
pathPrefix: "semantic_layer.object_types",
|
|
110
|
+
}),
|
|
111
|
+
...collectRecordClaims({
|
|
112
|
+
records: recordArray(semanticLayer, "link_types"),
|
|
113
|
+
idKey: "link_type_id",
|
|
114
|
+
nameKeys: ["business_meaning"],
|
|
115
|
+
statementKeys: ["business_meaning"],
|
|
116
|
+
fallbackPrefix: "Link Type",
|
|
117
|
+
pathPrefix: "semantic_layer.link_types",
|
|
118
|
+
}),
|
|
119
|
+
...collectRecordClaims({
|
|
120
|
+
records: recordArray(semanticLayer, "value_types"),
|
|
121
|
+
idKey: "value_type_id",
|
|
122
|
+
nameKeys: ["name"],
|
|
123
|
+
statementKeys: ["representation"],
|
|
124
|
+
fallbackPrefix: "Value Type",
|
|
125
|
+
pathPrefix: "semantic_layer.value_types",
|
|
126
|
+
}),
|
|
127
|
+
...collectRecordClaims({
|
|
128
|
+
records: recordArray(semanticLayer, "constraints"),
|
|
129
|
+
idKey: "constraint_id",
|
|
130
|
+
nameKeys: ["constraint_kind"],
|
|
131
|
+
statementKeys: ["statement"],
|
|
132
|
+
fallbackPrefix: "Constraint",
|
|
133
|
+
pathPrefix: "semantic_layer.constraints",
|
|
134
|
+
}),
|
|
135
|
+
...collectRecordClaims({
|
|
136
|
+
records: recordArray(dynamicLayer, "actor_types"),
|
|
137
|
+
idKey: "actor_type_id",
|
|
138
|
+
nameKeys: ["name"],
|
|
139
|
+
statementKeys: ["description"],
|
|
140
|
+
fallbackPrefix: "Actor Type",
|
|
141
|
+
pathPrefix: "dynamic_layer.actor_types",
|
|
142
|
+
}),
|
|
143
|
+
...collectRecordClaims({
|
|
144
|
+
records: recordArray(dynamicLayer, "actor_roles"),
|
|
145
|
+
idKey: "role_id",
|
|
146
|
+
nameKeys: ["name"],
|
|
147
|
+
statementKeys: ["description"],
|
|
148
|
+
fallbackPrefix: "Actor Role",
|
|
149
|
+
pathPrefix: "dynamic_layer.actor_roles",
|
|
150
|
+
}),
|
|
151
|
+
...collectRecordClaims({
|
|
152
|
+
records: recordArray(dynamicLayer, "permission_policies"),
|
|
153
|
+
idKey: "policy_id",
|
|
154
|
+
nameKeys: ["permission_kind"],
|
|
155
|
+
statementKeys: ["condition", "permission_kind"],
|
|
156
|
+
fallbackPrefix: "Permission Policy",
|
|
157
|
+
pathPrefix: "dynamic_layer.permission_policies",
|
|
158
|
+
}),
|
|
159
|
+
...collectRecordClaims({
|
|
160
|
+
records: recordArray(dynamicLayer, "state_models"),
|
|
161
|
+
idKey: "state_model_id",
|
|
162
|
+
nameKeys: ["name"],
|
|
163
|
+
statementKeys: ["description"],
|
|
164
|
+
fallbackPrefix: "State Model",
|
|
165
|
+
pathPrefix: "dynamic_layer.state_models",
|
|
166
|
+
}),
|
|
167
|
+
...collectRecordClaims({
|
|
168
|
+
records: recordArray(dynamicLayer, "lifecycle_rules"),
|
|
169
|
+
idKey: "rule_id",
|
|
170
|
+
nameKeys: ["name", "rule_kind"],
|
|
171
|
+
statementKeys: ["statement", "description"],
|
|
172
|
+
fallbackPrefix: "Lifecycle Rule",
|
|
173
|
+
pathPrefix: "dynamic_layer.lifecycle_rules",
|
|
174
|
+
}),
|
|
175
|
+
...collectRecordClaims({
|
|
176
|
+
records: recordArray(kineticLayer, "action_types"),
|
|
177
|
+
idKey: "action_type_id",
|
|
178
|
+
nameKeys: ["name"],
|
|
179
|
+
statementKeys: ["description"],
|
|
180
|
+
fallbackPrefix: "Action Type",
|
|
181
|
+
pathPrefix: "kinetic_layer.action_types",
|
|
182
|
+
}),
|
|
183
|
+
...collectRecordClaims({
|
|
184
|
+
records: recordArray(kineticLayer, "functions"),
|
|
185
|
+
idKey: "function_id",
|
|
186
|
+
nameKeys: ["name"],
|
|
187
|
+
statementKeys: ["description"],
|
|
188
|
+
fallbackPrefix: "Function",
|
|
189
|
+
pathPrefix: "kinetic_layer.functions",
|
|
190
|
+
}),
|
|
191
|
+
...collectRecordClaims({
|
|
192
|
+
records: recordArray(kineticLayer, "workflows"),
|
|
193
|
+
idKey: "workflow_id",
|
|
194
|
+
nameKeys: ["name"],
|
|
195
|
+
statementKeys: ["description"],
|
|
196
|
+
fallbackPrefix: "Workflow",
|
|
197
|
+
pathPrefix: "kinetic_layer.workflows",
|
|
198
|
+
}),
|
|
199
|
+
...collectRecordClaims({
|
|
200
|
+
records: recordArray(dataBindingLayer, "source_bindings"),
|
|
201
|
+
idKey: "binding_id",
|
|
202
|
+
nameKeys: ["binding_kind"],
|
|
203
|
+
statementKeys: ["statement"],
|
|
204
|
+
fallbackPrefix: "Source Binding",
|
|
205
|
+
pathPrefix: "data_binding_layer.source_bindings",
|
|
206
|
+
}),
|
|
207
|
+
...collectRecordClaims({
|
|
208
|
+
records: recordArray(dataBindingLayer, "read_models"),
|
|
209
|
+
idKey: "read_model_id",
|
|
210
|
+
nameKeys: ["name"],
|
|
211
|
+
statementKeys: ["transformation_summary"],
|
|
212
|
+
fallbackPrefix: "Read Model",
|
|
213
|
+
pathPrefix: "data_binding_layer.read_models",
|
|
214
|
+
}),
|
|
215
|
+
...collectRecordClaims({
|
|
216
|
+
records: recordArray(dataBindingLayer, "writebacks"),
|
|
217
|
+
idKey: "writeback_id",
|
|
218
|
+
nameKeys: ["name"],
|
|
219
|
+
statementKeys: ["writeback_summary", "description"],
|
|
220
|
+
fallbackPrefix: "Writeback",
|
|
221
|
+
pathPrefix: "data_binding_layer.writebacks",
|
|
222
|
+
}),
|
|
223
|
+
...collectRecordClaims({
|
|
224
|
+
records: recordArray(dataBindingLayer, "provenance_bindings"),
|
|
225
|
+
idKey: "provenance_id",
|
|
226
|
+
nameKeys: ["author_or_system"],
|
|
227
|
+
statementKeys: ["timestamp_ref", "statement"],
|
|
228
|
+
fallbackPrefix: "Provenance Binding",
|
|
229
|
+
pathPrefix: "data_binding_layer.provenance_bindings",
|
|
230
|
+
}),
|
|
231
|
+
...collectRecordClaims({
|
|
232
|
+
records: recordArray(seed, "handoff_limitations"),
|
|
233
|
+
idKey: "limitation_id",
|
|
234
|
+
nameKeys: ["limitation_kind"],
|
|
235
|
+
statementKeys: ["description", "mitigation_or_next_action"],
|
|
236
|
+
fallbackPrefix: "Handoff Limitation",
|
|
237
|
+
pathPrefix: "handoff_limitations",
|
|
238
|
+
}),
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
export function ontologySeedExcludedClaimIds(ontologySeed) {
|
|
242
|
+
const seed = recordValue(ontologySeed) ?? {};
|
|
243
|
+
return new Set(recordArray(seed, "handoff_limitations")
|
|
244
|
+
.map((limitation) => stringValue(limitation.limitation_id))
|
|
245
|
+
.filter((id) => id !== null));
|
|
246
|
+
}
|
|
247
|
+
export function ontologySeedAnswerabilitySummary(ontologySeed) {
|
|
248
|
+
const seed = recordValue(ontologySeed) ?? {};
|
|
249
|
+
const validationLayer = recordValue(seed.validation_layer);
|
|
250
|
+
const kineticLayer = recordValue(seed.kinetic_layer);
|
|
251
|
+
const handoffLimitations = recordArray(seed, "handoff_limitations");
|
|
252
|
+
const coverageAxes = stringArray(validationLayer?.coverage_axes);
|
|
253
|
+
const unsupportedQuestionCandidates = recordArray(validationLayer, "unsupported_question_candidates");
|
|
254
|
+
const actionTypes = recordArray(kineticLayer, "action_types");
|
|
255
|
+
const actionIds = new Set(actionTypes
|
|
256
|
+
.map((action) => stringValue(action.action_type_id))
|
|
257
|
+
.filter((id) => id !== null));
|
|
258
|
+
const limitedActionIds = new Set(handoffLimitations.flatMap((limitation) => stringArray(limitation.affected_refs))
|
|
259
|
+
.filter((ref) => actionIds.has(ref)));
|
|
260
|
+
return {
|
|
261
|
+
declared_question_count: coverageAxes.length,
|
|
262
|
+
supported_question_count: Math.max(0, coverageAxes.length - unsupportedQuestionCandidates.length),
|
|
263
|
+
deferred_question_count: handoffLimitations.length,
|
|
264
|
+
unsupported_question_count: unsupportedQuestionCandidates.length,
|
|
265
|
+
supported_action_count: Math.max(0, actionTypes.length - limitedActionIds.size),
|
|
266
|
+
unsupported_action_count: limitedActionIds.size,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { isTargetMaterialKind, } from "../target-material-kind.js";
|
|
4
|
+
import { loadReconstructContractRegistry, projectRootFromProfilesRoot, resolveRegistryRef, validateSourceProfileDefinitionHashes, } from "./contract-registry.js";
|
|
4
5
|
const TARGET_MATERIAL_KIND_PATTERN = /^>\s*Target material kind:\s*`([^`]+)`\s*$/m;
|
|
5
6
|
function firstMarkdownHeading(markdown) {
|
|
6
7
|
const match = markdown.match(/^#\s+(.+)$/m);
|
|
@@ -20,11 +21,14 @@ function sectionBody(markdown, heading) {
|
|
|
20
21
|
return bodyLines.join("\n").trim();
|
|
21
22
|
}
|
|
22
23
|
function compactSectionText(markdown, heading) {
|
|
23
|
-
|
|
24
|
+
const compacted = sectionBody(markdown, heading)
|
|
24
25
|
.split(/\r?\n/)
|
|
25
26
|
.map((line) => line.trim())
|
|
26
27
|
.filter((line) => line.length > 0)
|
|
27
28
|
.join(" ");
|
|
29
|
+
return compacted.length > 0
|
|
30
|
+
? compacted
|
|
31
|
+
: "Source profile definition only; support and migration status are registry-owned.";
|
|
28
32
|
}
|
|
29
33
|
function parseScanTargets(markdown) {
|
|
30
34
|
return sectionBody(markdown, "Scan Targets")
|
|
@@ -40,15 +44,97 @@ export function parseReconstructSourceProfile(args) {
|
|
|
40
44
|
if (!isTargetMaterialKind(rawKind)) {
|
|
41
45
|
throw new Error(`Invalid or missing target material kind in source profile: ${args.profilePath}`);
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
if (args.record && args.record.target_material_kind !== rawKind) {
|
|
48
|
+
throw new Error(`Source profile ${args.profilePath} target_material_kind=${rawKind} does not match registry target_material_kind=${args.record.target_material_kind}`);
|
|
49
|
+
}
|
|
50
|
+
const fallbackRecord = args.record ?? {
|
|
51
|
+
profile_id: `${rawKind}-source-profile`,
|
|
44
52
|
target_material_kind: rawKind,
|
|
53
|
+
is_default_for_kind: true,
|
|
54
|
+
definition_ref: args.profilePath,
|
|
55
|
+
definition_sha256: "unknown",
|
|
56
|
+
contract_status: "profile_file_only",
|
|
57
|
+
runtime_implementation_status: "unknown",
|
|
58
|
+
schema_version: 1,
|
|
59
|
+
profile_version: 1,
|
|
60
|
+
migration_status: "unknown",
|
|
61
|
+
supersedes: [],
|
|
62
|
+
replaced_by: [],
|
|
63
|
+
split_from: [],
|
|
64
|
+
split_into: [],
|
|
65
|
+
merged_from: [],
|
|
66
|
+
merged_into: [],
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
...fallbackRecord,
|
|
45
70
|
profile_path: path.resolve(args.profilePath),
|
|
46
71
|
title: firstMarkdownHeading(args.markdown),
|
|
47
|
-
support_summary:
|
|
72
|
+
support_summary: args.record
|
|
73
|
+
? [
|
|
74
|
+
`contract_status=${args.record.contract_status}`,
|
|
75
|
+
`runtime_implementation_status=${args.record.runtime_implementation_status}`,
|
|
76
|
+
`schema_version=${args.record.schema_version}`,
|
|
77
|
+
`profile_version=${args.record.profile_version}`,
|
|
78
|
+
`migration_status=${args.record.migration_status}`,
|
|
79
|
+
].join("; ")
|
|
80
|
+
: compactSectionText(args.markdown, "Support Status"),
|
|
48
81
|
scan_targets: parseScanTargets(args.markdown),
|
|
49
82
|
};
|
|
50
83
|
}
|
|
84
|
+
async function fileExists(filePath) {
|
|
85
|
+
try {
|
|
86
|
+
const stat = await fs.stat(filePath);
|
|
87
|
+
return stat.isFile();
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function loadProfilesFromRegistry(args) {
|
|
94
|
+
if (!(await fileExists(args.registryPath)))
|
|
95
|
+
return null;
|
|
96
|
+
const registry = await loadReconstructContractRegistry({
|
|
97
|
+
registryPath: args.registryPath,
|
|
98
|
+
});
|
|
99
|
+
const projectRoot = projectRootFromProfilesRoot(args.profilesRoot);
|
|
100
|
+
await validateSourceProfileDefinitionHashes({ projectRoot, registry });
|
|
101
|
+
const records = registry.source_profile_records
|
|
102
|
+
.sort((left, right) => left.profile_id.localeCompare(right.profile_id));
|
|
103
|
+
return Promise.all(records.map(async (record) => {
|
|
104
|
+
if (record.definition_ref === null) {
|
|
105
|
+
return {
|
|
106
|
+
...record,
|
|
107
|
+
profile_path: `registry:${record.profile_id}`,
|
|
108
|
+
title: `Source Profile Registry Record: ${record.profile_id}`,
|
|
109
|
+
support_summary: [
|
|
110
|
+
`contract_status=${record.contract_status}`,
|
|
111
|
+
`runtime_implementation_status=${record.runtime_implementation_status}`,
|
|
112
|
+
`schema_version=${record.schema_version}`,
|
|
113
|
+
`profile_version=${record.profile_version}`,
|
|
114
|
+
`migration_status=${record.migration_status}`,
|
|
115
|
+
"definition_ref=null",
|
|
116
|
+
].join("; "),
|
|
117
|
+
scan_targets: [],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const profilePath = resolveRegistryRef({
|
|
121
|
+
projectRoot,
|
|
122
|
+
ref: record.definition_ref,
|
|
123
|
+
});
|
|
124
|
+
return parseReconstructSourceProfile({
|
|
125
|
+
profilePath,
|
|
126
|
+
markdown: await fs.readFile(profilePath, "utf8"),
|
|
127
|
+
record,
|
|
128
|
+
});
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
51
131
|
export async function loadReconstructSourceProfiles(profilesRoot) {
|
|
132
|
+
const registryProfiles = await loadProfilesFromRegistry({
|
|
133
|
+
profilesRoot,
|
|
134
|
+
registryPath: path.join(path.dirname(path.resolve(profilesRoot)), "reconstruct-contract-registry.yaml"),
|
|
135
|
+
});
|
|
136
|
+
if (registryProfiles)
|
|
137
|
+
return registryProfiles;
|
|
52
138
|
const entries = await fs.readdir(profilesRoot, { withFileTypes: true });
|
|
53
139
|
const profilePaths = entries
|
|
54
140
|
.filter((entry) => entry.isFile() && entry.name.endsWith(".md"))
|
|
@@ -69,5 +155,8 @@ export async function loadReconstructSourceProfiles(profilesRoot) {
|
|
|
69
155
|
}
|
|
70
156
|
export async function resolveReconstructSourceProfile(args) {
|
|
71
157
|
const profiles = await loadReconstructSourceProfiles(args.profilesRoot);
|
|
72
|
-
|
|
158
|
+
const matchingProfiles = profiles.filter((profile) => profile.target_material_kind === args.targetMaterialKind);
|
|
159
|
+
return matchingProfiles.find((profile) => profile.is_default_for_kind) ??
|
|
160
|
+
matchingProfiles[0] ??
|
|
161
|
+
null;
|
|
73
162
|
}
|