Skip to content

fix(review): repair stale gate-check publication state - #2351

Merged
JSONbored merged 6 commits into
mainfrom
codex/fix-metagraphed-surface-context
Jul 1, 2026
Merged

fix(review): repair stale gate-check publication state#2351
JSONbored merged 6 commits into
mainfrom
codex/fix-metagraphed-surface-context

Conversation

@JSONbored

@JSONbored JSONbored commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix stale AI-review cache inputs so review results are keyed by the current review context.
  • Persist successful Gate check publication into local check summaries.
  • Repair scheduled sweep recovery so all current-head PRs missing the required Gate check are re-reviewed, even when ordinary stale maintenance is backpressured.

What changed

  • Adds a dedicated AI review cache input fingerprint module and tests.
  • Records local Gittensory Orb Review Agent summaries after publishing Gate checks.
  • Treats missing current Gate checks as repair-priority sweep candidates.
  • Lets repair-priority candidates bypass the webhook freshness skip and expand beyond the normal stale-maintenance cap.
  • Keeps the normal low sweep cap and backlog deferral for ordinary stale maintenance.
  • Adds regressions for cache invalidation, Gate summary persistence, missing-check repair priority, backlog bypass for repair, and healthy fresh PR no-op behavior.

Why

Required Gate checks could remain in GitHub as Expected — Waiting for status to be reported when local publication state was stale or a webhook was missed. The scheduler also repaired only a small stale batch per pass, so one repo could leave current-head required statuses stranded behind unrelated maintenance backlog.

Validation

  • npx vitest run test/unit/agent-sweep.test.ts test/unit/queue.test.ts test/unit/ai-review-cache.test.ts
  • npm run typecheck
  • git diff --check
  • Scoped coverage run completed all focused tests; changed-source LCOV check found no missed coverable changed lines and no changed-branch misses in the touched source files.

Notes

  • The normal stale sweep cap remains in place for rate-limit safety. Only missing current Gate checks use the expanded repair batch.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.78%. Comparing base (385990b) to head (ede5fa1).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2351      +/-   ##
==========================================
+ Coverage   95.73%   95.78%   +0.05%     
==========================================
  Files         223      224       +1     
  Lines       24755    24917     +162     
  Branches     8970     9056      +86     
==========================================
+ Hits        23699    23867     +168     
+ Misses        433      428       -5     
+ Partials      623      622       -1     
Files with missing lines Coverage Δ
src/db/repositories.ts 96.30% <100.00%> (+<0.01%) ⬆️
src/queue/processors.ts 91.07% <100.00%> (+0.85%) ⬆️
src/review/ai-review-cache-input.ts 100.00% <100.00%> (ø)
src/settings/agent-sweep.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored force-pushed the codex/fix-metagraphed-surface-context branch from d7eb457 to 7149942 Compare July 1, 2026 11:17
@JSONbored JSONbored changed the title fix(review): pin metagraphed surface context fix(review): invalidate stale ai review cache inputs Jul 1, 2026
@loopover-orb

loopover-orb Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-01 19:21:29 UTC

8 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review

Review summary
The cache fingerprinting change correctly stops reusing AI-review rows when prompt/config inputs change, and the sweep now has a clear repair path for missing current Gate checks. The highest-risk regression is in public-surface completion: a successful Gate check is now counted as a published output, so configured comment/label failures can be stamped as complete and hidden from later repair. The backlog bypass also has an edge case where non-actionable priority PRs can enlarge the repair cap and pull ordinary stale work into a draining backlog.

Blockers

  • src/queue/processors.ts:5813 and src/queue/processors.ts:5135 treat a published Gate check as sufficient output for finishPublicSurfacePublication, so in a comment_only or label_only repo where the Gate check succeeds but the configured comment/label write fails, markPullRequestSurfacePublished still stamps the head and the sweep will no longer repair the missing configured surface.
  • src/queue/processors.ts:1350 computes repairCandidateLimit from raw priorityPullNumbers.length before src/settings/agent-sweep.ts:72 filters drafts, so an open draft that is marked priority can inflate the backlog-bypass cap and let an ordinary stale PR enqueue while per-PR backlog is active.
Nits — 6 non-blocking
  • nit: src/review/ai-review-cache-input.ts:68 preserves changedPaths order in the fingerprint, so equivalent file sets can miss the cache if the upstream file listing order changes.
  • nit: src/queue/processors.ts:5813 duplicates the same recordPublishedGateCheckSummary catch-and-log block across the primary and fallback Gate publication paths, which makes future changes easy to apply inconsistently.
  • In src/queue/processors.ts:5135, make finishPublicSurfacePublication require all configured non-Gate public outputs to succeed before stamping lastPublishedSurfaceSha, or keep Gate publication out of publishedOutputs and track it separately.
  • In src/queue/processors.ts:1350, derive the backlog repair cap from PRs that selectRegateCandidates can actually enqueue, such as open non-draft priority PRs, rather than from the raw priority number set.
  • In src/review/ai-review-cache-input.ts:68, sort changedPaths before hashing unless review file order is intentionally model-visible and must invalidate the cache.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ No-issue rationale PR body explains why no issue is linked.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (size label size:XL; no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 67 registered-repo PR(s), 57 merged, 589 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 67 PR(s), 589 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 67 PR(s), 589 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Triage stale or unlinked PRs.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 1, 2026
@JSONbored
JSONbored force-pushed the codex/fix-metagraphed-surface-context branch from 7149942 to 903cf4c Compare July 1, 2026 11:57
@dosubot dosubot Bot added size:XL and removed size:L labels Jul 1, 2026
@JSONbored JSONbored changed the title fix(review): invalidate stale ai review cache inputs fix(review): repair stale gate-check publication state Jul 1, 2026
@JSONbored
JSONbored force-pushed the codex/fix-metagraphed-surface-context branch from 903cf4c to d4abb3c Compare July 1, 2026 12:15
@dosubot dosubot Bot added the size:XL label Jul 1, 2026
JSONbored added 5 commits July 1, 2026 05:30
The AI-review cache fingerprint only recorded Boolean(REES_URL), so
changing the configured analyzer endpoint from one URL to another kept
the same cache key -- a same-head PR could reuse AI-review output
produced against a different analyzer service. Fingerprint the URL
value itself (still one-way-hashed by aiReviewInputFingerprint, so it
never appears in the output), matching the pattern already used for the
other REES_* fields.
While an active per-PR regate backlog defers ordinary stale maintenance
(the point of the earlier check), a repo with even one priority repair
(a PR missing its current Gate check) escaped that deferral entirely and
picked up a full SWEEP_MAX_PRS batch -- letting unrelated ordinary stale
PRs ride along whenever any priority repair existed, contradicting the
"normal maintenance yields behind repairs" intent. Cap the candidate
limit to exactly the priority count when a backlog is active; a repo
with no backlog still gets a normal, full-size sweep.

Also documents (not fixes -- verified as a false positive) why
`decision.willLabel` in the incomplete-surface audit path is safe even
though `decision` can still be the un-reassigned `prelim` value there:
`willLabel` is a non-optional boolean on every PublicSurfaceDecision
variant, and the path is only reachable when "label" was never in
prelim.actions to begin with.
…unreachable

runAiReviewForAdvisory is the sole assignment site reaching the cache-write
branch, and every one of its "ok" returns sets metadata explicitly, so the
nullish fallback is a type-level safeguard only.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui ede5fa1 Commit Preview URL

Branch Preview URL
Jul 01 2026, 07:13 PM

@JSONbored
JSONbored merged commit a8030ca into main Jul 1, 2026
13 checks passed
@JSONbored
JSONbored deleted the codex/fix-metagraphed-surface-context branch July 1, 2026 19:30
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 1, 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.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant