Skip to main content

Module bootstrap

Module bootstrap 

Source
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§

DoctorReport
Structured diagnostics — the data contract shared by cortex doctor and its agent twin.
InitOutcome
The outcome of cortex init.
RevokeTokenOutcome
The outcome of cortex revoke-token.
SetTokenOutcome
The outcome of cortex set-admin-token.

Functions§

db_tuning_guidance
Operator guidance for tuning the PostgreSQL server (shared_buffers, work_mem, …), printed by cortex tune-db and at the end of cortex init. Per the owner decision (see docs/DB_TUNING.md), cortex does 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 (see docs/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 — see docs/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 of set_admin_token. Removes either a specific token or every token mapped to owner (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 behind cortex 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 for rerun_tokensmerging into the existing file so other tokens are preserved. The library logic behind cortex set-admin-token.