Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .agents/rules/checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions tools/checks/context-budget.sh
Original file line number Diff line number Diff line change
@@ -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

7 changes: 5 additions & 2 deletions tools/checks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -76,3 +77,5 @@ if [ -n "$unlicensed" ]; then
exit 1
fi

bash "$(dirname "$(readlink -f "$0")")/context-budget.sh" || exit 1

1 change: 1 addition & 0 deletions tools/checks/project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading