Skip to content

docs(pegboard-runner): explain alloc idx eviction invariant#4626

Closed
NathanFlurry wants to merge 1 commit into04-12-fix_pegboard_isolate_runner_config_dc_lookup_failuresfrom
04-12-docs_pegboard-runner_explain_alloc_idx_eviction_invariant
Closed

docs(pegboard-runner): explain alloc idx eviction invariant#4626
NathanFlurry wants to merge 1 commit into04-12-fix_pegboard_isolate_runner_config_dc_lookup_failuresfrom
04-12-docs_pegboard-runner_explain_alloc_idx_eviction_invariant

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@claude
Copy link
Copy Markdown

claude bot commented Apr 13, 2026

PR Review: docs(pegboard-runner): explain alloc idx eviction invariant

This is a documentation-only change adding two comment lines to clarify a subtle synchronization invariant in the pegboard-runner disconnect logic.

Summary

The added comment explains why alloc idx is intentionally not cleared when a runner disconnects via eviction: the replacement connection (which reuses the same runner_id) would have already rewritten the alloc idx, so clearing it here would introduce a race condition against the new connection.

Feedback

Correctness: The explanation is accurate and helpful. The comment correctly describes the invariant that needs to hold to avoid a race between the outgoing and incoming connections sharing a runner_id.

Comment style: Per CLAUDE.md conventions, comments should be written as normal, complete sentences and should avoid dashes (hyphens are OK). The added comment uses a comma to join two related ideas, which reads naturally. No issues here.

Comment placement: The comment is placed at the top of the else block (the non-evicted path), which is the right location — it explains why the block only runs in the non-evicted case, complementing the if condition on line 238.

Minor suggestion: The comment could lead with the condition to mirror the symmetric if branch above more clearly. For example:

// If evicted, the replacement connection already rewrote the alloc idx under the same
// runner_id. Clearing it here would race the new connection.

This is purely optional — the current wording is clear.

No functional, performance, or security concerns. This is a pure documentation change with no behavioral impact.

Overall: looks good to merge once out of draft.

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