3.1 KiB
3.1 KiB
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 importinghapi.*, 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 offinance:writeand 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 astart-date14 days back. The overlap absorbs posting lag and outages of up to two weeks, and idempotent ingest drops repeats. History starts at each Account'stracked_from, and there is no backfill. - Failure: a SimpleFIN transport error, a non-empty
errorsarray (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:
botsis default-deny. Egress is allowed only to DNS, the hAPI app port, and, through CiliumtoFQDNs, 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.