feat(modapi): nav.closest, the closest point on the game's navmesh, made after its navmesh update #2745

Open
ChloeNow wants to merge 5 commits from ChloeNow/Longshot:feat/modapi-nav-closest into mod-api
Contributor

feat(modapi): nav.closest, the closest point on the game's navmesh, made after its navmesh update

Summary

A first longshot/nav module: nav.closest(position, { radius }) settles with the point on the game's own navmesh
closest to a position (and its distance), or null. A mod can now put a spawned actor where a character could stand,
check that a spot is walkable, or snap a marker to the ground, as the game's AI does (its
QueryGetClosestNavMeshPoint). It is the first of the navmesh calls: paths, line of sight along the navmesh and a mod's
own cuts come next, on the same site (docs/dev/reference/nav.md, "What comes next").

  • game-core:
    • nav (new) asks the game's closest-point call (nav.closest, f_80542dc0). The request is built on the guest
      stack, as the game's callers build it (layout::nav), for the map's first character type, with the default
      filter and no navmesh object of the asker's own.
    • The manager comes from its variable (nav.manager, 0x84eaedb0); 0 means no navmesh now.
    • Fixed slots hand queries over without a lock, as rays does.
  • One site: nav.updated, the return of the navmesh manager's update job (f_80781b00, which holds the manager's
    lock exclusively while it steps the Havok AI world). Queries are made there, on that job's thread, once every lock is
    released.
    • This is the reason the main thread never asks itself: the call takes the same lock shared, and the update may wait
      on jobs the main thread runs, which is the reason world.ray is cast after the physics step.
    • The site is off while nothing is asked.
  • api: services::nav (new). It allows at most 64 queries a frame for a mod, and nulls a query that has waited 4
    frames (a pause, a load). Answers settle at the next serial point. It needs state.read.
    • The feature is has("nav.closest").
    • Schema: nav.toml, plus NavPoint and NavOptions in types.toml.
  • Docs:
    • docs/modding/nav.md, the guide.
    • docs/dev/reference/nav.md: what was read of the game, the request's layout, the threading, and the run.
    • The generated reference.

Read first: game/crates/game-core/src/nav.rs, the nav.updated site in game/sites/sites.toml, and
game/crates/api/src/services/nav.rs.

Testing

Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, build e0f3ccfa.

Game-free tests:

  • game-core nav: 6 new tests, run with host_sys::fake.
    • Asked, made and taken.
    • Cancelled.
    • Every slot taken.
    • The request in guest memory, byte for byte as the game builds it, against a fake call.
    • Nothing near, no manager, a bad ask.
    • The feature needs the call, the manager and the site.
  • api services::nav: 2 new tests (a point read as a NavPoint with its distance, and the radius rules). The settling
    and the limit are covered by the in-game run.
  • game-core (all), game-sites, and the builder's sites (the new site's owner line) pass.
  • schema-gen --check, tests/test_doc_anchors.py, and cargo check --workspace are clean.

In the game: a probe mod's in-game test, dev.py game-tests, sandboxed and headless. Link starts in Kokiri Forest
at (-46.09, 118.44, 15.39).

  • has("nav.closest") is true.
  • From Link: the point 0.05 m below his feet.
  • From 1.5 m above him (radius 3): the ground below, 1.55 m away.
  • From 30 m above (radius 2): null.
  • 40 queries in one frame along a 20 m line, 1 m up (radius 4): all settled, 34 points and 6 null, where the line left
    the walkable ground.
  • 70 asked in one frame: 64 asked, the other 6 thrown as a LimitError at the call.
  • The test: ok - test/nav.test.ts: the closest navmesh point is under Link, found from above, and none 30 m up, 1
    passed, exit 0.
  • Run again on this branch's head, rebased on the squashed mod-api (eaf4a48b9), with the builder confining the
    game: the same numbers, and the test passed (exit 0). It was merged locally with #2726 and #2747, which a sandboxed
    test run on the new mod-api needs; that merge was not pushed. The first runs were on the earlier mod-api, before
    the rebase and BeanBot's batch-bounding commit.

Still to test:

  • @Beanstalk: Linux, in the game: dev.py game-tests of a mod calling nav.closest at Link in Kokiri Forest.
  • By hand: Hyrule Field's tiled navmesh, and a map with none.
  • By hand: a query across a load, which should be null after 4 frames.
The 118 checks that fail on Windows on mod-api (`eaf4a48b9`) too

test_antilag.py, test_astc_decoder_gpu.py, test_async_safe_frees.py, test_audio_output_devices.py, test_audio_source_load.py, test_auto_handheld.py, test_bc_copy_layer_pitch.py, test_builder_channel.py, test_builtin_compute_unoptimized.py, test_capture_dimensions.py, test_capture_readback_visibility.py, test_capture_resources.py, test_coopmat_probe_failures.py, test_crash_record.py, test_desc_counts.py, test_dev_ab.py, test_dev_build.py, test_dev_migrate.py, test_dev_packs.py, test_dev_update.py, test_device_policy.py, test_draw_binds.py, test_draw_stream_visibility.py, test_drs.py, test_dummy_views.py, test_dump_readback.py, test_fallback_pipeline_state.py, test_float_add_subgroup.py, test_framegen_resources.py, test_framelog_sink.py, test_fsr3_release_frees.py, test_fsr3fi_hud_mask.py, test_fsr4_bind_dispatch.py, test_fsr4_tune.py, test_fsr_image_retirement.py, test_fsr_uniform_ownership.py, test_game_menu_mouse_buttons.py, test_gcn_mesh_shared_warp.py, test_image_view_retry.py, test_import_buffer_binding.py, test_import_log.py, test_import_reach.py, test_inline_write_order.py, test_input_background.py, test_input_movie.py, test_job_queue.py, test_lifter.py, test_linux_pressure.py, test_loaded_modules_drop.py, test_longshot_builder.py, test_longshot_ctl.py, test_lost_wait_said.py, test_low_vram_texture_mips.py, test_menu_hooks.py, test_mesh_fallback_strict_fmul.py, test_mesh_first_types.py, test_pads_after_menu.py, test_parity_gates.py, test_pass_barrier.py, test_pass_hazard.py, test_pcache_header_read.py, test_pipeline_key_values.py, test_pipeline_state_portable.py, test_pipeline_states.py, test_present_probe.py, test_present_queue_default.py, test_present_sites.py, test_present_source_crop.py, test_program_answer_domains.py, test_program_cache_cleanup.py, test_program_cache_one_variant.py, test_push_state.py, test_queue_priority.py, test_recorder_own_idle.py, test_recorder_parts.py, test_recorder_sync.py, test_recording_admission.py, test_replay_write_order.py, test_reshade_fx.py, test_run_all_mingw.py, test_same_draw.py, test_same_dyn.py, test_sampler_admission.py, test_seed_reader.py, test_shader_store.py, test_sparse_bind_failure.py, test_sparse_bind_ranges.py, test_split_ub_flush.py, test_staging_burst.py, test_taau_typed_dispatch.py, test_table_track.py, test_target_layouts.py, test_target_reuse_memory.py, test_temporal_present_bandwidth.py, test_texel_buffer_ownership.py, test_texture_init_barrier.py, test_texture_staging_publication.py, test_ub_snapshot_default.py, test_ub_update_batch.py, test_ui_record.py, test_ui_texture_upload.py, test_vcore_video_acquire.py, test_vendor_fixes.py, test_vertex_bind.py, test_vertex_bind_range.py, test_video_catchup.py, test_video_hold_early.py, test_video_input_limit.py, test_vk_occlusion_queries.py, test_vulkan_clear_mip.py, test_vulkan_copy_span.py, test_vulkan_copy_span_gpu_compile.py, test_wb_diff_observations_gpu.py, test_widen_alpha.py, test_windows_on_linux.py, test_windows_stop.py, test_wmma16_zero_c_kchain.py, test_xinput_thread.py

Measurements

Nothing to measure: the site is off while no mod asks, and a query is one call of the game's own on its navmesh job's thread.

Risks

  • Safety of the call. It is made on the navmesh job's thread once the job has released its locks, while the game's
    own readers take the same lock shared from their threads. The call is a reader too.
  • Wrong answers. If the game changed its request layout, a query would answer wrong, not crash: the request is the
    game's own, fully written and zeroed. The site's signature pins the build.
  • Reverting is enough: nothing is written to saves.

Checklist

Ready for review

  • One topic, on current mod-api; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named): Windows, this branch: 669 passed, 120 failed, 47 skipped. The same 118 fail on mod-api; the other two (test_host_alloc_wait, test_mesh_args_cleanup) pass on rerun, flaky under the full run.
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

