fix(store): close 3 aggregate-query tiebreaker sites flagged in #36 §3#38
Merged
Merged
Conversation
§0 TL;DR: add deterministic group-key ASC tiebreakers for the 3 aggregate GROUP BY sites flagged in PR #36 §3. §1 Evidence: adds tests for trending real-delta, effectiveness, and stats by_category tie order; full suite reports 134 passed on current master. §4 Hard-rule self-quote: did NOT touch per-row tiebreaker sites, server.py, tests/mcp, SKILL.md, .cursor/rules, README, CHANGELOG, or pyproject.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
§0 TL;DR
Closes the 3 aggregate-query tiebreaker sites that PR #36 §3 reported but did not silently fix per the "report, don't silently fix" hard rule from #33. Same SQLite tiebreaker bug class as #30 / #33 / #34 / #36 but DIFFERENT fix shape — these are GROUP BY queries where the deterministic tiebreaker is the GROUP key (alphabetical ASC), not rowid.
Authored by Codex (OpenAI), PR opened by Claude A — Codex's PR creation was blocked by the same `gh` 401 / GitHub connector 403 auth issue we hit 5 times already today. 6-of-6 rescue today per `feedback_codex_pr_creation_blocked.md`. Branch pushed cleanly; PR-creation rescue only.
+3 tests, 131 → 134 passing. After this PR, the SQLite-tiebreaker class is FULLY closed in the instinct repo (per-row + LIMIT-1 + aggregate, all sites covered).
§1 Sites fixed (all
src/instinct/store.py)§2 Why ASC on group key (different from #34/#36)
ASC chosen over DESC because aggregate display benefits from alphabetical-stable order on ties (predictable, scannable). DESC would also work but ASC matches the natural "first alphabetically when values tie" convention.
§3 Tests added (3 new)
Each test creates ≥2 groups producing identical aggregate values (tie scenario), calls the function twice, asserts same order both calls AND that the order matches the alphabetical group-key tiebreaker.
§4 Validation
```
$ PYTHONPATH=src python -m pytest -q
134 passed in [time] (was 131 pre-fix; +3 new)
$ PYTHONPATH=src ruff check src/instinct/store.py tests/test_store.py
All checks passed!
```
Baseline note: task brief expected 113→116, but current master already includes #37 (PR merged after the brief was drafted), so this clone verifies the live 131→134 delta. +3 strict increase confirmed.
§5 No 4th aggregate site found (decision gate clean)
Audit during this PR: `_promote_universal()` has `GROUP BY cl.pattern` but no aggregate `ORDER BY` tie to stabilize. No 4th aggregate site discovered. Scope stays at exactly the 3 sites #36 §3 flagged.
No other decision-gate triggers. No surprises.
§6 Maintainer checklist
§7 Hard rule self-quote
§8 References — full SQLite-tiebreaker class lineage (instinct)
After this PR merges, all SQLite ORDER BY sites in `src/instinct/store.py` have a deterministic tiebreaker matching their semantic model. The cross-repo rule `feedback_sqlite_rowid_tiebreaker.md` is fully realised in the instinct repo.
🤖 Generated with Claude Code on behalf of Codex (OpenAI)