Skip to content

Add orchestrator CLI command with REST API for task queue management#1194

Open
konard wants to merge 8 commits intomainfrom
issue-1193-172b71650d82
Open

Add orchestrator CLI command with REST API for task queue management#1194
konard wants to merge 8 commits intomainfrom
issue-1193-172b71650d82

Conversation

@konard
Copy link
Contributor

@konard konard commented Jan 29, 2026

Summary

Implements issue #1193 - Add orchestrator CLI command for centralized task queue management.

New Features

  • orchestrator CLI command with configurable --port (default: 8080) and --hostname (default: 0.0.0.0)
  • REST API using LINO format (Links Notation - alternative to JSON):
    • POST /api/v0/solve/enqueue - enqueue solve tasks with issue URL and options
    • GET /api/v0/solve/queue - retrieve queue status and stats
    • GET /api/v0/solve/task/:id - get details for a specific task
    • GET /health - health check endpoint
  • --use-orchestrator option for solve, hive, and telegram-bot commands to delegate tasks to orchestrator
  • Upstream load balancing support (master/slave pattern) via --upstream option
  • Queue management with resource-aware throttling (RAM, CPU, disk, Claude/GitHub limits)
  • Separate queues per tool type (PR feat: separate queues for claude and agent tools #1167): Claude tasks never block agent tasks and vice versa

Files Added

  • src/orchestrator.mjs - Main CLI entry point
  • src/orchestrator.config.lib.mjs - CLI configuration/argument parsing
  • src/orchestrator-queue.lib.mjs - Queue management logic with tool-specific queues (aligned with telegram-solve-queue.lib.mjs from PR feat: separate queues for claude and agent tools #1167)
  • src/orchestrator-client.lib.mjs - Client library for communicating with orchestrator
  • dependencies/lino-rest-api/ - LINO REST API implementation (codec, middleware, app)
  • tests/orchestrator-*.test.mjs - Unit tests (29 tests)
  • tests/lino-codec.test.mjs - LINO codec tests

Files Modified

  • package.json - Added orchestrator binary
  • src/solve.config.lib.mjs - Added --use-orchestrator option
  • src/hive.config.lib.mjs - Added --use-orchestrator option
  • src/telegram-bot.mjs - Added --useOrchestrator option
  • eslint.config.mjs - Extended to include dependencies folder
  • tests/solve-queue.test.mjs - Fixed test expecting incorrect threshold value (0.85 → 0.75)

Architecture: Separate Queues per Tool (Issue #1159)

// Instead of single queue:
this.queue = [];                    // Single queue for all tools

// Now separate queues:
this.queues = {                     // Separate queues per tool
  claude: [],
  agent: [],
};
this.lastStartTimeByTool = {        // Independent timing per tool
  claude: null,
  agent: null,
};

Key changes applied from PR #1167:

  • getToolQueue(tool) method for accessing tool-specific queues
  • queue getter for backwards compatibility (returns combined queue)
  • getTotalQueueLength() and getProcessingCountByTool() methods
  • findStartableItems() to return startable items from each tool queue
  • Tool-specific canStartCommand() with independent lastStartTimeByTool
  • Agent tasks skip Claude API limits (5-hour session, weekly limits)

Test Plan

  • Run npm test - All tests pass (70 main + 18 limits + 63 usage = 151 tests)
  • Run node --test tests/orchestrator*.test.mjs - 29 tests pass
  • ESLint passes with no errors
  • CI checks pass
  • Start orchestrator: ./src/orchestrator.mjs --port 8080 --verbose
  • Test health endpoint: curl http://localhost:8080/health
  • Test queue endpoint: curl http://localhost:8080/api/v0/solve/queue
  • Test enqueue: curl -X POST http://localhost:8080/api/v0/solve/enqueue -H "Content-Type: text/lino" -d "issueUrl: https://github.com/owner/repo/issues/1"

Fixes #1193

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #1193
@konard konard self-assigned this Jan 29, 2026
Implements issue #1193 with the following features:

- New `orchestrator` CLI command with configurable --port and --hostname
- REST API using lino-rest-api (Links Notation format):
  - POST /api/v0/solve/enqueue - enqueue solve tasks
  - GET /api/v0/solve/queue - retrieve queue status
  - GET /api/v0/solve/task/:id - get task details
  - GET /health - health check endpoint
- New --use-orchestrator option for solve, hive, and telegram-bot commands
- Support for upstream orchestrator load balancing (master/slave pattern)
- Queue management with resource-aware throttling (RAM, CPU, disk, Claude/GitHub limits)
- Unit tests for orchestrator-queue, orchestrator-client, and lino-codec

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Add orchestartor CLI command Add orchestrator CLI command with REST API for task queue management Jan 29, 2026
@konard konard marked this pull request as ready for review January 29, 2026 00:59
konard and others added 2 commits January 29, 2026 02:01
Reduced verbose multi-line comments explaining configuration priority
to a single concise line. This keeps the file under the 1500 line limit
after adding the --useOrchestrator option.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard
Copy link
Contributor Author

konard commented Jan 29, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $8.483700 USD
  • Calculated by Anthropic: $7.070713 USD
  • Difference: $-1.412986 (-16.66%)
    📎 Log file uploaded as Gist (1458KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Jan 29, 2026

Also make sure to apply changes from #1167.

And ensure all changes are correct, consistent and fully meet all discussed requirements (check issue description and all comments in issue and in pull request).

@konard konard marked this pull request as draft January 29, 2026 10:20
@konard
Copy link
Contributor Author

konard commented Jan 29, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-29T10:20:10.110Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

konard and others added 4 commits January 29, 2026 11:21
Updates orchestrator-queue.lib.mjs with the same tool-specific queue
implementation from PR #1167 (telegram-solve-queue):

- Separate queues per tool type (claude, agent) instead of single queue
- Tool-specific timing (lastStartTimeByTool) for independent processing
- canStartCommand() and checkApiLimits() accept tool parameter
- Skip Claude API limits when tool is 'agent'
- New methods: getToolQueue(), getTotalQueueLength(), getProcessingCountByTool()
- New methods: findStartableItems(), findStartableItem()
- Updated consumer loop to check each tool queue independently
- Add updateAllWaitingItems() for tool-specific waiting reasons

This ensures:
- Claude tasks never block agent tasks (and vice versa)
- Each tool queue maintains FIFO order
- Each tool has independent rate limiting

Also adds comprehensive tests for the new functionality:
- Tool-specific queue tests
- Cross-queue findByUrl and findById tests
- Per-tool cancellation tests
- Stats with per-tool breakdown tests
- Tool-specific limit handling tests

See: #1159

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The test was asserting 0.85 but the actual QUEUE_CONFIG uses 0.75.
Updated the test to match the current configuration value.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use Object.values() instead of Object.entries() when we only need the
queue arrays, not the tool keys. The tool is already included in the
item's toJSON() output.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 29, 2026 10:40
@konard
Copy link
Contributor Author

konard commented Jan 29, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $7.641584 USD
  • Calculated by Anthropic: $5.969452 USD
  • Difference: $-1.672132 (-21.88%)
    📎 Log file uploaded as Gist (1555KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Jan 29, 2026

🔄 Auto-restart 1/3

Detected uncommitted changes from previous run. Starting new session to review and commit them.

Uncommitted files:

?? issue_1193.txt
?? issue_comments.json
?? pr_1167_diff.txt
?? pr_1167_view.txt
?? pr_conversation_comments.json
?? pr_review_comments.json
?? pr_view.txt

Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback.

@konard
Copy link
Contributor Author

konard commented Jan 29, 2026

🔄 Auto-restart 1/3 Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.337334 USD
  • Calculated by Anthropic: $1.013733 USD
  • Difference: $-1.323601 (-56.63%)
    📎 Log file uploaded as Gist (1955KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Jan 29, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.337334 USD
  • Calculated by Anthropic: $1.013733 USD
  • Difference: $-1.323601 (-56.63%)
    📎 Log file uploaded as Gist (1959KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

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.

Add orchestartor CLI command

1 participant