Skip to content

feat(loop): a constitution the autonomous loops cannot edit - #186

Merged
AminChirazi merged 1 commit into
mainfrom
feat/loop-constitution
Jul 28, 2026
Merged

feat(loop): a constitution the autonomous loops cannot edit#186
AminChirazi merged 1 commit into
mainfrom
feat/loop-constitution

Conversation

@AminChirazi

Copy link
Copy Markdown
Contributor

Why

The autonomous loops' safety rests on one property: green CI means the work is sound. An agent optimising for green has two routes — do the work, or weaken the thing that measures the work. The second is always cheaper. So the files that constrain the loops must be outside their reach, or the system has no fixed point.

What

scripts/gate/constitution-check.sh refuses any change to CHARTER.md, CODEOWNERS, scripts/gate/, or .github/workflows/ unless the PR author is on a human allowlist.

It fails closed: an identity not on the list is treated as a loop, so a new loop identity is constrained the moment it exists, with no edit here required. The allowlist living inside a protected path is deliberate — a loop cannot add itself.

The logic is a script rather than inline YAML so it is testable. The workflow runs its 24 cases on every PR, including that a loop cannot edit the check itself, and that dependabot[bot] and unknown actors are refused.

Also lands the verified pieces of the loop gate:

File Status
sandbox-run.sh rootless podman isolation, 6/6 tests passing on the host
token-scope-check.sh loop-credential scope + ruleset-bypass verification
protection.json branch protection, already applied
ruleset-repo-guard.json repo ruleset 19879637, already applied

One required follow-up

constitution must be added to the required status checks. A pull_request run uses the workflow from the PR's own merge commit, so a PR that deletes this job runs without it. What stops that is a required check which never reports blocking the merge:

gh api -X PATCH repos/automators-com/flowproof/branches/main/protection/required_status_checks \
  -f 'contexts[]=constitution'

Until that is run, this gate is advisory.

Why scripts/gate/ and not .loop/

.gitignore marks .loop/ as local scratch — "Field-hardening loop scratch state (local bookkeeping, not product)". A gate has to be committed to be enforceable. Worth noting the same constraint applies to the gap ledger from the design: it needs a tracked home too.

Testing

  • 24/24 gate cases pass, driving the real script (not a copy — no drift possible)
  • git-diff mode verified against this commit: refuses loop-bot, allows AminChirazi
  • bash -n clean on all five scripts
  • Host verification: 644 tests, clippy -D warnings, and cargo fmt all clean

No engine code touched, so the what changed filter should skip the E2E jobs.

🤖 Generated with Claude Code

The loops' safety rests on one property: green CI means the work is sound. An
agent optimising for green has two routes - do the work, or weaken the thing
that measures the work - and the second is always cheaper. So the files that
constrain the loops have to be outside their reach, or there is no fixed point.

`scripts/gate/constitution-check.sh` refuses any change to CHARTER.md,
CODEOWNERS, scripts/gate/, or .github/workflows/ unless the PR author is on a
human allowlist. It fails closed: an identity not on the list is treated as a
loop, so a new loop is constrained the moment it exists.

The logic is a script rather than inline YAML so it is testable, and the
workflow runs its 24 cases on every PR - including the case that a loop cannot
edit the check itself.

The gate lives in scripts/gate/ and not .loop/: .loop/ is gitignored local
scratch ("not product"), and a gate has to be committed to be enforceable.

This is one of three independent locks. The others are the loop credential's
scope and branch protection requiring the `constitution` check - which must be
added to the required list once this lands, since a check that never reports is
what stops a PR deleting the job.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@AminChirazi
AminChirazi merged commit e4501ef into main Jul 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants