Skip to content

test(server): isolate task tool SQLite fixtures - #199

Merged
thebtf merged 2 commits into
masterfrom
fix/v5242-sqlite-test-isolation
Jul 18, 2026
Merged

test(server): isolate task tool SQLite fixtures#199
thebtf merged 2 commits into
masterfrom
fix/v5242-sqlite-test-isolation

Conversation

@thebtf

@thebtf thebtf commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Use t.Name() for the in-memory SQLite fixture URI in newTaskToolEngine, so each test invocation gets a stable test-local database instead of relying on wall-clock uniqueness under parallel/race scheduling.

Evidence

  • go test ./pkg/server -run 'TestNewTaskToolEngine|TestLimitedRecipeProfile' -count=20 -timeout 300s
  • Diff is one test-only line in pkg/server/task_tool_test.go; no production behavior changes.

Release context

This closes the independent package-test collision found while preparing v5.24.2. The muxcore lifecycle release blocker is tracked separately in Engram mcp-mux #405 and is not bypassed by this PR.

Summary by CodeRabbit

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

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6a8900ea-614f-49eb-a458-c67e7fcf9bcd

📥 Commits

Reviewing files that changed from the base of the PR and between f9bc0c1 and 226b827.

📒 Files selected for processing (1)
  • pkg/server/task_tool_test.go

Walkthrough

В newTaskToolEngine имя SQLite in-memory базы изменено: вместо временной метки используется имя текущего теста t.Name().

Changes

Тестовая SQLite-база

Layer / File(s) Summary
Формирование детерминированного имени базы
pkg/server/task_tool_test.go
Строка подключения SQLite теперь использует t.Name() вместо time.Now().UnixNano() для идентификатора in-memory базы.

Estimated code review effort: 1 (Trivial) | ~2 минуты

Poem

Я兔ик прыгнул к тестам в ряд,
Где базы имя — чистый лад.
Не время шепчет свой секрет,
А имя теста держит след.
Пускай проверки мчатся вскачь! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Заголовок точно отражает тестовое изолирование SQLite-фикстуры для task tool.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v5242-sqlite-test-isolation

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

@thebtf

thebtf commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review focus:test isolation correctness and regression risk files:pkg/server/task_tool_test.go

@thebtf

thebtf commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

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

Copy link
Copy Markdown

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 updates the SQLite database connection string in the test helper to use the test name instead of a timestamp. The review feedback correctly points out that using the test name directly can cause failures in subtests because subtest names contain slashes, which SQLite interprets as directory paths. A suggestion was provided to sanitize the test name by replacing slashes with underscores.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/server/task_tool_test.go Outdated
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Focused file outline =="
ast-grep outline pkg/server/task_tool_test.go --items all || true

echo
echo "== Pull request diff =="
git diff --unified=80 HEAD^ HEAD -- pkg/server/task_tool_test.go

echo
echo "== Fixture helper definitions and call sites =="
rg -n -C 8 '\bnewTaskToolEngine\s*\(' pkg/server/task_tool_test.go

echo
echo "== Test and subtest naming around the focused helper =="
rg -n -C 5 '^\s*func\s+Test|t\.Run\s*\(' pkg/server/task_tool_test.go

echo
echo "== SQLite connection / in-memory URI construction in focused file =="
rg -n -C 6 'sqlite|SQLite|:memory:|mode=memory|cache=shared|dsn|DSN|Open\s*\(' pkg/server/task_tool_test.go

Length of output: 47566


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Count fixture-construction calls per test/helper function =="
python3 - <<'PY'
from pathlib import Path
import re

path = Path("pkg/server/task_tool_test.go")
lines = path.read_text().splitlines()
func = None
counts = {}
pattern = re.compile(r'\b(?:newTaskToolEngine|newTaskToolServer(?:WithProfile|WithWorkflowHooks)?)\s*\(')

