Skip to content

Preserve active solves across deploys#178

Merged
coder13 merged 9 commits into
masterfrom
agent/deploy-safe-reconnect
Jul 11, 2026
Merged

Preserve active solves across deploys#178
coder13 merged 9 commits into
masterfrom
agent/deploy-safe-reconnect

Conversation

@coder13

@coder13 coder13 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • preserve authenticated room membership through brief socket restarts, including the current scramble, waiting/competing state, and room admin
  • keep an in-progress browser timer mounted while the room socket reconnects
  • save completed solves in a local outbox until the client rejoins the room and receives a persistence acknowledgement
  • make result submission idempotent with stable submission IDs and immutable attempt keys, including recovery when room advancement fails after the result is saved
  • disable the legacy Grand Prix mode unless GRAND_PRIX_ENABLED=true is explicitly configured
  • expose dependency-aware API and socket health endpoints; optional PostgreSQL failure reports degraded without taking the primary MongoDB/Redis path out of service
  • classify deploys by changed paths, roll socket before API/static when both change, and skip application replacement for documentation-only changes
  • wait for backing-service health before migrations and restore exact pre-deploy images with the previous Compose configuration if rollout readiness fails

User-visible behavior

Socket deploys still cause a brief transport reconnect, but they no longer end the user's room session. A solve already in progress continues timing locally. If it finishes while disconnected, the next solve is blocked and the completed time is retained on the device until it can be submitted safely.

The local result is marked as delivery-attempted before its first emit, so an uncertain submission cannot be discarded accidentally. A definitive server rejection remains discardable across refreshes. Invalid manual times stay in the input for correction and never enter the outbox.

Grand Prix rooms are hidden and rejected in production while the mode is disabled. Normal rooms are unaffected.

Deployment behavior

DEPLOY_TARGET=auto resolves documentation-only changes to none, browser-only changes to api, and shared/server/deployment changes to all. Missing runtime containers promote an automatic deploy to a full bootstrap. Full deploys replace socket before API/static, health-check each service, and gracefully reload nginx after each handoff.

Rollback tags preserve the exact image IDs that were running before deployment. Rollback also uses Compose files from the pre-deploy commit, so a bad command, environment definition, or health check can be reverted along with the image. Database migrations are intentionally not reversed and must remain backward-compatible.

Validation

  • manually restarted the API and socket processes multiple times during active solves; timing continued and completed results submitted after reconnect
  • yarn lint
  • yarn test — 55 client tests and 70 server tests
  • yarn build
  • Prisma schema validation, migration deploy, and drift check against local PostgreSQL
  • scripts/test-deploy-classifier.sh
  • scripts/test-deploy.sh
  • Bash syntax checks for all deploy scripts
  • production and development Compose parsing with Docker's default context
  • yarn cypress:run — 6 tests across both specs
  • git diff --check

coder13 added 9 commits July 9, 2026 16:07
Mirror new application data and pseudonymous metrics into PostgreSQL while MongoDB remains the source of truth. Add versioned migrations, Compose services, retention controls, and focused coverage for the migration path.
Describe the migration by its schema responsibility rather than the temporary dual-write rollout strategy. Keep the initial username index compatible with the final schema when migrations are replayed.
Replace the custom migration registry with a canonical Prisma schema and Prisma Migrate history. Run migrate deploy as a one-shot production service and enforce schema validation and drift checks in CI.
Normalize solve penalties and add stable cursor ordering. Mirror only dirty room participants, attempts, and results to avoid replaying room history on every save.
Move shared event and protocol constants to JSON so the Vite client uses ESM while the CommonJS server reads the same data. Import the Material UI theme provider through its supported direct package entry to avoid the optimizer's broken barrel initialization.
Add PostgreSQL dual writes and room metrics
Delay disconnect cleanup while clients reconnect and reconcile membership through the shared Redis adapter. Deploy application services sequentially without recreating stateful dependencies.
Expose dependency-aware HTTP readiness endpoints and a Socket.IO health round trip. Point Compose and nginx at the explicit health routes for deployment verification.
Persist and retry completed solves with idempotent acknowledgements across socket reconnects.

Roll services selectively with health-gated rollback so routine deploys minimize room disruption.
@coder13 coder13 changed the title Preserve room sessions across deploys Preserve active solves across deploys Jul 11, 2026
@coder13 coder13 changed the base branch from dev to master July 11, 2026 05:07
@coder13 coder13 marked this pull request as ready for review July 11, 2026 05:07
@coder13 coder13 merged commit bc91fa2 into master Jul 11, 2026
6 checks passed
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