Skip to content

chore: working tree reconciliation#42

Draft
marksverdhei wants to merge 6 commits into
mainfrom
chore/hygiene-sweep-1781472651
Draft

chore: working tree reconciliation#42
marksverdhei wants to merge 6 commits into
mainfrom
chore/hygiene-sweep-1781472651

Conversation

@marksverdhei

Copy link
Copy Markdown
Contributor

Automated hygiene sweep.

marksverdhei and others added 6 commits April 17, 2026 10:55
…ounts

extract_text / extract_codex_text now take truncate=True|False.
Scorers stay on truncate=True so large file contents don't dominate
relevance scoring. turn_tokens switches to truncate=False so budget
accounting matches what the API actually sees (tool_use inputs and
function_call outputs are sent untruncated).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two linked accounting bugs let compact.py claim it hit the budget while
writing output many times over the requested size:

1. lib/selector.py: when the tail system turn was force-kept past the
   greedy pass, only used_tokens (local) got updated. result
   .scored_kept_tokens stayed low, so print_stats under-reported and
   the overshoot check in compact.py never tripped. The force-kept
   turn is always long (short tail turns are already in kept_indices),
   so its tokens now flow into scored_kept_tokens.

2. compact.py / compact_codex.py: nuclear_compact returns a fresh
   SelectionResult with empty dropped_turns. Swapping result destroyed
   the primary pass's dropped list before append_archive_jsonl ran, so
   a nuclear-fallback compaction lost the archive of discarded turns.
   Capture primary_dropped before the swap and restore it on the new
   result, so the archive always reflects what was actually dropped.

Also brings compact_codex.py to parity with compact.py: adds the 10%
budget padding (so we don't compact borderline sessions) and the same
nuclear fallback path when primary scoring can't reach budget.

Verified with 1.7M-byte session: tight budget (5k) correctly triggers
nuclear, archive captures 6 primary-dropped turns, report and actual
output agree.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
patcher.py: the patched cli.js silently downgraded
PLUGIN_SETTING_METHOD=llama-embed (or any non-local method) to eitf,
while the hook script accepted the same method name. Users saw
different behavior on the two code paths with no signal. Now the
patch throws SUPERCOMPACT_EITF:unsupported_method and the outer
try/catch routes to the built-in LLM fallback, which is what the
user would have gotten without the patch.

supercompact-precompact.sh: backup rotation was a no-op because both
pre-compact-full and pre-supercompact used fixed names, so cp
overwrote the previous backup and ls | tail -n +4 had nothing to
rotate. Each compaction destroyed the prior backup. Now names are
timestamped with a shared stamp per run, so consecutive compactions
accumulate and the keep-last-3 rotation actually prunes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Five entry points (compact.py, compact_codex.py, compact-session.sh,
supercompact-precompact.sh, patched cli.js) default to 80,000 tokens
except the cli.js patch, which uses max(40% × preCompactTokenCount,
40000). Spell this out so the percentage path isn't mistaken for a
bug.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The nuclear pass was logging every truncation step (up to 8 lines per
run). Replace with a single summary: input -> output tokens, final
block size, and whether we fit the budget or gave up.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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