Skip to content

CUR2-1984: sui transfers refactor#9540

Merged
tomfutago merged 13 commits intomainfrom
CUR2-1984-sui-transfers-refactor
Apr 17, 2026
Merged

CUR2-1984: sui transfers refactor#9540
tomfutago merged 13 commits intomainfrom
CUR2-1984-sui-transfers-refactor

Conversation

@tomfutago
Copy link
Copy Markdown
Contributor

Thank you for contributing to Spellbook 🪄

Please open the PR in draft and mark as ready when you want to request a review.

Description:

[...]


quick links for more information:

@github-actions github-actions bot added WIP work in progress dbt: tokens covers the Tokens dbt subproject labels Apr 7, 2026
@tomfutago
Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Medium Risk
Changes incremental anchor reconstruction for tokens_sui_object_event_deltas and modifies supply-row filtering/ranking in tokens_sui_base_transfers, which can affect transfer correctness around window boundaries and mint/burn semantics.

Overview
Adds a new incremental helper model, tokens_sui_coin_object_anchor_state, that stores the latest Coin<T> object state per object_id + block_month and wires it into tokens_sui_object_event_deltas so incremental runs can seed boundary anchors without rescanning full historical object history.

Updates tokens_sui_base_transfers to include owner_net_type in output and adjusts the supply-matching ranking so legacy Created/Deleted rows are dropped before residual reconciliation rows when event-native mint/burn rows exist.

Extends seeds and schema/tests to cover the new anchor-state helper and new boundary cases, and shifts sui_transfer_start_date to 2025-10-01 in multiple models/tests for bounded-history CI validation.

Reviewed by Cursor Bugbot for commit 02719e8. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test date accidentally committed, skipping years of data
    • Restored sui_transfer_start_date to 2023-04-12 in both affected Sui transfer models and removed the CI-only test date/comment.

Create PR

Or push these changes by commenting:

@cursor push d952c08c12
Preview (d952c08c12)
diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql
--- a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql
+++ b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql
@@ -12,7 +12,7 @@
   )
 }}
 
-{% set sui_transfer_start_date = '2026-01-01' %} -- just ci test
+{% set sui_transfer_start_date = '2023-04-12' %}
 
 with
 

diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql
--- a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql
+++ b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql
@@ -12,7 +12,7 @@
   )
 }}
 
-{% set sui_transfer_start_date = '2026-01-01' %} -- just ci test
+{% set sui_transfer_start_date = '2023-04-12' %}
 {% set incremental_time = var('DBT_ENV_INCREMENTAL_TIME') | int %}
 {% set incremental_time_unit = var('DBT_ENV_INCREMENTAL_TIME_UNIT') %}
 {% set incremental_anchor_horizon_sql %}

You can send follow-ups to the cloud agent here.

@tomfutago tomfutago marked this pull request as ready for review April 7, 2026 12:50
@github-actions github-actions bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Apr 7, 2026
@tomfutago tomfutago requested review from 0xRobin April 7, 2026 12:50
@tomfutago
Copy link
Copy Markdown
Contributor Author

bugbot run

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test-only start date committed to production models
    • Restored sui_transfer_start_date to 2023-04-12 in the three affected production Sui transfer models and removed the temporary CI-only override comment.

Create PR

Or push these changes by commenting:

@cursor push af641b9725
Preview (af641b9725)
diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql
--- a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql
+++ b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_base_transfers.sql
@@ -12,7 +12,7 @@
   )
 }}
 
-{% set sui_transfer_start_date = '2025-10-01' %} -- just ci test
+{% set sui_transfer_start_date = '2023-04-12' %}
 
 with
 

diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_coin_object_anchor_state.sql b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_coin_object_anchor_state.sql
--- a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_coin_object_anchor_state.sql
+++ b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_coin_object_anchor_state.sql
@@ -11,7 +11,7 @@
   )
 }}
 
-{% set sui_transfer_start_date = '2025-10-01' %} -- just ci test
+{% set sui_transfer_start_date = '2023-04-12' %}
 
 with
 

diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql
--- a/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql
+++ b/dbt_subprojects/tokens/models/transfers_and_balances/sui/tokens_sui_object_event_deltas.sql
@@ -14,7 +14,7 @@
   )
 }}
 
-{% set sui_transfer_start_date = '2025-10-01' %} -- just ci test
+{% set sui_transfer_start_date = '2023-04-12' %}
 
 with

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 02719e8. Configure here.

@tomfutago
Copy link
Copy Markdown
Contributor Author

Regression Report: PR #9540

Models tested: 2

Scope note: CI tables were built with the current bounded window (sui_transfer_start_date = '2025-10-01'), so this is a bounded-window regression, not full-history parity.

tokens_sui_object_event_deltas

  • Row count: prod 979,001,796, ci 978,728,101 (-0.03%) -- pass
  • Daily coverage: 1 date with diffs (2026-04-16) -- acceptable timing drift
  • Key-match: ci_only 0, prod_only 273,695 -- accepted timing drift
  • Block range: bounded by CI block_date + checkpoint; unmatched rows are prod-only and concentrated on 2026-04-16
  • Uniqueness: 0 duplicate keys, 0 duplicate rows

tokens_sui_base_transfers

  • Row count: prod 864,823,811, ci 864,823,342 (-0.00%) -- pass
  • Daily coverage: 11 dates with diffs (2026-04-06..2026-04-16) -- small recent-window drift
  • Key-match: ci_only 48,677, prod_only 49,146 -- accepted expected logic change; unmatched supply-event rows 0/0
  • Block range: bounded by CI block_date + checkpoint; dominant drift is expected object_created -> ownership_balance_topup replacement, residual net drift 469 rows
  • Uniqueness: 0 duplicate keys, 0 duplicate rows

Cross-model:

  • n/a

Verification queries:

tokens_sui_object_event_deltas

tokens_sui_base_transfers

Copy link
Copy Markdown
Collaborator

@0xRobin 0xRobin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFG! How much performance improvement do you expect on the incremental?

@tomfutago
Copy link
Copy Markdown
Contributor Author

LFG! How much performance improvement do you expect on the incremental?

very rough ballpark 2-4x but let's see what happens in reality

@tomfutago tomfutago merged commit e6a7a53 into main Apr 17, 2026
2 of 3 checks passed
@tomfutago tomfutago deleted the CUR2-1984-sui-transfers-refactor branch April 17, 2026 09:33
@github-actions github-actions bot locked and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dbt: tokens covers the Tokens dbt subproject ready-for-review this PR development is complete, please review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants