From 81c82632091a1ee69080dda93e75965b3203320a Mon Sep 17 00:00:00 2001 From: Eric Bell Date: Thu, 22 Oct 2026 13:45:25 -0400 Subject: [PATCH] after addressing detector issues vs oct21 review --- racoon-workflow.md | 2 + .../staleness.json | 171 ++++++++++-------- .../tests/atomic-rubric.yaml | 101 ++++++----- .../tests/grader-context.md | 12 +- .../tests/holistic-rubric.md | 34 ++-- .../tests/rubric-criteria.md | 30 +-- .../toolkit-files.json | 2 +- 7 files changed, 194 insertions(+), 158 deletions(-) diff --git a/racoon-workflow.md b/racoon-workflow.md index 8355b30d..6cc9dea8 100644 --- a/racoon-workflow.md +++ b/racoon-workflow.md @@ -21,6 +21,8 @@ cp the 4 essential files into place npx tsx scripts/stage-atomic-rubric.ts potion-voice-user-ownership +rm the reference runs/ rubric-regrades/ and jobs/ + 15 pretrial detectors until all clear # trials diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/staleness.json b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/staleness.json index eccaf409..39c06440 100644 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/staleness.json +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/staleness.json @@ -1,171 +1,182 @@ { "version": 1, - "generatedAt": "2026-10-16T18:17:54.255Z", - "referenceRuns": [ - { - "runId": "reward-0.5000-hCpLyTL", - "status": "fresh", - "changed": [], - "capturedAt": "2026-10-16T17:09:39.217Z", - "capturedBy": "run" - }, - { - "runId": "reward-0.5800-Vz8kjv9", - "status": "fresh", - "changed": [], - "capturedAt": "2026-10-16T17:09:39.217Z", - "capturedBy": "run" - }, - { - "runId": "reward-0.6300-NSP5wKq", - "status": "fresh", - "changed": [], - "capturedAt": "2026-10-16T17:09:39.217Z", - "capturedBy": "run" - }, - { - "runId": "reward-0.9000-F8cEYH2", - "status": "fresh", - "changed": [], - "capturedAt": "2026-10-16T17:09:39.217Z", - "capturedBy": "run" - } - ], + "generatedAt": "2026-10-22T17:42:44.013Z", + "referenceRuns": [], "detectors": [ { "report": "detector-answer-obviousness.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-broken-dev-env.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-credential-leakage.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-cross-task-reference.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-dimension-misapplication.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-fact-check-rubric-claims.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-good-response-defined.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-good-response-exhaustiveness.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-meaningful-failure.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], + "changed": [ + "prompt (instruction.md)", + "holistic rubric (tests/holistic-rubric.md)" + ], "capturedAt": "2026-10-16T18:03:12.554Z", "capturedBy": "stamp" }, { "report": "detector-offline-verifiability.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-over-hinting.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-rubric-clarity.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-rubric-coverage.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)", + "atomic rubric (tests/atomic-rubric.yaml)", + "grader context (tests/grader-context.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-rubric-form.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)", + "atomic rubric (tests/atomic-rubric.yaml)", + "grader context (tests/grader-context.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-rubric-generality.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" }, { "report": "detector-run-behaviors.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], + "changed": [ + "prompt (instruction.md)", + "holistic rubric (tests/holistic-rubric.md)" + ], "capturedAt": "2026-10-16T18:03:12.554Z", "capturedBy": "stamp" }, { "report": "detector-snapshot-leakage.md", - "status": "fresh", + "status": "stale", "method": "checksums", - "changed": [], - "capturedAt": "2026-10-16T18:03:12.554Z", + "changed": [ + "holistic rubric (tests/holistic-rubric.md)" + ], + "capturedAt": "2026-10-22T17:31:38.774Z", "capturedBy": "stamp" } ] 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 79dea3aa..ac5f47cd 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 @@ -10,10 +10,12 @@ criteria: severity: certain_dealbreaker guideline: 'The response should enforce tenant isolation using userId on all VoiceCloning and UserAudioProfile queries and updates in the voice cloning handler. **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.**' + 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.**' elaboration: Verifies that voice cloning queries and updates incorporate userId - to prevent unauthorized cross-tenant operations. + 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. - id: synthesis-tenant-isolation-queries-updates name: Synthesis Tenant Isolation Queries & Updates category: primary_intent @@ -23,12 +25,14 @@ criteria: - voice-synthsizer-job-handler severity: certain_dealbreaker guideline: 'The response should scope all synthesis queries and database updates - by tenant identity (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.**' + 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.**' elaboration: Ensures that both queries and database updates in the speech synthesis - handler enforce tenant isolation using profile-derived userId. + 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. - id: cloning-prevent-unauthorized-side-effects name: Cloning Prevent Unauthorized Side Effects category: primary_intent @@ -39,18 +43,20 @@ criteria: severity: crux guideline: 'The response should prevent unauthorized side effects, including audio generation rendering and database mutations in the voice cloning handler, when - tenant validation fails or records do not match tenant context. **Answer key: - Audio generation rendering and database mutations in voice-cloning-job-handler - must be halted if tenant ownership checks fail.**' + 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.**' elaboration: "Failing this crux criterion applies a heavy penalty to Narrow Correctness - and a heavy penalty to the overall score. Routing note: If a preflight check or - update fails to match a record **before tenant context is established**, and rendering - or side effects still proceed, that is a Crux failure. **Exception**: `userId`-scoped - status updates (e.g., setting `status: 'error'`) in catch blocks **after a successful - initial preflight** are NOT Crux failures. These writes target the job's own records - and cannot mutate cross-tenant data; charge unchecked null returns under - scoped-update-null-handling instead. Do not double-charge a single defect across - query criteria and side-effect criteria." + 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." - id: synthesis-prevent-unauthorized-side-effects name: Synthesis Prevent Unauthorized Side Effects category: primary_intent @@ -61,17 +67,20 @@ criteria: severity: crux guideline: 'The response should prevent unauthorized side effects, including audio generation rendering and database mutations in the speech synthesis handler, when - tenant validation fails or records do not match tenant context. **Answer key: - Audio generation rendering and database mutations in voice-synthsizer-job-handler - must be halted if tenant ownership checks fail.**' + 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.**' elaboration: "Failing this crux criterion applies a heavy penalty to Narrow Correctness - and a heavy penalty to the overall score. Routing note: If a preflight check or - update fails to match a record **before tenant context is established**, and rendering - or side effects still proceed, that is a Crux failure. **Exception**: `userId`-scoped - status updates in catch blocks **after a successful initial preflight** are NOT Crux - failures. These writes target the job's own records and cannot mutate cross-tenant - data; charge unchecked null returns under scoped-update-null-handling instead. - Do not double-charge a single defect across query criteria and side-effect criteria." + 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." - id: initial-profile-tenant-resolution name: Initial Profile Tenant Resolution category: dodged_bullet @@ -82,10 +91,12 @@ criteria: severity: possible_dealbreaker 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. **Answer key: The initial lookup on UserAudioProfile by - _id: userAudioProfileId is necessary to resolve userId and establish tenant context.**' + in that initial query. **Answer key (illustrative): 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. + to discover the tenant identity. Equivalent bootstrap queries (direct model call, + differently named helper) receive full credit. - id: scoped-update-null-handling name: Scoped Update Null Handling category: dodged_bullet @@ -97,14 +108,16 @@ criteria: severity: unlikely_dealbreaker guideline: '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: Database update operations that filter by tenant userId should - check for a null result to ensure defensive error handling.**' + occur. **Answer key (illustrative): Database update operations that filter by tenant + userId should check for a null result to ensure defensive error handling.**' elaboration: '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).' + (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.' - id: worker-loop-crash-prevention name: Worker Loop Crash Prevention category: dodged_bullet @@ -115,12 +128,14 @@ criteria: - voice-synthsizer-job-handler severity: possible_dealbreaker guideline: 'The response should catch and handle exceptions during message processing - in a try-catch block 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.**' + 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.**' elaboration: 'Ensures background worker loops remain resilient against unhandled - errors. Non-penalty note: Framework SQS message deletion and acknowledgment on - both completed and rejected jobs is standard behavior and must not be penalized.' + 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.' - id: refactor-summary-accuracy name: Refactor Summary Accuracy category: dodged_bullet @@ -132,8 +147,8 @@ criteria: severity: unlikely_dealbreaker guideline: 'The response should accurately summarize the refactored multi-tenant isolation changes across background worker handlers in any written explanations - or code documentation. **Answer key: Any written summary, response message, or - code documentation must accurately describe the multi-tenant isolation logic without - misleading claims.**' + 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.**' elaboration: Evaluates the factual accuracy and structure of the written refactoring summary and code documentation. 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 166e2a9d..e5c566f3 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 @@ -8,14 +8,18 @@ The repository contains background workers consuming job payloads from AWS SQS q - `UserAudioProfile`: Profile linking audio resources to a specific `userId`. - `RecordingSalutation`: Speech synthesis salutation model. - `Recording`: Synthesis audio recording model. +- `Salutation`: Salutation model created during synthesis. +- `Job`: Job model created during synthesis. ## Evaluation Notes 1. **Tenant Isolation**: - - Every database read and update on `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording` must be scoped by `userId` (except the initial `UserAudioProfile` lookup by `_id: userAudioProfileId` to resolve tenant identity). + - Every database read and update on `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`, `Salutation`, and `Job` must be scoped by `userId` (except the initial `UserAudioProfile` lookup by `_id: userAudioProfileId` to resolve tenant identity). + - **Equivalent implementations**: Direct model predicates, differently named helpers, filter objects containing `userId`, or conditional updates all satisfy the requirement — the answer-key method names are illustrative. 2. **Side Effects vs. Minor Defects**: - If a preflight query or update fails to match a record **before tenant context is established**, and audio generation rendering or database mutations STILL proceed, this is a **Crux failure** (`cloning-prevent-unauthorized-side-effects` / `synthesis-prevent-unauthorized-side-effects`). - - **Exception**: `userId`-scoped status updates (e.g., setting `status: 'error'`) in catch blocks **after a successful initial preflight** are NOT Crux failures. These writes target the job's own records and cannot mutate cross-tenant data. + - **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. - If a database update is ALREADY scoped by `userId` (preventing cross-tenant data mutations), failing to check its null return value without executing downstream unauthorized side effects is a minor defensive programming defect under **Broader Correctness / the craft of software engineering** (`scoped-update-null-handling`). - - **Note**: 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). + - **Note**: 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 is charged solely to `scoped-update-null-handling`, not to the Crux criteria.** 3. **Worker Resilience**: - - Processing loops must catch exceptions to prevent worker termination. Framework SQS message deletion/acknowledgment is standard behavior and should not be penalized. + - Processing loops must catch exceptions to prevent worker termination. Promise rejection handling, try-catch, or equivalent per-message boundaries all satisfy this. Framework SQS message deletion/acknowledgment is standard behavior and should not be penalized. 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 f2c885f1..03dd18b3 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 @@ -9,11 +9,12 @@ The candidate must audit database operations in both worker handlers, enforce te ## Scored Dimensions & Criteria Guidance ### 1. Narrow Correctness -- **Query Scoping**: All queries and database updates on `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording` must include `userId` filtering (except the initial `UserAudioProfile` lookup by `_id: userAudioProfileId` used to resolve tenant identity). +- **Query Scoping**: All queries and database updates on `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`, `Salutation`, and `Job` must include `userId` filtering (except the initial `UserAudioProfile` lookup by `_id: userAudioProfileId` used to resolve tenant identity). - **Side-Effect Halting (Crux)**: - Audio generation rendering and database mutations in either handler must be halted if tenant ownership checks fail or if preflight checks return no matching record. - - **Crux Rule**: If a preflight lookup or update returns null / 0 matched records **before** tenant context is established, and the handler STILL proceeds to render audio or execute side effects, this is a **Crux failure** (unauthorized side effect executed). - - **Exception**: `userId`-scoped status updates (e.g., setting `status: 'error'`) in catch blocks **after** a successful initial preflight are **not** Crux failures. These writes target the job's own records and cannot mutate cross-tenant data; they are evaluated under `scoped-update-null-handling` instead. + - **Crux Rule**: If a preflight lookup or update returns null / 0 matched records **before tenant context is established**, and the handler STILL proceeds to render audio or execute side effects, this is a **Crux failure** (unauthorized side effect executed). + - **Tenant context is established** when the initial `UserAudioProfile` lookup yields a valid `userId` (the bootstrap step permitted above). 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. - **Deduction Guidance**: Failing a Crux side-effect criterion applies a heavy penalty to Narrow Correctness and a heavy penalty to the overall score. Charge preflight side-effect execution under Crux criteria (`cloning-prevent-unauthorized-side-effects` / `synthesis-prevent-unauthorized-side-effects`). ### 2. Broader Correctness / the craft of software engineering @@ -30,14 +31,16 @@ The candidate must audit database operations in both worker handlers, enforce te ## Single-Deduction Rule Do not double-charge a single code omission across multiple criteria. Charge query syntax omissions under the query isolation criteria (`cloning-tenant-isolation` / `synthesis-tenant-isolation-queries-updates`), charge preflight execution before validation under Crux criteria, and charge unchecked null results on safely scoped updates under `scoped-update-null-handling`. +**Note on answer-key APIs**: The method names and signatures below are **illustrative examples** of the tenant-scoped operations and control-flow boundaries. Equivalent implementations using direct model predicates, differently named helpers, filter objects containing `userId`, or conditional updates receive full credit — the requirement is the behavioral outcome, not a specific helper surface. + ## Answer Key: Call Sites & Halt Points The following lists the database operations that must be tenant-scoped and the control-flow points where execution must halt on ownership failure. ### voice-cloning-job-handler **Reads requiring `userId` scope** (after initial `UserAudioProfile` bootstrap): -- `VoiceCloning.read({ _id, userAudioProfileId }, userId)` - preflight ownership check -- `VoiceCloning` service: `read`, `find`, `update`, `remove` - all filter by `userId` -- `UserAudioProfile` service: `read`, `update`, `remove` - all filter by `userId` +- `VoiceCloning.read({ _id, userAudioProfileId }, userId)` — preflight ownership check (illustrative) +- `VoiceCloning` service: `read`, `find`, `update`, `remove` — all filter by `userId` (illustrative) +- `UserAudioProfile` service: `read`, `update`, `remove` — all filter by `userId` (illustrative) **Updates requiring `userId` scope**: - `VoiceCloning.update({ _id, status: 'processing' }, userId)` @@ -57,17 +60,18 @@ The following lists the database operations that must be tenant-scoped and the c ### voice-synthsizer-job-handler **Reads requiring `userId` scope** (after initial `UserAudioProfile` bootstrap): -- `UserAudioProfile.readById(userAudioProfileId)` - bootstrap (permitted unscoped by `userId`, filters by `_id` + `deleted:false`) -- `RecordingSalutation.findOne({ _id: salutationId, userId, deleted: false })` - preflight -- `Recording.findOne({ _id: recordingId, userId, deleted: false })` - preflight -- `RecordingSalutation` service: `read`, `find`, `update`, `remove`, `updateOrCreate` - all filter by `userId` -- `Recording` service: `read`, `find`, `update`, `remove` - all filter by `userId` -- `Job` service: `insertMany` - scopes by `userId` +- `UserAudioProfile.readById(userAudioProfileId)` — bootstrap (permitted unscoped by `userId`, filters by `_id` + `deleted:false`) (illustrative) +- `RecordingSalutation.findOne({ _id: salutationId, userId, deleted: false })` — preflight (illustrative) +- `Recording.findOne({ _id: recordingId, userId, deleted: false })` — preflight (illustrative) +- `RecordingSalutation` service: `read`, `find`, `update`, `remove`, `updateOrCreate` — all filter by `userId` (illustrative) +- `Recording` service: `read`, `find`, `update`, `remove` — all filter by `userId` (illustrative) +- `Salutation` service: `create`, `read`, `find`, `update`, `remove`, `updateOrCreate` — all filter by `userId` (illustrative) +- `Job` service: `insertMany` — scopes by `userId` (illustrative) **Updates requiring `userId` scope**: -- `salutationService.updateOrCreate({ firstName, salutationVideo, userAudioProfileId }, userId)` -- `RecordingSalutation.findOneAndUpdate({ _id: salutationId, userId, deleted: false }, { $set: { salutationVideo } }, { new: true })` -- `Job.insertMany([{ firstName, recordingId, salutationId, metadata }], userId)` +- `salutationService.updateOrCreate({ firstName, salutationVideo, userAudioProfileId }, userId)` (illustrative) +- `RecordingSalutation.findOneAndUpdate({ _id: salutationId, userId, deleted: false }, { $set: { salutationVideo } }, { new: true })` (illustrative) +- `Job.insertMany([{ firstName, recordingId, salutationId, metadata }], userId)` (illustrative) **Halt points** (must stop before audio rendering / side effects): 1. Initial `resolveTenantContext`: if `UserAudioProfile` bootstrap returns null or `status !== 'completed'` → halt, acknowledge message (if not yet acknowledged), no rendering. diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/rubric-criteria.md b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/rubric-criteria.md index f8f66a8a..efd6105d 100644 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/rubric-criteria.md +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/tests/rubric-criteria.md @@ -1,47 +1,47 @@ ### 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: All database reads and updates in voice-cloning-job-handler on VoiceCloning and UserAudioProfile must filter by userId in addition to record _id.** +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. +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 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.** +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. +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 tenant validation fails or records do not match tenant context. **Answer key: Audio generation rendering and database mutations in voice-cloning-job-handler must be halted if tenant ownership checks fail.** +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. Routing note: If a preflight check or update fails to match a record **before tenant context is established**, and rendering or side effects still proceed, that is a Crux failure. **Exception**: `userId`-scoped status updates (e.g., setting `status: 'error'`) in catch blocks **after a successful initial preflight** are NOT Crux failures. These writes target the job's own records and cannot mutate cross-tenant data; charge unchecked null returns under scoped-update-null-handling instead. Do not double-charge a single defect across query criteria and side-effect criteria. +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 tenant validation fails or records do not match tenant context. **Answer key: Audio generation rendering and database mutations in voice-synthsizer-job-handler must be halted if tenant ownership checks fail.** +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. Routing note: If a preflight check or update fails to match a record **before tenant context is established**, and rendering or side effects still proceed, that is a Crux failure. **Exception**: `userId`-scoped status updates in catch blocks **after a successful initial preflight** are NOT Crux failures. These writes target the job's own records and cannot mutate cross-tenant data; charge unchecked null returns under scoped-update-null-handling instead. Do not double-charge a single defect across query criteria and side-effect criteria. +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: The initial lookup on UserAudioProfile by _id: userAudioProfileId is necessary to resolve userId and establish tenant context.** +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. +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: Database update operations that filter by tenant userId should check for a null result to ensure defensive error 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). +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 in a try-catch block 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.** +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. Non-penalty note: Framework SQS message deletion and acknowledgment on both completed and rejected jobs is standard behavior and must not be penalized. +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: Any written summary, response message, or code documentation must accurately describe the multi-tenant isolation logic without misleading claims.** +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. diff --git a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/toolkit-files.json b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/toolkit-files.json index 851b684c..2cc126ad 100644 --- a/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/toolkit-files.json +++ b/worker-toolkit-potion-polyglot-v1.0.1/harbor-tasks/potion-voice-user-ownership/toolkit-files.json @@ -1,6 +1,6 @@ { "version": 1, - "generatedAt": "2026-10-16T18:17:54.563Z", + "generatedAt": "2026-10-22T17:42:44.067Z", "files": [ { "taskPath": "environment/Dockerfile",