Repository navigation
Validate consensus windows, admission rejections, sandbox DB skip, CLI help - #661
Open
ZeeTech374 wants to merge 1 commit into
Open
ZeeTech374 wants to merge 1 commit into
ZeeTech374 wants to merge 1 commit into
Conversation
…I help Refract-Protocol#579: The real "consensus window" implementation lives in src/oracle/windowing/ (window-config.ts, consensus-window.service.ts), not in consensus.dto.ts as the issue described — that DTO file has no window-duration field at all. Added assertValidFeedWindowConfig(), called from getFeedConfig() on every lookup, rejecting any FeedWindowConfig whose windowDurationMs is <= 0 by name, which closes the "never closes" stall this issue describes for the real window-selection path. Also added a SetConsensusWindowDto with @ISINT() @min(1) windowDurationMs in consensus.dto.ts itself, matching the issue's literal ask for a DTO-boundary rejection, as a forward-looking surface for when window duration becomes settable through the API; nothing currently calls it, but it exists for that boundary to validate against once it is. Refract-Protocol#578: future-dated readings are already rejected in two independent places (ReadingAdmissionGate.admit in oracle-timestamp.ts, and FreshnessGuard in freshnessPolicy.ts) — left both untouched, including the staleness/too-old path. The real gap was the issue's second requirement: rejections were only logged via Logger.warn, never recorded anywhere an operator could query by provider. Added EvidenceKind "rejected_reading", a rejectedReadingToEvidence helper, and OracleEvidenceBuffer.recordRejection() (never-throwing, like the existing recordReadings()). Wired it into OracleEventRepository's admitForInsert() rejection branch via an @optional() constructor parameter, so no existing instantiation site breaks. Note: OracleEvidenceBuffer itself is not currently registered as a NestJS provider anywhere in this app (it has no @Injectable(), and no concrete EvidenceStore implementation actually matches its interface — the only candidate file, oracle-event.repository.spec.ts, tests a `persist`-based class shape that doesn't match the real OracleEventRepository in this file, a pre-existing drift unrelated to this issue). Building full end-to-end DI wiring would mean writing a real EvidenceStore/EvidenceSpool backing from scratch, well beyond this issue's scope — the capability is real and ready to wire in once a store exists. Refract-Protocol#580: isSandboxMode() is already respected by oracle-bootstrap.module.ts as a working precedent, but DatabaseService.onApplicationBootstrap() always built a real Pool and ran a 5-retry/~30s exponential-backoff probe regardless of sandbox mode, and DbService's "graceful when DATABASE_URL is missing" fallback was masked by the typed config factory's hardcoded localhost default, which populated even when the env var was never set. In sandbox mode, DatabaseService now skips pool creation entirely (query()/ getClient() throw a clear, named error if actually called; getPoolStats() returns zeros instead of throwing), and DbService now only honors an explicitly-set DATABASE_URL under sandbox mode rather than silently falling back to the config default. Non-sandbox behavior and validation are unchanged in both files. Note: src/config/env.schema.ts is completely empty despite configuration.ts importing and calling `validateEnv(process.env)` from it — a separate, pre-existing, repo-wide defect that will throw at config-factory invocation in every mode, not just sandbox, and is far outside this issue's scope to reconstruct blind (configuration.ts also has internally inconsistent typing for at least one field, EVENT_INDEXER_ENABLED, used as both a boolean and a string in the same file). This fork's two DB-layer changes are self-contained and don't depend on that factory running. Also, no startup banner exists anywhere in this clone's src/ (a different fork's prior banner work, if any, is not present here), so the "prints the banner" half of this issue's Done-when criterion can't be demonstrated end-to-end from this branch alone — out of scope for Refract-Protocol#580's named files (database.service.ts, db.service.ts) and belongs to separate banner work. Refract-Protocol#581: added the missing docs/oracle-feeds.example.json reference and a one-line example invocation to the --help text in src/oracle/config/oracle-config-lint.cli.ts. The example file already exists at that path. Closes Refract-Protocol#578 Closes Refract-Protocol#579 Closes Refract-Protocol#580 Closes Refract-Protocol#581
|
@ZeeTech374 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.
#579: The real "consensus window" implementation lives in src/oracle/windowing/ (window-config.ts, consensus-window.service.ts), not in consensus.dto.ts as the issue described — that DTO file has no window-duration field at all. Added assertValidFeedWindowConfig(), called from getFeedConfig() on every lookup, rejecting any FeedWindowConfig whose windowDurationMs is <= 0 by name, which closes the "never closes" stall this issue describes for the real window-selection path. Also added a SetConsensusWindowDto with @ISINT() @min(1) windowDurationMs in consensus.dto.ts itself, matching the issue's literal ask for a DTO-boundary rejection, as a forward-looking surface for when window duration becomes settable through the API; nothing currently calls it, but it exists for that boundary to validate against once it is.
#578: future-dated readings are already rejected in two independent places (ReadingAdmissionGate.admit in oracle-timestamp.ts, and FreshnessGuard in freshnessPolicy.ts) — left both untouched, including the staleness/too-old path. The real gap was the issue's second requirement: rejections were only logged via Logger.warn, never recorded anywhere an operator could query by provider. Added EvidenceKind "rejected_reading", a rejectedReadingToEvidence helper, and OracleEvidenceBuffer.recordRejection() (never-throwing, like the existing recordReadings()). Wired it into OracleEventRepository's admitForInsert() rejection branch via an @optional() constructor parameter, so no existing instantiation site breaks. Note: OracleEvidenceBuffer itself is not currently registered as a NestJS provider anywhere in this app (it has no @Injectable(), and no concrete EvidenceStore implementation actually matches its interface — the only candidate file, oracle-event.repository.spec.ts, tests a
persist-based class shape that doesn't match the real OracleEventRepository in this file, a pre-existing drift unrelated to this issue). Building full end-to-end DI wiring would mean writing a real EvidenceStore/EvidenceSpool backing from scratch, well beyond this issue's scope — the capability is real and ready to wire in once a store exists.#580: isSandboxMode() is already respected by oracle-bootstrap.module.ts as a working precedent, but DatabaseService.onApplicationBootstrap() always built a real Pool and ran a 5-retry/~30s exponential-backoff probe regardless of sandbox mode, and DbService's "graceful when DATABASE_URL is missing" fallback was masked by the typed config factory's hardcoded localhost default, which populated even when the env var was never set. In sandbox mode, DatabaseService now skips pool creation entirely (query()/ getClient() throw a clear, named error if actually called; getPoolStats() returns zeros instead of throwing), and DbService now only honors an explicitly-set DATABASE_URL under sandbox mode rather than silently falling back to the config default. Non-sandbox behavior and validation are unchanged in both files. Note: src/config/env.schema.ts is completely empty despite configuration.ts importing and calling
validateEnv(process.env)from it — a separate, pre-existing, repo-wide defect that will throw at config-factory invocation in every mode, not just sandbox, and is far outside this issue's scope to reconstruct blind (configuration.ts also has internally inconsistent typing for at least one field, EVENT_INDEXER_ENABLED, used as both a boolean and a string in the same file). This fork's two DB-layer changes are self-contained and don't depend on that factory running. Also, no startup banner exists anywhere in this clone's src/ (a different fork's prior banner work, if any, is not present here), so the "prints the banner" half of this issue's Done-when criterion can't be demonstrated end-to-end from this branch alone — out of scope for #580's named files (database.service.ts, db.service.ts) and belongs to separate banner work.#581: added the missing docs/oracle-feeds.example.json reference and a one-line example invocation to the --help text in
src/oracle/config/oracle-config-lint.cli.ts. The example file already exists at that path.
Closes #578
Closes #579
Closes #580
Closes #581
Summary
Type of change
Checklist
.envvalues committedNotes for reviewers