Skip to content

fix(trackers): attribute in-flight writes, repair Azure work item hooks, failure-comment switch - #393

Merged
artempartos merged 5 commits into
developfrom
fix/tracker-write-attribution
Oct 1, 2026
Merged

artempartos merged 5 commits into
developfrom
fix/tracker-write-attribution

Conversation

@artempartos

@artempartos artempartos commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Flow should always recognise its own tracker writes as Flow's, even when the tracker's webhook arrives before the write returns. This PR fixes that, and makes the workitem.* Service Hooks something Azure's Test connection checks and repairs. It also puts the failure-comment setting on the tracker trigger form.

1. Attribution race: events that overtake the write

What was wrong. InternalTools::Concerns::TrackerContext#with_write (app/services/internal_tools/concerns/tracker_context.rb:48-57 on develop) only stored tracker_operations.issue_id after the provider call returned. Trackers::EventPipeline#matching_operation (app/services/trackers/event_pipeline.rb:90-96) matches events by issue_id. So a webhook processed while the call was still in flight matched nothing:

  • Under "Only from other workflows" it had no chain, so it could restart the workflow that made the change.
  • On a Jira connection that acts as a person (3LO, not marked as dedicated), it looked like that person's own change.

The design doc (§6.6) already claimed the row "still finds" such an event; the code didn't do it.

