Skip to content

fix(watch): Track configured file counts separately - #95

Merged
JordanCoin merged 1 commit into
JordanCoin:mainfrom
reneleonhardt:fix/configured-state-count
Aug 3, 2026
Merged

fix(watch): Track configured file counts separately#95
JordanCoin merged 1 commit into
JordanCoin:mainfrom
reneleonhardt:fix/configured-state-count

Conversation

@reneleonhardt

Copy link
Copy Markdown
Contributor

What does this PR do?

Tracks configured files separately from the full watch inventory, including live config and .gitignore changes.
Session hooks therefore size agentic coding context from active sandbox filters without changing the legacy file_count field or publishing stale dependency state.

Type of change

  • Bug fix
  • New feature
  • New language support
  • Documentation
  • Other (describe below)

Checklist

  • I've tested this locally with go build && ./codemap .
  • I've read CONTRIBUTING.md (for new language support)
  • I've updated documentation if needed

Additional notes

Verification: go test ./watch ./cmd -count=1.

Developed with carefully directed, manually reviewed AI assistance.

Co-Authored-By: GPT-5.6 Sol codex@openai.com

Co-Authored-By: GPT-5.6 Sol <codex@openai.com>
@JordanCoin

Copy link
Copy Markdown
Owner

Reviewed — this is careful work. Using *int + ConfiguredCount() (int, bool) so a stale state file is distinguishable from a genuine zero is exactly right, and separating FileCount (all tracked) from ConfiguredFileCount (filter-included) fixes a real conflation in the large-repo thresholds.

One functional finding:

refreshConfiguredFiles permanently drops the dependency graph until the daemon restarts. It nils FileGraph, clears DepCtx, and sets HasDeps = false, with the comment "rebuild lazily on restart" — but there's no lazy rebuild anywhere; nothing recomputes it. So editing .codemap/config.json (or touching any .gitignore, since filterControlEvent matches by basename anywhere in the tree) silently kills live hub/importer intelligence for the rest of the daemon's life. Since you're already re-walking in that function, calling computeDeps() behind the same shouldComputeDependencyGraph guard would keep the invariant you're protecting without the cliff.

Minor: isConfiguredFile calls config.Load(d.root) per file event, so a bulk change (branch switch, install) re-reads and re-parses config.json once per file. Worth hoisting alongside the refresh.

Nice catch excluding .codemap/ from ScanConfiguredFiles now that the daemon watches that directory — that would otherwise have inflated the count via its own state writes.

@JordanCoin
JordanCoin merged commit 7c6c168 into JordanCoin:main Aug 3, 2026
12 checks passed
JordanCoin added a commit that referenced this pull request Aug 3, 2026
refreshConfiguredFiles invalidated the dependency graph and left it that
way, with a comment deferring the rebuild to "restart". Nothing rebuilds
it lazily, so a single edit to .codemap/config.json — or a touch of any
.gitignore, which filterControlEvent matches by basename anywhere in the
tree — permanently stripped hub and importer intelligence from the
running daemon. Every hook that reads daemon state silently degraded from
that point on.

Rebuild after invalidating, behind the same shouldComputeDependencyGraph
guard Start uses so large repos still skip the work. computeDeps takes
the graph lock itself, so it is called after the unlock.

TestConfiguredFilterChangeInvalidatesDependencyState asserted the graph
stayed nil, which encoded the defect rather than the intent. Its real
invariant is that state computed under the old filters is discarded, so
it now asserts the stale entries are gone; the published-state check is
unchanged. A new test covers the rebuild, using a sentinel entry so a
rebuilt graph is distinguishable from the startup graph.

Follow-up to #95 by @reneleonhardt.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@reneleonhardt
reneleonhardt deleted the fix/configured-state-count branch August 3, 2026 05:50
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.

2 participants