Skip to content

fix(lancedb): dump manifest version判定を共通化 - #564

Merged
hmjn023 merged 2 commits into
developfrom
fix/lancedb-manifest-version
Jul 2, 2026
Merged

hmjn023 merged 2 commits into
developfrom
fix/lancedb-manifest-version

Conversation

@hmjn023

@hmjn023 hmjn023 commented Jul 2, 2026 •

Copy link
Copy Markdown
Owner

概要

LanceDB dumpがversion 4で作成される一方、delta同期と起動時確認がversion 3を期待していた不整合を修正します。この不整合により、メディア追加時のdelta同期が全件full syncへフォールバックしていました。

変更内容

  • dump manifest versionを共通定数として公開
  • delta同期と起動時キャッシュ判定で共通定数を使用
  • maintenance serviceのテストfixtureを現行versionへ更新

検証

  • bun run lint
  • bun run typecheck
  • git diff --check

補足

対象unit testはViteの既存エイリアス解決エラーによりserver設定ではsuite読込前に停止しました。root設定ではlancedb dump serviceの5テストが成功しています。

Summary by CodeRabbit

  • Bug Fixes
    • LanceDBダンプのバージョン判定が固定値から、期待値に連動するよう改善されました。
    • その結果、キャッシュの有効判定や差分更新/フル同期の判断がより適切になります。
  • New Features
    • ダンプのバージョン情報を外部から参照できるようになりました。
  • Tests
    • manifestのバージョン更新にあわせて関連テストケースを調整しました。

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cc666c5f-820d-4f8c-8985-91366fcf6b07

📥 Commits

Reviewing files that changed from the base of the PR and between cc3ef56 and b8d4a8c.

📒 Files selected for processing (1)
  • apps/server/src/tests/unit/application/services/maintenance-service.test.ts

📝 Walkthrough

Walkthrough

LanceDBダンプのバージョン値を公開定数に集約し、server側のバージョン判定をその定数参照に統一しました。関連テストのmanifest version期待値も4に更新されています。

Changes

LANCEDB_DUMP_VERSION定数化

Layer / File(s) Summary
定数のエクスポート化と再エクスポート
packages/application/src/services/lancedb-dump-service.ts, apps/server/src/application/services/lancedb-dump-service.ts
LANCEDB_DUMP_VERSION を export const に変更し、apps/server側から再エクスポートするようにした。
バージョン比較箇所の定数参照への置き換え
apps/server/src/application/services/backup-service.ts, apps/server/src/application/services/maintenance-service.ts
manifest.versionの比較を固定値3からLANCEDB_DUMP_VERSION参照に変更した。
maintenance-serviceテストの期待値更新
apps/server/src/tests/unit/application/services/maintenance-service.test.ts
lancedb-dump-serviceのモック方法と各ケースのmanifest想定versionを3から4に更新した。

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 LanceDB dump の manifest version 判定を共通定数に統一する変更を適切に表しています。
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lancedb-manifest-version

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

このプルリクエストでは、ハードコードされていた LANCEDB_DUMP_VERSION を共通の定数としてエクスポートし、BackupService や MaintenanceService などの各サービスおよびテストコードで参照するように修正しています。レビューでは、テストコードにおける lancedb-dump-service のモック作成時に、バージョン番号をハードコードするのではなく、Vitest の importOriginal を使用して実際のモジュールからインポートを継承することで、将来的なメンテナンスコストを削減する改善案が提示されています。

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 apps/server/src/tests/unit/application/services/maintenance-service.test.ts Outdated
…rvice.test.ts

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@hmjn023
hmjn023 merged commit 4dd044d into develop Jul 2, 2026
1 check was pending
@hmjn023
hmjn023 deleted the fix/lancedb-manifest-version branch July 2, 2026 13:58

@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

🧹 Nitpick comments (1)
apps/server/src/tests/unit/application/services/maintenance-service.test.ts (1)

44-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

vi.importActualで実定数値を取り込むことを検討してください。

LANCEDB_DUMP_VERSION: 4をモックにハードコードしていますが、本PR自体が「定数のハードコード値の不一致」によるバグ修正であることを踏まえると、テスト側も実際のLANCEDB_DUMP_VERSIONをハードコードするのではなくvi.importActual経由で取得する方が、将来的な値変更時の乖離を防げます。

♻️ 提案する修正例
-vi.mock("~/application/services/lancedb-dump-service", () => ({
-	...
-	LANCEDB_DUMP_VERSION: 4,
-	...
-}));
+vi.mock("~/application/services/lancedb-dump-service", async () => {
+	const actual = await vi.importActual<
+		typeof import("~/application/services/lancedb-dump-service")
+	>("~/application/services/lancedb-dump-service");
+	return {
+		...actual,
+		// 他のモック値はそのまま維持
+	};
+});
🤖 Prompt for 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.

In `@apps/server/src/tests/unit/application/services/maintenance-service.test.ts`
at line 44, The test mock is hardcoding LANCEDB_DUMP_VERSION to 4, which can
drift from the वास्तविक constant and defeat the intent of the fix. Update the
mock in maintenance-service.test.ts to obtain LANCEDB_DUMP_VERSION via
vi.importActual from the same module used in production, and use that imported
value in the mocked module setup so the test stays aligned with the real
constant.
🤖 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 `@apps/server/src/application/services/backup-service.ts`:
- Line 13: The static import of LANCEDB_DUMP_VERSION in backup-service.ts still
eagerly initializes lancedb-dump-service, which defeats the intended lazy
loading. Update the backup-service code path to load LANCEDB_DUMP_VERSION via a
dynamic import like the existing createLanceDbDumpService flow in
lancedb-dump-service, and keep the import inside the relevant function or
runtime branch so module initialization is deferred. Use the symbols
backup-service, LANCEDB_DUMP_VERSION, and createLanceDbDumpService to locate and
align the change.

---

Nitpick comments:
In `@apps/server/src/tests/unit/application/services/maintenance-service.test.ts`:
- Line 44: The test mock is hardcoding LANCEDB_DUMP_VERSION to 4, which can
drift from the वास्तविक constant and defeat the intent of the fix. Update the
mock in maintenance-service.test.ts to obtain LANCEDB_DUMP_VERSION via
vi.importActual from the same module used in production, and use that imported
value in the mocked module setup so the test stays aligned with the real
constant.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 65b365b1-4210-4815-af17-7d9f108f1182

📥 Commits

Reviewing files that changed from the base of the PR and between 9a83060 and cc3ef56.

📒 Files selected for processing (5)
  • apps/server/src/application/services/backup-service.ts
  • apps/server/src/application/services/lancedb-dump-service.ts
  • apps/server/src/application/services/maintenance-service.ts
  • apps/server/src/tests/unit/application/services/maintenance-service.test.ts
  • packages/application/src/services/lancedb-dump-service.ts

import type { Table } from "drizzle-orm";
import { and, asc, eq, gt, inArray, lt, or, sql } from "drizzle-orm";
import type { PgColumn } from "drizzle-orm/pg-core";
import { LANCEDB_DUMP_VERSION } from "~/application/services/lancedb-dump-service";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# lancedb-dump-service.ts のトップレベルに重い副作用(LanceDB接続確立など)がないか確認
sed -n '1,20p' packages/application/src/services/lancedb-dump-service.ts
sed -n '1,10p' apps/server/src/application/services/lancedb-dump-service.ts

# backup-service.ts内での同モジュールへのimportパターンを確認
rg -n 'lancedb-dump-service' apps/server/src/application/services/backup-service.ts

Repository: hmjn023/solid-imager

Length of output: 1514


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- backup-service.ts top imports and relevant dynamic imports ---'
sed -n '1,80p' apps/server/src/application/services/backup-service.ts
echo
sed -n '1030,1085p' apps/server/src/application/services/backup-service.ts
echo
sed -n '1260,1295p' apps/server/src/application/services/backup-service.ts
echo
sed -n '1328,1360p' apps/server/src/application/services/backup-service.ts
echo
sed -n '1588,1665p' apps/server/src/application/services/backup-service.ts

echo
echo '--- lancedb-dump-service.ts top of file and all runtime imports ---'
sed -n '1,120p' apps/server/src/application/services/lancedb-dump-service.ts
echo
rg -n 'from "@|from "~/' apps/server/src/application/services/lancedb-dump-service.ts

Repository: hmjn023/solid-imager

Length of output: 8977


静的 import による早期評価を再確認 backup-service.ts で LANCEDB_DUMP_VERSION を静的 import すると、~/application/services/lancedb-dump-service のモジュール初期化自体は走ります。apps/server/src/application/services/lancedb-dump-service.ts では createLanceDbDumpService(...) をトップレベルで呼んでいるため、遅延ロードに寄せたい意図があるならここは動的 import に揃えるべきです。

🤖 Prompt for 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.

In `@apps/server/src/application/services/backup-service.ts` at line 13, The
static import of LANCEDB_DUMP_VERSION in backup-service.ts still eagerly
initializes lancedb-dump-service, which defeats the intended lazy loading.
Update the backup-service code path to load LANCEDB_DUMP_VERSION via a dynamic
import like the existing createLanceDbDumpService flow in lancedb-dump-service,
and keep the import inside the relevant function or runtime branch so module
initialization is deferred. Use the symbols backup-service,
LANCEDB_DUMP_VERSION, and createLanceDbDumpService to locate and align the
change.

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