Skip to content

Harden tag release dispatch - #790

Merged
haasonsaas merged 7 commits into
mainfrom
harden-tag-release-dispatch
Jun 18, 2026
Merged

haasonsaas merged 7 commits into
mainfrom
harden-tag-release-dispatch

Conversation

@haasonsaas

Copy link
Copy Markdown
Contributor

Summary

  • retry transient release-run listing and workflow dispatch failures
  • confirm a dispatched release workflow appears for the release tag before exiting
  • cover the retry and confirmation behavior in the tag-release workflow test

Source-of-truth: evalops/maestro-internal#2792

Verification

  • actionlint .github/workflows/tag-release.yml
  • node ./scripts/run-vitest.js --run test/workflows/tag-release.test.ts test/scripts/ci-guardrails.test.ts test/scripts/workflow-footguns.test.ts
  • bunx biome check .github/workflows/tag-release.yml test/workflows/tag-release.test.ts
  • npm run check:workflow-footguns
  • pre-commit release validators ran during commit

@cursor

cursor Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes only CI release orchestration, but a false confirmation failure could block releases until the workflow is fixed.

Overview
The dispatch-public-release job no longer fires gh workflow run once and exits. It wraps GitHub API calls in a shared retry() helper (three attempts with backoff) for listing active release runs, counting existing workflow_dispatch runs for the tag, and dispatching the release workflow.

After dispatch, it polls up to six times (10s apart) until the dispatched-run count increases; if no new run shows up, the step fails explicitly instead of succeeding silently. Helper functions active_release_run_count and dispatched_release_run_count replace inline gh run list snippets.

tag-release.test.ts assertions were updated to lock in the retry strings, confirmation loop, and workflow_dispatch jq filter.

Reviewed by Cursor Bugbot for commit 2fab074. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41863a19f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

exit 0
fi
gh workflow run release --repo "${GITHUB_REPOSITORY}" --ref "${RELEASE_TAG}" --field "version=${RELEASE_VERSION}"
retry "Dispatch release workflow" gh workflow run release --repo "${GITHUB_REPOSITORY}" --ref "${RELEASE_TAG}" --field "version=${RELEASE_VERSION}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recheck runs before retrying dispatch

