Skip to content

Config file not updated when new include/exclude patterns are added in a new release #270

@marcelovani

Description

@marcelovani

Problem

When a new release adds include/exclude patterns to DEFAULT_CONFIG (e.g. new file extensions or framework-specific paths), existing projects are not affected. The .codegraph/config.json was written at init time and is never updated — so new patterns are silently ignored until the user manually reinitialises.

This was discovered while working on Drupal support (#268). The new release added:

  • Include patterns: **/*.module, **/*.install, **/*.theme, **/*.inc, **/*.routing.yml, **/*.twig
  • Exclude patterns: **/web/core/**, **/web/modules/contrib/**, **/web/themes/contrib/**

After upgrading and reindexing, the file/node/edge counts were identical to before — because the existing config.json had none of the new patterns. The only workaround today is to delete config.json and run codegraph init -i again, which is non-obvious and undocumented.

Note: the database schema already has a proper migration system (migrations.ts) that auto-applies changes on next run. The config file has no equivalent.

Proposed Solution

Add a config migration mechanism similar to the existing DB migrations:

  1. Bump config.version when DEFAULT_CONFIG patterns change.
  2. On init / serve startup, compare the stored version against the current DEFAULT_CONFIG version.
  3. When the stored version is older, merge in any new include/exclude patterns from the default (without overriding user customisations).
  4. Persist the updated config and bump the version.

Alternatively, a simpler short-term fix would be a codegraph config reset command that regenerates config.json from defaults while preserving user-added custom patterns.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions