From 349a68b8b7cba655a44fed962d246225f1751400 Mon Sep 17 00:00:00 2001 From: Bobby Date: Fri, 27 Nov 2026 14:37:54 -0500 Subject: [PATCH] new: in-cluster importer Bots (ADR-0011) Co-Authored-By: Claude Opus 5.5 --- docs/adr/0011-in-cluster-importer-bots.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/adr/0011-in-cluster-importer-bots.md diff --git a/docs/adr/0011-in-cluster-importer-bots.md b/docs/adr/0011-in-cluster-importer-bots.md new file mode 100644 index 0000000..aa12eef --- /dev/null +++ b/docs/adr/0011-in-cluster-importer-bots.md @@ -0,0 +1,19 @@ +# Importer Bots run in-cluster and call hAPI's internal Service + +Finance fills its ledger from importer Bots that call `POST /v1/finance/transactions/ingest`; hAPI itself holds no bank credentials. v1 ships one importer, the **SimpleFIN Bot**, for the Household's Financial Accounts only. It is a **CronJob in the cluster's `bots` namespace**, built from its own package (`bots/simplefin/`) and image in this repo, delivered by the same CI and Flux as hAPI (ADR-0007). It calls hAPI through the **in-cluster Service** rather than `hapi.bobbypalko.com`, still authenticating with its own Bot Token like every other Principal (ADR-0005). We chose this because the cluster already provides SOPS secrets, logs, delivery and Kuma push, and because an outage at the public edge shouldn't stop imports. + +## Considered Options + +- **A home machine.** Outbound traffic works fine from behind CGNAT, but it's one more box to patch, monitor and keep secrets on, outside Flux and SOPS. +- **Calling the public hostname.** This fits ADR-0002's "one public surface" more literally, but it ties imports to the NodeBalancer and Envoy and charges the edge's per-IP limits for traffic that never leaves the cluster. +- **A subcommand of the hAPI image** (`hapi import simplefin`). This would put bank-facing code and its egress inside the API's image and blur the line that importers are Bots outside hAPI. +- **A separate repo.** Rejected under the standing "in this repo, cleanly separable" preference. import-linter forbids `bots/` from importing `hapi.*`, so the Bot talks to hAPI over HTTP only. + +## Consequences + +- **ADR-0002 is narrowed rather than broken.** Every request still needs a Principal's Token. Only in-cluster Bots skip the edge, and the Gateway still never routes `:8081`. +- **Credentials:** the Bot is the Principal `simplefin-importer`, holding a single Household grant of `finance:write` and no Bindings. Its Token, the SimpleFIN Access URL, the mapping from SimpleFIN account ids to Financial Account ids, and its Kuma push URL all live in one SOPS secret (`bot-simplefin`) and are mounted as files (ADR-0008). The Vaultwarden item "SimpleFIN Access URL" stays the source of truth. The mapping is encrypted because account ids and institutions are metadata we keep out of a public repo. Unmapped SimpleFIN accounts are skipped with a warning. +- **Runs:** every 6 h with `concurrencyPolicy: Forbid`, fetching a `start-date` 14 days back. The overlap absorbs posting lag and outages of up to two weeks, and idempotent ingest drops repeats. History starts at each Account's `tracked_from`, and there is no backfill. +- **Failure:** a SimpleFIN transport error, a non-empty `errors` array (e.g. a bank needs reconnecting), or a failed ingest makes the run exit non-zero. A clean run pings a Kuma push monitor with a 13 h window, which allows two missed runs (ADR-0009). +- **Network:** `bots` is default-deny. Egress is allowed only to DNS, the hAPI app port, and, through Cilium `toFQDNs`, the SimpleFIN bridge and Kuma push hosts on 443. Pods run non-root, with a read-only root filesystem and no service-account token. +- **No shared Bot library** until a second Bot exists.