Forgejo: give conversation and PR sessions read access to their checkout #49
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#49
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?
Implementation: #52
Problem
forgejo_read_file_at_refis in the tool set of unattended Forgejo conversation and pull request sessions, but it only snapshots a file tolocal://tree@<sha7>/<path>and tells the agent to open it withread— which those sessions don't have. So the tool is available but unusable. Beyond that, answers on issues and PR reviews often benefit from looking at the code in the session's checkout.Give these sessions
read,grep,findandglob.These tools bypass
PermissionFilterand can't be confined to the checkout. This is accepted: trigger sessions run in a per-issue/PR clone, and only comments from users with push access start them — the same trust bar as implementer sessions, which already havereadandbash. The general problem of read tools bypassing permissions is tracked separately (deck inbox).Plan
Approach
apps/server/src/bridge/session-policy.ts: prepend"read","grep","find","glob"(in that order, same asIMPLEMENTER_TOOL_NAMES) toCONVERSATION_TOOL_NAMES. This covers bothforgejoConversationPolicyandforgejoPullRequestPolicy(the latter spreadsCONVERSATION_TOOL_NAMES). Nodecidechange: both policies already return"default"for any tool intoolNames, and these tools never reachdecideanyway.CONVERSATION_TOOL_NAMES(currently "No read/grep/find/glob: they can't be confined…") to state the actual reasoning: read/grep/find/glob are included even though they bypassPermissionFilterand can't be confined to the checkout, because the session runs in its own per-issue/PR clone and is only started by comments from users with push access (same trust bar as implementer sessions); there is still no file write,bashorask(askwould hang without a UI).forgejoConversationPolicy.systemContextandforgejoPullRequestPolicy.systemContext, add a bullet after the "Read the thread/conversation first" bullet:"- Your working directory is a checkout of the repository; use \read`, `grep`, `find` and `glob` to look at code when it helps your answer. `forgejo_read_file_at_ref` snapshots a file at another ref; open the snapshot with `read`."` Keep the existing "You cannot change … code" bullet.apps/server/src/bridge/session-policy.test.ts: the "tools outside the surface are denied" test (≈line 87) uses"read"; change it to"bash"with params{ command: "ls" }, same expected deny message. Add one test assertingpolicyToolNamesof both aforgejo_conversationand aforgejo_pull_requesttrigger containread,grep,find,globand do not containbash,edit,write.docs/configuration.md(≈line 237, trigger sessions bullet), addread,grep,find,glob(read-only, not confined to the checkout) to the listed tool set and change "There is no file access,bash, …" to "There is no file writing,bash, …".Critical files & anchors
apps/server/src/bridge/session-policy.ts—CONVERSATION_TOOL_NAMES+ its comment; bothsystemContextfunctions.apps/server/src/bridge/session-policy.test.ts— deny test usingread.docs/configuration.md— trigger-session tool set bullet.Verification
cd apps/server && bun test src/bridge/session-policy.test.ts src/bridge/permission-filter.test.ts src/forgejo— all pass, including the new tool-surface test.@<agent> what does forgejo_read_file_at_ref return for README.md on main?on an issue; the session callsforgejo_read_file_at_ref, thenreadon thelocal://tree@…path, and the reply quotes file content.