What changed.

  • Updates, transitions, assignments, comments. The issue is now recorded on the ledger row before the call. The new port method Trackers::Provider#issue_identifier(ref) reads it off the ref without making a request: on Azure it's the work item id, on Jira the numeric id or the key. Once the call returns, the canonical id replaces it. The pipeline matches on either issue.id or issue.key.
  • Creates. A create only learns its issue from the tracker's answer. Suppose an issue_created event arrives, matches nothing, and a create_issue row on the same external project is still pending with no issue (and is less than 2 minutes old). The pipeline then raises EventPipeline::WriteInFlight instead of publishing. Both delivery jobs (Trackers::ProcessDeliveryJob for Jira, ResolveAzureDevopsEventJob for Azure) retry that error up to 12 times, 5 s apart. On the last attempt they pass wait_for_writes: false, so the event is published as it stands.
  • TrackerOperation#succeed! now sets the result and the issue in one update. Before, there was a moment when a succeeded create had no issue, so its event could be neither matched nor waited for.
  • Trackers::RunStatusReporter had the same bug in another form. When it resent a failure comment that had been refused (e.g. rate_limited), the ledger row was still failed, and the pipeline only matches pending and succeeded rows. The row is now set back to pending before the resend (TrackerOperation#retry!, now also used by with_write).

Tests that deliver the webhook while the write is in flight. before_answering hooks were added to FakeJira::Api and FakeAzureDevops::WorkItemService; they run once the call has been applied and before it returns.

  • tracker_tools_jira_test: on a 3LO Jira connection, an agent transitions ENG-1 by key. Jira's webhook is delivered and processed mid-call, and the event is attributed to the run, so the "ignore Aixle" trigger does not restart the workflow.
  • tracker_tools_jira_test: an issue-created webhook arrives during a create. The job is retried rather than published, and after the create returns the event is attributed.
  • tracker_tools_test: the same create race on Azure, through ResolveAzureDevopsEventJob.
  • run_status_reporter_test: a comment resent after a refusal is attributed even though its event arrives mid-call.
  • event_pipeline_test / process_delivery_job_test: waiting stops on the last attempt, and a create left pending past the 2-minute window holds nothing up.

All four race tests fail when run against the old attribution code: the workflow gets restarted, or the event has no origin.

2. Azure Test connection didn't cover workitem.* hooks

What was wrong. AzureDevops::IntegrationService#test → provision_subscriptions → SubscriptionService#ensure_all! used the default GATE_EVENT_TYPES, which are the CI hooks only (integration_service.rb:144, subscription_service.rb:29). Failures were only logged, and the flash said "Connection verified" no matter what. SubscriptionService#refresh_status! had no callers at all, so a hook deleted in Azure was never noticed.

What changed.

  • Check, then repair. Test connection first asks Azure for the state of every hook (refresh_status!). Then ensure_all! recreates the missing, refused or deleted ones. The workitem.* hooks are included once an active tracker trigger waits for this connection's trackers, either by name or as "any tracker" in the project. Connecting provisions them on the same rule, so an "any tracker" trigger set up before the connection now gets its hooks.

  • Result in the UI. The new SubscriptionService#undelivered lists every hook that isn't delivering, with the reason: missing, the error code, disabled, or probation. The result shows in the flash:

    • all hooks in place: green, "Connection verified. Service Hooks are in place for CI and Boards events";
    • some hooks failing: red, "Connection verified, but these Service Hooks are not delivering: workitem.created, workitem.updated in Customer Platform (permission_denied)";
    • deployment Azure can't reach: "…Azure cannot reach this deployment, so it has no Service Hooks".

    In the controller, only the success branch of test_connection changed (one line). Jira's test returns no message, so Jira still shows "Connection verified".

Tests. subscription_service_test covers three cases: a waiting Boards trigger gets work-item hooks, a hook deleted in Azure is recreated, and refused hooks are named while the connection stays verified. azure_devops_integrations_test checks the red flash end to end.

3. Failure comment (§6.9): notify_on_failure had no switch on the form

The comment is controlled by notify_on_failure (on by default), and only the API could turn it off. The tracker trigger form now has a Comment on the issue when a run fails switch, on by default (TrackerTriggerFields.tsx, plus notifyOnFailure in trackerTrigger.ts). The create/update_workflow_trigger MCP param descriptions and the TriggerBinding comment used to describe it as Slack-only; they're corrected.

Docs

  • trackers.md: the switch, attribution of in-flight writes, and what Test connection now does for Boards hooks.
  • azure-devops.md: Test connection as the check-and-repair step for every Service Hook, and a new "A Boards trigger never fires" troubleshooting row.

Both have identical bundled copies under app/frontend/pages/Docs/data/pages/. The design doc §6.6 and §6.9 now describe what the code does.

How it was tested

Targeted local runs, through a throwaway test container:

  • Backend: bin/rails test on every touched test file and its neighbours (test/services/trackers, both delivery jobs, the trigger binding models, the Azure subscription, onboarding and service-hook-grant tests, the Azure, Jira and integrations request tests, the webhooks trackers controller, the Jira integration service, the Azure parity tools, and the personal MCP trigger tests): 293 runs, all green.
  • Frontend: rubocop on the changed Ruby files, brakeman (0 warnings), vitest on TriggerFormPanel.test.tsx, yarn tsc, yarn lint (0 errors), yarn fsd.

CI runs the full suite and is the full verification.

Merging with the parallel PRs. The switch sits right after "Changes made by Aixle", and its form field sits next to aixleChanges. Both spots are clear of the lines #392 (trackers UI) edits.

Not done, and why

  • No persistent Service Hook status on the integration card. The result shows in the Test connection flash only, which keeps the change out of the shared Integrations page component.
  • No CHANGELOG entry. None of the recent integration PRs added one, and nine parallel branches editing it would conflict.

🤖 Generated with Claude Code

artempartos and others added 5 commits October 1, 2026 18:21
The event pipeline matches a tracker event to the write that caused it by
issue id, but with_write stored the issue id only after the provider call
returned. A webhook processed while the call was still in flight matched
nothing: under "Only from other workflows" it carried no chain and could
restart the same workflow, and on a Jira connection that acts as a person
it passed for that person's change.

Updates, transitions, assignments and comments now record the issue before
the call, as the caller named it (Provider#issue_identifier: the id, or on
Jira possibly the key), and the pipeline matches either. A create learns
its issue only from the answer, so an issue-created event that arrives
while a create on the same project is pending is retried by the delivery
job (12 runs, 5 s apart) and published as it stands on the last one.

RunStatusReporter resent a refused failure comment while its ledger row
was still `failed`, which the pipeline never matches; it is pending again
before the resend, as in with_write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…onnection

Test connection re-provisioned only the CI hooks, so the workitem.* hooks
Boards triggers depend on were never retried, and every failure was only
logged: the connection reported itself verified while no event could
arrive.

It now asks Azure for the state of every hook first (refresh_status!, which
had no caller), recreates the missing, refused or deleted ones, including
the workitem.* hooks once a tracker trigger waits for this connection's
trackers, and reports the outcome in the flash: green when every hook is in
place, red with each hook that is not delivering and why. Connecting
provisions the workitem.* hooks too when a trigger for any tracker already
exists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The comment Flow posts on an issue when a tracker-started run fails or is
cancelled is governed by notify_on_failure (on by default), which only the
API could turn off. The tracker trigger form now has the switch, and the
MCP trigger tools and the model no longer describe the setting as
Slack-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
… switch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…setting

Keeps the switch, and its field in the form value, clear of the lines the
trackers UI work (#392) edits, so the two merge without conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit 4bcb879 into develop Oct 1, 2026
7 checks passed
artempartos added a commit that referenced this pull request Dec 2, 2026
)

The worker count is what a company is billed for, hour by hour, whether
the workers are busy or idle. It shared one Save Changes button with
branding, Enter in any field submitted it, and the unsaved-changes dialog
could save it on the way out, so a mistyped number changed the bill
without anyone noticing.

Workers now have their own Save workers button. Where the installation
bills for them, saving asks for confirmation first; branding, Enter and
the leave-page dialog never save the count. Each change is written to the
audit trail with who made it and the old and new number.

Board task #393.

Signed-off-by: Artem Petrov <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant