Skip to content

#779, #780: a rejection takes the checks of an approval and is an approvals row - #785

Merged
ephico2real2 merged 7 commits into
mainfrom
fix/779-780-reject-decisions
Dec 1, 2026
Merged

ephico2real2 merged 7 commits into
mainfrom
fix/779-780-reject-decisions

Conversation

@ephico2real2

@ephico2real2 ephico2real2 commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Closes #779
Closes #780
Part of #18

What was wrong

The fix

  • ApprovalLedger._eligible (core/approvals.py) holds the checks of a decision in docs/14's order; approve and the new reject share it. reject returns the approving group of the open seat the person would fill, by the matching that gives an approval its counted_for. A rejection fills no slot.
  • :reject (routers/requests.py) locks the request first (get_for_update, as :approve), then: environment (403 environment-forbidden), state (409 not-pending), the ledger (403 not-eligible, 409 self-approval, 409 already-approved), then the approvals row, the move to rejected, the audit event and the notice. Each refusal writes nothing.
  • Migration 0014 adds approvals.decision (varchar(10), NOT NULL, default 'approve', check ck_approvals_decision). Every existing row reads as an approval with no table rewrite. RequestRepo.approvals reads approvals only. RequestRepo.record_rejection writes the rejection's row with counted_for. REQUIRED_REVISION is 0014.
  • The downgrade refuses, changing nothing, while a rejection is stored (the owner's rule on PR #592 An Idempotency-Key belongs to the caller that sent it (migration 0008) #601: refuse, never drop); the refusal names the DELETE an operator can run on purpose.

The migration number

0013 was PR #774's (the operations tables). This migration depends on nothing in it. #774 merged first (390655a), so after the merge of main (dc9eaff) 0014 revises 0013, and REQUIRED_REVISION is 0014. A database stamped 0014 under the earlier chain (revising 0012) has no 0013 tables: 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:

Question (#779, #780) Decision Source
Reject needs eligibility for an open slot, or any slot? An open slot: the check of :approve docs/01 "Approval of record" names one set of checks for both calls; GitHub and GitLab reviewers approve or reject from one list; NIST SP 800-53 Rev. 5.2.0 AC-5
Does one eligible rejection end the request? Yes, unchanged GitHub Docs, "Reviewing deployments": "If a job is rejected, the workflow will fail."; GitLab "Deployment approvals": "Reject a deployment to prevent it."
May a person who approved then reject? No: 409 already-approved, a person decides once GitLab: "A user can give only one approval per deployment"
Where is the rejection recorded? approvals.decision + counted_for (#780's option 1) docs/01; NIST SP 800-53 Rev. 5.2.0 AU-3 (type, when, where, source, outcome, identity)
Existing rows Constant default 'approve', no rewrite PostgreSQL 16 ALTER TABLE, Notes

All 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.

File Before (main 307daf9 + the new tests) After
tests/core/test_approvals.py 3 failed (ApprovalLedger has no reject), 36 passed 39 passed
tests/service/test_reject_decision_779_780.py 6 failed: the three refusal tests at the reject's 200, the approver-then-reject test, the row test (no approvals row), the 0014 test (no revision) 8 passed at dc9eaff: the six, test_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 added
tests/service/test_usage_verdicts_310.py n/a (asserts the required revision) 12 passed
tests/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) 1 failed (the reject answered 200), 2 passed, on main 5d15e21 3 passed
tests/service/test_data_model_doc.py, test_models_match_migrations.py n/a 1 and 15 passed
tests/service/test_api_samples.py (no rewrite), test_api_docs.py (contract written) n/a 3 passed; contract test passed
scripts/doc-citations.py --check, scripts/api-examples-doc.py --check, api-types.mjs --check 0 problems, current, current

Not 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

  • The live Claude Doc of docs/01: only the export changed (the handover lists the live docs as waiting for the owner).
  • The data-model figure (read at head 0003) is unchanged; it shows no column this change touches.
  • samples.json is not rewritten: its test passes, and a rewrite only moves run-dependent values.

…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.
@ephico2real2
ephico2real2 merged commit 03cda30 into main Dec 1, 2026
11 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant