[PR #386] [MERGED] feat(agents-md-integrity): add total and per-line character limits #389

Closed
opened 2026-10-26 22:39:17 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/github-workflows/pull/386
Author: @mattmillerai
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @mattmillerai

Base: main ← Head: agents-md-char-ceiling


📝 Commits (3)

  • 5e3366d feat(agents-md-integrity): add total and per-line character limits
  • 4592f38 fix(agents-md-integrity): count both CRLF characters toward the char ceiling
  • 6fdc55c fix(agents-md-integrity): reject a non-integer char limit; split lines on CR/LF only

📊 Changes

7 files changed (+500 additions, -34 deletions)

View changed files

📝 .github/agents-md-integrity/README.md (+29 -3)
📝 .github/agents-md-integrity/check_agents_md.py (+171 -26)
📝 .github/agents-md-integrity/tests/test_check_agents_md.py (+207 -0)
📝 .github/workflows/agents-md-integrity.yml (+46 -4)
📝 .github/workflows/test-agents-md-integrity.yml (+31 -0)
📝 README.md (+1 -1)
📝 docs/callers/agents-md-integrity.md (+15 -0)

📄 Description

ELI-5

The AGENTS.md checker only counted lines, so a file could stay at 111 lines and still be 200k+ characters, because one paragraph counts as one line. Everything in that file gets loaded into every agent session. This PR adds character limits too, on the root file and on every nested AGENTS.md. By default they only warn, so no caller goes red when it bumps its pin.

What changed

New optional inputs on agents-md-integrity.yml (env MAX_CHARS / WARN_CHARS / MAX_LINE_CHARS on the script):

Input Default Over it
max_chars 0 (off) fails. 40000 is suggested, matching Claude Code's oversized-memory-file floor.
warn_chars 25000 warns
max_line_chars 3000 warns (catches the "paragraph as one line" case)
  • These apply to the root agents file and every nested AGENTS.md the walk already visits. exclude_paths still prunes as before.
  • Each finding names the file, its size in chars (plus a chars/4 token estimate), its longest lines (L42 (89015 chars)), and the fix: move the rationale into docs/agents/ and leave a one-line pointer (a plain link, not an @ import).
  • Characters count as decoded, with CRLF as two; lines split on CRLF/LF/CR only (not splitlines()), so L<n> matches an editor.
  • The line checks are unchanged. They now live in one _size_findings helper that both the root and nested paths call, and the existing messages are kept word for word.
  • Docs updated: workflow header + input descriptions, docs/callers/agents-md-integrity.md (Inputs table + a "warn-first" gotcha), the checker README, and the catalog row in README.md.

Judgment calls

  • max_chars defaults to off, not 40000. The ticket asks that existing callers not break, and a hard 40000 default would fail every oversized caller the day it bumps. The two warn limits default on, so oversized files show up right away without failing anything.
  • max_line_chars is always warn-only. The ticket asks for "warn-only by default" but only names three inputs. I didn't add a fourth input just to escalate long lines to failures; max_chars already supplies the failing ceiling.
  • A character limit that is not a whole number (40k, 40000.5) is a config error (exit 2), not a fallback to the default. For max_chars the default is "off", so a fallback would quietly disable the ceiling the caller asked for. 40000.0 is accepted. max_lines / warn_lines keep their existing fallback.

Residual

  • The incident repo's PR (named on the ticket) was not exercised. I couldn't open it from this sandbox. The fixtures reproduce its shape from the ticket's numbers (111 lines, one 89,015-char line), not its actual files. Once a caller bumps, that repo should be checked with max_chars: 40000 set.
  • No caller sets the new inputs yet. Turning on max_chars fleet-wide means each caller sets it after its warnings are cleared. I didn't sweep the callers to count how many files are currently over 25000 chars or have lines over 3000 chars, so I don't know how many would warn after a bump.
  • Pre-existing: a malformed MAX_LINES / WARN_LINES value is still silently replaced by its default. Only the new character limits are strict.
  • CLAUDE.md itself is not measured, so Claude-only text below the @AGENTS.md import escapes the character limits. This is proposed as a follow-up.

Provenance

  • Authored by: agent-work loop
  • Verified:
    • Tests: agents-md-integrity suite green (62 tests). New tests cover pass, warn, fail, at-limit, 0=off, nested, exclusions, line checks unchanged, env wiring, defaults-pass, CRLF counted as two, U+2028/NEL not splitting a line, and exit 2 on a non-integer limit. The CRLF test was confirmed to fail without the fix.
    • New smoke step in test-agents-md-integrity.yml (default warns + exit 0; MAX_CHARS=40000 exits 1) passes locally.
    • workflow-pins suite green, including the declared-vs-documented input drift harness.
    • Lints clean: check_workflow_pins.py, check-org-repo-literals.sh, check_agents_md.py --root ..
    • Not run: a real Actions run of the reusable workflow (only CI can run it).
  • Deviations: max_line_chars cannot be escalated to a failure (it is warn-only, see Judgment calls).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/github-workflows/pull/386 **Author:** [@mattmillerai](https://github.com/mattmillerai) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@mattmillerai](https://github.com/mattmillerai) **Base:** `main` ← **Head:** `agents-md-char-ceiling` --- ### 📝 Commits (3) - [`5e3366d`](https://github.com/Comfy-Org/github-workflows/commit/5e3366d979b33acc4f78ced19c25720cb1087c19) feat(agents-md-integrity): add total and per-line character limits - [`4592f38`](https://github.com/Comfy-Org/github-workflows/commit/4592f38274c0ca4d3e54c17f3c16c398345366f9) fix(agents-md-integrity): count both CRLF characters toward the char ceiling - [`6fdc55c`](https://github.com/Comfy-Org/github-workflows/commit/6fdc55c588d2a01f962aa6fbfbff8da646a4c894) fix(agents-md-integrity): reject a non-integer char limit; split lines on CR/LF only ### 📊 Changes **7 files changed** (+500 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `.github/agents-md-integrity/README.md` (+29 -3) 📝 `.github/agents-md-integrity/check_agents_md.py` (+171 -26) 📝 `.github/agents-md-integrity/tests/test_check_agents_md.py` (+207 -0) 📝 `.github/workflows/agents-md-integrity.yml` (+46 -4) 📝 `.github/workflows/test-agents-md-integrity.yml` (+31 -0) 📝 `README.md` (+1 -1) 📝 `docs/callers/agents-md-integrity.md` (+15 -0) </details> ### 📄 Description ## ELI-5 The AGENTS.md checker only counted **lines**, so a file could stay at 111 lines and still be 200k+ characters, because one paragraph counts as one line. Everything in that file gets loaded into every agent session. This PR adds **character** limits too, on the root file and on every nested `AGENTS.md`. By default they only warn, so no caller goes red when it bumps its pin. ## What changed New optional inputs on `agents-md-integrity.yml` (env `MAX_CHARS` / `WARN_CHARS` / `MAX_LINE_CHARS` on the script): | Input | Default | Over it | |---|---|---| | `max_chars` | `0` (off) | **fails**. `40000` is suggested, matching Claude Code's oversized-memory-file floor. | | `warn_chars` | `25000` | warns | | `max_line_chars` | `3000` | warns (catches the "paragraph as one line" case) | - These apply to the root agents file **and** every nested `AGENTS.md` the walk already visits. `exclude_paths` still prunes as before. - Each finding names the file, its size in chars (plus a chars/4 token estimate), its longest lines (`L42 (89015 chars)`), and the fix: move the rationale into `docs/agents/` and leave a one-line pointer (a plain link, not an `@` import). - Characters count as decoded, with CRLF as two; lines split on CRLF/LF/CR only (not `splitlines()`), so `L<n>` matches an editor. - The line checks are unchanged. They now live in one `_size_findings` helper that both the root and nested paths call, and the existing messages are kept word for word. - Docs updated: workflow header + input descriptions, `docs/callers/agents-md-integrity.md` (Inputs table + a "warn-first" gotcha), the checker README, and the catalog row in `README.md`. ### Judgment calls - **`max_chars` defaults to off, not `40000`.** The ticket asks that existing callers not break, and a hard 40000 default would fail every oversized caller the day it bumps. The two warn limits default **on**, so oversized files show up right away without failing anything. - **`max_line_chars` is always warn-only.** The ticket asks for "warn-only by default" but only names three inputs. I didn't add a fourth input just to escalate long lines to failures; `max_chars` already supplies the failing ceiling. - A character limit that is not a whole number (`40k`, `40000.5`) is a config error (exit 2), not a fallback to the default. For `max_chars` the default is "off", so a fallback would quietly disable the ceiling the caller asked for. `40000.0` is accepted. `max_lines` / `warn_lines` keep their existing fallback. ## Residual - **The incident repo's PR (named on the ticket) was not exercised.** I couldn't open it from this sandbox. The fixtures reproduce its *shape* from the ticket's numbers (111 lines, one 89,015-char line), not its actual files. Once a caller bumps, that repo should be checked with `max_chars: 40000` set. - **No caller sets the new inputs yet.** Turning on `max_chars` fleet-wide means each caller sets it after its warnings are cleared. I didn't sweep the callers to count how many files are currently over 25000 chars or have lines over 3000 chars, so I don't know how many would warn after a bump. - Pre-existing: a malformed `MAX_LINES` / `WARN_LINES` value is still silently replaced by its default. Only the new character limits are strict. - `CLAUDE.md` itself is not measured, so Claude-only text below the `@AGENTS.md` import escapes the character limits. This is proposed as a follow-up. ## Provenance - **Authored by:** agent-work loop - **Verified:** - Tests: `agents-md-integrity` suite green (62 tests). New tests cover pass, warn, fail, at-limit, `0`=off, nested, exclusions, line checks unchanged, env wiring, defaults-pass, CRLF counted as two, U+2028/NEL not splitting a line, and exit 2 on a non-integer limit. The CRLF test was confirmed to fail without the fix. - New smoke step in `test-agents-md-integrity.yml` (default warns + exit 0; `MAX_CHARS=40000` exits 1) passes locally. - `workflow-pins` suite green, including the declared-vs-documented input drift harness. - Lints clean: `check_workflow_pins.py`, `check-org-repo-literals.sh`, `check_agents_md.py --root .`. - Not run: a real Actions run of the reusable workflow (only CI can run it). - **Deviations:** `max_line_chars` cannot be escalated to a failure (it is warn-only, see Judgment calls). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 22:39:17 +00:00
Sign in to join this conversation.
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
Comfy-Org/github-workflows#389
No description provided.