MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / application_watch_status

Function application_watch_status

src/daemon/application.c:634–666  ·  view source on GitHub ↗

index_status watch visibility (#2167). The physical watcher is the truth for * "watched"; the reasons explain the documented scope: only an MCP session's * own project is watched, and only while that session is open. Takes the * application mutex and the watcher lock one after the other, never nested. */

Source from the content-addressed store, hash-verified

632 * own project is watched, and only while that session is open. Takes the
633 * application mutex and the watcher lock one after the other, never nested. */
634static void application_watch_status(void *context, const char *project,
635 cbm_mcp_watch_status_t *out) {
636 cbm_daemon_application_session_t *session = context;
637 cbm_daemon_application_t *application = session ? session->application : NULL;
638 if (!application || !application->watcher) {
639 out->reason = "watcher_disabled";
640 return;
641 }
642 cbm_watcher_project_info_t info;
643 if (cbm_watcher_project_info(application->watcher, project, &info)) {
644 out->watched = true;
645 out->strategy = application_watch_strategy_name(info.strategy);
646 out->poll_interval_ms = info.poll_interval_ms;
647 out->last_scan_unix_s = info.last_scan_unix_s;
648 return;
649 }
650 const char *session_project = cbm_mcp_server_session_project(session->mcp);
651 if (!session_project || strcmp(session_project, project) != 0) {
652 out->reason = "not_session_project";
653 return;
654 }
655 if (application->config &&
656 !cbm_config_get_bool(application->config, CBM_CONFIG_AUTO_WATCH, true)) {
657 out->reason = "auto_watch_off";
658 return;
659 }
660 /* Only MCP sessions run background initialization; a one-shot CLI command
661 * never holds a watch across calls. */
662 cbm_mutex_lock(&application->mutex);
663 bool mcp_session = session->background_eligible;
664 cbm_mutex_unlock(&application->mutex);
665 out->reason = mcp_session ? "not_registered" : "cli_session";
666}
667
668static void application_refresh_watch(cbm_daemon_application_session_t *session) {
669 if (!session || !session->application) {

Callers

nothing calls this directly

Calls 6

cbm_watcher_project_infoFunction · 0.85
cbm_config_get_boolFunction · 0.85
cbm_mutex_lockFunction · 0.85
cbm_mutex_unlockFunction · 0.85

Tested by

no test coverage detected