# Configuration

The categories you follow, how the briefing is sized and tuned, and every section of
`config.json`. Install and onboarding are in [Getting started](getting-started.md).

## Categories

A category is a topic in a region, for example "Brazil Markets" or "Europe Politics", or a topic
followed across regions, such as "Science", with Brazilian and global sources. Each one is a
profile in `profiles/` with its own relevance rules and scoring rubric. There are 40:

| Region | Categories |
|---|---|
| Brazil | `br-markets`, `br-economy`, `br-politics`, `br-regulatory`, `br-fintech`, `br-tech-startups`, `br-sports` |
| Latin America | `latam-economy`, `latam-politics`, `latam-tech`, `latam-sports` |
| United States | `us-markets`, `us-economy-fed`, `us-politics`, `us-regulatory`, `us-sports` |
| Europe | `eu-markets`, `eu-economy`, `eu-politics`, `eu-regulatory`, `eu-sports` |
| Asia-Pacific | `apac-economy`, `apac-tech`, `apac-politics` |
| Oceania | `oceania-politics`, `oceania-economy`, `oceania-sports` |
| Middle East and Africa | `mea-geopolitics`, `mea-economy`, `mea-fintech` |
| Canada | `ca-politics`, `ca-economy` |
| Global | `global-tech-ai`, `global-fintech-crypto`, `global-macro` |
| Topics | `science`, `health`, `climate-energy`, `culture`, `startups-vc` |

Change them at any time:

```bash
herald categories list                  # all categories, [x] = followed (--lang en for English names)
herald categories add sports            # add the five sports categories
herald categories remove us-sports
herald categories set br eu-politics    # replace the whole selection
```

Wherever a category id is accepted, you can also use:
- the number shown by `list`;
- a region: `br`, `latam`, `us`, `eu`, `apac`, `oceania`, `mea`, `ca`, `global` (every
  category of that region, its sports one included, such as `br-sports`);
- `topics` (the five topic categories);
- `sports` (the five sports categories);
- `all`.

Sources whose categories you don't follow are not fetched at all, so a smaller selection also
means a faster run. The example config follows the 13 business and politics categories, with no
Latin America, Europe, Asia-Pacific, Oceania, Middle East and Africa, Canada, topics or sports.

## Tuning the content

**Profiles** live in `profiles/*.md`. Each one has:
- YAML front matter: pre-filter keywords, exclusions, a description used for embedding
  similarity, the score threshold and item caps. `keyword_languages` (default `[en, pt]`) lists
  the languages the keywords are written in; items in other languages are matched by meaning
  instead of being penalized for missing them;
- a body with `# Relevant`, `# Ignore`, `# Scoring rubric (0–10)` and `# Output` sections. The
  rubric decides what the model considers important.

Per-profile `threshold` and `max_items` overrides go in `config.json`.

**How many stories, and from which categories.** The briefing size follows the categories you
follow. With `digest.max_items: "auto"` (the default) you get two slots per category, between 20
and 50: 50 with all 40 categories, 20 with five. Set a number instead to fix the size. Slots are
filled in this order:
1. The same story from several outlets, even in different languages, is merged into one entry
   that lists every outlet. The scoring model makes this call once per run.
2. Every category you follow gets `digest.min_per_category` slots (default 1), if it has a story
   above its threshold.
3. The remaining slots go to the highest scores, up to each category's `max_items`.

The shipped profiles are the 40 categories listed in
[Categories](#categories). To add a category, add a profile file with a
`category:` region (`brazil`, `latam`, `us`, `europe`, `apac`, `oceania`, `mea`, `canada`, `global`, `topics`). Then add it to `digest.section_order` and
to a digest group.

**Watchlists** in `config.json` cover B3/US tickers, companies, people and keywords. Matching
items always reach the scorer. Watchlists also decide which companies get CVM material facts and
SEC 8-Ks fetched.

**Upcoming section.** It covers:
- Copom (dates from config, since BCB has no public calendar API);
- Boletim Focus (Mondays, shifted on B3 holidays);
- IBGE releases;
- FOMC;
- BLS/BEA releases;
- other central banks' rate decisions (`central_banks`, dates from config);
- UK releases from the ONS release calendar API (`ons`: CPI, GDP, labour market, retail sales);
- releases of other statistics offices with an official, keyless machine-readable calendar (table
  below);
- manual events such as earnings.

`central_banks`, `ons` and the statistics-office providers are off by default; add them to
`calendars.enabled`.

```json
"calendars": {
  "enabled": ["copom", "focus", "ibge", "fomc", "bls", "bea", "central_banks", "ons", "statcan", "earnings"],
  "copom_dates": ["2027-01-27", "2027-03-17"],
  "central_bank_dates": {"cnb": ["2027-02-04", "2027-03-25"], "boe": ["2027-02-04"]},
  "manual": [{"date": "2027-02-05", "country": "BR", "kind": "earnings", "title": "Itaú (ITUB4): 4Q26 results"}]
}
```

None of these central banks publishes its decision schedule in a machine-readable format, so
copy the dates from the official page. Each event links back to it. Unknown ids fail the
provider (reported in the run report) instead of being guessed.

| Id | Bank | Official schedule |
|---|---|---|
| `banxico` | Banco de México | [Anuncios de política monetaria](https://www.banxico.org.mx/publicaciones-y-prensa/anuncios-de-las-decisiones-de-politica-monetaria/anuncios-politica-monetaria-t.html) |
| `bcch` | Banco Central de Chile | [Calendario de Política Monetaria y Financiera](https://www.bcentral.cl/web/banco-central/noticias-y-publicaciones/prensa/calendario-de-politica-monetaria-y-financiera) |
| `banrep` | Banco de la República (Colombia) | [Calendario Junta Directiva](https://www.banrep.gov.co/es/calendario-junta-directiva) |
| `bcrp` | Banco Central de Reserva del Perú | [bcrp.gob.pe](https://www.bcrp.gob.pe/) (schedule in its *Notas Informativas*) |
| `boc` | Bank of Canada | [Policy interest rate](https://www.bankofcanada.ca/core-functions/monetary-policy/key-interest-rate/) |
| `rba` | Reserve Bank of Australia | [Board meeting schedules](https://www.rba.gov.au/schedules-events/board-meeting-schedules.html) |
| `rbnz` | Reserve Bank of New Zealand | [OCR decision dates](https://www.rbnz.govt.nz/news-and-events/how-we-release-information/ocr-decision-dates-and-financial-stability-report-dates-to-feb-2028) |
| `boe` | Bank of England | [Upcoming MPC dates](https://www.bankofengland.co.uk/monetary-policy/upcoming-mpc-dates) |
| `riksbank` | Sveriges Riksbank | [Calendar](https://www.riksbank.se/en-gb/press-and-published/calendar/) |
| `norges_bank` | Norges Bank | [Monetary policy meetings](https://www.norges-bank.no/en/topics/Monetary-policy/Monetary-policy-meetings/) |
| `snb` | Swiss National Bank | [Time schedule](https://www.snb.ch/en/services-events/digital-services/event-schedule) |
| `nbp` | Narodowy Bank Polski | [Schedule of MPC meetings](https://nbp.pl/en/monetary-policy/schedule-of-mpc-meetings) |
| `cnb` | Czech National Bank | [Bank Board](https://www.cnb.cz/en/about_cnb/bank-board/) |
| `mnb` | Magyar Nemzeti Bank | [The Monetary Council](https://www.mnb.hu/en/monetary-policy/the-monetary-council) |
| `bnr` | Banca Națională a României | [NBR Board meetings calendar](https://www.bnr.ro/en/2528-nbr-board-meetings-calendar) |
| `ecb` | European Central Bank | [Meetings of the Governing Council](https://www.ecb.europa.eu/press/calendars/mgcgc/html/index.en.html) |
| `cbi` | Central Bank of Iceland | [Monetary Policy Committee](https://www.cb.is/monetary-policy/monetary-policy-committee) |
| `nbu` | National Bank of Ukraine | [Schedule of Board meetings on monetary policy](https://bank.gov.ua/en/monetary/schedule) |
| `bccr` | Banco Central de Costa Rica | [Calendario de reuniones de política monetaria](https://www.bccr.fi.cr/cr/es/politica-monetaria/informes-y-comunicados-sobre-politica-monetaria/calendario-politica-monetaria.html) |

`ecb` covers every euro-area national central bank (for example Banque de France, Bundesbank,
Banca d'Italia, Banco de Portugal, OeNB and the Baltic central banks): they take no rate
decisions of their own. Not listed:

- BCRA (Argentina): it currently runs a monetary-aggregates regime and publishes no schedule of
  rate decisions;
- Danmarks Nationalbank: it moves its rates with the ECB under the krone peg, on no schedule of
  its own;
- the central banks of Montenegro, Kosovo and El Salvador: no own policy rate (euro or dollar);
- National Bank of Serbia, Bank of Albania, NBRM (North Macedonia), BCU (Uruguay), BCP
  (Paraguay), Banguat, BCH (Honduras) and Banco Central de la República Dominicana: no official
  schedule page could be verified (several announce only the next meeting, or block automated
  clients). Add their dates as `calendars.manual` events if you need them.

Statistics-office providers keep the headline releases only: CPI, GDP, the labour market and
retail sales.

| Id | Office | Official feed |
|---|---|---|
| `ons` | Office for National Statistics (UK) | [Release calendar API](https://api.beta.ons.gov.uk/v1/search/releases) (JSON) |
| `statcan` | Statistics Canada | [Key indicators schedule](https://www.statcan.gc.ca/en/developers/schedule-key_indicators-eng-json) (JSON); times are The Daily's 08:30 Eastern |
| `ine_es` | INE (Spain) | [Statistics availability calendar](https://www.ine.es/en/daco/daco41/calen_ics_en.htm) (iCalendar) |
| `czso` | Czech Statistical Office | [News releases calendar](https://csu.gov.cz/kalendar-vsech-produktu-csu-v-ical) (iCalendar, English titles) |
| `ine_pt` | INE (Portugal) | [Releases calendar](https://www.ine.pt/xportal/xmain?xpid=INE&xpgid=ics_feeds&xlang=EN) (iCalendar, English titles) |

No provider exists yet for these offices: no official, keyless machine-readable release
calendar that robots.txt allows has been found for them:

- ABS (Australia), Stats NZ, INEGI (Mexico, yearly PDF);
- SCB (Sweden), SSB (Norway), Swiss FSO;
- Insee (France), CBS (Netherlands);
- Destatis (Germany): one `.ics` download per release, no subscribable feed;
- Istat (Italy): its iCalendar feeds are hosted on `google.com/calendar`, which robots.txt
  disallows;
- GUS (Poland) and KSH (Hungary): HTML release calendars only (their news feeds are in the
  catalog);
- INE Chile, DANE (Colombia), INEI (Peru): HTML calendars only (DANE's calendar RSS lists past
  events and is stale);
- INS (Romania): its site's TLS certificate chain does not verify, so nothing can be fetched.

Add their dates as `calendars.manual` events if you need them.

**Politics** draws on outlets across the spectrum. Each politics source carries a `spectrum`
label, and every run reports the label mix of candidates and selected stories. Entries report
facts common to the coverage and attribute claims.

**Wire copies** are detected from bylines and collapsed into one story that credits the agency
(Agência Brasil, Estadão Conteúdo, Folhapress, Reuters, AP, Bloomberg, AFP, EFE).

## Output languages

Herald writes the briefing in every language listed in `output.languages`. The default is
Brazilian Portuguese and English; six languages are supported:

| Code | Language |
|---|---|
| `pt-BR` | Brazilian Portuguese |
| `en` | English |
| `es` | Spanish |
| `fr` | French |
| `it` | Italian |
| `de` | German |

```json
"output": { "languages": ["pt-BR", "en", "es"], "primary": "pt-BR" }
```

- `herald config set languages pt-BR en es` writes both keys (the first code is `primary`) and
  gives every channel in `notifiers` the same `languages`; to send a channel fewer, edit its
  `languages` afterwards. Codes are checked before anything is saved.
- Unknown codes are rejected when the config loads, in `output.languages` and in every
  notifier's `languages`.
- `primary` is the language of a notifier without `languages` and the bot's fallback. Left out,
  it is the first language in the list; set, it must be one of them.
- The enrichment model writes all languages of a story in one call. Only when they would not fit
  the output budget (`ai.enrichment.max_tokens`, about 1,200 tokens per language with room for
  reasoning) does Herald split them into several calls. The run report shows the languages and
  the enrichment calls per story (`output  pt-BR, en, es  (1 enrichment call per story)`); each
  extra language adds output tokens to the `enrichment` cost line.
- Each language gets its own file (`data/briefings/<date>.<lang>.md`), site page and feeds.
  Channels pick theirs with `languages`; email and bot subscribers pick their own.
- Section titles, dates, category and region names, the email footer, push notifications and
  bot replies are translated in `src/herald/i18n.py`; category names are in each profile's
  `names`.

## Configuration reference

`config.json` plus `.env`. Any string can reference environment variables as `${VAR}` or
`${VAR:-default}`, so secrets stay out of `config.json`. The full schema with defaults is in
`src/herald/config.py`.

| Section | Controls |
|---|---|
| `window_hours`, `timezone`, `schedule` | Time window, local time (an IANA name; `herald config set timezone Europe/Lisbon` checks and saves it), skipping B3/NYSE holidays |
| `sources` | Catalog files, `max_tier`, enable/disable lists, `states` to follow, per-tier caps, rate limits (`rate_limit`: `per_host_interval_s`, `per_host_concurrency`, `timeout_s`, and `max_concurrency`, the number of sources fetched at once and the connection pool size, default 64) |
| `profiles` | The categories you follow (`enabled`, managed by `herald init` / `herald categories`); per-category `threshold`/`max_items` overrides; `dir`, the folder with the category profiles (default `profiles`, relative to the config file's folder; when it is missing or empty, `herald init` and `herald categories` stop with an error naming the resolved path) |
| `watchlists` | Tickers, companies, people, keywords; CVM/SEC filings |
| `prefilter`, `embeddings`, `cluster`, `routing` | The cheap relevance stage and clustering; `embeddings.threads`, the CPU threads of the local model (default: the CPUs Herald may use, at most 4 when no container CPU limit is visible; the `embeddings: loading` log line says how many and why). Set it to the machine's CPUs when a limit is hidden, such as 2 on a 2-CPU LXC VPS or Docker inside a container, or higher on a big machine |
| `ai.scoring`, `ai.enrichment`, `ai.pricing` | Providers, models, price table for the cost report |
| `digest` | Briefing size (`max_items`, `"auto"` by default), per-category floor (`min_per_category`), section order (`section_order`; the old `profile_order` key still works but logs a deprecation warning), Brazil/Latin America/US/Europe/Asia-Pacific/Oceania/Middle East and Africa/Canada/global/topics/sports groups (optional caps), diversity |
| `output` | Briefing languages (`["pt-BR", "en"]` by default; also `es`, `fr`, `it`, `de`) and the primary language ([above](#output-languages)) |
| `history` | Repeat-suppression window and retention |
| `calendars` | Upcoming-section providers, Copom and other central-bank dates, manual events |
| `site` | Static HTML site and feeds; `base_url` (its public URL) turns on the feeds and links webhook events, the WhatsApp button and the push notifications to each page; `feed_days` |
| `notifiers` | Delivery channels ([Channels](channels.md)); `herald config set channels telegram slack` turns those types on and every other one off |
