Repository navigation
#779, #780: a rejection takes the checks of an approval and is an approvals row - #785
Merged
Merged
Conversation
…rovals row #779 (security): :reject checked only requests:reject in the environment, so an approver in no approving group of the request could veto it, and a requester could reject their own request where selfApproval is false. :reject now locks the request, checks the environment and the state, and runs ApprovalLedger.reject, which shares _eligible with approve: 403 not-eligible, 409 self-approval, 409 already-approved (a person decides a request once). One eligible rejection still ends the request. #780: docs/01 says "Each decision is an approvals row and an audit event". Migration 0014 adds approvals.decision (approve | reject, default approve, check ck_approvals_decision); a rejection writes a row with counted_for, the group of the open seat it was decided for. RequestRepo.approvals reads approvals only, so no rejection fills a slot. The downgrade refuses while a rejection is stored (refuse, never drop). REQUIRED_REVISION is 0014. 0014 revises 0012: 0013 is PR #774's, not merged. Docs 01, 12, 14, 16, GLOSSARY, the authorization figure, openapi.json and the portal types updated; the design and its sources are in docs/reviews/2026-12-01-issue-779-780/design.md. Closes #779 Closes #780 Part of #18
…he rejection's row After merging main (PR #784): Opal, an approver in no approving group of the request, is refused on :reject (403 not-eligible, every table unchanged) beside her refused :approve, and the rejection's approvals row names the decision and approver-platform. Before the fix the reject answered 200. Two citations of problem_docs.py relocated.
…ded when the rejecter is in one; reject examples worded for a rejection; client-owner gap documented and filed (#789) Reviewer 1 (Codex gpt-6.2-astra) Medium rejected as a rule (record half kept), Low amended; reviewer 2 (Fable) findings. Applied by the coordinator after a line-by-line read. Record: docs/reviews/2026-12-01-issue-779-780/.
…tions relocated, lock rebuilt from both sides)
ephico2real2
added a commit
that referenced
this pull request
Dec 1, 2026
…sion #785 merges ahead of this branch with 0014 revising 0013. Until it is on main this branch's chain has a gap at 0014, and the service tests cannot migrate.
…revises 0013 #774 merged first with 0013_operations revising 0012, so 0014 revises 0013 and REQUIRED_REVISION stays 0014. Conflicts combined from both sides: REQUIRED_REVISION's comment names 0013; test_usage_verdicts_310 reads REQUIRED_REVISION; docs/14 keeps this branch's step 5 and #789 rows with the citations relocated; GLOSSARY lists 0013 and 0014; docs/16's schema block written again at head 0014 (16 tables) with scripts/db-schema-doc.py. citations.lock.json is the union of both sides (ours over theirs, except main.py:204-208, where main's text is the file's), relocated and written; every entry's text is one side's, so no span changed. The texts that said 0013 was #774's and unmerged now say 0014 revises 0013; the 0014 tests start and downgrade at 0013.
…iew record: 0014 revises 0013
15 tasks
ephico2real2
added a commit
that referenced
this pull request
Dec 1, 2026
…REVISION is 0015, the contract has 51 operations test_a_database_at_0013_is_behind_this_code reads REQUIRED_REVISION, as test_usage_verdicts_310 does; docs/08 counts the operation this PR adds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #779
Closes #780
Part of #18
What was wrong
:rejectchecked only that a role grantsrequests:rejectin the request's environment. An approver in no approving group of the request could veto it (the issue's probe: OPAL got 403not-eligibleon:approveand 200 on:rejectof the same request), and a requester could reject their own request whereselfApprovalis false.The fix
ApprovalLedger._eligible(core/approvals.py) holds the checks of a decision in docs/14's order;approveand the newrejectshare it.rejectreturns the approving group of the open seat the person would fill, by the matching that gives an approval itscounted_for. A rejection fills no slot.:reject(routers/requests.py) locks the request first (get_for_update, as:approve), then: environment (403environment-forbidden), state (409not-pending), the ledger (403not-eligible, 409self-approval, 409already-approved), then the approvals row, the move torejected, the audit event and the notice. Each refusal writes nothing.approvals.decision(varchar(10), NOT NULL, default'approve', checkck_approvals_decision). Every existing row reads as an approval with no table rewrite.RequestRepo.approvalsreads approvals only.RequestRepo.record_rejectionwrites the rejection's row withcounted_for.REQUIRED_REVISIONis0014.DELETEan operator can run on purpose.The migration number
0013was PR #774's (the operations tables). This migration depends on nothing in it. #774 merged first (390655a), so after the merge of main (dc9eaff)0014revises0013, andREQUIRED_REVISIONis0014. A database stamped0014under the earlier chain (revising0012) has no0013tables: only test databases ever were; recreate them.Design decisions and sources
Recorded in
docs/reviews/2026-12-01-issue-779-780/design.md, with quotes. In short::approvealready-approved, a person decides onceapprovals.decision+counted_for(#780's option 1)'approve', no rewriteAll fetched 2026-12-01.
Tests
On the Mac, PostgreSQL 16 on 127.0.0.1:55432, database
cmapi_t779. No cluster: nothing was run on kind or CRC.tests/core/test_approvals.pyApprovalLedgerhas noreject), 36 passedtests/service/test_reject_decision_779_780.pytest_a_database_at_0013_is_behind_this_code(was_0012_, added after the before-run; on main it would fail, a 0013 schema reads ok), and one the review addedtests/service/test_usage_verdicts_310.pytests/service/test_decisions_story_18.py(merged from PR #784, updated here: Opal's refused reject beside her refused approve, every table unchanged; the rejection's approvals row in the reject block)tests/service/test_data_model_doc.py,test_models_match_migrations.pytests/service/test_api_samples.py(no rewrite),test_api_docs.py(contract written)scripts/doc-citations.py --check,scripts/api-examples-doc.py --check,api-types.mjs --checkNot run locally: the full suites (CI is the gate), the other existing reject tests (
test_flow,test_review_a_concurrency,test_review_c_authz,test_review_i_crosscheck,test_expire_check_263,test_list_filters,test_capacity_reservations_62). By reading them: each rejects with an approver of the group the request needs (AMY or LEAD,approver-platform), so each stays eligible; the concurrency tests now see the reject take the row lock first, which keeps one winner.Who wrote what
Opus 5.5 (
high), the implementer: every commit and file in this PR (15206fd, f19279d; the merge of main brings PR #784's test, which f19279d updates). Review is next: this touches a migration and authorization, so both reviewers (Codex reviewer 1, a separate Opus or Fable reviewer 2). Codex is the only outside model family.Not done here
0003) is unchanged; it shows no column this change touches.samples.jsonis not rewritten: its test passes, and a rewrite only moves run-dependent values.