Skip to content

fix(session): stop resubmitting rejected reviews to unchanged daemons - #1199

Merged
benvinegar merged 1 commit into
mainfrom
fix/rejected-review-retry-churn
Oct 18, 2026
Merged

benvinegar merged 1 commit into
mainfrom
fix/rejected-review-retry-churn

Conversation

@benvinegar

@benvinegar benvinegar commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Problem

A large hunk diff main review repeatedly sent an approximately 8.3 MB registration with 5,501 files to a daemon whose registration limit is 5,000 files. Authentication succeeded, registration was rejected, and reconnecting submitted the same invalid payload again. The review never appeared in the session list.

Changes

  • Track authenticated payload rejection separately from build/version skew.
  • Keep health polling, but do not reconnect and resend to an unchanged healthy daemon, including when launch metadata is absent.
  • Retry after an explicit successful review replacement, a daemon-generation change, or an unhealthy incumbent. Snapshot-only updates do not release the refusal.
  • Fence asynchronous health/admin results and reentrant replacements so stale work cannot clear or resurrect another refusal.
  • Suggest a smaller review instead of suggesting that a daemon restart can bypass payload limits.
  • Add deterministic lifecycle regressions and an actual-daemon oversized-registration/smaller-review recovery test; include a patch Changeset.

This belongs in the existing session client lifecycle. It does not change payload limits, transport/protocol shapes, or transient-disconnect retry behavior. The wire snapshot remains unchanged.

Verification

Rebased onto current main (483ea47d) in an isolated worktree and installed its committed lockfile with bun install --frozen-lockfile; no dependency upgrades are included. Tested on macOS with Bun 1.4.3.

  • bun test packages/hunk/src/session/broker/brokerClient.test.ts — 56 passed.
  • bun test packages/hunk/src/session/client/daemonSkew.test.ts — 9 passed.
  • bun test packages/hunk/src/session/broker/wire.snapshot.test.ts — 3 passed.
  • bun run test:session-broker-node — 4 passed.
  • bun run typecheck — passed.
  • bun run deps:check — passed.
  • Targeted oxfmt --check, oxlint --deny-warnings, and git diff --check — passed.

Linux and Windows were not tested locally. The status-line wording is the only intended visual change; its existing 80-column notice test passes.

Scope of the incident finding

The registration/retry loop was confirmed, but it is not proven to explain the original process's full memory footprint. An isolated 3,000-iteration rejection/reconnect probe did not reproduce substantial retained memory. This PR fixes retry churn, not a claimed complete memory-leak diagnosis; resize geometry retention is addressed independently in #1200.

@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
hunk-web Ignored Ignored Preview Oct 18, 2026 12:42am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects how Hunk review sessions reconnect to their local daemon.

The retry changes appear sound, but the new tests must satisfy the repository’s environment-access rule before merging.

Findings

  1. P2 Tests bypass environment boundary ▶
Fix with agent prompt
### Issue 1
packages/hunk/src/session/broker/brokerClient.test.ts:256
The new fixtures write directly to `process.env` here and in the real-daemon test. The repository guide says “Never access `process.env` directly” and requires the approved environment layer or parameters instead. Move these settings behind that boundary before merging to satisfy the repository requirement.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Stops resending rejected reviews to an unchanged healthy daemon.

  • Rejected reviews wait for a change before the client resends them.
  • Rejected reviews now point people toward a smaller review.

Intentional behavior acknowledged by benvinegar: missing launch metadata does not release a refusal while the daemon remains healthy. This prevents repeat submissions when daemon identity cannot be distinguished.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Authenticated review rejected] --> B[Record payload wait]
  B --> C[Poll daemon health]
  C --> D{Healthy and same fingerprint?}
  D -->|Yes, including null-to-null| C
  D -->|No| E[Release wait and reconnect]
  B --> F[Successful explicit review replacement]
  F --> E
  B --> G[Snapshot-only update]
  G --> C
Loading

Reviews (1) · Last reviewed commit: "fix(session): stop resubmitting rejected..." · Reviewed by Greptile

/** Authenticate observed sockets with real signed hellos while keeping retry time deterministic. */
async function createRefusalLifecycleTest(withMetadata = false, subscribe = false) {
const runtimeDir = mkdtempSync(join(tmpdir(), "hunk-payload-refusal-"));
process.env.XDG_RUNTIME_DIR = runtimeDir;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Tests bypass environment boundary

The new fixtures write directly to process.env here and in the real-daemon test. The repository guide says “Never access process.env directly” and requires the approved environment layer or parameters instead. Move these settings behind that boundary before merging to satisfy the repository requirement.

Context Used: guidelines.mdc Cursor rule (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hunk/src/session/broker/brokerClient.test.ts
Line: 256

Comment:
**Tests bypass environment boundary**

The new fixtures write directly to `process.env` here and in the real-daemon test. The repository guide says “Never access `process.env` directly” and requires the approved environment layer or parameters instead. Move these settings behind that boundary before merging to satisfy the repository requirement.

**Context Used:** guidelines.mdc Cursor rule ([source](https://github.com/modem-dev/modem/blob/main/.cursor/rules/guidelines.mdc))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@benvinegar
benvinegar merged commit 4b15946 into main Oct 18, 2026
16 checks passed
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