Skip to content

HerdDigestService

Defined in: src/herd-digest.ts:171

new HerdDigestService(deps): HerdDigestService

Defined in: src/herd-digest.ts:187

HerdDigestServiceDeps

HerdDigestService

currentAttentionFingerprint(): Record<string, string[]>

Defined in: src/herd-digest.ts:471

Fingerprint the herd’s CURRENT attention surface from the live in-memory caches, with the SAME logic generate() uses at spawn time. The route diffs a stored digest’s attentionFingerprint against this to derive staleCount (how far the herd drifted). Cheap + pure-classification: no spawn, no DB write; reads the injected snapshots once. stalledSessionIds/mergeTrainState are optional, so a herd missing them still scores.

Record<string, string[]>


generate(opts?): Promise<GenerateResult>

Defined in: src/herd-digest.ts:268

Assemble the herd state, spawn a rundown agent, and write a generating row for today’s dayKey. Shared by sweep (auto) and regenerate (on-demand).

Returns: “in-flight” — a generating row already exists for today, or a spawn is mid-flight. “empty” — the herd has no active sessions at all; nothing to triage, no spawn. “started” — spawn launched; a generating row is written for today. “error” — herdr.start failed (or api-key fail-closed); tmpdir cleaned, no row.

NOTE: a herd with active sessions but ZERO attention-bearing ones still spawns — the digest can legitimately say “all clear”. Only a completely empty herd short-circuits. Does NOT throw — a spawn failure self-heals to “error”. opts.force (regenerate) bypasses the existing-generating-row skip.

boolean

Promise<GenerateResult>


regenerate(): Promise<GenerateResult>

Defined in: src/herd-digest.ts:393

On-demand force (the ⟳ button): re-spawn today’s digest even if it’s already ready.

Promise<GenerateResult>


snapshot(): HerdDigest | null

Defined in: src/herd-digest.ts:499

Latest digest for client bootstrap (null when none generated yet).

HerdDigest | null


sweep(): Promise<void>

Defined in: src/herd-digest.ts:237

Daily auto-spark — the “first look of the day”. Fires generate() at most once per calendar day when ALL of: (a) no ready or generating digest exists for today’s dayKey, (b) the operator is present (isActive()), and (c) the herd is non-empty (≥1 active session). Idempotent/safe to call every tick: a failed digest for today is allowed to re-spark (the day’s look is still owed); a ready/generating one is not.

Promise<void>


tick(): Promise<void>

Defined in: src/herd-digest.ts:403

Finalize any generating digest whose verdict file is ready or that has timed out. Restart-safe: reads from the DB, not memory.

Promise<void>