2.4 KiB
2.4 KiB
type: module
path: "src/batch.ts"
status: active
language: typescript
purpose: "Index both corpora against the journal DB; produce match rows + recommendations; build per-row outputs."
maintainer: Kaysser Kayyali
last_updated: 2026-06-22
linked_issues: []
depends_on: content-hash, foundry-block, db.ts, toObsidian.ts
used_by: server, cli
tags: [module]
created: 2026-06-22
updated: 2026-06-22
batch
src/batch.ts — indexAll, recommend, and the row builders (seedRow, syncRow,
rePullRow, importRow). See index-recommend.
indexAll(db, ccDir, refinedDir, refinedOverlay?, ccOverlay?)
Walks refined + cc dirs (with dev-mode overlays), reads each file's meta, matches by
basename (canonical — the exporter names cc files by entry name), with uuid fallback
for curated notes whose filename differs but are already linked by foundry.cc_uuid. Produces:
matched, ccOnly, refinedOnly, counts, byRecommendation. In dev mode the server
passes the <out>/refined + <out>/cc mirrors as overlays so dev writes are reflected.
recommend(params) → Recommendation
refined-only → review
cc-only (entry?) → import : review
matched-unlinked → review
matched+linked, !seeded → seed
!hasCc | !ccSynced → sync-cc
refinedChanged && ccChanged → conflict
refinedChanged → sync-cc (vault newer → push)
ccChanged → repull (cc/foundry newer → pull)
else → in-sync
refinedChanged = note's foundry.contentHash != note body hash (vault newer than last
baseline). ccChanged = cc file's cc_sync_hash != cc body hash. Both compare against
LOCAL baselines, not live Foundry.
Row builders
seedRow— inject/refresh thefoundry:block from the journal entry (curation untouched).syncRow— regenerate cc.md from the refined note AND refresh the refinedfoundry:block; baselines both sides.rePullRow— regenerate the refined body from Foundry (entryToObsidian(row.entry, …)), preserving curated type/aliases/status tags. Uses the snapshotrow.entry.importRow— cc-only entry → new un-curated refined note underrefined/imported/<folder>/.
Notes / gotchas
row.entrycomes fromdb.byId(ccId)— the LevelDB snapshot, not live Foundry. So pull ops reflect the snapshot; live Foundry edits need a fresh snapshot (docker-stop full index) or a future live-pull path. See 003-relay-no-journal-db-no-docker-stop.