Skip to content

fix(#1308): transparent delivery baseline context, issue target.ref, team nomination delivery, preflight guards, and progress wording - #1310

Merged
zhaozhaozz merged 2 commits into
agent-CI-Infra:mainfrom
zhaozhaozz:fix/issue-1308-delivery-baseline-transparency
Nov 24, 2026
Merged

zhaozhaozz merged 2 commits into
agent-CI-Infra:mainfrom
zhaozhaozz:fix/issue-1308-delivery-baseline-transparency

Conversation

@zhaozhaozz

Copy link
Copy Markdown
Collaborator

Fixes #1308

Summary

Addresses all five delivery-baseline, team-nomination, preflight, and issue-progress transparency gaps described in #1308:

  1. End-to-end delivery context & QA handoff transparency (src/tasks/delivery-context.ts, src/tasks/request.ts, src/roles/team.ts, src/tasks/children.ts, src/tasks/acceptance.ts)

    • Injects a deterministic delivery_context (target, base_branch, base_sha, pr_base_semantics, goal, intended_delivery, writes) across Task Manager, Dev, and Observer (reviewer / test) prompts.
    • Surfaces delivery and changed_files_count on latest_dev_result and delegate_role results, target / base_branch / delivery / pr_url on read_child_tasks, and candidate_changes on Observer prompts.
    • Adds a top-level delivery_handoff section in QA acceptance input outside boundedCandidate so delivery intent, target/base branch, baseline/candidate HEAD SHAs, changed file summary, and child PR references are never truncated by large diffs.
  2. Effective target: { type: "issue", number, ref? } (src/tasks/request.ts, src/dispatch/store.ts, src/dispatch/manager.ts, src/tasks/management.ts, src/agent/failures.ts, src/agent/failure-actions.ts, docs/prompts/manager-dispatch.md)

    • Resolves target.ref for issue tasks: an existing open bot_pr still takes precedence; a remote branch sets baseBranch and targetSha (and fails explicitly with target_branch_not_found instead of silently falling back to main); bare commit SHAs / tags are allowed only for read-only tasks and rejected with target_ref_not_branch when pull_request write is held.
    • Keeps repository .agents/skills/, AGENTS.md, and CLAUDE.md strictly pinned to the trusted policyBase || defaultBranch checkout.
    • Includes ref in issue dispatch deduplication keys (issue:<n>@<ref>) and documents target.ref in create_task schemas and Manager dispatch prompt.
  3. Team nomination delivery semantics & child-nomination guardrails (src/roles/catalog.ts, src/roles/nomination.ts, src/roles/team.ts)

    • Adds optional delivery?: "pull_request" | "review" | "report" to nominationSchema (generic tasks only, bounded by effectiveWrites).
    • Validates nominated candidate results against the actual target finish tool (open_pull_request / post_review / submit_report) rather than hardcoding submit_report.
    • Enforces child-nomination boundaries: child workspaces are not auto-imported; parent tasks requiring reviewable_pull_request reject nominating a child without pr_url when delivery is omitted; nominating a child with pr_url defaults parent delivery to report with child_pull_requests preserved and no duplicate PR.
  4. QA preflight test-path exclusion & workspace HEAD drift guardrail (runner/workspace.mjs, src/agent/workspace.ts, src/agent/engine.ts, src/tasks/request.ts, src/tasks/acceptance.ts, src/tasks/delivery-context.ts)

    • Exports isTestFixturePath and relaxes only privateKeyBlock matching for test fixture paths (tests?/__tests__/specs? at any depth, .test./.spec./test_*/*_test.*) while keeping redactor.contains and dirtyPathPattern strict on all paths.
    • workspace_finalize returns actual head_sha; control plane tracks workspace_base_head_sha (including snapshot checkouts and workspace advances) and rejects drifted workspace HEAD (workspace_head_drifted) in both open_pull_request and QA deterministic preflight unless an authorized conflict resolution or integration took place.
  5. Issue progress comment wording & non-default base branch (src/review/progress.ts, src/tasks/request.ts)

    • Renders completed / succeeded tasks without a PR as 已结束(未开出 PR) / Ended (no pull request) (prioritizing stopped.reason, then redacted/truncated result.summary) instead of misleadingly showing 开发失败(completed) or an unclickable retry hint.
    • Displays 基线分支 / Base branch in the progress comment start section when developing against a non-default base branch.

Documentation

  • Updated docs/features/github-automation.md and docs/design/dispatch-and-tasks.md in sync with the behavioral and architectural changes.

Verification

Verified on head f80853a0c97f0487ce8da5fbefce4654e28ab9c3 (rebased onto origin/main b7c90cbf):

  • npm ci && npm ci --prefix runner --omit=dev --ignore-scripts — exit 0
  • npm run check — exit 0 (tsc -p tsconfig.json --noEmit + 784 runtime JS files)
  • BOT_TEST_JOBS=8 npm test — 2669/2669 passed across 232 test sets (including new unit suite test/ut/src/tasks/delivery-baseline-transparency.test.mjs, new integration suite test/st/src/tasks/issue-ref-and-head-drift.test.mjs, and updated test/st/src/review/issue-progress.test.mjs); test/st/src/harness/codex-harness.test.mjs experienced parallel CPU-contention grace-window flake under 8-way load and passed standalone:
    • node test/framework/test-sets.mjs test/st/src/harness/codex-harness.test.mjs — 67/67 passed
  • docker compose -f docker/compose.yaml config --quiet && docker compose -f docker/compose.yaml -f docker/compose.build.yaml config --quiet — exit 0

…e target.ref, team nomination delivery, preflight guards, and progress wording
@zhaozhaozz

Copy link
Copy Markdown
Collaborator Author

Fixed the CI failure in test/st/src/tasks/issue-ref-and-head-drift.test.mjs on cc7ecfc72c3b57ba8e949c46540ff25e42d64c91: the test's simulated rogue git commit now passes explicit -c user.name=... -c user.email=... -c commit.gpgsign=false so it does not depend on global Git identity configuration on fresh CI runners.

Verification (cc7ecfc72c3b57ba8e949c46540ff25e42d64c91)

  • npm run check — passed
  • GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null npm test -- test/ut/src/tasks/delivery-baseline-transparency.test.mjs test/st/src/tasks/issue-ref-and-head-drift.test.mjs — 10/10 passed (reproducing clean runner environment)

@zhaozhaozz
zhaozhaozz added this pull request to the merge queue Nov 24, 2026
@zhaozhaozz

Copy link
Copy Markdown
Collaborator Author

Independent review: approved and enqueued

Reviewed head: cc7ecfc72c3b57ba8e949c46540ff25e42d64c91 (also reviewed the parent fix commit f80853a0; the rebase target is main at b7c90cbf).

Verified independently:

  • Issue target.ref (src/tasks/request.ts, src/dispatch/store.ts, docs/prompts/manager-dispatch.md): an open bot PR keeps precedence; a remote branch becomes both the checkout baseline and the PR base; a missing branch fails with target_branch_not_found instead of falling back to the default branch; a bare SHA/tag on a task holding pull_request write is rejected with target_ref_not_branch while read-only tasks may pin it; dedup keys include the ref. Repository skills/AGENTS.md/CLAUDE.md are pinned to policy.base_branch || defaultBranch (no longer the bot PR base), which is covered by a real non-default-branch fixture with an adversarial release-branch AGENTS.md.
  • HEAD drift guard (runner/workspace.mjs, src/tasks/workspace.ts, src/tasks/delivery-context.ts, src/tasks/acceptance.ts): workspace_finalize returns the actual HEAD; the baseline recorded at prepare is compared at open_pull_request and in the QA deterministic preflight, with explicit conflict-merge/rebase/integration exemptions. The refusal is repairable in-turn and the test asserts the real refusal text.
  • Delivery context / QA handoff: delivery_context reaches Manager, Dev and Observer prompts; latest_dev_result/delegate_role expose delivery and changed-file count; read_child_tasks exposes target/base_branch/delivery/pr_url; QA gets a top-level delivery_handoff with baseline, intended vs actual delivery, bounded change lists and workflow flags outside boundedCandidate. summarizeFileChanges has independent path/sha truth.
  • Team nomination delivery: validated against the actual target finish tool, bounded by parent effective writes, and the child-nomination guard rejects a silent downgrade for reviewable_pull_request parents while aggregating a child PR as report with child_pull_requests (no duplicate PR).
  • Progress wording: completed/succeeded without a PR renders as "Ended (no pull request)", prefers stopped.reason then a redacted summary, keeps the retry hint out, and shows a non-default base branch. The test path exemption is limited to the private-key heuristic while redactor.contains and dirtyPathPattern stay strict.

Required checks on the reviewed head are green: unit (both shards), e2e, the four image builds, and CodeQL/Analyze. The previously failing issue-ref-and-head-drift set is fixed by the explicit git identity in cc7ecfc7; I re-ran the two new sets and issue-progress locally (19/19 passing).

No blocking issues found. Enqueued with expectedHeadOid=cc7ecfc72c3b57ba8e949c46540ff25e42d64c91; the queue entry is AWAITING_CHECKS at position 1.

Non-blocking notes (no change required for this PR):

  1. A task that ends normally without a PR still receives the needs-human label (needsHumanWhenStopped treats any non-PR end as stopped). This matches the documented "blocked without a PR" behavior and the updated progress text, but if 任务基线与交付交接信息透明化,并修复 Issue 目标 ref、团队提名与预检/进展文案问题 #1308 intended normal endings to stay label-free, that is a separate decision.
  2. For a resumed task whose workspace was created before this change in snapshot mode (no git cache), resolveExpectedWorkspaceHead falls back to snapshot_sha, which is the remote base SHA rather than the synthetic local snapshot commit, so the first delivery after an upgrade could be refused as drift. Production request tasks normally run in git worktrees, where the fallback is exact; worth keeping in mind for degraded/local modes.

@agent-ci-infra-bot

Copy link
Copy Markdown
Contributor

检视结论:无 must-fix 问题(审查版本 cc7ecfc72c3b57ba8e949c46540ff25e42d64c91)

审查对象为 PR #1310 当前 head cc7ecfc7(= f80853a0 + 一个测试修复提交),已逐项核对全部 22 个文件的实际 diff、#1308 描述的五个缺口与 PR 自述证据。

F1(已修复)新集成用例在 f80853a0 上必失败,导致 unit 红灯

  • 现象:unit shard 1 / 2(job 138228409093)# tests 1350 / # fail 1、# failed sets: issue-ref-and-head-drift,unit 聚合检查 failure,其余 11 个检查 success。
  • 本地复现(同一 head、dist 由源码重建后):test/st/src/tasks/issue-ref-and-head-drift.test.mjs:321 断言 open_pull_request must reject drifted HEAD in-turn with workspace_head_drifted 失败。
  • 根因:该用例用 run_command 执行 git commit 模拟 HEAD 漂移,但 runner 的 command() 不注入 git 身份(只有内部 git() 在 runner/workspace.mjs:160 注入 GIT_AUTHOR_*/GIT_COMMITTER_*,共享 worktree 也未配置本地身份),提交以 exit 128 Author identity unknown 失败,HEAD 从未漂移,workspace_head_drifted 护栏路径等于没被覆盖。给该命令补 -c user.name/-c user.email 后同一用例 1/1 通过(我先本地验证了这一改法,cc7ecfc7 的提交正是此修复)。
  • 当前状态:cc7ecfc7 已在 test/st/src/tasks/issue-ref-and-head-drift.test.mjs:260 修正;我在该 head 上重跑该用例 1/1 通过,说明护栏端到端可用。

证据(cc7ecfc7)

  • CI 全绿:unit、unit shard 1 / 2、unit shard 2 / 2、e2e、bot-control-plane、bot-manager/computer/tunnel 镜像构建、Analyze (*)、CodeQL 均 success(run 45331421126 / 45331421326 / 45331421206)。
  • 本地:npm run check 通过(tsc --noEmit + 784 runtime JS);npm run build 通过;test/ut/src/tasks/delivery-baseline-transparency.test.mjs + test/st/src/tasks/issue-ref-and-head-drift.test.mjs 通过(先按 9/1 复现旧失败,修正后 10/10)。

已核对且无问题的关键点

  • target.ref:只有远端分支存在才改 baseBranch 并写 base_sha;缺失分支 target_branch_not_found 不回退默认分支;持 pull_request 写时裸 SHA/标签 target_ref_not_branch(src/tasks/request.ts:537-574);可信 .agents/skills/、AGENTS.md、CLAUDE.md 仍只从 policyBase || defaultBranch 取(src/tasks/request.ts:630-637),非默认分支基线被标记 checkout_trusted: false。
  • HEAD 漂移护栏:在 open_pull_request 的 finish 校验内(src/tasks/request.ts:1125-1145),冲突解冲、集成、变基已豁免;Manager 用 delivery:"pull_request" 提名 Dev 结果时经 validateNominationResult 传入目标收尾工具名,同样会走该护栏,未形成旁路。
  • QA 侧:delivery_handoff 放在 boundedCandidate 之外(src/tasks/acceptance.ts:322),确定性预检复用同一 drift 判定并区分 conflict_resolved/rebase/integration(src/tasks/acceptance.ts:127-139)。
  • 团队提名:delivery 受 effectiveWrites 约束(src/roles/team.ts:157-176);子任务无 pr_url 且父合同 reviewable_pull_request 时显式拒收,避免静默降级;子任务已有 pr_url 时默认 report 并保留 child_pull_requests,有单测断言。
  • 进展评论:completed/succeeded 无 PR 显示「已结束(未开出 PR)」并优先使用 stopped.reason/脱敏摘要;新增「基线分支」;paused 仍优先于 stopped 文案;test/st/src/review/issue-progress.test.mjs 已同步。
  • 文档双维度同步(docs/features/github-automation.md、docs/design/dispatch-and-tasks.md)与 docs/prompts/manager-dispatch.md 一致,未新增 docs/ 根散文档;runner/workspace.mjs 的 head_sha 返回值与 workspace.ts 的 collectArtifact 兜底在 worktree / 文件快照 / advance 三种模式下均能给出基线比较结果。

非阻塞观察(无需在本 PR 处理)

  • src/review/progress.ts:179 新增的 completed/succeeded 早返回实际不可达:renderProgress 的 endedWithoutPr 分支先命中,controlStop 只在 stopped 分支被调用;留着无害,可作为后续清理。
  • privateKeyBlock 的测试路径豁免只放宽文本启发式,redactor.contains 与 dirtyPathPattern 仍严格,符合文档描述。
  • 该用例依赖 runner 允许在 run_command 中执行 git commit;若以后收紧命令策略需同步调整。

Reviewed commit: cc7ecfc
Coverage: PR #1310; 22 changed file(s)

Merged via the queue into agent-CI-Infra:main with commit 5e2769b Nov 24, 2026
12 checks passed
@zhaozhaozz
zhaozhaozz deleted the fix/issue-1308-delivery-baseline-transparency branch November 24, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

任务基线与交付交接信息透明化,并修复 Issue 目标 ref、团队提名与预检/进展文案问题

1 participant