Repository navigation
Fix operator CLI exit codes, claim-list query validation, stats DTO drift, and feed-definitions caching - #663
Open
Joel234-png wants to merge 1 commit into
Conversation
…rift, and feed-definitions caching Refract-Protocol#597: operator-cli.ts and oracle-ops.ts (src/oracle/consensus/cli.ts) each only ever used two ad-hoc exit codes in practice. Added a shared contract (src/common/cli-exit-codes.ts: 0 success, 1 usage error, 2 remote/operation failure) and made every process.exit / CliResult.exitCode in both scripts conform to it, distinguishing bad invocations (unknown flag/command, missing required arg, missing --yes confirmation, malformed reconstruct query) from failures while actually running (DB error, unreadable/malformed evidence ledger). docs/relayer-key-compromise-runbook.md does not actually invoke either CLI, so the codes are documented in README.md's existing "Operator CLI" section instead, which already documents real invocations of operator-cli.ts. Refract-Protocol#596: ListClaimsDto (src/claim/dto/list-claims.dto.ts) is dead code - the real list-claims routes (GET /claims/holder/:address, GET /claims/recent) consume PageQueryDto. No global ValidationPipe exists in src/main.ts at all (src/common/pagination.spec.ts's own "Mirrors main.ts's global pipe" comment confirms one was assumed to exist); enabling it now app-wide was judged too risky for this issue's scope given 23 controllers with no prior validation coverage, so ClaimController gets its own `@UsePipes(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true }))`, matching the existing per-controller pattern already used by ConsensusController. An unknown query key on either route now returns 400 naming that key; existing limit/cursor filters are unaffected. test/contracts/consumers/refract-frontend/ does not exist in this repo, so there was no fixture to update. Refract-Protocol#595: GET /claims/stats and /claims/stats/ops already return the typed ClaimStatsResponseDto / ClaimStatsOpsResponseDto via plainToInstance, not an ad-hoc object - that part of the issue didn't match reality. The real stats source is ClaimService.getStats() (an in-memory counter snapshot), not claim.repository.ts, which has no such query. The actual drift: getStats() computes deadLetterClaims and settlementRetries but neither DTO exposed them, so they were silently dropped even from the ops-only response. Added both as @expose()d fields on ClaimStatsOpsResponseDto only, keeping the public DTO unchanged (consistent with settlementConfigured's existing public/ops split). src/index.ts is an unrelated, broken legacy entrypoint (imports ./utils/logger and ./services/heartbeat, neither of which exists, and isn't package.json's actual "main") rather than a types-export barrel, so nothing was exported from it; this repo has no types/exports field in package.json either. Refract-Protocol#594: feed-definitions.service.ts already has a self-refreshing in-process cache (`this.cache`), but its only real callers (getEnabledFeeds, getCachedFeed) have zero callers anywhere else in the codebase - the "every oracle tick" read path the issue describes isn't actually wired to this service. The real, closest-available fix: listLatest() and getLatest(), which ARE called on every admin request (FeedsController's GET routes), hit the database on every call despite the set changing rarely and the cache already existing. Both now read from the cache; update()'s optimistic- concurrency check was moved to a new private fetchLatestFromDb() so it keeps reading the authoritative row (a stale cached version there would silently defeat the conflict check). Did not reuse the existing Redis-backed CacheService - it's TTL/cross-instance by design, which this issue's own scope explicitly says isn't needed, and would be a worse fit than the already-correct, write-invalidated per-process Map. Closes Refract-Protocol#594 Closes Refract-Protocol#595 Closes Refract-Protocol#596 Closes Refract-Protocol#597
|
@Joel234-png Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#597: operator-cli.ts and oracle-ops.ts (src/oracle/consensus/cli.ts) each only ever used two ad-hoc exit codes in practice. Added a shared contract (src/common/cli-exit-codes.ts: 0 success, 1 usage error, 2 remote/operation failure) and made every process.exit / CliResult.exitCode in both scripts conform to it, distinguishing bad invocations (unknown flag/command, missing required arg, missing --yes confirmation, malformed reconstruct query) from failures while actually running (DB error, unreadable/malformed evidence ledger). docs/relayer-key-compromise-runbook.md does not actually invoke either CLI, so the codes are documented in README.md's existing "Operator CLI" section instead, which already documents real invocations of operator-cli.ts.
#596: ListClaimsDto (src/claim/dto/list-claims.dto.ts) is dead code - the real list-claims routes (GET /claims/holder/:address, GET /claims/recent) consume PageQueryDto. No global ValidationPipe exists in src/main.ts at all (src/common/pagination.spec.ts's own "Mirrors main.ts's global pipe" comment confirms one was assumed to exist); enabling it now app-wide was judged too risky for this issue's scope given 23 controllers with no prior validation coverage, so ClaimController gets its own
@UsePipes(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true })), matching the existing per-controller pattern already used by ConsensusController. An unknown query key on either route now returns 400 naming that key; existing limit/cursor filters are unaffected. test/contracts/consumers/refract-frontend/ does not exist in this repo, so there was no fixture to update.#595: GET /claims/stats and /claims/stats/ops already return the typed ClaimStatsResponseDto / ClaimStatsOpsResponseDto via plainToInstance, not an ad-hoc object - that part of the issue didn't match reality. The real stats source is ClaimService.getStats() (an in-memory counter snapshot), not claim.repository.ts, which has no such query. The actual drift: getStats() computes deadLetterClaims and settlementRetries but neither DTO exposed them, so they were silently dropped even from the ops-only response. Added both as @expose()d fields on ClaimStatsOpsResponseDto only, keeping the public DTO unchanged (consistent with settlementConfigured's existing public/ops split). src/index.ts is an unrelated, broken legacy entrypoint (imports ./utils/logger and ./services/heartbeat, neither of which exists, and isn't package.json's actual "main") rather than a types-export barrel, so nothing was exported from it; this repo has no types/exports field in package.json either.
#594: feed-definitions.service.ts already has a self-refreshing in-process cache (
this.cache), but its only real callers (getEnabledFeeds, getCachedFeed) have zero callers anywhere else in the codebase - the "every oracle tick" read path the issue describes isn't actually wired to this service. The real, closest-available fix: listLatest() and getLatest(), which ARE called on every admin request (FeedsController's GET routes), hit the database on every call despite the set changing rarely and the cache already existing. Both now read from the cache; update()'s optimistic- concurrency check was moved to a new private fetchLatestFromDb() so it keeps reading the authoritative row (a stale cached version there would silently defeat the conflict check). Did not reuse the existing Redis-backed CacheService - it's TTL/cross-instance by design, which this issue's own scope explicitly says isn't needed, and would be a worse fit than the already-correct, write-invalidated per-process Map.Closes #594
Closes #595
Closes #596
Closes #597
Summary
Type of change
Checklist
.envvalues committedNotes for reviewers