Skip to content

feat(completion): task_completed 事件 + 发布节流 + Stop hook 发布 (PR7)#194

Open
raysonmeng wants to merge 1 commit into
feat/v3-pr6-routingfrom
feat/v3-pr7-completion
Open

feat(completion): task_completed 事件 + 发布节流 + Stop hook 发布 (PR7)#194
raysonmeng wants to merge 1 commit into
feat/v3-pr6-routingfrom
feat/v3-pr7-completion

Conversation

@raysonmeng

Copy link
Copy Markdown
Owner

概要 / Summary

v3 §11.1 单团队 MVP 的 PR7(stacked,base = feat/v3-pr6-routing / #193)。实现 §3.3 的 task_completed 房间事件:agent 广播结构化「完成」信号(repo/branch/commit 是 git 指针,绝非文件内容 —— 控制面/数据面分离 §2.6),离线成员重连时补投。

PR7 of the v3 §11.1 single-team MVP. Implements the §3.3 task_completed room event: an agent broadcasts a structured completion (git pointers, never file contents) that offline members replay on reconnect.

改动 / Changes

  • src/task-completed.tsbuildTaskCompletedEnvelope:广播(无 to)、store_if_offline、payload {summary, repo, branch, commit, contract, unblocks}
  • src/publish-throttle.ts — 跨进程时间窗去重节流,拆 peek()(纯读)/record()(盖戳)/allow();0600 JSON 持久化;record 仅在确认 publish 之后,broker 离线绝不烧掉去重窗口。
  • src/cli/publish.tsabg publish / announce:解析登录 + cwd→room,组装信封,--from-hook 按 commit 去重,经 BrokerClient(带 connect 超时)发布。登录闸在 openStore 之前 —— 纯 v1 / 未登录用户完全惰性(不落 collab.db、不收紧 state dir 权限)。runPublish 是 fail-open 边界(恒 exit 0)。
  • plugins Stop hook → scripts/publish-completion.sh:nohup detach、防注入(positional args)、fail-open;并登记进 smoke-pack.mjs + install-safety.cjs 两处打包完整性守卫。

测试 / Tests

  • publish-throttle.test.ts(3)+ task-completed.test.ts(2)+ integration-test/publish.test.ts(8):e2e 投递、skip 三态、离线、commit 去重、离线重试不烧窗口、v1-only 惰性、非 git→skipped-empty、runPublish fail-open。
  • bun run check 全绿:1776 pass / 0 fail,bundle 同步,版本对齐。

Cross-review

6 轮(workflow + 前台并行),抓出并修复 1 MEDIUM(节流槽在 broker 离线尝试时被消耗 → 该 commit 在窗口内永久压制)+ 2 LOW(v1-only 副作用、打包 allowlist 漂移)+ 2 测试覆盖缺口;连续两轮 0 真实 issue 收敛。

铁律自检 / Invariants

🤖 Generated with Claude Code

v3 §11.1 单团队 MVP 的 PR7。实现 §3.3 的 task_completed 房间事件:agent
广播结构化完成信号(repo/branch/commit 是 git 指针,绝非文件内容),离线成员
重连时补投。

PR7 of the v3 §11.1 single-team MVP. Implements the §3.3 task_completed room
event: an agent broadcasts a structured completion (git pointers, never file
contents) that offline members replay on reconnect.

- src/task-completed.ts: buildTaskCompletedEnvelope — broadcast,
  store_if_offline, payload {summary, repo, branch, commit, contract, unblocks}.
- src/publish-throttle.ts: cross-process windowed throttle (peek/record/allow),
  0600 JSON; record ONLY after a confirmed publish so a broker outage never
  burns the dedup window.
- src/cli/publish.ts: abg publish / announce — resolves login + cwd→room,
  builds the envelope, throttles --from-hook by commit, publishes via
  BrokerClient with a connect timeout. The login gate runs BEFORE opening the
  Store, so v1-only / not-logged-in users stay fully inert (no collab.db, no
  state-dir chmod). runPublish is the fail-open boundary (always exit 0).
- plugins Stop hook → scripts/publish-completion.sh (nohup-detached,
  injection-safe, fail-open); registered in BOTH packaging-completeness guards.

Tests: publish-throttle (3) + task-completed (2) + publish integration (8:
e2e delivery, skip states, offline, commit-dedup, offline-retry, v1-only inert,
non-git skipped-empty, runPublish fail-open).

Cross-review: 6 rounds (workflow + foreground), fixed 1 MEDIUM (throttle slot
burned on a broker-offline attempt) + 2 LOW (v1-only side effects, packaging
allowlist drift) + 2 test-coverage gaps; converged on 2 consecutive clean rounds.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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