Routine: Abstraction Police
Enforce the layering: operator → types ← backend; types imports no sibling; cli imports no lego sibling; the dashboard talks to the backend only through its API client and never reimplements server-authoritative logic.
Routine ground rules
- A user request to run this routine authorizes the full cycle: plan, fix, verify, then invoke
$ship (Codex) or /ship (Claude) directly in the same run. Honor explicit user limits such as audit-only or no-ship.
- Keep a concise execution plan in the conversation and update it as findings are confirmed. Continue into implementation without a planning approval pause. Do not create or file a
.pm milestone/task as a prerequisite or substitute for fixing; use the board only if the user requests it.
- After the verification phase, follow the shipping phase below without asking the user to invoke ship separately. Preserve the ship skill's branch, conflict-resolution, and safety rules.
- Fix everything you find directly in the working tree. If a fix can't be finished safely in this run, revert only your partial work for that fix and list it under Deferred in the report — never leave the tree half-refactored.
- Scope: parse
$ARGUMENTS per Phase 1 — an optional path/module scope or skill-specific target. No argument = the skill's stated default (usually the whole repo via parallel agents per module: lego/types, lego/operator, lego/backend, lego/cli, dashboard).
- False-positive discipline: if a finding is intentional, load-bearing, or ambiguous, skip it with a one-line reason — don't argue it into a change.
- Every change must pass the verification gates for the modules it touched before being reported as done: operator
make test + make lint (from lego/operator/), cd lego/backend && go test ./..., cd lego/cli && go test ./..., dashboard yarn test + typecheck.
- Run
npx prettier@3.4.2 --write on any markdown touched.
- Before shipping, summarize results in commentary using: Fixed (file:line + one-line rationale) / Deferred (item + why) / Skipped (finding + reason) / Gates (commands run + outcomes).
Phase 1 — Scope
Parse $ARGUMENTS as an optional module/boundary. Empty = all boundaries.
Phase 2 — Mechanical audit
- Per Go module, diff actual imports against the law:
go list -deps ./... or grep -rn '"github.com/bex-co/bex/lego/'.
- Within-module layer skips:
cmd/ reaching deep into internals instead of the intended package surface.
- Check whether
lego/backend/.golangci.yml and lego/operator/.golangci.yml encode the DAG in depguard rules (backend's depguard currently guards the id convention). Missing DAG rules are themselves a finding.
Phase 3 — Semantic audit
Parallel agents compare dashboard logic against lego/backend/internal/apps: blueprint validation and pricing are the likely offenders. Logic that must stay server-authoritative (pricing, plan diffs, authz decisions) may not live client-side; the dashboard renders API answers.
Phase 4 — Fix
- Wrong-direction or sideways imports → move the shared code to
lego/types (the only module both operator and backend may import) and migrate callers.
- Dashboard reimplementations → replace with API data (extend the GraphQL/REST response if a field is missing).
- Add depguard rules encoding the DAG to the golangci configs so
make lint catches future violations.
Phase 5 — Verify and report
Types moves ripple: run all Go gates; make lint must pass WITH the new depguard rules; dashboard gates if touched. Report per the standard format.
Final phase — Ship
After all required gates pass, read and execute the ship skill for the routine's completed changes. Stage only intended changes from this run; preserve unrelated work. Do not end at a plan, findings report, milestone, or request for shipping approval. If there are no changes, report that outcome without creating an empty commit. If a required gate remains blocked or fails after reasonable repairs, report the exact blocker and do not ship unverified changes.
Once the push succeeds, report the shipped HEAD SHA and subject per the ship skill and stop; do not monitor CI or deployment.
1---2name: routine-abstraction-police3description: Audits and fixes layering violations against the workspace import DAG (operator→types←backend; cli standalone; dashboard consumes the API, never reimplements it) and adds depguard rules so violations can't return. Use when the user asks to run the abstraction-police routine, audit module boundaries, or fix layering violations.4---56# Routine: Abstraction Police78Enforce the layering: `operator → types ← backend`; `types` imports no sibling; `cli` imports no lego sibling; the dashboard talks to the backend only through its API client and never reimplements server-authoritative logic.910## Routine ground rules1112- A user request to run this routine authorizes the full cycle: plan, fix, verify, then invoke `$ship` (Codex) or `/ship` (Claude) directly in the same run. Honor explicit user limits such as audit-only or no-ship.13- Keep a concise execution plan in the conversation and update it as findings are confirmed. Continue into implementation without a planning approval pause. Do not create or file a `.pm` milestone/task as a prerequisite or substitute for fixing; use the board only if the user requests it.14- After the verification phase, follow the shipping phase below without asking the user to invoke ship separately. Preserve the ship skill's branch, conflict-resolution, and safety rules.15- Fix everything you find directly in the working tree. If a fix can't be finished safely in this run, revert only your partial work for that fix and list it under **Deferred** in the report — never leave the tree half-refactored.16- Scope: parse `$ARGUMENTS` per Phase 1 — an optional path/module scope or skill-specific target. No argument = the skill's stated default (usually the whole repo via parallel agents per module: lego/types, lego/operator, lego/backend, lego/cli, dashboard).17- False-positive discipline: if a finding is intentional, load-bearing, or ambiguous, skip it with a one-line reason — don't argue it into a change.18- Every change must pass the verification gates for the modules it touched before being reported as done: operator `make test` + `make lint` (from `lego/operator/`), `cd lego/backend && go test ./...`, `cd lego/cli && go test ./...`, dashboard `yarn test` + typecheck.19- Run `npx prettier@3.4.2 --write` on any markdown touched.20- Before shipping, summarize results in commentary using: **Fixed** (file:line + one-line rationale) / **Deferred** (item + why) / **Skipped** (finding + reason) / **Gates** (commands run + outcomes).2122## Phase 1 — Scope2324Parse `$ARGUMENTS` as an optional module/boundary. Empty = all boundaries.2526## Phase 2 — Mechanical audit2728- Per Go module, diff actual imports against the law: `go list -deps ./...` or `grep -rn '"github.com/bex-co/bex/lego/'`.29- Within-module layer skips: `cmd/` reaching deep into internals instead of the intended package surface.30- Check whether `lego/backend/.golangci.yml` and `lego/operator/.golangci.yml` encode the DAG in depguard rules (backend's depguard currently guards the id convention). Missing DAG rules are themselves a finding.3132## Phase 3 — Semantic audit3334Parallel agents compare dashboard logic against `lego/backend/internal/apps`: blueprint validation and pricing are the likely offenders. Logic that must stay server-authoritative (pricing, plan diffs, authz decisions) may not live client-side; the dashboard renders API answers.3536## Phase 4 — Fix3738- Wrong-direction or sideways imports → move the shared code to `lego/types` (the only module both operator and backend may import) and migrate callers.39- Dashboard reimplementations → replace with API data (extend the GraphQL/REST response if a field is missing).40- Add depguard rules encoding the DAG to the golangci configs so `make lint` catches future violations.4142## Phase 5 — Verify and report4344Types moves ripple: run all Go gates; `make lint` must pass WITH the new depguard rules; dashboard gates if touched. Report per the standard format.4546## Final phase — Ship4748After all required gates pass, read and execute [the ship skill](../ship/SKILL.md) for the routine's completed changes. Stage only intended changes from this run; preserve unrelated work. Do not end at a plan, findings report, milestone, or request for shipping approval. If there are no changes, report that outcome without creating an empty commit. If a required gate remains blocked or fails after reasonable repairs, report the exact blocker and do not ship unverified changes.4950Once the push succeeds, report the shipped HEAD SHA and subject per the ship skill and stop; do not monitor CI or deployment.