feat(completion): task_completed 事件 + 发布节流 + Stop hook 发布 (PR7)#194
Open
raysonmeng wants to merge 1 commit into
Open
feat(completion): task_completed 事件 + 发布节流 + Stop hook 发布 (PR7)#194raysonmeng wants to merge 1 commit into
raysonmeng wants to merge 1 commit into
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要 / 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.ts—buildTaskCompletedEnvelope:广播(无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.ts—abg publish/announce:解析登录 + cwd→room,组装信封,--from-hook按 commit 去重,经BrokerClient(带 connect 超时)发布。登录闸在 openStore 之前 —— 纯 v1 / 未登录用户完全惰性(不落collab.db、不收紧 state dir 权限)。runPublish是 fail-open 边界(恒 exit 0)。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
feat/v3-pr6-routing(feat(routing): Envelope 三档路由 + traceId/hop 防环 + 离线补投 (PR6) #193),合并顺序在其后。🤖 Generated with Claude Code