Skip to content

Comments

Clean up stale lock entries when sources removed from config#27

Merged
fbosch merged 6 commits intomasterfrom
copilot/cleanup-lock-entries
Feb 23, 2026
Merged

Clean up stale lock entries when sources removed from config#27
fbosch merged 6 commits intomasterfrom
copilot/cleanup-lock-entries

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Lock entries in docs-lock.json were persisted indefinitely, even after sources were removed from docs.config.json. This created inconsistency with the prune command's behavior and allowed stale metadata to accumulate.

Changes

  • Modified buildLock in src/commands/sync.ts: Filter previous lock sources to only include IDs present in current config before merging sync results
  • Added test coverage: Verify lock entries are removed when sources are deleted and preserved when sources remain

Implementation

const buildLock = async (plan, previous) => {
  const configSourceIds = new Set(plan.sources.map((source) => source.id));
  const sources: Record<string, DocsCacheLockSource> = {};
  
  // Only preserve lock entries for sources still in config
  if (previous?.sources) {
    for (const [id, source] of Object.entries(previous.sources)) {
      if (configSourceIds.has(id)) {
        sources[id] = source;
      }
    }
  }
  
  // Update/add entries for synced sources
  for (const result of plan.results) {
    const prior = sources[result.id];
    sources[result.id] = buildLockSource(result, prior, now);
  }
  // ...
};

The lock file now maintains 1:1 correspondence with the config file after each sync.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: fbosch <6979916+fbosch@users.noreply.github.com>
Copilot AI changed the title [WIP] Add automatic cleanup for lock entries in docs-cache sync Clean up stale lock entries when sources removed from config Feb 18, 2026
Copilot AI requested a review from fbosch February 18, 2026 10:54
@fbosch fbosch marked this pull request as ready for review February 18, 2026 12:05
Copilot AI review requested due to automatic review settings February 18, 2026 12:05
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 18, 2026

Open in StackBlitz

npx https://pkg.pr.new/fbosch/docs-cache@27

commit: 4c21752

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements cleanup of stale lock entries when sources are removed from the configuration file, ensuring the lock file maintains a 1:1 correspondence with the config file after each sync. This aligns the lock file behavior with the prune command's approach of removing cache entries for sources no longer in the config.

Changes:

  • Modified buildLock function to filter previous lock sources, keeping only those present in current config
  • Added comprehensive test coverage for lock entry cleanup and preservation scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/commands/sync.ts Implements lock cleanup logic by filtering previous lock entries based on current config sources
tests/sync-lock-cleanup.test.js Adds tests verifying lock entries are removed when sources are deleted and preserved when sources remain

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fbosch and others added 4 commits February 23, 2026 12:29
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@fbosch fbosch merged commit a161ea0 into master Feb 23, 2026
15 checks passed
@fbosch fbosch deleted the copilot/cleanup-lock-entries branch February 23, 2026 11:49
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