ci: validate pull request coordination claims #221

Open
github-bot wants to merge 53 commits from github-bot/gh-221 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:47 UTC · original
ubiquitarianism:codex/coord-claim-check-20261124-7e48 → main · +2052 −0 · 2 files · 53 commits · draft

Claimed in the coordination issue as: COORD-CLAIM-CHECK

Summary

  • Validate every work-item ID declared in the PR title and the Claimed in the coordination issue as: field. IDs from both locations are combined; only IDs in issue #14's Open work table are valid.
  • Require a prior unchanged claim on issue #14 for each ID, posted before the PR and owned by the PR author. Editing or deleting a claim invalidates it.
  • Accept explanatory text, comma-separated IDs, and contiguous bulleted batches after claiming:; reject malformed partial lists.
  • Keep the editable issue body separate from the Action-owned open-PR roster comment.
  • Refresh the roster every 15 minutes. Reconcile claim status after relevant comments, edits to issue #14, PR lifecycle events, and validator runs. PR lifecycle events recompute all open heads targeting main, including when a PR opens, changes commits or base, or closes. Queue automatic status reconciliation and audit all open PR heads hourly; manual per-PR refresh remains available.
  • Publish commit status context coordination-claim on current PR heads, independent of workflow rerun age or attempt limits. This is an eventually consistent diagnostic and must not be the sole required merge check because claim data lives in issue #14. Strict enforcement requires an authorized merge flow to revalidate claims immediately before merging. The Actions job coordination-claim-validator is also diagnostic.
  • Verify the repository's effective GitHub Actions event policy allows pull_request_target before December 2, 2026. The repository policy could not be confirmed through the available API; if the event is blocked, validator workflow_run events and the hourly audit remain recovery paths.
  • Manual refresh: gh workflow run coordination-activity.yml -f pr_number=<N>.
  • Mark PRs without a valid claim as Needs claim. The workflow does not close or assign PRs.

Security and scope

The claim validator is read-only. The activity workflow has issue-comment and commit-status write permissions so it can update its own marked comment and publish the current status for PR heads. Neither workflow checks out or executes pull-request code.

Local verification: both workflow YAML files parsed, all three embedded Python scripts compiled, and 42 focused checks passed for claim parsing, PR field extraction, and comment targeting. GitHub Actions execution still needs confirmation.

**@⁠Andretuta** on GitHub · 2026-11-24 02:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/221) `ubiquitarianism:codex/coord-claim-check-20261124-7e48` → `main` · +2052 −0 · 2 files · 53 commits · draft Claimed in the coordination issue as: COORD-CLAIM-CHECK ## Summary - Validate every work-item ID declared in the PR title and the `Claimed in the coordination issue as:` field. IDs from both locations are combined; only IDs in issue #14's **Open work** table are valid. - Require a prior unchanged claim on issue #14 for each ID, posted before the PR and owned by the PR author. Editing or deleting a claim invalidates it. - Accept explanatory text, comma-separated IDs, and contiguous bulleted batches after `claiming:`; reject malformed partial lists. - Keep the editable issue body separate from the Action-owned open-PR roster comment. - Refresh the roster every 15 minutes. Reconcile claim status after relevant comments, edits to issue #14, PR lifecycle events, and validator runs. PR lifecycle events recompute all open heads targeting `main`, including when a PR opens, changes commits or base, or closes. Queue automatic status reconciliation and audit all open PR heads hourly; manual per-PR refresh remains available. - Publish commit status context `coordination-claim` on current PR heads, independent of workflow rerun age or attempt limits. This is an eventually consistent diagnostic and must not be the sole required merge check because claim data lives in issue #14. Strict enforcement requires an authorized merge flow to revalidate claims immediately before merging. The Actions job `coordination-claim-validator` is also diagnostic. - Verify the repository's effective GitHub Actions event policy allows pull_request_target before December 2, 2026. The repository policy could not be confirmed through the available API; if the event is blocked, validator workflow_run events and the hourly audit remain recovery paths. - Manual refresh: `gh workflow run coordination-activity.yml -f pr_number=<N>`. - Mark PRs without a valid claim as **Needs claim**. The workflow does not close or assign PRs. ## Security and scope The claim validator is read-only. The activity workflow has issue-comment and commit-status write permissions so it can update its own marked comment and publish the current status for PR heads. Neither workflow checks out or executes pull-request code. Local verification: both workflow YAML files parsed, all three embedded Python scripts compiled, and 42 focused checks passed for claim parsing, PR field extraction, and comment targeting. GitHub Actions execution still needs confirmation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:49:16 +00:00
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 05:28 UTC · original

