---
name: ba-audit-actors
description: >
  Audits the actors of a `.smartstack/ba/` project — existence, duplicate names
  (case-insensitive), missing type (ACT-001, ACT-002, ACT-006 — ACT-003..005 retired). Actors are PROJECT-scoped, so
  it reads every `<APP>/acteur.md` plus the menu tree, applies the rules, and
  writes a verdict to `_audit/actors.md` at the project root. Run after
  `/ba-create-actors` or as part of pre-dev readiness.
allowed-tools: [Read, Write, Glob, Grep, Bash]  # Bash: the audit-ba engine (deterministic mechanical rules)
---

# ba-audit-actors — Actors audit

You audit the actors of a `.smartstack/ba/` project against the rules below and
write a verdict file. The rules are unchanged from the SmartStack convention;
only the I/O is file-based.

## Deterministic engine — how this audit runs

The MECHANICAL rules of this dimension are evaluated by the shared `audit-ba`
CLI (see `/ba-audit-run`) — **never by reading the corpus yourself, never by
spawning per-module subagents** (the 394M-token incident shape). Your only
job here is the judgment residue.

1. **Run the engine, scoped to this dimension**:

   ```bash
   npx --prefer-offline tsx skills/business-analyse/audit-run/cli/audit-ba/index.ts \
     --spec '{"baRoot":".smartstack/ba","dimensions":["actors"]}'
   ```

2. **Exit 3 = parsing suspect -> STOP.** A control counter disagrees with the
   parser (`report.parseControl.perDoc`): fix the doc's form or report the
   parser bug, then re-run. Never « complete by hand » — no green verdict may
   be born from a silent parser.
3. **No judgment rules in this dimension** — a single engine run suffices; the verdict is final.
4. **Chat summary** (3-6 lines, business terms): the PARSE TOTALS (say the
   counts — that is how a « 0 erreur » stays verifiable), err/warn counts,
   remaining judgments, and the fix skill each finding names.

The CLI writes the verdict to `.smartstack/ba/_audit/actors.md`
(existing format — anchor, `Verdict :` header, emoji sections; `0 err` =
pass for the downstream gate). The rule texts below remain the AUTHORITATIVE
spec — the CLI registry is drift-tested against them.

## Scope

Actors are **project-wide**: collect the actors declared in every
`.smartstack/ba/<APP>/acteur.md` and audit them as one set. The verdict file
always lives at the project root: `.smartstack/ba/_audit/actors.md`.

## Cross-phase checks moved elsewhere

`ba-audit-actors` runs before use cases and permissions exist. Cross-phase checks
therefore live in the audit of the phase that consumes the reference:

- `UC-008` (in `ba-audit-use-cases`) verifies that every use case's primary actor
  points to an existing actor.
- `RBAC-005` (in `ba-audit-rbac`) verifies that every permission entry references
  an existing actor.

The legacy ACT-003 (unused actors), ACT-004 (actors without permissions) and
ACT-005 (actors not linked to an application) were removed: the first two
duplicated UC-008 / RBAC-005 with the source-of-truth on the wrong side, and
ACT-005 referenced an actor↔application link that no longer exists in the
project-scoped model.

## Rules

### ACT-001 — At least 1 actor exists
- `err` if 0 actors across the whole project; `ok` if ≥ 1 (state the count).
- Count distinct actor headings found across all `acteur.md` files.
- Fix: `/ba-create-actors`.

### ACT-002 — No duplicate actor names (case-insensitive)
- `err` if two or more DIFFERENT actors share the same label ignoring case;
  `ok` if none.
- Compare actor labels case-insensitively across the whole project. **Legitimate
  reuse is NOT a duplicate**: the same actor written in several apps' `acteur.md`
  with the **same `BA-…-AC-…` code** (the `/ba-create-actors` multi-app
  `Périmètre` pattern) is the documented design — `ok`. What IS a duplicate:
  the same (or near-identical) label under **different codes**, or the same
  code carrying **divergent definitions** across apps (contradictory `Type` /
  `Catégorie`).
- Fix: `/ba-create-actors` — merge the different-code duplicates into a single
  `BA-NNN-AC-NNN` (re-linking via `Périmètre` lines), or reconcile the divergent
  definitions of a shared code.

### ACT-006 — All actors have a type (internal/external/system)
- `warn` if any actor is missing its `**Type**` (or it isn't one of
  `internal | external | system`); `ok` if all are typed.
- Fix: `/ba-create-actors`.

## Output

Write `.smartstack/ba/_audit/actors.md` per the doc-templates skeleton:
- Anchor `<!-- ba:audit dimension=actors scope=project -->`.
- Header `# Audit acteurs — projet` + `_<date> · Verdict : <emoji> N warn · M err · K ok_`.
- `## ✅ Conforme`, `## ⚠️ Avertissements`, `## ❌ Bloquants` sections; one bullet
  per finding. The rule codes (`ACT-001`, …) stay **bold** so they remain
  greppable, but explain each in business terms. For every `warn`/`err`: what's
  wrong (offending names/codes **bold**), why it matters, and a `→` fix naming
  `/ba-create-actors`.
- Re-Write the whole file each run (overwrite — it's a fresh verdict).

Then a 3–6 line chat summary in the user's language — business terms, not rule
codes. If any `err`, state clearly that the actors must be fixed before moving on.

## Used by the readiness orchestrator

`/ba-audit-pre-dev` runs every dimension and aggregates the verdicts. When invoked
by it, still write `.smartstack/ba/_audit/actors.md` as usual — the orchestrator
reads these files.
