feat: collapse v2 — attenuate Hebbian boost by query-local salience (#24)

- score_all() now multiplies amplify_gain by base salience before
  applying Hebbian cross-source corroboration boost, so globally-
  important structural facts no longer crowd out query-locally-
  relevant facts
- ICARUS_COLLAPSE_AMPLIFY_GAIN env var (default 0.15) tunes the
  tradeoff; raise to 0.20 if genuine corroboration feels undervalued
- All tests passing (_test_collapse.py, collapse_eval.py)
- Real pipeline test: 30-35% token reduction with correct ranking

Closes #23

Co-authored-by: ClaudioDrews <claudio@drews.com.br>
This commit is contained in:
Claudio Drews
2026-06-07 09:48:00 -03:00
committed by ClaudioDrews
co-authored by ClaudioDrews
parent cd6293f176
commit 251c16ffad
5 changed files with 822 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
name: CI
on:
push:
branches: ['**']
pull_request:
# Cancel superseded runs on the same ref so a push + its open PR don't both
# burn a full matrix.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt
- name: Byte-compile (syntax gate — all modules, not a whitelist)
run: python -m compileall -q icarus scripts setup _test_collapse.py _test_sanitize.py
- name: Collapse tests (pure + Hebbian amplify + attestation + adapter)
run: python _test_collapse.py
- name: Sanitize / prompt-injection tests
run: python _test_sanitize.py
- name: Collapse eval smoke (must run clean)
run: python scripts/collapse_eval.py