Checked at fe9588f. Good news first: there's no injection or pwn-request path. Nothing from the event is interpolated into run:, the heredocs are quoted (<<'PY'), there's no checkout and no uses:, permissions start at {} and are scoped per job, and workflow_run only reads event metadata. Two things should be fixed before this merges, because any GitHub user can trigger them:

  1. Regex backtracking (ReDoS). CLAIM_FIELD_RE (coordination-activity.yml:71-73, the copy at :604, and coordination-claim.yml:40) is (?im)^\s*>?\s*Claimed… and runs over every open PR body. \s also matches newlines, so the two \s* backtrack against each other on whitespace-heavy bodies; one PR body full of blank lines can keep every activity run busy until its timeout. The bullet regex used on #14 comments has the same shape. Using [ \t]* instead of \s* there, and capping the length of what's scanned, removes it. (Found by reading the code; not measured.)
  2. API-budget exhaustion. issue_comment (created, edited, deleted) has no author_association filter, and a deleted comment with no IDs re-targets every open PR (:324, :857), which costs ~360+ REST calls per run against the repo's shared 1 000 / hour GITHUB_TOKEN budget. A few create/delete cycles by anyone would starve the other workflows. Filtering on author_association (or rate-limiting the "all PRs" path) closes it.

Minor: the roster comment may approach GitHub's 65 536-character limit as the PR count grows, and nearly every PR would show a failed coordination-claim status, which is a policy call for the owner.

Security review; read only, nothing run.
AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.

**@⁠QemmHD** on GitHub · 2026-11-24 05:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/221#issuecomment-7122983566) Checked at `fe9588f`. Good news first: there's no injection or pwn-request path. Nothing from the event is interpolated into `run:`, the heredocs are quoted (`<<'PY'`), there's no checkout and no `uses:`, permissions start at `{}` and are scoped per job, and `workflow_run` only reads event metadata. Two things should be fixed before this merges, because any GitHub user can trigger them: 1. **Regex backtracking (ReDoS).** `CLAIM_FIELD_RE` (`coordination-activity.yml:71-73`, the copy at `:604`, and `coordination-claim.yml:40`) is `(?im)^\s*>?\s*Claimed…` and runs over every open PR body. `\s` also matches newlines, so the two `\s*` backtrack against each other on whitespace-heavy bodies; one PR body full of blank lines can keep every activity run busy until its timeout. The bullet regex used on #14 comments has the same shape. Using `[ \t]*` instead of `\s*` there, and capping the length of what's scanned, removes it. (Found by reading the code; not measured.) 2. **API-budget exhaustion.** `issue_comment` (`created, edited, deleted`) has no `author_association` filter, and a deleted comment with no IDs re-targets every open PR (`:324`, `:857`), which costs ~360+ REST calls per run against the repo's shared 1 000 / hour `GITHUB_TOKEN` budget. A few create/delete cycles by anyone would starve the other workflows. Filtering on `author_association` (or rate-limiting the "all PRs" path) closes it. Minor: the roster comment may approach GitHub's 65 536-character limit as the PR count grows, and nearly every PR would show a failed `coordination-claim` status, which is a policy call for the owner. Security review; read only, nothing run. AI-assisted (Claude Code, Claude Opus 5.5). Discord: bigpeppa.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 05:39 UTC · original · requested changes

Requesting changes for the two issues anyone on GitHub can trigger (details in my comment above): the backtracking in CLAIM_FIELD_RE and the bullet regex (use [ \t]* and cap input), and the unfiltered issue_comment path where a deleted comment re-targets every PR and drains the shared GITHUB_TOKEN budget (add an author_association filter). No injection or pwn-request path. Happy to re-review once those are in.

AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.

**@⁠QemmHD** on GitHub · 2026-11-24 05:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/221#pullrequestreview-6034243094) · **requested changes** Requesting changes for the two issues anyone on GitHub can trigger (details in my comment above): the backtracking in `CLAIM_FIELD_RE` and the bullet regex (use `[ \t]*` and cap input), and the unfiltered `issue_comment` path where a deleted comment re-targets every PR and drains the shared GITHUB_TOKEN budget (add an `author_association` filter). No injection or pwn-request path. Happy to re-review once those are in. AI-assisted (Claude Code, Claude Opus 5.5). Discord: bigpeppa.
Author
Owner

@⁠GrahamboJangles on GitHub · 2026-11-24 10:45 UTC · original

Reviewed head ade227657e863b19765d64f1d3076e32dcb78a62 (PR last updated 2026-11-24T07:17:45Z). CPU-only review: I extracted the three embedded Python blocks straight from this head's diff, ran them as-is against live repo data fetched at 10:19Z — every number below is measured, not estimated. No GPU, no game files, nothing merged.

What ran, and the harness: the parser/evaluator functions (ids_from_claim_comment, open_work_ids, claim_fields, pull_claim_ids, evaluate_claim) were cut from the diff at the first network call and imported unchanged. Only approximation: GraphQL lastEditedAt was fed from REST data — the REST comments payload has no edited_at field, so all 650 comments were treated as unedited (_last_edited_at = None), which matches every comment I sampled.

Coordination compliance: COORD-CLAIM-CHECK is in the Open work table, claim comment 7120227654 by Andretuta created 02:31:27Z, unchanged (updated_at == created_at), predates the PR → the evaluator returns claimed, and the PR's own coordination-claim-validator check passes (8s) on this head. CI here: validator, no-game-data, change-scope, jactionlint all pass; several jobs pending, none failing.

Finding 1 — title-ID scan creates phantom work items (measured bug). pull_claim_ids unions ids_from_text(title), but ID_PATTERN matches any uppercase hyphenated token, including ordinary technical prose. Live sweep over all 487 open PRs: 79 declare phantom IDs from their titles — SHA-256 in #616, UTF-8 in #483, 78-81 in #553/#512, FUZZ-8 in #630. Minimal counterexample, same evaluator and data: PR #616 evaluates invalid (candidates {EXE-SHA-VALIDATE, SHA-256}); delete only the SHA-256 token from the title and it evaluates claimed for hamdog0203 via unchanged claim comment 7128088818 (09:56:11Z < PR opened 10:00:03Z). So after the merge, #616-style PRs fail with Unknown work-item IDs: SHA-256 and no path forward. Suggest the title scan keep only tokens that are in allowed_ids, or already present in claims_by_id — or scan just a trailing parenthesized ID segment.

Finding 2 — the table gate and the stale table interact badly at ship time (measured). allowed_ids comes solely from the Open work table, which currently holds exactly 3 IDs (COORD-CLAIM-CHECK, SHADER-1264, TEST-ATOMIC-GUARD), while issue #14 comments hold 650 comments with 240 parseable claims and 274 distinct claimed IDs. Evaluating all 487 open PRs live: 1 claimed, 271 invalid, 215 needs-claim — the 271 invalids fail on exactly one cause, candidates - allowed_ids (their claim comments are unchanged and author-matched). As merged, the roster and the coordination-claim commit status stamp ~271 open PR heads red on the first hourly audit. invalid also conflates "ID not in the Open work table" with "claim malformed/ownership mismatch", and the roster renders both as Needs claim. Not a correctness bug — the body already scopes the status as diagnostic — but a distinct state (e.g. claim-ok-unlisted) would let the table-refresh work tracked as COORD-TABLE-REFRESH converge instead of the status noise reading as broken claims.

Finding 3 — two ~750-line copies of the same script already drift. difflib across the reconcile-job and sync-job blocks in coordination-activity.yml: 3 differing blocks. (a) the sync copy carries an extra unreachable stop("GitHub GraphQL retry loop ended unexpectedly.") that the reconcile copy lacks; (b/c, more serious) the pull_request_target branch of status_target_pulls exists in two versions — sync has the pre-"recompute all heads" form (base-ref guard without the edited carve-out, plus the closed-PR head-sha filter) while reconcile has the current recompute-all form. Sync's copy is dead today (publish_claim_statuses is unreachable in COORDINATION_MODE: sync), so nothing is broken now — but this is a copy-paste maintenance trap of 1,500 lines that has already diverged at its first fix. One script file in-repo (e.g. .github/scripts/coordination_activity.py, invoked as python3 .github/scripts/coordination_activity.py by both jobs — trusted base content, no PR-code checkout, so security is unchanged) collapses this to a single copy.

Finding 4 — keyword strictness misreports good-faith claims. The claiming: regex is exact and case-insensitive; tahffo68hk-hash's claim on this very item family was posted as claim: VK-XDXR-POSTBUILD-READBACK-STAGE (09:56:39Z) and parses to nothing — so #615 evaluates invalid with the message No unchanged claim for VK-XDXR-POSTBUILD-READBACK-STAGE, despite a well-formed claim in the wrong keyword. The enforcement direction is right (protocol is claiming:); suggest the fail message quote the required keyword (expected a line starting 'claiming:').

Cost scaling (measured inputs, projected behavior): both jobs subscribe to every non-bot comment on #14, every issue edit, every PR lifecycle event, and schedules (sync 5x/hour, reconcile hourly at :17). Each run paginates all comments (650 → 7 pages), all open PRs (487 → 5 pages), plus GraphQL edit-metadata batches over all claim comments (240 → 3 queries) ≈ 15+ requests per run. The #14 feed is running ~15 comments/30min (measured 09:30Z–10:01Z) and PR events are heavy; per-event full re-sync is O(events × collection size). Fine on today's numbers with the concurrency queue serializing, but a targeted refresh path (the code already computes per-PR targets in status_target_pulls) would keep costs flat for the reconcile job — the roster sync is the only piece that genuinely needs the whole collection.

Security checked: no PR code executes anywhere — pull_request_target runs without checkout and the claim validator uses plain pull_request; permissions are per-job minimal (statuses: write only in reconcile, issues: write only in sync, and sync edits only its own marker-bounded bot comment, with duplicate-marker and 64 KiB guards); the validator re-checks the head SHA against the event and fails closed on drift. Read-only against claims. No new measurements of my own claimed anywhere in this review.

One-line summary: sound security model and single-PR behavior (self-verifies claimed), but merge as-is after Finding 1's title-token filter lands and the Open work table gets refreshed, or ~271 open PRs get stamped red by the first audit.