feat(modapi): nav.closest, the closest point on the game's navmesh, made after its navmesh update ## Summary A first `longshot/nav` module: `nav.closest(position, { radius })` settles with the point on the game's own navmesh closest to a position (and its distance), or null. A mod can now put a spawned actor where a character could stand, check that a spot is walkable, or snap a marker to the ground, as the game's AI does (its `QueryGetClosestNavMeshPoint`). It is the first of the navmesh calls: paths, line of sight along the navmesh and a mod's own cuts come next, on the same site (`docs/dev/reference/nav.md`, "What comes next"). - **`game-core`**: - `nav` (new) asks the game's closest-point call (`nav.closest`, `f_80542dc0`). The request is built on the guest stack, as the game's callers build it (`layout::nav`), for the map's first character type, with the default filter and no navmesh object of the asker's own. - The manager comes from its variable (`nav.manager`, `0x84eaedb0`); 0 means no navmesh now. - Fixed slots hand queries over without a lock, as `rays` does. - **One site**: `nav.updated`, the return of the navmesh manager's update job (`f_80781b00`, which holds the manager's lock exclusively while it steps the Havok AI world). Queries are made there, on that job's thread, once every lock is released. - This is the reason the main thread never asks itself: the call takes the same lock shared, and the update may wait on jobs the main thread runs, which is the reason `world.ray` is cast after the physics step. - The site is off while nothing is asked. - **`api`**: `services::nav` (new). It allows at most 64 queries a frame for a mod, and nulls a query that has waited 4 frames (a pause, a load). Answers settle at the next serial point. It needs `state.read`. - The feature is `has("nav.closest")`. - Schema: `nav.toml`, plus `NavPoint` and `NavOptions` in `types.toml`. - **Docs**: - `docs/modding/nav.md`, the guide. - `docs/dev/reference/nav.md`: what was read of the game, the request's layout, the threading, and the run. - The generated reference. Read first: `game/crates/game-core/src/nav.rs`, the `nav.updated` site in `game/sites/sites.toml`, and `game/crates/api/src/services/nav.rs`. ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, build `e0f3ccfa`. **Game-free tests:** - `game-core` `nav`: 6 new tests, run with `host_sys::fake`. - Asked, made and taken. - Cancelled. - Every slot taken. - The request in guest memory, byte for byte as the game builds it, against a fake call. - Nothing near, no manager, a bad ask. - The feature needs the call, the manager and the site. - `api` `services::nav`: 2 new tests (a point read as a `NavPoint` with its distance, and the radius rules). The settling and the limit are covered by the in-game run. - `game-core` (all), `game-sites`, and the builder's `sites` (the new site's owner line) pass. - `schema-gen --check`, `tests/test_doc_anchors.py`, and `cargo check --workspace` are clean. **In the game:** a probe mod's in-game test, `dev.py game-tests`, sandboxed and headless. Link starts in Kokiri Forest at (-46.09, 118.44, 15.39). - `has("nav.closest")` is true. - From Link: the point 0.05 m below his feet. - From 1.5 m above him (radius 3): the ground below, 1.55 m away. - From 30 m above (radius 2): null. - 40 queries in one frame along a 20 m line, 1 m up (radius 4): all settled, 34 points and 6 null, where the line left the walkable ground. - 70 asked in one frame: 64 asked, the other 6 thrown as a `LimitError` at the call. - The test: `ok - test/nav.test.ts: the closest navmesh point is under Link, found from above, and none 30 m up`, 1 passed, exit 0. - Run again on this branch's head, rebased on the squashed `mod-api` (`eaf4a48b9`), with the builder confining the game: the same numbers, and the test passed (exit 0). It was merged locally with #2726 and #2747, which a sandboxed test run on the new `mod-api` needs; that merge was not pushed. The first runs were on the earlier `mod-api`, before the rebase and BeanBot's batch-bounding commit. **Still to test:** - @Beanstalk: Linux, in the game: `dev.py game-tests` of a mod calling `nav.closest` at Link in Kokiri Forest. - By hand: Hyrule Field's tiled navmesh, and a map with none. - By hand: a query across a load, which should be null after 4 frames. <details><summary>The 118 checks that fail on Windows on mod-api (`eaf4a48b9`) too</summary> `test_antilag.py`, `test_astc_decoder_gpu.py`, `test_async_safe_frees.py`, `test_audio_output_devices.py`, `test_audio_source_load.py`, `test_auto_handheld.py`, `test_bc_copy_layer_pitch.py`, `test_builder_channel.py`, `test_builtin_compute_unoptimized.py`, `test_capture_dimensions.py`, `test_capture_readback_visibility.py`, `test_capture_resources.py`, `test_coopmat_probe_failures.py`, `test_crash_record.py`, `test_desc_counts.py`, `test_dev_ab.py`, `test_dev_build.py`, `test_dev_migrate.py`, `test_dev_packs.py`, `test_dev_update.py`, `test_device_policy.py`, `test_draw_binds.py`, `test_draw_stream_visibility.py`, `test_drs.py`, `test_dummy_views.py`, `test_dump_readback.py`, `test_fallback_pipeline_state.py`, `test_float_add_subgroup.py`, `test_framegen_resources.py`, `test_framelog_sink.py`, `test_fsr3_release_frees.py`, `test_fsr3fi_hud_mask.py`, `test_fsr4_bind_dispatch.py`, `test_fsr4_tune.py`, `test_fsr_image_retirement.py`, `test_fsr_uniform_ownership.py`, `test_game_menu_mouse_buttons.py`, `test_gcn_mesh_shared_warp.py`, `test_image_view_retry.py`, `test_import_buffer_binding.py`, `test_import_log.py`, `test_import_reach.py`, `test_inline_write_order.py`, `test_input_background.py`, `test_input_movie.py`, `test_job_queue.py`, `test_lifter.py`, `test_linux_pressure.py`, `test_loaded_modules_drop.py`, `test_longshot_builder.py`, `test_longshot_ctl.py`, `test_lost_wait_said.py`, `test_low_vram_texture_mips.py`, `test_menu_hooks.py`, `test_mesh_fallback_strict_fmul.py`, `test_mesh_first_types.py`, `test_pads_after_menu.py`, `test_parity_gates.py`, `test_pass_barrier.py`, `test_pass_hazard.py`, `test_pcache_header_read.py`, `test_pipeline_key_values.py`, `test_pipeline_state_portable.py`, `test_pipeline_states.py`, `test_present_probe.py`, `test_present_queue_default.py`, `test_present_sites.py`, `test_present_source_crop.py`, `test_program_answer_domains.py`, `test_program_cache_cleanup.py`, `test_program_cache_one_variant.py`, `test_push_state.py`, `test_queue_priority.py`, `test_recorder_own_idle.py`, `test_recorder_parts.py`, `test_recorder_sync.py`, `test_recording_admission.py`, `test_replay_write_order.py`, `test_reshade_fx.py`, `test_run_all_mingw.py`, `test_same_draw.py`, `test_same_dyn.py`, `test_sampler_admission.py`, `test_seed_reader.py`, `test_shader_store.py`, `test_sparse_bind_failure.py`, `test_sparse_bind_ranges.py`, `test_split_ub_flush.py`, `test_staging_burst.py`, `test_taau_typed_dispatch.py`, `test_table_track.py`, `test_target_layouts.py`, `test_target_reuse_memory.py`, `test_temporal_present_bandwidth.py`, `test_texel_buffer_ownership.py`, `test_texture_init_barrier.py`, `test_texture_staging_publication.py`, `test_ub_snapshot_default.py`, `test_ub_update_batch.py`, `test_ui_record.py`, `test_ui_texture_upload.py`, `test_vcore_video_acquire.py`, `test_vendor_fixes.py`, `test_vertex_bind.py`, `test_vertex_bind_range.py`, `test_video_catchup.py`, `test_video_hold_early.py`, `test_video_input_limit.py`, `test_vk_occlusion_queries.py`, `test_vulkan_clear_mip.py`, `test_vulkan_copy_span.py`, `test_vulkan_copy_span_gpu_compile.py`, `test_wb_diff_observations_gpu.py`, `test_widen_alpha.py`, `test_windows_on_linux.py`, `test_windows_stop.py`, `test_wmma16_zero_c_kchain.py`, `test_xinput_thread.py` </details> ## Measurements Nothing to measure: the site is off while no mod asks, and a query is one call of the game's own on its navmesh job's thread. ## Risks - **Safety of the call.** It is made on the navmesh job's thread once the job has released its locks, while the game's own readers take the same lock shared from their threads. The call is a reader too. - **Wrong answers.** If the game changed its request layout, a query would answer wrong, not crash: the request is the game's own, fully written and zeroed. The site's signature pins the build. - **Reverting** is enough: nothing is written to saves. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named): Windows, this branch: 669 passed, 120 failed, 47 skipped. The same 118 fail on mod-api; the other two (`test_host_alloc_wait`, `test_mesh_args_cleanup`) pass on rerun, flaky under the full run. - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A new module, longshot/nav, and its first call: nav.closest(position, { radius }) settles with the point on the game's
navmesh closest to a position (a NavPoint: the point and its distance), or null (none within the radius, no navmesh now,
or not made in 4 frames), as the game's AI asks it (QueryGetClosestNavMeshPoint).

