Skip to content

feat(agents): let delegated child tasks own pull request watches - #611

Merged
lastobelus merged 4 commits into
lastcode/mainfrom
lastcode/child-owned-pr-watches
Nov 7, 2026
Merged

lastobelus merged 4 commits into
lastcode/mainfrom
lastcode/child-owned-pr-watches

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

A delegated child that waits on a pull request has to end its turn and hand the watch to its parent. This PR lets an app-owned child keep the watch itself: it stays one unfinished task, handles real CI and review events as they arrive, and returns a single final result to its parent.

How ownership and events work

  • Ownership: a watch belongs to one exact task and one watch generation. A stale or foreign watch cannot wake or finish another task.
  • Terminal events: saved before the task is admitted to continue. Recovery retries that same saved event, so a result is not lost, and a cancelled task is not revived.
  • Lifecycle: a task can run Actions before and after a watch and still end with one parent result.
  • Unchanged: top-level watches and merge permissions behave as before. A child owning a watch adds no merge authority.

Rollout stays gated

Ordinary child watches need both the new capability and an explicit #482 acceptance of the identified installed Phase 4 checkpoint. Merging this does not grant that acceptance, and existing parent-mediated watches do not transfer automatically. Phase 3 stays accepted on its recorded checkpoint.

Not in this PR: UI, a production install, restart or checkpoint, merge-authority changes.

Agent context growth

Guidance for the new flow adds a small, measured amount of agent context:

Surface Before After
Claude system append 17,521 B 19,208 B
Codex additional context 18,857 B 20,542 B
Tool list 74,704 B 75,222 B

Checks

Earlier integrated source validation

  • 476 tests in the 13 owning suites.
  • Terra xhigh read-only review of that exact head: no material findings. The discovery repair then received one credential-continuity finding; the final correction passed Terra xhigh R3 with no material findings.

Focused checks

  • 122 lifecycle and result tests.
  • 132 delivery and message tests.
  • 480 context-budget and eval-runner tests.
  • 125 instruction and replay tests, run before a minor gate-wording correction.
  • Quick CI on the final repaired head 48a968acc95188c20afe079cbe3011d5f3a3bc28 against base c8ecf0d8509de27c377dfed86f64a65da912b3db.
  • Focused model evals: the four new cases passed 3 of 3 samples each; 29 of 30 samples overall. The remaining sample is a legacy simulator case with an invalid 41-character SHA, kept as is; the baseline passed that case.

Runtime result and remaining acceptance

  • Current-head local gates passed: formatting, lint, unused-code checks, GraphQL checks, 36 affected typechecks and tests in 42 owning files.
  • Full model run completed: 197 Codex-applicable cases from the 205-case catalog, 378/399 completed samples passed, plus two interrupted Responses streams. All four new watch cases and six selected watch-workflow controls passed 20/20 samples. Eight other scenarios failed a majority of samples; these and the other individual misses remain unresolved and retained. This is not an all-pass full-suite claim, and no full historical-baseline regression comparison is claimed.
  • Genuine source QA initially found missing watch discovery; the repaired discovery and continuity paths pass 141 owning tests. The final frozen-evidence audit passed 67 assertions: one Task, two successful Actions, one gate read, one actual CI event, one unwatch and one parent final, without actor polling or relay. Actual web Task-card navigation and parent-back passed. Observer deviations remain recorded: a missed final WAL update and cleanup after the genuine final; pre-cleanup evidence proves the workflow.
  • GitHub CI exposed four migration-list expectations that omitted the new index; the corrected four tests pass. Exact-head GitHub CI and Codex review passed with zero unresolved review threads. The guarded merge revalidates current head and base.

Part of #482; it does not fix it. Phase 4 installed and real-use acceptance remain separate.

Implemented with Codex GPT-6.1 Sol; source review by Terra at xhigh.

Co-Authored-By: OpenAI Codex [email protected]

lastobelus and others added 2 commits November 6, 2026 16:59
Carry-Group: incubator
Carry-Fix: #482
Carry-Observation: Watch ownership, task finality, injected guidance and feature evals depend on the existing Incubator delegation layer and ship together.

Co-Authored-By: OpenAI Codex <[email protected]>
Carry-Group: incubator
Carry-Fix: #482
Carry-Observation: Records measured context for the owned-watch feature and its model-facing guardrails.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T00:42:21.209314Z 48a968a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lastobelus lastobelus added the agent-context-increase Intentional agent context growth approved by a maintainer label Nov 7, 2026
Derive discovery visibility from server-issued child identity, while retaining exact native-call authorization for mutations. Refresh migration expectations for the new watch index.

