Let unattended Forgejo sessions comment on any issue or PR in their repository #180
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#180
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
Unattended, trigger-started sessions can only comment on the issue/PR that started them. If a conversation session tries to comment on a different issue, it gets denied, e.g.
only #7 may be commented on in this unattended conversation session. The restriction lives indecide()of all three policies inapps/server/src/bridge/session-policy.ts:forgejo_conversation: onlyscope.numberforgejo_pull_request: onlyscope.numberforgejo_implementer:scope.numberplus PRs mapped to the session (getForgejoSession(...) === sessionId)Wanted: sessions of all three kinds can post comments (
forgejo_create_issue_comment,forgejo_create_pr_comment,forgejo_create_pr_thread_comment) on any issue or PR in the session's own repository, with no prompt.#Nstays the place to answer the triggering conversation. Commenting on other issues/PRs is allowed when relevant.What stays unchanged: the same-repo confinement (
repoMismatch/assertTriggerRepo). Theforgejo_post_reviewrestriction in PR sessions stays (own PR only).forgejo_abandon_implementationis still limited toscope.number. The thread tool's own check thatcomment_idbelongs to the given PR is in the tool itself and is not touched.Plan
Approach
All edits go in
apps/server/src/bridge/session-policy.tsand its tests.decide()methods, replace theFORGEJO_COMMENT_TOOLSblock withif (Object.hasOwn(FORGEJO_COMMENT_TOOLS, toolName)) return "allow";:getForgejoSessionfrom the import on line 24, since it has no other use in the file. KeeplistForgejoSessionNumbers.FORGEJO_COMMENT_TOOLS(lines 97–98). It becomes: "All three post on an issue/PR given bynumber, which may be any number in the session's repository; the thread tool itself checks that itscomment_idis an inline comment of that PR."systemContextline 234: change- Reply only on #${number}: ...to- Reply on #${number}: ...(keep the rest of the sentence). Add a new bullet right after it:"- You may also comment on other issues or pull requests in this repository when it is relevant (e.g. to cross-reference related work)."systemContextline 320: change "Reply only on" to "Reply on" the same way and add the same bullet after it.systemContext: append the same bullet to the sharedrulesarray (after theforgejo_create_issuebullet, ~line 405).apps/server/src/bridge/session-policy.test.ts:"allow"for number 8."allow"for number 8."allow"for number 7 and for number 99 with sessions s1 and s2, with no mapping needed. Remove thedenyconstant and thesetForgejoSessioncall if nothing else in that test uses them.apps/server/src/bridge/permission-filter.test.tsline 131: rewrite the test as "commenting on another number runs without a prompt". Expectpromptnull,isErrorfalse, andh.ranequal to["forgejo_create_pr_comment"]. Drop thetoContain("#7")assertion. The deny-rule test at ~line 170 stays: it proves that user deny rules still win.Verification
cd apps/server && bun test src/bridge/session-policy.test.ts src/bridge/permission-filter.test.ts: all tests pass. With the conversation trigger on #7,decidePolicy(TRIGGER, "forgejo_create_pr_thread_comment", {number: 8, ...}, "s")returns"allow".bun run typecheckor the repo's equivalent) to catch the unused import.