feat(api): enhance batch and task management with automatic status transitions#25
Merged
shark0F0497 merged 4 commits intomainfrom Apr 7, 2026
Merged
feat(api): enhance batch and task management with automatic status transitions#25shark0F0497 merged 4 commits intomainfrom
shark0F0497 merged 4 commits intomainfrom
Conversation
Collaborator
Author
|
kilo reviewer crashed, run locally |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Please ensure your PR meets the following requirements:
Summary
This PR implements a complete production lifecycle management system, adding batch/task lifecycle automation, Axon recorder integration, and automatic order/batch status transitions based on task completion.
Motivation
The current API lacks proper batch and task lifecycle management. Key issues addressed:
This PR solves these by implementing automatic status advancement, device-side notifications, and declarative batch management.
Changes
Modified Files
cmd/keystone-edge/main.go- Added recorder RPC timeout configurationdocs/designs/production-units.md- Updated design documentationinternal/api/handlers/auth.go- Extended auth handler with recorder hubinternal/api/handlers/axon_rpc.go- Added automatic task status advancement on config/begin RPCs, device disconnect handlinginternal/api/handlers/batch.go- Major enhancement: added CreateBatch, AdjustBatchTasks, RecallBatch, ListBatchTasks; refactored PatchBatch for cancellation-only; added task status counting (completed/cancelled/failed)internal/api/handlers/common.go- Common function updatesinternal/api/handlers/episode.go- Episode handler updatesinternal/api/handlers/order.go- Added task count fields, automatic status advancement (created→in_progress→completed), target_count validation, open batch finalization on order completioninternal/api/handlers/robot.go- Robot handler updatesinternal/api/handlers/skill.go- Skill handler updatesinternal/api/handlers/sop.go- SOP handler updatesinternal/api/handlers/station.go- Station handler updatesinternal/api/handlers/task.go- Added task_id filter, removed direct cancellation (must use batch), added batch status validation, new status transitions (pending→ready→in_progress→completed/failed)internal/api/handlers/transfer.go- Enhanced upload handling, added batch/order status advancement after upload complete, device disconnect task revertinternal/server/server.go- Updated handler initialization to include recorder hubinternal/services/recorder_hub.go- Hub updates for new functionalityinternal/storage/database/migrations/000001_initial_schema.up.sql- Schema changes: batches.name nullable, removed skills/sops name columns, updated unique constraintsAdded Files
Deleted Files
Type of Change
Impact Analysis
Breaking Changes
The following breaking changes require attention:
PATCH /batches/:id behavior change: Previously allowed pending→active and active→completed transitions. Now only supports cancellation (pending/active→cancelled). Use automatic status advancement instead.
PUT /tasks/:id cancellation removed: Setting status to "cancelled" is no longer allowed via task endpoint. Must use PATCH /batches/:id to cancel the parent batch.
DELETE /batches/:id response changed: Returns 200 with JSON body instead of 204 No Content.
Database schema changes:
batches.nameis now nullableskills.namecolumn removed (use slug)sops.namecolumn removed (use slug)Backward Compatibility
Partially backward compatible with deprecation warnings in API responses. Client applications using PATCH batch for status transitions other than cancellation will need to be updated.
Testing
Test Environment
Test Cases
Manual Testing Steps
Tested via curl/Postman:
Test Coverage
Screenshots / Recordings
Performance Impact
Documentation
Related Issues
Additional Notes
Status Advancement: Batch and order status advancement happens automatically after task completion. No manual intervention required.
Recorder Integration: When devices connect/disconnect or batches are cancelled, the system automatically notifies the Axon recorder to clear/cancel configurations.
Transaction Safety: All critical operations use transactions to ensure consistency between tasks, batches, and orders.
Best-Effort Notifications: Recorder RPC failures are logged but do not block the main operation (e.g., batch cancellation still succeeds even if device is unreachable).
Reviewers
@kilo-code-bot
Notes for Reviewers
internal/api/handlers/batch.gotryAdvanceBatchStatusandtryAdvanceOrderStatusChecklist for Reviewers