Skip to content

fix(deps): anchor index resolution to target path; add fresh deps exraction - #79

Merged
VioletCranberry merged 2 commits into
mainfrom
fix/deps-extract-index-resolution
Jun 1, 2026
Merged

fix(deps): anchor index resolution to target path; add fresh deps exraction#79
VioletCranberry merged 2 commits into
mainfrom
fix/deps-extract-index-resolution

Conversation

@VioletCranberry

@VioletCranberry VioletCranberry commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

Two related dependency-extraction safety fixes, discovered while diagnosing why another repository index had thin
dependency data (only workflow-YAML edges, no Python).

  1. CLI index-resolution data-loss bug 🐛

cocosearch deps extract resolved the index name from the caller's cwd, not the target path. All three
resolution steps — config discovery (find_config_file), git derivation (derive_index_from_git), and the derived-name
fallback — ignored the path argument.

Impact: run from a project directory, deps extract /other/repo --fresh resolves to this project's index and wipes its
edges while re-extracting against the wrong files. (index had the same latent bug; fallback_path only masked
it when no cwd config existed.)

Fix:

  • find_config_file(start_dir=None) — anchor config + git-root discovery to a given directory (git-root lookup now
    uses git -C)
  • derive_index_from_git(path=None) — forward the path to get_main_repo_root
  • _resolve_index_name — pass fallback_path into the git step
  • deps_extract_command / index_command — anchor config + index-name resolution to the target codebase path

Backward compatible (new params default to cwd behavior). The read-only deps show/tree/impact/stats commands are
intentionally untouched — they take a relative file arg and are meant to run in-project.

  1. Dashboard "Fresh Extract Deps" ✨

The dashboard "Extract Deps" button only ran incremental extraction, so files unchanged since a stale/broken index
were never re-extracted (the button reported success but did nothing for them). Added a fresh path end to end:

  • /api/extract-deps now accepts a fresh flag, forwarded to extract_dependencies
  • A red "Fresh Extract Deps" button mirrors the existing Reindex / Fresh Index two-button pattern

Testing

  • New unit tests: find_config_file start_dir anchoring (+ git-root variant), derive_index_from_git path forwarding,
    deps_extract_command regression (resolves from target path, not cwd), /api/extract-deps fresh-flag forwarding
    (default + explicit)
  • Full suite green (1257 passing across affected areas), ruff clean
  • E2E: re-ran the exact command that corrupted an index pre-fix (deps extract --fresh, no --name, from a
    different project dir) — now correctly targets the right index and leaves the cwd project's edges untouched

VioletCranberry and others added 2 commits June 1, 2026 13:13
…raction

Two related fixes around dependency extraction safety.

1. CLI index-resolution data-loss bug
   `cocosearch deps extract <path>` (and `index <path>`) resolved the index
   name from the caller's cwd, not the target path. All three resolution
   steps — config discovery, git derivation, and the derived-name fallback —
   ignored the path argument. Run from a project directory, `deps extract
   /other/repo --fresh` would resolve to *this* project's index and wipe its
   edges while re-extracting against the wrong files.

   - find_config_file(start_dir=None): anchor config + git-root discovery to a
     given directory (git-root lookup now uses `git -C`).
   - derive_index_from_git(path=None): forward the path to get_main_repo_root.
   - _resolve_index_name: pass fallback_path into the git derivation step.
   - deps_extract_command / index_command: anchor config and index-name
     resolution to the target codebase path.

   Changes are backward compatible (new params default to cwd behavior); the
   read-only deps show/tree/impact/stats commands are intentionally untouched
   (they take a relative file arg and run in-project).

2. Dashboard "Fresh Extract Deps"
   The dashboard "Extract Deps" button only ran incremental extraction, so
   files unchanged since a broken/stale index never got re-extracted. Added a
   fresh option end to end: /api/extract-deps now accepts a `fresh` flag and
   forwards it to extract_dependencies; a red "Fresh Extract Deps" button
   mirrors the existing Reindex/Fresh Index two-button pattern.

Tests: find_config_file start_dir anchoring, derive_index_from_git path
forwarding, deps_extract_command regression (resolves from target path), and
/api/extract-deps fresh-flag forwarding (default + explicit).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
index_command received the same cwd-anchoring fix as deps_extract_command
but lacked an equivalent regression test. Add one asserting that config
discovery (find_config_file) and index-name resolution (_resolve_index_name
fallback_path) are anchored to the target codebase path, not the caller's
cwd — closing the test-coverage asymmetry between the two commands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@VioletCranberry
VioletCranberry merged commit c657438 into main Jun 1, 2026
5 checks passed
@VioletCranberry
VioletCranberry deleted the fix/deps-extract-index-resolution branch June 1, 2026 13:38
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.

1 participant