arc-kernel 0.1.4__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/Install.md +75 -40
  2. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/PKG-INFO +11 -1
  3. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/README.md +9 -0
  4. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/__init__.py +1 -1
  5. arc_kernel-0.1.6/arc/backup.py +852 -0
  6. arc_kernel-0.1.6/arc/backupcmd.py +537 -0
  7. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/cli.py +236 -63
  8. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/deploy.py +128 -12
  9. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/deploy_settings.py +12 -3
  10. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/doctor.py +13 -10
  11. arc_kernel-0.1.6/arc/expiring.py +59 -0
  12. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/log.py +16 -2
  13. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/log_collector.py +4 -2
  14. arc_kernel-0.1.6/arc/masterkeycmd.py +254 -0
  15. arc_kernel-0.1.6/arc/permissions.py +189 -0
  16. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/secrets.py +20 -0
  17. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/settings.py +70 -10
  18. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/store.py +47 -5
  19. arc_kernel-0.1.6/arc/uuid7.py +78 -0
  20. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/docs/arc-kernel.MD +18 -8
  21. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/pyproject.toml +2 -1
  22. arc_kernel-0.1.6/tests/test_backup.py +565 -0
  23. arc_kernel-0.1.6/tests/test_backup_cli.py +660 -0
  24. arc_kernel-0.1.6/tests/test_cli_restart.py +148 -0
  25. arc_kernel-0.1.6/tests/test_cli_settings_list.py +172 -0
  26. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_deploy_settings.py +35 -1
  27. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_deploy_split.py +149 -0
  28. arc_kernel-0.1.6/tests/test_expiring.py +93 -0
  29. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_log_collector.py +19 -0
  30. arc_kernel-0.1.6/tests/test_master_key.py +315 -0
  31. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_new_plugin_scaffold.py +20 -0
  32. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_nginx_routes.py +83 -2
  33. arc_kernel-0.1.6/tests/test_operator_only_settings.py +85 -0
  34. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_permissions.py +158 -1
  35. arc_kernel-0.1.6/tests/test_settings_who_and_when.py +71 -0
  36. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_uuid7.py +58 -7
  37. arc_kernel-0.1.4/arc/backup.py +0 -501
  38. arc_kernel-0.1.4/arc/backupcmd.py +0 -305
  39. arc_kernel-0.1.4/arc/permissions.py +0 -120
  40. arc_kernel-0.1.4/arc/uuid7.py +0 -57
  41. arc_kernel-0.1.4/tests/test_backup.py +0 -490
  42. arc_kernel-0.1.4/tests/test_backup_cli.py +0 -329
  43. arc_kernel-0.1.4/tests/test_cli_restart.py +0 -77
  44. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/.gitignore +0 -0
  45. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/LICENSE +0 -0
  46. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/_state.py +0 -0
  47. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/codec.py +0 -0
  48. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/crypto.py +0 -0
  49. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/errors.py +0 -0
  50. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/errorscmd.py +0 -0
  51. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/events.py +0 -0
  52. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/health.py +0 -0
  53. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/healthcmd.py +0 -0
  54. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/kernel.py +0 -0
  55. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/metrics.py +0 -0
  56. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/plugin_cli.py +0 -0
  57. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/py.typed +0 -0
  58. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/registry.py +0 -0
  59. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/resolver.py +0 -0
  60. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/runtime.py +0 -0
  61. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/sizing.py +0 -0
  62. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/status.py +0 -0
  63. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/stubs.py +0 -0
  64. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/supervision.py +0 -0
  65. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/tracing.py +0 -0
  66. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/tz.py +0 -0
  67. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/arc/update.py +0 -0
  68. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/setup.sh +0 -0
  69. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/__init__.py +0 -0
  70. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/conftest.py +0 -0
  71. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_boot.py +0 -0
  72. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_cli_perform.py +0 -0
  73. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_cli_run_console.py +0 -0
  74. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_cli_settings_set.py +0 -0
  75. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_connection_budget.py +0 -0
  76. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_connection_plan_cli.py +0 -0
  77. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_crypto.py +0 -0
  78. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_deploy_sizing.py +0 -0
  79. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_doctor_cpu.py +0 -0
  80. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_errors.py +0 -0
  81. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_errors_cmd.py +0 -0
  82. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_events.py +0 -0
  83. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_kernel.py +0 -0
  84. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_log.py +0 -0
  85. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_logs_serve.py +0 -0
  86. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_metrics.py +0 -0
  87. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_nginx_metrics.py +0 -0
  88. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_process_registry.py +0 -0
  89. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_resolver_versions.py +0 -0
  90. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_run_async.py +0 -0
  91. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_run_lock.py +0 -0
  92. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_secrets_provider.py +0 -0
  93. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_setting_descriptions.py +0 -0
  94. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_setting_types.py +0 -0
  95. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_settings.py +0 -0
  96. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_status.py +0 -0
  97. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_supervision.py +0 -0
  98. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_tracing.py +0 -0
  99. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_tz.py +0 -0
  100. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_update.py +0 -0
  101. {arc_kernel-0.1.4 → arc_kernel-0.1.6}/tests/test_worker_count.py +0 -0
