Repository navigation
Notes 1/5: add durable storage and retryable erasure - #1239
ThinkOffApp wants to merge 9 commits into
Conversation
a839cea to
ce51371
Compare
|
Thanks @ThinkOffApp for opening the series. The scope we agreed on #1012 stands. Two things before we review slice 1:
As agreed, with - Synthema, Ash's AI Assistant. |
Open the journal fixture for directory iteration on Linux. Use the platform libc and socket surfaces on Windows, preserve temporary-file identity with volume and file index, and refuse reparse points for no-follow opens. Keep POSIX fork and privileged symlink tests separate from the portable hardlink ownership regression. Refresh tokenizer example build configuration so the selected tokenizer directory is observed.
Keep the stable sidecar writer lock on Windows without mandatory locks on journal data. Replace an open destination through FileRenameInfoEx when MoveFileEx cannot, preserving old readers. Cover replacement with an open reader and refusal of another writer at the rename seam. Move Notes flag parsing into notes_flags so the merge with current main remains within the CLI line limit.
Startup refuses --notes, naming the cause, with --recall, --compact-memory, TENSORFOLD_REQUEST_LOG, --cortheon or a speech model; on an engine that cannot erase its prompt states (no hook, or a peer that does not acknowledge drops, found by forgetting a span no tokenizer emits); and on a journal that recorded a start with one of those writers on. --learn and --slide stay accepted: each erase names their places with complete: false. The docs list every place erase does not yet fully reach.
A request log, an engine without prompt-state erase and a peer that does not acknowledge drops each exit 2 without appending a run to the journal; an accepted start serves /v1/notes, takes a write and appends its run, so the journal-size check can fail.
4ab2519 to
e8e7c04
Compare
Each refused start runs on its own thread with a 20 s deadline; a start that listens instead is stopped with SIGTERM and fails as NotRefused, so a lost refusal is a red test, not a CI timeout.
|
Thanks @ashhart . Both are in e8e7c04.
With |
ashhart
left a comment
There was a problem hiding this comment.
Thanks @ThinkOffApp. We rebased this onto current main (three add/add conflicts, both sides kept) and went through it carefully. Two things we fixed locally that you'll want too: with --notes off, /v1/notes still reached the Notes handler and answered its own 404 (an off server should reply exactly as main does), and host_test.zig importing serve_recorder_test.zig breaks zig build test-dsv41-shared (that step has no engine_api; the import fits in draft_host_test.zig).
Still needed before device checks:
- Erase must always be able to complete on any configuration
--notesaccepts. Today--learn/--learn-conversationsand--slideare accepted (notes_refuse.zig), and with them, or with stored Responses, every erase reportscomplete: false. Please refuse those combinations, or erase from those stores too. - An erase can stay pending forever and keep the erased text on disk: a saved state whose last token equals the note's first token counts as
heldand is never removed (prompt_cache_forget.zig,prompt_learn.zig,rows_forget.zig), soneedsRetrystays true and the journal keeps the note's token spans. These are only caches, so removing too much is safe. - Security:
journal.zigopens an existing journal read-write without checking who owns it. If the snapshot directory is writable by another local user (e.g./tmp), they can create the journal first and read or inject notes. Please refuse a journal that isn't owned by the server's user or is group/other accessible. - Docs: erase rewrites and renames the journal, so old bytes can remain in freed blocks, snapshots and backups, and dropped KV buffers aren't zeroed. The docs should call erase a logical deletion.
- With
--notesoff, every lane round takes the host mutex once more (takeForgets). It's probably negligible, but it's on the decode loop: checkpending()under the lock the loop already holds, or we'll A/B it. - Smaller: the journal and snapshot are read whole with no size limit, there's no cap on note count, and each erase rewrites and fsyncs the whole journal under the notes lock.
We also still need to decide whether --notes should require --api-key (on a loopback bind without one, any local process can read and erase notes). We'll come back on that and on the overall shape from #1012 before the later slices.
|
Closing with the rest of the Notes series; the reasons are on #1254. Thank you. |
Adds opt-in
--notes SNAPSHOTand authenticated/v1/notesroutes to list, add, change, take back and erase notes. This is slice 1/5 for #1012, based on850c692a. Generation does not read Notes in this slice.Writes become visible after journal commit. Note IDs and source IDs never move or get reused. Erase can also make a later write redundant; the response explicitly lists that removal.
There are two separate limits to erase:
GET /v1/noteslists its IDs inpending_erases. Once actionable cleanup finishes, the record is retired even when permanent warnings remain. The reply exposescleanup_complete,retryableandstate(complete,pendingorunresolved).cleanup_complete: truemeans actionable cleanup finished;complete: falsecan still name unresolved places. GLM-DSA and GLM with an expert-parallel peer never acknowledge peer drops yet: their erases remain retryable indefinitely and keep those reversible spans.complete: false; they do not keep recoverable spans merely as a warning. Recall, speech state, unowned learned folders, Responses, logs, compaction files and learned weights are not all selectively erased. Active requests are counted, not cancelled. A retired erase returns 404 on retry and cannot target another note.Raw and quoted span checks retain the value word and cover short notes, prefixed turns such as “Hi! My favourite colour is green.”, trailing text and terminal-punctuation variants. A one- or two-word note can produce a very short span: “I'm Ana.” gives the single token “ Ana”, so erasure also drops unrelated states containing that token. These checks do not prove coverage of all paraphrases or arbitrary tokenizer contexts. Erase removes supported cached/saved conversation states; sibling inspection stops at 16 folders and refuses indexes over 8 MiB. A temporary error listing sibling folders currently counts as a permanent warning. Disk I/O is synchronous, with no measured frame-latency bound.
Validation on Zig 0.17.0:
test-notes-tokenizeralways reruns and passes 14/14 separately on Qwen3.8 and Nemotron with--cache-poison=poisoned; an unset directory fails instead of skipping.6244c620is byte-identical to GitHub's merge tree. Its macOS server suite has one additional upstream CLI test (774 passed, 4 skipped). Lean: 437 inherited findings, 437 in that merge, zero new. Formatting passes for all 83 outgoing Zig files; whitespace checks pass.Source:
4ab2519fafa5a0cbc6b2f10776e3330d81b6633a. Native SHA-256:b12401971280d76485ca24dcfef8741dab3bd135a6b6ebffb9f3eceec7423dbc.Merge still requires addressing the short-span over-erasure, missing GLM peer acknowledgments and temporary-folder-error classification above. Real-model learning-on erasure, Metal/CUDA exactness and the final stack's #1012 gates remain pending. This draft does not claim universal erasure or completion of #1012