Skip to content

feat: live settings: signup, signup quota, retention and terms changeable from the operator console - #16

Merged
LukiPrince merged 5 commits into
mainfrom
feat/live-settings
Nov 14, 2026
Merged

LukiPrince merged 5 commits into
mainfrom
feat/live-settings

Conversation

@LukiPrince

Copy link
Copy Markdown
Owner

Live settings, PR 3 of the operator API: the console can change four settings while the server runs, without a restart. Without PRINTAPI_OPERATOR_TOKEN nothing changes: the new settings table is never read, every value is the environment one as in 3.5.0, and /operator/settings is 404.

What is live (docs/operator.md#live-settings)

  • Only signup, signup_quota, job_retention_days and terms. The environment variables are the start values. With the token set, a database override applies on top of them.
  • GET /operator/settings returns each key's value and source (db | env | env-locked | default). A key also gets ignored when its stored row is not applied. env_only shows the startup-only values and never holds a secret.
  • PUT /operator/settings {set, unset, reason?} validates with the env parsers' rules, which moved into the pure module settings.rs. It writes in one transaction with one settings.update audit row. The rows are then re-read and Live is swapped, in the same critical section.
  • Each request takes one snapshot. Only these read it: the signup handler, GET /health, the operator org create and the retention pass.
  • Overview: features: ["support", "settings"].

Kept apart from the security defaults

  • fetch_cap(), the private-URL policy, trusted proxies and the operator gate keep their startup values. Opening or closing signup live moves none of them. Tested: after a live open and close, a raw_uri to 127.0.0.1 and an event delivery to 10.0.0.1 are still refused.
  • A change that would leave signup open while private URLs are allowed answers 409. That includes an unset falling back to an env open. The same rule applies at startup, where such a DB row is ignored with a stderr line.
  • Emergency brake: while the token is set, any PRINTAPI_SIGNUP other than open locks signup shut and beats the database. That covers closed, but also CLOSED, off or a typo. While locked, only closing changes are accepted.
  • A job_retention_days change that lowers retention, or switches it on, needs a reason of at least 8 characters, because the next pass scrubs for good.
  • The terms version may not contain control characters and is at most 100 characters (env and live). Values in stderr lines are quoted.

Fixes from the review (security and Codex adversarial, read-only, each cross-checked)

  • unset could reopen signup with private URLs allowed.
  • The brake failed open on near-miss values (CLOSED, off, a typo).
  • A stale row was invisible and could not be cleared while locked.
  • Control characters in the terms version reached stderr.
  • The startup warnings named the wrong cause.

Checks

  • cargo test --workspace 1103 passed, clippy -D warnings, fmt.
  • pytest tools/docs 102, agent 75, check_docs OK.
  • Parity "785 steps: 759 pass, 0 diff, 26 known". --db-compat 23/23.
  • No web/ change.
  • By hand with the release binary:
    • A live open shows on /health.
    • A retention change without a reason answers 400.
    • With PRINTAPI_SIGNUP=CLOSED, signup is env-locked and the DB row shows as ignored.
    • With PRINTAPI_PRIVATE_URLS=allow, the open row is ignored.
    • Without the token: 404, and signup closed.

No release (that would be 3.6.0, only after asking).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX

LukiPrince and others added 5 commits November 14, 2026 14:54
Step 1 of live settings (spec A5), data side only: no route, no runtime wiring.

- New pure module settings: the env parsers (parse_quota, parse_fetch_cap,
  parse_retention, parse_terms, is_terms_url, py_strip) moved out of main.rs
  unchanged; Live with a source per value (db | env | env-locked | default);
  build_live (startup env, destinations policy, override rows -> Live plus
  stderr notes); validate_put (400 / 409 / reason rules).
- Table settings(key, value, updated_at); store::settings_rows reads only the
  four live keys; store::operator_update_settings writes a change and one
  settings.update audit row in one transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
…rtup overrides

AppState holds the effective live values as an Arc<Live> behind a lock held only to clone or
swap it; each request takes one snapshot. Only the signup handler, GET /health, the operator org
create and retention_pass read it. Config.signup_open keeps its startup meaning, so fetch_cap(),
the destinations default and the hosted checks are untouched. With the operator token unset the
settings table is never read. AppState::apply_settings writes a change, re-reads the rows,
rebuilds Live and swaps it inside one db.with. main.rs fills Config.env_flags and judges the
open-signup warnings on the effective values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
GET shows the four live settings with their source and the env-only
values (no secret). PUT validates with the env parsers' rules, writes
the rows and one settings.update audit row, and swaps the live values
in the same critical section. Overview features gain "settings".
Unsetting a retention override that falls back to a lower value needs
a reason like a lowering set does. Docs: operator.md "Live settings",
server.md, README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
…RLs, the brake fails closed, ignored rows are shown

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
@LukiPrince
LukiPrince merged commit 7f9d3ed into main Nov 14, 2026
28 checks passed
@LukiPrince
LukiPrince deleted the feat/live-settings branch November 14, 2026 14:46
@LukiPrince LukiPrince mentioned this pull request Nov 14, 2026
LukiPrince added a commit that referenced this pull request Nov 14, 2026
Support access (#15) and live settings (#16). The example version in
docs/operator.md follows.


Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant