Skip to content

fix: break chicken-and-egg deadlock in batch cleanup nudge system - #27

Merged
ranxianglei merged 1 commit into
masterfrom
ranxianglei/2026-06-28_batch-cleanup-nudge-fix
Jun 28, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
ranxianglei/2026-06-28_batch-cleanup-nudge-fix

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

buildNudgeText() returned undefined when no blocks were marked, creating a deadlock: model doesn't mark → nudge doesn't fire → model doesn't know to mark → repeat. The nudge that's supposed to encourage marking required an existing mark to fire.

Three-tier escalation design:

  • No marks + old-gen blocks: guide model to start marking (📋)
  • Some marks (<3 or <40% ratio): encourage marking more (⚠️)
  • Enough marks (≥3 AND ≥40% old-gen ratio): urge active compress (🔥)

Additional fixes:

  • High-tier (75%) now falls through to nudge instead of returning noop when merge conditions unmet — model gets guidance at high pressure
  • lowThreshold lowered from 60% to 55% (aligns with compress trigger)
  • Escalation ratio computed against old-gen subset (not all marked blocks)
  • collectActiveMarkedBlocks self-cleans stale marks for deactivated blocks

Oracle review: APPROVE_WITH_NITS (both nits addressed)
Tests: 22/22 pass, tsc --noEmit clean

buildNudgeText() returned undefined when no blocks were marked, creating a
deadlock: model doesn't mark → nudge doesn't fire → model doesn't know to
mark → repeat. The nudge that's supposed to encourage marking required an
existing mark to fire.

Three-tier escalation design:
- No marks + old-gen blocks: guide model to start marking (📋)
- Some marks (<3 or <40% ratio): encourage marking more (⚠️)
- Enough marks (≥3 AND ≥40% old-gen ratio): urge active compress (🔥)

Additional fixes:
- High-tier (75%) now falls through to nudge instead of returning noop
  when merge conditions unmet — model gets guidance at high pressure
- lowThreshold lowered from 60% to 55% (aligns with compress trigger)
- Escalation ratio computed against old-gen subset (not all marked blocks)
- collectActiveMarkedBlocks self-cleans stale marks for deactivated blocks

Oracle review: APPROVE_WITH_NITS (both nits addressed)
Tests: 22/22 pass, tsc --noEmit clean
@ranxianglei
ranxianglei merged commit 00b122d into master Jun 28, 2026
3 checks passed
ranxianglei pushed a commit that referenced this pull request Aug 28, 2026
…minContextLimit

Per @Dog's feedback in issue #342: minContextLimit defaults to 80%
(lib/config.ts:200) and is documented as the soft lower threshold for
turn/iteration reminders, so gating growth nudges on it suppresses ALL
growth nudges below 80% for default users — effectively disabling
compression for most of a session. The dual-agent review's minLimitResolved
guard did not address this (a default user with a known context still gets
growth nudges suppressed below 80%).

Use minNudgeContextPercent (default 15, a percent of model context) as the
growth-nudge floor instead. It is the intended 'don't nudge below this'
knob and was previously a no-op (plumbed into computeShouldNudge but
ignored). When the model context limit is unknown the floor is unresolvable
and growth nudges keep pre-#342 behavior. overMaxLimit and the emergency
override bypass the floor; T2/T3 tier-promotion nudges are unaffected.

- Reverts the review commit's minLimitResolved mechanism (dead code here)
- Preserves the review commit's README/CONFIGURATION default fixes (80%/80%)
- Tests: 4 floor tests + 2 new (unresolvable model limit, T2 independence)
  re-pointed at the floor; pre-existing test #27 raised into the [floor, max)
  range. 1035 tests, 0 failures.
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