Skip to content

feat(config): add watcher_enabled config key to disable the background watcher (#335)#1105

Open
nguiaSoren wants to merge 1 commit into
DeusData:mainfrom
nguiaSoren:feat/335-watcher-enabled-config
Open

feat(config): add watcher_enabled config key to disable the background watcher (#335)#1105
nguiaSoren wants to merge 1 commit into
DeusData:mainfrom
nguiaSoren:feat/335-watcher-enabled-config

Conversation

@nguiaSoren

Copy link
Copy Markdown
Contributor

Summary

Adds a persistent watcher_enabled config key (default true) that fully
disables the background watcher when set to false. Closes #335.

Per the maintainer's contract on #335: watcher_enabled defaults to true,
false prevents the watcher thread from starting and from registering
projects, and manual index_repository continues to work normally. Scope is
limited to this one switch — no other watcher policy changes.

Why (and how it differs from auto_watch)

auto_watch (default true) already gates per-session registration — but
the watcher thread still runs idle even with auto_watch=false. #335 asks
for a way to stop the watcher entirely (the doc-heavy-repo use case: every save
churns the graph baseline). watcher_enabled is that master switch: when
false, main() never creates the watcher, so the poll thread never starts and
nothing is registered. auto_watch is left unchanged as the finer-grained
per-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.cCBM_CONFIG_WATCHER_ENABLED
    ("watcher_enabled") plus a small NULL-safe predicate
    cbm_config_watcher_enabled(cfg) (returns the persisted bool, default true).
    Listed in config usage help and config list output, alongside the sibling
    keys.
  • src/main.c — gate watcher creation + set_watcher on the predicate; the
    existing thread-create is already gated on g_watcher, so a disabled watcher
    means no thread and (via the existing NULL guard in
    register_watcher_if_enabled) no registration. cbm_mcp_server_set_config
    stays outside the gate
    so auto_index / auto_watch still read config when
    the watcher is off. Logs watcher.disabled reason=config when skipped.
  • tests/test_cli.ccli_config_watcher_enabled_default_and_persist
    drives the predicate main() gates on: default on, false/0/off disable,
    true/1/on re-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 — document watcher_enabled, and add
    the previously-missing auto_watch row so the watcher knobs are described
    together.

Verification

  • Clean scripts/test.sh (ASan + UBSan) green: 6329 passed, 1 skipped,
    including the new test.
  • Behavioral proof on the built binary (isolated CBM_CACHE_DIR):
    config set watcher_enabled false → server logs watcher.disabled reason=config and no watcher thread starts; default/true → watcher starts
    normally (watcher.disabled count 0); manual index_repository unaffected.
  • No Makefile.cbm change (all touched files already compiled); no config set
    allowlist to update; no CHANGELOG in the repo.

All commits are DCO signed-off.

…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>
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.

Add config key to disable file watcher

1 participant