Let the implementer switch its own PR between draft and ready #223
Labels
No labels
Agent
Ignore
Agent
In Progress
Agent
Planned
Agent
Planning
Agent
Ready
Agent
Triage
Compat
Breaking
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lucas/omp-deck#223
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
An implementer session can't switch its own pull request between draft and ready for review. In Forgejo, a PR is a draft when its title starts with
WIP:or[WIP]. The way to toggle that isforgejo_update_prwith a newtitle(apps/server/src/forgejo/tools/prs.ts,updatePr). The shared lifecycle prompt (apps/server/src/forgejo/tools/context.ts:43) tells agents to do exactly that. ButIMPLEMENTER_TOOL_NAMESinapps/server/src/bridge/session-policy.tsdoesn't includeforgejo_update_pr, soforgejoImplementerPolicy.decidehits its fallback{ deny: "not available in unattended Forgejo implementer sessions" }. Implementer PRs opened withdraft: truecan never be marked ready, and a ready PR can't go back to draft.Decided scope: the implementer may call
forgejo_update_pronly on its own PRs, and may change onlytitleandbody. Changingbaseorstatestays denied. Closing a PR is still reserved forforgejo_abandon_implementation.Plan
Approach
Expose the tool. In
apps/server/src/bridge/session-policy.ts, add"forgejo_update_pr"to theIMPLEMENTER_TOOL_NAMESarray, directly after"forgejo_create_pr".Gate it in
forgejoImplementerPolicy.decide. Add a branch right after the existingforgejo_create_prblock (before thescope.headBranchblock):paramNumberandimplementerPrNumbershelpers in the same file. Don't add new helpers.if (this.toolNames.includes(toolName)) return "allow";. That keeps the call unattended-safe ("allow", not "default").implementerPrNumbersreads the local session mapping only (no Forgejo call), so this path needs no API-failure handling.[]before a PR exists, so every edit is denied until the PR is opened. That is intended.Tell the implementer. In
forgejoImplementerPolicy.systemContext, add this bullet to therulesarray, after theforgejo_create_issuebullet:"- Mark your pull request ready for review by removing the \WIP:`/`[WIP]` prefix from its title with `forgejo_update_pr`, and turn it back into a draft by adding `WIP: ` in front. You may change only the title and body of your own pull requests."`Don't change the "Do not close the pull request or change labels yourself" sentence in the abandon bullet.
Critical files & anchors
apps/server/src/bridge/session-policy.ts:IMPLEMENTER_TOOL_NAMES(~L200–233),forgejoImplementerPolicy.decide(~L461),systemContextrules(~L506).apps/server/src/bridge/session-policy.test.ts: implementer describe block, around the existingforgejo_abandon_implementationandforgejo_create_prtests (~L181–241). Copy theirIMPL/bootDb()/setForgejoSession/NO_APIsetup.Verification
Add tests to
apps/server/src/bridge/session-policy.test.tsin the implementer section:policyToolNames(IMPL)contains"forgejo_update_pr".bootDb()andsetForgejoSession("o/r", 12, "s1"):decidePolicy(IMPL, "forgejo_update_pr", { number: 12, title: "Ready" }, "s1", process.cwd(), NO_API)returns"allow".{ number: 12, body: "b" }returns"allow".{ number: 13, title: "x" }(not mapped to s1) returns{ deny: "only this session's own pull requests can be edited; #13 is not one of them" }. The same holds for session"s2"with#12.{ number: 12, state: "closed" }and{ number: 12, base: "dev" }each return{ deny: "only the title and body of a pull request can be changed in this session" }.scope.pull: 12and no mapping,{ number: 12, title: "x" }returns"allow".policySystemContext(IMPL, "s1")contains"forgejo_update_pr".Run from the repo root:
bun test apps/server/src/bridge/session-policy.test.ts. The new tests MUST pass. Then runbun test apps/server/src/bridgeto confirmpermission-filter.test.tsstill passes.