Skip to content

fix(review): replace the live in-flight dispatch check with a persisted R2 marker - #4133

Merged
JSONbored merged 1 commit into
mainfrom
4112-dispatch-marker-followup
Jul 8, 2026
Merged

fix(review): replace the live in-flight dispatch check with a persisted R2 marker#4133
JSONbored merged 1 commit into
mainfrom
4112-dispatch-marker-followup

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Follow-up to feat(review): GitHub-Actions build-and-serve visual-capture fallback #4131 (merged): the gittensory review on that PR flagged that hasInFlightFallbackDispatch's live GitHub runs-API query has a real eventual-consistency gap — a freshly-dispatched run isn't guaranteed to be visible via that API the instant dispatch returns, so a recapture-poll landing in that narrow window could still redispatch and get itself cancelled by the workflow's own concurrency: cancel-in-progress: true group.
  • Replaces the live query with a persisted R2 sentinel (isFallbackDispatchInFlight/markFallbackDispatched/clearFallbackDispatchMarker), written synchronously right after a successful dispatch (no API round-trip to race against), cleared by the workflow_run webhook handler on ANY conclusion (success/failure/cancelled/timed_out — not just success, so a genuinely failed run doesn't block a retry for the rest of the window), and self-expiring after the workflow's 15-minute timeout-minutes (+ a queueing buffer) as a fail-safe if a webhook delivery is ever lost.
  • Both write helpers use a real try/catch rather than .catch() on the R2 call's return value — a minimal/partial R2Bucket implementation that doesn't implement a given method throws synchronously at the call site, before .catch() would even attach. Caught this via a test-mock gap while writing regression tests, not from a production report.

Scope

Validation

  • git diff --check
  • npm run typecheck
  • Targeted tests: test/unit/actions-fallback.test.ts, test/unit/actions-fallback-webhook.test.ts, test/unit/visual-capture.test.ts, test/unit/visual-config-wiring.test.ts, test/unit/focus-manifest.test.ts, test/unit/queue.test.ts — all 1411 tests pass.
  • Scoped coverage on the two changed source files: actions-fallback.ts 100% stmts/branch/funcs/lines; capture.ts's one uncovered line (236) is pre-existing, unrelated code this PR didn't touch.
  • npm run test:workers, build:mcp, test:mcp-pack, ui:openapi:check, ui:lint, ui:typecheck, ui:build, npm audit — not re-run locally for this exact commit (none of these files touch the OpenAPI/MCP/UI surfaces); CI runs them authoritatively.

Safety

  • No secrets, wallet/hotkey/trust-score/reward data anywhere.
  • No auth/cookie/CORS/session changes.
  • No API/OpenAPI/MCP surface touched.
  • No UI changes (backend only) — no UI Evidence section needed.
  • No docs/changelog changes needed.

Notes

  • Default-off feature (review.visual.actions_fallback), unaffected by this change either way — this only hardens the dispatch guard's own internal correctness.

…ed R2 marker

The prior fix queried GitHub's own runs API right before dispatching, which
has a real gap: a freshly-dispatched run isn't guaranteed to be visible via
that API the instant dispatch returns, so a poll landing in that window could
still redispatch and cancel the in-flight run. A persisted marker written
synchronously on a successful dispatch, cleared on the webhook_run completion
(any conclusion), and self-expiring after the workflow's 15-minute timeout
closes that gap without depending on API eventual consistency.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 8, 2026
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.71%. Comparing base (ca3f8ab) to head (2a93f21).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4133   +/-   ##
=======================================
  Coverage   93.71%   93.71%           
=======================================
  Files         385      385           
  Lines       36195    36207   +12     
  Branches    13263    13265    +2     
=======================================
+ Hits        33919    33932   +13     
  Misses       1618     1618           
+ Partials      658      657    -1     
Files with missing lines Coverage Δ
src/queue/processors.ts 95.18% <100.00%> (+<0.01%) ⬆️
src/review/visual/actions-fallback.ts 100.00% <100.00%> (+0.69%) ⬆️
src/review/visual/capture.ts 91.03% <100.00%> (+0.18%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit b8a1ba4 into main Jul 8, 2026
10 checks passed
@JSONbored
JSONbored deleted the 4112-dispatch-marker-followup branch July 8, 2026 07:11
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Development

Successfully merging this pull request may close these issues.

1 participant