- game_core::nav: the game's call (f_80542dc0: the navmesh manager, the request as the AI node and the movement code
  build it, the point out) made on the navmesh manager's update job's thread, at the update's return (the site
  nav.updated, f_80781b00's), never from the main thread: the call takes the manager's reader/writer lock shared, and
  the update holds it exclusively while it steps the navmesh world. The hand-over is the rays' slots, no lock; with
  nothing asked the site is off. A mod's request: the map's first character type, the game's default face filter, no
  navmesh object of its own, no flags.
- api::services::nav: at most 64 queries a frame a mod, a radius more than 0 and at most 50 m (2 by default); a stopped
  mod's queries let go. has("nav.closest") is the call, the manager's variable and the site found in this build.
- sites.toml: the locations nav.closest and nav.manager, the site nav.updated (its signature the update's step call).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/modding/nav.md: nav.closest for mod authors (the radius, when it is null, when it settles, the
limits). docs/dev/reference/nav.md: the game's navmesh manager, the closest-point call and its
request as the game's callers build it, why queries are made at the update job's return, and the
in-game run (sandboxed, Kokiri Forest). Both pages are listed in the guide's indexes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(modapi): nav.closest's limit in the run
All checks were successful
PR description / Title and description (pull_request_target) Successful in 5s
d6ccb5ba51
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 4060 Laptop, sandboxed dev.py game-tests of a probe mod in Kokiri Forest on this head (with #2726 and #2742 merged locally): the closest point under Link, the ground found from 1.5 m above, null 30 m up, 40 queries in a frame all settled, the 65th to 70th in a frame a LimitError; 1 passed, exit 0.

Tested in game: Windows 11, RTX 4060 Laptop, sandboxed dev.py game-tests of a probe mod in Kokiri Forest on this head (with #2726 and #2742 merged locally): the closest point under Link, the ground found from 1.5 m above, null 30 m up, 40 queries in a frame all settled, the 65th to 70th in a frame a LimitError; 1 passed, exit 0.
Member

Possibly related, for context:

  • PR #2663 feat(modapi): world shapes: sphere, capsule and box casts and overlaps through the game's own shape query — Related mod API native game-query feature; overlaps same mod API code and schema/docs areas.
Possibly related, for context: - PR #2663 feat(modapi): world shapes: sphere, capsule and box casts and overlaps through the game's own shape query — Related mod API native game-query feature; overlaps same mod API code and schema/docs areas.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The change leaves the update hook active after the last querying mod stops. The recorded Windows run shows the basic query working, but load behavior, Linux, and the cost of queries remain untested. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

Adds an asynchronous mod API for finding a nearby navmesh point, with per-mod limits and a timeout. It gives mods a useful placement primitive, at the cost of work on the navmesh update thread and a fixed shared query pool.

Should fix (1): not blocking, but worth doing before merging.

  • L1 game/crates/api/src/services/nav.rs:91: Stopping the last mod with pending queries cancels its slots but never disables the update site. (more on the line) Do: Call nav::idle after removing the last query, and cover stopping a mod with a pending query.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 game/sites/sites.toml:2227: The worker-thread call and its timeout have only been exercised in one area on Windows. (more on the line) Do: Run the query on Linux, on a tiled map and a map without a navmesh, and across a load; check the returned points, nulls and timeout.
  • L3 game/crates/game-core/src/nav.rs:179: The cost of processing a batch on the navmesh update thread is unknown. (more on the line) Do: Compare frame times and update-job duration with and without representative and maximum query batches, using repeated runs in a demanding scene. (@fix does its part first: Bound or spread the number of queries processed by one update.)

@fix can do L1 and L3.

More: does it help, other systems, switches, what was read

Does it help: Yes for the basic feature: the reported Windows run found ground below Link, returned null for a distant query, and settled 40 queries. It does not establish behavior across loads, on tiled or absent navmeshes, or on Linux; query costs were not measured.

Other systems: The hook runs on the game’s navmesh worker and can affect its update timing when mods query it. The recorded run covers one Windows NVIDIA system in Kokiri Forest; Linux, tiled and absent navmeshes, and queries across loads remain untested. Saves are not written, and no renderer interface changes.

Switches: None.

Reviewed: d6ccb5ba51 against 5c1cd9f5b1: Read the repository rules and PR template, commit log, changed nav service and game-core implementation, layouts, call binding, schema and site change, and traced frame and shutdown paths, site registration and guest-memory access. Read the integration diffs and skimmed generated documentation and the recorded run. The sibling Tooling checkout and docs/review-checklist.md were absent. Larger surrounding files and unrelated existing site definitions were skimmed, not read in full.; nothing run (a code review).

Checked and fine:

  • All three commits record AI assistance.
  • The request fields and output are initialized before the game call; cancellation handles a query already being processed.
  • The generated reference and permission table include the new API, and no switch or renderer API version changes are present.

Testing: Read-only review; no code or tests were run. The author reports game-free checks and one in-game Windows run, with two other PRs merged locally.

Overlaps and merge order: The reported test included local merges of #2726 and #2742; their merge status and overlap could not be verified offline.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The change leaves the update hook active after the last querying mod stops. The recorded Windows run shows the basic query working, but load behavior, Linux, and the cost of queries remain untested. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. Adds an asynchronous mod API for finding a nearby navmesh point, with per-mod limits and a timeout. It gives mods a useful placement primitive, at the cost of work on the navmesh update thread and a fixed shared query pool. **Should fix (1)**: not blocking, but worth doing before merging. - **L1** `game/crates/api/src/services/nav.rs:91`: Stopping the last mod with pending queries cancels its slots but never disables the update site. (more on the line) **Do:** Call nav::idle after removing the last query, and cover stopping a mod with a pending query. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `game/sites/sites.toml:2227`: The worker-thread call and its timeout have only been exercised in one area on Windows. (more on the line) **Do:** Run the query on Linux, on a tiled map and a map without a navmesh, and across a load; check the returned points, nulls and timeout. - **L3** `game/crates/game-core/src/nav.rs:179`: The cost of processing a batch on the navmesh update thread is unknown. (more on the line) **Do:** Compare frame times and update-job duration with and without representative and maximum query batches, using repeated runs in a demanding scene. *(`@fix` does its part first: Bound or spread the number of queries processed by one update.)* `@fix` can do L1 and L3. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the basic feature: the reported Windows run found ground below Link, returned null for a distant query, and settled 40 queries. It does not establish behavior across loads, on tiled or absent navmeshes, or on Linux; query costs were not measured. **Other systems:** The hook runs on the game’s navmesh worker and can affect its update timing when mods query it. The recorded run covers one Windows NVIDIA system in Kokiri Forest; Linux, tiled and absent navmeshes, and queries across loads remain untested. Saves are not written, and no renderer interface changes. **Switches:** None. **Reviewed:** d6ccb5ba5135 against 5c1cd9f5b1ac: Read the repository rules and PR template, commit log, changed nav service and game-core implementation, layouts, call binding, schema and site change, and traced frame and shutdown paths, site registration and guest-memory access. Read the integration diffs and skimmed generated documentation and the recorded run. The sibling Tooling checkout and docs/review-checklist.md were absent. Larger surrounding files and unrelated existing site definitions were skimmed, not read in full.; nothing run (a code review). **Checked and fine:** - All three commits record AI assistance. - The request fields and output are initialized before the game call; cancellation handles a query already being processed. - The generated reference and permission table include the new API, and no switch or renderer API version changes are present. **Testing:** Read-only review; no code or tests were run. The author reports game-free checks and one in-game Windows run, with two other PRs merged locally. **Overlaps and merge order:** The reported test included local merges of #2726 and #2742; their merge status and overlap could not be verified offline. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -0,0 +88,4 @@
}
/// A stopped mod's queries let go.
pub(crate) fn nav_gone(&self, main: &MainThread, id: &ModId) {
Member

L1 (should fix): Stopping the last mod with pending queries cancels its slots but never disables the update site.

When: When nav_gone removes the final query, subsequent nav_step calls return immediately because the query list is empty, so nav::idle is never called and the hook stays active for the rest of the session.

Do: Call nav::idle after removing the last query, and cover stopping a mod with a pending query.

**L1** (should fix): Stopping the last mod with pending queries cancels its slots but never disables the update site. *When:* When nav_gone removes the final query, subsequent nav_step calls return immediately because the query list is empty, so nav::idle is never called and the hook stays active for the rest of the session. **Do:** Call nav::idle after removing the last query, and cover stopping a mod with a pending query.
@ -0,0 +176,4 @@
return;
}
for slot in &self.slots {
if slot.state.compare_exchange(ASKED, QUERYING, Ordering::AcqRel, Ordering::Acquire).is_err() {
Member

L3 (should fix): The cost of processing a batch on the navmesh update thread is unknown.

When: A mod can request 64 queries in a frame, and multiple mods can fill the shared pool; those game calls execute serially before the update job returns.

Do: Compare frame times and update-job duration with and without representative and maximum query batches, using repeated runs in a demanding scene.

**L3** (should fix): The cost of processing a batch on the navmesh update thread is unknown. *When:* A mod can request 64 queries in a frame, and multiple mods can fill the shared pool; those game calls execute serially before the update job returns. **Do:** Compare frame times and update-job duration with and without representative and maximum query batches, using repeated runs in a demanding scene.
@ -2224,2 +2224,4 @@
builds.e0f3ccfa = { fn = "f_838d0080", offset = 0xa4 }
[[site]]
name = "nav.updated"
Member

L2 (should fix): The worker-thread call and its timeout have only been exercised in one area on Windows.

When: Queries during a map load, on a tiled navmesh, or on Linux can take different lifecycle and scheduling paths from the recorded Kokiri Forest run.

Do: Run the query on Linux, on a tiled map and a map without a navmesh, and across a load; check the returned points, nulls and timeout.

**L2** (should fix): The worker-thread call and its timeout have only been exercised in one area on Windows. *When:* Queries during a map load, on a tiled navmesh, or on Linux can take different lifecycle and scheduling paths from the recorded Kokiri Forest run. **Do:** Run the query on Linux, on a tiled map and a map without a navmesh, and across a load; check the returned points, nulls and timeout.
Owner
@fix
fix(modapi): bound navmesh query batches and idle on mod stop
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
861ff40e24
As the review on #2745 asked.
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The query batch is bounded, but its cost on the navmesh update thread remains unmeasured, and the platform and game-state runs are still missing. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 861ff40e24. It was already up to date with mod-api. I edited its description to match the change.

Changed

  • Disable the update site after the last mod stops: Cancel stopped mods’ queries and call nav::idle when none remain; added shutdown coverage (game/crates/api/src/services/nav.rs:40). The test was not run.

Changed in part (the rest is for the author)

  • Bound queries per navmesh update: Limited each update to 32 queries with rotating slot priority, added a batch test, and updated the documentation (game/crates/game-core/src/nav.rs:38). The author must measure batch cost in game on representative hardware. Tests were not run.

Nothing was built or run: the checks run again on the new head.

Adds a mod API for finding the closest point on the game’s navmesh. The follow-up limits work to 32 queries per update and disables the site after the last mod’s queries are cancelled; the cost is delayed or timed-out queries under backlog.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 game/sites/sites.toml:2227: The worker-thread call and its timeout have only been exercised in one area on Windows. When: Queries during a map load, on a tiled navmesh, or on Linux can take different lifecycle and scheduling paths from the recorded Kokiri Forest run. Do: Run the query on Linux, on a tiled map and a map without a navmesh, and across a load; check the returned points, nulls and timeout.
  • L3 game/crates/game-core/src/nav.rs:179: The cost of the new 32-query batch on the navmesh update thread remains unknown. When: A mod submits a full batch while the game is running; the added work can delay the navmesh update, but its duration and effect on frame times are unmeasured. Do: Measure batch duration and frame times in game with and without sustained 32-query batches on representative hardware.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (2; not asked for, not blocking)
  • The API guide still describes nav queries as answered a frame later, although a backlog can delay them.
  • The developer reference still describes the slot hand-over as having no lock, although the slots use mutexes.
More: does it help, other systems, switches, what was read

Does it help: Unproven on the current head. A Windows in-game run before the follow-up found points and enforced the per-mod limit, but the bounded-batch and shutdown changes have not been run in game.

Other systems: The query executes on a game worker thread and depends on the navmesh manager and update site. Linux, tiled and absent navmeshes, and a load-spanning timeout remain untested.

Switches: None.

Reviewed: 861ff40e24 against 5c1cd9f5b1: Read AGENTS.md, CONTRIBUTING.md, the fix diff, the nav service and core query implementation, and the changed service wiring and site definition. Skimmed the overall diff statistics and commits; did not read every changed file in full.; nothing run (a code review).

Checked and fine:

  • The batch loop stops after 32 claimed queries and rotates its starting slot.
  • Stopping a mod cancels its queries and calls idle when no service queries remain.
  • The follow-up retains the nav.closest feature and its worker-thread query path.

Testing: No commands that run project code or tests were executed. The supplied Windows in-game and game-free results predate the follow-up; CI has not run on this head.

Overlaps and merge order: #2726 and #2742 were merged locally for the reported sandboxed run; their current merge status is not supplied.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The query batch is bounded, but its cost on the navmesh update thread remains unmeasured, and the platform and game-state runs are still missing. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 861ff40e24a9. It was already up to date with `mod-api`. I edited its description to match the change. **Changed** - **Disable the update site after the last mod stops**: Cancel stopped mods’ queries and call nav::idle when none remain; added shutdown coverage (game/crates/api/src/services/nav.rs:40). The test was not run. **Changed in part (the rest is for the author)** - **Bound queries per navmesh update**: Limited each update to 32 queries with rotating slot priority, added a batch test, and updated the documentation (game/crates/game-core/src/nav.rs:38). The author must measure batch cost in game on representative hardware. Tests were not run. Nothing was built or run: the checks run again on the new head. Adds a mod API for finding the closest point on the game’s navmesh. The follow-up limits work to 32 queries per update and disables the site after the last mod’s queries are cancelled; the cost is delayed or timed-out queries under backlog. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `game/sites/sites.toml:2227`: The worker-thread call and its timeout have only been exercised in one area on Windows. *When:* Queries during a map load, on a tiled navmesh, or on Linux can take different lifecycle and scheduling paths from the recorded Kokiri Forest run. **Do:** Run the query on Linux, on a tiled map and a map without a navmesh, and across a load; check the returned points, nulls and timeout. - **L3** `game/crates/game-core/src/nav.rs:179`: The cost of the new 32-query batch on the navmesh update thread remains unknown. *When:* A mod submits a full batch while the game is running; the added work can delay the navmesh update, but its duration and effect on frame times are unmeasured. **Do:** Measure batch duration and frame times in game with and without sustained 32-query batches on representative hardware. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The API guide still describes nav queries as answered a frame later, although a backlog can delay them. - The developer reference still describes the slot hand-over as having no lock, although the slots use mutexes. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the current head. A Windows in-game run before the follow-up found points and enforced the per-mod limit, but the bounded-batch and shutdown changes have not been run in game. **Other systems:** The query executes on a game worker thread and depends on the navmesh manager and update site. Linux, tiled and absent navmeshes, and a load-spanning timeout remain untested. **Switches:** None. **Reviewed:** 861ff40e24a9 against 5c1cd9f5b1ac: Read AGENTS.md, CONTRIBUTING.md, the fix diff, the nav service and core query implementation, and the changed service wiring and site definition. Skimmed the overall diff statistics and commits; did not read every changed file in full.; nothing run (a code review). **Checked and fine:** - The batch loop stops after 32 claimed queries and rotates its starting slot. - Stopping a mod cancels its queries and calls idle when no service queries remain. - The follow-up retains the nav.closest feature and its worker-thread query path. **Testing:** No commands that run project code or tests were executed. The supplied Windows in-game and game-free results predate the follow-up; CI has not run on this head. **Overlaps and merge order:** #2726 and #2742 were merged locally for the reported sandboxed run; their current merge status is not supplied. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean approved these changes 2026-11-28 19:15:03 +00:00
ChloeNow force-pushed feat/modapi-nav-closest from 861ff40e24
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
to b31f6fee96
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
2026-11-29 21:48:24 +00:00
Compare
Author
Contributor

Rebased onto the squashed mod-api (eaf4a48b9): only this PR's 4 commits now, BeanBot's batch-bounding fix kept, the generated docs made again. game-core nav (7), api nav (4), the site owners and schema-gen pass. An in-game run on the new mod-api (the builder now starts the game) is next; this comes out of WIP once that passes.

Rebased onto the squashed mod-api (`eaf4a48b9`): only this PR's 4 commits now, BeanBot's batch-bounding fix kept, the generated docs made again. game-core nav (7), api nav (4), the site owners and schema-gen pass. An in-game run on the new mod-api (the builder now starts the game) is next; this comes out of WIP once that passes.
ChloeNow changed title from WIP: feat(modapi): nav.closest, the closest point on the game's navmesh, made after its navmesh update to feat(modapi): nav.closest, the closest point on the game's navmesh, made after its navmesh update 2026-11-30 00:22:17 +00:00
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
This pull request has changes conflicting with the target branch.
  • builder/crates/build-compile/src/packages.rs
  • builder/crates/build-compile/src/toolchain.rs
  • builder/crates/build-core/src/game_layout.rs
  • builder/crates/build-core/src/sandbox_linux.rs
  • builder/crates/build-core/src/sandbox_windows/gather.rs
  • builder/crates/build-core/src/settings_folder.rs
  • builder/crates/build-driver/src/build.rs
  • builder/crates/build-driver/src/folder.rs
  • builder/crates/build-driver/src/shaders.rs
  • builder/crates/build-driver/src/sources.rs
  • builder/crates/build-driver/src/verify.rs
  • builder/crates/sites/tests/site_owners.txt
  • builder/crates/synthetic-game/game/host/synthetic_host.c
  • builder/crates/synthetic-game/tests/end_to_end.rs
  • docs/dev/developing.md
  • docs/dev/reference/architecture.md
  • docs/dev/reference/build-events.md
  • docs/dev/reference/build.md
  • docs/dev/reference/control-bridge.md
  • docs/dev/reference/profiles.md
  • docs/dev/reference/switches.md
  • docs/dev/reference/upscalers.md
  • docs/dev/setup.md
  • docs/modding/README.md
  • docs/modding/api-guide.md
  • docs/modding/content.md
  • docs/modding/permissions.md
  • docs/modding/reference.md
  • docs/modding/scripting.md
  • docs/modding/settings.md
  • docs/user/advanced.md
  • docs/user/common-issues.md
  • docs/user/graphics-and-controls.md
  • docs/user/images/guide/README.md
  • docs/user/requirements.md
  • docs/user/updates-and-saves.md
  • game/crates/api/src/services/features.rs
  • game/crates/api/src/services/frame.rs
  • game/crates/api/src/services/mod.rs
  • game/crates/api/src/services/renderer_lines.rs
  • game/crates/api/src/services/settings_host.rs
  • game/crates/api/src/settings/decl.rs
  • game/crates/api/src/settings/mod.rs
  • game/crates/cloth/build.rs
  • game/crates/game-core/src/call/mod.rs
  • game/crates/game-core/src/debug.rs
  • game/crates/game-core/src/layout/mod.rs
  • game/crates/game-core/src/lib.rs
  • game/crates/game-core/src/locations.rs
  • game/crates/game-core/src/travel.rs
  • game/crates/game-core/src/video.rs
  • game/crates/host-sys/src/settings_abi.rs
  • game/crates/host-sys/src/settings_link.rs
  • game/crates/longshot-game/src/options_store.rs
  • game/crates/longshot-game/src/perf.rs
  • game/crates/longshot-game/src/settings_file.rs
  • game/crates/longshot-game/src/settings_file/tests.rs
  • game/crates/longshot-game/src/settings_now.rs
  • game/crates/longshot-game/tests/menu_places.tsv
  • game/crates/schema/src/emit/settings_abi.rs
  • game/game.h
  • game/modapi/schema/api.toml
  • game/modapi/schema/types.toml
  • game/mods/controls/mod.toml
  • game/mods/developer/mod.toml
  • game/mods/gameplay/mod.toml
  • game/mods/graphics/mod.toml
  • game/mods/grass/Cargo.toml
  • game/mods/grass/README.md
  • game/mods/grass/mod.toml
  • game/mods/grass/src/lib.rs
  • game/mods/grass/src/tests.rs
  • game/mods/grass/test/grass.test.ts
  • game/mods/interface/mod.toml
  • game/mods/menu/src/credits.ts
  • game/mods/menu/src/layout.ts
  • game/mods/menu/strings/de.json
  • game/mods/menu/strings/es-419.json
  • game/mods/menu/strings/es.json
  • game/mods/menu/strings/fr.json
  • game/mods/menu/strings/it.json
  • game/mods/menu/strings/ja.json
  • game/mods/menu/strings/ko.json
  • game/mods/menu/strings/nl.json
  • game/mods/menu/strings/pl.json
  • game/mods/menu/strings/pt-BR.json
  • game/mods/menu/strings/ru.json
  • game/mods/menu/strings/zh-Hans.json
  • game/mods/menu/strings/zh-Hant.json
  • game/mods/menu/test/text-keys.test.ts
  • game/settings_abi.h
  • game/settings_caps.h
  • game/sites/sites.toml
  • gpu/vk/menu/framegen.cpp
  • gpu/vk/menu/framegen.h
  • gpu/vk/menu/language.cpp
  • gpu/vk/menu/sim_turf.cpp
  • gpu/vk/menu/sim_turf.h
  • gpu/vk/menu/threads.cpp
  • gpu/vk/renderer_guard.h
  • gpu/vk/switches.def
  • gpu/vk/vk_api.h
  • gpu/vk/vk_dlssg.cpp
  • gpu/vk/vk_draw.cpp
  • gpu/vk/vk_framegen.cpp
  • gpu/vk/vk_menu.cpp
  • gpu/vk/vk_menu.h
  • gpu/vk/vk_menu_i18n.cpp
  • gpu/vk/vk_shader.cpp
  • gpu/vk/vk_ui.cpp
  • host/control.c
  • host/control.h
  • host/display.c
  • host/nn_applet.c
  • host/nn_hid.c
  • host/nn_vi.c
  • host/options_path.c
  • host/posix/display_sdl.c
  • host/rx_backend.c
  • scripts/devtools/ab.py
  • scripts/shaders.py
  • scripts/sl_sdk.py
  • tests/test_device_policy.py
  • tests/test_fps_overlay_order.py
  • tests/test_frame_rate_cap_30.py
  • tests/test_framegen_by_row.py
  • tests/test_hos_ab.py
  • tests/test_key_press_queue.py
  • tests/test_menu_ini_keys.py
  • tests/test_menu_slider_ends.py
  • tests/test_pipeline_state_counts.py
  • tests/test_program_hooks.py
  • tests/test_stick_dead_zone.py
  • tests/test_temporal_present_bandwidth.py
  • tests/test_ui_renderer.py
  • tests/upscale_independent_test.cpp
  • website/public/schemas/mod.schema.json
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/modapi-nav-closest:ChloeNow-feat/modapi-nav-closest'
git switch 'ChloeNow-feat/modapi-nav-closest'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'mod-api'
git merge --no-ff 'ChloeNow-feat/modapi-nav-closest'
git switch 'ChloeNow-feat/modapi-nav-closest'
git rebase 'mod-api'
git switch 'mod-api'
git merge --ff-only 'ChloeNow-feat/modapi-nav-closest'
git switch 'ChloeNow-feat/modapi-nav-closest'
git rebase 'mod-api'
git switch 'mod-api'
git merge --no-ff 'ChloeNow-feat/modapi-nav-closest'
git switch 'mod-api'
git merge --squash 'ChloeNow-feat/modapi-nav-closest'
git switch 'mod-api'
git merge --ff-only 'ChloeNow-feat/modapi-nav-closest'
git switch 'mod-api'
git merge 'ChloeNow-feat/modapi-nav-closest'
git push origin 'mod-api'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!2745
No description provided.