StockAnalysis / PROGRESS.md
igardner's picture
docs: update crash recovery handoff
8dc0b0d
|
Raw History Blame Contribute Delete
15 kB

Progress log

2026-10-30 — malformed SQLite, fresh database, and load reduction (current working tree)

User-directed changes

  • Read-only PRAGMA integrity_check found /data/app.db malformed; /app/instance/app.db passed but is a materially different dataset. The user selected a fresh empty default database, not the legacy database.
  • Verified a byte-identical SHA-256 copy of the malformed file at /data/recovery-source-app.db, then removed only /data/app.db. /app/instance/app.db was left untouched. The runtime later recreated /data/app.db, which passed a read-only integrity check. Config.ensure_data_dir() no longer imports the legacy file; SQLite startup integrity preflight reports corruption before migrations/simulation.
  • Found that the global guest-creation hook ran for sessionless /health probes. Aggregate data showed 313 non-bot users and 313 user_create events; health and static endpoints are now excluded and have regression coverage.
  • Bounded simulation to stable TestBot0–TestBot9, avoids converting real users with colliding nicknames, and emits at most one bot message per active lobby/room every 60 seconds (configurable, minimum 30 seconds).
  • Reduced successful API poll logging; lobby and room use WebSockets without redundant polling and slower 15–30 second fallback. Telemetry keeps event detail but batches up to 50 events/request and logs one summary.
  • Matchmaking participation now requires at least 3 words (configurable); shorter chat remains visible. This leaves a simple extension point for later dynamic word/phrase triggers.
  • Initial questionnaire answers are stored in the profile and answer-bearing telemetry in one transaction. Skipping later prompts preserves answers already entered; the forget action removes both profile and telemetry copies.
  • Updated README/API/agent/status/user notes. The supplied trace reports Python 3.13 while Dockerfile specifies 3.11; Dockerfile was not changed pending deployment verification.

Verification and operations

  • Python compilation, Node syntax checks, and unittest pass on disposable SQLite; tests cover full/partial onboarding persistence and deletion, fresh DB creation without legacy import, word-qualified participation, telemetry batching, and ten-account cap.
  • Tests used only disposable SQLite databases. No app/container restart was run; a Python app process was observed running after the file reappeared, and was left alone. The recovery copy remains in /data; it is malformed and has not been repaired.
  • Committed locally as 626842d fix: reset corrupt sqlite and reduce lobby load. Push is pending confirmation of the destination: configured origin points to igardner/StockAnalysis, while older project notes name another Space. No push or manual restart has happened; a push may trigger an HF rebuild.

2026-10-29 — playable game and first-visit flow

Implemented in this pass

  • Built The Midnight Parlor as a playable loop: private role, optional Investigator clue, discussion, sealed votes, reveal, elimination, replay, and a win condition. Added member-only game state/action APIs and persisted roles in GamePlayer.
  • Added backend-only configurable role definitions and a consented, numeric language-signal assignment interface. Default assignment is secure random; onboarding/chat text is not analyzed or used for roles.
  • Added a first-visit sequence with three personal prompts, skip, explicit future-use opt-in, private profile storage, telemetry redaction (lengths only), and delete-answers action.
  • Added GSAP 3.15 door/arrival timelines with SRI, reduced-motion and CSS fallbacks; the logo mark remains unchanged.
  • Added the official eight GSAP skills to .agents/skills/ using the repository's documented OpenCode install path.
  • Prevented joining full/started rooms; finished games reveal role names.

Commits and verification

  • ee34154 feat: stabilize lobby controls and matchmaking, 58d07c0 chore: add official GSAP agent skills, and 135e328 feat: add playable parlor game and player onboarding are committed and pushed to origin/main; the handoff-doc update was also committed/pushed afterward.
  • Git confirmed HEAD and origin/main matched after the latest push. No manual container restart was run; HF may build automatically from a push.
  • Python compilation, Node syntax checks for all six scripts, and four unittest cases pass on a disposable SQLite DB. Tests cover onboarding save/delete/privacy, idempotent matchmaking, role privacy, investigator clue, accusation-to-win, custom signal assignment, and template/script ID wiring.
  • No browser or live WebSocket test was possible: this environment has no Chromium, Playwright, Selenium, jsdom, or ESLint. /data/app.db and instance/app.db were not used by tests.

