-
Notifications
You must be signed in to change notification settings - Fork 759
feat(storage): inspect Codex diagnostic logs safely - Part 1 #1727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
07a636a
rebase(log-guard): restack inspect on latest dev
Wibias 50188a3
fix(i18n): add French Log Guard inspect labels
Wibias 50cbd28
fix(i18n): add French Log Guard schema labels
Wibias 1784170
perf(log-guard): memoize inspection so repeat scans stop blocking the…
lidge-jun d00a51b
fix(log-guard): key the inspection cache on file identity, not size+m…
lidge-jun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| title: Codex Log Guard | ||
| description: Inspect Codex diagnostic-log storage safely before enabling future protection or reclaim actions. | ||
| --- | ||
|
|
||
| OpenCodex can inspect Codex's persistent diagnostic-log database from the **Storage** page and from the CLI. The inspection surface is deliberately read-only: it does not install triggers, delete logs, checkpoint SQLite, vacuum the database, or change Codex configuration. | ||
|
|
||
| ## What Inspect reports | ||
|
|
||
| OpenCodex resolves Codex's effective `sqlite_home` using Codex's existing precedence and inspects the canonical `logs_2.sqlite` database there. A higher-numbered or legacy `logs_N.sqlite` file is never substituted as the mutation-capable target. | ||
|
|
||
| The Storage view reports: | ||
|
|
||
| - the main database, WAL, and SHM file sizes; | ||
| - total log rows and the share stored at `TRACE` level; | ||
| - the largest log-target buckets by row count, using rank labels instead of target names; | ||
| - SQLite freelist space that may be reclaimable later; and | ||
| - whether the observed schema is compatible with the currently known Codex log schema. | ||
|
|
||
| If `sqlite_home` is outside `CODEX_HOME`, the diagnostic database is shown separately. Its bytes are not silently folded into the existing `CODEX_HOME` storage total. | ||
|
|
||
| OpenCodex does not select or expose `feedback_log_body` while producing these diagnostics. Log levels are reduced to the fixed known level set plus `OTHER`, and target names are not serialized. | ||
|
|
||
| ## CLI | ||
|
|
||
| ```bash | ||
| ocx storage codex-logs status | ||
| ocx storage codex-logs status --json | ||
| ocx doctor | ||
| ``` | ||
|
|
||
| The existing command remains unchanged: | ||
|
|
||
| ```bash | ||
| ocx storage --json | ||
| ``` | ||
|
|
||
| Its response now also carries the same Codex-log inspection report used by the Storage page. | ||
|
|
||
| ## Management API | ||
|
|
||
| ```text | ||
| GET /api/storage/codex-logs | ||
| ``` | ||
|
|
||
| `GET /api/storage` also includes the report as `codexLogs` so the dashboard can refresh the normal storage breakdown and Codex-log diagnostics from one snapshot request. | ||
|
|
||
| ## Read-only snapshot semantics | ||
|
|
||
| Inspection opens the database read-only with SQLite `immutable=1`. This prevents the diagnostic read itself from creating or updating `-wal` or `-shm` sidecars. | ||
|
|
||
| The trade-off is important: SQL aggregates describe the last checkpointed database snapshot. If Codex is actively writing, the live WAL can contain newer rows than the aggregate counts. OpenCodex therefore reports the WAL file size separately and does **not** label the result as SSD write rate, NAND writes, or drive-wear/TBW consumption. | ||
|
|
||
| ## Compatibility states | ||
|
|
||
| A known schema reports inspection, future protection, and future reclaim capabilities as supported. A missing, unreadable, or unknown future schema remains inspectable as metadata but is reported as unsupported for mutation-capable operations. | ||
|
|
||
| An unknown schema is not guessed into compatibility. This lets a newer Codex version remain observable while preventing later Log Guard releases from treating an unreviewed database layout as safe to modify. | ||
|
|
||
| ## What is not in this stage | ||
|
|
||
| This is **Inspect**, the first Log Guard stage. It does not reduce Codex writes by itself and does not reclaim database pages. | ||
|
|
||
| Later stages are intentionally separate: | ||
|
|
||
| - **Protect** will add explicit write-reduction modes after safety checks and Codex-process quiescence. | ||
| - **Reclaim** will add explicit, offline, bounded SQLite space reclamation. | ||
|
|
||
| Neither action is automatically enabled by Inspect. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import type { Locale } from "./catalogs"; | ||
|
|
||
| export type LogGuardLabelKey = "inspectionOnly" | "externalSqliteHome" | "inspectionUnavailable"; | ||
|
|
||
| const LABELS: Record<Locale, Record<LogGuardLabelKey, string>> = { | ||
| en: { | ||
| inspectionOnly: "Inspection only", | ||
| externalSqliteHome: "External SQLite storage", | ||
| inspectionUnavailable: "Diagnostic log inspection is unavailable.", | ||
| }, | ||
| de: { | ||
| inspectionOnly: "Nur Inspektion", | ||
| externalSqliteHome: "Externer SQLite-Speicher", | ||
| inspectionUnavailable: "Die Diagnoseprotokoll-Inspektion ist nicht verfügbar.", | ||
| }, | ||
| fr: { | ||
| inspectionOnly: "Inspection uniquement", | ||
| externalSqliteHome: "Stockage SQLite externe", | ||
| inspectionUnavailable: "L’inspection des journaux de diagnostic est indisponible.", | ||
| }, | ||
| ko: { | ||
| inspectionOnly: "검사 전용", | ||
| externalSqliteHome: "외부 SQLite 저장소", | ||
| inspectionUnavailable: "진단 로그 검사를 사용할 수 없습니다.", | ||
| }, | ||
| zh: { | ||
| inspectionOnly: "仅检查", | ||
| externalSqliteHome: "外部 SQLite 存储", | ||
| inspectionUnavailable: "诊断日志检查当前不可用。", | ||
| }, | ||
| "zh-TW": { | ||
| inspectionOnly: "僅檢查", | ||
| externalSqliteHome: "外部 SQLite 儲存空間", | ||
| inspectionUnavailable: "診斷記錄檢查目前無法使用。", | ||
| }, | ||
| ru: { | ||
| inspectionOnly: "Только проверка", | ||
| externalSqliteHome: "Внешнее хранилище SQLite", | ||
| inspectionUnavailable: "Проверка диагностических журналов недоступна.", | ||
| }, | ||
| ja: { | ||
| inspectionOnly: "検査のみ", | ||
| externalSqliteHome: "外部 SQLite ストレージ", | ||
| inspectionUnavailable: "診断ログの検査を利用できません。", | ||
| }, | ||
| tr: { | ||
| inspectionOnly: "Yalnızca inceleme", | ||
| externalSqliteHome: "Harici SQLite depolaması", | ||
| inspectionUnavailable: "Tanılama günlüğü incelemesi kullanılamıyor.", | ||
| }, | ||
| }; | ||
|
|
||
| export function logGuardLabel(locale: Locale, key: LogGuardLabelKey): string { | ||
| return LABELS[locale][key]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import type { Locale } from "./catalogs"; | ||
|
|
||
| export type LogGuardSchemaState = "compatible" | "missing" | "unreadable" | "unsupported"; | ||
|
|
||
| const SCHEMA_LABELS: Record<Locale, Record<LogGuardSchemaState, string>> = { | ||
| en: { | ||
| compatible: "Compatible", | ||
| missing: "Database not found", | ||
| unreadable: "Database unavailable", | ||
| unsupported: "Unsupported", | ||
| }, | ||
| de: { | ||
| compatible: "Kompatibel", | ||
| missing: "Datenbank nicht gefunden", | ||
| unreadable: "Datenbank nicht lesbar", | ||
| unsupported: "Nicht unterstützt", | ||
| }, | ||
| fr: { | ||
| compatible: "Compatible", | ||
| missing: "Base de données introuvable", | ||
| unreadable: "Base de données indisponible", | ||
| unsupported: "Non pris en charge", | ||
| }, | ||
| ko: { | ||
| compatible: "호환됨", | ||
| missing: "데이터베이스 없음", | ||
| unreadable: "데이터베이스를 읽을 수 없음", | ||
| unsupported: "지원되지 않음", | ||
| }, | ||
| zh: { | ||
| compatible: "兼容", | ||
| missing: "未找到数据库", | ||
| unreadable: "无法读取数据库", | ||
| unsupported: "不受支持", | ||
| }, | ||
| "zh-TW": { | ||
| compatible: "相容", | ||
| missing: "找不到資料庫", | ||
| unreadable: "無法讀取資料庫", | ||
| unsupported: "不支援", | ||
| }, | ||
| ru: { | ||
| compatible: "Совместимо", | ||
| missing: "База не найдена", | ||
| unreadable: "База недоступна", | ||
| unsupported: "Не поддерживается", | ||
| }, | ||
| ja: { | ||
| compatible: "互換", | ||
| missing: "データベースが見つかりません", | ||
| unreadable: "データベースを読み取れません", | ||
| unsupported: "未対応", | ||
| }, | ||
| tr: { | ||
| compatible: "Uyumlu", | ||
| missing: "Veritabanı bulunamadı", | ||
| unreadable: "Veritabanı okunamıyor", | ||
| unsupported: "Desteklenmiyor", | ||
| }, | ||
| }; | ||
|
|
||
| export function logGuardSchemaStateLabel(locale: Locale, state: LogGuardSchemaState): string { | ||
| return SCHEMA_LABELS[locale][state]; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.