Skip to content

feat(remote_agent): add dispatch guard for queue load#80

Open
PiyushDatta wants to merge 1 commit intomainfrom
agent/workerpal-d4f80a1c/ce445545-27c9-4d64-ae0c-5ebef047b619
Open

feat(remote_agent): add dispatch guard for queue load#80
PiyushDatta wants to merge 1 commit intomainfrom
agent/workerpal-d4f80a1c/ce445545-27c9-4d64-ae0c-5ebef047b619

Conversation

@PiyushDatta
Copy link
Copy Markdown
Collaborator

Summary

  • Apply WorkerPal completion ce445545-27c9-4d64-ae0c-5ebef047b619 to main_agents.
  • Integrate commit 20909f6ba7ff04dec7ebcd604c7f3391a623946c from refs/pushpals/agent/workerpal-d4f80a1c/ce445545-27c9-4d64-ae0c-5ebef047b619.
  • Worker workerpal-d4f80a1c reported: Executed task and modified 1 file(s) (quality gate soft-pass after 4 auto-revision attempt(s))
  • Canonical task request: Implement an adaptive dispatch guard in apps/remotebuddy/src/autonomous_engine.ts that ingests queue telemetry (moving p95 latency, worker idle counts), throttles or reroutes delegation when pressure exceeds configured thresholds, and em...

Motivation / Context

  • Preserve and review autonomous worker output before final merge to base branch.
  • Keep integration branch current with queued worker completions.

Planned Scope

  • apps/remotebuddy/src/autonomous_engine.ts

Planned Validation

  • Planned: bun run test:root

Changes

  • Updated apps/remotebuddy/src/autonomous_engine.ts

Testing / Validation

  • Planned: bun run test:root
  • Worker completion summary did not include explicit command pass/fail output.

Impact / Risk

  • Risk level: medium (automated worker-generated change; maintainer review required).
  • No secrets or credentials are expected in this PR body.

SourceControlManager Note

  • Use this worker-provided PR title/body when creating the integration PR.
  • Suggested title: fix(repo): Implement an adaptive dispatch guard in apps/remotebuddy/src/autonomous_engine.ts that ingest...

Checklist

  • Tests added/updated where appropriate

  • Validation commands run (or noted as not run)

  • Docs/comments updated if needed

  • No sensitive data (secrets/tokens) committed

  • Agent branch: agent/workerpal-d4f80a1c/ce445545-27c9-4d64-ae0c-5ebef047b619

  • Completion ref: refs/pushpals/agent/workerpal-d4f80a1c/ce445545-27c9-4d64-ae0c-5ebef047b619

  • Commit: 20909f6ba7ff04dec7ebcd604c7f3391a623946c

  • Completion ID: 073d0178-2e87-4c4c-8095-4300cc231b82

- introduce DispatchGuardConfig/env helpers in apps/remotebuddy/src/autonomous_engine.ts to bound queue latency thresholds
- evaluate queue and idle telemetry via evaluateDispatchGuardState and decideDispatchGuardAction to throttle, reroute, or allow
- fetch /system/status metrics, log guard decisions, and block objectives with guardBlockReason when pressure stays high
- reroute selections using pickQueueHealthRerouteCandidate and flush guard metrics/logs through CommunicationManager hooks
- add vitest suite to autonomous_engine.ts covering guard decisions, reroute selection, and metrics emission

Tests:
- not run
@PiyushDatta
Copy link
Copy Markdown
Collaborator Author

ReviewAgent: Changes Rejected (score 7.8/10)

Verdict: The dispatch guard implementation is well-structured and thoroughly unit-tested, but it contains a policy-breaking fallback that can bypass protection under queue pressure.

Issues:

  • Policy bypass bug: when guard decision is reroute and no eligible queue_health candidate exists, code forces action: "allow" via queue_guard_reroute_override, which dispatches the original non-queue objective during elevated pressure and defeats enforceQueueHealthReroute semantics.
  • Behavioral gap: no test covers the reroute-with-no-candidate path, so the unsafe fallback is unverified and currently unchecked by the suite.
  • Operational risk: fetchQueueTelemetry() uses an unbounded fetch with no timeout/abort path, so a slow or hung /system/status call can stall objective dispatch flow.

This PR has been re-queued for automated fixes. A worker will address the issues above.

@PiyushDatta
Copy link
Copy Markdown
Collaborator Author

ReviewAgent: Changes Rejected (score 7.9/10)

Verdict: The dispatch guard feature is thoughtfully implemented with strong unit coverage, but it contains a policy bypass and operational resilience gaps that prevent production-ready confidence.

Issues:

  • Policy bypass under elevated load: when guard action is reroute but no eligible queue_health candidate exists, the code creates queue_guard_reroute_override with action: "allow" and proceeds with normal dispatch; this violates strict queue protection intent and can still dispatch non-queue-health work during elevated pressure.
  • No timeout/abort on fetchQueueTelemetry() (GET /system/status): a slow or hanging status endpoint can stall candidate processing in the autonomy tick and degrade scheduler responsiveness.
  • Test coverage misses the most sensitive integration branch: there is no end-to-end test asserting behavior when reroute is required but unavailable (currently fail-open), and no test validating that blocked objectives are recorded with the expected status: "blocked" and block_reason for guard-throttle/reroute cases.

This PR has been re-queued for automated fixes. A worker will address the issues above.

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