---
name: ba-audit-actors
description: >
  Audits the actors of a `.smartstack/ba/` project — existence, duplicate names
  (case-insensitive), missing type (ACT-001..006). 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]
---

# 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.

## File model — how to audit

1. **Read state**: `Glob .smartstack/ba/**/index.md` to rebuild the menu tree,
   then `Glob .smartstack/ba/*/acteur.md` to find every application's
   **authoritative** actor file. Read each `acteur.md` (the App level is
   authoritative — skip rollups, marked `<!-- ba:rollup auto -->`). Each actor is
   a `### BA-{NNN}-AC-{NNN} — <label>` heading with `**Type**`, `**Description**`,
   `**Périmètre**`, `**Origine**` fields.
2. **Apply** the rules ACT-001, ACT-002, ACT-006 (below) across **all** actors of
   the project — actors are project-scoped (no application/module/section binding).
3. **Write** the verdict to `.smartstack/ba/_audit/actors.md` (project root scope,
   not under any app) using the audit-verdict skeleton from
   `_workflow/doc-templates.md`. Then print a 3–6 line business summary in chat.

There is no database, no `[ACTION]` envelope, no i18n label codes — the `.md`
verdict IS the record. The verdict header (`0 err` = pass) is what a downstream
gate reads.

## 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 actors share the same label ignoring case (e.g.
  `Manager` and `manager`); `ok` if none.
- Compare actor labels case-insensitively across the whole project (an actor
  appearing under the same label in two apps is still a duplicate).
- Fix: `/ba-create-actors` — rename or merge the duplicate actors into a single
  `BA-NNN-AC-NNN`.

### 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.
