Skip to content

refactor: unify duplicate Logger interfaces into single canonical type#14

Open
yuanrengu wants to merge 1 commit into
Tencent:mainfrom
yuanrengu:refactor/unify-logger-interface
Open

refactor: unify duplicate Logger interfaces into single canonical type#14
yuanrengu wants to merge 1 commit into
Tencent:mainfrom
yuanrengu:refactor/unify-logger-interface

Conversation

@yuanrengu
Copy link
Copy Markdown

Summary

23 files had local Logger/StoreLogger/PluginLogger/PipelineLogger/RunnerLogger/ExtractorLogger/TriggerLogger interface definitions with identical shapes ({debug?, info, warn, error}). This PR replaces all duplicates with imports from the canonical Logger in src/core/types.ts.

Changes

  • 17 files: local interface Logger removed → import type { Logger } from ../types.js
  • 6 files: named variants replaced with type aliases for backward compatibility:
    • StoreLoggertype StoreLogger = Logger (exported, used by tcvdb-client/factory)
    • PluginLoggertype PluginLogger = Logger (exported, used by offload/*)
    • PipelineLoggertype PipelineLogger = Logger (exported, used by seed-runtime)
    • RunnerLoggertype RunnerLogger = Logger
    • ExtractorLoggertype ExtractorLogger = Logger
    • TriggerLoggertype TriggerLogger = Logger

Preserved as-is (different contract)

  • CheckpointLogger in checkpoint.ts — only info + optional warn (no error)
  • Logger in ensure-hook-policy.ts — only info, warn, debug? (no error)

Impact

  • -128 lines (35 insertions, 163 deletions)
  • Zero behavioral change — type-only refactor
  • All named variants preserved as type aliases for backward compatibility
  • Build verified: npx tsdown passes (714.61 kB, no errors)
  • No circular dependencies: core/types.ts has zero imports

Test plan

  • npx tsdown builds successfully
  • No circular dependency chains
  • All import type paths verified correct (relative to each file)
  • Named type aliases (StoreLogger, PluginLogger, etc.) remain importable from original modules
  • No runtime behavior changes (type-only refactor)

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>
@yuanrengu yuanrengu force-pushed the refactor/unify-logger-interface branch from 7e0d289 to a7911ff Compare May 15, 2026 15:38
@Maxwell-Code07
Copy link
Copy Markdown
Collaborator

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! 🙏

@yuanrengu
Copy link
Copy Markdown
Author

@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.

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.

2 participants