Skip to content

Feat(forks): Require an expiring pool token - #232

Merged
ModeSevenIndustrialSolutions merged 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-220
Nov 23, 2026
Merged

ModeSevenIndustrialSolutions merged 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-220

Conversation

@lf-releng-code-monkey-bot

@lf-releng-code-monkey-bot lf-releng-code-monkey-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #220

Authored by an AI agent; human review required
Command Exit
uv run ruff format scripts/pool_token.py scripts/fork_pool.py 2
uv run ruff check scripts/pool_token.py scripts/fork_pool.py 2
uv run python -B -m unittest discover -s tests 0
AISLOP_NO_TELEMETRY=1 aislop scan --json . 0
AISLOP_NO_TELEMETRY=1 prek run --files README.md docs/DESIGN.md scripts/fork_pool.py scripts/pool_token.py tests/test_fork_pool.py 1
AISLOP_NO_TELEMETRY=1 prek run --files README.md docs/DESIGN.md scripts/fork_pool.py scripts/pool_token.py tests/test_fork_pool.py 0

The github-code-monkey-bot workflow opened this pull request.
Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.

Round 1 of revision, on its base. It set out to fix the failing checks: Audit changes.


Requires the fork pool token to expire, as #220 asks. check_token reads GitHub-Authentication-Token-Expiration from the gh api --include user reply it already reads. A missing header, one it cannot parse, or an expiry more than 90 days ahead fails the forks job before any write and names the date. An expiry 14 days away or less passes, with a ::warning on every run. The scope check runs first and has not changed. DESIGN.md §10.6, its failure-mode row and the README state the rule and the rotation it implies.

Commits:

  1. Test(forks): Add expected-fail token expiry tests: covers no header, an unparsable one, more than 90 days ahead, within 14 days, an expiry in between, and extra scopes still refused.
  2. Feat(forks): Require an expiring pool token: the check, the docs, and the test markers removed.

This round

The Audit changes job failed the aislop gate with complexity/file-too-large on scripts/fork_pool.py. The expiry check had grown that file to 445 lines, and aislop flags anything above 441. The token check (token_identity, check_expiry, check_token, PoolError and their constants) now lives in a new scripts/pool_token.py, which fork_pool.py imports. That leaves fork_pool.py at 328 lines and pool_token.py at 137. Behaviour has not changed. DESIGN.md §10.6 and its script table name the new module. The fix is amended into the Feat commit, and the branch stays on its original base.

Checks run

  • uv run python -B -m unittest discover -s tests: 1719 tests, OK
  • prek run --files <the five changed files>: every hook passed, aislop included
  • aislop scan --json .: no diagnostics
  • uv run ruff … exited 2 because ruff is not in the project's uv environment. The prek ruff and ruff format hooks ran in its place and passed.

For the reviewer

PoolError moved to pool_token.py along with the check that raises it. fork_pool.py re-imports it, so its callers and the tests still use fork_pool.PoolError and fork_pool.check_token.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the token-expiry enforcement change.

No open issues 🎉

What changed in this PR

Adds expiry enforcement for the classic fork pool token, addressing #220 and limiting how long a leaked credential remains usable.

Changes:

  • Rejects missing, unreadable, or more-than-90-day expiries before fork operations; warns when 14 days or less remain.
  • Adds expiry validation tests while preserving scope-check coverage.
  • Documents token creation limits and rotation guidance.
File Description
tests/​test_fork_pool.py Tests expiry failures, warnings, silent acceptance, and early stopping.
scripts/​fork_pool.py Reads the expiry header and enforces expiry limits and warnings.
README.md Adds rollout guidance for token expiry and rotation.
docs/​DESIGN.md Explains expiry safeguards, rotation, and failure handling.

Review effort: Balanced

lf-releng-code-monkey-bot Bot and others added 2 commits November 23, 2026 13:04
The fork pool token is a classic token, which may be created with no
expiry and can write to every repository its account can. Pin the
expiry rule before it exists: no expiry header, an unparsable one or
one more than 90 days ahead fails before any fork is read; one within
14 days warns and goes ahead; one in between passes silently.

The existing scope tests now carry a valid expiry, so they show the
scope check still refuses extra scopes once the expiry passes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
The fork pool token is a classic token, which cannot be limited to
organisations and may be created with no expiry; a leaked one could
add API-signed commits to the forks that head open pull requests for
as long as it lives.

check_token now reads GitHub-Authentication-Token-Expiration from the
reply it already reads. No header, an unparsable one, or an expiry
more than 90 days ahead fails the job before any write, naming the
date; an expiry 14 days away or less passes with a warning on every
run, so the rotation falls due before the job stops. The scope check
runs first and is unchanged. DESIGN.md section 10.6, its failure-mode
row and the README state the rule and the rotation it implies.

The token check moves from fork_pool.py into a new pool_token.py,
which fork_pool.py imports. Review round 1: the aislop gate failed
the Audit changes job with complexity/file-too-large on fork_pool.py
(445 lines, flagged above 441); the split leaves it at 328 lines and
pool_token.py at 139, with no change in behaviour.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the token-expiry validation change.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.

The change appears sound: expiry checks enforce the documented policy before fork operations, and the module extraction preserves existing scope validation. No actionable defects found in the reviewed diff.

Antagonistic round 1 of 3.


Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit 55f2c8c into lfreleng-actions:main Nov 23, 2026
36 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the code-monkey/issue-220 branch November 23, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat(forks): Require an expiring pool token

2 participants