for line in lines:
    match = re.match(r'^func\s+([A-Za-z0-9_]+)\s*\(', line)
    if match:
        func = match.group(1)
        counts.setdefault(func, 0)
    if func and pattern.search(line) and not re.match(r'^func\s+(?:newTaskToolEngine|newTaskToolServer(?:WithProfile|WithWorkflowHooks)?)\s*\(', line):
        counts[func] += 1

for name, count in counts.items():
    if count:
        print(f"{name}: {count}")
PY

echo
echo "== Locate and map loom engine construction =="
rg -n -C 5 '\bfunc\s+NewEngine\s*\(' loom
engine_file="$(rg -l --glob '*.go' '^\s*func\s+NewEngine\s*\(' loom | head -n 1)"
if [ -n "$engine_file" ]; then
  ast-grep outline "$engine_file" --items all
  echo
  echo "== NewEngine implementation =="
  start="$(rg -n '^\s*func\s+NewEngine\s*\(' "$engine_file" | head -n 1 | cut -d: -f1)"
  sed -n "${start},$((start + 140))p" "$engine_file"
fi

echo
echo "== Other task-tool fixture database URI builders in this package =="
rg -n -C 4 'file:.*(?:memory|cache=shared)|mode=memory|task_tool_' pkg/server --glob '*_test.go'

Length of output: 15223


@thebtf Reviewed pkg/server/task_tool_test.go with focus on SQLite fixture isolation and regression risk.

No findings. t.Name() provides a stable, distinct in-process SQLite URI for each top-level test and parallel subtest using this helper. Each enclosing test constructs one engine, and cleanup ordering correctly closes the engine before the database handle. The change is test-only and removes the timestamp-collision risk without changing production behavior.

✅ Action performed

Review finished.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/server/task_tool_test.go`:
- Line 1718: Update the SQLite URI construction in the test setup around
sql.Open to escape t.Name() or replace it with a safe deterministic hash before
inserting it into the database URI. Preserve the shared in-memory database
behavior while ensuring names containing slashes, query characters, or spaces
cannot alter URI parsing or cause test databases to collide.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4a0f0b6-cfea-46e1-88d4-d0fb30873271

📥 Commits

Reviewing files that changed from the base of the PR and between d2960cd and f9bc0c1.

📒 Files selected for processing (1)
  • pkg/server/task_tool_test.go

Comment thread pkg/server/task_tool_test.go Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: f9bc0c122b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thebtf

thebtf commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review focus:verify SQLite URI escaping and test isolation files:pkg/server/task_tool_test.go incremental

@thebtf

thebtf commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Focused file outline =="
ast-grep outline pkg/server/task_tool_test.go --items all

echo
echo "== Incremental diff =="
git diff --unified=60 HEAD^ HEAD -- pkg/server/task_tool_test.go

echo
echo "== Fixture URI construction and lifecycle =="
rg -n -C 14 -P 'func\s+newTaskToolEngine\s*\(|t\.Name\(\)|sqlite|SQLite|mode=memory|cache=shared|Close\s*\(' pkg/server/task_tool_test.go

echo
echo "== Fixture call sites with enclosing test/subtest names =="
rg -n -C 8 -P '^\s*func\s+Test|t\.Run\s*\(|newTaskToolEngine\s*\(' pkg/server/task_tool_test.go

echo
echo "== SQLite driver module/version and URI-related references =="
rg -n -C 3 -P 'modernc\.org/sqlite|mattn/go-sqlite3|sqlite' go.mod go.sum pkg/server --glob '*.go'

Length of output: 66700


@thebtf Reviewed the incremental change in pkg/server/task_tool_test.go.

No findings. url.PathEscape(t.Name()) safely confines test and subtest names to the SQLite URI path component, so characters such as /, ?, #, and % cannot alter URI/query parsing. Distinct parallel tests and subtests therefore retain separate in-memory databases, while the existing cleanup order closes the engine before the database handle.

✅ Action performed

Review finished.

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 226b8278a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thebtf
thebtf merged commit 24575a4 into master Jul 18, 2026
8 checks passed
@thebtf
thebtf deleted the fix/v5242-sqlite-test-isolation branch July 18, 2026 15:17
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