Library settings¶
TL;DR
PUT /libraries/{owner}/{repo}/settingsreplaces a library's include and exclude paths and tag rules as a whole set, and its chunking whenchunkingis sent.- Chunking defaults to
split_level3,min_chars0,max_chars4000; no chunk is ever longer than 8,000 characters. - A change re-processes every version with one job:
reprocess,rechunkorretag, the widest one needed. - Each version keeps serving its old state until its new one is complete.
Endpoint¶
| Method | Path | Purpose | Role |
|---|---|---|---|
PUT |
/libraries/{owner}/{repo}/settings |
replace paths, tag rules and chunking | admin |
GET /libraries/{owner}/{repo} has the current settings.
The request¶
PUT /libraries/{owner}/{repo}/settings (LIB-09, TAG-02, IMP-03) takes
{"include_paths", "exclude_paths", "tag_rules", "chunking"}.
- The paths and tag rules are replaced as a whole set: what is left out is cleared.
- The chunking is replaced only when it is sent.
chunkingleft out ornullkeeps the stored one, so a client that edits only paths and tag rules (the web UI) never resets it. - It is validated like
POST /libraries. Nothing is stored on a failure:- 422
invalid_path_pattern,invalid_tagorinvalid_chunking_config - or a field error
- 422
- 404 for an unknown library.

Chunking¶
chunking is {"split_level": 1-6, "min_chars": 0, "max_chars": 4000, "chunker": "markdown"}
with split_level 3.
| Field | Default | Meaning |
|---|---|---|
split_level |
3 | the deepest heading that starts a chunk;2 cuts at # and ## only |
min_chars |
0 | chunks shorter than this are merged |
max_chars |
4000 | a longer chunk is cut again at its deeper headings;null for no bound |
chunker |
markdown |
markdown-it-py, the only chunker |
- These are the defaults, also for a library added without
chunking(#381). Before #381 the defaults weresplit_level6 andmax_charsnull, which libraries added then keep. - A field left out of a sent
chunkingtakes its default, so send"max_chars": nullfor no bound.
How a version is cut¶
- A chunk longer than
max_charsis cut again at its deeper headings, never inside a code block or table. A section without deeper headings stays whole. - Chunks shorter than
min_charsare merged with the next one (the last with the one before), as long as the result stays withinmax_chars.- The text before the first heading is never merged.
- A merged chunk keeps the heading path and anchor of its first section, so a hit in a later section of it links to that first heading.
Limits¶
max_charsmust not be smaller thanmin_chars.- Both are at most 1,000,000, and at most 8,000 when sent, or 422
invalid_chunking_config. No chunk is longer, so a biggermax_charswould never cut and a biggermin_charsnever merge. - Settings stored before that limit still load, and their larger sizes have no effect.
The 8,000-character ceiling
Whatever the settings, a chunk is at most 8,000 characters (about 2,000 tokens;
max_section_chars in ChunkingConfig, not yet a setting).
- A longer group of sections is cut again at its deeper headings, and merges stop there.
- A section still longer is split between its top-level blocks, never inside a code block, table, list or MDX component. Only a single block longer than that makes a longer chunk.
- Every part keeps the section's heading path, anchor and occurrence index, and only the first records the heading in the outline.
Re-processing¶
Every version is then re-processed by one job, at the commit it serves. A branch is not synced.
| What changed | Job | What it does |
|---|---|---|
| paths | reprocess |
fetches each version again and re-imports it; unchanged blobs reuse their chunks |
| chunking (paths unchanged) | rechunk |
copies what each version serves into a new manifest, re-derives its tags, cuts the stored text again |
| only tag rules | retag |
derives each stored article's tags again from its stored front matter and the new rules |
rechunkfetches nothing. A blob already cut with that chunking reuses its chunks.- A version stored by an older parser, or holding a rare article whose stored text cannot be cut exactly as its import cut it, is re-imported at its commit instead. Such a version needs the repository to be reachable whenever its chunking changes.
retagfetches and chunks nothing, and manual tags stay.
Switching over¶
Each version keeps serving its old state (its old chunks too) until its new one is complete, and then switches at once:
- a new manifest is activated
- or, for a
retag, the version's catalog entries are re-tagged in one transaction, with search's tag copies following a moment later under the same lock (as for manual tags; a rerun of the job always brings them in line)
Failures¶
- A version that cannot be re-processed keeps what it had, the others go on, and the job fails
naming it.
error_codeis the failures' shared code, elsereprocess_failed. - Sending the same settings again then queues that job again.
- A job redoes what the smaller ones do (
reprocess>rechunk>retag). While a wider one failed and has not been redone, a retry or a smaller edit queues the wider one, so a smaller job never hides that failure.
The jobs count done / total in versions.
The answer¶
| Status | When | Body |
|---|---|---|
| 202 | a job was queued | the job in Location; job_id, reprocess (paths, chunking or tags),the stored chunking, versions (the refs the job re-processes) |
| 200 | nothing changed and the last re-processing did not fail, or the library has no version yet |
job_id: null |
- With no version yet, imports to come use the new settings.
- Edits of one library take turns.
- A queued job that does at least what is needed is reused.
- Removal waits for these jobs like for an import.