feat: [ENG-1888] Define IQueryLogStore interface#351
feat: [ENG-1888] Define IQueryLogStore interface#351bao-byterover merged 1 commit intoproj/query-logfrom
Conversation
|
Claude finished @bao-byterover's task in 1m 43s —— View job PR Review: feat: [ENG-1888] Define IQueryLogStore interface
SummaryThis PR extends Issues Found1. ID generation is a domain/use-case concern, not a storage contract. The store's responsibility is persisting and retrieving entries. Putting 2. The 3. "Best-effort" JSDoc is misleading — see inline
Score: 2 / 5The stub pattern and TypeScript are clean, but the two structural issues (ID generation on the store interface, interface methods without consumer tests) are direct violations of the repo's documented architecture principles and should be resolved before merge. |
| /** Retrieve an entry by ID. Returns null if not found or if the file is corrupt. */ | ||
| getById(id: string): Promise<null | QueryLogEntry> | ||
| /** Generate the next monotonic log entry ID. */ | ||
| getNextId(): Promise<string> |
There was a problem hiding this comment.
concern (design): getNextId() on the storage interface conflates ID generation with persistence. The store's contract should be limited to reading/writing entries; ID generation is a domain/use-case concern.
If IDs must be monotonic relative to persisted data (e.g. derived from a sequence counter in the log directory), that could justify it — but even then, a separate IIdGenerator or a factory function scoped to the store would keep the interface focused. As-is, callers cannot generate an ID without touching the store.
Could this be pushed down to the FileQueryLogStore implementation (a non-interface method) and called internally by save() when entry.id is absent? Or generated by the use case with Date.now() since existing IDs already look like qry-{timestamp}?
| tier?: QueryLogTier[] | ||
| }): Promise<QueryLogEntry[]> | ||
| /** Persist (create or overwrite) a log entry. Best-effort — callers should handle errors. */ | ||
| save(entry: QueryLogEntry): Promise<void> |
There was a problem hiding this comment.
nitpick: "Best-effort — callers should handle errors" is an unusual contract for a Promise<void>. If errors can be thrown, that's normal async behavior, not "best-effort." True best-effort would mean the method swallows errors internally and never rejects.
Consider either: (a) removing "Best-effort" and just saying "Callers should handle I/O errors." or (b) having the method return Promise<{ok: boolean}> or catch-and-log internally if truly best-effort is the intent.
| getNextId: sandbox.stub().resolves('qry-9999'), | ||
| list: sandbox.stub().resolves([]), | ||
| save: sandbox.stub().resolves(), | ||
| } |
There was a problem hiding this comment.
issue (outside-in): getNextId and save stubs are wired into the factory but no test in this file calls them or asserts on them. Per the repo's Outside-In principle, interface methods should be driven by a concrete consumer test before they appear in the interface.
If QueryLogUseCase doesn't yet call save() or getNextId(), these stubs are forward-looking placeholders rather than tests that validate current behavior — which is an Inside-Out smell. The stubs should be added (and the interface methods should be added) once the use case tests that exercise them exist.
* feat: [ENG-1897] Create brv query-log view oclif command (#347) * feat: [ENG-1897] Create brv query-log view oclif command * feat: [ENG-1897] fix review * feat: [ENG-1896] Implement QueryLogUseCase with list and detail views (#349) * feat: [ENG-1896] Implement QueryLogUseCase with list and detail views * feat: [ENG-1896] Fix review * feat: [ENG-1888] Define IQueryLogStore interface (#351) * feat: [ENG-1887] Define QueryLogEntry entity with discriminated union (#353) * feat: [ENG-1889] Implement FileQueryLogStore with Zod validation (#354) * feat: [ENG-1889] Implement FileQueryLogStore with Zod validation * feat: [ENG-1889] fix review * feat: [ENG-1899] Create brv query-log summary oclif command (#357) * feat: [ENG-1899] Create brv query-log summary oclif command * feat: [ENG-1899] fix review * feat: [ENG-1898] Implement QueryLogSummaryUseCase (#368) * feat: [ENG-1892] Add QueryExecutorResult type with tier and timing metadata (#369) * feat: [ENG-1893] Wire QueryLogHandler into daemon lifecycle (#370) * feat: [ENG-1894] Wire QueryLogHandler into daemon lifecycle (#371) * feat: [ENG-1894] enhance message output * feat: [proj/query-log] fix review * feat: [ENG-2123] brv curate view / brv query-log view truncate long c… (#424) * feat: [ENG-2123] brv curate view / brv query-log view truncate long content * feat: [ENG-2123] fix review * feat: [ENG-2177] Increase Storage Limit for Curate Log and Query Log (#430) * feat: [ENG-2177] Increase Storage Limit for Curate Log and Query Log * feat: [ENG-2177] fix review * feat: [ENG-2177] fix slow test --------- Co-authored-by: Hoang Pham <lehoangpham1092@gmail.com>
No description provided.