kibi-cli 2.3.0 → 2.5.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/dist/cli-json-command.d.ts +6 -0
- package/dist/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +39 -11
- package/dist/cli-operation-loader.d.ts.map +1 -1
- package/dist/cli-operation-loader.js +7 -0
- package/dist/cli-operation-metadata.d.ts +13 -5
- package/dist/cli-operation-metadata.d.ts.map +1 -1
- package/dist/cli-operation-metadata.js +15 -5
- package/dist/cli-protocol.d.ts +14 -0
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +31 -2
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +7 -0
- package/dist/cli-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +13 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +11 -2
- package/dist/commands/discovery-shared.d.ts.map +1 -1
- package/dist/commands/discovery-shared.js +8 -2
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +4 -2
- package/dist/commands/gc.d.ts.map +1 -1
- package/dist/commands/gc.js +7 -0
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +0 -1
- package/dist/commands/merge-driver.d.ts +31 -0
- package/dist/commands/merge-driver.d.ts.map +1 -0
- package/dist/commands/merge-driver.js +268 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +281 -14
- package/dist/commands/proof-compact.d.ts +9 -0
- package/dist/commands/proof-compact.d.ts.map +1 -0
- package/dist/commands/proof-compact.js +58 -0
- package/dist/commands/prove.d.ts +38 -0
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +222 -47
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +61 -16
- package/dist/commands/sync.d.ts +8 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +42 -16
- package/dist/diagnostics.js +1 -1
- package/dist/engine-limits.d.ts +74 -0
- package/dist/engine-limits.d.ts.map +1 -0
- package/dist/engine-limits.js +201 -0
- package/dist/engine.d.ts +10 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +57 -9
- package/dist/extractors/manifest.d.ts +8 -0
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +34 -5
- package/dist/extractors/markdown.d.ts +8 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +57 -0
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +2 -0
- package/dist/intent-search.d.ts +4 -1
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +186 -33
- package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidate-helpers.js +8 -1
- package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidates.js +55 -39
- package/dist/operations/bootstrap/discovery.js +1 -1
- package/dist/operations/bootstrap/generate.d.ts +2 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +107 -37
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +3 -0
- package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance.js +7 -1
- package/dist/operations/bootstrap/intent-claims.d.ts +17 -0
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -0
- package/dist/operations/bootstrap/intent-claims.js +103 -0
- package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -0
- package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/markdown-candidates.js +32 -10
- package/dist/operations/bootstrap/presentation.d.ts +2 -0
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +66 -3
- package/dist/operations/bootstrap/requirement-claims.d.ts +1 -0
- package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/requirement-claims.js +13 -1
- package/dist/operations/bootstrap/types.d.ts +28 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/bootstrap/types.js +16 -0
- package/dist/operations/bootstrap/validation.d.ts +4 -0
- package/dist/operations/bootstrap/validation.d.ts.map +1 -0
- package/dist/operations/bootstrap/validation.js +20 -0
- package/dist/operations/migration/inventory-rederive.d.ts +81 -0
- package/dist/operations/migration/inventory-rederive.d.ts.map +1 -0
- package/dist/operations/migration/inventory-rederive.js +484 -0
- package/dist/operations/migration/kb-sources.d.ts +53 -0
- package/dist/operations/migration/kb-sources.d.ts.map +1 -0
- package/dist/operations/migration/kb-sources.js +233 -0
- package/dist/operations/migration/origin-backfill.d.ts +39 -0
- package/dist/operations/migration/origin-backfill.d.ts.map +1 -0
- package/dist/operations/migration/origin-backfill.js +164 -0
- package/dist/operations/migration/polarity-values.d.ts +10 -0
- package/dist/operations/migration/polarity-values.d.ts.map +1 -0
- package/dist/operations/migration/polarity-values.js +60 -0
- package/dist/operations/migration/schema6.d.ts +59 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -0
- package/dist/operations/migration/schema6.js +379 -0
- package/dist/operations/migration/source-paths.d.ts +131 -0
- package/dist/operations/migration/source-paths.d.ts.map +1 -0
- package/dist/operations/migration/source-paths.js +308 -0
- package/dist/operations/migration/superseded-closure.d.ts +54 -0
- package/dist/operations/migration/superseded-closure.d.ts.map +1 -0
- package/dist/operations/migration/superseded-closure.js +187 -0
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +3 -5
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +225 -67
- package/dist/operations/mutation/contradictions.d.ts +16 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +32 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +15 -7
- package/dist/operations/mutation/origin.d.ts +21 -0
- package/dist/operations/mutation/origin.d.ts.map +1 -0
- package/dist/operations/mutation/origin.js +78 -0
- package/dist/operations/mutation/plan-apply-journal.d.ts +182 -0
- package/dist/operations/mutation/plan-apply-journal.d.ts.map +1 -0
- package/dist/operations/mutation/plan-apply-journal.js +613 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +3 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.js +13 -2
- package/dist/operations/mutation/relationships.d.ts +5 -5
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +31 -11
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +3 -1
- package/dist/operations/mutation/source-authoring.d.ts +6 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +7 -1
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-refresh.js +4 -1
- package/dist/operations/mutation/types.d.ts +14 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts +30 -3
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +105 -35
- package/dist/operations/mutation/validate-upsert.d.ts +6 -0
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +34 -30
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +751 -144
- package/dist/operations/planning/compile-intent.d.ts +34 -1
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +314 -98
- package/dist/operations/proof/code-scope.d.ts +28 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -1
- package/dist/operations/proof/code-scope.js +72 -0
- package/dist/operations/proof/compact-receipts.d.ts +49 -0
- package/dist/operations/proof/compact-receipts.d.ts.map +1 -0
- package/dist/operations/proof/compact-receipts.js +160 -0
- package/dist/operations/proof/ingest-proof.d.ts +2 -0
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +44 -23
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +5 -9
- package/dist/operations/proof/receipt-compaction.d.ts +48 -0
- package/dist/operations/proof/receipt-compaction.d.ts.map +1 -0
- package/dist/operations/proof/receipt-compaction.js +121 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +12 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts +2 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +51 -5
- package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +11 -1
- package/dist/operations/semantic-advisor/conditional-rules.d.ts +33 -0
- package/dist/operations/semantic-advisor/conditional-rules.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/conditional-rules.js +262 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +3 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.js +14 -6
- package/dist/operations/semantic-advisor/plugin-orchestration.js +1 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -1
- package/dist/prolog.d.ts +9 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +56 -10
- package/dist/proof/command-test-report.d.ts +74 -0
- package/dist/proof/command-test-report.d.ts.map +1 -0
- package/dist/proof/command-test-report.js +206 -0
- package/dist/public/branch-resolver.d.ts +1 -0
- package/dist/public/branch-resolver.d.ts.map +1 -1
- package/dist/public/branch-resolver.js +1 -0
- package/dist/public/diagnostic-usage.d.ts +14 -0
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +55 -1
- package/dist/public/entity-origin.d.ts +69 -0
- package/dist/public/entity-origin.d.ts.map +1 -0
- package/dist/public/entity-origin.js +142 -0
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +1 -0
- package/dist/public/impact/requirement-quality.js +1 -1
- package/dist/public/operations/catalog.d.ts +203 -20
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/catalog.js +3 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +8 -0
- package/dist/public/operations/contracts.d.ts +0 -5
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +63 -14
- package/dist/public/operations/discovery-entities.d.ts +15 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +59 -0
- package/dist/public/operations/discovery-executors.d.ts +6 -1
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +65 -6
- package/dist/public/operations/index.d.ts +1 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +1 -0
- package/dist/public/operations/migration-plan.d.ts +5 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +26 -1
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +24 -3
- package/dist/public/operations/origin-review.d.ts +51 -0
- package/dist/public/operations/origin-review.d.ts.map +1 -0
- package/dist/public/operations/origin-review.js +307 -0
- package/dist/public/operations/predicate-schema-conformance.js +1 -1
- package/dist/public/operations/repair-plan.d.ts.map +1 -1
- package/dist/public/operations/repair-plan.js +4 -0
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +17 -5
- package/dist/public/operations/runtime-types.d.ts +9 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/schema6-check-actions.d.ts +127 -0
- package/dist/public/operations/schema6-check-actions.d.ts.map +1 -0
- package/dist/public/operations/schema6-check-actions.js +575 -0
- package/dist/public/operations/source-path-dangling.d.ts +17 -0
- package/dist/public/operations/source-path-dangling.d.ts.map +1 -0
- package/dist/public/operations/source-path-dangling.js +66 -0
- package/dist/public/operations/specs/bootstrap.d.ts +73 -1
- package/dist/public/operations/specs/bootstrap.d.ts.map +1 -1
- package/dist/public/operations/specs/bootstrap.js +66 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +15 -1
- package/dist/public/operations/specs/check.d.ts +2 -2
- package/dist/public/operations/specs/check.js +1 -1
- package/dist/public/operations/specs/composite.d.ts +351 -0
- package/dist/public/operations/specs/composite.d.ts.map +1 -0
- package/dist/public/operations/specs/composite.js +96 -0
- package/dist/public/operations/specs/discovery.d.ts +8 -3
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +8 -3
- package/dist/public/operations/specs/modeling.d.ts +2 -2
- package/dist/public/operations/specs/modeling.js +2 -2
- package/dist/public/operations/specs/mutation-schemas.d.ts +73 -8
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +43 -7
- package/dist/public/operations/specs/mutation.d.ts +1 -1
- package/dist/public/operations/specs/mutation.js +1 -1
- package/dist/public/operations/specs/planning.d.ts +2 -2
- package/dist/public/operations/specs/planning.js +4 -4
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +13 -26
- package/dist/public/operations/specs/upsert.d.ts +79 -9
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +6 -1
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +3 -1
- package/dist/public/operations/types.d.ts +1 -1
- package/dist/public/operations/types.d.ts.map +1 -1
- package/dist/public/proof-receipt.d.ts +1 -0
- package/dist/public/proof-receipt.d.ts.map +1 -1
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +52 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +2 -0
- package/dist/public/skills/kibi-bootstrap/SKILL.md +52 -11
- package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
- package/dist/public/skills/kibi-usage/SKILL.md +82 -18
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
- package/dist/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +2 -2
- package/dist/public/skills/kibi-usage/resources/operation-access.md +29 -1
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
- package/dist/public/skills/kibi-usage/resources/workflows.md +42 -25
- package/dist/public/telemetry-acceptance.d.ts +64 -0
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +143 -7
- package/dist/public/telemetry-remediation.d.ts.map +1 -1
- package/dist/public/telemetry-remediation.js +26 -10
- package/dist/relationships/shards.d.ts +13 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +54 -28
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +44 -3
- package/dist/runtime/detached-snapshot.d.ts +38 -0
- package/dist/runtime/detached-snapshot.d.ts.map +1 -0
- package/dist/runtime/detached-snapshot.js +92 -0
- package/dist/schemas/entity.schema.json +122 -0
- package/dist/search-answer.d.ts +157 -0
- package/dist/search-answer.d.ts.map +1 -0
- package/dist/search-answer.js +846 -0
- package/dist/traceability/impact-knowledge.d.ts.map +1 -1
- package/dist/traceability/impact-knowledge.js +7 -0
- package/dist/traceability/symbol-extract.js +3 -3
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +12 -0
- package/dist/types/entities.d.ts +13 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts +1 -1
- package/dist/types/relationships.d.ts.map +1 -1
- package/dist/utils/branch-resolver.d.ts +37 -1
- package/dist/utils/branch-resolver.d.ts.map +1 -1
- package/dist/utils/branch-resolver.js +130 -3
- package/dist/utils/repo-relative-path.d.ts +18 -0
- package/dist/utils/repo-relative-path.d.ts.map +1 -0
- package/dist/utils/repo-relative-path.js +58 -0
- package/dist/utils/rule-registry.generated.d.ts +75 -3
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +89 -3
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.d.ts.map +1 -1
- package/dist/utils/schema-version.js +4 -3
- package/dist/utils/strict-modeling.d.ts +1 -1
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +23 -3
- package/package.json +3 -3
- package/schema/entities.pl +22 -0
- package/schema/relationships.pl +14 -0
- package/schema/validation.pl +45 -1
- package/src/public/branch-resolver.ts +1 -0
- package/src/public/diagnostic-usage.ts +59 -1
- package/src/public/entity-origin.ts +175 -0
- package/src/public/impact/full-kb-quality.ts +1 -0
- package/src/public/impact/requirement-quality.ts +1 -1
- package/src/public/operations/catalog.ts +3 -0
- package/src/public/operations/check-executor.ts +15 -0
- package/src/public/operations/contracts.ts +75 -15
- package/src/public/operations/discovery-entities.ts +74 -0
- package/src/public/operations/discovery-executors.ts +88 -10
- package/src/public/operations/index.ts +1 -0
- package/src/public/operations/migration-plan.ts +30 -1
- package/src/public/operations/node-ports.ts +24 -3
- package/src/public/operations/origin-review.ts +375 -0
- package/src/public/operations/predicate-schema-conformance.ts +1 -1
- package/src/public/operations/repair-plan.ts +4 -0
- package/src/public/operations/result-envelope.ts +18 -6
- package/src/public/operations/runtime-types.ts +9 -0
- package/src/public/operations/schema6-check-actions.ts +699 -0
- package/src/public/operations/source-path-dangling.ts +81 -0
- package/src/public/operations/specs/bootstrap.ts +78 -4
- package/src/public/operations/specs/check-rules.generated.ts +15 -1
- package/src/public/operations/specs/check.ts +1 -1
- package/src/public/operations/specs/composite.ts +141 -0
- package/src/public/operations/specs/discovery.ts +9 -3
- package/src/public/operations/specs/modeling.ts +2 -2
- package/src/public/operations/specs/mutation-schemas.ts +49 -7
- package/src/public/operations/specs/mutation.ts +1 -1
- package/src/public/operations/specs/planning.ts +4 -4
- package/src/public/operations/specs/reporting.ts +13 -38
- package/src/public/operations/specs/upsert.ts +7 -1
- package/src/public/operations/symbol-repair-plan.ts +3 -1
- package/src/public/operations/types.ts +2 -0
- package/src/public/proof-receipt.ts +1 -0
- package/src/public/schemas/entity.ts +57 -0
- package/src/public/schemas/relationship.ts +2 -0
- package/src/public/skills/kibi-bootstrap/SKILL.md +52 -11
- package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
- package/src/public/skills/kibi-usage/SKILL.md +82 -18
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
- package/src/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
- package/src/public/skills/kibi-usage/resources/logic-ir.md +2 -2
- package/src/public/skills/kibi-usage/resources/operation-access.md +29 -1
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
- package/src/public/skills/kibi-usage/resources/workflows.md +42 -25
- package/src/public/telemetry-acceptance-types.d.ts +4 -1
- package/src/public/telemetry-acceptance.ts +210 -7
- package/src/public/telemetry-remediation.ts +39 -10
- package/src/schemas/entity.schema.json +122 -0
- package/src/schemas/relationship.schema.json +2 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
/** Review: an exception that exempts nothing until a human approves it. */
|
|
19
|
+
// implements REQ-kibi-entity-origin, REQ-kibi-schema6-migration
|
|
20
|
+
export const EXCEPTION_UNAPPROVED_REVIEW_CODE = "review_exception_unapproved";
|
|
21
|
+
/** Review: an agent-recorded exception approval nobody corroborated. */
|
|
22
|
+
// implements REQ-kibi-entity-origin, REQ-kibi-schema6-migration
|
|
23
|
+
export const EXCEPTION_SELF_ATTESTED_REVIEW_CODE = "review_exception_approval_self_attested";
|
|
24
|
+
/** Review: a predicate whose missing key_arguments leave rule pairs open. */
|
|
25
|
+
// implements REQ-kibi-schema6-migration
|
|
26
|
+
export const PREDICATE_KEY_ARGUMENTS_REVIEW_CODE = "review_predicate_key_arguments";
|
|
27
|
+
/** Review: a success scenario whose feasibility cannot be decided. */
|
|
28
|
+
// implements REQ-kibi-schema6-migration
|
|
29
|
+
export const SCENARIO_FEASIBILITY_REVIEW_CODE = "review_scenario_feasibility_unknown";
|
|
30
|
+
/** Review: agent-authored requirements no human has approved (one action). */
|
|
31
|
+
// implements REQ-kibi-entity-origin, REQ-kibi-schema6-migration
|
|
32
|
+
export const AGENT_REQUIREMENTS_REVIEW_CODE = "review_agent_requirements_unapproved";
|
|
33
|
+
// implements REQ-kibi-entity-origin, REQ-kibi-schema6-migration
|
|
34
|
+
export const AGENT_REQUIREMENTS_REVIEW_ACTION_ID = "review-agent-requirements-unapproved";
|
|
35
|
+
/** Automatic: close superseded requirements that are not closed. */
|
|
36
|
+
// implements REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
37
|
+
export const CLOSE_SUPERSEDED_REQUIREMENTS_CODE = "close_superseded_requirements";
|
|
38
|
+
// implements REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
39
|
+
export const CLOSE_SUPERSEDED_REQUIREMENTS_ACTION_ID = "close-superseded-requirements";
|
|
40
|
+
/** Review: requirements that supersede each other (no automatic fix). */
|
|
41
|
+
// implements REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
42
|
+
export const SUPERSESSION_CYCLE_REVIEW_CODE = "review_supersession_cycle";
|
|
43
|
+
/**
|
|
44
|
+
* Automatic: repair redundant or dead authored `source` values. A moved
|
|
45
|
+
* knowledge file is rewritten to its `.kb/` path; a value naming the
|
|
46
|
+
* entity's own file or nothing Kibi can map is removed.
|
|
47
|
+
*/
|
|
48
|
+
// implements REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
49
|
+
export const SOURCE_PATH_REWRITE_CODE = "source_path_rewrite";
|
|
50
|
+
// implements REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
51
|
+
export const SOURCE_PATH_REWRITE_ACTION_ID = "source-path-rewrite";
|
|
52
|
+
/** Review: a source value Kibi cannot edit safely (the automatic fix's fallback). */
|
|
53
|
+
// implements REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
54
|
+
export const SOURCE_PATH_REVIEW_CODE = "review_source_path_dangling";
|
|
55
|
+
/** Review: symbols whose every owning requirement is retired (one queue). */
|
|
56
|
+
// implements REQ-kibi-schema6-migration
|
|
57
|
+
export const SYMBOL_OWNER_REVIEW_CODE = "review_symbol_owner_superseded";
|
|
58
|
+
// implements REQ-kibi-schema6-migration
|
|
59
|
+
export const SYMBOL_OWNER_REVIEW_ACTION_ID = "review-symbol-owner-superseded";
|
|
60
|
+
/** Review: an accepted ADR nothing links to. */
|
|
61
|
+
// implements REQ-kibi-schema6-migration
|
|
62
|
+
export const ADR_UNLINKED_REVIEW_CODE = "review_adr_unlinked";
|
|
63
|
+
/** Review: an ADR still proposed. */
|
|
64
|
+
// implements REQ-kibi-schema6-migration
|
|
65
|
+
export const ADR_PROPOSED_REVIEW_CODE = "review_adr_proposed";
|
|
66
|
+
/** Review: human- or agent-authored requirements with no rationale (one queue). */
|
|
67
|
+
// implements REQ-kibi-schema6-migration
|
|
68
|
+
export const RATIONALE_REVIEW_CODE = "review_requirement_rationale_missing";
|
|
69
|
+
// implements REQ-kibi-schema6-migration
|
|
70
|
+
export const RATIONALE_REVIEW_ACTION_ID = "review-requirement-rationale-missing";
|
|
71
|
+
/** Automatic: recompile sources rewritten by earlier migration actions. */
|
|
72
|
+
// implements REQ-cli-schema-migration, REQ-kibi-schema6-migration
|
|
73
|
+
export const MIGRATION_SYNC_CODE = "migration_sync";
|
|
74
|
+
// implements REQ-cli-schema-migration, REQ-kibi-schema6-migration
|
|
75
|
+
export const MIGRATION_SYNC_ACTION_ID = "migration-sync";
|
|
76
|
+
const MIGRATE_YES = {
|
|
77
|
+
kind: "cli",
|
|
78
|
+
command_argv: ["kibi", "migrate", "--yes"],
|
|
79
|
+
};
|
|
80
|
+
// implements REQ-kibi-entity-origin, REQ-kibi-schema6-migration
|
|
81
|
+
export function exceptionUnapprovedActionId(exceptionId) {
|
|
82
|
+
return `review-exception-unapproved-${exceptionId}`;
|
|
83
|
+
}
|
|
84
|
+
function stableIdPart(value) {
|
|
85
|
+
return value.replace(/[^A-Za-z0-9_-]+/g, "-");
|
|
86
|
+
}
|
|
87
|
+
/** The sync that recompiles sources rewritten by earlier actions. */
|
|
88
|
+
// implements REQ-cli-schema-migration, REQ-kibi-schema6-migration
|
|
89
|
+
export function migrationSyncActionInput(dependsOn) {
|
|
90
|
+
return {
|
|
91
|
+
id: MIGRATION_SYNC_ACTION_ID,
|
|
92
|
+
code: MIGRATION_SYNC_CODE,
|
|
93
|
+
category: "freshness",
|
|
94
|
+
safety: "automatic",
|
|
95
|
+
autoApplicable: true,
|
|
96
|
+
invocation: { kind: "cli", command_argv: ["kibi", "sync"] },
|
|
97
|
+
dependsOn,
|
|
98
|
+
affectedFiles: [".kb/branches"],
|
|
99
|
+
postconditions: [{ syncState: "fresh" }],
|
|
100
|
+
evidence: {
|
|
101
|
+
reason: "Earlier migration actions rewrite authored sources; recompile them so status, check and coverage read the migrated KB.",
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** One automatic action that closes every listed superseded requirement. */
|
|
106
|
+
// implements REQ-cli-schema-migration, REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
|
|
107
|
+
export function closeSupersededRequirementsActionInput(closures) {
|
|
108
|
+
const sorted = [...closures].sort((left, right) => left.id.localeCompare(right.id));
|
|
109
|
+
return {
|
|
110
|
+
id: CLOSE_SUPERSEDED_REQUIREMENTS_ACTION_ID,
|
|
111
|
+
code: CLOSE_SUPERSEDED_REQUIREMENTS_CODE,
|
|
112
|
+
category: "quality",
|
|
113
|
+
safety: "automatic",
|
|
114
|
+
autoApplicable: true,
|
|
115
|
+
invocation: MIGRATE_YES,
|
|
116
|
+
affectedEntityIds: sorted.map((closure) => closure.id),
|
|
117
|
+
affectedFiles: sorted.flatMap((closure) => closure.path !== undefined ? [closure.path] : []),
|
|
118
|
+
postconditions: [{ rule: "superseded-requirement-open", violations: 0 }],
|
|
119
|
+
evidence: {
|
|
120
|
+
reason: "A requirement another requirement supersedes is retired and must be closed (superseded-requirement-open). Each listed requirement gets status: closed; the rest of its file is unchanged.",
|
|
121
|
+
count: sorted.length,
|
|
122
|
+
requirements: sorted.map((closure) => ({
|
|
123
|
+
id: closure.id,
|
|
124
|
+
status: closure.status,
|
|
125
|
+
supersededBy: [...closure.supersededBy],
|
|
126
|
+
})),
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Review: requirements that supersede each other; a person picks the current one. */
|
|
131
|
+
// implements REQ-cli-schema-migration, REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
|
|
132
|
+
export function supersessionCycleReviewActionInput(cycle) {
|
|
133
|
+
const members = [...cycle.members].sort();
|
|
134
|
+
const edges = cycle.edges.map(([from, to]) => `${from} supersedes ${to}`);
|
|
135
|
+
return {
|
|
136
|
+
id: `review-supersession-cycle-${members.map(stableIdPart).join("-")}`,
|
|
137
|
+
code: SUPERSESSION_CYCLE_REVIEW_CODE,
|
|
138
|
+
category: "quality",
|
|
139
|
+
safety: "review",
|
|
140
|
+
invocation: {
|
|
141
|
+
kind: "review",
|
|
142
|
+
instruction: `Supersession cycle between ${members.join(" and ")} (${edges.join("; ")}): none of them is current, so kibi migrate closes none of them. Decide which requirement states current intent, delete the supersedes link that points at it (kb_delete relationships [{type: supersedes, from: <other>, to: <current>}]), then set status: closed on the requirements it replaces.`,
|
|
143
|
+
},
|
|
144
|
+
affectedEntityIds: members,
|
|
145
|
+
affectedFiles: [...(cycle.files ?? [])],
|
|
146
|
+
dispositionRequired: true,
|
|
147
|
+
allowedDispositions: ["fixed", "deferred"],
|
|
148
|
+
evidence: {
|
|
149
|
+
cycle: members,
|
|
150
|
+
edges: cycle.edges.map(([from, to]) => [from, to]),
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function byEntityThenFile(left, right) {
|
|
155
|
+
return (left.entityId.localeCompare(right.entityId) ||
|
|
156
|
+
left.file.localeCompare(right.file));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* One automatic action that rewrites every listed moved source and removes
|
|
160
|
+
* every listed redundant or dead one.
|
|
161
|
+
*/
|
|
162
|
+
// implements REQ-kibi-schema6-migration, REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
|
|
163
|
+
export function sourcePathRewriteActionInput(input) {
|
|
164
|
+
const rewrites = [...input.rewrites].sort(byEntityThenFile);
|
|
165
|
+
const removals = [...input.removals].sort(byEntityThenFile);
|
|
166
|
+
const all = [...rewrites, ...removals].sort(byEntityThenFile);
|
|
167
|
+
return {
|
|
168
|
+
id: SOURCE_PATH_REWRITE_ACTION_ID,
|
|
169
|
+
code: SOURCE_PATH_REWRITE_CODE,
|
|
170
|
+
category: "quality",
|
|
171
|
+
safety: "automatic",
|
|
172
|
+
autoApplicable: true,
|
|
173
|
+
invocation: MIGRATE_YES,
|
|
174
|
+
affectedEntityIds: [...new Set(all.map((item) => item.entityId))],
|
|
175
|
+
affectedFiles: [...new Set(all.map((item) => item.file))],
|
|
176
|
+
postconditions: [
|
|
177
|
+
{ rule: "source-path-dangling", violations: 0 },
|
|
178
|
+
{ selfReferencingSources: 0 },
|
|
179
|
+
],
|
|
180
|
+
evidence: {
|
|
181
|
+
reason: "The authored source field is dead data: the compiled source is always the entity's own file, and Kibi ignores the field when compiling and never writes it. Each rewrite points a knowledge file named by its pre-canonical path (under documentation/, or relative to the knowledge root) at the same file under .kb/. Each removal deletes a value that names the entity's own file (reason self) or nothing Kibi can map (reason dangling). Only the source line changes.",
|
|
182
|
+
count: all.length,
|
|
183
|
+
rewrites: rewrites.map((rewrite) => ({ ...rewrite })),
|
|
184
|
+
removals: removals.map((removal) => ({ ...removal })),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Review: a source value Kibi would rewrite or remove but cannot edit
|
|
190
|
+
* safely (it spans several lines, or the edit would change other fields).
|
|
191
|
+
*/
|
|
192
|
+
// implements REQ-kibi-schema6-migration, REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
|
|
193
|
+
export function sourcePathReviewActionInput(source) {
|
|
194
|
+
const shown = typeof source.value === "string"
|
|
195
|
+
? source.value
|
|
196
|
+
: JSON.stringify(source.value);
|
|
197
|
+
const where = source.file !== undefined ? ` in ${source.file}` : "";
|
|
198
|
+
const edit = source.rewrite !== undefined
|
|
199
|
+
? `replace the whole field with the single line 'source: ${source.rewrite}'`
|
|
200
|
+
: "delete the whole field, every line of it";
|
|
201
|
+
return {
|
|
202
|
+
id: `review-source-path-dangling-${stableIdPart(source.entityId)}`,
|
|
203
|
+
code: SOURCE_PATH_REVIEW_CODE,
|
|
204
|
+
category: "quality",
|
|
205
|
+
safety: "review",
|
|
206
|
+
invocation: {
|
|
207
|
+
kind: "review",
|
|
208
|
+
instruction: `${source.entityId} has source '${shown}'${where}, which kibi migrate would repair automatically but cannot edit safely (${source.reason ?? "the edit would not read back as exactly that change"}). The compiled source is always the entity's own file; Kibi ignores the authored field when compiling and never writes it. A person edits the frontmatter by hand: ${edit}. Then rerun kibi migrate.`,
|
|
209
|
+
},
|
|
210
|
+
affectedEntityIds: [source.entityId],
|
|
211
|
+
affectedFiles: source.file !== undefined ? [source.file] : [],
|
|
212
|
+
dispositionRequired: true,
|
|
213
|
+
evidence: {
|
|
214
|
+
entityId: source.entityId,
|
|
215
|
+
source: source.value,
|
|
216
|
+
...(source.reason !== undefined ? { refused: source.reason } : {}),
|
|
217
|
+
...(source.rewrite !== undefined ? { rewrite: source.rewrite } : {}),
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Map the blocking findings that schema 6 migrates mechanically to stable
|
|
223
|
+
* actions with the same ids `kibi migrate` plans from authored sources:
|
|
224
|
+
* superseded-requirement-open (one close action, one review per cycle) and
|
|
225
|
+
* source-path-dangling (one automatic rewrite-or-remove action; a review
|
|
226
|
+
* only for a value Kibi cannot edit safely), plus the sync that recompiles
|
|
227
|
+
* what they rewrite.
|
|
228
|
+
*/
|
|
229
|
+
// implements REQ-cli-schema-migration, REQ-agent-guided-migration-orchestration, REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
230
|
+
export function lifecycleActionsFromViolations(violations) {
|
|
231
|
+
const actions = [];
|
|
232
|
+
const consumed = new Set();
|
|
233
|
+
const closures = [];
|
|
234
|
+
const rewrites = [];
|
|
235
|
+
const removals = [];
|
|
236
|
+
for (const [index, violation] of violations.entries()) {
|
|
237
|
+
const entityId = text(violation.entityId);
|
|
238
|
+
const evidence = isRecord(violation.evidence) ? violation.evidence : {};
|
|
239
|
+
const source = text(violation.source);
|
|
240
|
+
if (violation.rule === "superseded-requirement-open") {
|
|
241
|
+
const cycle = stringList(evidence.cycle);
|
|
242
|
+
if (cycle.length > 0) {
|
|
243
|
+
const edges = Array.isArray(evidence.edges)
|
|
244
|
+
? evidence.edges.flatMap((edge) => {
|
|
245
|
+
const pair = stringList(edge);
|
|
246
|
+
return pair.length === 2
|
|
247
|
+
? [[pair[0], pair[1]]]
|
|
248
|
+
: [];
|
|
249
|
+
})
|
|
250
|
+
: [];
|
|
251
|
+
actions.push(supersessionCycleReviewActionInput({ members: cycle, edges }));
|
|
252
|
+
}
|
|
253
|
+
else if (entityId !== "") {
|
|
254
|
+
closures.push({
|
|
255
|
+
id: entityId,
|
|
256
|
+
...(source !== "" ? { path: source } : {}),
|
|
257
|
+
status: text(evidence.status),
|
|
258
|
+
supersededBy: stringList(evidence.supersededBy),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
consumed.add(index);
|
|
265
|
+
}
|
|
266
|
+
else if (violation.rule === "source-path-dangling") {
|
|
267
|
+
if (entityId === "")
|
|
268
|
+
continue;
|
|
269
|
+
const file = text(evidence.file) || source;
|
|
270
|
+
const rewrite = text(evidence.rewrite);
|
|
271
|
+
const refused = text(evidence.refused);
|
|
272
|
+
const from = typeof evidence.value === "string"
|
|
273
|
+
? evidence.value
|
|
274
|
+
: (JSON.stringify(evidence.value) ?? "");
|
|
275
|
+
if (refused !== "" || file === "") {
|
|
276
|
+
actions.push(sourcePathReviewActionInput({
|
|
277
|
+
entityId,
|
|
278
|
+
value: evidence.value,
|
|
279
|
+
...(file !== "" ? { file } : {}),
|
|
280
|
+
...(refused !== "" ? { reason: refused } : {}),
|
|
281
|
+
...(rewrite !== "" ? { rewrite } : {}),
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
else if (rewrite !== "") {
|
|
285
|
+
rewrites.push({ entityId, file, from, to: rewrite });
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
removals.push({
|
|
289
|
+
entityId,
|
|
290
|
+
file,
|
|
291
|
+
from,
|
|
292
|
+
reason: evidence.remove === "self" ? "self" : "dangling",
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
consumed.add(index);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const rewriteActionIds = [];
|
|
299
|
+
if (closures.length > 0) {
|
|
300
|
+
actions.push(closeSupersededRequirementsActionInput(closures));
|
|
301
|
+
rewriteActionIds.push(CLOSE_SUPERSEDED_REQUIREMENTS_ACTION_ID);
|
|
302
|
+
}
|
|
303
|
+
if (rewrites.length > 0 || removals.length > 0) {
|
|
304
|
+
actions.push(sourcePathRewriteActionInput({ rewrites, removals }));
|
|
305
|
+
rewriteActionIds.push(SOURCE_PATH_REWRITE_ACTION_ID);
|
|
306
|
+
}
|
|
307
|
+
if (rewriteActionIds.length > 0) {
|
|
308
|
+
actions.push(migrationSyncActionInput(rewriteActionIds));
|
|
309
|
+
}
|
|
310
|
+
return { actions, consumed };
|
|
311
|
+
}
|
|
312
|
+
/** Action codes `kibi migrate` plans itself from authored sources. */
|
|
313
|
+
// implements REQ-kibi-schema6-migration, REQ-kibi-kb-lifecycle-integrity
|
|
314
|
+
export const SOURCE_PLANNED_LIFECYCLE_CODES = new Set([
|
|
315
|
+
CLOSE_SUPERSEDED_REQUIREMENTS_CODE,
|
|
316
|
+
SUPERSESSION_CYCLE_REVIEW_CODE,
|
|
317
|
+
SOURCE_PATH_REWRITE_CODE,
|
|
318
|
+
SOURCE_PATH_REVIEW_CODE,
|
|
319
|
+
MIGRATION_SYNC_CODE,
|
|
320
|
+
]);
|
|
321
|
+
/** Exception review shared by the source scan and the exception-unapproved rule. */
|
|
322
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
323
|
+
export function exceptionUnapprovedActionInput(input) {
|
|
324
|
+
const bases = input.exempts.join(", ");
|
|
325
|
+
return {
|
|
326
|
+
id: exceptionUnapprovedActionId(input.exceptionId),
|
|
327
|
+
code: EXCEPTION_UNAPPROVED_REVIEW_CODE,
|
|
328
|
+
category: "quality",
|
|
329
|
+
safety: "review",
|
|
330
|
+
invocation: {
|
|
331
|
+
kind: "review",
|
|
332
|
+
instruction: `${input.exceptionId} exempts ${bases} but has no approved_by, so it exempts nothing: success scenarios it specifies are checked against ${bases} and fail scenario-feasibility if they assume a forbidden value. If a human approved the exception, kb_upsert ${input.exceptionId} with approved_by set to that person and approval_ref to the decision record. If not, remove the exempts link (kb_delete relationships [{type: exempts, from: ${input.exceptionId}, to: <base>}]) and set expects: rejection on the scenario, or correct its assumes facts.`,
|
|
333
|
+
},
|
|
334
|
+
affectedEntityIds: [input.exceptionId, ...input.exempts],
|
|
335
|
+
affectedFiles: input.source !== undefined ? [input.source] : [],
|
|
336
|
+
dispositionRequired: true,
|
|
337
|
+
evidence: { exceptionId: input.exceptionId, exempts: [...input.exempts] },
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function isRecord(value) {
|
|
341
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
342
|
+
}
|
|
343
|
+
function stringList(value) {
|
|
344
|
+
return Array.isArray(value)
|
|
345
|
+
? value.filter((item) => typeof item === "string")
|
|
346
|
+
: [];
|
|
347
|
+
}
|
|
348
|
+
function text(value) {
|
|
349
|
+
return typeof value === "string" ? value : "";
|
|
350
|
+
}
|
|
351
|
+
function reviewQueue() {
|
|
352
|
+
return { ids: [], files: [], evidence: [], total: 0 };
|
|
353
|
+
}
|
|
354
|
+
const PREDICATE_SIGNATURE = /predicate (\S+):(\S+)\/(\d+) declares no key_arguments/;
|
|
355
|
+
/**
|
|
356
|
+
* Map the schema 6 review findings of one check to stable review actions.
|
|
357
|
+
* Returns the actions and the indexes of the diagnostics they replace.
|
|
358
|
+
*/
|
|
359
|
+
// implements REQ-cli-schema-migration, REQ-agent-guided-migration-orchestration, REQ-kibi-schema6-migration
|
|
360
|
+
export function schema6ReviewActionsFromCheck(diagnostics) {
|
|
361
|
+
const actions = [];
|
|
362
|
+
const consumed = new Set();
|
|
363
|
+
const agentRequirements = [];
|
|
364
|
+
let agentRequirementsTotal = 0;
|
|
365
|
+
const agentRequirementFiles = [];
|
|
366
|
+
const symbolOwners = reviewQueue();
|
|
367
|
+
const rationaleQueue = reviewQueue();
|
|
368
|
+
const predicates = new Map();
|
|
369
|
+
for (const [index, diagnostic] of diagnostics.entries()) {
|
|
370
|
+
const entityId = text(diagnostic.entityId);
|
|
371
|
+
const evidence = isRecord(diagnostic.evidence) ? diagnostic.evidence : {};
|
|
372
|
+
const source = text(diagnostic.source);
|
|
373
|
+
switch (diagnostic.id) {
|
|
374
|
+
case "rule.exception-unapproved": {
|
|
375
|
+
if (entityId === "")
|
|
376
|
+
continue;
|
|
377
|
+
actions.push(exceptionUnapprovedActionInput({
|
|
378
|
+
exceptionId: entityId,
|
|
379
|
+
exempts: stringList(evidence.exempts),
|
|
380
|
+
...(source !== "" ? { source } : {}),
|
|
381
|
+
}));
|
|
382
|
+
consumed.add(index);
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
case "rule.exception-approval-self-attested": {
|
|
386
|
+
if (entityId === "")
|
|
387
|
+
continue;
|
|
388
|
+
actions.push({
|
|
389
|
+
id: `review-exception-approval-self-attested-${entityId}`,
|
|
390
|
+
code: EXCEPTION_SELF_ATTESTED_REVIEW_CODE,
|
|
391
|
+
category: "quality",
|
|
392
|
+
safety: "review",
|
|
393
|
+
invocation: {
|
|
394
|
+
kind: "review",
|
|
395
|
+
instruction: text(diagnostic.suggestion) || text(diagnostic.message),
|
|
396
|
+
},
|
|
397
|
+
affectedEntityIds: [entityId, ...stringList(evidence.exempts)],
|
|
398
|
+
affectedFiles: source !== "" ? [source] : [],
|
|
399
|
+
dispositionRequired: true,
|
|
400
|
+
evidence: { diagnostic },
|
|
401
|
+
});
|
|
402
|
+
consumed.add(index);
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case "rule.scenario-feasibility-unknown": {
|
|
406
|
+
if (entityId === "")
|
|
407
|
+
continue;
|
|
408
|
+
actions.push({
|
|
409
|
+
id: `review-scenario-feasibility-unknown-${entityId}`,
|
|
410
|
+
code: SCENARIO_FEASIBILITY_REVIEW_CODE,
|
|
411
|
+
category: "semantic",
|
|
412
|
+
safety: "review",
|
|
413
|
+
invocation: {
|
|
414
|
+
kind: "review",
|
|
415
|
+
instruction: `${text(diagnostic.message)}. ${text(diagnostic.suggestion)}`,
|
|
416
|
+
},
|
|
417
|
+
affectedEntityIds: [entityId],
|
|
418
|
+
affectedFiles: source !== "" ? [source] : [],
|
|
419
|
+
dispositionRequired: true,
|
|
420
|
+
evidence: { diagnostic },
|
|
421
|
+
});
|
|
422
|
+
consumed.add(index);
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
case "rule.agent-requirement-unapproved": {
|
|
426
|
+
// The rule lists a bounded page plus one workspace summary; the
|
|
427
|
+
// review is one decision queue, not one action per requirement.
|
|
428
|
+
if (entityId !== "" && entityId !== "workspace") {
|
|
429
|
+
agentRequirements.push(entityId);
|
|
430
|
+
if (source !== "")
|
|
431
|
+
agentRequirementFiles.push(source);
|
|
432
|
+
}
|
|
433
|
+
if (typeof evidence.total === "number") {
|
|
434
|
+
agentRequirementsTotal = evidence.total;
|
|
435
|
+
}
|
|
436
|
+
consumed.add(index);
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
case "rule.symbol-owner-superseded":
|
|
440
|
+
case "rule.requirement-rationale-missing": {
|
|
441
|
+
// Bounded page plus one summary finding: one review queue each.
|
|
442
|
+
const queue = diagnostic.id === "rule.symbol-owner-superseded"
|
|
443
|
+
? symbolOwners
|
|
444
|
+
: rationaleQueue;
|
|
445
|
+
if (entityId !== "" && entityId !== "workspace") {
|
|
446
|
+
queue.ids.push(entityId);
|
|
447
|
+
if (source !== "")
|
|
448
|
+
queue.files.push(source);
|
|
449
|
+
queue.evidence.push({ entityId, evidence });
|
|
450
|
+
}
|
|
451
|
+
if (typeof evidence.total === "number")
|
|
452
|
+
queue.total = evidence.total;
|
|
453
|
+
consumed.add(index);
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
case "rule.adr-unlinked":
|
|
457
|
+
case "rule.adr-proposed": {
|
|
458
|
+
if (entityId === "")
|
|
459
|
+
continue;
|
|
460
|
+
const unlinked = diagnostic.id === "rule.adr-unlinked";
|
|
461
|
+
actions.push({
|
|
462
|
+
id: `${unlinked ? "review-adr-unlinked" : "review-adr-proposed"}-${entityId}`,
|
|
463
|
+
code: unlinked ? ADR_UNLINKED_REVIEW_CODE : ADR_PROPOSED_REVIEW_CODE,
|
|
464
|
+
category: "quality",
|
|
465
|
+
safety: "review",
|
|
466
|
+
invocation: {
|
|
467
|
+
kind: "review",
|
|
468
|
+
instruction: `${text(diagnostic.message)}. ${text(diagnostic.suggestion)}`,
|
|
469
|
+
},
|
|
470
|
+
affectedEntityIds: [entityId],
|
|
471
|
+
affectedFiles: source !== "" ? [source] : [],
|
|
472
|
+
dispositionRequired: true,
|
|
473
|
+
evidence: { diagnostic },
|
|
474
|
+
});
|
|
475
|
+
consumed.add(index);
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
case "rule.rule-key-arguments-missing": {
|
|
479
|
+
const match = PREDICATE_SIGNATURE.exec(text(diagnostic.message));
|
|
480
|
+
if (match === null)
|
|
481
|
+
continue;
|
|
482
|
+
const signature = `${match[1]}:${match[2]}/${match[3]}`;
|
|
483
|
+
const group = predicates.get(signature) ?? {
|
|
484
|
+
signature,
|
|
485
|
+
pairs: [],
|
|
486
|
+
messages: [],
|
|
487
|
+
suggestion: text(diagnostic.suggestion),
|
|
488
|
+
};
|
|
489
|
+
if (entityId !== "")
|
|
490
|
+
group.pairs.push(entityId);
|
|
491
|
+
group.messages.push(text(diagnostic.message));
|
|
492
|
+
predicates.set(signature, group);
|
|
493
|
+
consumed.add(index);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
default:
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
for (const group of [...predicates.values()].sort((left, right) => left.signature.localeCompare(right.signature))) {
|
|
501
|
+
const pairs = [...new Set(group.pairs)].sort();
|
|
502
|
+
actions.push({
|
|
503
|
+
id: `review-predicate-key-arguments-${group.signature.replace(/[^A-Za-z0-9_-]+/g, "-")}`,
|
|
504
|
+
code: PREDICATE_KEY_ARGUMENTS_REVIEW_CODE,
|
|
505
|
+
category: "semantic",
|
|
506
|
+
safety: "review",
|
|
507
|
+
invocation: {
|
|
508
|
+
kind: "review",
|
|
509
|
+
instruction: `Predicate ${group.signature} declares no key_arguments, which leaves ${pairs.length} opposing rule pair(s) unresolved (${pairs.join(", ")}). ${group.suggestion}`,
|
|
510
|
+
},
|
|
511
|
+
affectedEntityIds: [...new Set(pairs.flatMap((pair) => pair.split("/")))],
|
|
512
|
+
dispositionRequired: true,
|
|
513
|
+
evidence: {
|
|
514
|
+
predicate: group.signature,
|
|
515
|
+
rulePairs: pairs,
|
|
516
|
+
findings: [...new Set(group.messages)].sort(),
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
if (symbolOwners.ids.length > 0) {
|
|
521
|
+
const listed = [...new Set(symbolOwners.ids)].sort();
|
|
522
|
+
const total = Math.max(symbolOwners.total, listed.length);
|
|
523
|
+
actions.push({
|
|
524
|
+
id: SYMBOL_OWNER_REVIEW_ACTION_ID,
|
|
525
|
+
code: SYMBOL_OWNER_REVIEW_CODE,
|
|
526
|
+
category: "symbol",
|
|
527
|
+
safety: "review",
|
|
528
|
+
invocation: {
|
|
529
|
+
kind: "review",
|
|
530
|
+
instruction: `${total} symbol(s) implement only superseded or deprecated requirements${total > listed.length ? `; these ${listed.length} come first` : ""}: ${listed.join(", ")}. For each, kb_upsert the symbol with an implements link to the requirement that replaced its owner (evidence lists the replacements) when it still implements that behavior, or remove the symbol when the behavior is gone. Rerun kb_check for the next page.`,
|
|
531
|
+
},
|
|
532
|
+
affectedEntityIds: listed,
|
|
533
|
+
affectedFiles: [...new Set(symbolOwners.files)].sort(),
|
|
534
|
+
dispositionRequired: true,
|
|
535
|
+
evidence: { symbols: symbolOwners.evidence, total },
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
if (rationaleQueue.ids.length > 0) {
|
|
539
|
+
const listed = [...new Set(rationaleQueue.ids)].sort();
|
|
540
|
+
const total = Math.max(rationaleQueue.total, listed.length);
|
|
541
|
+
actions.push({
|
|
542
|
+
id: RATIONALE_REVIEW_ACTION_ID,
|
|
543
|
+
code: RATIONALE_REVIEW_CODE,
|
|
544
|
+
category: "quality",
|
|
545
|
+
safety: "review",
|
|
546
|
+
invocation: {
|
|
547
|
+
kind: "review",
|
|
548
|
+
instruction: `${total} human- or agent-authored requirement(s) state no rationale${total > listed.length ? `; these ${listed.length} come first` : ""}: ${listed.join(", ")}. Ask the person who stated the intent why it matters, then kb_upsert the requirement with rationale set to that answer (or link the ADR that records the decision). Rerun kb_check for the next page.`,
|
|
549
|
+
},
|
|
550
|
+
affectedEntityIds: listed,
|
|
551
|
+
affectedFiles: [...new Set(rationaleQueue.files)].sort(),
|
|
552
|
+
dispositionRequired: true,
|
|
553
|
+
evidence: { requirements: listed, total },
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
if (agentRequirements.length > 0) {
|
|
557
|
+
const listed = [...new Set(agentRequirements)].sort();
|
|
558
|
+
const total = Math.max(agentRequirementsTotal, listed.length);
|
|
559
|
+
actions.push({
|
|
560
|
+
id: AGENT_REQUIREMENTS_REVIEW_ACTION_ID,
|
|
561
|
+
code: AGENT_REQUIREMENTS_REVIEW_CODE,
|
|
562
|
+
category: "quality",
|
|
563
|
+
safety: "review",
|
|
564
|
+
invocation: {
|
|
565
|
+
kind: "review",
|
|
566
|
+
instruction: `${total} agent-authored requirement(s) have no human approval${total > listed.length ? `; these ${listed.length} come first` : ""}: ${listed.join(", ")}. Have a person read each one; when it states the intended behavior, kb_upsert it with origin.approved_by set to the reviewer (keep kind: agent and the rest of origin). Rerun kb_check for the next page.`,
|
|
567
|
+
},
|
|
568
|
+
affectedEntityIds: listed,
|
|
569
|
+
affectedFiles: [...new Set(agentRequirementFiles)].sort(),
|
|
570
|
+
dispositionRequired: true,
|
|
571
|
+
evidence: { requirements: listed, total },
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
return { actions, consumed };
|
|
575
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type SourceRepair } from "../../operations/migration/source-paths.js";
|
|
2
|
+
import type { Violation } from "../../utils/rule-registry.js";
|
|
3
|
+
/** An authored source field that names no path, entity or URL. */
|
|
4
|
+
export declare const SOURCE_PATH_DANGLING_RULE = "source-path-dangling";
|
|
5
|
+
/**
|
|
6
|
+
* One blocking finding per authored source that resolves to nothing. The
|
|
7
|
+
* evidence names the automatic fix (`rewrite` or `remove`) and, when the
|
|
8
|
+
* edit is not safe, why (`refused`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function sourcePathDanglingViolations(dangling: readonly SourceRepair[]): Violation[];
|
|
11
|
+
/**
|
|
12
|
+
* Read the authored `source` field of every entity file once and report the
|
|
13
|
+
* values that resolve to nothing. The compiled `source` (the entity's own
|
|
14
|
+
* file) always resolves, so the check reads authored frontmatter.
|
|
15
|
+
*/
|
|
16
|
+
export declare function collectSourcePathDanglingViolations(workspaceRoot: string): Violation[];
|
|
17
|
+
//# sourceMappingURL=source-path-dangling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-path-dangling.d.ts","sourceRoot":"","sources":["../../../src/public/operations/source-path-dangling.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,kEAAkE;AAElE,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAiBhE;;;;GAIG;AAEH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,SAAS,YAAY,EAAE,GAChC,SAAS,EAAE,CAgBb;AAED;;;;GAIG;AAEH,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,GACpB,SAAS,EAAE,CAEb"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { findDanglingSources, shownSourceValue, } from "../../operations/migration/source-paths.js";
|
|
19
|
+
/** An authored source field that names no path, entity or URL. */
|
|
20
|
+
// implements REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
|
|
21
|
+
export const SOURCE_PATH_DANGLING_RULE = "source-path-dangling";
|
|
22
|
+
function suggestion(source) {
|
|
23
|
+
const compiled = `The compiled source is always the entity's own file (${source.file}), so the field carries nothing Kibi compiles.`;
|
|
24
|
+
if (source.refused !== undefined) {
|
|
25
|
+
return `kibi migrate cannot edit this source field safely (${source.refused}), so it plans a review_source_path_dangling action for a person. ${compiled}`;
|
|
26
|
+
}
|
|
27
|
+
if (source.fix.kind === "rewrite") {
|
|
28
|
+
return `The file moved to ${source.fix.to}; kibi migrate rewrites the source field there (source_path_rewrite). ${compiled}`;
|
|
29
|
+
}
|
|
30
|
+
const why = source.fix.reason === "self"
|
|
31
|
+
? "it names the entity's own file"
|
|
32
|
+
: "nothing it names can be mapped";
|
|
33
|
+
return `kibi migrate removes this source field (source_path_rewrite) because ${why}. ${compiled}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* One blocking finding per authored source that resolves to nothing. The
|
|
37
|
+
* evidence names the automatic fix (`rewrite` or `remove`) and, when the
|
|
38
|
+
* edit is not safe, why (`refused`).
|
|
39
|
+
*/
|
|
40
|
+
// implements REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
|
|
41
|
+
export function sourcePathDanglingViolations(dangling) {
|
|
42
|
+
return dangling.map((source) => ({
|
|
43
|
+
rule: SOURCE_PATH_DANGLING_RULE,
|
|
44
|
+
entityId: source.entityId,
|
|
45
|
+
description: `${source.entityId} names source '${shownSourceValue(source.value)}', which is not an existing workspace path, an entity id or an http(s) URL`,
|
|
46
|
+
suggestion: suggestion(source),
|
|
47
|
+
source: source.file,
|
|
48
|
+
evidence: {
|
|
49
|
+
value: source.value,
|
|
50
|
+
file: source.file,
|
|
51
|
+
...(source.fix.kind === "rewrite"
|
|
52
|
+
? { rewrite: source.fix.to }
|
|
53
|
+
: { remove: source.fix.reason }),
|
|
54
|
+
...(source.refused !== undefined ? { refused: source.refused } : {}),
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Read the authored `source` field of every entity file once and report the
|
|
60
|
+
* values that resolve to nothing. The compiled `source` (the entity's own
|
|
61
|
+
* file) always resolves, so the check reads authored frontmatter.
|
|
62
|
+
*/
|
|
63
|
+
// implements REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
|
|
64
|
+
export function collectSourcePathDanglingViolations(workspaceRoot) {
|
|
65
|
+
return sourcePathDanglingViolations(findDanglingSources(workspaceRoot));
|
|
66
|
+
}
|