Skip to content

feat(scoring): expose merged scorer output#3

Draft
ovitrif wants to merge 1 commit into
feat/scorer-diagnosticsfrom
codex/scorer-merge-api
Draft

feat(scoring): expose merged scorer output#3
ovitrif wants to merge 1 commit into
feat/scorer-diagnosticsfrom
codex/scorer-merge-api

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented May 15, 2026

Stacked on #2.

Context

This PR adds the small write/merge API surface needed by scorer-kit after the diagnostics API from #2.

The immediate use case is offline score-file tooling: read multiple serialized LDK scorer files, inspect their contents, compare them, merge them into a new ChannelLiquidities file, and write that file back out for use by downstream tooling.

This is motivated by a support case where one available scorer file appears to have insufficient route coverage, while another historical scorer file appears to contain useful data for that route. The goal is to let an external tool build an auditable merged scorer file instead of treating one scorer source as globally authoritative.

What Changed

  • Adds ChannelLiquidities::merge(...) as a simple default merge helper. It decays both inputs to a shared timestamp, preserves unique entries, and combines duplicate short-channel-id entries using LDK's existing per-channel merge semantics.
  • Adds ChannelLiquidities::merge_with(...) for policy-driven duplicate handling. The caller gets diagnostic views of both duplicate entries and can choose KeepExisting, ReplaceWithOther, or Combine per channel.
  • Adds ChannelLiquidityMergeAction to make those duplicate-resolution choices explicit.
  • Adds CombinedScorer::scores() so callers that use the existing CombinedScorer::merge(...) path can explicitly serialize the in-memory combined state. This intentionally does not change CombinedScorer's Writeable implementation, which still persists local-only scores.

Why Policy-Driven Merge

Blindly averaging every duplicate scorer entry is not obviously correct when combining independently generated scorer files. One source may be better for most overlapping channels, while another may be better for a smaller set of channels that it observed more effectively.

This PR keeps the low-level LDK operation available, but lets external tooling own the actual merge policy. That policy can be deterministic and auditable: prefer richer history, prefer newer datapoints, prefer a known source by default, or explicitly override known support-ticket targets.

Test Plan

  • cargo test -p lightning --lib routing::scoring::tests::

@ovitrif ovitrif self-assigned this May 16, 2026
@ovitrif ovitrif force-pushed the codex/scorer-merge-api branch from c7801e0 to 0a47329 Compare May 16, 2026 11:26
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.

1 participant