feat(config): add watcher_enabled config key to disable the background watcher (#335)#1105
Open
nguiaSoren wants to merge 1 commit into
Open
feat(config): add watcher_enabled config key to disable the background watcher (#335)#1105nguiaSoren wants to merge 1 commit into
nguiaSoren wants to merge 1 commit into
Conversation
…tcher (DeusData#335) Add a persistent `watcher_enabled` config key (default true). When false, main() skips creating the background watcher entirely: the poll thread never starts and no projects are registered. Manual index_repository is unaffected, and the config wiring stays unconditional so auto_index / auto_watch keep working even when the watcher is off. This is distinct from auto_watch, which only gates per-session registration while the watcher IS running. watcher_enabled is the master switch that stops the thread from starting at all — the request in DeusData#335 (doc-heavy repos where every save churns the graph baseline). - cli.h/cli.c: CBM_CONFIG_WATCHER_ENABLED key + cbm_config_watcher_enabled() predicate (NULL-safe, default true), shown in `config` help + `config list`. - main.c: gate watcher creation + set_watcher on the predicate; keep cbm_mcp_server_set_config outside the gate so auto_index still reads config. Log watcher.disabled when skipped. - test_cli.c: cli_config_watcher_enabled_default_and_persist drives the predicate main() gates on — default on, disable/re-enable variants, persistence across reopen, and a NULL-config default (a config-store failure must never silently disable the watcher). - docs: document watcher_enabled, and add the previously-undocumented auto_watch row to CONFIGURATION.md so the watcher knobs are described together; README example. Closes DeusData#335. Signed-off-by: soren <nguiasoren@gmail.com>
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
Adds a persistent
watcher_enabledconfig key (defaulttrue) that fullydisables the background watcher when set to
false. Closes #335.Per the maintainer's contract on #335:
watcher_enableddefaults totrue,falseprevents the watcher thread from starting and from registeringprojects, and manual
index_repositorycontinues to work normally. Scope islimited to this one switch — no other watcher policy changes.
Why (and how it differs from
auto_watch)auto_watch(defaulttrue) already gates per-session registration — butthe watcher thread still runs idle even with
auto_watch=false. #335 asksfor a way to stop the watcher entirely (the doc-heavy-repo use case: every save
churns the graph baseline).
watcher_enabledis that master switch: whenfalse,main()never creates the watcher, so the poll thread never starts andnothing is registered.
auto_watchis left unchanged as the finer-grainedper-session registration control. Both are now documented together.
(Note: the watcher polls for git changes now, not raw mtime as the original
0.6.0-era issue described; the user-visible concern — auto-reindex churn — is the
same, and this switch addresses it.)
The change
src/cli/cli.h/src/cli/cli.c—CBM_CONFIG_WATCHER_ENABLED(
"watcher_enabled") plus a small NULL-safe predicatecbm_config_watcher_enabled(cfg)(returns the persisted bool, defaulttrue).Listed in
configusage help andconfig listoutput, alongside the siblingkeys.
src/main.c— gate watcher creation +set_watcheron the predicate; theexisting thread-create is already gated on
g_watcher, so a disabled watchermeans no thread and (via the existing NULL guard in
register_watcher_if_enabled) no registration.cbm_mcp_server_set_configstays outside the gate so
auto_index/auto_watchstill read config whenthe watcher is off. Logs
watcher.disabled reason=configwhen skipped.tests/test_cli.c—cli_config_watcher_enabled_default_and_persistdrives the predicate
main()gates on: default on,false/0/offdisable,true/1/onre-enable, persistence across reopen, and a NULL-config default(a config-store failure must never silently disable the watcher). The existing
dump_verify-style tests feed synthetic values; this exercises the real seam.docs/CONFIGURATION.md/README.md— documentwatcher_enabled, and addthe previously-missing
auto_watchrow so the watcher knobs are describedtogether.
Verification
scripts/test.sh(ASan + UBSan) green: 6329 passed, 1 skipped,including the new test.
CBM_CACHE_DIR):config set watcher_enabled false→ server logswatcher.disabled reason=configand no watcher thread starts; default/true→ watcher startsnormally (
watcher.disabledcount 0); manualindex_repositoryunaffected.Makefile.cbmchange (all touched files already compiled); noconfig setallowlist to update; no CHANGELOG in the repo.
All commits are DCO signed-off.