The oracle comparison clean-up job is written and never started

Open Beginner friendly
#688 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, redis, typescript

Research direction

Read src/jobs/oracleRetention.ts and the “Lending rate retention” block in src/index.ts (lines 220–249), then inspect src/__tests__/oracleRetention.test.ts for the existing test patterns. Wire startup pruning and the queue/worker into main(), with an hourly unref'd timer fallback if queue creation fails. Done when tests cover the startup wiring and Redis fallback, prune failures are logged without stopping the service, and old rows are pruned hourly.

Written by the indexing model from the issue text.

Description

area:database difficulty:easy help wanted points:100 Stellar Wave
Background

src/jobs/oracleRetention.ts is a complete retention job for the
oracle_comparisons table. It has a batched delete
(pruneOldOracleComparisons), a per-network wrapper
(pruneAllNetworksOracleComparisons), a queue, a worker and a schedule
(createOracleRetentionQueue, startOracleRetentionWorker,
scheduleOracleRetention). It has a test, src/__tests__/oracleRetention.test.ts.

Nothing calls it. src/index.ts starts the snapshot, lending-rate and
partition jobs, but it never imports oracleRetention. A search of src/ and
scripts/ finds no caller outside the file itself.

Meanwhile src/services/oracleComparison.ts (line 173) inserts into
oracle_comparisons on every comparison run. So the table only grows.

What to build

Start the job from main() in src/index.ts, the same way the lending-rate
job is started a few lines above:

  • run one prune at boot, inside a try/catch that logs and continues;
  • try to start the queue and worker;
  • if Redis is not available, close what was created and fall back to an hourly
    in-process timer with .unref().

Redis being down must not stop the service and must not stop the pruning.

Where to look
  • src/jobs/oracleRetention.ts
  • src/index.ts, the "Lending rate retention" block (lines 220–249) as the
    pattern to copy
  • docs/RUNBOOK.md if it lists the background jobs
Done when
  • oracle_comparisons rows older than ORACLE_COMPARISON_RETENTION_DAYS
    are removed on a running instance (show this on a local database)
  • The job still runs hourly when Redis is down
  • A failed prune is logged and does not crash the process
  • A test covers the wiring (job started, fallback used when the queue
    cannot be created)

Drips Wave · Complexity: Easy · 100 points


Repo: Divinity-Labs/Lens. Install with npm ci, typecheck with
npx tsc --noEmit, test with npm test. Tests are vitest, not jest.
Running jest reports zero tests and proves nothing.

You cannot reach production. Contributors have no access to the deployed
service or its database. Everything must be provable on your own machine. The
Postgres and Redis in docker-compose.yml are enough.

Five generated files are compared byte for byte: openapi.json /
openapi.yaml, the generated tables in README.md, schema.graphql,
clients/typescript/src/schema.d.ts, and the Prisma baseline
prisma/migrations/0_init/migration.sql. The commands that regenerate them are
in the scripts section of package.json (openapi:gen, readme:gen,
graphql:schema:gen, client:gen) and in docs/database-migrations.md. If a
guard fails and the diff looks identical, it is Windows line endings (CRLF),
not your change.

The database is migrated with prisma migrate deploy. Never use
prisma db push. A change to prisma/schema.prisma needs a new migration
folder and a regenerated baseline, or CI fails. Schema drift is not repaired at
start-up any more.

Start-up must stay forgiving. A boot-time check must never stop the whole
service because one optional dependency (Redis, one network's RPC, one venue)
is down. Report it, do not exit.

A CI job that fails at the install step hides every later step. If your
change touches dependencies, check that the steps after install really ran.

Do not weaken a test to make it pass. Never put a secret, a connection
string, or an RPC URL that contains an API key in code, logs, tests or the PR.
Never shorten a Stellar address or contract id; copy it whole from the repo.



Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Dominant language
TypeScript
Stars
4
Forks
71
Avg merge
2d 6h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Divinity-Labs/Lens

All issues in Divinity-Labs/Lens

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.