Skip to content

fix(approvals): owner check on approval reads, and a scheduled expiry sweep (#18413, #18412) - #20555

Closed
mrveiss wants to merge 4 commits into
mainfrom
issue-18413-approval-ownership-expiry
Closed

mrveiss wants to merge 4 commits into
mainfrom
issue-18413-approval-ownership-expiry

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thinking Path

GET /approval-gates and GET /approval-gates/{id} returned an approval's context to any caller, while the pending list already filtered by owner. And expire_stale existed with only a test calling it, so stale rows were never swept.

What Changed

  • approval_gate_service.py: one rule, visibility(viewer, is_admin), shared by the list, the single read and list_pending, and get_visible. Someone else's approval is a 404 identical to a missing one. A sourced row with no owner is admin-only.
  • New ApprovalExpiryScheduler, started by start_background_workers and drained at shutdown, interval from AUTOBOT_APPROVAL_EXPIRY_SWEEP_INTERVAL_S. It only changes status and deletes nothing.
  • Company reviewers use /api/llc/approvals, unaffected: these routes already exclude company rows.

Verification

  • approval_gates_ownership_18413_test.py: owner reads, another user gets the same 404, admin reads all. approval_expiry_scheduler_18412_test.py: 6 passed, including a failing sweep that does not stop the loop. Neighbouring worker and shutdown tests pass.
  • Not run: the Postgres tests that hold the resume-once guarantee (test_approval_inbox_query_13421.py). Other SLM or service callers of these GET routes were not searched.
  • Possible text overlap with feat(company-os): work items follow a parent rule table on create and update (#18978) #20478 in approval_gates.py.

Model Used

Claude Sonnet for the implementation, Claude Opus for coordination.

Single-issue rationale

Closes nothing outright. Refs #18412, whose scheduled sweep this delivers, and #18413, whose third criterion names S2a and S2e sub-issues of #13421 that do not exist. The approve and reject ownership gap is tracked on #17161.

@mrveiss mrveiss added this to the M3 - Refined GUI complete milestone Nov 1, 2026
@mrveiss mrveiss added the phase:M3.7 Company OS, Automation and BI screens label Nov 1, 2026
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss

mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Code review on PR #20555 (head 4e71238): changes needed.

Read only; nothing was run. The read scoping is right: admins see all, others get the same 404 as a missing gate, matching the inbox rule. The sweep's conditional claim handles a racing decision and deletes nothing.

  • Medium, approval_gates.py write routes: approve, reject, request_revision, resubmit, add_comment, link_task and unlink_task have no ownership check, and approve returns the response including context. A non-owner with a gate's id gets 404 on GET but can approve and read it through POST. Add get_visible to them, or state which role approves someone else's gate.
    Low: the REST create_approval sets no owner, so those rows are readable by anyone signed in; the ownership and race behaviours run on mocks only; every worker sweeps, safely but redundantly.

@mrveiss

mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Code review on PR #20555 (head 276a150): approve.

Read only; nothing was run. All 7 write routes apply the same owner-or-admin 404 before any service call, tested per route, agreeing with the existing inbox rule. A sourced gate whose owner is gone depends on an admin, and no delegated reviewer exists; that's a separate product question, not new here. The Postgres resume-once test remains unrun, as stated.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Auto-sync: merging main into issue-18413-approval-ownership-expiry conflicts

The sync aborted the merge and pushed nothing. Conflicts are information, so it never resolves one itself. Below, for each conflicted file, are the commits that touched it on each side since the merge base 25ab945e81. Merge main in yourself and push; the label clears on the first run that finds this branch 0 behind.

repo_tests/autobot_has_no_pro_edition_19982_test.py

side commit subject issue refs
main 2c5b5b73f fix(train): reach floors return to mid-window on the merged tree (#20452) #20452
this branch 4e712384c fix(frontend): re-pin the reach floors this branch moved (#18413) #18413

@github-actions github-actions Bot added the sync-conflict Set by the branch sync (#19548) label Nov 1, 2026
This was referenced Nov 1, 2026
@mrveiss mrveiss removed the sync-conflict Set by the branch sync (#19548) label Nov 5, 2026
mrveiss added a commit that referenced this pull request Nov 5, 2026
mrveiss added a commit that referenced this pull request Nov 5, 2026
timothybrush pushed a commit to timothybrush/AutoBot-AI that referenced this pull request Nov 5, 2026
@mrveiss

mrveiss commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Landed on main via train merge 9dccf70 (train PR #20841); the PR head tree equals origin/main (git diff origin/main...232628d and git diff origin/main 232628d are both empty). The four commits are 'Merge main into' auto-sync merges with no content, and git cherry lists nothing because it skips merges. Closing.

@mrveiss

mrveiss commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Branch deleted after verification: every commit is in main and the branch shows 0 changed files against main. Restore it from this PR if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M3.7 Company OS, Automation and BI screens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant