Skip to content

ci(#9128): harden behaviour-test dispatch and jobs-listing reads - #9129

Merged
rh-hemartin merged 2 commits into
mainfrom
agent/9128-dispatch-jobs-reliability
Nov 6, 2026
Merged

rh-hemartin merged 2 commits into
mainfrom
agent/9128-dispatch-jobs-reliability

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Re-lands the behaviour-test dispatch-assertion and jobs-listing reliability work that #9084 carried and then reverted in 7fae148f7, which called it scope drift. This change is the exact inverse of that revert. It applies cleanly to current main. The other differences between #9084 and main in these files are trace-context ID and Jira changes, and they are left out.

Related Issue

Split from #9084. Related: #9124 (root cause of the first-page jobs 404), #8142 (earlier hardening of the CountHarnessDispatches callers).

Changes

Forge layer (internal/forge/)

  • WorkflowRun.RunAttempt and WorkflowJob.RunAttempt. The GitHub adapter fills them from run_attempt in every workflow-run and jobs read.
  • New sentinel forge.ErrJobsListingNotFoundFirstPage. The GitHub and GitLab ListWorkflowRunJobs adapters attach it only when page 1 returns not-found. A 404 on a later page never carries it. GitHub listing errors now name the repository, run ID, and page.

GitHub Actions behaviour driver (pkg/behaviourtest/drivers/ci/githubactions/)

  • settleHarnessDispatchCount and AssertNoHarnessAgentArtifact list runs with the paginated listHarnessRunsAfterPaginated and ignore completed/skipped runs.
  • Runs that have not started (queued/requested/pending) count as pending, and their jobs are never read.
  • classifyJobsError(status, err) sorts listing errors into skip, retryLater, or fatal, in one place for both paths. The count path keeps skip and retryLater runs pending. The one-shot negative assertion skips only runs that have not started and fails closed in every other case.
  • CountHarnessDispatches keeps a per-assertion cache of completed job listings. A listing is cached only when it has a decisive counted agent match (a non-empty conclusion that is not skipped or cancelled) and every job belongs to the run's known attempt.
  • docs/contributing/forge-abstraction.md documents the workflow-attempt fields and the cache's reuse rules.

Testing

  • go build ./... and go vet ./... pass.
  • go test -race passes for ./internal/forge/, ./internal/forge/github/, ./internal/forge/gitlab/, and ./pkg/behaviourtest/drivers/ci/githubactions/.
  • Coverage: runUnstarted, classifyJobsError, settleHarnessDispatchCount, CountHarnessDispatches, and GitHub ListWorkflowRunJobs are at 100%. AssertNoHarnessAgentArtifact is at 93.3%.
  • Tests restored or added: dispatch_reads_test.go (request counts, skipped runs, jobs reads for runs that have not started, classifyJobsError table, waiting runs, completed-job cache, fatal errors), workflow_attempt_test.go, the GitHub and GitLab first-page and later-page 404 sentinel tests, and the pagination test for dispatch assertions.
  • Pre-commit hooks, run by hand: the sandbox can't fetch the remote hook repositories, so I ran each hook's tool directly on the changed files. pre-commit-hooks v6.0.0 (end-of-file, trailing-whitespace, private-key, merge-conflict, mixed-line-ending, large-files), gofmt, go vet ./..., lint-broken-symlinks, lint-docs-links, and lychee all passed, and the secret scan was clean. pre-commit run / make lint itself did not run.

Checklist

🤖 Generated with Claude Code


Closes #9128

Post-script verification

  • Branch is not main/master (agent/9128-dispatch-jobs-reliability)
  • Secret scan passed (gitleaks — 7d0eb20c443064d1f5ddb9d0ad9f191cfdd6f9cf..HEAD)
  • PR body secret scan passed (gitleaks — no-git)
  • Final PR description secret scan passed (gitleaks — no-git)

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 4:52 PM UTC · Completed 5:01 PM UTC

Commit: 3b177d8 · View workflow run →

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

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://628bb8bc-site.fullsend-ai.workers.dev

Commit: ae9b74024bc8a0df7ac7c81e40a41a30ec273e86

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Nov 5, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Preserving moderate risk score of 2: elevated git churn and change coupling across touched forge files are balanced by strong test coverage (50% test file ratio), zero protected or security-sensitive paths, and exact scope alignment with linked issue #9128.

Previous run

Risk Assessment: moderate (2/5)

Details

Preserving moderate risk score of 2: high git churn and change coupling on core forge files are balanced by strong test coverage (50% test file ratio), zero protected or security-sensitive paths, and exact scope alignment with linked issue #9128.

Previous run (2)

Risk Assessment: moderate (2/5)

Details

Moderate risk: large change size and high git churn/coupling on core forge files are balanced by strong test coverage (50% test files), zero protected or security-sensitive paths, and exact scope alignment with linked issue #9128.

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Review

Findings

Low

  • [edge-case] pkg/behaviourtest/drivers/ci/githubactions/githubactions.go:1809 — The paginated exact-count path counts duplicate run IDs independently. ListWorkflowRunsSince fetches numbered pages of a newest-first listing and does not deduplicate. If a run is created between the page 1 and page 2 fetches, the last entry of page 1 can reappear on page 2. If that run holds a completed matching agent job, it is counted twice. This needs more than 100 in-window harness runs plus a concurrent new run, so it is unlikely.
    Remediation: Deduplicate by workflow run ID in ListWorkflowRunsSince or listHarnessRunsAfterPaginated, and add a regression test where a newer run shifts the boundary between page fetches.
  • [naming-convention] pkg/behaviourtest/drivers/ci/githubactions/githubactions.go:1837 — In settleHarnessDispatchCount, for _, job := range jobs shadows the matched agent job from hasJob, job := matchAgentJob(jobs, agent) (line 1832). The matched job is used in the switch right after the cache block.
    Remediation: Rename the loop variable to j.

Earlier findings

  • pkg/behaviourtest/drivers/ci/githubactions/dispatch_reads_test.go:167, doc-style — resolved; the doc comment now sits next to its test function.
  • internal/forge/forge.go:262, code-organization — resolved; ErrJobsListingNotFoundFirstPage now follows IsNotFound.

Labels: PR changes Go behaviour-test driver and forge CI listing code.

Previous run

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJhcHByb3ZlIiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJkb2Mtc3R5bGUiLCJmaWxlIjoicGtnL2JlaGF2aW91cnRlc3QvZHJpdmVycy9jaS9naXRodWJhY3Rpb25zL2Rpc3BhdGNoX3JlYWRzX3Rlc3QuZ28iLCJpZCI6ImZfMTU3MWQ0M2VmODNhNjBmZSIsImxpbmUiOjE2NywiYWN0aW9uYWJsZSI6dHJ1ZSwiZGltZW5zaW9uIjoic3R5bGUtY29udmVudGlvbnMifSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJjb2RlLW9yZ2FuaXphdGlvbiIsImZpbGUiOiJpbnRlcm5hbC9mb3JnZS9mb3JnZS5nbyIsImlkIjoiZl8wZjE1ZDIwNjM4MWNlNTM2IiwibGluZSI6MjYyLCJhY3Rpb25hYmxlIjpmYWxzZSwiZGltZW5zaW9uIjoic3R5bGUtY29udmVudGlvbnMifV0sImRpc3Bvc2l0aW9ucyI6W3siaWQiOiJmXzE1NzFkNDNlZjgzYTYwZmUiLCJzdGF0dXMiOiJyZXNvbHZlZF9ieV9jaGFuZ2UifSx7ImlkIjoiZl8wZjE1ZDIwNjM4MWNlNTM2Iiwic3RhdHVzIjoicmVzb2x2ZWRfYnlfY2hhbmdlIn1dfQ== -->

Looks good to me

Earlier findings

  • pkg/behaviourtest/drivers/ci/githubactions/dispatch_reads_test.go:167, doc-style, resolved: the doc comment now sits directly above TestCountHarnessDispatches_WaitingRunHoldsCompletedAgentJob.
  • internal/forge/forge.go:262, code-organization, resolved: IsNotFound now follows ErrNotFound, and ErrJobsListingNotFoundFirstPage comes after it.
Previous run (2)

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImRvYy1zdHlsZSIsImZpbGUiOiJwa2cvYmVoYXZpb3VydGVzdC9kcml2ZXJzL2NpL2dpdGh1YmFjdGlvbnMvZGlzcGF0Y2hfcmVhZHNfdGVzdC5nbyIsImlkIjoiZl8xNTcxZDQzZWY4M2E2MGZlIiwibGluZSI6MTY3LCJhY3Rpb25hYmxlIjp0cnVlLCJkaW1lbnNpb24iOiJzdHlsZS1jb252ZW50aW9ucyJ9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImNvZGUtb3JnYW5pemF0aW9uIiwiZmlsZSI6ImludGVybmFsL2ZvcmdlL2ZvcmdlLmdvIiwiaWQiOiJmXzBmMTVkMjA2MzgxY2U1MzYiLCJsaW5lIjoyNjIsImFjdGlvbmFibGUiOmZhbHNlLCJkaW1lbnNpb24iOiJzdHlsZS1jb252ZW50aW9ucyJ9XX0= -->

Review

Findings

Low

  • [doc-style] pkg/behaviourtest/drivers/ci/githubactions/dispatch_reads_test.go:167 — The doc comment for TestCountHarnessDispatches_WaitingRunHoldsCompletedAgentJob (lines 167-170) sits directly above TestClassifyJobsError's own doc comment, so godoc merges them into one block. The test it describes (line 205) has no doc comment.
    Remediation: Move lines 167-170 to immediately precede func TestCountHarnessDispatches_WaitingRunHoldsCompletedAgentJob.
  • [code-organization] internal/forge/forge.go:262 — ErrJobsListingNotFoundFirstPage is placed between ErrNotFound and IsNotFound, splitting a sentinel/predicate pair that stays adjacent for every other sentinel in the file.
    Remediation: Move the sentinel below func IsNotFound.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 5:03 PM UTC · Completed 5:09 PM UTC

Commit: 3b177d8 · View workflow run →

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

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

fullsend-ai-coder Bot added a commit that referenced this pull request Nov 5, 2026
Move the count-side test doc comment next to its test function so godoc
no longer merges it with TestClassifyJobsError, and place
ErrJobsListingNotFoundFirstPage after IsNotFound so the ErrNotFound
sentinel/predicate pair stays adjacent.

Note: pre-commit could not fetch remote hook repositories (certificate
verification failure); the applicable hooks (whitespace check, gofmt,
go vet) were run directly and passed.

Addresses #9129

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (bot-triggered)

Addressed both low-severity review findings (doc comment placement and sentinel ordering). Pure code movement, no behaviour change; affected package tests and go vet pass.

Fixed (2):

  1. Doc comment for the count-side waiting-run test sits above TestClassifyJobsError and merges with its godoc (pkg/behaviourtest/drivers/ci/githubactions/dispatch_reads_test.go): Moved the misplaced doc comment to directly precede TestCountHarnessDispatches_WaitingRunHoldsCompletedAgentJob.
  2. ErrJobsListingNotFoundFirstPage splits the ErrNotFound/IsNotFound sentinel-predicate pair (internal/forge/forge.go): Moved the new sentinel (with its doc comment) below IsNotFound so ErrNotFound and IsNotFound are adjacent again.

Tests: passed

CI inspections (5):

  1. test (CI) (pending, in_progress): Still running at inspection time; no failure observed.
  2. behaviour (E2E Tests) (pending, in_progress): Still running at inspection time.
  3. playback (E2E Tests) (pending, in_progress): Still running at inspection time.
  4. commit-lint, web, gateway-doc-configs, test-sandbox-darwin (CI) (passing, success): Passed.
  5. pr-title-lint, vouch-gate, DCO, build site (passing, success): Passed.

Conflict update: skipped; strategy none; forge MERGEABLE; target main

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:11 PM UTC · Completed 5:18 PM UTC

Commit: 76ca703 · View workflow run →

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

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Nov 5, 2026
@rh-hemartin
rh-hemartin enabled auto-merge November 6, 2026 10:40
@rh-hemartin
rh-hemartin disabled auto-merge November 6, 2026 10:40
@rh-hemartin rh-hemartin added the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Nov 6, 2026
Re-land the behaviour-test reliability slice that #9084 carried and
then reverted in 7fae148 as scope drift. This commit is the inverse
of that revert, which applies cleanly to main; the other differences
between #9084 and main in these files belong to the trace-context work
and are not included.

Forge layer:
- Add RunAttempt to WorkflowRun and WorkflowJob, populated by the
  GitHub adapter from run_attempt.
- Add ErrJobsListingNotFoundFirstPage. The GitHub and GitLab
  ListWorkflowRunJobs adapters attach it only to a page-1 not-found
  (the shape tracked in #9124). GitHub errors now name the
  repository, run, and page.

GitHub Actions behaviour driver:
- settleHarnessDispatchCount and AssertNoHarnessAgentArtifact list
  runs through the paginated, time-bounded listing and ignore
  skipped runs.
- Runs that have not started (queued/requested/pending) are counted
  as pending without reading their jobs.
- classifyJobsError(status, err) maps listing errors to skip,
  retryLater, or fatal for both paths. The count path keeps skip and
  retryLater runs pending; the one-shot negative path skips only
  runs that have not started and fails closed otherwise.
- CountHarnessDispatches caches a completed run's jobs across polls
  only when a decisive counted agent match exists and every job
  belongs to the run's known attempt.

Tests: dispatch_reads_test.go and workflow_attempt_test.go come back
with the original regressions. Added cases in github_test.go,
methods_test.go, and githubactions_test.go cover first-page vs
later-page 404s and the error context.

Closes #9128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the count-side test doc comment next to its test function so godoc
no longer merges it with TestClassifyJobsError, and place
ErrJobsListingNotFoundFirstPage after IsNotFound so the ErrNotFound
sentinel/predicate pair stays adjacent.

Note: pre-commit could not fetch remote hook repositories (certificate
verification failure); the applicable hooks (whitespace check, gofmt,
go vet) were run directly and passed.

Addresses #9129

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:40 AM UTC · Completed 11:57 AM UTC

Commit: ae9b740 · View workflow run →

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

@fullsend-ai-review fullsend-ai-review Bot removed the ready-for-merge All reviewers approved — ready to merge label Nov 6, 2026
@fullsend-ai-review
fullsend-ai-review Bot dismissed their stale review November 6, 2026 11:57

Superseded by updated review

@fullsend-ai-review fullsend-ai-review Bot added ready-for-merge All reviewers approved — ready to merge component/e2e End-to-end tests go Pull requests that update go code labels Nov 6, 2026
@rh-hemartin
rh-hemartin enabled auto-merge November 6, 2026 12:29
@rh-hemartin
rh-hemartin added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 7c9f11f Nov 6, 2026
75 checks passed
@rh-hemartin
rh-hemartin deleted the agent/9128-dispatch-jobs-reliability branch November 6, 2026 13:05

This branch was successfully deployed

1 active and 1 inactive deployments
site-preview — ae9b7402 Deployed Nov 6, 2026 by github-actions[bot]
dev — ae9b7402 Deployed Nov 6, 2026 by rh-hemartin via behaviour #19075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/e2e End-to-end tests go Pull requests that update go code ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

behaviourtest: dispatch-assertion and jobs-listing reliability (split from #9084)

2 participants