Introduce the PieceReader read port #118

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

Imported from GitHub amaurycoudr/chess-project#118, 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

Introduce the PieceReader read port — a 4-method interface over piece placement (pieceAt, squaresOf, occupancy, occupancyOf) — and route the read-only consumers through it, without changing any behavior.

Board already exposes all four methods, so it implements the port as-is. Every module that currently accepts a concrete Board purely to read from it is widened to accept PieceReader instead. This is pure type widening: no logic moves, no allocation changes, no perft impact.

Acceptance criteria

  • PieceReader interface defined with pieceAt, squaresOf, occupancy, occupancyOf; not exported from the package
  • Board declared implements PieceReader (no method changes needed)
  • movegen.ts and zobrist.ts signatures that took Board now take PieceReader
  • castling.ts (castlingMoves, homeRookPresent) and rules.hasInsufficientMaterial widened to PieceReader
  • No behavior change: pnpm lint, pnpm typecheck, pnpm test, pnpm build all green; perft node counts unchanged
  • No new exports from index.ts
> _Imported from GitHub [amaurycoudr/chess-project#118](https://github.com/amaurycoudr/chess-project/issues/118), 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:118 --> --- ## Parent #117 ## What to build Introduce the `PieceReader` read port — a 4-method interface over piece placement (`pieceAt`, `squaresOf`, `occupancy`, `occupancyOf`) — and route the read-only consumers through it, without changing any behavior. `Board` already exposes all four methods, so it implements the port as-is. Every module that currently accepts a concrete `Board` purely to read from it is widened to accept `PieceReader` instead. This is pure type widening: no logic moves, no allocation changes, no perft impact. ## Acceptance criteria - [ ] `PieceReader` interface defined with `pieceAt`, `squaresOf`, `occupancy`, `occupancyOf`; not exported from the package - [ ] `Board` declared `implements PieceReader` (no method changes needed) - [ ] `movegen.ts` and `zobrist.ts` signatures that took `Board` now take `PieceReader` - [ ] `castling.ts` (`castlingMoves`, `homeRookPresent`) and `rules.hasInsufficientMaterial` widened to `PieceReader` - [ ] No behavior change: `pnpm lint`, `pnpm typecheck`, `pnpm test`, `pnpm build` all green; perft node counts unchanged - [ ] No new exports from `index.ts`
root commented 2026-05-22 12:44:43 +00:00 (Migrated from gitlab.core-project.space)

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

Implemented by Sandcastle on branch sandcastle/sequential-reviewer/1779453661375 — awaiting review. Introduced PieceReader read port; widened movegen, zobrist, castling, and rules.hasInsufficientMaterial signatures from Board to PieceReader with no behavior change.

> _Imported from a [GitHub comment](https://github.com/amaurycoudr/chess-project/issues/118#issuecomment-4518747595) by [@amaurycoudr](https://github.com/amaurycoudr) on 2026-05-22 12:44 UTC._ <!-- github-comment:4518747595 --> Implemented by Sandcastle on branch `sandcastle/sequential-reviewer/1779453661375` — awaiting review. Introduced `PieceReader` read port; widened movegen, zobrist, castling, and rules.hasInsufficientMaterial signatures from `Board` to `PieceReader` with no behavior change.
root commented 2026-05-22 14:20:01 +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/118#issuecomment-4519525403) by [@amaurycoudr](https://github.com/amaurycoudr) on 2026-05-22 14:20 UTC._ <!-- github-comment:4519525403 --> 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 #119

mentioned in issue #119
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 08:38:49 +00:00 (Migrated from gitlab.core-project.space)

mentioned in issue #141

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

mentioned in commit 81a871ba17

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

mentioned in commit 6bd42d7f09

mentioned in commit 6bd42d7f0979d639f43fb1853627a0d9d8b15fc0
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#118
No description provided.