Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/master' into capy/fix-7172-timeline-chunk-reuse

garrytandb25155742e9
diff --cc CHANGELOG.md
index 6a78c37bcb,8a9d800bd2..6b796ddd11
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -10,35 -10,26 +10,55 @@@ credits are retained; no result has bee
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [Unreleased]
+
+**A timeline entry no longer rewrites the passages it didn't change, and a big passage replacement can't time out the write that carries it (#7172).** A managed write replaced its page's passages inside its publication, under the publication's 5 s statement bound. A passage whose index moved (a long entry near the top of a descending timeline adds a passage above the others) was deleted and inserted again with its vector, and on a large index each inserted row can cost about half a second, so the write ended `write_interrupted` (SQLSTATE 57014) on every attempt. Separately, a page whose stored embedding signature was missing or in an older format had every passage re-embedded after each write, which looked the same from outside: every passage got a new embedding time.
+
+### What changed
+
+| Situation | Before | Now |
+|---|---|---|
+| An entry shifts unchanged passages to new indexes | each moved passage deleted and re-inserted (vector copied) | the row keeps its id and vector and changes index in place |
+| A managed put_page, edit_page, add_timeline_entry, tag write, import or sync whose passages need more than 5 vector-index writes (a passage that carries a vector, inserted or renumbered) | all of them in one statement inside the publication; on a slow index, 57014 on every attempt, then `write_interrupted` | the page commits first; its passages finish in post-commit transactions of at most 5 vector-index writes each, then the projection is sealed. Passages without a vector (new text, a new page) are still written in the publication, as before |
+| Search during those steps | n/a | the page's passages are hidden until the seal (as for any pending projection); the receipt says `searchable: "pending"` and turns `true` when sealed |
+| The embedding step after a write, page signature missing or older format | every passage re-embedded (paid) | passages whose recorded embedding input is current keep their vectors; the page signature is restamped |
+
+The bound of 5 is derived in `src/core/page-state/chunk-moves.ts` (`CHUNK_VECTOR_WRITE_BUDGET`): a row version that carries a vector adds an HNSW entry, a graph search over the whole index that nothing amortizes across rows, while one without a vector adds no HNSW entry and only cheap b-tree and GIN pending-list entries (measured on pgvector: 300 passages inserted in 2.2 s with vectors and 0.06 s without; 300 renumbered in about 1 s with vectors and 0.002 s without). The slowest reported rate on a large index is about 0.5 s per vector-carrying row, and half of the 5 s statement bound is left for the rest of the write. No timeout, retry or deadline is raised, and nothing is configurable.
+
+### What to watch for after you upgrade
+
+- A write that was blocked by repeated `write_interrupted` (57014) on a large page can be submitted again; it commits and finishes its passages right after.
+- If a page's receipt stays `searchable: "pending"` for more than a minute, no process is finishing it: run `gbrain projections drain`.
+- When a top entry changes the text of every passage below it (the chunker packs about 300 words with a 50-word overlap, so a short entry can shift every boundary), those passages are new text and are embedded again; this release does not change the chunker.
+
+### Itemized changes
+
+- `reuseStoredChunkVectors` matches a stored row by source and text at any index (its own index first), so a kept row can move.
+- New `src/core/page-state/chunk-moves.ts`: the vector-index write bound and the move planner (one UPDATE per wave; a cycle parks one row at a negative index).
+- `continueDeferredProjection` runs the bounded steps after commit, holding the page's queue row under a claim it renews each step (the lease a segmented projection claim uses); the projection drain resumes a page whose steps stopped (queue reason `chunk_replacement_deferred`). A group publication now runs its members' post-commit work, as a single publication does.
+- Writes that wrap a page publication in their own (takes, the facts fence, maintenance pages) still replace passages in one transaction.
+- `readEmbeddingEffectProjection` accepts a vector whose recorded input hash is one the current page accepts, whatever the page-level signature says, and restamps the page.
+
+ ## [0.60.337.0] - 2026-10-21
+
+ **Agents can ask gbrain what happened to a file instead of copying its path rules, and `gbrain sync status` no longer contradicts itself.** A landing check that rebuilt gbrain's path-to-slug rules in its own code reported pages as synced but unsearchable for days when nothing was wrong. `gbrain sources resolve-path` gives gbrain's own answer for each path, and sync status and doctor now flag the pages that really are committed but not yet searchable.
+
+ ### What changed
+
+ | Situation | Before | Now |
+ |---|---|---|
+ | A harness checks whether a synced file landed | it had to copy gbrain's path-to-slug rules and drifted | `gbrain sources resolve-path <id> <path...> [--stdin] [--json]` (MCP `sources_resolve_path`, read scope, up to 200 paths) returns each path's slug, one of 14 states, `searchable: true \| 'keyword' \| false`, a reason and a fix |
+ | Pages a managed sync committed are still not searchable | nothing said so | `gbrain sync status --detail` adds a `landing` block, and the doctor check `sync_landing_gaps` warns about pages committed longer ago than the freshness target that search still can't fully see |
+ | A folder `index.md` or `README.md` below the source root with `type:` or `title:` frontmatter | skipped by sync, so it never became a page | imported as a page. Bare ones and every one at the root stay skipped. `gbrain config set sync.metafile_pages off` restores the old skip |
+ | One file waits on a person while the rest of the source syncs | `sync status` said `blocked` | `synced` with reason `held_needs_human`. `blocked` now means only that the source can't advance |
+ | A source falls behind its checkout | latency looked healthy, "no resident watcher" showed while a sync was running, and a fixed error still demanded a person | `freshness.behind` counts the commits not synced yet, `notifier.drain_holder` names the process syncing the source, an error the sync has since moved past is marked `superseded`, and `needs_human_from` says why a person is needed (#7189) |
+
+ The first sync after upgrading imports existing typed nested metafiles once. Nothing else is rewritten or deleted.
+
+ ### For contributors
+
+ - Harness authors: [docs/guides/resolve-paths.md](docs/guides/resolve-paths.md) lists the states and how a landing check should treat each one.
+
## [0.60.336.0] - 2026-10-21
**Writes no longer wait out their lock bound behind a large page's background index build.** Since 0.60.331.0, a new page over 4 MiB replies when it commits and its search index is built afterwards. Each step of that build held the page's lock while it inserted up to 4 MiB of passages, which took 1.6–2 s on a loaded host. A write to that page waits at most 1 s for the lock, so it failed and prepared again, copying a large page's prior file to its recovery stage once per attempt. A managed sync import, checkpoint or purge anywhere on the same source waited the same way, and could finish only on the next pass.
diff --cc src/core/behavior-change-notice.ts
index bc99bbf764,6f78c01c8d..eff4c50544
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -1043,9 -1043,12 +1043,15 @@@ export const BEHAVIOR_CHANGES: Readonly
{ since: '0.60.332.0', text: 'The `score` that search and query return now never increases down the list: in a reranked list it is the rerank score (times any rank prior), and a pinned or unreranked row takes its neighbour\'s value. The fused score it replaced stays on the row as `fused_score`.' },
{ since: '0.60.332.0', text: 'One search or query chunk row returns at most 8,000 characters of chunk text by default, ending with the marker that names the read for the rest (an old oversized chunk could return tens of thousands). Pass `snippet_chars: 0` for the full chunk. Evidence blocks (conversations, long-page units) keep their own budget and cap.' },
{ since: '0.60.332.0', text: '`gbrain search --explain` and `gbrain query --explain` now pass explain to the search, so `score_details` reports the arms, RRF and blend that ran; before, every row said `single_arm_path` / `no_query_embedding` even when both arms ran. A CLI search or query whose keyword or vector arm failed or timed out now prints the `degraded_recall` notice on stderr (the `--json` array stays bare), as MCP already did.' },
+ // GBRA-150 (synced-but-not-searchable landing checks). `since` is restamped at the merge slot.
+ { since: '0.60.337.0', id: 'sync_status_blocked_means_source_stopped', text: '`gbrain sync status` now reads `blocked` only when the source cannot advance without a person or an operator, the meaning a sync run\'s drain outcome and a sync job\'s `blocked` progress already had. A file hold that waits on a person while the rest of the source keeps syncing now reads `synced` with the new reason `held_needs_human` (it read `blocked` before); `needs_human`, `next` and the hold rows are unchanged, so a client acting on `needs_human` sees no difference.' },
+ { since: '0.60.337.0', id: 'sources_resolve_path', text: 'New read-only `gbrain sources resolve-path <id> <path...> [--stdin] [--json]` (MCP `sources_resolve_path`, read scope, at most 200 paths) says what gbrain did with each file path of a source by its own rules: the slug sync gives it, whether it is skipped, held, not synced yet, deleted, or a live page, and whether search can find it (`searchable` true, `keyword` or false), with a `why` and a `fix`. Landing checks should call it instead of copying gbrain\'s path-to-slug rules. `gbrain sync status --detail` adds a `landing` block, and the new cheap doctor check `sync_landing_gaps` warns when pages a managed sync committed more than the freshness target ago still cannot be fully searched.' },
+ { since: '0.60.337.0', id: 'sync_status_coherent_7189', text: '`gbrain sync status --json` no longer contradicts itself while a source falls behind (#7189). `freshness` adds `behind` (commits on the checkout HEAD after the last synced commit, and the oldest one\'s age), because its latency samples date only commits that already synced. The `notifier` block adds `drain_holder`: with no notifier running, the process holding the source\'s drain lease is named and no fix is offered while it makes progress, instead of "No resident … watches this source". A `last_error` the source\'s sync has committed a page past now carries `superseded: { at }` and no longer sets `needs_human`, `state` or `next`. New `needs_human_from` says whether `needs_human` comes from a hold or the last error. In `gbrain sources resolve-path`, a large page whose embedding budget is held or capped reads `pending_embedding` with `embedding_hold`, never `keyword_only`, which means `embed_skip`.' },
+ // GBRA-150 (nested typed metafiles become pages): Garry, "take all recommendations" (2026-10-20), answering the proposal to import typed non-root index.md/README.md. `since` is stamped at the merge slot.
+ { since: '0.60.337.0', text: 'Sync now imports a folder-scaffolding file below a source\'s root (`index.md`, `README.md`, `log.md`, `schema.md` or `RESOLVER.md`) as a page when its frontmatter has `type:` or `title:`, for example `projects/acme-example/index.md`. A bare one at any depth and every one at the source root stay skipped. The first sync after the upgrade imports the existing typed files once and deletes or rewrites nothing else; deleting such a file later soft-deletes its page. `gbrain config set sync.metafile_pages off` restores the old skip. Default change approved by Garry, "take all recommendations", 2026-10-20.' },
+ // #7172. `since` is restamped at the merge slot.
+ { since: 'TBD', text: 'A managed put_page, edit_page, add_timeline_entry, add_tag or remove_tag, managed import or sync whose passages need more than 5 vector-index writes (a passage carrying a vector, inserted or renumbered) commits the page first and finishes its passages in post-commit transactions of at most 5 vector-index writes each, instead of writing them all inside the publication, where a slow index could end it 57014 `write_interrupted`. Search sees the page once the last step seals it; until then its receipt says `searchable: "pending"`, and `gbrain projections drain` finishes a page whose writer stopped. A passage whose text is unchanged keeps its row and vector when an entry above it moves it to another index.' },
+ { since: 'TBD', text: 'The embedding step after a managed write no longer re-embeds every passage of a page whose stored embedding signature is missing or in an older format: a passage whose recorded embedding input is still current keeps its vector and the page signature is restamped, so only passages whose text changed reach the embedding provider.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */