Skip to content

fix: make long-history submission merges bounded - #94

Open
chsong1 wants to merge 1 commit into
sculptdotfun:mainfrom
chsong1:fix/93-submit-timeout
Open

fix: make long-history submission merges bounded#94
chsong1 wants to merge 1 commit into
sculptdotfun:mainfrom
chsong1:fix/93-submit-timeout

Conversation

@chsong1

@chsong1 chsong1 commented Jul 30, 2026

Copy link
Copy Markdown

AI둜 μž‘μ„±λœ λ‚΄μš©μž…λ‹ˆλ‹€.

Summary

Fixes #93.

Long-history re-submissions no longer perform one sequential daily_breakdowns write per day or race those uncancelled writes against a 25-second application timer. A 270-day merge now performs one conflict-safe bulk upsert, so the API does not report failure while the same submission continues and commits in the background.

This includes the timeout-response correction from #80 and fixes the underlying O(days) merge that triggers it.

Changes

  • replace the per-day update/insert loop with one upsert on the existing (submission_id, date) unique key
  • preserve the existing machine-contribution rules through mergeMachineContribution
  • remove the uncancellable Promise.race that could return a false failure after writes continued
  • recognize both timeout and timed out database error spellings as 504
  • surface failed existing-submission reads, bulk daily writes, and parent submission updates
  • treat profile projection errors as post-commit/non-fatal so an accepted submission is not reported as failed
  • add route and data-layer regressions to the default test command

Verification

  • pnpm test β€” pass
    • ccusage: 34 tests
    • streaks: 9 tests
    • 270-day merge: exactly one bulk daily write
    • bulk/parent DB errors are surfaced
    • post-commit profile error remains a successful submission
    • Database operation timed out maps to 504
  • node test/ccusage.test.mts /Users/chsong/cc.json && node --import tsx test/submissions.test.mts β€” pass against the real 270-day, 205,565,284,264-token payload from Submit reports generic 500 after long-history merge already committedΒ #93 (37 ccusage checks plus merge-path checks)
  • pnpm build β€” application compiled successfully; page-data collection then stopped because the local checkout has no GITHUB_ID, GITHUB_SECRET, NEXTAUTH_SECRET, or NEXTAUTH_URL

Notes

The bulk upsert relies on the existing unique constraint; no schema migration is required. It removes the observed timeout mechanism but does not attempt to redesign cross-request transaction/concurrency semantics, which predate this change.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@chsong1 is attempting to deploy a commit to the sculpt Team on Vercel.

A member of the Team first needs to authorize it.

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.

Submit reports generic 500 after long-history merge already committed

1 participant