Commit 08dd8d6
feat: polymorphic provider backend, observability, and secrets hygiene
This commit is the full enhancement set on top of upstream tobi/qmd:
Provider abstraction
- LlamaCpp constructor now dispatches embed/rerank between local
node-llama-cpp and Jina AI via env vars or per-index YAML URIs.
- Generation (query expansion) stays local for latency reasons.
- Jina embeddings: jina-embeddings-v3 (1024d, 8192 ctx, Matryoshka).
- Jina reranking: jina-reranker-v2-base-multilingual.
- Backwards-compatible: no env var set == identical upstream behaviour.
Observability layer
- New append-only jina_usage SQLite table + getUsageSnapshot helper.
- qmd usage command with text/JSON/CSV/ASCII histogram outputs.
- qmd usage chart renders a daily histogram with unicode block bars.
- Quota warnings (ok/warn/critical/over) driven by QMD_JINA_QUOTA.
- qmd status shows compact quota summary when a remote provider
is active.
- Stable qmd.usage.v1 JSON schema for CI gates and scripting.
Benchmarking
- qmd bench jina measures embed_single, embed_batch, and rerank
stages against local and/or Jina backends with deterministic
synthetic workloads.
- --runs N flattens samples across runs for median/mean/stddev/p95.
- High-variance stages (stddev > 20% of median) highlighted yellow.
- Side-by-side comparison table with speedup ratio and winner.
- Stable qmd.bench.jina.v1 JSON output.
Secrets hygiene
- .env auto-load via zero-dep src/dotenv.ts (180 lines, 18 tests).
- .env.example template documenting all env vars.
- .gitignore excludes .env, .env.*, *.key, *.pem, secrets/.
- scripts/scan-secrets.sh detects leaked keys for Jina, OpenAI,
Anthropic, Voyage, Cohere, GitHub, AWS, and PEM blocks.
- Scanner reports file:line without re-leaking the key value.
- scripts/pre-commit hook invokes the scanner on staged files.
- scripts/install-hooks.sh installs both pre-commit and pre-push.
Tests
- +68 new tests (50 jina + 18 dotenv), 467 total, 0 regressions.
- All Jina tests mock fetch: zero real API calls during test runs.
- Clean typecheck on tsconfig.build.json.
Documentation
- README.md rewritten in English with upstream attribution and
a clear "what this fork adds" delta table near the top.
- docs/01-architecture-changes.md design rationale (569 lines)
covering the six substantive shifts, what deliberately did not
change, architectural deltas, and open questions.
- CHANGELOG.md Unreleased section documents every shift.
Upstream compatibility: additive, never subtractive. Every new
capability is opt-in. If you set no new env vars and touch no new
YAML fields, QMD behaves identically to upstream tobi/qmd.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c2f3a40 commit 08dd8d6
17 files changed
Lines changed: 5659 additions & 430 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
5 | 95 | | |
6 | 96 | | |
7 | 97 | | |
| |||
0 commit comments