feat(hooks): /compact focus steers distiller output + relay arc ranking - #114
Merged
Merged
Conversation
/compact <text> arrives as custom_instructions on PreCompact's stdin only (SessionStart never sees it), so it's persisted -- truncated to ~300 chars -- into the session's exported metadata.json as compactFocus. Two readers consume it: - SessionStart(source="compact") reads the persisted focus and ranks the compact-relay arc block by deterministic token-overlap against each candidate arc's signature+fix text (transcripts/focus.py), fetching up to 3xK candidates via the existing bounded LIMIT query. A "Compaction focus: <text>" line is prepended when a focus is present. No persisted focus -> today's pure-recency behavior, byte-identical. - The over-cap detached distiller spawn forwards the same focus as --focus (new simba transcript distill flag); distill_transcript reorders its <failure-arcs> output section by the same scoring, never touching the failure_arc sidecar schema or what gets stored. No focus -> byte- identical output. Scoring is plain lowercase word-token overlap (tokens <3 chars dropped) -- no LLM, no embeddings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Phase 2 of the compact relay: the text you type after
/compactnow does double duty. Claude Code natively uses it to steer the summary (docs: "the summary keeps what you choose"); simba now uses the same text — received by the PreCompact hook ascustom_instructions— to steer what the relay brings back across the boundary.How
compactFocusin the exportmetadata.jsonit already writes; key omitted entirely for auto-compact. SessionStart(compact) reads it back for the same session_id.transcripts/focus.py, no LLM/embeddings), orders by (score, recency) and injects the top K, prefixed withCompaction focus: <text>. No focus → byte-identical to today.simba transcript distill --focus TEXTreorders the output document's arc listing by the same scoring (focus-matched arcs first); thefailure_arcsidecar is untouched. The PreCompact spawn forwards the focus automatically.Tests
Red-first across all three legs: persistence (manual vs auto), ranking (relevance beats recency only when focused; caps respected; no-focus byte-identity), distiller ordering (byte-identical without focus). Full suite exit 0, ruff clean.