When gh workflow run reaches GitHub but the CLI exits non-zero because of a transient response/connection failure, this retries a non-idempotent dispatch without checking whether the run was already created. The GitHub CLI manual says this command creates a workflow_dispatch event and triggers the workflow, and I checked .github/workflows/release.yml:16-18, where duplicate release runs for the same ref are queued rather than canceled; that can run the release pipeline twice for one tag and later fail or race on publishing the same npm version. Re-list for the tag before each dispatch retry instead of blindly retrying this command.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba6bdfe548

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread test/workflows/tag-release.test.ts Outdated
expect(dispatchStep?.run).toContain("release_run_count()");
expect(dispatchStep?.run).toContain("retry()");
expect(dispatchStep?.run).toContain(
'retry "List active release workflows" release_run_count',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fix stale release workflow test assertions

As committed, bunx vitest --run test/workflows/tag-release.test.ts fails because the workflow now calls active_release_run_count for the active-run check, but this new assertion still expects release_run_count; the same test also expects the old confirm/error strings below. This makes the workflow test suite fail on every CI run until the assertions are updated to match the YAML.

Useful? React with 👍 / 👎.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Tests assert wrong workflow strings
    • Updated the workflow test to assert the current helper names, retry label, and error text used by tag-release.yml.
  • ✅ Fixed: Capped list breaks dispatch confirmation
    • Changed dispatch confirmation to compare the latest matching run ID before and after dispatch instead of relying on a limited run-count window.

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit ba6bdfe. Configure here.

Comment thread test/workflows/tag-release.test.ts Resolved
Comment thread .github/workflows/tag-release.yml Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c897d23a29

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +194 to +195
--limit 50 \
--jq "[.[] | select(.headBranch == \"${RELEASE_TAG}\" and .event == \"workflow_dispatch\")] | length"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Track the dispatched run instead of comparing capped counts

In a redispatch for a tag that already has a previous workflow_dispatch release run near the 50-result cutoff, this capped count can stay unchanged: the new run enters the gh run list --limit 50 window while the old matching run falls out, so release_count > existing_count never becomes true and the job fails after successfully dispatching. Track the latest run id/createdAt, or use the run URL returned by gh workflow run, instead of confirming by count.

Useful? React with 👍 / 👎.

@haasonsaas
haasonsaas merged commit cc36964 into main Jun 18, 2026
14 checks passed
@haasonsaas
haasonsaas deleted the harden-tag-release-dispatch branch June 18, 2026 12:46
haasonsaas added a commit that referenced this pull request Jun 19, 2026
Resolve conflicts in .github/workflows/tag-release.yml and
test/workflows/tag-release.test.ts by taking main's hardened
dispatch confirmation (dispatched_release_run_count + dispatch_status
capture) from PR #790, which is the deliberately-merged source-of-truth
hardening (maestro-internal#2792). The mirror sync preserves public-owned
CI workflows per the PR's stated invariant.

Both Bugbot findings are addressed:
- Workflow test assertions now match the workflow YAML (dispatched_release_run_count).
- Stale cached telemetry enablement fixed via live shouldEnableTelemetry()
  checks (commits 8806287 + 7eaaff1 regression test), preserved through the merge.
haasonsaas added a commit that referenced this pull request Jun 19, 2026
Address review feedback on the public mirror sync:

1. src/telemetry.ts (codex-connector P2): the meter-only guard added in
   8806287 skipped the default file write whenever a remote meter
   destination was configured, but only canonical-turn events mirror to
   Meter. Non-canonical events (tool-execution, api-request,
   background-task) therefore had no sink and were silently dropped.
   Now skip the default file only for canonical turns when a meter
   destination is present; non-canonical events fall back to the default
   file. Regression test in test/telemetry/telemetry-meter.test.ts
   records a tool-execution event and asserts the default file captures
   it (and the meter endpoint is not called).

2. .github/workflows/tag-release.yml (Bugbot 0855fa3a): the count-based
   dispatch confirmation caps gh run list at --limit 50, so a tag that
   already has 50+ matching dispatched runs would not see the count
   increase on a new successful dispatch and the step would fail. Add a
   latest_dispatched_release_run_id() helper (highest databaseId, which
   is monotonic with creation time) and use it as the primary
   confirmation, with the count check retained as a fallback. This keeps
   PR #790's dispatch_status capture and count-based design intact while
   closing the capped-window edge case. Test assertions updated to lock
   in the new helper.
haasonsaas added a commit that referenced this pull request Jun 19, 2026
* chore: sync public mirror from internal

* [maestro] Fix release dispatch confirmation

* fix telemetry enablement refresh

* [maestro] Keep tag release dispatch test green

* [maestro] Restore latest run dispatch confirmation

* isolate telemetry oauth regression test

* fix(telemetry+ci): keep non-turn telemetry and harden dispatch confirm

Address review feedback on the public mirror sync:

1. src/telemetry.ts (codex-connector P2): the meter-only guard added in
   8806287 skipped the default file write whenever a remote meter
   destination was configured, but only canonical-turn events mirror to
   Meter. Non-canonical events (tool-execution, api-request,
   background-task) therefore had no sink and were silently dropped.
   Now skip the default file only for canonical turns when a meter
   destination is present; non-canonical events fall back to the default
   file. Regression test in test/telemetry/telemetry-meter.test.ts
   records a tool-execution event and asserts the default file captures
   it (and the meter endpoint is not called).

2. .github/workflows/tag-release.yml (Bugbot 0855fa3a): the count-based
   dispatch confirmation caps gh run list at --limit 50, so a tag that
   already has 50+ matching dispatched runs would not see the count
   increase on a new successful dispatch and the step would fail. Add a
   latest_dispatched_release_run_id() helper (highest databaseId, which
   is monotonic with creation time) and use it as the primary
   confirmation, with the count check retained as a fallback. This keeps
   PR #790's dispatch_status capture and count-based design intact while
   closing the capped-window edge case. Test assertions updated to lock
   in the new helper.

* fix(ci): guard jq max_by against empty dispatched-run array

Bugbot (0855fa3a, high severity) on 8b9dc84: latest_dispatched_release_run_id()
used max_by(.databaseId).databaseId with // "" fallback. While // catches
the max_by error in some jq builds, it can propagate non-zero under
set -euo pipefail in CI when no workflow_dispatch runs exist for the tag
yet, aborting the step before a new release can be dispatched.

Replace with an explicit length guard:
  if length == 0 then "" else (max_by(.databaseId).databaseId | tostring) end

Verified empty/no-match/match cases all return rc=0. The tostring ensures
consistent string output for bash comparison.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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.

2 participants