arc-kernel 0.1.0__tar.gz → 0.1.1__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.
- arc_kernel-0.1.1/.gitignore +14 -0
- arc_kernel-0.1.1/Install.md +415 -0
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/PKG-INFO +11 -7
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/README.md +5 -5
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/__init__.py +6 -5
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/_state.py +1 -1
- arc_kernel-0.1.1/arc/cli.py +2548 -0
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/codec.py +14 -5
- arc_kernel-0.1.1/arc/crypto.py +143 -0
- arc_kernel-0.1.1/arc/deploy.py +410 -0
- arc_kernel-0.1.1/arc/doctor.py +244 -0
- arc_kernel-0.1.1/arc/events.py +584 -0
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/health.py +2 -2
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/healthcmd.py +8 -2
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/kernel.py +52 -31
- arc_kernel-0.1.1/arc/log.py +225 -0
- arc_kernel-0.1.1/arc/metrics.py +251 -0
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/plugin_cli.py +8 -6
- arc_kernel-0.1.1/arc/py.typed +0 -0
- arc_kernel-0.1.1/arc/registry.py +279 -0
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/resolver.py +81 -30
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/arc/runtime.py +112 -7
- arc_kernel-0.1.1/arc/secrets.py +111 -0
- arc_kernel-0.1.1/arc/settings.py +560 -0
- arc_kernel-0.1.1/arc/sizing.py +74 -0
- arc_kernel-0.1.1/arc/store.py +282 -0
- arc_kernel-0.1.1/arc/stubs.py +435 -0
- arc_kernel-0.1.1/arc/tracing.py +285 -0
- arc_kernel-0.1.1/arc/tz.py +130 -0
- arc_kernel-0.1.1/arc/update.py +92 -0
- arc_kernel-0.1.1/arc/uuid7.py +57 -0
- arc_kernel-0.1.1/docs/arc-kernel.MD +1005 -0
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/pyproject.toml +9 -2
- arc_kernel-0.1.1/tests/__init__.py +0 -0
- arc_kernel-0.1.1/tests/conftest.py +87 -0
- arc_kernel-0.1.1/tests/test_boot.py +184 -0
- arc_kernel-0.1.1/tests/test_cli_perform.py +71 -0
- arc_kernel-0.1.1/tests/test_cli_restart.py +77 -0
- arc_kernel-0.1.1/tests/test_cli_run_console.py +76 -0
- arc_kernel-0.1.1/tests/test_crypto.py +147 -0
- arc_kernel-0.1.1/tests/test_events.py +125 -0
- arc_kernel-0.1.1/tests/test_kernel.py +137 -0
- arc_kernel-0.1.1/tests/test_log.py +29 -0
- arc_kernel-0.1.1/tests/test_metrics.py +186 -0
- arc_kernel-0.1.1/tests/test_new_plugin_scaffold.py +84 -0
- arc_kernel-0.1.1/tests/test_process_registry.py +100 -0
- arc_kernel-0.1.1/tests/test_resolver_versions.py +198 -0
- arc_kernel-0.1.1/tests/test_run_async.py +124 -0
- arc_kernel-0.1.1/tests/test_run_lock.py +172 -0
- arc_kernel-0.1.1/tests/test_settings.py +224 -0
- arc_kernel-0.1.1/tests/test_tracing.py +198 -0
- arc_kernel-0.1.1/tests/test_tz.py +94 -0
- arc_kernel-0.1.1/tests/test_update.py +147 -0
- arc_kernel-0.1.1/tests/test_uuid7.py +81 -0
- arc_kernel-0.1.0/.gitignore +0 -10
- arc_kernel-0.1.0/arc/cli.py +0 -841
- arc_kernel-0.1.0/arc/doctor.py +0 -107
- arc_kernel-0.1.0/arc/registry.py +0 -173
- arc_kernel-0.1.0/arc/secrets.py +0 -85
- arc_kernel-0.1.0/arc/settings.py +0 -246
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/LICENSE +0 -0
- {arc_kernel-0.1.0 → arc_kernel-0.1.1}/setup.sh +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Generated by `arc stubs` — project-specific (reflects THIS project's
|
|
13
|
+
# currently enabled plugins.lock), regenerated on demand, never committed.
|
|
14
|
+
arc/__init__.pyi
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
# Installing ARC
|
|
2
|
+
|
|
3
|
+
ARC is a plugin platform: a small Python **kernel** (the `arc` command) plus **plugins** that each add one capability — database access, an HTTP server, user accounts, background jobs, and so on. This guide takes a blank Linux machine to a running ARC with a working **Admin Console** in your browser.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Browser ──HTTP──► gateway (:8001) ──► relay ──► pgdb ──► PostgreSQL
|
|
7
|
+
│ │
|
|
8
|
+
│ └─► redix ──► Redis / Valkey (cache, locks, rate limits)
|
|
9
|
+
└─ serves /admin
|
|
10
|
+
lineup workers ◄── Redis / Valkey (background jobs)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Most of the time is spent waiting on package downloads; the ARC steps themselves take seconds.
|
|
14
|
+
|
|
15
|
+
## Steps
|
|
16
|
+
|
|
17
|
+
1. [Install the system packages](#1-install-the-system-packages)
|
|
18
|
+
2. [Install uv and Python 3.12](#2-install-uv-and-python-312)
|
|
19
|
+
3. [Install the `arc` command](#3-install-the-arc-command)
|
|
20
|
+
4. [Create the PostgreSQL role and database](#4-create-the-postgresql-role-and-database)
|
|
21
|
+
5. [Create your project](#5-create-your-project)
|
|
22
|
+
6. [Install the plugins](#6-install-the-plugins)
|
|
23
|
+
7. [Create the tables](#7-create-the-tables)
|
|
24
|
+
8. [Create the first admin user](#8-create-the-first-admin-user)
|
|
25
|
+
9. [Build the Admin UI](#9-build-the-admin-ui)
|
|
26
|
+
10. [Start ARC](#10-start-arc)
|
|
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).
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## What you need
|
|
33
|
+
|
|
34
|
+
| Component | Needed for | Version |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| Linux | everything | Ubuntu 22.04 tested. Windows: use WSL2 (native Windows is not tested). |
|
|
37
|
+
| Python | the kernel and every plugin | **3.12 or newer** (`uv` can fetch it for you) |
|
|
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
|
+
| 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. |
|
|
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
|
+
| 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
|
+
|
|
44
|
+
You do not need a compiler or any `-dev` libraries: every Python dependency installs from a prebuilt wheel.
|
|
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 real PyPI package: `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, `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)*: the `arc deploy` commands, the server-wide `setup.sh`, Valkey, and every OS other than Ubuntu.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 1. Install the system packages
|
|
51
|
+
|
|
52
|
+
On Ubuntu or Debian:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
sudo apt update
|
|
56
|
+
sudo apt install -y git curl postgresql redis-server
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Make sure both servers are running:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
sudo systemctl enable --now postgresql redis-server
|
|
63
|
+
pg_isready
|
|
64
|
+
redis-cli ping
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`pg_isready` should say `accepting connections` and `redis-cli ping` should answer `PONG`.
|
|
68
|
+
|
|
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`.
|
|
70
|
+
|
|
71
|
+
**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
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install -g yarn
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The Admin UI's lockfile is Yarn 1 (`yarn.lock` begins `# yarn lockfile v1`), so install Yarn **1.x**, not Yarn Berry.
|
|
78
|
+
|
|
79
|
+
## 2. Install uv and Python 3.12
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Open a new shell (or follow the installer's PATH hint), then:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
uv --version
|
|
89
|
+
uv python install 3.12
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`uv` uses a system Python 3.12 if there is one and downloads its own otherwise, so this step is safe either way.
|
|
93
|
+
|
|
94
|
+
You need `uv` even though step 3 uses `pip`: `arc init` and `arc install` run `uv sync` to build the project's environment. It is also what supplies Python 3.12 on a machine whose own Python is older.
|
|
95
|
+
|
|
96
|
+
## 3. Install the `arc` command
|
|
97
|
+
|
|
98
|
+
The `arc` command is published on PyPI as **`arc-kernel`**:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install arc-kernel
|
|
102
|
+
arc --help
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**The `pip` has to belong to Python 3.12 or newer** — the package declares `Requires-Python >=3.12`. Check with `pip --version`: it should end in `(python 3.12)` or later. On Ubuntu 22.04, whose default Python is 3.10, pip refuses with:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
ERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python >=3.12
|
|
109
|
+
ERROR: Could not find a version that satisfies the requirement arc-kernel (from versions: none)
|
|
110
|
+
ERROR: No matching distribution found for arc-kernel
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
That is not a broken package, just a pip running an older Python. Use the Python 3.12 that `uv` gave you in step 2, in either of these ways:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# a) a virtualenv, then plain pip inside it
|
|
117
|
+
uv venv --seed --python 3.12 ~/.arc-cli
|
|
118
|
+
source ~/.arc-cli/bin/activate
|
|
119
|
+
pip install arc-kernel
|
|
120
|
+
|
|
121
|
+
# b) or let uv do both in one step and put `arc` on your PATH permanently
|
|
122
|
+
uv tool install arc-kernel
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
If your shell says `arc: command not found` after (b), run `uv tool update-shell` and open a new shell. Avoid `sudo pip install arc-kernel` into the system Python: recent distributions (Ubuntu 24.04, Debian 12) mark it "externally managed" and refuse global `pip install`s *(not run)*, which is what the virtualenv in (a) sidesteps.
|
|
126
|
+
|
|
127
|
+
This global `arc` only bootstraps projects. `arc init` (step 5) clones the kernel into your project, and from then on the project's own copy is the `arc` you use. So the published package can lag behind the kernel on GitHub without harm, apart from one small gap that step 5 shows how to close.
|
|
128
|
+
|
|
129
|
+
> Setting up a shared server where several people will each create projects? `setup.sh` in this repository installs `uv`, Python 3.12 and `arc` system-wide for every user *(not run)*:
|
|
130
|
+
> `sudo ARC_KERNEL_REPO=https://github.com/vignesh-ramsh/arc.git ./setup.sh`
|
|
131
|
+
|
|
132
|
+
## 4. Create the PostgreSQL role and database
|
|
133
|
+
|
|
134
|
+
Create a dedicated role and a database **owned by that role**:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
sudo -u postgres psql <<'SQL'
|
|
138
|
+
CREATE ROLE arc WITH LOGIN PASSWORD 'replace-with-a-strong-password';
|
|
139
|
+
CREATE DATABASE arc OWNER arc ENCODING 'UTF8';
|
|
140
|
+
SQL
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Generate the password with `openssl rand -hex 16` so it contains nothing that needs escaping inside the SQL string. (ARC itself handles special characters fine — this only protects the line above.)
|
|
144
|
+
|
|
145
|
+
**The `OWNER arc` part matters.** On first migration ARC runs `CREATE EXTENSION IF NOT EXISTS pgcrypto`. On PostgreSQL 14 `pgcrypto` is marked `trusted = true` (you can see it in `pgcrypto.control`), so the database's owner can install it with no superuser rights. This was verified in both directions:
|
|
146
|
+
|
|
147
|
+
- role owns the database → works, no superuser needed
|
|
148
|
+
- database owned by someone else → fails with `permission denied to create extension "pgcrypto"`
|
|
149
|
+
|
|
150
|
+
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.
|
|
151
|
+
|
|
152
|
+
Check that the role can log in over TCP:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
PGPASSWORD='replace-with-a-strong-password' psql -h 127.0.0.1 -U arc -d arc -c 'select 1'
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
If that fails, see [Troubleshooting](#troubleshooting).
|
|
159
|
+
|
|
160
|
+
## 5. Create your project
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
arc init myproject --kernel-repo https://github.com/vignesh-ramsh/arc.git
|
|
164
|
+
cd myproject
|
|
165
|
+
source .venv/bin/activate
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Run this as your normal user, not with `sudo`. To avoid typing the URL every time, `export ARC_KERNEL_REPO=https://github.com/vignesh-ramsh/arc.git` in your shell profile.
|
|
169
|
+
|
|
170
|
+
`arc init` creates:
|
|
171
|
+
|
|
172
|
+
| Path | What it is |
|
|
173
|
+
|---|---|
|
|
174
|
+
| `arc/` | the kernel source, cloned from `--kernel-repo` |
|
|
175
|
+
| `plugins/` | where plugins are installed |
|
|
176
|
+
| `.arc/` | project config: `arc.toml`, `plugins.lock`, the encrypted settings store `arc.store.db`, and the master key `arc.mkey` |
|
|
177
|
+
| `config/`, `logs/`, `backups/` | per-environment overrides, log files, backup targets |
|
|
178
|
+
| `pyproject.toml`, `.venv/` | a [uv workspace](https://docs.astral.sh/uv/concepts/projects/workspaces/) tying the kernel and every plugin into one virtual environment |
|
|
179
|
+
| `.gitignore` | already excludes the master key, the settings store, `.venv/`, `arc/` and `plugins/*/` |
|
|
180
|
+
|
|
181
|
+
> **Look for `Wrote …/.vscode/settings.json` in the output.** If it is missing, the `arc` you installed from PyPI is older than the kernel it just cloned. An older `arc init` does not yet write that file (it enables the red-underline checks for table and field names in VS Code), and its `.gitignore` leaves out `.arc/arc.store.db`, the encrypted settings store, so `git add .` would commit it. With the project's virtualenv active (as above), run `arc init .` once more — it is safe to repeat: it keeps your master key and existing files and only adds what is missing.
|
|
182
|
+
|
|
183
|
+
> **Back up `.arc/arc.mkey`.** It encrypts every secret ARC stores, including your database password. Lose it and those secrets cannot be recovered — ARC will report `Could not decrypt secret … wrong master key, or the store is corrupt`. `arc init` keeps it out of git on purpose; keep a copy somewhere safe.
|
|
184
|
+
|
|
185
|
+
## 6. Install the plugins
|
|
186
|
+
|
|
187
|
+
Every plugin is its own public GitHub repository. Install them in this order, **configuring each service right after the plugin that talks to it** — that keeps the installer quiet (see the note below the commands).
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# PostgreSQL access
|
|
191
|
+
arc install https://github.com/vignesh-ramsh/psqldb.git --name pgdb
|
|
192
|
+
arc pgdb setup
|
|
193
|
+
|
|
194
|
+
# Redis / Valkey access
|
|
195
|
+
arc install https://github.com/vignesh-ramsh/redix.git
|
|
196
|
+
arc redix setup
|
|
197
|
+
|
|
198
|
+
# everything else
|
|
199
|
+
arc install https://github.com/vignesh-ramsh/relay.git
|
|
200
|
+
arc install https://github.com/vignesh-ramsh/gateway.git
|
|
201
|
+
arc install https://github.com/vignesh-ramsh/lineup.git
|
|
202
|
+
arc install https://github.com/vignesh-ramsh/filer.git
|
|
203
|
+
arc install https://github.com/vignesh-ramsh/authn.git
|
|
204
|
+
arc install https://github.com/vignesh-ramsh/mail.git
|
|
205
|
+
arc install https://github.com/vignesh-ramsh/admin.git
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
> **The pgdb repository is called `psqldb`** — a leftover from before the plugin was renamed. Always pass `--name pgdb`. Without it the folder becomes `plugins/psqldb`, and `arc update` then silently skips the plugin (it looks for `plugins/pgdb`, finds nothing, and reports `skipped_no_git`) so pgdb would never receive updates.
|
|
209
|
+
|
|
210
|
+
`arc pgdb setup` asks for the details of the role you created in step 4, tests the connection, and only then saves it:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
Host [localhost]: 127.0.0.1
|
|
214
|
+
Port [5432]:
|
|
215
|
+
Database name: arc
|
|
216
|
+
User: arc
|
|
217
|
+
Password (blank for none):
|
|
218
|
+
Connecting to 127.0.0.1:5432/arc...
|
|
219
|
+
Connected — PostgreSQL 14.24 ...
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
(The password is typed blind — nothing is echoed.)
|
|
223
|
+
|
|
224
|
+
`arc redix setup` is the same for Redis: host `127.0.0.1`, port `6379`, DB index `0`, and leave user and password blank unless you configured them.
|
|
225
|
+
|
|
226
|
+
Both commands store the connection string **encrypted** in `.arc/arc.store.db`.
|
|
227
|
+
|
|
228
|
+
**What each plugin does**
|
|
229
|
+
|
|
230
|
+
| Plugin | Purpose | Needs |
|
|
231
|
+
|---|---|---|
|
|
232
|
+
| `pgdb` | PostgreSQL access, schema migrations, soft-delete and audit trail | — |
|
|
233
|
+
| `redix` | Redis/Valkey client: cache, distributed locks, rate limiting | — |
|
|
234
|
+
| `relay` | CRUD, hooks and the whitelisted-API layer everything else is built on | `pgdb` |
|
|
235
|
+
| `gateway` | the HTTP and WebSocket server | — |
|
|
236
|
+
| `lineup` | background-job workers and the cron scheduler | `redix`, `pgdb` |
|
|
237
|
+
| `filer` | file uploads and storage (local disk or S3) | `pgdb`, `relay` |
|
|
238
|
+
| `authn` | users, roles, sessions, login, access keys | `pgdb`, `relay` |
|
|
239
|
+
| `mail` | templated email over SMTP | `pgdb`, `relay` |
|
|
240
|
+
| `admin` | the Admin Console: web UI and API | `relay`, `gateway`, `authn`, `filer`, `pgdb` |
|
|
241
|
+
|
|
242
|
+
Install all nine; that is the configuration this guide was tested with. Redis is technically optional for the Admin Console — without `redix`, ARC falls back to in-process caching and locking, and login rate limiting becomes per-worker rather than shared — but you should run it. Background jobs (`lineup`) require it.
|
|
243
|
+
|
|
244
|
+
**Why the order matters.** After every install ARC regenerates IDE type stubs, which needs a successful boot. A boot fails until `pgdb_dsn` (and `redix_url`) are set, so installing `pgdb` and *then* configuring it avoids a `Warning: arc stubs failed to regenerate IDE stubs` on every later install. The warning is harmless — just noise — if you do it in another order.
|
|
245
|
+
|
|
246
|
+
## 7. Create the tables
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
arc pgdb plan
|
|
250
|
+
arc pgdb migrate
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
`plan` previews every change without writing to the database. On a fresh database it lists only additions — `CREATE TABLE` lines, plus a few `ADD COLUMN` lines that plugins like `filer` add to their own tables — each marked `[safe]`. `migrate` shows the same plan, asks for confirmation, then applies it (add `--yes` for scripts). Expect `Migration complete.` and about 20 tables.
|
|
254
|
+
|
|
255
|
+
Migrate also writes the SQL it ran to `migrations/*.sql` inside each plugin's folder. Those files are git-ignored.
|
|
256
|
+
|
|
257
|
+
## 8. Create the first admin user
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
arc authn create-user --email you@example.com --superuser
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
It prompts for a password (hidden, with confirmation). Passwords are scored with [zxcvbn](https://github.com/dropbox/zxcvbn) and must reach a minimum score (`authn_min_password_score`, default 3 out of 4), so something like `Password1!` will be refused. To have ARC generate a strong one instead and print it **once**:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
arc authn create-user --email you@example.com --superuser --random-password
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`--superuser` creates the `Superuser` role if it does not exist and grants it. It bypasses every role check, so give it only to administrators — ARC prints a warning to that effect.
|
|
270
|
+
|
|
271
|
+
## 9. Build the Admin UI
|
|
272
|
+
|
|
273
|
+
The Admin UI is a React app that has to be built once. It lives in `plugins/admin/admin/ui`:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
cd plugins/admin/admin/ui
|
|
277
|
+
yarn install --frozen-lockfile
|
|
278
|
+
yarn build
|
|
279
|
+
cd ../../../..
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
> **Do this instead of `arc build` on a fresh machine.** `arc build` runs `npm run build` and never installs dependencies first, so on a new checkout it stops with `sh: 1: tsc: not found`. Installing with Yarn first, as above, is what the lockfile is written for.
|
|
283
|
+
|
|
284
|
+
If you skip this step ARC still runs and the Admin **API** works, but `/admin` returns 404. ARC records a boot advisory saying `admin: UI not built` (read from the plugin's source; this guide's test run always built the UI first).
|
|
285
|
+
|
|
286
|
+
## 10. Start ARC
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
arc run
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
gateway: 8 worker(s) → http://127.0.0.1:8001
|
|
294
|
+
A queue used only through an ad hoc arc.relay.enqueue(fn, queue="...") call and never declared is not consumed — declare it with arc.relay.declare_queue(), or list every queue with `arc settings set lineup_queues a,b`.
|
|
295
|
+
lineup worker: 8 process(es) (auto-discovered queues: default, mail)
|
|
296
|
+
lineup scheduler: 1 (fixed — never scaled, would double-fire cron jobs)
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
`arc run` supervises the HTTP server, the job workers and the scheduler as one unit. Open **http://127.0.0.1:8001/admin** and sign in with the email and password from step 8. `Ctrl-C` stops everything.
|
|
300
|
+
|
|
301
|
+
Nothing needs configuring for background jobs: the workers consume every queue the installed plugins declare, which is the `auto-discovered queues` list above — `default`, plus `mail` for outgoing email. You only touch this if **your own** code enqueues onto a queue of its own name. Either declare it in a plugin's `register()` with `arc.relay.declare_queue("name")`, or list every queue by hand with `arc settings set lineup_queues default,mail,name`. A `lineup_queues` value *replaces* discovery, so always include `default` and `mail` in it.
|
|
302
|
+
|
|
303
|
+
The worker counts are sized to your machine's CPU and memory (never more than 8). On a small VM you can lower them: `arc settings set gateway_workers 2` and `arc settings set lineup_workers 2`. To use another port, `arc run --port 9000`.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Verify everything
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
arc doctor
|
|
311
|
+
arc pgdb status
|
|
312
|
+
arc redix status
|
|
313
|
+
arc health
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
- `arc doctor` prints the plugin load order and ends with **`Boot resolution OK.`** Two lines starting `warning: optional ordering skipped` are normal and expected — they describe a harmless dependency cycle, not a problem.
|
|
317
|
+
- `arc pgdb status` and `arc redix status` should each print `OK` with a latency.
|
|
318
|
+
- `arc health` lists each capability with `ok: yes`. For a deeper check that really opens connections and reports pool sizes and settings drift, use `arc doctor --deep`.
|
|
319
|
+
|
|
320
|
+
From another terminal, a quick end-to-end check:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8001/openapi.json # 200
|
|
324
|
+
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8001/whoami # 403 until you log in
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
A `403` on `/whoami` before logging in is correct, not a fault.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Keep it running and put it on the internet
|
|
332
|
+
|
|
333
|
+
`arc run` stops when you close the terminal. These two commands turn it into a service *(not run — read from the commands' own `--help`)*.
|
|
334
|
+
|
|
335
|
+
**A per-user systemd service** — no root needed:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
arc deploy dev --enable
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
This installs a `systemd --user` unit whose command is `arc run`, starts it, keeps it running across logouts, and sets `restart_command` so `arc restart` works.
|
|
342
|
+
|
|
343
|
+
**nginx and HTTPS in front of it** — needs root:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
sudo "$(command -v arc)" deploy prod --domain app.example.com
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
This writes an nginx site for that domain that proxies to `arc run`, and obtains a Let's Encrypt certificate with certbot. Use `--no-ssl` for plain HTTP, and `--port` if you changed `arc run`'s port. It only touches its own nginx site file. Run it from inside your project with the virtualenv active: `sudo` does not inherit your `PATH`, so a bare `sudo arc` usually cannot find a user-installed `arc`, and `"$(command -v arc)"` hands `sudo` the full path to the project's copy.
|
|
350
|
+
|
|
351
|
+
**Before going public**, review these settings (`arc settings set <key> <value>`):
|
|
352
|
+
|
|
353
|
+
| Setting | Why |
|
|
354
|
+
|---|---|
|
|
355
|
+
| `gateway_force_https` → `true` | Sends `Strict-Transport-Security`. Only turn on once HTTPS works. |
|
|
356
|
+
| `gateway_trusted_proxies` | The IP of your reverse proxy, so the real client IP is read from `X-Forwarded-For` rather than being nginx's address. Login rate limiting is keyed on the pair (client IP, account), so without this ARC sees nginx's address for everyone and that per-source separation is lost. |
|
|
357
|
+
| `gateway_cors_origins` | Left empty, CORS is disabled — the safe default. Only list origins that genuinely need cross-origin access. |
|
|
358
|
+
| `gateway_metrics_token` | Left empty, `/metrics` is open to anyone who can reach the port. Set a token if it is reachable. |
|
|
359
|
+
| `arc_server_timezone` | Defaults to `UTC`; set an IANA name such as `Asia/Kolkata` if you want naive date-times interpreted in local time. |
|
|
360
|
+
|
|
361
|
+
Keep `arc run` on `127.0.0.1` (the default) and let nginx be the only public listener. Back up `.arc/` (especially `arc.mkey`) and dump the database with `pg_dump`.
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Troubleshooting
|
|
366
|
+
|
|
367
|
+
**`permission denied to create extension "pgcrypto"`** during `arc pgdb migrate`
|
|
368
|
+
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.
|
|
369
|
+
|
|
370
|
+
**`'pgdb_dsn' is not set`** (or `Warning: arc stubs failed to regenerate IDE stubs` while installing)
|
|
371
|
+
You have not run `arc pgdb setup` yet. Harmless until you do. The same applies to `redix_url` and `arc redix setup`.
|
|
372
|
+
|
|
373
|
+
**`password authentication failed for user "arc"`**, or `no pg_hba.conf entry`
|
|
374
|
+
Connect to `127.0.0.1` rather than a socket, and check that `pg_hba.conf` allows password (`scram-sha-256` or `md5`) logins from `127.0.0.1/32`. Reload with `sudo systemctl reload postgresql`.
|
|
375
|
+
|
|
376
|
+
**`arc build` ends with `Not restarted: 'restart_command' isn't set`**
|
|
377
|
+
Informational, and the exit code is 0. The build completed (look for `Backend build complete`); ARC just does not know how to restart your processes, so a running `arc run` is still on the old code until you restart it yourself. Run `arc deploy dev` once to set `restart_command`, or set it by hand to whatever restarts your processes. (A restart command you *did* configure that fails makes `arc build` exit non-zero. An explicit `arc restart` with nothing configured is still an error.)
|
|
378
|
+
|
|
379
|
+
**`sh: 1: tsc: not found` while building the UI**
|
|
380
|
+
Dependencies were never installed. Follow [step 9](#9-build-the-admin-ui) with `yarn install --frozen-lockfile` first.
|
|
381
|
+
|
|
382
|
+
**`/admin` returns 404**
|
|
383
|
+
The UI is not built. Do step 9, then restart `arc run`.
|
|
384
|
+
|
|
385
|
+
**Admin pages load but show errors, or a mail you queued never arrives**
|
|
386
|
+
Check that `arc run` printed no `warning:` lines and that its `queues` list includes `mail`. If you have set `lineup_queues` by hand (step 10), it replaces auto-discovery, so it must list `default,mail` too.
|
|
387
|
+
|
|
388
|
+
**`another arc run is already active for this project (pid N)`**
|
|
389
|
+
A previous `arc run` is still alive. Run `arc kill` (add `--yes` in scripts) and start again. If you are certain nothing is running, delete `.arc/runtime/arc_run.lock`.
|
|
390
|
+
|
|
391
|
+
**`502 Bad Gateway` from nginx**
|
|
392
|
+
nginx is up but nothing is listening on the port it proxies to — `arc run` is not running. Start it (or `systemctl --user start` the unit) and check `arc doctor`.
|
|
393
|
+
|
|
394
|
+
**Port 8001 is already in use**
|
|
395
|
+
`arc run --port 9000`. If you use `arc deploy prod`, pass the same `--port`.
|
|
396
|
+
|
|
397
|
+
**`uv sync` removed all my plugins**
|
|
398
|
+
A bare `uv sync` at the project root uninstalls every workspace member. Always use `uv sync --all-packages`. ARC's own commands already do.
|
|
399
|
+
|
|
400
|
+
**`redix: FAILED to connect`**
|
|
401
|
+
Check `redis-cli ping`, then re-run `arc redix setup`. If Redis has a password, enter it there.
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
## Updating
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
arc update
|
|
409
|
+
arc pgdb plan
|
|
410
|
+
arc restart
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
`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.)
|
|
414
|
+
|
|
415
|
+
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: arc-kernel
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
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
|
|
@@ -19,6 +19,10 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
|
19
19
|
Requires-Python: >=3.12
|
|
20
20
|
Requires-Dist: cryptography>=42.0
|
|
21
21
|
Requires-Dist: msgspec>=0.18
|
|
22
|
+
Requires-Dist: opentelemetry-api>=1.25
|
|
23
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.25
|
|
24
|
+
Requires-Dist: opentelemetry-sdk>=1.25
|
|
25
|
+
Requires-Dist: packaging>=23.0
|
|
22
26
|
Requires-Dist: rich>=13.0
|
|
23
27
|
Requires-Dist: tomlkit>=0.12
|
|
24
28
|
Requires-Dist: typer>=0.12
|
|
@@ -88,9 +92,9 @@ Every plugin repo has, at its root:
|
|
|
88
92
|
```toml
|
|
89
93
|
# plugin.toml — ARC-specific metadata only
|
|
90
94
|
[plugin]
|
|
91
|
-
name = "
|
|
95
|
+
name = "pgdb"
|
|
92
96
|
version = "0.1.0"
|
|
93
|
-
capability = "
|
|
97
|
+
capability = "pgdb" # exported as arc.<capability> at boot
|
|
94
98
|
requires = []
|
|
95
99
|
optional_requires = ["redix"]
|
|
96
100
|
```
|
|
@@ -98,7 +102,7 @@ optional_requires = ["redix"]
|
|
|
98
102
|
```toml
|
|
99
103
|
# pyproject.toml — standard Python packaging; real dependencies live HERE
|
|
100
104
|
[project]
|
|
101
|
-
name = "
|
|
105
|
+
name = "pgdb"
|
|
102
106
|
dependencies = ["asyncpg>=0.29"]
|
|
103
107
|
|
|
104
108
|
[build-system]
|
|
@@ -107,5 +111,5 @@ build-backend = "hatchling.build"
|
|
|
107
111
|
```
|
|
108
112
|
|
|
109
113
|
Following this same kernel's convention, plugin packages should also use a
|
|
110
|
-
flat layout (`
|
|
111
|
-
`
|
|
114
|
+
flat layout (`pgdb/pgdb/__init__.py` inside the plugin's own repo, not
|
|
115
|
+
`pgdb/src/pgdb/`) — same reasoning, same fix, applied consistently.
|
|
@@ -62,9 +62,9 @@ Every plugin repo has, at its root:
|
|
|
62
62
|
```toml
|
|
63
63
|
# plugin.toml — ARC-specific metadata only
|
|
64
64
|
[plugin]
|
|
65
|
-
name = "
|
|
65
|
+
name = "pgdb"
|
|
66
66
|
version = "0.1.0"
|
|
67
|
-
capability = "
|
|
67
|
+
capability = "pgdb" # exported as arc.<capability> at boot
|
|
68
68
|
requires = []
|
|
69
69
|
optional_requires = ["redix"]
|
|
70
70
|
```
|
|
@@ -72,7 +72,7 @@ optional_requires = ["redix"]
|
|
|
72
72
|
```toml
|
|
73
73
|
# pyproject.toml — standard Python packaging; real dependencies live HERE
|
|
74
74
|
[project]
|
|
75
|
-
name = "
|
|
75
|
+
name = "pgdb"
|
|
76
76
|
dependencies = ["asyncpg>=0.29"]
|
|
77
77
|
|
|
78
78
|
[build-system]
|
|
@@ -81,5 +81,5 @@ build-backend = "hatchling.build"
|
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
Following this same kernel's convention, plugin packages should also use a
|
|
84
|
-
flat layout (`
|
|
85
|
-
`
|
|
84
|
+
flat layout (`pgdb/pgdb/__init__.py` inside the plugin's own repo, not
|
|
85
|
+
`pgdb/src/pgdb/`) — same reasoning, same fix, applied consistently.
|
|
@@ -4,19 +4,20 @@ ARC kernel — capability-based Python platform.
|
|
|
4
4
|
`import arc` is the only import application code ever needs (Architecture
|
|
5
5
|
§3.2). After `arc.boot()`, every enabled plugin's capability is reachable as
|
|
6
6
|
`arc.<capability>` via module-level `__getattr__` (PEP 562) — never
|
|
7
|
-
`import arc.
|
|
7
|
+
`import arc.pgdb`.
|
|
8
8
|
|
|
9
9
|
import arc
|
|
10
10
|
|
|
11
11
|
arc.boot()
|
|
12
|
-
user = await arc.
|
|
12
|
+
user = await arc.pgdb.fetch_one(...)
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
from typing import Any
|
|
18
18
|
|
|
19
|
-
from . import codec, health # noqa: F401 - attaches arc.codec / arc.health as real submodules
|
|
19
|
+
from . import codec, events, health, log, metrics, tracing, uuid7 # noqa: F401 - attaches arc.codec / arc.events / arc.health / arc.log / arc.metrics / arc.tracing / arc.uuid7 as real submodules
|
|
20
|
+
from .crypto import CryptoError, decrypt, encrypt, hash, verify_hash # noqa: A001,F401 - hash is a deliberate API name
|
|
20
21
|
from .kernel import ( # noqa: F401
|
|
21
22
|
ArcAdvisory,
|
|
22
23
|
Capability,
|
|
@@ -27,7 +28,7 @@ from .kernel import ( # noqa: F401
|
|
|
27
28
|
from .resolver import BootPlan, PluginSpec, ResolutionError # noqa: F401
|
|
28
29
|
from .runtime import BootError, boot, find_project_root, shutdown # noqa: F401
|
|
29
30
|
|
|
30
|
-
__version__ = "0.1.
|
|
31
|
+
__version__ = "0.1.1"
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
def __getattr__(name: str) -> Any:
|
|
@@ -62,4 +63,4 @@ def __dir__() -> list[str]:
|
|
|
62
63
|
kernel = _state.get_kernel()
|
|
63
64
|
if kernel is not None:
|
|
64
65
|
names.update(kernel.capabilities())
|
|
65
|
-
return sorted(names)
|
|
66
|
+
return sorted(names)
|