-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Develop #556
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9786274
fix(server): sync PostgreSQL and LanceDB discrepancies on startup
4499eed
feat(ai): add CCIP vector extraction and similarity search
962f0ed
fix(ccip): address review feedback
e8017bf
fix(ccip): handle follow-up review comments
19067f5
Merge pull request #555 from hmjn023/feat/ccip-vector-similarity
hmjn023 b98726a
Merge pull request #553 from hmjn023/fix/lancedb-postgres-startup-sync
hmjn023 99b4e51
fix: PR #556 レビューコメント対応
hmjn023 3cda69e
fix(ccip): resolve PR review blockers
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| --- | ||
| name: job-system | ||
| description: solid-imagerのbackground job、JobWorker、job dispatch、AI concurrency、親子batch進捗、stale recoveryを扱う。job type追加、非同期処理、Managerのbatch操作、job event変更時に使用する。 | ||
| --- | ||
|
|
||
| # Job System | ||
|
|
||
| ## データフロー | ||
|
|
||
| 1. jobは`IJobRepository.create`または`createIfUnique`で投入する。 | ||
| 2. `apps/server/src/infrastructure/jobs/job-worker.ts`がAI jobとその他jobを別poolでclaimする。 | ||
| 3. `apps/server/src/application/services/job-dispatch-service.ts`がjob typeごとのhandlerへ振り分ける。 | ||
| 4. handlerはpayloadをZod schemaでparseしてから処理する。 | ||
| 5. UIへ進捗を出す場合は`RealtimeEventBus.publishJob`だけを使用する。 | ||
|
|
||
| ## Job追加時の必須更新 | ||
|
|
||
| - dispatchへ明示的な分岐を追加する。未知jobは警告後に完了扱いになるため、登録漏れを残さない。 | ||
| - AI推論を行うjobは`JobWorker.aiJobTypes`へ追加し、`jobs.aiConcurrency`の対象にする。 | ||
| - payload schema、成功・失敗、claim pool、stale recoveryのunit testを追加する。 | ||
| - source単位で直列化が必要なjobはLanceDB syncと同様にclaim条件とactive keyを実装する。 | ||
| - media lifecycleから投入する場合はupload、watcher、copy/move、delete、bulk操作を監査する。 | ||
|
|
||
| ## Batch Job | ||
|
|
||
| - 親jobは進捗記録でありworkerに実行させない。`status: in_progress`で作成する。 | ||
| - 子jobへ`parentId`を設定し、子の完了時に親payloadの`processed`を原子的に更新する。 | ||
| - 親更新では`updatedAt`も更新する。 | ||
| - job event schemaは`packages/core/src/domain/sources/events.ts`を唯一の正とする。 | ||
| - clientは既存のjob event hookを再利用し、独自pollingやEventSourceを追加しない。 | ||
|
|
||
| ## 検証 | ||
|
|
||
| `claimPending`のinclude/exclude、AI concurrency、親job非claim、進捗完了、失敗、stale job回復を確認する。 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| interface: | ||
| display_name: "Job System" | ||
| short_description: "solid-imagerのbackground job設計と実装規約" | ||
| default_prompt: "既存のjob worker、dispatch、進捗イベント設計に従って変更してください。" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --- | ||
| name: media-search | ||
| description: solid-imagerのメディア検索schema、simple/pro/vector mode、shared search store、session persistence、preset、検索API、無限スクロールを扱う。検索条件・mode・sort・類似検索・検索画面変更時に使用する。 | ||
| --- | ||
|
|
||
| # Media Search | ||
|
|
||
| ## 既存設計 | ||
|
|
||
| - schemaと型の正は`packages/core/src/domain/search/`とmedia schemaに置く。 | ||
| - stateの正は`packages/ui/src/stores/search-store.ts`。server/Tauriは同じstoreをre-exportする。 | ||
| - 検索状態はstoreと`use-current-search-persistence`の`sessionStorage`で保持する。URL queryへ別系統の状態を追加しない。 | ||
| - simple/pro変換はcoreのsearch logicを経由する。 | ||
| - user presetとcurrent session stateを区別する。一時的な類似元などを通常presetへ混ぜない。 | ||
| - server/Tauri共通表示は`packages/ui`へ置き、app側はAPI clientとroute wiringだけを持つ。 | ||
|
|
||
| ## 変更手順 | ||
|
|
||
| 1. Zod `SearchState`とdefault stateを更新する。 | ||
| 2. mode遷移、condition生成、preset復元への影響を確認する。 | ||
| 3. session保存対象と復元処理を同時に更新する。 | ||
| 4. oRPC contract、router、application/repositoryの順で検索処理を追加する。 | ||
| 5. `useSearchPage`のquery keyへ結果を変える全stateを含める。 | ||
| 6. paginationを使わないmodeではnext pageを返さない。 | ||
| 7. 大量画像は既存のvirtualized gridとlazy loadingを維持する。 | ||
|
|
||
| ## Vector類似検索 | ||
|
|
||
| - `vector`はsimple/proと独立した第三modeとして扱う。 | ||
| - 個別media画面はstoreへanchor IDを設定して`/search`へ通常遷移する。 | ||
| - URL queryは使用しない。 | ||
| - source filterとtopKを明示し、通常sortは適用しない。 | ||
| - CCIPはキャラクター類似であり一般的な重複画像検索ではないことをUIに表示する。 | ||
|
|
||
| ## 検証 | ||
|
|
||
| mode遷移、session復元、preset非汚染、query key、server/Tauri parity、空結果、エラー、無限scroll停止を確認する。 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| interface: | ||
| display_name: "Media Search" | ||
| short_description: "solid-imagerの検索状態・API・UI設計規約" | ||
| default_prompt: "既存の検索store、session persistence、API、共有UI設計に従って変更してください。" |
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
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
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
27 changes: 27 additions & 0 deletions
27
apps/server/src/application/services/ccip-vector-service.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { CcipVectorService } from "@solid-imager/application/services/ccip-vector-service"; | ||
| import { services } from "~/application/registry"; | ||
| import { taggingService } from "~/application/services/tagging-service"; | ||
| import { LanceDbCcipVectorStore } from "~/infrastructure/ai/lancedb-ccip-vector-store"; | ||
|
|
||
| let service: CcipVectorService | null = null; | ||
|
|
||
| export function getCcipVectorService(): CcipVectorService { | ||
| if (!service) { | ||
| const config = services.getConfigService().getConfig(); | ||
| service = new CcipVectorService({ | ||
| mediaRepository: services.getMediaRepository(), | ||
| sourceRepository: services.getSourceRepository(), | ||
| taggingService, | ||
| vectorStore: new LanceDbCcipVectorStore(config.lancedb.ccipVectorDir), | ||
| }); | ||
|
hmjn023 marked this conversation as resolved.
|
||
| } | ||
| return service; | ||
| } | ||
|
|
||
| export const ccipVectorService = new Proxy({} as CcipVectorService, { | ||
| get(_target, property) { | ||
| const instance = getCcipVectorService(); | ||
| const value = instance[property as keyof CcipVectorService]; | ||
| return typeof value === "function" ? value.bind(instance) : value; | ||
| }, | ||
| }); | ||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.