fix(submit): preserve source-scoped multi-machine submissions#388
fix(submit): preserve source-scoped multi-machine submissions#388IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
Conversation
|
@IvGolovach is attempting to deploy a commit to the Inevitable Team on Vercel. A member of the Team first needs to authorize it. |
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.
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.
…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)
|
What is the update on this feature? Would love it! |
Thanks for checking in- yes, this is still active, and I really appreciate the interest in this feature. The implementation from this PR was carried forward into #389, which is the current landing branch for it. It preserves the original authored work from here, and that is the branch to watch for merge progress :) |
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