1. 15 Aug, 2026 6 commits
    • Aryan Noshirvnai's avatar
      Switch primary login to username/password, repurpose Telegram auth as account linking · c5585aed
      Aryan Noshirvnai authored
      Adds POST /auth/register and POST /auth/login (username/password, PBKDF2-hashed
      stdlib-only, no new dependency). The former phone/code Telegram flow moves to
      /auth/telegram/{request_code,login,chats,chats/{id}/music} - it now links a
      Telegram account (for the chat-scanning music-tagging feature) to an
      already-authenticated user rather than being the identity mechanism itself.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      c5585aed
    • Aryan Noshirvnai's avatar
      Replace GeoDrop with LiveLocation: live position + currently-playing song · 5bbe811c
      Aryan Noshirvnai authored
      GeoDrop was a one-off "drop a song at this exact point" pin, permanent
      once created. Redesigning it as a live broadcast instead: one row per
      user, continuously overwritten as their position and currently-playing
      song change, so nearby people see what you're listening to right now,
      not a static pin you left once.
      
      - LiveLocation model: unique per user_id, upserted on every meaningful
        location/song change plus a periodic heartbeat while sharing is on.
      - PUT /social/live-location - upsert (song_id nullable: sharing your
        position doesn't require actively playing something).
      - DELETE /social/live-location - stop sharing.
      - GET /social/live-location/nearby - other users' live positions within
        a radius, self-excluded, enriched with song/username, sorted by
        distance. Filters out anything not updated in the last 5 minutes
        (LIVE_LOCATION_STALE_AFTER) - there's no reliable way for a closing
        browser tab to notify the server with an authenticated request, so
        staleness expiry is the actual "they stopped sharing" mechanism, not
        a clean disconnect signal.
      - GET /social/live-location/{user_id}/stream - stream whatever a nearby
        user is currently playing, same cross-user reasoning as the other
        social stream endpoints.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      5bbe811c
    • Aryan Noshirvnai's avatar
      Add GET /social/posts/{id}/stream for cross-user post playback · 104986d6
      Aryan Noshirvnai authored
      A post's song_id isn't necessarily the poster's own library song, so
      playing it needed the same not-scoped-to-caller stream endpoint pattern
      already used for rooms, geo-drops, and soundmarks.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      104986d6
    • Aryan Noshirvnai's avatar
      Enrich Posts/GeoDrop responses, validate songs exist, add list/stream endpoints · 77a227a2
      Aryan Noshirvnai authored
      Posts and GeoDrop only ever returned bare song_id/user_id, had no way
      to browse posts at all (only create one or fetch one specific post's
      remix tree by id), and let you create a post/drop referencing a
      nonexistent song_id with no validation.
      
      - GET /social/posts: recent top-level posts (remixes nest under their
        parent via the existing tree endpoint instead), with a remix_count so
        the frontend doesn't need a second call to know if a post has replies.
      - Post/GeoDrop responses now include full song metadata
        (title/artist/album/coverart) and the author's username.
      - create_post/create_geo_drop now 404 if the song (or, for remixes, the
        parent post) doesn't exist instead of silently creating a dangling row.
      - GET /social/geo-drop/{id}/stream: stream a dropped song regardless of
        who uploaded it, mirroring /soundmarks/{id}/stream and
        /social/rooms/{id}/stream's same reasoning - the whole point of a
        drop is someone else finding and playing it.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      77a227a2
    • Aryan Noshirvnai's avatar
      Fix channels.py accepting user_id/owner_id from the request body · f25ef119
      Aryan Noshirvnai authored
      Every route in this router trusted a client-supplied user_id/owner_id
      instead of deriving it from the JWT like every other router in the app
      (soundmarks, social, discovery, library all use get_current_user) - any
      caller could create a channel as any user, follow/unfollow as any user,
      or post vibe-sets/stories/showcases as any user by just changing a
      number in the request body. Also none of the routes required auth at
      all, including plain reads.
      
      Adds get_current_user to every route and derives the caller's identity
      from current_user.id instead, removing the now-redundant id fields from
      every request schema.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      f25ef119
    • Aryan Noshirvnai's avatar
      Add now-playing to live rooms: full song metadata + cross-user streaming · 58f8389f
      Aryan Noshirvnai authored
      Rooms could already chat, react, and request/pass the aux, but nobody
      could actually hear anything - now_playing only ever broadcast a bare
      song_id, there was no way to stream a song you didn't upload yourself
      (the DJ's pick usually isn't the listener's own library song), and the
      DJ could set a nonexistent song_id with no validation.
      
      Adds full song metadata (title/artist/album/coverart) to both the
      snapshot and now_playing_changed broadcasts, validates the song exists
      before setting it, and adds GET /social/rooms/{id}/stream - mirrors
      /soundmarks/{id}/stream's same "shared social content, not scoped to
      the uploader" reasoning - so any room member can actually play what the
      DJ picked.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      58f8389f
  2. 12 Aug, 2026 3 commits
  3. 11 Aug, 2026 3 commits
    • Aryan Noshirvnai's avatar
      Make soundmarks with no anthem yet discoverable via /nearby · 5e02a15d
      Aryan Noshirvnai authored
      Previously /soundmarks/nearby only returned soundmarks that already
      had an active song, so a brand new soundmark (created by a super
      admin, no fallback song_id set, no proposals yet) was invisible to
      the Nearby page - there was no way for anyone to ever discover it and
      make the first proposal. Now it's included with song: null, and the
      webapp shows a "propose one" prompt instead of a play button for that
      case.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      5e02a15d
    • Aryan Noshirvnai's avatar
      Add song proposals + voting to Soundmarks, and a Nominatim geocode proxy · 8b2ac79a
      Aryan Noshirvnai authored
      Users can now propose a song for any soundmark; the most-voted
      proposal is what actually plays there, not just an admin's original
      pick. One vote per (soundmark, user), movable between proposals.
      Directly setting a soundmark's song (business/super admin) now also
      seeds a proposal with the setter's own vote, so it competes fairly
      in the same ranking instead of being a separate, un-votable channel
      that a single stray vote could trivially override - and instead of
      silently losing to the crowd the moment anyone else proposes
      something. Soundmark.song_id remains as the fallback used only while
      a soundmark has zero proposals.
      
      /soundmarks/nearby and /soundmarks/{id}/stream now resolve through
      the same popularity logic, so a soundmark that only has user
      proposals (no admin-set song_id at all) is discoverable and
      streamable too, not just admin-seeded ones.
      
      Also added GET /soundmarks/geocode, a server-side proxy to
      OpenStreetMap's free Nominatim geocoder for the webapp's upcoming
      location-picker autocomplete - proxied because Nominatim's usage
      policy requires a real, identifying User-Agent header, which browser
      JS can't set on a raw fetch().
      
      11 new tests (proposal creation/merging, vote-switching, popularity
      overriding the admin fallback, and the geocode proxy incl. failure
      handling) - 144 backend tests passing overall.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      8b2ac79a
    • Aryan Noshirvnai's avatar
      Add Soundmarks: location-tied anthems with business/super admin roles · 79bdfe8f
      Aryan Noshirvnai authored
      New feature, distinct from the existing GeoDrop (any user dropping a
      song for others to find): a Soundmark is a curated anthem tied to a
      place. One with no owner is a super-admin-curated landmark; one with
      a business_owner_id is that business's location, and only its owner
      (or a super admin) can change its anthem.
      
      - User.role ("user" | "business_admin" | "super_admin") plus
        get_current_business_admin / get_current_super_admin dependencies.
        Super admin passes both checks - same privileges, elevated.
      - New soundmarks router: nearby detection (haversine against each
        soundmark's own trigger radius, not a caller-supplied search
        radius), cross-user anthem streaming (deliberately not scoped to
        the caller owning the underlying song, unlike /library/stream),
        business-owner song assignment, super-admin CRUD, a "public
        library" search across every user's songs (no such cross-user
        endpoint existed before - everything else is locked to the
        caller), and user role management (promote/demote, with owning a
        soundmark auto-promoting a plain user to business_admin so
        ownership isn't otherwise inaccessible to them).
      - GET /auth/me so the webapp can read the caller's role.
      
      25 new tests covering role gating, ownership enforcement, cross-user
      song picking/streaming, and radius-based nearby matching. Promoted
      dev-test-user to super_admin for webapp testing.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      79bdfe8f
  4. 10 Aug, 2026 3 commits
    • Aryan Noshirvnai's avatar
      Skip re-tagging/re-storing a song a user already has in their library · a97f9454
      Aryan Noshirvnai authored
      Previously, re-uploading (or re-tagging from Telegram) a file already
      in your library created a brand new LibrarySong row and a second copy
      of the stored file every time - the IdentifiedTrack cache already
      skipped re-identifying it, but still re-ran ffmpeg tagging and wrote a
      duplicate file, and always inserted a new row. Add a fingerprint
      column to library_songs and check it (per-user) before doing any of
      that: a match now just hands back the existing entry.
      
      Dedup is per-user and keyed by the same content fingerprint already
      used for the IdentifiedTrack cache, not by title/artist text (which
      drifts across correction passes and isn't reliable for this).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      a97f9454
    • Aryan Noshirvnai's avatar
      Fix the real "can't sync to MPEG frame" cause: mutagen, not ffmpeg · f2a1dce8
      Aryan Noshirvnai authored
      The previous fix (permissive ffmpeg retry on CouldntDecodeError) never
      actually applied to this case - confirmed via the full traceback this time
      (added logger.exception in the prior commit, which paid off immediately):
      the failing file had a .mp3 extension, so it took the "already mp3, just
      copy" fast path entirely, skipping ffmpeg. The actual failure was
      mutagen.mp3.HeaderNotFoundError inside MP3(mp3_file_path, ID3=ID3) - a
      .mp3 extension doesn't guarantee mutagen's strict frame-sync scanner can
      parse the content.
      
      Now: if that direct-copy fast path produces something mutagen can't read,
      re-encode through the same permissive ffmpeg fallback (which sniffs actual
      content, not the extension) and retry once. If even that fails, raises the
      same AudioDecodeError as before for a clean user-facing message instead of
      a raw mutagen exception.
      
      Added tests/test_audio_processing.py with two real (not mocked) cases:
      real WAV audio misnamed as .mp3 (exercises the actual recovery path with
      real audio content) and pure random bytes (confirms genuinely unrecoverable
      input still fails cleanly via AudioDecodeError, not a raw exception).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      f2a1dce8
    • Aryan Noshirvnai's avatar
      Fix "Can't sync to MPEG frame": permissive ffmpeg fallback + stop leaking errors to clients · 2cb2e5a1
      Aryan Noshirvnai authored
      Confirmed from a real webapp upload (dev server log): a file Shazam
      successfully identified ("Invisible" by Duran Duran, despite the local
      AcoustID fingerprinter also struggling with the same file - symphonia's
      demuxer logged dozens of "skipping junk"/"invalid mpeg audio header"
      warnings but still recovered enough to match) then failed outright at the
      ffmpeg conversion step with "Can't sync to MPEG frame", killing the whole
      request with a 500 even though identification had already succeeded. This
      is exactly the "messy real-world MP3s" scenario the product is meant to
      handle, not an edge case worth ignoring.
      
      - audio_processing.py: on CouldntDecodeError from pydub's default (strict)
        ffmpeg invocation, retry once via a direct ffmpeg subprocess with
        -err_detect ignore_err -fflags +igndts+discardcorrupt, which tells ffmpeg
        to skip past bad frames instead of giving up. New AudioDecodeError is
        raised only if that also fails, distinct from a bare Exception so callers
        can show a clean message instead of raw ffmpeg stderr.
      - music.py: both /music/upload and /music/tag now catch AudioDecodeError
        specifically (422, clean user-facing message) and everything else via
        logger.exception + a generic 500 message - previously upload_direct did
        `raise HTTPException(500, detail=str(e))`, which is exactly the raw
        ffmpeg stderr the user saw rendered directly in the webapp's error
        banner, and logged nothing server-side for future diagnosis.
      
      Verified: full 104-test suite still passes, module imports cleanly, dev
      server restarted successfully.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      2cb2e5a1
  5. 09 Aug, 2026 17 commits
    • Aryan Noshirvnai's avatar
      Fix deploy_prod: this runner's job containers have a read-only root fs · 893240bd
      Aryan Noshirvnai authored
      Confirmed via job trace: echo "\$PROD_SSH_PRIVATE_KEY" > ~/.ssh/prod_deploy_key
      failed with "Read-only file system" writing to /root/.ssh. Moved the SSH
      key and known_hosts to /tmp instead - reliably writable regardless of a
      read-only root, unlike the home directory.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      893240bd
    • Aryan Noshirvnai's avatar
      Also skip the sidechain test in CI, not just detect_key · b47fa899
      Aryan Noshirvnai authored
      Per explicit instruction: remove any test that risks making CI take this
      long, not just the one already confirmed to hang. sidechain's shrink fix
      (sr=8000->400) tested fine locally, but this runner has proven wildly
      inconsistent - the exact same non-DSP pipeline ranged from 4 minutes to
      40+ minutes stuck at unrelated steps across back-to-back identical runs.
      Not worth trusting a single local timing over that track record. Both
      DSP-heavy tests in this file are now CI-skipped; every other test file
      was checked and doesn't touch librosa/numba/scipy/pedalboard at all.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      b47fa899
    • Aryan Noshirvnai's avatar
      Skip the numba-hanging test in CI specifically, not just disable JIT · 9a4474e8
      Aryan Noshirvnai authored
      The NUMBA_DISABLE_JIT fix from the last commit didn't fully cover this:
      librosa.feature.chroma_cqt compiles a numba @stencil kernel, and stencils
      ignore NUMBA_DISABLE_JIT entirely (unlike regular @jit) - confirmed via a
      live job trace (job 4275) that sat completely motionless for 40+ minutes
      mid-traceback, inside numba's own type-inference error-formatting code.
      librosa's resampling isn't the cause either - confirmed res_type defaults
      to soxr_hq (not the numba-based resampy backend) in this version.
      
      Skips this one test when CI=true (GitLab's own predefined variable) rather
      than continuing to chase what looks like a numba/llvmlite compiler bug
      specific to this runner's CPU. Still runs normally locally - verified both
      paths: skipped under CI=true, passes normally without it.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      9a4474e8
    • Aryan Noshirvnai's avatar
      Fix genuine CI hang: disable numba JIT for the test job · 3f902f2c
      Aryan Noshirvnai authored
      Confirmed via the GitLab API: pipeline 1023/1024's test job sat completely
      motionless for 40+ minutes with zero new output, stalled right where
      test_detect_key_returns_valid_structure would run - the one test exercising
      librosa.feature.chroma_cqt, which is numba-JIT-compiled
      (librosa.core.constantq imports numba's jit decorator, confirmed locally).
      
      numba's JIT cache never persists across CI runs (fresh container every job),
      so that compile cost is paid from scratch on every single push for a
      one-shot call that's never repeated in-process - zero benefit, and on this
      runner's CPU (already documented elsewhere in this codebase as lacking
      SSE3/SSE4/AVX) it appears to hang outright rather than just compile slowly.
      NUMBA_DISABLE_JIT=1 forces the pure-Python fallback - verified locally this
      costs nothing measurable (2.2s either way for a single detect_key call) and
      all 104 tests still pass.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      3f902f2c
    • Aryan Noshirvnai's avatar
      Add CORS middleware for the new stax_webapp frontend · 60f85ef5
      Aryan Noshirvnai authored
      No CORS configuration existed at all - every fetch() from a browser-based
      frontend on a different origin (localhost:5173, or the dev server's own
      :5173) would have been silently blocked. Auth here is a Bearer token in
      localStorage, never a cookie, so allow_credentials isn't needed - origins
      are read from CORS_ORIGINS (comma-separated), defaulting to the webapp's
      known dev origins.
      
      Verified: OPTIONS preflight to /auth/request_code from
      http://144.76.210.145:5173 now gets a correct
      Access-Control-Allow-Origin response.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      60f85ef5
    • Aryan Noshirvnai's avatar
      Revert to the proven non-Docker CI setup, keep the deploy_prod SSH key fix · a250228b
      Aryan Noshirvnai authored
      Confirmed via the GitLab API: the non-Docker test job (torch/demucs removed,
      cached static ffmpeg, sidechain test fixed) already ran successfully in
      4m14s (pipeline 1016). A second run of the same setup spiked to 26 minutes
      due to runner contention unrelated to what's installed - the Docker Hub
      pre-baked image wouldn't reliably fix that either, so dropping that
      direction rather than adding a registry/visibility decision for marginal,
      inconsistent benefit.
      
      The revert to 9a952fea's .gitlab-ci.yml would have also reintroduced the
      already-fixed deploy_prod SSH key bug (chmod on raw key text instead of a
      written-out file) - confirmed via API that pipeline 1019's deploy_prod
      failed on exactly that. Re-applied that fix on top of the reverted test job.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      a250228b
    • Aryan Noshirvnai's avatar
      Rewrite CI test job around a pre-baked Docker Hub image · 6b0d6620
      Aryan Noshirvnai authored
      Every push was paying apt-get + pip install + ffmpeg-download cost fresh,
      even with caching helping at the margins. Complete rewrite: Dockerfile.ci
      now bakes ffmpeg, libsndfile1, and the full requirements.txt into one image,
      built and pushed to Docker Hub by the manual build_ci_image job. The test
      job itself no longer does apt-get, pip install, or any download at all - it
      just pulls that image and runs pytest directly.
      
      Verified before pushing (no docker available locally to build-test with):
      every requirements.txt package that could plausibly need compilation
      (tgcrypto, pedalboard, pyrogram, shazamio/shazamio-core) has a prebuilt
      manylinux2014_x86_64/cp310 wheel, so no gcc/build-essential is needed in
      the image.
      
      Needs DOCKERHUB_USER + DOCKERHUB_TOKEN as CI/CD variables before
      build_ci_image can push anywhere - GitLab's own Container Registry isn't
      available on this instance (confirmed earlier), Docker Hub is (this runner
      already pulls python:3.10-slim from it successfully).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      6b0d6620
    • Aryan Noshirvnai's avatar
      Fix deploy_prod: PROD_SSH_PRIVATE_KEY is Variable-type, not File-type · 4fc454ba
      Aryan Noshirvnai authored
      Confirmed from the job log - chmod failed with "unrecognized option
      '-----BEGIN OPENSSH PRIVATE KEY-----" because $PROD_SSH_PRIVATE_KEY expands
      to the raw key text, not a file path (which File-type CI/CD variables give
      you). Writing it to ~/.ssh/prod_deploy_key ourselves works regardless of
      which type the variable actually is, so this doesn't depend on getting that
      GitLab dropdown exactly right.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      4fc454ba
    • Aryan Noshirvnai's avatar
      Remove stale stax_backend_dev.service - would crash-loop if deployed · 6e2863e9
      Aryan Noshirvnai authored
      deploy.sh installs every deploy/systemd/*.service file automatically. This
      one came in from the origin/dev merge targeting a different, unrelated
      deployment (/root/stax_backend_api-dev, port 8001, an HTTP_PROXY pointing
      at 127.0.0.1:8118 - leftover from the old Iran-server tunnel setup that's
      been explicitly retired). Deployed as-is it would just crash-loop against a
      working directory that doesn't exist on this prod box.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      6e2863e9
    • Aryan Noshirvnai's avatar
      Fix CI: add xz-utils, needed to extract the static ffmpeg .tar.xz · 9a952fea
      Aryan Noshirvnai authored
      python:3.10-slim has no xz binary by default (my local machine did, which
      is why this got missed) - tar shells out to it for .tar.xz decompression
      and failed with "xz: Cannot exec: No such file or directory". xz-utils is
      tiny with almost no dependency tree, unlike ffmpeg's, so this doesn't
      reintroduce the slowness being fixed.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      9a952fea
    • Aryan Noshirvnai's avatar
      Replace apt-get ffmpeg with a cached static binary - real fix for CI speed · d7f43a66
      Aryan Noshirvnai authored
      The Container Registry approach (build_ci_image) is reverted - confirmed via
      job log that $CI_REGISTRY is empty on this self-hosted instance (Container
      Registry isn't deployed here), so there was nowhere to push to.
      
      Root cause confirmed from an actual job log: apt-get install ffmpeg alone
      took 2min51s, unpacking/configuring 185 packages (video codecs, X11/Mesa/GL,
      fonts, speech-recognition libs) that this project never uses - it's audio-
      only. None of that is cacheable via apt itself.
      
      Fix: download John Van Sickle's static ffmpeg build (verified genuinely
      static via ldd - "not a dynamic executable", confirmed real mp3 encoding
      works at 278x realtime) instead of apt-installing it, and cache the binary
      itself via the existing cache: block so even the download only happens on
      the first run. git is also dropped from the apt install list - confirmed
      unused anywhere in app/test code (GitLab's own checkout doesn't use it).
      
      Verified locally: full 104-test suite passes with *only* this static binary
      on PATH (system ffmpeg hidden), matching what CI will have.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      d7f43a66
    • Aryan Noshirvnai's avatar
      Add manual job to build a pre-baked CI test image (phase 1/2) · 715396bf
      Aryan Noshirvnai authored
      apt-get install ffmpeg/git/libsndfile1 in the test job takes ~2m50s every
      single push (confirmed from a job log: ffmpeg drags in ~185 packages -
      video codecs, X11/Mesa/GL, fonts, speech-recognition libs - none of which
      this project uses), and none of it is cacheable the way pip's downloads are.
      
      This adds build_ci_image (when: manual, new "build" stage) which builds
      Dockerfile.ci and pushes it to this project's Container Registry. It does
      not touch the test job yet - purely additive, so if this runner turns out
      not to support Docker-in-Docker, nothing about the existing working pipeline
      changes. Once this job is confirmed to succeed, a follow-up commit switches
      test's image to the built one and drops its apt-get step.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      715396bf
    • Aryan Noshirvnai's avatar
      Make CI tests light: defer torch/demucs to a prod-only requirements file · 4a81091f
      Aryan Noshirvnai authored
      CI's test job was installing torch + demucs (a neural net stem-separation
      model) on every single push even though nothing in the test suite calls the
      real separator - test_remix.py mocks render_remix_sync entirely, and
      remix_engine.py's own detect_key/sidechain/style-preset tests only need
      librosa/scipy/numpy/pedalboard, not torch. That's most of what was making
      the pipeline slow (torch alone is a large download+install, on top of the
      memory pressure that caused the earlier 5min stall).
      
      - src/services/remix_engine.py: `import torch` and the mkldnn tweak move
        from module level into _get_separator(), alongside the already-lazy demucs
        import. The module (and everything depending on it, like the /remix
        router) now imports cleanly with neither installed.
      - requirements.txt: demucs removed. numpy/scipy/librosa/soundfile/pedalboard
        stay - real libraries, but not the heavy part, and needed for the audio-
        math tests that do run in CI.
      - requirements-remix.txt (new): just demucs, install torch CPU-only before
        it. Only installed by deploy.sh (prod), never in CI.
      - .gitlab-ci.yml test job: drops the torch install step entirely.
      
      Verified locally: uninstalled torch+demucs from the dev venv, app still
      imports and all 104 tests still pass in ~3s.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      4a81091f
    • Aryan Noshirvnai's avatar
      Shrink sidechain envelope test's sample count to fix a ~5min CI stall · 4a6db62c
      Aryan Noshirvnai authored
      filtfilt's cost scales with sample count, not just CPU SIMD support - the
      original sr=8000 (16k total samples) took ~5 minutes on CI's runner alone
      (likely memory pressure from the torch/demucs/librosa import chain already
      loaded by that point, not raw compute on such a tiny array). Same real-time
      duration/filter behavior at sr=400, just far fewer samples to filter.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      4a6db62c
    • Aryan Noshirvnai's avatar
      Fix CI: use only: instead of rules: for job branch gating · 00739c1b
      Aryan Noshirvnai authored
      This GitLab instance rejected rules: with "unknown keys" - confirmed by
      origin/dev's own prior .gitlab-ci.yml (pipeline #1007) using only: and
      passing on this same server/runner. Reverting to the proven syntax.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      00739c1b
    • Aryan Noshirvnai's avatar
      Merge origin/dev (remix engine, live rooms, channels, custom console) into dev · 78e816ec
      Aryan Noshirvnai authored
      Reconciles the hardening/caching/deploy-pipeline work on this branch with the
      previously-unmerged remix engine, Pass-the-Aux room websocket infra, Channels
      router, and custom API console from origin/dev.
      
      Conflict resolution notes:
      - Kept the current JWT/session-based auth (src/core/security.py) over origin/dev's
        older session-string-header auth; adapted its unique test coverage (chats/music
        endpoint, discovery listen/swipe content paths, library search/stream/lyrics/
        playlist content paths, remix-tree tests) to the current auth_as fixture instead
        of dropping that coverage.
      - Kept origin/dev's branded login-page + session-cookie docs auth (superset of the
        plain HTTP Basic version), and its recursive _build_remix_tree over a flat one-
        level version.
      - Replaced the stopgap _run_lightweight_migrations()/create_all-at-import-time in
        database.py with Alembic, which both sides now share as the single source of
        truth for schema; generated a new migration for the 7 tables origin/dev added
        (Correction, RemixJob, Channel, ChannelFollow, VibeSet, VibeSetTrack, AudioStory,
        ChannelShowcase).
      - Fixed a real bug surfaced by the merge: remix_engine.py and remix.py hardcoded
        /root/antigrav-stax-audio/* for stem cache/temp/downloads, a different directory
        than storage.py's LOCAL_STORAGE_ROOT-based paths that main.py's /downloads mount
        actually serves - remix downloads would have 404'd. Both now share storage.py's
        paths.
      - deploy.sh and .gitlab-ci.yml now install CPU-only torch and libsndfile1, needed
        by the remix engine's demucs/librosa dependency chain.
      - test_channels.py::test_showcase_owner_only still posted to /social/posts without
        auth headers; updated to use the auth_as fixture like the rest of the suite.
      
      104 tests pass (up from 40 pre-merge + origin/dev's own suite, combined and
      de-duplicated).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      78e816ec
    • Aryan Noshirvnai's avatar
      Harden backend, add permanent identification cache, self-bootstrapping deploy · 92a8a0e4
      Aryan Noshirvnai authored
      - Extract auth/storage into src/core/security.py and src/services/storage.py,
        scope library/discovery/social routes to the authenticated user
      - Add IdentifiedTrack cache table keyed by audio fingerprint so repeat uploads
        of the same song skip Shazam/AcoustID/Gemini identification entirely;
        enable sqlite WAL mode so cache reads don't stall behind unrelated writes
      - Add Alembic migrations (baseline schema + identified_tracks)
      - Add pytest-mock to requirements.txt - was missing despite being used
        throughout the existing test suite via the mocker fixture
      - Rewrite deploy/scripts/deploy.sh to self-bootstrap a bare prod server
        (system packages, repo clone, venv, .env from CI-supplied secrets,
        systemd unit sync) and restart services on every deploy
      - Add .gitlab-ci.yml: test stage runs on dev/main pushes, deploy_prod runs
        only on main and SSHes into prod to trigger deploy.sh
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
      92a8a0e4
  6. 07 Aug, 2026 1 commit
  7. 06 Aug, 2026 7 commits
    • Aryan Noshirvani's avatar
      Make remix tree fetching actually recursive · f887411d
      Aryan Noshirvani authored
      GET /social/posts/{id}/tree only ever fetched one level of children -
      a remix of a remix wouldn't show up at all. Rewrote it as a proper
      recursive walk (_build_remix_tree), each node now nesting its own
      children the same way, all the way down. Depth-capped at 50 as a
      guard against runaway recursion on pathological/corrupted data, well
      beyond anything a real remix-of-a-remix chain would reach.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
      f887411d
    • Aryan Noshirvani's avatar
      Add Channels: the last social pillar with nothing built before this · 8ff8c429
      Aryan Noshirvani authored
      Per the original vision doc, Channels are the creator hub - users host
      Vibe Sets, Audio Stories, and remix showcases. This pillar had zero
      model, router, or definition beyond one paragraph before this commit.
      
      New models (src/core/database.py): Channel, ChannelFollow, VibeSet +
      VibeSetTrack (a curated, ordered song collection - same shape as the
      existing Playlist/PlaylistTrack pair, owned by a channel instead of a
      user), AudioStory (ephemeral - expires_at defaults to 24h from
      creation; expired stories are filtered out of the "active" listing
      rather than deleted, the same soft-expiry pattern this codebase
      already uses for DiscoveredSong's 24h history), and ChannelShowcase
      (pins an existing Post - i.e. an actual remix from the tree - to a
      channel).
      
      New router (src/api/routers/channels.py): create/list channels, get
      channel detail with follower count, follow/unfollow (idempotent),
      create/list vibe sets + get one with its tracks, create/list stories,
      showcase/list showcased posts. Vibe sets/stories/showcase are owner-
      only (403 for anyone else), matching the "creator hub" framing -
      followers can browse, only the owner publishes.
      
      Found and fixed a real SQLAlchemy bug while testing create_vibe_set:
      returning an ORM object after a *second* db.commit() (for the
      VibeSetTrack rows, after the VibeSet itself was already committed and
      refreshed) serialized as an empty {} with no error - SQLAlchemy's
      expire_on_commit default re-expires already-loaded objects on every
      commit, not just the one that touched them. A final db.refresh()
      right before returning fixes it. Caught by an actual assertion on the
      response body, not just a status-code check.
      
      Also added a route-ordering regression test: GET /channels/vibe-sets/
      {id} must be registered before the generic /{channel_id} catch-all,
      or FastAPI matches "vibe-sets" against {channel_id}:int first and
      422s instead of ever reaching the real route.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
      8ff8c429
    • Aryan Noshirvani's avatar
      Add real-time WebSocket infrastructure for Pass-the-Aux rooms · fc48e64c
      Aryan Noshirvani authored
      There was zero real-time infrastructure anywhere in this backend
      before this - LiveRoom only ever supported create/list. Added
      WS /social/rooms/{room_id}/ws:
      
      - Chat: broadcast to everyone in the room (including the sender - a
        simpler, more predictable rule than asymmetric exclusion; clients
        can dedupe by user_id if they update optimistically).
      - Reactions + a "fire meter": 🔥 reactions accumulate into a count
        that decays over a 30s window (src/services/room_manager.py), so it
        reads as "how hot is it right now," not a lifetime total.
      - DJ handoff: request_aux queues a listener, pass_aux (DJ-only, an
        explicit rejection if a non-DJ tries) hands off to the front of the
        queue or a requested user_id. Confirmed via the actual LiveRoom.dj_id
        column, not just the in-memory session.
      - now_playing (DJ-only) updates LiveRoom.current_song_id live.
      - Presence (user_joined/user_left) and an initial state snapshot on
        connect (current DJ, current song, who's here, recent chat, fire
        count, queue) so a client joining mid-session isn't starting blind.
      
      Room state (connections, chat history, fire events, DJ queue) is
      in-memory and ephemeral by design (src/services/room_manager.py) -
      only dj_id/current_song_id persist to the DB, since that's the only
      part that should still be true if someone checks GET /social/rooms
      without being live-connected. An empty room's ephemeral state is
      discarded when the last person disconnects.
      
      Found and fixed a real deployment gap while verifying this against the
      actual running server rather than just the test suite: uvicorn had no
      WebSocket protocol implementation installed at all (no `websockets` or
      `wsproto` in requirements.txt) - Starlette's TestClient simulates
      WebSockets in-process and doesn't need one, so all 8 new tests passed
      happily while the real deployed server would have silently rejected
      every WebSocket connection. Added websockets>=13.0 to requirements.txt
      and confirmed a real end-to-end session (two live `websockets` client
      connections, not TestClient) against the actual running dev instance:
      chat, reactions, fire count, aux request/handoff, all working and
      persisting to the DB correctly.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
      fc48e64c
    • Aryan Noshirvani's avatar
      Replace HTTP Basic's native popup with a real branded login page · 375a447d
      Aryan Noshirvani authored
      HTTP Basic Auth's credential prompt is a browser-native dialog - there
      is no HTML/CSS control over it at all, so "make the login screen
      better" had nowhere to go under the previous setup. Switched to a
      proper login page (matching the console's dark/neon theme) backed by
      a random per-session cookie:
      
      - GET/POST /login: styled form, wrong credentials redirect back with
        an inline error instead of a blank 401.
      - Session tokens are secrets.token_urlsafe(32), tracked in an
        in-memory dict with a 24h expiry - not the old hardcoded
        "valid_token_xyz" bypass value this app used to ship with.
      - GET /logout clears the session and cookie.
      - HTTP Basic is kept as a fallback authentication path (checked
        alongside the session cookie) specifically so curl -u still works
        for scripted/API access - only interactive browser use needed the
        new login page, and this repo's own test suite and my own manual
        testing throughout this session both rely on curl -u.
      
      Added tests/test_docs_auth.py covering the full flow: redirect when
      unauthenticated, login page rendering, wrong-credential error
      redirect, correct-credential session + docs/openapi access, the Basic
      fallback, and logout. Also manually verified live against the running
      dev instance end-to-end with curl (cookie jar) before committing.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
      375a447d
    • Aryan Noshirvani's avatar
      Wire the remix engine into the social graph · 383b5162
      Aryan Noshirvani authored
      Completed remixes were only ever written to the RemixJob row and the
      downloads/ folder - invisible to /library, /social, and therefore to
      "remix trees" entirely. A remix created through /remix had zero
      connection to the rest of the app's social model.
      
      - /remix now accepts library_song_ids (comma-separated LibrarySong
        IDs) as an alternative/addition to uploaded files. Using a library
        song as a source is what makes tree linkage possible - a source
        with no existing library entry has nothing to link back to. Also
        accepts an optional user_id for attribution.
      - On completion, the engine now registers the output as a real
        LibrarySong (streamable, searchable, playlist-able, same as any
        other library entry) and creates a Post referencing it, so finished
        remixes actually show up in the social feed.
      - parent_post_id links to the first library-sourced input's most
        recent existing Post, if any - the schema only supports one parent
        per post (a tree, not a DAG), so with multiple library-sourced
        inputs only the first is represented as the "parent."
      - RemixJob gained result_song_id/result_post_id columns, surfaced in
        the GET /remix/{id} response once done. Added a lightweight
        automatic migration in database.py (create_all only creates missing
        tables, never ALTERs existing ones for new columns - this bit dev's
        own already-running database the moment these columns were added).
      
      Also fixed two real bugs hit while testing this end-to-end against the
      live Gemini API (not caught by mocked tests, since they're about the
      actual shape of model output):
      - gain_db came back as a per-stem dict ({"drums": -6.0, "other": 0.0})
        instead of the single float the schema asks for, when a role listed
        multiple stems - added _coerce_gain_db to average/sanitize whatever
        comes back rather than assuming schema compliance is guaranteed even
        with response_mime_type=application/json.
      - Gemini occasionally returns syntactically invalid JSON outright (a
        missing comma mid-response) - added a 3-attempt retry around
        generation+parsing, the standard mitigation for this class of
        transient flakiness.
      
      Verified end-to-end against the real API: submitted a remix using two
      pre-existing library songs (one with an existing social Post), and
      confirmed GET /social/posts/{id}/tree shows the finished remix as a
      real child post with the correct caption and parent linkage.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
      383b5162
    • Aryan Noshirvani's avatar
      Fix dormant telegram_bot bug: implement init_db/log_correction · 242f03ef
      Aryan Noshirvani authored
      src/telegram_bot/bot.py has called src.core.database.init_db() and
      log_correction() since before this session started - neither function
      existed anywhere in the codebase, not even in the original pre-reorg
      flat-file layout. The bot was never deployed, so this never surfaced,
      but it would have crashed immediately on first use.
      
      Implemented rather than just removing the calls, since they represent
      real intended behavior:
      - init_db(): idempotent wrapper around the table creation that already
        runs at module import time - a defensive check for the bot running
        as a standalone process that might start before the API ever has.
      - log_correction(): a new Correction model + write, recording a
        user's manual song-ID correction (picked from candidates, typed
        manually, or confirmed a Gemini guess) as a simple audit trail -
        what the call site's arguments (user_id, title, artist, source)
        clearly imply was the original intent.
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
      242f03ef
    • Aryan Noshirvani's avatar
      Replace hardcoded-password docs auth with HTTP Basic + custom console · 3c11a7b4
      Aryan Noshirvani authored
      Ports the same fix already tested and running on dev to main:
      - Removes the hardcoded plaintext admin/stax123 cookie-login flow and
        its fixed "valid_token_xyz" session-bypass cookie, replacing it with
        standard HTTP Basic Auth on /docs and /openapi.json, credentials
        from DOCS_USERNAME/DOCS_PASSWORD env vars (secrets.compare_digest).
      - Replaces stock Swagger UI with the custom branded console (dark/neon
        theme matching the Flutter app), minus the AI Remix panel - main
        doesn't have the /remix router, so that panel would just point at a
        404. Kept the Tag & Identify panel (main's /music/upload is real)
        and the generic OpenAPI-driven endpoint explorer.
      
      Tested locally end-to-end before this commit: full test suite 21/21
      green, and manually verified on a scratch port (401 with no
      credentials, 200 with correct ones, console renders without the
      remix panel, /openapi.json lists main's actual routes).
      Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
      Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
      3c11a7b4