Skip to content

v0.21.0 — daemon staleness fixes, server split, prefer_project

Choose a tag to compare

@turbyho turbyho released this 13 Jul 22:03
v0.21.0

Overview

v0.21.0 delivers a new daemon architecture for fw-context watch with correct
staleness detection, server code reorganization into handler modules, a new
prefer_project parameter for lookup_definition, and shared dep-file parsing.
All users of the watch daemon should upgrade — stale detection is now reliable.

Changes

Features

  • Daemon staleness detection overhaul — new daemon.py module replaces
    ad-hoc checks in background.py. Uses PID-file based reindex detection,
    catches files modified before daemon startup, and deduplicates modified files
    by resolved absolute path. fw-context watch status now reports accurate
    Index state (running vs idle) and Modified count drops to 0 after clean
    reindex.
  • Server split — tool implementations moved from server.py to handler
    modules (handlers/maintenance.py, handlers/source.py), keeping the
    FastMCP server entry point focused on registration.
  • prefer_project orderinglookup_definition gets a new prefer_project
    parameter that inserts s.is_project DESC into the ORDER BY clause so
    project-code symbols sort before vendor/SDK symbols when both share the same
    name.
  • Header staleness in get_active_build — when deps_verification is
    "full", get_active_build now reports the count of TUs affected by stale
    dependency headers.
  • Shared dep-file parsingdep_files.py extracted as a shared utility
    used by both the index runner and query-time header staleness detection.

Fixes

  • False "Index: running"_is_bg_reindex_running no longer checks
    watcher.lock, which was always present when the daemon ran (idle included).
    Replaced with reindex.pid written only during active index subprocess.
  • Stale header mtimes after git checkout — Tier 1 mtime fast-path now
    always updates TU stored mtimes and refreshes dependency header mtimes.
    A new _refresh_header_mtimes final pass catches remaining headers whose
    mtime drifted but were never updated (e.g. when .d files are absent).
  • Duplicate entries in _count_modified_files — deduplicated by resolved
    absolute path, keeping the maximum stored mtime. Fixes duplicates from
    files indexed under both absolute and relative path formats.
  • Missed startup files — daemon _staleness_check now calls
    _count_modified_files on startup so files modified before the watcher
    started trigger an immediate index run.
File Change
CLAUDE.md Add GPG-signed commits requirement
src/fw_context_mcp/cli.py Write/remove reindex.pid for standalone index runs
src/fw_context_mcp/config/tools.py Streamline BASE_INSTRUCTIONS (160 to 90 lines)
src/fw_context_mcp/indexer/dep_files.py New — shared dep-file parsing utility
src/fw_context_mcp/indexer/runner.py Tier 1 mtime updates, _refresh_header_mtimes pass
src/fw_context_mcp/mcp/background.py Replace watcher.lock with reindex.pid check
src/fw_context_mcp/mcp/daemon.py New — daemon with correct staleness detection
src/fw_context_mcp/mcp/handlers/maintenance.py Header staleness check in get_active_build
src/fw_context_mcp/mcp/handlers/source.py prefer_project param in lookup_definition
src/fw_context_mcp/mcp/server.py Move tool impls to handler modules
src/fw_context_mcp/mcp/shared/stale.py Deduplicate modified files, drop pathlib resolve
tests/test_incremental_reindex.py Update for new staleness behavior
tests/test_lookup_definition.py New — prefer_project ordering tests

Breaking changes

None.