4 flagging detectors 10th time

This commit is contained in:
2026-10-15 10:35:31 -04:00
parent 8a67338a8d
commit 31a89a1e1b
12 changed files with 152 additions and 156 deletions

View File

@@ -1,17 +1,17 @@
{
"version": 1,
"capturedAt": "2026-10-14T20:06:23.869Z",
"capturedAt": "2026-10-14T20:10:25.873Z",
"capturedBy": "stamp",
"inputs": {
"prompt": "90c3f7385ab0ae8be11fcc7571cc66c0827e274c4433a03f248bc0e9372e31f5",
"prompt": "2436e35620757186b1dc4bd4acfe1932206a42322060756a25b0de58a608d40e",
"graderGuidance": null,
"sessionJsonl": null,
"workspacePatch": null,
"gitref": "fcd8a9d0",
"graderGuidanceConsolidated": null,
"holisticRubric": "4866b4cc73694ac35d72d394dfd8007e59bdc59a65d7095cb319a0f920d3ee15",
"atomicRubric": "010e39d610c810c8ed6c3f602eb5d57d4ae898df0d7d263f17f965cd9cf55350",
"holisticRubric": "1be5c7d5d9b74f38cb52bed9562e0bedce8932429703774e4fc9b9d2c569a901",
"atomicRubric": "2db084eaf0a5d9ba1f6c33800a79371508399df514cb6a99fb54d86283e8741f",
"rubricsYaml": null,
"graderContext": "353a498d1b4bbb04e05e72186a71864c808f2d837a54fafc88f72cdf3b79a7c3"
"graderContext": "e4960980794d650baa1a1ef88302d02c99cb0c3050b7ee3ae06bfa5a7dd5a846"
}
}

View File

@@ -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 Narrow Correctness.
- **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.
- **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.
@@ -35,7 +35,7 @@ Inherited SQS acknowledgment order is now an explicit non-penalty rule. The writ
All four original grades credit per-message exception handling or continued polling. This guardrail was met across the run set.
The original rewards span 0.62–0.73. They were graded against an earlier holistic revision, so they establish observed agent behavior rather than scores under the current wording.
The original rewards span 0.62–0.73. They were captured under earlier prompt and holistic revisions, so they establish observed agent behavior rather than the current package's elicitation rate or scores.
## Per-deduction assessment
@@ -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 holistic Crux penalty targets Narrow Correctness.
- **Verdict for this deduction:** `meaningful`. It directly violates the task's stop condition. The current holistic Crux penalty targets the overall score.
### 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:** “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.”
- **Guidance says:** “If tenant ownership validation fails or requested records do not match the tenant context (`userId`), the system must immediately halt unauthorized side effects—including audio generation rendering and database mutations across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.” The scoring note says failure “applies a heavy penalty to the overall score.”
- **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 Narrow Correctness 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 overall-score 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.
@@ -79,4 +79,4 @@ The tenant-source compatibility target and polling-loop resilience target have p
The current rubric targets a real compatibility regression and a real ownership-stop gap. The first appears in all four reference runs, and the second in three original grades. The shipped baseline and reproduced run checks support their consequences. The new protection for inherited SQS acknowledgment removes the mixed-deduction reason for the earlier `partial` verdict.
The verdict is `meaningful` with medium confidence because the four reference grades were produced under an earlier holistic revision. They support elicitation and impact, but they do not show how graders would apply the current wording to those same responses.
The verdict is `meaningful` with medium confidence because the four reference grades were captured under earlier prompt and holistic revisions. They support the real-world importance of the failure and show it occurred in those runs, but they cannot establish its frequency under the current package.

View File

@@ -1,17 +1,17 @@
{
"version": 1,
"capturedAt": "2026-10-14T20:03:21.432Z",
"capturedAt": "2026-10-14T20:10:25.873Z",
"capturedBy": "stamp",
"inputs": {
"prompt": "427adf9dd0a79938e71a3e631208f43bc6862007ab9a37c6487d1ff47eb04c9f",
"prompt": "2436e35620757186b1dc4bd4acfe1932206a42322060756a25b0de58a608d40e",
"graderGuidance": null,
"sessionJsonl": null,
"workspacePatch": null,
"gitref": "fcd8a9d0",
"graderGuidanceConsolidated": null,
"holisticRubric": "c2d8bf2ffbc26e70e08ac8b17328479fde3be26560a67f7b1fde6441464e8b2b",
"atomicRubric": "0d2dd44fdd404c3074f21431f0f80781769d102a7269fa9b4097842867f1c609",
"holisticRubric": "1be5c7d5d9b74f38cb52bed9562e0bedce8932429703774e4fc9b9d2c569a901",
"atomicRubric": "2db084eaf0a5d9ba1f6c33800a79371508399df514cb6a99fb54d86283e8741f",
"rubricsYaml": null,
"graderContext": "062756b472897d794d59e832a7b2303436a985572eabbf0a92a62399346046ae"
"graderContext": "e4960980794d650baa1a1ef88302d02c99cb0c3050b7ee3ae06bfa5a7dd5a846"
}
}

View File

@@ -9,14 +9,14 @@ Assessed: harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md
## Material ambiguities
None found. The rubric names the handlers, models, tenant field, record field, initial tenant-resolution lookup, ownership-stop trigger, and overall-score Crux target. It also explicitly protects the initial lookup and standard SQS acknowledgment and prevents double-charging a single defect.
None found. The rubric names the handlers, models, tenant source, initial lookup exemption, failed-ownership trigger, and overall-score Crux target. Its routing note states how to charge query omissions and unauthorized side effects without charging one defect twice.
The four captured reference grades were reviewed. They predate this holistic revision, so they do not establish how graders would apply its wording; they do not reveal an unresolved competing reading of the current rules.
The four captured reference grades were reviewed. They predate this prompt and holistic revision, so they cannot prove consistent application of the current wording; they do not reveal a competing interpretation of its present rules.
## Copy-edit issues
None found.
None found. “Audio generation rendering” is redundant but does not interrupt comprehension or change a scoring boundary.
## Overall verdict
The revised holistic rubric reads clearly and gives a grader concrete boundaries for the task's scored behavior. No material ambiguity or disruptive prose issue remains.
The holistic rubric remains clear enough for consistent scoring. No material ambiguity or disruptive prose issue was found.

View File

@@ -1,17 +1,17 @@
{
"version": 1,
"capturedAt": "2026-10-14T20:03:21.432Z",
"capturedAt": "2026-10-14T20:10:25.873Z",
"capturedBy": "stamp",
"inputs": {
"prompt": "427adf9dd0a79938e71a3e631208f43bc6862007ab9a37c6487d1ff47eb04c9f",
"prompt": "2436e35620757186b1dc4bd4acfe1932206a42322060756a25b0de58a608d40e",
"graderGuidance": null,
"sessionJsonl": null,
"workspacePatch": null,
"gitref": "fcd8a9d0",
"graderGuidanceConsolidated": null,
"holisticRubric": "c2d8bf2ffbc26e70e08ac8b17328479fde3be26560a67f7b1fde6441464e8b2b",
"atomicRubric": "0d2dd44fdd404c3074f21431f0f80781769d102a7269fa9b4097842867f1c609",
"holisticRubric": "1be5c7d5d9b74f38cb52bed9562e0bedce8932429703774e4fc9b9d2c569a901",
"atomicRubric": "2db084eaf0a5d9ba1f6c33800a79371508399df514cb6a99fb54d86283e8741f",
"rubricsYaml": null,
"graderContext": "062756b472897d794d59e832a7b2303436a985572eabbf0a92a62399346046ae"
"graderContext": "e4960980794d650baa1a1ef88302d02c99cb0c3050b7ee3ae06bfa5a7dd5a846"
}
}

View File

@@ -1,7 +1,7 @@
---
detector: detector-rubric-coverage
verdict: clear
confidence: MEDIUM
verdict: material-issues
confidence: HIGH
---
# Rubric-coverage check: potion-voice-user-ownership
@@ -11,32 +11,37 @@ Assessed: harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md agai
| Holistic clause (short, verbatim key phrase) | Criterion id(s) | Status |
| --- | --- | --- |
| “reads and updates ... `VoiceCloning` and `UserAudioProfile` ... `userId` ... `_id`” | cloning-tenant-isolation | covered |
| “downstream queries and updates ... `RecordingSalutation` and `Recording` ... `userId`” | synthesis-tenant-isolation-queries-updates | covered |
| “execution must halt before rendering audio or mutating database records” | prevent-unauthorized-side-effects | covered |
| “applies a heavy penalty to the overall score” | prevent-unauthorized-side-effects | covered |
| “initial query ... `_id: userAudioProfileId` ... permitted without requiring `userId`” | initial-profile-tenant-resolution | covered |
| “All database reads and updates on `VoiceCloning` and `UserAudioProfile` ... `userId` ... `_id`” | cloning-tenant-isolation | covered |
| “Downstream reads and updates on `RecordingSalutation` and `Recording` ... profile-derived `userId`” | synthesis-tenant-isolation-queries-updates | covered |
| “halt all unauthorized side effects” | prevent-unauthorized-side-effects | covered |
| “heavy penalty to the overall score” | prevent-unauthorized-side-effects | covered |
| “Do not double-charge a single defect” | prevent-unauthorized-side-effects elaboration | covered |
| “caught gracefully in a try-catch block” | worker-loop-crash-prevention | covered |
| “SQS queue message deletion and acknowledgment ... must not be penalized” | inherited-sqs-acknowledgment-protection | covered |
| “summary, code explanations, or inline documentation ... without misleading claims” | refactor-summary-accuracy | covered |
| “initial lookup ... `_id: userAudioProfileId` ... must not be penalized” | initial-profile-tenant-resolution | covered |
| “caught gracefully in a `try-catch` block” | worker-loop-crash-prevention | covered |
| “message deletion and acknowledgment ... on completed or rejected jobs ... must not be penalized” | worker-loop-crash-prevention elaboration | partial |
| “written summary, response message, or code documentation ... without misleading claims” | refactor-summary-accuracy | covered |
## Coverage gaps
None found.
### Completed-job SQS allowance is lost
- **Holistic clause:** The Queue Acknowledgment Allowance protects “Standard SQS queue message deletion and acknowledgment ... on completed or rejected jobs” and says it “must not be penalized.”
- **Closest criterion:** The worker-loop-crash-prevention elaboration says, “Framework SQS message deletion and acknowledgment on rejected jobs is standard framework behavior and must not be penalized.”
- **What is lost:** The atomic rule protects rejected jobs but omits completed jobs. A grader applying it could deduct for baseline SQS acknowledgment on a completed job, which the holistic rubric expressly permits. grader-context.md does not restore this allowance.
- **Suggested criterion:** Extend the existing non-trigger to “completed or rejected jobs.”
## Invented content
None found. The criteria's handler, model, tenant-source, side-effect, and polling facts are supported by the holistic rubric or grader context. The scored design of the SQS protection is assessed by the rubric-form detector, not counted as an unsupported requirement here.
None found. The atomic requirements and answer-key facts are supported by the holistic rubric or grader context.
## Context integrity
The holistic rubric's architecture and tenant-resolution facts survive in grader-context.md, which also preserves the standard queue acknowledgment allowance. Facts needed by the criteria are present in the context or the criteria themselves.
The overview's handler and isolation facts survive in grader-context.md. The holistic SQS allowance is absent from that context and only partially represented in the worker-loop elaboration; its completed-job protection is missing from both.
## Crux alignment
The holistic side-effect rule applies a heavy penalty to the overall score. prevent-unauthorized-side-effects is the one atomic crux criterion and its elaboration repeats that effect. No other Crux mismatch exists.
The holistic side-effect rule directs a heavy penalty to the overall score. prevent-unauthorized-side-effects has severity crux and an elaboration with the same penalty target. No Crux mismatch remains.
## Overall verdict
The seven atomic criteria now represent the holistic rubric's load-bearing requirements, protections, charge-once rule, and overall-score Crux. Coverage is clear; the separate form detector assesses whether those criteria are well shaped for scoring.
The substantive isolation rules and Crux penalty now align. The completed-job half of a load-bearing “must not penalize” protection is still missing from the atomic package, making coverage materially incomplete.

