Repository navigation
Notes 2/5: add n-gram and suffix-array index - #1240
Closed
ThinkOffApp wants to merge 14 commits into
Closed
ThinkOffApp wants to merge 14 commits into
ThinkOffApp wants to merge 14 commits into
Conversation
ThinkOffApp
force-pushed
the
notes-pr2-index
branch
2 times, most recently
from
October 24, 2026 17:31
7c9fb78 to
1c47f39
Compare
ThinkOffApp
marked this pull request as ready for review
October 24, 2026 19:29
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.
ThinkOffApp
force-pushed
the
notes-pr2-index
branch
from
October 24, 2026 22:33
1c47f39 to
e0f1a84
Compare
7 of 9 tasks
7 of 8 tasks
ashhart
requested changes
Oct 26, 2026
ashhart
left a comment
Owner
There was a problem hiding this comment.
Thanks @ThinkOffApp. This applies cleanly on #1239 (rebased). Your fix from #1241 (40154d4: usage errors print main's two lines, help only for -h) belongs in this slice. Before it can go further:
- The whole index is rebuilt on every write or erase while holding the notes lock (
storage.zig), briefly with two copies in memory. Since chat lookups in #1241/#1254 take the same lock, each write would stall every"notes": truerequest for a rebuild. Please measure write latency and peak memory at 1k, 100k and 1M notes with lookups running. - The incremental path (
layer.zig,bounded.zig,merge.zig,core_build.zig, and the index's layer/reaper/retired fields) isn't reachable from storage. Wire it up, or move it to the slice that uses it. index.zigsays it's vendored from another MIT project, but the notices only name the test-suite repo. We need to settle provenance before taking vendored code.docs/NOTES-CODE-COMMENTS.mdmoves long comments out of the code (please keep comments short in place instead), covers later slices, and links to a design doc that doesn't exist.- Smaller: the
--noteshelp line promises lookup that this slice doesn't do;--notes-indexwithout--notesis silently ignored; andid_placeis sized by the largest id ever issued, which grows forever because ids aren't reused.
This was referenced Oct 26, 2026
Owner
|
Closing with the rest of the Notes series; the reasons are on #1254. Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Adds the LLWZ n-gram index on top of the journaled store: posting lists, or a suffix array over the notes' folded keys (
--notes-index sa, the default;postingson request). Storage builds the index after load and journal replay, and rebuilds the whole index before a write or erase commits (O(all notes); the incremental path (layered versions and background merge in layer.zig, bounded.zig and merge.zig) is vendored, but storage does not use it yet). A retryable erase returns before that swap, so the live index stays. If index build fails after the journal opens, the journal is closed. Lookup, live fetch and promotion remain separate slices.docs/NOTES-CODE-COMMENTS.mdis the full pin commentary, including sections for later slices (15 is overlay.zig, 21-29 are lookup and after).Second of five dependent Notes slices for #1012. It sits on top of Notes 1/5 (
4ab2519f), so until 1/5 merges this diff also shows 1/5's commit; this slice's own changes are the last 4 commits. Serve notes flags live innotes_flags.zig. Shared snapshot types stay innotes/types.zig; the index re-exports them so Model.state matches.Receipt
1c47f39d642ef06a77eef6d1b9b4f437669a4487.zig build test-server-cpu --summary all -Dcpu=apple_m1: 5/5 steps succeeded; 787/791 tests passed, 4 skipped.--notes-indexis sa by default, postings on request, nothing else.Remaining qualification
This is a draft for review, not a claim that #1012's six gates pass. Retrieval is the next slice. Not run on this follow-up: plain/native rebuild, real-model Metal/CUDA exactness, and the full device-dependent
zig build testtarget.Checklist
4ab2519f.