HerdDigestService
Defined in: src/herd-digest.ts:171
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HerdDigestService(
deps):HerdDigestService
Defined in: src/herd-digest.ts:187
Parameters
Section titled “Parameters”Returns
Section titled “Returns”HerdDigestService
Methods
Section titled “Methods”currentAttentionFingerprint()
Section titled “currentAttentionFingerprint()”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.
Returns
Section titled “Returns”Record<string, string[]>
generate()
Section titled “generate()”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.
Parameters
Section titled “Parameters”force?
Section titled “force?”boolean
Returns
Section titled “Returns”Promise<GenerateResult>
regenerate()
Section titled “regenerate()”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.
Returns
Section titled “Returns”Promise<GenerateResult>
snapshot()
Section titled “snapshot()”snapshot():
HerdDigest|null
Defined in: src/herd-digest.ts:499
Latest digest for client bootstrap (null when none generated yet).
Returns
Section titled “Returns”HerdDigest | null
sweep()
Section titled “sweep()”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.
Returns
Section titled “Returns”Promise<void>
tick()
Section titled “tick()”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.
Returns
Section titled “Returns”Promise<void>