Skip to content

feat(jirapoll): take each candidate's lastCheck from the search results - #9876

Draft
guyoron1 wants to merge 76 commits into
fullsend-ai:mainfrom
guyoron1:feat/jirapoll-search-checkpoint
Draft

guyoron1 wants to merge 76 commits into
fullsend-ai:mainfrom
guyoron1:feat/jirapoll-search-checkpoint

Conversation

@guyoron1

@guyoron1 guyoron1 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Jira search now returns each candidate's lastCheck entity property with its row, and the activity filter compares updated with that value instead of reading the property with one call per candidate. Processing still reads lastCheck from the issue, as ADR 0085 Decision item 2 requires ("That value is used only to skip idle issues"). This removes the per-candidate cost before AISDLC-880 lifts the row limit.

Draft because it is stacked on #9855 → #9854 → #9853 → #9852. #9758 has merged, so the base is now main. Its own changes are the commits feat(jirapoll): take each candidate's lastCheck…, fix(jiramock): serve a search whose body cannot be read… and refactor(jirapoll): parseLastCheck cannot fail…; everything else in the diff belongs to the PRs below it. Jira: AISDLC-879.

Related Issue

Part of #9751

Changes

  • internal/forge/jira: SearchIssues(ctx, jql, limit, properties ...string) sends the properties list of POST /rest/api/3/search/jql and decodes each row's properties object into the new Issue.Properties. Without names it sends none, as before.
  • internal/jirapoll:
    • searchCandidates asks for p.lastCheckKey() (GitHub or GitLab namespace).
    • parseLastCheck is split out of loadLastCheck (same parse and clamps); hasNewActivity parses the row's value with it. It fails open as before: a row without the property, or with a value that is not a timestamp, is active. With fix(jirapoll): treat an unparseable lastCheck as unset #9852 below it in the stack such a value is unset, not an error, so parseLastCheck returns no error.
    • filterActive and hasNewActivity no longer take a context, since they make no call.
  • pkg/behaviourtest/drivers/jiramock: the search returns the requested properties an issue has, as Jira does; a search naming none, or with a body the mock cannot read, is served as before.
  • Tests:
    • TestSearchIssues_Properties (client): the request carries the names on every call and the response decodes; no names, no properties key.
    • TestRunTakesLastCheckFromSearch: the poller asks for exactly the lastCheck key, an idle candidate costs no property read, and a picked one is still read from the issue.
    • TestFilterActiveDecision feeds the value through the row and fails on any property read; the "read fails" row goes (there is no read to fail). The GitLab key test does the same.
    • TestSearchReturnsRequestedProperties (jiramock). Both test mocks now return requested properties like Jira.
  • Docs: the Jira guide's activity-filter and cost text; a jiramock change note in the behaviour-testing guide.

Notes for review:

  • Live check done by Dharit. Atlassian's OpenAPI spec documents properties on POST /rest/api/3/search/jql ("A list of up to 5 issue properties to include in the results") and properties on each returned issue ("Details of the issue properties identified in the request"). I could not run it against a Jira Cloud site from here; the comment of 30 November reports one run on a Jira Cloud site: each row came back with its stored value, a ticket without the property came back with an empty properties object, and a write showed in the next search. If a site ignored the parameter, every row would lack the property and every candidate would be active, which is the pre-ADR 0160 behaviour, not a loss.
  • fix(jirapoll): treat an unparseable lastCheck as unset #9852 (AISDLC-875) is in the stack below this PR, so the two changes to the lastCheck parsing are already combined here.
  • SearchIssues is called only by the poller (and tests), so the variadic parameter changes no other caller.

Testing

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

All pass. Patch coverage on changed production lines: 28/28.

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>
Implements the checkpoint clause of ADR 0085 Decision item 2. The
activity filter read every candidate's lastCheck property with its own
call; the search now returns it with each row, so the filter makes no
call of its own. Processing still reads lastCheck from the issue.

- jira.LiveClient.SearchIssues takes the names of entity properties to
  return (the search/jql "properties" parameter) and decodes them into
  the new Issue.Properties.
- searchCandidates asks for the target's lastCheck key. hasNewActivity
  parses the row's value with the new parseLastCheck, split out of
  loadLastCheck, and fails open as before: a row without the property,
  or with one that does not parse, is active. filterActive and
  hasNewActivity drop their context argument.
- jiramock's search returns the requested properties an issue has, as
  Jira does.
