Skip to content

test(agent): wire TestRig job tools through the scheduler - #716

Merged
zmanian merged 2 commits into
nearai:mainfrom
Protocol-zero-0:fix/606-test-rig-job-scheduler
Mar 8, 2026
Merged

zmanian merged 2 commits into
nearai:mainfrom
Protocol-zero-0:fix/606-test-rig-job-scheduler

Conversation

@Protocol-zero-0

Copy link
Copy Markdown
Contributor

Summary

  • align tests/support/test_rig.rs with production wiring so job tools share the agent's ContextManager and receive a lazy SchedulerSlot
  • fill the scheduler slot after Agent::new() so create_job in TestRig-backed e2e runs dispatch through the real scheduler path
  • strengthen the builtin job e2e assertion to fail if TestRig ever regresses back to the scheduler unavailable fallback path

Why

Issue #606 points out that the TestRig wasn't exercising the same job execution path as the real application. It registered job tools against a separate ContextManager with no scheduler, so tests could pass while bypassing the actual scheduler wiring used in production.

Tests

  • cargo fmt --check
  • cargo test --test e2e_builtin_tool_coverage job_create_status -- --nocapture
  • target/debug/deps/e2e_builtin_tool_coverage-142df138fb18c392 --exact tests::job_list_cancel --nocapture

Notes

I had to clear the temporary target/ directory in this disposable local clone to recover disk space before the targeted test build. No source files outside this PR were changed.

Made with Cursor

Align TestRig with the production agent wiring so create_job exercises the real scheduler path instead of silently falling back to an unscheduled context-only job. Tighten the e2e assertion to lock in the in-progress scheduler behavior for future refactors.

Made-with: Cursor
Copilot AI review requested due to automatic review settings March 8, 2026 05:43
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added size: S 10-49 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: new First-time contributor labels Mar 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 aligns the TestRig test harness with the production wiring in main.rs so that job tools share the agent's ContextManager and dispatch through the real Scheduler. Previously, register_job_tools in the TestRig used a standalone, freshly-created ContextManager and passed scheduler_slot: None, meaning create_job always fell back to the unscheduled path — causing tests to pass while bypassing actual scheduler wiring.

Changes:

  • In test_rig.rs: Replace the isolated ContextManager::new() with Arc::clone(&components.context_manager) and pass a real SchedulerSlot (filled after Agent::new) to register_job_tools, mirroring main.rs exactly.
  • In test_rig.rs: Pass Some(Arc::clone(&components.context_manager)) to Agent::new so the agent's scheduler uses the same context store as the job tools.
  • In e2e_builtin_tool_coverage.rs: Strengthen the job_create_status test to assert that create_job dispatches through the scheduler ("in_progress" present, "scheduler unavailable" absent).

Reviewed changes

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

File Description
tests/support/test_rig.rs Reuses components.context_manager and wires a real SchedulerSlot in register_job_tools; passes the same ContextManager to Agent::new; fills the slot after Agent::new to match production startup sequence
tests/e2e_builtin_tool_coverage.rs Adds regression-guard assertions in job_create_status to ensure create_job returns "in_progress" and does not fall back to the "scheduler unavailable" path

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

@zmanian zmanian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mirrors production main.rs wiring exactly — shared ContextManager via Arc::clone, proper SchedulerSlot lazy-fill pattern, and Agent::new receives the shared context manager. Regression assertions verify create_job dispatches through the scheduler. Clean fix.

@zmanian
zmanian enabled auto-merge (squash) March 8, 2026 19:54

@zmanian zmanian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM - TestRig scheduler wiring.

@zmanian
zmanian merged commit 732b3ec into nearai:main Mar 8, 2026
22 checks passed
This was referenced Mar 8, 2026
bkutasi pushed a commit to bkutasi/ironclaw that referenced this pull request Mar 28, 2026
Align TestRig with the production agent wiring so create_job exercises the real scheduler path instead of silently falling back to an unscheduled context-only job. Tighten the e2e assertion to lock in the in-progress scheduler behavior for future refactors.

Made-with: Cursor

Co-authored-by: Zaki Manian <zaki@iqlusion.io>
drchirag1991 pushed a commit to drchirag1991/ironclaw that referenced this pull request Apr 8, 2026
Align TestRig with the production agent wiring so create_job exercises the real scheduler path instead of silently falling back to an unscheduled context-only job. Tighten the e2e assertion to lock in the in-progress scheduler behavior for future refactors.

Made-with: Cursor

Co-authored-by: Zaki Manian <zaki@iqlusion.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: new First-time contributor risk: low Changes to docs, tests, or low-risk modules size: S 10-49 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants