Skip to content

feat(startup): opt-in auto-resume of all indexed projects#72

Merged
giancarloerra merged 2 commits into
mainfrom
feat/auto-resume-all-projects
Jun 11, 2026
Merged

feat(startup): opt-in auto-resume of all indexed projects#72
giancarloerra merged 2 commits into
mainfrom
feat/auto-resume-all-projects

Conversation

@giancarloerra

@giancarloerra giancarloerra commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

On server startup, auto-resume (file watcher plus incremental catch-up update) can now cover every indexed project instead of only the one at process.cwd(). Two opt-in environment variables control it; with both unset, behavior is unchanged. This closes the gap where per-session MCP clients (Claude Code and similar) lose the watchers of every project not opened in the current session, leaving their indexes stale until a manual codebase_watch start.

Changes

  • autoResumeIndexedProjects (src/services/startup.ts) now supports three modes:
    • Default (unchanged): resume only the current working directory.
    • SOCRATICODE_AUTO_RESUME_PROJECTS=path1,path2: resume an explicit comma-separated list (comma matches the existing SOCRATICODE_LINKED_PROJECTS convention). Takes precedence over SOCRATICODE_AUTO_RESUME.
    • SOCRATICODE_AUTO_RESUME=all: resume every indexed project whose Qdrant metadata has a stored path.
  • Multi-project resume is strictly sequential: each project's catch-up (incremental update or interrupted-index recovery) completes before the next project starts, so N projects never stampede the embedding provider with concurrent re-embeds.
  • Every skipped project is logged loudly at warn level: directory does not exist, path not indexed, collection has no stored path (indexed before path tracking), or an unrecognized SOCRATICODE_AUTO_RESUME value (which falls back to the default mode with a warning).
  • The single-project resume logic is extracted into a resumeProject helper; all existing log messages, guard ordering, and the default-mode flow are preserved verbatim. Qdrant collections are fetched once per startup instead of per project.
  • One project failing to resume does not stop the remaining projects.
  • README: two new rows in the Indexing Behaviour env table plus a pointer from the watcher FAQ entry.

Existing safety machinery is reused, not duplicated: cross-process watch locks prevent concurrent sessions from double-watching a repo, a failed watcher subscribe on a stale path logs and releases its lock, and repeatedly erroring watchers self-stop.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test coverage improvement

Testing

  • Unit tests pass (npm run test:unit): 840/840, including 12 new tests
  • Integration tests pass (npm run test:integration) — if applicable
  • TypeScript compiles cleanly (npx tsc --noEmit)
  • New tests added for new/changed functionality

The 12 new tests in tests/unit/startup.test.ts encode the contract, not just coverage: strict sequencing is proven by holding project A's catch-up promise open and asserting project B is untouched until it resolves; precedence of the explicit list over =all is asserted via metadata never being consulted; each skip path (missing directory, unindexed explicit entry at warn level, no stored path, vanished stored path, empty list, unrecognized mode value) asserts its specific warn log; failure isolation is proven by making one project's status lookup throw and asserting the next still resumes. The 25 pre-existing startup tests pass unchanged, pinning the default mode exactly.

Checklist

  • My code follows the existing code style and conventions
  • I have added/updated JSDoc comments where appropriate
  • I have updated documentation (README.md / DEVELOPER.md) if needed
  • I have addressed all CodeRabbit review comments (or marked as resolved with explanation)
  • I have read the Contributing Guide
  • I agree to the Contributor License Agreement

Related issues

Fixes #70

Summary by CodeRabbit

  • New Features

    • Multi-project auto-resume at startup: opt-in via two new environment variables, resumes indexed projects sequentially, skips missing/invalid paths, deduplicates entries, and logs progress/warnings.
  • Documentation

    • README and FAQ updated with guidance on the new environment variables and how to resume all indexed repositories at startup.
  • Tests

    • Added unit tests covering multi-project resume scenarios and failure/skip behaviors.

SOCRATICODE_AUTO_RESUME=all resumes the file watcher and incremental
catch-up for every indexed project with a stored path on server
startup. SOCRATICODE_AUTO_RESUME_PROJECTS accepts an explicit
comma-separated list and takes precedence. Default (both unset) keeps
the original cwd-only behavior.

Multi-project resume is strictly sequential so N projects never run
concurrent embedding catch-ups, and every skipped project (missing
directory, no stored path, not indexed) is logged at warn level.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5835adce-6420-4e4a-92bc-b1f91533db69

📥 Commits

Reviewing files that changed from the base of the PR and between f3362bb and fa4dd92.

📒 Files selected for processing (2)
  • src/services/startup.ts
  • tests/unit/startup.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/services/startup.ts
  • tests/unit/startup.test.ts

📝 Walkthrough

Walkthrough

Adds environment-variable-driven multi-project auto-resume for file watchers (explicit list via SOCRATICODE_AUTO_RESUME_PROJECTS or all indexed via SOCRATICODE_AUTO_RESUME=all), refactors per-project resume into awaited sequential flows with recovery and incremental catch-up, and adds unit tests and README docs.

Changes

Multi-project auto-resume implementation

Layer / File(s) Summary
Documentation of auto-resume environment variables
README.md
SOCRATICODE_AUTO_RESUME and SOCRATICODE_AUTO_RESUME_PROJECTS are documented and FAQ updated to point users to these variables for multi-repo resume at startup.
Entry-point env dispatch and default behavior
src/services/startup.ts
Call-time reading of SOCRATICODE_AUTO_RESUME / SOCRATICODE_AUTO_RESUME_PROJECTS, branching to explicit-list, all-indexed, or default single-project resume, and non-fatal top-level warning wrapping.
Resume explicit list and all-indexed discovery
src/services/startup.ts
resumeProjectList parses, resolves, deduplicates, and validates explicit project paths and resumes them sequentially; resumeAllIndexedProjects discovers indexed collections in Qdrant, loads stored project metadata, filters/matches on-disk paths, deduplicates, and resumes sequentially.
Per-project sequential resume and recovery
src/services/startup.ts
resumeProject centralizes per-project logic: collection existence checks, interrupted-index detection, awaited indexProject recovery (no watcher until recovery completes), conditional watcher start, and awaited updateProjectIndex with try/catch non-fatal logging.
Test infrastructure and multi-project test suite
tests/unit/startup.test.ts
Adds fs/os/path imports, expands Qdrant mock with getProjectMetadata, clears env between tests, and adds temp-dir based tests covering explicit-list and all-indexed modes, sequencing, deduplication, logging, failure isolation, and fallback behaviors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 In morning dew I hop and see,
I wake each watcher, one, two, three.
Env vars point the way I roam,
Sequential paths bring projects home.
Little paws restart the code — hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature: opt-in auto-resume capability for all indexed projects on startup, which directly addresses the core change in the PR.
Description check ✅ Passed The description covers all template sections: Summary, Changes, Type of change (marked), Testing (marked with results), and Checklist (completed). Content is detailed and addresses the implementation across multiple files.
Linked Issues check ✅ Passed The PR fully implements the requirements from issue #70: adds opt-in multi-project auto-resume via two environment variables (SOCRATICODE_AUTO_RESUME and SOCRATICODE_AUTO_RESUME_PROJECTS), maintains sequential processing, reuses existing safety mechanisms, and provides warn-level logging for skipped projects.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objectives: implementation of multi-project auto-resume in startup.ts, comprehensive test coverage in startup.test.ts, and documentation updates in README.md. No unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/auto-resume-all-projects

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/services/startup.ts`:
- Around line 271-283: The current flow calls startWatching(resolvedPath) before
the try/catch and if it throws the subsequent updateProjectIndex(resolvedPath)
is skipped; modify the code so failures to start the watcher don't prevent the
incremental update: wrap the startWatching call in a safe try/catch (or move it
inside the existing try) that catches and logs errors from startWatching (using
logger) but does not rethrow, and ensure updateProjectIndex(resolvedPath) still
runs inside the try block so the incremental re-embed proceeds even if
isWatching/startWatching fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 842f5b05-20b6-422a-912b-97a8b18637e9

📥 Commits

Reviewing files that changed from the base of the PR and between fcf74c0 and f3362bb.

📒 Files selected for processing (3)
  • README.md
  • src/services/startup.ts
  • tests/unit/startup.test.ts

Comment thread src/services/startup.ts
…rows

startWatching can throw outside its internal guard (lock-file writes,
gitignore reads). Wrap it so a watcher failure degrades to a warning
instead of skipping the project's catch-up update, which would leave
the index stale.
@giancarloerra giancarloerra merged commit 72073c3 into main Jun 11, 2026
5 checks passed
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.

Auto-resume file watchers for all indexed projects, not only cwd

1 participant