shoc-backend/AGENTS.md
Alexandre Brandizzi b421b5bc44 docs(governance): add canonical governance docs, unified quality-gate script, and CI parity
- ARCHITECTURE_AND_CODE_QUALITY.md: canonical layering, EF allowlist,
  transaction/commit convention, cancellation, migrations, error disclosure,
  Big-O/perf, ADR exceptions (supersedes BACKEND_ARCHITECTURE.md)
- QUALITY_GATES.md: gate inventory + pass/fail/skip semantics; local==CI
- REVIEW_AND_PR_FRAMEWORK.md: exact-head review, board-backed regression
  inventory, security/perf evidence, ADR exceptions, no godfile theater
- AGENTS.md: repo-specific delta + precedence pointers
- scripts/governance-check.sh: unified G1 restore + G2 ArchitectureTests +
  G3 changed-file format (portable bash)
- .github/workflows/architecture-quality.yml: call the same local script
- ArchitectureTests.cs: add business-service interface-dependency invariant
2026-07-24 17:36:19 -03:00

72 lines
3.1 KiB
Markdown

# AGENTS.md — SeaHaven backend (repo-specific delta)
This file is the **repo-specific delta** for the Seahaven backend. It layers on
top of the operator/workspace agent baseline (the global `AGENTS.md` and the
agent-config-kit framework) and does not repeat it. Where this file and the
baseline conflict on repo details, **this file wins for this repository**.
## Canonical governance documents (precedence)
1. `ARCHITECTURE_AND_CODE_QUALITY.md` — *what* the rules mean (canonical;
supersedes the older `BACKEND_ARCHITECTURE.md`, which is retained only as
historical reference).
2. `QUALITY_GATES.md` — *how* rules are enforced (commands + CI mapping).
3. `REVIEW_AND_PR_FRAMEWORK.md` — *who* reviews, in what order, with what
evidence.
When these conflict with each other, the one that *owns* the topic wins
(meaning → architecture doc; execution → quality gates; process → review
framework). When unsure, ask; do not silently pick.
## Architecture in one line
```text
Controller -> I{Feature}Service -> I{Feature}DataService -> ApplicationDbContext
```
- Controllers depend on `I{Feature}Service` only — never `DbContext`/EF/concrete
services/data services.
- Business services depend on feature-specific data/query/command interfaces —
never `DbContext`, never `IConfiguration`, never a generic repository.
- Data services own EF; EF/`DbContext` lives only on the documented
infrastructure allowlist (data services, `ApplicationDbContext`, migrations,
Identity/composition, transactions inside data services).
- One commit convention: `SaveChangesAsync(CancellationToken)` inside the owning
data service is the atomic boundary; explicit transactions stay inside data
services.
- Tenant scope is server-derived; authorization is enforced at service entry.
- No HTTP response leaks exception/stack/SQL/credential/crypto detail; secrets
are never logged.
Full detail: `ARCHITECTURE_AND_CODE_QUALITY.md`.
## Running the gates (local == CI)
```bash
bash scripts/governance-check.sh # restore + ArchitectureTests + changed-file format
dotnet build SeaHavenIndustries.sln -c Release
dotnet test SeaHavenIndustries.sln -c Release --no-build
```
CI (`architecture-quality` workflow) calls the same `scripts/governance-check.sh`
so a local green run means the same thing as CI. See `QUALITY_GATES.md`.
## Hard rules (deviation needs an ADR; no wildcard suppressions)
- EF allowlist, dependency direction, no client exception disclosure,
server-derived tenant scope, one commit convention, cancellation forwarding
(verified, not just signed).
- Suppress a single diagnostic with a cited ADR only — never global sweeps.
- See `ARCHITECTURE_AND_CODE_QUALITY.md` §10 for the ADR exception process.
## Do not touch without explicit instruction
- Product behavior, database **migrations**, secrets, dependency versions, and
files unrelated to the current task.
- The `.ai-config-kit-sidecar-write-scope` marker file is a transient
authorization artifact — **never commit it**.
## Reporting
State every changed file with a one-line summary. Report each gate as
pass / fail / skipped / not-run with evidence; never infer a pass from silence.