- The Jira guide and the behaviour-testing guide describe the change.

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

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://75f3d94d-site.fullsend-ai.workers.dev

Commit: ead3b82016b90b4f00c8d8c8ac6c1e9c97975ebf

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>
…eckpoint

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

# Conflicts:
#	internal/jirapoll/poller_idle_test.go
Review follow-up for taking lastCheck from the search results.

- The mock's search answered 400 to a body it could not decode. It
  ignored the body before, so it now treats such a body as naming no
  properties.
- The multi-repo section of the Jira guide no longer says each poller
  reads an entity property per candidate; the search returns it.

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>
…eckpoint

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

# Conflicts:
#	docs/guides/user/jira-integration.md
With the unparseable-lastCheck fix merged in, a stored value that is
not a timestamp is treated as unset instead of returning an error, so
parseLastCheck has no error left to return. Drop the return value and
the branch in hasNewActivity that checked it.

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
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
internal/jirapoll/poller.go 97.26% 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

Preserved moderate risk score as Tier 1 signals remain unchanged following a documentation reflow, with zero protected or security-sensitive paths, no CI or dependency changes, solid test coverage, and alignment with linked issue #9751 despite active poller component churn.

@fullsend-ai-review

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

Copy link
Copy Markdown

Review

Findings

Low

  • [architectural-conflict] docs/ADRs/0160-spend-jira-poll-slots-only-on-candidates-with-new-activity.md:288 — The PR appends an ## Amendments entry (2026-11-25, Jira poller: an unparseable lastCheck fails every quiet poll cycle #9766) to ADR 0160, which is Accepted on main. The entry changes how Decision item 1 handles an unparseable checkpoint (treated as unset instead of going to the per-issue error path). The Context, Decision and Consequences text is not rewritten, and the same ## Amendments pattern already exists on main (ADR 0070 line 250, ADR 0038 line 384), but docs/contributing/adrs.md still points to a new superseding ADR when a decision changes and asks that edits to accepted ADRs be called out in the PR description.
    Remediation: Call out the edit to ADR 0160 in the PR description; if maintainers see it as a decision change rather than an annotation, move it to a new ADR and leave a cross-reference note in 0160.
  • [api-shape] internal/jirapoll/types.go:30 — JiraClient still declares DeleteEntityProperty, but no non-test code in internal/jirapoll calls it now that per-issue locks are removed. Consumer-defined interfaces should declare only the methods the consuming package needs.
    Remediation: Remove DeleteEntityProperty from the JiraClient interface and the unused mock method in poller_test.go.

Earlier findings

  • docs/ADRs/0160-spend-jira-poll-slots-only-on-candidates-with-new-activity.md:288, architectural-conflict — reclassified medium → low: the base repo already carries post-acceptance ## Amendments sections that add behaviour changes (ADR 0070:250, ADR 0038:384), and this PR only appends a short dated note without rewriting the Decision text.

@fullsend-ai-review
fullsend-ai-review Bot dismissed stale reviews from themself December 2, 2026 23:24

Superseded by updated review

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review

Copy link
Copy Markdown

Finding threads left open (4):

  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.
  2. 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.
  3. 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.
  4. 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.

@fullsend-ai-review fullsend-ai-review Bot added the requires-manual-review Review requires human judgment label Dec 2, 2026
…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>
…eckpoint

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:36 PM UTC

Commit: ead3b82 · View workflow run →

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

@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Preserved moderate risk score as Tier 1 signals remain unchanged with zero protected or security-sensitive paths, no CI or dependency modifications, solid test coverage (0.40), and alignment with linked issue #9751 despite poller component churn.

@fullsend-ai-review

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

Copy link
Copy Markdown

Looks good to me

Earlier findings

  • internal/jirapoll/types.go:30, api-shape, resolved: DeleteEntityProperty is no longer part of the JiraClient interface.
  • docs/ADRs/0160-spend-jira-poll-slots-only-on-candidates-with-new-activity.md:288, architectural-conflict, reclassified to info: the dated Amendments entry appends to the ADR without rewriting Context, Decision or Consequences, and accepted ADRs 0038 and 0070 already use the same pattern.

No findings at or above low severity; 1 lower-severity finding(s) were not posted.

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

Superseded by updated review

@fullsend-ai-review

Copy link
Copy Markdown

Finding threads left open (4):

  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.
  2. 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.
  3. 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.
  4. 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 — ead3b820 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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants