fix(core): address PR review — buffer ordering, flush safety, dbPath in logs

- Flush buffer before appendAgentLogBatch to prevent rowid ordering
  inversion when callers interleave buffered and direct writes (P1)
- Wrap size-triggered flush in try-catch for consistency with timer path
- Move bumpLastModified inside transactions for atomicity
- Expose db.path getter and include DB path in all flush error logs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Timothy Laurent
2026-05-03 09:16:46 -07:00
parent 2f96fd34a9
commit 71f26c07b0
2 changed files with 16 additions and 5 deletions

View File

@@ -698,6 +698,8 @@ export class Database {
private db: DatabaseSync;
private readonly dbPath: string;
private readonly inMemory: boolean;
/** Returns the database file path (or ":memory:" for in-memory databases). */
get path(): string { return this.dbPath; }
corruptionDetected = false;
/** Tracks transaction nesting depth for savepoint-based nested transactions. */
private transactionDepth = 0;