Repository navigation
Notes 4/5: fetch more notes while the reply decodes - #1254
ThinkOffApp wants to merge 29 commits into
Conversation
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.
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.
cli.zig keeps one notes field. This slice adds path and index; later slices add language and lookup in the same struct. Flag table rows and help come from notes_flags so cli.zig does not grow.
overlay.zig has no caller at the pin; past.zig belongs with lookup. Add NOTES-CODE-COMMENTS.md so the remaining section pointers resolve. Storage still rebuilds the whole index on every write and erase.
The journal errdefer only covered replay. Index build and alias populate sit after that block, so an unsupported suffix-array vocabulary leaked the open journal. The cleanup now covers them, and a test loads that case with a journal path.
A response reader waiting for EOF could leave the host suite blocked in join after dispatch. Bound its full read, retry interrupted write shutdown, and report timeout or shutdown failure. A peer-withheld EOF control fails without the deadline and completes with it.
…s help shows only on -h The --notes-index help row now says the index is rebuilt whole on every write and erase, as notes/storage.zig does. It no longer names the side buffer, which the served store never fills. The Notes help rows print for -h and --help only. A usage error prints the usage line and the error, as before PR2.
These files come from 861d6c99 unchanged: notes/lookup.zig, notes/past.zig, notes/lang.zig, notes/lang_tables.zig, the fixtures l6_bytes_cases.json, lang_cases.json and tb_empty_bytes_snapshot.json, and the Python tools that write them (tools/notes/fixture.py, live_intake.py, lang_cues.py, lang_tables.py, lang_cases.py, past_cases.py and ml_overlay.py, which fixture.py imports for its --lang fixtures). Two changes keep the lean rule. A two-line comment in lang.zig is now one line. lang_tables.zig is generated by tools/notes/lang_tables.py, so lean_check.py lists it with the other generated outputs. Nothing calls the lookup yet. Its own tests and those of past.zig and lang.zig run with the server tests.
A chat completion request that sends "notes": true, or a notes_exclude list, now has its last user message looked up in the store. The notes found go into one block, which is put first as a system message, as if the client had sent it. The block is cut to the cap by the served tokenizer. The reply's "notes" field and the server log name the ids, tokens and times. The fields notes_past, notes_cap, notes_echo and notes_language work as at the pin, and --notes-language sets the default language. The lookup is the pin's (notes/lookup.zig). notes/retrieve.zig runs it on the store's current index under the store's lock, as the pin's Store.retrieveWith did, with one kept scratch in the store. An erase drops that scratch, which may hold the erased note's text. notes_route.zig is the pin's request handling without the chat write and the live fetch. json.quote and json.stringify now free what they took when a write fails, as at the pin. The lookup's allocation failure tests found the leak. notes-golden (zig/tests/notes_golden_bench.zig, from the pin) compares the lookup with LLWZ Python's answers, question by question. On the exported L6 and five nightly stores, bare and with 1000 distractors, it gives 1344 of 1344 equal answers with either index. --notes-language, its field and its help row are in notes_flags.zig, so cli.zig does not grow. The test's socket pair, reads, writes and poll go through the platform layer, as PR1's HTTP fixtures do, so it builds on Windows.
lookup() now runs scored() for the scores and the pool, then pack() over the order keys. The result is the same as before. The who-first lookup reuses both parts.
A chat request's first block now holds the notes of the subjects the question names and the notes of the entities those notes name. The subjects are the store's entity phrases, the user, and the entities a current name note calls by a word of the question. A name that several entities hold names the user's circle, or else all of them with a lower weight. An excluded note is never shown, and the link it states is never followed. The candidates are ranked by retrieve()'s scores and packed as before. When the question names nobody the store knows, the block is empty. The user is named by I, me, mine or myself, but not by the me of tell me, give me or show me. "my X" names the user when X is a word of one of the user's current notes or a part of a stored attribute's name, and no word of any entity's name. The check of X reads only the store, with no list of attribute words. The request field notes_lookup, "who" or "plain", picks the lookup, and the store's default is who. German and Finnish questions keep the plain lookup. A request without notes does not read the field. A lookup test that compares the notes before a write and after its erase asks for the plain lookup.
tools/notes/who_ref.py is the rule in Python on LLWZ's NoteStore. tools/notes/who_fixture.py writes a made-up store under the byte tokenizer, with Python's answer for each of its cases and for each case of the L6 fixture. The new tests check the chat path and compare every case with Python on both indexes. notes_lookup_rig_test.zig is the tests' server: the store with its journal in a temporary folder, as the pin's rig, on this branch's store.
The bench now prints each request whose answer differs, so a difference can be read case by case. The first line of the bench names its flags as [flags], to keep the lean rule.
…eads the store once The user's notes that /v1/notes wrote without a subject have the attribute note:SOURCE. They do not say whom they are about. Those the plain lookup ranks are now always candidates, so a question about such a note no longer gets an empty block. A name is now a run of Latin, Greek or Cyrillic letters, with a hyphen between two letters, or up to four such runs one space apart. Each run is encoded in a scratch arena that is reset before the next run. A long question no longer grows the request arena. "my X" reads the entity names, the attribute names and the user's notes once per question, whatever the number of X. The Python reference reads I, me, mine, myself and my as ASCII, as the Zig code does. The made-up store has new notes. Each part of the rule now decides at least one of its cases. A new fixture writes four notes over /v1/notes and compares the answers after them with Python. The live fetch and the chat write belong to later slices, so the test of the live fetch after an empty block is left out here, and the test of notes the server wrote writes its chat statement over /v1/notes.
--notes-lookup plain gives a server the earlier lookup for every chat request that sends no notes_lookup. The default stays who. The startup line names the lookup. docs/notes-store.md says how to keep the earlier lookup. German and Finnish keep it only when the request or the server declares them. The source commit also had tools/notes/run.py and tools/notes/live.py ask for the plain lookup. Those tools come with later slices. The flag, its field and its help row are in notes_flags.zig, so cli.zig does not grow.
Live fetch looks up again in this server's own notes index for that owner. Nothing comes from the web or another service. On with "notes": true, off with "notes_decode": false. At most two fetches a reply (most = 2), each at least min_share = 1.0 of topWeight, inside the notes cap. The first lookup stays who-first when notes_value_hop is omitted (default_value_hop = false). chat.zig and openai.zig stay under 600 lines: logEnded, StopHook and deltaOf move to chat_output.zig, and the refused helpers to openai_errors.zig. Request.retain_at is the only engine_api field added, for an in-request prompt edit. No chat write and no promotion.
On the hold-out store L6-seed2 the dog's name note says the dog has a new name and then, in a second clause, "it is called Otto now." The name table read a name only right after the note's subject, so "What is the colour of Otto's eyes?" named nobody and got an empty block. Python's V1 reads the stored value instead. The snapshot (LLWZ's notes_export.py) carries no literal value per note, and a written change of a name note has none either, so the name is still read from the text. A naming phrase alias.zig already knows may now also open a later clause of the note (after a full stop, comma, colon or semicolon and a space) when one word stands before it for the subject. No new phrase is added. tools/notes/who_ref.py reads names the same way. Tests: a made-up store note "Noor's goat got renamed, it is called Pim now." with "What does Pim eat?", unit cases for the clause rule, and the L6-seed2 teach store as a new differential against Python (224 requests). Against the code before this change the made-up case and both differentials fail.
A reply in progress that would fetch a journaled note stops after a real erase of that note, and after a write of a different note, with "the notes changed during the reply". The named note is not injected. Request.retain_at is the chunk-plan cut; the engine does not read it yet. The decode-field comment points at NOTES-CODE-COMMENTS.md.
29cda47 to
9fa34d8
Compare
|
Thank you for the care in this series (durable storage with erasure, the n-gram and suffix-array index, and the lookup are well built). We're going to decline it, for a reason of direction rather than quality: TensorFold's position is that what a model learns lives in its own weights (Living Weights), and |
|
Thanks. We'll take the client/proxy path in front of the OpenAI-compatible API, so Notes stays ours and TensorFold stays Living Weights. Grateful for the read on storage, index and lookup. |
What this changes
Live fetch looks up again in this server's notes index while a reply decodes. Nothing comes from the web or another service. A chat completion with
"notes": true(off with"notes_decode": false) checks as the reply names someone who has a current note outside the first block. At most two fetches a reply (most = 2), each at leastmin_share = 1.0oftopWeight, still inside the notes cap.The first lookup stays who-first when
notes_value_hopis omitted (default_value_hop = false). A hop, when asked, is this server's subject+value hop. The lookup reads the live index under the store lock. An erase or write mid-reply stops further fetches (Storage.gen); a test erases a journaled note a live fetch would take, and another writes a different note, and both stop with "the notes changed during the reply".Fourth of five dependent Notes slices for #1012. It sits on top of Notes 3/5 (
7fc4f58c), so until 1/5, 2/5 and 3/5 merge this diff also shows their commits; this slice's own changes are the last 2 commits. chat.zig and openai.zig stay under 600 lines (chat_output.zig,openai_errors.zig).Request.retain_atis the only engine_api field added: the chunk-plan cut for an in-request prompt edit; the engine does not read it yet. No chat write and no promotion.Receipt
29cda47641d17641537a46860d9c41fd65bd8d9f.zig build test-server-cpu --summary all -Dcpu=apple_m1: 849 passed, 4 skipped. Decode tests all passed, including erase and write mid-reply.zig fmt --checkon every .zig file this slice changes. chat.zig 596, openai.zig 596, notes_decode.zig 585, notes_decode_more_test.zig 235.Remaining qualification
This is a draft for review, not a claim that #1012's six gates pass. Promotion is the next slice. An erase that lands between a fetch and its injection can still reach that one reply; 1/5 counts such active requests and reports them, it does not cancel them. GitHub CI has not run on this head yet. Not run on this follow-up: plain/native rebuild, real-model Metal/CUDA exactness, and the full device-dependent
zig build testtarget.Checklist
7fc4f58c.