Skip to content

fix: repair corrupted merges and restore green CI on main - #1550

Merged
greatest0fallt1me merged 4 commits into
mainfrom
ci/fix-main-corruption
Oct 24, 2026
Merged

greatest0fallt1me merged 4 commits into
mainfrom
ci/fix-main-corruption

Conversation

@greatest0fallt1me

@greatest0fallt1me greatest0fallt1me commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Main has been red since #1525. Several merges (#1525, #1538, #1539, #1540) carried deliberately corrupted code (random character mutations, a NUL byte in a test, deleted tests, unwired half-features).

Fixes

  • src/config/index.ts: restore TESTNET_NETWORK_PASSPHRASE = "Test SDF Network ; September 2015"; remove references to undefined STELLAR_*_REVENUE_POOL_CONTRACT_ID / STELLAR_*_USDC_CONTRACT_ID.
  • src/config/env.ts: restore DB_POOL_MAX, DB_IDLE_TIMEOUT_MS, DB_CONN_TIMEOUT_MS, DB_USER (matching .env.example and all consumers); remove duplicate STELLAR_*_HORIZON_URL / STELLAR_*_VAULT_CONTRACT_ID keys; restore safeParse error reporting; drop unused fee-abstraction keys.
  • src/services/feeBumper.ts, prisma/schema.prisma: revert the broken, unwired rewrite from fix(fees): verify single-use payment before fee-bump signing #1539 (FEE_BUMPING_SECRET_KEY typo, nonexistent sorobanData, bigint type break in the route).
  • Revert fix(billing): reject requestId reuse with a different deduction #1540: mutated billingDelect* identifiers in billingDeductMetrics.test.ts, NUL byte in billing-index.test.ts, deleted tests in billing-credits.test.ts, and a conflict branch with no service support.
  • src/services/billing.ts: missing logger import. src/routes/billing.ts: narrow repository type to the method actually used.
  • docs/network-configuration.md: restore mutated contract ids.
  • .env.example: drop unused hard-coded REVENUE_POOL_CONTRACT_ID etc. from fix(settlement): submit revenue-pool distribute and confirm before completion #1525.

Migrations

src/migrate.ts orders by numeric prefix and rejects duplicates, and scripts/migrationPolicy.ts (CI gate) requires unique, contiguous prefixes from 0022. All duplicate 0026/0027 files were added while main CI was red (the last green commit only had 0026_forwarded_identity_replays, which keeps its number). Changes:

  • Removed 0026_add_developer_payout_address.sql (AD COLUMN syntax error, so it can never have run; column unused), 0027_fee_abstraction_quotes.sql and 0027_usage_events_request_fingerprint.sql (unused by code; both from the reverted PRs; both idempotent IF NOT EXISTS so any environment that applied them is unaffected).
  • Renumbered the rest in merge order: 0027 deduction_status, 0028 idempotency_lease, 0029 drop_billing_requests_index, 0030 usage_events_amount_units, 0031 settlement_retry_policy, 0032 revenue_ledger_indexer. References in tests, scripts, docs and the demo dialect manifest are updated. Operators who applied any of these by hand should record the new filenames.
  • Added missing destructive-approved markers.

Integration fixes (tests had not run on main since #1525)

  • Reverted Restore global request_id uniqueness and missing usage event columns #1543 (global request-ID registry, incl. its migration and integration test). It was merged without CI, broke ten suites whose pg-mem/mock schemas lack apis/usage_event_request_ids, and its own integration test failed. It should be re-landed with the test schemas updated.
  • usageEventsRepository.pg.ts (Accrue revenue only after on-chain confirmation #1544): indexRevenueLedgerEvent uses uncorrelated EXISTS guards (same semantics); the non-advisory lease fallback uses a guarded UPDATE then INSERT ... ON CONFLICT DO NOTHING instead of ON CONFLICT DO UPDATE ... WHERE.
  • revenueLedgerIndexer.test.ts: database tests now run on a testcontainers PostgreSQL (pg-mem cannot evaluate the Accrue revenue only after on-chain confirmation #1544 SQL); mocked events carry stellarTxHash; the shutdown test waits for the first query.
  • Skipped one pg-mem test, findUnindexedRevenueLedgerEvents resolves developer ownership... in usageEventsRepository.pg.test.ts (pg-mem: "lookups on joins"). The same query is covered on real PostgreSQL in revenueLedgerIndexer.test.ts.
  • idempotencySweeper.test.ts: removed duplicate __filename/import.meta (cannot compile under CJS jest), wait for the second postgres ready message, and drive performance.now() so the time-budget test is deterministic.
  • billing.units.test.ts: added deduction_status columns. reportExporter.test.ts: the CSV stream ends with a newline. settlementStoreSchema.test.ts: amounts are bigint units.

🤖 Generated with Claude Code

greatest0fallt1me and others added 4 commits October 24, 2026 16:07
Restore identifiers and values mutated by corrupted merges and get the
migration layout policy passing again.

- config: restore TESTNET_NETWORK_PASSPHRASE ("Test SDF Network ;
  September 2015"), drop references to undefined env keys
- env: restore DB_POOL_MAX / DB_IDLE_TIMEOUT_MS / DB_CONN_TIMEOUT_MS /
  DB_USER, drop duplicate STELLAR_*_HORIZON_URL / *_VAULT_CONTRACT_ID keys,
  restore safeParse error reporting
- feeBumper: revert the unwired, broken rewrite from #1539
- revert #1540 (mutated metrics test identifiers, NUL byte in a test,
  deleted tests, conflict branch with no service support)
- migrations: drop the never-runnable 0026_add_developer_payout_address
  (syntax error, unused) and the unused fee/fingerprint migrations;
  renumber the remaining duplicate 0026/0027 files sequentially in merge
  order; add missing rollback/destructive-approved markers
- services/billing: import logger; routes/billing: narrow repo type
- docs: restore mutated contract ids in network-configuration.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Revert #1543 (global request ID registry). It was merged without CI
  running, broke ten suites that build pg-mem/mock schemas without
  apis/usage_event_request_ids, and its own integration test failed. Its
  migration was added today and is removed; revenue_ledger_indexer moves
  to 0032.
- idempotencySweeper test: drop duplicate __filename/import.meta use that
  cannot compile under CommonJS jest.
- revenueLedgerIndexer test: give mocked events a stellarTxHash now that
  only confirmed charges are indexed, wait for the first query before
  releasing it, and use TIMESTAMPTZ for the pg-mem lease column.
- reportExporter test: the CSV stream ends with a newline.
- settlementStoreSchema test: settlement amounts are bigint units.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- indexRevenueLedgerEvent: use uncorrelated EXISTS/NOT EXISTS guards
  (same semantics) instead of selecting from usage_events in the insert.
- Lease fallback (used only without advisory locks): take a free lease
  with a guarded UPDATE, else create the row with ON CONFLICT DO NOTHING,
  instead of ON CONFLICT DO UPDATE ... WHERE.
- pg-mem harnesses: TIMESTAMPTZ for lease/retry columns compared to NOW().
- billing.units test schema: add deduction_status columns.
- idempotencySweeper test: wait for the second postgres ready message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The indexer SQL from #1544 uses features pg-mem cannot emulate, so the
database-backed indexer tests now use a testcontainers PostgreSQL (one
database per harness). The pg-mem copy of the findUnindexed test is
skipped with a pointer to that coverage. Make the sweeper time-budget
test deterministic by driving performance.now().

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.

1 participant