Skip to content

fix(librarian): re-analyze prose edited via tools and rework analysis scheduling#42

Open
Viscerous wants to merge 2 commits into
tealios:masterfrom
Viscerous:fix/reanalyze-after-tool-prose-edits
Open

fix(librarian): re-analyze prose edited via tools and rework analysis scheduling#42
Viscerous wants to merge 2 commits into
tealios:masterfrom
Viscerous:fix/reanalyze-after-tool-prose-edits

Conversation

@Viscerous

@Viscerous Viscerous commented Jun 23, 2026

Copy link
Copy Markdown

Auto re-analysis only fired from the HTTP route handler, so prose edited by the librarian's own tools (editProse, updateFragment, editFragment) never triggered re-analysis, and the per-passage freshness indicator went stale until the next poll.

  • Shared reanalyzeAfterProseChange() so every edit path (route + tools) schedules re-analysis and marks the freshness index stale.
  • Reworked the scheduler: removed the 2s debounce in favor of a leading-edge, concurrency-guarded coalescer. Analysis (one of the longest steps) starts immediately when idle, and triggers arriving while a run is in flight coalesce to the latest fragment. Guarantees one run per story at a time.
  • Run-scoped hold: while a write-enabled agent run is active, analysis is deferred and fires once on the final state, so a multi-step editing agent triggers a single analysis instead of one per step.
  • Resolved the llm/tools scheduler import cycle by deferring the agents import to the one runtime-only call site.

Tests: tests/librarian/scheduler.test.ts (rewritten for the new model), tests/llm/generation.test.ts.

Fixes: #38
Note: touches the editProse loop, so it conflicts with #43, whichever lands second needs a trivial rebase.

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.

Internal edits to prose don't trigger re-analysis

1 participant