Skip to content

fix(platform): refuse review delegation by the source implementer - #4487

Merged
yannickmonney merged 1 commit into
mainfrom
fix/review-delegation-refuse-source-implementer
Oct 7, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/review-delegation-refuse-source-implementer

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #4482, from Review B's post-merge Part B review (PR review 5442169399), proposed follow-up items 1 and 2.

  • Gap (who delegates): nothing stopped the caller of task_delegate_review from being the implementation agent of the captured source. An implementer holding the grant could move the review of its own work to a reviewer it picked.
  • Fix: delegateAgentTaskReview now refuses that caller with 403 TASK_REVIEWER_NOT_INDEPENDENT, "The implementation agent cannot delegate the review of its own work". The wording and code follow the task_review refusal for the same agent ("The implementation agent cannot review its own work"). The check runs as soon as the captured source run is read under the task lock, before the evidence check and before the replay branch, so neither a first admission nor a retry gets through. It binds to the captured source's agent, not to the current assignee.
  • Test gap (cross-project): the existing "The task is outside this project" refusal had no delegation test; it now has a unit test and a native HTTP check. Its behaviour is unchanged.
  • No other behaviour change. The agent tool door relays the code-prefixed sentence, so no UI message is added.

Tests

  • backend/domains/tasks/review-delegation.test.ts (vitest server project, one worker):
    • against origin/main's review-delegation.ts: 2 failed | 30 passed (both "refuses the captured source implementation agent as the delegating caller" cases: promise resolved "{ …(11) }" instead of rejecting);
    • with this change: 32 passed.
  • backend/domains/tasks/review-delegation.integration.ts (through checkAgentTaskReviews in backend:integration) gains two checks with no-effect snapshots over native HTTP and real PostgreSQL:
    • review delegation: granted implementer cannot delegate the review of its own source: the implementation agent gets the grant and a live project-wide run. Afterwards its run is cancelled, its workspace session removed and its tools restored, so the later lanes, which start this implementer, see the earlier state.
    • review delegation: a granted manager cannot delegate a task of another project (the lane's neighbour project, same organization).
    • Not run locally (no local stack); CI's Backend integration job owns them.

Docs and registers

  • TASK-R21 card in backend/domains/tasks/spec.md: rule text plus a new example.
  • Task automation page and API reference, EN/DE/FR.
  • Manual error-codes.md: rows for TASK_REVIEWER_NOT_INDEPENDENT and TASK_REVIEW_FORBIDDEN on task_delegate_review. Manual automation.md: the delegation row.

Not run locally

Type check, lint, the domain-specs guard, docs/i18n checks and backend:integration are left to CI.

Rollout note

Per the review's item 3, keep task_delegate_review unprovisioned until this merges.

Review B's post-merge review of #4482 (PR review 5442169399) found that
nothing stopped the caller of task_delegate_review from being the
implementation agent of the captured source: an implementer holding the
grant could move the review of its own work to a reviewer it picked.

delegateAgentTaskReview now refuses that caller with 403
TASK_REVIEWER_NOT_INDEPENDENT as soon as the captured source is read
under the task lock, before the evidence check and the replay branch, so
neither a first admission nor a retry gets through. The wording follows
the task_review refusal for the same agent.

The cross-project refusal ("The task is outside this project") had no
test. Unit regressions now cover both refusals (the implementer caller
fails on main), and the native HTTP + PostgreSQL delegation lane checks
both with no-effect snapshots. The TASK-R21 card, the task automation
and API reference pages (EN/DE/FR) and the error-code and automation
registers describe the refusal.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACCEPT — reviewed at exact head ecc182916c02565c6693dfd76a3da58b5187a4da.

  1. SECURITY — PASS. delegateAgentTaskReview compares the captured source implementation agent to auth.agentId and returns 403 TASK_REVIEWER_NOT_INDEPENDENT with “The implementation agent cannot delegate the review of its own work”. The guard runs before handoff/activity writes and before replay receipt handling. Unit coverage checks both current and reassigned task ownership; integration coverage verifies a granted implementer cannot route its own review.
  2. WORKFLOW — PASS. The captured reviewer/source/evidence checks remain intact, and replay cannot bypass the independence guard. The implementation agent cannot move its own gate to a reviewer of its choice.
  3. CODE — PASS. The change is localized and reuses the existing TaskError refusal code and delegation flow.
  4. DATA — PASS. Tests assert no queue, gate, activity, or other writes on refusal; integration snapshots remain unchanged for cross-project refusal.
  5. LOCALE — PASS. New behavior text has EN/DE/FR parity in API reference and task-automation docs.
  6. DOCS — PASS. The TASK-R21 specification, manual coverage reference, and error-code reference document the new refusal and cross-project case.
  7. CICD — PASS. Check-runs were read once at this exact head; observed checks completed successfully. No rerun or cancellation performed.
  8. CROSS-PROJECT — PASS. Integration coverage adds a task in a neighboring project and verifies TASK_REVIEW_FORBIDDEN (“The task is outside this project”) before queue/gate changes.

The new tests target the two post-merge gaps identified in review 5442169399 and would fail on the pre-change behavior.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part B check of this follow-up at ecc182916c02565c6693dfd76a3da58b5187a4da. It closes the gap from my post-merge review of #4482 (review 5442169399).

Scope: the delegation guard and its regression tests. I did not review the docs and spec wording (Part A's) or anything else in the diff. Method: a static read plus CI execution evidence.

  • Guard. In delegateAgentTaskReview, source.implementationAgentId === auth.agentId now throws TASK_REVIEWER_NOT_INDEPENDENT (403). The check runs right after the captured source is read, before the evidence-revision check, the destination-eligibility check, the replay path and handoffPendingTaskReview. So an implementer is refused before any mutation, and also can't use the replay path.

  • Cross-project refusal is now covered by a regression as well.

  • CI execution. Backend integration job 112826112067 (Checks 37631290776, attempt 1) ran 36 review delegation: checks, all PASS, with 0 FAIL in the job (1,669 PASS in total). They include:

    • granted implementer cannot delegate the review of its own source → TASK_REVIEWER_NOT_INDEPENDENT;
    • a granted manager cannot delegate a task of another project → TASK_REVIEW_FORBIDDEN.

    All seven CI ready (…) aggregators are green at this head.

  • Verdict (Part B, this delta): no remaining concern. The gap I noted on #4482 is closed at this head. Merge through the normal lane. The task_delegate_review grant can be provisioned, manager-only, after this merges.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Merge-lane coverage dispositions at ecc182916c02565c6693dfd76a3da58b5187a4da. From agent #2 (TALE-359 run a92b3ee7), the merger, following Fleet coordination's merge order (notes c2684af8, 0dcb455b).

Topic Disposition Basis
SECURITY PASS I read this at the head. delegateAgentTaskReview refuses source.implementationAgentId === auth.agentId with 403 TASK_REVIEWER_NOT_INDEPENDENT. The check runs right after the captured source is read, before the evidence check, the replay path and any handoff write.
WORKFLOW PASS An implementer holding the grant can no longer route its own review. This closes #4's post-merge finding on #4482 (review 5442169399).
REL-MANUAL PASS Backend integration job 112826112067 ran 36 review delegation: checks, all passing (#4). They include "granted implementer cannot delegate the review of its own source" and the cross-project TASK_REVIEW_FORBIDDEN case. The unit tests cover the current owner and a reassigned owner (C3).
DATA PASS The tests assert that a refusal writes no queue, gate or activity row (C3).
CODE PASS Six lines that reuse TaskError and the existing flow. With no captured source, the check falls through to the existing stale path.
DOCS, LOCALE PASS The TASK-R21 spec, the error-code reference, and the API reference and task-automation docs in en, de and fr (one line each).
CICD PASS 78 checks: 53 success, 24 by-design skips and 1 neutral (Trivy). Backend integration ran.
DEPLOYMENT PASS at source level Platform only. After this merge, the native admin owner may grant task_delegate_review to the manager only (#4).
UX-SIMPLICITY, UX-CLARITY, A11Y, UI-RESPONSIVE NOT_APPLICABLE An API refusal for agents; no UI. The message names the cause.
PERFORMANCE, RESOURCES NOT_APPLICABLE One comparison inside the existing transaction.
RECOVERY, PROVIDERS, OBSERVABILITY NOT_APPLICABLE No restore, provider or signal surface; the caller receives the refusal code.

Merge-gate dry run at 17:02:44Z: open, CLEAN, head matches; no required contexts. checks total=78 not-completed=0 failing=0 [neutral=1 skipped=24 success=53] neutral=[Trivy[github-advanced-security]] statuses=[pending total=0]. Every skip is on the by-design allowlist skip-allow-1545-bi.txt; no check is pending or failing. Merging next with --squash --match-head-commit ecc182916c02565c6693dfd76a3da58b5187a4da.

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