**@⁠GrahamboJangles** on GitHub · 2026-11-24 10:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/221#issuecomment-7129213310) Reviewed head `ade227657e863b19765d64f1d3076e32dcb78a62` (PR last updated 2026-11-24T07:17:45Z). CPU-only review: I extracted the three embedded Python blocks straight from this head's diff, ran them as-is against live repo data fetched at 10:19Z — every number below is measured, not estimated. No GPU, no game files, nothing merged. **What ran, and the harness:** the parser/evaluator functions (`ids_from_claim_comment`, `open_work_ids`, `claim_fields`, `pull_claim_ids`, `evaluate_claim`) were cut from the diff at the first network call and imported unchanged. Only approximation: GraphQL `lastEditedAt` was fed from REST data — the REST comments payload has no edited_at field, so all 650 comments were treated as unedited (`_last_edited_at = None`), which matches every comment I sampled. **Coordination compliance:** `COORD-CLAIM-CHECK` is in the Open work table, claim comment 7120227654 by Andretuta created 02:31:27Z, unchanged (`updated_at == created_at`), predates the PR → the evaluator returns `claimed`, and the PR's own `coordination-claim-validator` check passes (8s) on this head. CI here: validator, `no-game-data`, `change-scope`, `jactionlint` all pass; several jobs pending, none failing. **Finding 1 — title-ID scan creates phantom work items (measured bug).** `pull_claim_ids` unions `ids_from_text(title)`, but `ID_PATTERN` matches any uppercase hyphenated token, including ordinary technical prose. Live sweep over all 487 open PRs: **79 declare phantom IDs from their titles** — `SHA-256` in #616, `UTF-8` in #483, `78-81` in #553/#512, `FUZZ-8` in #630. Minimal counterexample, same evaluator and data: PR #616 evaluates `invalid` (candidates `{EXE-SHA-VALIDATE, SHA-256}`); delete only the `SHA-256` token from the title and it evaluates `claimed` for hamdog0203 via unchanged claim comment 7128088818 (09:56:11Z < PR opened 10:00:03Z). So after the merge, #616-style PRs fail with `Unknown work-item IDs: SHA-256` and no path forward. Suggest the title scan keep only tokens that are in `allowed_ids`, or already present in `claims_by_id` — or scan just a trailing parenthesized ID segment. **Finding 2 — the table gate and the stale table interact badly at ship time (measured).** `allowed_ids` comes solely from the Open work table, which currently holds exactly 3 IDs (`COORD-CLAIM-CHECK`, `SHADER-1264`, `TEST-ATOMIC-GUARD`), while issue #14 comments hold 650 comments with 240 parseable claims and 274 distinct claimed IDs. Evaluating all 487 open PRs live: **1 claimed, 271 invalid, 215 needs-claim** — the 271 invalids fail on exactly one cause, `candidates - allowed_ids` (their claim comments are unchanged and author-matched). As merged, the roster and the `coordination-claim` commit status stamp ~271 open PR heads red on the first hourly audit. `invalid` also conflates "ID not in the Open work table" with "claim malformed/ownership mismatch", and the roster renders both as `Needs claim`. Not a correctness bug — the body already scopes the status as diagnostic — but a distinct state (e.g. `claim-ok-unlisted`) would let the table-refresh work tracked as `COORD-TABLE-REFRESH` converge instead of the status noise reading as broken claims. **Finding 3 — two ~750-line copies of the same script already drift.** difflib across the reconcile-job and sync-job blocks in `coordination-activity.yml`: 3 differing blocks. (a) the sync copy carries an extra unreachable `stop("GitHub GraphQL retry loop ended unexpectedly.")` that the reconcile copy lacks; (b/c, more serious) the `pull_request_target` branch of `status_target_pulls` exists in two versions — sync has the pre-"recompute all heads" form (base-ref guard without the `edited` carve-out, plus the closed-PR head-sha filter) while reconcile has the current recompute-all form. Sync's copy is dead today (`publish_claim_statuses` is unreachable in `COORDINATION_MODE: sync`), so nothing is broken now — but this is a copy-paste maintenance trap of 1,500 lines that has already diverged at its first fix. One script file in-repo (e.g. `.github/scripts/coordination_activity.py`, invoked as `python3 .github/scripts/coordination_activity.py` by both jobs — trusted base content, no PR-code checkout, so security is unchanged) collapses this to a single copy. **Finding 4 — keyword strictness misreports good-faith claims.** The `claiming:` regex is exact and case-insensitive; tahffo68hk-hash's claim on this very item family was posted as `claim: VK-XDXR-POSTBUILD-READBACK-STAGE` (09:56:39Z) and parses to nothing — so #615 evaluates `invalid` with the message `No unchanged claim for VK-XDXR-POSTBUILD-READBACK-STAGE`, despite a well-formed claim in the wrong keyword. The enforcement direction is right (protocol is `claiming:`); suggest the fail message quote the required keyword (`expected a line starting 'claiming:'`). **Cost scaling (measured inputs, projected behavior):** both jobs subscribe to every non-bot comment on #14, every issue edit, every PR lifecycle event, and schedules (sync 5x/hour, reconcile hourly at :17). Each run paginates all comments (650 → 7 pages), all open PRs (487 → 5 pages), plus GraphQL edit-metadata batches over all claim comments (240 → 3 queries) ≈ 15+ requests per run. The #14 feed is running ~15 comments/30min (measured 09:30Z–10:01Z) and PR events are heavy; per-event full re-sync is O(events × collection size). Fine on today's numbers with the concurrency queue serializing, but a targeted refresh path (the code already computes per-PR targets in `status_target_pulls`) would keep costs flat for the reconcile job — the roster sync is the only piece that genuinely needs the whole collection. **Security checked:** no PR code executes anywhere — `pull_request_target` runs without checkout and the claim validator uses plain `pull_request`; permissions are per-job minimal (`statuses: write` only in reconcile, `issues: write` only in sync, and sync edits only its own marker-bounded bot comment, with duplicate-marker and 64 KiB guards); the validator re-checks the head SHA against the event and fails closed on drift. Read-only against claims. No new measurements of my own claimed anywhere in this review. One-line summary: sound security model and single-PR behavior (self-verifies `claimed`), but merge as-is after Finding 1's title-token filter lands and the Open work table gets refreshed, or ~271 open PRs get stamped red by the first audit.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-24 15:56 UTC · original

Security review of the two workflows at ade227657 (read-only: I read the diff and pulled live counts through the API, nothing was run).

Safe: no pwn-request and no injection. Neither workflow checks out or runs PR code. There are no uses: steps at all. The only ${{ }} is github.token in env:. The heredoc is quoted, and event data is read from GITHUB_EVENT_PATH inside Python. There is no subprocess, eval or exec. The permissions are close to least privilege: {} at the top level, statuses: write for reconcile, issues: write for sync. Claims can't be spoofed: the owner must be the comment author, the claim must predate the PR, and it must not have been edited. The bot only PATCHes its own marked comment. I found no ReDoS in the claim regexes.

What I would fix before merging:

1. API amplification exhausts the repo's GITHUB_TOKEN quota (high, availability).

  • Every pull_request_target event recomputes all open PRs (status_target_pulls, L579-587). That means one GET /commits/{sha}/status per head, plus POSTs.
  • Today that is 656 PRs. One title edit or push on any PR comes to roughly 745 REST calls: validator, reconcile and sync on pull_request_target, then reconcile and sync again via workflow_run. The sync job's if has no workflow_run filter.
  • This repo is owned by a user account, so GITHUB_TOKEN gets 1,000 requests per hour. The hourly reconcile at 17 * * * * costs about 673 calls. conflict-label.yml runs at the same minute and makes one call per open PR. Together they exceed the limit before any user activity.
  • Any account can then keep it exhausted by editing its own PR title a few times. Editing a Claiming: comment works too, since changed_claim_ids counts the old and new body.
  • cancel-in-progress: false with queue: max lets the backlog grow without bound. Old success statuses stay in place while reconcile fails.

Suggested fixes:

  • On pull_request_target, target only the event PR's head.sha / before, or drop that trigger from reconcile, since the workflow_run path already targets one SHA.
  • Read the existing statuses in bulk through GraphQL: about 7 queries instead of 654 GETs.
  • Don't run sync on workflow_run.
  • Stop the publish loop on the first 403/429.
  • Move the cron off :17.

2. The roster comment can't be posted at today's size (medium). The 65,536-character guard (L785-798) stops every sync run. Rendering the 656 open PRs with safe_cell produces about 125k characters, so no comment is ever created. Options: summarize (counts, plus only the "needs claim" rows), split it over several managed comments, or write the full table to the job summary.

3. Invisible claims block any ID (medium, abuse).

  • ids_from_claim_comment (L324, and its copies at L1097 and L1866) parses the raw body. It doesn't strip HTML comments or fenced code blocks, while claim_fields (L414) does.
  • A comment on #14 containing <!--\nClaiming: SHADER-1264, ...\n--> renders as nothing. It makes every later PR for those IDs fail with "multiple owners", including the legitimate claimant's PR.
  • Fixes: strip comments and fences before parsing. Prefer "the earliest unedited claim wins" over "exactly one owner". Optionally ignore minimized comments and cap the number of IDs per comment.

