Feat/vibe v2 session director #4

Merged
kami merged 8 commits from feat/vibe-v2-session-director into master 2026-08-03 11:23:10 +02:00
Owner
No description provided.
kami added 7 commits 2026-08-02 17:10:30 +02:00
kami reviewed 2026-08-02 17:56:38 +02:00
kami left a comment
Author
Owner

review everything one more time and make sure you've got the functionality right.

review everything one more time and make sure you've got the functionality right.
@@ -161,0 +164,4 @@
// Durable sessions intentionally do not trust x-user-id. A self-hosted
// deployment may configure one owner through MUZICK_VIBE_USER_ID today;
// an authenticated deployment can replace this resolver at registration.
const vibeOwnerId = process.env.MUZICK_VIBE_USER_ID?.trim() || null;
Author
Owner

seems rather useless or even redundant when we talk multi-user.

seems rather useless or even redundant when we talk multi-user.
@@ -0,0 +10,4 @@
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
/** Identity must come from authenticated server configuration/middleware, never a client header. */
Author
Owner

why?

why?
@@ -0,0 +25,4 @@
// Require an actual offset-bearing timestamp, rather than Date.parse's
// permissive inputs such as "2026" or locale-dependent strings.
return typeof value === 'string'
&& /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/i.test(value)
Author
Owner

regexep should be a const.

regexep should be a const.
@@ -0,0 +36,4 @@
const { coordinator, identityResolver } = options;
const requireUser = (request: FastifyRequest, reply: { code: (statusCode: number) => { send: (payload: unknown) => unknown } }): string | null => {
const userId = identityResolver(request);
if (userId && validUuid(userId)) return userId;
Author
Owner

vibe is not blocked for one user only. but vibe is unique for each user.

vibe is not blocked for one user only. but vibe is unique for each user.
@@ -0,0 +41,4 @@
return null;
};
fastify.post('/v2/vibe/sessions', async (request, reply) => {
Author
Owner

that's too much checks and error codes in one function, don't you think?

that's too much checks and error codes in one function, don't you think?
@@ -0,0 +105,4 @@
if (!body || !VIBE_EVENT_TYPES.includes(body.type as typeof VIBE_EVENT_TYPES[number])) {
return reply.code(400).send({ error: 'type must be a supported Vibe event type' });
}
// Delivery is an authoritative state transition performed only by /next.
Author
Owner

elaborate.

elaborate.
Author
Owner

again. too much error catching in one function.

again. too much error catching in one function.
@@ -0,0 +161,4 @@
}
});
fastify.post('/v2/vibe/sessions/:sessionId/next', async (request, reply) => {
Author
Owner

not sure if it's right to provide and support two /next paths — for normal Playlist and for the Vibe.

not sure if it's right to provide and support two /next paths — for normal Playlist and for the Vibe.
@@ -0,0 +3,4 @@
* has no precise location, identifiers, or browser telemetry: clients can
* supply a hint, but the server owns the time fields and can ignore all of it.
*/
export const VIBE_CONTEXT_VALUES = {
Author
Owner

how would muzick know any of this?

how would muzick know any of this?
kami added 1 commit 2026-08-03 10:44:12 +02:00
refactor(vibe): simplify durable session flow
Typecheck / typecheck (backend) (push) Has been cancelled
Typecheck / typecheck (workers) (push) Has been cancelled
Typecheck / typecheck (backend) (pull_request) Has been cancelled
Typecheck / typecheck (workers) (pull_request) Has been cancelled
9eba247a58
kami merged commit dfb8ed6f28 into master 2026-08-03 11:23:10 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kami/muzick#4