Skip to content

Engine: the search tree (engine/tree, engine/treeNode, capability tree) - #22

Merged
cjus merged 3 commits into
mainfrom
claude/search-tree
Nov 1, 2026
Merged

cjus merged 3 commits into
mainfrom
claude/search-tree

Conversation

@cjus

@cjus cjus commented Nov 1, 2026

Copy link
Copy Markdown
Owner

For cjus/chessgui#350 (Engine Mind's search-tree panel: "why not that move?"). Defines the names §13 reserved: engine/tree and engine/treeNode, behind the capability tree, added to the 1.0 draft. Not to merge yet (the owner reviews first).

Why

A search tree answers "why not that move?": for each root move, how the search settled it (the best, refuted by a reply, dismissed at once, pruned, reduced), and each move's replies the same way. A tree is large (with cb2026 at depth 16: 560–900 nodes at three plies, 6,300–9,300 nodes and 16,000–23,000 decisions at six), so the node keeps it under a handle and the client reads it a node and a page of children at a time.

What

  • §7.8 The search tree. engine/tree {position, depth, plies?, limit?} searches and answers with the handle, expiresMs (idle expiry, renewed by each read), the search's result (depth, selDepth, nodes, timeMs, bestMove, score, pv), recorded (plies, nodes, decisions, truncated), the root, and its first limit children. engine/treeNode {tree, path, offset?, limit?} answers with the node (childCount is the total) and a page of its children.
  • A node is shown as its last search, the one whose score counted: its depth, its window (alpha, beta, CNP scores, an edge left out when there is none), its score with its bound read against that window, childCount, subtree, and decisions. The searches before the last show as the decisions that led to it.
  • Decisions are alpha-beta's, not an engine's (rule 3): cutoff (move, order), table, tablebase, nullMove, nodePruned (move, optional: ProbCut's capture), movePruned (move), reduced (plies), extended (plies), research (reason: depth or window). Each may name the engine/techniques id behind it in technique. A decision's move is always a move from its own node. A client ignores a kind or reason it doesn't know; the crate reads them as Unknown.
  • Limits maxTreeDepth (default maxDepth), maxTreePlies, maxConcurrentTrees (default 1). A tree counts toward maxConcurrentTrees, not maxConcurrentSearches, so a client can ask for one while the engine plays.
  • Error Expired (-32018): a handle the node no longer keeps, or never gave. A path to no node of the tree is InvalidParams.
  • Cancelling: $/cancelRequest drops a tree (Cancelled, nothing kept), and doesn't make the next tree Busy. engine/stop doesn't apply: a tree is wanted whole. maxTimeMs bounds a tree's search (LimitExceeded).
  • §1 names the handle as the one exception to requests standing alone: a cache, per connection, that a client asks again for. Nodes SHOULD record a tree deterministically. §9, §10, §13, §14 updated.
  • Types: Tree, TreeNodePage, TreeParams, TreeResult, Recorded, TreeNode, Decision, DecisionKind, ResearchReason, TreeNodeParams, TreeNodeResult, EngineCapabilities::tree, the three Limits fields with tree_depth() and concurrent_trees(), code::EXPIRED, with tests. The spec's examples are cb2026's real tree of §7.1's position (its PV shortened).
  • Seven sessions: tree, tree-errors, tree-limits, tree-while-searching, tree-cancel, tree-checkmated, tree-unsupported.

Checked

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test, RUSTDOCFLAGS=-D\ warnings cargo doc --workspace --no-deps and cargo deny check pass locally.
  • cb2026's node, built against this branch (its PR is open, pinned here), passes every session that applies, the six new ones included.

Breaking for struct literals: EngineCapabilities and Limits literals need the new fields, as with ponder and quiet. cb2026's and Solrac's pin bumps make those changes.

🤖 Generated with Claude Code

cjus and others added 3 commits November 1, 2026 16:05
…lity tree)

The tree's request and result, its nodes and their decisions in alpha-beta's
terms, the tree limits (maxTreeDepth, maxTreePlies, maxConcurrentTrees) and the
error Expired. The spec and the conformance sessions follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engine/tree searches a position and keeps its tree under a handle that expires;
engine/treeNode reads a node and a page of its children by its path. A node is
its last search: its window, its score bounded by that window, its children and
its decisions, which are alpha-beta's (cutoff, table, tablebase, nullMove,
nodePruned, movePruned, reduced, extended, research), each naming the
engine/techniques id behind it. The capability tree, the limits maxTreeDepth,
maxTreePlies and maxConcurrentTrees, and the error Expired (-32018), recorded in
1.0's changes and taken off the reserved names. The examples are cb2026's tree
of 7.1's position. Seven sessions: reading a tree, its errors, its limits, a
tree during a search, a cancelled one, a checkmated position, and a node
without tree (cjus/chessgui#350).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xample's prose

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cjus
cjus marked this pull request as ready for review November 1, 2026 23:32
@cjus
cjus merged commit deeab77 into main Nov 1, 2026
2 checks passed
cjus added a commit to cjus/chessengine that referenced this pull request Nov 1, 2026
The same tree as the branch's 68cf80d, now on the protocol's main.

No functional change.

Bench: 767812

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant