Skip to content

fix(daemon): preserve server-owned counters on rewrite; wire fired co…#22

Merged
nickroci merged 1 commit into
mainfrom
fix/scholar-counter-preservation
Jun 4, 2026
Merged

fix(daemon): preserve server-owned counters on rewrite; wire fired co…#22
nickroci merged 1 commit into
mainfrom
fix/scholar-counter-preservation

Conversation

@nickroci

@nickroci nickroci commented Jun 4, 2026

Copy link
Copy Markdown
Owner

…unter

Two bookkeeping-counter bugs in the knowledge daemon:

  1. Counter clobber. LLM entry rewrites (update_entry / merge_entries / abstract) wrote the model's frontmatter verbatim, overwriting the fired-helpful and reinforced counters the daemon had just bumped on disk. The fired-helpful high-water dedup then froze the loss permanently. The executor is now the single source of truth for the server-owned bookkeeping fields (fired, fired-helpful, last_fired_helpful, reinforced, last_reinforced, last_surfaced, created): on any rewrite that replaces an existing entry it forces those values from the prior on-disk entry onto the proposed body and discards whatever the model emitted. Prose and all other frontmatter stay LLM-owned.

  2. Dead fired counter. fired had no writer (0 on every entry). Priming now calls decay.record_surface() per surfaced entry, which increments fired per surface event (not daily-gated) and stamps last_surfaced in one atomic write, so fired-helpful <= fired holds.

Adds regression tests for both (executor preservation across update/merge/deprecate/abstract; per-event fired increment; invariant guard). Fix-forward only: no existing knowledge data was modified.

…unter

Two bookkeeping-counter bugs in the knowledge daemon:

1. Counter clobber. LLM entry rewrites (update_entry / merge_entries /
   abstract) wrote the model's frontmatter verbatim, overwriting the
   fired-helpful and reinforced counters the daemon had just bumped on
   disk. The fired-helpful high-water dedup then froze the loss
   permanently. The executor is now the single source of truth for the
   server-owned bookkeeping fields (fired, fired-helpful,
   last_fired_helpful, reinforced, last_reinforced, last_surfaced,
   created): on any rewrite that replaces an existing entry it forces
   those values from the prior on-disk entry onto the proposed body and
   discards whatever the model emitted. Prose and all other frontmatter
   stay LLM-owned.

2. Dead `fired` counter. `fired` had no writer (0 on every entry).
   Priming now calls decay.record_surface() per surfaced entry, which
   increments `fired` per surface event (not daily-gated) and stamps
   last_surfaced in one atomic write, so fired-helpful <= fired holds.

Adds regression tests for both (executor preservation across
update/merge/deprecate/abstract; per-event fired increment; invariant
guard). Fix-forward only: no existing knowledge data was modified.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nickroci nickroci merged commit 3e0f678 into main Jun 4, 2026
4 checks passed
@nickroci nickroci deleted the fix/scholar-counter-preservation branch June 4, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant