hl-mem 0.21.0__tar.gz
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.
- hl_mem-0.21.0/.env.example +4 -0
- hl_mem-0.21.0/.gitattributes +1 -0
- hl_mem-0.21.0/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- hl_mem-0.21.0/.github/workflows/publish.yml +61 -0
- hl_mem-0.21.0/.github/workflows/quality-smoke.yml +22 -0
- hl_mem-0.21.0/.github/workflows/test.yml +165 -0
- hl_mem-0.21.0/.gitignore +58 -0
- hl_mem-0.21.0/AGENTS.md +155 -0
- hl_mem-0.21.0/CONTRIBUTING.md +62 -0
- hl_mem-0.21.0/LICENSE +201 -0
- hl_mem-0.21.0/PKG-INFO +189 -0
- hl_mem-0.21.0/README.md +169 -0
- hl_mem-0.21.0/README_EN.md +163 -0
- hl_mem-0.21.0/benchmarks/longmemeval/README.md +11 -0
- hl_mem-0.21.0/benchmarks/longmemeval/manifest.json +20 -0
- hl_mem-0.21.0/config.example.toml +82 -0
- hl_mem-0.21.0/docs/CHANGELOG.md +544 -0
- hl_mem-0.21.0/docs/CODE-REVIEW-BATCH-ABCD.md +216 -0
- hl_mem-0.21.0/docs/EXTRACTION-BENCHMARK-REPORT.md +123 -0
- hl_mem-0.21.0/docs/EXTRACTION-BENCHMARK-REVIEW.md +249 -0
- hl_mem-0.21.0/docs/EXTRACTION-NEXT-STEPS.md +339 -0
- hl_mem-0.21.0/docs/HANDOFF.md +131 -0
- hl_mem-0.21.0/docs/P0-DATA-CLEANUP-AUDIT-2026-07-28.md +61 -0
- hl_mem-0.21.0/docs/README.md +51 -0
- hl_mem-0.21.0/docs/RECALL-QUALITY-POST-GOVERNANCE.md +65 -0
- hl_mem-0.21.0/docs/SCALING-ROADMAP.md +109 -0
- hl_mem-0.21.0/docs/SCOPE-RECLASSIFY-DRYRUN.md +96 -0
- hl_mem-0.21.0/docs/adr/0001-core-strategy.md +86 -0
- hl_mem-0.21.0/docs/adr/0002-mvp-scope-and-embedding.md +49 -0
- hl_mem-0.21.0/docs/api-schema.json +2081 -0
- hl_mem-0.21.0/docs/api.md +144 -0
- hl_mem-0.21.0/docs/architecture.md +337 -0
- hl_mem-0.21.0/docs/archive/refactor/README.md +3 -0
- hl_mem-0.21.0/docs/archive/refactor/phase15-batch1-config-llm.md +84 -0
- hl_mem-0.21.0/docs/archive/refactor/phase15-batch1-remaining-fixes.md +66 -0
- hl_mem-0.21.0/docs/archive/refactor/phase15-batch1-test-updates.md +245 -0
- hl_mem-0.21.0/docs/archive/refactor/phase15-batch2-domain-compat.md +87 -0
- hl_mem-0.21.0/docs/archive/refactor/phase15-batch3-god-functions.md +136 -0
- hl_mem-0.21.0/docs/archive/refactor/phase15-batch4-types-storage.md +152 -0
- hl_mem-0.21.0/docs/archive/refactor/phase15-batch5-cleanup.md +167 -0
- hl_mem-0.21.0/docs/archive/refactor/phase16-batch1-dedup.md +108 -0
- hl_mem-0.21.0/docs/archive/refactor/phase16-batch2-contracts.md +101 -0
- hl_mem-0.21.0/docs/archive/refactor/phase16-batch2-followup.md +56 -0
- hl_mem-0.21.0/docs/archive/refactor/phase16-batch3-hermes-cleanup.md +103 -0
- hl_mem-0.21.0/docs/archive/refactor/phase17-design.md +165 -0
- hl_mem-0.21.0/docs/archive/refactor/phase17-stage1.md +310 -0
- hl_mem-0.21.0/docs/archive/refactor/phase17-stage2.md +95 -0
- hl_mem-0.21.0/docs/archive/refactor/phase17-stage3.md +142 -0
- hl_mem-0.21.0/docs/archive/refactor/phase17-stage4.md +117 -0
- hl_mem-0.21.0/docs/archive/refactor/phase18-topic-tags.md +210 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-lifecycle.md +144 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase1-p0.md +249 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase10-conflict-fix-proposal.md +353 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase10-conflict-fix.md +53 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase11-mutual-exclusivity.md +82 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase11-proposal.md +416 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase12-proposal.md +425 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase12-quality.md +85 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase13-batch1a-task.md +284 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase13-batch1b-task.md +240 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase13-batch2a-task.md +343 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase13-batch2b3-task.md +148 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase13-batch4-task.md +170 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase13-consensus.md +81 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase13-proposal.md +297 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase14-brief.md +104 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase14-proposal.md +678 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase2-domain.md +181 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase3-services.md +227 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase4-dependencies.md +143 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase5-dedup.md +117 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase6-maintenance.md +108 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase7-quality.md +230 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase8-hardfix.md +292 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-phase9-improvements.md +254 -0
- hl_mem-0.21.0/docs/archive/refactor/refactor-plan-v2.md +647 -0
- hl_mem-0.21.0/docs/archive/refactor/v0.9.0-fixes.md +72 -0
- hl_mem-0.21.0/docs/archive/research/recall-and-llm-cost-2026-07-27.md +308 -0
- hl_mem-0.21.0/docs/archive/research/recall-and-llm-cost-v2-2026-07-27.md +178 -0
- hl_mem-0.21.0/docs/archive/reviews/attribute-taxonomy-analysis.md +392 -0
- hl_mem-0.21.0/docs/archive/reviews/codex-arch-review-v2-report.md +161 -0
- hl_mem-0.21.0/docs/archive/reviews/codex-arch-review-v2.md +96 -0
- hl_mem-0.21.0/docs/archive/reviews/codex-dead-code-review-report.md +322 -0
- hl_mem-0.21.0/docs/archive/reviews/codex-quality-review-report.md +454 -0
- hl_mem-0.21.0/docs/archive/reviews/consensus.md +94 -0
- hl_mem-0.21.0/docs/archive/reviews/data-quality-analysis.md +455 -0
- hl_mem-0.21.0/docs/archive/reviews/external-review-assessment.md +335 -0
- hl_mem-0.21.0/docs/archive/reviews/hermes-review-feedback.md +71 -0
- hl_mem-0.21.0/docs/archive/reviews/hindsight-analysis.txt +283 -0
- hl_mem-0.21.0/docs/archive/reviews/hindsight-vs-hlmem.md +490 -0
- hl_mem-0.21.0/docs/archive/reviews/hl-mem-vs-memos.md +428 -0
- hl_mem-0.21.0/docs/archive/reviews/optimization-consensus.md +34 -0
- hl_mem-0.21.0/docs/archive/reviews/optimization-round1-hermes.md +76 -0
- hl_mem-0.21.0/docs/archive/reviews/optimization-round2-hermes.md +65 -0
- hl_mem-0.21.0/docs/archive/reviews/phase17-review.md +543 -0
- hl_mem-0.21.0/docs/archive/reviews/push-readiness.md +161 -0
- hl_mem-0.21.0/docs/archive/reviews/round1-hermes-review.md +45 -0
- hl_mem-0.21.0/docs/archive/reviews/round2-hermes-response.md +37 -0
- hl_mem-0.21.0/docs/archive/reviews/round3-embedding-revision.md +31 -0
- hl_mem-0.21.0/docs/archive/reviews/second-review-assessment.md +289 -0
- hl_mem-0.21.0/docs/archive/reviews/topic-tags-retrieval-design.md +337 -0
- hl_mem-0.21.0/docs/archive/reviews/trigram-review.md +171 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.11.0-status-assessment.md +169 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.11.1-code-quality.md +211 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.12.0-code-review.md +197 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.12.0-future-direction.md +154 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.12.1-memory-quality-audit.md +220 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.12.3-code-review.md +259 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.12.4-external-review-assessment.md +261 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.13.0-convergence-review.md +248 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.14.3-recall-and-monitoring-proposal.md +544 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.14.3-recall-quality-evaluation.md +124 -0
- hl_mem-0.21.0/docs/archive/reviews/v0.9.0-code-review.md +238 -0
- hl_mem-0.21.0/docs/archive/superpowers/plans/2026-07-22-all-phases-completion.md +58 -0
- hl_mem-0.21.0/docs/archive/superpowers/plans/2026-07-22-keyword-bound-recall-eval.md +84 -0
- hl_mem-0.21.0/docs/archive/tasks/benchmark-extraction-five-model-plan-2026-07-28.md +416 -0
- hl_mem-0.21.0/docs/archive/tasks/cleanup-task.md +112 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-dead-code-review-task.md +77 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-quality-review-task.md +146 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-benchmark.md +111 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-data-reextraction.md +110 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-extraction-prefilter.md +59 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-feedback-lifecycle.md +173 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-image-evidence.md +127 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-install-script.md +270 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-memory-quality-audit.md +108 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-memory-quality-fixes.md +141 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-p0p1-fixes.md +166 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-procedure-intent.md +176 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-prompt-tuning.md +141 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-proposals.md +137 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-query-expansion.md +127 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-recall-and-monitoring-proposal.md +159 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-recall-quality-eval.md +53 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-relation-discovery.md +160 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-release-docs.md +130 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-update-docs.md +53 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-v0.12.0-release.md +106 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-v0.12.0-review.md +163 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-v0.12.3-fixes.md +77 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-v0.13.0-p1-fixes.md +50 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-v0.13.1-content-fixes.md +94 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-v0.13.1-docs-restructure.md +168 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-v0.15.0-recall-and-monitoring.md +221 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-vs-memos.md +101 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-week1.md +232 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-week2.md +177 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-week3.md +233 -0
- hl_mem-0.21.0/docs/archive/tasks/codex-task-week4.md +191 -0
- hl_mem-0.21.0/docs/archive/tasks/v0.20.0-day1-lexicalizer-task.md +69 -0
- hl_mem-0.21.0/docs/archive/tasks/v0.20.0-day2-migration-task.md +94 -0
- hl_mem-0.21.0/docs/archive/tasks/v0.20.0-day3-5-claims-events-final-task.md +89 -0
- hl_mem-0.21.0/docs/archive/tasks/v0201-watchdog-observability-plan.md +111 -0
- hl_mem-0.21.0/docs/audit-log-design.md +867 -0
- hl_mem-0.21.0/docs/capability-matrix.md +44 -0
- hl_mem-0.21.0/docs/compatibility.md +42 -0
- hl_mem-0.21.0/docs/configuration.md +319 -0
- hl_mem-0.21.0/docs/design/extraction-pre-filter.md +151 -0
- hl_mem-0.21.0/docs/implementation-plan.md +62 -0
- hl_mem-0.21.0/docs/mcp-tools.json +326 -0
- hl_mem-0.21.0/docs/mcp.md +113 -0
- hl_mem-0.21.0/docs/memory-management-design.md +465 -0
- hl_mem-0.21.0/docs/proposals/00-overview.md +181 -0
- hl_mem-0.21.0/docs/proposals/01-query-expansion.md +162 -0
- hl_mem-0.21.0/docs/proposals/02-relation-discovery.md +194 -0
- hl_mem-0.21.0/docs/proposals/03-benchmark-suite.md +212 -0
- hl_mem-0.21.0/docs/proposals/04-image-evidence.md +206 -0
- hl_mem-0.21.0/docs/proposals/05-feedback-lifecycle.md +210 -0
- hl_mem-0.21.0/docs/proposals/06-procedure-intent.md +180 -0
- hl_mem-0.21.0/docs/proposals/07-quality-trends.md +71 -0
- hl_mem-0.21.0/docs/proposals/config-management-toml-plan.md +369 -0
- hl_mem-0.21.0/docs/proposals/extraction-prompt-optimization.md +499 -0
- hl_mem-0.21.0/docs/proposals/plan-lifecycle-research.md +146 -0
- hl_mem-0.21.0/docs/proposals/recall-improvement-proposal.md +408 -0
- hl_mem-0.21.0/docs/proposals/v019-integration-and-polish-proposal.md +1207 -0
- hl_mem-0.21.0/docs/proposals/v0201-watchdog-observability.md +15 -0
- hl_mem-0.21.0/docs/releases/v0.20.0-tokenized-fts.md +45 -0
- hl_mem-0.21.0/docs/releases/v0.20.1-watchdog-observability.md +29 -0
- hl_mem-0.21.0/docs/releases/v0.20.2-recall-quality-supervision.md +40 -0
- hl_mem-0.21.0/docs/research/competitor-comparison.md +106 -0
- hl_mem-0.21.0/docs/research/memos-vs-hindsight.md +106 -0
- hl_mem-0.21.0/docs/review/clean-100-events-report.md +165 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.13.2-ssot-ci.md +201 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.13.3-comprehensive-governance.md +183 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.13.3-governance-fixes.md +145 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.13.4-v0.14.0.md +191 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.14.0-evaluation.md +63 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.14.1-evaluation.md +33 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.14.1-execution.md +110 -0
- hl_mem-0.21.0/docs/review/codex-task-v0.14.2-final-polish.md +73 -0
- hl_mem-0.21.0/docs/review/v0.14.0-external-evaluation.md +247 -0
- hl_mem-0.21.0/docs/review/v0.14.1-final-polish-evaluation.md +40 -0
- hl_mem-0.21.0/docs/review/v0.14.2-database-health-check.md +376 -0
- hl_mem-0.21.0/docs/superpowers/plans/2026-08-02-ci-six-failures.md +118 -0
- hl_mem-0.21.0/docs/superpowers/plans/2026-08-02-recall-direction4-evaluation.md +108 -0
- hl_mem-0.21.0/docs/watchdog.md +143 -0
- hl_mem-0.21.0/evaluation/ab_tests/__init__.py +1 -0
- hl_mem-0.21.0/evaluation/ab_tests/framework.py +31 -0
- hl_mem-0.21.0/evaluation/baselines/recall_regression_v1_baseline.json +1 -0
- hl_mem-0.21.0/evaluation/baselines/smoke_v2_baseline.json +126 -0
- hl_mem-0.21.0/evaluation/datasets/recall_regression_v1.jsonl +30 -0
- hl_mem-0.21.0/evaluation/datasets/smoke_v1.jsonl +10 -0
- hl_mem-0.21.0/evaluation/datasets/smoke_v2.jsonl +17 -0
- hl_mem-0.21.0/evaluation/labeling/recall_labels_v1.jsonl +50 -0
- hl_mem-0.21.0/evaluation/run_calibration.py +30 -0
- hl_mem-0.21.0/evaluation/run_recall_regression.py +94 -0
- hl_mem-0.21.0/install_to_hermes.py +142 -0
- hl_mem-0.21.0/pyproject.toml +115 -0
- hl_mem-0.21.0/scripts/__init__.py +1 -0
- hl_mem-0.21.0/scripts/ab_test_index_text.py +828 -0
- hl_mem-0.21.0/scripts/benchmark_extraction.py +672 -0
- hl_mem-0.21.0/scripts/check_docs_consistency.py +155 -0
- hl_mem-0.21.0/scripts/check_imports.py +128 -0
- hl_mem-0.21.0/scripts/check_mcp_snapshot.py +39 -0
- hl_mem-0.21.0/scripts/check_openapi_snapshot.py +47 -0
- hl_mem-0.21.0/scripts/clean_disputed_claims.py +234 -0
- hl_mem-0.21.0/scripts/cleanup_duplicates_v3.py +183 -0
- hl_mem-0.21.0/scripts/create_gold_dataset.py +393 -0
- hl_mem-0.21.0/scripts/diagnose_extraction_gaps.py +210 -0
- hl_mem-0.21.0/scripts/eval_against_gold.py +186 -0
- hl_mem-0.21.0/scripts/extraction_benchmark_review_analysis.py +157 -0
- hl_mem-0.21.0/scripts/extraction_benchmark_validation_batch_d_20260728_160739.jsonl +15 -0
- hl_mem-0.21.0/scripts/extraction_benchmark_validation_batch_d_20260728_160739.manifest.json +58 -0
- hl_mem-0.21.0/scripts/extraction_testset.jsonl +50 -0
- hl_mem-0.21.0/scripts/generate_configuration_reference.py +293 -0
- hl_mem-0.21.0/scripts/generate_daily_report.py +45 -0
- hl_mem-0.21.0/scripts/gold_dataset.jsonl +20 -0
- hl_mem-0.21.0/scripts/healthcheck.py +43 -0
- hl_mem-0.21.0/scripts/hlmem_supervisor.py +832 -0
- hl_mem-0.21.0/scripts/reclassify_predicates.py +176 -0
- hl_mem-0.21.0/scripts/reclassify_scope.py +361 -0
- hl_mem-0.21.0/scripts/reextract_claims.py +545 -0
- hl_mem-0.21.0/scripts/repair_v019_double_encoded_values.py +718 -0
- hl_mem-0.21.0/scripts/rerun_benchmark_model.py +86 -0
- hl_mem-0.21.0/scripts/run_quality_smoke.py +451 -0
- hl_mem-0.21.0/scripts/run_reranker_comparison.py +40 -0
- hl_mem-0.21.0/scripts/verify_projection_consistency.py +344 -0
- hl_mem-0.21.0/src/hl_mem/__init__.py +3 -0
- hl_mem-0.21.0/src/hl_mem/adapters/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/__init__.py +5 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/episode_mapper.py +50 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/http_client.py +171 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/plugin/__init__.py +35 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/plugin/plugin.yaml +12 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/prefetch.py +523 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/provider.py +855 -0
- hl_mem-0.21.0/src/hl_mem/adapters/hermes/renderer.py +49 -0
- hl_mem-0.21.0/src/hl_mem/api/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/api/schemas.py +309 -0
- hl_mem-0.21.0/src/hl_mem/api/server.py +659 -0
- hl_mem-0.21.0/src/hl_mem/application/__init__.py +7 -0
- hl_mem-0.21.0/src/hl_mem/application/context_packet.py +295 -0
- hl_mem-0.21.0/src/hl_mem/application/correction.py +397 -0
- hl_mem-0.21.0/src/hl_mem/application/forget.py +39 -0
- hl_mem-0.21.0/src/hl_mem/application/health.py +14 -0
- hl_mem-0.21.0/src/hl_mem/application/ingest.py +689 -0
- hl_mem-0.21.0/src/hl_mem/application/memories.py +113 -0
- hl_mem-0.21.0/src/hl_mem/application/recall.py +998 -0
- hl_mem-0.21.0/src/hl_mem/cli.py +518 -0
- hl_mem-0.21.0/src/hl_mem/components.py +226 -0
- hl_mem-0.21.0/src/hl_mem/config.py +8 -0
- hl_mem-0.21.0/src/hl_mem/config_loader.py +239 -0
- hl_mem-0.21.0/src/hl_mem/core/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/core/vector.py +85 -0
- hl_mem-0.21.0/src/hl_mem/daily_cli.py +285 -0
- hl_mem-0.21.0/src/hl_mem/doctor.py +274 -0
- hl_mem-0.21.0/src/hl_mem/domain/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/domain/claims/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/domain/claims/attributes.py +687 -0
- hl_mem-0.21.0/src/hl_mem/domain/claims/claim.py +91 -0
- hl_mem-0.21.0/src/hl_mem/domain/claims/conflicts.py +150 -0
- hl_mem-0.21.0/src/hl_mem/domain/claims/dedup.py +114 -0
- hl_mem-0.21.0/src/hl_mem/domain/claims/query_tags.py +89 -0
- hl_mem-0.21.0/src/hl_mem/domain/claims/retention.py +118 -0
- hl_mem-0.21.0/src/hl_mem/domain/consolidation_scope.py +17 -0
- hl_mem-0.21.0/src/hl_mem/domain/constants.py +52 -0
- hl_mem-0.21.0/src/hl_mem/domain/content.py +159 -0
- hl_mem-0.21.0/src/hl_mem/domain/entity.py +119 -0
- hl_mem-0.21.0/src/hl_mem/domain/feedback.py +37 -0
- hl_mem-0.21.0/src/hl_mem/domain/recall.py +64 -0
- hl_mem-0.21.0/src/hl_mem/domain/relations.py +212 -0
- hl_mem-0.21.0/src/hl_mem/domain/temporal.py +59 -0
- hl_mem-0.21.0/src/hl_mem/errors.py +37 -0
- hl_mem-0.21.0/src/hl_mem/evaluation/__init__.py +6 -0
- hl_mem-0.21.0/src/hl_mem/evaluation/longmemeval.py +241 -0
- hl_mem-0.21.0/src/hl_mem/evaluation/metrics.py +155 -0
- hl_mem-0.21.0/src/hl_mem/evaluation/models.py +56 -0
- hl_mem-0.21.0/src/hl_mem/evaluation/reporting.py +90 -0
- hl_mem-0.21.0/src/hl_mem/evaluation/runner.py +364 -0
- hl_mem-0.21.0/src/hl_mem/experience/__init__.py +5 -0
- hl_mem-0.21.0/src/hl_mem/experience/service.py +30 -0
- hl_mem-0.21.0/src/hl_mem/http_utils.py +39 -0
- hl_mem-0.21.0/src/hl_mem/ingest/__init__.py +8 -0
- hl_mem-0.21.0/src/hl_mem/ingest/budget.py +72 -0
- hl_mem-0.21.0/src/hl_mem/ingest/chunking.py +220 -0
- hl_mem-0.21.0/src/hl_mem/ingest/embedder.py +117 -0
- hl_mem-0.21.0/src/hl_mem/ingest/event_filter.py +78 -0
- hl_mem-0.21.0/src/hl_mem/ingest/extractors.py +79 -0
- hl_mem-0.21.0/src/hl_mem/ingest/image_describer.py +203 -0
- hl_mem-0.21.0/src/hl_mem/ingest/llm_extractor.py +831 -0
- hl_mem-0.21.0/src/hl_mem/ingest/pre_filter.py +179 -0
- hl_mem-0.21.0/src/hl_mem/ingest/repair.py +213 -0
- hl_mem-0.21.0/src/hl_mem/ingest/schemas.py +116 -0
- hl_mem-0.21.0/src/hl_mem/lifecycle.py +147 -0
- hl_mem-0.21.0/src/hl_mem/llm/__init__.py +25 -0
- hl_mem-0.21.0/src/hl_mem/llm/client.py +214 -0
- hl_mem-0.21.0/src/hl_mem/llm/providers.py +93 -0
- hl_mem-0.21.0/src/hl_mem/llm/types.py +80 -0
- hl_mem-0.21.0/src/hl_mem/mcp/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/mcp/__main__.py +6 -0
- hl_mem-0.21.0/src/hl_mem/mcp/runtime.py +106 -0
- hl_mem-0.21.0/src/hl_mem/mcp/server.py +429 -0
- hl_mem-0.21.0/src/hl_mem/monitoring/__init__.py +16 -0
- hl_mem-0.21.0/src/hl_mem/monitoring/alerts.py +79 -0
- hl_mem-0.21.0/src/hl_mem/monitoring/channels.py +63 -0
- hl_mem-0.21.0/src/hl_mem/monitoring/metrics.py +100 -0
- hl_mem-0.21.0/src/hl_mem/monitoring/reports.py +27 -0
- hl_mem-0.21.0/src/hl_mem/monitoring/worker.py +78 -0
- hl_mem-0.21.0/src/hl_mem/observability/__init__.py +15 -0
- hl_mem-0.21.0/src/hl_mem/observability/audit.py +271 -0
- hl_mem-0.21.0/src/hl_mem/observability/llm_spans.py +108 -0
- hl_mem-0.21.0/src/hl_mem/protocols.py +275 -0
- hl_mem-0.21.0/src/hl_mem/recall/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/recall/calibration.py +76 -0
- hl_mem-0.21.0/src/hl_mem/recall/extended_pipeline.py +9 -0
- hl_mem-0.21.0/src/hl_mem/recall/lexicalizer.py +70 -0
- hl_mem-0.21.0/src/hl_mem/recall/observation.py +48 -0
- hl_mem-0.21.0/src/hl_mem/recall/procedure_pipeline.py +211 -0
- hl_mem-0.21.0/src/hl_mem/recall/query_expansion.py +250 -0
- hl_mem-0.21.0/src/hl_mem/recall/ranking.py +81 -0
- hl_mem-0.21.0/src/hl_mem/recall/recall_pipeline.py +57 -0
- hl_mem-0.21.0/src/hl_mem/recall/relation_expansion.py +193 -0
- hl_mem-0.21.0/src/hl_mem/recall/relevance.py +190 -0
- hl_mem-0.21.0/src/hl_mem/recall/reranker.py +138 -0
- hl_mem-0.21.0/src/hl_mem/recall/resources/domain_terms.txt +25 -0
- hl_mem-0.21.0/src/hl_mem/recall/resources/stopwords.txt +4 -0
- hl_mem-0.21.0/src/hl_mem/recall/staged_pipeline.py +835 -0
- hl_mem-0.21.0/src/hl_mem/recall/trace.py +264 -0
- hl_mem-0.21.0/src/hl_mem/security/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/security/retention.py +25 -0
- hl_mem-0.21.0/src/hl_mem/server.py +54 -0
- hl_mem-0.21.0/src/hl_mem/settings.py +803 -0
- hl_mem-0.21.0/src/hl_mem/storage/__init__.py +5 -0
- hl_mem-0.21.0/src/hl_mem/storage/_shared.py +104 -0
- hl_mem-0.21.0/src/hl_mem/storage/backup.py +201 -0
- hl_mem-0.21.0/src/hl_mem/storage/claims.py +693 -0
- hl_mem-0.21.0/src/hl_mem/storage/database.py +164 -0
- hl_mem-0.21.0/src/hl_mem/storage/events.py +186 -0
- hl_mem-0.21.0/src/hl_mem/storage/evidence.py +95 -0
- hl_mem-0.21.0/src/hl_mem/storage/experience.py +666 -0
- hl_mem-0.21.0/src/hl_mem/storage/jobs.py +173 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/001_initial.sql +141 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/002_claims_fts_subject.sql +22 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/003_fact_hash.sql +2 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/004_audit_log.sql +42 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/005_memory_management.sql +22 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/006_canonical_attribute.sql +8 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/007_supersede_and_consolidation.sql +30 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/008_experience.sql +56 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/009_derived_memory.sql +4 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/010_experience_constraints.sql +54 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/011_fact_hash_v2.sql +3 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/012_status_check.sql +3 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/013_conflict_cases.sql +17 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/014_memory_relations.sql +14 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/015_lease_token.sql +1 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/016_claim_slots_and_tags.sql +6 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/017_dedup_pairs.sql +23 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/018_claims_tags_fts.sql +26 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/019_llm_call_spans.sql +24 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/020_job_progress.sql +5 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/021_claim_temporal_entities.sql +3 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/022_fts_trigram.sql +81 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/023_relation_proposals.sql +31 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/024_memory_usefulness.sql +23 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/025_memory_usefulness_episode_trace.sql +52 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/026_relation_proposals_run_id.sql +77 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/027_tags_fts_trigger_narrow.sql +10 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/028_relation_proposals_drop_mode_unique.sql +76 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/029_ttl_scan_indexes.sql +6 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/030_events_fts_fix.sql +32 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/031_claim_index_text.sql +33 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/032_provider_calls.sql +16 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/033_claims_fts_trigger_narrow.sql +8 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/034_fix_claims_fts_column_name.sql +28 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/035_retrieval_feedback_injected.sql +1 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/036_tokenized_fts_v2.sql +28 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/backfill_claim_slots_v1.py +179 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/backfill_conflict_key_v2.py +79 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/backfill_conflict_key_v3.py +71 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/fact_hash_v2.py +60 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/snapshots/__init__.py +1 -0
- hl_mem-0.21.0/src/hl_mem/storage/migrations/snapshots/v006_snapshot.py +504 -0
- hl_mem-0.21.0/src/hl_mem/storage/postgres.py +35 -0
- hl_mem-0.21.0/src/hl_mem/storage/relation_proposals.py +69 -0
- hl_mem-0.21.0/src/hl_mem/storage/tokenized_fts.py +119 -0
- hl_mem-0.21.0/src/hl_mem/storage/usefulness.py +156 -0
- hl_mem-0.21.0/src/hl_mem/workers/__init__.py +5 -0
- hl_mem-0.21.0/src/hl_mem/workers/backfill_expires_at.py +152 -0
- hl_mem-0.21.0/src/hl_mem/workers/backfill_index_text.py +316 -0
- hl_mem-0.21.0/src/hl_mem/workers/backfill_short_ttl.py +144 -0
- hl_mem-0.21.0/src/hl_mem/workers/backfill_tokenized_fts.py +30 -0
- hl_mem-0.21.0/src/hl_mem/workers/consolidate.py +404 -0
- hl_mem-0.21.0/src/hl_mem/workers/decay.py +179 -0
- hl_mem-0.21.0/src/hl_mem/workers/dedup_judge.py +75 -0
- hl_mem-0.21.0/src/hl_mem/workers/deduplicate.py +242 -0
- hl_mem-0.21.0/src/hl_mem/workers/discover_relations.py +445 -0
- hl_mem-0.21.0/src/hl_mem/workers/index_integrity.py +242 -0
- hl_mem-0.21.0/src/hl_mem/workers/induce_policies.py +90 -0
- hl_mem-0.21.0/src/hl_mem/workers/mental_models.py +145 -0
- hl_mem-0.21.0/src/hl_mem/workers/read_only.py +25 -0
- hl_mem-0.21.0/src/hl_mem/workers/rebuild_usefulness.py +26 -0
- hl_mem-0.21.0/src/hl_mem/workers/reclassify.py +229 -0
- hl_mem-0.21.0/src/hl_mem/workers/repair_conflict_losers.py +138 -0
- hl_mem-0.21.0/src/hl_mem/workers/scheduling.py +49 -0
- hl_mem-0.21.0/src/hl_mem/workers/ttl.py +77 -0
- hl_mem-0.21.0/src/hl_mem/workers/worker.py +818 -0
- hl_mem-0.21.0/start_hl_mem.sh +21 -0
- hl_mem-0.21.0/start_production.bat +19 -0
- hl_mem-0.21.0/start_server.py +6 -0
- hl_mem-0.21.0/tests/__init__.py +1 -0
- hl_mem-0.21.0/tests/conftest.py +35 -0
- hl_mem-0.21.0/tests/eval/README.md +29 -0
- hl_mem-0.21.0/tests/eval/__init__.py +1 -0
- hl_mem-0.21.0/tests/eval/bench_vector_search.py +77 -0
- hl_mem-0.21.0/tests/eval/ci_gate.py +198 -0
- hl_mem-0.21.0/tests/eval/conftest.py +52 -0
- hl_mem-0.21.0/tests/eval/dataset.py +214 -0
- hl_mem-0.21.0/tests/eval/eval_runner.py +478 -0
- hl_mem-0.21.0/tests/eval/fixtures/__init__.py +1 -0
- hl_mem-0.21.0/tests/eval/fixtures/build_ci_snapshot.py +206 -0
- hl_mem-0.21.0/tests/eval/fixtures/build_snapshot.py +82 -0
- hl_mem-0.21.0/tests/eval/gate_check.py +108 -0
- hl_mem-0.21.0/tests/eval/gate_v019.json +39 -0
- hl_mem-0.21.0/tests/eval/metrics.py +186 -0
- hl_mem-0.21.0/tests/eval/release_config_v019.json +23 -0
- hl_mem-0.21.0/tests/eval/repair_manifest_v019.json +17 -0
- hl_mem-0.21.0/tests/eval/reports/.gitkeep +1 -0
- hl_mem-0.21.0/tests/eval/runner.py +158 -0
- hl_mem-0.21.0/tests/eval/test_chinese_fts.py +147 -0
- hl_mem-0.21.0/tests/eval/test_ci_fixture_hash.py +33 -0
- hl_mem-0.21.0/tests/eval/test_dataset_schema.py +170 -0
- hl_mem-0.21.0/tests/eval/test_metrics.py +166 -0
- hl_mem-0.21.0/tests/eval/test_no_answer_eval.py +25 -0
- hl_mem-0.21.0/tests/eval/test_recall_eval.py +26 -0
- hl_mem-0.21.0/tests/eval/test_recall_v2_gate.py +260 -0
- hl_mem-0.21.0/tests/eval/test_runner.py +105 -0
- hl_mem-0.21.0/tests/eval/test_temporal_eval.py +36 -0
- hl_mem-0.21.0/tests/fixtures/longmemeval_small.json +67 -0
- hl_mem-0.21.0/tests/fixtures/v010_after_018.sql +32 -0
- hl_mem-0.21.0/tests/integration/__init__.py +1 -0
- hl_mem-0.21.0/tests/integration/test_conflict_pipeline.py +34 -0
- hl_mem-0.21.0/tests/integration/test_context_packet_feedback.py +137 -0
- hl_mem-0.21.0/tests/integration/test_e2e.py +101 -0
- hl_mem-0.21.0/tests/integration/test_extract_pipeline.py +62 -0
- hl_mem-0.21.0/tests/integration/test_forget.py +20 -0
- hl_mem-0.21.0/tests/integration/test_hermes_delivery.py +118 -0
- hl_mem-0.21.0/tests/integration/test_p0p1_integration.py +220 -0
- hl_mem-0.21.0/tests/scenarios/__init__.py +1 -0
- hl_mem-0.21.0/tests/scenarios/chinese_test_cases.py +50 -0
- hl_mem-0.21.0/tests/scenarios/conftest.py +12 -0
- hl_mem-0.21.0/tests/test_e2e_real.py +159 -0
- hl_mem-0.21.0/tests/test_migration_upgrade.py +134 -0
- hl_mem-0.21.0/tests/unit/__init__.py +1 -0
- hl_mem-0.21.0/tests/unit/test_answerable_index.py +605 -0
- hl_mem-0.21.0/tests/unit/test_api_observability.py +78 -0
- hl_mem-0.21.0/tests/unit/test_attribute_map.py +113 -0
- hl_mem-0.21.0/tests/unit/test_audit.py +61 -0
- hl_mem-0.21.0/tests/unit/test_backfill_conflict_key_v2.py +96 -0
- hl_mem-0.21.0/tests/unit/test_backfill_tokenized_fts.py +177 -0
- hl_mem-0.21.0/tests/unit/test_backup_cli.py +195 -0
- hl_mem-0.21.0/tests/unit/test_batch_cosine.py +104 -0
- hl_mem-0.21.0/tests/unit/test_benchmark.py +194 -0
- hl_mem-0.21.0/tests/unit/test_benchmark_extraction.py +79 -0
- hl_mem-0.21.0/tests/unit/test_budget.py +22 -0
- hl_mem-0.21.0/tests/unit/test_claim_temporal_entities.py +132 -0
- hl_mem-0.21.0/tests/unit/test_clean_disputed_claims.py +119 -0
- hl_mem-0.21.0/tests/unit/test_cleanup_duplicates_v3.py +183 -0
- hl_mem-0.21.0/tests/unit/test_comprehensive_fixes.py +300 -0
- hl_mem-0.21.0/tests/unit/test_concurrency.py +166 -0
- hl_mem-0.21.0/tests/unit/test_config_assembly.py +46 -0
- hl_mem-0.21.0/tests/unit/test_config_loader.py +181 -0
- hl_mem-0.21.0/tests/unit/test_conflict.py +120 -0
- hl_mem-0.21.0/tests/unit/test_conftest_environment.py +40 -0
- hl_mem-0.21.0/tests/unit/test_consolidate.py +165 -0
- hl_mem-0.21.0/tests/unit/test_consolidation_scope.py +127 -0
- hl_mem-0.21.0/tests/unit/test_context_packet.py +220 -0
- hl_mem-0.21.0/tests/unit/test_daily_cli.py +214 -0
- hl_mem-0.21.0/tests/unit/test_daily_memory_api.py +253 -0
- hl_mem-0.21.0/tests/unit/test_decay.py +291 -0
- hl_mem-0.21.0/tests/unit/test_dedup.py +45 -0
- hl_mem-0.21.0/tests/unit/test_doctor.py +71 -0
- hl_mem-0.21.0/tests/unit/test_dry_run_extract.py +71 -0
- hl_mem-0.21.0/tests/unit/test_embeddings.py +38 -0
- hl_mem-0.21.0/tests/unit/test_entity.py +36 -0
- hl_mem-0.21.0/tests/unit/test_event_filter.py +41 -0
- hl_mem-0.21.0/tests/unit/test_experience_api.py +144 -0
- hl_mem-0.21.0/tests/unit/test_experience_policy.py +196 -0
- hl_mem-0.21.0/tests/unit/test_explicit_save_idempotency.py +151 -0
- hl_mem-0.21.0/tests/unit/test_extended_recall.py +24 -0
- hl_mem-0.21.0/tests/unit/test_extraction_batch_a.py +123 -0
- hl_mem-0.21.0/tests/unit/test_extraction_chunking.py +152 -0
- hl_mem-0.21.0/tests/unit/test_extraction_pre_filter.py +299 -0
- hl_mem-0.21.0/tests/unit/test_extraction_prompt_quality.py +53 -0
- hl_mem-0.21.0/tests/unit/test_extraction_repair.py +196 -0
- hl_mem-0.21.0/tests/unit/test_extractor_subject_guard.py +41 -0
- hl_mem-0.21.0/tests/unit/test_extractors.py +34 -0
- hl_mem-0.21.0/tests/unit/test_feedback_lifecycle.py +178 -0
- hl_mem-0.21.0/tests/unit/test_fts_trigram_behavior.py +156 -0
- hl_mem-0.21.0/tests/unit/test_healthcheck.py +70 -0
- hl_mem-0.21.0/tests/unit/test_hermes_renderer.py +71 -0
- hl_mem-0.21.0/tests/unit/test_hlmem_supervisor.py +578 -0
- hl_mem-0.21.0/tests/unit/test_hybrid_priors.py +252 -0
- hl_mem-0.21.0/tests/unit/test_image_evidence.py +70 -0
- hl_mem-0.21.0/tests/unit/test_index_integrity.py +251 -0
- hl_mem-0.21.0/tests/unit/test_induce_policies.py +155 -0
- hl_mem-0.21.0/tests/unit/test_ingest_schemas.py +70 -0
- hl_mem-0.21.0/tests/unit/test_install_to_hermes.py +18 -0
- hl_mem-0.21.0/tests/unit/test_job_progress.py +85 -0
- hl_mem-0.21.0/tests/unit/test_jsonl_import.py +209 -0
- hl_mem-0.21.0/tests/unit/test_lexicalizer.py +46 -0
- hl_mem-0.21.0/tests/unit/test_lifecycle_policy_derivation.py +37 -0
- hl_mem-0.21.0/tests/unit/test_llm_client.py +143 -0
- hl_mem-0.21.0/tests/unit/test_llm_extractor.py +184 -0
- hl_mem-0.21.0/tests/unit/test_llm_providers.py +107 -0
- hl_mem-0.21.0/tests/unit/test_llm_spans.py +105 -0
- hl_mem-0.21.0/tests/unit/test_llm_thinking_settings.py +46 -0
- hl_mem-0.21.0/tests/unit/test_m4_recall_semantics.py +152 -0
- hl_mem-0.21.0/tests/unit/test_maintenance_scan_indexes.py +33 -0
- hl_mem-0.21.0/tests/unit/test_management_surfaces.py +66 -0
- hl_mem-0.21.0/tests/unit/test_mcp_runtime.py +141 -0
- hl_mem-0.21.0/tests/unit/test_memory_api_idempotency_namespace.py +123 -0
- hl_mem-0.21.0/tests/unit/test_memory_correction.py +444 -0
- hl_mem-0.21.0/tests/unit/test_mental_models.py +54 -0
- hl_mem-0.21.0/tests/unit/test_migration_022_trigram.py +141 -0
- hl_mem-0.21.0/tests/unit/test_migration_036_tokenized_fts.py +146 -0
- hl_mem-0.21.0/tests/unit/test_monitoring.py +57 -0
- hl_mem-0.21.0/tests/unit/test_observation.py +23 -0
- hl_mem-0.21.0/tests/unit/test_p0_1_usefulness_episode_trace.py +78 -0
- hl_mem-0.21.0/tests/unit/test_p0_2_ttl_bonus_valid_to.py +161 -0
- hl_mem-0.21.0/tests/unit/test_p0_3_relation_concurrent.py +112 -0
- hl_mem-0.21.0/tests/unit/test_p1_1_component_degradation.py +49 -0
- hl_mem-0.21.0/tests/unit/test_p1_3_relation_proposal_runs.py +89 -0
- hl_mem-0.21.0/tests/unit/test_p1_4_tags_fts_trigger.py +35 -0
- hl_mem-0.21.0/tests/unit/test_p1_5_like_escape.py +66 -0
- hl_mem-0.21.0/tests/unit/test_p1_8_settings_modes.py +37 -0
- hl_mem-0.21.0/tests/unit/test_p1_9_recall_side_effects.py +63 -0
- hl_mem-0.21.0/tests/unit/test_pipeline.py +82 -0
- hl_mem-0.21.0/tests/unit/test_procedure_intent.py +43 -0
- hl_mem-0.21.0/tests/unit/test_production_boundaries.py +56 -0
- hl_mem-0.21.0/tests/unit/test_projection_consistency.py +265 -0
- hl_mem-0.21.0/tests/unit/test_provider.py +963 -0
- hl_mem-0.21.0/tests/unit/test_quality_smoke_hash.py +65 -0
- hl_mem-0.21.0/tests/unit/test_query_expansion.py +241 -0
- hl_mem-0.21.0/tests/unit/test_query_expansion_settings.py +35 -0
- hl_mem-0.21.0/tests/unit/test_query_tags.py +49 -0
- hl_mem-0.21.0/tests/unit/test_recall_context.py +14 -0
- hl_mem-0.21.0/tests/unit/test_recall_diagnostic_scripts.py +355 -0
- hl_mem-0.21.0/tests/unit/test_recall_fold_temporal_cleanup.py +431 -0
- hl_mem-0.21.0/tests/unit/test_recall_observation_stopgap.py +22 -0
- hl_mem-0.21.0/tests/unit/test_recall_score_output.py +92 -0
- hl_mem-0.21.0/tests/unit/test_reclassify.py +49 -0
- hl_mem-0.21.0/tests/unit/test_relation_discovery.py +170 -0
- hl_mem-0.21.0/tests/unit/test_relation_expansion.py +166 -0
- hl_mem-0.21.0/tests/unit/test_relevance_gate.py +399 -0
- hl_mem-0.21.0/tests/unit/test_repair_double_encoded.py +299 -0
- hl_mem-0.21.0/tests/unit/test_repository.py +95 -0
- hl_mem-0.21.0/tests/unit/test_reranker.py +165 -0
- hl_mem-0.21.0/tests/unit/test_reranker_registry.py +30 -0
- hl_mem-0.21.0/tests/unit/test_scope_normalization.py +127 -0
- hl_mem-0.21.0/tests/unit/test_search_trace.py +189 -0
- hl_mem-0.21.0/tests/unit/test_session_context.py +221 -0
- hl_mem-0.21.0/tests/unit/test_settings_contract.py +97 -0
- hl_mem-0.21.0/tests/unit/test_startup_scripts.py +123 -0
- hl_mem-0.21.0/tests/unit/test_tag_boost.py +230 -0
- hl_mem-0.21.0/tests/unit/test_text_search_backend.py +42 -0
- hl_mem-0.21.0/tests/unit/test_tokenized_fts_repository.py +125 -0
- hl_mem-0.21.0/tests/unit/test_ttl.py +75 -0
- hl_mem-0.21.0/tests/unit/test_v015_recall_monitoring.py +92 -0
- hl_mem-0.21.0/tests/unit/test_v021_repairs.py +309 -0
- hl_mem-0.21.0/tests/unit/test_v091_fixes.py +290 -0
- hl_mem-0.21.0/tests/unit/test_vector_backend_protocol.py +48 -0
- hl_mem-0.21.0/tests/unit/test_worker.py +145 -0
- hl_mem-0.21.0/uv.lock +1531 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.sh text eol=lf
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
## Type of change
|
|
4
|
+
|
|
5
|
+
- [ ] Bug fix
|
|
6
|
+
- [ ] New feature
|
|
7
|
+
- [ ] Refactor
|
|
8
|
+
- [ ] Documentation
|
|
9
|
+
- [ ] CI/Tooling
|
|
10
|
+
|
|
11
|
+
## Contract checklist
|
|
12
|
+
|
|
13
|
+
- [ ] REST API changed? → update `docs/api-schema.json` snapshot
|
|
14
|
+
- [ ] MCP tools changed? → update `docs/mcp-tools.json` snapshot
|
|
15
|
+
- [ ] Config env vars changed? → update `.env.example` + compatibility policy
|
|
16
|
+
- [ ] SQLite schema changed? → new migration + snapshot upgrade test
|
|
17
|
+
- [ ] Breaking change? → deprecation notice in CHANGELOG
|
|
18
|
+
|
|
19
|
+
## Test plan
|
|
20
|
+
|
|
21
|
+
- [ ] `python scripts/check_docs_consistency.py` passes
|
|
22
|
+
- [ ] `python scripts/check_imports.py` passes
|
|
23
|
+
- [ ] `ruff check src/` passes
|
|
24
|
+
- [ ] Existing tests not broken
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distributions
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v5
|
|
16
|
+
- uses: actions/setup-python@v6
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.11"
|
|
19
|
+
- name: Validate tag matches project version
|
|
20
|
+
env:
|
|
21
|
+
RELEASE_TAG: ${{ github.ref_name }}
|
|
22
|
+
run: |
|
|
23
|
+
python - <<'PY'
|
|
24
|
+
import os
|
|
25
|
+
import tomllib
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
project = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))["project"]
|
|
29
|
+
expected_tag = f"v{project['version']}"
|
|
30
|
+
actual_tag = os.environ["RELEASE_TAG"]
|
|
31
|
+
if actual_tag != expected_tag:
|
|
32
|
+
raise SystemExit(f"release tag {actual_tag!r} does not match project version {expected_tag!r}")
|
|
33
|
+
PY
|
|
34
|
+
- name: Build wheel and source distribution
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install --upgrade build
|
|
37
|
+
python -m build
|
|
38
|
+
- uses: actions/upload-artifact@v7
|
|
39
|
+
with:
|
|
40
|
+
name: python-package-distributions
|
|
41
|
+
path: dist/
|
|
42
|
+
|
|
43
|
+
publish:
|
|
44
|
+
name: Publish distributions
|
|
45
|
+
needs: build
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
environment:
|
|
48
|
+
name: pypi
|
|
49
|
+
url: https://pypi.org/p/hl-mem
|
|
50
|
+
permissions:
|
|
51
|
+
id-token: write
|
|
52
|
+
steps:
|
|
53
|
+
- uses: actions/download-artifact@v8
|
|
54
|
+
with:
|
|
55
|
+
name: python-package-distributions
|
|
56
|
+
path: dist/
|
|
57
|
+
# 首次创建 PyPI 项目前,需在账户 Publishing 页面添加 pending publisher;项目存在后可在设置中维护。
|
|
58
|
+
# 需绑定 GitHub publisher(owner lohr13、repository hl_mem、workflow publish.yml、environment pypi)。
|
|
59
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
60
|
+
with:
|
|
61
|
+
packages-dir: dist/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Quality Smoke
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
schedule:
|
|
6
|
+
- cron: "0 2 * * *"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
smoke:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v5
|
|
13
|
+
- uses: actions/setup-python@v6
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.11"
|
|
16
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
17
|
+
- run: uv sync --frozen
|
|
18
|
+
- run: uv run --frozen python scripts/run_quality_smoke.py
|
|
19
|
+
- uses: actions/upload-artifact@v7 # Node 24
|
|
20
|
+
with:
|
|
21
|
+
name: quality-smoke-${{ github.sha }}
|
|
22
|
+
path: evaluation/results/
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
tags: ['v*']
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.11", "3.12"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
|
+
- uses: actions/setup-python@v6
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: uv sync --frozen
|
|
25
|
+
- name: Run full test suite
|
|
26
|
+
env:
|
|
27
|
+
HL_MEM_ENV: test
|
|
28
|
+
run: |
|
|
29
|
+
uv run --frozen python -m pytest tests/ -q --tb=short --cov=hl_mem --cov-report=term-missing --cov-fail-under=60
|
|
30
|
+
- name: Run migration upgrade test
|
|
31
|
+
run: uv run --frozen python -m pytest tests/test_migration_upgrade.py -q --tb=short
|
|
32
|
+
|
|
33
|
+
lint:
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v5
|
|
37
|
+
- uses: actions/setup-python@v6
|
|
38
|
+
with:
|
|
39
|
+
python-version: "3.11"
|
|
40
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
41
|
+
- run: uv sync --frozen
|
|
42
|
+
- run: uv run --frozen ruff check .
|
|
43
|
+
|
|
44
|
+
type-check:
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v5
|
|
48
|
+
- uses: actions/setup-python@v6
|
|
49
|
+
with:
|
|
50
|
+
python-version: "3.11"
|
|
51
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
52
|
+
- run: uv sync --frozen
|
|
53
|
+
- run: uv run --frozen python -m mypy src/hl_mem/ --ignore-missing-imports
|
|
54
|
+
|
|
55
|
+
quality-smoke:
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/checkout@v5
|
|
59
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
60
|
+
- run: uv sync --frozen
|
|
61
|
+
- run: uv run --frozen python scripts/run_quality_smoke.py
|
|
62
|
+
|
|
63
|
+
recall-gate:
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
steps:
|
|
66
|
+
- uses: actions/checkout@v5
|
|
67
|
+
- uses: actions/setup-python@v6
|
|
68
|
+
with:
|
|
69
|
+
python-version: "3.11"
|
|
70
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
71
|
+
- run: uv sync --frozen
|
|
72
|
+
- name: Run offline recall contract and fixture gate
|
|
73
|
+
if: ${{ hashFiles('tests/eval/datasets/recall_v2.jsonl') != '' && hashFiles('tests/eval/datasets/recall_v2.manifest.json') != '' && hashFiles('tests/eval/baselines/baseline_v019_ci.json') != '' }}
|
|
74
|
+
run: uv run --frozen python -m tests.eval.ci_gate
|
|
75
|
+
- name: Report unavailable private recall fixtures
|
|
76
|
+
if: ${{ hashFiles('tests/eval/datasets/recall_v2.jsonl') == '' || hashFiles('tests/eval/datasets/recall_v2.manifest.json') == '' || hashFiles('tests/eval/baselines/baseline_v019_ci.json') == '' }}
|
|
77
|
+
run: echo "Recall fixture gate skipped because private evaluation artifacts are not checked into Git."
|
|
78
|
+
|
|
79
|
+
format:
|
|
80
|
+
runs-on: ubuntu-latest
|
|
81
|
+
steps:
|
|
82
|
+
- uses: actions/checkout@v5
|
|
83
|
+
- uses: actions/setup-python@v6
|
|
84
|
+
with:
|
|
85
|
+
python-version: "3.11"
|
|
86
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
87
|
+
- run: uv sync --frozen
|
|
88
|
+
- name: Check formatting
|
|
89
|
+
run: |
|
|
90
|
+
uv run --frozen black --check .
|
|
91
|
+
uv run --frozen isort --check-only .
|
|
92
|
+
|
|
93
|
+
build:
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
strategy:
|
|
96
|
+
matrix:
|
|
97
|
+
python-version: ["3.11", "3.12"]
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/checkout@v5
|
|
100
|
+
- uses: actions/setup-python@v6
|
|
101
|
+
with:
|
|
102
|
+
python-version: ${{ matrix.python-version }}
|
|
103
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
104
|
+
- run: uv sync --frozen
|
|
105
|
+
- name: Build wheel and source distribution
|
|
106
|
+
run: uv run --frozen python -m build
|
|
107
|
+
- name: Verify import in a clean environment
|
|
108
|
+
run: |
|
|
109
|
+
python -m venv .build-venv
|
|
110
|
+
.build-venv/bin/python -m pip install --upgrade pip
|
|
111
|
+
.build-venv/bin/python -m pip install dist/*.whl
|
|
112
|
+
.build-venv/bin/python -c "import hl_mem; print(hl_mem.__version__)"
|
|
113
|
+
|
|
114
|
+
migrations:
|
|
115
|
+
runs-on: ubuntu-latest
|
|
116
|
+
strategy:
|
|
117
|
+
matrix:
|
|
118
|
+
python-version: ["3.11", "3.12"]
|
|
119
|
+
steps:
|
|
120
|
+
- uses: actions/checkout@v5
|
|
121
|
+
- uses: actions/setup-python@v6
|
|
122
|
+
with:
|
|
123
|
+
python-version: ${{ matrix.python-version }}
|
|
124
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
125
|
+
- run: uv sync --frozen
|
|
126
|
+
- name: Apply migrations from an empty database
|
|
127
|
+
run: |
|
|
128
|
+
uv run --frozen python -c "import tempfile; from pathlib import Path; from hl_mem.storage.database import Database; path = Path(tempfile.mkdtemp()) / 'fresh.db'; db = Database(path); connection = db.open(); applied = {row[0] for row in connection.execute('SELECT version FROM schema_migrations')}; expected = {path.stem for path in Path('src/hl_mem/storage/migrations').glob('*.sql')}; missing = expected - applied; assert not missing, f'missing SQL migrations: {sorted(missing)}'; db.close(); print(f'applied {len(expected)} SQL migrations')"
|
|
129
|
+
|
|
130
|
+
import-boundary:
|
|
131
|
+
runs-on: ubuntu-latest
|
|
132
|
+
steps:
|
|
133
|
+
- uses: actions/checkout@v5
|
|
134
|
+
- uses: actions/setup-python@v6
|
|
135
|
+
with:
|
|
136
|
+
python-version: "3.11"
|
|
137
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
138
|
+
- run: uv sync --frozen
|
|
139
|
+
- name: Check dependency direction
|
|
140
|
+
run: uv run --frozen python scripts/check_imports.py
|
|
141
|
+
|
|
142
|
+
doc-consistency:
|
|
143
|
+
runs-on: ubuntu-latest
|
|
144
|
+
steps:
|
|
145
|
+
- uses: actions/checkout@v5
|
|
146
|
+
- uses: actions/setup-python@v6
|
|
147
|
+
with:
|
|
148
|
+
python-version: "3.11"
|
|
149
|
+
- run: python scripts/check_docs_consistency.py
|
|
150
|
+
|
|
151
|
+
contract-snapshots:
|
|
152
|
+
# NOTE: Snapshot mismatch means contract changed.
|
|
153
|
+
# Reviewers must verify this is intentional before approving.
|
|
154
|
+
runs-on: ubuntu-latest
|
|
155
|
+
steps:
|
|
156
|
+
- uses: actions/checkout@v5
|
|
157
|
+
- uses: actions/setup-python@v6
|
|
158
|
+
with:
|
|
159
|
+
python-version: "3.11"
|
|
160
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2, Node 24
|
|
161
|
+
- run: uv sync --frozen
|
|
162
|
+
- name: Check OpenAPI and MCP contracts
|
|
163
|
+
run: |
|
|
164
|
+
uv run --frozen python scripts/check_openapi_snapshot.py
|
|
165
|
+
uv run --frozen python scripts/check_mcp_snapshot.py
|
hl_mem-0.21.0/.gitignore
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.pyo
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
*.db
|
|
6
|
+
*.egg-info/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.venv/
|
|
10
|
+
hl_mem_test.db
|
|
11
|
+
hl_mem_budget_test.json
|
|
12
|
+
.env
|
|
13
|
+
.env.bak*
|
|
14
|
+
hl_mem.toml
|
|
15
|
+
*.db
|
|
16
|
+
*.db-*
|
|
17
|
+
*.budget.json
|
|
18
|
+
var/*.db
|
|
19
|
+
var/*.db-*
|
|
20
|
+
var/*.db.cleanup_backup_*
|
|
21
|
+
var/*.db.bak_*
|
|
22
|
+
var/*.db.bak.*
|
|
23
|
+
var/*.db.manifest.json
|
|
24
|
+
var/*.log
|
|
25
|
+
*.log
|
|
26
|
+
pytest_*.txt
|
|
27
|
+
pending_commits.txt
|
|
28
|
+
tests/eval/reports/*.json
|
|
29
|
+
evaluation/results/
|
|
30
|
+
scripts/*.stdout.log
|
|
31
|
+
scripts/*.stderr.log
|
|
32
|
+
scripts/*.pid
|
|
33
|
+
scripts/*.lock
|
|
34
|
+
scripts/*artifacts.txt
|
|
35
|
+
scripts/*.partial.jsonl
|
|
36
|
+
scripts/benchmark_runs/
|
|
37
|
+
scripts/extraction_benchmark_results*.jsonl
|
|
38
|
+
scripts/extraction_benchmark_results*.manifest.json
|
|
39
|
+
scripts/extraction_benchmark_results*.gold_eval.txt
|
|
40
|
+
scripts/extraction_benchmark_results*.analysis.md
|
|
41
|
+
scripts/extraction_benchmark_glm*.jsonl
|
|
42
|
+
scripts/glm52_*.jsonl
|
|
43
|
+
fix_env_ak.py
|
|
44
|
+
test_hermes_ak.py
|
|
45
|
+
|
|
46
|
+
# 评测数据和报告(包含敏感信息,不推送到公开仓库)
|
|
47
|
+
tests/eval/datasets/
|
|
48
|
+
tests/eval/baselines/
|
|
49
|
+
docs/eval-reports/
|
|
50
|
+
|
|
51
|
+
# cc-connect runtime artifacts (not part of this repo)
|
|
52
|
+
.cc-connect/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# hlmem watchdog runtime state
|
|
56
|
+
var/watchdog.state
|
|
57
|
+
var/crash-packages/
|
|
58
|
+
|
hl_mem-0.21.0/AGENTS.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# HL-Mem 项目 AGENTS.md
|
|
2
|
+
|
|
3
|
+
## 项目概述
|
|
4
|
+
|
|
5
|
+
HL-Mem 是面向 AI Agent 的本地优先记忆系统。核心设计:事件溯源双通道 + 双时间模型 + 证据链 + slot+tags 分类体系 + importance 联动 TTL + 多因子召回 + 完整生命周期管理。
|
|
6
|
+
|
|
7
|
+
**当前版本:v0.20.2(2026-08-02)**
|
|
8
|
+
|
|
9
|
+
## 技术栈
|
|
10
|
+
|
|
11
|
+
- **运行时**:Python 3.11+,FastAPI + uvicorn
|
|
12
|
+
- **存储**:SQLite WAL + FTS5(全文检索)+ 向量 BLOB(暴力余弦,首版)
|
|
13
|
+
- **LLM 提取**:API 密钥通过 .env 配置,provider/model 通过 TOML 配置,使用结构化 JSON 输出
|
|
14
|
+
- **Embedding**:API 密钥通过 .env 配置,provider/model/维度通过 TOML 配置
|
|
15
|
+
- **Reranker**:API 密钥通过 .env 配置,provider/model 通过 TOML 配置
|
|
16
|
+
- **分类体系**:SLOT_REGISTRY(15 operational slot + 40 topic tags;Phase 18 已接入检索,soft boost 默认开启,独立 tag channel 默认关闭待评测)
|
|
17
|
+
- **TTL**:retention 纯函数(scope × importance 三档)
|
|
18
|
+
- **跨 subject 去重**:DedupJudge(audit-only 默认开启)
|
|
19
|
+
- **包管理**:uv(lockfile: uv.lock)
|
|
20
|
+
- **测试**:pytest + pytest-asyncio(asyncio_mode=auto)730 passed,1 skipped
|
|
21
|
+
|
|
22
|
+
## 代码结构
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
src/hl_mem/
|
|
26
|
+
├── api/ # FastAPI 适配层
|
|
27
|
+
│ ├── server.py # REST API (16 routes)
|
|
28
|
+
│ └── schemas.py # Pydantic DTO
|
|
29
|
+
├── application/ # 共享应用服务
|
|
30
|
+
│ ├── ingest.py # IngestService
|
|
31
|
+
│ ├── recall.py # RecallService
|
|
32
|
+
│ └── forget.py # ForgetService
|
|
33
|
+
├── domain/ # 纯领域逻辑(不依赖基础设施)
|
|
34
|
+
│ ├── claims/ # claim 写入/冲突/去重/retention/query_tags
|
|
35
|
+
│ ├── temporal.py # 双时间可见性
|
|
36
|
+
│ ├── relations.py # 记忆关系
|
|
37
|
+
│ ├── entity.py # 实体归一化
|
|
38
|
+
│ ├── recall.py # 召回领域逻辑
|
|
39
|
+
│ └── content.py # 多模态内容协议
|
|
40
|
+
├── core/ # 纯数学
|
|
41
|
+
│ └── vector.py # cosine similarity
|
|
42
|
+
├── ingest/ # 数据摄入
|
|
43
|
+
│ ├── llm_extractor.py # LLM 提取器
|
|
44
|
+
│ ├── extractors.py # FakeExtractor / LLMExtractor
|
|
45
|
+
│ ├── chunking.py # 结构感知分块
|
|
46
|
+
│ ├── embedder.py # Embedding 向量化
|
|
47
|
+
│ ├── event_filter.py # 事件预过滤
|
|
48
|
+
│ └── budget.py # Token 预算控制
|
|
49
|
+
├── llm/ # LLM 客户端(Provider 解耦)
|
|
50
|
+
│ ├── client.py # LLMClient
|
|
51
|
+
│ ├── providers.py # 百炼/智谱/OpenAI-compatible
|
|
52
|
+
│ └── types.py # LLMRequest/LLMResponse
|
|
53
|
+
├── recall/ # 召回层
|
|
54
|
+
│ ├── staged_pipeline.py # 三通道 RRF (FTS + Dense + Tag)
|
|
55
|
+
│ ├── trace.py # SearchTrace 可观测性
|
|
56
|
+
│ ├── ranking.py # 多因子排序
|
|
57
|
+
│ ├── reranker.py # Reranker 重排
|
|
58
|
+
│ ├── relation_expansion.py # 一跳关系扩展
|
|
59
|
+
│ └── observation.py # 派生记忆构建
|
|
60
|
+
├── storage/ # 存储层(按职责拆分)
|
|
61
|
+
│ ├── database.py # SQLite WAL + migration runner
|
|
62
|
+
│ ├── claims.py # ClaimRepository
|
|
63
|
+
│ ├── events.py # EventRepository
|
|
64
|
+
│ ├── evidence.py # EvidenceRepository
|
|
65
|
+
│ ├── experience.py # ExperienceRepository
|
|
66
|
+
│ ├── jobs.py # JobRepository
|
|
67
|
+
│ ├── relation_proposals.py # 关系候选审计
|
|
68
|
+
│ ├── usefulness.py # 反馈效用聚合
|
|
69
|
+
│ ├── backup.py # 在线备份
|
|
70
|
+
│ └── migrations/ # 36 SQL migrations (001-036)
|
|
71
|
+
├── workers/ # 后台任务
|
|
72
|
+
│ ├── worker.py # Job 调度器
|
|
73
|
+
│ ├── ttl.py # TTL 过期
|
|
74
|
+
│ ├── decay.py # 置信度衰减
|
|
75
|
+
│ ├── consolidate.py # LLM 语义归并
|
|
76
|
+
│ ├── deduplicate.py # 跨 subject 语义去重
|
|
77
|
+
│ ├── backfill_expires_at.py # TTL 回填工具
|
|
78
|
+
│ ├── discover_relations.py # 关系候选发现
|
|
79
|
+
│ ├── mental_models.py # Mental Model 维护
|
|
80
|
+
│ ├── rebuild_usefulness.py # usefulness 重建
|
|
81
|
+
│ └── induce_policies.py # 策略归纳
|
|
82
|
+
├── experience/ # Experience 通道
|
|
83
|
+
│ └── service.py # Episode/Trace/Policy
|
|
84
|
+
├── evaluation/ # Benchmark / LongMemEval
|
|
85
|
+
├── observability/ # 审计日志与 LLM spans
|
|
86
|
+
├── security/ # retention 策略
|
|
87
|
+
├── adapters/hermes/ # Hermes 集成
|
|
88
|
+
│ ├── provider.py # HermesMemoryProvider
|
|
89
|
+
│ └── plugin/ # 薄委托层
|
|
90
|
+
├── mcp/
|
|
91
|
+
│ └── server.py # MCP 工具契约
|
|
92
|
+
├── components.py # 统一组件工厂
|
|
93
|
+
├── settings.py # Settings dataclass + 校验
|
|
94
|
+
├── protocols.py # 接口协议
|
|
95
|
+
├── errors.py # 异常族
|
|
96
|
+
├── http_utils.py # 统一重试工具
|
|
97
|
+
├── lifecycle.py # 状态机守卫
|
|
98
|
+
└── cli.py # CLI 入口
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 测试
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
.venv/Scripts/python.exe -m pytest tests/unit/ -q --tb=short
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
当前:730 passed,1 skipped。
|
|
108
|
+
|
|
109
|
+
## 关键设计决策
|
|
110
|
+
|
|
111
|
+
### 写入管线
|
|
112
|
+
- fact_hash v2(JSON 数组有边界哈希)→ conflict_key(canonical attribute slot)→ semantic dedup(cosine > 0.82, best-match)
|
|
113
|
+
- 冲突判定:确定性规则优先(ConflictResolver),灰区走 LLM 四分类(ConflictConsolidator)
|
|
114
|
+
- **事务原子化**:整个写入流程(update_status + insert_claim + supersede + evidence_link)在单一 BEGIN IMMEDIATE 中
|
|
115
|
+
|
|
116
|
+
### 召回管线
|
|
117
|
+
- FTS5 全文检索 + dense vector 余弦相似度 → RRF 融合
|
|
118
|
+
- 多因子排序:recency / importance / access_count / scope / helpful_rate
|
|
119
|
+
- 可选 Reranker(密钥与 provider/model 由配置提供)
|
|
120
|
+
- 双时间过滤:valid_from/valid_to + recorded_from/recorded_to
|
|
121
|
+
- **上下文预算**:token_budget + context_mode="packed" + 跨类型配额
|
|
122
|
+
- 偏好专用召回 intent(RecallIntent.PREFERENCE)
|
|
123
|
+
- **派生记忆接入**:recall 自动查询活跃 derivation 并填充 observations
|
|
124
|
+
|
|
125
|
+
### 生命周期管理
|
|
126
|
+
- TTL 过期(ephemeral)→ 线性衰减(temporal/permanent 分级)→ 归档(embedding 清空)→ 重分类
|
|
127
|
+
- 访问频率延缓衰减(每 10 次召回 +30 天)
|
|
128
|
+
- **冲突终态收敛**:conflict_cases 状态机(pending → auto_resolved/manual_required → resolved/rejected)
|
|
129
|
+
- stale 传播:claim 撤回时关联的 derivation 自动标记 stale
|
|
130
|
+
|
|
131
|
+
### 架构分层
|
|
132
|
+
- **api/** 是适配层(FastAPI DTO + 路由),不含业务逻辑
|
|
133
|
+
- **application/** 是应用服务层,拥有事务边界
|
|
134
|
+
- **domain/** + **core/** 是纯函数,不依赖基础设施
|
|
135
|
+
- **storage/** 是数据访问层,只依赖 domain 和 core
|
|
136
|
+
- **workers/** 是后台调度,通过 application 服务操作数据
|
|
137
|
+
- **lifecycle.py** 是状态机守卫,所有状态变更统一经过 assert_transition()
|
|
138
|
+
|
|
139
|
+
## 配置
|
|
140
|
+
|
|
141
|
+
环境变量(关键项):
|
|
142
|
+
- `HL_MEM_ENV` — dev/production
|
|
143
|
+
- `HL_MEM_DB_PATH` — SQLite 路径
|
|
144
|
+
- `HL_MEM_EMBEDDER` — fake/real
|
|
145
|
+
- `HL_MEM_RERANKER` — off/fake/on/real
|
|
146
|
+
- `LLM_API_KEY` — 百炼 Coding AK
|
|
147
|
+
- `EMBEDDING_API_KEY` — 百炼通用 AK
|
|
148
|
+
- `HL_MEM_DECAY_TEMPORAL_DAYS` / `HL_MEM_DECAY_PERMANENT_DAYS` — 衰减策略
|
|
149
|
+
- `HL_MEM_DEDUP_THRESHOLD` — 语义去重阈值
|
|
150
|
+
|
|
151
|
+
集中配置:`config.py`(常量)+ `settings.py`(Settings 校验)+ `components.py`(工厂)
|
|
152
|
+
|
|
153
|
+
## Migration
|
|
154
|
+
|
|
155
|
+
36 个 SQL migration(001-036),按版本号顺序执行。不可变。
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Contributing to HL-Mem
|
|
2
|
+
|
|
3
|
+
感谢你帮助改进 HL-Mem。提交应聚焦单一问题,并保持本地优先、证据可追溯和向后兼容的设计原则。
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
需要 Python 3.11+、Git 和 [uv](https://docs.astral.sh/uv/)。
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone git@github.com:lohr13/hl_mem.git
|
|
11
|
+
cd hl_mem
|
|
12
|
+
uv sync --extra dev
|
|
13
|
+
cp .env.example .env
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
默认测试使用 fake providers,不需要外部 API key。仅在运行真实 Provider 检查时配置 `.env`,不要提交凭据、数据库或生成的报告。
|
|
17
|
+
|
|
18
|
+
## Tests and checks
|
|
19
|
+
|
|
20
|
+
提交前运行与改动范围匹配的检查;行为变更应包含回归测试。
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Full suite
|
|
24
|
+
.venv/Scripts/python.exe -m pytest tests/ -q --tb=short
|
|
25
|
+
|
|
26
|
+
# Unit tests
|
|
27
|
+
.venv/Scripts/python.exe -m pytest tests/unit/ -q --tb=short
|
|
28
|
+
|
|
29
|
+
# Formatting and import order
|
|
30
|
+
uv run black --check --line-length 120 src tests
|
|
31
|
+
uv run isort --check-only --profile black src tests
|
|
32
|
+
|
|
33
|
+
# Architecture import boundaries
|
|
34
|
+
uv run python scripts/check_imports.py
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Code style
|
|
38
|
+
|
|
39
|
+
- 使用 Python 3.11+ 和完整的 PEP 484 类型标注。
|
|
40
|
+
- Black 行宽为 120;isort 使用 `profile=black`。
|
|
41
|
+
- 模块、类和公开函数使用中文 docstring;复杂逻辑使用简洁中文注释。
|
|
42
|
+
- `domain/` 与 `core/` 保持纯净,不反向依赖 `storage/`、`api/` 或 `workers/`。
|
|
43
|
+
- 运行时模型、端口、路径、超时和密钥必须来自设置、配置文件或环境变量。
|
|
44
|
+
- 外部 API 必须设置超时和 retry,并提供可操作的错误信息。
|
|
45
|
+
- 已发布 migration 不可修改;schema 变化应新增顺序 migration。
|
|
46
|
+
|
|
47
|
+
## Pull requests
|
|
48
|
+
|
|
49
|
+
1. 从最新 `main` 创建短生命周期分支。
|
|
50
|
+
2. 一个 PR 只解决一个问题;避免无关重构和格式噪声。
|
|
51
|
+
3. 更新相关文档、CHANGELOG 和能力矩阵,并添加或更新测试。
|
|
52
|
+
4. 在 PR 描述中说明动机、实现方式、风险、验证命令和结果。
|
|
53
|
+
5. 确认没有提交密钥、运行数据库、缓存或 `var/` 数据。
|
|
54
|
+
6. 响应评审意见;涉及行为变化时补充可复现证据。
|
|
55
|
+
|
|
56
|
+
提交信息使用英文 Conventional Commits,例如:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
feat(recall): add bounded query expansion
|
|
60
|
+
fix(storage): preserve temporal visibility
|
|
61
|
+
docs: clarify provider configuration
|
|
62
|
+
```
|