fix the session-list scan's line count, and pin both new paths with tests
The rewritten cst_agent_store_info() counted a transcript line that ran past a whole 64 KiB read block a second time, when the newline ending its tail arrived: a session with one very long line (a tool that read a file back) reported one message too many -- exactly what the sidebar shows the person. - src/agent_store.c: the tail's newline ends a line that was already counted. - tests/test_store.c: test_info_scan() holds the scan down -- a 70 KiB line is one line, the first user message comes from the head of the file, and a user line past the window is not called the first one. - tests/test_tools_ext.c: a byte budget stops the session_search walk, says so in the result, and never reports a match it did not reach; the same query without a budget finds it. make check and make asan are green.
This commit is contained in:
+4
-1
@@ -469,7 +469,10 @@ int cst_agent_store_info(const char *workspace, const char *id,
|
||||
if (!nl)
|
||||
break;
|
||||
const size_t len = (size_t)(nl - (buf + at));
|
||||
if (len > 0)
|
||||
/* A line counts once. A line that ran past a whole block was counted
|
||||
* when its tail was dropped, so the newline that ends it is not a line
|
||||
* of its own. */
|
||||
if (len > 0 && !slice)
|
||||
info->messages++;
|
||||
if (!slice && len > 0 && want_first && seen < kFirstUserBytes) {
|
||||
*nl = 0; /* the parse reads a C string; the newline is ours */
|
||||
|
||||
Reference in New Issue
Block a user