28 Commits
Author SHA1 Message Date
9qeklajc ff55788e2d fix: address PR 634 review feedback 2026-07-26 12:44:37 +02:00
9qeklajc 7108d554c8 merge: combine PR #632 with broader pool-exhaustion fixes 2026-07-24 23:22:01 +02:00
Jeroen UbbinkandClaude Opus 4.8 a2cedd6769 feat: make the DB connection pool env-configurable
Add DATABASE_POOL_SIZE / DATABASE_MAX_OVERFLOW / DATABASE_POOL_TIMEOUT,
consumed like every other typed env var through the pydantic Settings
(constrained Fields, defaults 5/10/30 matching SQLAlchemy's own baseline
so leaving them unset is behaviour-neutral). An out-of-range or
non-integer value fails validation and refuses to boot — the same
fail-loud behaviour a malformed DATABASE_URL already has — rather than
silently starting up misconfigured. create_db_engine sizes the pool from
these and logs the effective values at startup so they can be confirmed
from the boot output during an incident. In-memory SQLite (StaticPool,
which rejects the pool kwargs) is detected and built without them.

pool_pre_ping is deliberately not exposed: the default backend is a local
SQLite file with no network peer to drop idle connections, so it would add
a SELECT 1 per checkout for no benefit — and it detects dead connections,
not the live-but-wedged ones behind the exhaustion this series addresses.

These knobs are infrastructure the node needs before it can open a DB
session, so they can never be sourced from the DB (chicken-and-egg). A new
ENV_ONLY_FIELDS set keeps them out of the persisted settings blob and
stops a DB value from shadowing env in both SettingsService.initialize and
.update, so env stays authoritative.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 22:26:57 +02:00
9qeklajc 1b09639265 docs: document DB pool and mint concurrency env vars in .env.example 2026-07-24 21:44:11 +02:00
Jeroen UbbinkandClaude Opus 4.8 d4657dca5a docs: reflect the optional, auto-generated secret key
The secret-key docs still said ROUTSTR_SECRET_KEY was required and that
the node would not start without it. Update the README, .env.example, and
the provider docs (configuration, quickstart, deployment) to the current
behaviour: the key is optional; when unset the node generates one beside
the database, so it persists on the same volume as the data, and prints a
one-time back-it-up notice; set it explicitly to manage the key yourself.
Switch the generation and reset snippets to `uv run python`, and add the
containerised reset variant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 10:51:20 +02:00
Jeroen UbbinkandClaude Opus 4.8 14748c28fb docs: document ROUTSTR_SECRET_KEY and first-run admin password
Explain that ROUTSTR_SECRET_KEY is now mandatory (with the generation command)
and describe the first-run flow where a temporary admin password is logged once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 10:51:20 +02:00
redshift 2e350e082b feat: add Tinfoil direct blind-upstream integration
Add TinfoilUpstreamProvider that uses inference.tinfoil.sh as a direct
EHBP upstream. Routstr acts as a blind relay: it forwards the opaque
encrypted body to the Tinfoil enclave without ever seeing plaintext,
and bills from the X-Tinfoil-Usage-Metrics response header.

- New routstr/upstream/tinfoil.py: fetches models from public
  GET /v1/models, parses Tinfoil pricing into standard Model/Pricing
  schema, supports_ehbp=True, proxies /attestation to atc.tinfoil.sh
- Updated routstr/upstream/ehbp.py:
  - parse_tinfoil_usage_metrics() parses prompt=N,completion=N header
  - _resolve_ehbp_target_url() honors X-Tinfoil-Enclave-Url from SDK
  - _strip_proxy_headers() removes proxy-only headers before forwarding
  - _compute_ehbp_actual_cost() converts usage to msats via calculate_cost
  - forward_ehbp_request() finalizes with exact token cost when usage
    header is present (non-streaming), falls back to max-cost otherwise
  - forward_ehbp_x_cashu_request() computes refund from actual cost
    when usage is available
- Updated routstr/proxy.py: forward /attestation and /.well-known/ paths
  without model/cost/auth lookups
- Updated routstr/upstream/__init__.py and helpers.py: register and
  auto-seed Tinfoil provider from TINFOIL_API_KEY env var
- Updated .env.example with TINFOIL_API_KEY
- 22 new unit tests in tests/unit/test_tinfoil_integration.py
- Updated docs/tinfoil-direct-integration.md and docs/ehbp-proxy-support.md
  with implementation status and billing behavior table
2026-06-21 13:16:01 +08:00
Evan Yang 8fc1b6484c Add Nostr analytics snapshots and expand stats model coverage 2026-03-13 15:55:29 +08:00
9qeklajc f7fc5ba5d7 fix url 2025-10-25 22:47:34 +02:00
Shroominic d2b8a4e78b update env example 2025-09-06 14:57:09 +01:00
Cursor Agentanddb2002dominic d4c1389249 docs: Add comprehensive documentation for Routstr Core project
Co-authored-by: db2002dominic <db2002dominic@gmail.com>
2025-08-25 01:17:40 +00:00
Shroominic 2b94185918 Apply .env.example and Dockerfile changes from reserved-balance-and-fixes branch 2025-08-22 15:36:39 -03:00
Shroominic f428410a24 update example env 2025-08-05 21:52:31 -03:00
Shroominic 22aa55e3d6 option to set provider fees 2025-08-02 22:10:55 -03:00
Shroominic 01e14d3f35 dev logging 2025-08-02 22:05:19 -03:00
Shroominic c6d7939d0a update examples 2025-08-01 22:31:18 -03:00
Shroominic 54cf5a3fc7 rm unreliable snort relay 2025-07-20 14:27:19 -03:00
Shroominic d63a21bc26 rm CURRENCY 2025-07-14 16:27:04 -03:00
9qeklajc ce24fd728b add currency env var 2025-06-30 15:27:09 +02:00
Shroominic acaf56ec00 update env example 2025-06-28 14:17:09 -03:00
Routstr DevandShroominic 1959e3a0fe Missed .env.example. 2025-06-28 14:14:23 -03:00
shroominic 873ad7d419 Allow running without models.json 2025-06-09 23:23:01 +02:00
GitHappens2Me b76414dc00 clean up and .env variables 2025-05-28 20:30:24 +02:00
GitHappens2Me f9620458b5 added current cashu balance to admin interface, improved .env.example 2025-05-24 18:40:13 +02:00
GitHappens2Me d992bc78be added required variables to .env.example 2025-05-23 22:04:13 +02:00
GitHappens2Me 6e24ff77c8 initial commit 2025-05-19 14:26:10 +02:00
Shroominic 214dfabc55 pay-out 2025-04-29 13:08:30 +08:00
Shroominic c78cd021f5 example .env 2025-04-19 12:46:00 +08:00