refactor: unify duplicate Logger interfaces into single canonical type#14
Conversation
23 files had local Logger/StoreLogger/PluginLogger/PipelineLogger/RunnerLogger/ExtractorLogger/TriggerLogger
interface definitions with identical shapes ({debug?, info, warn, error}).
Replace all with imports from the canonical `Logger` in `src/core/types.ts`:
- 17 files: local `interface Logger` → `import type { Logger }`
- 6 files: named variants (StoreLogger, PluginLogger, etc.) → `type X = Logger` alias
Two intentionally different interfaces are preserved:
- `CheckpointLogger` (only info + optional warn) — different contract
- `ensure-hook-policy.ts` Logger (no error) — different contract
Net: -120 lines, zero behavioral change.
Signed-off-by: yuanrengu <heyonggang0811@126.com>
7e0d289 to
a7911ff
Compare
|
Hi @yuanrengu, thanks for the PR! 🧹 Unifying duplicate Logger interfaces across the codebase is a worthwhile cleanup direction. We'll review the changes and get back to you shortly. Thanks for the contribution! 🙏 |
|
@Maxwell-Code07 Thanks! I've been diving into agent memory systems lately and learning a lot through this project. Happy to help improve it — let me know if any changes are needed. |
|
LGTM. This PR will be merged soon, thanks for your contribution! There is only one point that needs attention. The comment for interface Logger in src/core/type.ts(Line 17-22) is now outdated after this PR — the relationship has been inverted. /**
* Canonical logger interface used across all TDAI modules.
*
* Named variants (StoreLogger, PluginLogger, etc.) are type aliases
* of this interface, kept for backward compatibility.
*/
export interface Logger { |
@yuanrengu Hello, would it be convenient for you to update the comment according to the suggestions mentioned above? After updating the comment, this PR can be merged. |
StoreLogger, PluginLogger, etc. are now type aliases of Logger, not the other way around. Update the comment to clarify this inverted relationship. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@withRiver Thanks for the review! Updated the JSDoc comment on Logger in src/core/types.ts to clarify that StoreLogger/PluginLogger etc. are now type aliases of the canonical Logger interface. Please take another look, thanks! |
Summary
23 files had local
Logger/StoreLogger/PluginLogger/PipelineLogger/RunnerLogger/ExtractorLogger/TriggerLoggerinterface definitions with identical shapes ({debug?, info, warn, error}). This PR replaces all duplicates with imports from the canonicalLoggerinsrc/core/types.ts.Changes
interface Loggerremoved →import type { Logger }from../types.jsStoreLogger→type StoreLogger = Logger(exported, used by tcvdb-client/factory)PluginLogger→type PluginLogger = Logger(exported, used by offload/*)PipelineLogger→type PipelineLogger = Logger(exported, used by seed-runtime)RunnerLogger→type RunnerLogger = LoggerExtractorLogger→type ExtractorLogger = LoggerTriggerLogger→type TriggerLogger = LoggerPreserved as-is (different contract)
CheckpointLoggerincheckpoint.ts— onlyinfo+ optionalwarn(noerror)Loggerinensure-hook-policy.ts— onlyinfo,warn,debug?(noerror)Impact
npx tsdownpasses (714.61 kB, no errors)core/types.tshas zero importsTest plan
npx tsdownbuilds successfullyimport typepaths verified correct (relative to each file)StoreLogger,PluginLogger, etc.) remain importable from original modules