StockAnalysis / README.md
igardner's picture
fix: reset corrupt sqlite and reduce lobby load
626842d
|
Raw History Blame Contribute Delete
5.61 kB
metadata
title: cuddly happy game platform
colorFrom: purple
colorTo: pink
sdk: docker
pinned: false
license: cc0-1.0

cuddly happy game platform

A parlor-styled social-deduction game platform. Guests wait together in a shared matchmaking queue, answer an eerie first-visit questionnaire, and then play The Midnight Parlor: private roles, an investigator clue, discussion, accusations, reveals, and repeat rounds. The name, logo mark, and dark parlor direction are intentional.

The included social-deduction loop is a playable prototype, not the final game design. Role definitions are backend-configurable; assignment uses a shuffled fallback and accepts optional, consented structured language signals. No text analyzer or model is wired to those signals. Onboarding answers are private, skippable, and are not analyzed or used for roles in this build. The original Hugging Face inference smoke-test utility remains available at /inference as a secondary page.

Run

pip install -r requirements.txt
python app.py

The app listens on port 7860. / and /lobby both open the shared lobby. Users are not automatically dropped into a test room.

Main behavior

  • Five queued human users form a room by default (MATCHMAKING_MIN_PLAYERS). The queue count and assignment are persisted; users can leave before a match forms.
  • The Parlor Poll rotates automatically (LOBBY_ROUND_SECONDS, default 35 seconds) and reveals aggregated votes between rounds.
  • At five guests, The Midnight Parlor assigns one Mastermind, one Investigator, and Guests. Players can investigate privately, call a vote, lock accusations, review the reveal, and continue rounds until one side wins.
  • On first visit, guests are invited to answer four personal prompts, including the oddly intrusive “What's your brothers maiden name?” prompt. All submitted answers are saved together on the guest profile and in private SQLite telemetry in one transaction; skipping the remaining questions preserves answers already entered. They are not analyzed or used for role assignment here. “Forget my parlor answers” removes both stored copies; a separate opt-in records whether they may want future role personalization.
  • Role catalogs are backend-configurable via GAME_SETTINGS_JSON (role_definitions). RoleAssignmentStrategy accepts optional consented normalized trait scores, but no text analyzer or model is wired into that input yet.
  • Lobby/room messages are stored in SQLite and delivered over WebSockets, with HTTP polling as a fallback.
  • TEST_MODE defaults to true for this test Space. Simulation reuses at most 10 stable bot accounts, never creates accounts beyond that pool, and emits at most one bot message per active lobby/room per minute. Set TEST_MODE=false to disable simulation.
  • A queued guest becomes matchmaking-ready after sending a lobby message with at least MATCHMAKING_MIN_WORDS words (default 3). Shorter messages remain visible but do not qualify.
  • CC0 DiceBear avatars remain customizable in the lobby.

Storage and configuration

SQLite defaults to /data/app.db on the Hugging Face persistent volume. If it does not exist, startup creates a new empty database; it never silently imports instance/app.db. Set DATABASE_URL to use another SQLite or SQLAlchemy database; DATA_DIR changes the default data directory. Existing SQLite databases are checked with PRAGMA integrity_check before migrations or app startup. Corrupt files are not repaired or replaced automatically.

Useful settings:

Setting Default Purpose
DATABASE_URL sqlite:////data/app.db SQLAlchemy database URI
DATA_DIR /data on HF, local data/ otherwise Persistent file directory
MATCHMAKING_MIN_PLAYERS 5 Human queue threshold for forming a room
MATCHMAKING_MIN_WORDS 3 Minimum words in a lobby message to qualify as matchmaking participation
LOBBY_ROUND_SECONDS 35 Duration of an open poll round
TEST_BOT_CHAT_INTERVAL 60 Minimum simulated chat interval in seconds; values below 30 are clamped
LOBBY_CHAT_GENERATION_TOKEN unset Required bearer secret for internal generation-job endpoints
LOBBY_CHAT_API_URL unset Optional OpenAI-compatible chat completions base URL
LOBBY_CHAT_MODEL unset Optional model name; scripted fallback works without it
LOBBY_CHAT_API_KEY unset Optional server-only provider credential
GAME_SETTINGS_JSON {} Backend game configuration, including custom role definitions

See agents.md for endpoint and WebSocket contracts, including the protected chat-generation job API. Never put provider credentials in browser code or request bodies.

The first-visit door transition uses GSAP 3.15 from cdnjs with an SRI pin, a CSS fallback, and reduced-motion support. The official GSAP agent skills are installed project-locally in .agents/skills/.

Development checks

python -m py_compile app.py config.py models.py routes/*.py services/*.py
node --check static/js/lobby.js
node --check static/js/room.js
node --check static/js/gameplay.js
node --check static/js/onboarding.js
node --check static/js/arrival.js
node --check static/js/telemetry.js
python -m unittest discover -s tests -v

Telemetry is batched (up to 50 events per request) and stored in SQLite; container logs summarize batches rather than emitting one line per telemetry event. Successful polling GETs are not logged individually. Credential-like values are redacted. GET /health reports basic service status.