Skip to content

fix(rules): correct mihomo rule name mapping#68

Open
cesaryuan wants to merge 1 commit intoforu17:mainfrom
cesaryuan:fix/mihomo-rule-name-mapping
Open

fix(rules): correct mihomo rule name mapping#68
cesaryuan wants to merge 1 commit intoforu17:mainfrom
cesaryuan:fix/mihomo-rule-name-mapping

Conversation

@cesaryuan
Copy link
Copy Markdown

@cesaryuan cesaryuan commented Apr 13, 2026

Summary

  • fix mihomo rule-name mapping so proxy groups are not recorded as rules
  • preserve existing Surge rule-name behavior when the resolved rule already matches the last chain hop
  • centralize collector rule-name generation into a shared helper and add regression coverage

close #67

Testing

  • corepack pnpm --filter @neko-master/collector test -- src/database/repositories/traffic-writer.test.ts
  • corepack pnpm --filter @neko-master/collector test -- src/modules/stats/stats.service.test.ts
  • corepack pnpm --filter @neko-master/collector exec tsc --noEmit

Copilot AI review requested due to automatic review settings April 13, 2026 05:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes rule-name normalization in the collector so Mihomo/Clash “proxy group” hops are no longer persisted as rule names, while preserving Surge’s existing rule-name semantics when the resolved rule already matches the last chain hop. This also centralizes rule-name generation to a shared helper and adds regression tests.

Changes:

  • Introduce a shared buildRuleName helper and reuse it across SQLite writes, ClickHouse writes, and realtime aggregation.
  • Correct Mihomo/Clash rule-name derivation to use rule + rulePayload (instead of the last chain hop).
  • Add/adjust tests to cover Mihomo mapping + Surge preservation behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
apps/web/components/features/rules/interactive-rule-stats.tsx Clarifies (in comment) that Gateway-rule proxy-group names match Surge’s stored rule naming behavior.
apps/collector/src/shared/utils/rule-name.ts Adds centralized helper for consistent rule-name construction across collectors/writers.
apps/collector/src/modules/stats/stats.service.test.ts Updates chain-flow regression fixture to reflect corrected rule/rulePayload semantics.
apps/collector/src/modules/realtime/realtime.store.ts Uses shared helper so realtime rule aggregation matches persisted rule naming.
apps/collector/src/modules/collector/batch-buffer.ts Uses shared helper for rule-count logging (aligning with persisted rule naming).
apps/collector/src/modules/clickhouse/clickhouse.writer.ts Uses shared helper so ClickHouse writes match SQLite/realtime rule naming.
apps/collector/src/database/repositories/traffic-writer.test.ts Adds regression coverage for Mihomo mapping + Surge-preservation behavior.
apps/collector/src/database/repositories/traffic-writer.repository.ts Replaces duplicated rule-name logic with shared helper and fixes rule→proxy mapping to use the resolved rule name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[Bug] Mihomo 中的代理组 (proxy group) 被解析成规则

2 participants