Skip to content

feat(us4): drop project_settings subsystem (PR-v5-4)#184

Merged
thebtf merged 1 commit into
mainfrom
feat/v5-us4-project-settings
Apr 18, 2026
Merged

feat(us4): drop project_settings subsystem (PR-v5-4)#184
thebtf merged 1 commit into
mainfrom
feat/v5-us4-project-settings

Conversation

@thebtf
Copy link
Copy Markdown
Owner

@thebtf thebtf commented Apr 18, 2026

Scope: US4 per plan.md §Phase 4 — drop project_settings table + ProjectSettingsStore Go type + adaptive-threshold caller code.

Changes

  • Migration 097_drop_project_settings (per-C3 rollback returns error)
  • Delete internal/db/gorm/project_settings_store.go
  • internal/search/manager.go: remove projectSettingsStore field + Set method; GetProjectThreshold thin-wraps globalDefault (callers unchanged)
  • internal/worker/service.go: remove field + init + Set call
  • internal/worker/handlers_scoring.go: remove AdjustThreshold block (was only caller)
  • internal/worker/reaper/reaper.go: drop project_settings comment entry

Verified

  • go build ./... green
  • go vet ./... clean
  • go test -short -count=1 ./... green

Conventions compliance (plan.md §Cross-Phase Conventions)

  • C3: rollback returns IRREVERSIBLE error
  • C6: DROP TABLE IF EXISTS is portable
  • C7: CodeRabbit-only review (.github/pr-review.json already on main)
  • C8: single coherent PR

Non-atomic diff

6 files changed, +28/-130. Clean pure-delete PR per plan.md C8 ''larger PRs''.

Safety gates (NFR-2)

  • Vault invariants preserved (no vault code touched)
  • credentials, memories, behavioral_rules tables untouched
  • content table untouched

Summary by CodeRabbit

Изменения

  • Удаленные функции
    • Удалена поддержка адаптивных пороговых значений релевантности для отдельных проектов. Система больше не хранит и не изменяет пороги релевантности для каждого проекта отдельно. Теперь используется единое глобальное пороговое значение.

Removes the per-project adaptive threshold infrastructure:

- Migration 097_drop_project_settings (DROP TABLE project_settings;
  per plan.md C3 rollback returns IRREVERSIBLE error — data was derived
  from learning signals)
- Delete internal/db/gorm/project_settings_store.go (ProjectSettings
  model + ProjectSettingsStore type + GetThreshold/AdjustThreshold/
  UpsertSettings methods)
- internal/search/manager.go: remove projectSettingsStore field and
  SetProjectSettingsStore method; GetProjectThreshold becomes a thin
  wrapper returning globalDefault (kept as a wrapper so callers in
  internal/worker don't need to change — remove together in a later
  US if wanted)
- internal/worker/service.go: remove projectSettingsStore field +
  init + SetProjectSettingsStore call (3 lines total)
- internal/worker/handlers_scoring.go: remove the adaptive threshold
  adjustment block in the utility-signal handler (it was the only
  caller of ProjectSettingsStore.AdjustThreshold)
- internal/worker/reaper/reaper.go: drop the project_settings entry
  from the ''tables related to projects.id'' comment

Verified:
  go build ./... — clean
  go vet ./... — clean
  go test -short -count=1 ./... — green

Per plan.md C7: CodeRabbit-only review.
Per plan.md C8: single coherent PR, no atomic-commit split.

Plan.md §Phase 4. Closes task #42.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b25a6f6a-85c4-412d-9196-016d2ccd2467

📥 Commits

Reviewing files that changed from the base of the PR and between b53535e and c793ae5.

📒 Files selected for processing (6)
  • internal/db/gorm/migrations.go
  • internal/db/gorm/project_settings_store.go
  • internal/search/manager.go
  • internal/worker/handlers_scoring.go
  • internal/worker/reaper/reaper.go
  • internal/worker/service.go
💤 Files with no reviewable changes (3)
  • internal/worker/reaper/reaper.go
  • internal/worker/service.go
  • internal/db/gorm/project_settings_store.go

Обзор

Удаляет функциональность адаптивной регулировки порогов для конкретных проектов путём удаления таблицы БД project_settings, связанного хранилища GORM и всех кодовых путей, которые использовали эту функциональность во время обработки наблюдений и инициализации сервиса.

Изменения