Lower:

  • PRs that share a head SHA are combined, so anyone can push a copy of refs/pull/N/head and open an unclaimed PR to turn the victim's status red. This fails closed, never into a forged success.
  • safe_cell doesn't neutralize #N / owner/repo#N / bare URLs in titles, so the bot comment creates cross-reference entries. & isn't escaped either. A code span or a U+200B after @/# would cover both.
  • The ~400 lines of Python are in the workflow three times and have already diverged (status_target_pulls L579 vs L1352). Moving them to tools/ would fix that, run from a default-branch checkout with persist-credentials: false and python3 -I, as conflict-label.yml already does.
  • IDs are taken from anywhere in a title. 371 of 656 open titles contain ID-like tokens, including UTF-8 and SHA-256, so expect most PRs to show failure at rollout.
  • For fork PRs, coordination-claim-validator runs the fork's own copy, so like the PR text says, it can't be a required check.

AI-assisted (Claude Code): review by a read-only agent, finding 3 re-checked by hand against the diff.

**@⁠adrianmjim** on GitHub · 2026-11-24 15:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/221#issuecomment-7136861352) Security review of the two workflows at `ade227657` (read-only: I read the diff and pulled live counts through the API, nothing was run). **Safe:** no pwn-request and no injection. Neither workflow checks out or runs PR code. There are no `uses:` steps at all. The only `${{ }}` is `github.token` in `env:`. The heredoc is quoted, and event data is read from `GITHUB_EVENT_PATH` inside Python. There is no subprocess, eval or exec. The permissions are close to least privilege: `{}` at the top level, `statuses: write` for reconcile, `issues: write` for sync. Claims can't be spoofed: the owner must be the comment author, the claim must predate the PR, and it must not have been edited. The bot only PATCHes its own marked comment. I found no ReDoS in the claim regexes. What I would fix before merging: **1. API amplification exhausts the repo's `GITHUB_TOKEN` quota (high, availability).** - Every `pull_request_target` event recomputes all open PRs (`status_target_pulls`, L579-587). That means one `GET /commits/{sha}/status` per head, plus POSTs. - Today that is 656 PRs. One title edit or push on any PR comes to roughly 745 REST calls: validator, reconcile and sync on `pull_request_target`, then reconcile and sync again via `workflow_run`. The sync job's `if` has no `workflow_run` filter. - This repo is owned by a user account, so `GITHUB_TOKEN` gets 1,000 requests per hour. The hourly reconcile at `17 * * * *` costs about 673 calls. `conflict-label.yml` runs at the same minute and makes one call per open PR. Together they exceed the limit before any user activity. - Any account can then keep it exhausted by editing its own PR title a few times. Editing a `Claiming:` comment works too, since `changed_claim_ids` counts the old and new body. - `cancel-in-progress: false` with `queue: max` lets the backlog grow without bound. Old `success` statuses stay in place while reconcile fails. Suggested fixes: - On `pull_request_target`, target only the event PR's `head.sha` / `before`, or drop that trigger from reconcile, since the `workflow_run` path already targets one SHA. - Read the existing statuses in bulk through GraphQL: about 7 queries instead of 654 GETs. - Don't run sync on `workflow_run`. - Stop the publish loop on the first 403/429. - Move the cron off `:17`. **2. The roster comment can't be posted at today's size (medium).** The 65,536-character guard (L785-798) stops every sync run. Rendering the 656 open PRs with `safe_cell` produces about 125k characters, so no comment is ever created. Options: summarize (counts, plus only the "needs claim" rows), split it over several managed comments, or write the full table to the job summary. **3. Invisible claims block any ID (medium, abuse).** - `ids_from_claim_comment` (L324, and its copies at L1097 and L1866) parses the raw body. It doesn't strip HTML comments or fenced code blocks, while `claim_fields` (L414) does. - A comment on #14 containing `<!--\nClaiming: SHADER-1264, ...\n-->` renders as nothing. It makes every later PR for those IDs fail with "multiple owners", including the legitimate claimant's PR. - Fixes: strip comments and fences before parsing. Prefer "the earliest unedited claim wins" over "exactly one owner". Optionally ignore minimized comments and cap the number of IDs per comment. Lower: - PRs that share a head SHA are combined, so anyone can push a copy of `refs/pull/N/head` and open an unclaimed PR to turn the victim's status red. This fails closed, never into a forged success. - `safe_cell` doesn't neutralize `#N` / `owner/repo#N` / bare URLs in titles, so the bot comment creates cross-reference entries. `&` isn't escaped either. A code span or a U+200B after `@`/`#` would cover both. - The ~400 lines of Python are in the workflow three times and have already diverged (`status_target_pulls` L579 vs L1352). Moving them to `tools/` would fix that, run from a default-branch checkout with `persist-credentials: false` and `python3 -I`, as `conflict-label.yml` already does. - IDs are taken from anywhere in a title. 371 of 656 open titles contain ID-like tokens, including `UTF-8` and `SHA-256`, so expect most PRs to show failure at rollout. - For fork PRs, `coordination-claim-validator` runs the fork's own copy, so like the PR text says, it can't be a required check. AI-assisted (Claude Code): review by a read-only agent, finding 3 re-checked by hand against the diff.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 16:08 UTC · original

