Skip to content

Refactor/ingest consolidation 225 - #255

Merged
Miracle656 merged 1 commit into
Divinity-Labs:mainfrom
CHKM001:refactor/ingest-consolidation-225
Oct 25, 2026
Merged

Miracle656 merged 1 commit into
Divinity-Labs:mainfrom
CHKM001:refactor/ingest-consolidation-225

Conversation

@CHKM001

@CHKM001 CHKM001 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

PR #225 Consolidate the two ingestion trees into src/ingest/

Problem

src/ingesters/ and src/ingest/ both existed and both held ingestion code — the classic SDEX / AMM / Soroswap / snapshot loops plus the TOID helper in src/ingesters/, and the venue and oracle adapters in src/ingest/. New contributors put new work in whichever directory they happened to open first, so the split persisted. There was no rule telling them which one was canonical.

Solution

One ingestion location: src/ingest/. The five classic files move into it, and src/ingesters/ is removed. The venue/oracle sub-trees (src/ingest/venues/, src/ingest/oracles/, src/ingest/cex/) stay where they are, so src/ingest/ now holds every adapter and every ingester loop under one root.

This is a pure move. No source values, price strings, venue names, or behaviour change.

Changes

Moved (100% renames, no content change in the files' own imports):

  • src/ingesters/amm.ts → src/ingest/amm.ts
  • src/ingesters/sdex.ts → src/ingest/sdex.ts
  • src/ingesters/soroswap.ts → src/ingest/soroswap.ts
  • src/ingesters/snapshot.ts → src/ingest/snapshot.ts
  • src/ingesters/toid.ts → src/ingest/toid.ts

src/ingest/ sits at the same depth as src/ingesters/ did, so each moved file keeps its existing relative imports (../config, ../metrics, ./toid) unchanged.

Deleted: src/ingesters/.

Imports updated:

  • src/index.ts — the four start*Ingester imports.
  • src/__tests__/dualNetworkAlerts.test.ts, ammIngester.test.ts, sdexIngester.test.ts, snapshotIngester.test.ts, soroswapEnabled.test.ts, soroswapIngester.test.ts, toid.test.ts.
  • tests/ingestMetrics.test.ts.

Stale path references corrected:

  • src/db.ts — comment pointing at ingesters/toid.ts.
  • docs/ingest-metrics.md — the sdex.ts link and the adapter-location note.
  • CONTRIBUTING.md — the directory tree now lists a single ingest/ entry.

Acceptance criteria

  • A single ingestion directory; src/ingesters/ is gone.
  • All imports updated — npm test green, build clean.
  • No source string changes (price_points.source values and every venue name are untouched).

Tests

  • npm test (vitest) — 58 files / 627 tests pass, 1 pre-existing skip.
  • npx tsc --noEmit — clean.
  • npm run build (prisma generate + tsc) — clean.

No test semantics changed; only import specifiers moved.

Notes for reviewers

  • Git reports all five files as 100% renames, which is the evidence that no content moved with them.
  • The only non-test source edit is src/index.ts's import block plus a comment in src/db.ts; everything else is ../ingesters/ → ../ingest/.
  • The moved files resolve to the same modules they did before, so the diff is safe to verify by import-path inspection rather than by reading the files end to end.

Closes #225

@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@CHKM001 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! 🚀

Learn more about application limits

Miracle656 pushed a commit that referenced this pull request Oct 16, 2026
…stion (#250)

Closes #218. One VenueAdapter contract covering discover, read, derive and write, with scheduling and error handling moved into the runner, and the existing adapters migrated onto it. Verified locally: tsc clean, 607 passing.

Merging this first because two other PRs build on the same ground — #255 consolidates the ingest directories and will need a rebase onto this, and #256 defines a second interface of the same name.
@Miracle656

Copy link
Copy Markdown
Collaborator

This has gone conflicting — #250 landed a couple of hours ago and moved the ingest layer onto a single VenueAdapter contract, with scheduling and error handling owned by a runner in src/ingest/venues/. That is the ground your branch is standing on, so a rebase is needed before I can review it properly.

Worth knowing before you start, so the rebase is quick rather than a surprise: src/ingesters/amm.ts, sdex.ts and soroswap.ts now have counterparts under src/ingest/venues/, and the per-adapter polling and retry code has moved into runner.ts. If your change duplicates any of that, it should get smaller.

No rush and nothing wrong with the work — rebase on main and push, and I will pick it straight up.

@CHKM001
CHKM001 force-pushed the refactor/ingest-consolidation-225 branch from 63f8227 to 19fdd4b Compare October 17, 2026 00:02
@CHKM001

CHKM001 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

DONE!

@CHKM001
CHKM001 force-pushed the refactor/ingest-consolidation-225 branch from 19fdd4b to 2e555b5 Compare October 21, 2026 01:07
@CHKM001

CHKM001 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

done

@CHKM001
CHKM001 force-pushed the refactor/ingest-consolidation-225 branch 3 times, most recently from 7e82f7c to c62295a Compare October 24, 2026 08:50
Move the remaining ingester modules out of the legacy `src/ingesters/`
directory and into the unified `src/ingest/` tree, and delete the old
re-export shims:

- `src/ingesters/snapshot.ts` → `src/ingest/snapshot.ts`
- `src/ingesters/toid.ts`     → `src/ingest/toid.ts`
- remove `src/ingesters/{amm,sdex,soroswap}.ts` (shims)

Redirect every import, test and doc reference to the new paths; no
`src/ingesters/` reference remains. The consolidation itself is a pure
move/rename plus reference updates — behaviour is unchanged.

Also fold in the fixes needed to land green on the Typecheck & build job,
each a pre-existing defect inherited from the base branch:

- package-lock.json: add the missing `node_modules/@lukeed/ms` install
  entry so `npm ci` succeeds (the committed lock was out of sync with
  package.json — `npm ci` failed "Missing @lukeed/ms from lock file").
- openapi.yaml: define the `BadRequest` response component. `/rates` (400)
  referenced `#/components/responses/BadRequest`, which was never defined,
  so `npm run client:gen` failed to resolve the $ref. Regenerated
  `openapi.json` and `clients/typescript/src/schema.d.ts` to match.
- auth.test.ts: reset the shared `webhookDeliveryFailure` prisma mocks in
  `beforeEach` (clearAllMocks does not reset implementations, so a call
  count leaked between admin tests under shuffled order).
- vitest.config.ts: set `hookTimeout` to match `testTimeout` (20s); suites
  that build the whole app in `beforeAll` can exceed the 10s hook default
  under parallel-fork contention.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@CHKM001
CHKM001 force-pushed the refactor/ingest-consolidation-225 branch from c62295a to dcae56b Compare October 24, 2026 10:13
@Miracle656
Miracle656 merged commit 2b99824 into Divinity-Labs:main Oct 25, 2026
3 checks passed
Miracle656 added a commit that referenced this pull request Oct 25, 2026
 #225)

The classic AMM, SDEX and Soroswap ingesters lived in `src/ingesters/` while
every other venue sat behind the `VenueAdapter` interface in
`src/ingest/venues/`, so there were two places to look for "how does a venue
get ingested" and two shapes to keep in step. They are one now, and the old
modules are reduced to the re-exports that keep existing imports working.

One fix on top: `openapi.yaml` defined `components/responses/BadRequest`
twice after the merge — the branch's own version and the one on `main`. Same
duplicate-key failure #604 hit earlier today: `js-yaml` refuses the file
outright, so `openapi.json` would not generate and the openapi, live-spec and
README guards all failed together without any of them naming the cause.

Kept `main`'s definition and removed the branch's. They differ: the branch's
carries an optional `code` alongside `error`, `main`'s marks `error` required.
That is a real question — an enumerated machine-readable `code` is what #437 is
for — but it should be answered once, deliberately, for every error response,
not arrive as the losing half of a merge. Nothing referenced the branch's
version, so no `$ref` changes meaning.

Regenerated `openapi.json`, the TypeScript client and the README tables.

138 test files / 1,666 tests pass; tsc clean.

Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
@Miracle656

Copy link
Copy Markdown
Collaborator

Merged as bd468c8 — this closes #225.

Having two homes for "how a venue gets ingested" — src/ingesters/ for classic AMM, SDEX and Soroswap, src/ingest/venues/ behind VenueAdapter for everything else — meant two shapes to keep in step and two places to look. Collapsing them onto the one interface, and leaving the old modules as re-exports so existing imports keep working, is the right way to do that: the consolidation lands without a flag-day rename across the repo.

One fix on top: duplicate YAML key

After merging main, openapi.yaml defined components/responses/BadRequest twice — your branch's version and the one now on main. js-yaml refuses the file outright:

duplicated mapping key   line 2087

so openapi.json would not generate, and tests/openapi.test.ts, liveSpecValidation and the README guards all failed together without any of them naming the real cause. This is the second PR today to hit it (#604 was the first), which is why it is worth saying out loud: a duplicate key is invisible on the page and fatal to the parser.

The two definitions genuinely differ:

# yours
description: Bad request — a parameter failed validation.
properties: { error: string, code: string }

# main's
description: Invalid request parameters
required: [error]
properties: { error: string }

I kept main's and removed yours, but not because yours is worse — an enumerated, machine-readable code is the better shape, and it is exactly what #437 is for. That belongs as a deliberate decision applied to every error response at once, not as the surviving half of a merge nobody inspected. Nothing $refs it differently, so no response changed meaning.

If you want that code field, #437 is where it should land.

Regenerated openapi.json, clients/typescript/src/schema.d.ts and the README tables — all three byte-compared in CI.

138 test files / 1,666 tests pass; tsc --noEmit clean.

Noobb-byte added a commit to Noobb-byte/Lens that referenced this pull request Oct 26, 2026
Resolve conflicts with main:
- db.ts: take main's upsertPricePoints (observedAt/sourceTime and the Divinity-Labs#620
  fix) and keep deriving the row id from the event identity
- history/candles: keep main's cursor pagination alongside the gap
  declaration (gaps cover the full requested window)
- openapi.yaml: restore incomplete/gaps on the candles response;
  regenerate openapi.json, README tables and the TypeScript client
- package.json, schema.prisma, README: keep both sides
- backfillService: follow toid's move to ../ingest/toid (Divinity-Labs#255)

The idempotency test is unchanged. It still fails intermittently in a full
run because SDEX trade points carry a wall-clock timestamp since Divinity-Labs#394, which
is a bug in main rather than in this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

Classic AMM and Soroswap ingesters live outside src/ingest/

2 participants