Skip to content

feat(compile): 由 OV 托管外部任务生命周期 - #4436

Draft
qin-ctx wants to merge 1 commit into
mainfrom
feat/ov-external-compile-tasks
Draft

feat(compile): 由 OV 托管外部任务生命周期#4436
qin-ctx wants to merge 1 commit into
mainfrom
feat/ov-external-compile-tasks

Conversation

@qin-ctx

@qin-ctx qin-ctx commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Description

本 PR 将 Compile 从“OV 直接代理 Bot 任务”调整为“OV 托管任务生命周期、外部 Compile Server 负责执行”,并把这套执行模型实现为可注册 Provider 的通用外部异步任务能力。

Before

ov compile 直接请求 /bot/v1/compile,任务由 Bot 保存和执行。CLI 需要识别 cmp_ 前缀,并分别请求 Bot 的状态和取消接口。OV 只负责转发,无法通过统一 TaskRecord/QueueFS 提供持久状态、重启恢复和通用任务查询。

After

ov compile 请求 POST /api/v1/compile。OV 先持久化 TaskRecord,再写入 ExternalTask QueueFS;后台消费者通过 Compile Provider 调用外部 /bot/v1/compile,轮询执行状态并更新 OV TaskRecord。CLI 使用统一的 /api/v1/tasks/{task_id} 查询和取消任务,原 /bot/v1/compile* 路径保留为兼容入口。

当前用户的 OV API Key 作为任务私有认证数据保存,并在调用外部 Server 时放入 openviking_connectionX-API-Key。外部 Server 根据 server_url 选择正确的 OV 实例,并使用该用户 Key 读取来源和写回产物。compile_api.api_key 只用于 OV 到外部 Server 的服务级认证。

Example

同一个输入:

ov compile \
  --from viking://resources/research \
  --to viking://resources/research-wiki \
  --skill viking://agent/skills/wiki \
  --wait
  • 修改前:CLI 创建、查询和取消都走 /bot/v1/compile*,任务状态由 Bot 持有。
  • 修改后:CLI 通过 /api/v1/compile 获得 OV Task ID,并通过 /api/v1/tasks/{task_id} 等待结果;OV 使用相同 Task ID 作为 Idempotency-Key 调用外部 Server,崩溃恢复后重复提交不会重复执行。

Flow

  1. OV 认证请求,构造包含当前用户 API Key、租户、用户和 OV 地址的 openviking_connection
  2. OV 先创建 TaskRecord,保存 Compile 请求和私有回调认证,再将任务写入 ExternalTask QueueFS。
  3. QueueFS 消费者调用已注册的 Compile Provider,以 OV Task ID 作为幂等键创建外部任务。
  4. OV 轮询外部任务,将执行 Stage、结果、失败或取消状态收敛到统一 TaskRecord。
  5. 外部 Server 使用请求中的 OV 地址和用户 API Key 读写产物;CLI 始终只查询 OV Task。
  6. 用户取消任务时,OV 先进入 cancelling,再通知外部任务并在 QueueFS 工作完成后进入 cancelled

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

无。

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 not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • 新增通用 ExternalTaskService、Provider 协议和 QueueFS 消费器,由 OV 统一管理持久化、重试、恢复、状态和取消。
  • 新增 Compile Provider、compile_api 配置和 /api/v1/compile,并让 CLI 状态与取消统一使用 Task API。
  • 抽取共享 openviking_connection 构造逻辑,安全传递当前用户身份;补充外部 Compile Server 的幂等、多实例、写回和错误契约。

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

已执行:

  • uv run pytest -q tests/test_config_loader.py tests/unit/service/test_core_consistency.py tests/server/test_bot_proxy_auth.py tests/test_task_tracker.py tests/storage/test_queue_manager.py --no-cov:96 passed
  • cargo test -p ov_cli compile:6 passed
  • cargo check -p ov_cli
  • Ruff、py_compile、变更文件 rustfmt --checkgit diff --check

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

不适用。

Additional Notes

  • 本 PR 只实现 OpenViking 和 ov CLI;外部 Compile Server 尚未实现,因此没有进行真实端到端联调。
  • 外部 Server 的完整接口和多实例要求见 docs/design/external-compile-server-api.md

Keep durable task state, recovery, query, and cancellation in OpenViking while external providers execute the workload.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant