Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(stamphog): raise the default size ceilings to 50 files and 1200 lines (#127203)

Julian Bez7dc3d14cbe32
diff --git a/.stamphog/README.md b/.stamphog/README.md
index 8bdd67697332..3f2b382e40fb 100644
--- a/.stamphog/README.md
+++ b/.stamphog/README.md
@@ -25,7 +25,7 @@ A path rule cannot see these, because the marker sits in product code or in a bu
`ownership` comes from the shipped default, which declares one `hogli-resolver` source at the repo root, so stamphog reads the same merged view the reviewer auto-assigner builds.
-`overrides` comes from the shipped default and grants folders a ceiling of 50 files and 1000 lines.
+`overrides` comes from the shipped default and grants folders a ceiling of 75 files and 1500 lines.
Two folders currently take it up: [`products/desktop/`](../products/desktop/AGENT_APPROVALS.md) and [`products/visual_review/`](../products/visual_review/AGENT_APPROVALS.md).
## Proposing a change
diff --git a/products/desktop/AGENT_APPROVALS.md b/products/desktop/AGENT_APPROVALS.md
index 39b8516fa5eb..a9b4a34edc73 100644
--- a/products/desktop/AGENT_APPROVALS.md
+++ b/products/desktop/AGENT_APPROVALS.md
@@ -1,7 +1,7 @@
---
stamphog:
size_gate:
- max_lines: 1000
+ max_lines: 1500
---
Desktop PRs are often tall: one feature usually lands across packages/core, packages/ui and the app in a single PR, so substantive line counts run past the global ceiling without adding review risk.
diff --git a/products/stamphog/README.md b/products/stamphog/README.md
index 607638bd4524..dd56cc30f124 100644
--- a/products/stamphog/README.md
+++ b/products/stamphog/README.md
@@ -99,8 +99,8 @@ A repository that only wants a bigger size gate and one more pattern in a deny c
```yaml
size_gate:
- max_lines: 1000
- max_files: 40
+ max_lines: 1500
+ max_files: 60
deny:
infra_cicd:
match:
diff --git a/products/stamphog/backend/tests/test_integration.py b/products/stamphog/backend/tests/test_integration.py
index a16b69e0997d..1656003ba2f5 100644
--- a/products/stamphog/backend/tests/test_integration.py
+++ b/products/stamphog/backend/tests/test_integration.py
@@ -319,7 +319,7 @@ def _big_api_file(filename: str, additions: int) -> dict:
return {**_api_file(filename), "additions": additions, "deletions": 0}
-_LIFTING_FOLDER_FILE = "---\nstamphog:\n size_gate:\n max_lines: 1000\n---\nTall PRs are normal here.\n"
+_LIFTING_FOLDER_FILE = "---\nstamphog:\n size_gate:\n max_lines: 1500\n---\nTall PRs are normal here.\n"
@pytest.mark.parametrize(
@@ -356,10 +356,16 @@ _LIFTING_FOLDER_FILE = "---\nstamphog:\n size_gate:\n max_lines: 1000\n---\n
id="pending-migration",
),
pytest.param(
- [_big_api_file("lib/big.py", 900)], None, False, False, "final:REFUSED", "too large", id="size-folders-read"
+ [_big_api_file("lib/big.py", 1300)],
+ None,
+ False,
+ False,
+ "final:REFUSED",
+ "too large",
+ id="size-folders-read",
),
pytest.param(
- [_big_api_file("lib/big.py", 900)],
+ [_big_api_file("lib/big.py", 1300)],
None,
False,
True,
@@ -370,7 +376,7 @@ _LIFTING_FOLDER_FILE = "---\nstamphog:\n size_gate:\n max_lines: 1000\n---\n
# sym/AGENT_APPROVALS.md is a symlink out of the repo, which the sandbox would follow, so the
# folder files are unknown and the size band stays with the sandbox.
pytest.param(
- [_big_api_file("sym/big.py", 900)],
+ [_big_api_file("sym/big.py", 1300)],
None,
False,
False,
@@ -380,7 +386,7 @@ _LIFTING_FOLDER_FILE = "---\nstamphog:\n size_gate:\n max_lines: 1000\n---\n
),
# The PR head's src/AGENT_APPROVALS.md lifts the ceiling, so the sandbox review must decide.
pytest.param(
- [_big_api_file("src/deep/big.py", 900)],
+ [_big_api_file("src/deep/big.py", 1300)],
None,
False,
False,
diff --git a/products/stamphog/packages/pr-approval-agent/README.md b/products/stamphog/packages/pr-approval-agent/README.md
index 1ecdf6e738ac..d6916e1e6a9a 100644
--- a/products/stamphog/packages/pr-approval-agent/README.md
+++ b/products/stamphog/packages/pr-approval-agent/README.md
@@ -83,10 +83,11 @@ Deny-list (hard gate)
│
▼
Size ceiling (hard gate)
- - >800 substantive lines or >30 substantive files → too large for auto-review
- (limits derived from 90 days of denial outcomes: the friction cluster of
- denied-yet-merged-unchanged PRs sits at 500-750 substantive lines, and past
- ~800 the merged-unchanged rate collapses, so escalation is genuinely right)
+ - >1200 substantive lines or >50 substantive files → too large for auto-review
+ (limits derived from 60 days of size-gate denials and git history: the share
+ of merged PRs that get a follow-up fix on the same files within 14 days rises
+ gently up to ~1200 substantive lines and jumps past it, and people already
+ stamp PRs this size in Slack within minutes)
- A folder's AGENT_APPROVALS.md can raise either ceiling for its own files,
within the `overrides` contract in policy.yml (see "Policy files" below)
- The whole PR still has to fit the most generous ceiling in play, so
@@ -268,8 +269,8 @@ Resolution:
Each scope's files are counted against that scope's own ceiling.
A grant covers exactly the files that resolve to it, which is the nearest valid grant of that key on their chain, and nothing else.
-Example: with a folder ceiling of 50 files and a global ceiling of 20, a PR changing 30 files under that folder plus 19 files elsewhere passes, because each budget fits.
-Add a 21st global file and the PR is denied for the global budget, however much headroom the folder still has.
+Example: with a folder ceiling of 75 files and a global ceiling of 50, a PR changing 60 files under that folder plus 49 files elsewhere passes, because each budget fits.
+Add a 51st global file and the PR is denied for the global budget, however much headroom the folder still has.
Files whose chain grants nothing count against the global budget, so splitting files across pseudo-scopes can never inflate the allowance.
That covers a missing folder file, a prose-only file, and a file with only invalid grants.
@@ -280,9 +281,9 @@ A folder that raises only the line ceiling still counts its files against the on
#### The roof bounds the whole PR
Per-scope budgets alone would let a PR's total grow with the number of scopes it touches.
-A folder granting 1000 lines next to an 800-line global pool would allow 1800, and every further granting folder would add its own budget on top.
+A folder granting 1500 lines next to a 1200-line global pool would allow 2700, and every further granting folder would add its own budget on top.
So each ceiling also carries a roof over the whole PR: the most generous ceiling in play for that key.
-A PR touching a folder that grants 1000 lines gets a 1000-line roof, whatever else it touches.
+A PR touching a folder that grants 1500 lines gets a 1500-line roof, whatever else it touches.
The roof needs no separate number in `policy.yml`.
Every grant is validated at or under the contract ceiling, and the global pool is always a scope, so the roof stays between the global default and the contract ceiling.
diff --git a/products/stamphog/packages/pr-approval-agent/defaults/policy.yml b/products/stamphog/packages/pr-approval-agent/defaults/policy.yml
index 7795ad6d6bc4..c2f3720a459a 100644
--- a/products/stamphog/packages/pr-approval-agent/defaults/policy.yml
+++ b/products/stamphog/packages/pr-approval-agent/defaults/policy.yml
@@ -160,8 +160,8 @@ allow:
- '.yaml'
- '.yml'
size_gate:
- max_lines: 800
- max_files: 30
+ max_lines: 1200
+ max_files: 50
tiers:
t1_subclasses:
T1a-trivial:
@@ -178,9 +178,9 @@ tiers:
breadth: 'not-cross-cutting'
overrides:
'size_gate.max_files':
- ceiling: 50
+ ceiling: 75
'size_gate.max_lines':
- ceiling: 1000
+ ceiling: 1500
# Author-familiarity signal — judgment layer only, never a gate. Non-delegable (absent from
# `overrides`). STRONG = blame overlap >= min_blame_overlap_pct; MODERATE = both of its keys satisfied;
# else NONE. Thresholds are stamphog's backtested defaults.
diff --git a/products/stamphog/packages/pr-approval-agent/test_policy.py b/products/stamphog/packages/pr-approval-agent/test_policy.py
index e54a1e93d217..a26a183676f5 100644
--- a/products/stamphog/packages/pr-approval-agent/test_policy.py
+++ b/products/stamphog/packages/pr-approval-agent/test_policy.py
@@ -202,8 +202,8 @@ OLD_ALLOW_PATH_PATTERNS = [
"__snapshots__/",
".github/CODEOWNERS",
]
-OLD_MAX_LINES = 800
-OLD_MAX_FILES = 30
+OLD_MAX_LINES = 1200
+OLD_MAX_FILES = 50
# ── 1. Equality snapshot: loaded policy matches pre-extraction literals ──
@@ -455,7 +455,7 @@ def test_load_effective_policy(
return
loaded = load_effective_policy(lockfile_names=_LOCKFILE_NAMES, ownership_formats=_OWNERSHIP_FORMATS)
assert set(loaded.deny) == set(_valid_policy_dict()["deny"])
- assert loaded.size_gate.max_lines == (overlay or {}).get("size_gate", {}).get("max_lines", 800)
+ assert loaded.size_gate.max_lines == (overlay or {}).get("size_gate", {}).get("max_lines", 1200)
def test_server_owned_digest_section_is_allowed_and_ignored(tmp_path: Path) -> None:
@@ -604,8 +604,8 @@ def test_resolve_budgets_each_ceiling_independently(
pytest.param("stamphog:\n size_gate:\n breadth: single-area", id="undelegated-size-gate-key"),
pytest.param("stamphog:\n size_gate: {}", id="empty-grant"),
pytest.param(_grant(max_files=99), id="files-over-ceiling"),
- pytest.param(_grant(max_lines=1001), id="lines-over-ceiling"),
- pytest.param(_grant(max_files=50, max_lines=1001), id="one-key-over-ceiling"),
+ pytest.param(_grant(max_lines=1501), id="lines-over-ceiling"),
+ pytest.param(_grant(max_files=50, max_lines=1501), id="one-key-over-ceiling"),
],
)
def test_resolve_invalid_folder_file_pools_files_into_global(fake_repo: Path, frontmatter: str) -> None:
@@ -631,7 +631,7 @@ def test_resolve_no_folder_file_uses_global() -> None:
[
pytest.param(None, gates.MAX_LINES, id="no-grant-keeps-the-global-total"),
pytest.param(_grant(max_lines=200), gates.MAX_LINES, id="grant-under-the-global-default"),
- pytest.param(_grant(max_lines=1000), 1000, id="grant-over-the-global-default"),
+ pytest.param(_grant(max_lines=1500), 1500, id="grant-over-the-global-default"),
],
)
def test_roof_is_the_most_generous_ceiling_in_play(
diff --git a/products/stamphog/packages/pr-approval-agent/test_review_local.py b/products/stamphog/packages/pr-approval-agent/test_review_local.py
index 74d7c9ff1188..ce3c37a9610e 100644
--- a/products/stamphog/packages/pr-approval-agent/test_review_local.py
+++ b/products/stamphog/packages/pr-approval-agent/test_review_local.py
@@ -650,16 +650,16 @@ _PENDING_MIGRATION_CHECK = [{"name": "Migration risk", "status": "in_progress",
pytest.param(_pregate_context([_api_file("src/app.py")], draft=True), "REFUSED", True, id="draft-prerequisite"),
pytest.param(_pregate_context([_api_file("src/app.py")], user_type="Bot"), "REFUSED", False, id="bot-author"),
pytest.param(
- _pregate_context([_lines(f"src/mod_{i}.py", 5) for i in range(60)]),
+ _pregate_context([_lines(f"src/mod_{i}.py", 5) for i in range(80)]),
"REFUSED",
True,
id="past-the-file-contract",
),
# Between the global ceiling and the delegation contract, a folder AGENT_APPROVALS.md on the PR
# head can lift the size gate, and the pre-check cannot read one.
- pytest.param(_pregate_context([_lines("src/big.py", 900)]), None, False, id="size-a-folder-could-lift"),
+ pytest.param(_pregate_context([_lines("src/big.py", 1300)]), None, False, id="size-a-folder-could-lift"),
pytest.param(
- _pregate_context([_lines("src/big.py", 900)], folder_policies_known=True),
+ _pregate_context([_lines("src/big.py", 1300)], folder_policies_known=True),
"REFUSED",
True,
id="size-with-folder-files-known",
diff --git a/products/stamphog/packages/pr-approval-agent/version.py b/products/stamphog/packages/pr-approval-agent/version.py
index 0a460dc53dbd..5a7d48363a87 100644
--- a/products/stamphog/packages/pr-approval-agent/version.py
+++ b/products/stamphog/packages/pr-approval-agent/version.py
@@ -9,4 +9,4 @@ changes don't need a bump - they are tracked by the policy sha shown next to
the version in the verdict table.
"""
-STAMPHOG_VERSION = "2.6.1"
+STAMPHOG_VERSION = "2.7.0"
diff --git a/products/visual_review/AGENT_APPROVALS.md b/products/visual_review/AGENT_APPROVALS.md
index 9d75a75d7748..5587d49a072e 100644
--- a/products/visual_review/AGENT_APPROVALS.md
+++ b/products/visual_review/AGENT_APPROVALS.md
@@ -1,7 +1,7 @@
---
stamphog:
size_gate:
- max_files: 50
+ max_files: 75
---
Visual review PRs are often mechanical and wide: snapshot churn, per-story updates, and bulk screenshot regeneration routinely touch many files at once.