6.4 KiB
Criterion: cloning-tenant-isolation
The response should enforce tenant isolation using userId on all VoiceCloning and UserAudioProfile queries and updates in the voice cloning handler. Answer key (illustrative): All database reads and updates in voice-cloning-job-handler on VoiceCloning and UserAudioProfile must filter by userId in addition to record _id.
Verifies that voice cloning queries and updates incorporate userId to prevent unauthorized cross-tenant operations. Equivalent implementations using direct model predicates, differently named helpers, filter objects containing userId, or conditional updates receive full credit.
Criterion: synthesis-tenant-isolation-queries-updates
The response should scope all synthesis queries and database updates by tenant identity (profile-derived userId) across RecordingSalutation, Recording, Salutation, and Job records. Answer key (illustrative): Downstream reads and updates to RecordingSalutation, Recording, Salutation, and Job in voice-synthsizer-job-handler must be scoped by the profile-derived userId.
Ensures that both queries and database updates in the speech synthesis handler enforce tenant isolation using profile-derived userId. Equivalent implementations using direct model predicates, differently named helpers, filter objects containing userId, or conditional updates receive full credit.
Criterion: cloning-prevent-unauthorized-side-effects
The response should prevent unauthorized side effects, including audio generation rendering and database mutations in the voice cloning handler, when a preflight check fails to match a record before tenant context is established. Answer key (illustrative): Audio generation rendering and database mutations in voice-cloning-job-handler must be halted if preflight ownership checks fail before tenant context is established.
Failing this crux criterion applies a heavy penalty to Narrow Correctness and a heavy penalty to the overall score. Tenant context is established when the initial UserAudioProfile lookup yields a valid userId. After that point, any userId-scoped no-match is NOT a Crux trigger - it falls under scoped-update-null-handling. Exception: userId-scoped status updates (e.g., setting status: 'error') in catch blocks after tenant context is established are NOT Crux failures. These writes target the job's own records and cannot mutate cross-tenant data. Do not double-charge a single defect across query criteria and side-effect criteria. The rendering-after-scoped-null case is charged solely to scoped-update-null-handling as a moderate Broader Correctness defect.
Criterion: synthesis-prevent-unauthorized-side-effects
The response should prevent unauthorized side effects, including audio generation rendering and database mutations in the speech synthesis handler, when a preflight check fails to match a record before tenant context is established. Answer key (illustrative): Audio generation rendering and database mutations in voice-synthsizer-job-handler must be halted if preflight ownership checks fail before tenant context is established.
Failing this crux criterion applies a heavy penalty to Narrow Correctness and a heavy penalty to the overall score. Tenant context is established when the initial UserAudioProfile lookup yields a valid userId. After that point, any userId-scoped no-match is NOT a Crux trigger - it falls under scoped-update-null-handling. Exception: userId-scoped status updates in catch blocks after tenant context is established are NOT Crux failures. These writes target the job's own records and cannot mutate cross-tenant data. Do not double-charge a single defect across query criteria and side-effect criteria. The rendering-after-scoped-null case is charged solely to scoped-update-null-handling as a moderate Broader Correctness defect.
Criterion: initial-profile-tenant-resolution
The response should allow the initial UserAudioProfile lookup by _id: userAudioProfileId as a valid tenant-resolution step without requiring userId in that initial query. Answer key (illustrative): The initial lookup on UserAudioProfile by _id: userAudioProfileId is necessary to resolve userId and establish tenant context.
Prevents improperly docking points for the initial profile query needed to discover the tenant identity. Equivalent bootstrap queries (direct model call, differently named helper) receive full credit.
Criterion: scoped-update-null-handling
The response should check and handle null or zero-match return values on tenant-scoped database updates when no downstream unauthorized side effects occur. Answer key (illustrative): Database update operations that filter by tenant userId should check for a null result to ensure defensive error handling.
Evaluates defensive error handling on scoped database updates. Note: If an update filters by userId (so 0 rows are mutated), failing to check the null return is a minor craft defect under Broader Correctness, provided no unauthorized audio rendering or side effects occur. Rendering audio after a tenant-scoped update returns null / 0 matched records is a moderate Broader Correctness defect (the preflight passed, but the subsequent scoped update failed to match). This defect is charged HERE, not under the Crux side-effect criteria - the Crux guidelines exclude later scoped-update failures, so there is no double-counting.
Criterion: worker-loop-crash-prevention
The response should catch and handle exceptions during message processing to prevent background worker polling loops from crashing. Answer key: Errors during job processing must be caught gracefully so the worker polling loop remains active.
Ensures background worker loops remain resilient against unhandled errors. Promise rejection handling, try-catch, or equivalent per-message boundaries all satisfy this requirement. Non-penalty note: Framework SQS message deletion and acknowledgment on both completed and rejected jobs is standard behavior and must not be penalized.
Criterion: refactor-summary-accuracy
The response should accurately summarize the refactored multi-tenant isolation changes across background worker handlers in any written explanations or code documentation. Answer key (illustrative): Any written summary, response message, or code documentation must accurately describe the multi-tenant isolation logic without misleading claims.
Evaluates the factual accuracy and structure of the written refactoring summary and code documentation.