Add a CLI option to control stale-index warnings
Author: nayar-900Created Sep 1, 2026Updated Sep 7, 2026
Labelsenhancement
Area
Other
Problem or opportunity
GitNexus checks whether the indexed repository is stale relative to the current Git HEAD and surfaces staleness information. However, users running GitNexus in scripts, CI environments, or automated workflows may want different behavior depending on the context.
For example, an interactive user may want a visible warning when the index is stale, while an automated workflow may prefer to suppress the warning or explicitly fail when stale data is detected.
Currently, there is no simple CLI-level option to control how stale-index detection is handled.
Proposed solution
Add a CLI option that allows users to control stale-index handling for commands that rely on the index.
For example:
gitnexus query "authentication" --stale-policy warn
gitnexus query "authentication" --stale-policy ignore
gitnexus query "authentication" --stale-policy error
### Alternatives considered
**Alternatives considered**
```markdown
One alternative is to rely on environment variables or configuration files for this behavior. However, a CLI option is easier to discover, works well in CI/scripts, and allows different invocations to use different policies without modifying persistent configuration.
Another alternative is to automatically re-index whenever the repository is stale. This could unexpectedly trigger expensive analysis and embedding work, so automatic re-indexing should remain separate from stale-index policy.
### Acceptance criteria
- [ ] A `--stale-policy` CLI option is available for commands that consume the repository index.
- [ ] `warn` preserves the current behavior of reporting staleness while continuing execution.
- [ ] `ignore` suppresses stale-index warnings while continuing execution.
- [ ] `error` exits with a non-zero status when the index is stale.
- [ ] The default behavior remains backward compatible.
- [ ] Invalid policy values produce a clear CLI validation error.
- [ ] CLI help documents the available policies.
- [ ] Tests cover fresh and stale indexes for each supported policy.
### Constraints
- Must not change the existing index format or analysis pipeline.
- The default behavior must remain backward compatible.
- `--stale-policy` should not automatically trigger re-indexing.
- The implementation should work consistently across supported CLI commands that consume indexed data.
- The option should not add new runtime dependencies.
### Contribution
- [x] I am willing to open a PR for this (may need design discussion first).
Source: abhigyanpatwari/GitNexus