Explicitly not implemented

  • No model/text analyzer, player text generation, or automatic use of onboarding answers for role assignment. The future interface accepts structured numeric signals only.
  • No manual container restart was run. Pushing to the HF Space may trigger its automated build; the remote database-selection question remains from the earlier notes below.

Earlier 2026-10-29 — lobby-only recovery notes (historical)

Implemented in the working tree (not committed or deployed)

  • Changed / and /lobby to show the matchmaking lobby instead of auto-creating an Auto-Test Room; TEST_MODE now defaults to false.
  • Added persistent matchmaking entries, a five-human default threshold, leave-queue behavior, stale-entry expiry, room assignment, and lobby WebSocket events.
  • Added the looping Parlor Poll with stored rounds/votes and public vote totals only after reveal.
  • Added lobby chat over HTTP with WebSocket broadcast and polling fallback; room chat now shows send failures and rejects non-members.
  • Added protected, idempotent internal chat-generation jobs, a scripted fallback, and optional server-side OpenAI-compatible provider settings. No provider is configured by this change.
  • Made generation run on a separate worker so a slow model call cannot block matchmaking/round rotation; bounded and rate-limited queued generation jobs.
  • Moved the default SQLite path to /data/app.db where available; added additive migrations and a non-destructive copy from instance/app.db only when /data/app.db does not exist.
  • Added a startup warning when both database candidates exist so deployment logs make the selected file and unmerged legacy file visible.
  • Updated lobby/room accessibility and mobile styling, reduced noisy browser telemetry, redacted common credential patterns in logs, and updated README.md, agents.md, and STATUS.md.
  • Added queue position and stale-entry expiry, truthful WebSocket-vs-polling indicators, bounded chat DOM/deduplication memory, and stable IDs for WebSocket room messages.
  • Follow-up UI audit found .btn { display:inline-flex } could override the browser's default [hidden] presentation; added an explicit [hidden] { display:none !important } rule. Also made repeat queue POSTs truly idempotent (no new join event/reordering) and guarded duplicate in-flight clicks.
  • Added a static-asset version query to the CSS and front-end scripts so a browser cannot silently keep using the stale broken controls.
  • Added regression checks for repeated queue joins, hidden controls, and every getElementById() hook used by lobby/room JavaScript.
  • Re-ran JS syntax checks with Node and the template-hook regression test. ESLint/Ruff/Flake8 are not installed here; no dependency was added just for linting.

Verification

  • Python compilation and Node syntax checks passed.
  • Isolated Flask smoke tests passed for lobby-only entry, poll vote, queue leave/match, room access/member-only chat, telemetry persistence, internal generation auth/idempotency, and scripted generation.
  • Added tests/test_lobby_flow.py (built-in unittest, no new dependency) to keep the core lobby-to-match/generation flow reproducible; python -m unittest discover -s tests -v passes on a disposable database.
  • Tested additive migrations using an isolated copy/schema. Tests used /tmp/opencode databases, not an intentional write to either existing app database.
  • Tested the non-destructive legacy SQLite backup helper against a disposable source/target database; it preserved a committed row.

Not done / blockers for tomorrow

  • No browser-based visual, responsive, keyboard, or screen-reader QA; no live WebSocket integration test.
  • Confirmed there is no local Chromium/Chrome, Playwright, or Selenium installed, so a screenshot audit cannot be honestly claimed in this environment.
  • No real chat model/provider configured or tested; generation currently uses the deterministic scripted fallback unless provider secrets/settings are supplied.
  • No deploy, commit, push, or container restart was performed.
  • Database choice needs review before deployment: read-only inspection found /data/app.db with 806 users, 1 room, 3 room messages, and 1,584 telemetry rows; /app/instance/app.db has 3,980 users, 1,311 rooms, 6,018 memberships, 142,201 room messages, and 11,481 telemetry rows. These are materially different datasets. The code defaults to /data/app.db (unless DATABASE_URL overrides it) and will not merge the instance DB when the target exists. Do not merge or overwrite either file blindly; confirm which dataset is authoritative first.
  • The new runtime assumes the current one-worker Gunicorn configuration. If worker count is increased, add a cross-process scheduler lease/external worker before scaling.

