feat: daemon mode so models load once across CLI invocations - #3
Merged
Conversation
Adds an auto-spawned `noirdoc-daemon` that holds the spaCy + GLiNER models
in memory, eliminating the ~10s cold-start per `noirdoc redact` call.
- AF_UNIX socket + JSON-lines protocol under `~/.noirdoc/`
- Pydantic-validated envelope (`hello`, `redact`, `status`, `shutdown`)
- Single asyncio lock for FIFO serialization; queue depth tracked
- Idle shutdown after 10 min (configurable via NOIRDOC_DAEMON_IDLE_SECONDS)
- Version handshake: CLI shuts down + respawns mismatched daemon
- Transparent fallback to in-process Redactor on any daemon failure
- New `noirdoc daemon {status,stop,restart,logs}` subcommands
- `--no-daemon` / `NOIRDOC_NO_DAEMON` opt-out for `noirdoc redact`
Cold-path benchmark: 2.97s -> 0.07s warm (~40x). Models cached in the
daemon; namespaces re-read from disk per request to avoid coherence bugs.
comppaz
added a commit
that referenced
this pull request
Apr 27, 2026
The v0.1.1 tag shipped without a corresponding changelog section, so the daemon (PR #3) was undocumented and `ns summary` (PR #2) was still parked under [Unreleased]. Backfill the section now so the GitHub release link (which dereferences to CHANGELOG.md) and future readers see what 0.1.1 actually contained. Documentation-only; no code change, no re-tag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
noirdoc-daemonkeeps spaCy + GLiNER models in memory, eliminating the ~10 s cold-start pernoirdoc redact(cold 2.97 s → warm 0.07 s, ~40×).~/.noirdoc/, pydantic-validated envelope (hello,redact,status,shutdown).asyncio.Lockenforces FIFO serialization; idle shutdown after 10 min (configurable viaNOIRDOC_DAEMON_IDLE_SECONDS).Redactor.noirdoc daemon {status,stop,restart,logs}and a--no-daemon/NOIRDOC_NO_DAEMONopt-out fornoirdoc redact.Test plan
pytest tests/daemon/— 28/28 passing (protocol round-trips, spawn / stale-socket cleanup, serial queue + queue-depth, version handshake, fallback)noirdoc daemon status→ not running, twonoirdoc redactcalls back-to-back, then idle-shutdown after 10 minkill -9mid-request, confirm fallback warning + completion