Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f49acddab3 |
No files matched your search
+2
-86
@@ -1,6 +1,6 @@
|
||||
# hAPI
|
||||
|
||||
hAPI ("home API") is a personal, cloud-hosted API serving one household and its automations: finance, fitness, maintenance, and smart home. Access is restricted to a small, known set of Principals.
|
||||
hAPI ("home API") is a personal, cloud-hosted API serving one household and its automations: finance, fitness, home maintenance, and smart home. Access is restricted to a small, known set of Principals.
|
||||
|
||||
## Language
|
||||
|
||||
@@ -15,7 +15,7 @@ A human Principal (the Owner, family, friends).
|
||||
_Avoid_: User, human user, member
|
||||
|
||||
**Bot**:
|
||||
A non-human Principal: a script, automation, or integration such as Home Assistant. Some Bots are built into hAPI itself, such as the scheduler, and never hold a Token.
|
||||
A non-human Principal: a script, automation, or integration such as Home Assistant.
|
||||
_Avoid_: Service account, machine user, integration account
|
||||
|
||||
**Owner**:
|
||||
@@ -60,92 +60,8 @@ _Avoid_: Shared data, common data
|
||||
The Principal that created or last changed a record, distinct from who owns it.
|
||||
_Avoid_: Author, owner, creator
|
||||
|
||||
### Notifications
|
||||
|
||||
**Notification**:
|
||||
A message hAPI keeps for one Person or for the Household about something that needs their attention, delivered through one or more channels such as ntfy. A Notification to a Person is seen only by that Person; one to the Household by every Household member. Platform alerts to the Owner (from CI, delivery, or monitoring) are not Notifications.
|
||||
_Avoid_: Alert, event, message
|
||||
|
||||
### Smart home
|
||||
|
||||
Smart home is hAPI's side of the house: queuing Jobs for Home Assistant, which remains the source of truth for the house's state.
|
||||
|
||||
**Job**:
|
||||
A request, queued in hAPI, for Home Assistant to carry out an action in the house. Jobs are Household data. Domain code, Persons, and Bots can all create them.
|
||||
_Avoid_: Task, command, message
|
||||
|
||||
### Finance
|
||||
|
||||
**Financial Account**:
|
||||
A bank, credit card, or cash account whose money hAPI tracks. It is owned by a Person or by the Household, and its Transactions share that owner.
|
||||
_Avoid_: Account (on its own), bank account, wallet
|
||||
|
||||
**Transaction**:
|
||||
A single posted movement of money into or out of one Financial Account.
|
||||
_Avoid_: Entry, charge, payment
|
||||
|
||||
**Category**:
|
||||
A named bucket that Transactions are sorted into, of kind expense, income, or transfer. Household Categories can be used by the Household and by every Household member; Personal Categories only by their Person.
|
||||
_Avoid_: Tag, label, envelope
|
||||
|
||||
**Budget**:
|
||||
One owner's zero-based monthly plan: expected income assigned across Categories, then rebalanced during the month with Moves. The Household has one, and each Person may have one.
|
||||
_Avoid_: Plan, envelope
|
||||
|
||||
**Target**:
|
||||
A Budget's standing amount for one Category over a period (monthly, quarterly, or annual), spread into even monthly shares.
|
||||
_Avoid_: Goal, limit
|
||||
|
||||
**Allocation**:
|
||||
What a Budget assigns to one Category in one month: the Target's monthly share, adjusted by Moves.
|
||||
_Avoid_: Budgeted amount, envelope
|
||||
|
||||
**Move**:
|
||||
A shift of money from one Category's Allocation to another's within one month of a Budget. It never changes the month's total.
|
||||
_Avoid_: Transfer (a kind of Category), reallocation
|
||||
|
||||
**Banked**:
|
||||
Said of a Category whose Target period is longer than a month. Its unspent Allocations carry forward as a banked balance until the bill draws it down.
|
||||
_Avoid_: Sinking fund, rollover, savings
|
||||
|
||||
**Payee mapping**:
|
||||
An owner's remembered link from a payee to a Category, learned from manual categorization and applied to newly ingested Transactions.
|
||||
_Avoid_: Rule, auto-categorization
|
||||
|
||||
### Maintenance
|
||||
|
||||
Maintenance is the recurring upkeep of the Household's property: the home, its land, its equipment, its vehicles, and its digital systems (such as the hAPI cluster). It is not a to-do list: errands, bills, and one-off chores don't belong.
|
||||
|
||||
**Asset**:
|
||||
A thing the Household keeps up, such as the roof, the furnace, a car, or the hAPI cluster. It may have a meter whose Readings track its use.
|
||||
_Avoid_: Equipment, item, entity (a Home Assistant term); in Finance, use another word
|
||||
|
||||
**Task**:
|
||||
A recurring piece of upkeep, due either a fixed interval after it was last done or on a calendar rhythm, and optionally also after a set amount of use. Tasks always recur; one-off work is recorded only as a Service.
|
||||
_Avoid_: Chore, reminder, to-do (and never a Job)
|
||||
|
||||
**Service**:
|
||||
One piece of maintenance work done on a date. It may fulfill a Task, and may concern an Asset.
|
||||
_Avoid_: Completion, repair, log entry
|
||||
|
||||
**Reading**:
|
||||
An Asset's meter value (an odometer's distance or a runtime counter) taken on a date, used to decide when usage-based Tasks come due.
|
||||
_Avoid_: Measurement (a Fitness term), metric
|
||||
|
||||
### Fitness
|
||||
|
||||
**Workout**:
|
||||
One session of exercise by one Person: an ordered list of Exercises performed, with what was done in each. A run is a Workout with a single cardio Exercise.
|
||||
_Avoid_: Session, activity, training
|
||||
|
||||
**Exercise**:
|
||||
A named movement that Workouts record, of kind strength, bodyweight, timed, or cardio; the kind decides what is recorded for it. Household Exercises can be used by every Household member; Personal Exercises only by their Person.
|
||||
_Avoid_: Movement, lift, activity
|
||||
|
||||
**Set**:
|
||||
One bout of a strength, bodyweight, or timed Exercise within a Workout: reps and load, or a duration. A warmup Set doesn't count toward records.
|
||||
_Avoid_: Rep, round
|
||||
|
||||
**Measurement**:
|
||||
One reading of a Person's body (weight, body fat, or a circumference) at a point in time.
|
||||
_Avoid_: Metric, stat, body stat
|
||||
@@ -7,7 +7,6 @@ hAPI serves exactly one Household, so there is no multi-tenancy. Every record is
|
||||
- **The Owner has no special read access to Personal data.** Owner authority covers Principals and the platform only. Bots reach Personal data only through a **Binding** that the bound Person grants and can revoke. The Owner cannot grant one on another Person's behalf.
|
||||
- Every record carries its owner plus **Recorded by**: the Principal that created it and the one that last changed it. Principals are deactivated, never hard-deleted, so Recorded by never dangles.
|
||||
- Ownership is fixed when a record is created, except that a Person may move their own Personal record to the Household (one way only).
|
||||
- **Finance exception:** Financial Accounts and their Transactions never move. To bring an account into the Household, the Personal Financial Account stops tracking at a date and a new Household one starts tracking from it, so spending history stays with the owner who spent it. Finance Categories can still be promoted.
|
||||
- When a Person is removed, their Personal data is exported and then explicitly deleted. Household data they recorded stays with the Household.
|
||||
- Persons who are not Household members (e.g. friends) see only their own Personal data.
|
||||
- Not in v1: roles within the Household, sharing outside the Household, and guest access to Household data.
|
||||
@@ -28,6 +28,6 @@ hAPI uses a **Linode Managed PostgreSQL 18** cluster (Shared 2 GB, 1 node) attac
|
||||
- **Cross-Person work runs per Person.** Purging a removed Person's data, or a job such as reminders, sets `hapi.principal_id` to each Person in turn.
|
||||
- **Data repairs** normally ship as reviewed Alembic data migrations run as `hapi_migrator`, targeting rows by id or condition without printing them.
|
||||
- **Break-glass goes through `hapi db breakglass --reason "…"`.** It opens `psql` as `hapi_migrator` from a pod and emits structured audit events to hAPI's centralized logs: start, end, reason, and every statement. Query results are never logged. The platform offers no statement logging or pgaudit, so this is the only audit trail.
|
||||
- **Connection budget:** the plan allows 50 connections. That leaves about 46 usable after 3 reserved superuser slots and one platform backend. Each app pod holds at most 10 (`pool_size=5`, `max_overflow=5`), and the admin CLI holds 1–2. The rule is: (maximum concurrent app pods, including rollout surge) × 10, plus about 6 for migrate, CLI, break-glass and bootstrap, must be ≤ 46. That caps app pods at 4. Any future worker process counts against the same budget. **Amended by ADR-0012:** housekeeping CronJobs use a pool of 1, so the rule is app pods (with surge) × 10 + concurrently runnable CronJobs × 1 + ~6 ≤ 46.
|
||||
- **Plan changes are restores.** An in-place resize stalled during verification. Changing size or node count is done as a restore-to-new-cluster, with the same runbook as disaster recovery: fork, wait for DNS, `hapi db bootstrap`, repoint the app. Single-node maintenance windows (pinned to a quiet slot) cause short downtime, covered by 14-day point-in-time recovery. **Amended by ADR-0014:** our own daily dumps (an Object Lock bucket, pulled off-account) cover damage found after 14 days and account loss, and `hapi db bootstrap` also creates a read-only `BYPASSRLS` `hapi_backup` role for `hapi db backup`.
|
||||
- **Connection budget:** the plan allows 50 connections. That leaves about 46 usable after 3 reserved superuser slots and one platform backend. Each app pod holds at most 10 (`pool_size=5`, `max_overflow=5`), and the admin CLI holds 1–2. The rule is: (maximum concurrent app pods, including rollout surge) × 10, plus about 6 for migrate, CLI, break-glass and bootstrap, must be ≤ 46. That caps app pods at 4. Any future worker process counts against the same budget.
|
||||
- **Plan changes are restores.** An in-place resize stalled during verification. Changing size or node count is done as a restore-to-new-cluster, with the same runbook as disaster recovery: fork, wait for DNS, `hapi db bootstrap`, repoint the app. Single-node maintenance windows (pinned to a quiet slot) cause short downtime, covered by 14-day point-in-time recovery.
|
||||
- Passwords are rotated manually with a runbook. `password_encryption` is set explicitly to `scram-sha-256`.
|
||||
@@ -14,7 +14,7 @@ hAPI needs Home Assistant to carry out actions in the house: things queued while
|
||||
|
||||
- **The bridge needs no new infrastructure or credentials.** HA is the `home-assistant` Bot with a Household grant of `smart_home:write`, and its Token lives in HA's `secrets.yaml`. There's no `jobs` Scope: `smart_home:write` both creates Jobs and consumes them, and ADR-0005 allows splitting the Scope later.
|
||||
- **Delivery is at-least-once, FIFO by `not_before` (or creation time).** `next` hands out the oldest eligible Job and hides it for a 2-minute lease. After 3 deliveries with no result, the Job becomes `failed` (`no_result`), so one broken Job can't stall the queue. HA scripts must be idempotent: set states, don't toggle. After each result, HA calls `homeassistant.update_entity` on the sensor so a backlog drains without waiting for the next poll.
|
||||
- **Job lifecycle:** `pending → succeeded | failed | expired | cancelled`. A Job may carry an optional `not_before`. `expires_at` defaults to 1 h after `not_before` (or after creation), and an expired Job is never delivered. A result is `{status, error?, response?}`, where `response` holds the script's response variables. The first result wins, and a later one gets `409`. Any Household member, or any Bot with `smart_home:write`, can cancel a `pending` Job. Finished Jobs are immutable and are kept for 90 days. `hapi jobs sweep`, a CronJob every 15 min (ADR-0012), removes them and marks pending Jobs past `expires_at` as `expired`; until it does, reads derive `expired` from `expires_at`.
|
||||
- **Job lifecycle:** `pending → succeeded | failed | expired | cancelled`. A Job may carry an optional `not_before`. `expires_at` defaults to 1 h after `not_before` (or after creation), and an expired Job is never delivered. A result is `{status, error?, response?}`, where `response` holds the script's response variables. The first result wins, and a later one gets `409`. Any Household member, or any Bot with `smart_home:write`, can cancel a `pending` Job. Finished Jobs are immutable and are kept for 90 days. Until scheduling exists, `hapi jobs purge` removes them.
|
||||
- **hAPI checks only the shape of a Job, not what it does.** Script names must match `hapi_[a-z0-9_]+`, and variables are capped at 16 KB. hAPI keeps no catalogue of HA scripts. HA rejects unknown scripts, which comes back as a failed result.
|
||||
- **HA-side configuration** is a reference package in this repo (`integrations/home-assistant/hapi_jobs.yaml`: rest sensor, automation, rest_command), copied into HA by hand. The `hapi_*` scripts themselves live in a separate HA configuration repo.
|
||||
- **hAPI records HA's last poll**, so a stalled bridge can be detected. Turning that into an alert is part of observability.
|
||||
@@ -20,5 +20,5 @@ Every green merge to protected `main` reaches production, with no release tags a
|
||||
- **The CI write credential is a deploy key with write access**, stored as an Actions secret and allowlisted past `main`'s branch protection. The build workflow's path filter skips bump commits, so a bump doesn't trigger another build.
|
||||
- **Renovate runs nightly** on the same runner as its own bot user. It auto-merges only dev-only tooling. Anything that ships (runtime dependencies, base image, charts, Flux, Talos, OpenTofu providers) arrives as a PR the Owner merges.
|
||||
- **Not delivered through Flux:** the runner VM, Cilium, and the Linode CCM live in OpenTofu under `infra/`, and the Owner runs `tofu apply` over the tailnet. Talos and Kubernetes upgrades are a manual `talosctl` runbook. CI never holds the Tofu state key.
|
||||
- **Failures notify through ntfy:** a final `if: failure()` step in each workflow, and Flux's notification-controller for failed reconciles and rollouts. Topics and auth: ADR-0013 (`ops` topic, each sender its own publish-only ntfy user).
|
||||
- **Failures notify through ntfy:** a final `if: failure()` step in each workflow, and Flux's notification-controller for failed reconciles and rollouts. Topics and auth are designed with notifications.
|
||||
- **Deferred:** having Flux verify commit signatures, and signing images (cosign) with admission-time verification. Both guard against a compromised Gitea and belong together in cluster hardening.
|
||||
@@ -16,9 +16,9 @@ ADR-0002 allows no anonymous public endpoints, but kubelet probes can't carry a
|
||||
|
||||
- **`/livez`** returns a constant. **`/readyz`** passes once startup is done (config loaded, pools created). On SIGTERM, `/readyz` fails first and the pod drains for about 5 s before it shuts down. Readiness also gates rollouts (ADR-0007): an image that never becomes Ready stalls the rollout.
|
||||
- **`/v1/health`** checks `db` (a `SELECT 1` through the app pool) and `schema` (at the expected Alembic head). These are critical: if either fails, the status is `down` with HTTP 503. It also checks `ha_bridge` (no poll for 5 min, see ADR-0006) and `job_backlog` (oldest pending Job too old). These are non-critical: if one fails, the status is `degraded` with HTTP 200. Bodies carry no error text, hostnames, versions or latencies. Kuma points two monitors at it: *up* (HTTP status) and *healthy* (a JSON query asserting `status == "ok"`).
|
||||
- **Collection:** vmagent scrapes the app, kubelet/cAdvisor, kube-state-metrics, node-exporter, Flux and Cilium. A Vector DaemonSet takes pod stdout and Talos service logs (`machine.logging`, JSON over TCP). An event exporter ships Kubernetes Events as logs. Everything lives in a `monitoring` namespace on Block Storage PVs and arrives as Flux `HelmRelease`s. **Amended by ADR-0015:** the Vector and node-exporter DaemonSets run in a separate `privileged` namespace, `monitoring-node`, while `monitoring` enforces Pod Security `restricted`. Vector also ships the Kubernetes audit log.
|
||||
- **Collection:** vmagent scrapes the app, kubelet/cAdvisor, kube-state-metrics, node-exporter, Flux and Cilium. A Vector DaemonSet takes pod stdout and Talos service logs (`machine.logging`, JSON over TCP). An event exporter ships Kubernetes Events as logs. Everything lives in a `monitoring` namespace on Block Storage PVs and arrives as Flux `HelmRelease`s.
|
||||
- **App metrics** come from `prometheus-client`: requests by route template, method and status; latency; DB pool usage; Job depth, age and failures; seconds since HA's last poll; auth failures by reason. **Labels never carry `principal_id` or Personal data.** Per-Principal detail stays in logs.
|
||||
- **Retention:** logs and metrics are kept for 30 days, breakglass audit events for 1 year. **Amended by ADR-0014:** the daily backup job also exports breakglass audit events to the backup bucket, and the off-account copy keeps them for 1 year, so they survive a cluster rebuild. **Amended by ADR-0015:** Kubernetes audit logs are also kept 1 year and included in the same export.
|
||||
- **Retention:** logs and metrics are kept for 30 days, breakglass audit events for 1 year.
|
||||
- **Locked down:** Grafana requires login, with analytics, update checks and Gravatar off. Datasource plugins are pinned in the image. Outbound traffic from `monitoring` is denied by default, except vmalert → ntfy and the Watchdog → Kuma push.
|
||||
- **Every failure has one alerting owner.**
|
||||
- Kuma: reachability and degraded status.
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Envoy Gateway at the edge, DNS-01 through a delegated challenge zone, CAA pinned to our account
|
||||
|
||||
Public traffic reaches hAPI on one hostname, **`hapi.bobbypalko.com`**, over IPv4 only. OpenTofu reserves the IPv4 address. A Linode NodeBalancer created by the CCM listens on that address in **TCP mode** and sends **Proxy Protocol v2** to an **Envoy Gateway**. Envoy Gateway terminates TLS and forwards plain HTTP to hAPI `:8000`; Cilium's WireGuard encrypts traffic between nodes. There's no CDN (ADR-0002), so the Gateway is the only shield and enforces the edge limits. Envoy Gateway was chosen over Cilium's built-in Gateway because Cilium's Gateway has none of the limits we need as typed policy. Certificates come from **cert-manager** and Let's Encrypt over DNS-01, because `:80` is closed. The DNS-01 credential can only edit a separate, delegated **`acme.bobbypalko.com`** zone, not `bobbypalko.com` itself. A **CAA record pinned to our ACME account** means that even a leaked DNS token can't get a certificate for us.
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **Cilium's built-in Gateway** (it's already the CNI, ADR-0003). It has one component fewer, but as of v1.20 it offers only global switches (Proxy Protocol, ALPN, trusted XFF hops). It has no rate limiting, connection limits, body or header limits, client timeouts or minimum-TLS policy. The only workaround is hand-written CiliumEnvoyConfig, which doesn't cleanly patch the listeners Cilium generates. Rejected.
|
||||
- **Traefik with built-in ACME.** It renews certificates just as cert-manager does, but Traefik OSS keeps ACME state in a local file, so it can't run more than one replica. It would also still need the same DNS credential. Rejected.
|
||||
- **A DNS-01 token on the whole `bobbypalko.com` zone** (an IAM restricted user with `domain_admin` on it). Simpler, but a leaked token could repoint `git.` or any other record. Rejected under ADR-0008's narrow-token rule.
|
||||
- **Moving DNS to Cloudflare** for per-zone tokens. Rejected: it moves the whole zone to buy a token scope we can get with a delegated subzone.
|
||||
- **Self-hosted acme-dns.** It has the narrowest credential, but it means running a public DNS server. Kept as the fallback if the delegated-zone setup doesn't hold up (see Consequences).
|
||||
- **TLS terminated at the NodeBalancer (HTTPS mode).** Rejected: cert-manager can't rotate a certificate uploaded to Linode, and traffic from the NodeBalancer to the nodes would cross the unencrypted VPC in plaintext.
|
||||
- **A backup ACME CA (GTS, ZeroSSL).** Deferred: each needs EAB credentials, which is one more secret to manage, plus its own CAA entry.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **Tofu owns the stable parts:** the reserved IPv4, the NodeBalancer's Cloud Firewall (inbound TCP 443 only), the `A` record, the `_acme-challenge.hapi` CNAME, the `acme.` delegation and the CAA record. The Gateway's Service references the IP and the firewall through the CCM's `reserved-ipv4` and `firewall-id` annotations. The CCM creates and recreates the NodeBalancer without changing the address. There's no external-dns.
|
||||
- **No `AAAA`.** The NodeBalancer's IPv6 frontend address can't be reserved, so recreating the NodeBalancer would silently break the record.
|
||||
- **NodeBalancer:** `default-protocol: tcp`, `default-proxy-protocol: v2`, `throttle: 20` (new connections per second per client IP; the Household shares one CGNAT IP), and VPC backends.
|
||||
- **Envoy Gateway:** 2 Envoy replicas spread across both workers, with a PDB and memory requests tuned down from the chart's 512Mi. The Gateway accepts Proxy Protocol only.
|
||||
- `ClientTrafficPolicy`: TLS 1.3 only; ALPN h2 and http/1.1 (no HTTP/3); headers up to 16 KiB; about 50 connections per IP; request timeout 30 s, idle 60 s; client IP taken from Proxy Protocol.
|
||||
- `BackendTrafficPolicy`: per-IP local rate limit of about 20 req/s, burst 100 (per replica, no Redis), and bodies up to 1 MiB (413). The app caps `transactions/ingest` batches on its own.
|
||||
- HSTS is set at the edge. There's no per-Principal rate limiting (ADR-0005).
|
||||
- **uvicorn trusts `X-Forwarded-For` only from the Gateway's pod range.** That way, logs and limits see the real client.
|
||||
- **Layout:** one `Gateway` in a `gateway` namespace with a single HTTPS listener for `hapi.bobbypalko.com` and `allowedRoutes` limited to the `hapi` namespace. One `HTTPRoute` sends traffic to `:8000`; `:8081` is never routed (ADR-0009). Any other SNI or Host gets no certificate and no route.
|
||||
- **Certificates:**
|
||||
- cert-manager uses an ACME ClusterIssuer for Let's Encrypt on the default profile, plus a staging issuer for bring-up. `renewBefore` stays at its default, which is a proportion of the lifetime, so lifetimes can shrink (64 days from Feb 2027, 45 from 2028) without changes on our side. The DNS-01 solver is `linode/cert-manager-webhook-linode` with `cnameStrategy: Follow`.
|
||||
- The webhook's token belongs to a **restricted Linode user** with `domain_admin` on `acme.bobbypalko.com` only. It's delivered through SOPS (ADR-0008).
|
||||
- **CAA on `hapi.bobbypalko.com`** (not the apex, so other hostnames are unaffected): `0 issue "letsencrypt.org; validationmethods=dns-01; accounturi=<our account>"`.
|
||||
- **The ACME account key is generated offline and committed SOPS-encrypted.** A cluster rebuilt from code (ADR-0003) reuses the same account. Otherwise the CAA pin would block our own issuance.
|
||||
- **Verify during the build:**
|
||||
1. That a restricted user's token really is capped by the user's grants: it must fail to edit `bobbypalko.com`.
|
||||
2. That Linode serves the delegated `acme.` subzone.
|
||||
3. That the CCM copies Gateway `spec.infrastructure` / `EnvoyProxy` Service annotations onto the NodeBalancer.
|
||||
If either of the first two fails, switch to acme-dns before going live.
|
||||
- **Delivery (ADR-0007):** cert-manager with the webhook, and Envoy Gateway with the **Standard-channel** Gateway API CRDs, arrive as Flux `HelmRelease`s in `deploy/infrastructure`. Cilium runs with `gatewayAPI.enabled=false`, so two controllers never compete for the CRDs. Renovate opens PRs for these charts, but they aren't auto-merged.
|
||||
- **Observability (ADR-0009):** Envoy writes JSON access logs to stdout (client IP, status, bytes, duration, rate-limit verdict), without `Authorization` or query strings. Vector ships them to VictoriaLogs with the standard 30-day retention. Kuma's TLS-expiry notification on the `/v1/health` monitor alerts at 14 days. A vmalert rule on `certmanager_certificate_expiration_timestamp_seconds` is the in-cluster backstop.
|
||||
@@ -1,19 +0,0 @@
|
||||
# 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.
|
||||
@@ -1,21 +0,0 @@
|
||||
# Scheduled work runs as CronJobs of the hAPI image, as a tokenless `scheduler` Bot
|
||||
|
||||
hAPI's recurring work is a small set of **Kubernetes CronJobs that run `hapi <subcommand>`** from the same digest-pinned image as the app, delivered the same way as the migrate Job (ADR-0007). There is no worker Deployment, no in-process scheduler and no task queue. Most domain logic is computed on read (Finance summaries, Maintenance due dates, Fitness bests), so little has to run on a timer. A CronJob keeps nothing running between runs, gets retries and `concurrencyPolicy: Forbid` from Kubernetes, and is a CLI command the Owner can also run by hand.
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **A worker Deployment with an in-process scheduler** (APScheduler, arq). Rejected: it runs all the time, holds its own pool of up to 10 connections from ADR-0004's budget, and needs leader election before it can have more than one replica.
|
||||
- **Scheduling inside the API pods.** Rejected: with 2 replicas every task needs an advisory lock, and the work competes with requests for the event loop.
|
||||
- **A transactional outbox of domain events** (e.g. "Reading recorded"), drained by a CronJob. Rejected for v1. The state already in the database is the event: a scheduled check compares it with what has already been notified, at the cost of up to one interval of latency. A generic event model can arrive once something needs sub-minute reactions.
|
||||
- **FastAPI `BackgroundTasks` after commit.** Rejected: the work is lost if the pod dies.
|
||||
- **Running as `hapi_migrator`**, which bypasses RLS as the table owner. Rejected: it would put migrator credentials in a recurring pod.
|
||||
- **Giving the scheduler Bindings to Personal data.** Rejected: every Person would have to consent, and v1's per-Person work is read-only anyway.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **v1 inventory:** `hapi jobs sweep` every 15 min marks pending Jobs past `expires_at` as `expired` and deletes finished Jobs older than 90 days (replacing ADR-0006's `hapi jobs purge`). Reads derive `expired` from `expires_at` until the sweep catches up, so correctness never depends on how often it runs. The notification checks are CronJobs running `hapi notify <check>` (`tasks`, `jobs`, `budget`, `tokens`), plus `hapi notify deliver` every 2 min, which alone publishes to ntfy (ADR-0013). Purging a removed Person's data stays an on-demand Owner CLI command, and Finance month rollover, Banked carry-forward and `date_review` need no schedule.
|
||||
- **Principal:** work on Household data runs as a built-in **`scheduler` Bot**. A migration creates it, it can never hold a Token (so it can't be reached from the API), and the Owner gives it Household grants like any other Bot. Recorded by shows `scheduler`. Work on Personal data runs once per Person with `hapi.principal_id` set to that Person (ADR-0004), and is **read-only**: a scheduled write to Personal data needs a new decision.
|
||||
- **Event-triggered work** (e.g. a new Reading making a Task due) is picked up by the next scheduled check. Checks write **durable Notifications**, which double as the record of what was already notified. A Notification not yet delivered stays pending and is retried on the next run, so an ntfy outage loses nothing, and a future frontend inbox reads the same records.
|
||||
- **Connection budget (amends ADR-0004):** each housekeeping CronJob uses a pool of 1 with no overflow and `concurrencyPolicy: Forbid`. The rule becomes: app pods including surge × 10 + concurrently runnable CronJobs × 1 + ~6 ≤ 46.
|
||||
- **Monitoring:** one generic vmalert rule fires when any CronJob hasn't succeeded within twice its interval (kube-state-metrics' `kube_cronjob_status_last_successful_time`). ADR-0009's Watchdog covers vmalert itself. Kuma push monitors are kept for jobs whose silence must be caught even when the whole cluster is down: the importer (ADR-0011) and backups.
|
||||
- **Time:** the Household timezone is one setting in `deploy/`, fed both to the app config and to `spec.timeZone` on calendar-based CronJobs (daily checks, month-end). Interval jobs like the sweep ignore it.
|
||||
@@ -1,30 +0,0 @@
|
||||
# Notifications are durable records delivered by one CronJob; platform alerts bypass hAPI
|
||||
|
||||
hAPI's **Notifications** are database records addressed to one Person or to the Household, written by `hapi notify <check>` CronJobs (ADR-0012) and published to ntfy at **notify.bobbypalko.com** by a single `hapi notify deliver` CronJob. **Platform alerts are a separate lane:** CI, Flux, vmalert and Kuma publish straight to Owner-only ntfy topics with their own credentials and never touch hAPI, because they must work when hAPI or its database is down. ntfy is the only channel in v1: no preferences, no read state, no Notifications API; a Person opts out by muting in the ntfy app.
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **Routing platform alerts through hAPI** (one Notification model for everything). Rejected: an alert that hAPI is down can't depend on hAPI.
|
||||
- **Each check delivering what it wrote, or every check draining all pending Notifications.** Rejected: a budget run sending Token reminders is surprising, and an ntfy outage would fail every check. One deliver job keeps checks pure writers and isolates ntfy failures to one CronJob.
|
||||
- **Checks over Personal domain data** (e.g. a Person's Budget). Deferred to v2 with the Personal importer: they'd need scheduled writes for a Person, which ADR-0012 forbids.
|
||||
- **Per-Person preferences and a frontend inbox.** Deferred: the records already support an inbox and read state later.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **ntfy access:** the server denies anonymous read and publish. The Owner manages users by hand from a runbook in `docs/` (also an off-boarding step alongside Token revocation): a read-only user per Person for `hapi-p-<person-id>` and `hapi-household`; the Owner's user also reads `ops` and `ops-urgent`; each sender (hAPI, vmalert, Flux, CI, Kuma) has its own publish-only user limited to its topics. hAPI's, vmalert's and Flux's tokens come through SOPS (ADR-0008), CI's is a Gitea secret, Kuma's lives in Kuma. Topics are named by id, never by name. `upstream-base-url` points at ntfy.sh for iOS (only a poll request leaves, never content), the cache stays at 12 h, attachments are off.
|
||||
- **Content:** a short title and a link to the resource. Never amounts, balances, Measurements or other domain values.
|
||||
- **v1 checks** (all run as the `scheduler` Bot, read only Household and platform data):
|
||||
|
||||
| Check | Recipient | Fires | Schedule |
|
||||
|---|---|---|---|
|
||||
| `tasks` | Household | once on entering `lead_days`, once on overdue, per due occurrence (a Service or snooze starts the next) | daily 08:00 |
|
||||
| `jobs` | Household | a Job ends `failed` or `expired` | every 15 min |
|
||||
| `budget` | Household | a Household Budget Category goes into the red this month (Banked: its banked balance goes negative); refires only after it recovers | hourly |
|
||||
| `tokens` | the Token's Person, or the Owner for Bot Tokens | 30 and 7 days before expiry | daily |
|
||||
|
||||
- **Record:** recipient (Person or Household), `kind`, `dedupe_key` (unique with `kind`; it is the "already notified" ledger), `title`, `body`, priority 1–5, optional link, `created_at`, `delivered_at`, `attempts`. `hapi jobs sweep` deletes delivered Notifications after 180 days.
|
||||
- **Delivery:** `hapi notify deliver` every 2 min publishes pending Notifications oldest first, using the Notification id as ntfy's message/sequence id so retries don't double-push. It gives up after 24 h; a vmalert rule fires on undelivered Notifications that old. It counts as one more pool-1 CronJob in ADR-0012's connection rule.
|
||||
- **Breakglass fails closed:** `hapi db breakglass` publishes a priority-5 Household alert synchronously (and records a Notification) before opening the session, and refuses to start if the publish fails. Bypassing the wrapper with raw credentials remains the residual risk ADR-0009 accepts.
|
||||
- **Platform topics and priorities:** `ops` (Flux, vmalert, CI) and `ops-urgent` (Kuma *down*, the Watchdog). Priority 5: Kuma down, breakglass. 4: vmalert critical, Flux reconcile/rollout failure, Task overdue. 3: CI failure, Kuma degraded, Job failed/expired, Token expiring in 7 days. 2: Task due soon, budget overspend, Token expiring in 30 days.
|
||||
- **Importer staleness** needs no hAPI check: the SimpleFIN Bot already fails on a non-empty `errors` array and Kuma's 13 h push monitor catches it (ADR-0011).
|
||||
- **Egress** to notify.bobbypalko.com:443 is needed from hAPI's CronJobs and Flux's notification-controller (vmalert's is already allowed by ADR-0009); the policies themselves belong to cluster hardening.
|
||||
@@ -1,24 +0,0 @@
|
||||
# Backups go to an Object Lock bucket the cluster can't read back, pulled off-account to the Owner's machine
|
||||
|
||||
Linode's 14-day point-in-time recovery covers a bad migration, a bad delete or a lost database (ADR-0004). It doesn't cover damage found after 14 days, or losing the Linode account. So hAPI also takes its own daily dump. A **`hapi db backup` CronJob** streams `pg_dump -Fc | age | upload` into **`hapi-backups`**, a Linode Object Storage bucket with **Object Lock in compliance mode**. Dumps are encrypted to a **dedicated backup age recipient**, and its private key is never in the cluster. A **puller outside Linode**, holding only a `read_only` key, copies new objects out and never deletes or overwrites them. A compromised cluster can therefore neither read nor erase backups, and losing the account doesn't lose them. Recovery targets: (a) inside Linode, minutes of data lost and back within about 2 h; (b) damage found late, up to one day lost; (c) account loss, everything since the puller's last copy lost, with a weekend of downtime acceptable. Nothing is highly available.
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **Backblaze B2 (or R2 or S3) as the off-platform target.** Rejected in favour of Linode plus a pull: no new vendor, and Object Lock plus an off-account copy give the same protection. Linode keys are only `read_only` or `read_write` (there's no write-only key), so compliance-mode lock is what stops the cluster's key from deleting.
|
||||
- **Pushing to a home NAS.** Impossible: no connection may start from home into the cluster (ADR-0002, CGNAT). The pull direction works.
|
||||
- **Encrypting with the SOPS age key.** Rejected: Flux holds it in the cluster, so a compromised cluster could decrypt every old dump.
|
||||
- **Dumping as `hapi_migrator`** (it owns the tables, so it bypasses RLS). Rejected by ADR-0012: no migrator credentials in recurring pods.
|
||||
- **A separate backup image** (postgres + age + rclone). Rejected: ADR-0012's one-image, one-delivery-path rule. `postgresql-client-18` is added to the hAPI image instead, and `pg_restore` comes with it.
|
||||
- **etcd / Talos snapshots.** Not taken: everything in etcd is in git or can be recreated (certificates get reissued, the Tailscale operator re-authenticates from SOPS, the CCM recreates the NodeBalancer on the reserved IP). Losing the cluster means rebuilding it from code (ADR-0003).
|
||||
- **Keeping breakglass audit events only in VictoriaLogs**, or also writing them to Postgres. Rejected: the monitoring PVs don't survive a rebuild, and `hapi_migrator` could edit rows in Postgres.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **`hapi_backup` role** (amends ADR-0004): LOGIN, `BYPASSRLS`, SELECT only, created by `hapi db bootstrap`. Its reads stay complete through `ALTER DEFAULT PRIVILEGES` set as `hapi_migrator`. Its password is its own SOPS secret, mounted only into the backup pod. Whoever holds it, or the backup private key, can read all Personal data. Like `akmadmin` and the Tofu state, that is controlled by policy and audit, not by cryptography (ADR-0001). The dump uses one connection, counted in ADR-0012's CronJob term. To verify during the build: that `akmadmin` can create a `BYPASSRLS` role on Aiven.
|
||||
- **Backup key:** an age keypair generated offline. The cluster has only the public recipient, in plain config. The private key is in Vaultwarden and the offline copy (ADR-0008), next to the other Owner roots.
|
||||
- **Bucket:** created by Tofu with Object Lock (compliance mode, which turns on versioning). Each object is locked for 35 days, and a lifecycle rule expires it after 35 days. The cluster's key is `read_write` and limited to this bucket (through SOPS). To verify during the build: that it can't delete a locked version.
|
||||
- **Schedule and content:** daily at 03:00 Household time (`spec.timeZone`, ADR-0012). The job copies the plaintext stream into `pg_restore --list` before encrypting it, so an archive whose table of contents doesn't parse fails the run. The same job exports the previous day's breakglass audit events from VictoriaLogs to `audit/`, encrypted to the same recipient (amends ADR-0009: the 1-year retention now survives a rebuild). The backup pod's egress is limited to the DB, Object Storage, VictoriaLogs and Kuma.
|
||||
- **Puller:** a script in `infra/backup-pull/` (with a `just` recipe) running `rclone copy --immutable` plus pruning. It keeps 90 dailies, the dump from each 1st of the month for 3 years, and `audit/` for 1 year. It also pulls the versioned Tofu state bucket (which holds the Talos machine secrets, ADR-0003) with a second `read_only` key. It isn't a Principal: it never talks to hAPI. **For now it runs on the Owner's PC** as a systemd user timer (daily, `Persistent=true`). There, tier (c)'s data loss is "since the last pull", which is safe as long as the PC pulls at least once in 35 days. **It moves unchanged to a NAS** when one exists.
|
||||
- **Monitoring:** two Kuma push monitors. The backup CronJob's alerts after 26 h of silence. The puller's (it pushes only after copying an object less than 26 h old) alerts after **8 days while it runs on the PC. Change that to 26 h when it moves to the NAS.** ADR-0012's generic vmalert rule also covers the CronJob.
|
||||
- **Restore runbook:** the database is VPC-only, so restores run as **`hapi db restore`** in a pod. The Owner pastes in the backup private key at run time (like the `akmadmin` password), and it's never stored. Path **(A)**: a Linode point-in-time fork, then bootstrap, then repoint the app (ADR-0004's runbook, shared with plan resizes). Path **(B)**: a new database, then bootstrap, then `hapi db restore` from our dump as `hapi_migrator`, then repoint the app. If the account is lost, the Owner first uploads the dump from the puller's copy into the new account's bucket. A cluster rebuild needs the SOPS age key, the Tofu state passphrase (Vaultwarden or the offline copy) and Gitea. Backing up Gitea is out of scope. Its fallbacks are the Owner's local clone and rebuilding images in CI.
|
||||
- **Rehearsal:** before go-live, as acceptance for the build epic, run one full drill: rebuild the cluster from code in an empty Linode project, then path (B) from a pulled copy. After that, every 6 months, run path (B) into a throwaway database, check the Alembic revision and row counts per table, then delete it. This also rehearses plan resizes. It's tracked as a Household Maintenance Task, "Rehearse disaster recovery" (fixed RRULE), so the `tasks` check reminds through ntfy. **Amended by ADR-0015:** the Task concerns the "hAPI cluster" Asset, now that Maintenance covers the Household's digital systems.
|
||||
@@ -1,28 +0,0 @@
|
||||
# Cluster hardening baseline: deny-by-default network, restricted pods, audit logs; signing deferred
|
||||
|
||||
v1 hardens the cluster with built-in mechanisms only. That means **default-deny CiliumNetworkPolicies** in every namespace we own, **Pod Security `restricted`** wherever it fits, two **ValidatingAdmissionPolicies** (in-apiserver CEL rules), **Kubernetes audit logging**, and a written **upgrade runbook** with a fixed cadence. **Commit signature verification and cosign image signing are deferred.** We chose this because each measure here closes a real gap without adding a controller to run. Signing would only move trust onto keys held by the same Gitea and runner it's meant to protect against.
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **Flux commit verification plus cosign signing with admission-time verification, in v1.** Rejected for now. CI commits the digest bump to `main` (ADR-0007), so HEAD is usually a CI commit, and CI would need its own signing key. There's no keyless identity for Gitea, so the cosign key would be key-based too. Both keys would live in Gitea Actions secrets or on the runner, where an attacker who controls Gitea can run a workflow that uses them. Signed tags from a hardware key would break "every green merge deploys". Flux image automation would need git write credentials in the cluster.
|
||||
- **Kyverno (or sigstore policy-controller) for admission.** Rejected for two rules. It adds a controller, a webhook that can fail open or closed, and more upgrades to keep up with. Revisit when signing returns.
|
||||
- **Moving `monitoring` to `privileged` as a whole.** Rejected in favour of isolating the node agents in their own namespace.
|
||||
- **Keeping ops reminders out of hAPI** (a personal calendar), since hAPI can't remind you to fix hAPI while it's down. Rejected: these are recurring upkeep, which is what Maintenance Tasks are for, and Kuma covers the outage case. The glossary's Maintenance now includes the Household's digital systems.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **NetworkPolicy:** every namespace we own (`hapi`, `bots`, `gateway`, `envoy-gateway-system`, `monitoring`, `monitoring-node`, `cert-manager`, `flux-system`) is default-deny for ingress and egress. Each component's allows sit next to its manifests in `deploy/`. Rules that name hosts are `CiliumNetworkPolicy`, using `toFQDNs` for ntfy, Linode Object Storage, the Linode API, SimpleFIN, Kuma and Let's Encrypt, and `toCIDR` for the Managed DB's VPC address. This includes the allows already promised by ADR-0009, ADR-0011, ADR-0013 and ADR-0014. `kube-system` (Cilium, CCM and CoreDNS, installed by Tofu) stays open.
|
||||
- **Pod Security:** the cluster default stays at Talos's `baseline`. Every namespace we own enforces `restricted`, except **`monitoring-node`**, which is `privileged` and holds only the Vector and node-exporter DaemonSets. This amends ADR-0009.
|
||||
- **Admission (ValidatingAdmissionPolicy, Deny from day one, delivered by Flux):**
|
||||
1. Images must come from Gitea's registry, or carry an `@sha256:` digest. Applies everywhere except `kube-system`.
|
||||
2. Pods in `hapi` and `bots` must set `readOnlyRootFilesystem: true` and `automountServiceAccountToken: false`.
|
||||
- **Audit logging:** the apiserver audit policy is set in Talos machine config at `Metadata` level. It keeps every write and every access to `secrets`, `pods/exec`, `pods/portforward` and `serviceaccounts/token`, and drops controllers' and Flux's reads, health endpoints and Events. Vector in `monitoring-node` ships the control-plane node's audit file to VictoriaLogs, where it's **kept 1 year** and included in ADR-0014's daily `audit/` export. A `pods/exec` or a Secret read by a human sends an alert to the ntfy `ops` topic. Dial the policy back if it's too noisy.
|
||||
- **Upgrades:** Talos, Kubernetes, Cilium and CCM versions are pinned in `infra/`. Renovate opens PRs for them and never auto-merges. Security patches go in within 14 days; minor versions after their `.1`, staying within upstream support. The procedure goes in `docs/runbooks/cluster-upgrade.md`, written during the build:
|
||||
1. Take a throwaway local `talosctl etcd snapshot`, never stored (ADR-0014's no-etcd-backups rule still holds).
|
||||
2. Upgrade and drain the workers one at a time.
|
||||
3. Upgrade the control plane, accepting a few minutes without the API.
|
||||
4. Run `talosctl health` and check that Flux reconciles.
|
||||
|
||||
The reminder is a monthly Household Maintenance Task, "Upgrade the cluster", on a **"hAPI cluster" Asset**. ADR-0014's "Rehearse disaster recovery" Task hangs off the same Asset.
|
||||
- **Supply chain in v1:** images stay digest-pinned (ADR-0007), admission rule 1 limits where images come from, CI's Trivy scan stays, and `main` has branch protection in Gitea. Revisit signing once CI has an identity a compromised Gitea can't use.
|
||||
- **Deferred to v2:** runtime detection (Tetragon/Falco), in-cluster vulnerability scanning (Trivy Operator), CIS scanning, the Cilium host firewall (the Linode Cloud Firewall already covers nodes), least-privilege kubeconfigs (the Owner keeps Talos's admin kubeconfig, used only over the tailnet), and any CI check of policy coverage. etcd secret encryption needs no decision: Talos enables it by default.
|
||||
@@ -0,0 +1,181 @@
|
||||
# Which sources can feed posted Transactions from our banks and cards?
|
||||
|
||||
Research for [#65](https://git.bobbypalko.com/bobby/hapi/issues/65), part of the Finance map (#44). Researched 2026-11-24.
|
||||
|
||||
**Question.** For each institution (joint, the priority: Capital One and Fulton Bank; personal: Diamond Credit Union, Chase and Apple Card), what routes let an importer Bot running outside hAPI fetch **posted** Transactions? For each route:
|
||||
|
||||
- Does it give the purchase/transaction date as well as the posted date?
|
||||
- Does it give a stable per-transaction id that works as an idempotent `external_id`, and does that id survive pending to posted?
|
||||
- Can pending transactions be filtered out?
|
||||
- What is the auth model, and which credential does the Bot (or a third party) hold? Is it read-only, what does it cost, and do the ToS allow personal use?
|
||||
|
||||
**How to read this.** Sections 1 to 3 are **facts**, each with its source. Section 4 lists what I **could not verify**. Section 5 is **recommendation**, which is my judgement and not a sourced fact. "Unverified" means I found no first-party source; it does not mean the thing is false.
|
||||
|
||||
---
|
||||
|
||||
## 1. Routes, one at a time (facts)
|
||||
|
||||
### 1.1 SimpleFIN Bridge (aggregator for individuals)
|
||||
|
||||
| Question | Answer | Source |
|
||||
|---|---|---|
|
||||
| Purchase date | `transacted_at` is **optional**: "when the transaction happened". `posted` is required: "when the transaction posted to the account" (`0` if pending). | [SimpleFIN protocol](https://www.simplefin.org/protocol.html) (v2.0.0-draft, last changed 2026-03-19) |
|
||||
| Stable id | `id` is required: "An ID that uniquely describes a transaction within an Account". It is unique **per account**, not globally. The spec does not say whether the id survives pending to posted. | same |
|
||||
| Pending filter | Yes, on the server side. `GET /accounts` **excludes pending by default**; `pending=1` opts in. | same |
|
||||
| Auth / credential | The user makes a one-time Setup Token. The app POSTs to its claim URL once and gets an **Access URL** that embeds HTTP Basic credentials. That Access URL is the only secret the Bot holds. "Your application never sees the user's bank account credentials." The user can disable the token at any time. | [SimpleFIN developer guide](https://beta-bridge.simplefin.org/info/developers), [protocol](https://www.simplefin.org/protocol.html) |
|
||||
| Who holds bank credentials | SimpleFIN says "We outsource to MX to securely store and access your financial institutions" and "No bank account credentials ever touch our servers." | [SimpleFIN security](https://beta-bridge.simplefin.org/info/security) |
|
||||
| Read-only | Yes. The protocol exists to "share read-only financial data", and it defines no write operations. | [protocol](https://www.simplefin.org/protocol.html) |
|
||||
| Limits | Meant for daily updates, at about 24 requests a day or fewer. Each request can cover at most **90 days**. Going far over the limit disables the token. | [developer guide](https://beta-bridge.simplefin.org/info/developers) |
|
||||
| Cost | **$1.50 a month or $15 a year** plus tax, for up to 25 institutions and 25 apps. | [SimpleFIN Bridge home](https://beta-bridge.simplefin.org/) |
|
||||
| ToS | The terms don't mention personal or self-written clients. They forbid access "using a method other than the interface and the instructions that we provide" and require staying within usage limits. A personal Bot that uses the documented protocol fits that wording. Liability is capped at the fees paid. | [SimpleFIN terms](https://beta-bridge.simplefin.org/info/terms) |
|
||||
| Security history | A 2026-05-28 incident report says a bug may have let **up to 39 users see each other's transaction data, balances and names**. Per MX, no bank credentials were exposed. | [SimpleFIN security](https://beta-bridge.simplefin.org/info/security) |
|
||||
|
||||
### 1.2 Plaid (aggregator, developer account)
|
||||
|
||||
| Question | Answer | Source |
|
||||
|---|---|---|
|
||||
| Purchase date | Yes. For a posted transaction, `date` is the **posted** date and `authorized_date` is "the date that the transaction was authorized". Matching `datetime` and `authorized_datetime` fields exist, but may carry default times. | [Plaid Transactions API](https://plaid.com/docs/api/products/transactions/) |
|
||||
| Stable id | `transaction_id` is unique, but **a posted transaction is a new transaction with a new id**. Plaid removes the pending one and links them through `pending_transaction_id`. If you only ingest posted transactions, the posted id is stable. | [Plaid transaction states](https://plaid.com/docs/transactions/transactions-data/) |
|
||||
| Pending filter | There is a `pending` boolean on every transaction, so the client filters. **Capital One provides no pending data through Plaid at all.** | [Plaid transaction states](https://plaid.com/docs/transactions/transactions-data/), [Plaid OAuth guide: Capital One](https://plaid.com/docs/link/oauth/) |
|
||||
| Auth / credential | The Bot holds a Plaid `client_id` and secret plus a per-Item `access_token`. Chase and Capital One are **OAuth institutions**. To use them you need Production access, a company profile, application display info, a signed Master Services Agreement and the **security questionnaire**. Chase consent lasts 6 or 12 months. Capital One consent must be refreshed yearly. | [Plaid OAuth guide](https://plaid.com/docs/link/oauth/) |
|
||||
| Read-only | The Transactions product is read-only. The same Plaid account can also enable money-moving products (Transfer). | [Plaid docs](https://plaid.com/docs/link/oauth/) |
|
||||
| Cost | Transactions is a **per-Item monthly subscription**, billed while an access token exists. The Trial plan allows **10 Production Items**, with live data. Pay-as-you-go has no minimum and is described as "Best for individuals and solo developers". Unit prices are shown only in the Dashboard. | [Plaid billing](https://plaid.com/docs/account/billing/), [Plaid pricing](https://plaid.com/pricing/) |
|
||||
| ToS | Development accounts are "solely for internal evaluation" and not for production. Production requires a compliance review. Nothing I found rules out an individual, but the OAuth registration assumes a company. | [Plaid developer terms](https://plaid.com/legal/terms-of-use), [OAuth guide](https://plaid.com/docs/link/oauth/) |
|
||||
|
||||
### 1.3 Teller (aggregator, developer tier)
|
||||
|
||||
| Question | Answer | Source |
|
||||
|---|---|---|
|
||||
| Purchase date | There is a **single** `date` field: "The ISO 8601 date of the transaction". Teller's sync guidance says "When a pending transaction posts, its date often changes to the posting date." In practice a posted transaction may carry only the posted date. | [Teller Transactions API](https://teller.io/docs/api/account/transactions) |
|
||||
| Stable id | "Teller maintains stable transaction IDs. Occasionally, when a pending transaction changes significantly upon posting and cannot be matched to the original, it's created as a new record with a new ID." | same |
|
||||
| Pending filter | `status` is `posted` or `pending`, and the client filters. There is no server-side filter parameter. | same |
|
||||
| Auth / credential | **mTLS client certificate** plus a per-enrollment access token sent over HTTP Basic. "Access tokens are useless without a Teller client certificate." Enrollment happens through Teller Connect. | [Teller authentication](https://teller.io/docs/api/authentication) |
|
||||
| Read-only | Not stated for the token scope. Teller has a Payments product (beta). | same |
|
||||
| Cost | The developer tier includes **100 live connections free** ("free for independent developers"). After that, Transactions costs **$0.30 per enrollment per month**. | [teller.io](https://teller.io/) |
|
||||
| ToS | Not reviewed (see section 4). | |
|
||||
|
||||
### 1.4 File exports (CSV / OFX / QFX / QBO)
|
||||
|
||||
Common facts about OFX, which QFX and QBO are built on. Each `STMTTRN` carries **`FITID`** (the institution's transaction id), **`DTPOSTED`** (posted date) and an optional **`DTUSER`** ("date user initiated transaction, if known"). Sources: OFX field definitions as reproduced in the [Haskell `ofx` package docs](https://hackage.haskell.org/package/ofx-0.4.0.4/docs/ofx.haddock) (which cite OFX spec §11.4.2.3.1.1), and a [libofx sample OFX 2.0.1 statement](https://stuff.mit.edu/afs/sipb/project/libofx/src/libofx-0.8.0/doc/ofx_sample_files/ofx_spec201_stmtrs_example.xml). Both are secondary; I did not open the OFX spec PDF itself. An export file contains whatever the bank chose to include, and exports are generally posted-only. Whether `DTUSER` is filled in depends on the institution.
|
||||
|
||||
Per-institution export facts are in section 2.
|
||||
|
||||
### 1.5 Apple FinanceKit (on-device, Apple Card / Apple Cash / Savings)
|
||||
|
||||
| Question | Answer | Source |
|
||||
|---|---|---|
|
||||
| Purchase date | Yes. `transactionDate: Date` (non-optional) is "The time the transaction took place… This may be different from the time the transaction posted." `postedDate: Date?` is the posted date; "If not provided, use `transactionDate` as `postedDate`." | [Transaction](https://developer.apple.com/documentation/financekit/transaction), [transactionDate](https://developer.apple.com/documentation/financekit/transaction/transactiondate), [postedDate](https://developer.apple.com/documentation/financekit/transaction/posteddate) |
|
||||
| Stable id | `id: UUID` is "A unique internal ID". WWDC24 says it is "unique for every transaction, but **unique per device** as well… especially useful to track how a given transaction evolves over time." `transactionHistory(forAccountID:since:)` returns `Changes` with `inserted`, `updated` and `deleted` plus a resumable `HistoryToken`, so a status change should arrive as an *update* to the same id. That last point is inferred from the API shape; Apple does not say it outright. | [id](https://developer.apple.com/documentation/financekit/transaction/id), [Meet FinanceKit (WWDC24)](https://developer.apple.com/videos/play/wwdc2024/2023/), [FinanceStore.Changes](https://developer.apple.com/documentation/financekit/financestore/changes) |
|
||||
| Pending filter | Yes. `TransactionStatus` has `authorized`, `booked`, `memo`, `pending` and `rejected`. Posted means `booked`. | [TransactionStatus](https://developer.apple.com/documentation/financekit/transactionstatus) |
|
||||
| Other fields | `accountID`, `creditDebitIndicator`, `transactionAmount`, `foreignCurrencyAmount`, `merchantName`, `merchantCategoryCode`, `transactionDescription`, `originalTransactionDescription`, `transactionType`. | [Transaction](https://developer.apple.com/documentation/financekit/transaction) |
|
||||
| Auth / credential | Two gates. First, an **entitlement** that the developer Account Holder requests, granted per bundle ID. Second, per-user authorization on the device, where the user picks the accounts and the earliest date shared and can revoke in Settings. The data is read from the on-device store and "never seen by Apple". | [Get started with FinanceKit](https://developer.apple.com/financekit/), [WWDC24](https://developer.apple.com/videos/play/wwdc2024/2023/) |
|
||||
| **Eligibility** | The app must "Be listed in the Finance category in App Store Connect and **distributed through the App Store** for iPhone in the United States or United Kingdom" and "Provide financial management tools". The US requires iOS 17.4+ and excludes Apple Card Family participants. | [Get started with FinanceKit](https://developer.apple.com/financekit/) |
|
||||
| History | "FinanceKit tries to preserve… at least some months of history"; history "can be compacted by the system". | [WWDC24](https://developer.apple.com/videos/play/wwdc2024/2023/) |
|
||||
| Shortcuts | iOS 17 added a **Transaction** personal automation that "can run when a Wallet transaction is made". It fires at tap time, so it is an authorization and **not a posted** transaction. I found no Apple-documented Shortcuts action that reads FinanceKit history. | [What's new in Shortcuts for iOS 17](https://support.apple.com/en-us/HT213909) |
|
||||
|
||||
---
|
||||
|
||||
## 2. Per institution (facts)
|
||||
|
||||
### Capital One (joint, priority)
|
||||
|
||||
- **Official API / MCP.** The DevExchange consumer-transactions API is **partner-gated**: production access requires partner approval and pricing is negotiated ([API Evangelist profile of DevExchange](https://github.com/api-evangelist/capital-one), secondary). **I found no official Capital One MCP server**. Every "Capital One MCP" I found is third-party, such as [hashwnath/capitalone-mcp-server](https://github.com/hashwnath/capitalone-mcp-server), which wraps sandbox and partner APIs and has no personal transactions tool, or connectors built on GoCardless. Capital One's portal ([developer.capitalone.com](https://developer.capitalone.com/)) is a JS app that I could not search. See section 4.
|
||||
- **Aggregators.** Capital One shares data with Plaid under a data-sharing agreement, through its API ([Capital One newsroom](https://www.capitalone.com/about/newsroom/data-sharing-agreement/), 2021). Through Plaid it is OAuth, gives **no pending data**, and needs consent refreshed yearly ([Plaid OAuth guide](https://plaid.com/docs/link/oauth/)). Capital One itself uses **MX** and Mastercard for its inbound external-accounts feature ([Capital One external-accounts T&C](https://www.capitalone.com/digital/external-accounts-terms-conditions/), modified 2026-07-29). That shows a working MX relationship, but it is not proof that SimpleFIN (via MX) can pull *from* Capital One. SimpleFIN and Teller coverage: unverified.
|
||||
- **File export.** Credit card CSV columns are **Transaction Date, Posted Date, Card No., Description, Category, Debit, Credit**. There is **no transaction id**. Source: [Tiller guide, 2026-05-23](https://tiller.com/export-capital-one-transactions/), secondary. Users also report QFX, OFX and QBO downloads ([Quicken community](https://community.quicken.com/discussion/7852368/can-i-download-transactions-from-capital-one-accounts)). The 360 bank-account CSV columns are unverified.
|
||||
|
||||
### Fulton Bank (joint, priority)
|
||||
|
||||
- **Official API.** None found for consumers.
|
||||
- **Quicken / QuickBooks.** Fulton's personal online-banking product sheet lists **Web Connect** ("Log into Online Banking and export your transactions to Quicken or QuickBooks") and **Direct Connect** ("Import your transactions right to Quicken® or QuickBooks® without ever logging into Online Banking"). Fulton's guides say **a Direct Connect fee applies** to personal accounts. Source: [Fulton Online Banking sheet](https://www.fultonbank.com/-/media/Files/Product-Info-Sheets/Online-Banking.ashx) and [consumer guide](https://www.fultonbank.com/-/media/Files/Blue-Foundry/consumer-guide.pdf). Both URLs **return 404 as of 2026-11-24**; the quotes come from the search index. Business (BOSS) exports offer CSV, BAI, QuickBooks and Quicken (OFX) formats ([BOSS Download/Export guide](https://www.fultonbank.com/-/media/Files/Commercial/BOSS/Download-Export/BOSS-User-Guide---Download_Export.pdf), business only).
|
||||
- **Context.** Fulton's Blue Foundry transition guides refer to a conversion starting July 2026. Expect digital-banking changes.
|
||||
- **Aggregators.** SimpleFIN, Plaid and Teller coverage are all unverified.
|
||||
|
||||
### Diamond Credit Union (personal)
|
||||
|
||||
- **Official API.** None.
|
||||
- **Export.** Diamond's public site ([online banking](https://diamondcu.org/personal/online-banking/), [FAQ](https://diamondcu.org/about/faq/), [account tools](https://diamondcu.org/account-management/)) documents **no transaction export, Quicken/QuickBooks or third-party-app feature** for personal members. The listed features are balances, activity, transfers, deposits, card controls and bill pay. A Diamond business page (now 404) reportedly offered Quicken/QuickBooks download "free with your Diamond Business Checking Account". Digital banking runs at `digital.diamondcu.org`.
|
||||
- **Aggregators.** Coverage is unverified everywhere.
|
||||
|
||||
### Chase (personal)
|
||||
|
||||
- **Official API.** None for consumers. Chase charges aggregators for data access. Its Plaid agreement was extended in September 2025 with a pricing structure, and Plaid said it would not pass the cost on ([JPMorganChase/Plaid release](https://www.businesswire.com/news/home/20250916390149/en/JPMorganChase-and-Plaid-Announce-an-Extension-to-their-Data-Access-Agreement-for-Sharing-of-Consumer-Permissioned-Data)). Through Plaid, Chase is OAuth: consent lasts 6 or 12 months and you need the security questionnaire ([Plaid OAuth guide](https://plaid.com/docs/link/oauth/)). Teller's docs use Chase in example payloads, but I could not confirm Teller's live support. SimpleFIN coverage is unverified.
|
||||
- **File export.** The download icon on account activity offers CSV, QFX, QBO and QIF, for both card and bank accounts ([GnuCash list, 2023](https://lists.gnucash.org/pipermail/gnucash-user/2023-August/108468.html), secondary). Community parsers report the card CSV columns as **Card, Transaction Date, Post Date, Description, Category, Type, Amount, Memo**, with **no id** ([pfin chase parser](https://beta.pkg.go.dev/git.sr.ht/~mendelmaleh/pfin/parser/chase), secondary). Checking CSV columns are unverified.
|
||||
|
||||
### Apple Card (personal)
|
||||
|
||||
- **FinanceKit** is the only programmatic route (section 1.5). It requires an **App Store–distributed Finance-category app**.
|
||||
- **File export.** From Wallet (Card Balance, then a statement or Statements, then Export Transactions) or from **card.apple.com** (Statements, then Export Transactions), for a monthly statement **or a start/end date range** ([Apple Support 102284](https://support.apple.com/en-us/102284)). Apple's page does not name the formats. Coverage dating from the 2020 launch lists **CSV, OFX, QFX and QBO** ([MacRumors, 2020](https://www.macrumors.com/2020/02/11/apple-card-now-supports-ofx-exporting/)). Users report the CSV columns as **Transaction Date, Clearing Date, Description, Merchant, Category, Type, Amount (USD)**, with **no id** ([Apple Discussions](https://discussions.apple.com/thread/251068204?page=2), secondary). OFX `FITID` content is unverified.
|
||||
- **Aggregators.** None. Apple Card is not reachable through Plaid, Teller or SimpleFIN. This is implied by FinanceKit being the only route, and I found no aggregator claiming Apple Card.
|
||||
|
||||
### Regulatory backdrop
|
||||
|
||||
The CFPB's §1033 Personal Financial Data Rights rule, which would require banks to offer data APIs, **is not in force**. It was enjoined on 2025-10-29 and is being reconsidered, and the 2026-04-01 compliance date passed without enforcement ([CFPB](https://www.consumerfinance.gov/personal-financial-data-rights/), [Cozen O'Connor, 2026](https://www.cozen.com/news-resources/publications/2026/section-1033-compliance-date-open-banking-rule-enjoined-and-under-reconsideration)). No bank is obliged to give individuals a direct API.
|
||||
|
||||
---
|
||||
|
||||
## 3. Summary table (facts; "?" = unverified)
|
||||
|
||||
"Purchase date" means the route can give a purchase date distinct from the posted date. "Id stable p→p" means the id survives pending to posted. That doesn't matter for a posted-only ingest, as long as the posted id is stable.
|
||||
|
||||
| Institution | Route | Purchase date | Txn id / stable p→p | Pending filter | Bot holds | Cost | Coverage |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| **Capital One** | SimpleFIN | `transacted_at` optional, ? if populated | `id` per account / ? | server-side, default off | Access URL (read-only) | $15/yr total | ? |
|
||||
| | Plaid | `authorized_date` | yes / new id on post (no pending at C1 anyway) | n/a (no pending at C1) | client secret + access_token; OAuth, needs company and questionnaire | per-Item monthly, price in Dashboard; trial 10 Items | yes (OAuth) |
|
||||
| | Teller | single `date`, often becomes posted date | mostly stable | client-side `status` | mTLS cert + token | free ≤100 connections | ? |
|
||||
| | CSV | Transaction Date + Posted Date | **none** | export is posted | nothing (manual download) | free | yes (card) |
|
||||
| | OFX/QFX | `DTUSER` ? | `FITID` | posted | nothing (manual) | free | reported |
|
||||
| | Official API / MCP | — | — | — | partner only; **no official MCP found** | — | no |
|
||||
| **Fulton** | Web Connect (QFX/QBO) | `DTUSER` ? | `FITID` | posted | nothing (manual) | free | yes (bank-documented, page now 404) |
|
||||
| | Direct Connect | as OFX | `FITID` | posted | OFX login | fee | yes, but whether non-Intuit clients work is ? |
|
||||
| | SimpleFIN / Plaid / Teller | as above | as above | as above | as above | as above | ? |
|
||||
| **Diamond CU** | any | ? | ? | ? | ? | ? | nothing documented |
|
||||
| **Chase** | Plaid | `authorized_date` | new id on post | `pending` flag | as above, OAuth 6/12-month consent | as above | yes (OAuth) |
|
||||
| | CSV / QFX / QBO | CSV: Transaction Date + Post Date | CSV **none**; QFX `FITID` | posted | nothing (manual) | free | yes |
|
||||
| | SimpleFIN / Teller | as above | as above | as above | as above | as above | ? |
|
||||
| **Apple Card** | FinanceKit | `transactionDate` + `postedDate` | UUID, **per device**; updates in place (inferred) | `status == .booked` | on-device auth; app needs entitlement and App Store distribution | Apple Developer Program | yes, but a private app is likely ineligible |
|
||||
| | Wallet / card.apple.com export | CSV: Transaction Date + Clearing Date | CSV **none**; OFX `FITID` ? | statements are posted | nothing (manual) | free | yes |
|
||||
|
||||
---
|
||||
|
||||
## 4. Could not verify
|
||||
|
||||
- **SimpleFIN institution coverage** for all five institutions. The Bridge's search form is behind Cloudflare Turnstile and returned "No institutions found" even for "bank" when scripted. → Sign in at https://beta-bridge.simplefin.org/search-institutions and search manually.
|
||||
- **Whether SimpleFIN/MX populates `transacted_at`**, and whether SimpleFIN `id`s survive pending to posted. → Check the raw `/accounts` JSON once connected.
|
||||
- **Teller institution coverage** (`GET https://api.teller.io/institutions` timed out from here) and Teller's ToS.
|
||||
- **A Capital One MCP server.** I found no first-party announcement, docs page or newsroom item, and the developer portal can't be scripted. If the owner has a link, the conclusion changes.
|
||||
- **Fulton's current personal export formats and Direct Connect fee.** The bank PDFs now 404. Also whether Fulton's Direct Connect accepts non-Intuit OFX clients.
|
||||
- **Diamond CU's export options** inside digital banking (they may exist behind login), and any aggregator support.
|
||||
- **Apple Card export formats and columns** from a first-party source, and whether its OFX `FITID` is stable across re-exports.
|
||||
- **Whether FinanceKit's `pending` to `booked` change arrives as an update to the same id.** This is inferred from the `Changes` API, not stated by Apple.
|
||||
- **Whether FinanceKit's entitlement can be granted to an individual or unlisted app.** The criteria require App Store distribution in the Finance category.
|
||||
- **Chase and Capital One 360 checking CSV columns.**
|
||||
- **Plaid's actual per-Item Transactions price**, which is only visible in the Dashboard.
|
||||
|
||||
---
|
||||
|
||||
## 5. Recommendation (judgement, not fact)
|
||||
|
||||
**First importer route for the joint accounts: SimpleFIN Bridge, gated on a coverage check, with OFX/QFX file import as the fallback and the history backfill.**
|
||||
|
||||
Why SimpleFIN first:
|
||||
|
||||
- **Security.** It is the smallest credential the Bot can hold: a single read-only Access URL that the owner can revoke. No mTLS keypair and no client secret that could also enable money movement. hAPI still holds no bank credentials, and the Bot holds no bank login either; MX does. The trade-off is trusting SimpleFIN and MX. The May 2026 cross-user exposure incident is a real cost to weigh.
|
||||
- **Posted-only by default** (`pending` off), which matches the ingest contract with no client filtering.
|
||||
- **Cost and ToS.** $15 a year, designed for individuals. Plaid's OAuth path for Capital One and Chase needs a company profile, an MSA and a security questionnaire, which is out of proportion for one household. Teller's single `date` field loses the purchase date once a transaction posts, which hurts a required `occurred_on`.
|
||||
|
||||
How to map it:
|
||||
|
||||
- `external_id = simplefin:{account.id}:{transaction.id}`. Namespace by account, because the id is only unique within an account.
|
||||
- `occurred_on = transacted_at` when present. Otherwise the Bot must decide between falling back to `posted` and flagging the transaction. That is an open question for the Finance map.
|
||||
- `posted_on = posted`.
|
||||
- Pull daily with a window of a few days. Each request covers at most 90 days.
|
||||
|
||||
**First step, about 10 minutes for the owner:** sign in to SimpleFIN Bridge and search for "Capital One" and "Fulton". Connect one account and inspect a raw `/accounts` response for `transacted_at` and the shape of `id`.
|
||||
|
||||
If SimpleFIN doesn't cover one of them, or omits `transacted_at`: use **OFX/QFX export** for that bank. Both joint banks offer it: Capital One QFX and Fulton Web Connect. It gives `FITID`, usable as `external_id = ofx:{acctid}:{fitid}`, plus `DTPOSTED` and possibly `DTUSER`. The Bot becomes a file-drop importer. It is semi-manual but has zero standing credentials. Prefer OFX/QFX over CSV, because the CSVs carry no transaction id. Use the file route for the one-off **history backfill** in any case, because SimpleFIN's per-request window is 90 days.
|
||||
|
||||
Later, for the personal accounts:
|
||||
|
||||
- Chase follows the same order as the joint accounts.
|
||||
- Diamond CU needs the owner to check what digital banking offers behind login.
|
||||
- Apple Card is realistically **Wallet/card.apple.com export (OFX or CSV)**. FinanceKit needs an App Store–listed Finance app, and its ids are per device, so re-pairing a phone would mint new `external_id`s.
|
||||
Reference in new issue
Block a user