Когорта / Файл(ы) Резюме
Миграция БД
internal/db/gorm/migrations.go
Добавляет миграцию 097_drop_project_settings для удаления таблицы project_settings; откат помечен как необратимый.
Удалено хранилище параметров
internal/db/gorm/project_settings_store.go
Полностью удалён файл с моделью ProjectSettings и хранилищем ProjectSettingsStore (80 строк), включая методы получения, изменения и сохранения порогов.
Упрощение поиска и обработки
internal/search/manager.go, internal/worker/handlers_scoring.go, internal/worker/service.go
Удалены ссылки на projectSettingsStore, метод установки хранилища, логика адаптивной регулировки порогов; GetProjectThreshold теперь возвращает глобальное значение по умолчанию.
Очистка документации
internal/worker/reaper/reaper.go
Удалена заметка о структуре таблицы project_settings.

Ожидаемый объём работы при проверке кода

🎯 2 (Simple) | ⏱️ ~12 минут

Возможно связанные PR

  • PR #59: Основной PR, который добавил таблицу project_settings, ProjectSettingsStore и все связанные кодовые пути — данный PR полностью их удаляет.
  • PR #179: Оба PR работают с удалением/адаптацией функции адаптивной регулировки порогов для конкретных проектов в одной области функциональности.

Стихотворение

🐰 Прощайте, настройки проектов, уходите с весной,
Таблица упала, хранилище спит,
Простые пороги — вот наша игра,
Адаптив не нужен, пришла вам беда,
Нет больше забот о настройке судьбы! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Название четко отражает основное изменение: удаление подсистемы project_settings, включая таблицу БД, GORM-тип и связанный код. Оно конкретно, лаконично и понятно описывает основное намерение PR в одном предложении.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/v5-us4-project-settings

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Comment @coderabbitai help to get the list of available commands and usage tips.

@thebtf
Copy link
Copy Markdown
Owner Author

thebtf commented Apr 18, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@thebtf thebtf merged commit 4aa3838 into main Apr 18, 2026
8 checks passed
@thebtf thebtf deleted the feat/v5-us4-project-settings branch April 18, 2026 18:44
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request removes per-project adaptive thresholds by dropping the project_settings database table and removing the associated ProjectSettingsStore and logic across the search manager and worker service. The changes include a new migration to drop the table and updates to the scoring handlers to remove threshold adjustment logic. Feedback focuses on improving Go idiomaticity by using blank identifiers for unused parameters in GetProjectThreshold and merging redundant lock/unlock blocks in the worker service initialization.

Comment on lines 372 to 376
func (m *Manager) GetProjectThreshold(ctx context.Context, project string, globalDefault float64) float64 {
if m.projectSettingsStore == nil {
return globalDefault
}
threshold, err := m.projectSettingsStore.GetThreshold(ctx, project)
if err != nil {
return globalDefault
}
// If the stored threshold equals the default (0.3), honor globalDefault
// in case the operator configured a higher global threshold.
if threshold == 0.3 {
return globalDefault
}
return threshold
_ = ctx
_ = project
return globalDefault
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For unused parameters in a function signature, it is more idiomatic in Go to use the blank identifier _ directly in the parameter list rather than using _ = parameter in the function body. This clearly signals to both the compiler and other developers that the parameters are intentionally ignored while maintaining the required signature for compatibility.

func (m *Manager) GetProjectThreshold(_ context.Context, _ string, globalDefault float64) float64 {
	return globalDefault
}

Comment on lines 863 to 867
s.grpcServer = grpcSrv
s.initMu.Unlock()

// Wire project settings store for adaptive per-project thresholds.
projectSettingsStore := gorm.NewProjectSettingsStore(store.DB)
searchMgr.SetProjectSettingsStore(projectSettingsStore)
s.projectSettingsStore = projectSettingsStore

s.initMu.Lock()
s.searchMgr = searchMgr
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

After removing the projectSettingsStore initialization logic, this Unlock() and subsequent Lock() sequence has become redundant. Merging these two critical sections into one improves readability and slightly reduces overhead by avoiding an unnecessary lock release and re-acquisition during the initialization phase.

Suggested change
s.grpcServer = grpcSrv
s.initMu.Unlock()
// Wire project settings store for adaptive per-project thresholds.
projectSettingsStore := gorm.NewProjectSettingsStore(store.DB)
searchMgr.SetProjectSettingsStore(projectSettingsStore)
s.projectSettingsStore = projectSettingsStore
s.initMu.Lock()
s.searchMgr = searchMgr
s.grpcServer = grpcSrv
s.searchMgr = searchMgr

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