Skip to content

feat(platform): enable guarded review delegation - #4482

Merged
yannickmonney merged 9 commits into
mainfrom
feat/native-review-delegation
Oct 7, 2026
Merged

yannickmonney merged 9 commits into
mainfrom
feat/native-review-delegation

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Pending task reviews can remain tied to an unavailable reviewer while other project agents are idle. Add an explicit, project-only task_delegate_review grant that transfers a native pending review using the exact source run, evidence revision and captured reviewer, with a bounded receipt for safe reconciliation. Tale CLI also gains a conditional tools-only configuration facet so operators can provision review capabilities without rewriting models, instructions or secret grants.

The handoff reuses the existing review transaction and preserves the editor path. Current session authority and stored grants are checked before writes or replay; the implementation agent cannot become its own reviewer. API contract 3.17 publishes the additive tool vocabulary. Deploying this code does not automatically grant the new tool.

Checklist

  • bun run check equivalent gates passed: formatting, conflicts, links, and all 49 lint/typecheck/test/UI tasks, with no cached tasks. Bun 1.4.2, two Turbo tasks and a 6 GiB Node heap. The final CLI expectation repair passed 36 focused platform-apply tests and the full CLI suite: 2,429 passed, 29 skipped, zero failures.
  • bun run lint:sast passed with no findings; its full scan reported parser/timeout exclusions. Required hosted SAST passed before merge.
  • EN/DE/FR activity and tool labels updated; sparse de-CH inheritance covered.
  • EN/DE/FR API, task automation and CLI guides updated and rendered at desktop/mobile sizes.
  • CLI README updated. Root README translations are N/A: repository overview and setup are unchanged.

Test plan

  • Delegation: 123 real PostgreSQL checks passed, including all 34 new handoff, stale-evidence, revocation, retry and ordered verdict-race cases. One pre-existing object-store byte-transfer case was explicitly skipped in this focused fixture.
  • Tools configuration: 30 real PostgreSQL checks passed, including concurrent tools/full-agent saves, stale writes, authorization and exact preservation of unrelated fields.
  • Focused bridge, schema, CLI recovery, localized timeline and documentation tests passed. Combined source/API review found no actionable issue; the existing contract guards and regenerated OpenAPI agree.
  • All seven required hosted checks passed on final head 236d4e9ff8ea8b907b77f60ac11ada38494d0be5 before merging. No database migration or default tool grant is introduced.

Merge provenance: the owner-authorized T3 Code interactive continuation merged the independently reviewed final head through the normal exact-head protected squash flow at 2026-10-07T11:22:03Z, producing d044b72b58a78dabed15d9aeb0c23ce3c5c88fc7. The independent source/security review covered captured-review authorization, same-head CLI expectation repairs, stale evidence and replay behavior. The fleet may retain its post-merge review; the shared push account was acting for this authorized interactive integration. Native capability activation remains a separate, reviewed Ops configuration update after a compatible full runtime deployment.

Post-merge boundary audit (2026-10-07): an independent exact-source read confirmed that the implementation agent is already refused as its own reviewer by review-delegation.ts:113–126, reviews.ts:218–219 and the handoff core at reviews.ts:828–833; the native verdict independently refuses it at agent-review.ts:172–177. The real PostgreSQL delegation test at review-delegation.integration.ts:355–367 explicitly grants the implementer task_review, expects TASK_REVIEWER_NOT_INDEPENDENT and verifies no effects; this case passed in the retained 123-check integration receipt. Those bytes are identical at the merge commit and release candidate 26765dcbe00846163274ab12eae1b11e7f829a41.

Cross-project task, approval and destination checks are also present (review-delegation.ts:63–74,103; reviews.ts:146–150). Two additional direct task_delegate_review regressions for a genuine foreign task and a genuine foreign-project reviewer would strengthen coverage beyond the existing editor-routing and forged-metadata tests. This is a useful follow-up, not evidence that these authorization checks are absent. No native reviewer verdict, runtime prerequisite or configuration grant is changed by this source audit.

@yannickmonney
yannickmonney marked this pull request as ready for review October 7, 2026 10:06
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Review verdict: ACCEPT

Reviewed exact head 236d4e9ff8ea8b907b77f60ac11ada38494d0be5 (merge base 6eaa56999b), independently of the PR author. I found no blocking correctness or privilege-escalation issue in the changed surface.

  • SECURITY — PASS: task_delegate_review is project-agent-only; the live run/session and current stored grant are rechecked in the mutation transaction. Task, organization, project, captured approval, source run, evidence revision, captured reviewer, and pending successor are bound and locked; self-review and same-as-captured reviewer are refused. Replay validates the immutable receipt/request and current successor, and the CLI schema accepts no execution, model, instruction, secret, or future-routing fields.
  • WORKFLOW — PASS: delegation is serialized with the task/run lock, refuses live runs and stale/replaced gates, preserves task ownership/evidence, and routes only to an eligible independent reviewer.
  • CODE — PASS: shared catalog normalization is canonical and preserves existing tool behavior; project-only tools are filtered from automation. New delegation and tools-only paths use existing validation/audit patterns.
  • DATA — PASS (CI-backed): receipt validation is idempotent and source-bound; approval updates are transactional/locked. PostgreSQL race coverage is present in the new integration fixtures; rely on the Backend integration job for execution.
  • LOCALE — PASS: EN/DE/FR keys are added consistently and refusal copy identifies the cause and recovery action.
  • DOCS — PASS: API/docs/manual references describe the tools-only and delegation constraints.
  • CICD — UNAVAILABLE at review read: the four observed CI-ready aggregators (Commitlint, Security, SAST, E2E) passed, while Checks/Build still had running jobs including Backend integration. No rerun or cancellation was performed; final merge should wait for remaining required jobs.

