Skip to content

CI: Flag repositories sharing a Scorecard slot - #404

Open
lf-releng-code-monkey-bot[bot] wants to merge 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-400
Open

lf-releng-code-monkey-bot[bot] wants to merge 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-400

Conversation

@lf-releng-code-monkey-bot

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

Copy link
Copy Markdown
Contributor

Closes #400

Authored by an AI agent; human review required
Command Exit
uv run pytest -q tests/test_scorecard_slots.py -k hash_in_block (with fix) 0
uv run pytest -q tests/test_scorecard_slots.py -k hash_in_block (old reader) 1
uvx zizmor --persona auditor .github/workflows/scorecard-slots.yaml 0
AISLOP_NO_TELEMETRY=1 bash scripts/agents/aislop-gate.sh 39799460cf292525bf1dcc85900cd3a8a827ca68 (ruff missing) 3
uv run pytest -q tests 0
uvx gitlint --commits 39799460..HEAD 0
AISLOP_NO_TELEMETRY=1 bash scripts/agents/aislop-gate.sh 39799460cf292525bf1dcc85900cd3a8a827ca68 0
uvx zizmor --persona auditor .github/workflows/ 0
prek run --files .github/scripts/scorecard_schedule.py .github/scripts/tests/test_scorecard_slots.py .github/workflows/scorecard-slots.yaml (before ruff-format fix) 1
prek run --files .github/scripts/scorecard_schedule.py .github/scripts/scorecard_slots.py .github/scripts/tests/test_scorecard_slots.py .github/workflows/scorecard-slots.yaml README.md 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 10 of revision, on its base.


Adds a weekly check for repositories that share an OpenSSF Scorecard slot (#400).

  • .github/scripts/scorecard_slots.py and scorecard_schedule.py read each repository's Scorecard schedule. They report cron values that two or more repositories share, and schedules that are not weekly on Sunday. For each repository that should move, they name a free slot. In a shared slot, a template keeps the slot first. After that, the repository with the oldest commit date on its cron line keeps it (read from the blame). The offline suite sits in .github/scripts/tests/test_scorecard_slots.py.
  • .github/workflows/scorecard-slots.yaml runs every Monday under lfreleng-actions. It fetches the repository list, the workflow files and their blame. It writes the job summary and posts to Slack only when there is a finding. A fork can dispatch it, but it does not post. It is a separate workflow rather than a job in repo-audit.yaml, because that workflow targets a hard-coded organisation and has no owner gating.
  • The README describes the check next to the other scheduled workflows.

Round 10

  • Same commit for files and blame (workflow commit): the first GraphQL query now returns the default branch tip's oid along with both workflow files. The blame query reads object(oid:) from that same commit, so a push between the two requests can no longer pair a cron line with blame from a different version.
  • # in block scalars (script commit): comments are now stripped from every line except block-scalar text. The schedule reader also no longer reads that text as keys. As a result, cron: |- above 4 0 * * 0 # text now reads as the whole scalar and is reported. There is a regression test covering literal and folded scalars, and it fails on the old reader.

Checks run

uv run pytest -q tests (125 passed), prek run --files over every changed file, gitlint, the aislop gate, and zizmor --persona auditor .github/workflows/ all pass. I installed ruff so the aislop lint engine could run.

For the reviewer

Commit.file(path:) and Repository.object(oid:) are standard GitHub GraphQL fields. I could not run them against the live API from this runner, so the first dispatch is worth watching.

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.

🟡 Changes recommended

Schedule parsing misses valid entries and reads commented-out cron values, producing inaccurate audits, while manual dispatch fails for personal-account forks.

4 open issues
What changed in this PR

Adds a weekly Scorecard schedule audit to help keep organisation repositories on distinct Sunday slots, including repositories created from templates.

Changes:

  • Detects shared slots and non-Sunday schedules, suggests unused slots, and generates a job-summary table.
  • Adds a Monday workflow to collect schedules and blame data, with owner-gated scheduling and Slack notifications.
  • Adds offline regression tests and documents the audit and Slack setup.
File Description
README.md Documents the audit, slot-selection rules, and notification behavior.
.github/​workflows/​scorecard-slots.yaml Collects repository schedules and runs the weekly audit with Slack reporting.
.github/​scripts/​tests/​test_scorecard_slots.py Tests collisions, template priority, slot allocation, and input handling.
.github/​scripts/​scorecard_slots.py Parses schedules, identifies findings, and renders suggested moves.

Review effort: Balanced

Comment thread .github/scripts/scorecard_slots.py Resolved
Comment thread .github/scripts/scorecard_slots.py Resolved
Comment thread .github/scripts/scorecard_slots.py Resolved
Comment thread .github/workflows/scorecard-slots.yaml Resolved

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.

🟡 Changes recommended

The schedule parser truncates valid unquoted cron lists at commas and misses inline trigger mappings, hiding scheduled runs and collisions and potentially producing incorrect slot suggestions.

2 open issues

Review effort: Balanced

Comment thread .github/scripts/scorecard_slots.py Resolved
Comment thread .github/scripts/scorecard_slots.py Resolved

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.

🟡 Changes recommended

The schedule parser can misread sibling cron inputs and block scalars or omit quoted YAML keys, causing false findings, missed collisions, and recommendations for already-occupied slots.

3 open issues

Review effort: Balanced

Comment thread .github/scripts/scorecard_slots.py Resolved
Comment thread .github/scripts/scorecard_slots.py Resolved
Comment thread .github/scripts/scorecard_slots.py Resolved

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.

🟡 Changes recommended

Schedule extraction can hide or invent collisions, while text-based timestamp sorting can select the wrong repository to retain a shared slot.

2 open issues

Review effort: Balanced

Comment thread .github/scripts/scorecard_schedule.py Resolved
Comment thread .github/scripts/scorecard_slots.py Resolved

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.

🟡 Changes recommended

Equivalent cron month expressions are not normalized, causing false Sunday-cadence warnings and missed collision detection.

1 open issue

Review effort: Balanced

Comment thread .github/scripts/scorecard_slots.py Resolved

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.

🟡 Changes recommended

Valid anchored schedules and multiline quoted cron values are misparsed, causing false schedule findings and missed collision detection.

2 open issues

Review effort: Balanced

Comment thread .github/scripts/scorecard_schedule.py Resolved
Comment thread .github/scripts/scorecard_schedule.py Resolved

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.

🟡 Changes recommended

The schedule reader mishandles multiline plain scalars and double-quoted YAML escapes, causing false off-Sunday findings and missed schedule collisions.

2 open issues

Review effort: Balanced

Comment thread .github/scripts/scorecard_schedule.py Resolved
Comment thread .github/scripts/scorecard_schedule.py Resolved

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.

🟡 Changes recommended

Cron aliases are treated as literal strings rather than resolved values, causing false Sunday-schedule violations and missed schedule collisions in valid workflows.

1 open issue

Review effort: Balanced

Comment thread .github/scripts/scorecard_schedule.py Resolved

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.

🟡 Changes recommended

Schedule parsing mishandles quoted literals, multiline anchors, and block-scalar contents, allowing invalid schedules to pass and real collisions to go undetected.

3 open issues

Review effort: Balanced

Comment thread .github/scripts/scorecard_schedule.py Resolved
Comment thread .github/scripts/scorecard_schedule.py Resolved
Comment thread .github/scripts/scorecard_schedule.py Resolved

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.

🟡 Changes recommended

File and blame requests are not pinned to the same commit, risking incorrect slot reassignment, and comment stripping can silently accept invalid block-scalar cron values.

2 open issues

Review effort: Balanced

Comment thread .github/workflows/scorecard-slots.yaml Resolved
Comment thread .github/scripts/scorecard_schedule.py Resolved
lf-releng-code-monkey-bot Bot and others added 2 commits November 27, 2026 00:11
Each repository runs OpenSSF Scorecard in its own Sunday slot, but a
repository created from a template inherits the template's cron line
and stays on its minute. Add a script that reads every repository's
Scorecard schedule and reports cron values two or more repositories
share, and schedules that are not weekly on Sunday.

For each repository that should move it names a free slot: the first
unused grid slot (minute-of-day 4 + 9k), or once the grid is full the
first unused minute off :00 and :30. In a shared slot a template keeps
it, then the oldest commit date of the cron line, from the blame, then
the oldest repository.

The script takes a data directory a workflow fills, so its suite runs
offline. The suite imports nothing from pytest, as the other suites in
.github/scripts do for the type-checking hooks, so it lands with the
code rather than as expected-fail tests first.

Review round 1 (Copilot) on the schedule parser:

- A cron value in a trailing YAML comment was read as a schedule.
  Lines now lose any unquoted comment before they are scanned.
- A flow sequence opened on the 'schedule:' line and closed on a
  later one was skipped. The parser now follows it until its
  brackets close, keeping each cron's own line number.
- A '- cron:' item at the same indentation as 'schedule:', which YAML
  allows, was skipped. Same-depth sequence items now count; the next
  mapping key still ends the schedule.

Each has a regression case in the suite.

Review round 2 (Copilot) on the schedule parser:

- A trigger written inline, 'on: {schedule: [{cron: ...}]}', was not
  read, so its repository looked unscheduled and its minute free.
  'schedule:' is now found as a key inside a flow mapping too.
- A plain cron value in block context was cut at a comma, so
  '- cron: 4 0 * * 0,1' read as Sunday only. A comma, '}' or ']' now
  ends a plain value only inside a flow collection.

Each has a regression case in the suite.

Review round 3 (Copilot) on the schedule parser:

- A quoted key, '"schedule":' or "- 'cron': ...", was not matched,
  so its schedule was skipped and its minute looked free. Single-
  and double-quoted keys now match as plain ones do.
- A block scalar value, 'cron: >-' or 'cron: |' with the expression
  on the next line, read as the literal '>-'. The value is now taken
  from the lines indented below the key, and keeps the key's line.
- In 'on: {schedule: [...], workflow_dispatch: {inputs: {cron: ...}}}'
  the dispatch input's 'cron' key was read as a schedule. Only the
  schedule's own flow value is now scanned.

Each has a regression case in the suite. The schedule reader moves to
scorecard_schedule.py beside the script, which imports it as
fuzz_publish.py imports its siblings, keeping both files within
aislop's file-size limit.

Review round 4 (Copilot):

- 'schedule:' was read wherever it appeared, so a dispatch input of
  that name could hide the real trigger and a YAML example in a
  'run: |' script could add a cron. Only the 'schedule' key of the
  top-level 'on:' mapping is read now, in block or flow style, at the
  mapping's own indentation or flow depth.
- Blame dates keep the committer's offset, so sorting them as text
  could pick the wrong holder of a shared slot. They are compared as
  UTC instants now; an unknown date still sorts last.

Each has a regression case in the suite.

Review round 5 (Copilot): the weekly check read the cron's spelling,
not its cadence, so '4 0 * 1-12 0' or '4 0 * */1 0' was reported as
not weekly on Sunday and did not group with '4 0 * * 0'. Each field is
now expanded to the values it matches, names and steps included, so
equivalent spellings classify and group alike. A day of month must
still start with '*': cron ORs a restricted day of month with the
weekday, so '1-31' runs daily and stays a finding.

Each has a regression case in the suite.

Review round 6 (Copilot) on the schedule parser:

- A quoted cron value spread over lines, 'cron: "4 0' then an indented
  '* * 0"', read as '"4 0': a false off-Sunday finding, and its
  minute looked free. Such a value is now folded onto its key's line
  before it is read, and keeps that line for the blame.
- An anchor or tag on a value, 'schedule: &weekly' or 'on: &trigger',
  sent the reader down the flow path and it found no cron. Anchors and
  tags are now skipped before block or flow parsing is chosen, on
  'on', 'schedule' and 'cron' alike.

Each has a regression case in the suite.

Review round 7 (Copilot) on the schedule parser:

- A double-quoted value kept its escapes, so 'cron: "4 0\u0020* * 0"'
  read as a false off-Sunday finding and missed its shared slot. YAML
  escapes are now decoded, a '\' ending a line joins it to the next,
  and a single-quoted value reads '' as one quote.
- A plain value spread over lines, 'cron: 4 0' then an indented
  '* * 0', read as '4 0'. In block style the indented lines below the
  key now complete it; in flow style, including a flow item opened in
  a block sequence, the collection's lines are joined before it is
  read. The cron keeps its key's line for the blame.

Each has a regression case in the suite.

Review round 8 (Copilot): an alias in place of a cron value,
'cron: *weekly' with '&weekly' on a scalar elsewhere in the file, read
as the literal '*weekly': a false off-Sunday finding, and its slot
looked free. A plain alias now reads its anchor's value, quoted,
plain, multi-line or block scalar, and keeps its cron key's line. An
aliased 'schedule: *name' reads the node its anchor marks.

Each has a regression case in the suite.

Review round 9 (Copilot) on alias resolution:

- A quoted '*weekly', 'cron: "*weekly"', was unquoted before alias
  resolution and read an anchor's value, masking an invalid schedule.
  A quoted value now stays quoted until it is read, so only a plain
  '*name' is an alias; a block scalar's text is always literal.
- Anchor discovery searched block scalar text, so '&weekly' inside a
  'DOCUMENTATION: |' value shadowed the real anchor and a later
  'cron: *weekly' claimed the wrong minute. Block scalar text lines are
  now found first and skipped.
- An anchored value over several lines resolved in part: a quoted
  '&w "4 0' then '* * 0"' kept its quotes, and a plain flow value
  stopped at the line end. Quoted values are now folded wherever a
  value opens, after an anchor included, and a plain flow value runs
  on to its ',', '}' or ']'.

Each has a regression case in the suite that fails on the old reader.

Review round 10 (Copilot): comments were removed before block scalar
text was found, so 'cron: |-' above '4 0 * * 0 # text' read as
'4 0 * * 0' and passed, though the scalar keeps the '#' and is not a
valid weekly cron. Comments are now removed from every line but a
block scalar's text, and the schedule reader skips that text as a key.

It has a regression case, literal and folded, that fails on the old
reader.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
Run scorecard_slots.py every Monday against the organisation the
workflow runs in. The workflow lists the public, non-archived, non-fork
repositories, fetches each Scorecard workflow file and its blame, and
leaves every decision to the script, which writes the job summary.

It posts to Slack, as repo-audit.yaml does, only when there is a
finding. The schedule and the Slack post run only under
lfreleng-actions, so a fork can dispatch the check without posting.

It is a workflow of its own rather than a job in repo-audit.yaml: that
workflow audits the profile README of a hard-coded organisation with
no owner gating, while this one needs both a different target and the
gating.

Review round 1 (Copilot): a fork owned by a personal account has no
/orgs/ endpoint, so a manual dispatch failed listing repositories.
The step now reads the owner's account type and lists a user's own
repositories through /users/. The schedule and Slack guards still
test github.repository_owner.

Review round 10 (Copilot): the files were read at HEAD and the blame
at the default branch tip in a separate request, so a push between
them could pair a cron line with another version's blame. The first
query now returns the tip's oid with both files, and the blame reads
that same commit.

Co-authored-by: Copilot <[email protected]>
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.

🟡 Changes recommended

Line-local comment stripping removes literal content from multiline quoted cron values, causing non-weekly schedules to go undetected and suppressing Slack alerts.

1 open issue

Review effort: Balanced

'cron:' or an anchor. A block scalar's text is data, not YAML, so it
keeps any '#' it holds and is neither folded nor searched for anchors.
"""
lines, content, parent = [strip_comment(line) for line in raw], set[int](), -1

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI CI and tests updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Flag repositories sharing a Scorecard slot

1 participant