Skip to content

feat(jirapoll): limit reading to 5 minutes per cycle and 2 per issue - #9855

Draft
guyoron1 wants to merge 57 commits into
fullsend-ai:mainfrom
guyoron1:feat/jirapoll-time-limits
Draft

guyoron1 wants to merge 57 commits into
fullsend-ai:mainfrom
guyoron1:feat/jirapoll-time-limits

Conversation

@guyoron1

@guyoron1 guyoron1 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The jira-poll driver now stops reading from Jira five minutes after a cycle starts, and gives each issue two minutes. An issue over its limit is a failed read; at the cycle limit the driver dispatches and commits what it finished and exits normally, leaving the rest for the next cycle. Implements the time limits of ADR 0085 Decision item 3.

Draft because it is stacked on #9854 → #9853 → #9852. #9758 has merged, so the base is now main. Its own changes are the commits feat(jirapoll): limit reading to 5 minutes…, fix(jirapoll): report a cancelled poll cycle…, fix(jirapoll): exit normally at the cycle time limit…, fix(jirapoll): hold the issue time limit when it passes inside the matcher, docs(jira-poll): count a slow issue as failed in the write-check troubleshooting row, fix(jirapoll): leave a discarded issue out of the cycle's event counts and fix(jirapoll): keep a timed-out issue out of the no-match warning; everything else in the diff belongs to the PRs below it. Jira: AISDLC-878.

Related Issue

Part of #9751

Changes

  • internal/jirapoll/poller.go: Run reads under a context that ends CycleTimeLimit after the cycle starts (preflight, search, activity filter, issues), and runs each processIssue under an IssueTimeLimit context derived from it. Dispatch (GitLab Dispatcher) and the lastCheck commits keep the caller's context, so the limit never stops them.
    • Issue over 2 minutes: WARNING: reading <KEY> took longer than 2m0s; none of its records were taken and its lastCheck was not advanced, counted as a failed issue; the next issue is read.
    • The same holds when the limit passes inside the matcher and processIssue returns no error. processIssue drops an event whose match fails and advances the checkpoint past it, so a matcher that honours its context and ran out of time would lose the issue's remaining requests. Run now takes no result from an issue whose limit has passed. The matcher fullsend ships ignores its context, so nothing is lost today.
    • Cycle limit mid-issue: WARNING: the 5m0s cycle time limit cut off reading <KEY>; it waits for the next cycle. The issue is unfinished, not failed. Issues not reached: one WARNING: ... with N selected issue(s) not read line.
    • Cycle limit during the search: WARNING: the 5m0s cycle time limit was reached during the search; no issue was read this cycle, and the cycle exits normally with an empty batch.
    • A role-roster load cut by a limit counts as that issue's timeout rather than failing the whole cycle.
    • When the caller's context ends (the job is cancelled), Run returns poll cycle interrupted: … and logs no time limit.
    • The cycle fails only when at least one issue failed or took longer than the per-issue limit and none was served: the existing all N selected issues failed to process, or all N issues read before the 5m0s cycle time limit failed or timed out; … when the limit ended the cycle first. A poller stalled by slow issues therefore fails its run, and reaching the cycle limit is not a failure by itself.
  • internal/jirapoll/types.go: Options.CycleTimeLimit (default 5m) and Options.IssueTimeLimit (default 2m). Not exposed as config keys: ADR 0085 treats them as initial values.
  • Tests (poller_idle_test.go), with a slowClient whose comment listing blocks until its context ends and whose property writes fail on an ended context (so a commit made under the read context would fail the test):
    • TestRunIssueTimeLimit: the slow issue yields nothing and keeps its lastCheck; the other is served and committed.
    • TestRunIssueTimeLimitInsideTheMatcher: a matcher that honours its context runs out of time after the issue's first event; none of the issue's records are taken, its lastCheck stays, and the other issue is served. It fails without the check in Run.
    • TestRunTimedOutIssueDoesNotCountTowardAllDroppedGuard: one issue matches an event and then times out, and the only event of the other issue fails matching. The cycle ends in the all-dropped error and neither lastCheck moves. Before the last commit the timed-out issue's matched event stayed in the cycle's counts, the guard did not fire, and the other issue's lastCheck advanced past a request that was never dispatched (the review of 1 December). Run now puts the counts back when an issue's result is not taken; feat(jirapoll)!: serve issues oldest first up to a per-cycle limit #9898 replaces this with counts carried per issue.
    • TestRunTimedOutIssueStaysOutOfNoMatchWarning: main now warns when a cycle dispatches nothing because no agent matched a request (fix(#9503)!: dispatch built-in agents from Jira without registration #9831). An issue that times out after such an event is left out of that warning, because the events it had left were never tried; the other issue's unmatched request is still named. It fails without the last commit.
    • TestRunCycleTimeLimitLeavesRestForNextCycle: cycle 1 serves and commits the first issue after the limit passes and exits normally; cycle 2 serves the request cycle 1 cut off (the ADR's "leaves undispatched requests eligible for the next one").
    • TestRunTimeLimitOutcomes: the cycle limit cutting off the first issue, a search that fails at the limit and a search that returns after it all exit normally with nothing dispatched; a slow issue followed by the cycle limit, and every issue over the per-issue limit, fail the run.
    • TestRunCallerCancelIsNotATimeLimit: a cancelled cycle returns the cancellation and logs no time limit.
  • docs/guides/user/jira-integration.md: a "Time limits" paragraph under Poll coordination. The Step 4 comment reflow in poller.go fixes a wrap left by refactor(jirapoll): return an issue's records with its checkpoint as one unit #9854.

Notes for review:

  • The limits are context deadlines, so an in-flight Jira call is cancelled at the limit rather than the clock being checked only between calls. The effect ADR 0085 asks for is the same (the issue is left for the next cycle), and a hung call cannot overrun the limit.
  • The exit rules are ADR 0085 Decision item 3 as written. At the cycle limit the driver stops reading, dispatches and commits what it finished and exits normally, including when the search used up the limit and no issue was read. A cycle ends in an error when every issue it read failed or timed out. The authentication preflight also runs under the limit; if it does not finish, the run fails as any failed preflight does.
  • Not marked breaking: no field, flag or default an adopter sets changes. A cycle that used to run past five minutes now stops early, by design.
  • 3 December: the two paragraphs this PR adds to the Jira guide are wrapped at about 80 columns, as docs/contributing/documentation.md asks. The text is unchanged.

Testing

  • make lint passes (stage changes first, then run)
  • Tests added/updated for new or modified logic
go test -race -count=3 ./internal/jirapoll/
go test -race -count=1 -run 'Jira|jira' ./internal/cli/ ./pkg/behaviourtest/... ./internal/poll/

All pass. Patch coverage on changed production lines: all but two, which are the existing search candidates error return, re-indented. The lines the two fix commits add are covered.

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes)
  • Commits are signed off (DCO) — human and human-directed agent sessions only
  • I wrote this contribution myself and can explain all changes in it

A lastCheck entity property that is not a timestamp made loadLastCheck
return an error, so processIssue failed the issue on every pick and
never saved a valid value. The activity filter keeps such an issue
active, so when it was the only active candidate every quiet cycle
ended in "all 1 selected issues failed to process".

Treat a value that is not a JSON string holding an RFC 3339 timestamp
as unset, as a future value already is. The issue gets one first-poll
look bounded by the backfill window, which saves a valid lastCheck.
Processing logs a WARNING naming the issue without the stored value,
and the filter's per-cycle line names such candidates. A failed read
is still an error.

Amend ADR 0160 Decision item 1, which said the per-issue error path
reports such a value, and update the Jira guide's security note.

Fixes fullsend-ai#9766

Signed-off-by: guy oron <goron@redhat.com>
Implements ADR 0085 Decision item 1. The managed GitHub workflow and
the managed GitLab schedule run one poll cycle at a time per
repository, so the lock never coordinated anything there.

- The driver neither reads nor writes the lock property and ignores
  locks left by earlier versions. filterLocked becomes filterActive,
  the activity filter alone. attemptLock, releaseLock, readLock,
  isLockStale, LockValue, Options.StaleThreshold and the jitter
  sleep go.
- Before reading an issue's comments and history, processIssue
  writes a writeCheck entity property to confirm the credential can
  write, as the lock write did. An issue that fails yields no records
  and the driver warns and goes on; a cycle in which every selected
  issue fails ends in the existing all-failed error. Idle candidates
  still cost no write.
- The "poll complete" line drops its unlocked count.
- The Jira guide, architecture overview and custom poller example
  describe the one-cycle-per-repository rule; the example gains a
  concurrency group.

BREAKING CHANGE: the jira-poll driver no longer locks issues. A
scheduler other than the managed GitHub workflow or GitLab schedule
must keep two poll cycles for one repository from overlapping, for
example with a GitHub Actions concurrency group; overlapping cycles
dispatch the same requests twice. Lock properties left by earlier
versions are ignored and can be deleted.

Signed-off-by: guy oron <goron@redhat.com>
…one unit

processIssue appended its dispatch records straight to the cycle's
list, and Run sliced them back out by index to pair them with the
issue's checkpoint. processIssue now returns a pendingCheckpoint that
holds both, and Run adds the records and the checkpoint to the cycle
together.

No behaviour changes. The per-cycle and per-issue limits of ADR 0085
Decision item 3 need this: an issue that does not fit in the room left
must be left out whole, records and checkpoint, for the next cycle.

Signed-off-by: guy oron <goron@redhat.com>
Implements the time limits of ADR 0085 Decision item 3.

- Run reads under a context that ends CycleTimeLimit (5m) after the
  cycle starts: the auth preflight, the search, the activity filter and
  the selected issues. Each issue is read under its own IssueTimeLimit
  (2m) context. Dispatching and committing checkpoints keep the caller's
  context, so they get the rest of the job's time.
- An issue over its limit is a failed read: a WARNING names it, none of
  its records are taken and its lastCheck stays, and the next issue is
  read. When the cycle limit is reached the issue being read and those
  not reached wait for the next cycle, and the cycle dispatches and
  commits what it finished and exits normally.
- A cycle that serves none of its selected issues fails: the existing
  "all N selected issues failed to process" error, or a new one when
  the cycle limit ended reading first.
- The Jira guide describes the limits.

Signed-off-by: guy oron <goron@redhat.com>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://3840eaea-site.fullsend-ai.workers.dev

Commit: e247b90e12ad7b33bb8c8f18c86497e81f4cf2d6

Review follow-up for the unparseable lastCheck fix.

- TestRunGarbageLastCheckTreatedAsUnset runs a full cycle for each way
  a stored value can fail: a string that is not a time, JSON that is
  not a string, and bytes that are not JSON. The first only reaches the
  time.Parse branch; the other two reach the json.Unmarshal branch.
- It asserts the saved lastCheck equals the issue's updated value
  instead of only being set.
- TestRunAllSelectedIssuesFailedFailsCycle restores coverage of Run's
  all-failed guard, which the replaced test was the only one to reach.

Signed-off-by: guy oron <goron@redhat.com>
Review follow-up for the lock removal.

- A denied issue keeps its lastCheck unset, so its request is retried;
  the served issue's lastCheck is committed.
- The write-check property holds an RFC 3339 time, and a served issue
  costs two property writes: the check and the lastCheck.
- TestRenderJiraPollCaller asserts the managed poll job's concurrency
  group and cancel-in-progress: false. With no per-issue lock, that
  group is what keeps two cycles from overlapping.
- The two filter tests are renamed from FilterLocked to FilterActive,
  and the mock's counter comment no longer refers to a lock.

Signed-off-by: guy oron <goron@redhat.com>
…heck

Review follow-up for the lock removal.

- Restore docs/architecture.md. main already describes the lock
  removal there (ADR 0085), and the edit here conflicted with it.
- The Jira guide says the write-check property stays on the issue and
  why it is not deleted, and that the poll job's concurrency group
  covers one workflow file, so a repository must not be polled from a
  second workflow. The custom poller example says the same.
- Three code comments no longer mention a Jira lock.

Signed-off-by: guy oron <goron@redhat.com>
…-records-unit

Signed-off-by: guy oron <goron@redhat.com>
…l-time-limits

Signed-off-by: guy oron <goron@redhat.com>
…ed out

Review follow-up for the cycle and per-issue time limits.

- When the caller's context ends, Run returns "poll cycle interrupted"
  with that error. It used to log that the cycle time limit was reached
  and return a time-limit error, because a cancelled read context looks
  the same as an expired one.
- The error for a cycle that the time limit ended with no issue served
  now reads "... reached with none of the N selected issues served
  (M tried)".
- The Jira guide no longer says a cycle can run long while reading
  under sustained Jira errors: retry waits count against the limits.

Signed-off-by: guy oron <goron@redhat.com>
…remove-lock

Signed-off-by: guy oron <goron@redhat.com>

# Conflicts:
#	docs/guides/user/jira-integration.md
…-records-unit

Signed-off-by: guy oron <goron@redhat.com>
…l-time-limits

Signed-off-by: guy oron <goron@redhat.com>

# Conflicts:
#	docs/guides/user/jira-integration.md
Review follow-up for the cycle and per-issue time limits. ADR 0085
Decision item 3 says that at the cycle limit the driver stops reading
and exits normally, and that a cycle ends in an error when every issue
it tried failed or timed out. Two cases did not follow it:

- A search that ran into the cycle limit failed the run. It now logs a
  WARNING, reads no issue and exits normally.
- An issue the cycle limit cut off counted as a failure, so a cycle
  that finished no issue always failed. It now waits for the next cycle
  without counting, and the cycle fails only when at least one issue
  failed or took longer than the per-issue limit and none was served.

The Jira guide describes both.

Signed-off-by: guy oron <goron@redhat.com>
…seable-lastcheck

Signed-off-by: guy oron <goron@redhat.com>
Signed-off-by: guy oron <goron@redhat.com>

# Conflicts:
#	internal/jirapoll/poller.go
#	internal/jirapoll/poller_test.go
Signed-off-by: guy oron <goron@redhat.com>

# Conflicts:
#	internal/jirapoll/poller.go
…in merge

The project-set refactor on main describes a processed issue as read
under the lock and its lock as kept single. The lock is gone on this
branch, so the test comment names the write-check property and the
uniqueIssues comment no longer lists a lock.

Signed-off-by: guy oron <goron@redhat.com>
Signed-off-by: guy oron <goron@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:06 PM UTC · Completed 11:19 PM UTC

Commit: b66e01c · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.64

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.50000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/jirapoll/poller.go 97.10% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Moderate risk reflects elevated churn, coupling, and unflagged timeout behavior modifications in core Jira poller logic, balanced by solid test coverage, clean CI and security metadata, and an active linked issue without risk labels.

@fullsend-ai-review

fullsend-ai-review Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Review

Findings

Low

  • [logic-error] internal/jirapoll/poller.go:124 — The authentication preflight runs under the cycle-limited context and fails the run on any error, including the five-minute limit expiring. The search step at line 139 instead warns and exits normally when the limit passes. The PR description says the preflight failure is intended, but the guide's "Time limits" paragraph lists the authentication check among the steps that count toward the five minutes and then says reaching the limit "is not a failure by itself". Reaching the limit in the preflight needs a /myself call or Retry-After waits of about five minutes, which is unusual.
    Remediation: Either state in the guide that a preflight cut off by the limit fails the run, or make the preflight warn and exit normally as the search does, with a test whose GetMyself blocks until its context ends.
  • [code-organization] internal/jirapoll/lock.go:1 — This PR removes all locking code from lock.go, but the file keeps its name. What remains is property-key derivation, the write-access check and the lastCheck checkpoints. A name such as checkpoint.go would match its contents.

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review
fullsend-ai-review Bot dismissed their stale review December 2, 2026 23:18

Superseded by updated review

…ble-lastcheck

Signed-off-by: guy oron <goron@redhat.com>
…remove-lock

Signed-off-by: guy oron <goron@redhat.com>
…-records-unit

Signed-off-by: guy oron <goron@redhat.com>
Every unparseable row of the filter's decision table had updated one
hour ago, inside the backfill window, where "treated as unset" and
"floored to the window start" give the same answer. The new row has
updated three days ago: unset keeps the issue active, while a floor
would drop it and leave the bad value stored.

Signed-off-by: guy oron <goron@redhat.com>
…remove-lock

Signed-off-by: guy oron <goron@redhat.com>
With the lock gone the driver deletes no entity property, so
DeleteEntityProperty leaves the JiraClient interface and the test mock.
A delete now fails to compile, which replaces the mock's delete counter.

TestRunIgnoresLegacyLock also fails if the legacy lock is read: until
now a filter that read it and skipped the issue on a read error passed.

Signed-off-by: guy oron <goron@redhat.com>
The jira-poll driver keeps no per-issue lock, so on GitLab the poll
job's resource group is what keeps two cycles apart. Nothing failed if
the template lost it.

Signed-off-by: guy oron <goron@redhat.com>
docs/architecture.md called the lock's removal a target state, and the
normalized-entity spec listed an operational lock among the properties
Fullsend keeps on an issue. The driver now writes a write-check
property instead.

Signed-off-by: guy oron <goron@redhat.com>
…-records-unit

Signed-off-by: guy oron <goron@redhat.com>
…l-time-limits

Signed-off-by: guy oron <goron@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 2:23 PM UTC · Completed 2:35 PM UTC

Commit: e247b90 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.35

@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Moderate risk reflects elevated churn, coupling, and unflagged timeout behavior modifications in core Jira poller logic, balanced by solid test coverage, clean CI and security metadata, and an active linked issue without risk labels.

@fullsend-ai-review

fullsend-ai-review Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Review

Findings

Low

  • [logic-error] internal/jirapoll/poller.go:124 — Still present: when GetMyself exhausts the cycle reading deadline, Run returns an authentication-preflight failure, while the same deadline during search or issue processing ends the cycle normally. A slow Jira response at preflight is reported as an authentication failure.
    Remediation: Distinguish the internal cycle-deadline expiry from genuine auth errors and caller cancellation; on the internal deadline emit the cycle-limit warning and finish with an empty batch; add a blocking-GetMyself test.
  • [code-organization] internal/jirapoll/lock.go:1 — Still present: after the per-issue lock removal the file holds only entity-property key helpers, the write-access check and lastCheck checkpoint routines, so the lock.go name is misleading.
    Remediation: Rename the file (for example checkpoint.go or properties.go).

Labels: PR changes Jira poller code, tests and user docs.

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:

  • internal/jirapoll/lock.go (file-level): Line 1 ·
    [low] code-organization

Still present: after the per-issue lock removal the file holds only entity-property key helpers, the write-access check and lastCheck checkpoint routines, so the lock.go name is misleading.

Suggested fix: Rename the file (for example checkpoint.go or properties.go).

@fullsend-ai-review
fullsend-ai-review Bot dismissed their stale review December 3, 2026 14:34

Superseded by updated review

myself, err := p.client.GetMyself(ctx)
myself, err := p.client.GetMyself(readCtx)
if err != nil {
return fmt.Errorf("authentication preflight failed: %w", err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] logic-error

Still present: when GetMyself exhausts the cycle reading deadline, Run returns an authentication-preflight failure, while the same deadline during search or issue processing ends the cycle normally. A slow Jira response at preflight is reported as an authentication failure.

Suggested fix: Distinguish the internal cycle-deadline expiry from genuine auth errors and caller cancellation; on the internal deadline emit the cycle-limit warning and finish with an empty batch; add a blocking-GetMyself test.

@fullsend-ai-review

Copy link
Copy Markdown

Finding threads left open (1):

  1. Thread: the explanation was posted in this older copy of a finding thread, but it could not be resolved. Reason: FORBIDDEN: Resource not accessible by integration. Next step: resolve it manually.

This branch was successfully deployed

1 active deployment
site-preview — e247b90e Deployed Dec 3, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation go Pull requests that update go code requires-manual-review Review requires human judgment risk/moderate PR risk: moderate testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants