1.1 Identify all call sites of sync_task_manager.create_task() (scheduler + routers) and classify use-cases: incremental, backfill, group execution.
1.2 Identify existing status/query endpoints and UI expectations for task status fields (pending/running/completed/failed/cancelled).
2. Redis requirement (Mode A)
2.1 Introduce a single “Redis availability gate” used by task submission endpoints (e.g., assert_redis_available()), returning a clear HTTP error when Redis is disabled/unreachable.
2.2 Remove silent fallback in SyncTaskManager.create_task(use_queue=True); when Redis is unavailable, raise a domain error instead of switching to legacy execution.
2.3 Update /health to explicitly report async queue availability (already exposes cache stats; extend/align semantics if needed).
3.2 Define a stable status machine for tasks: pending -> running -> completed|failed|cancelled (+ retrying optional).
3.3 Ensure get_task() and execution aggregation (update_execution_stats) reflect retries correctly (e.g., failures within attempts do not mark execution finished until attempts exhausted).
4. Worker behavior: timeout + retry
4.1 Add per-task timeout enforcement in TaskWorker:
enforce wall-clock timeout for plugin execution (incremental/backfill)
on timeout: mark failed with reason, do not hang worker
4.2 Add automatic retry loop:
configurable max attempts (default from settings.TUSHARE_MAX_RETRIES or plugin config)
exponential backoff with jitter, persisted in Redis
classify retryable errors vs non-retryable (e.g., config missing, plugin not found are non-retryable)
4.3 Ensure proxy correctness:
wrap actual plugin network execution in proxy_context() (already done in SyncTaskManager; ensure worker matches)
verify no proxy is applied globally at server startup
5. API: status query + cancellation + retry endpoints
5.1 Align datamanage API endpoints to read status from Redis task keys when present; avoid relying on in-memory _tasks.
5.2 Ensure task cancellation works for Redis pending tasks (queue removal + status update).
5.3 Ensure user-triggered retry creates a new task (new id) or re-enqueues same id (pick one and document).
6. Remove legacy execution path (single system)
6.1 Remove SyncTaskManager in-memory queue usage for execution (keep ClickHouse persistence for history if desired).
6.2 Ensure scheduler DataSyncScheduler always submits jobs via Redis queue.
6.3 Ensure local-dev worker auto-start behavior is explicit and documented (either keep auto-spawn or require running worker command).
7. Validation
7.1 Add minimal unit tests for TaskQueue serialization and retry metadata.
7.2 Add integration-style smoke test instructions (manual):
enqueue a task
observe running/completed status transitions
simulate Redis down and confirm API returns expected error
verify proxy-enabled environment still fetches TuShare data
7.3 Run formatting/lint checks (if configured).
8. OpenSpec
8.1 Run openspec validate refactor-redis-queue-sync --strict and fix all issues.
1---2name: 2479-tasks-9f728d7c3description: 1. Discovery / Baseline4---5## 1. Discovery / Baseline6- [ ] 1.1 Identify all call sites of `sync_task_manager.create_task()` (scheduler + routers) and classify use-cases: incremental, backfill, group execution.7- [ ] 1.2 Identify existing status/query endpoints and UI expectations for task status fields (pending/running/completed/failed/cancelled).89## 2. Redis requirement (Mode A)10- [ ] 2.1 Introduce a single “Redis availability gate” used by task submission endpoints (e.g., `assert_redis_available()`), returning a clear HTTP error when Redis is disabled/unreachable.11- [ ] 2.2 Remove silent fallback in `SyncTaskManager.create_task(use_queue=True)`; when Redis is unavailable, raise a domain error instead of switching to legacy execution.12- [ ] 2.3 Update `/health` to explicitly report async queue availability (already exposes cache stats; extend/align semantics if needed).1314## 3. Unified job model: task + execution15- [ ] 3.1 Extend `TaskQueue` task payload to include:16 - retry metadata: `attempt`, `max_attempts`, `next_run_at`, `last_error_type`17 - timeout metadata: `timeout_seconds`, `deadline_at`18 - timestamps: `updated_at`19- [ ] 3.2 Define a stable status machine for tasks: `pending -> running -> completed|failed|cancelled` (+ `retrying` optional).20- [ ] 3.3 Ensure `get_task()` and execution aggregation (`update_execution_stats`) reflect retries correctly (e.g., failures within attempts do not mark execution finished until attempts exhausted).2122## 4. Worker behavior: timeout + retry23- [ ] 4.1 Add per-task timeout enforcement in `TaskWorker`:24 - enforce wall-clock timeout for plugin execution (incremental/backfill)25 - on timeout: mark failed with reason, do not hang worker26- [ ] 4.2 Add automatic retry loop:27 - configurable max attempts (default from `settings.TUSHARE_MAX_RETRIES` or plugin config)28 - exponential backoff with jitter, persisted in Redis29 - classify retryable errors vs non-retryable (e.g., config missing, plugin not found are non-retryable)30- [ ] 4.3 Ensure proxy correctness:31 - wrap actual plugin network execution in `proxy_context()` (already done in `SyncTaskManager`; ensure worker matches)32 - verify no proxy is applied globally at server startup3334## 5. API: status query + cancellation + retry endpoints35- [ ] 5.1 Align `datamanage` API endpoints to read status from Redis task keys when present; avoid relying on in-memory `_tasks`.36- [ ] 5.2 Ensure task cancellation works for Redis pending tasks (queue removal + status update).37- [ ] 5.3 Ensure user-triggered retry creates a new task (new id) or re-enqueues same id (pick one and document).3839## 6. Remove legacy execution path (single system)40- [ ] 6.1 Remove `SyncTaskManager` in-memory queue usage for execution (keep ClickHouse persistence for history if desired).41- [ ] 6.2 Ensure scheduler `DataSyncScheduler` always submits jobs via Redis queue.42- [ ] 6.3 Ensure local-dev worker auto-start behavior is explicit and documented (either keep auto-spawn or require running worker command).4344## 7. Validation45- [ ] 7.1 Add minimal unit tests for `TaskQueue` serialization and retry metadata.46- [ ] 7.2 Add integration-style smoke test instructions (manual):47 - enqueue a task48 - observe running/completed status transitions49 - simulate Redis down and confirm API returns expected error50 - verify proxy-enabled environment still fetches TuShare data51- [ ] 7.3 Run formatting/lint checks (if configured).5253## 8. OpenSpec54- [ ] 8.1 Run `openspec validate refactor-redis-queue-sync --strict` and fix all issues.
Run npx skillmds@latest add tools-only/2479-tasks-9f728d7c in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
1. Discovery / Baseline It is listed under Product & Planning on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tools-only (@tools-only) published this skill. Their other Agent Skills are listed on their SkillMD profile.