Tomorrow: start here

  1. Check the actual deployment's DATABASE_URL/DATA_DIR and HF volume mount before starting the app. The local code default does not prove which file a running deployment currently uses.
  2. Decide with the user which SQLite dataset is authoritative. Back up both files before any migration or merge; do not concatenate SQLite files or overwrite either one.
  3. Once chosen, test the additive migration against a copy of that exact database under /tmp/opencode, verify representative users/rooms/messages, then only switch runtime storage with explicit approval.
  4. Run the app against a disposable database and do desktop/mobile browser QA at 320, 375, 768, and 1440px. Check queue join/leave, round rollover/reveal, five-user match, reconnect, lobby chat, room chat, keyboard focus, and reduced motion.
  5. Run an actual WebSocket integration test. The current checks covered HTTP/polling and emitted broadcast code paths, not a live socket handshake.
  6. Only wire a real chat provider if the user supplies/configures its URL, model, and secret. The provider-neutral service and protected job API already exist; deterministic fallback is the current behavior.
  7. Review git diff with the user, then commit/deploy only when explicitly asked. No commit/push/restart has happened in this session.

Key implementation files

  • Backend: services/lobby.py, services/lobby_chat.py, routes/lobby.py, routes/websocket.py, models.py, config.py.
  • Frontend: templates/index.html, templates/room.html, templates/base.html, static/js/lobby.js, static/js/room.js, static/css/app.css.
  • API/config docs: agents.md, README.md; current handoff/status: STATUS.md.

Running notes for the StockAnalysis rebuild. Every entry below is committed and pushed before the next step starts, so the work survives a reset.

2026-10-25

  • Read the HF docs for Spaces as Agent Tools and Spaces as API endpoints, plus Gradio's API-visibility and curl pages. Confirmed the live contract: agents.md -> /gradio_api/info -> POST /gradio_api/call/v2/<endpoint> -> GET /gradio_api/call/<endpoint>/<event_id>.
  • Confirmed api_visibility="private" hides an event from the API docs and Gradio clients but does not block direct HTTP.
  • Baseline repo had only the old smoke-test dashboard. No earlier stock-analysis work was present in the working tree or in git history.
  • Ignored local session transcripts and agent tooling so they are not published to the public Space repo.
  • Decision: no local servers, no /tmp, no kill/pkill, no process cleanup. Verification is limited to static checks and offline unit checks.
  • Added external_api.py: reads EXTERNAL_API_URL, sends the ticker request with HF_TOKEN when present, passes JSON through unchanged, and wraps non-JSON or error responses. Includes STOCK_MODEL_ID when set.
  • Added local_parser.py: optional OpenAI-compatible local model call (Ollama/vLLM/LM Studio) that converts non-JSON upstream text into JSON. It is opt-in via LOCAL_PARSER_URL and LOCAL_PARSER_MODEL, and its prompt forbids inventing data.
  • Ran offline checks with mocked responses for JSON, text, error, and parse paths. No servers started, no processes touched, no /tmp files.
  • Rewrote app.py around stock analysis: status pills, ticker/horizon/risk/ question form, JSON result, raw-response accordion, API/agents accordion, and a fixed bottom-right smoke-test panel that keeps the live model table, history, download, and settings.
  • Only the Analyze event is public (api_name="analyze"). Smoke-test and page load events are marked private, with a documented caveat that private is not a security boundary for direct HTTP.
  • Added agents.md with the HF one-shot block, the concrete /analyze request/poll flow, three-output contract, curl and gradio_client examples, and the error/response shapes.
  • python -m py_compile app.py external_api.py local_parser.py smoke.py passed.
  • Rewrote README.md for the stock-analysis app. Kept the 30-model snapshot, the last smoke-test result, the dynamic selection rules, storage layout, and smoke-test settings. Added the agent contract, configuration table, custom model slot, local parser setup, external adapter contract, and disclaimer.
  • Expanded agents.md with explicit boundaries, promises, input/output rules, error and retry guidance, auth/data-handling rules, discovery notes, and a clear no-guarantee disclaimer. README now points at those details.
  • Pushed the full local history to origin/main (1beeba1..4567005). The session HF_TOKEN was used from the environment through a one-shot credential helper; it was not written to the repo or a credential store.
  • Live schema still showed the old app after the push. Checked the runtime API: devMode: true, runtime SHA f5c9dc1, repo SHA 34ae3c8.
  • Researched the documented cause instead of polling blindly. The HF Spaces debugging reference says: in dev mode the Space does not rebuild on commits; disable dev mode and factory-reboot to apply the pushed state. Forum reports show the same stale-runtime-SHA pattern in dev mode.
  • Next: disable dev mode through the Space API and run the documented factory reboot, then verify the new analyze schema once.