Skip to content

feat(nav): walkDistancesFrom — reuse the resolved origin across a destination scan (4.2.0) - #61

Merged
apotema merged 2 commits into
mainfrom
perf/reuse-resolved-movement-nodes
Oct 14, 2026
Merged

apotema merged 2 commits into
mainfrom
perf/reuse-resolved-movement-nodes

Conversation

@apotema

@apotema apotema commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

What

Controller.walkDistancesFrom(game, origin) returns a WalkDistances query whose to(target) reuses the origin's world position and validated nearest node across a synchronous, read-only candidate scan. Same semantics as walkDistance on every path: pre-graph Euclidean, off-graph origin → ∞ without touching the target's cache entry, targets resolved live through the position-validated nearest_node_cache. Documented as scan-scoped (discard before the origin or its ancestors move, the graph changes, or the frame advances); not a cross-frame cache.

Consumer: Flying Platform's findEmptyStorageDestinationFiltered (one origin, ~300 accepting slots per scan) — companion FP PR follows once this is released. Version bumped to 4.2.0 (minor: new query, no behaviour change).

Measured (Flying Platform big_colony, Android emulator, ReleaseFast, per-frame probes; same tree on 4.1.0 vs this branch via a local override, no tracer running)

destination scan 4.1.0 this branch
~250 path queries per scan (n=221) 135 µs 110 µs
~350 queries (n=26) 198 µs 182 µs
<100 queries (n=60) 85 µs 85 µs
production_flush p95 / p99 / max 6.3 / 11.7 / 14.9 ms 5.6 / 9.3 / 13.4 ms

The saving scales with queries per scan (the per-candidate origin resolution it removes); scans with few queries are unchanged. Investigation thread: moca-tecnologia/flying-platform-labelle#1042 (last comment).

Validation

zig build test: 13/13 incl. the two new WalkOrigin tests (Euclidean fallback, graph unreachable, refresh after movement and graph rebuild).

https://claude.ai/code/session_01LpszrcSrLLijQcxxvgWyUQ

Minor: a new query (`Controller.walkDistancesFrom` / `WalkDistances`)
for synchronous destination scans; no behaviour change for existing
callers.

Claude-Session: https://claude.ai/code/session_01LpszrcSrLLijQcxxvgWyUQ
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 8d159ba1-8b9d-424c-abba-117d1d41e0e4
📥 Commits

Reviewing files that changed from the base of the PR and between 2aec3e4 and 014aa79.

📒 Files selected for processing: 3
  • README.md
  • build.zig.zon
  • src/nav/controller.zig

Included review availability: This review used your included allowance. 9 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

📝 Walkthrough

Controller.walkDistancesFrom adds a scan-scoped query that resolves its origin once and resolves each destination live. It supports Euclidean fallback and graph path distances, with infinite results for unreachable cases. The documentation describes when to discard the query. The package version changes to 4.2.0.

Changes: Navigation distance scans

Layer / File(s) Summary
Distance scan query API
src/nav/controller.zig, README.md, build.zig.zon
The controller adds walkDistancesFrom and documents its use and constraints. The README describes the query. The package version changes from 4.1.0 to 4.2.0.
Origin resolution and distance results
src/nav/controller.zig
WalkOrigin handles Euclidean fallback, graph path costs, and infinite results. Tests cover fallback, unreachable results, and fresh origin resolution across scans.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 014aa

No identified issue blocks merging; run the normal checks before merge.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the new navigation query and its main benefit: reusing the resolved origin during a destination scan. The version suffix is relevant to the release change.
Description check Passed The description directly explains the new API, preserved distance semantics, scan-scoped restrictions, performance measurements, version change, and test validation. It is fully related to the changes…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T17:51:00.890351Z 014aa79 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@apotema
apotema merged commit 70d6e5e into main Oct 14, 2026
2 checks passed
@apotema
apotema deleted the perf/reuse-resolved-movement-nodes branch October 14, 2026 17:51
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