Skip to content

feat: add resetScores devtools command#1005

Open
piotr-iohk wants to merge 4 commits into
masterfrom
feat/probe-reset-scores
Open

feat: add resetScores devtools command#1005
piotr-iohk wants to merge 4 commits into
masterfrom
feat/probe-reset-scores

Conversation

@piotr-iohk

Copy link
Copy Markdown
Collaborator

This PR adds a resetScores devtools command that wipes the persisted pathfinding scores, so mainnet probe runs can start from a fresh scorer.

Description

  • Adds ResetScores to the debug devtools ContentProvider, callable over adb like the existing probe commands
  • Delegates to LightningRepo.resetPathfindingScores(): stops the node, deletes the scorer and external_pathfinding_scores_cache VSS keys, then restarts the node (external scores are re-downloaded on startup)
  • On VSS delete failure the node is restarted before returning the error, so the wallet is never left stopped
  • Exposes latestPathfindingScoresSyncTimestamp in the probeReadiness response, so e2e can gate probing on a fresh post-reset scores sync

Without the reset, locally learned scores accumulate in VSS under the probe seed across nightly runs (probe results train the scorer), so consecutive scorer A/B runs are not comparable.

Pairs with:

Preview

QA Notes

Manual Tests

  • 1. Build mainnet debug E2E APK → restore probe wallet → adb content call resetScores: returns {"success":true} in ~7s.
  • 2. App logs confirm full sequence: node stop → deleteObject success for scorer and external_pathfinding_scores_cache → node rebuild without cache merge → fresh External scores merged successfully after restart.
  • 3. regression: adb content call probeReadiness: still returns readiness JSON, now including latestPathfindingScoresSyncTimestamp.

Automated Checks

  • Verified end-to-end locally via the companion e2e probe spec with PROBE_RESET_SCORES=true: readiness gated on a post-reset scores sync timestamp.
  • CI: standard compile, unit test, and detekt checks run by the PR bot.

Made with Cursor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c15e5824e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/repositories/LightningRepo.kt Outdated
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a resetScores devtools command that clears persisted pathfinding scores from VSS storage, enabling fresh scorer state for mainnet probe runs. It also exposes latestPathfindingScoresSyncTimestamp in the probeReadiness response so e2e tests can gate on a confirmed post-reset sync.

  • LightningRepo.resetPathfindingScores() stops the node, deletes scorer and external_pathfinding_scores_cache VSS keys, then restarts the node; on VSS failure it attempts a restart before returning the error.
  • DevToolsProvider is extended with a ResetScores data object and a new DevResult.Ack type, wiring the adb-callable command to the repo method.

Confidence Score: 3/5

The change is devtools-only and ADB-gated, so blast radius is limited, but the error-recovery restart path silently drops its own result, which can leave the wallet stopped with no log evidence.

The core stop → delete → restart contract works correctly on the happy path. On the failure path, the start() call intended to recover the wallet discards its Result entirely — if that restart also fails, the node stays stopped and neither the caller nor the logs surface it. A second concern is the gap between waitForNodeToStop() returning and stop() acquiring the mutex, where a concurrent lifecycle call could interleave during the sensitive delete window.

app/src/main/java/to/bitkit/repositories/LightningRepo.kt — specifically the error recovery branch in resetPathfindingScores and the lifecycle-mutex coverage between waitForNodeToStop and stop.

Important Files Changed

Filename Overview
app/src/main/java/to/bitkit/repositories/LightningRepo.kt Adds resetPathfindingScores() with a stop → delete VSS keys → restart flow; the error-recovery restart call discards its Result, leaving the node silently stopped on restart failure
app/src/debug/java/to/bitkit/dev/DevToolsProvider.kt Wires ResetScores command and DevResult.Ack type cleanly following existing patterns; latestPathfindingScoresSyncTimestamp correctly forwarded from NodeProbeReadiness

Sequence Diagram

sequenceDiagram
    participant ADB as adb shell
    participant DTP as DevToolsProvider
    participant LR as LightningRepo
    participant VSS as VssBackupClientLdk

    ADB->>DTP: call("resetScores")
    DTP->>LR: resetPathfindingScores()
    LR->>LR: waitForNodeToStop()
    LR->>LR: stop()
    LR->>VSS: setup(walletIndex)
    LR->>VSS: deleteObject("scorer")
    LR->>VSS: deleteObject("external_pathfinding_scores_cache")
    alt VSS delete succeeds
        LR->>LR: "start(walletIndex, shouldRetry=false)"
        LR-->>DTP: Result.success(Unit)
        DTP-->>ADB: "{"success":true}"
    else VSS delete fails
        LR->>LR: "start(walletIndex, shouldRetry=false) [result discarded]"
        LR-->>DTP: Result.failure(error)
        DTP-->>ADB: "{"error":"..."}"
    end
Loading

Reviews (1): Last reviewed commit: "feat: add resetScores devtools command" | Re-trigger Greptile

Comment thread app/src/main/java/to/bitkit/repositories/LightningRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/repositories/LightningRepo.kt
Comment thread app/src/main/java/to/bitkit/repositories/LightningRepo.kt Outdated
@piotr-iohk piotr-iohk added this to the 2.4.0 milestone Jun 11, 2026
piotr-iohk and others added 2 commits June 11, 2026 15:01
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@piotr-iohk piotr-iohk requested a review from pwltr June 11, 2026 13:38

@ovitrif ovitrif left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utAck; reviewed for android code correctness

added 1 nit

Comment thread app/src/main/java/to/bitkit/repositories/LightningRepo.kt Outdated
pwltr
pwltr previously approved these changes Jun 11, 2026

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK

Co-authored-by: Cursor <cursoragent@cursor.com>
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