Apply a checked Move without checking it again, so the Puzzle sample loads fast #448
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amaurycoudr/chess-project#448
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Loading the committed Puzzle sample (53,187 Puzzles, #442) takes about a minute of CPU. Almost all of it is the engine checking each line:
checkLineinapps/api/src/puzzles/puzzle-set.tscallsgame.isLegal(move)and thengame.apply(move), andapplychecks legality again. Each Move's legality is computed twice, about 35 s of the load.It costs us twice:
db:puzzlesafter the migrations, so each deploy waits that long;pnpm testfortest:slow(it starved the other tests in the commit hook), so it no longer runs on every commit.What to build
A way for the engine to apply a Move already known to be legal without checking it again, used by the Puzzle loader (and anywhere else that checks first, then applies). It stays behind the engine facade (ADR 0001); the shape is the implementer's call, for example
applyreturning aResultso callers drop their separateisLegal, or an apply that trusts a Move taken fromlegalMoves().Acceptance criteria
pnpm turbo run test:slow --filter=@chess/api) is measurably faster; before and after timings in the merge request.pnpm test.CONTRIBUTING.md, "The five commands").mentioned in merge request !554