Repository navigation
CNP: follow a search's root (engine/root, rootMs, capability root) - #250
Merged
Merged
Conversation
Engine::search_following_root tells a caller where the main thread's root loop is (cb2026_engine::root): the move it is on, its place and the line's count, the line's best so far and the nodes below each root move, at every root move and whenever the search looks at the clock, and at once when a later move beats the best on its null-window search (better) or a depth's score falls outside its aspiration window (failHigh, failLow). The CNP node passes it on as engine/root at most every rootMs, research at once, on an interval of its own. Helpers don't follow. The search is the same node for node, followed or not. The cnp pin moves to cjus/chess-node-protocol#23's merge, 6274420. For Solrac's Engine Mind (Solrac Chess AI #357). No functional change. Bench: 767812 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cjus
added a commit
that referenced
this pull request
Nov 2, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No functional change. Bench: 767812 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rustdoc refuses a link from the public root module to the crate-private RootFollower. No functional change. Bench: 767812 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cb2026's side of cjus/chess-node-protocol#23 (spec 7.9): a search with
rootMsis followed at its root. This is pillar 3, live search, of Solrac's Engine Mind (Solrac Chess AI #357).The engine:
cb2026_engine::rootEngine::search_following_root(…, on_root: Option<&mut dyn FnMut(&RootInfo)>).Engine::searchcalls it withNone, so every other caller is unchanged.RootInfogives the depth being searched, the line (MultiPV), the root move being searched with its place and the line's count, the line's best so far, every root move searched with the main thread's nodes below it (all depths and lines together), the total nodes and the time.RootResearchisBetter(mv),FailHigh(score)orFailLow(score).Searcherholds aRootFollower. Helper threads don't get one: their roots go in their own orders, a depth apart. The hooks:search_root: the start and end of each root move. A move that raises the score becomes the line's best.search_move: its PVS re-search, when the node is a root move's (path.len() == 1), givesBetter, before the full-window re-search.search_depth: an aspiration window's failure givesFailHighorFailLowwith the fail-soft score, before the wider re-search. The report's move is the one the re-search starts with.should_stop's clock check (everyCHECK_INTERVAL, 1024 nodes) gives a plain report, so a long first move shows its nodes growing.main_searchtells it each line's depth, moves and last best.Optioncheck at those places.search,main_search,pvs,aspirationandcut_node_flagsexcerpts now show these one-line hooks (chapters 4, 6, 11, 13, 14.1 and 19). No prose changed.The CNP node
rootand readsrootMs. Reports pass the throttle oncerootMshas passed since the last notification, on an interval apart fromprogressMs's. A research is sent at once, and the interval then counts from it.multipvis present when more than one line was asked for. A level's extra candidate lines are searched and counted but not reported, as their lines aren't.engine.search_following_root, before the thread sends its answer, so nothing comes after the result. A search that reaches its root sends at least one notification: the first move of depth 1 always passes the throttle.cnppin moves to Engine: following the root (engine/root, rootMs, capability root) chess-node-protocol#23's merge,6274420.Same search, node for node
cb2026 benchis unchanged at 767812.root::tests::following_the_root_changes_nothing_in_the_searchcompares the result and every report of a followed search with an unfollowed one, for one line and for three. In the measurements below, the node counts of all four runs of each position are identical.Cost
These are single-thread fixed-depth searches (
"deterministic": true) throughcb2026 --cnp, 5 runs each, with the medians shown.mainis origin/main's binary (6a0038f);branchis this PR's. The runs were interleaved on the M1 Max with the machine quiet (load about 5–12):The unused hooks (
branchwith norootMs) androotMs250 are within ±1% ofmain, which is run-to-run noise.rootMs0, the worst case, sends a notification at every clock check, about 1,800 a second, each with all the root moves, and costs 2–6%.A real search
The position after 1.e4 e5 2.Nf3 Nc6 was searched for 5 s with MultiPV 3 and
rootMs250, reaching depth 19. It sent 57engine/root, all before the result: 16 plain, 40betterand 1failLow, with nofailHigh. 31 of thebetters came in the first 100 ms (depths 1–10). From 200 ms on there were 15 plain, 9betterand 1failLow. Two of them, abridged here to the three biggest node counts:Tests
root::tests): the search is unchanged when followed; every root move is followed, with its nodes (their sum never more than the total), its place, the count and a best from depth 1 on; abetter(always a later move, about itself) and an aspiration failure (the depth restarting at its first move, which is the fail-high move after a fail high) are heard at depth 8 from the start; with three lines, each line is followed over its own moves (20, 19, 18).following_the_root_is_throttled_and_never_comes_after_the_answercovers the ids, line numbers, places, node sums, the throttle (each plain notification at leastrootMsafter the one before), the bounds onfailHighandfailLow, and nothing after the answer.a_search_that_doesn_t_ask_isn_t_followed: noengine/root, and progress still comes.crates/cli/tests/cnp.rs): CNP'sroot(including its newforbidstep: noengine/rootafter the result) androot-multipvpass against the real binary.root-unsupportedis skipped, since cb2026 offersroot.Checks
scripts/check.shpassed locally on 2ba3f58, the latest commit: fmt, clippy (with the trainer'sgpufeature too), tests (GPU included), the perft suite, docs,cargo denyand the book.Docs
docs/PRD.md(Chess Node Protocol) anddocs/status.mdare updated.No functional change. Bench: 767812
🤖 Generated with Claude Code