import type { StorageClient } from "../storage/client.js"; /** * Hard ceiling on log.md, enforced on every append. * * Storage has no append primitive, so appendLogEntry is a read-modify-write of * the whole file. Left unbounded it grows forever and eventually crosses * MAX_FILE_SIZE_BYTES (2 MB), at which point updateFile throws — and because * every caller invokes appendLogEntry fire-and-forget with a swallowed catch, * logging would stop silently. Production was at 1.0 MB and growing ~30 KB/day * when this was added (GH #417). * * 512 KB is a deliberate compromise, not a perf target. The activity digest * parses log.md for the last 7 days, so the file cannot be trimmed below that * window without breaking it. At the observed ~620 bytes/entry this holds * roughly 845 entries (~17 days at the observed rate) — comfortable margin * over the digest's 7 days, and a quarter of the hard cap. * * Getting the write path genuinely cheap needs the events moved out of a * markdown file entirely; this bounds the damage until then. */ export declare const LOG_MAX_BYTES: number; /** * Age-based trim, applied in addition to the byte ceiling. Note this is the * weaker of the two bounds in practice — production had zero entries older * than two months, so the byte ceiling is what actually does the work. */ export declare const LOG_RETENTION_DAYS = 90; /** * Trim log.md to the configured bounds, oldest entries first. * * Preserves any preamble before the first entry and keeps entries in their * original order. Returns the content unchanged when nothing needs dropping, * so a bounded file costs only the scan. */ export declare function rotateLog(content: string, now?: Date): string; export type LogEventType = "ingest" | "query" | "update" | "create" | "move" | "delete" | "lint" | "error"; export interface LogEntry { type: LogEventType; title: string; detail?: string; } /** * Record an activity event. * * On Postgres-backed deployments this is a single indexed insert into * `wiki_events`, and `log.md` is not touched at all. Storage has no append * primitive, so the previous implementation read the whole file, concatenated, * and wrote it back — ~920 KB of round-trip traffic per page write, measured * at 2.6-3.6s against the production file, on every create/update/patch/move/ * restore/delete (GH #417, #419). * * Local and Drive backends keep appending to `log.md`, bounded by rotateLog(). * * @param userId Storage owner subject. Empty for api-key / connector-key * writes, which share the global root. * @param authorSubject Actor that performed the write (GH #498) — falls back * to `userId` when omitted, matching the pre-attribution * behavior for call sites that haven't been updated yet. */ export declare function appendLogEntry(drive: StorageClient, entry: LogEntry, userId?: string, authorSubject?: string): Promise; //# sourceMappingURL=log.d.ts.map