Expand description
Self-install and diagnostics: the library logic behind cortex init and cortex doctor.
Kept in the library (not the binary) so the contracts are testable; the cortex binary is a
thin renderer over these functions.
Structs§
- Doctor
Report - Structured diagnostics — the data contract shared by
cortex doctorand its agent twin. - Init
Outcome - The outcome of
cortex init. - Revoke
Token Outcome - The outcome of
cortex revoke-token. - SetToken
Outcome - The outcome of
cortex set-admin-token.
Functions§
- db_
tuning_ guidance - Operator guidance for tuning the PostgreSQL server (
shared_buffers,work_mem, …), printed bycortex tune-dband at the end ofcortex init. Per the owner decision (seedocs/DB_TUNING.md),cortexdoes not reimplement the pgtune heuristic — it points at the upstream service and pre-fills the host’s RAM / cores so the operator’s inputs are ready. The per-table autovacuum is already automatic (a migration); this is the host-sized server config (seedocs/DB_TUNING.md). - doctor
- Runs the install diagnostics against the given database URL.
- generate_
token - Generates a fresh random admin/API token: 32 URL-safe alphanumeric characters (~190 bits). Used
by
cortex set-admin-token --generate. The token is a plaintext bearer credential (the lightweight scheme — seedocs/archive/AAA_DESIGN.md); hashing-at-rest is a documented later step. - init
- Self-migrates the database (embedded migrations) and scaffolds a config file if one is missing.
- revoke_
admin_ token - Revokes admin/API token(s) from the JSON token file at
auth_path(config.json/CORTEX_AUTH_FILE) — the inverse ofset_admin_token. Removes either a specifictokenor every token mapped toowner(the caller supplies exactly one). Merges into the existing file (other tokens are preserved) and writes atomically; rewrites only when something actually changed. The library logic behindcortex revoke-token. A revoked token stops working immediately — the frontend re-reads this file on every gated request. - set_
admin_ token - Sets (or updates) an admin/API token in the JSON token file at
auth_path(config.json/CORTEX_AUTH_FILE) — the single source of truth forrerun_tokens— merging into the existing file so other tokens are preserved. The library logic behindcortex set-admin-token.