WorktreePortSlots: follow git pointers with the HEAD check, and share the Either-sequence fold #754

Open
opened 2026-10-08 02:50:37 +00:00 by claude · 1 comment
Member

Found during IW-682 (port allocation for worktrees). Both items touch core/adapters/WorktreePortSlots.scala. Follow-ups, verbatim:

  • WorktreePortSlots follows .git/commondir pointers without the HEAD check that GitDirReader.stateRoot does — a hostile checkout could make claim create the lock/slot file outside a git dir
  • Either-sequence fold is copied in three places — core/adapters/WorktreePortSlots.scala sequence, core/model/CommandIndexFile.scala:423 traverse, core/model/ReviewStateCliParser.scala:350 sequence
Found during IW-682 (port allocation for worktrees). Both items touch `core/adapters/WorktreePortSlots.scala`. Follow-ups, verbatim: - [ ] WorktreePortSlots follows `.git`/`commondir` pointers without the `HEAD` check that GitDirReader.stateRoot does — a hostile checkout could make claim create the lock/slot file outside a git dir - [ ] Either-sequence fold is copied in three places — core/adapters/WorktreePortSlots.scala `sequence`, core/model/CommandIndexFile.scala:423 `traverse`, core/model/ReviewStateCliParser.scala:350 `sequence`
Author
Member

Intake: needs-input
Workflow: waterfall
Reason: G7 (1 [human] finding)
Analysis: project-management/issues/IW-754/analysis.md on branch IW-754

1. Should this issue replace only the three fold copies the issue names, or all eleven copies the analysis found? (G7)

The issue names three copies of the same loop. The loop turns a list of results that can fail into one result, at WorktreePortSlots.scala:239, CommandIndexFile.scala:423 and ReviewStateCliParser.scala:347. The analysis found 8 more copies (see the table and the decision). It plans to replace all 11 with one shared function that reports the first bad entry. Four of the extra sites report the last bad entry now: HerdrReply, ServiceDeclaration, LinearClient and YouTrackClient. With all 11, users of these sites see a different error message.

  • a) Only the three named copies. This is a smaller change. The other 8 copies go into FOLLOW-UPS.md as a new item. The duplication and the incorrect "returning first error" comment in YouTrackClient stay until that item is done.
  • b) All eleven copies. Each extra site is a change of 1 to 3 lines. The error message changes at the four sites above, and the incorrect YouTrackClient comment goes away.

Recommended: b) — The issue asks for one shared fold, and if we keep 8 copies, the duplication that the issue is about stays in the code.

Answer in a comment on this issue, per number, for example "1: a", or in your own words; intake reads it on its next iteration.

Intake: needs-input Workflow: waterfall Reason: G7 (1 [human] finding) Analysis: project-management/issues/IW-754/analysis.md on branch IW-754 ### 1. Should this issue replace only the three fold copies the issue names, or all eleven copies the analysis found? (G7) The issue names three copies of the same loop. The loop turns a list of results that can fail into one result, at [WorktreePortSlots.scala:239](https://code.iterative.works/iterative-works/iw-cli/src/branch/IW-754/core/adapters/WorktreePortSlots.scala#L239), CommandIndexFile.scala:423 and ReviewStateCliParser.scala:347. The analysis found 8 more copies (see [the table](https://code.iterative.works/iterative-works/iw-cli/src/branch/IW-754/project-management/issues/IW-754/analysis.md#L27-L39) and [the decision](https://code.iterative.works/iterative-works/iw-cli/src/branch/IW-754/project-management/issues/IW-754/analysis.md#L65)). It plans to replace all 11 with one shared function that reports the first bad entry. Four of the extra sites report the last bad entry now: HerdrReply, ServiceDeclaration, LinearClient and YouTrackClient. With all 11, users of these sites see a different error message. - **a) Only the three named copies.** This is a smaller change. The other 8 copies go into FOLLOW-UPS.md as a new item. The duplication and the incorrect "returning first error" comment in YouTrackClient stay until that item is done. - **b) All eleven copies.** Each extra site is a change of 1 to 3 lines. The error message changes at the four sites above, and the incorrect YouTrackClient comment goes away. **Recommended: b)** — The issue asks for one shared fold, and if we keep 8 copies, the duplication that the issue is about stays in the code. Answer in a comment on this issue, per number, for example "1: a", or in your own words; intake reads it on its next iteration.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
iterative-works/iw-cli#754
No description provided.