Artifact 89bf45f87bac61da047fde0970e5bbd5620757e0df5747da46a6c4c20803dfc4:
- File
fuzz/fuzz_stats.c
— part of check-in
[a4373d90f3]
at
2026-11-10 07:30:42
on branch stats
— Add ctx stats; ctx remote writes a missing local copy; usage knows every command
ctx stats shows, per week and per project, session days and how often agents really used ctx: searches, searches with no matches, ctx turn reads and skill loads. It counts commands that ran, not mentions in arguments or heredocs, through a ctx_calls(body, sub) SQL function that ctx sql can use too, and runs in seconds on a 500,000-turn archive. A new fuzz target covers the command scanner.
ctx remote NAME FILE, given a local file that does not exist, writes a copy of the repository there, readable only by its owner, so sharing no longer needs a manual fsl_export. An existing file is never overwritten.
eval/skill_eval.py usage now reads the command list from ctx's own usage text, so wiki, source, project and the other newer commands are no longer counted as unknown. (user: dmestas, size: 685) [annotate] [blame] [check-ins using] [more...]
/* Stats: counting ctx calls in any shell command, and in any turn body through the * SQL function, ends and never reads past the end. */ #define CTX_NO_MAIN #include "../src/ctx.c" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t n) { static sqlite3 *db; if (!db) { db = db_open(":memory:"); sqlite3_create_function(db, "ctx_calls", 2, SQLITE_UTF8, NULL, sql_ctx_calls, NULL, NULL); } if (count_ctx_runs((const char *)data, n, "search") < 0) __builtin_trap(); sqlite3_stmt *q = db_prepare(db, "SELECT ctx_calls(?1, 'turn')"); sqlite3_bind_text(q, 1, (const char *)data, (int)n, SQLITE_STATIC); sqlite3_step(q); sqlite3_finalize(q); return 0; }