Policy layer: swarm-policy.sh contract + policy-lib.sh loader (landing, merge authority, human labels + triggers) #12
Labels
No labels
agent-blocked
agent-working
bug
deferred
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-info
needs-triage
no-triage
priority
ready-for-agent
ready-for-human
ready-for-session
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Depends on
#1 Build the prompt-skeleton templating/render pipeline
Matou/dev-factory
#3 Move host-state ownership (crontab, /tmp/matou-swarm.lock, swarm.db) to this repo
Matou/dev-factory
#6 onboard-host: host registry + idempotent machine enrolment — compute plugs in like repos do
Matou/dev-factory
Reference
Matou/dev-factory#12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of the agent-driven install-session arc (Ben, 2026-08-21/22;
docs/superpowers/specs/2026-08-21-vendor-command-design.md§Context records the decomposition: 2 vendor ✅ → 1 policy layer + prompt rendering → 3 host enrolment → 4 the install session). Worked by the factory's own swarm (STATUS.md 2026-08-22 — SELF-HOSTED).Why
Per-repo behaviour today is either prose inside
prompt.mdor hardcoded in the harness (push to main inrun-swarm.sh:608/prompt.mdstep 6; matou-app's PR-per-issue flow lives in its own.sandcastle/, not here). Ben's rulings: landing and merge authority are per-repo knobs, loop-in is the human-label state machine (per-repo label definitions + trigger rules, not a level ladder), and we build enforcement now, not record-now-enforce-later.Contract —
swarm-policy.sh(consumer identity layer, besideswarm-identity.sh)Plain
KEY=value, sourceable by bash and parseable by node, same discipline asswarm.config:Defaults when the file is absent:
LANDING=push,MERGE_AUTHORITY=human, the core label set with today's triggers, today's protected dirs — i.e. byte-identical behaviour for idss.Deliverables
policy-lib.sh:policy_load [file](sources with defaults, exportsSWARM_POLICY_*),policy_validate(unknown key, bad enum, aHUMAN_LABELSname not in the repo's label set → exit 2 with the offending key named — fail LOUD before any worker spawns, likeswarm_resolve_model),policy_human_labels(emits name/trigger lines for renderers).run-swarm.shcallspolicy_load+policy_validatein preflight (no behaviour change yet — consumers of the knobs are the follow-up tickets).onboarding/vendor-manifestlistspolicy-lib.sh;vendor-excludelistsswarm-policy.sh;onboard.sh policy <out-file> [KEY=value ...]writes a validated file (pattern:e2e-tier).tests/policy-lib-test.sh: absent file → defaults; each enum rejected/accepted; unknown key rejected; label-not-minted rejected (shimmedcurllabel list).docs/adr/0002-per-repo-policy-layer.mdrecording the rulings above.Acceptance
run-swarm.shpreflight with no policy file printspolicy: defaults (LANDING=push MERGE_AUTHORITY=human).LANDING=mergefails preflight withpolicy: LANDING must be push|pr (got merge).policy-lib.sh.swarm-claim host=matou-dev-server-01 run=81
(automated multi-host claim — lowest live claim id works this ticket)
close-report for #12 — status
success✅ close-report gates passed — every claim verified against main; closing.
envelope
Closed by hand (Ben's session) after review:
5d401f4matches the contract — defaults reproduce today's behaviour,SWARM_POLICY_*exports, exit-2 validation naming the offending key, fixed trigger vocabulary, label-minted check viaforgejo-lib.sh, preflight abort with a Mattermost notice,onboard.sh policywriter, ADR 0002, offline tests; no product literal. One doc nit for the next touch: ADR 0002's Context calls this "sub-project 3" — it is sub-project 1 of the arc (vendor was 2). Close PATCH failed for themachines-team permission gap like #19/#20/#11/#18.Work complete and merged — but the tracker close is blocked by a permission gap (#20 / GOTCHAS 6)
The implementation for #12 is done, verified, and pushed to
origin/mainat commit5d401f4f29801e2164f86fcf7c1db32ca1325a5a:policy-lib.sh—policy_load/policy_validate/policy_human_labels(+_policy_check_structure), fail-LOUD on unknown key / bad enum / malformed-or-unmintedHUMAN_LABELS, exit 2 naming the offending token.run-swarm.shpreflight callspolicy_load+policy_validate(validate-only — no knob consumed yet); printspolicy: defaults (LANDING=push MERGE_AUTHORITY=human)when absent,policy: LANDING must be push|pr (got merge)on a bad enum.onboard.sh policy <out-file> [KEY=value ...]+onboard_write_policy(structure-validated writer).onboarding/vendor-manifest+policy-lib.sh;vendor-exclude+swarm-policy.sh.docs/adr/0002-per-repo-policy-layer.md;tests/policy-lib-test.sh(27 checks) +onboard-lib-test.shwriter cases. Full offline suite green.The close-report gate ran, verified every claim against
main, and posted its envelope (comment above).Why this issue is still OPEN
The run's bot token has
repo.codewrite (push + comments land) but not issue-metadata write: a direct probe returns HTTP 403 on bothPATCH /issues/12 {state:closed}andPOST /issues/12/labels. This is precisely the #20 / GOTCHAS 6 hazard. The gate's "closing" wording is stale because the vendored.sandcastle/close-report.shsits atFACTORY_REF 1b7abc2, which predates #20's fix (close-first / verify-state==closed/ report-reality / exit-non-zero-on-403). So the close silently 403'd and the old copy narrated success.I cannot swap the labels to
agent-blockedeither (same 403), so this comment is the durable record.What a human must do to re-arm / close
machinesteamrepo.issues(andrepo.pulls) write onMatou/dev-factory(GOTCHAS 6).5106a1b) soclose-report.shdetects a failed close loudly:bash onboarding/onboard.sh vendor .sandcastle <sha>.