Route isAttackedIn through the PieceReader port #119

Closed
opened 2026-05-22 12:39:58 +00:00 by root · 8 comments
root commented 2026-05-22 12:39:58 +00:00 (Migrated from gitlab.core-project.space)

Imported from GitHub amaurycoudr/chess-project#119, opened by @amaurycoudr on 2026-05-22 12:39 UTC.
Closed on GitHub on 2026-05-23 06:28 UTC as completed.


Parent

#117

What to build

Route isAttackedIn through the PieceReader port. Today it takes the raw { sets: PieceSets; occupancy: SquareSet } pair, and its two callers assemble that argument differently — rules.isCheck passes a fresh position.board.toSets() copy, SearchBoard.legalMoves passes the live #sets ref plus a separately-computed occupancy. This slice replaces that parameter with a single PieceReader, derived occupancy included, so both callers pass a board directly.

End-to-end: attack detection runs identically whether handed an immutable snapshot or a live board, with one calling convention.

Acceptance criteria

  • isAttackedIn signature changed from { sets, occupancy } to a PieceReader; occupancy derived internally via pieceReader.occupancy()
  • rules.isCheck passes position.board directly — no toSets() copy, no hand-rolled occupancy
  • SearchBoard.legalMoves passes its board through the port — no { sets, occupancy } tuple
  • attacks.test.ts updated to drive isAttackedIn via a PieceReader
  • pnpm lint, pnpm typecheck, pnpm test, pnpm build all green; perft node counts unchanged

Blocked by

> _Imported from GitHub [amaurycoudr/chess-project#119](https://github.com/amaurycoudr/chess-project/issues/119), opened by [@amaurycoudr](https://github.com/amaurycoudr) on 2026-05-22 12:39 UTC._ > _Closed on GitHub on 2026-05-23 06:28 UTC as completed._ <!-- github-issue:119 --> --- ## Parent #117 ## What to build Route `isAttackedIn` through the `PieceReader` port. Today it takes the raw `{ sets: PieceSets; occupancy: SquareSet }` pair, and its two callers assemble that argument differently — `rules.isCheck` passes a fresh `position.board.toSets()` copy, `SearchBoard.legalMoves` passes the live `#sets` ref plus a separately-computed occupancy. This slice replaces that parameter with a single `PieceReader`, derived occupancy included, so both callers pass a board directly. End-to-end: attack detection runs identically whether handed an immutable snapshot or a live board, with one calling convention. ## Acceptance criteria - [ ] `isAttackedIn` signature changed from `{ sets, occupancy }` to a `PieceReader`; occupancy derived internally via `pieceReader.occupancy()` - [ ] `rules.isCheck` passes `position.board` directly — no `toSets()` copy, no hand-rolled occupancy - [ ] `SearchBoard.legalMoves` passes its board through the port — no `{ sets, occupancy }` tuple - [ ] `attacks.test.ts` updated to drive `isAttackedIn` via a `PieceReader` - [ ] `pnpm lint`, `pnpm typecheck`, `pnpm test`, `pnpm build` all green; perft node counts unchanged ## Blocked by - Blocked by #118
root commented 2026-05-22 12:50:50 +00:00 (Migrated from gitlab.core-project.space)

Imported from a GitHub comment by @amaurycoudr on 2026-05-22 12:50 UTC.

Implemented by Sandcastle on branch sandcastle/sequential-reviewer/1779453986599 — awaiting review. Routed isAttackedIn through the PieceReader port: signature collapsed from { sets, occupancy } to a single PieceReader, with rules.isCheck and both SearchBoard.legalMoves callsites passing the board directly; attacks.test.ts drives the function via pos.board (no more attackContext helper). All four gates green; perft node counts unchanged.

> _Imported from a [GitHub comment](https://github.com/amaurycoudr/chess-project/issues/119#issuecomment-4518792082) by [@amaurycoudr](https://github.com/amaurycoudr) on 2026-05-22 12:50 UTC._ <!-- github-comment:4518792082 --> Implemented by Sandcastle on branch `sandcastle/sequential-reviewer/1779453986599` — awaiting review. Routed `isAttackedIn` through the `PieceReader` port: signature collapsed from `{ sets, occupancy }` to a single `PieceReader`, with `rules.isCheck` and both `SearchBoard.legalMoves` callsites passing the board directly; `attacks.test.ts` drives the function via `pos.board` (no more `attackContext` helper). All four gates green; perft node counts unchanged.
root commented 2026-05-22 14:20:02 +00:00 (Migrated from gitlab.core-project.space)

Imported from a GitHub comment by @amaurycoudr on 2026-05-22 14:20 UTC.

Promoted to branch refactor/introduce-the-piecereader-read-port-118 (PR #122), not yet merged to main. A dependent slice should git fetch origin refactor/introduce-the-piecereader-read-port-118 and branch off it.

> _Imported from a [GitHub comment](https://github.com/amaurycoudr/chess-project/issues/119#issuecomment-4519525548) by [@amaurycoudr](https://github.com/amaurycoudr) on 2026-05-22 14:20 UTC._ <!-- github-comment:4519525548 --> Promoted to branch `refactor/introduce-the-piecereader-read-port-118` (PR #122), not yet merged to main. A dependent slice should `git fetch origin refactor/introduce-the-piecereader-read-port-118` and branch off it.
root (Migrated from gitlab.core-project.space) closed this issue 2026-05-23 06:28:33 +00:00
root commented 2026-10-13 08:38:43 +00:00 (Migrated from gitlab.core-project.space)

mentioned in issue #120

mentioned in issue #120
root commented 2026-10-13 10:18:45 +00:00 (Migrated from gitlab.core-project.space)

mentioned in commit 5ef5e336a2

mentioned in commit 5ef5e336a21f92e2ba8ecac01e74530dcfd78003
root commented 2026-10-13 10:18:45 +00:00 (Migrated from gitlab.core-project.space)

mentioned in commit 81a871ba17

mentioned in commit 81a871ba176181e5cbb1c732a1b2cc39996b5794
root commented 2026-10-13 10:27:19 +00:00 (Migrated from gitlab.core-project.space)

mentioned in commit 6bd42d7f09

mentioned in commit 6bd42d7f0979d639f43fb1853627a0d9d8b15fc0
root commented 2026-10-13 10:27:20 +00:00 (Migrated from gitlab.core-project.space)

mentioned in commit 658aeacfa2

mentioned in commit 658aeacfa2b7e4ba1b8ef53786f93be314ea2cec
root commented 2026-10-14 15:46:23 +00:00 (Migrated from gitlab.core-project.space)

mentioned in merge request !527

mentioned in merge request !527
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
amaurycoudr/chess-project#119
No description provided.