Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/capy/belief-ledger-w1' into capy/belief-w1-coverage

garrytan41b5f6702905
diff --cc src/core/belief/ledger.ts
index c76459a099,c3b7cfe33f..47c519f298
--- a/src/core/belief/ledger.ts
+++ b/src/core/belief/ledger.ts
@@@ -61,14 -62,8 +62,14 @@@ export function noteBelief(note: Belief
store.getStore()?.notes.push(note);
}
+/** True when an enclosing batch on this async context already records these slugs (a nested writer must not append them twice). */
+export function beliefBatchCovers(sourceId: string, slugs: readonly string[]): boolean {
+ const outer = store.getStore();
+ return !!outer && outer.opts.sourceId === sourceId && slugs.every(slug => outer.opts.slugs.includes(slug));
+}
+
/** Coverage and purge probes for one source, in one read. */
- export async function readLedgerSource(tx: Pick<BrainEngine, 'executeRaw'>, sourceId: string): Promise<{ incarnation: string; purgeEpoch: number; coverage: string | null; managed: boolean; purgesPossible: boolean } | null> {
+ export async function readLedgerSource(tx: Pick<BrainEngine, 'executeRaw'>, sourceId: string): Promise<{ incarnation: string; purgeEpoch: number; coverage: string | null; purgesPossible: boolean } | null> {
const [row] = await tx.executeRaw<Record<string, unknown>>(`SELECT s.incarnation::text AS incarnation, s.purge_epoch,
(SELECT e.event_type FROM belief_events e WHERE e.source_id = s.id AND e.subject_kind = 'coverage' AND e.subject_key = $2
AND e.source_incarnation = s.incarnation ORDER BY e.id DESC LIMIT 1) AS coverage,