fix(MULTIVERSION-0001): prevent version jobs from overwriting repo-wide NULL rules entry

Version jobs now write rules only to the version-specific (repo, versionId)
row. Previously every version job unconditionally wrote to the (repo, NULL)
row as well, causing whichever version indexed last to contaminate the
repo-wide rules that the context API merges into every query response.

Adds a regression test (Bug5b) that indexes the main branch, then indexes a
version with different rules, and asserts the NULL row still holds the
main-branch rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Giancarmine Salucci
2026-03-29 01:15:58 +01:00
parent cd4ea7112c
commit bbc67f8064
2 changed files with 75 additions and 7 deletions

View File

@@ -276,10 +276,13 @@ export class IndexingPipeline {
// ---- Stage 6: Persist rules from config ----------------------------
if (parsedConfig?.config.rules?.length) {
// Repo-wide rules (versionId = null).
this.upsertRepoConfig(repo.id, null, parsedConfig.config.rules);
// Version-specific rules stored separately when indexing a version.
if (normJob.versionId) {
if (!normJob.versionId) {
// Main-branch job: write the repo-wide entry only.
this.upsertRepoConfig(repo.id, null, parsedConfig.config.rules);
} else {
// Version job: write only the version-specific entry.
// Writing to the NULL row here would overwrite repo-wide rules
// with whatever the last-indexed version happened to carry.
this.upsertRepoConfig(repo.id, normJob.versionId, parsedConfig.config.rules);
}
}