Repository navigation
Conversation
There was a problem hiding this comment.
🔒 Automated security review — no issues found
This PR changes channel-open recommendations from one recycled row per peer to an append-only history: a partial unique index keeps one Open row per (node, peer), Upsert refreshes the open row or inserts a new one, expiry moves to the end of the job run filtered by LastEvidenceAt, and the Routing Management page gains a paged history table. I attacked the new surfaces triage flagged: queries are EF-parameterized with no string concatenation; the partial unique index blocks duplicate-open races in Upsert (concurrent inserts fail with a caught exception, not corruption); promote/dismiss go through the atomic UpdateIfStatus guard, so a history row cannot be resurrected by an operator; the history page inherits the page's Superadmin/NodeManager authorization and Blazor output encoding; paging inputs are server-controlled ints. The end-of-run ExpireOpen behaves like the old start-of-run wipe on failure (nothing refreshed, everything expires), so no regression there. No exploitable path found.
Reviewed 6 files at 2eccbd1. Nothing to report.
Not a guarantee — one diff, no knowledge of your threat model.
🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.
2eccbd1 to
3622feb
Compare
3622feb to
0ad8a61
Compare
There was a problem hiding this comment.
🔒 Automated security review — no issues found
This PR turns channel-open recommendations into append-only history: one Open row per (node, peer) enforced by a new partial unique index, refresh-in-place while qualifying, insert-otherwise, expiry moved to the end of the job run, and a paged history table on the Routing Management page. I attacked the new read path for IDOR (nodeId is only ever resolved from the caller's managed-node list, behind a role check), the promote/dismiss paths for replaying history rows (both gated by an atomic status-filtered ExecuteUpdate, with the orphaned request cancelled on a lost race), and the new check-then-insert Upsert for a duplicate-Open race (backstopped by the partial unique index and a caught exception). The expiry cutoff cannot expire rows refreshed in the same run. No exploitable defect found; the acknowledged unbounded table growth is rate-limited by job cadence and indexed paging, with no attacker-meaningful gain.
Reviewed 11 files at 0ad8a61. Nothing to report.
Not a guarantee — one diff, no knowledge of your threat model.
🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.
There was a problem hiding this comment.
🟡 Changes recommended
Critical race conditions can overwrite historical recommendation evidence and bypass an operator’s dismissal cooldown, allowing a replacement recommendation to be automatically promoted in the same run.
4 open issues
1 file not reviewed
src/Migrations/20261127171256_KeepChannelOpenRecommendationHistory.Designer.cs: Generated file
What changed in this PR
This PR preserves channel-open recommendation history in NodeGuard instead of recycling past rows, and makes that history visible in Routing Management.
Changes:
- Refresh only open recommendations, expire unrefreshed rows after each run, and use each peer’s latest decision for cooldowns.
- Restrict uniqueness to open rows while retaining historical recommendations.
- Add paginated history with evidence, outcomes, and request links, plus updated tests and documentation.
| File | Description |
|---|---|
test/NodeGuard.Tests/Jobs/AutoChannelOpenJobTests.cs |
Tests recording before expiry. |
test/NodeGuard.Tests/Data/Repositories/ChannelOpenRecommendationRepositoryTests.cs |
Tests history retention, refreshes, cooldowns, and pagination. |
src/Pages/RoutingManagement.razor |
Displays recommendation history in pages of 20. |
src/Migrations/ApplicationDbContextModelSnapshot.cs |
Records the revised recommendation indexes. |
src/Migrations/20261127171256_KeepChannelOpenRecommendationHistory.Designer.cs |
Defines the migration’s target model. |
src/Migrations/20261127171256_KeepChannelOpenRecommendationHistory.cs |
Replaces global uniqueness with open-row uniqueness. |
src/Jobs/AutoChannelOpenJob.cs |
Moves recommendation expiry to the end of each run. |
src/Data/Repositories/Interfaces/IChannelOpenRecommendationRepository.cs |
Adds history queries and revises lifecycle contracts. |
src/Data/Repositories/ChannelOpenRecommendationRepository.cs |
Preserves past rows and implements history queries. |
src/Data/Models/ChannelOpenRecommendation.cs |
Updates lifecycle documentation. |
src/Data/ApplicationDbContext.cs |
Configures lookup and open-only unique indexes. |
docs/auto-channel-open.md |
Documents history, expiry, and cooldown behavior. |
Review effort: Balanced
0ad8a61 to
f3d99cb
Compare
There was a problem hiding this comment.
🔒 Automated security review — no issues found
This PR changes channel-open recommendations from one recycled row per peer to append-only history: the unique index becomes partial (Open rows only), the upsert refreshes a live Open row under a FOR UPDATE row lock and otherwise inserts, cooldowns group by peer taking the latest decision, expiry moves to the end of the job run keyed on LastEvidenceAt, and the Routing Management page adds a role-authorized, paginated history view. I attacked the surfaces triage flagged: the interpolated raw SQL is an int PK parameterized by EF's FormattableString handling (no injection); the operator-vs-job race is closed by the row lock plus reload and by UpdateIfStatus's conditional update, with the partial unique index backstopping concurrent inserts; refreshed rows carry LastEvidenceAt after the run-start cutoff, so end-of-run expiry cannot kill live rows; and history-table growth is bounded at one row per peer per job run with no attacker-controlled amplification. No exploitable defect found.
Reviewed 12 files at 3cdd5a6. Nothing to report.
Not a guarantee — one diff, no knowledge of your threat model.
🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.
There was a problem hiding this comment.
🔒 Automated security review — no issues found
This PR turns channel-open recommendations into an append-only history: one Open row per (node, peer) enforced by a new partial unique index, in-place refresh under a FOR UPDATE lock, end-of-run expiry by LastEvidenceAt, a paginated history table on the role-gated Routing Management page, and per-reserved-peer fee fields that flow into the planner's fallback outbound policy. I attacked the flagged surfaces: the raw SQL interpolates only an int id; the upsert/decision race is closed by the row lock plus atomic conditional UpdateIfStatus and DisallowConcurrentExecution on the job; expire-at-end cannot self-expire refreshed rows because Evaluate stamps a later LastEvidenceAt than the run-start cutoff; pagination is bounded, node-scoped per user, and Blazor-encoded; reserved-peer fees are validated on the only save path and re-rejected at promotion if negative. No exploitable defect found.
Reviewed 17 files at 72ee56a. Nothing to report.
Not a guarantee — one diff, no knowledge of your threat model.
🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.
72ee56a to
ca97325
Compare


Until now a node had one recommendation row per peer, recycled every time the peer qualified again, so a past promotion, dismissal or failure was overwritten by the next one. This PR keeps them all. A peer has at most one open recommendation, refreshed from run to run while it keeps qualifying. Once it is promoted, dismissed, failed or expired, that row is history and is never reused: the peer gets a new one the next time it qualifies.
To make that work the job now expires at the end of the run instead of the start. It refreshes what still qualifies and then expires the open rows it did not refresh; expiring first would have turned every still-qualifying recommendation into a history row every run. The unique index on node and peer now covers only open rows, with a plain index for lookups, and the cooldown takes each peer's latest decision since there can be several.
The Routing Management page lists the past recommendations under the open ones, in pages of 20, with the evidence each had, its outcome and its channel request. Nothing is deleted, so the table grows with every expiry and failed attempt.
Stack created with GitHub Stacks CLI • Give Feedback 💬