View File

@@ -1,17 +1,17 @@
{
"version": 1,
"capturedAt": "2026-10-14T20:06:23.869Z",
"capturedAt": "2026-10-14T20:10:25.873Z",
"capturedBy": "stamp",
"inputs": {
"prompt": "90c3f7385ab0ae8be11fcc7571cc66c0827e274c4433a03f248bc0e9372e31f5",
"prompt": "2436e35620757186b1dc4bd4acfe1932206a42322060756a25b0de58a608d40e",
"graderGuidance": null,
"sessionJsonl": null,
"workspacePatch": null,
"gitref": "fcd8a9d0",
"graderGuidanceConsolidated": null,
"holisticRubric": "4866b4cc73694ac35d72d394dfd8007e59bdc59a65d7095cb319a0f920d3ee15",
"atomicRubric": "010e39d610c810c8ed6c3f602eb5d57d4ae898df0d7d263f17f965cd9cf55350",
"holisticRubric": "1be5c7d5d9b74f38cb52bed9562e0bedce8932429703774e4fc9b9d2c569a901",
"atomicRubric": "2db084eaf0a5d9ba1f6c33800a79371508399df514cb6a99fb54d86283e8741f",
"rubricsYaml": null,
"graderContext": "353a498d1b4bbb04e05e72186a71864c808f2d837a54fafc88f72cdf3b79a7c3"
"graderContext": "e4960980794d650baa1a1ef88302d02c99cb0c3050b7ee3ae06bfa5a7dd5a846"
}
}

View File

@@ -1,7 +1,7 @@
---
detector: detector-rubric-form
verdict: minor-issues
confidence: MEDIUM
verdict: clear
confidence: HIGH
---
# Rubric-form check: potion-voice-user-ownership
@@ -17,34 +17,22 @@ 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 sweeps over the atomic rubric and grader context: pass; no candidates matched.
9. Numeric-penalty pattern sweeps over the atomic rubric and grader context: pass; no candidates matched.
10. The detector contract defines no check numbered 10.
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.
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 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.
None found. Each criterion states one independently judgeable requirement. The charge-once routing note clarifies attribution without adding a second response requirement.
## Phrasing and answer keys
### Answer keys bold terms rather than full factual relationships
- **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.
### Side-effect answer key is narrower in wording than its guideline
- **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.”
None found. Each factual answer key is inline in its own guideline and the full answer-key sentence is bold. The profile-derived tenant source, both-handler side-effect scope, and try-catch form are in their respective guidelines.
## Fair-grading findings
None found. The previous standalone SQS allowance criterion has been removed; the remaining criteria target behavior an agent can meaningfully get wrong.
None found. The inherited SQS acknowledgment allowance is a non-trigger in the worker-loop elaboration rather than a separate scored criterion. The coverage detector separately assesses the allowance's scope.
## Overall verdict
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.
The six-criterion artifact passes the deterministic and judgment checks. No material or minor form finding remains.

View File

@@ -1,19 +1,22 @@
# Audit and Refactor Background Workers for Multi-Tenant Data Isolation
# Refactor Background Handlers for Multi-Tenant Data Isolation
## 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`).
Our backend background processing workers currently handle voice cloning and speech synthesis jobs by retrieving database records using only document identifiers provided in queue messages (e.g., `_id`, `userAudioProfileId`, `salutationId`), without verifying user ownership context (`userId`).
## 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.
You must audit and refactor the background job processing handlers (`voice-cloning-job-handler` and `voice-synthsizer-job-handler`) to enforce strict multi-tenant data isolation and prevent unauthorized cross-tenant data access or side effects.
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).
## Objectives
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.
1. **Enforce Multi-Tenant Data Scoping**:
- Ensure all database queries and updates across `voice-cloning-job-handler` and `voice-synthsizer-job-handler` incorporate tenant scoping (`userId`).
- In `voice-cloning-job-handler`, all reads and updates on `VoiceCloning` and `UserAudioProfile` must filter by `userId` alongside record `_id`.
- In `voice-synthsizer-job-handler`, initial profile lookup by `_id: userAudioProfileId` resolves tenant context (`userId`). All downstream reads and updates on `RecordingSalutation` and `Recording` must be scoped by that resolved `userId`.
4. **Response Explanation**:
- Accurately describe the multi-tenant security refactoring in any accompanying summary or code documentation.
2. **Prevent Unauthorized Side Effects**:
- Halt unauthorized side effects (including audio rendering/generation and database mutations across both voice cloning and speech synthesis handlers) immediately if tenant validation fails or if requested records do not belong to the tenant.
3. **Maintain Worker Loop Resilience**:
- Wrap job execution in proper exception handling (`try-catch`) so unhandled processing errors do not crash background polling loops.
- Note: Standard framework SQS queue message deletion/acknowledgment on completed or rejected jobs is standard behavior and should be preserved.
4. **Documentation**:
- If providing a written response summary or inline code documentation, accurately describe the refactoring and tenant isolation logic.

View File

@@ -6,11 +6,10 @@ criteria:
- Narrow Correctness
severity: certain_dealbreaker
call_site_key: voice-cloning-job-handler
guideline: The response should enforce tenant isolation using userId on all VoiceCloning
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** to **VoiceCloning** and **UserAudioProfile**
in **voice-cloning-job-handler** must filter by **userId** in addition to record
**_id**.
key: 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.
- id: synthesis-tenant-isolation-queries-updates
@@ -19,29 +18,30 @@ criteria:
- Narrow Correctness
severity: certain_dealbreaker
call_site_key: voice-synthsizer-job-handler
guideline: The response should scope all synthesis queries and database updates
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.
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.**'
elaboration: Ensures that downstream queries and database updates in the speech
synthesis handler enforce tenant isolation using the profile-derived userId.
- id: prevent-unauthorized-side-effects
category: primary_intent
dimensions:
- Narrow Correctness
severity: crux
call_site_key: voice-synthsizer-job-handler
guideline: The response should prevent unauthorized side effects, including audio
guideline: 'The response should prevent unauthorized side effects, including audio
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: 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.'
context. **Answer key: Audio generation rendering and database mutations across
both voice cloning and speech synthesis handlers must be halted if tenant ownership
checks fail.**'
elaboration: 'Guarantees that unauthorized jobs do not trigger audio rendering or
database updates. Routing note: Charge syntax omissions under query criteria;
charge side-effect execution under this criterion. Do not double-charge a single
defect across query criteria and side-effect criteria. Failing this crux criterion
applies a heavy penalty to the overall score.'
- id: initial-profile-tenant-resolution
category: dodged_bullet
dimensions:
@@ -50,34 +50,33 @@ 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. **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: 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 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 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.'
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.**'
elaboration: Ensures background worker polling loops remain resilient against unhandled
errors. Framework SQS message deletion and acknowledgment on rejected jobs is
standard framework behavior and 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 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.
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.**'
elaboration: Evaluates the clarity and truthfulness of the written refactoring summary
and code documentation.

View File

