Skip to content

feat(plugin): bounded grouped recall packing for #318-lite - #325

Merged
hurttlocker merged 1 commit into
mainfrom
feat/318-lite-grouped-recall
Mar 11, 2026
Merged

hurttlocker merged 1 commit into
mainfrom
feat/318-lite-grouped-recall

Conversation

@hurttlocker

Copy link
Copy Markdown
Owner

What this does

Implements a surgically small #318-lite recall packing layer in the OpenClaw plugin:

  • groups recall candidates by project/file/section
  • collapses same-source hits into one provenance-safe packed entry
  • keeps selection deterministic and prompt-budget-aware using existing recall surfaces

Problem / Context

Issue: #318

After #319 Slice A, recall became budget-governed and deterministic, but still packed one raw item per hit. That can over-fragment context when multiple hits come from the same source section.

Q’s direction for #318-lite was to steal the useful pattern only (group/collapse/provenance/budget) without introducing full summary storage or architecture expansion.

How it works

1) Grouped packing (project/file/section)

plugin/recall.ts now groups deduped recall hits by:

  • inferred project (from source_file path root)
  • normalized source_file
  • normalized source_section

2) Provenance-safe same-source collapse

For each group:

  • preserve top-ranked source hit as representative entry
  • collapse additional same-source hits into the packed entry text
  • keep provenance metadata:
    • packed_hits
    • packed_memory_ids
    • manifest memory id list for selected/dropped records

No persistent summary store. No synthetic long-lived node storage.

3) Prompt-budget-aware selection (existing surface reused)

Recall still uses the current path:

  • before_agent_start -> search -> dedupe -> buildRecallPlan -> prependContext

But plan selection now operates on packed groups instead of raw single hits, while preserving:

  • deterministic ordering
  • hard recallLimit
  • hard recallBudgetChars

4) Observability

Manifest now reports:

  • raw_count
  • deduped_count
  • packed_count
  • collapsed_hits
  • selected/dropped details with packed provenance metadata

Plugin logs now explicitly show raw/deduped/packed and budget usage before injection.

Files changed

  • plugin/recall.ts
  • plugin/recall.test.ts
  • plugin/index.ts
  • plugin/README.md

Testing done

Exact commands run:

  1. node --check plugin/index.ts
  2. node --check plugin/recall.ts
  3. node --test plugin/*.test.ts
  4. go test ./...

Screenshots / before-after

Terminal/log behavior change:

  • Before: manifest summarized raw/deduped + selected/dropped counts for single-hit packing
  • After: manifest/logs include grouped packing stats (packed, collapsed_hits) and inject packed recall entries

Breaking changes / risks

Breaking changes: None.

Risk note:

  • packed collapse could hide a low-salience detail from secondary same-source hits if a prompt is extremely budget-constrained.
  • mitigations: deterministic ordering, packed provenance ids retained, and budget/selection observability in manifest logs.

Explicit out-of-scope (enforced)

Merge notes

@hurttlocker
hurttlocker merged commit 57ea3c3 into main Mar 11, 2026
4 checks passed
@hurttlocker
hurttlocker deleted the feat/318-lite-grouped-recall branch March 21, 2026 01:27
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.

1 participant