Skip to content

feat(workspacedeps): installation records, dependency service and HTTP API - #1137

Draft
sheepbox8646 wants to merge 6 commits into
workspace-deps/01-corefrom
workspace-deps/02-service-api
Draft

feat(workspacedeps): installation records, dependency service and HTTP API#1137
sheepbox8646 wants to merge 6 commits into
workspace-deps/01-corefrom
workspace-deps/02-service-api

Conversation

@sheepbox8646

@sheepbox8646 sheepbox8646 commented Sep 2, 2026

Copy link
Copy Markdown
Member

变更内容

workspace-deps 第 2 层:持久化、状态机与 HTTP 面。

  • 数据库:迁移 0146_bot_dependency_installations(同步进 0001_init),team RLS 四条 policy,bots 外键 NOT VALID;sqlc 查询与 Store 契约及 Postgres 实现;集成测试纳入 migrations.yml
  • serviceinternal/workspacedeps):install/update/reinstall/remove/rollback 状态机(内存互斥 + 数据库中间态 + stale 回收),version 可选(空=最新),state.json 与 shim 由 Server 写入;三态对账(installed/missing/采纳);条目带 image_versionoverlay,动作集由是否有脚本与当前副本决定,底座依赖卸载=移除覆盖层;preflight(satisfied/missing/platform_unsupported);操作终态经不可取消的上下文落库,锁被占用时还原原记录,对账时回收「无人持有」的僵死中间态,discovery 失败降级为 discovery_error 而非 500;所有配置了 check-update 且未锁定的依赖走 24h 上游检查 worker,按 (dependency, platform) 去重扇出。
  • HTTP API/bots/{bot_id}/dependencies 的 list、preflight、check-updates、script 预览、rollback,install/update/reinstall/remove 的 SSE 日志流(15s 心跳,请求断开即取消,请求体可带 version);与 bot 无关的 GET /workspace-dependencies/catalogworkspace_dependency.* 错误码与三语文案;swagger/SDK 再生成。
  • 装配:catalog 加载失败阻止启动;service、update worker、stale reaper 进 FX 生命周期。

验证

  • go test ./... 全绿;golangci-lint 涉及包 0 issues。
  • 迁移在一次性数据库上 up → down → up 幂等;Postgres 集成测试通过。
  • 第二套 dev 环境真实验证:list/catalog/preflight/check-updates(真实上游版本)/脚本预览/rollback 409;install SSE 真实 npm install 成功并生成单行 state.json 与 0755 shim。

⚠️ No human QA — this PR has not been verified by a human yet. Remove this line once a human confirms the happy path.

🤖 Generated with Claude Code

https://claude.ai/code/session_017sihinqYWYNmZ9K842WqDJ

@sheepbox8646 sheepbox8646 changed the title workspace deps/02 service api feat(workspacedeps): installation records, dependency service and HTTP API Sep 2, 2026
@sheepbox8646
sheepbox8646 force-pushed the workspace-deps/02-service-api branch from 37e76ad to ce75591 Compare September 3, 2026 08:00
@sheepbox8646
sheepbox8646 force-pushed the workspace-deps/02-service-api branch from ce75591 to f3e877c Compare September 3, 2026 09:32
@sheepbox8646
sheepbox8646 force-pushed the workspace-deps/02-service-api branch 2 times, most recently from 33a8263 to 91a9b5a Compare September 3, 2026 12:19
sheepbox8646 and others added 6 commits September 3, 2026 22:12
…store

Adds migration 0146 (mirrored into 0001), team-scoped sqlc queries and a
Store contract plus its Postgres implementation. The table records intent
per (bot, workspace target, dependency); discovery corrects the observed
columns and a stale reaper recovers interrupted operations.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017sihinqYWYNmZ9K842WqDJ
…ecks

The service owns the install/update/reinstall/remove/rollback state
machine over the runner, writes state.json and shims after each success,
reconciles database intent against discovery (installed / missing /
adopted) and exposes preflight for the enable-agent flow. Agent-class
entries compare against the catalog pin; tool-class entries get a 24h
upstream check worker with per-(dependency, platform) deduplication.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017sihinqYWYNmZ9K842WqDJ
Exposes the dependency service under /bots/{bot_id}/dependencies: list,
preflight, install/update/reinstall/remove as SSE log streams, rollback,
check-updates and a script preview. Adds the workspace_dependency.* error
codes with web locale strings, wires catalog/service/update worker/stale
reaper into the FX graph, runs an agent alignment scan after container
reconciliation, and regenerates swagger and the TypeScript SDK.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017sihinqYWYNmZ9K842WqDJ
…catalog endpoint

The service stops modelling agent pins: RequiredVersion, NeedsAlignment,
the alignment scan at start-up (and Manager.RunningNativeBotIDs, which only
served it) and the version_mismatch preflight reason are gone. Entries
report the copy in effect (managed → toolkit → PATH) together with the
image baseline (ImageVersion) and whether a managed overlay shadows it
(Overlay); installability follows the catalog scripts (ActionSupported,
SupportedActions, UserActions) instead of the source, so node/python/uv
overlays can be installed and removed and an agent CLI is checked upstream
like any tool. Install, update and reinstall take an optional requested
version that reaches the script as MEMOH_DEP_VERSION; the recorded version
is the one the script reports. The HTTP API exposes image_version/overlay,
accepts a {version} body, and gains the bot-independent
GET /workspace-dependencies/catalog for the Supermarket. Adds the
docker-backed test that installs, checks, updates and removes every
catalog entry against the real workspace image. Swagger and the SDK are
regenerated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017sihinqYWYNmZ9K842WqDJ
…status

Finalize every operation through a context that survives request
cancellation, restore the previous record when the workspace lock or the
in-memory mutex refuses an operation instead of leaving it as installing,
reclaim interrupted operations during reconciliation when no instance
holds the lock, and degrade the list to database records with a
discovery_error instead of failing when discovery cannot run.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017sihinqYWYNmZ9K842WqDJ
@sheepbox8646
sheepbox8646 force-pushed the workspace-deps/02-service-api branch from 91a9b5a to cc72161 Compare September 3, 2026 14:18
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