Adopt hardened repo-guard policy-delta gate for library size governance
Problem
PersistMemoryManager already has a repository policy that defines a hard library-size budget for the kernel subtree:
size_rules[0].id: kernel-subtree-max-bytes
glob: include/**
metric: bytes
max: 270000
count: all_tracked
level: blocking
However, the downstream gate is still not strict enough:
repo-policy.json currently sets global enforcement to advisory.
.github/workflows/repo-guard.yml currently runs the repo-guard PR check with enforcement: advisory.
- The workflow is pinned to an older
repo-guard SHA that predates the new policy-delta hardening from netkeep80/repo-guard#99.
- This leaves the library-size policy visible but not fully merge-blocking.
- An AI-authored PR should not be able to grow
include/** and relax the size budget / governance policy in the same change.
The goal is to make the library-size budget an actual protected invariant for PRs.
Desired behavior
After this change:
- PRs are evaluated by a
repo-guard version that includes policy-delta hardening from netkeep80/repo-guard#99.
repo-guard runs in blocking mode in CI.
repo-policy.json uses blocking enforcement.
- A PR that grows
include/** beyond the trusted base policy's kernel-subtree-max-bytes limit fails.
- A PR that tries to raise or weaken the size limit in
repo-policy.json is detected as policy relaxation.
- Policy relaxation is allowed only as a dedicated trusted governance PR, not together with kernel/generated/product changes.
- PR-body authorization is not enough to authorize governance changes.
- Linked-issue authorization is used only when the issue is trusted by maintainer permission or a trusted maintainer-applied label such as
governance-approved.
Proposed changes
Update PersistMemoryManager to consume the hardened repo-guard behavior.
1. Update the repo-guard Action ref
In .github/workflows/repo-guard.yml, replace the current pinned repo-guard SHA with a release tag or immutable SHA that includes netkeep80/repo-guard#99.
Preferred after release:
uses: netkeep80/repo-guard@vX.Y.Z
Temporary pre-release option, only if explicitly accepted by the maintainer:
uses: netkeep80/repo-guard@<merged-commit-sha-containing-policy-delta>
Do not leave this on the old SHA.
2. Make the PR gate blocking
In .github/workflows/repo-guard.yml:
jobs:
policy-check:
- name: repo-guard advisory check
+ name: repo-guard blocking check
...
with:
mode: check-pr
- enforcement: advisory
+ enforcement: blocking
3. Make policy enforcement blocking
In repo-policy.json:
"enforcement": {
- "mode": "advisory"
+ "mode": "blocking"
},
4. Preserve the existing size budget
Do not raise this limit in this PR:
{
"id": "kernel-subtree-max-bytes",
"scope": "directory",
"metric": "bytes",
"glob": "include/**",
"max": 270000,
"count": "all_tracked",
"level": "blocking"
}
This issue is about enforcing the existing budget, not increasing it.
5. Add or verify repository protection outside code
After the PR lands, configure branch protection / repository ruleset for main:
- require PR before merge;
- require the repo-guard blocking status check;
- require approval for governance files if CODEOWNERS is present;
- do not allow AI/bot users to bypass this gate.
If CODEOWNERS is not present yet, consider adding:
/repo-policy.json @netkeep80
/.github/workflows/repo-guard.yml @netkeep80
/.github/CODEOWNERS @netkeep80
This can be included in the same governance PR if the new-file budget allows it, or split into a follow-up governance PR.
Non-goals
- Do not raise
kernel-subtree-max-bytes.
- Do not change files under
include/**.
- Do not refresh generated single-header output.
- Do not combine this governance hardening with kernel refactoring.
- Do not weaken any
diff_rules, size_rules, paths.forbidden, or paths.governance_paths.
Acceptance criteria
Manual verification
After the PR is opened, verify that repo-guard fails if a test branch tries to do both of these in one PR:
- increase the tracked size under
include/**;
- raise
size_rules[*].max for kernel-subtree-max-bytes.
Expected result:
FAIL: policy-relaxation
PR attempts to relax trusted repository policy
Also verify that a normal kernel PR exceeding the trusted base limit fails through the size rule.
Contract
change_type: governance
scope:
- repo-policy.json
- .github/workflows/repo-guard.yml
- .github/CODEOWNERS
- scripts/check-repo-guard-rollout.sh
- docs/index.md
budgets:
max_new_files: 1
max_new_docs: 0
max_net_added_lines: 80
authorized_governance_paths:
- repo-policy.json
- .github/workflows/repo-guard.yml
- .github/CODEOWNERS
- scripts/check-repo-guard-rollout.sh
anchors:
affects:
- repo-guard check-pr trusted policy boundary
- repo-policy.json policy relaxation
- PersistMemoryManager library size budget
- include subtree size governance
- canonical-docs-sync registry rule
must_touch:
- repo-policy.json
- .github/workflows/repo-guard.yml
- scripts/check-repo-guard-rollout.sh
must_not_touch:
- include/**
- single_include/**
expected_effects:
- PersistMemoryManager uses hardened repo-guard policy-delta behavior
- repo-guard PR check becomes blocking rather than advisory
- existing include subtree byte budget becomes a merge-blocking invariant
- AI-authored PRs cannot self-raise the library size limit in the same change that grows the library
- repo-guard rollout validator is updated in lockstep with the workflow pin and enforcement mode
- pre-existing canonical-docs-sync incompatibility in docs/index.md is fixed without changing the canonical document set
Adopt hardened repo-guard policy-delta gate for library size governance
Problem
PersistMemoryManageralready has a repository policy that defines a hard library-size budget for the kernel subtree:size_rules[0].id:kernel-subtree-max-bytesglob:include/**metric:bytesmax:270000count:all_trackedlevel:blockingHowever, the downstream gate is still not strict enough:
repo-policy.jsoncurrently sets global enforcement toadvisory..github/workflows/repo-guard.ymlcurrently runs the repo-guard PR check withenforcement: advisory.repo-guardSHA that predates the newpolicy-deltahardening fromnetkeep80/repo-guard#99.include/**and relax the size budget / governance policy in the same change.The goal is to make the library-size budget an actual protected invariant for PRs.
Desired behavior
After this change:
repo-guardversion that includespolicy-deltahardening fromnetkeep80/repo-guard#99.repo-guardruns in blocking mode in CI.repo-policy.jsonuses blocking enforcement.include/**beyond the trusted base policy'skernel-subtree-max-byteslimit fails.repo-policy.jsonis detected as policy relaxation.governance-approved.Proposed changes
Update
PersistMemoryManagerto consume the hardenedrepo-guardbehavior.1. Update the repo-guard Action ref
In
.github/workflows/repo-guard.yml, replace the current pinnedrepo-guardSHA with a release tag or immutable SHA that includesnetkeep80/repo-guard#99.Preferred after release:
Temporary pre-release option, only if explicitly accepted by the maintainer:
Do not leave this on the old SHA.
2. Make the PR gate blocking
In
.github/workflows/repo-guard.yml:3. Make policy enforcement blocking
In
repo-policy.json:"enforcement": { - "mode": "advisory" + "mode": "blocking" },4. Preserve the existing size budget
Do not raise this limit in this PR:
{ "id": "kernel-subtree-max-bytes", "scope": "directory", "metric": "bytes", "glob": "include/**", "max": 270000, "count": "all_tracked", "level": "blocking" }This issue is about enforcing the existing budget, not increasing it.
5. Add or verify repository protection outside code
After the PR lands, configure branch protection / repository ruleset for
main:If CODEOWNERS is not present yet, consider adding:
This can be included in the same governance PR if the new-file budget allows it, or split into a follow-up governance PR.
Non-goals
kernel-subtree-max-bytes.include/**.diff_rules,size_rules,paths.forbidden, orpaths.governance_paths.Acceptance criteria
.github/workflows/repo-guard.ymluses arepo-guardref that includespolicy-deltahardening fromnetkeep80/repo-guard#99..github/workflows/repo-guard.ymlrunsmode: check-pr..github/workflows/repo-guard.ymlrunsenforcement: blocking.advisory; it saysblockingor equivalent.repo-policy.jsonhas"enforcement": { "mode": "blocking" }.kernel-subtree-max-bytesrule remains present.270000.all_tracked.blocking.include/**.single_include/**.diff_rules,paths.forbidden,paths.governance_paths, or workflow enforcement expectations.Manual verification
After the PR is opened, verify that repo-guard fails if a test branch tries to do both of these in one PR:
include/**;size_rules[*].maxforkernel-subtree-max-bytes.Expected result:
Also verify that a normal kernel PR exceeding the trusted base limit fails through the size rule.
Contract