feat: ingest Brevier reading copies and phone notes (#53)
build / test (push) Successful in 3m51s
build / image (push) Successful in 37s

feat: ingest Brevier reading copies and phone notes (#53)

Co-authored-by: David Gwilliam <dhgwilliam@gmail.com>
Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #53.
This commit is contained in:
2026-11-09 00:31:31 +00:00
committed by david
parent aa8bfa61e1
commit 6242f21e3d
9 changed files with 834 additions and 13 deletions
+59 -5
View File
@@ -29,8 +29,10 @@ const (
logDebounce = 30 * time.Second
karakeepInterval = 30 * time.Minute
bookorbitInterval = 30 * time.Minute
healthInterval = 15 * time.Minute
snippetInterval = 10 * time.Minute
// Brevier's archive changes only when a page is read, so an hour is plenty.
brevierInterval = 1 * time.Hour
healthInterval = 15 * time.Minute
snippetInterval = 10 * time.Minute
)
// fileState is a cheap identity for a file: an unchanged size+mtime means the
@@ -230,6 +232,7 @@ func (w *Watcher) Start() error {
opencodeTicker := time.NewTicker(opencodeInterval)
karakeepTicker := time.NewTicker(karakeepInterval)
bookorbitTicker := time.NewTicker(bookorbitInterval)
brevierTicker := time.NewTicker(brevierInterval)
healthTicker := time.NewTicker(healthInterval)
threadTicker := time.NewTicker(10 * time.Minute)
snippetTicker := time.NewTicker(snippetInterval)
@@ -244,16 +247,16 @@ func (w *Watcher) Start() error {
// Ingestion only runs where the sources exist. A node with no local
// sources (KNOX_LOCAL_SOURCES=none) leaves these nil: nil channels block
// forever, so the select never fires for them.
var browserC, giteaC, gitC, opencodeC, karakeepC, bookorbitC, healthC <-chan time.Time
var browserC, giteaC, gitC, opencodeC, karakeepC, bookorbitC, brevierC, healthC <-chan time.Time
if LocalSourcesEnabled() {
browserC, giteaC, gitC = browserTicker.C, giteaTicker.C, gitTicker.C
opencodeC, karakeepC, bookorbitC = opencodeTicker.C, karakeepTicker.C, bookorbitTicker.C
healthC = healthTicker.C
brevierC, healthC = brevierTicker.C, healthTicker.C
} else {
log.Printf("[knox] KNOX_LOCAL_SOURCES=none: local ingest disabled, derivation still active")
}
var browserRunning, giteaRunning, gitRunning, threadRunning, gossipRunning atomic.Bool
var opencodeRunning, karakeepRunning, bookorbitRunning, healthRunning, snippetRunning atomic.Bool
var opencodeRunning, karakeepRunning, bookorbitRunning, brevierRunning, healthRunning, snippetRunning atomic.Bool
for {
select {
@@ -347,6 +350,14 @@ func (w *Watcher) Start() error {
defer bookorbitRunning.Store(false)
w.ingestBookOrbit()
}()
case <-brevierC:
if !brevierRunning.CompareAndSwap(false, true) {
continue
}
go func() {
defer brevierRunning.Store(false)
w.ingestBrevier()
}()
case <-healthC:
if !healthRunning.CompareAndSwap(false, true) {
continue
@@ -804,6 +815,49 @@ func (w *Watcher) ingestBookOrbit() {
}
}
// ingestBrevier pulls the local Brevier archive (pages that were read) and any
// notes exported from the phone into a drop directory.
func (w *Watcher) ingestBrevier() {
results, err := ingest.NewBrevierIngester().IngestAll()
if err != nil {
log.Printf("[knox] brevier ingest error: %v", err)
return
}
if len(results) == 0 {
return
}
var newCount, updated int
for _, result := range results {
_, isNew, err := w.knoxDB.RecordObservation(db.ObservationRecord{
Fingerprint: result.Fingerprint,
SourceID: result.SourceID,
SourcePath: result.SourcePath,
Project: result.Project,
ContentType: result.ContentType,
Title: result.Title,
Summary: result.Summary,
Content: result.Content,
CreatedAt: result.CreatedAt,
Confidence: result.Confidence,
IngesterVersion: result.IngesterVersion,
Trigger: "brevier_timer",
Provenance: ingest.ProvenanceJSON(result.Provenance),
ContentHash: result.ContentHash,
})
if err != nil {
continue
}
if isNew {
newCount++
} else {
updated++
}
}
if newCount > 0 || updated > 0 {
log.Printf("[knox] brevier: %d new, %d updated", newCount, updated)
}
}
// checkSkillsHealth warns when the skills git repo looks broken — the skills
// MCP auto-commits/pushes but hides git errors, so silent breakage (corrupt
// objects, unpushed commits, low disk) would otherwise go unnoticed.