Repository navigation
feat(git): implement automation event handling and related tests - #700
Conversation
- Added automation tests for Git webhook events, ensuring correct triggers on PR state changes and issue creations. - Enhanced the Service to handle automation events, linking tasks to change requests and branches. - Updated router logic to recognize opened issue bodies as comments. - Introduced event variable handling for plugin trigger events, allowing dynamic template variable substitution. - Migrated existing GitHub automation nodes to the new git.* namespace for consistency across platforms. - Improved permissions handling for task-scoped events in the real-time service.
There was a problem hiding this comment.
Summary
This PR moves the Git automation nodes from the GitHub plugin into core under a git.* namespace. The approach is clean and the implementation is thorough — the runtime delegation, event emission, condition/action logic, and migration all hold up to scrutiny.
I reviewed the core logic in automation.go, automation_runtime.go, the event emission paths in service.go, the worker consumer changes, the migration, and the E2E/unit tests. I found no blocking issues.
Strengths
- Clean delegation architecture.
AutomationRuntimewrapping the plugin runtime via anAutomationOwnercheck keeps core Git logic separate from plugin logic while preserving the existing interface. ThegitNodesindex andisGit*helpers make ownership checks cheap and clear. - Correct event semantics.
isIssueBodycorrectly distinguishes an issue's opening text from later comments (no comment ID), bot comments/reviews are excluded so automations cannot trigger themselves, and Paca's own run status is filtered out ofgit.pr_ci_completed. - Idempotent actions. Merging an already-merged PR returns
applied: false, error: nil, andautomationSetStatetreats an already-in-target-state PR as done rather than an error. The worker'sRunStepSkippedhandling for!appliedis the right integration. - Safe, scoped migration.
000080only renames the six knowngithub.*types and is idempotent by construction (theWHEREclause excludes already-renamed rows). - Good test coverage. The E2E spec exercises the node catalog, validation edges, and end-to-end runs from a queued event. Unit tests cover redelivery/bot filtering, idempotency, live-head merge behavior, and the taskless trigger validation.
Minor observations (non-blocking)
isIssueBodyheuristic relies on an emptyLocation.CommentID. The comment in the code explains this well, but it's an implicit provider contract. Consider documenting it in the provider SPI so future Git providers know to leave the comment ID empty on the opening issue text.automationMergereads the live request first. This is the right call for correctness (retries and stale caches), but it adds an extraGetChangeRequestper merge action. Worth keeping an eye on if action-heavy graphs become common.git.issue_createdonly reachescall_api,trigger_ai_agent, andwait. This is documented and validated, but the E2E test only covers thewaitpath. A unit test for thetrigger_ai_agenttaskless path would close the loop.
Verification
I ran go build ./..., go test ./internal/service/git/, go test ./internal/service/automation/, go test ./internal/events/, and go test ./internal/worker/ for the changed packages — all passed. I did not run the E2E suite or the web tests in this environment.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…c for state transitions
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
Reviewed the delta pushed since the last Pullfrog review (b4c418e), i.e. commits d9b11cd0 and defc3927, focused on the new behavior rather than re-reading the whole PR.
- Previous state read by the upsert —
UpsertChangeRequestnow reports the state it replaced through aFOR UPDATECTE, andsaveChangeRequestuses that instead of a separate pre-read, sogit.pr_state_changedstill fires only on a genuine transition when deliveries race or are redelivered. - Best-effort state emission —
emitStateChangelogs and returns instead of failing the webhook; since the row is already persisted, a retry could not re-observe the transition anyway. - Paca-footer suppression — comments and reviews whose text carries Paca's footer no longer emit the comment/review triggers, closing the self-trigger loop for agents acting through a user identity.
- Taskless edge coverage — the E2E spec now asserts that
call_apiandtrigger_ai_agentare reachable fromgit.issue_created, alongsidewait. - Docs — the provider SPI and workflow docs now spell out the empty-
comment_idissue-body contract and list thegit.*node surface in §6.4. - Web realtime — the task Git panel hook now matches the
git.event prefix and invalidates thegit-prefixed query key;PluginNodeTypegained the optionaltasklessflag.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
… timeout for race detection
There was a problem hiding this comment.
The one open review thread (comment footers treated as Paca's) is addressed, and this push adds no new issues.
Reviewed changes
Reviewed the delta since the prior review (defc392), i.e. commit d093c03, which touches only comment filtering, one test case, and the CI timeout.
- Comment-footer detection tightened —
postedByPacanow requires the trimmed text to end with</sub>and the trailingPosted byblock to be a single line, so a person replying to a Paca comment with a quote keepsgit.pr_comment_created/git.pr_review_submitted. - Regression test for quoted footers — the trigger table now asserts a reply quoting a Paca footer still emits
git.pr_comment_created. - API CI race-test budget raised — the
-racestep's-timeoutmoves from 120s to 300s to match a suite that has grown past the old budget, with a comment explaining why. - Prior thread resolved — the inline note on
automation.gois addressed by the new footer check and the corresponding test.
go test ./internal/service/git/ passes on the updated branch.

Summary
Automations built on the GitHub plugin's own nodes (for example Pull Request State Changed → state is merged → set Done) silently stopped firing when the plugins became Git providers: the plugins no longer declare any automation nodes, so nothing emitted
github.pr_state_changedand the othergithub.*nodes were gone too.Core now owns the Git automation nodes under a
git.*namespace, so every Git platform (GitHub, GitLab, …) drives the same triggers, condition and actions. The provider only has to deliver normalized webhook events.Changes
Triggers (emitted by core after a webhook is ingested or a task is linked)
git.pr_linked,git.pr_state_changed(only on a real transition, not a redelivery or a push),git.branch_linked.git.pr_ready_for_review,git.pr_review_submitted,git.pr_comment_created,git.pr_ci_completed(Paca's own run status is excluded; bot comments and reviews never trigger, so an automation that comments cannot start itself).git.issue_created: an issue belongs to no task, so the run has none. A new issue is recognised as thecreatedcomment on an issue that has no comment id, so the GitHub and GitLab plugins need no change.Conditions (read the task's newest linked pull/merge request)
git.pr_state,git.pr_ci_status(read live from the provider),git.pr_draft,git.pr_base_branch,git.has_pr.Actions
git.merge_prandgit.comment_pr(these replace the oldgithub.*ones), plusgit.close_pr,git.reopen_pr,git.mark_pr_ready,git.add_labels,git.request_reviewers. Each is idempotent: a retried run of an action that is already satisfied counts as done.Engine and wiring
gitsvc.AutomationRuntimewraps the plugin runtime, so the engine, node validation and the palette see thegit.*nodes next to plugin nodes. The web UI renders them from their config schema, so it needs no changes.{{event.<field>}}placeholders (for example{{event.title}}on an issue) and survive a paused run.tasklessflag, read through the resolver, so a trigger whose events carry no task cannot be connected to a node that needs one.LinkTaskToChangeRequest/LinkTaskBranchreport whether the link is new; newListChangeRequestTasks.000080renames storedgithub.*nodes togit.*, so existing automations keep working without being rebuilt.Live refresh
git.task.updatedwhen a task's pull requests or branches change, and the task Git panel refreshes on it. The deadgithub.routing rules in the API permission rules and the realtime service are removed.Notes for reviewers
github.*types. A plugin that declares its own differently named nodes is unaffected.git.issue_createdcan only reachcall_api,trigger_ai_agentandwaitnodes (there is no task); graph validation rejects other edges.Testing
go test ./...andgo vetforservices/api; realtime tests; webtsc -band the realtime hook test.git-automation-nodes.spec.ts(13 tests, passing on Chromium against the e2e stack): node catalog, graph validation, and graphs running end to end from a queued event (merged pull request moves the task, a closed one does not, a new pull request, an opened issue). The e2e stack has no Git provider, so these put the linked pull request in the database and the event on the trigger stream. The existing automation, Git task-link, webhook and realtime specs still pass.mobile-chrome.