Skip to content

fix: resolve recorder upload task conflicts#94

Merged
shark0F0497 merged 1 commit into
mainfrom
feat/record-upload-conflict
Jun 17, 2026
Merged

fix: resolve recorder upload task conflicts#94
shark0F0497 merged 1 commit into
mainfrom
feat/record-upload-conflict

Conversation

@shark0F0497

Copy link
Copy Markdown
Collaborator

Pull Request Checklist

Please ensure your PR meets the following requirements:

  • Code follows the style guidelines
  • Tests pass locally
  • Code is formatted
  • Documentation updated if needed
  • Commit messages follow conventional commits
  • PR description is complete and clear

Summary

This PR prevents recorder config/begin flows and finish callbacks from racing with tasks that have already moved into upload-related states. It also expands transfer status handling so Keystone can reconcile missed upload requests from transfer status snapshots.


Motivation

  • Avoid starting or configuring a task after the same task has already moved into uploading, completed, or another non-runnable status.
  • Make recorder finish callbacks idempotent for upload states and reject terminal states instead of sending duplicate upload requests.
  • Recover from transient transfer disconnect/write failures by re-queueing eligible upload_request messages when transfer status proves the upload is not already active.

Changes

Modified Files

  • [internal/api/handlers/axon_rpc.go](internal/api/handlers/axon_rpc.go) - Adds task status guards before recorder config and begin RPC calls, including recorder state sync/freshness checks for begin.
  • [internal/api/handlers/task.go](internal/api/handlers/task.go) - Rejects config reads for non-pending tasks and tightens finish callback handling across uploadable, idempotent, and terminal statuses.
  • [internal/api/handlers/task_uploading.go](internal/api/handlers/task_uploading.go) - Aligns upload status transition behavior with the guarded finish callback flow.
  • [internal/api/handlers/transfer.go](internal/api/handlers/transfer.go) - Parses richer transfer status payloads and reconciles eligible failed upload requests with a cooldown.
  • [internal/services/transfer_hub.go](internal/services/transfer_hub.go) - Adds transfer status fields and upload snapshot records used by the status endpoint and reconciliation.
  • [internal/api/handlers/recorder_axon_interaction_test.go](internal/api/handlers/recorder_axon_interaction_test.go) - Updates recorder RPC tests for the new pre-RPC task guards.
  • [internal/api/handlers/task_state_recovery_test.go](internal/api/handlers/task_state_recovery_test.go) - Adds finish callback idempotency, terminal status, and config guard coverage.

Added Files

  • [docs/designs/task-recorder-upload-guard-design.md](docs/designs/task-recorder-upload-guard-design.md) - Documents the recorder/upload guard design.
  • [internal/api/handlers/transfer_status_test.go](internal/api/handlers/transfer_status_test.go) - Covers transfer upload snapshots and upload request reconciliation behavior.

Deleted Files

  • None

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update (documentation changes only)
  • Refactoring (code improvement without functional changes)
  • Performance improvement (code changes that improve performance)
  • Test changes (adding, modifying, or removing tests)

Impact Analysis

Breaking Changes

None

Backward Compatibility

Fully backward compatible. Existing recorder and transfer APIs remain the same; invalid task-state transitions now return conflict responses instead of forwarding unsafe RPC/upload requests.


Testing

Test Environment

  • Local CLI environment
  • Go test command executed outside the sandbox because these tests use httptest listeners.

Test Cases

  • Unit tests pass locally: go test -run 'TestRecorder|TestRecordingFinish|TestGetTaskConfig|TestTransferStatus' ./internal/api/handlers/...
  • Integration tests pass locally
  • E2E tests pass (if applicable)
  • Manual testing completed

Manual Testing Steps

Not run.

Test Coverage

  • New tests added
  • Existing tests updated
  • Coverage maintained or improved

Screenshots / Recordings

Not applicable.


Performance Impact

  • Memory usage: No change
  • CPU usage: No change
  • Throughput: No change
  • Lock contention: No change

Documentation


Related Issues

  • N/A

Additional Notes

  • Full integration tests were not run locally.

Reviewers

None requested.


Notes for Reviewers

  • Please focus on task status transitions in recorder config/begin and finish callback handling.
  • Please verify transfer status reconciliation only re-queues upload requests for recoverable send failures and skips already active uploads.

Checklist for Reviewers

  • Code changes are correct and well-implemented
  • Tests are adequate and pass
  • Documentation is updated and accurate
  • No unintended side effects
  • Performance impact is acceptable
  • Backward compatibility maintained (if applicable)

@shark0F0497 shark0F0497 merged commit a6bac21 into main Jun 17, 2026
5 checks passed
@shark0F0497 shark0F0497 deleted the feat/record-upload-conflict branch June 17, 2026 04:35
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