Skip to content

[codex] Improve replanning and moving target following#1

Merged
nsawill1405 merged 1 commit intomainfrom
codex/moving-goal-following
Apr 17, 2026
Merged

[codex] Improve replanning and moving target following#1
nsawill1405 merged 1 commit intomainfrom
codex/moving-goal-following

Conversation

@nsawill1405
Copy link
Copy Markdown
Owner

Summary

  • add opt-in moving-target following for Navigator:MoveTo with drift and interval controls
  • fix navigator replanning state handling and internal module requires used by the packaged runtime
  • refresh the example scenes and tests so blocked replans and humanoid demos behave reliably

Why

  • moving instance goals were only picked up on the next path compute, so target chasing was not supported directly
  • pending replan reasons could leak across replans and exhaust maxReplans incorrectly
  • the blocked-path example and demo NPC setup were not reliably exercising the intended humanoid navigation path

Impact

  • developers can now opt into chasing moving BasePart and Attachment goals without changing static-goal behavior
  • packaged consumers get the corrected internal requires for Planner, Coordinator, and Navigator
  • the demo place better reflects the public API and expected replanning behavior

Validation

  • stylua --check src test example
  • selene src test example
  • lune run test/run.luau
  • rojo build default.project.json --output /tmp/PathfindingPlus.rbxlx

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Warning

Rate limit exceeded

@nsawill1405 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0af7f50b-2606-4afb-bc85-ce52fcbf17ca

📥 Commits

Reviewing files that changed from the base of the PR and between 2501907 and fba52cc.

📒 Files selected for processing (10)
  • README.md
  • example/src/ServerScriptService/Bootstrap.server.luau
  • src/Coordinator/init.luau
  • src/Navigator/MovingGoalPolicy.luau
  • src/Navigator/PrepareReplan.luau
  • src/Navigator/init.luau
  • src/Planner/init.luau
  • test/run.luau
  • test/specs/MovingGoalPolicy.spec.luau
  • test/specs/NavigatorReplan.spec.luau
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/moving-goal-following

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nsawill1405 nsawill1405 marked this pull request as ready for review April 17, 2026 18:06
Copilot AI review requested due to automatic review settings April 17, 2026 18:06
@nsawill1405 nsawill1405 merged commit 99c33ad into main Apr 17, 2026
4 checks passed
@nsawill1405 nsawill1405 deleted the codex/moving-goal-following branch April 17, 2026 18:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Navigator:MoveTo with an opt-in “follow moving goal” mode while also fixing internal module require paths for packaged consumers and updating demos/tests to better exercise replanning behavior.

Changes:

  • Add moving-goal repath logic (threshold + interval gated) and consume-once replanning reasons in Navigator.
  • Fix internal require(...) paths in Planner, Coordinator, and Navigator for packaged runtime layouts.
  • Add targeted unit tests and refresh the demo scene setup for more reliable blocked-path replans.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/specs/NavigatorReplan.spec.luau Adds coverage for consuming/clearing pending replan reasons.
test/specs/MovingGoalPolicy.spec.luau Adds coverage for the moving-goal repath decision policy.
test/run.luau Registers the new specs in the test runner.
src/Planner/init.luau Updates internal Goal require path for packaged runtime.
src/Navigator/init.luau Implements moving-goal repathing + replan-reason consumption integration.
src/Navigator/PrepareReplan.luau Introduces helper to consume and clear pending replan reason.
src/Navigator/MovingGoalPolicy.luau Adds a policy module to decide when a moving goal should trigger repathing.
src/Coordinator/init.luau Updates internal Shared/* require paths for packaged runtime.
example/src/ServerScriptService/Bootstrap.server.luau Refreshes demo NPC creation + blocked-scene layout and repath trigger.
README.md Documents moving-target following options and tuning notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Navigator/init.luau
Comment on lines +189 to +196
local currentGoalPosition, goalError = self:_resolveGoal(run)
if currentGoalPosition == nil then
return false, goalError
end

local shouldRepath = MovingGoalPolicy.shouldRepath({
enabled = run.moveOptions.followMovingGoal == true,
goalType = typeof(run.goal),
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_shouldRepathForMovingGoal calls _resolveGoal(run) unconditionally, even when followMovingGoal is disabled or the goal isn’t an Instance. This adds extra coordinator/spacing work on every poll and also changes behavior when an Instance goal becomes invalid mid-run (it will now surface during waypoint waits). Consider early-returning before resolving the goal unless moving-goal following is enabled and applicable, so static-goal navigation keeps its previous behavior/perf profile.

Suggested change
local currentGoalPosition, goalError = self:_resolveGoal(run)
if currentGoalPosition == nil then
return false, goalError
end
local shouldRepath = MovingGoalPolicy.shouldRepath({
enabled = run.moveOptions.followMovingGoal == true,
goalType = typeof(run.goal),
if run.moveOptions.followMovingGoal ~= true or typeof(run.goal) ~= "Instance" then
return false, nil
end
local currentGoalPosition, goalError = self:_resolveGoal(run)
if currentGoalPosition == nil then
return false, goalError
end
local shouldRepath = MovingGoalPolicy.shouldRepath({
enabled = true,
goalType = "Instance",

Copilot uses AI. Check for mistakes.
Comment thread src/Navigator/init.luau
replanCount = 0,
nextWaypointIndex = 1,
lastGoalPosition = nil,
lastObservedGoalPosition = nil,
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastObservedGoalPosition is written and initialized, but it’s never read anywhere in the codebase. This makes the run state harder to reason about and suggests either dead state or a missing use (e.g., exposing it via GetDebugSnapshot). Consider removing it entirely or wiring it into the intended consumer.

Suggested change
lastObservedGoalPosition = nil,

Copilot uses AI. Check for mistakes.
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.

2 participants