Skip to content

Commit 1ea1f15

Browse files
committed
Incremental parsing, cache migration, ASCII checks
Add incremental JSONL session parsing with persisted offsets and parser state stored in the scan cache; scanner can resume from file offsets, cap per-line size, and honor a per-refresh time budget. Introduce new CLI/config options (--max-jsonl-line-kib, --scan-time-budget-ms) and update scan planning to use per-file planning weights and bounded parse budgets. Add cache DB schema migration (v1 -> v2) and migration helpers, extend cache entries with file_offset, fully_parsed and parser_state, and update load/persist logic to reuse stale summaries when needed. Add ASCII-only guard scripts, a pre-commit hook installer, and a GitHub Actions workflow to run the ASCII check; update README and CHANGELOG and bump package version to 0.3.0. Also include a detailed review.md describing security hardening and limits.
1 parent 108330d commit 1ea1f15

File tree

11 files changed

+1151
-196
lines changed

11 files changed

+1151
-196
lines changed

.github/workflows/ascii-check.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: ASCII Check
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
ascii-check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Run ASCII check
14+
run: bash scripts/check-ascii.sh

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
**/*.rs.bk
33

44
/dist
5-
/dist_*
5+
/dist_*
6+
/internal

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented in this file.
4+
5+
## 0.3.0 - 2026-02-16
6+
7+
- Added incremental session parsing with persisted offsets and parser state in `comon.db`.
8+
- Reduced restart regressions: unchanged files outside current scan plan now stay visible via cache.
9+
- Added `--scan-time-budget-ms` for bounded per-refresh parse time (`0` disables budget).
10+
- Added `--max-jsonl-line-kib` to cap parsed line size without hard-dropping large files.
11+
- Added cache DB schema migration (`v1 -> v2`) for offset/parser-state fields.
12+
- For historical backfill after copying older sessions, run once:
13+
- `comon --full-scan --scan-time-budget-ms 0`

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "comon"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = "2021"
55
license = "Apache-2.0"
66

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@ Single-binary, cross-platform TUI for:
77
- Local Codex usage stats (last 7/30 days, chart, top models) by scanning `CODEX_HOME/sessions`.
88
- Live account limits/credits by spawning `codex app-server` and calling `account/rateLimits/read`.
99

10+
See `CHANGELOG.md` for release history.
11+
1012
<img width="1647" height="861" alt="Dkh7CxLgx7" src="https://github.com/user-attachments/assets/edec765d-0924-493b-8c10-cb32bca867a9" />
1113

14+
## Release 0.3.0
15+
16+
- Added incremental session parsing with persisted offsets and parser state in `comon.db`.
17+
- Reduced restart regressions: unchanged files outside current scan plan now stay visible via cache.
18+
- Added `--scan-time-budget-ms` for bounded per-refresh parse time (`0` disables budget).
19+
- Added `--max-jsonl-line-kib` to cap parsed line size without hard-dropping large files.
20+
- Added cache DB schema migration (`v1 -> v2`) for offset/parser-state fields.
21+
- For historical backfill after copying older sessions, run once: `comon --full-scan --scan-time-budget-ms 0`
22+
1223
## Requirements
1324

1425
- Rust toolchain (stable) installed.
@@ -48,9 +59,11 @@ Common flags:
4859
- `--usage-days <n>`: days to scan for usage (clamped 1..=90; default from config)
4960
- `--refresh-usage-secs <n>`: usage refresh interval in seconds (default from config)
5061
- `--refresh-limits-secs <n>`: limits refresh interval in seconds (default from config)
51-
- `--max-session-file-mib <n>`: max size (MiB) of a single session file to scan (default from config)
62+
- `--max-session-file-mib <n>`: per-file planning weight (MiB) for scan budget (default from config)
5263
- `--max-session-total-mib <n>`: max total size (MiB) to scan across session files (default from config)
5364
- `--max-session-files <n>`: max number of session files to scan per refresh (default from config)
65+
- `--max-jsonl-line-kib <n>`: max parsed JSONL line size in KiB (default from config)
66+
- `--scan-time-budget-ms <n>`: max parse time budget per refresh in ms (`0` disables budget)
5467
- `--full-scan`: scan all files under `CODEX_HOME/sessions`, including old months (ignores mtime cutoff)
5568
- `--no-full-scan`: disable full scan for this run (overrides config)
5669
- `--scan-cache-max-entries <n>`: max entries kept in cache database (`comon.db`) (default from config)
@@ -73,6 +86,8 @@ Config precedence:
7386
"max_session_file_mib": 256,
7487
"max_session_total_mib": 256,
7588
"max_session_files": 10000,
89+
"max_jsonl_line_kib": 512,
90+
"scan_time_budget_ms": 1500,
7691
"full_scan": false,
7792
"scan_cache_max_entries": 50000
7893
}
@@ -84,6 +99,16 @@ Example:
8499
comon --codex-home "C:\\Users\\You\\.codex" --cwd "C:\\Repos\\some-git-repo"
85100
```
86101

102+
Large-log recovery/tuning example:
103+
104+
```bash
105+
# One-time backfill for copied/old sessions:
106+
comon --full-scan --scan-time-budget-ms 0
107+
108+
# Normal usage with bounded incremental refresh:
109+
comon --scan-time-budget-ms 1500 --max-jsonl-line-kib 512
110+
```
111+
87112
## Key bindings
88113

89114
- `Tab` Toggle data (Tokens/Time/Runs)
@@ -247,12 +272,28 @@ Optional custom install root:
247272
bash install.sh ~/.local
248273
```
249274

275+
## Development checks
276+
277+
ASCII-only guardrails for docs/code/scripts:
278+
279+
```bash
280+
# Run full repository check (tracked files)
281+
bash scripts/check-ascii.sh
282+
283+
# Install local pre-commit hook (checks staged files on commit)
284+
bash scripts/install-pre-commit-hook.sh
285+
```
286+
287+
CI also runs this check on each push and pull request via `.github/workflows/ascii-check.yml`.
288+
250289
## Notes
251290

252291
- Usage stats are derived from Codex session JSONL logs. If you have no session data yet, values will be empty.
253292
- Limits/credits require `codex app-server` to start successfully (auth, environment, and a usable working directory).
254293
- comon stores local app state in `~/.comon/state.json` by default (or `$COMON_HOME`, or `--comon-home`).
255294
- comon stores scan cache in `~/.comon/comon.db` to avoid rereading unchanged session files.
295+
- Large session logs are parsed incrementally with persisted parser offsets in `comon.db`; unchanged files are reused from cache.
296+
- If historical days look incomplete after adding old session files, run once with `--full-scan --scan-time-budget-ms 0` to complete backfill.
256297
- comon uses embedded SQLite (`rusqlite` with bundled SQLite); no system `sqlite3` CLI is required at runtime.
257298
- comon stores user-editable runtime settings in `~/.comon/config.json` by default.
258299
- Privacy: comon stores metadata (workspace paths, timestamps, token/run/time aggregates) and does not persist prompt/completion text.

0 commit comments

Comments
 (0)