Skip to content

feat(scoring): expose merged scorer output#3

Draft
ovitrif wants to merge 2 commits into
feat/scorer-diagnosticsfrom
codex/scorer-merge-api
Draft

feat(scoring): expose merged scorer output#3
ovitrif wants to merge 2 commits 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/filter API surface needed by scorer-kit after the diagnostics API from #2.

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

The goal is to let external tooling build an auditable 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 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 ChannelLiquidities::remove(scid) so offline tooling can filter decoded scorer files before merging or re-serializing them.
  • Adds ChannelLiquidityMergeAction to make 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 write behavior, 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 explicitly selected set.

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, preserve a baseline source by default, or explicitly overlay selected short-channel-ids.

Test Plan

  • cargo test -p lightning --lib channel_liquidities_
  • 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
@ovitrif ovitrif mentioned this pull request May 17, 2026
14 tasks
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