d6d2a24ddc
Applies gofmt to the 18 files that were already unformatted at HEAD (pre-existing debt — 122 insertions / 122 deletions, whitespace plus import-block reorderings only; `git diff -w` confirms no semantic changes). Kept on its own branch so the functional change set (see the review-hardening PR) stays reviewable without formatting noise. Verified: go build, go vet, go test ./... pass on this branch; a merge simulation with the functional branch produces a clean 3-way merge with all tests green. Reviewed-on: #4 Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
24 lines
699 B
Go
24 lines
699 B
Go
package watch
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/david/knox/internal/db"
|
|
)
|
|
|
|
// Reconcile rebuilds all derived state from the observation log: entries are
|
|
// reconstituted via deterministic SQL aggregation, then the auto-threader
|
|
// re-links/re-creates threads idempotently by cluster_key. Returns the threads
|
|
// created and observations linked.
|
|
func Reconcile(kdb *db.KnoxDB) (int, int, error) {
|
|
if _, _, err := kdb.RebuildEntriesFromObservations(); err != nil {
|
|
return 0, 0, fmt.Errorf("rebuild entries: %w", err)
|
|
}
|
|
threader := NewAutoThreader(kdb)
|
|
created, linked, err := threader.AutoThread()
|
|
if err != nil {
|
|
return 0, 0, fmt.Errorf("auto-thread: %w", err)
|
|
}
|
|
return created, linked, nil
|
|
}
|