@@ -1,22 +1,28 @@
# Grader Context & Reference Guide: potion-voice-user-ownership
# Grader Context & Architecture Guide
## 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.
## Overview
## 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`.
This task evaluates refactoring background worker polling handlers (`voice-cloning-job-handler` and `voice-synthsizer-job-handler`) for multi-tenant data isolation.
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`.
## Data Models & Mappings
3. **Side-Effect Control**:
* If tenant checks fail, side effects (audio generation rendering and database writes) must be aborted immediately.
- **`VoiceCloning`**: Stores voice cloning job records (`_id`, `userId`, `userAudioProfileId`, `status`).
- **`UserAudioProfile`**: Stores user audio profile records (`_id`, `userId`, `status`).
- **`RecordingSalutation`**: Stores salutation generation requests (`_id`, `userAudioProfileId`, `salutationId`).
- **`Recording`**: Stores generated audio metadata (`_id`, `userAudioProfileId`, `recordingId`).
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.
## Handler Logic & Tenant Isolation
### 1. Voice Cloning Handler (`voice-cloning-job-handler`)
- Receives job payload containing `_id` and `userId`.
- Database reads and updates on `VoiceCloning` and `UserAudioProfile` must query with both `_id` and `userId`.
### 2. Speech Synthesis Handler (`voice-synthsizer-job-handler`)
- Receives job payload containing `userAudioProfileId` (and optionally `salutationId` / `recordingId`).
- Performs initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` to resolve the owner's `userId`.
- All downstream queries and updates on `RecordingSalutation` and `Recording` must use `userId`.
## Side-Effect Halting & Error Handling
- If tenant validation fails or requested records are missing/unauthorized, side effects (audio synthesis rendering and database mutations) across both handlers must be halted immediately.
- Failing to halt side effects triggers a heavy penalty to the overall score (`severity: crux`).
- Job execution must be wrapped in a `try-catch` block to keep worker polling loops running.

View File

@@ -1,35 +1,30 @@
# Holistic Evaluation Rubric: potion-voice-user-ownership
# Holistic Evaluation Rubric
## 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.
---
This rubric evaluates candidate solutions for refactoring background worker handlers (`voice-cloning-job-handler` and `voice-synthsizer-job-handler`) to enforce multi-tenant data isolation.
## 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.
### Crux Requirement: Unauthorized Side-Effect Halting
- **Rule**: If tenant ownership validation fails or requested records do not match the tenant context (`userId`), the system must immediately halt unauthorized side effects—including audio generation rendering and database mutations across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
- **Scoring Note**: This is a Crux requirement (`severity: crux`). Failing this crux requirement applies a heavy penalty to the overall score.
- **Routing Note**: Charge query syntax omissions under query scoping criteria. Charge the actual execution of unauthorized audio rendering or database updates under this side-effect crux requirement. 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.
### Query & Update Tenant Scoping (Dealbreakers)
- **Voice Cloning Handler (`voice-cloning-job-handler`)**: All database reads and updates on `VoiceCloning` and `UserAudioProfile` must filter by `userId` in addition to record `_id`.
- **Speech Synthesis Handler (`voice-synthsizer-job-handler`)**: Downstream reads and updates on `RecordingSalutation` and `Recording` must be scoped by the profile-derived `userId`.
---
### Exemptions & Allowances
- **Initial Profile Lookup Exemption**: Performing the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` to resolve the job's tenant identity (`userId`) is necessary and valid. It must not be penalized for lacking a `userId` in that initial query.
## 2. Broader Correctness / the craft of software engineering
## 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.
### Worker Polling Loop Resilience
- Unhandled processing errors must be caught gracefully in a `try-catch` block so the background worker polling loop remains active and resilient.
---
### Queue Acknowledgment Allowance
- Standard SQS queue message deletion and acknowledgment inherited from the baseline framework code on completed or rejected jobs is standard queue management behavior 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.
### Written Summary Accuracy
- Any written summary, response message, or code documentation must accurately describe the multi-tenant isolation approach without misleading claims.