diff --git a/.agents/rules/checks.md b/.agents/rules/checks.md index cd9d01b..43d85b9 100644 --- a/.agents/rules/checks.md +++ b/.agents/rules/checks.md @@ -37,6 +37,16 @@ gate with: ln -s ../../tools/checks/pre-commit .git/hooks/pre-commit +`context-budget.sh` holds the AGENTS.md at the top of a checkout, as the index holds it, to a ceiling +of bytes, and `pre-commit` runs it, so it fails the commit and the `Checks` run of every tree that runs +the mount's gate: each session and each workflow agent that loads CLAUDE.md loads harness/AGENTS.md and +the project's AGENTS.md before its first turn, and from 2026-10-09 to 2026-11-22 the one file they +replaced grew from 42268 bytes to the 66014 the two weigh (luainkernel/harness#6, D172 D). The +harness's ceiling is a line of the check, and a project's the `budget` key of its +`.agents/harness.conf`; a project that names none is not read. A lesson that needs room moves an older +passage to the check, the skill or the path rule that holds its subject, and a pull request that moves +a ceiling says why. + `advisory.sh` runs the heuristic checks over a change, the file checks over the files it adds or modifies and the commit checks over its commits, the harness's and the project's own its `.agents/harness.conf` names under `advisory` and `commit`: the list the `Checks` workflow annotates a pull request diff --git a/tools/checks/context-budget.sh b/tools/checks/context-budget.sh new file mode 100755 index 0000000..92233a3 --- /dev/null +++ b/tools/checks/context-budget.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# SPDX-FileCopyrightText: (c) 2026 Ring Zero Desenvolvimento de Software LTDA +# SPDX-License-Identifier: MIT OR GPL-2.0-only +# +# Holds the AGENTS.md at the top of the checkout, as the index holds it, to a ceiling of bytes: every +# session and every workflow agent that loads CLAUDE.md loads it before its first turn +# (luainkernel/harness#6, D172 D). The harness's ceiling is the line below, and a project's the budget +# key of its .agents/harness.conf (project.sh); a project that names none is not read. A pull request +# that moves a ceiling says why. +# Prints what fails and exits 1, silent otherwise. +# Usage: bash tools/checks/context-budget.sh + +. "$(dirname "$(readlink -f "$0")")/project.sh" + +if [ "$(git rev-parse --show-toplevel 2> /dev/null)" -ef "$(harness_root)" ]; then + ceiling=40557 +else + ceiling=$(project_conf budget) +fi +[ -n "$ceiling" ] || exit 0 + +size=$(git show :AGENTS.md 2> /dev/null | wc -c) +[ "$size" -le "$ceiling" ] && exit 0 +echo "AGENTS.md: $size bytes, past its ceiling of $ceiling; a lesson that needs room moves an older passage to the check, the skill or the path rule that holds its subject" +exit 1 + diff --git a/tools/checks/pre-commit b/tools/checks/pre-commit index 4cf9fd1..4efc474 100755 --- a/tools/checks/pre-commit +++ b/tools/checks/pre-commit @@ -5,8 +5,9 @@ # # Pre-commit hook: reject staged text files (C, Lua, Makefile, shell scripts) # missing the trailing blank line the tree requires, any staged file that carries -# the machine it was written on (machine-leak.sh), and a staged source file without -# its copyright and license header. A project with a gate of its own runs this +# the machine it was written on (machine-leak.sh), a staged source file without +# its copyright and license header, and an AGENTS.md past its ceiling +# (context-budget.sh). A project with a gate of its own runs this # from its hook, as its own pre-commit's first step. # Install with: ln -s ../../tools/checks/pre-commit .git/hooks/pre-commit @@ -76,3 +77,5 @@ if [ -n "$unlicensed" ]; then exit 1 fi +bash "$(dirname "$(readlink -f "$0")")/context-budget.sh" || exit 1 + diff --git a/tools/checks/project.sh b/tools/checks/project.sh index 154a5b0..61d6f9f 100644 --- a/tools/checks/project.sh +++ b/tools/checks/project.sh @@ -22,6 +22,7 @@ # range the rev-range checks of its own review-packet.sh runs over a change # repos the other repositories that mount the harness, owner/name, whose pull requests and issues # the post guards read as the checkout's (gh_family in commands.sh) +# budget the ceiling in bytes of the project's AGENTS.md (context-budget.sh) # A key the project leaves out gives nothing: no path, no check, no repository. # the checkout of the harness this file is in, through any link to it