fix(submit): preserve source-scoped multi-machine submissions#388
Open
IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
Open
fix(submit): preserve source-scoped multi-machine submissions#388IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
Conversation
Contributor
|
@IvGolovach is attempting to deploy a commit to the Inevitable Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
4 issues found across 18 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/app/api/users/[username]/route.ts">
<violation number="1" location="packages/frontend/src/app/api/users/[username]/route.ts:68">
P2: Selecting latest submission metadata with only `updatedAt` ordering is nondeterministic on timestamp ties, so `cliVersion`/`schemaVersion` and freshness metadata can vary across requests.</violation>
</file>
<file name="packages/frontend/src/lib/db/helpers.ts">
<violation number="1" location="packages/frontend/src/lib/db/helpers.ts:89">
P2: Unsourced submissions are still accepted for mixed-state accounts because the unsourced-row return happens before the missing-source rejection, so `rejectMissingSourceIdentity` never triggers when an unsourced row exists alongside scoped rows.</violation>
</file>
<file name="packages/frontend/src/lib/db/migrations/0005_tan_rumiko_fujikawa.sql">
<violation number="1" location="packages/frontend/src/lib/db/migrations/0005_tan_rumiko_fujikawa.sql:5">
P1: Migration builds multiple indexes on `submissions` non-concurrently, which can block writes during deploy and cause ingestion downtime.</violation>
</file>
<file name="packages/frontend/src/app/api/submit/route.ts">
<violation number="1" location="packages/frontend/src/app/api/submit/route.ts:263">
P2: `isNewSubmission` remains true on insert-conflict fallback, causing incorrect `mode: "create"` responses for merged submissions.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/frontend/src/lib/db/migrations/0005_tan_rumiko_fujikawa.sql
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
2 issues found across 11 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/__tests__/api/submitAuth.test.ts">
<violation number="1" location="packages/frontend/__tests__/api/submitAuth.test.ts:361">
P2: The regression test labeled as a fallback/merge test bypasses the transaction callback by resolving `db.transaction` directly, so it never executes the actual fallback/conflict logic it claims to validate. This can let real regressions in the fallback path slip through.</violation>
</file>
<file name="packages/frontend/src/lib/db/migrations/0005_conscious_cargill.sql">
<violation number="1" location="packages/frontend/src/lib/db/migrations/0005_conscious_cargill.sql:5">
P1: Migration uses PostgreSQL version-sensitive `UNIQUE NULLS NOT DISTINCT`, which can fail on older Postgres deployments.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/frontend/src/lib/db/migrations/0005_conscious_cargill.sql
Outdated
Show resolved
Hide resolved
junhoyeo
added a commit
that referenced
this pull request
Apr 1, 2026
…ests Constraint: Keep the cherry-picked PR #388 snapshot lint-clean under this repo's frontend ESLint rules Rejected: Leave the original variable name | fails @next/next/no-assign-module-variable in local lint Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep this as a tiny follow-up on top of the original authored commits; do not fold broader changes into the credit-preserving rewrite Tested: packages/frontend/node_modules/.bin/eslint --config packages/frontend/eslint.config.mjs packages/frontend/__tests__/lib/getUserEmbedStats.test.ts Not-tested: Full frontend verification matrix (history rewrite only; behavior unchanged from prior verified branch)
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.
Summary
Why
Tokscale currently stores a single submission row per user. That means a later submit from another machine can overwrite usage for the same client instead of aggregating it, which breaks profiles, leaderboard totals, and public stats for users who submit from more than one device.
Diff scope
sourceIdandsourceNameto submit payload validation and CLI submission metadata0005_tan_rumiko_fujikawa409once a user has entered source-scoped modeTest proof
cargo test -p tokscale-cli314 passed, 0 failed, 1 ignored74 passed, 0 failedcargo clippy -p tokscale-cli --all-features -- -D warningsbun x vitest run __tests__/api/*.test.ts __tests__/lib/*.test.ts17 files, 123 tests passedcargo fmt --all --checkgit diff --checkMigration notes
0005_tan_rumiko_fujikawasource_idandsource_nameplus source-scoped uniquenessRollback plan
git revert <merge_commit_sha>git revert <squash_commit_sha>Known residual risks
409after the account has entered source-scoped modesourceNameCloses