allsource-core 0.30.0

High-performance event store core built in Rust
Documentation
# Fly.io Configuration for AllSource Core
# Deploy from monorepo root (Core Dockerfile needs workspace context):
#   flyctl deploy --config apps/core/fly.toml --dockerfile apps/core/Dockerfile
# One machine only: .internal resolves to every started machine
# (docs/runbooks/CORE_DEPLOY.md).

app = "allsource-core"
primary_region = "iad"  # US East (Virginia) - change to your preferred region
# Strict archive reads run up to ALLSOURCE_STRICT_ARCHIVE_TIMEOUT_SECONDS (60s);
# the old process must be able to finish them before it is killed.
kill_timeout = 65

# A boot replays the system WAL before it is ready (4m47s on 2026-11-01), and
# /health answers 503 not_ready until then; a shorter wait reports the release
# as failed while the machine is still booting.
[deploy]
  wait_timeout = "15m"

[build]
  dockerfile = "Dockerfile"

[env]
  RUST_LOG = "allsource_core=info,tower_http=info"
  ALLSOURCE_HOST = "::"
  # PORT is automatically set by Fly.io

  # Sustainable data strategy (Steps 1-6, landed 2026-04-27 — see
  # docs/proposals/SUSTAINABLE_DATA_STRATEGY.md). The cache budget is
  # eviction target introduced after issue #160 (WAL replay OOM) is
  # based on estimated event bytes, not total process RSS. Keep
  # headroom for indices, the runtime and archive staging; this soft
  # cache limit alone cannot prevent OOM during a cold load.
  ALLSOURCE_CACHE_BYTES = "2147483648"
  # Admit one strict cold loader at a time on this 8 GiB machine. The
  # worker retains its slot after an HTTP timeout until warming actually ends.
  ALLSOURCE_ARCHIVE_WORKERS = "1"
  # The event feed and read models decode a tenant's whole archive. The
  # 128 MiB default refused Longhand's control-plane tenant (one 2026-04
  # snapshot alone decodes to 149,338,384 B), failing its feed and read
  # models on every call. Decoding peaks near 8.25x the text (~6.3 GiB at
  # this limit). Tenant hydration also passes admit_hydration, which refuses
  # a load free memory cannot hold; the narrow feed scan does not, and this
  # limit is its only bound.
  ALLSOURCE_STRICT_ARCHIVE_MAX_DECODED_BYTES = "805306368"
  ALLSOURCE_STRICT_ARCHIVE_TIMEOUT_SECONDS = "60"
  # Step 6: checkpoint cadence (Parquet flush + WAL truncate). Bounds
  # cold-restart replay to ~one minute of writes regardless of how
  # large the dataset has grown.
  ALLSOURCE_CHECKPOINT_INTERVAL_SECONDS = "60"
  # Step 4: per-tenant compaction cadence (default 3600s / hourly is
  # also set by code; explicit here so ops can grep fly.toml).
  ALLSOURCE_SNAPSHOT_INTERVAL_SECONDS = "3600"
  # Step 5: retention for the `system` tenant ONLY — Core's own CP heartbeat
  # stream. It reaches no customer tenant: RetentionConfig's default_ttl is
  # None and `system` is the single override. Plan-tier retention
  # (subscription.go: 7/14/90/365/-1 days) is a Control Plane concept that
  # nothing currently enforces.
  #
  # 0 = keep forever. Unsetting this does NOT disable it — the code default
  # is 30 days.
  #
  # Deliberately off while compaction runs for the first time. The sweep
  # never ran before 2026-10-12, so this TTL never ran either, and enabling
  # both at once would have the first pass delete ~1.9 GB of heartbeats that
  # have never been subject to it. Compaction alone fixes the fragmentation
  # behind gh#321. Set this to 30 as a separate, deliberate change — no
  # cold-tier archive is configured, so the events are deleted outright.
  ALLSOURCE_RETENTION_SYSTEM_DAYS = "0"

  # One-shot flat→tenant Parquet migration (Step 1 / commit bdd3cd8).
  # The migrator is idempotent: once the storage tree has no flat files
  # at the root, every subsequent boot's pre-Core check is a fast
  # directory listing. Safe to leave set permanently — see
  # apps/core/docker-entrypoint.sh and
  # docs/migrations/STORAGE_LAYOUT_FLAT_TO_TENANT.md.
  ALLSOURCE_MIGRATE_FLAT_TO_TENANT = "true"

  # System checkpoints (docs/runbooks/SYSTEM_CHECKPOINTS.md). A boot loads the
  # newest valid checkpoint and replays only the system WAL after it; the WAL
  # itself is never pruned. VERIFY off: boot does not replay the whole system
  # WAL into memory to compare it with the loaded checkpoint, so a checkpoint
  # is trusted on its CRC alone and a wrong fold is not detected at boot.
  # VERIFY on at 8 GB loads the full WAL and is not safe there.
  ALLSOURCE_SYSTEM_CHECKPOINT = "true"
  ALLSOURCE_SYSTEM_CHECKPOINT_INTERVAL_SECONDS = "300"
  ALLSOURCE_SYSTEM_CHECKPOINT_VERIFY = "false"

# Core is internal-only (bead t-0ff8). Public ingress removed 2026-04-17.
# All user-facing traffic enters through Control Plane's delegation layer.
# Internal .fly network (http://allsource-core.internal:3900) still works
# because other Fly apps in the same org reach machine IPs directly — no
# [http_service] / [[services]] block is needed. See
# docs/deployment/API_SUBDOMAIN_SETUP.md for the full topology.
#
# Rollback: restore [http_service] and re-allocate a public IPv6 with
# `fly ips allocate-v6 -a allsource-core`.

# Top-level machine orchestration (was nested under [http_service])
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1

# Internal HTTP health check so auto_stop/auto_start don't kill a healthy
# machine. Runs inside the Fly network; does not expose anything publicly.
[checks.health]
  grace_period = "10s"
  interval = "30s"
  method = "GET"
  path = "/health"
  port = 3900
  protocol = "http"
  timeout = "5s"
  type = "http"

# Fly scrapes this every 15s into the org Prometheus behind fly-metrics.net.
# The series carry no tenant label; per-tenant usage comes from the control plane.
[metrics]
  port = 3900
  path = "/metrics"

[[vm]]
  # shared-cpu-8x to unlock 16 GiB. On 8 GiB, Core refused to hydrate the
  # largest tenant on 2026-10-24 (needed 2,474,258,624 B, 1,969,930,240 B
  # available).
  cpu_kind = "shared"
  cpus = 8
  # 2 GiB estimated cache target and one strict archive worker.
  # Constrained Linux evidence supports 600,000 rows for the measured
  # synthetic shape, not arbitrary concurrent load. See
  # docs/evidence/2026-09-27-isolated-archive-capacity/. Do not downsize or
  # widen row/worker limits without new headroom evidence.
  memory_mb = 16384

[mounts]
  source = "allsource_data"
  destination = "/app/data"