@dommaker/harness 1.16.0 → 3.0.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/CHANGELOG.md +35 -0
- package/README.md +7 -7
- package/dist/agents/index.d.ts +1 -2
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/lifecycle.d.ts +2 -34
- package/dist/agents/lifecycle.d.ts.map +1 -1
- package/dist/agents/lifecycle.js +1 -103
- package/dist/agents/lifecycle.js.map +1 -1
- package/dist/agents/types.d.ts +1 -19
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/{hooks → bootstrap}/bootstrap.d.ts +9 -3
- package/dist/bootstrap/bootstrap.d.ts.map +1 -0
- package/dist/{hooks → bootstrap}/bootstrap.js +26 -30
- package/dist/bootstrap/bootstrap.js.map +1 -0
- package/dist/{hooks → bootstrap}/index.d.ts +3 -2
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/{hooks → bootstrap}/index.js +3 -2
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/cli/command-contract.d.ts +6 -9
- package/dist/cli/command-contract.d.ts.map +1 -1
- package/dist/cli/command-contract.js +6 -0
- package/dist/cli/command-contract.js.map +1 -1
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +9 -8
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/check.d.ts +1 -1
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +12 -5
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +9 -5
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.d.ts.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.js +11 -8
- package/dist/cli/commands/constraints-pack-proposal.js.map +1 -1
- package/dist/cli/commands/constraints-reactivate.d.ts +10 -2
- package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
- package/dist/cli/commands/constraints-reactivate.js +2 -6
- package/dist/cli/commands/constraints-reactivate.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +23 -5
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +19 -9
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +24 -16
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +2 -73
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +13 -17
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/failure.d.ts.map +1 -1
- package/dist/cli/commands/failure.js +5 -6
- package/dist/cli/commands/failure.js.map +1 -1
- package/dist/cli/commands/init/ci-platform.d.ts +35 -0
- package/dist/cli/commands/init/ci-platform.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-platform.js +59 -0
- package/dist/cli/commands/init/ci-platform.js.map +1 -0
- package/dist/cli/commands/init/ci-wiring.d.ts +20 -0
- package/dist/cli/commands/init/ci-wiring.d.ts.map +1 -0
- package/dist/cli/commands/init/ci-wiring.js +72 -0
- package/dist/cli/commands/init/ci-wiring.js.map +1 -0
- package/dist/cli/commands/init/git-hooks.d.ts +15 -0
- package/dist/cli/commands/init/git-hooks.d.ts.map +1 -0
- package/dist/cli/commands/init/git-hooks.js +64 -0
- package/dist/cli/commands/init/git-hooks.js.map +1 -0
- package/dist/cli/commands/init/governance.d.ts +14 -0
- package/dist/cli/commands/init/governance.d.ts.map +1 -0
- package/dist/cli/commands/init/governance.js +132 -0
- package/dist/cli/commands/init/governance.js.map +1 -0
- package/dist/cli/commands/{init.d.ts → init/index.d.ts} +13 -14
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +148 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/output-style.d.ts +19 -0
- package/dist/cli/commands/init/output-style.d.ts.map +1 -0
- package/dist/cli/commands/init/output-style.js +110 -0
- package/dist/cli/commands/init/output-style.js.map +1 -0
- package/dist/cli/commands/init/presets.d.ts +26 -0
- package/dist/cli/commands/init/presets.d.ts.map +1 -0
- package/dist/cli/commands/init/presets.js +104 -0
- package/dist/cli/commands/init/presets.js.map +1 -0
- package/dist/cli/commands/init/snippets.d.ts +18 -0
- package/dist/cli/commands/init/snippets.d.ts.map +1 -0
- package/dist/cli/commands/init/snippets.js +49 -0
- package/dist/cli/commands/init/snippets.js.map +1 -0
- package/dist/cli/commands/knowledge/audit.d.ts +30 -0
- package/dist/cli/commands/knowledge/audit.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/audit.js +114 -0
- package/dist/cli/commands/knowledge/audit.js.map +1 -0
- package/dist/cli/commands/knowledge/decay.d.ts +19 -0
- package/dist/cli/commands/knowledge/decay.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/decay.js +48 -0
- package/dist/cli/commands/knowledge/decay.js.map +1 -0
- package/dist/cli/commands/knowledge/health.d.ts +38 -0
- package/dist/cli/commands/knowledge/health.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/health.js +178 -0
- package/dist/cli/commands/knowledge/health.js.map +1 -0
- package/dist/cli/commands/knowledge/import.d.ts +26 -0
- package/dist/cli/commands/knowledge/import.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/import.js +63 -0
- package/dist/cli/commands/knowledge/import.js.map +1 -0
- package/dist/cli/commands/knowledge/index.d.ts +25 -0
- package/dist/cli/commands/knowledge/index.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/index.js +84 -0
- package/dist/cli/commands/knowledge/index.js.map +1 -0
- package/dist/cli/commands/knowledge/list.d.ts +25 -0
- package/dist/cli/commands/knowledge/list.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/list.js +60 -0
- package/dist/cli/commands/knowledge/list.js.map +1 -0
- package/dist/cli/commands/knowledge/search.d.ts +32 -0
- package/dist/cli/commands/knowledge/search.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/search.js +72 -0
- package/dist/cli/commands/knowledge/search.js.map +1 -0
- package/dist/cli/commands/knowledge/shared.d.ts +14 -0
- package/dist/cli/commands/knowledge/shared.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/shared.js +6 -0
- package/dist/cli/commands/knowledge/shared.js.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts +18 -0
- package/dist/cli/commands/knowledge/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/snapshot.js +34 -0
- package/dist/cli/commands/knowledge/snapshot.js.map +1 -0
- package/dist/cli/commands/knowledge/stats.d.ts +26 -0
- package/dist/cli/commands/knowledge/stats.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/stats.js +132 -0
- package/dist/cli/commands/knowledge/stats.js.map +1 -0
- package/dist/cli/commands/knowledge/store-access.d.ts +25 -0
- package/dist/cli/commands/knowledge/store-access.d.ts.map +1 -0
- package/dist/cli/commands/knowledge/store-access.js +69 -0
- package/dist/cli/commands/knowledge/store-access.js.map +1 -0
- package/dist/cli/commands/knowledge-view.d.ts +8 -19
- package/dist/cli/commands/knowledge-view.d.ts.map +1 -1
- package/dist/cli/commands/knowledge-view.js +12 -63
- package/dist/cli/commands/knowledge-view.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +19 -8
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/release.d.ts +1 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +25 -59
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +17 -5
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +13 -8
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/{core → cli/commands}/spec/validator.d.ts +10 -19
- package/dist/cli/commands/spec/validator.d.ts.map +1 -0
- package/dist/{core → cli/commands}/spec/validator.js +52 -78
- package/dist/cli/commands/spec/validator.js.map +1 -0
- package/dist/cli/commands/spec-baseline-check.d.ts +8 -41
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +32 -238
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/spec.d.ts +1 -1
- package/dist/cli/commands/spec.d.ts.map +1 -1
- package/dist/cli/commands/spec.js +14 -11
- package/dist/cli/commands/spec.js.map +1 -1
- package/dist/cli/commands/status.d.ts +0 -2
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +31 -55
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +13 -13
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/compact.d.ts +9 -0
- package/dist/cli/commands/sync-docs/compact.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/compact.js +73 -0
- package/dist/cli/commands/sync-docs/compact.js.map +1 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +17 -36
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/gate.d.ts +27 -0
- package/dist/cli/commands/sync-docs/gate.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/gate.js +72 -0
- package/dist/cli/commands/sync-docs/gate.js.map +1 -0
- package/dist/cli/commands/sync-docs/index.d.ts +13 -27
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +19 -529
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/main-flow.d.ts +21 -0
- package/dist/cli/commands/sync-docs/main-flow.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/main-flow.js +93 -0
- package/dist/cli/commands/sync-docs/main-flow.js.map +1 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +18 -26
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/sync-docs/sync-output.d.ts +15 -0
- package/dist/cli/commands/sync-docs/sync-output.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/sync-output.js +217 -0
- package/dist/cli/commands/sync-docs/sync-output.js.map +1 -0
- package/dist/cli/commands/sync-docs/sync-state.d.ts +71 -0
- package/dist/cli/commands/sync-docs/sync-state.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/sync-state.js +274 -0
- package/dist/cli/commands/sync-docs/sync-state.js.map +1 -0
- package/dist/cli/commands/sync-docs/sync-writes.d.ts +12 -0
- package/dist/cli/commands/sync-docs/sync-writes.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/sync-writes.js +72 -0
- package/dist/cli/commands/sync-docs/sync-writes.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +0 -2
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +13 -6
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/gate-command.d.ts +1 -1
- package/dist/cli/gate-command.d.ts.map +1 -1
- package/dist/context/index.d.ts +2 -4
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -6
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +27 -84
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +3 -25
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/types.js +2 -1
- package/dist/context/types.js.map +1 -1
- package/dist/core/app-constraints-loader.d.ts +1 -1
- package/dist/core/app-constraints-loader.d.ts.map +1 -1
- package/dist/core/app-constraints-loader.js +6 -23
- package/dist/core/app-constraints-loader.js.map +1 -1
- package/dist/core/constraint-lifecycle.d.ts +3 -8
- package/dist/core/constraint-lifecycle.d.ts.map +1 -1
- package/dist/core/constraint-lifecycle.js +27 -31
- package/dist/core/constraint-lifecycle.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +2 -1
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +4 -6
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/check-cache.d.ts +4 -43
- package/dist/core/constraints/check-cache.d.ts.map +1 -1
- package/dist/core/constraints/check-cache.js +6 -51
- package/dist/core/constraints/check-cache.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +0 -16
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +23 -64
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +3 -3
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +2 -2
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +5 -5
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +17 -3
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +22 -10
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +5 -34
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js +11 -33
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.js +4 -8
- package/dist/core/constraints/checkers/templated/exec.js.map +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js.map +1 -1
- package/dist/core/constraints/checkers/templated/regex-scan.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/regex-scan.js +8 -26
- package/dist/core/constraints/checkers/templated/regex-scan.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +10 -33
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +6 -46
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts +8 -26
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +9 -102
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/{iron-laws.d.ts → errors.d.ts} +1 -2
- package/dist/core/constraints/definitions/errors.d.ts.map +1 -0
- package/dist/core/constraints/definitions/{iron-laws.js → errors.js} +1 -21
- package/dist/core/constraints/definitions/errors.js.map +1 -0
- package/dist/core/constraints/definitions/{guidelines.d.ts → warnings.d.ts} +1 -2
- package/dist/core/constraints/definitions/warnings.d.ts.map +1 -0
- package/dist/core/constraints/definitions/{guidelines.js → warnings.js} +18 -5
- package/dist/core/constraints/definitions/warnings.js.map +1 -0
- package/dist/core/constraints/definitions.d.ts +2 -1
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +6 -5
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts +0 -9
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +192 -224
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/find-constraint.d.ts +14 -0
- package/dist/core/constraints/find-constraint.d.ts.map +1 -0
- package/dist/core/constraints/find-constraint.js +25 -0
- package/dist/core/constraints/find-constraint.js.map +1 -0
- package/dist/core/constraints/git-evidence.d.ts.map +1 -1
- package/dist/core/constraints/git-evidence.js +2 -0
- package/dist/core/constraints/git-evidence.js.map +1 -1
- package/dist/core/constraints/governance-accessors.d.ts +54 -0
- package/dist/core/constraints/governance-accessors.d.ts.map +1 -0
- package/dist/core/constraints/governance-accessors.js +62 -0
- package/dist/core/constraints/governance-accessors.js.map +1 -0
- package/dist/core/constraints/index.d.ts +4 -4
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +1 -4
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +1 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -1
- package/dist/core/constraints/injection-writer.js +3 -6
- package/dist/core/constraints/injection-writer.js.map +1 -1
- package/dist/core/constraints/pack-proposal.d.ts.map +1 -1
- package/dist/core/constraints/pack-proposal.js +3 -14
- package/dist/core/constraints/pack-proposal.js.map +1 -1
- package/dist/core/constraints/run-env.d.ts +1 -13
- package/dist/core/constraints/run-env.d.ts.map +1 -1
- package/dist/core/constraints/run-env.js +2 -23
- package/dist/core/constraints/run-env.js.map +1 -1
- package/dist/core/constraints/triggers.d.ts +10 -6
- package/dist/core/constraints/triggers.d.ts.map +1 -1
- package/dist/core/constraints/triggers.js +11 -5
- package/dist/core/constraints/triggers.js.map +1 -1
- package/dist/core/constraints/usage-report.d.ts +0 -6
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +0 -9
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -8
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +5 -41
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +4 -49
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/spec/baseline-check.d.ts +54 -0
- package/dist/core/spec/baseline-check.d.ts.map +1 -0
- package/dist/core/spec/baseline-check.js +261 -0
- package/dist/core/spec/baseline-check.js.map +1 -0
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/command.js +7 -4
- package/dist/core/validators/check-handlers/command.js.map +1 -1
- package/dist/core/validators/check-handlers/file.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/file.js +49 -5
- package/dist/core/validators/check-handlers/file.js.map +1 -1
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/http.js +6 -4
- package/dist/core/validators/check-handlers/http.js.map +1 -1
- package/dist/core/validators/check-handlers/output.d.ts +1 -1
- package/dist/core/validators/check-handlers/output.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/output.js +2 -1
- package/dist/core/validators/check-handlers/output.js.map +1 -1
- package/dist/core/validators/checkpoint.d.ts +5 -13
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +53 -80
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/core/validators/cso.d.ts +1 -4
- package/dist/core/validators/cso.d.ts.map +1 -1
- package/dist/core/validators/cso.js +1 -9
- package/dist/core/validators/cso.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -5
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +21 -35
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/failure/classifier.d.ts +2 -21
- package/dist/failure/classifier.d.ts.map +1 -1
- package/dist/failure/classifier.js +7 -42
- package/dist/failure/classifier.js.map +1 -1
- package/dist/failure/error-types.d.ts +48 -0
- package/dist/failure/error-types.d.ts.map +1 -0
- package/dist/failure/error-types.js +122 -0
- package/dist/failure/error-types.js.map +1 -0
- package/dist/failure/index.d.ts +4 -3
- package/dist/failure/index.d.ts.map +1 -1
- package/dist/failure/index.js +8 -10
- package/dist/failure/index.js.map +1 -1
- package/dist/failure/recorder.d.ts +7 -27
- package/dist/failure/recorder.d.ts.map +1 -1
- package/dist/failure/recorder.js +11 -64
- package/dist/failure/recorder.js.map +1 -1
- package/dist/gates/acceptance.d.ts +43 -19
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +148 -122
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/command.d.ts +1 -17
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +0 -29
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts +11 -10
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +55 -74
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/definitions.d.ts +1 -1
- package/dist/gates/performance.d.ts +2 -16
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +18 -27
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts.map +1 -1
- package/dist/gates/registry.js +3 -2
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/review.d.ts +1 -9
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +38 -21
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts +6 -9
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +42 -76
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +11 -78
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +5 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/index.d.ts +20 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -18
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-dimensions.d.ts +45 -0
- package/dist/knowledge/audit-dimensions.d.ts.map +1 -0
- package/dist/knowledge/audit-dimensions.js +144 -0
- package/dist/knowledge/audit-dimensions.js.map +1 -0
- package/dist/knowledge/audit-rules.d.ts +43 -0
- package/dist/knowledge/audit-rules.d.ts.map +1 -0
- package/dist/knowledge/audit-rules.js +272 -0
- package/dist/knowledge/audit-rules.js.map +1 -0
- package/dist/knowledge/audit-scoring.d.ts +6 -60
- package/dist/knowledge/audit-scoring.d.ts.map +1 -1
- package/dist/knowledge/audit-scoring.js +8 -391
- package/dist/knowledge/audit-scoring.js.map +1 -1
- package/dist/knowledge/audit.d.ts +6 -3
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +12 -7
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/{import.d.ts → cold-start.d.ts} +2 -3
- package/dist/knowledge/cold-start.d.ts.map +1 -0
- package/dist/knowledge/{import.js → cold-start.js} +136 -182
- package/dist/knowledge/cold-start.js.map +1 -0
- package/dist/knowledge/index-generator.d.ts +2 -0
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +43 -50
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/index.d.ts +7 -7
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +4 -9
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/ingest.d.ts +50 -6
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +109 -16
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle.d.ts +0 -5
- package/dist/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/knowledge/lifecycle.js +29 -41
- package/dist/knowledge/lifecycle.js.map +1 -1
- package/dist/knowledge/query.d.ts +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +8 -8
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/store.d.ts +4 -7
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +26 -63
- package/dist/knowledge/store.js.map +1 -1
- package/dist/knowledge/types.d.ts +2 -36
- package/dist/knowledge/types.d.ts.map +1 -1
- package/dist/knowledge/types.js +2 -3
- package/dist/knowledge/types.js.map +1 -1
- package/dist/monitoring/analyzer-base.d.ts +1 -10
- package/dist/monitoring/analyzer-base.d.ts.map +1 -1
- package/dist/monitoring/analyzer-base.js +1 -58
- package/dist/monitoring/analyzer-base.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +3 -54
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +9 -136
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +1 -14
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +9 -29
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +1 -1
- package/dist/pretool-use-hook.d.ts.map +1 -1
- package/dist/pretool-use-hook.js +12 -19
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +8 -8
- package/dist/release/integrity.js.map +1 -1
- package/dist/sdd/index-generator.d.ts.map +1 -1
- package/dist/sdd/index-generator.js +4 -0
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/types/checkpoint.d.ts +8 -8
- package/dist/types/checkpoint.d.ts.map +1 -1
- package/dist/types/command-definition.d.ts +81 -0
- package/dist/types/command-definition.d.ts.map +1 -0
- package/dist/types/command-definition.js +10 -0
- package/dist/types/command-definition.js.map +1 -0
- package/dist/types/command-io.d.ts +19 -0
- package/dist/types/command-io.d.ts.map +1 -0
- package/dist/types/command-io.js +3 -0
- package/dist/types/command-io.js.map +1 -0
- package/dist/types/constraint.d.ts +3 -24
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/failure.d.ts +6 -39
- package/dist/types/failure.d.ts.map +1 -1
- package/dist/types/failure.js +6 -112
- package/dist/types/failure.js.map +1 -1
- package/dist/types/gate.d.ts +72 -0
- package/dist/types/gate.d.ts.map +1 -0
- package/dist/types/gate.js +13 -0
- package/dist/types/gate.js.map +1 -0
- package/dist/types/spec.d.ts +0 -4
- package/dist/types/spec.d.ts.map +1 -1
- package/dist/types/trace.d.ts +0 -4
- package/dist/types/trace.d.ts.map +1 -1
- package/dist/utils/attempt.d.ts +22 -0
- package/dist/utils/attempt.d.ts.map +1 -0
- package/dist/utils/attempt.js +40 -0
- package/dist/utils/attempt.js.map +1 -0
- package/dist/utils/clip.d.ts +8 -0
- package/dist/utils/clip.d.ts.map +1 -0
- package/dist/utils/clip.js +15 -0
- package/dist/utils/clip.js.map +1 -0
- package/dist/utils/detect-source-roots.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.js +42 -51
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/dist/utils/diff-parse.d.ts +31 -0
- package/dist/utils/diff-parse.d.ts.map +1 -0
- package/dist/utils/diff-parse.js +72 -0
- package/dist/utils/diff-parse.js.map +1 -0
- package/dist/utils/file-walk.d.ts +2 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +3 -8
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/guards.d.ts +6 -0
- package/dist/utils/guards.d.ts.map +1 -0
- package/dist/utils/guards.js +11 -0
- package/dist/utils/guards.js.map +1 -0
- package/dist/utils/jsonl.d.ts +0 -12
- package/dist/utils/jsonl.d.ts.map +1 -1
- package/dist/utils/jsonl.js +0 -12
- package/dist/utils/jsonl.js.map +1 -1
- package/dist/utils/log-rotate.d.ts +14 -0
- package/dist/utils/log-rotate.d.ts.map +1 -0
- package/dist/utils/log-rotate.js +74 -0
- package/dist/utils/log-rotate.js.map +1 -0
- package/dist/utils/numeric-flag.d.ts +10 -2
- package/dist/utils/numeric-flag.d.ts.map +1 -1
- package/dist/utils/numeric-flag.js +17 -2
- package/dist/utils/numeric-flag.js.map +1 -1
- package/dist/utils/package-json.d.ts +49 -0
- package/dist/utils/package-json.d.ts.map +1 -0
- package/dist/utils/package-json.js +78 -0
- package/dist/utils/package-json.js.map +1 -0
- package/dist/utils/package-version.d.ts +5 -2
- package/dist/utils/package-version.d.ts.map +1 -1
- package/dist/utils/package-version.js +8 -11
- package/dist/utils/package-version.js.map +1 -1
- package/package.json +1 -6
- package/src/CONTEXT.md +12 -11
- package/src/__tests__/acceptance-gate.test.ts +23 -51
- package/src/__tests__/app-constraints-loader.test.ts +5 -7
- package/src/__tests__/checker-extra.test.ts +12 -80
- package/src/__tests__/checker-primitives-sdk.test.ts +3 -18
- package/src/__tests__/checker.test.ts +5 -7
- package/src/__tests__/checkpoint.test.ts +45 -59
- package/src/__tests__/context-files-resolution.test.ts +3 -2
- package/src/__tests__/contract-gate.test.ts +1 -33
- package/src/__tests__/cso-validator.test.ts +1 -9
- package/src/__tests__/effective-constraints.test.ts +1 -3
- package/src/__tests__/error-classifier.test.ts +1 -42
- package/src/__tests__/failure-recorder.test.ts +45 -114
- package/src/__tests__/install-precommit-hook.test.ts +61 -0
- package/src/__tests__/iron-laws.test.ts +14 -21
- package/src/__tests__/layering.test.ts +4 -4
- package/src/__tests__/project-config-loader.test.ts +2 -1
- package/src/__tests__/public-exports.test.ts +5 -16
- package/src/__tests__/public-type-surface.test.ts +10 -41
- package/src/__tests__/public-value-surface.test.ts +9 -20
- package/src/__tests__/review-gate.test.ts +0 -17
- package/src/__tests__/security-gate.test.ts +0 -18
- package/src/__tests__/skip-semantics.test.ts +9 -11
- package/src/__tests__/trace-analyzer-extra.test.ts +13 -129
- package/src/__tests__/trace-analyzer.test.ts +7 -7
- package/src/__tests__/trace-collector.test.ts +0 -43
- package/src/__tests__/traces.test.ts +7 -39
- package/src/agents/CONTEXT.md +2 -4
- package/src/agents/__tests__/lifecycle.test.ts +4 -155
- package/src/agents/index.ts +0 -3
- package/src/agents/lifecycle.ts +1 -116
- package/src/agents/types.ts +1 -21
- package/src/{hooks → bootstrap}/CONTEXT.md +5 -5
- package/src/{hooks → bootstrap}/bootstrap.ts +32 -39
- package/src/{hooks → bootstrap}/index.ts +3 -2
- package/src/cli/__tests__/command-contract.test.ts +18 -0
- package/src/cli/command-contract.ts +8 -5
- package/src/cli/commands/CONTEXT.md +21 -21
- package/src/cli/commands/__tests__/check-read-count.test.ts +4 -7
- package/src/cli/commands/__tests__/check-skip-output.test.ts +0 -1
- package/src/cli/commands/__tests__/check.test.ts +1 -1
- package/src/cli/commands/__tests__/command-gate-dead-options.test.ts +7 -5
- package/src/cli/commands/__tests__/constraints-pack-proposal.test.ts +0 -1
- package/src/cli/commands/__tests__/constraints-report.test.ts +2 -2
- package/src/cli/commands/__tests__/constraints-retire.test.ts +5 -3
- package/src/cli/commands/__tests__/contract.test.ts +11 -4
- package/src/cli/commands/__tests__/failure.test.ts +9 -9
- package/src/cli/commands/__tests__/init-governance-io.test.ts +7 -2
- package/src/cli/commands/__tests__/init.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge-audit-threshold.test.ts +14 -8
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +2 -1
- package/src/cli/commands/__tests__/knowledge-view.test.ts +52 -172
- package/src/cli/commands/__tests__/knowledge.test.ts +30 -6
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +3 -2
- package/src/cli/commands/__tests__/passes-gate.test.ts +105 -29
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +3 -6
- package/src/cli/commands/__tests__/project-path-convention.test.ts +4 -21
- package/src/cli/commands/__tests__/registry.test.ts +5 -2
- package/src/cli/commands/__tests__/release.test.ts +25 -3
- package/src/cli/commands/__tests__/report-false-green.test.ts +10 -6
- package/src/cli/commands/__tests__/review.test.ts +20 -6
- package/src/cli/commands/__tests__/security.test.ts +14 -0
- package/src/cli/commands/__tests__/spec-baseline-read-count.test.ts +2 -2
- package/src/cli/commands/__tests__/spec.test.ts +33 -23
- package/src/cli/commands/__tests__/validate.test.ts +32 -15
- package/src/cli/commands/acceptance.ts +11 -10
- package/src/cli/commands/check.ts +12 -6
- package/src/cli/commands/command.ts +8 -7
- package/src/cli/commands/constraints-pack-proposal.ts +10 -8
- package/src/cli/commands/constraints-reactivate.ts +13 -9
- package/src/cli/commands/constraints-retire.ts +33 -12
- package/src/cli/commands/contract.ts +33 -20
- package/src/cli/commands/definitions.ts +23 -94
- package/src/cli/commands/failure.ts +7 -8
- package/src/cli/commands/init/ci-platform.ts +66 -0
- package/src/cli/commands/init/ci-wiring.ts +48 -0
- package/src/cli/commands/init/git-hooks.ts +31 -0
- package/src/cli/commands/init/governance.ts +127 -0
- package/src/cli/commands/init/index.ts +156 -0
- package/src/cli/commands/init/output-style.ts +82 -0
- package/src/cli/commands/init/presets.ts +105 -0
- package/src/cli/commands/init/snippets.ts +57 -0
- package/src/cli/commands/knowledge/audit.ts +155 -0
- package/src/cli/commands/knowledge/decay.ts +57 -0
- package/src/cli/commands/knowledge/health.ts +180 -0
- package/src/cli/commands/knowledge/import.ts +82 -0
- package/src/cli/commands/knowledge/index.ts +60 -0
- package/src/cli/commands/knowledge/list.ts +73 -0
- package/src/cli/commands/knowledge/search.ts +92 -0
- package/src/cli/commands/knowledge/shared.ts +13 -0
- package/src/cli/commands/knowledge/snapshot.ts +38 -0
- package/src/cli/commands/knowledge/stats.ts +112 -0
- package/src/cli/commands/knowledge/store-access.ts +40 -0
- package/src/cli/commands/knowledge-view.ts +11 -34
- package/src/cli/commands/passes-gate.ts +23 -10
- package/src/cli/commands/performance.ts +2 -2
- package/src/cli/commands/release.ts +26 -22
- package/src/cli/commands/review.ts +19 -7
- package/src/cli/commands/security.ts +17 -11
- package/src/{core → cli/commands}/spec/__tests__/validator.test.ts +75 -61
- package/src/{core → cli/commands}/spec/validator.ts +65 -94
- package/src/cli/commands/spec-baseline-check.ts +37 -315
- package/src/cli/commands/spec.ts +15 -11
- package/src/cli/commands/status.ts +2 -4
- package/src/cli/commands/sync-docs/agents-syncer.ts +28 -47
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +14 -13
- package/src/cli/commands/sync-docs/compact.ts +36 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +15 -31
- package/src/cli/commands/sync-docs/gate.ts +78 -0
- package/src/cli/commands/sync-docs/index.ts +21 -585
- package/src/cli/commands/sync-docs/main-flow.ts +109 -0
- package/src/cli/commands/sync-docs/project-reader.ts +23 -25
- package/src/cli/commands/sync-docs/sync-output.ts +218 -0
- package/src/cli/commands/sync-docs/sync-state.ts +327 -0
- package/src/cli/commands/sync-docs/sync-writes.ts +49 -0
- package/src/cli/commands/validate.ts +13 -8
- package/src/cli/gate-command.ts +1 -1
- package/src/context/CONTEXT.md +6 -6
- package/src/context/__tests__/session-manager.test.ts +1 -41
- package/src/context/index.ts +1 -10
- package/src/context/session-manager.ts +30 -90
- package/src/context/types.ts +3 -38
- package/src/core/CONTEXT.md +11 -11
- package/src/core/app-constraints-loader.ts +5 -23
- package/src/core/constraint-lifecycle.ts +31 -40
- package/src/core/constraints/__tests__/check-cache.test.ts +2 -124
- package/src/core/constraints/__tests__/collect-constraints.test.ts +0 -6
- package/src/core/constraints/__tests__/run-env.test.ts +26 -114
- package/src/core/constraints/__tests__/triggers.test.ts +3 -2
- package/src/core/constraints/__tests__/usage-report.test.ts +3 -6
- package/src/core/constraints/capabilities-parser.ts +4 -6
- package/src/core/constraints/check-cache.ts +4 -70
- package/src/core/constraints/checker.ts +25 -75
- package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +0 -1
- package/src/core/constraints/checkers/__tests__/docs-freshness-degraded.test.ts +2 -0
- package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/input-contract.test.ts +1 -25
- package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +3 -2
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +3 -0
- package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/templated-checkers.test.ts +1 -0
- package/src/core/constraints/checkers/__tests__/templates-registry.test.ts +0 -2
- package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +1 -0
- package/src/core/constraints/checkers/capability-sync.ts +2 -2
- package/src/core/constraints/checkers/context-doc-sync.ts +1 -1
- package/src/core/constraints/checkers/docs-freshness.ts +1 -1
- package/src/core/constraints/checkers/index.ts +21 -8
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +5 -32
- package/src/core/constraints/checkers/no-test-simplification.ts +10 -32
- package/src/core/constraints/checkers/templated/exec.ts +2 -7
- package/src/core/constraints/checkers/templated/file-exists.ts +1 -1
- package/src/core/constraints/checkers/templated/regex-scan.ts +6 -25
- package/src/core/constraints/checkers/types.ts +12 -65
- package/src/core/constraints/context-builder.ts +11 -102
- package/src/core/constraints/definitions/{iron-laws.ts → errors.ts} +0 -21
- package/src/core/constraints/definitions/{guidelines.ts → warnings.ts} +18 -4
- package/src/core/constraints/definitions.ts +4 -3
- package/src/core/constraints/doc-freshness/runner.ts +201 -232
- package/src/core/constraints/find-constraint.ts +24 -0
- package/src/core/constraints/git-evidence.ts +2 -0
- package/src/core/constraints/governance-accessors.ts +74 -0
- package/src/core/constraints/index.ts +0 -5
- package/src/core/constraints/injection-writer.ts +3 -6
- package/src/core/constraints/pack-proposal.ts +4 -15
- package/src/core/constraints/run-env.ts +1 -26
- package/src/core/constraints/triggers.ts +11 -6
- package/src/core/constraints/usage-report.ts +0 -9
- package/src/core/index.ts +5 -10
- package/src/core/project-config-loader.ts +5 -67
- package/src/core/spec/baseline-check.ts +300 -0
- package/src/core/validators/__tests__/http-retry-sleep.test.ts +1 -1
- package/src/core/validators/__tests__/passes-gate-counts.test.ts +52 -0
- package/src/core/validators/check-handlers/command.ts +9 -6
- package/src/core/validators/check-handlers/file.ts +48 -5
- package/src/core/validators/check-handlers/http.ts +8 -6
- package/src/core/validators/check-handlers/output.ts +7 -6
- package/src/core/validators/checkpoint.ts +52 -85
- package/src/core/validators/cso.ts +1 -12
- package/src/core/validators/passes-gate.ts +27 -38
- package/src/failure/CONTEXT.md +1 -1
- package/src/failure/__tests__/recorder.test.ts +2 -1
- package/src/failure/classifier.ts +2 -42
- package/src/failure/error-types.ts +122 -0
- package/src/failure/index.ts +9 -9
- package/src/failure/recorder.ts +12 -77
- package/src/gates/CONTEXT.md +9 -10
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +16 -14
- package/src/gates/__tests__/acceptance.test.ts +69 -94
- package/src/gates/__tests__/command-single-predicate.test.ts +16 -61
- package/src/gates/__tests__/command.test.ts +23 -25
- package/src/gates/__tests__/gate-interface.test.ts +5 -10
- package/src/gates/__tests__/performance.test.ts +8 -54
- package/src/gates/__tests__/review.test.ts +27 -50
- package/src/gates/__tests__/security-default-scan.test.ts +6 -3
- package/src/gates/__tests__/security.test.ts +30 -61
- package/src/gates/acceptance.ts +199 -156
- package/src/gates/command.ts +1 -34
- package/src/gates/contract.ts +83 -93
- package/src/gates/definitions.ts +1 -1
- package/src/gates/performance.ts +36 -43
- package/src/gates/registry.ts +4 -3
- package/src/gates/review.ts +68 -31
- package/src/gates/security.ts +69 -96
- package/src/gates/types.ts +22 -84
- package/src/index.ts +11 -32
- package/src/knowledge/CONTEXT.md +21 -25
- package/src/knowledge/__tests__/audit-labels.test.ts +3 -3
- package/src/knowledge/__tests__/audit-scoring.test.ts +9 -7
- package/src/knowledge/__tests__/audit.test.ts +1 -1
- package/src/knowledge/__tests__/import.test.ts +1 -1
- package/src/knowledge/__tests__/ingest-validate-entry.test.ts +235 -0
- package/src/knowledge/__tests__/ingest.test.ts +19 -20
- package/src/knowledge/__tests__/store.test.ts +6 -10
- package/src/knowledge/__tests__/tree-walker.test.ts +5 -13
- package/src/knowledge/audit-dimensions.ts +190 -0
- package/src/knowledge/audit-rules.ts +339 -0
- package/src/knowledge/audit-scoring.ts +7 -495
- package/src/knowledge/audit.ts +12 -12
- package/src/knowledge/{import.ts → cold-start.ts} +150 -192
- package/src/knowledge/index-generator.ts +48 -53
- package/src/knowledge/index.ts +6 -11
- package/src/knowledge/ingest.ts +137 -19
- package/src/knowledge/lifecycle.ts +28 -38
- package/src/knowledge/query.ts +8 -7
- package/src/knowledge/store.ts +29 -66
- package/src/knowledge/types.ts +2 -48
- package/src/monitoring/CONTEXT.md +3 -3
- package/src/monitoring/__tests__/skipped-lines-report.test.ts +3 -16
- package/src/monitoring/__tests__/traces.test.ts +1 -27
- package/src/monitoring/analyzer-base.ts +1 -28
- package/src/monitoring/trace-analyzer.ts +12 -168
- package/src/monitoring/traces.ts +11 -35
- package/src/pretool-use-hook.ts +26 -21
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +0 -2
- package/src/release/integrity.ts +8 -9
- package/src/sdd/index-generator.ts +4 -0
- package/src/types/checkpoint.ts +8 -8
- package/src/types/command-definition.ts +85 -0
- package/src/types/command-io.ts +14 -0
- package/src/types/constraint.ts +3 -32
- package/src/types/failure.ts +7 -113
- package/src/types/gate.ts +77 -0
- package/src/types/spec.ts +0 -4
- package/src/types/trace.ts +0 -6
- package/src/utils/__tests__/attempt.test.ts +94 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +4 -7
- package/src/utils/__tests__/package-json.test.ts +58 -0
- package/src/utils/__tests__/package-version.test.ts +21 -2
- package/src/utils/attempt.ts +35 -0
- package/src/utils/clip.ts +12 -0
- package/src/utils/detect-source-roots.ts +38 -44
- package/src/utils/diff-parse.ts +80 -0
- package/src/utils/file-walk.ts +3 -7
- package/src/utils/guards.ts +8 -0
- package/src/utils/jsonl.ts +0 -30
- package/src/utils/log-rotate.ts +43 -0
- package/src/utils/numeric-flag.ts +24 -2
- package/src/utils/package-json.ts +61 -0
- package/src/utils/package-version.ts +8 -10
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -502
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/knowledge.d.ts +0 -169
- package/dist/cli/commands/knowledge.d.ts.map +0 -1
- package/dist/cli/commands/knowledge.js +0 -700
- package/dist/cli/commands/knowledge.js.map +0 -1
- package/dist/context/knowledge-injector.d.ts +0 -51
- package/dist/context/knowledge-injector.d.ts.map +0 -1
- package/dist/context/knowledge-injector.js +0 -128
- package/dist/context/knowledge-injector.js.map +0 -1
- package/dist/core/constraints/checkers/templates-registry.d.ts +0 -18
- package/dist/core/constraints/checkers/templates-registry.d.ts.map +0 -1
- package/dist/core/constraints/checkers/templates-registry.js +0 -25
- package/dist/core/constraints/checkers/templates-registry.js.map +0 -1
- package/dist/core/constraints/definitions/guidelines.d.ts.map +0 -1
- package/dist/core/constraints/definitions/guidelines.js.map +0 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +0 -1
- package/dist/core/constraints/definitions/iron-laws.js.map +0 -1
- package/dist/core/spec/validator.d.ts.map +0 -1
- package/dist/core/spec/validator.js.map +0 -1
- package/dist/gates/checker-gate.d.ts +0 -27
- package/dist/gates/checker-gate.d.ts.map +0 -1
- package/dist/gates/checker-gate.js +0 -52
- package/dist/gates/checker-gate.js.map +0 -1
- package/dist/gates/index.d.ts +0 -10
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -11
- package/dist/gates/index.js.map +0 -1
- package/dist/hooks/bootstrap.d.ts.map +0 -1
- package/dist/hooks/bootstrap.js.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/knowledge/doctor.d.ts +0 -37
- package/dist/knowledge/doctor.d.ts.map +0 -1
- package/dist/knowledge/doctor.js +0 -81
- package/dist/knowledge/doctor.js.map +0 -1
- package/dist/knowledge/import.d.ts.map +0 -1
- package/dist/knowledge/import.js.map +0 -1
- package/dist/knowledge/lint.d.ts +0 -90
- package/dist/knowledge/lint.d.ts.map +0 -1
- package/dist/knowledge/lint.js +0 -412
- package/dist/knowledge/lint.js.map +0 -1
- package/dist/knowledge/migration.d.ts +0 -28
- package/dist/knowledge/migration.d.ts.map +0 -1
- package/dist/knowledge/migration.js +0 -105
- package/dist/knowledge/migration.js.map +0 -1
- package/dist/knowledge/reference-tracker.d.ts +0 -31
- package/dist/knowledge/reference-tracker.d.ts.map +0 -1
- package/dist/knowledge/reference-tracker.js +0 -125
- package/dist/knowledge/reference-tracker.js.map +0 -1
- package/src/__tests__/spec-validator.test.ts +0 -58
- package/src/cli/commands/init.ts +0 -590
- package/src/cli/commands/knowledge.ts +0 -820
- package/src/context/__tests__/knowledge-injector.test.ts +0 -197
- package/src/context/knowledge-injector.ts +0 -174
- package/src/core/constraints/checkers/templates-registry.ts +0 -24
- package/src/gates/__tests__/checker-gate.test.ts +0 -86
- package/src/gates/checker-gate.ts +0 -52
- package/src/gates/index.ts +0 -11
- package/src/knowledge/__tests__/doctor.test.ts +0 -300
- package/src/knowledge/__tests__/lint.test.ts +0 -536
- package/src/knowledge/__tests__/migration.test.ts +0 -185
- package/src/knowledge/__tests__/reference-tracker.test.ts +0 -169
- package/src/knowledge/doctor.ts +0 -103
- package/src/knowledge/lint.ts +0 -460
- package/src/knowledge/migration.ts +0 -82
- package/src/knowledge/reference-tracker.ts +0 -101
- /package/src/{hooks → bootstrap}/__tests__/bootstrap.test.ts +0 -0
package/src/knowledge/ingest.ts
CHANGED
|
@@ -11,13 +11,36 @@ import type {
|
|
|
11
11
|
IngestOptions,
|
|
12
12
|
SourceRef,
|
|
13
13
|
} from './types';
|
|
14
|
+
import { MATURITY_LEVELS, STORAGE_LAYERS } from './types';
|
|
14
15
|
import type { KnowledgeStore } from './store';
|
|
15
16
|
import { KnowledgeAudit } from './audit';
|
|
17
|
+
import { MAX_SOURCE_REFS } from './audit-rules';
|
|
16
18
|
import { splitFrontmatter } from '../utils/frontmatter';
|
|
17
19
|
|
|
18
|
-
const MAX_SOURCE_REFS = 20;
|
|
19
20
|
const MAX_EXTERNAL_CONTENT_LENGTH = 5000;
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* `validateEntry` 的一条摄入前校验问题(lint.ts 删除后的保种落点,ADR-0040 Phase 4)。
|
|
24
|
+
* severity='high' 按阻断处理(拒收),其余为提示。
|
|
25
|
+
*/
|
|
26
|
+
export interface IngestValidationIssue {
|
|
27
|
+
severity: 'low' | 'medium' | 'high';
|
|
28
|
+
description: string;
|
|
29
|
+
suggestion: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `ingestEntry` / `ingestBatch` / `ingestExternal` 的返回(判别联合):
|
|
34
|
+
* - `accepted`:已落盘(新建或去重合并),`entry` 为最终形态
|
|
35
|
+
* - `rejected`:审计质量门拒收、未落盘,`reasons` 为逐条拒绝理由
|
|
36
|
+
*
|
|
37
|
+
* 原实现把 `__rejected` / `__rejectReasons` 经 `as any` 偷挂在返回条目上——
|
|
38
|
+
* 类型面看不见、全仓零消费点(Phase 4 any 清零时核实),改为显式判别联合。
|
|
39
|
+
*/
|
|
40
|
+
export type IngestResult =
|
|
41
|
+
| { status: 'accepted'; entry: KnowledgeEntry }
|
|
42
|
+
| { status: 'rejected'; entry: KnowledgeEntry; reasons: string[] };
|
|
43
|
+
|
|
21
44
|
/** Known prompt injection patterns to strip from external content */
|
|
22
45
|
const INJECTION_PATTERNS = [
|
|
23
46
|
/ignore\s+(all\s+)?previous\s+instructions/gi,
|
|
@@ -62,12 +85,12 @@ export class KnowledgeIngest {
|
|
|
62
85
|
/**
|
|
63
86
|
* Ingest a single knowledge entry.
|
|
64
87
|
* Auto-fills id, created, maturity, and other defaults.
|
|
65
|
-
* Returns
|
|
88
|
+
* Returns a discriminated result: accepted = saved (new or merged), rejected = audit gate refusal.
|
|
66
89
|
*/
|
|
67
90
|
ingestEntry(
|
|
68
91
|
partial: Partial<KnowledgeEntry>,
|
|
69
92
|
options: IngestOptions,
|
|
70
|
-
):
|
|
93
|
+
): IngestResult {
|
|
71
94
|
const entry = this.buildEntry(partial, options);
|
|
72
95
|
|
|
73
96
|
// Quality gate: audit before saving
|
|
@@ -75,10 +98,8 @@ export class KnowledgeIngest {
|
|
|
75
98
|
let issues = audit.validate(entry);
|
|
76
99
|
const critical = issues.filter(i => i.action === 'reject');
|
|
77
100
|
if (critical.length > 0) {
|
|
78
|
-
// Reject: return
|
|
79
|
-
|
|
80
|
-
(entry as any).__rejectReasons = critical.map(i => i.detail);
|
|
81
|
-
return entry;
|
|
101
|
+
// Reject: return without saving; caller branches on status / reasons
|
|
102
|
+
return { status: 'rejected', entry, reasons: critical.map(i => i.detail) };
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
// If caller explicitly set maturity, skip demote actions from audit.
|
|
@@ -91,7 +112,7 @@ export class KnowledgeIngest {
|
|
|
91
112
|
const existing = this.findDuplicate(entry.title, entry.content, entry.type);
|
|
92
113
|
if (existing) {
|
|
93
114
|
// Merge: update existing entry with new content and metadata
|
|
94
|
-
return this.mergeEntries(existing, entry, options);
|
|
115
|
+
return { status: 'accepted', entry: this.mergeEntries(existing, entry, options) };
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
this.store.save(entry);
|
|
@@ -113,17 +134,17 @@ export class KnowledgeIngest {
|
|
|
113
134
|
}
|
|
114
135
|
}
|
|
115
136
|
|
|
116
|
-
return entry;
|
|
137
|
+
return { status: 'accepted', entry };
|
|
117
138
|
}
|
|
118
139
|
|
|
119
140
|
/**
|
|
120
141
|
* Ingest multiple entries in batch.
|
|
121
|
-
* Returns
|
|
142
|
+
* Returns one result per input (accepted/rejected).
|
|
122
143
|
*/
|
|
123
144
|
ingestBatch(
|
|
124
145
|
partials: Partial<KnowledgeEntry>[],
|
|
125
146
|
options: IngestOptions,
|
|
126
|
-
):
|
|
147
|
+
): IngestResult[] {
|
|
127
148
|
return partials.map(p => this.ingestEntry(p, options));
|
|
128
149
|
}
|
|
129
150
|
|
|
@@ -136,7 +157,7 @@ export class KnowledgeIngest {
|
|
|
136
157
|
ingestExternal(
|
|
137
158
|
partial: Partial<KnowledgeEntry>,
|
|
138
159
|
options: Omit<IngestOptions, 'origin'> & { fullContentPath?: string },
|
|
139
|
-
):
|
|
160
|
+
): IngestResult {
|
|
140
161
|
const sanitizedContent = sanitizeExternalContent(partial.content || '');
|
|
141
162
|
return this.ingestEntry(
|
|
142
163
|
{ ...partial, content: sanitizedContent },
|
|
@@ -144,6 +165,103 @@ export class KnowledgeIngest {
|
|
|
144
165
|
);
|
|
145
166
|
}
|
|
146
167
|
|
|
168
|
+
/**
|
|
169
|
+
* 摄入前单条校验(KnowledgeLinter.validateEntry 的保种落点,ADR-0040 Phase 4;
|
|
170
|
+
* 原 lint.ts 随 audit 正本收口删除)。返回空数组 = 可摄入。
|
|
171
|
+
*
|
|
172
|
+
* 检查项:
|
|
173
|
+
* - maturity/layer 未声明枚举值 → high(字段缺省跳过,兼容只传四字段的
|
|
174
|
+
* pre-ingest 调用方;存量枚举扫描由 audit 覆盖)
|
|
175
|
+
* - content < 20 字符 → high(疑似 LLM 幻觉,拒收)
|
|
176
|
+
* - title 过于宽泛(只有症状词)→ medium
|
|
177
|
+
* - 与同 type、共享 ≥2 tag 的 proven 条目矛盾风险 → high
|
|
178
|
+
* - 与存量条目标题精确重复 / 互相包含 → medium / low
|
|
179
|
+
*/
|
|
180
|
+
validateEntry(entry: { title: string; content: string; tags: string[]; type: string; maturity?: string; layer?: string }): IngestValidationIssue[] {
|
|
181
|
+
const issues: IngestValidationIssue[] = [];
|
|
182
|
+
|
|
183
|
+
// 未声明枚举值(字段缺省跳过)
|
|
184
|
+
if (entry.maturity !== undefined && !(MATURITY_LEVELS as readonly string[]).includes(entry.maturity)) {
|
|
185
|
+
issues.push({
|
|
186
|
+
severity: 'high',
|
|
187
|
+
description: `maturity "${entry.maturity}" is not a declared value (${MATURITY_LEVELS.join(' | ')}).`,
|
|
188
|
+
suggestion: 'Map to a declared maturity (e.g. pending → draft) before writing; the store write gate rejects undeclared values.',
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (entry.layer !== undefined && !(STORAGE_LAYERS as readonly string[]).includes(entry.layer)) {
|
|
192
|
+
issues.push({
|
|
193
|
+
severity: 'high',
|
|
194
|
+
description: `layer "${entry.layer}" is not a declared value (${STORAGE_LAYERS.join(' | ')}).`,
|
|
195
|
+
suggestion: 'Map to a declared layer or drop the field; the store write gate rejects undeclared values.',
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Content too short
|
|
200
|
+
if ((entry.content || '').length < 20) {
|
|
201
|
+
issues.push({
|
|
202
|
+
severity: 'high',
|
|
203
|
+
description: `Content too short (${entry.content.length} chars). LLM may have hallucinated.`,
|
|
204
|
+
suggestion: 'Reject — re-extract with better prompt or discard.',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Title too vague
|
|
209
|
+
const vaguePatterns = /^(错误|失败|问题|异常|bug|error|fail|issue|problem|unknown|untitled)$/i;
|
|
210
|
+
if (vaguePatterns.test(entry.title.trim())) {
|
|
211
|
+
issues.push({
|
|
212
|
+
severity: 'medium',
|
|
213
|
+
description: `Title "${entry.title}" is too vague to be useful.`,
|
|
214
|
+
suggestion: 'Re-extract with root cause in title, not symptom.',
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Contradicts proven entry with same tags
|
|
219
|
+
if (entry.tags && entry.tags.length > 0) {
|
|
220
|
+
const allEntries = this.store.list({ excludeArchived: false });
|
|
221
|
+
for (const existing of allEntries) {
|
|
222
|
+
if (existing.maturity !== 'proven') continue;
|
|
223
|
+
if (existing.type !== entry.type) continue;
|
|
224
|
+
const sharedTags = entry.tags.filter(t => existing.tags.includes(t));
|
|
225
|
+
if (sharedTags.length >= 2) {
|
|
226
|
+
issues.push({
|
|
227
|
+
severity: 'high',
|
|
228
|
+
description: `New entry "${entry.title}" shares tags [${sharedTags.join(', ')}] with proven entry "${existing.title}" (${existing.id}). Contradiction risk.`,
|
|
229
|
+
suggestion: `Review against ${existing.id}. If aligned, merge. If contradictory, flag for human review.`,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Near-duplicate title check (simple: case-insensitive substring match)
|
|
236
|
+
if (entry.title.length > 10) {
|
|
237
|
+
const allEntries = this.store.list({ excludeArchived: false });
|
|
238
|
+
for (const existing of allEntries) {
|
|
239
|
+
if (existing.id === entry.title) continue; // not same entry (entry doesn't have id yet)
|
|
240
|
+
const existingTitle = (existing.title || '').toLowerCase();
|
|
241
|
+
const newTitle = (entry.title || '').toLowerCase();
|
|
242
|
+
if (existingTitle === newTitle) {
|
|
243
|
+
issues.push({
|
|
244
|
+
severity: 'medium',
|
|
245
|
+
description: `Exact title match with existing entry "${existing.title}" (${existing.id}).`,
|
|
246
|
+
suggestion: `Merge into ${existing.id} instead of creating duplicate.`,
|
|
247
|
+
});
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
// Check high similarity (either title contains the other)
|
|
251
|
+
if (existingTitle.includes(newTitle) || newTitle.includes(existingTitle)) {
|
|
252
|
+
issues.push({
|
|
253
|
+
severity: 'low',
|
|
254
|
+
description: `Title similarity with existing "${existing.title}" (${existing.id}).`,
|
|
255
|
+
suggestion: `Consider merging with ${existing.id}.`,
|
|
256
|
+
});
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return issues;
|
|
263
|
+
}
|
|
264
|
+
|
|
147
265
|
// ── Internal ───────────────────────────────────────────────
|
|
148
266
|
|
|
149
267
|
private buildEntry(
|
|
@@ -151,7 +269,7 @@ export class KnowledgeIngest {
|
|
|
151
269
|
options: IngestOptions,
|
|
152
270
|
): KnowledgeEntry {
|
|
153
271
|
const now = new Date().toISOString();
|
|
154
|
-
const type = partial.type ||
|
|
272
|
+
const type = partial.type || 'guideline';
|
|
155
273
|
const id = partial.id || this.generateId(type);
|
|
156
274
|
|
|
157
275
|
return {
|
|
@@ -187,11 +305,6 @@ export class KnowledgeIngest {
|
|
|
187
305
|
return `${prefix}-${seq}`;
|
|
188
306
|
}
|
|
189
307
|
|
|
190
|
-
private inferType(_options: IngestOptions): KnowledgeSubsystem {
|
|
191
|
-
// Default to 'guideline' if type can't be inferred
|
|
192
|
-
return 'guideline';
|
|
193
|
-
}
|
|
194
|
-
|
|
195
308
|
private findDuplicate(title: string, content: string, type: KnowledgeSubsystem): KnowledgeEntry | undefined {
|
|
196
309
|
// A1: Read from disk directly to avoid stale index causing dedup failure
|
|
197
310
|
const all = this.store.readEntriesFromDisk().filter(e => e.type === type);
|
|
@@ -282,7 +395,12 @@ export class KnowledgeIngest {
|
|
|
282
395
|
tags: [...new Set([...existing.tags, ...incoming.tags])],
|
|
283
396
|
sourceReferences: [...existing.sourceReferences, ...incoming.sourceReferences].slice(-MAX_SOURCE_REFS),
|
|
284
397
|
};
|
|
285
|
-
|
|
398
|
+
// fail-fast:刚经 readEntriesFromDisk 读到的条目 update 不到 = 并发删除/索引漂移,不静默吞
|
|
399
|
+
const updated = this.store.update(existing.id, merged);
|
|
400
|
+
if (!updated) {
|
|
401
|
+
throw new Error(`mergeEntries: 条目 ${existing.id} 落盘更新失败(读得到写不回)`);
|
|
402
|
+
}
|
|
403
|
+
return updated;
|
|
286
404
|
}
|
|
287
405
|
|
|
288
406
|
private defaultSourceRef(source: string): SourceRef[] {
|
|
@@ -14,10 +14,11 @@ import type {
|
|
|
14
14
|
} from './types';
|
|
15
15
|
import { DEFAULT_DECAY_CONFIG } from './types';
|
|
16
16
|
import type { KnowledgeStore } from './store';
|
|
17
|
+
import { TEST_ID_PATTERN } from './audit-rules';
|
|
18
|
+
import { attempt } from '../utils/attempt';
|
|
17
19
|
|
|
18
20
|
const MAX_REFERENCED_BY = 20;
|
|
19
21
|
const MIN_CONTENT_FOR_PROVEN = 100;
|
|
20
|
-
const TEST_ID_PATTERN = /^(test-|inj-test)/;
|
|
21
22
|
const SIGNAL_SATURATION_THRESHOLD = 3;
|
|
22
23
|
const CONTEXT_DECAY_MONTHS = 3;
|
|
23
24
|
const RULE_MIN_RESULTS_FOR_DECAY = 3;
|
|
@@ -70,7 +71,7 @@ export class KnowledgeLifecycle {
|
|
|
70
71
|
// But still record execution result if provided
|
|
71
72
|
if (success !== undefined) {
|
|
72
73
|
const executionResults = [
|
|
73
|
-
...(entry.executionResults
|
|
74
|
+
...(entry.executionResults),
|
|
74
75
|
{ contributor: contributor || 'unknown', success, timestamp: now, source: execSource },
|
|
75
76
|
].slice(-MAX_REFERENCED_BY);
|
|
76
77
|
this.store.update(entryId, { executionResults });
|
|
@@ -80,7 +81,7 @@ export class KnowledgeLifecycle {
|
|
|
80
81
|
|
|
81
82
|
const referencedBy = [...entry.referencedBy, refKey].slice(-MAX_REFERENCED_BY);
|
|
82
83
|
const executionResults = success !== undefined
|
|
83
|
-
? [...(entry.executionResults
|
|
84
|
+
? [...(entry.executionResults), { contributor: contributor || 'unknown', success, timestamp: now, source: execSource }].slice(-MAX_REFERENCED_BY)
|
|
84
85
|
: entry.executionResults;
|
|
85
86
|
|
|
86
87
|
const updated = this.store.update(entryId, {
|
|
@@ -92,9 +93,8 @@ export class KnowledgeLifecycle {
|
|
|
92
93
|
|
|
93
94
|
// Fire consumption event callbacks
|
|
94
95
|
for (const cb of this.onReferenceCallbacks) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
} catch { /* non-blocking */ }
|
|
96
|
+
// 显式 fail-open(attempt):消费回调是外挂监听,崩了不拖死引用记账主流程
|
|
97
|
+
attempt(() => cb({ entryId, contributor: contributor || 'unknown', timestamp: now, success }), () => undefined);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
return updated;
|
|
@@ -117,7 +117,7 @@ export class KnowledgeLifecycle {
|
|
|
117
117
|
// RC2: block test entries from any promotion
|
|
118
118
|
if (TEST_ID_PATTERN.test(entryId)) return undefined;
|
|
119
119
|
|
|
120
|
-
const mode = entry.consumptionMode
|
|
120
|
+
const mode = entry.consumptionMode;
|
|
121
121
|
|
|
122
122
|
switch (mode) {
|
|
123
123
|
case 'rule': return this.checkRulePromotion(entry);
|
|
@@ -143,7 +143,7 @@ export class KnowledgeLifecycle {
|
|
|
143
143
|
return 'archived';
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
const mode = entry.consumptionMode
|
|
146
|
+
const mode = entry.consumptionMode;
|
|
147
147
|
|
|
148
148
|
switch (mode) {
|
|
149
149
|
case 'rule': return this.checkRuleDecay(entry);
|
|
@@ -226,14 +226,13 @@ export class KnowledgeLifecycle {
|
|
|
226
226
|
// Emit event for downstream consumers
|
|
227
227
|
const now = new Date().toISOString();
|
|
228
228
|
for (const cb of this.onReferenceCallbacks) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
} catch { /* non-blocking */ }
|
|
229
|
+
// 显式 fail-open(attempt):外挂监听回调失败不拖死标记主流程
|
|
230
|
+
attempt(() => cb({
|
|
231
|
+
entryId,
|
|
232
|
+
contributor: 'lifecycle',
|
|
233
|
+
timestamp: now,
|
|
234
|
+
context: 'skillCandidate:marked',
|
|
235
|
+
}), () => undefined);
|
|
237
236
|
}
|
|
238
237
|
|
|
239
238
|
return true;
|
|
@@ -277,14 +276,13 @@ export class KnowledgeLifecycle {
|
|
|
277
276
|
// Emit event for downstream consumers
|
|
278
277
|
const now = new Date().toISOString();
|
|
279
278
|
for (const cb of this.onReferenceCallbacks) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
} catch { /* non-blocking */ }
|
|
279
|
+
// 显式 fail-open(attempt):外挂监听回调失败不拖死标记主流程
|
|
280
|
+
attempt(() => cb({
|
|
281
|
+
entryId,
|
|
282
|
+
contributor: 'lifecycle',
|
|
283
|
+
timestamp: now,
|
|
284
|
+
context: 'constraintCandidate:marked',
|
|
285
|
+
}), () => undefined);
|
|
288
286
|
}
|
|
289
287
|
|
|
290
288
|
return true;
|
|
@@ -320,21 +318,13 @@ export class KnowledgeLifecycle {
|
|
|
320
318
|
return false;
|
|
321
319
|
}
|
|
322
320
|
|
|
323
|
-
/**
|
|
324
|
-
* Check if a source should auto-promote to verified on ingest.
|
|
325
|
-
* Used by KnowledgeBus to decide initial maturity level.
|
|
326
|
-
*/
|
|
327
|
-
shouldAutoPromote(source: string): boolean {
|
|
328
|
-
return this.config.autoPromoteSources.some(s => source.includes(s));
|
|
329
|
-
}
|
|
330
|
-
|
|
331
321
|
/**
|
|
332
322
|
* Get execution success rate for an entry.
|
|
333
323
|
* Returns { rate, total } or undefined if no execution data.
|
|
334
324
|
*/
|
|
335
325
|
getExecutionSuccessRate(entryId: string): { rate: number; total: number } | undefined {
|
|
336
326
|
const entry = this.store.get(entryId);
|
|
337
|
-
if (!entry ||
|
|
327
|
+
if (!entry || entry.executionResults.length === 0) return undefined;
|
|
338
328
|
const total = entry.executionResults.length;
|
|
339
329
|
const successes = entry.executionResults.filter(r => r.success).length;
|
|
340
330
|
return { rate: successes / total, total };
|
|
@@ -346,7 +336,7 @@ export class KnowledgeLifecycle {
|
|
|
346
336
|
*/
|
|
347
337
|
getHumanSuccessRate(entryId: string): { rate: number; total: number } | undefined {
|
|
348
338
|
const entry = this.store.get(entryId);
|
|
349
|
-
if (!entry ||
|
|
339
|
+
if (!entry || entry.executionResults.length === 0) return undefined;
|
|
350
340
|
const humanResults = entry.executionResults.filter(r => r.source === 'human');
|
|
351
341
|
if (humanResults.length === 0) return undefined;
|
|
352
342
|
const total = humanResults.length;
|
|
@@ -378,8 +368,8 @@ export class KnowledgeLifecycle {
|
|
|
378
368
|
const execRate = this.getExecutionSuccessRate(entry.id);
|
|
379
369
|
if (execRate && execRate.total >= 3 && execRate.rate >= 0.8) return 'proven';
|
|
380
370
|
if (entry.contributors.length >= 3 && entry.projects.length >= 2) return 'proven';
|
|
381
|
-
const refCount = entry.referencedBy
|
|
382
|
-
const distinctSources = new Set(entry.sourceReferences
|
|
371
|
+
const refCount = entry.referencedBy.length;
|
|
372
|
+
const distinctSources = new Set(entry.sourceReferences.map(s => s.workflow).filter(Boolean));
|
|
383
373
|
if (refCount >= 3 && distinctSources.size >= 2) return 'proven';
|
|
384
374
|
return undefined;
|
|
385
375
|
}
|
|
@@ -442,7 +432,7 @@ export class KnowledgeLifecycle {
|
|
|
442
432
|
*/
|
|
443
433
|
private checkSignalDecay(entry: KnowledgeEntry): MaturityLevel | undefined {
|
|
444
434
|
if (entry.maturity !== 'active') return undefined;
|
|
445
|
-
const refCount = entry.referencedBy
|
|
435
|
+
const refCount = entry.referencedBy.length;
|
|
446
436
|
if (refCount < SIGNAL_SATURATION_THRESHOLD) return undefined;
|
|
447
437
|
|
|
448
438
|
const newer = this.store.list({
|
|
@@ -450,7 +440,7 @@ export class KnowledgeLifecycle {
|
|
|
450
440
|
excludeArchived: false,
|
|
451
441
|
}).find(e =>
|
|
452
442
|
e.id !== entry.id &&
|
|
453
|
-
|
|
443
|
+
e.consumptionMode === 'signal' &&
|
|
454
444
|
e.created > entry.created
|
|
455
445
|
);
|
|
456
446
|
if (newer) return 'archived';
|
package/src/knowledge/query.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
import type { KnowledgeStore } from './store';
|
|
17
17
|
import { KnowledgeLifecycle } from './lifecycle';
|
|
18
18
|
import { estimateTokens } from './token-estimate';
|
|
19
|
+
import { attempt } from '../utils/attempt';
|
|
19
20
|
|
|
20
21
|
// ── Constants ──────────────────────────────────────────────
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@ const CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* 外部来源条目的 prompt 标记(harness#161:三层防御第二层 marking 的唯一正本)。
|
|
26
|
-
* `KnowledgeQuery.formatForPrompt()`
|
|
27
|
+
* `KnowledgeQuery.formatForPrompt()` 与下游编排消费方的注入格式化共用同一常量,
|
|
27
28
|
* 仓内不允许存在第二份字面量。
|
|
28
29
|
*/
|
|
29
30
|
export const EXTERNAL_SOURCE_MARKER = '[External Source — verify before acting]';
|
|
@@ -86,9 +87,8 @@ export class KnowledgeQuery {
|
|
|
86
87
|
|
|
87
88
|
// P2a: Record references for all returned entries (drives maturity ladder)
|
|
88
89
|
for (const entry of entries) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} catch { /* non-blocking */ }
|
|
90
|
+
// 显式 fail-open(attempt):引用记账是查询的副作用,失败不影响查询结果返回
|
|
91
|
+
attempt(() => this.lifecycle.recordReference(entry.id), () => undefined);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
return result;
|
|
@@ -162,7 +162,7 @@ export class KnowledgeQuery {
|
|
|
162
162
|
// signal 条目原三次 queryByMode 均不取,分组后同样不消费)
|
|
163
163
|
const grouped: Record<ConsumptionMode, KnowledgeEntry[]> = { rule: [], reference: [], context: [], signal: [] };
|
|
164
164
|
for (const entry of this.store.list({})) {
|
|
165
|
-
grouped[entry.consumptionMode
|
|
165
|
+
grouped[entry.consumptionMode].push(entry);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
const rules = grouped.rule;
|
|
@@ -173,8 +173,9 @@ export class KnowledgeQuery {
|
|
|
173
173
|
: allRefs.slice(0, 3);
|
|
174
174
|
|
|
175
175
|
const allContext = grouped.context;
|
|
176
|
-
const
|
|
177
|
-
|
|
176
|
+
const phase = taskContext.phase;
|
|
177
|
+
const context = phase
|
|
178
|
+
? allContext.filter(e => e.applicablePhases.includes(phase))
|
|
178
179
|
: allContext;
|
|
179
180
|
|
|
180
181
|
return { rules, references, context };
|
package/src/knowledge/store.ts
CHANGED
|
@@ -24,14 +24,6 @@ const DEFAULT_DIR = '.harness/knowledge';
|
|
|
24
24
|
const INDEX_FILE = 'index.json';
|
|
25
25
|
const CONSUMPTION_STATS_FILE = '.consumption-stats.json';
|
|
26
26
|
|
|
27
|
-
interface StoreConfig {
|
|
28
|
-
baseDir: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const DEFAULT_CONFIG: StoreConfig = {
|
|
32
|
-
baseDir: DEFAULT_DIR,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
27
|
/**
|
|
36
28
|
* KnowledgeStore interface — abstract contract for knowledge storage.
|
|
37
29
|
*/
|
|
@@ -81,8 +73,8 @@ export class FileKnowledgeStore implements KnowledgeStore {
|
|
|
81
73
|
*/
|
|
82
74
|
private indexCache: { mtimeMs: number; size: number; entries: IndexEntry[] } | undefined;
|
|
83
75
|
|
|
84
|
-
constructor(config?:
|
|
85
|
-
this.baseDir = config?.baseDir ||
|
|
76
|
+
constructor(config?: { baseDir?: string }) {
|
|
77
|
+
this.baseDir = config?.baseDir || DEFAULT_DIR;
|
|
86
78
|
this.ensureDirectory();
|
|
87
79
|
}
|
|
88
80
|
|
|
@@ -105,7 +97,15 @@ export class FileKnowledgeStore implements KnowledgeStore {
|
|
|
105
97
|
|
|
106
98
|
return entries.map(idx => {
|
|
107
99
|
const full = this.get(idx.id);
|
|
108
|
-
|
|
100
|
+
if (!full) {
|
|
101
|
+
// 索引在册但条目文件缺失/不可解析 = 索引漂移:抛出让它暴露,
|
|
102
|
+
// 不捏造 content 为空的空心条目(修复手段 = rebuildIndex)
|
|
103
|
+
throw new Error(
|
|
104
|
+
`[harness] 知识条目 "${idx.id}" 索引在册但条目文件缺失或不可解析(索引漂移),` +
|
|
105
|
+
`修复:harness knowledge index(rebuildIndex)`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return full;
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -224,7 +224,7 @@ export class FileKnowledgeStore implements KnowledgeStore {
|
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* 从磁盘读取所有条目(不依赖索引)
|
|
227
|
-
*
|
|
227
|
+
* 用于摄入去重等「不能在索引漂移现场先崩」的盘驱动枚举
|
|
228
228
|
*/
|
|
229
229
|
readEntriesFromDisk(): KnowledgeEntry[] {
|
|
230
230
|
const files = this.listFiles();
|
|
@@ -287,12 +287,10 @@ export class FileKnowledgeStore implements KnowledgeStore {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
private readFile(filePath: string): KnowledgeEntry | undefined {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
290
|
+
// fail-fast:文件来自 listFiles 的目录扫描,读到一半失败(IO/权限)直接抛;
|
|
291
|
+
// 内容形状问题(frontmatter 损坏/缺失)由 parseFile 显式上报后返回 undefined
|
|
292
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
293
|
+
return this.parseFile(raw, filePath);
|
|
296
294
|
}
|
|
297
295
|
|
|
298
296
|
private parseFile(raw: string, filePath: string): KnowledgeEntry | undefined {
|
|
@@ -373,28 +371,6 @@ export class FileKnowledgeStore implements KnowledgeStore {
|
|
|
373
371
|
};
|
|
374
372
|
}
|
|
375
373
|
|
|
376
|
-
private indexToEntry(idx: IndexEntry): KnowledgeEntry {
|
|
377
|
-
return {
|
|
378
|
-
id: idx.id,
|
|
379
|
-
type: idx.type,
|
|
380
|
-
title: idx.title,
|
|
381
|
-
content: '',
|
|
382
|
-
maturity: idx.maturity,
|
|
383
|
-
layer: idx.layer,
|
|
384
|
-
created: idx.created,
|
|
385
|
-
lastReferenced: idx.lastReferenced,
|
|
386
|
-
contributors: [],
|
|
387
|
-
projects: [],
|
|
388
|
-
tags: idx.tags ?? [],
|
|
389
|
-
applicablePhases: idx.applicablePhases ?? [],
|
|
390
|
-
sourceReferences: [],
|
|
391
|
-
referencedBy: [],
|
|
392
|
-
executionResults: [],
|
|
393
|
-
consumptionMode: idx.consumptionMode || 'reference',
|
|
394
|
-
origin: idx.origin || 'agent',
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
|
|
398
374
|
private matchesFilter(entry: IndexEntry, filter: QueryFilter): boolean {
|
|
399
375
|
if (filter.types && filter.types.length > 0 && !filter.types.includes(entry.type)) return false;
|
|
400
376
|
if (filter.maturity && filter.maturity.length > 0 && !filter.maturity.includes(entry.maturity)) return false;
|
|
@@ -432,11 +408,8 @@ export class FileKnowledgeStore implements KnowledgeStore {
|
|
|
432
408
|
getSnapshot(date: string): IndexEntry[] | undefined {
|
|
433
409
|
const snapPath = path.join(this.baseDir, SNAPSHOTS_DIR, `index-${date}.json`);
|
|
434
410
|
if (!fs.existsSync(snapPath)) return undefined;
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
} catch {
|
|
438
|
-
return undefined;
|
|
439
|
-
}
|
|
411
|
+
// fail-fast:快照在场但损坏直接抛——吞成 undefined 会把损坏伪装成「没有快照」
|
|
412
|
+
return JSON.parse(fs.readFileSync(snapPath, 'utf-8')) as IndexEntry[];
|
|
440
413
|
}
|
|
441
414
|
|
|
442
415
|
/**
|
|
@@ -470,40 +443,30 @@ export class FileKnowledgeStore implements KnowledgeStore {
|
|
|
470
443
|
*/
|
|
471
444
|
getConsumptionStats(): ConsumptionStats | undefined {
|
|
472
445
|
const statsPath = path.join(this.baseDir, CONSUMPTION_STATS_FILE);
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
return undefined;
|
|
478
|
-
}
|
|
446
|
+
if (!fs.existsSync(statsPath)) return undefined;
|
|
447
|
+
// fail-fast:统计文件在场但损坏直接抛,不装成「无统计」
|
|
448
|
+
const stats = JSON.parse(fs.readFileSync(statsPath, 'utf-8')) as { dailyEvents?: number };
|
|
449
|
+
return { dailyEvents: stats.dailyEvents ?? 0 };
|
|
479
450
|
}
|
|
480
451
|
|
|
481
452
|
// ── Index I/O ────────────────────────────────────────────
|
|
482
453
|
|
|
483
454
|
readIndex(): IndexEntry[] {
|
|
484
455
|
const indexPath = path.join(this.baseDir, INDEX_FILE);
|
|
485
|
-
|
|
486
|
-
try {
|
|
487
|
-
stat = fs.statSync(indexPath);
|
|
488
|
-
} catch {
|
|
489
|
-
stat = undefined;
|
|
490
|
-
}
|
|
491
|
-
if (!stat) {
|
|
456
|
+
if (!fs.existsSync(indexPath)) {
|
|
492
457
|
this.indexCache = undefined;
|
|
493
458
|
return [];
|
|
494
459
|
}
|
|
460
|
+
const stat = fs.statSync(indexPath);
|
|
495
461
|
const cached = this.indexCache;
|
|
496
462
|
if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {
|
|
497
463
|
return cached.entries;
|
|
498
464
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
} catch {
|
|
505
|
-
return [];
|
|
506
|
-
}
|
|
465
|
+
// fail-fast:index 在场但损坏直接抛——吞成 [] 会让 store 误以为库是空的
|
|
466
|
+
const raw = fs.readFileSync(indexPath, 'utf-8');
|
|
467
|
+
const entries = JSON.parse(raw) as IndexEntry[];
|
|
468
|
+
this.indexCache = { mtimeMs: stat.mtimeMs, size: stat.size, entries };
|
|
469
|
+
return entries;
|
|
507
470
|
}
|
|
508
471
|
|
|
509
472
|
private writeIndex(entries: IndexEntry[]): void {
|