Skip to content

fix(plugin): keep collapsed-hit detail marker visible in #318-lite packing (#326) - #327

Merged
hurttlocker merged 1 commit into
mainfrom
feat/326-preserve-collapse-marker
Mar 11, 2026
Merged

hurttlocker merged 1 commit into
mainfrom
feat/326-preserve-collapse-marker

Conversation

@hurttlocker

Copy link
Copy Markdown
Owner

What this does

Fixes the #318-lite transparency defect tracked in #326 by ensuring packed same-source entries retain the collapse-detail marker/tail even when the primary snippet is very long.

Problem / Context

Issue: #326

Dogfood showed this defect on main:

  • grouped packed entry had packed_hits > 1
  • but packed content sometimes lost [collapsed ...] tail after truncation
  • this reduced hidden-detail transparency under prompt budget pressure

Root cause:

  • collapseSameSourceHits concatenated primary + [collapsed ...: tail]
  • then truncated the full combined string to maxPackedContentChars
  • long primary snippet consumed the whole cap and cut off marker/tail

How it works

File: plugin/recall.ts

  • Added bounded budgeting logic inside collapseSameSourceHits:
    • reserve a minimum tail budget (minCollapsedTailChars) for the collapse marker/tail
    • trim primary content budget first
    • then fit tail into remaining space
  • Result: for multi-hit packed entries, packed content keeps collapse marker + secondary detail token while staying under existing caps.

No architecture changes. No storage changes. No #320 behavior.

Tests added

File: plugin/recall.test.ts

New deterministic regression test:

  • buildRecallPlan keeps collapsed marker + secondary detail under long primary snippet
  • verifies for long-primary same-source packed entry:
    • packed_hits === 2
    • packed content includes [collapsed 2 same-source hits:
    • packed content includes secondary detail token
    • packed content remains within cap (<= 520)

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 ./...

Integrated dogfood rerun (post-fix)

Reran integrated recall-lane operator pass on main-equivalent branch with the same prompt set (+ defect repro prompt).

Observed on defect repro prompt (Q merged 323 then 324 then 325 next 318 lite):

  • packed entry retained marker/tail:
    • snippet evidence: ... [collapsed 2 same-source hits: - Mister told Q he wi...]
  • transparency defect no longer reproduced.

Breaking changes / risks

Breaking changes: None.

Risk note:

  • Slightly more aggressive truncation of primary snippet in packed multi-hit entries to preserve collapse-tail transparency.
  • This is intentional and bounded to packed_hits > 1 paths.

Out of scope (enforced)

Merge notes

@hurttlocker

Copy link
Copy Markdown
Owner Author

Post-fix dogfood evidence (truth-maintenance rerun)

I reran the integrated recall-lane operator pass on the fixed branch build (/tmp/cortex-326) using the same prompt set (+ the long-primary edge repro checks) after CI settled.

Result

✅ PASS — collapsed-hit detail marker now survives under budget on long-primary packed entries.

Concise evidence (long-primary edge case)

Prompt:

  • Option A approved #314 then #318-lite hold #320

Observed (budgetChars=1200):

  • rawCount=10, dedupedCount=2, packedCount=1, collapsedHits=1, selectedCount=1
  • selected packed entry: packedHits=2, packedMemoryIds=[19633,19259]
  • packed content length remains capped: contentLen=520
  • hasCollapsedMarker=true
  • collapsed tail preview present: # Daily Log — 2026-03...

Snippet:

  • ... Session was just compacted. The conversation summary abo... [collapsed 2 same-source hits: # Daily Log — 2026-03...]

This confirms #326 fixes the transparency defect without widening scope (#320 remains held).

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