No numbered findings. Optional local packages/shared/src/agent-tool-grants.test.ts was NOT_RUN because the required pressure guard failed (I/O PSI above 10% at the first reading).

@yannickmonney
yannickmonney merged commit d044b72 into main Oct 7, 2026
@yannickmonney
yannickmonney deleted the feat/native-review-delegation branch October 7, 2026 11:22

@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 post-merge review: SECURITY and WORKFLOW at 236d4e9ff8ea8b907b77f60ac11ada38494d0be5 (merged as d044b72b58, included in v0.5.76).

Scope:

  • The delegation path: delegateAgentTaskReview, liveReviewIssuer and agentReviewBlockedReason.
  • The new grant in packages/shared/src/agent-tool-grants.ts.
  • The project tool-grant route and service, and the CLI agent-tools resource.
  • API contract 3.17.0.

Method: a static read of the merged source, plus the CI execution evidence below. I did no local runtime run.

Verdict: no revert, with one hardening follow-up recommended before the grant is given to any agent.

SECURITY: pass, with one gap

  • Grant gating. A delegation needs a live project-agent run in the caller's org, project, session and exec, and that run's current tools must include task_delegate_review (liveReviewIssuer). Revoking the grant therefore stops an already minted token.

  • No automatic grant. task_delegate_review is a project-only write tool and is not part of any lane's baseline. An agent gets it only from an explicit tool list: the project route, used by someone who can write the project, or a managed agent-tools resource from the CLI. The project route refuses changes to managed agents.

  • Independence. The checks refuse:

    • delegating to the caller itself or to the current recipient;
    • a destination without the current review grant in the task's project;
    • the implementation agent of the captured source as destination (self_review).

    Human-required review policy and workflow approvals can't be rerouted, because only kind: 'agent' gates with wfExecutionId === null qualify.

  • Org and project scope. Every read is org-scoped. The task, the approval metadata and the destination's eligibility are all bound to the caller's project.

  • Replay and races.

    • Each task has a queue and a run-start lock, and the approval is read with FOR UPDATE.
    • Each delegation is bound to the exact approval, run, evidence revision and reviewer.
    • An identical retry by the same live issuer returns the stored receipt; any other replay is refused as stale.
  • Execution evidence. Backend integration job 112775214976 (Checks 37615849162 at 26765dcbe) ran 34 review delegation: checks, all passing; the job had 1,667 PASS and 0 FAIL. They cover:

    • grant loss at first admission and on retry;
    • a token without the grant;
    • self-delegation and the current recipient;
    • an implementer becoming the destination, with or without the grant;
    • human policy;
    • stale evidence in seven variants;
    • two managers electing one successor;
    • concurrent identical retries;
    • verdict-versus-handoff races in both orders.
  • Gap: who delegates. Nothing stops the caller from being the implementation agent of the captured source. An implementer that holds task_delegate_review can move the review of its own work to a reviewer it chooses: not itself, but its pick. I suggest refusing when auth.agentId === source.implementationAgentId, with a regression test.

  • Test gap. The "task is outside this project" refusal exists in code, but I found no delegation test for it.

WORKFLOW: semantics pass; rollout needs care

  • Semantics. Exactly one captured gate changes. Task owner, future reviewer defaults, status, source and runs are preserved, and a durable receipt and an activity row are written. task_get exposes the receipt for reconciliation.
  • API contract. 3.16.0 → 3.17.0 adds the new tool name to the tools enum and adds no public delegation endpoint. The new tools-configuration route is an app route that the CLI uses.
  • Provisioning. The serving build (0.5.74) predates this change, so the grant can't be live in production yet. I can't see whether a declaration is staged for when v0.5.76 is adopted. I recommend granting it only to the coordinating manager agent, never to implementers or reviewers, and only after the follow-up above merges.
  • Process. This PR was merged before the merge lane's decision, so this Part B review is post-merge and the change is already in the v0.5.76 tag.

Proposed follow-up (small PR, independent reviewer)

  1. In delegateAgentTaskReview, refuse with 403 when the caller is the implementation agent of the captured source, and add a regression test.
  2. Add a delegation regression for the cross-project refusal.
  3. Keep task_delegate_review unprovisioned until 1 and 2 are merged.

yannickmonney added a commit that referenced this pull request Oct 7, 2026
)

The implementation agent of a captured task review can no longer delegate
that review, even with the task_delegate_review grant: the call is refused
with TASK_REVIEWER_NOT_INDEPENDENT before any handoff, replay or activity
write. Integration coverage adds the cross-project refusal
(TASK_REVIEW_FORBIDDEN). The TASK-R21 spec, the error-code reference, the
API reference and the task-automation docs (en, de, fr) describe both.

Follow-up to #4482 (post-merge review 5442169399).
Independent review: ACCEPT at ecc1829 (C3, PR review 5443524819), and a
Part B check PASS (agent #4, PR review 5445201194).
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