diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.inputs.json b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.inputs.json index f2166b68..f213dfcc 100644 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.inputs.json +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.inputs.json @@ -1,17 +1,17 @@ { "version": 1, - "capturedAt": "2026-10-14T20:03:21.432Z", + "capturedAt": "2026-10-14T20:06:23.869Z", "capturedBy": "stamp", "inputs": { - "prompt": "427adf9dd0a79938e71a3e631208f43bc6862007ab9a37c6487d1ff47eb04c9f", + "prompt": "90c3f7385ab0ae8be11fcc7571cc66c0827e274c4433a03f248bc0e9372e31f5", "graderGuidance": null, "sessionJsonl": null, "workspacePatch": null, "gitref": "fcd8a9d0", "graderGuidanceConsolidated": null, - "holisticRubric": "c2d8bf2ffbc26e70e08ac8b17328479fde3be26560a67f7b1fde6441464e8b2b", - "atomicRubric": "0d2dd44fdd404c3074f21431f0f80781769d102a7269fa9b4097842867f1c609", + "holisticRubric": "4866b4cc73694ac35d72d394dfd8007e59bdc59a65d7095cb319a0f920d3ee15", + "atomicRubric": "010e39d610c810c8ed6c3f602eb5d57d4ae898df0d7d263f17f965cd9cf55350", "rubricsYaml": null, - "graderContext": "062756b472897d794d59e832a7b2303436a985572eabbf0a92a62399346046ae" + "graderContext": "353a498d1b4bbb04e05e72186a71864c808f2d837a54fafc88f72cdf3b79a7c3" } } diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.md b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.md index d99db60a..1421c8c8 100644 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.md +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-meaningful-failure.md @@ -10,7 +10,7 @@ Assessed: harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md and ## Load-bearing targets - **Tenant-source and filter isolation:** The Narrow Correctness section requires `userId` scoping on `VoiceCloning` and `UserAudioProfile` operations in cloning, and on `RecordingSalutation` and `Recording` operations downstream of the synthesizer's initial profile lookup. -- **Stop unauthorized downstream work:** The Narrow Correctness section calls halting audio generation or database updates after failed ownership validation its Crux requirement and applies a heavy penalty to the overall score. +- **Stop unauthorized downstream work:** The Narrow Correctness section calls halting audio generation or database updates after failed ownership validation its Crux requirement and applies a heavy penalty to Narrow Correctness. - **Worker resilience:** The Broader Correctness section requires polling loops to survive message-processing exceptions. Inherited SQS acknowledgment order is now an explicit non-penalty rule. The written summary is peripheral to the central security failure. @@ -53,7 +53,7 @@ The original rewards span 0.62–0.73. They were graded against an earlier holis - **Fired in:** 3/4 original grades; the 0.73 original grade does not mention it. - **What the agent actually wrote:** The 0.66 final response says, “Referenced records are authorized before processing.” A preflight read does not establish that a later scoped update still matched. - **Real-world consequence if the agent is wrong:** File and audio work can continue after a later ownership failure. The 0.66 grade reports the mocked download, and the 0.62 grade reports directory creation and another update before a failed processing update. -- **Verdict for this deduction:** `meaningful`. It directly violates the task's stop condition. The current Crux penalty has an overall-score target. +- **Verdict for this deduction:** `meaningful`. It directly violates the task's stop condition. The current holistic Crux penalty targets Narrow Correctness. ### Missing baseline-payload verification — meaningful @@ -69,9 +69,9 @@ The old grades also discuss acknowledgment before database success and, in one r ### Unauthorized effects after ownership failure — holds -- **Guidance says:** “If tenant context checks fail or records do not belong to the requesting user, execution must halt before rendering audio or mutating database records.” The same clause says failure “applies a heavy penalty to the overall score.” +- **Guidance says:** “When tenant ownership checks fail or records do not match the tenant context, the handler MUST halt all unauthorized side effects, including audio generation rendering and database updates.” The scoring line says failure “results in a heavy penalty to Narrow Correctness.” - **Reachability / evidence / proportionality:** Both workers perform model writes and audio work after record lookups. The 0.62 and 0.66 grades describe concrete later side effects after scoped-update failures. Preventing cross-tenant effects is a proportionate core security requirement. -- **Call:** The consequence is real, and a heavy penalty for actual cross-tenant rendering or writes is proportionate. The current scoping clauses name both handlers and the `userId` field. +- **Call:** The consequence is real, and a heavy Narrow Correctness penalty for actual cross-tenant rendering or writes is proportionate. The current scoping clauses name both handlers and the `userId` field. The tenant-source compatibility target and polling-loop resilience target have plausible stakes. The former manifested in every run; the latter was met. diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.inputs.json b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.inputs.json index f2166b68..f213dfcc 100644 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.inputs.json +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.inputs.json @@ -1,17 +1,17 @@ { "version": 1, - "capturedAt": "2026-10-14T20:03:21.432Z", + "capturedAt": "2026-10-14T20:06:23.869Z", "capturedBy": "stamp", "inputs": { - "prompt": "427adf9dd0a79938e71a3e631208f43bc6862007ab9a37c6487d1ff47eb04c9f", + "prompt": "90c3f7385ab0ae8be11fcc7571cc66c0827e274c4433a03f248bc0e9372e31f5", "graderGuidance": null, "sessionJsonl": null, "workspacePatch": null, "gitref": "fcd8a9d0", "graderGuidanceConsolidated": null, - "holisticRubric": "c2d8bf2ffbc26e70e08ac8b17328479fde3be26560a67f7b1fde6441464e8b2b", - "atomicRubric": "0d2dd44fdd404c3074f21431f0f80781769d102a7269fa9b4097842867f1c609", + "holisticRubric": "4866b4cc73694ac35d72d394dfd8007e59bdc59a65d7095cb319a0f920d3ee15", + "atomicRubric": "010e39d610c810c8ed6c3f602eb5d57d4ae898df0d7d263f17f965cd9cf55350", "rubricsYaml": null, - "graderContext": "062756b472897d794d59e832a7b2303436a985572eabbf0a92a62399346046ae" + "graderContext": "353a498d1b4bbb04e05e72186a71864c808f2d837a54fafc88f72cdf3b79a7c3" } } diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.md b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.md index d78a211b..40e7f50a 100644 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.md +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/detectors/detector-rubric-form.md @@ -1,7 +1,7 @@ --- detector: detector-rubric-form -verdict: material-issues -confidence: HIGH +verdict: minor-issues +confidence: MEDIUM --- # Rubric-form check: potion-voice-user-ownership @@ -9,7 +9,7 @@ Assessed: harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml and ## Deterministic contract -1. YAML parses with the task slug and seven criteria: pass (parsed with the installed yaml package). +1. YAML parses with the task slug and six criteria: pass (parsed with the installed yaml package). 2. Task slug matches: pass. 3. IDs are unique kebab-case: pass. 4. Categories use the allowed vocabulary: pass. @@ -17,39 +17,34 @@ Assessed: harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml and 6. One Crux is within the two-Crux cap: pass. 7. Dimensions name standard criteria: pass. 8. Guidelines are nonempty: pass. -9. Numeric-penalty pattern sweeps over the atomic rubric and grader context: pass; no candidates matched. +9. Numeric-penalty sweeps over the atomic rubric and grader context: pass; no candidates matched. 10. The detector contract defines no check numbered 10. -11. Positive-phrasing pattern sweep over guidelines: pass; no negated-requirement candidates matched. +11. Positive-phrasing sweep: pass. The only candidate, “records do not match” in prevent-unauthorized-side-effects, describes a failed ownership condition rather than phrasing the requirement negatively. ## Atomicity and self-containment -None found. The main behavior requirements are recognizable as separate criteria without reading sibling criteria. +None found. The six criteria state independently judgeable requirements. The inherited SQS acknowledgment allowance is now a non-trigger in the worker-loop elaboration, not a separate scored criterion. ## Phrasing and answer keys -### Every factual answer key is outside its guideline +### Answer keys bold terms rather than full factual relationships -- **Criterion:** All seven criteria. -- **Where:** For example, cloning-tenant-isolation's guideline ends “queries and updates in the voice cloning handler.” Its elaboration begins “**Answer key:** All **database reads** and **updates** ...”. The same guideline/elaboration split occurs in every criterion. -- **Why:** The form rule requires a factual criterion's answer key inline and in bold in its guideline. A grader reading guidelines alone has to search elaborations for the expected facts. The problem is material because it affects every scored criterion. -- **Suggested rewrite:** Move each factual answer key into its own guideline, with the full factual relationship in bold; keep elaborations for clarification and routing. +- **Criterion:** cloning-tenant-isolation, synthesis-tenant-isolation-queries-updates, and other factual criteria. +- **Where:** The cloning key says, “**Answer key:** All **database reads** and **updates** to **VoiceCloning** and **UserAudioProfile** ... must filter by **userId** in addition to record **_id**.” +- **Why:** The keys are inline and include the required facts, but only selected terms are bold. The whole factual answer-key sentence is not bold. This is minor because the facts remain immediately visible and judgeable. +- **Suggested rewrite:** Bold each full answer-key sentence. -### Substantive requirements appear only in elaborations +### Side-effect answer key is narrower in wording than its guideline -- **Criterion:** synthesis-tenant-isolation-queries-updates and worker-loop-crash-prevention. -- **Where:** The synthesis elaboration requires “the profile-derived **userId**,” while the guideline only says “tenant identity (userId).” The worker-loop elaboration requires a “**try-catch block**,” while its guideline only says to catch and handle exceptions. -- **Why:** Those are graded specifics from the holistic rubric. A reader applying only guidelines could credit a queue-supplied userId or a different exception mechanism, while the elaborations require the profile source and try-catch form. -- **Suggested rewrite:** State “profile-derived userId” and “try-catch block” in the respective guidelines. +- **Criterion:** prevent-unauthorized-side-effects. +- **Where:** The guideline requires halting side effects “across both voice cloning and speech synthesis handlers,” but its answer key starts “Synthesis **audio generation rendering** and **database mutations** must be halted.” +- **Why:** The guideline clearly covers both handlers, while the answer-key sentence could be read as describing synthesis only. “Audio generation rendering” is also awkward phrasing. This is a wording issue; the full criterion still states the intended scope. +- **Suggested rewrite:** Name both handlers in the answer key and use “audio rendering.” ## Fair-grading findings -### Framework allowance is a standalone scored criterion - -- **Criterion:** inherited-sqs-acknowledgment-protection. -- **Where:** “The response should allow standard framework SQS message deletion and acknowledgment behavior without penalizing message deletion on completed or rejected jobs.” -- **Why:** The allowance instructs the grader not to deduct for baseline queue behavior. It is not an independent property an agent's response can meaningfully fail, so awarding a scored dodged-bullet pass can dilute functional criteria. -- **Suggested rewrite:** Put the allowance in the relevant functional criterion's elaboration as a non-trigger rather than a separate scored criterion. +None found. The previous standalone SQS allowance criterion has been removed; the remaining criteria target behavior an agent can meaningfully get wrong. ## Overall verdict -The YAML passes the deterministic contract, but the judgment layer has material defects. Every factual answer key sits outside its guideline, two substantive facts are hidden in elaborations, and the SQS non-penalty instruction is scored as though it were an agent behavior. +The artifact passes its deterministic contract, and all criteria are judgeable. The remaining issues are answer-key formatting and a narrower side-effect answer-key sentence, not broken criterion form. diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/instruction.md b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/instruction.md index 4c214b0f..12381e1e 100755 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/instruction.md +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/instruction.md @@ -1,18 +1,19 @@ -# Refactor Worker Handlers for Multi-Tenant Data Isolation +# Audit and Refactor Background Workers for Multi-Tenant Data Isolation -## Context & Problem -Our backend background worker services (`voice-cloning-job-handler` and `voice-synthsizer-job-handler`) process asynchronous job queue messages for voice cloning and speech synthesis. Currently, database queries and updates retrieve and modify records (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`) using only the document identifier (`_id`) provided in the job message. +## Overview +Our backend asynchronous processing workers handle voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`) jobs via SQS queues. Currently, these handlers process queue messages by looking up database records (`UserAudioProfile`, `VoiceCloning`, `RecordingSalutation`, `Recording`) using only document ObjectIds (`_id`, `userAudioProfileId`, `salutationId`, `recordingId`) from the queue message payload without scoping queries or updates by tenant identity (`userId`). -Because queries lack explicit tenant scoping (`userId`), malformed, unvalidated, or cross-tenant job payloads can inspect or mutate records belonging to other users, creating a critical multi-tenant data separation vulnerability. +## Requirements +1. **Tenant Query & Update Isolation**: + - Refactor `voice-cloning-job-handler` so that all database queries and updates to `VoiceCloning` and `UserAudioProfile` enforce tenant isolation using `userId` in addition to record `_id`. + - Refactor `voice-synthsizer-job-handler` so that downstream queries and updates to `RecordingSalutation` and `Recording` enforce tenant isolation using the `userId` derived from the associated `UserAudioProfile`. + - The initial query on `UserAudioProfile` by `_id: userAudioProfileId` to resolve the `userId` is an expected tenant-resolution step. -## Task Requirements -1. **Multi-Tenant Query & Update Scoping**: - - Refactor all database reads and updates in `voice-cloning-job-handler` (`VoiceCloning`, `UserAudioProfile`) to filter by `userId` in addition to document `_id`. - - Refactor downstream queries and updates in `voice-synthsizer-job-handler` (`RecordingSalutation`, `Recording`) to enforce tenant scoping using the profile-derived `userId`. - - Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted as the valid tenant-resolution step needed to establish the job's `userId`. +2. **Side-Effect Halting**: + - If tenant ownership validation fails or requested records do not belong to the target tenant context, immediately halt all side effects (including audio generation rendering and database mutations). -2. **Side-Effect & Mutation Protection**: - - Ensure that if tenant ownership validation fails, unauthorized side effects (such as audio rendering or cross-tenant database updates) are immediately halted. +3. **Polling Loop Resilience**: + - Wrap processing logic in a `try-catch block` to catch errors gracefully during message processing, keeping the background worker polling loop active. -3. **Polling Loop Error Resilience**: - - Wrap job processing logic in proper exception handling (try-catch blocks) so unhandled processing errors do not crash background worker polling loops. +4. **Response Explanation**: + - Accurately describe the multi-tenant security refactoring in any accompanying summary or code documentation. diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml index 8717618d..e3fcb2e7 100755 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml @@ -7,10 +7,12 @@ criteria: severity: certain_dealbreaker call_site_key: voice-cloning-job-handler guideline: The response should enforce tenant isolation using userId on all VoiceCloning - and UserAudioProfile queries and updates in the voice cloning handler. - elaboration: '**Answer key:** All **database reads** and **updates** in **voice-cloning-job-handler** - on **VoiceCloning** and **UserAudioProfile** must filter by **userId** in addition - to record **_id**.' + and UserAudioProfile queries and updates in the voice cloning handler. **Answer + key:** All **database reads** and **updates** to **VoiceCloning** and **UserAudioProfile** + in **voice-cloning-job-handler** must filter by **userId** in addition to record + **_id**. + elaboration: Verifies that voice cloning queries and updates incorporate userId + to prevent unauthorized cross-tenant operations. - id: synthesis-tenant-isolation-queries-updates category: primary_intent dimensions: @@ -18,10 +20,12 @@ criteria: severity: certain_dealbreaker call_site_key: voice-synthsizer-job-handler guideline: The response should scope all synthesis queries and database updates - by tenant identity (userId) across RecordingSalutation and Recording records. - elaboration: '**Answer key:** Downstream **reads** and **updates** to **RecordingSalutation** - and **Recording** in **voice-synthsizer-job-handler** must be scoped by the profile-derived - **userId**.' + by tenant identity using the profile-derived userId across RecordingSalutation + and Recording records. **Answer key:** Downstream **reads** and **updates** to + **RecordingSalutation** and **Recording** in **voice-synthsizer-job-handler** + must be scoped by the **profile-derived userId**. + elaboration: Ensures that both queries and database updates in the speech synthesis + handler enforce tenant isolation using profile-derived userId. - id: prevent-unauthorized-side-effects category: primary_intent dimensions: @@ -29,12 +33,15 @@ criteria: severity: crux call_site_key: voice-synthsizer-job-handler guideline: The response should prevent unauthorized side effects, including audio - generation and database mutations across both handlers, when tenant validation - fails. + generation rendering and database mutations across both voice cloning and speech + synthesis handlers, when tenant validation fails or records do not match tenant + context. **Answer key:** Synthesis **audio generation rendering** and **database + mutations** must be halted if **tenant ownership checks** fail. elaboration: 'Failing this crux criterion applies a heavy penalty to the overall - score. Routing note: Do not double-charge a single defect across query criteria - and side-effect criteria. **Answer key:** Synthesis **audio generation** and **database - mutations** must be halted if **tenant ownership checks** fail.' + score. Routing note: Charge syntax omissions under cloning-tenant-isolation or + synthesis-tenant-isolation-queries-updates; charge side-effect execution under + this criterion. Do not double-charge a single defect across query criteria and + side-effect criteria.' - id: initial-profile-tenant-resolution category: dodged_bullet dimensions: @@ -43,39 +50,34 @@ criteria: call_site_key: voice-synthsizer-job-handler guideline: 'The response should allow the initial UserAudioProfile lookup by _id: userAudioProfileId as a valid tenant-resolution step without requiring userId - in that initial query.' - elaboration: '**Answer key:** The initial lookup on **UserAudioProfile** by **_id: - userAudioProfileId** is necessary to resolve **userId** and establish tenant context.' -- id: inherited-sqs-acknowledgment-protection - category: dodged_bullet - dimensions: - - Broader Correctness / the craft of software engineering - severity: possible_dealbreaker - call_site_key: voice-synthsizer-job-handler - guideline: The response should allow standard framework SQS message deletion and - acknowledgment behavior without penalizing message deletion on completed or rejected - jobs. - elaboration: '**Answer key:** **SQS message deletion** and **acknowledgment** inherited - from the baseline framework is standard queue processing behavior and must not - be penalized.' + in that initial query. **Answer key:** The initial lookup on **UserAudioProfile** + by **_id: userAudioProfileId** is necessary to resolve **userId** and establish + **tenant context**.' + elaboration: Prevents improperly docking points for the initial profile query needed + to discover the tenant identity. - id: worker-loop-crash-prevention category: primary_intent dimensions: - Broader Correctness / the craft of software engineering severity: possible_dealbreaker call_site_key: voice-synthsizer-job-handler - guideline: The response should catch and handle exceptions during message processing - to prevent background worker polling loops from crashing. - elaboration: '**Answer key:** Errors during job processing must be caught gracefully - in a **try-catch block** so the worker **polling loop** remains active.' + guideline: The response should catch and handle exceptions using a try-catch block + during message processing to prevent background worker polling loops from crashing. + **Answer key:** Errors during job processing must be caught gracefully in a **try-catch + block** so the worker **polling loop** remains active. + elaboration: 'Ensures background worker loops remain resilient against unhandled + errors. Non-penalty note: Standard SQS queue message deletion or acknowledgment + behavior on completed/failed jobs inherited from the framework must not be penalized.' - id: refactor-summary-accuracy category: primary_intent dimensions: - Communication severity: unlikely_dealbreaker call_site_key: voice-synthsizer-job-handler - guideline: The response should accurately summarize the multi-tenant isolation refactor - in its written response or code documentation. - elaboration: '**Answer key:** Any written **summary**, **explanation**, or **code - documentation** must accurately reflect the multi-tenant isolation changes without - misleading claims.' + guideline: The response should accurately describe the multi-tenant isolation refactor + in its written response summary and code documentation if provided. **Answer key:** + Any written **summary** or **code documentation** must **accurately reflect** + the actual code refactoring and **multi-tenant security logic** without misleading + claims. + elaboration: Evaluates that written explanations and inline documentation accurately + reflect the implemented tenant isolation changes. diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/grader-context.md b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/grader-context.md index 2f3dec0e..c3c174d5 100755 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/grader-context.md +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/grader-context.md @@ -1,20 +1,22 @@ -# Grader Context & Ground Truth Reference +# Grader Context & Reference Guide: potion-voice-user-ownership -## Background Worker Architecture -The application runs background tasks handling voice cloning and speech synthesis via AWS SQS queue messages. +## Architecture & Data Flow +The application processes background jobs via AWS SQS queues and MongoDB/Mongoose models: +* `voice-cloning-job-handler`: Handles voice model training/cloning. Operates on `VoiceCloning` and `UserAudioProfile` models. +* `voice-synthsizer-job-handler`: Handles text-to-speech audio synthesis. Operates on `UserAudioProfile`, `RecordingSalutation`, and `Recording` models. -### Key Components & Models -1. **`voice-cloning-job-handler`**: - - Manages `VoiceCloning` job state and `UserAudioProfile` updates. - - Requires filtering reads and updates by `userId` alongside `_id`. +## Tenant Resolution & Isolation Mechanics +1. **Voice Cloning Handler**: + * Queue message payload contains `userId` and `voiceCloningId`. + * Queries and updates on `VoiceCloning` and `UserAudioProfile` must incorporate `userId`. -2. **`voice-synthsizer-job-handler`**: - - Message payload contains `userAudioProfileId`, `recordingId`, and optional `salutationId`. - - **Step 1 (Tenant Resolution)**: Resolves tenant context by querying `UserAudioProfile` using `_id: userAudioProfileId` to retrieve `userAudioProfile.userId`. - - **Step 2 (Scoped Operations)**: Uses the resolved `userId` to scope all subsequent queries and updates on `RecordingSalutation` and `Recording`. +2. **Speech Synthesis Handler**: + * Queue payload contains `userAudioProfileId`, `salutationId`, and `recordingId`. + * Step 1: Query `UserAudioProfile` by `_id: userAudioProfileId` to retrieve `profile.userId`. + * Step 2: Downstream queries/updates on `RecordingSalutation` and `Recording` must use `userId: profile.userId`. -3. **Side-Effect Protection**: - - If `userId` resolution fails or records do not match `userId`, execution must abort before calling audio synthesis engines or saving updates. +3. **Side-Effect Control**: + * If tenant checks fail, side effects (audio generation rendering and database writes) must be aborted immediately. -4. **Framework Queue Behavior**: - - Baseline worker loops handle SQS message acknowledgment and deletion upon job completion or rejection. This standard queue behavior must not be flagged as a flaw. +4. **Framework Queue Notes**: + * SQS message deletion/acknowledgment on processed or rejected messages is handled by the consumer framework and is not a security flaw. diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md index a2d0b97b..44b02cb9 100755 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md @@ -1,15 +1,35 @@ -# Holistic Evaluation Rubric: Multi-Tenant Data Isolation Refactor +# Holistic Evaluation Rubric: potion-voice-user-ownership -## Narrow Correctness -- **Voice Cloning Tenant Isolation**: All database reads and updates in `voice-cloning-job-handler` on `VoiceCloning` and `UserAudioProfile` records must explicitly filter by `userId` in addition to record `_id`. -- **Synthesis Tenant Isolation**: All downstream queries and updates in `voice-synthsizer-job-handler` on `RecordingSalutation` and `Recording` records must be scoped by `userId`. -- **Side-Effect Control (Crux Requirement)**: If tenant context checks fail or records do not belong to the requesting user, execution must halt before rendering audio or mutating database records. *Crux requirement*: Failing to halt unauthorized side effects applies a heavy penalty to the overall score. -- **Initial Profile Lookup Exemption**: The initial query on `UserAudioProfile` by `_id: userAudioProfileId` is the necessary tenant-resolution step to discover `userId`. It must be permitted without requiring `userId` in that initial lookup. -- **Deduction Routing**: Do not double-charge a single defect across query criteria and side-effect criteria. +## Overview +Evaluates the candidate's refactoring of backend background worker handlers (`voice-cloning-job-handler` and `voice-synthsizer-job-handler`) to enforce multi-tenant data isolation and worker polling loop resilience. -## Broader Correctness / the craft of software engineering -- **Polling Loop Resilience**: Errors occurring during message processing must be caught gracefully in a try-catch block so background worker polling loops remain active. -- **SQS Framework Acknowledgment Protection**: Standard SQS queue message deletion and acknowledgment behavior inherited from the baseline framework code is standard infrastructure operation and must not be penalized as a defect. +--- -## Communication -- **Refactor Summary & Documentation Accuracy**: Any written response summary, code explanations, or inline documentation must accurately describe the multi-tenant isolation refactor without misleading claims. +## 1. Narrow Correctness + +### Crux Requirement: Unauthorized Side-Effect Prevention +* **Rule**: When tenant ownership checks fail or records do not match the tenant context, the handler MUST halt all unauthorized side effects, including audio generation rendering and database updates. +* **Scoring**: This is a Crux requirement under Narrow Correctness. Failing to halt unauthorized side effects results in a heavy penalty to Narrow Correctness. Do not double-charge a single defect across query criteria and side-effect criteria. + +### Scoping & Tenant Isolation Dealbreakers +* **Voice Cloning Handler (`voice-cloning-job-handler`)**: + * All database reads and updates to `VoiceCloning` and `UserAudioProfile` must filter by `userId` in addition to `_id`. +* **Speech Synthesis Handler (`voice-synthsizer-job-handler`)**: + * Downstream database reads and updates to `RecordingSalutation` and `Recording` must filter by the profile-derived `userId`. +* **Tenant Resolution Lookup Exemption**: + * The initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is necessary to discover the `userId` and must NOT be penalized for lacking `userId` in that first query. + +--- + +## 2. Broader Correctness / the craft of software engineering + +### Polling Loop Resilience +* Errors encountered during job processing must be caught gracefully in a `try-catch block` to keep background worker polling loops active. +* **SQS Acknowledgment Non-Penalty Note**: Standard framework queue message deletion or acknowledgment behavior on completed or rejected jobs inherited from the baseline framework code is acceptable queue processing and MUST NOT be penalized. + +--- + +## 3. Communication + +### Refactor Summary & Documentation Accuracy +* Any written response summary or code documentation provided by the candidate must accurately reflect the multi-tenant isolation logic without misleading or contradictory claims.