Skip to content

feat: collapse v2 — non-bijunctive recall with Hebbian cross-source corroboration#24

Merged
ClaudioDrews merged 1 commit into
mainfrom
feat/collapse-v2
Jun 7, 2026
Merged

feat: collapse v2 — non-bijunctive recall with Hebbian cross-source corroboration#24
ClaudioDrews merged 1 commit into
mainfrom
feat/collapse-v2

Conversation

@ClaudioDrews

Copy link
Copy Markdown
Owner

Summary

Implements non-bijunctive recall collapse with Hebbian cross-source corroboration, unified salience ranking, and physical-entropy attestation.

What it does

Replaces the stock per-source quota emission with a single cross-source salience budget:

  • PRUNE — weak paths relative to the strongest (not an absolute floor)
  • AMPLIFY — Hebbian cross-source corroboration: facts surfaced by 2+ sources receive a salience boost ("fire together, wire together"), attenuated by query-local relevance (see Hebbian weight vs. query-local relevance tradeoff (collapse v2) #23)
  • BUDGET — best N candidates across all sources, regardless of origin

Files

File Description
icarus/collapse.py Core algorithm: salience(), score_all(), collapse(), attest()
icarus/hooks.py Integration: _apply_collapse() in pre_llm_call, env-configurable tunables
_test_collapse.py Unit tests (15+ scenarios, all passing)
scripts/collapse_eval.py Smoke test: stock vs collapse, token delta, attestation
.github/workflows/ci.yml CI: runs tests on push/PR

Tunables (env vars)

All with sensible defaults. Key ones:

  • ICARUS_COLLAPSE=1 — master switch (set to 0 to restore legacy per-source emission)
  • ICARUS_COLLAPSE_BUDGET=6 — max survivors across all sources
  • ICARUS_COLLAPSE_AMPLIFY_GAIN=0.15 — Hebbian boost per corroborating source (tune for Hebbian weight vs. query-local relevance tradeoff (collapse v2) #23 tradeoff)
  • ICARUS_COLLAPSE_DEBUG=1 — logs full salience-ranked pool + attestation hash

Real pipeline results

  • 30-35% token reduction in pre_llm_call context injection
  • Correct ranking: query-relevant facts survive, off-topic pruned
  • Fail-open: any collapse error → inject everything unchanged (safety contract)

Closes #23

- 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
  (Gabi Qdrant corpus now survives, was pruned in v1)

Closes #23
@ClaudioDrews ClaudioDrews merged commit 4dec57e into main Jun 7, 2026
4 checks passed
ClaudioDrews added a commit that referenced this pull request Jun 7, 2026
)

- 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>
@ClaudioDrews ClaudioDrews deleted the feat/collapse-v2 branch June 7, 2026 12:51
ClaudioDrews added a commit that referenced this pull request Jun 7, 2026
)

- 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>
ClaudioDrews added a commit that referenced this pull request Jun 7, 2026
)

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hebbian weight vs. query-local relevance tradeoff (collapse v2)

1 participant