fix(binjovi): revoke write authorization for a dropped repository #720

Merged
binjovi-bot merged 1 commit from fix/prune-integration-repos into trunk 2026-09-13 17:52:57 +00:00
Owner

Removing a repository from the Binjovi write integration never took its
authorization away.

The bootstrap INSERTs the desired repository rows WHERE NOT EXISTS, and the
only two DELETEs in that transaction clean up the retired
binjovi-operator-bot observer integrations. The statement is add-only. A
repository dropped from the list in Git kept its row in
authorized_integ_resource_repo, and binjovi-bot kept write authorization to
it, indefinitely. Nothing reported that anywhere.

It also made the repository undeletable. Deleting sean/hermes answered 500,
and the Forgejo log gave the reason:

DeleteRepository: foreign key constraint violation: update or delete on table
"repository" violates foreign key constraint
"authorized_integ_resource_repo_repo_id_fkey"

Hermes hit both halves at once: a live write grant to a service that no longer
exists, and a row that blocked removing the repository at all.

The change

Adds the matching DELETE so the bootstrap converges instead of only
accumulating. It reuses the same desired list the INSERT uses, so the two
cannot drift apart.

NOT IN is safe here. Every id is already checked against ^[1-9][0-9]{0,18}$
in the guard loop before psql runs, so no NULL can enter the list, and the
degenerate NOT IN case deletes nothing rather than everything.

The Job template is immutable, so the generation moves v28 -> v29 and the
fingerprint pin moves with it.

Scope

Found while retiring Hermes, but it is not a Hermes problem -- it applies to
every repository ever dropped from that list. Worth checking whether any other
stale rows are already in the table.

bash tests/check.sh exits 0.

https://claude.ai/code/session_01GfkEuwuvGSqGyXVuxwT7PA

Removing a repository from the Binjovi write integration never took its authorization away. The bootstrap `INSERT`s the desired repository rows `WHERE NOT EXISTS`, and the only two `DELETE`s in that transaction clean up the retired `binjovi-operator-bot` observer integrations. The statement is **add-only**. A repository dropped from the list in Git kept its row in `authorized_integ_resource_repo`, and `binjovi-bot` kept write authorization to it, indefinitely. Nothing reported that anywhere. It also made the repository **undeletable**. Deleting `sean/hermes` answered 500, and the Forgejo log gave the reason: ``` DeleteRepository: foreign key constraint violation: update or delete on table "repository" violates foreign key constraint "authorized_integ_resource_repo_repo_id_fkey" ``` Hermes hit both halves at once: a live write grant to a service that no longer exists, and a row that blocked removing the repository at all. ### The change Adds the matching `DELETE` so the bootstrap converges instead of only accumulating. It reuses the same desired list the `INSERT` uses, so the two cannot drift apart. `NOT IN` is safe here. Every id is already checked against `^[1-9][0-9]{0,18}$` in the guard loop before `psql` runs, so no NULL can enter the list, and the degenerate `NOT IN` case deletes nothing rather than everything. The Job template is immutable, so the generation moves **v28 -> v29** and the fingerprint pin moves with it. ### Scope Found while retiring Hermes, but it is not a Hermes problem -- it applies to every repository ever dropped from that list. Worth checking whether any other stale rows are already in the table. `bash tests/check.sh` exits 0. https://claude.ai/code/session_01GfkEuwuvGSqGyXVuxwT7PA
fix(binjovi): revoke write authorization for a dropped repository
All checks were successful
binjovi/ci Binjovi completed the frozen plan
4a197a24fc
Removing a repository from the Binjovi write integration never took its
authorization away. The bootstrap INSERTs the desired repository rows
WHERE NOT EXISTS and the only two DELETEs in that transaction clean up
the retired binjovi-operator-bot observer integrations, so the statement
is add-only. A repository dropped from the list in Git kept its row in
authorized_integ_resource_repo, and binjovi-bot kept write authorization
to it. Nothing reported that.

It also made the repository undeletable. Deleting sean/hermes answered
500, and Forgejo logged the reason:

  DeleteRepository: foreign key constraint violation: update or delete
  on table "repository" violates foreign key constraint
  "authorized_integ_resource_repo_repo_id_fkey"

Hermes hit both halves: a live write grant to a retired service, and a
row that blocked removing the repository at all.

This adds the matching DELETE so the bootstrap converges instead of only
accumulating. It reuses the same desired list, so the two cannot drift.
NOT IN is safe here: every id is already checked against
^[1-9][0-9]{0,18}$ before psql runs, so no NULL can enter the list, and
the degenerate case of NOT IN deletes nothing rather than everything.

The Job template is immutable, so the generation moves to v29 and the
fingerprint pin moves with it.

Claude-Session: https://claude.ai/code/session_01GfkEuwuvGSqGyXVuxwT7PA
binjovi-bot deleted branch fix/prune-integration-repos 2026-09-13 17:52:58 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sean/seanfarm!720
No description provided.