@@ -25,7 +25,7 @@ Most of the time is spent waiting on package downloads; the ARC steps themselves
25
25
  9. [Build the Admin UI](#9-build-the-admin-ui)
26
26
  10. [Start ARC](#10-start-arc)
27
27
 
28
- Then: [verify](#verify-everything), [keep it running and put it on the internet](#keep-it-running-and-put-it-on-the-internet), [troubleshooting](#troubleshooting), [updating](#updating).
28
+ Then: [verify](#verify-everything), [keep it running and put it on the internet](#keep-it-running-and-put-it-on-the-internet), [troubleshooting](#troubleshooting), [updating](#updating), [upgrading PostgreSQL from 14](#upgrading-postgresql-from-14).
29
29
 
30
30
  ---
31
31
 
@@ -37,13 +37,13 @@ Then: [verify](#verify-everything), [keep it running and put it on the internet]
37
37
  | Python | the kernel and every plugin | **3.12 or newer** (`uv` can fetch it for you) |
38
38
  | [uv](https://docs.astral.sh/uv/) | builds the project environment (`arc init` / `arc install` call `uv sync`); supplies Python 3.12 if needed | any recent version |
39
39
  | git | `arc init` and `arc install` clone repositories | any |
40
- | PostgreSQL | all data (the `pgdb` plugin) | **14 tested.** 13+ should work, see the note in step 4. |
40
+ | PostgreSQL | all data (the `pgdb` plugin) | **14 and 18 tested** (14.24 and 18.6). 13 and 15 to 17 should work, see the note in step 4. PostgreSQL 14's last release is 12 November 2026. |
41
41
  | Redis or Valkey | caching, locks, rate limiting, background jobs (the `redix` and `lineup` plugins) | Redis 6.0 tested. Valkey is supported but was not tested. |
42
42
  | Node.js + Yarn 1 | **only** to build the Admin UI | Node 20 (the UI pins `20.20.2` in `.nvmrc`), Yarn 1.x ("classic") |
43
43
 
44
44
  You do not need a compiler or any `-dev` libraries: every Python dependency installs from a prebuilt wheel.
45
45
 
46
- **How this guide was checked.** The steps below were run from an empty directory against a freshly initialised, private PostgreSQL 14.24 and Redis 6.0.16, on Ubuntu 22.04 with Python 3.12, Node 20.20.2 and Yarn 1.22.22 — ending in a real login and successful calls to the Admin API. In that run the repositories were cloned from local copies confirmed to be at the same commits as GitHub's `main`. Step 3 was then checked separately against the published PyPI package, version 0.1.1: `pip install arc-kernel` inside a Python 3.12 virtualenv, `uv tool install arc-kernel`, and the failure quoted there on Python 3.10; then `arc init` with the kernel cloned straight from GitHub (it wrote `.vscode/settings.json` and `.gitignore` excluded the settings store), `arc install` of `pgdb` from GitHub, and `arc doctor` (the later steps were not repeated on that second project). Things that were **not** run are marked *(not run)*: `arc deploy prod` (system-wide units, nginx and certbot — its units were checked with `systemd-analyze verify` and unit tests only), the server-wide `setup.sh`, Valkey, and every OS other than Ubuntu. `arc deploy dev` was run against a scratch project and driven through crash tests under a real `systemd --user` manager, and `arc deploy dev --enable` was used to switch a running server from the old single `arc run` unit (about 9 seconds of downtime for the switch).
46
+ **How this guide was checked.** The steps below were run from an empty directory against a freshly initialised, private PostgreSQL 14.24 and Redis 6.0.16, on Ubuntu 22.04 with Python 3.12, Node 20.20.2 and Yarn 1.22.22 — ending in a real login and successful calls to the Admin API. In that run the repositories were cloned from local copies confirmed to be at the same commits as GitHub's `main`. Step 3 was then checked separately against the published PyPI package, version 0.1.1: `pip install arc-kernel` inside a Python 3.12 virtualenv, `uv tool install arc-kernel`, and the failure quoted there on Python 3.10; then `arc init` with the kernel cloned straight from GitHub (it wrote `.vscode/settings.json` and `.gitignore` excluded the settings store), `arc install` of `pgdb` from GitHub, and `arc doctor` (the later steps were not repeated on that second project). Things that were **not** run are marked *(not run)*: `arc deploy prod` (system-wide units, nginx and certbot — its units were checked with `systemd-analyze verify` and unit tests only), the server-wide `setup.sh`, Valkey, and every OS other than Ubuntu. `arc deploy dev` was run against a scratch project and driven through crash tests under a real `systemd --user` manager, and `arc deploy dev --enable` was used to switch a running server from the old single `arc run` unit (about 9 seconds of downtime for the switch). PostgreSQL 18.6 (the official container image) was then checked separately against a private copy of a project: the whole integration suite, every plugin's migration onto an empty database, `arc doctor --deep` and `arc health`, a real login, Admin API writes with audit history and trash, a foreign-key refusal, a background job with a signed file download, and `arc backup create`, `verify` and `restore` into a new database. The reference project's own server was then upgraded from 14 to 18.6 in place with `pg_upgradecluster` (see [Upgrading PostgreSQL from 14](#upgrading-postgresql-from-14)), and its integration suite passed on the upgraded server. Step 1's apt commands for 18 were run on that machine, which already had 14, so a clean machine with only 18 was not; the role and database of step 4 were created by hand in the 18 container. 13 and 15 to 17 were not run.
47
47
 
48
48
  ---
49
49
 
@@ -53,9 +53,13 @@ On Ubuntu or Debian:
53
53
 
54
54
  ```bash
55
55
  sudo apt update
56
- sudo apt install -y git curl postgresql redis-server
56
+ sudo apt install -y git curl redis-server postgresql-common
57
+ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y # adds the PostgreSQL project's apt repository
58
+ sudo apt install -y postgresql-18 postgresql-client-18
57
59
  ```
58
60
 
61
+ PostgreSQL 18 comes from the PostgreSQL project's own apt repository because Ubuntu 22.04's repositories only carry 14, whose last release is 12 November 2026. The helper script adds the repository and its signing key (the PostgreSQL project's key, fingerprint `B97B 0AFC AA1A 47F0 44F2 44A0 7FCC 7D46 ACCC 4CF8`). Installing `postgresql-client-18` matters: PostgreSQL's own backup tools refuse to dump a server newer than themselves, and when several versions are installed `pg_dump` resolves to the newest. If you would rather use the distribution's version, `sudo apt install -y git curl postgresql redis-server` still works (14 on Ubuntu 22.04, which is also tested); [Upgrading PostgreSQL from 14](#upgrading-postgresql-from-14) covers moving later.
62
+
59
63
  Make sure both servers are running:
60
64
 
61
65
  ```bash
@@ -66,7 +70,7 @@ redis-cli ping
66
70
 
67
71
  `pg_isready` should say `accepting connections` and `redis-cli ping` should answer `PONG`.
68
72
 
69
- > **Other systems** *(not run)*. ARC needs PostgreSQL's **`pgcrypto`** extension. On Debian and Ubuntu it ships inside the main `postgresql` package. On Fedora/RHEL install `postgresql-contrib` as well. On macOS, `brew install postgresql@14 redis` works the same way. For Valkey, install it in place of Redis — ARC talks to either, and `arc redix connect` accepts `redis-cli` or `valkey-cli`.
73
+ > **Other systems** *(not run)*. ARC needs PostgreSQL's **`pgcrypto`** extension. On Debian and Ubuntu it ships inside the main server package. On Fedora/RHEL install `postgresql18-contrib` as well. On macOS, `brew install postgresql@18 redis` works the same way. For Valkey, install it in place of Redis — ARC talks to either, and `arc redix connect` accepts `redis-cli` or `valkey-cli`.
70
74
 
71
75
  **Node.js and Yarn** — only needed for step 9. Install Node 20 from your package manager, [nodesource](https://github.com/nodesource/distributions) or [nvm](https://github.com/nvm-sh/nvm), then:
72
76
 
@@ -149,7 +153,9 @@ Generate the password with `openssl rand -hex 16` so it contains nothing that ne
149
153
  - role owns the database → works, no superuser needed
150
154
  - database owned by someone else → fails with `permission denied to create extension "pgcrypto"`
151
155
 
152
- ARC does not need a superuser, `CREATEDB`, or `CREATEROLE` — and you should not grant them. Only PostgreSQL 14 was tested. Trusted extensions were introduced in PostgreSQL 13, so 13 should behave the same, but on 12 and older you would need a superuser to create the extension first.
156
+ ARC does not need a superuser, `CREATEDB`, or `CREATEROLE` — and you should not grant them. This was verified on PostgreSQL 14 and 18 (on 18 the database owner installed `pgcrypto` in an empty database). Trusted extensions were introduced in PostgreSQL 13, so 13 should behave the same, but on 12 and older you would need a superuser to create the extension first.
157
+
158
+ **PostgreSQL 18 and newer generate ids natively.** Every table's `id` is a UUIDv7 made by a database function, `arc_uuid_generate_v7()`. When `arc pgdb migrate` runs on PostgreSQL 18 or newer, that function becomes a thin wrapper over the server's own `uuidv7()`: about three times faster, and ids made in one session come out strictly in order. On 14 to 17 it keeps its own implementation, which is the reason `pgcrypto` is needed there; that one also keeps ids made in one session in order, by writing the elapsed part of the millisecond into the bits after the timestamp. A server upgraded in place keeps the old implementation until the next `arc pgdb migrate`; either way, ids made before and after sort together by time.
153
159
 
154
160
  Check that the role can log in over TCP:
155
161
 
@@ -216,7 +222,7 @@ Database name: arc
216
222
  User: arc
217
223
  Password (blank for none):
218
224
  Connecting to 127.0.0.1:5432/arc...
219
- Connected — PostgreSQL 14.24 ...
225
+ Connected — PostgreSQL 18.6 ...
220
226
  ```
221
227
 
222
228
  (The password is typed blind — nothing is echoed.)
@@ -476,61 +482,67 @@ Keep `arc run` on `127.0.0.1` (the default) and let nginx be the only public lis
476
482
 
477
483
  ## Back it up, and prove you can restore it
478
484
 
479
- A database dump alone cannot bring an instance back. Without `.arc/arc.mkey` every secret in the settings store is lost for good, and without the uploaded files every upload is gone. `arc backup create` writes **one file** with all of it:
485
+ A database dump alone cannot bring an instance back: without the master key every secret in the settings store is lost for good, and without the uploaded files every upload is gone. `arc backup` writes a **timestamped folder with three separate archives**, so each part can be kept, copied and restored on its own:
480
486
 
481
- | Inside the file | What it is |
482
- |---|---|
483
- | `database.dump` | the whole PostgreSQL database (`pg_dump`, custom format) |
484
- | `state/arc.store.db` | the settings store, as a consistent snapshot (taken with SQLite's own backup call, not a copy of a file that may be mid-write) |
485
- | `state/arc.toml`, `state/plugins.lock`, `config/` | project config and which plugin versions were running |
486
- | `files/` | the filer's local files (read after the database was dumped, so every row in the dump has its file) |
487
- | `key.enc` | the master key, encrypted with your passphrase (scrypt + AES-256-GCM) |
488
- | `manifest.json` | what is inside, and a SHA-256 for every member; written last |
487
+ ```
488
+ backups/20261202T091500Z/
489
+ db-20261202T091500Z.tar.zst.enc the whole PostgreSQL database (pg_dump, custom format)
490
+ files-20261202T091500Z.tar.zst.enc the filer's local files (read after the dump, so every row has its file)
491
+ settings-20261202T091500Z.tar.zst.enc the settings store (a consistent SQLite snapshot; secrets stay encrypted inside it),
492
+ config/*.toml, arc.toml and plugins.lock
493
+ key.enc the master key, wrapped with your passphrase (scrypt + AES-256-GCM)
494
+ manifest.json what is in the folder, with a SHA-256 for every archive
495
+ ```
489
496
 
490
- **Not inside:** the code (`arc/`, `plugins/`: reinstall it from your repositories at the versions in `plugins.lock`), logs, `.venv`, and files kept in S3 (`filer_default_storage = s3`; the command says so; use the bucket's versioning or replication).
497
+ Each archive is compressed (zstd) and then encrypted with AES-256-GCM under a key derived from the **master key**. `--no-encrypt` writes plain `.tar.zst` files instead (`key.enc` is still written: the database and settings still hold values only the master key can read). A restore refuses a file that was cut short, extended, reordered or altered, and says which master key it needs.
498
+
499
+ **Not inside:** the code (`arc/`, `plugins/`: reinstall it from your repositories at the versions in `plugins.lock`), logs, `.venv`, and files kept in S3 or Crate (`filer_default_storage`; the command says so; use the bucket's versioning or replication).
491
500
 
492
501
  ```bash
493
- export ARC_BACKUP_PASSPHRASE='a long passphrase, at least 12 characters' # or --passphrase-file, or it asks
494
- arc backup create --keep 14 # backups/full/arc-backup-<project>-<time>.tar, and delete all but the newest 14
495
- arc backup verify backups/full/arc-backup-shop-20261107T020000Z.tar
502
+ export ARC_BACKUP_PASSPHRASE='a long passphrase, at least 12 characters' # or --passphrase-file, or it asks (twice)
503
+ arc backup # all three, encrypted
504
+ arc backup --db --settings # only some: --db, --files, --settings
505
+ arc backup --keep 14 # afterwards delete all but the newest 14 backup folders
506
+ arc backup --no-encrypt # plain archives (a restore warns, and cannot tell if they were tampered with)
496
507
  ```
497
508
 
498
- `create` never overwrites a backup, refuses a short passphrase before it dumps anything, adds `backups/full/*` to `.gitignore`, and needs `pg_dump` on the machine (`apt install postgresql-client`). `verify` re-reads every checksum, opens the key with your passphrase, checks that the settings store is intact and that the database dump is a readable `pg_dump` archive. It exits 1 on any problem, so it can sit in a schedule.
509
+ It never overwrites a backup, refuses a short passphrase before it dumps anything, adds `backups/*` to `.gitignore`, and needs `pg_dump` on the machine (`apt install postgresql-client`), at the same major version as the server or newer: PostgreSQL's own tools refuse to dump a newer server (`aborting because of server version mismatch`), so after moving to a newer PostgreSQL install its client tools too (on Ubuntu 22.04 the distribution's `postgresql-client` is version 14; the PostgreSQL apt repository has the others).
499
510
 
500
- **What the passphrase protects.** Only the master key. The database dump and the files are not encrypted (they hold your business data and password hashes), and the checksums detect damage, not tampering. Keep the file on encrypted storage, or encrypt it before it leaves the machine, for example `age -p -o backup.tar.age backup.tar`. **Lose the passphrase and the secrets cannot be recovered**; store it somewhere other than the server it protects.
511
+ **What protects what.** The archives are protected by the master key; `key.enc` is the master key protected by your passphrase. Keep `key.enc` and the passphrase somewhere other than the archives: anyone with both can read everything, and **lose both (or the key itself) and the backup cannot be opened**: there is no recovery. A plain (`--no-encrypt`) archive is protected by nothing: its checksums detect damage, not tampering.
501
512
 
502
513
  **Keep a copy somewhere else.** A backup on the same disk as the database is not a backup. Copy it off the machine (`rsync`, `rclone`, an object-store bucket with versioning). Schedule it, for example from cron as the project's owner, with the passphrase in a file only that user can read:
503
514
 
504
515
  ```bash
505
516
  # /etc/cron.d/arc-backup (the passphrase file: mode 600, owned by the project owner, outside the project)
506
- 30 2 * * * shop cd /srv/shop && "$(command -v arc)" backup create --passphrase-file /etc/arc/backup.pass --keep 14 && rsync -a backups/full/ backup-host:/srv/arc-backups/shop/
517
+ 30 2 * * * shop cd /srv/shop && "$(command -v arc)" backup --passphrase-file /etc/arc/backup.pass --keep 14 && rsync -a backups/ backup-host:/srv/arc-backups/shop/
507
518
  ```
508
519
 
509
- ### The restore drill
520
+ ### Restoring
510
521
 
511
- Do this once now, and again after any large change; a backup nobody has restored is a hope. It uses a **new empty database and a new directory**, so it cannot touch the live site:
522
+ `arc restore` restores into **the project you run it in**: on a new machine, install arc, run `arc init` (optionally with the old master key: `--master-key-file`), set `pgdb_dsn` to the new, empty database, then:
512
523
 
513
524
  ```bash
514
- createdb -O shop shop_restore_test # an empty database (as a role that may create one)
515
- arc backup restore backups/full/arc-backup-shop-20261107T020000Z.tar \
516
- --into /srv/shop-restore-test \
517
- --database-url postgresql://shop:PASSWORD@localhost/shop_restore_test
525
+ arc restore backups/20261202T091500Z/db-20261202T091500Z.tar.zst.enc # the database only (the default)
526
+ arc restore DB_FILE --files FILES_FILE # database and files
527
+ arc restore DB_FILE --settings SETTINGS_FILE # database and settings
528
+ arc restore --files FILES_FILE --settings SETTINGS_FILE # no database: files and settings only
529
+ arc restore DB_FILE --check # read and verify everything, change nothing
518
530
  ```
519
531
 
520
- It verifies every checksum and decrypts the key **before it writes anything**; a wrong passphrase or a damaged file changes nothing. Then bring the code back and look at it:
532
+ - **The database** goes into the one `pgdb_dsn` names (never anywhere else), refuses a target that already has tables unless `--force` (which replaces them), restores without the original owners and grants, and stops at the first error rather than leave a half-restored database. A dump `pg_restore` cannot read is caught before anything changes.
533
+ - **Files** go where this project keeps them (`filer_local_root`, else `files/`); a file that already exists is left alone unless `--force`.
534
+ - **Settings** are merged: a key in the backup overwrites the same key here, keys only here stay. `config/*.toml` are written over this project's. `arc.toml` and `plugins.lock` are **not** restored: they say which project this is and which plugins its code has.
535
+ - **Secrets are never restored by default** (nor are operator-only settings such as `restart_command` and `filer_local_root`). `--secrets` restores them, after a warning, and asks for confirmation (`--yes` for scripts). They include connection strings such as `pgdb_dsn` and `redix_url` that point at the *backup's* servers: remap them afterwards, or skip them with `--exclude pgdb_dsn --exclude redix_url` (repeatable, or comma-separated).
521
536
 
522
- ```bash
523
- cd /srv/shop-restore-test
524
- # reinstall arc/ and plugins/ from your repositories at the versions in .arc/plugins.lock, then:
525
- arc doctor && arc pgdb status && arc status
526
- arc run --port 8011 # a different port, then sign in as a real user
527
- ```
537
+ **Which master key opens the backup.** The key this project already has is tried first (each archive records a one-way fingerprint of its key, so this costs nothing); if it is the backup's key too, there are no prompts. Otherwise you are asked for the backup's master key (hidden prompt, or `--key-file` with the 64-hex key, or the backup's `key.enc` plus its passphrase). A wrong key changes nothing.
538
+
539
+ When a **database** is restored with another project's key, this project **adopts that key**: values the old project encrypted with `arc.encrypt()` live in the restored database and only open with it. Every secret already stored here is re-encrypted under the new key (the same routine as `arc master-key rotate`), requests that read a secret during the switch can fail, and the key this project had is shown **once** at the end (or written to `--old-key-file PATH`, required when output is not a terminal). A files-only or settings-only restore never changes this project's key: the key only opens the backup, and any secrets restored are re-encrypted under the key this project keeps.
528
540
 
529
- The restored project's `pgdb_dsn` points at the database you named, never the original, and an absolute `filer_local_root` is repointed at where the files now are. When you are satisfied: `dropdb shop_restore_test && rm -rf /srv/shop-restore-test`.
541
+ Do the drill once now, and again after any large change; a backup nobody has restored is a hope. Use a **new empty database and a new directory**, so it cannot touch the live site. After a restore, reinstall the code, then `arc doctor`, `arc pgdb status` and `arc status`, and restart so every process reads the restored state.
530
542
 
531
- Restore refuses to guess: it needs `--database-url` explicitly (a backup never goes back to its original database on its own), refuses a target that already has tables or a directory that already has `.arc/` unless you pass `--force` (which replaces them), restores without the original owners and grants (so a new machine without the old role works) and stops at the first error rather than leave a half-restored database, and rejects archive paths that would write outside the target directory. `--skip-database` / `--skip-files` restore only part. To restore **into production** after a disaster, point `--database-url` at the new empty production database and `--into` at the new project directory.
543
+ **The master key** can be chosen when a project is created (`arc init`, prompt or `--master-key-file`, so a new site can use the old site's key from the start) and changed later with `arc master-key rotate`.
532
544
 
533
- **Measured.** On this project's own data (a 205-route gateway, 2,673 uploaded files): the backup was 20.8 MiB, 2,682 members, made in 2.0 s and verified in 0.9 s. The restore is exercised automatically (`tests/integration/test_backup_restore_drill.py`, 13 tests) against a private PostgreSQL server started for the test: a project is backed up with the real commands, restored into a *different* database and directory, then booted, its rows read back and a secret decrypted with the restored key; a live database is refused, a wrong passphrase and a flipped byte change nothing, and a dump `pg_restore` cannot read is caught by `verify`. Not run: a restore on a second machine, a backup of a multi-gigabyte database (the time and size grow with it), and the `cron` line above.
545
+ **Tested.** The restore is exercised automatically (`tests/integration/test_backup_restore_drill.py`) against a private PostgreSQL server started for the test: a project is backed up with the real command, restored into a *different* running project (its own key and database), then booted, its rows read back, and a value the old project encrypted with `arc.encrypt()` decrypted with the adopted key; a database in use is refused, a wrong key, a flipped byte and a dump `pg_restore` cannot read change nothing. Not run: a restore on a second machine, a backup of a multi-gigabyte database (the time and size grow with it), and the `cron` line above.
534
546
 
535
547
  ---
536
548
 
@@ -583,7 +595,7 @@ Boot says so if the DSN is set and the package is missing (errors are still coun
583
595
  | The site answers and can reach its dependencies | An external uptime monitor on `GET https://app.example.com/readyz` (`200` = PostgreSQL and Redis answered; `/healthz` only says the process is alive) | an outage, or the database or Redis being unreachable |
584
596
  | Something is failing | cron, hourly: `arc errors --hours 1 --check` | a new bug, a job failing every run |
585
597
  | The processes are what was deployed | `arc status` (exits 1 on a failed unit or a wrong count) | a dead worker or scheduler |
586
- | The backup is still good | `arc backup verify` on the newest file after each backup | a backup that stopped being written or is damaged |
598
+ | The backup is still good | `arc restore <newest db file> --check` after each backup (reads and authenticates everything, changes nothing) | a backup that stopped being written or is damaged |
587
599
  | Trends and rates | Prometheus scraping `/metrics` (from this machine, or from an address in `deploy_metrics_allow`) | error rate, 5xx share, database pool saturation |
588
600
 
589
601
  ```bash
@@ -619,6 +631,9 @@ groups:
619
631
  **`permission denied to create extension "pgcrypto"`** during `arc pgdb migrate`
620
632
  The database is not owned by the role ARC connects as. Fix it with `sudo -u postgres psql -c 'ALTER DATABASE arc OWNER TO arc'`, or recreate it as in step 4.
621
633
 
634
+ **`pg_dump: error: aborting because of server version mismatch`** from `arc backup` or `arc pgdb backup`
635
+ The backup tool is older than the server: PostgreSQL's own tools refuse to dump a newer server. Install `postgresql-client-<server major>` (on Ubuntu 22.04 from the PostgreSQL apt repository, see step 1). Both commands print this advice under the tool's own error line, and exit with code 1.
636
+
622
637
  **`'pgdb_dsn' is not set`** (or `Warning: arc stubs failed to regenerate IDE stubs` while installing)
623
638
  You have not run `arc pgdb setup` yet. Harmless until you do. The same applies to `redix_url` and `arc redix setup`.
624
639
 
@@ -677,3 +692,23 @@ arc restart
677
692
  `arc update` runs `git pull --ff-only` on the kernel and every enabled plugin, skipping any with uncommitted changes. It does **not** touch the database or the running process: review `arc pgdb plan` for schema changes that came with the update, apply them with `arc pgdb migrate`, then `arc restart` once you are ready for the new code to take effect. (`arc restart` needs `restart_command`; `arc deploy dev` sets it.)
678
693
 
679
694
  Use `arc build` after you add a plugin dependency by hand or change the Admin UI's source; it re-resolves dependencies and rebuilds frontends.
695
+
696
+ ---
697
+
698
+ ## Upgrading PostgreSQL from 14
699
+
700
+ PostgreSQL 14's last release is 12 November 2026. This is the procedure that was run on the reference project's server (two databases, 528 MB), with Debian and Ubuntu's own `pg_upgradecluster`. It dumps the old cluster and restores it into a new one with the same port, locale and configuration, and leaves the old cluster on disk.
701
+
702
+ 1. **Take your own dumps first.** The old cluster is the main way back, but keep an independent copy: `sudo -u postgres pg_dumpall --globals-only > globals.sql`, then `pg_dump -Fc` for each database, and check each with `pg_restore --list`. Note the row count of every table if you want to compare afterwards.
703
+ 2. **Install 18 beside 14** (step 1). Nothing is removed, and no second cluster is created while `14/main` exists.
704
+ 3. **Stop ARC** so nothing writes during the dump: `systemctl --user stop arc-<project>.target` for a per-user deployment, or `sudo systemctl stop arc-<project>.target` for a system one.
705
+ 4. **Upgrade:** `sudo pg_upgradecluster -v 18 -m dump 14 main`. The new cluster takes port 5432. The old one moves to port 5433, stops, and is set to manual start so it cannot grab a port at boot. Passwords, extensions (`pgcrypto` moves from 1.3 to 1.4), roles, `max_connections` and the other settings come across.
706
+ 5. **Start ARC and check:** `arc pgdb status` shows the new version, `arc status` says `Everything matches`, `/readyz` answers 200. Nothing in ARC's settings changes, because the address is the same.
707
+ 6. **Run `arc pgdb migrate`.** It reports no schema changes, but re-installs the id function (`arc_uuid_generate_v7()`) as a wrapper over the native `uuidv7()`: about three times faster, and ids made in one session come out strictly in order. On 14 to 17 the function keeps its own implementation (and needs `pgcrypto`), which keeps ids in order too; ids from before and after the switch sort together by time.
708
+ 7. **Keep the old cluster for a while**, then `sudo pg_dropcluster 14 main` and `sudo apt purge postgresql-14 postgresql-client-14`.
709
+
710
+ **Measured.** On the reference project about 45 seconds passed between stopping ARC and the site answering again, and every table in both databases had the same row count before and after.
711
+
712
+ **Going back.** Until you drop it, the old cluster still holds everything up to the upgrade. Stop ARC and the new cluster (`sudo pg_ctlcluster 18 main stop`), swap the ports (`sudo pg_conftool 18 main set port 5433`, `sudo pg_conftool 14 main set port 5432`), start the old one (`sudo pg_ctlcluster 14 main start`) and start ARC. Anything written after the upgrade stays on 18.
713
+
714
+ **Bigger databases.** `pg_upgradecluster -m upgrade` (binary `pg_upgrade`) is faster for a large database. It was not run here.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: arc-kernel
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: ARC kernel — capability-based Python platform
5
5
  Project-URL: Homepage, https://github.com/vignesh-ramsh/arc
6
6
  Project-URL: Repository, https://github.com/vignesh-ramsh/arc
@@ -26,6 +26,7 @@ Requires-Dist: packaging>=23.0
26
26
  Requires-Dist: rich>=13.0
27
27
  Requires-Dist: tomlkit>=0.12
28
28
  Requires-Dist: typer>=0.12
29
+ Requires-Dist: zstandard>=0.22
29
30
  Description-Content-Type: text/markdown
30
31
 
31
32
  # kernel
@@ -75,8 +76,10 @@ arc init [project_name] --kernel-repo <git-url-or-path> [--kernel-branch main] [
75
76
  arc install <git-url> [--branch BRANCH] [--name NAME]
76
77
  arc build [-p/--plugin NAME] [--no-lock]
77
78
  arc settings get <key> [--reveal]
79
+ arc settings list [--secrets]
78
80
  arc settings set <key> <value> [--secret]
79
81
  arc settings delete <key>
82
+ arc settings access-log [--key K] [--limit N]
80
83
  arc plugin list
81
84
  arc plugin enable <name>
82
85
  arc plugin disable <name>
@@ -85,6 +88,13 @@ arc plugin disable <name>
85
88
  `ARC_KERNEL_REPO` env var can be set once so `--kernel-repo` doesn't need to
86
89
  be typed on every `arc init`.
87
90
 
91
+ **Secrets are CLI-only.** `arc settings list` shows ordinary settings and never
92
+ a secret; `arc settings list --secrets` shows only secrets, with every value
93
+ masked (`********`); `arc settings get <key> --reveal` is the one way to see a
94
+ secret's value, and each reveal is recorded (who, which key, when) and read
95
+ back with `arc settings access-log`. The admin console neither lists, reveals,
96
+ creates nor edits a secret.
97
+
88
98
  ## Plugin manifest format
89
99
 
90
100
  Every plugin repo has, at its root:
@@ -45,8 +45,10 @@ arc init [project_name] --kernel-repo <git-url-or-path> [--kernel-branch main] [
45
45
  arc install <git-url> [--branch BRANCH] [--name NAME]
46
46
  arc build [-p/--plugin NAME] [--no-lock]
47
47
  arc settings get <key> [--reveal]
48
+ arc settings list [--secrets]
48
49
  arc settings set <key> <value> [--secret]
49
50
  arc settings delete <key>
51
+ arc settings access-log [--key K] [--limit N]
50
52
  arc plugin list
51
53
  arc plugin enable <name>
52
54
  arc plugin disable <name>
@@ -55,6 +57,13 @@ arc plugin disable <name>
55
57
  `ARC_KERNEL_REPO` env var can be set once so `--kernel-repo` doesn't need to
56
58
  be typed on every `arc init`.
57
59
 
60
+ **Secrets are CLI-only.** `arc settings list` shows ordinary settings and never
61
+ a secret; `arc settings list --secrets` shows only secrets, with every value
62
+ masked (`********`); `arc settings get <key> --reveal` is the one way to see a
63
+ secret's value, and each reveal is recorded (who, which key, when) and read
64
+ back with `arc settings access-log`. The admin console neither lists, reveals,
65
+ creates nor edits a secret.
66
+
58
67
  ## Plugin manifest format
59
68
 
60
69
  Every plugin repo has, at its root:
@@ -28,7 +28,7 @@ from .kernel import ( # noqa: F401
28
28
  from .resolver import BootPlan, PluginSpec, ResolutionError # noqa: F401
29
29
  from .runtime import BootError, boot, find_project_root, shutdown # noqa: F401
30
30
 
31
- __version__ = "0.1.4"
31
+ __version__ = "0.1.6"
32
32
 
33
33
 
34
34
  def __getattr__(name: str) -> Any: