Protected-path enforcement: per-repo opt-out policy key (#208) #251

Open
matou-build-agent wants to merge 1 commit from agent/issue-208 into main

closes #208

What

Finishes #208. #193 already flipped protected-path enforcement to default-on
and moved the boundary pre-landing (the worker pushes a per-run branch; the
HOST lands main only after verify_protected_paths, so the rollback genuinely
keeps a machinery edit off main). This PR adds the ticket's remaining surface:
the consumer opt-out is now a closed-vocabulary policy key, not just the
PP_ENFORCE env var #193 left behind.

Changes

  • policy-lib.sh — new key PROTECTED_PATH_ENFORCE=on|off, default on.
    Loaded + exported as SWARM_POLICY_PROTECTED_PATH_ENFORCE, enum-validated,
    added to the closed allowed-key set. Absent file → on (byte-identical).
  • verify-lib.sh — _verify_pp_enforced resolves enforcement: an explicit
    PP_ENFORCE env still wins (break-glass / offline test seam); otherwise
    the policy key decides, defaulting on. verify_pp_snapshot /
    verify_protected_paths call it instead of reading PP_ENFORCE directly.
  • onboarding/onboard-lib.sh + install-prompt.md — onboard_write_policy
    accepts the key; the interview names it (contract test forces every policy key
    to be asked); opt-out taken only with a dated reason.
  • docs/adr/0002 — amendment documenting the key + the GOTCHAS 17 rollout.

Acceptance criteria

  • Enforcement active with no PP_ENFORCE set; a consumer opt-out suppresses
    it per repo (PROTECTED_PATH_ENFORCE=off) — verify-lib-test.sh,
    policy-lib-test.sh.
  • A worker touching a protected path is refused BEFORE the commit reaches
    main (#193 landed) — verify-lib-test.sh group 5, run-swarm-landing-test.sh
    9a/9b.
  • tests/verify-lib-test.sh models the shimmed-git push ordering and proves
    a breach is caught pre-landing, plus the opt-out path.
  • Offline suite green.

GOTCHAS 17

This mints a policy key. An OLD pinned policy-lib.sh refuses a file naming
PROTECTED_PATH_ENFORCE, so this repo's own .sandcastle/ self-copy may declare
it only after a human re-vendor carries the new validator in (GOTCHAS 4).
Root change — inert in the running copy until the next coordinated re-vendor.

Screenshots: none — harness-only change (shell libs + policy vocabulary +
docs); no visible UI surface. Evidence is the offline suite (every affected
tests/*.sh green).

closes #208 ## What Finishes #208. #193 already flipped protected-path enforcement to **default-on** and moved the boundary **pre-landing** (the worker pushes a per-run branch; the HOST lands `main` only after `verify_protected_paths`, so the rollback genuinely keeps a machinery edit off `main`). This PR adds the ticket's remaining surface: the **consumer opt-out is now a closed-vocabulary policy key**, not just the `PP_ENFORCE` env var #193 left behind. ## Changes - **`policy-lib.sh`** — new key `PROTECTED_PATH_ENFORCE=on|off`, default `on`. Loaded + exported as `SWARM_POLICY_PROTECTED_PATH_ENFORCE`, enum-validated, added to the closed allowed-key set. Absent file → `on` (byte-identical). - **`verify-lib.sh`** — `_verify_pp_enforced` resolves enforcement: an explicit `PP_ENFORCE` env still **wins** (break-glass / offline test seam); otherwise the policy key decides, defaulting on. `verify_pp_snapshot` / `verify_protected_paths` call it instead of reading `PP_ENFORCE` directly. - **`onboarding/onboard-lib.sh` + `install-prompt.md`** — `onboard_write_policy` accepts the key; the interview names it (contract test forces every policy key to be asked); opt-out taken only with a **dated reason**. - **`docs/adr/0002`** — amendment documenting the key + the GOTCHAS 17 rollout. ## Acceptance criteria - [x] Enforcement active with no `PP_ENFORCE` set; a consumer opt-out suppresses it per repo (`PROTECTED_PATH_ENFORCE=off`) — `verify-lib-test.sh`, `policy-lib-test.sh`. - [x] A worker touching a protected path is refused BEFORE the commit reaches main (#193 landed) — `verify-lib-test.sh` group 5, `run-swarm-landing-test.sh` 9a/9b. - [x] `tests/verify-lib-test.sh` models the shimmed-git push ordering and proves a breach is caught pre-landing, plus the opt-out path. - [x] Offline suite green. ## GOTCHAS 17 This mints a policy key. An OLD pinned `policy-lib.sh` refuses a file naming `PROTECTED_PATH_ENFORCE`, so this repo's own `.sandcastle/` self-copy may declare it only **after** a human re-vendor carries the new validator in (GOTCHAS 4). Root change — inert in the running copy until the next coordinated re-vendor. **Screenshots:** none — harness-only change (shell libs + policy vocabulary + docs); no visible UI surface. Evidence is the offline suite (every affected `tests/*.sh` green).
sandcastle: #208 — protected-path enforcement: per-repo opt-out policy key (consumes #193 default-on)
All checks were successful
ci / static (pull_request) Successful in 2m16s
ci / test (pull_request) Successful in 4m54s
ea8b4a2be2
#193 already flipped PP enforcement to default-on and moved the boundary
pre-landing (worker pushes a per-run branch; the HOST lands main only after
verify_protected_paths, so the rollback genuinely keeps a machinery edit off
main). This finishes #208's remaining surface: the consumer opt-out is now a
closed-vocabulary policy key, not just the PP_ENFORCE env var.

Key decisions / files:
- policy-lib.sh: new key PROTECTED_PATH_ENFORCE=on|off, default on. Loaded +
  exported as SWARM_POLICY_PROTECTED_PATH_ENFORCE, enum-validated, added to the
  closed allowed-key set. Absent file -> on (byte-identical).
- verify-lib.sh: _verify_pp_enforced resolves enforcement — an explicit
  PP_ENFORCE env still wins (break-glass / test seam); else the policy key
  decides, defaulting on. verify_pp_snapshot/verify_protected_paths call it.
- onboarding/onboard-lib.sh + install-prompt.md: onboard_write_policy accepts
  the key; the interview names it (contract test forces every key to be asked);
  opt-out taken only with a DATED reason.
- docs/adr/0002: amendment documenting the key + the GOTCHAS 17 rollout order.
- Tests: policy-lib (default/accept/reject enum), verify-lib (policy opt-out
  path + env override), onboard-lib (writer round-trip), install-prompt-contract
  (names it). Full offline suite green.

GOTCHAS 17 (mints a policy key): an OLD pinned policy-lib.sh refuses a file
naming PROTECTED_PATH_ENFORCE, so this repo's own .sandcastle self-copy may
declare it only after a human re-vendor carries the new validator in (GOTCHAS 4).
Root change — inert in the running copy until the next coordinated re-vendor.

STATUS.md header + docs/journal/2026-10-16-208.md updated (project state: new
policy key / gate).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
All checks were successful
ci / static (pull_request) Successful in 2m16s
ci / test (pull_request) Successful in 4m54s
This pull request has changes conflicting with the target branch.
  • STATUS.md
  • docs/adr/0002-per-repo-policy-layer.md
  • onboarding/onboard-lib.sh
  • onboarding/tests/onboard-lib-test.sh
  • verify-lib.sh
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin agent/issue-208:agent/issue-208
git switch agent/issue-208

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff agent/issue-208
git switch agent/issue-208
git rebase main
git switch main
git merge --ff-only agent/issue-208
git switch agent/issue-208
git rebase main
git switch main
git merge --no-ff agent/issue-208
git switch main
git merge --squash agent/issue-208
git switch main
git merge --ff-only agent/issue-208
git switch main
git merge agent/issue-208
git push origin main
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory!251
No description provided.