Skip to content

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

Merged
withRiver merged 2 commits into
Tencent:mainfrom
yuanrengu:refactor/unify-logger-interface
Jun 1, 2026
Merged

refactor: unify duplicate Logger interfaces into single canonical type#14
withRiver merged 2 commits into
Tencent:mainfrom
yuanrengu:refactor/unify-logger-interface

Conversation

@yuanrengu
Copy link
Copy Markdown
Contributor

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

@withRiver
Copy link
Copy Markdown
Collaborator

withRiver commented May 31, 2026

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. StoreLogger/RunnerLogger are now aliases of Logger, not the other way around. Suggest updating to:

/**
 * 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 {

@withRiver
Copy link
Copy Markdown
Collaborator

withRiver commented Jun 1, 2026

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. StoreLogger/RunnerLogger are now aliases of Logger, not the other way around. Suggest updating to:

/**
 * 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>
@yuanrengu
Copy link
Copy Markdown
Contributor Author

yuanrengu commented Jun 1, 2026

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. StoreLogger/RunnerLogger are now aliases of Logger, not the other way around. Suggest updating to:

/**
 * 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.

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

@withRiver withRiver merged commit d1534e4 into Tencent:main Jun 1, 2026
5 checks passed
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.

3 participants