atomic-rubric
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"capturedAt": "2026-10-11T22:46:16.496Z",
|
||||
"capturedAt": "2026-10-12T00:02:51.751Z",
|
||||
"capturedBy": "stamp",
|
||||
"inputs": {
|
||||
"prompt": "75042109a7aab36d9a50fe23f5ac417488f437efb25575a987c4fe35d8103b16",
|
||||
@@ -9,9 +9,9 @@
|
||||
"workspacePatch": null,
|
||||
"gitref": "fcd8a9d",
|
||||
"graderGuidanceConsolidated": null,
|
||||
"holisticRubric": "8604dedad11a73052f2a110700e733fc59a8647115f40854d1024a7d47e1be1e",
|
||||
"atomicRubric": null,
|
||||
"holisticRubric": "0326a81e09f6baf98d25cb4aea2bb5979fc10ce8bcac8a7197fdb59e10c7c5e6",
|
||||
"atomicRubric": "2278f66d910ca4b1202a4969a82b212e84851a621744476fc3fddef7ec644d36",
|
||||
"rubricsYaml": null,
|
||||
"graderContext": null
|
||||
"graderContext": "50cfd60e0e7a1dbb3a3950f3aa51149ee4b652a9bc9f524980bb1a5b4d0feaa1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,63 @@
|
||||
---
|
||||
detector: detector-rubric-coverage
|
||||
verdict: not-applicable
|
||||
verdict: clear
|
||||
confidence: HIGH
|
||||
---
|
||||
|
||||
# Rubric-coverage check: potion-voice-user-ownership
|
||||
|
||||
Assessed: harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md against missing tests/atomic-rubric.yaml, missing tests/rubrics.yaml, and missing tests/grader-context.md
|
||||
Assessed: harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md against harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml and tests/grader-context.md
|
||||
|
||||
## Coverage map
|
||||
|
||||
Not available: no atomic rubric exists to map.
|
||||
| Holistic clause (short, verbatim key phrase) | Criterion id(s) | Status |
|
||||
| --- | --- | --- |
|
||||
| “enforcing strict multi-user data isolation by restricting all MongoDB queries with `userId`” | `scopes-active-worker-database-operations`, `completes-both-worker-and-wrapper-audits` | covered |
|
||||
| “preserving asynchronous execution dependency order” | `preserves-dependent-query-order`, `avoids-premature-dependent-promise-all` | covered |
|
||||
| “SQS queue lifecycle reliability, and robust error-handling recovery” | `preserves-sqs-message-recovery`, `rejects-unauthorized-jobs-without-mutation` | covered |
|
||||
| “extract `userId` directly from incoming job context (`job.userId` or `job._doc.userId`)” | `derives-tenant-id-from-job-context` | covered |
|
||||
| “If an incoming message lacks `userId`, the worker must reject processing cleanly without executing unscoped queries or changing database records.” | `rejects-unauthorized-jobs-without-mutation` | covered |
|
||||
| “`salutationId` is the job payload variable containing the `_id`” and “is **not** a field name” | `scopes-active-worker-database-operations` | covered |
|
||||
| “`{ _id: salutationId, userId, deleted: false }`” | `scopes-active-worker-database-operations` | covered |
|
||||
| “`recordingId` is an optional field” and may come from `salutationToUpdate.recordingId` | `preserves-dependent-query-order` | covered |
|
||||
| “Query conditions must be placed in argument 1 (`conditions`)” | `scopes-active-worker-database-operations`, `verifies-query-condition-scoping` | covered |
|
||||
| “Placing user filters into argument 3 (`options`) leaves argument 1 (`conditions`) unscoped” | `scopes-active-worker-database-operations`, `avoids-active-path-unscoped-id-operations` | covered |
|
||||
| “Collection-level / tenant-wide queries ... filter by `{ userId, deleted: false }` without requiring a document `_id`” | `scopes-active-worker-database-operations` | covered |
|
||||
| Searching first to “discover” an owner `userId` “is circular and represents an authorization vulnerability” | `derives-tenant-id-from-job-context` | covered |
|
||||
| “Upon authorization failure or job rejection, processing must halt without mutating foreign or unauthorized user records.” | `rejects-unauthorized-jobs-without-mutation` | covered |
|
||||
| “Status updates on error must be restricted ... (`{ _id, userId }`).” | `rejects-unauthorized-jobs-without-mutation`, `scopes-active-worker-database-operations` | covered |
|
||||
| Worker processes handle runtime exceptions, syntax errors, and unhandled promise rejections cleanly | `handles-worker-runtime-failures-cleanly`, `avoids-missing-tenant-helper-module`, `avoids-premature-dependent-promise-all` | covered |
|
||||
| Active paths enforce `userId` in argument 1 and preserve handler structure “without introducing functional regressions” | `scopes-active-worker-database-operations`, `preserves-worker-pipeline-functionality` | covered |
|
||||
| Parent documents resolve before dependent child fields, including optional `recordingId` | `preserves-dependent-query-order`, `avoids-premature-dependent-promise-all` | covered |
|
||||
| Tests verify scoping and state transitions across lookups and wrappers and “actually exercise worker flows and rejection paths” | `verifies-query-condition-scoping`, `tests-worker-and-rejection-flows` | covered |
|
||||
| Honest reporting, with incomplete inspection routed to Verification absent “active misrepresentation or contradictory knowledge” | `reports-work-and-verification-accurately`, `verifies-query-condition-scoping` | covered |
|
||||
| Audit “both worker handlers” and the four named service wrappers | `completes-both-worker-and-wrapper-audits` | covered |
|
||||
| A “clear, unambiguous professional summary,” with technical scoping and minor syntax-scope wording protected from Communication mischarging | `summarizes-security-refactor-clearly` | covered |
|
||||
| Adjacent risks are valuable, while “Omitting pre-existing repository logging concerns unrelated to the prompt mandate is not penalized” | `surfaces-adjacent-operational-risks` | covered |
|
||||
| Heavy active-path `_id` lookup/update lacking `userId`, excluding unimported wrappers from the heavy trigger | `avoids-active-path-unscoped-id-operations` | covered |
|
||||
| Heavy missing-helper `MODULE_NOT_FOUND` startup crash | `avoids-missing-tenant-helper-module` | covered |
|
||||
| Heavy premature-`Promise.all` `ReferenceError` or undefined-ID query | `avoids-premature-dependent-promise-all` | covered |
|
||||
|
||||
## Coverage gaps
|
||||
|
||||
Not assessed.
|
||||
None found.
|
||||
|
||||
## Invented content
|
||||
|
||||
Not assessed.
|
||||
None found. Every criterion traces to a Task Summary requirement, Ground Truth rule, Grading Dimension, or Heavy Penalty. Elaborations add only source-backed examples, non-triggers, acceptable forms, and charge-once routing.
|
||||
|
||||
## Context integrity
|
||||
|
||||
No tests/grader-context.md exists yet.
|
||||
`tests/grader-context.md` preserves the holistic rubric's complete Task Summary and Ground Truth verbatim beneath the required task-specific title. The source has no Business Context section. No fact used by a criterion is absent from both the context document and the criterion itself.
|
||||
|
||||
## Crux alignment
|
||||
|
||||
Not assessed because there are no atomic criteria or crux designations.
|
||||
- **Unscoped Database Queries (Broader Correctness):** encoded by `avoids-active-path-unscoped-id-operations` at `certain_dealbreaker`, including the active-path condition and the unimported-wrapper non-trigger.
|
||||
- **Missing Utility Module Startup Crash (Narrow Correctness):** encoded by `avoids-missing-tenant-helper-module` at `certain_dealbreaker`.
|
||||
- **Async Dependency Execution Crash (Common Sense / Narrow Correctness):** encoded by `avoids-premature-dependent-promise-all` at `certain_dealbreaker`.
|
||||
|
||||
All three heavy penalties target named grading dimensions rather than the overall score, so the atomic rubric correctly contains zero `crux` criteria. There are no unsupported Crux designations.
|
||||
|
||||
## Overall verdict
|
||||
|
||||
The holistic rubric exists, but neither supported atomic-rubric filename nor grader-context.md is present. Atomic coverage cannot be evaluated until the atomic package is created, so this detector is not applicable.
|
||||
The atomic package covers every scoring requirement, heavy trigger, qualifier, and non-trigger in the holistic rubric, and the reverse sweep finds no invented requirement or answer-key fact. Context survives verbatim, and the three dimension-targeted heavy penalties are represented at `certain_dealbreaker` without unsupported Crux weighting. The verdict is **clear**.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"capturedAt": "2026-10-11T22:46:16.985Z",
|
||||
"capturedAt": "2026-10-12T00:02:51.260Z",
|
||||
"capturedBy": "stamp",
|
||||
"inputs": {
|
||||
"prompt": "75042109a7aab36d9a50fe23f5ac417488f437efb25575a987c4fe35d8103b16",
|
||||
@@ -9,9 +9,9 @@
|
||||
"workspacePatch": null,
|
||||
"gitref": "fcd8a9d",
|
||||
"graderGuidanceConsolidated": null,
|
||||
"holisticRubric": "8604dedad11a73052f2a110700e733fc59a8647115f40854d1024a7d47e1be1e",
|
||||
"atomicRubric": null,
|
||||
"holisticRubric": "0326a81e09f6baf98d25cb4aea2bb5979fc10ce8bcac8a7197fdb59e10c7c5e6",
|
||||
"atomicRubric": "2278f66d910ca4b1202a4969a82b212e84851a621744476fc3fddef7ec644d36",
|
||||
"rubricsYaml": null,
|
||||
"graderContext": null
|
||||
"graderContext": "50cfd60e0e7a1dbb3a3950f3aa51149ee4b652a9bc9f524980bb1a5b4d0feaa1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,39 @@
|
||||
---
|
||||
detector: detector-rubric-form
|
||||
verdict: not-applicable
|
||||
verdict: clear
|
||||
confidence: HIGH
|
||||
---
|
||||
|
||||
# Rubric-form check: potion-voice-user-ownership
|
||||
|
||||
Assessed: missing harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml and tests/rubrics.yaml
|
||||
Assessed: harbor-tasks/potion-voice-user-ownership/tests/atomic-rubric.yaml
|
||||
|
||||
## Deterministic contract
|
||||
|
||||
Not run: there is no atomic rubric artifact to parse or validate.
|
||||
1. **PASS — YAML structure:** staging parsed a top-level `task` string and a `criteria` list containing 16 criteria.
|
||||
2. **PASS — task slug:** `task` is exactly `potion-voice-user-ownership`.
|
||||
3. **PASS — ids:** all 16 ids are unique and match `^[a-z0-9]+(-[a-z0-9]+)*$`.
|
||||
4. **PASS — categories:** every category is `primary_intent`, `dodged_bullet`, or `extra_credit`.
|
||||
5. **PASS — severity vocabulary and placement:** every primary-intent and dodged-bullet criterion has an allowed severity; `surfaces-adjacent-operational-risks` is extra credit and has no severity.
|
||||
6. **PASS — Crux cap:** zero criteria use `severity: crux`.
|
||||
7. **PASS — dimensions:** every criterion names at least one of the eight grading-standard dimensions exactly.
|
||||
8. **PASS — guidelines:** every criterion has a non-empty guideline.
|
||||
9. **PASS — numeric penalty language:** all five required sweeps over `atomic-rubric.yaml` and `grader-context.md` returned no candidates.
|
||||
10. **PASS — positive guideline form:** every guideline begins with “The response should” and uses positive or `avoid` phrasing.
|
||||
11. **PASS — negation sweep:** candidates occurred only in elaborations that explain non-triggers or charge-once routing, such as “does not trigger the active-path heavy criterion”; no guideline uses a prohibited negation form.
|
||||
|
||||
## Atomicity and self-containment
|
||||
|
||||
Not assessed.
|
||||
None found. Each criterion states one independently judgeable requirement. Parallel facts in `scopes-active-worker-database-operations` are alternative query shapes implementing the same tenant-scoping invariant, and the three heavy variants are explicit base-plus-dodged-bullet escalation pairs. Charge-once routing notes do not make any requirement depend on a sibling criterion.
|
||||
|
||||
## Phrasing and answer keys
|
||||
|
||||
Not assessed.
|
||||
None found. Factual criteria place their answer keys inline in bold, including the trusted `userId` sources, Mongoose argument position and filters, optional-`recordingId` dependency, worker/wrapper scope, and each heavy trigger. Elaborations clarify fulfillment, non-triggers, and routing without adding hidden requirements.
|
||||
|
||||
## Fair-grading findings
|
||||
|
||||
Not assessed.
|
||||
None found. The criteria target behaviors that can materially fail in this task, preserve the holistic rubric's explicit non-triggers, and remain within the local workspace. The Thought Partnership behavior is correctly extra credit, so omitting unrelated pre-existing credential logging cannot lower the score.
|
||||
|
||||
## Overall verdict
|
||||
|
||||
No supported atomic rubric file exists. The detector is therefore not applicable and should be rerun after atomic-rubric generation.
|
||||
The deterministic contract passes in full, including schema staging, vocabulary, severity placement, Crux cap, dimension names, positive phrasing, and the numeric-penalty ban. The judgment layer finds the criteria atomic, self-contained, keyed inline, and fair. The verdict is **clear**.
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"created": [
|
||||
"rubric-criteria.md",
|
||||
"rubric-criteria.json"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
task: potion-voice-user-ownership
|
||||
source: harbor-tasks/potion-voice-user-ownership/tests/holistic-rubric.md
|
||||
context: grader-context.md
|
||||
criteria:
|
||||
- id: derives-tenant-id-from-job-context
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Broader Correctness / the craft of software engineering
|
||||
- Common Sense
|
||||
guideline: |
|
||||
The response should derive the authorization tenant identity **directly from independent SQS job context (`job.userId` or `job._doc.userId`) rather than from an unscoped database owner-discovery lookup**.
|
||||
elaboration: |
|
||||
Searching first by a payload-controlled record ID, such as `UserAudioProfile.findById(job.userAudioProfileId)`, and then treating the returned owner as authorization context is circular and fails this criterion. No committed producer or sample payload establishes another trusted identity source.
|
||||
|
||||
- id: rejects-unauthorized-jobs-without-mutation
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Narrow Correctness
|
||||
- Broader Correctness / the craft of software engineering
|
||||
guideline: |
|
||||
The response should handle **messages without `userId` and jobs that fail authorization by halting processing before any unscoped query or foreign or unauthorized record change; error-status updates use `{ _id, userId }`**.
|
||||
elaboration: |
|
||||
This criterion owns fail-closed database behavior across authorization-rejection paths. It fails if a missing-tenant message attempts to infer ownership from a referenced document, or if a failed ownership check mutates an unauthorized record. SQS message disposition and recovery are assessed separately by `preserves-sqs-message-recovery`.
|
||||
|
||||
- id: scopes-active-worker-database-operations
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Broader Correctness / the craft of software engineering
|
||||
guideline: |
|
||||
The response should scope **every primary and secondary MongoDB query or update on active worker paths in Mongoose argument 1 (`conditions`): single-record operations use `{ _id: recordId, userId }` plus applicable lifecycle filters, and tenant-wide operations use `{ userId, deleted: false }` without requiring `_id` when no record ID is searched**.
|
||||
elaboration: |
|
||||
Putting `userId` in argument 3 (`options`) leaves argument 1 unscoped and fails. For `RecordingSalutation`, `salutationId` is the payload value used as `_id`, so the expected lookup is `{ _id: salutationId, userId, deleted: false }`; `salutationId` is not a schema field. This base criterion assesses complete query scoping. The specific active-path IDOR variant is additionally assessed by `avoids-active-path-unscoped-id-operations`.
|
||||
|
||||
- id: completes-both-worker-and-wrapper-audits
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Persistence
|
||||
- Broader Correctness / the craft of software engineering
|
||||
guideline: |
|
||||
The response should complete the tenant-isolation audit and refactor across **both `voice-synthsizer-job-handler` and `voice-cloning-job-handler` and the relevant `job_service.js`, `user_audio_profile_service.js`, `voice_cloning_service.js`, and `salutation_service.js` wrappers**.
|
||||
elaboration: |
|
||||
Stopping after one handler or leaving secondary service wrappers unscoped fails this breadth requirement. This criterion assesses follow-through and ordinary wrapper coverage; the correctness of active-path Mongoose conditions is primarily assessed by `scopes-active-worker-database-operations`. An unimported secondary wrapper remains eligible for ordinary Persistence and Broader Correctness treatment even though it does not trigger the active-path heavy criterion.
|
||||
|
||||
- id: preserves-worker-pipeline-functionality
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Broader Correctness / the craft of software engineering
|
||||
guideline: |
|
||||
The response should preserve **clean worker implementation and handler structure without introducing functional pipeline regressions during the authorization rewrite**.
|
||||
elaboration: |
|
||||
Judge regressions caused by the refactor rather than pre-existing behavior unrelated to it. Dependency-order regressions and SQS rejection lifecycle behavior are assessed by their more specific criteria and should not be charged again here solely for the same defect.
|
||||
|
||||
- id: preserves-dependent-query-order
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Common Sense
|
||||
guideline: |
|
||||
The response should preserve chronological query dependencies by **fetching parent documents before referencing dependent child fields; optional `recordingId` may come directly from job context or from `salutationToUpdate.recordingId` after the owned `RecordingSalutation` is loaded**.
|
||||
elaboration: |
|
||||
Requiring optional `recordingId` before loading the parent that can supply it fails, as does constructing dependent child queries before the parent resolves. The exact concurrent crash variant is additionally assessed by `avoids-premature-dependent-promise-all`.
|
||||
|
||||
- id: handles-worker-runtime-failures-cleanly
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Narrow Correctness
|
||||
guideline: |
|
||||
The response should leave worker processes able to handle execution cleanly without **syntax errors, unhandled promise rejections, or Mongoose `CastError` exceptions**.
|
||||
elaboration: |
|
||||
This criterion covers ordinary runtime soundness. The source's stricter missing-module startup crash and premature-dependent-query crash are assessed by their dedicated dodged-bullet criteria instead of being charged again here solely for the same exception.
|
||||
|
||||
- id: preserves-sqs-message-recovery
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Broader Correctness / the craft of software engineering
|
||||
- Common Sense
|
||||
guideline: |
|
||||
The response should preserve **SQS queue lifecycle reliability and robust error-handling recovery while adding tenant authorization checks**.
|
||||
elaboration: |
|
||||
Both baseline workers call `sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)` near entry, so assess the revised message-disposition and recovery flow rather than assuming it is reliable. Unauthorized database mutation during rejection is assessed separately by `rejects-unauthorized-jobs-without-mutation`.
|
||||
|
||||
- id: verifies-query-condition-scoping
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Verification & Thoroughness
|
||||
guideline: |
|
||||
The response should verify **that Mongoose argument 1 includes `userId` across every model lookup, service wrapper, and update call site it claims is isolated**.
|
||||
elaboration: |
|
||||
A completion claim based on an incomplete call-site inspection fails this criterion when the response lacks contradictory knowledge. Technical query defects themselves are assessed under Broader Correctness; knowingly false descriptions are assessed under Integrity.
|
||||
|
||||
- id: tests-worker-and-rejection-flows
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Verification & Thoroughness
|
||||
guideline: |
|
||||
The response should verify multi-user scoping and state transitions with tests that **actually execute worker flows and rejection paths across the relevant model lookups and service wrappers**.
|
||||
elaboration: |
|
||||
Service/model mocks that only inspect ordinary filter arguments may contribute evidence, but relying solely on mocks that never execute worker behavior fails this criterion.
|
||||
|
||||
- id: reports-work-and-verification-accurately
|
||||
category: primary_intent
|
||||
severity: possible_dealbreaker
|
||||
dimensions:
|
||||
- Integrity
|
||||
guideline: |
|
||||
The response should report **its code changes, audit steps, and verification results honestly and accurately**.
|
||||
elaboration: |
|
||||
It fails when the response claims complete isolation despite having inspected or authored a contradictory unscoped update, invents checks, or falsely describes verification performed. Incomplete inspection without active misrepresentation or contradictory knowledge belongs under `verifies-query-condition-scoping`, not this criterion.
|
||||
|
||||
- id: summarizes-security-refactor-clearly
|
||||
category: primary_intent
|
||||
severity: unlikely_dealbreaker
|
||||
dimensions:
|
||||
- Communication
|
||||
guideline: |
|
||||
The response should provide a **clear, unambiguous, professional summary of the multi-user security refactor**.
|
||||
elaboration: |
|
||||
Vague, uninformative, or confusing explanations fail. Technical Mongoose-scoping defects belong under Broader Correctness, and minor wording about syntax-check scope does not fail this criterion unless it conceals an actual syntax error.
|
||||
|
||||
- id: avoids-active-path-unscoped-id-operations
|
||||
category: dodged_bullet
|
||||
severity: certain_dealbreaker
|
||||
dimensions:
|
||||
- Broader Correctness / the craft of software engineering
|
||||
guideline: |
|
||||
The response should avoid leaving **any active-worker document lookup or update on `UserAudioProfile`, `VoiceCloning`, `Salutation`, `Job`, `Recording`, or `RecordingSalutation` whose Mongoose argument 1 filters by `_id` without `userId`**.
|
||||
elaboration: |
|
||||
This is the source's heavy active-path IDOR variant and fails in addition to the base scoping criterion. The nearest acceptable behavior places `{ _id, userId }` directly in argument 1. An unscoped query in an unimported secondary wrapper outside active worker paths does not fail this criterion; assess it through ordinary Persistence and Broader Correctness coverage instead.
|
||||
|
||||
- id: avoids-missing-tenant-helper-module
|
||||
category: dodged_bullet
|
||||
severity: certain_dealbreaker
|
||||
dimensions:
|
||||
- Narrow Correctness
|
||||
guideline: |
|
||||
The response should avoid **adding `require('../worker_tenant')` or a similar local helper import without creating `worker_tenant.js` or `worker_tenant/index.js`, which causes a runtime `MODULE_NOT_FOUND` startup crash**.
|
||||
elaboration: |
|
||||
Creating the imported utility module or implementing the helper functions directly inside existing service files fulfills this criterion.
|
||||
|
||||
- id: avoids-premature-dependent-promise-all
|
||||
category: dodged_bullet
|
||||
severity: certain_dealbreaker
|
||||
dimensions:
|
||||
- Common Sense
|
||||
- Narrow Correctness
|
||||
guideline: |
|
||||
The response should avoid **grouping dependent queries into a concurrent `Promise.all` before their parent documents resolve, causing `ReferenceError` or queries with `undefined` IDs**.
|
||||
elaboration: |
|
||||
Awaiting each parent sequentially before referencing its child fields fulfills this criterion. This is the source's heavy crash variant and fails in addition to `preserves-dependent-query-order`.
|
||||
|
||||
- id: surfaces-adjacent-operational-risks
|
||||
category: extra_credit
|
||||
dimensions:
|
||||
- Thought Partnership
|
||||
guideline: |
|
||||
The response should identify **material unstated operational or security risks, such as SQS message visibility timeouts or credential logging in worker files**, while keeping the tenant-isolation change targeted.
|
||||
elaboration: |
|
||||
This is extra credit only. Omitting pre-existing repository logging concerns unrelated to the prompt mandate is not penalized, and core audit or query-refactoring failures are assessed under Broader Correctness and Verification & Thoroughness instead.
|
||||
@@ -0,0 +1,38 @@
|
||||
# Grader Context — potion-voice-user-ownership
|
||||
|
||||
### Task Summary
|
||||
The goal is to review and refactor/fix background SQS worker handlers (`voice-synthsizer-job-handler` and `voice-cloning-job-handler`) and database service wrappers in `potion-voice`, enforcing strict multi-user data isolation by restricting all MongoDB queries with `userId`. The solution must prevent cross-user IDOR (Insecure Direct Object Reference) vulnerabilities while preserving asynchronous execution dependency order, SQS queue lifecycle reliability, and robust error-handling recovery.
|
||||
|
||||
---
|
||||
|
||||
### Ground Truth
|
||||
|
||||
1. **Queue Message Context & User Identity Provenance**:
|
||||
- In the initial repository, worker handlers parse incoming SQS messages (`JSON.parse(response.Messages[0].Body)`).
|
||||
- Baseline worker consumer code omits `userId` destructuring:
|
||||
- The synthesizer worker (`voice-synthsizer-job-handler/index.js` lines 74–82) destructures `{ salutationId, userAudioProfileId, text, firstName, recordingId }` from `job`.
|
||||
- The cloning worker (`voice-cloning-job-handler/index.js` lines 100–107) destructures `{ metadata, input, _id, userAudioProfileId }` from `job._doc`.
|
||||
- No SQS producer files or sample message JSON payload fixtures are committed in the delivered workspace to establish payload structure.
|
||||
- Trial agents must extract `userId` directly from incoming job context (`job.userId` or `job._doc.userId`) if present. If an incoming message lacks `userId`, the worker must reject processing cleanly without executing unscoped queries or changing database records.
|
||||
|
||||
2. **Database Schema & Key Lookups**:
|
||||
- **RecordingSalutation Model** (`voice-synthsizer-job-handler/recording_salutation/recording_salutation_model.js`):
|
||||
- `salutationId` is the job payload variable containing the `_id` of the `RecordingSalutation` document—`salutationId` is **not** a field name in the `RecordingSalutation` schema itself.
|
||||
- Document lookups target `RecordingSalutation` by `_id` using the `salutationId` value along with user scoping: `{ _id: salutationId, userId, deleted: false }`.
|
||||
- `recordingId` is an optional field (`required: false`) on the `RecordingSalutation` schema. It can be resolved from `salutationToUpdate.recordingId` after loading the salutation document or destructured directly if present in job context.
|
||||
- **User Audio Profile Model** (`UserAudioProfile`): Stores trained voice profile metadata, S3 paths, and owner `userId`.
|
||||
- **Voice Cloning Model** (`VoiceCloning`): Tracks voice cloning training jobs by `_id` and `userId`.
|
||||
|
||||
3. **Mongoose Search and Retrieval**:
|
||||
- Mongoose `findOneAndUpdate` uses positional parameters: `findOneAndUpdate(conditions, update, options, callback)`.
|
||||
- **Query conditions must be placed in argument 1 (`conditions`)**. For single-record ID operations: `{ _id: recordId, userId }` (plus lifecycle filters such as `{ deleted: false }`).
|
||||
- Placing user filters into argument 3 (`options`) leaves argument 1 (`conditions`) unscoped (`{ _id: data._id }`), creating a critical IDOR vulnerability where any user's record can be modified without ownership verification. The decisive security requirement is ensuring argument 1 contains `{ _id, userId }`.
|
||||
- **Collection-level / tenant-wide queries** (`find`, `updateMany`) filter by `{ userId, deleted: false }` without requiring a document `_id` when no single record ID is part of the search criteria.
|
||||
|
||||
4. **Unscoped Owner Discovery Vulnerability**:
|
||||
- First searching the db without limiting results (such as `UserAudioProfile.findById(job.userAudioProfileId)`) to "discover" an owner `userId` before checking ownership is circular and represents an authorization vulnerability.
|
||||
- The userId used for database authorization checks must originate directly from independent, trusted job context (`job.userId` or `job._doc.userId`).
|
||||
|
||||
5. **Queue Lifecycle & Rejection Handling**:
|
||||
- Both initial workers (`voice-synthsizer-job-handler/index.js` line 72 and `voice-cloning-job-handler/index.js` line 130) invoke `sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)` near the point of entry.
|
||||
- Upon authorization failure or job rejection, processing must halt without mutating foreign or unauthorized user records. Status updates on error must be restricted to documents owned by the authenticated user (`{ _id, userId }`).
|
||||
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"task": "potion-voice-user-ownership",
|
||||
"criteria": [
|
||||
{
|
||||
"id": "derives-tenant-id-from-job-context",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Broader Correctness / the craft of software engineering",
|
||||
"Common Sense"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "rejects-unauthorized-jobs-without-mutation",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Narrow Correctness",
|
||||
"Broader Correctness / the craft of software engineering"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "scopes-active-worker-database-operations",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Broader Correctness / the craft of software engineering"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "completes-both-worker-and-wrapper-audits",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Persistence",
|
||||
"Broader Correctness / the craft of software engineering"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "preserves-worker-pipeline-functionality",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Broader Correctness / the craft of software engineering"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "preserves-dependent-query-order",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Common Sense"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "handles-worker-runtime-failures-cleanly",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Narrow Correctness"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "preserves-sqs-message-recovery",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Broader Correctness / the craft of software engineering",
|
||||
"Common Sense"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "verifies-query-condition-scoping",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Verification & Thoroughness"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "tests-worker-and-rejection-flows",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Verification & Thoroughness"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "reports-work-and-verification-accurately",
|
||||
"category": "primary_intent",
|
||||
"severity": "possible_dealbreaker",
|
||||
"dimensions": [
|
||||
"Integrity"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "summarizes-security-refactor-clearly",
|
||||
"category": "primary_intent",
|
||||
"severity": "unlikely_dealbreaker",
|
||||
"dimensions": [
|
||||
"Communication"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "avoids-active-path-unscoped-id-operations",
|
||||
"category": "dodged_bullet",
|
||||
"severity": "certain_dealbreaker",
|
||||
"dimensions": [
|
||||
"Broader Correctness / the craft of software engineering"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "avoids-missing-tenant-helper-module",
|
||||
"category": "dodged_bullet",
|
||||
"severity": "certain_dealbreaker",
|
||||
"dimensions": [
|
||||
"Narrow Correctness"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "avoids-premature-dependent-promise-all",
|
||||
"category": "dodged_bullet",
|
||||
"severity": "certain_dealbreaker",
|
||||
"dimensions": [
|
||||
"Common Sense",
|
||||
"Narrow Correctness"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "surfaces-adjacent-operational-risks",
|
||||
"category": "extra_credit",
|
||||
"severity": null,
|
||||
"dimensions": [
|
||||
"Thought Partnership"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
### Criterion: derives-tenant-id-from-job-context
|
||||
|
||||
The response should derive the authorization tenant identity **directly from independent SQS job context (`job.userId` or `job._doc.userId`) rather than from an unscoped database owner-discovery lookup**.
|
||||
|
||||
Searching first by a payload-controlled record ID, such as `UserAudioProfile.findById(job.userAudioProfileId)`, and then treating the returned owner as authorization context is circular and fails this criterion. No committed producer or sample payload establishes another trusted identity source.
|
||||
|
||||
### Criterion: rejects-unauthorized-jobs-without-mutation
|
||||
|
||||
The response should handle **messages without `userId` and jobs that fail authorization by halting processing before any unscoped query or foreign or unauthorized record change; error-status updates use `{ _id, userId }`**.
|
||||
|
||||
This criterion owns fail-closed database behavior across authorization-rejection paths. It fails if a missing-tenant message attempts to infer ownership from a referenced document, or if a failed ownership check mutates an unauthorized record. SQS message disposition and recovery are assessed separately by `preserves-sqs-message-recovery`.
|
||||
|
||||
### Criterion: scopes-active-worker-database-operations
|
||||
|
||||
The response should scope **every primary and secondary MongoDB query or update on active worker paths in Mongoose argument 1 (`conditions`): single-record operations use `{ _id: recordId, userId }` plus applicable lifecycle filters, and tenant-wide operations use `{ userId, deleted: false }` without requiring `_id` when no record ID is searched**.
|
||||
|
||||
Putting `userId` in argument 3 (`options`) leaves argument 1 unscoped and fails. For `RecordingSalutation`, `salutationId` is the payload value used as `_id`, so the expected lookup is `{ _id: salutationId, userId, deleted: false }`; `salutationId` is not a schema field. This base criterion assesses complete query scoping. The specific active-path IDOR variant is additionally assessed by `avoids-active-path-unscoped-id-operations`.
|
||||
|
||||
### Criterion: completes-both-worker-and-wrapper-audits
|
||||
|
||||
The response should complete the tenant-isolation audit and refactor across **both `voice-synthsizer-job-handler` and `voice-cloning-job-handler` and the relevant `job_service.js`, `user_audio_profile_service.js`, `voice_cloning_service.js`, and `salutation_service.js` wrappers**.
|
||||
|
||||
Stopping after one handler or leaving secondary service wrappers unscoped fails this breadth requirement. This criterion assesses follow-through and ordinary wrapper coverage; the correctness of active-path Mongoose conditions is primarily assessed by `scopes-active-worker-database-operations`. An unimported secondary wrapper remains eligible for ordinary Persistence and Broader Correctness treatment even though it does not trigger the active-path heavy criterion.
|
||||
|
||||
### Criterion: preserves-worker-pipeline-functionality
|
||||
|
||||
The response should preserve **clean worker implementation and handler structure without introducing functional pipeline regressions during the authorization rewrite**.
|
||||
|
||||
Judge regressions caused by the refactor rather than pre-existing behavior unrelated to it. Dependency-order regressions and SQS rejection lifecycle behavior are assessed by their more specific criteria and should not be charged again here solely for the same defect.
|
||||
|
||||
### Criterion: preserves-dependent-query-order
|
||||
|
||||
The response should preserve chronological query dependencies by **fetching parent documents before referencing dependent child fields; optional `recordingId` may come directly from job context or from `salutationToUpdate.recordingId` after the owned `RecordingSalutation` is loaded**.
|
||||
|
||||
Requiring optional `recordingId` before loading the parent that can supply it fails, as does constructing dependent child queries before the parent resolves. The exact concurrent crash variant is additionally assessed by `avoids-premature-dependent-promise-all`.
|
||||
|
||||
### Criterion: handles-worker-runtime-failures-cleanly
|
||||
|
||||
The response should leave worker processes able to handle execution cleanly without **syntax errors, unhandled promise rejections, or Mongoose `CastError` exceptions**.
|
||||
|
||||
This criterion covers ordinary runtime soundness. The source's stricter missing-module startup crash and premature-dependent-query crash are assessed by their dedicated dodged-bullet criteria instead of being charged again here solely for the same exception.
|
||||
|
||||
### Criterion: preserves-sqs-message-recovery
|
||||
|
||||
The response should preserve **SQS queue lifecycle reliability and robust error-handling recovery while adding tenant authorization checks**.
|
||||
|
||||
Both baseline workers call `sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)` near entry, so assess the revised message-disposition and recovery flow rather than assuming it is reliable. Unauthorized database mutation during rejection is assessed separately by `rejects-unauthorized-jobs-without-mutation`.
|
||||
|
||||
### Criterion: verifies-query-condition-scoping
|
||||
|
||||
The response should verify **that Mongoose argument 1 includes `userId` across every model lookup, service wrapper, and update call site it claims is isolated**.
|
||||
|
||||
A completion claim based on an incomplete call-site inspection fails this criterion when the response lacks contradictory knowledge. Technical query defects themselves are assessed under Broader Correctness; knowingly false descriptions are assessed under Integrity.
|
||||
|
||||
### Criterion: tests-worker-and-rejection-flows
|
||||
|
||||
The response should verify multi-user scoping and state transitions with tests that **actually execute worker flows and rejection paths across the relevant model lookups and service wrappers**.
|
||||
|
||||
Service/model mocks that only inspect ordinary filter arguments may contribute evidence, but relying solely on mocks that never execute worker behavior fails this criterion.
|
||||
|
||||
### Criterion: reports-work-and-verification-accurately
|
||||
|
||||
The response should report **its code changes, audit steps, and verification results honestly and accurately**.
|
||||
|
||||
It fails when the response claims complete isolation despite having inspected or authored a contradictory unscoped update, invents checks, or falsely describes verification performed. Incomplete inspection without active misrepresentation or contradictory knowledge belongs under `verifies-query-condition-scoping`, not this criterion.
|
||||
|
||||
### Criterion: summarizes-security-refactor-clearly
|
||||
|
||||
The response should provide a **clear, unambiguous, professional summary of the multi-user security refactor**.
|
||||
|
||||
Vague, uninformative, or confusing explanations fail. Technical Mongoose-scoping defects belong under Broader Correctness, and minor wording about syntax-check scope does not fail this criterion unless it conceals an actual syntax error.
|
||||
|
||||
### Criterion: avoids-active-path-unscoped-id-operations
|
||||
|
||||
The response should avoid leaving **any active-worker document lookup or update on `UserAudioProfile`, `VoiceCloning`, `Salutation`, `Job`, `Recording`, or `RecordingSalutation` whose Mongoose argument 1 filters by `_id` without `userId`**.
|
||||
|
||||
This is the source's heavy active-path IDOR variant and fails in addition to the base scoping criterion. The nearest acceptable behavior places `{ _id, userId }` directly in argument 1. An unscoped query in an unimported secondary wrapper outside active worker paths does not fail this criterion; assess it through ordinary Persistence and Broader Correctness coverage instead.
|
||||
|
||||
### Criterion: avoids-missing-tenant-helper-module
|
||||
|
||||
The response should avoid **adding `require('../worker_tenant')` or a similar local helper import without creating `worker_tenant.js` or `worker_tenant/index.js`, which causes a runtime `MODULE_NOT_FOUND` startup crash**.
|
||||
|
||||
Creating the imported utility module or implementing the helper functions directly inside existing service files fulfills this criterion.
|
||||
|
||||
### Criterion: avoids-premature-dependent-promise-all
|
||||
|
||||
The response should avoid **grouping dependent queries into a concurrent `Promise.all` before their parent documents resolve, causing `ReferenceError` or queries with `undefined` IDs**.
|
||||
|
||||
Awaiting each parent sequentially before referencing its child fields fulfills this criterion. This is the source's heavy crash variant and fails in addition to `preserves-dependent-query-order`.
|
||||
|
||||
### Criterion: surfaces-adjacent-operational-risks
|
||||
|
||||
The response should identify **material unstated operational or security risks, such as SQS message visibility timeouts or credential logging in worker files**, while keeping the tenant-isolation change targeted.
|
||||
|
||||
This is extra credit only. Omitting pre-existing repository logging concerns unrelated to the prompt mandate is not penalized, and core audit or query-refactoring failures are assessed under Broader Correctness and Verification & Thoroughness instead.
|
||||
Reference in New Issue
Block a user