Re-check of my CHANGES_REQUESTED at head ade227657:

  1. Regex backtracking: resolved. The claim line is now ^[ \t]{0,128}claiming:[ \t]{0,128}([^\r\n]{0,4096})$, bodies are capped at 65,536 characters, and the ID patterns are linear. I timed WORK_ID_RE, ID_LIST_RE and the claim-line regex on adversarial 60k-character inputs (long A-A-A-… runs, A-1, lists with a bad tail, tab and space floods, comma floods). The worst case was 4.5 ms. That matches adrianmjim's finding of no ReDoS.
  2. Budget drain: still open, and broader than I first wrote. reconcile-claims still runs for any issue_comment on #14 (created, edited or deleted) from any account except the bot. There's no author_association filter (coordination-activity.yml:31-38). adrianmjim's comment above measures the bigger version of the same problem: every pull_request_target event recomputes all ~656 open PRs, so one title edit costs about 745 REST calls against a 1,000/hour GITHUB_TOKEN quota. The hourly :17 reconcile plus conflict-label.yml at the same minute already go over it. I agree with his fixes: on PR events, target only the event's head SHA; skip sync on workflow_run; read statuses in bulk with GraphQL; stop on the first 403/429; move the cron off :17.

So my request for changes stands on point 2 only. Point 3 of his review (hidden <!-- claiming: … --> claims that block an ID) is also worth fixing before this goes live.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 16:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/221#issuecomment-7137177568) Re-check of my CHANGES_REQUESTED at head `ade227657`: 1. **Regex backtracking: resolved.** The claim line is now `^[ \t]{0,128}claiming:[ \t]{0,128}([^\r\n]{0,4096})$`, bodies are capped at 65,536 characters, and the ID patterns are linear. I timed `WORK_ID_RE`, `ID_LIST_RE` and the claim-line regex on adversarial 60k-character inputs (long `A-A-A-…` runs, `A-1, ` lists with a bad tail, tab and space floods, comma floods). The worst case was 4.5 ms. That matches adrianmjim's finding of no ReDoS. 2. **Budget drain: still open, and broader than I first wrote.** `reconcile-claims` still runs for any `issue_comment` on #14 (created, edited **or deleted**) from any account except the bot. There's no `author_association` filter (coordination-activity.yml:31-38). adrianmjim's comment above measures the bigger version of the same problem: every `pull_request_target` event recomputes all ~656 open PRs, so one title edit costs about 745 REST calls against a 1,000/hour `GITHUB_TOKEN` quota. The hourly `:17` reconcile plus `conflict-label.yml` at the same minute already go over it. I agree with his fixes: on PR events, target only the event's head SHA; skip sync on `workflow_run`; read statuses in bulk with GraphQL; stop on the first 403/429; move the cron off `:17`. So my request for changes stands on point 2 only. Point 3 of his review (hidden `<!-- claiming: … -->` claims that block an ID) is also worth fixing before this goes live. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/221/head:github-bot/gh-221'
git switch 'github-bot/gh-221'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-221'
git switch 'github-bot/gh-221'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-221'
git switch 'github-bot/gh-221'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-221'
git switch 'main'
git merge --squash 'github-bot/gh-221'
git switch 'main'
git merge --ff-only 'github-bot/gh-221'
git switch 'main'
git merge 'github-bot/gh-221'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.