Вот текст для `AGENT.md`:

---

```markdown
# Agent Operating Rules — City Briefing Agent

This project shares the am_core rules used across `automation/*` repos
(Change / Git / Deploy / Database / Security / Incident / Worker / Docs),
with the additions below. The am_core rules are the default; the additions
narrow them for this pipeline.

## First Contact Protocol

1. Read the directory structure — do not assume, read.
2. Identify the stack: languages, frameworks, Docker services, environment files.
3. Summarize the architecture in plain English before touching anything.
4. Ask one clarifying question if the purpose of a component is unclear.
5. Wait for confirmation before proceeding.

Never open files not relevant to the task. Never read `.env` unless explicitly
asked — acknowledge they exist and ask what you need.

## Scope change — Phase 12 vs Phase 13

For the current phase, email delivery is intentionally NOT part of the project.
Do not add, plan, or reference any of:

- Brevo API integration
- Transactional email
- Email templates
- Email sender configuration
- Email delivery status / retry handling
- Brevo credentials
- Email-related n8n nodes
- Email failure handling

If a change touches any of these, stop and ask. Adding them is a separate
future phase after this pipeline is stable.

The pipeline ends with a published Public HTML briefing URL. Status `published`
means brief generated + HTML deployed to VPS + public URL 200 + OG verified.

## Change Protocol

- Show a plan, wait for explicit approval ("go ahead" / "do it" / "yes").
  "Looks good" / "ok" is not approval.
- One logical unit at a time. Show a diff after each edit.
- Never edit `.env`, `docker-compose.yml`, `nginx.conf`, or infrastructure
  config without explicit instruction.
- Never run destructive commands (DROP / DELETE / TRUNCATE / `rm -rf`)
  without approval.

The only path that writes to the VPS webroot is the orchestrator's
`vps_deployment` stage; never hand-edit `/var/www/just2done.com/brief/` content.

## Git Protocol

Commit message format: `type(scope): short description`

Types: `feat` `fix` `refactor` `chore` `docs` `perf` `security`

Scopes relevant here: `pipeline`, `orchestrator`, `providers`, `html`, `db`,
`n8n`, `api`, `verify`, `voice`.

Never stage `.env`, `*.key`, `*.pem`, credentials. Never auto-commit or
auto-push. Default branch is `main`.

## Deploy Protocol

This service deploys to VPS `178.162.240.152` alongside the existing
`n8n.maxify.it` instance. Standard deploy:

```
# On VPS — pull and rebuild the service only
cd /root/show-city-briefing-agent
git pull origin main
docker compose up -d --build city-briefing-agent
docker compose logs --tail=50 city-briefing-agent
```

Never `docker compose down` in production. Never restart all services
when only one changed.

Post-deploy verify BOTH paths:
1. `curl -s -o /dev/null -w "%{http_code}" http://city-briefing-agent:8000/health`
   (from a container on the same docker network) — expect `200`.
2. Confirm `n8n.maxify.it` can resolve `http://city-briefing-agent:8000`
   (the schedule trigger depends on the shared docker network name).

A `published` brief is the only proof of an end-to-end good deploy — the
container being "Up" is necessary but not sufficient.

## Database Rules

The new `city_briefs_ops` DB owns two tables only: `city_briefs` and
`city_briefs_runs`. Reads direct; writes need confirmation. Destructive
ops (DROP / TRUNCATE) always require explicit confirmation. No migrations
during 10:00–22:00 LA peak unless emergency.

This service never writes to `abstraction_media_leads`, `leads`, or any other
existing DB. It reads the cleaned Planner mirror over HTTP
(`planner.maxify.it`), not the central Postgres.

## Security Rules

Never print, log, or echo: passwords, API keys, SSH private keys, `.env`
contents. Use environment variables for credentials. The logging layer
(`app/logging.py`) applies secret-redaction regex — keep patterns updated
when new credential-bearing env vars are added.

When adding new internal endpoints (default):
- Auth required (one of the `BRIEF_SERVICE_API_KEYS` bearer values)
- Rate-limit user-facing endpoints
- Validate input before any DB write
- Parameterized queries only — never string concatenation

Voice profiles and generated briefs may contain comedian IP — treat as
confidential; do not paste into external tools.

## Worker Requirements

The orchestrator is invoked by the n8n cron trigger at 09:00 LA through
`POST /api/v1/brief/run`. It must be:

- Idempotent — re-running for already-`published` shows sets later stages
  to `skipped` and returns the existing `public_url` (never re-generates).
- Bounded — `SHOW_CONCURRENCY` caps parallel shows so the AI providers are
  not overwhelmed.
- Isolated — one show's stage failure never cancels sibling shows.
- Retryable — retryable provider errors (5xx / 429 / timeout) retry 3× with
  exponential backoff; non-retryable errors fail the stage fast.
- Observable — every stage writes status + redacted error to
  `city_briefs_runs`; every brief writes its lifecycle to `city_briefs`.

## Documentation Standard

Every production fix leaves a Markdown file under `docs/ops/` with:
What failed / Why / Files changed / VPS install location / Schedule /
Verification / Known risks / Next improvement.

Acceptance criteria for this phase are documented in `README.md` — a
change is not done until the relevant checkbox in `README.md` is also green.

## What "Done" Means

A task is done when:
- The original symptom is resolved
- Root cause is controlled
- Recurrence is handled (timer / alert / guardrail)
- Post-deploy verification passed — including a `published` brief reaching
  `https://just2done.com/brief/<slug>` with HTTP 200 and verified OG metadata
- Documentation written

Not done when: "the command ran without errors" / "the container restarted".
Always verify the product, not just the operation.
```