nox-mem 3.1.1 → 3.2.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/README.md +24 -16
- package/dist/__tests__/brief-diversity.test.js +266 -0
- package/dist/__tests__/brief.test.js +287 -0
- package/dist/__tests__/churn.test.js +66 -0
- package/dist/__tests__/edge-typing.test.js +99 -0
- package/dist/__tests__/ingest-event.test.js +151 -0
- package/dist/__tests__/op-audit-e2e.test.js +130 -0
- package/dist/__tests__/pragma-alignment.test.js +123 -0
- package/dist/__tests__/reranker.test.js +326 -0
- package/dist/__tests__/retention.test.js +99 -0
- package/dist/__tests__/search-track-access.test.js +49 -0
- package/dist/__tests__/spo-injection.test.js +172 -0
- package/dist/__tests__/temporal-detector.test.js +103 -0
- package/dist/api/wire-up.js +12 -381
- package/dist/api-server.js +6 -102
- package/dist/db.js +61 -2
- package/dist/embed.js +23 -2
- package/dist/index.js +1 -22
- package/dist/knowledge-graph.js +20 -0
- package/dist/lib/answer/__tests__/e2e-gemini.test.js +229 -0
- package/dist/lib/answer/__tests__/integration-sqlite.test.js +388 -0
- package/dist/lib/answer/__tests__/integration.test.js +347 -0
- package/dist/lib/answer/__tests__/prompt.test.js +117 -0
- package/dist/lib/answer/__tests__/t5-t10.test.js +501 -0
- package/dist/lib/answer/provider.js +29 -4
- package/dist/lib/api/__tests__/safe-error-message.test.js +155 -0
- package/dist/lib/auth/__tests__/localhost-guard.test.js +144 -0
- package/dist/lib/error-sanitizer/__tests__/sanitize.test.js +354 -0
- package/dist/lib/events/__tests__/bus.test.js +208 -0
- package/dist/lib/ingest-router.js +0 -43
- package/dist/lib/op-audit-extension/__tests__/ran-at-guard.test.js +109 -0
- package/dist/lib/regex-extract/__tests__/extractor.test.js +197 -0
- package/dist/lib/regex-extract/__tests__/frontmatter.test.js +75 -0
- package/dist/lib/regex-extract/__tests__/ingest-router-l4.test.js +139 -0
- package/dist/lib/regex-extract/__tests__/production-wire.test.js +177 -0
- package/dist/lib/regex-extract/__tests__/reconcile.test.js +170 -0
- package/dist/lib/regex-extract/__tests__/strip-code.test.js +36 -0
- package/dist/privacy/__tests__/filter.test.js +352 -0
- package/dist/providers/__tests__/conformance-extended.test.js +249 -0
- package/dist/providers/__tests__/conformance.test.js +98 -0
- package/dist/providers/__tests__/cost-cap.test.js +151 -0
- package/dist/providers/__tests__/e2e-real.test.js +79 -0
- package/dist/providers/__tests__/factory.test.js +80 -0
- package/dist/providers/__tests__/fallback.test.js +223 -0
- package/dist/providers/__tests__/gemini.test.js +191 -0
- package/dist/providers/__tests__/health.test.js +128 -0
- package/dist/providers/__tests__/telemetry.test.js +219 -0
- package/dist/reindex.js +2 -2
- package/package.json +3 -4
- package/dist/api/answer.d.ts +0 -116
- package/dist/api/answer.validate-patch.d.ts +0 -72
- package/dist/api/brief-diversity.d.ts +0 -64
- package/dist/api/brief.d.ts +0 -114
- package/dist/api/conflict.d.ts +0 -33
- package/dist/api/conflict.js +0 -143
- package/dist/api/cors.d.ts +0 -73
- package/dist/api/events-stream-limited.d.ts +0 -133
- package/dist/api/events-stream-limited.js +0 -217
- package/dist/api/events-stream.d.ts +0 -53
- package/dist/api/events-stream.js +0 -125
- package/dist/api/export.d.ts +0 -42
- package/dist/api/export.js +0 -85
- package/dist/api/health-confidence-adapter.d.ts +0 -29
- package/dist/api/health-confidence-adapter.js +0 -73
- package/dist/api/health-confidence.d.ts +0 -36
- package/dist/api/health-confidence.js +0 -141
- package/dist/api/hooks.d.ts +0 -50
- package/dist/api/hooks.js +0 -115
- package/dist/api/import.d.ts +0 -38
- package/dist/api/import.js +0 -87
- package/dist/api/ingest-event.d.ts +0 -65
- package/dist/api/mark.d.ts +0 -42
- package/dist/api/mark.js +0 -127
- package/dist/api/server-deps-a2.d.ts +0 -55
- package/dist/api/server-deps-a2.js +0 -138
- package/dist/api/server-deps-l2-l3.d.ts +0 -68
- package/dist/api/server-deps-l2-l3.js +0 -123
- package/dist/api/server-deps-p1.d.ts +0 -84
- package/dist/api/server-deps-p2.d.ts +0 -32
- package/dist/api/server-deps-p2.js +0 -84
- package/dist/api/server-deps-p5.d.ts +0 -66
- package/dist/api/server-deps-p5.js +0 -139
- package/dist/api/viewer-static.d.ts +0 -30
- package/dist/api/viewer-static.js +0 -102
- package/dist/api/wire-up.d.ts +0 -54
- package/dist/api-impact.d.ts +0 -30
- package/dist/api-server.d.ts +0 -2
- package/dist/backfill-fts-anchor.d.ts +0 -15
- package/dist/backfill-source-type.d.ts +0 -20
- package/dist/churn.d.ts +0 -31
- package/dist/cli/answer.d.ts +0 -66
- package/dist/cli/conflict.d.ts +0 -38
- package/dist/cli/conflict.js +0 -282
- package/dist/cli/export.d.ts +0 -51
- package/dist/cli/export.js +0 -280
- package/dist/cli/hooks.d.ts +0 -54
- package/dist/cli/hooks.js +0 -133
- package/dist/cli/import.d.ts +0 -52
- package/dist/cli/import.js +0 -274
- package/dist/cli/mark.d.ts +0 -33
- package/dist/cli/mark.js +0 -130
- package/dist/cli/ocr-batch.d.ts +0 -12
- package/dist/cli/ocr-batch.js +0 -411
- package/dist/cli/snapshot-main.d.ts +0 -30
- package/dist/cli/snapshot-main.js +0 -47
- package/dist/cli/viewer.d.ts +0 -35
- package/dist/cli/viewer.js +0 -71
- package/dist/cli-telemetry.d.ts +0 -36
- package/dist/cli-telemetry.js +0 -150
- package/dist/compact.d.ts +0 -7
- package/dist/consolidate.d.ts +0 -18
- package/dist/consolidation.d.ts +0 -32
- package/dist/cross-agent-v2.d.ts +0 -45
- package/dist/cross-search.d.ts +0 -11
- package/dist/crystallize.d.ts +0 -43
- package/dist/db.d.ts +0 -11
- package/dist/dedup.d.ts +0 -1
- package/dist/detect-changes.d.ts +0 -29
- package/dist/digest.d.ts +0 -1
- package/dist/doctor.d.ts +0 -1
- package/dist/embed.d.ts +0 -57
- package/dist/evals.d.ts +0 -176
- package/dist/evals.js +0 -351
- package/dist/generate-user-profile.d.ts +0 -18
- package/dist/graphify-ingest.d.ts +0 -18
- package/dist/impact.d.ts +0 -39
- package/dist/index.d.ts +0 -2
- package/dist/ingest-entity.d.ts +0 -44
- package/dist/ingest.d.ts +0 -13
- package/dist/kg-llm.d.ts +0 -39
- package/dist/knowledge-graph.d.ts +0 -72
- package/dist/lib/answer/config.d.ts +0 -41
- package/dist/lib/answer/index.d.ts +0 -47
- package/dist/lib/answer/prompt.d.ts +0 -37
- package/dist/lib/answer/provider.d.ts +0 -47
- package/dist/lib/answer/retrieval.d.ts +0 -36
- package/dist/lib/answer/telemetry.d.ts +0 -99
- package/dist/lib/answer/types.d.ts +0 -108
- package/dist/lib/api/error-leak-fix.d.ts +0 -54
- package/dist/lib/api/safe-error-message.d.ts +0 -70
- package/dist/lib/archive/common-passwords.d.ts +0 -37
- package/dist/lib/archive/common-passwords.js +0 -753
- package/dist/lib/archive/encryption.d.ts +0 -81
- package/dist/lib/archive/encryption.js +0 -236
- package/dist/lib/archive/enforce-strength.d.ts +0 -54
- package/dist/lib/archive/enforce-strength.js +0 -70
- package/dist/lib/archive/entropy.d.ts +0 -34
- package/dist/lib/archive/entropy.js +0 -180
- package/dist/lib/archive/export-locking.d.ts +0 -102
- package/dist/lib/archive/export-locking.js +0 -202
- package/dist/lib/archive/format.d.ts +0 -20
- package/dist/lib/archive/format.js +0 -174
- package/dist/lib/archive/index.d.ts +0 -23
- package/dist/lib/archive/index.js +0 -17
- package/dist/lib/archive/manifest.d.ts +0 -53
- package/dist/lib/archive/manifest.js +0 -183
- package/dist/lib/archive/migration.d.ts +0 -36
- package/dist/lib/archive/migration.js +0 -100
- package/dist/lib/archive/migrations/v18_to_v19.d.ts +0 -16
- package/dist/lib/archive/migrations/v18_to_v19.js +0 -18
- package/dist/lib/archive/orchestrator.d.ts +0 -166
- package/dist/lib/archive/orchestrator.js +0 -428
- package/dist/lib/archive/serializers/chunks.d.ts +0 -30
- package/dist/lib/archive/serializers/chunks.js +0 -113
- package/dist/lib/archive/serializers/embeddings.d.ts +0 -36
- package/dist/lib/archive/serializers/embeddings.js +0 -115
- package/dist/lib/archive/serializers/kg.d.ts +0 -28
- package/dist/lib/archive/serializers/kg.js +0 -184
- package/dist/lib/archive/serializers/ops_audit.d.ts +0 -21
- package/dist/lib/archive/serializers/ops_audit.js +0 -97
- package/dist/lib/archive/server-deps.d.ts +0 -131
- package/dist/lib/archive/server-deps.js +0 -232
- package/dist/lib/archive/strength.d.ts +0 -50
- package/dist/lib/archive/strength.js +0 -77
- package/dist/lib/archive/types.d.ts +0 -159
- package/dist/lib/archive/types.js +0 -45
- package/dist/lib/archive/unpack-streaming.d.ts +0 -70
- package/dist/lib/archive/unpack-streaming.js +0 -255
- package/dist/lib/auth/localhost-guard.d.ts +0 -106
- package/dist/lib/confidence/config.d.ts +0 -37
- package/dist/lib/confidence/config.js +0 -107
- package/dist/lib/confidence/db-shim-singleton.d.ts +0 -20
- package/dist/lib/confidence/db-shim-singleton.js +0 -41
- package/dist/lib/confidence/db-shim.d.ts +0 -47
- package/dist/lib/confidence/db-shim.js +0 -141
- package/dist/lib/confidence/mark.d.ts +0 -58
- package/dist/lib/confidence/mark.js +0 -168
- package/dist/lib/confidence/ranking.d.ts +0 -69
- package/dist/lib/confidence/ranking.js +0 -101
- package/dist/lib/confidence/search-filter.d.ts +0 -44
- package/dist/lib/confidence/search-filter.js +0 -103
- package/dist/lib/confidence/types.d.ts +0 -146
- package/dist/lib/confidence/types.js +0 -20
- package/dist/lib/confidence/write-hooks.d.ts +0 -50
- package/dist/lib/confidence/write-hooks.js +0 -159
- package/dist/lib/conflict/audit-fk-check.d.ts +0 -72
- package/dist/lib/conflict/audit-fk-check.js +0 -131
- package/dist/lib/conflict/audit-writer.d.ts +0 -39
- package/dist/lib/conflict/audit-writer.js +0 -133
- package/dist/lib/conflict/db-singleton.d.ts +0 -28
- package/dist/lib/conflict/db-singleton.js +0 -61
- package/dist/lib/conflict/db.d.ts +0 -27
- package/dist/lib/conflict/db.js +0 -20
- package/dist/lib/conflict/detector-direct.d.ts +0 -21
- package/dist/lib/conflict/detector-direct.js +0 -105
- package/dist/lib/conflict/evidence.d.ts +0 -24
- package/dist/lib/conflict/evidence.js +0 -76
- package/dist/lib/conflict/index.d.ts +0 -14
- package/dist/lib/conflict/index.js +0 -12
- package/dist/lib/conflict/scheduler.d.ts +0 -78
- package/dist/lib/conflict/scheduler.js +0 -111
- package/dist/lib/conflict/shadow.d.ts +0 -75
- package/dist/lib/conflict/shadow.js +0 -161
- package/dist/lib/conflict/types.d.ts +0 -133
- package/dist/lib/conflict/types.js +0 -19
- package/dist/lib/cost-cap.d.ts +0 -94
- package/dist/lib/deps/deps-registry.d.ts +0 -111
- package/dist/lib/error-sanitizer/middleware.d.ts +0 -43
- package/dist/lib/error-sanitizer/sanitize.d.ts +0 -78
- package/dist/lib/eval-batch.d.ts +0 -34
- package/dist/lib/eval-batch.js +0 -103
- package/dist/lib/eval-metrics.d.ts +0 -36
- package/dist/lib/eval-metrics.js +0 -95
- package/dist/lib/eval.d.ts +0 -106
- package/dist/lib/eval.js +0 -343
- package/dist/lib/events/bus.d.ts +0 -135
- package/dist/lib/fts-anchor.d.ts +0 -1
- package/dist/lib/hooks/classifier.d.ts +0 -47
- package/dist/lib/hooks/classifier.js +0 -129
- package/dist/lib/hooks/config.d.ts +0 -49
- package/dist/lib/hooks/config.js +0 -106
- package/dist/lib/hooks/decorators.d.ts +0 -35
- package/dist/lib/hooks/decorators.js +0 -59
- package/dist/lib/hooks/pipeline.d.ts +0 -76
- package/dist/lib/hooks/pipeline.js +0 -213
- package/dist/lib/hooks/privacy-filter-adapter.d.ts +0 -55
- package/dist/lib/hooks/privacy-filter-adapter.js +0 -84
- package/dist/lib/hooks/rate-limit-constant-time.d.ts +0 -57
- package/dist/lib/hooks/rate-limit-constant-time.js +0 -69
- package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +0 -71
- package/dist/lib/hooks/rate-limit-dryrun-fix.js +0 -110
- package/dist/lib/hooks/rate-limit.d.ts +0 -54
- package/dist/lib/hooks/rate-limit.js +0 -122
- package/dist/lib/hooks/server-deps.d.ts +0 -61
- package/dist/lib/hooks/server-deps.js +0 -92
- package/dist/lib/hooks/source-allowlist.d.ts +0 -26
- package/dist/lib/hooks/source-allowlist.js +0 -53
- package/dist/lib/hooks/types.d.ts +0 -129
- package/dist/lib/hooks/types.js +0 -24
- package/dist/lib/hooks/worker.d.ts +0 -56
- package/dist/lib/hooks/worker.js +0 -150
- package/dist/lib/ingest-router.d.ts +0 -25
- package/dist/lib/ocr-detector.d.ts +0 -61
- package/dist/lib/ocr-detector.js +0 -138
- package/dist/lib/ocr-engine-stub.d.ts +0 -48
- package/dist/lib/ocr-engine-stub.js +0 -190
- package/dist/lib/ocr-engines/google-doc-ai.d.ts +0 -36
- package/dist/lib/ocr-engines/google-doc-ai.js +0 -164
- package/dist/lib/ocr-jobs.d.ts +0 -67
- package/dist/lib/ocr-jobs.js +0 -129
- package/dist/lib/op-audit-extension/ran-at-guard.d.ts +0 -86
- package/dist/lib/op-audit.d.ts +0 -71
- package/dist/lib/privacy-br/detector.d.ts +0 -42
- package/dist/lib/privacy-br/detector.js +0 -130
- package/dist/lib/privacy-br/index.d.ts +0 -20
- package/dist/lib/privacy-br/index.js +0 -20
- package/dist/lib/privacy-br/integration.d.ts +0 -71
- package/dist/lib/privacy-br/integration.js +0 -74
- package/dist/lib/privacy-br/patterns.d.ts +0 -117
- package/dist/lib/privacy-br/patterns.js +0 -434
- package/dist/lib/privacy-br/redact.d.ts +0 -42
- package/dist/lib/privacy-br/redact.js +0 -103
- package/dist/lib/privacy-br/types.d.ts +0 -55
- package/dist/lib/privacy-br/types.js +0 -25
- package/dist/lib/regex-extract/extractor.d.ts +0 -30
- package/dist/lib/regex-extract/frontmatter.d.ts +0 -44
- package/dist/lib/regex-extract/index.d.ts +0 -14
- package/dist/lib/regex-extract/ingest-router-l4.d.ts +0 -76
- package/dist/lib/regex-extract/patterns.d.ts +0 -61
- package/dist/lib/regex-extract/production-wire.d.ts +0 -128
- package/dist/lib/regex-extract/reconcile.d.ts +0 -162
- package/dist/lib/regex-extract/strip-code.d.ts +0 -24
- package/dist/lib/regex-extract/types.d.ts +0 -48
- package/dist/lib/reranker.d.ts +0 -80
- package/dist/lib/shadow-tracker.d.ts +0 -191
- package/dist/lib/shadow-tracker.js +0 -384
- package/dist/lib/spo-injection.d.ts +0 -52
- package/dist/lib/telemetry-collector.d.ts +0 -158
- package/dist/lib/telemetry-collector.js +0 -249
- package/dist/lib/temporal-detector.d.ts +0 -27
- package/dist/lib/viewer/auth.d.ts +0 -37
- package/dist/lib/viewer/auth.js +0 -70
- package/dist/lib/viewer/backpressure.d.ts +0 -59
- package/dist/lib/viewer/backpressure.js +0 -100
- package/dist/lib/viewer/broadcast-singleton.d.ts +0 -34
- package/dist/lib/viewer/broadcast-singleton.js +0 -49
- package/dist/lib/viewer/broadcast.d.ts +0 -66
- package/dist/lib/viewer/broadcast.js +0 -96
- package/dist/lib/viewer/event-types.d.ts +0 -132
- package/dist/lib/viewer/event-types.js +0 -74
- package/dist/lib/viewer/instrumentation.d.ts +0 -106
- package/dist/lib/viewer/instrumentation.js +0 -224
- package/dist/lib/viewer/migration.d.ts +0 -23
- package/dist/lib/viewer/migration.js +0 -56
- package/dist/lib/viewer/redaction.d.ts +0 -44
- package/dist/lib/viewer/redaction.js +0 -139
- package/dist/lib/viewer/session.d.ts +0 -51
- package/dist/lib/viewer/session.js +0 -87
- package/dist/mcp/tools/answer.d.ts +0 -94
- package/dist/mcp/tools/archive.d.ts +0 -152
- package/dist/mcp/tools/archive.js +0 -170
- package/dist/mcp/tools/conflict.d.ts +0 -44
- package/dist/mcp/tools/conflict.js +0 -130
- package/dist/mcp/tools/hooks.d.ts +0 -29
- package/dist/mcp/tools/hooks.js +0 -78
- package/dist/mcp/tools/mark.d.ts +0 -38
- package/dist/mcp/tools/mark.js +0 -82
- package/dist/mcp/tools/viewer.d.ts +0 -58
- package/dist/mcp/tools/viewer.js +0 -64
- package/dist/mcp-server.d.ts +0 -2
- package/dist/metrics.d.ts +0 -3
- package/dist/noise-filter.d.ts +0 -18
- package/dist/notion-sync.d.ts +0 -7
- package/dist/notion-sync.js +0 -97
- package/dist/observability/adapters/a3-adapter.d.ts +0 -63
- package/dist/observability/adapters/a3-adapter.js +0 -83
- package/dist/observability/adapters/p1-adapter.d.ts +0 -49
- package/dist/observability/adapters/p1-adapter.js +0 -63
- package/dist/observability/adapters/p5-adapter.d.ts +0 -36
- package/dist/observability/adapters/p5-adapter.js +0 -71
- package/dist/observability/cardinality.d.ts +0 -61
- package/dist/observability/cardinality.js +0 -300
- package/dist/observability/collectors/db-stats.collector.d.ts +0 -9
- package/dist/observability/collectors/db-stats.collector.js +0 -88
- package/dist/observability/collectors/eventbus.collector.d.ts +0 -6
- package/dist/observability/collectors/eventbus.collector.js +0 -50
- package/dist/observability/collectors/process.collector.d.ts +0 -7
- package/dist/observability/collectors/process.collector.js +0 -93
- package/dist/observability/collectors/provider-telemetry.collector.d.ts +0 -11
- package/dist/observability/collectors/provider-telemetry.collector.js +0 -112
- package/dist/observability/collectors/search-telemetry.collector.d.ts +0 -12
- package/dist/observability/collectors/search-telemetry.collector.js +0 -76
- package/dist/observability/exporter.d.ts +0 -30
- package/dist/observability/exporter.js +0 -182
- package/dist/observability/index.d.ts +0 -22
- package/dist/observability/index.js +0 -21
- package/dist/observability/metrics.d.ts +0 -53
- package/dist/observability/metrics.js +0 -213
- package/dist/observability/privacy-guard.d.ts +0 -32
- package/dist/observability/privacy-guard.js +0 -116
- package/dist/observability/record.d.ts +0 -83
- package/dist/observability/record.js +0 -217
- package/dist/observability/registry.d.ts +0 -60
- package/dist/observability/registry.js +0 -93
- package/dist/observability/types.d.ts +0 -115
- package/dist/observability/types.js +0 -235
- package/dist/observability.d.ts +0 -131
- package/dist/plugins/nox-hooks/index.d.ts +0 -61
- package/dist/plugins/nox-hooks/index.js +0 -99
- package/dist/primer.d.ts +0 -1
- package/dist/privacy/filter.d.ts +0 -27
- package/dist/privacy/patterns.d.ts +0 -29
- package/dist/privacy/tag-parser.d.ts +0 -24
- package/dist/project-context-gen.d.ts +0 -10
- package/dist/providers/embedding/gemini.d.ts +0 -73
- package/dist/providers/embedding/openai.d.ts +0 -76
- package/dist/providers/embedding/types.d.ts +0 -39
- package/dist/providers/embedding/voyage.d.ts +0 -36
- package/dist/providers/index.d.ts +0 -116
- package/dist/providers/llm/anthropic.d.ts +0 -29
- package/dist/providers/llm/chain.d.ts +0 -99
- package/dist/providers/llm/gemini.d.ts +0 -48
- package/dist/providers/llm/openai.d.ts +0 -64
- package/dist/providers/llm/types.d.ts +0 -47
- package/dist/providers/telemetry.d.ts +0 -87
- package/dist/providers/types.d.ts +0 -42
- package/dist/query-entity-count.d.ts +0 -54
- package/dist/reflect.d.ts +0 -26
- package/dist/reindex-errors.d.ts +0 -7
- package/dist/reindex.d.ts +0 -16
- package/dist/retention.d.ts +0 -40
- package/dist/salience.d.ts +0 -85
- package/dist/scripts/migrate-v17-ops-audit.d.ts +0 -17
- package/dist/search-dedup.d.ts +0 -44
- package/dist/search-expansion.d.ts +0 -20
- package/dist/search.d.ts +0 -62
- package/dist/seh-detector.d.ts +0 -31
- package/dist/self-improve.d.ts +0 -1
- package/dist/session-distill.d.ts +0 -29
- package/dist/session-update.d.ts +0 -1
- package/dist/shared-memory.d.ts +0 -24
- package/dist/stats.d.ts +0 -1
- package/dist/temporal-retrieval.d.ts +0 -132
- package/dist/tier-manager.d.ts +0 -69
- package/dist/vectorize.d.ts +0 -16
- package/dist/version.d.ts +0 -1
- package/dist/watch.d.ts +0 -8
package/dist/cli-telemetry.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
// F15 SEH (2026-05-03): self-evolving hooks via CLI telemetry.
|
|
2
|
-
// Cada subcomando registra stats; insights derivados detectam regressions e features dormentes.
|
|
3
|
-
import { getDb } from "./db.js";
|
|
4
|
-
export function ensureCliTelemetry() {
|
|
5
|
-
const db = getDb();
|
|
6
|
-
db.exec(`
|
|
7
|
-
CREATE TABLE IF NOT EXISTS cli_telemetry (
|
|
8
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
9
|
-
command TEXT NOT NULL,
|
|
10
|
-
args_summary TEXT,
|
|
11
|
-
status TEXT NOT NULL CHECK(status IN ('success','failed','timeout')),
|
|
12
|
-
duration_ms INTEGER NOT NULL,
|
|
13
|
-
ts TEXT DEFAULT (datetime('now'))
|
|
14
|
-
);
|
|
15
|
-
CREATE INDEX IF NOT EXISTS idx_cli_telemetry_cmd ON cli_telemetry(command, ts);
|
|
16
|
-
CREATE INDEX IF NOT EXISTS idx_cli_telemetry_ts ON cli_telemetry(ts);
|
|
17
|
-
-- CODE-FIX HIGH: covering index for p95 single-pass per command
|
|
18
|
-
CREATE INDEX IF NOT EXISTS idx_cli_telemetry_cmd_dur ON cli_telemetry(command, duration_ms);
|
|
19
|
-
`);
|
|
20
|
-
}
|
|
21
|
-
// SEC-FIX HIGH #5: redaction defensiva — bloqueia secrets em args_summary
|
|
22
|
-
const SECRET_PATTERN = /(api[_-]?key|token|password|passwd|secret|bearer|auth)[=\s:]+\S+/gi;
|
|
23
|
-
function redactSecrets(s) {
|
|
24
|
-
if (!s)
|
|
25
|
-
return null;
|
|
26
|
-
return s.replace(SECRET_PATTERN, "$1=***").substring(0, 200); // cap length
|
|
27
|
-
}
|
|
28
|
-
export function recordCliRun(opts) {
|
|
29
|
-
if (process.env.NOX_CLI_TELEMETRY === "0")
|
|
30
|
-
return; // opt-out
|
|
31
|
-
try {
|
|
32
|
-
const db = getDb();
|
|
33
|
-
ensureCliTelemetry();
|
|
34
|
-
// SEC-FIX HIGH #5: SEMPRE redact mesmo que caller passe raw (defesa em camadas)
|
|
35
|
-
const safeArgs = redactSecrets(opts.argsSummary);
|
|
36
|
-
db.prepare("INSERT INTO cli_telemetry (command, args_summary, status, duration_ms) VALUES (?, ?, ?, ?)").run(opts.command, safeArgs, opts.status, Math.round(opts.durationMs));
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// fail-open: telemetry never blocks user work
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export function computeCliInsights(opts = {}) {
|
|
43
|
-
const start = Date.now();
|
|
44
|
-
const db = getDb();
|
|
45
|
-
ensureCliTelemetry();
|
|
46
|
-
const windowDays = opts.windowDays ?? 7;
|
|
47
|
-
const total7dRow = db.prepare(`SELECT COUNT(*) AS c FROM cli_telemetry WHERE ts > datetime('now', '-' || ? || ' days')`).get(windowDays);
|
|
48
|
-
const totalAllRow = db.prepare("SELECT COUNT(*) AS c FROM cli_telemetry").get();
|
|
49
|
-
const uniqueRow = db.prepare("SELECT COUNT(DISTINCT command) AS c FROM cli_telemetry").get();
|
|
50
|
-
// Per-command stats — CODE-FIX HIGH: single-pass com all rows + agrupamento in-memory
|
|
51
|
-
// (era N+1 query: 1 GROUP BY + 1 OFFSET por comando). Agora 1 query covering index.
|
|
52
|
-
// CODE-FIX MEDIUM: julianday em vez de naive Date+Z (timezone-safe)
|
|
53
|
-
const allRuns = db.prepare(`SELECT command, status, duration_ms, ts,
|
|
54
|
-
ROUND((julianday('now') - julianday(ts)), 0) AS days_ago
|
|
55
|
-
FROM cli_telemetry ORDER BY command, duration_ms ASC`).all();
|
|
56
|
-
const groupMap = new Map();
|
|
57
|
-
for (const r of allRuns) {
|
|
58
|
-
if (!groupMap.has(r.command))
|
|
59
|
-
groupMap.set(r.command, []);
|
|
60
|
-
groupMap.get(r.command).push(r);
|
|
61
|
-
}
|
|
62
|
-
const byCommand = Array.from(groupMap.entries()).map(([cmd, runs]) => {
|
|
63
|
-
const total = runs.length;
|
|
64
|
-
const success = runs.filter((r) => r.status === 'success').length;
|
|
65
|
-
const failed = total - success;
|
|
66
|
-
const avg = Math.round((runs.reduce((s, r) => s + r.duration_ms, 0) / total) * 10) / 10;
|
|
67
|
-
// p95 via in-memory sorted access (runs already sorted asc por SQL ORDER BY)
|
|
68
|
-
const p95Idx = Math.max(0, Math.floor(total * 0.95) - 1);
|
|
69
|
-
const p95 = runs[p95Idx]?.duration_ms ?? avg;
|
|
70
|
-
const lastRun = runs.reduce((latest, r) => r.ts > latest ? r.ts : latest, "");
|
|
71
|
-
const daysSince = Math.min(...runs.map((r) => r.days_ago));
|
|
72
|
-
return {
|
|
73
|
-
command: cmd,
|
|
74
|
-
total_runs: total,
|
|
75
|
-
success_rate: total === 0 ? 0 : Math.round((success / total) * 1000) / 10,
|
|
76
|
-
failed_runs: failed,
|
|
77
|
-
avg_duration_ms: avg,
|
|
78
|
-
p95_duration_ms: p95,
|
|
79
|
-
last_run_at: lastRun,
|
|
80
|
-
days_since_last_run: daysSince,
|
|
81
|
-
};
|
|
82
|
-
}).sort((a, b) => b.total_runs - a.total_runs);
|
|
83
|
-
const slowCommands = [...byCommand]
|
|
84
|
-
.filter((c) => c.p95_duration_ms > 5000) // > 5s
|
|
85
|
-
.sort((a, b) => b.p95_duration_ms - a.p95_duration_ms)
|
|
86
|
-
.slice(0, 5);
|
|
87
|
-
const errorProne = [...byCommand]
|
|
88
|
-
.filter((c) => c.total_runs >= 3 && c.success_rate < 90)
|
|
89
|
-
.sort((a, b) => a.success_rate - b.success_rate)
|
|
90
|
-
.slice(0, 5);
|
|
91
|
-
const dormantCommands = [...byCommand]
|
|
92
|
-
.filter((c) => c.days_since_last_run >= 14)
|
|
93
|
-
.sort((a, b) => b.days_since_last_run - a.days_since_last_run)
|
|
94
|
-
.slice(0, 5);
|
|
95
|
-
const recentErrors = db.prepare(`SELECT command, ts, duration_ms FROM cli_telemetry
|
|
96
|
-
WHERE status != 'success' AND ts > datetime('now', '-' || ? || ' days')
|
|
97
|
-
ORDER BY ts DESC LIMIT 10`).all(windowDays);
|
|
98
|
-
return {
|
|
99
|
-
total_runs_7d: total7dRow.c,
|
|
100
|
-
total_runs_alltime: totalAllRow.c,
|
|
101
|
-
unique_commands: uniqueRow.c,
|
|
102
|
-
by_command: byCommand,
|
|
103
|
-
slow_commands: slowCommands,
|
|
104
|
-
error_prone_commands: errorProne,
|
|
105
|
-
dormant_commands: dormantCommands,
|
|
106
|
-
recent_errors: recentErrors,
|
|
107
|
-
duration_ms: Date.now() - start,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
export function formatCliInsights(insights, mode = 'text') {
|
|
111
|
-
if (mode === 'json')
|
|
112
|
-
return JSON.stringify(insights, null, 2);
|
|
113
|
-
const lines = [];
|
|
114
|
-
lines.push(`## CLI Telemetry Insights (F15 SEH)`);
|
|
115
|
-
lines.push(`Total runs 7d: ${insights.total_runs_7d} | All-time: ${insights.total_runs_alltime} | Unique commands: ${insights.unique_commands} | Computed in ${insights.duration_ms}ms`);
|
|
116
|
-
if (insights.total_runs_alltime === 0) {
|
|
117
|
-
lines.push(`\n(no telemetry data yet — run a few subcomandos pra populate)`);
|
|
118
|
-
return lines.join("\n");
|
|
119
|
-
}
|
|
120
|
-
lines.push(`\n### 📊 Top 10 most-used commands`);
|
|
121
|
-
for (const c of insights.by_command.slice(0, 10)) {
|
|
122
|
-
const sr = c.success_rate.toFixed(1);
|
|
123
|
-
lines.push(` ${c.command.padEnd(20)} runs=${String(c.total_runs).padStart(5)} sr=${sr}% avg=${c.avg_duration_ms}ms p95=${c.p95_duration_ms}ms last=${c.days_since_last_run}d`);
|
|
124
|
-
}
|
|
125
|
-
if (insights.slow_commands.length > 0) {
|
|
126
|
-
lines.push(`\n### 🐢 Slow commands (p95 > 5s)`);
|
|
127
|
-
for (const c of insights.slow_commands) {
|
|
128
|
-
lines.push(` ${c.command} — p95=${c.p95_duration_ms}ms (avg=${c.avg_duration_ms}ms, runs=${c.total_runs})`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (insights.error_prone_commands.length > 0) {
|
|
132
|
-
lines.push(`\n### ⚠️ Error-prone commands (success_rate < 90%, runs ≥ 3)`);
|
|
133
|
-
for (const c of insights.error_prone_commands) {
|
|
134
|
-
lines.push(` ${c.command} — sr=${c.success_rate}% (${c.failed_runs}/${c.total_runs} failed)`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (insights.dormant_commands.length > 0) {
|
|
138
|
-
lines.push(`\n### 💤 Dormant commands (last run > 14d)`);
|
|
139
|
-
for (const c of insights.dormant_commands) {
|
|
140
|
-
lines.push(` ${c.command} — last=${c.days_since_last_run}d ago (total runs=${c.total_runs})`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (insights.recent_errors.length > 0) {
|
|
144
|
-
lines.push(`\n### 🔴 Recent errors (last ${insights.recent_errors.length})`);
|
|
145
|
-
for (const e of insights.recent_errors) {
|
|
146
|
-
lines.push(` ${e.ts} ${e.command} (${e.duration_ms}ms)`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return lines.join("\n");
|
|
150
|
-
}
|
package/dist/compact.d.ts
DELETED
package/dist/consolidate.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface NotionItem {
|
|
2
|
-
title: string;
|
|
3
|
-
date: string;
|
|
4
|
-
category: string;
|
|
5
|
-
content: string;
|
|
6
|
-
source: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function consolidate(options?: {
|
|
9
|
-
retryFailed?: boolean;
|
|
10
|
-
dryRun?: boolean;
|
|
11
|
-
}): Promise<{
|
|
12
|
-
processed: number;
|
|
13
|
-
extracted: number;
|
|
14
|
-
skipped: number;
|
|
15
|
-
remaining: number;
|
|
16
|
-
notionItems: NotionItem[];
|
|
17
|
-
dryRun?: boolean;
|
|
18
|
-
}>;
|
package/dist/consolidation.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface MergeCandidate {
|
|
2
|
-
primary: {
|
|
3
|
-
id: number;
|
|
4
|
-
name: string;
|
|
5
|
-
type: string;
|
|
6
|
-
mentions: number;
|
|
7
|
-
};
|
|
8
|
-
duplicate: {
|
|
9
|
-
id: number;
|
|
10
|
-
name: string;
|
|
11
|
-
type: string;
|
|
12
|
-
mentions: number;
|
|
13
|
-
};
|
|
14
|
-
similarity: number;
|
|
15
|
-
reason: 'exact_lower' | 'substring' | 'levenshtein' | 'normalized';
|
|
16
|
-
shared_evidence_chunks: number;
|
|
17
|
-
fp_risk: 'low' | 'medium' | 'high';
|
|
18
|
-
fp_reasons: string[];
|
|
19
|
-
}
|
|
20
|
-
export interface ConsolidationResult {
|
|
21
|
-
scanned_entities: number;
|
|
22
|
-
candidate_pairs: number;
|
|
23
|
-
by_type: Record<string, number>;
|
|
24
|
-
by_fp_risk: Record<string, number>;
|
|
25
|
-
candidates: MergeCandidate[];
|
|
26
|
-
duration_ms: number;
|
|
27
|
-
}
|
|
28
|
-
export declare function findMergeCandidates(opts?: {
|
|
29
|
-
minSim?: number;
|
|
30
|
-
maxPerType?: number;
|
|
31
|
-
}): ConsolidationResult;
|
|
32
|
-
export declare function formatConsolidation(r: ConsolidationResult, mode?: 'json' | 'text', limit?: number): string;
|
package/dist/cross-agent-v2.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export interface AgentProfile {
|
|
2
|
-
agent: string;
|
|
3
|
-
totalChunks: number;
|
|
4
|
-
topTypes: Array<{
|
|
5
|
-
type: string;
|
|
6
|
-
count: number;
|
|
7
|
-
}>;
|
|
8
|
-
topTopics: string[];
|
|
9
|
-
lastActivity: string | null;
|
|
10
|
-
uniqueStrength: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function profileAgent(agentName: string): AgentProfile | null;
|
|
13
|
-
export declare function profileAllAgents(): AgentProfile[];
|
|
14
|
-
export interface SharedInsight {
|
|
15
|
-
agent: string;
|
|
16
|
-
type: string;
|
|
17
|
-
text: string;
|
|
18
|
-
date: string | null;
|
|
19
|
-
relevance: number;
|
|
20
|
-
}
|
|
21
|
-
export declare function pullInsightsFrom(sourceAgent: string, types?: string[], limit?: number): SharedInsight[];
|
|
22
|
-
export declare function pullAllInsights(excludeAgent?: string, types?: string[], limitPerAgent?: number): SharedInsight[];
|
|
23
|
-
export interface CrossEntity {
|
|
24
|
-
name: string;
|
|
25
|
-
type: string;
|
|
26
|
-
agents: string[];
|
|
27
|
-
totalMentions: number;
|
|
28
|
-
}
|
|
29
|
-
export declare function mergeCrossKnowledgeGraphs(): {
|
|
30
|
-
entities: CrossEntity[];
|
|
31
|
-
totalRelations: number;
|
|
32
|
-
};
|
|
33
|
-
export declare function findPath(startName: string, endName: string, maxDepth?: number): Array<{
|
|
34
|
-
entity: string;
|
|
35
|
-
relation: string;
|
|
36
|
-
}> | null;
|
|
37
|
-
export declare function formatProfiles(profiles: AgentProfile[]): string;
|
|
38
|
-
export declare function formatPath(path: Array<{
|
|
39
|
-
entity: string;
|
|
40
|
-
relation: string;
|
|
41
|
-
}> | null): string;
|
|
42
|
-
export declare function formatCrossKG(result: {
|
|
43
|
-
entities: CrossEntity[];
|
|
44
|
-
totalRelations: number;
|
|
45
|
-
}): string;
|
package/dist/cross-search.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface CrossSearchResult {
|
|
2
|
-
agent: string;
|
|
3
|
-
score: number;
|
|
4
|
-
source_file: string;
|
|
5
|
-
chunk_type: string;
|
|
6
|
-
chunk_text: string;
|
|
7
|
-
source_date: string | null;
|
|
8
|
-
}
|
|
9
|
-
export declare function crossSearch(query: string, limit?: number): CrossSearchResult[];
|
|
10
|
-
export declare function formatCrossResults(results: CrossSearchResult[]): string;
|
|
11
|
-
export declare function getCrossStats(): string;
|
package/dist/crystallize.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
interface ProcedureInput {
|
|
2
|
-
title: string;
|
|
3
|
-
steps: string[];
|
|
4
|
-
agent?: string;
|
|
5
|
-
tags?: string[];
|
|
6
|
-
preconditions?: string[];
|
|
7
|
-
}
|
|
8
|
-
export interface ValidationEntry {
|
|
9
|
-
timestamp: string;
|
|
10
|
-
outcome: "success" | "failure" | "partial";
|
|
11
|
-
agent: string;
|
|
12
|
-
notes?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface ValidationOptions {
|
|
15
|
-
outcome?: "success" | "failure" | "partial";
|
|
16
|
-
agent?: string;
|
|
17
|
-
notes?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Save a procedure as a type=procedure chunk and (best-effort) embed it
|
|
21
|
-
* immediately so it is hybrid-searchable without waiting for the weekly
|
|
22
|
-
* vectorize cron. Embedding failure never aborts the save — FTS still works.
|
|
23
|
-
*/
|
|
24
|
-
export declare function crystallize(input: ProcedureInput): Promise<number>;
|
|
25
|
-
/**
|
|
26
|
-
* Record a validation attempt for a procedure. Each call appends a structured
|
|
27
|
-
* entry to metadata.validations[] so we can track WHO validated, WHEN, and
|
|
28
|
-
* whether the run succeeded/failed/partial. Outcome defaults to "success"
|
|
29
|
-
* to preserve the old boolean-flip behavior for callers that pass no args.
|
|
30
|
-
*/
|
|
31
|
-
export declare function validateProcedure(chunkId: number, options?: ValidationOptions): void;
|
|
32
|
-
export declare function listProcedures(): Array<{
|
|
33
|
-
id: number;
|
|
34
|
-
title: string;
|
|
35
|
-
validated: boolean;
|
|
36
|
-
steps: number;
|
|
37
|
-
agent: string;
|
|
38
|
-
validations: number;
|
|
39
|
-
successRate: number | null;
|
|
40
|
-
lastValidated: string | null;
|
|
41
|
-
}>;
|
|
42
|
-
export declare function formatProcedureList(procs: ReturnType<typeof listProcedures>): string;
|
|
43
|
-
export {};
|
package/dist/db.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Database from "better-sqlite3";
|
|
2
|
-
export declare const DB_PATH: string;
|
|
3
|
-
export declare const BACKUP_DIR: string;
|
|
4
|
-
export declare function checkLargeDbIngestGuard(db: Database.Database, operation: string): void;
|
|
5
|
-
export declare function getDb(): Database.Database;
|
|
6
|
-
export declare function closeDb(): void;
|
|
7
|
-
/**
|
|
8
|
-
* Backup SQLite using the online backup API (safe even during writes).
|
|
9
|
-
* Retains up to `keepDays` daily backups.
|
|
10
|
-
*/
|
|
11
|
-
export declare function backupDb(keepDays?: number): string;
|
package/dist/dedup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isDuplicate(text: string, sourceFile: string, chunkType: string): Promise<boolean>;
|
package/dist/detect-changes.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface ChangedFile {
|
|
2
|
-
path: string;
|
|
3
|
-
status: string;
|
|
4
|
-
is_entity_file: boolean;
|
|
5
|
-
entity_type?: string;
|
|
6
|
-
entity_slug?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface AffectedEntity {
|
|
9
|
-
name: string;
|
|
10
|
-
type: string;
|
|
11
|
-
mention_count: number;
|
|
12
|
-
source_files: string[];
|
|
13
|
-
via: 'entity_file' | 'chunk_reference';
|
|
14
|
-
}
|
|
15
|
-
export interface DetectChangesResult {
|
|
16
|
-
since: string;
|
|
17
|
-
head: string;
|
|
18
|
-
repo: string;
|
|
19
|
-
files_changed: number;
|
|
20
|
-
files: ChangedFile[];
|
|
21
|
-
affected_entities: AffectedEntity[];
|
|
22
|
-
scanned_chunks: number;
|
|
23
|
-
duration_ms: number;
|
|
24
|
-
}
|
|
25
|
-
export declare function detectChanges(opts: {
|
|
26
|
-
since: string;
|
|
27
|
-
repo: string;
|
|
28
|
-
}): DetectChangesResult;
|
|
29
|
-
export declare function formatDetectChanges(r: DetectChangesResult, mode?: 'json' | 'text'): string;
|
package/dist/digest.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function digest(): Promise<void>;
|
package/dist/doctor.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function doctor(): Promise<void>;
|
package/dist/embed.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* embed.ts - Semantic embedding via Gemini API (gemini-embedding-001, 768-dim)
|
|
3
|
-
* Uses the same API key already configured in the OpenClaw gateway.
|
|
4
|
-
* Zero local model weight, zero sqlite-vec binding issues.
|
|
5
|
-
*
|
|
6
|
-
* Provider routing (added 2026-06-15):
|
|
7
|
-
* When NOX_EMBEDDING_PROVIDER / NOX_EMBED_PROVIDER is set to anything other
|
|
8
|
-
* than "gemini" (the default), embedding calls are delegated to the abstract
|
|
9
|
-
* EmbeddingProvider from src/providers/. The native Gemini path (taskType-aware
|
|
10
|
-
* RETRIEVAL_DOCUMENT / RETRIEVAL_QUERY) is preserved 100% when using gemini.
|
|
11
|
-
*/
|
|
12
|
-
import Database from "better-sqlite3";
|
|
13
|
-
declare const EMBEDDING_DIM = 3072;
|
|
14
|
-
/**
|
|
15
|
-
* Returns the effective embedding dimension for the current provider.
|
|
16
|
-
* Priority: provider.dimensions > NOX_EMBEDDING_DIM / NOX_EMBED_DIM env > EMBEDDING_DIM (3072).
|
|
17
|
-
* Used by ensureVecTable so the vec0 column matches whatever provider is active.
|
|
18
|
-
*/
|
|
19
|
-
export declare function activeEmbeddingDim(): number;
|
|
20
|
-
export declare function embedText(text: string): Promise<Float32Array>;
|
|
21
|
-
/**
|
|
22
|
-
* True batch embedding via Gemini batchEmbedContents API.
|
|
23
|
-
* Sends up to `batchSize` texts per HTTP call (default 50) — on gemini-embedding-001
|
|
24
|
-
* at 3072d we've measured ~13x throughput vs the per-text loop.
|
|
25
|
-
* Pauses `pauseMs` between batches to stay under 100 RPM on the free tier.
|
|
26
|
-
*/
|
|
27
|
-
export declare function embedBatchAPI(texts: string[], options?: {
|
|
28
|
-
batchSize?: number;
|
|
29
|
-
pauseMs?: number;
|
|
30
|
-
onProgress?: (done: number, total: number) => void;
|
|
31
|
-
}): Promise<Float32Array[]>;
|
|
32
|
-
/**
|
|
33
|
-
* Legacy serial embedBatch kept for callers that still use it; now delegates
|
|
34
|
-
* to the batch API with batchSize=1 preserved only to keep error-per-item
|
|
35
|
-
* semantics where they exist. Prefer embedBatchAPI for new code.
|
|
36
|
-
*/
|
|
37
|
-
export declare function embedBatch(texts: string[]): Promise<Float32Array[]>;
|
|
38
|
-
/**
|
|
39
|
-
* sqlite-vec v0.1.x compatibility note:
|
|
40
|
-
* - Does NOT support named INTEGER PRIMARY KEY columns
|
|
41
|
-
* - DOES support rowid-based inserts
|
|
42
|
-
* - We use a companion table (vec_chunk_map) to map rowid → chunk_id
|
|
43
|
-
* - Schema: vec_chunks has only `embedding` column, rowid = auto
|
|
44
|
-
* vec_chunk_map(vec_rowid, chunk_id) tracks the mapping
|
|
45
|
-
*/
|
|
46
|
-
export declare function ensureVecTable(db: Database.Database): void;
|
|
47
|
-
export declare function upsertEmbedding(db: Database.Database, chunkId: number, embedding: Float32Array): void;
|
|
48
|
-
export declare function semanticSearch(db: Database.Database, queryEmbedding: Float32Array, limit?: number): Array<{
|
|
49
|
-
chunk_id: number;
|
|
50
|
-
distance: number;
|
|
51
|
-
source_file: string;
|
|
52
|
-
chunk_type: string;
|
|
53
|
-
chunk_text: string;
|
|
54
|
-
source_date: string | null;
|
|
55
|
-
}>;
|
|
56
|
-
export declare function countEmbedded(db: Database.Database): number;
|
|
57
|
-
export { EMBEDDING_DIM };
|
package/dist/evals.d.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* evals.ts — F10 Phase B endpoint (Eval Dashboard)
|
|
3
|
-
*
|
|
4
|
-
* Adds one read-only endpoint under `/api/observability/*`:
|
|
5
|
-
*
|
|
6
|
-
* GET /api/observability/evals?db_source=<filter>&limit=<n>
|
|
7
|
-
* Returns the historical ablation/gate runs aggregated from `audits/data-G*`
|
|
8
|
-
* directories on disk. Each row carries enough metric breadth to drive the
|
|
9
|
-
* dashboard (nDCG@10, MRR, recall@10), the DB it ran against (for the post-G6
|
|
10
|
-
* fiasco filter — see [[g6-ablation-results-2026-05-20]]), and a list of gate
|
|
11
|
-
* annotations that match its run date.
|
|
12
|
-
*
|
|
13
|
-
* Source data layer
|
|
14
|
-
* -----------------
|
|
15
|
-
* The audits directory is heterogeneous:
|
|
16
|
-
*
|
|
17
|
-
* audits/data-g10b/*.json → {summary, per_category} per run (a8 mutex active/disabled)
|
|
18
|
-
* audits/data-g10c/*.json → derived aggregate: {aggregate.active, aggregate.disabled,
|
|
19
|
-
* per_style_active, per_style_disabled}
|
|
20
|
-
* audits/data-g10d/*.json → {summary, per_category} per t-threshold (a8d_t1/t2/baseline/control)
|
|
21
|
-
* audits/data-g10e/*.json → derived per-query diff array (NOT a run aggregate — skipped)
|
|
22
|
-
*
|
|
23
|
-
* Each "summary" block has:
|
|
24
|
-
* { label, toggles, n_queries, fixture_dir, endpoint, ndcg_at_10, mrr,
|
|
25
|
-
* recall_at_10, precision_at_5, mean_latency_ms, p95_latency_ms,
|
|
26
|
-
* n_valid_queries, wallclock_s }
|
|
27
|
-
*
|
|
28
|
-
* Adapter strategy:
|
|
29
|
-
* - Walk `audits/data-<X>/` directories.
|
|
30
|
-
* - For each .json file, sniff the shape:
|
|
31
|
-
* (a) `{ summary, per_category, ... }` → emit one row from summary
|
|
32
|
-
* (b) `{ aggregate: { active, disabled }, ... }` → emit two rows (one per agg key)
|
|
33
|
-
* (c) anything else (e.g. per-query derived array) → skip with a warn to stderr
|
|
34
|
-
* - `ran_at` = file mtime (UTC ISO), since aggregate JSONs don't carry a wall-clock.
|
|
35
|
-
* - `db_source` = parsed from `summary.fixture_dir` (last path component → e.g.
|
|
36
|
-
* "g9-g5db-2026-05-20" → "g5.db"; the convention is documented in
|
|
37
|
-
* [[g6-ablation-results-2026-05-20]] and [[g10-mutex-validated-2026-05-20]]).
|
|
38
|
-
* - `config_id` = `summary.label` (already unique per run).
|
|
39
|
-
* - `run_id` = `<G-bucket>::<label>` for stability across reads.
|
|
40
|
-
*
|
|
41
|
-
* Annotations:
|
|
42
|
-
* - Loaded from `public/observability/gate-annotations.json` once per process.
|
|
43
|
-
* - A row gets every annotation whose date falls on the same UTC calendar day.
|
|
44
|
-
*
|
|
45
|
-
* Caching:
|
|
46
|
-
* - 5-minute in-memory TTL (spec allows). Single-process server, no infra.
|
|
47
|
-
* - Test harness exposes `_resetEvalsCache()` to clear state between cases.
|
|
48
|
-
*
|
|
49
|
-
* Spec: specs/2026-05-01-F10-observability-dashboard.md §"P1 EVAL DASHBOARD"
|
|
50
|
-
* Status: Phase B implementation-ready
|
|
51
|
-
*/
|
|
52
|
-
export interface EvalRow {
|
|
53
|
-
run_id: string;
|
|
54
|
-
config_id: string;
|
|
55
|
-
db_source: string;
|
|
56
|
-
ndcg_at_10: number | null;
|
|
57
|
-
mrr: number | null;
|
|
58
|
-
recall_at_10: number | null;
|
|
59
|
-
precision_at_5: number | null;
|
|
60
|
-
mean_latency_ms: number | null;
|
|
61
|
-
p95_latency_ms: number | null;
|
|
62
|
-
n_queries: number | null;
|
|
63
|
-
ran_at: string;
|
|
64
|
-
ran_at_ms: number;
|
|
65
|
-
source_path: string;
|
|
66
|
-
annotations: string[];
|
|
67
|
-
}
|
|
68
|
-
export interface GateAnnotation {
|
|
69
|
-
date: string;
|
|
70
|
-
label: string;
|
|
71
|
-
description?: string;
|
|
72
|
-
}
|
|
73
|
-
interface SummaryShape {
|
|
74
|
-
label?: unknown;
|
|
75
|
-
toggles?: unknown;
|
|
76
|
-
n_queries?: unknown;
|
|
77
|
-
fixture_dir?: unknown;
|
|
78
|
-
endpoint?: unknown;
|
|
79
|
-
ndcg_at_10?: unknown;
|
|
80
|
-
mrr?: unknown;
|
|
81
|
-
recall_at_10?: unknown;
|
|
82
|
-
precision_at_5?: unknown;
|
|
83
|
-
mean_latency_ms?: unknown;
|
|
84
|
-
p95_latency_ms?: unknown;
|
|
85
|
-
n_valid_queries?: unknown;
|
|
86
|
-
wallclock_s?: unknown;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Maps the fixture_dir leaf to the canonical DB filename, the way the team
|
|
90
|
-
* tracks DBs in audits. The convention (per [[g6-ablation-results-2026-05-20]]
|
|
91
|
-
* and follow-ups) is that a fixture directory contains a substring naming the
|
|
92
|
-
* DB the eval was actually run against.
|
|
93
|
-
*
|
|
94
|
-
* Examples seen on disk:
|
|
95
|
-
* /path/to/workspace/eval-data/g9-g5db-2026-05-20 → "g5.db"
|
|
96
|
-
* /…/eval-data/entity-eval-v2 → "entity-eval-v2.db"
|
|
97
|
-
* /…/eval-data/entity-eval → "entity-eval.db"
|
|
98
|
-
* /…/eval-data/g9 → "g9.db"
|
|
99
|
-
*
|
|
100
|
-
* Returns "unknown.db" if no match. Tests must cover the unknown fallback.
|
|
101
|
-
*/
|
|
102
|
-
export declare function inferDbSource(fixtureDir: string | null): string;
|
|
103
|
-
/**
|
|
104
|
-
* Bucket key derived from the data-Gxx directory name. Used for stable run_ids
|
|
105
|
-
* and as a fallback config grouping in the UI.
|
|
106
|
-
*/
|
|
107
|
-
export declare function gateBucketFromDir(dir: string): string;
|
|
108
|
-
declare function toNumOrNull(v: unknown): number | null;
|
|
109
|
-
declare function toStringOrNull(v: unknown): string | null;
|
|
110
|
-
/**
|
|
111
|
-
* Returns the YYYY-MM-DD UTC calendar string for an ms timestamp. ISO substring
|
|
112
|
-
* is intentional — keeps the implementation portable across Node versions and
|
|
113
|
-
* avoids a Date locale dependency.
|
|
114
|
-
*/
|
|
115
|
-
export declare function isoDay(ms: number): string;
|
|
116
|
-
/**
|
|
117
|
-
* Picks every annotation whose `date` matches the run's UTC calendar day.
|
|
118
|
-
* Returns label strings (not the full object) — the UI only needs the labels
|
|
119
|
-
* to overlay vertical lines + tooltips, and richer data lives in the gate file.
|
|
120
|
-
*/
|
|
121
|
-
export declare function matchAnnotations(ranAtMs: number, annotations: GateAnnotation[]): string[];
|
|
122
|
-
/**
|
|
123
|
-
* Parses one audit JSON file into a list of normalized EvalRow.
|
|
124
|
-
*
|
|
125
|
-
* Returns `[]` (with stderr warning) when the file is unreadable, malformed,
|
|
126
|
-
* or carries a shape we explicitly do not aggregate (e.g. per-query diff arrays).
|
|
127
|
-
* Never throws — endpoint hardening per spec.
|
|
128
|
-
*/
|
|
129
|
-
export declare function parseAuditFile(filePath: string, fileMtimeMs: number, bucket: string, annotations: GateAnnotation[]): EvalRow[];
|
|
130
|
-
declare function rowFromSummary(s: SummaryShape, filePath: string, bucket: string, ranAt: string, ranAtMs: number, annotations: string[], configSuffix: string | null): EvalRow | null;
|
|
131
|
-
/**
|
|
132
|
-
* Returns the sorted absolute paths of `audits/data-*` JSON files under the
|
|
133
|
-
* given root. Best-effort: directories that disappear mid-walk are skipped.
|
|
134
|
-
*/
|
|
135
|
-
export declare function collectAuditFiles(auditsRoot: string): Array<{
|
|
136
|
-
file: string;
|
|
137
|
-
bucket: string;
|
|
138
|
-
mtimeMs: number;
|
|
139
|
-
}>;
|
|
140
|
-
/**
|
|
141
|
-
* Best-effort load of the gate-annotations.json file. Returns `[]` on missing
|
|
142
|
-
* file, parse error, or wrong shape — callers tolerate empty annotation list.
|
|
143
|
-
*/
|
|
144
|
-
export declare function loadAnnotations(filePath: string): GateAnnotation[];
|
|
145
|
-
/** Exposed for tests. */
|
|
146
|
-
export declare function _resetEvalsCache(): void;
|
|
147
|
-
export interface EvalsQuery {
|
|
148
|
-
/** Filter by db_source (e.g. "g5.db"). "all" or undefined = no filter. */
|
|
149
|
-
dbSource?: string;
|
|
150
|
-
/** Limit (default 500, max 2000). */
|
|
151
|
-
limit?: number;
|
|
152
|
-
/** Force refresh (skip TTL). */
|
|
153
|
-
force?: boolean;
|
|
154
|
-
}
|
|
155
|
-
export interface EvalsHandlerOptions {
|
|
156
|
-
auditsRoot?: string;
|
|
157
|
-
annotationsPath?: string;
|
|
158
|
-
ttlMs?: number;
|
|
159
|
-
now?: () => number;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Build the row list from disk (no cache). Useful for tests.
|
|
163
|
-
*/
|
|
164
|
-
export declare function buildEvalRows(opts?: EvalsHandlerOptions): EvalRow[];
|
|
165
|
-
/**
|
|
166
|
-
* Endpoint handler. Returns an array of EvalRow already sorted by ran_at ASC,
|
|
167
|
-
* filtered by db_source if requested, and capped to `limit`.
|
|
168
|
-
*/
|
|
169
|
-
export declare function handleObsEvals(query?: EvalsQuery, opts?: EvalsHandlerOptions): EvalRow[];
|
|
170
|
-
export declare const _internals: {
|
|
171
|
-
DEFAULT_TTL_MS: number;
|
|
172
|
-
toNumOrNull: typeof toNumOrNull;
|
|
173
|
-
toStringOrNull: typeof toStringOrNull;
|
|
174
|
-
rowFromSummary: typeof rowFromSummary;
|
|
175
|
-
};
|
|
176
|
-
export {};
|