Carry-Group: incubator
Carry-Fix: #482
Carry-Observation: Real provider discovery precedes native call metadata; the ownership decider remains authoritative.
@lastobelus lastobelus changed the title feat(agents): keep child tasks alive while they watch pull requests feat(agents): let delegated child tasks own pull request watches Nov 7, 2026
…anges

Keep discovery classification stable for a live MCP client; current watch mutation ownership remains authoritative. Cover shared-runtime reattachment after remote-task settlement.

Carry-Group: incubator
Carry-Fix: #482
Carry-Observation: Discovery visibility must not revoke the credential retained by an already-open shared provider client.
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 48a968acc9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus
lastobelus merged commit 17931c6 into lastcode/main Nov 7, 2026
43 of 56 checks passed
@lastobelus
lastobelus deleted the lastcode/child-owned-pr-watches branch November 7, 2026 02:26
lastobelus added a commit that referenced this pull request Nov 30, 2026
## Problem

[#482](#482) Phase 4 delivered app-owned task PR-watch continuation in [#611](#611), but agent instructions still required build-specific approval. A destination that supports continuation should not also need that approval before a delegated child can own a watch.

## Change

- **Support check:** The parent calls `orchestrator_capabilities` for the child's actual destination environment and confirms that `features.appOwnedPullRequestWatchContinuationVersion` is `1`. No build lookup or version guess is needed.
- **Assignment:** The parent must also assign the watch in the delegated child's brief.
- **Fallback:** Without the check and assignment, or if the watch is refused for lack of ownership support, the child hands off unfinished work and the parent owns the watch.
- **Unchanged:** Current owners keep their watches. Owning a watch grants no merge authority.
- **Consistency:** Updates agent instructions, the `watch_pull_request` tool description, docs, replay fixtures, an instruction test and eval cases, including cases for an assigned child without a capability receipt and a supported but unassigned child.

## Scope

This fixes the leftover approval rule and replaces it in agent guidance; runtime logic does not change. Background waits for commands are accounted for separately in [#824](#824).

## Admission and the unassigned control

The server **can** admit a live app-owned delegated child that calls the watch tool without a watch assignment in its brief. The [MCP handler](https://github.com/lastobelus/lastCode/blob/9c15a4feafbe74195e2db69d0267eeaa2ac1fea6/apps/server/src/mcp/toolkits/pullRequests/handlers.ts#L506-L520) passes authenticated execution provenance. [Registration](https://github.com/lastobelus/lastCode/blob/9c15a4feafbe74195e2db69d0267eeaa2ac1fea6/apps/server/src/orchestration-v2/Orchestrator.ts#L5359-L5443) requires the exact live delegated execution and a live task owner, and checks the existing watch generation’s owner when there is one. It does not check the brief for an assignment. The assignment rule is agent guidance.

The first live run produced no unassigned child traces. A follow-up native control on this exact source passed with Codex GPT-6.2 Sol at xhigh. The parent verified version 1, dispatched one app-owned child, and kept the watch assignment. The child handed the pending review back, and neither called `watch_pull_request`. The child reported reading the description, but there was no separate description lookup in the trace. [Issue 914](#914) tracks the blocked samples.

## Verification

- **Tests:** 591 focused tests passed.
- **Checks:** Changed-file checks passed.
- **Replay dry runs:** Six built successfully for each of Codex and Claude.

- **Agent context:** compared with the base, the Claude and Codex instruction payloads each shrank by 228 bytes and the MCP tool list shrank by 62 bytes.
- **Native wording check:** two assigned Codex Luna samples on the final source registered the watch, ran one pending gate check, stayed unfinished, then handled a real review wake and unwatched. One repeated the capability check, and one delegation call had a parameter error before dispatch. Four candidate samples (including all three unassigned controls) and three baseline samples stopped before delegation after reporting missing native tools. This gives two complete watch traces and no paired comparison.

Local review: 3 rounds with GPT-6.1 Terra (xhigh) at 9c15a4f, approved.

Implemented with Codex GPT-6.2 Sol in T3 Code. Guidance written with Claude Opus 5.5.

Carry-Source-Ref: refs/lastcode/carry-sources/pr-913/9c15a4feafbe74195e2db69d0267eeaa2ac1fea6
Carry-Source-Base: e5d27a1
Carry-Source-Head: 9c15a4f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-context-increase Intentional agent context growth approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant