Skip to content

fix(review): pin expectedHeadSha on the contributor_cap close action - #6466

Merged
JSONbored merged 1 commit into
mainfrom
fix/contributor-cap-close-expected-head-sha
Jul 16, 2026
Merged

fix(review): pin expectedHeadSha on the contributor_cap close action#6466
JSONbored merged 1 commit into
mainfrom
fix/contributor-cap-close-expected-head-sha

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Fixes 1 confirmed adversarial-audit finding(s) in src/settings/agent-actions.ts:

  • contributor_cap close action never pins expectedHeadSha, so it is auto-rejected the instant a maintainer approves it under auto_with_approval (src/settings/agent-actions.ts)

Each fix follows the audit's own verified failure scenario and root-cause analysis (2-independent-skeptic adversarial verification pass, both had to vote "confirmed").

Closes #6405

Test plan

  • Regression test(s) reproducing the audited failure scenario for each finding
  • Full local gate (npm run test:ci) green

The contributor_cap close action (per-contributor / install-wide open-item
cap short-circuit) never pinned expectedHeadSha, unlike the sibling
blacklist, review_nag, copycat, and screenshot_table close actions. Under
autonomy.close = "auto_with_approval" this left params.expectedHeadSha
undefined on the persisted pending row, which made
decidePendingAgentAction's isUnpinnedRatifyingAction guard unconditionally
reject the maintainer's accept before the close ever executed, silently
neutering the anti-abuse cap for any repo using the approval-gated close
policy.

Add the same `...(input.pr.headSha ? { expectedHeadSha: input.pr.headSha } : {})`
spread already used by the other closeKinds, and add regression tests
covering the pinned and defensive-fallback (no headSha) cases.
@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 16, 2026
@JSONbored
JSONbored merged commit 5fb7f1b into main Jul 16, 2026
13 checks passed
@JSONbored
JSONbored deleted the fix/contributor-cap-close-expected-head-sha branch July 16, 2026 09:31
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 16, 2026
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6466   +/-   ##
=======================================
  Coverage   95.59%   95.59%           
=======================================
  Files         589      589           
  Lines       47025    47026    +1     
  Branches    14951    14952    +1     
=======================================
+ Hits        44952    44953    +1     
  Misses       1291     1291           
  Partials      782      782           
Flag Coverage Δ
shard-1 44.07% <0.00%> (-0.18%) ⬇️
shard-2 37.03% <100.00%> (+0.39%) ⬆️
shard-3 32.33% <0.00%> (-0.04%) ⬇️
shard-4 34.47% <0.00%> (-0.84%) ⬇️
shard-5 31.44% <0.00%> (+0.42%) ⬆️
shard-6 45.70% <100.00%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/settings/agent-actions.ts 97.95% <100.00%> (+<0.01%) ⬆️

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

None yet

Development

Successfully merging this pull request may close these issues.

contributor_cap close action never pins expectedHeadSha, so it is auto-rejected the instant a maintainer approves it under auto_with_approval

1 participant