Run completed successfully: 4/4 trials, 0 exceptions, mean 0.830.
- pdFfcXv: 0.880 - bqMyPUM: 0.870 - W5t25ZE: 0.800 - auZATkH: 0.770 Results: result.json (harbor-jobs/2026-10-22__17-47-18/result.json)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"job_name": "2026-10-22__17-47-18",
|
||||
"jobs_dir": "harbor-jobs",
|
||||
"n_attempts": 4,
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
}
|
||||
},
|
||||
"agents": [
|
||||
{
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tasks": [
|
||||
{
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
Skipping image OS validation for hb__1489968d76cf84d223a8d0bfc3d16e72: docker inspect returned 1
|
||||
Skipping image OS validation for hb__1489968d76cf84d223a8d0bfc3d16e72: docker inspect returned 1
|
||||
Skipping image OS validation for hb__1489968d76cf84d223a8d0bfc3d16e72: docker inspect returned 1
|
||||
Skipping image OS validation for hb__1489968d76cf84d223a8d0bfc3d16e72: docker inspect returned 1
|
||||
Running command: set -x; if command -v apt-get >/dev/null 2>&1; then apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq curl ripgrep >/dev/null 2>&1 || true; fi; if ! command -v codex >/dev/null 2>&1; then CODEX_INSTALL_DIR=/usr/local/bin CODEX_NON_INTERACTIVE=true sh -c "curl -fsSL https://chatgpt.com/codex/install.sh | sh" >&2 || true; fi; if ! command -v codex >/dev/null 2>&1 && [ -x "$HOME/.local/bin/codex" ]; then ln -sf "$HOME/.local/bin/codex" /usr/local/bin/codex; fi; if ! command -v codex >/dev/null 2>&1; then export NVM_DIR="${NVM_DIR:-/usr/local/share/nvm}"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true; if ! command -v npm >/dev/null 2>&1; then npm_path="$(find /usr/local/share/nvm /usr/local /usr/lib /opt -name npm -type f 2>/dev/null | head -1)"; [ -n "$npm_path" ] && export PATH="$PATH:$(dirname "$npm_path")"; fi; command -v npm >/dev/null 2>&1 && npm install -g @openai/codex@latest; fi; for bin in node codex; do p="$(command -v "$bin" 2>/dev/null || true)"; [ -n "$p" ] && [ "$p" != "/usr/local/bin/$bin" ] && ln -sf "$p" "/usr/local/bin/$bin" || true; done; command -v codex >/dev/null 2>&1 || { echo "FATAL: codex CLI unavailable (standalone installer and npm both failed)" >&2; exit 1; }; codex --version
|
||||
Running command: set -x; if command -v apt-get >/dev/null 2>&1; then apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq curl ripgrep >/dev/null 2>&1 || true; fi; if ! command -v codex >/dev/null 2>&1; then CODEX_INSTALL_DIR=/usr/local/bin CODEX_NON_INTERACTIVE=true sh -c "curl -fsSL https://chatgpt.com/codex/install.sh | sh" >&2 || true; fi; if ! command -v codex >/dev/null 2>&1 && [ -x "$HOME/.local/bin/codex" ]; then ln -sf "$HOME/.local/bin/codex" /usr/local/bin/codex; fi; if ! command -v codex >/dev/null 2>&1; then export NVM_DIR="${NVM_DIR:-/usr/local/share/nvm}"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true; if ! command -v npm >/dev/null 2>&1; then npm_path="$(find /usr/local/share/nvm /usr/local /usr/lib /opt -name npm -type f 2>/dev/null | head -1)"; [ -n "$npm_path" ] && export PATH="$PATH:$(dirname "$npm_path")"; fi; command -v npm >/dev/null 2>&1 && npm install -g @openai/codex@latest; fi; for bin in node codex; do p="$(command -v "$bin" 2>/dev/null || true)"; [ -n "$p" ] && [ "$p" != "/usr/local/bin/$bin" ] && ln -sf "$p" "/usr/local/bin/$bin" || true; done; command -v codex >/dev/null 2>&1 || { echo "FATAL: codex CLI unavailable (standalone installer and npm both failed)" >&2; exit 1; }; codex --version
|
||||
Running command: set -x; if command -v apt-get >/dev/null 2>&1; then apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq curl ripgrep >/dev/null 2>&1 || true; fi; if ! command -v codex >/dev/null 2>&1; then CODEX_INSTALL_DIR=/usr/local/bin CODEX_NON_INTERACTIVE=true sh -c "curl -fsSL https://chatgpt.com/codex/install.sh | sh" >&2 || true; fi; if ! command -v codex >/dev/null 2>&1 && [ -x "$HOME/.local/bin/codex" ]; then ln -sf "$HOME/.local/bin/codex" /usr/local/bin/codex; fi; if ! command -v codex >/dev/null 2>&1; then export NVM_DIR="${NVM_DIR:-/usr/local/share/nvm}"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true; if ! command -v npm >/dev/null 2>&1; then npm_path="$(find /usr/local/share/nvm /usr/local /usr/lib /opt -name npm -type f 2>/dev/null | head -1)"; [ -n "$npm_path" ] && export PATH="$PATH:$(dirname "$npm_path")"; fi; command -v npm >/dev/null 2>&1 && npm install -g @openai/codex@latest; fi; for bin in node codex; do p="$(command -v "$bin" 2>/dev/null || true)"; [ -n "$p" ] && [ "$p" != "/usr/local/bin/$bin" ] && ln -sf "$p" "/usr/local/bin/$bin" || true; done; command -v codex >/dev/null 2>&1 || { echo "FATAL: codex CLI unavailable (standalone installer and npm both failed)" >&2; exit 1; }; codex --version
|
||||
Running command: set -x; if command -v apt-get >/dev/null 2>&1; then apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq curl ripgrep >/dev/null 2>&1 || true; fi; if ! command -v codex >/dev/null 2>&1; then CODEX_INSTALL_DIR=/usr/local/bin CODEX_NON_INTERACTIVE=true sh -c "curl -fsSL https://chatgpt.com/codex/install.sh | sh" >&2 || true; fi; if ! command -v codex >/dev/null 2>&1 && [ -x "$HOME/.local/bin/codex" ]; then ln -sf "$HOME/.local/bin/codex" /usr/local/bin/codex; fi; if ! command -v codex >/dev/null 2>&1; then export NVM_DIR="${NVM_DIR:-/usr/local/share/nvm}"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true; if ! command -v npm >/dev/null 2>&1; then npm_path="$(find /usr/local/share/nvm /usr/local /usr/lib /opt -name npm -type f 2>/dev/null | head -1)"; [ -n "$npm_path" ] && export PATH="$PATH:$(dirname "$npm_path")"; fi; command -v npm >/dev/null 2>&1 && npm install -g @openai/codex@latest; fi; for bin in node codex; do p="$(command -v "$bin" 2>/dev/null || true)"; [ -n "$p" ] && [ "$p" != "/usr/local/bin/$bin" ] && ln -sf "$p" "/usr/local/bin/$bin" || true; done; command -v codex >/dev/null 2>&1 || { echo "FATAL: codex CLI unavailable (standalone installer and npm both failed)" >&2; exit 1; }; codex --version
|
||||
Command outputs captured
|
||||
Command outputs captured
|
||||
Command outputs captured
|
||||
Command outputs captured
|
||||
Running command: mkdir -p "$CODEX_HOME" /tmp/codex-secrets /logs/agent
|
||||
Running command: mkdir -p "$CODEX_HOME" /tmp/codex-secrets /logs/agent
|
||||
Running command: mkdir -p "$CODEX_HOME" /tmp/codex-secrets /logs/agent
|
||||
Running command: mkdir -p "$CODEX_HOME" /tmp/codex-secrets /logs/agent
|
||||
Command outputs captured
|
||||
Codex auth: using OPENAI_API_KEY
|
||||
Running command: cat >/tmp/codex-secrets/auth.json <<EOF
|
||||
{
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
||||
}
|
||||
EOF
|
||||
ln -sf /tmp/codex-secrets/auth.json "$CODEX_HOME/auth.json"
|
||||
|
||||
cat >>"$CODEX_HOME/config.toml" <<TOML
|
||||
openai_base_url = "${OPENAI_BASE_URL}"
|
||||
TOML
|
||||
Command outputs captured
|
||||
Codex auth: using OPENAI_API_KEY
|
||||
Running command: cat >/tmp/codex-secrets/auth.json <<EOF
|
||||
{
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
||||
}
|
||||
EOF
|
||||
ln -sf /tmp/codex-secrets/auth.json "$CODEX_HOME/auth.json"
|
||||
|
||||
cat >>"$CODEX_HOME/config.toml" <<TOML
|
||||
openai_base_url = "${OPENAI_BASE_URL}"
|
||||
TOML
|
||||
Command outputs captured
|
||||
Codex auth: using OPENAI_API_KEY
|
||||
Running command: cat >/tmp/codex-secrets/auth.json <<EOF
|
||||
{
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
||||
}
|
||||
EOF
|
||||
ln -sf /tmp/codex-secrets/auth.json "$CODEX_HOME/auth.json"
|
||||
|
||||
cat >>"$CODEX_HOME/config.toml" <<TOML
|
||||
openai_base_url = "${OPENAI_BASE_URL}"
|
||||
TOML
|
||||
Command outputs captured
|
||||
Codex auth: using OPENAI_API_KEY
|
||||
Running command: cat >/tmp/codex-secrets/auth.json <<EOF
|
||||
{
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
||||
}
|
||||
EOF
|
||||
ln -sf /tmp/codex-secrets/auth.json "$CODEX_HOME/auth.json"
|
||||
|
||||
cat >>"$CODEX_HOME/config.toml" <<TOML
|
||||
openai_base_url = "${OPENAI_BASE_URL}"
|
||||
TOML
|
||||
Command outputs captured
|
||||
Running command: if [ -s ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh; fi; codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --model gpt-5.6-sol --json --enable unified_exec -c model_reasoning_effort=max -c agents.enabled=false -c features.external_agent_memory_import=false -c features.goals=false -c features.memories=false -c features.multi_agent=false -c features.multi_agent_v2=false -c tools.experimental_request_user_input.enabled=false -c tools.update_plan.enabled=false -c web_search=disabled -c model_provider=llm-proxy -c 'model_providers.llm-proxy.name="LLM proxy"' -c 'model_providers.llm-proxy.base_url="https://app-llmproxy.dataannotation.tech/api/llm_proxy/openai/v1"' -c 'model_providers.llm-proxy.env_key="OPENAI_API_KEY"' -c 'model_providers.llm-proxy.wire_api="responses"' -c 'model_providers.llm-proxy.http_headers.X-Surge-Client-Metadata='"'"'{"origin":"harbor-trial"}'"'"'' -- '# Background Worker Multi-Tenant Isolation Audit & Refactor
|
||||
|
||||
Our backend background processing services run asynchronous job workers for voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`). These workers consume job messages from AWS SQS queues and interact with MongoDB models (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`).
|
||||
|
||||
A recent security audit revealed a critical multi-tenant isolation vulnerability: job handlers retrieve and mutate database records using only record identifiers (`_id` or job IDs) supplied in queue payloads, without scoping queries and updates to the authenticated user/tenant context.
|
||||
|
||||
## Task Requirements
|
||||
|
||||
1. **Audit & Scope Database Operations**:
|
||||
- Refactor all database reads and updates across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
|
||||
- Incorporate tenant filtering (using `userId` or profile-derived `userId`) on all queries and updates involving `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`.
|
||||
- Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted to establish tenant context and resolve `userId`.
|
||||
|
||||
2. **Side-Effect Prevention & Error Handling**:
|
||||
- Ensure that job execution-including audio rendering and database mutations-is halted if tenant validation fails or if record ownership cannot be established.
|
||||
- Maintain worker loop stability so queue polling continues smoothly without crashing the worker process.
|
||||
|
||||
3. **Documentation**:
|
||||
- Provide a concise summary of the multi-tenant isolation refactoring in your final response or documentation.
|
||||
' 2>&1 </dev/null | tee /logs/agent/codex.txt
|
||||
Command outputs captured
|
||||
Running command: if [ -s ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh; fi; codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --model gpt-5.6-sol --json --enable unified_exec -c model_reasoning_effort=max -c agents.enabled=false -c features.external_agent_memory_import=false -c features.goals=false -c features.memories=false -c features.multi_agent=false -c features.multi_agent_v2=false -c tools.experimental_request_user_input.enabled=false -c tools.update_plan.enabled=false -c web_search=disabled -c model_provider=llm-proxy -c 'model_providers.llm-proxy.name="LLM proxy"' -c 'model_providers.llm-proxy.base_url="https://app-llmproxy.dataannotation.tech/api/llm_proxy/openai/v1"' -c 'model_providers.llm-proxy.env_key="OPENAI_API_KEY"' -c 'model_providers.llm-proxy.wire_api="responses"' -c 'model_providers.llm-proxy.http_headers.X-Surge-Client-Metadata='"'"'{"origin":"harbor-trial"}'"'"'' -- '# Background Worker Multi-Tenant Isolation Audit & Refactor
|
||||
|
||||
Our backend background processing services run asynchronous job workers for voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`). These workers consume job messages from AWS SQS queues and interact with MongoDB models (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`).
|
||||
|
||||
A recent security audit revealed a critical multi-tenant isolation vulnerability: job handlers retrieve and mutate database records using only record identifiers (`_id` or job IDs) supplied in queue payloads, without scoping queries and updates to the authenticated user/tenant context.
|
||||
|
||||
## Task Requirements
|
||||
|
||||
1. **Audit & Scope Database Operations**:
|
||||
- Refactor all database reads and updates across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
|
||||
- Incorporate tenant filtering (using `userId` or profile-derived `userId`) on all queries and updates involving `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`.
|
||||
- Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted to establish tenant context and resolve `userId`.
|
||||
|
||||
2. **Side-Effect Prevention & Error Handling**:
|
||||
- Ensure that job execution-including audio rendering and database mutations-is halted if tenant validation fails or if record ownership cannot be established.
|
||||
- Maintain worker loop stability so queue polling continues smoothly without crashing the worker process.
|
||||
|
||||
3. **Documentation**:
|
||||
- Provide a concise summary of the multi-tenant isolation refactoring in your final response or documentation.
|
||||
' 2>&1 </dev/null | tee /logs/agent/codex.txt
|
||||
Command outputs captured
|
||||
Running command: if [ -s ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh; fi; codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --model gpt-5.6-sol --json --enable unified_exec -c model_reasoning_effort=max -c agents.enabled=false -c features.external_agent_memory_import=false -c features.goals=false -c features.memories=false -c features.multi_agent=false -c features.multi_agent_v2=false -c tools.experimental_request_user_input.enabled=false -c tools.update_plan.enabled=false -c web_search=disabled -c model_provider=llm-proxy -c 'model_providers.llm-proxy.name="LLM proxy"' -c 'model_providers.llm-proxy.base_url="https://app-llmproxy.dataannotation.tech/api/llm_proxy/openai/v1"' -c 'model_providers.llm-proxy.env_key="OPENAI_API_KEY"' -c 'model_providers.llm-proxy.wire_api="responses"' -c 'model_providers.llm-proxy.http_headers.X-Surge-Client-Metadata='"'"'{"origin":"harbor-trial"}'"'"'' -- '# Background Worker Multi-Tenant Isolation Audit & Refactor
|
||||
|
||||
Our backend background processing services run asynchronous job workers for voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`). These workers consume job messages from AWS SQS queues and interact with MongoDB models (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`).
|
||||
|
||||
A recent security audit revealed a critical multi-tenant isolation vulnerability: job handlers retrieve and mutate database records using only record identifiers (`_id` or job IDs) supplied in queue payloads, without scoping queries and updates to the authenticated user/tenant context.
|
||||
|
||||
## Task Requirements
|
||||
|
||||
1. **Audit & Scope Database Operations**:
|
||||
- Refactor all database reads and updates across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
|
||||
- Incorporate tenant filtering (using `userId` or profile-derived `userId`) on all queries and updates involving `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`.
|
||||
- Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted to establish tenant context and resolve `userId`.
|
||||
|
||||
2. **Side-Effect Prevention & Error Handling**:
|
||||
- Ensure that job execution-including audio rendering and database mutations-is halted if tenant validation fails or if record ownership cannot be established.
|
||||
- Maintain worker loop stability so queue polling continues smoothly without crashing the worker process.
|
||||
|
||||
3. **Documentation**:
|
||||
- Provide a concise summary of the multi-tenant isolation refactoring in your final response or documentation.
|
||||
' 2>&1 </dev/null | tee /logs/agent/codex.txt
|
||||
Command outputs captured
|
||||
Running command: if [ -s ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh; fi; codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --model gpt-5.6-sol --json --enable unified_exec -c model_reasoning_effort=max -c agents.enabled=false -c features.external_agent_memory_import=false -c features.goals=false -c features.memories=false -c features.multi_agent=false -c features.multi_agent_v2=false -c tools.experimental_request_user_input.enabled=false -c tools.update_plan.enabled=false -c web_search=disabled -c model_provider=llm-proxy -c 'model_providers.llm-proxy.name="LLM proxy"' -c 'model_providers.llm-proxy.base_url="https://app-llmproxy.dataannotation.tech/api/llm_proxy/openai/v1"' -c 'model_providers.llm-proxy.env_key="OPENAI_API_KEY"' -c 'model_providers.llm-proxy.wire_api="responses"' -c 'model_providers.llm-proxy.http_headers.X-Surge-Client-Metadata='"'"'{"origin":"harbor-trial"}'"'"'' -- '# Background Worker Multi-Tenant Isolation Audit & Refactor
|
||||
|
||||
Our backend background processing services run asynchronous job workers for voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`). These workers consume job messages from AWS SQS queues and interact with MongoDB models (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`).
|
||||
|
||||
A recent security audit revealed a critical multi-tenant isolation vulnerability: job handlers retrieve and mutate database records using only record identifiers (`_id` or job IDs) supplied in queue payloads, without scoping queries and updates to the authenticated user/tenant context.
|
||||
|
||||
## Task Requirements
|
||||
|
||||
1. **Audit & Scope Database Operations**:
|
||||
- Refactor all database reads and updates across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
|
||||
- Incorporate tenant filtering (using `userId` or profile-derived `userId`) on all queries and updates involving `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`.
|
||||
- Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted to establish tenant context and resolve `userId`.
|
||||
|
||||
2. **Side-Effect Prevention & Error Handling**:
|
||||
- Ensure that job execution-including audio rendering and database mutations-is halted if tenant validation fails or if record ownership cannot be established.
|
||||
- Maintain worker loop stability so queue polling continues smoothly without crashing the worker process.
|
||||
|
||||
3. **Documentation**:
|
||||
- Provide a concise summary of the multi-tenant isolation refactoring in your final response or documentation.
|
||||
' 2>&1 </dev/null | tee /logs/agent/codex.txt
|
||||
Command outputs captured
|
||||
Running command: mkdir -p /logs/agent
|
||||
if [ -d "$CODEX_HOME/sessions" ]; then
|
||||
rm -rf /logs/agent/sessions
|
||||
cp -R "$CODEX_HOME/sessions" /logs/agent/sessions
|
||||
fi
|
||||
Command outputs captured
|
||||
Running command: rm -rf /tmp/codex-secrets "$CODEX_HOME"
|
||||
Command outputs captured
|
||||
Wrote Codex trajectory to harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__W5t25ZE/agent/trajectory.json
|
||||
Collecting main service artifacts
|
||||
The verifier.env contains an API key (often the case for LLM-based verifiers). You will incur costs associated with the API calls.
|
||||
Command outputs captured
|
||||
Running command: mkdir -p /logs/agent
|
||||
if [ -d "$CODEX_HOME/sessions" ]; then
|
||||
rm -rf /logs/agent/sessions
|
||||
cp -R "$CODEX_HOME/sessions" /logs/agent/sessions
|
||||
fi
|
||||
Command outputs captured
|
||||
Running command: rm -rf /tmp/codex-secrets "$CODEX_HOME"
|
||||
Command outputs captured
|
||||
Wrote Codex trajectory to harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__bqMyPUM/agent/trajectory.json
|
||||
Collecting main service artifacts
|
||||
The verifier.env contains an API key (often the case for LLM-based verifiers). You will incur costs associated with the API calls.
|
||||
Command outputs captured
|
||||
Running command: mkdir -p /logs/agent
|
||||
if [ -d "$CODEX_HOME/sessions" ]; then
|
||||
rm -rf /logs/agent/sessions
|
||||
cp -R "$CODEX_HOME/sessions" /logs/agent/sessions
|
||||
fi
|
||||
Command outputs captured
|
||||
Running command: rm -rf /tmp/codex-secrets "$CODEX_HOME"
|
||||
Command outputs captured
|
||||
Wrote Codex trajectory to harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__pdFfcXv/agent/trajectory.json
|
||||
Collecting main service artifacts
|
||||
The verifier.env contains an API key (often the case for LLM-based verifiers). You will incur costs associated with the API calls.
|
||||
Command outputs captured
|
||||
Running command: mkdir -p /logs/agent
|
||||
if [ -d "$CODEX_HOME/sessions" ]; then
|
||||
rm -rf /logs/agent/sessions
|
||||
cp -R "$CODEX_HOME/sessions" /logs/agent/sessions
|
||||
fi
|
||||
Command outputs captured
|
||||
Running command: rm -rf /tmp/codex-secrets "$CODEX_HOME"
|
||||
Command outputs captured
|
||||
Wrote Codex trajectory to harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__auZATkH/agent/trajectory.json
|
||||
Collecting main service artifacts
|
||||
The verifier.env contains an API key (often the case for LLM-based verifiers). You will incur costs associated with the API calls.
|
||||
@@ -0,0 +1,188 @@
|
||||
{
|
||||
"schema_version": 2,
|
||||
"created_at": "2026-10-22T17:47:19.357165Z",
|
||||
"harbor": {
|
||||
"version": "0.20.0",
|
||||
"is_editable": false
|
||||
},
|
||||
"n_concurrent_trials": 4,
|
||||
"retry": {
|
||||
"max_retries": 0,
|
||||
"exclude_exceptions": [
|
||||
"ModelNotFoundError",
|
||||
"VerifierTimeoutError",
|
||||
"RewardFileNotFoundError",
|
||||
"RewardFileEmptyError",
|
||||
"VerifierOutputParseError",
|
||||
"AgentTimeoutError",
|
||||
"AgentSafetyRefusalError",
|
||||
"AgentAuthenticationError",
|
||||
"ApiUsageLimitError"
|
||||
],
|
||||
"wait_multiplier": 1.0,
|
||||
"min_wait_sec": 1.0,
|
||||
"max_wait_sec": 60.0
|
||||
},
|
||||
"trials": [
|
||||
{
|
||||
"schema_version": 1,
|
||||
"task": {
|
||||
"name": "potion-voice-user-ownership",
|
||||
"type": "local",
|
||||
"digest": "sha256:62f127e2d7acca7be9d2dc877aacfadc21a899b67287c828ba333fed7d7460bd",
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"skills": [],
|
||||
"resume_trajectory": false,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"skills": [],
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"schema_version": 1,
|
||||
"task": {
|
||||
"name": "potion-voice-user-ownership",
|
||||
"type": "local",
|
||||
"digest": "sha256:62f127e2d7acca7be9d2dc877aacfadc21a899b67287c828ba333fed7d7460bd",
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"skills": [],
|
||||
"resume_trajectory": false,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"skills": [],
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"schema_version": 1,
|
||||
"task": {
|
||||
"name": "potion-voice-user-ownership",
|
||||
"type": "local",
|
||||
"digest": "sha256:62f127e2d7acca7be9d2dc877aacfadc21a899b67287c828ba333fed7d7460bd",
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"skills": [],
|
||||
"resume_trajectory": false,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"skills": [],
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"schema_version": 1,
|
||||
"task": {
|
||||
"name": "potion-voice-user-ownership",
|
||||
"type": "local",
|
||||
"digest": "sha256:62f127e2d7acca7be9d2dc877aacfadc21a899b67287c828ba333fed7d7460bd",
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"skills": [],
|
||||
"resume_trajectory": false,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"skills": [],
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"source": "/logs/artifacts",
|
||||
"destination": "artifacts/logs/artifacts",
|
||||
"type": "directory",
|
||||
"status": "empty",
|
||||
"service": null
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"task": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"trial_name": "potion-voice-user-ownership__W5t25ZE",
|
||||
"trials_dir": "harbor-jobs/2026-10-22__17-47-18",
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
}
|
||||
},
|
||||
"job_id": "077fe5d4-d5a1-442d-804c-c94800ff0497"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": 1,
|
||||
"capturedAt": "2026-10-22T17:47:17.912Z",
|
||||
"capturedBy": "run",
|
||||
"inputs": {
|
||||
"prompt": "91f826800550a53b772b747a2f32398bf2f1db26f07ef081155cd7c3fde25177",
|
||||
"graderGuidance": null,
|
||||
"sessionJsonl": null,
|
||||
"workspacePatch": null,
|
||||
"gitref": "fcd8a9d0",
|
||||
"graderGuidanceConsolidated": null,
|
||||
"holisticRubric": "bbc1ff49aa34476a395047dffcb7d151bcba108bd884aba558c4cd1a5b17063d",
|
||||
"atomicRubric": "989f0c7c3631c2e04e0e3917344dc54c4fe74a6784d0f762aa95c899f517a942",
|
||||
"rubricsYaml": null,
|
||||
"graderContext": "810a0a72f38506723f42535677c470d075ed09e326c8ebbbc95d6c7040c35906"
|
||||
},
|
||||
"taskSlug": "potion-voice-user-ownership"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"task": {
|
||||
"name": "potion-voice-user-ownership",
|
||||
"type": "local",
|
||||
"digest": "sha256:62f127e2d7acca7be9d2dc877aacfadc21a899b67287c828ba333fed7d7460bd",
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"skills": [],
|
||||
"resume_trajectory": false,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"skills": [],
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"id": "4b127441-e2eb-403c-bf95-99da95aa8ca3",
|
||||
"task_name": "potion-voice-user-ownership",
|
||||
"trial_name": "potion-voice-user-ownership__W5t25ZE",
|
||||
"trial_uri": "file:///home/eric/workspaces/dataannotation/project-2/worker-toolkit-potion-polyglot-v1.0.1/harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__W5t25ZE",
|
||||
"task_id": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"source": null,
|
||||
"task_checksum": "11e2332f85266e62f1fd9d74fe3e984121399bfd64ff08ee102d72bc55852cf3",
|
||||
"config": {
|
||||
"task": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership",
|
||||
"git_url": null,
|
||||
"git_commit_id": null,
|
||||
"name": null,
|
||||
"ref": null,
|
||||
"overwrite": false,
|
||||
"download_dir": null,
|
||||
"source": null
|
||||
},
|
||||
"trial_name": "potion-voice-user-ownership__W5t25ZE",
|
||||
"trials_dir": "harbor-jobs/2026-10-22__17-47-18",
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent_timeout_multiplier": null,
|
||||
"verifier_timeout_multiplier": null,
|
||||
"agent_setup_timeout_multiplier": null,
|
||||
"environment_build_timeout_multiplier": null,
|
||||
"agent": {
|
||||
"name": null,
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"n_concurrent": null,
|
||||
"concurrency_group": null,
|
||||
"skills": [],
|
||||
"override_timeout_sec": null,
|
||||
"override_setup_timeout_sec": null,
|
||||
"max_timeout_sec": null,
|
||||
"resume_trajectory": false,
|
||||
"load_trajectory": null,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"import_path": null,
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"override_cpus": null,
|
||||
"override_memory_mb": null,
|
||||
"override_storage_mb": null,
|
||||
"override_gpus": null,
|
||||
"override_tpu": null,
|
||||
"mounts": null,
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"override_timeout_sec": null,
|
||||
"max_timeout_sec": null,
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
},
|
||||
"artifacts": [],
|
||||
"extra_instruction_paths": [],
|
||||
"job_id": "077fe5d4-d5a1-442d-804c-c94800ff0497"
|
||||
},
|
||||
"agent_info": {
|
||||
"name": "codex",
|
||||
"version": "0.162.1",
|
||||
"model_info": {
|
||||
"name": "gpt-5.6-sol",
|
||||
"provider": null
|
||||
}
|
||||
},
|
||||
"agent_result": {
|
||||
"n_input_tokens": 930702,
|
||||
"n_cache_tokens": 853826,
|
||||
"n_output_tokens": 24691,
|
||||
"cost_usd": 1.1428544,
|
||||
"rollout_details": null,
|
||||
"metadata": null
|
||||
},
|
||||
"verifier_result": {
|
||||
"rewards": {
|
||||
"reward": 0.8
|
||||
}
|
||||
},
|
||||
"exception_info": null,
|
||||
"started_at": "2026-10-22T17:47:20.552558Z",
|
||||
"finished_at": "2026-10-22T17:55:08.778179Z",
|
||||
"environment_setup": {
|
||||
"started_at": "2026-10-22T17:47:20.842252Z",
|
||||
"finished_at": "2026-10-22T17:47:39.232534Z"
|
||||
},
|
||||
"agent_setup": {
|
||||
"started_at": "2026-10-22T17:47:39.232583Z",
|
||||
"finished_at": "2026-10-22T17:47:44.334797Z"
|
||||
},
|
||||
"agent_execution": {
|
||||
"started_at": "2026-10-22T17:47:44.334890Z",
|
||||
"finished_at": "2026-10-22T17:52:52.321479Z"
|
||||
},
|
||||
"verifier": {
|
||||
"started_at": "2026-10-22T17:52:58.358505Z",
|
||||
"finished_at": "2026-10-22T17:55:04.584150Z"
|
||||
},
|
||||
"step_results": null
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
Skipping image OS validation for hb__1489968d76cf84d223a8d0bfc3d16e72: docker inspect returned 1
|
||||
Running command: set -x; if command -v apt-get >/dev/null 2>&1; then apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq curl ripgrep >/dev/null 2>&1 || true; fi; if ! command -v codex >/dev/null 2>&1; then CODEX_INSTALL_DIR=/usr/local/bin CODEX_NON_INTERACTIVE=true sh -c "curl -fsSL https://chatgpt.com/codex/install.sh | sh" >&2 || true; fi; if ! command -v codex >/dev/null 2>&1 && [ -x "$HOME/.local/bin/codex" ]; then ln -sf "$HOME/.local/bin/codex" /usr/local/bin/codex; fi; if ! command -v codex >/dev/null 2>&1; then export NVM_DIR="${NVM_DIR:-/usr/local/share/nvm}"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true; if ! command -v npm >/dev/null 2>&1; then npm_path="$(find /usr/local/share/nvm /usr/local /usr/lib /opt -name npm -type f 2>/dev/null | head -1)"; [ -n "$npm_path" ] && export PATH="$PATH:$(dirname "$npm_path")"; fi; command -v npm >/dev/null 2>&1 && npm install -g @openai/codex@latest; fi; for bin in node codex; do p="$(command -v "$bin" 2>/dev/null || true)"; [ -n "$p" ] && [ "$p" != "/usr/local/bin/$bin" ] && ln -sf "$p" "/usr/local/bin/$bin" || true; done; command -v codex >/dev/null 2>&1 || { echo "FATAL: codex CLI unavailable (standalone installer and npm both failed)" >&2; exit 1; }; codex --version
|
||||
Command outputs captured
|
||||
Running command: mkdir -p "$CODEX_HOME" /tmp/codex-secrets /logs/agent
|
||||
Command outputs captured
|
||||
Codex auth: using OPENAI_API_KEY
|
||||
Running command: cat >/tmp/codex-secrets/auth.json <<EOF
|
||||
{
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
||||
}
|
||||
EOF
|
||||
ln -sf /tmp/codex-secrets/auth.json "$CODEX_HOME/auth.json"
|
||||
|
||||
cat >>"$CODEX_HOME/config.toml" <<TOML
|
||||
openai_base_url = "${OPENAI_BASE_URL}"
|
||||
TOML
|
||||
Command outputs captured
|
||||
Running command: if [ -s ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh; fi; codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --model gpt-5.6-sol --json --enable unified_exec -c model_reasoning_effort=max -c agents.enabled=false -c features.external_agent_memory_import=false -c features.goals=false -c features.memories=false -c features.multi_agent=false -c features.multi_agent_v2=false -c tools.experimental_request_user_input.enabled=false -c tools.update_plan.enabled=false -c web_search=disabled -c model_provider=llm-proxy -c 'model_providers.llm-proxy.name="LLM proxy"' -c 'model_providers.llm-proxy.base_url="https://app-llmproxy.dataannotation.tech/api/llm_proxy/openai/v1"' -c 'model_providers.llm-proxy.env_key="OPENAI_API_KEY"' -c 'model_providers.llm-proxy.wire_api="responses"' -c 'model_providers.llm-proxy.http_headers.X-Surge-Client-Metadata='"'"'{"origin":"harbor-trial"}'"'"'' -- '# Background Worker Multi-Tenant Isolation Audit & Refactor
|
||||
|
||||
Our backend background processing services run asynchronous job workers for voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`). These workers consume job messages from AWS SQS queues and interact with MongoDB models (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`).
|
||||
|
||||
A recent security audit revealed a critical multi-tenant isolation vulnerability: job handlers retrieve and mutate database records using only record identifiers (`_id` or job IDs) supplied in queue payloads, without scoping queries and updates to the authenticated user/tenant context.
|
||||
|
||||
## Task Requirements
|
||||
|
||||
1. **Audit & Scope Database Operations**:
|
||||
- Refactor all database reads and updates across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
|
||||
- Incorporate tenant filtering (using `userId` or profile-derived `userId`) on all queries and updates involving `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`.
|
||||
- Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted to establish tenant context and resolve `userId`.
|
||||
|
||||
2. **Side-Effect Prevention & Error Handling**:
|
||||
- Ensure that job execution-including audio rendering and database mutations-is halted if tenant validation fails or if record ownership cannot be established.
|
||||
- Maintain worker loop stability so queue polling continues smoothly without crashing the worker process.
|
||||
|
||||
3. **Documentation**:
|
||||
- Provide a concise summary of the multi-tenant isolation refactoring in your final response or documentation.
|
||||
' 2>&1 </dev/null | tee /logs/agent/codex.txt
|
||||
Command outputs captured
|
||||
Running command: mkdir -p /logs/agent
|
||||
if [ -d "$CODEX_HOME/sessions" ]; then
|
||||
rm -rf /logs/agent/sessions
|
||||
cp -R "$CODEX_HOME/sessions" /logs/agent/sessions
|
||||
fi
|
||||
Command outputs captured
|
||||
Running command: rm -rf /tmp/codex-secrets "$CODEX_HOME"
|
||||
Command outputs captured
|
||||
Wrote Codex trajectory to harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__W5t25ZE/agent/trajectory.json
|
||||
Collecting main service artifacts
|
||||
The verifier.env contains an API key (often the case for LLM-based verifiers). You will incur costs associated with the API calls.
|
||||
@@ -0,0 +1,19 @@
|
||||
class TenantValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message)
|
||||
this.name = 'TenantValidationError'
|
||||
}
|
||||
}
|
||||
|
||||
const requireUserId = (userId) => {
|
||||
if (!userId) {
|
||||
throw new TenantValidationError('Unable to establish record ownership')
|
||||
}
|
||||
|
||||
return userId
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
TenantValidationError,
|
||||
requireUserId,
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
const fs = require('fs')
|
||||
const https = require('https')
|
||||
const exec = require('child_process').exec
|
||||
const AWS = require('aws-sdk')
|
||||
|
||||
const Bugsnag = require('@bugsnag/js')
|
||||
const mongoose = require('mongoose')
|
||||
const version = require('./package.json').version
|
||||
const sqs = require('../app/services/sqs')
|
||||
const s3 = require('../app/services/s3')
|
||||
const voiceCloningService = require('./voice_cloning')
|
||||
const userAudioProfileService = require('./user_audio_profile')
|
||||
const {
|
||||
TenantValidationError,
|
||||
} = require('../app/services/utils/tenantValidation')
|
||||
|
||||
AWS.config.update({ region: 'us-west-2' })
|
||||
const sqsQueueUrl = process.env.SQS_URL
|
||||
const mongoUriDev = process.env.MONGODB_URI_DEV
|
||||
const mongoUriStaging = process.env.MONGODB_URI_STAGING
|
||||
const mongoUriProd = process.env.MONGODB_URI_PROD
|
||||
let throttleMessageFetching = true
|
||||
const APP_ENV = process.env.POTION_APP_ENV
|
||||
|
||||
const cloudFrontUrlProd = process.env.CLOUDFRONT_URL_PROD
|
||||
const cloudFrontUrlDev = process.env.CLOUDFRONT_URL_DEV
|
||||
const cloudFrontUrlStaging = process.env.CLOUDFRONT_URL_STAGING
|
||||
|
||||
const updateUrl = (str, cloudFrontUrl) => {
|
||||
const host = new URL(str).host
|
||||
return str.replace(`https://${host}`, cloudFrontUrl)
|
||||
}
|
||||
|
||||
function connectDB(dbUri, retryCount = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log('Connection Attempt : ', retryCount)
|
||||
mongoose.set('strictQuery', true)
|
||||
mongoose
|
||||
.connect(dbUri)
|
||||
.then((msg) => {
|
||||
console.log('Connected to Mongo DB !')
|
||||
resolve()
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Failed to connect dns mongo: ', err)
|
||||
if (retryCount < 6) {
|
||||
retryCount++
|
||||
connectDB(dbUri, retryCount)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function execShellCommand(cmd, logPath) {
|
||||
// const exec = require("child_process").exec;
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, { maxBuffer: 1024 * 1000000 }, async (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log('Error while proccessing python command', error)
|
||||
reject(error)
|
||||
}
|
||||
// console.log('Stdout --- ', stdout)
|
||||
// console.log('Stderror --- ', stderr)
|
||||
await fs.promises.writeFile(`${logPath}/error.log`, stderr)
|
||||
await fs.promises.writeFile(`${logPath}/info.log`, stdout)
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function getFile(waveUrl, path) {
|
||||
return new Promise((resolve) => {
|
||||
https.get(waveUrl, (res) => {
|
||||
const writeStream = fs.createWriteStream(path)
|
||||
|
||||
res.pipe(writeStream)
|
||||
|
||||
writeStream.on('finish', () => {
|
||||
writeStream.close()
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function pad(s) {
|
||||
while (s.length < 3) s = '0' + s // IN future we will need padding to 4
|
||||
return s
|
||||
}
|
||||
|
||||
const requireOwnedRecord = (record, recordName) => {
|
||||
if (!record) {
|
||||
throw new TenantValidationError(
|
||||
`${recordName} was not found for the resolved tenant`
|
||||
)
|
||||
}
|
||||
|
||||
return record
|
||||
}
|
||||
|
||||
const processQueue = () => {
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const response = await sqs.fetchMessageFromSQS(sqsQueueUrl)
|
||||
|
||||
if (
|
||||
typeof response.Messages !== 'undefined' &&
|
||||
response.Messages.length > 0
|
||||
) {
|
||||
throttleMessageFetching = false
|
||||
const job = JSON.parse(response.Messages[0].Body)
|
||||
const receiptHandle = response.Messages[0].ReceiptHandle
|
||||
console.log('job===', job)
|
||||
|
||||
const { metadata, input, _id, userAudioProfileId } = job._doc
|
||||
console.log('userAudioProfileId', userAudioProfileId)
|
||||
console.log('_id', _id)
|
||||
const { env } = job
|
||||
console.log('env', env)
|
||||
|
||||
console.log('metadata------', metadata)
|
||||
console.log('input', input)
|
||||
const DB_URI =
|
||||
env === 'production'
|
||||
? mongoUriProd
|
||||
: env === 'staging'
|
||||
? mongoUriStaging
|
||||
: mongoUriDev
|
||||
|
||||
console.log('DB_URI ', DB_URI)
|
||||
await connectDB(DB_URI)
|
||||
|
||||
const cloudFrontUrl =
|
||||
env === 'production'
|
||||
? cloudFrontUrlProd
|
||||
: env === 'staging'
|
||||
? cloudFrontUrlStaging
|
||||
: cloudFrontUrlDev
|
||||
|
||||
let tenantContext
|
||||
try {
|
||||
await sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)
|
||||
|
||||
// The profile lookup is the one unscoped lookup used to establish the
|
||||
// tenant. Every subsequent read and write uses its persisted userId.
|
||||
const userAudioProfile = requireOwnedRecord(
|
||||
await userAudioProfileService.readById(userAudioProfileId),
|
||||
'UserAudioProfile'
|
||||
)
|
||||
if (!userAudioProfile.userId) {
|
||||
throw new TenantValidationError(
|
||||
'UserAudioProfile does not have an owner'
|
||||
)
|
||||
}
|
||||
|
||||
const userId = userAudioProfile.userId
|
||||
requireOwnedRecord(
|
||||
await voiceCloningService.read(
|
||||
{ _id, userAudioProfileId },
|
||||
userId
|
||||
),
|
||||
'VoiceCloning'
|
||||
)
|
||||
tenantContext = { userId }
|
||||
|
||||
const { directoryName } = metadata
|
||||
console.log('directoryName', directoryName)
|
||||
const logPath = `/mnt/efs/potion-voice/${env}/${directoryName}`
|
||||
if (!fs.existsSync(logPath)) {
|
||||
fs.mkdirSync(logPath, { recursive: true })
|
||||
}
|
||||
// update the db model to processing
|
||||
requireOwnedRecord(
|
||||
await voiceCloningService.update(
|
||||
{ _id, status: 'processing' },
|
||||
userId
|
||||
),
|
||||
'VoiceCloning'
|
||||
)
|
||||
requireOwnedRecord(
|
||||
await userAudioProfileService.update(
|
||||
{
|
||||
_id: userAudioProfileId,
|
||||
status: 'processing',
|
||||
},
|
||||
userId
|
||||
),
|
||||
'UserAudioProfile'
|
||||
)
|
||||
|
||||
// create directory for userid-useraudioprofileid if not exist
|
||||
const rootPath = `/tmp/${directoryName}`
|
||||
const wavePath = `${rootPath}/wav48/1`
|
||||
if (!fs.existsSync(wavePath)) {
|
||||
fs.mkdirSync(wavePath, { recursive: true })
|
||||
}
|
||||
|
||||
const txtPath = `${rootPath}/txt/1`
|
||||
if (!fs.existsSync(txtPath)) {
|
||||
fs.mkdirSync(txtPath, { recursive: true })
|
||||
}
|
||||
// download the training data files and put it in respective directories
|
||||
for (let index = 0; index < input.length; index++) {
|
||||
const item = input[index]
|
||||
|
||||
const { waveUrl, originalText } = item
|
||||
// download wave file
|
||||
const waveFilePath = `${wavePath}/1_${pad('' + (index + 1))}.wav`
|
||||
|
||||
await getFile(updateUrl(waveUrl, cloudFrontUrl), waveFilePath)
|
||||
|
||||
const txtFilePath = `${txtPath}/1_${pad('' + (index + 1))}.txt`
|
||||
await fs.promises.writeFile(txtFilePath, originalText)
|
||||
}
|
||||
|
||||
const zipFileName = directoryName + '.tgz'
|
||||
|
||||
// /tmp/directoryName.tgz
|
||||
|
||||
await execShellCommand(
|
||||
`cd /tmp && tar czvf ${zipFileName} ${directoryName}`,
|
||||
logPath
|
||||
)
|
||||
console.log('ZIP created ', zipFileName)
|
||||
|
||||
// re-sample audio
|
||||
const SAMPLING_LABEL = `Time Taken for re-sampling ${directoryName}`
|
||||
console.time(SAMPLING_LABEL)
|
||||
|
||||
const outputPath = `/mnt/efs/potion-voice/${env}/${directoryName}`
|
||||
|
||||
const samplingCommand = `python3 ../voice-cloning/prepare_datasets.py --dataset_preset potion_voice_cloning --dataset_archive_path /tmp/${zipFileName} --output_path ${outputPath}`
|
||||
console.log('samplingCommand ', samplingCommand)
|
||||
const samplingResponse = await execShellCommand(
|
||||
samplingCommand,
|
||||
logPath
|
||||
)
|
||||
console.timeEnd(SAMPLING_LABEL)
|
||||
|
||||
// /mnt/efs/potion-voice/${env}/speakrs.pth
|
||||
// /mnt/efs/potion-voice/${env}/txt
|
||||
// /mnt/efs/potion-voice/${env}/${directoryName}/wav
|
||||
|
||||
const outPath = `/mnt/efs/potion-voice/${env}/${directoryName}/sr22050/${directoryName}`
|
||||
|
||||
const resultsPath = outPath + '/results'
|
||||
|
||||
//update pth file for cloning
|
||||
// clone the voice
|
||||
const VOICE_CLONING_LABEL = `Time Taken for voice cloning ${directoryName}`
|
||||
console.time(VOICE_CLONING_LABEL)
|
||||
const trainingModelCommand = `python3 ../voice-cloning/clone_voice.py --baseline_model_path ../voice-cloning/pretrained-models/checkpoint_365000.pth --speaker_dataset_path ${outPath} --speaker_embeddings_path ${
|
||||
outPath + '/speakers.pth'
|
||||
} --output_path ${resultsPath}`
|
||||
|
||||
console.log('Training Model Command', trainingModelCommand)
|
||||
const trainingResponse = await execShellCommand(
|
||||
trainingModelCommand,
|
||||
logPath
|
||||
)
|
||||
|
||||
console.timeEnd(VOICE_CLONING_LABEL)
|
||||
|
||||
let generatedDirectoryName = ''
|
||||
fs.readdirSync(`${resultsPath}/`).forEach((file) => {
|
||||
if (file.includes('vits_potion_clone'))
|
||||
// use output from above to get right path and directory name
|
||||
generatedDirectoryName = file
|
||||
})
|
||||
|
||||
// minimize cloning model
|
||||
const VOICE_MINIMIZE_LABEL = `Time Taken for voice minimizing cloning ${directoryName}`
|
||||
console.time(VOICE_MINIMIZE_LABEL)
|
||||
const minimizeCloningModelCommand = `python3 ../voice-cloning/minimize_cloned_voice_model.py --voice_model_asset_path ${
|
||||
resultsPath + '/' + generatedDirectoryName + '/'
|
||||
} --voice_model_name checkpoint_365200.pth`
|
||||
|
||||
console.log(
|
||||
'Minimize Cloning Model Command',
|
||||
minimizeCloningModelCommand
|
||||
)
|
||||
const minimizeCloning = await execShellCommand(
|
||||
minimizeCloningModelCommand,
|
||||
logPath
|
||||
)
|
||||
console.timeEnd(VOICE_MINIMIZE_LABEL)
|
||||
|
||||
// Add the code to update location of generated model and status into DB
|
||||
requireOwnedRecord(
|
||||
await voiceCloningService.update(
|
||||
{ _id, status: 'completed' },
|
||||
userId
|
||||
),
|
||||
'VoiceCloning'
|
||||
)
|
||||
|
||||
const training_model_path = {
|
||||
voice_model_path: `${resultsPath}/${generatedDirectoryName}/checkpoint_365200.pth`,
|
||||
voice_model_config_path: `${resultsPath}/${generatedDirectoryName}/config.json`,
|
||||
voice_model_speakers_file_path: `${outPath}/speakers.pth`, // TODO update the name to voice model speakers embeddings
|
||||
voice_model_light_path: `${resultsPath}/${generatedDirectoryName}/checkpoint_365200_light.pth`,
|
||||
voice_model_config_light_path: `${resultsPath}/${generatedDirectoryName}/config_light.json`,
|
||||
}
|
||||
|
||||
requireOwnedRecord(
|
||||
await userAudioProfileService.update(
|
||||
{
|
||||
_id: userAudioProfileId,
|
||||
status: 'completed',
|
||||
training_model_path,
|
||||
},
|
||||
userId
|
||||
),
|
||||
'UserAudioProfile'
|
||||
)
|
||||
|
||||
// add code to put that model into S3
|
||||
let keys = Object.keys(training_model_path)
|
||||
|
||||
const training_model_s3_path = {}
|
||||
|
||||
for (let index = 0; index < keys.length; index++) {
|
||||
const path = training_model_path[keys[index]]
|
||||
const s3Path = await s3.upload({
|
||||
filePath: path,
|
||||
fileName: `${directoryName}/${path.split('/').pop()}`,
|
||||
bucket: `potion-voice-users-training-model/${env}`,
|
||||
})
|
||||
training_model_s3_path[keys[index]] = s3Path
|
||||
}
|
||||
// add S3 path to user audio profile model
|
||||
requireOwnedRecord(
|
||||
await userAudioProfileService.update(
|
||||
{
|
||||
_id: userAudioProfileId,
|
||||
training_model_s3_path,
|
||||
},
|
||||
userId
|
||||
),
|
||||
'UserAudioProfile'
|
||||
)
|
||||
} catch (error) {
|
||||
console.log('error********************', error)
|
||||
Bugsnag.notify(
|
||||
new Error(
|
||||
`Unable to train for voice cloning videos ` + JSON.stringify(job)
|
||||
)
|
||||
)
|
||||
Bugsnag.notify(error)
|
||||
|
||||
// Never perform fallback mutations unless both records were already
|
||||
// validated against the same persisted tenant.
|
||||
if (tenantContext && !(error instanceof TenantValidationError)) {
|
||||
try {
|
||||
await voiceCloningService.update(
|
||||
{ _id, status: 'error' },
|
||||
tenantContext.userId
|
||||
)
|
||||
await userAudioProfileService.update(
|
||||
{
|
||||
_id: userAudioProfileId,
|
||||
status: 'error',
|
||||
},
|
||||
tenantContext.userId
|
||||
)
|
||||
} catch (statusUpdateError) {
|
||||
console.error('Unable to update voice cloning error status', {
|
||||
error: statusUpdateError,
|
||||
})
|
||||
Bugsnag.notify(statusUpdateError)
|
||||
}
|
||||
}
|
||||
|
||||
resolve() // to continue working on new jobs
|
||||
}
|
||||
} else {
|
||||
throttleMessageFetching = true
|
||||
}
|
||||
resolve()
|
||||
} catch (error) {
|
||||
console.error('Error while training voice clone', { error })
|
||||
Bugsnag.notify(error)
|
||||
resolve() // to continue working on new jobs
|
||||
} finally {
|
||||
mongoose.connection.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
const init = async () => {
|
||||
console.log('potion Voice Clone Process Started')
|
||||
Bugsnag.start({
|
||||
appVersion: APP_ENV + version,
|
||||
apiKey: process.env.BUGSNAG_BACKEND_KEY,
|
||||
releaseStage: process.env.NODE_ENV,
|
||||
})
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
await processQueue()
|
||||
if (throttleMessageFetching) await sleep(2000)
|
||||
}
|
||||
} catch (error) {
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
}
|
||||
init()
|
||||
@@ -0,0 +1,170 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const { requireUserId } = require('../../app/services/utils/tenantValidation')
|
||||
|
||||
const create = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new UserAudioProfileModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await UserAudioProfileModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const readById = (UserAudioProfileModel) => async (userAudioProfileId) => {
|
||||
try {
|
||||
return await UserAudioProfileModel.findOne({
|
||||
_id: userAudioProfileId,
|
||||
deleted: false,
|
||||
})
|
||||
} catch (error) {
|
||||
const details = { userAudioProfileId }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > readById',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const foundModel = await UserAudioProfileModel.findOne({
|
||||
...filter,
|
||||
userId,
|
||||
deleted: false,
|
||||
})
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const foundModels = await UserAudioProfileModel.find({
|
||||
...filter,
|
||||
userId,
|
||||
deleted: false,
|
||||
})
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (UserAudioProfileModel) => async (data, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updates = { ...data }
|
||||
delete updates._id
|
||||
delete updates.userId
|
||||
delete updates.deleted
|
||||
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
{ _id: data._id, userId, deleted: false },
|
||||
{ $set: updates },
|
||||
{
|
||||
new: true,
|
||||
}
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
{ ...filter, userId, deleted: false },
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updatedModel = await UserAudioProfileModel.updateMany(
|
||||
{ ...filter, userId, deleted: false },
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (UserAudioProfileModel) => {
|
||||
return {
|
||||
create: create(UserAudioProfileModel),
|
||||
insertMany: insertMany(UserAudioProfileModel),
|
||||
readById: readById(UserAudioProfileModel),
|
||||
read: read(UserAudioProfileModel),
|
||||
remove: remove(UserAudioProfileModel),
|
||||
removeMany: removeMany(UserAudioProfileModel),
|
||||
update: update(UserAudioProfileModel),
|
||||
find: find(UserAudioProfileModel),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const { requireUserId } = require('../../app/services/utils/tenantValidation')
|
||||
|
||||
const create = (VoiceCloningModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new VoiceCloningModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (VoiceCloningModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await VoiceCloningModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (VoiceCloningModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const foundModel = await VoiceCloningModel.findOne({
|
||||
...filter,
|
||||
userId,
|
||||
deleted: false,
|
||||
})
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (VoiceCloningModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const foundModels = await VoiceCloningModel.find({
|
||||
...filter,
|
||||
userId,
|
||||
deleted: false,
|
||||
})
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (VoiceCloningModel) => async (data, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updates = { ...data }
|
||||
delete updates._id
|
||||
delete updates.userId
|
||||
delete updates.deleted
|
||||
|
||||
const updatedModel = await VoiceCloningModel.findOneAndUpdate(
|
||||
{ _id: data._id, userId, deleted: false },
|
||||
{ $set: updates },
|
||||
{
|
||||
new: true,
|
||||
}
|
||||
)
|
||||
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (VoiceCloningModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updatedModel = await VoiceCloningModel.findOneAndUpdate(
|
||||
{ ...filter, userId, deleted: false },
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (VoiceCloningModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updatedModel = await VoiceCloningModel.updateMany(
|
||||
{ ...filter, userId, deleted: false },
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (VoiceCloningModel) => {
|
||||
return {
|
||||
create: create(VoiceCloningModel),
|
||||
insertMany: insertMany(VoiceCloningModel),
|
||||
read: read(VoiceCloningModel),
|
||||
remove: remove(VoiceCloningModel),
|
||||
removeMany: removeMany(VoiceCloningModel),
|
||||
update: update(VoiceCloningModel),
|
||||
find: find(VoiceCloningModel),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
const fs = require('fs')
|
||||
const exec = require('child_process').exec
|
||||
const AWS = require('aws-sdk')
|
||||
const Bugsnag = require('@bugsnag/js')
|
||||
const uuid = require('uuid').v4
|
||||
const version = require('./package.json').version
|
||||
const sqs = require('../app/services/sqs')
|
||||
const s3 = require('../app/services/s3')
|
||||
const userAudioProfileService = require('./user_audio_profile')
|
||||
const recordingModel = require('./recording')
|
||||
const recordingSalutationModel = require('./recording_salutation')
|
||||
const jobService = require('./job')
|
||||
const salutationService = require('./salutation')
|
||||
const {
|
||||
TenantValidationError,
|
||||
} = require('../app/services/utils/tenantValidation')
|
||||
let throttleMessageFetching = true
|
||||
AWS.config.update({ region: 'us-west-2' })
|
||||
const sqsQueueUrl = process.env.SQS_URL
|
||||
const mongoUriDev = process.env.MONGODB_URI_DEV
|
||||
const mongoUriStaging = process.env.MONGODB_URI_STAGING
|
||||
const mongoUriProd = process.env.MONGODB_URI_PROD
|
||||
const APP_ENV = process.env.POTION_APP_ENV
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
function execShellCommand(cmd) {
|
||||
// const exec = require("child_process").exec;
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, { maxBuffer: 1024 * 1000000 }, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log('Error while processing python command', error)
|
||||
reject(error)
|
||||
}
|
||||
console.log('Stdout --- ', stdout)
|
||||
console.log('Std error --- ', stderr)
|
||||
resolve(stdout || stderr)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function connectDB(dbUri, retryCount = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log('Connection Attempt : ', retryCount)
|
||||
mongoose.set('strictQuery', true)
|
||||
mongoose
|
||||
.connect(dbUri)
|
||||
.then((msg) => {
|
||||
console.log('Connected to Mongo DB !')
|
||||
resolve()
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Failed to connect dns mongo: ', err)
|
||||
if (retryCount < 6) {
|
||||
retryCount++
|
||||
connectDB(dbUri, retryCount)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const requireOwnedRecord = (record, recordName) => {
|
||||
if (!record) {
|
||||
throw new TenantValidationError(
|
||||
`${recordName} was not found for the resolved tenant`
|
||||
)
|
||||
}
|
||||
|
||||
return record
|
||||
}
|
||||
|
||||
const processQueue = () => {
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const response = await sqs.fetchMessageFromSQS(sqsQueueUrl)
|
||||
|
||||
if (
|
||||
typeof response.Messages !== 'undefined' &&
|
||||
response.Messages.length > 0
|
||||
) {
|
||||
throttleMessageFetching = false
|
||||
const job = JSON.parse(response.Messages[0].Body)
|
||||
const receiptHandle = response.Messages[0].ReceiptHandle
|
||||
try {
|
||||
await sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)
|
||||
|
||||
const {
|
||||
userAudioProfileId,
|
||||
text,
|
||||
firstName,
|
||||
salutationId,
|
||||
recordingId,
|
||||
baseUrlForPotionAi,
|
||||
env,
|
||||
} = job
|
||||
|
||||
const DB_URI =
|
||||
env === 'production'
|
||||
? mongoUriProd
|
||||
: env === 'staging'
|
||||
? mongoUriStaging
|
||||
: mongoUriDev
|
||||
|
||||
console.log('DB_URI ', DB_URI)
|
||||
await connectDB(DB_URI)
|
||||
|
||||
// This is the one unscoped lookup: the persisted profile establishes
|
||||
// the tenant used by every subsequent database operation.
|
||||
const userAudioProfile = requireOwnedRecord(
|
||||
await userAudioProfileService.readById(userAudioProfileId),
|
||||
'UserAudioProfile'
|
||||
)
|
||||
if (!userAudioProfile.userId) {
|
||||
throw new TenantValidationError(
|
||||
'UserAudioProfile does not have an owner'
|
||||
)
|
||||
}
|
||||
if (userAudioProfile.status !== 'completed') {
|
||||
throw new TenantValidationError(
|
||||
'UserAudioProfile is not ready for synthesis'
|
||||
)
|
||||
}
|
||||
|
||||
const { training_model_path, userId } = userAudioProfile
|
||||
|
||||
// Establish ownership of every queue-supplied record before invoking
|
||||
// the renderer, uploading audio, or mutating the database.
|
||||
const [salutationToUpdate, recordingToUpdate] = await Promise.all([
|
||||
recordingSalutationModel.findOne({
|
||||
_id: salutationId,
|
||||
userId,
|
||||
deleted: false,
|
||||
}),
|
||||
recordingModel.findOne({
|
||||
_id: recordingId,
|
||||
userId,
|
||||
deleted: false,
|
||||
}),
|
||||
])
|
||||
requireOwnedRecord(salutationToUpdate, 'RecordingSalutation')
|
||||
requireOwnedRecord(recordingToUpdate, 'Recording')
|
||||
|
||||
if (!training_model_path) {
|
||||
throw new TenantValidationError(
|
||||
'UserAudioProfile does not have a training model'
|
||||
)
|
||||
}
|
||||
|
||||
const {
|
||||
voice_model_light_path,
|
||||
voice_model_config_light_path,
|
||||
voice_model_speakers_file_path, // name for speakers embeddings file path
|
||||
} = training_model_path
|
||||
|
||||
const outputPath = `/tmp/${uuid()}/`
|
||||
if (!fs.existsSync(outputPath)) {
|
||||
fs.mkdirSync(outputPath, { recursive: true })
|
||||
}
|
||||
|
||||
const AI_COMMAND = `python3 ../voice-cloning/synthesize_speech.py --voice_model_path ${voice_model_light_path} --voice_model_config_path ${voice_model_config_light_path} --speaker_embeddings_path ${voice_model_speakers_file_path} --txt "${text}" --output_path ${outputPath}`
|
||||
console.log('AI_COMMAND ', AI_COMMAND)
|
||||
|
||||
const SYNTHESIZE_AI_LABEL = `Time consumed by AI` + Math.random()
|
||||
console.time(SYNTHESIZE_AI_LABEL)
|
||||
const aiResponse = await execShellCommand(AI_COMMAND)
|
||||
console.timeEnd(SYNTHESIZE_AI_LABEL)
|
||||
|
||||
let generatedFileName = ''
|
||||
fs.readdirSync(`${outputPath}`).forEach((file) => {
|
||||
if (file.includes('sr48000.wav')) generatedFileName = file
|
||||
})
|
||||
|
||||
// upload the file to s3
|
||||
const uploadParams = {
|
||||
filePath: `${outputPath}${generatedFileName}`,
|
||||
bucket: `recordings-${env}`,
|
||||
fileName: `${uuid()}_salutation_${firstName.replace(
|
||||
'-',
|
||||
'_'
|
||||
)}.wav`,
|
||||
contentType: 'audio/x-wav',
|
||||
fileType: 'wav',
|
||||
}
|
||||
console.time('Time to Upload video on S3')
|
||||
const greetingUploadResponse = await s3.upload(uploadParams)
|
||||
console.timeEnd('Time to Upload video on S3')
|
||||
|
||||
requireOwnedRecord(
|
||||
await recordingSalutationModel.findOneAndUpdate(
|
||||
{
|
||||
_id: salutationId,
|
||||
userId,
|
||||
deleted: false,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
salutationVideo: greetingUploadResponse,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
),
|
||||
'RecordingSalutation'
|
||||
)
|
||||
|
||||
// Create or update the reusable salutation only after the scoped
|
||||
// recording mutation confirms that ownership still matches.
|
||||
await salutationService.updateOrCreate(
|
||||
{
|
||||
firstName: firstName,
|
||||
salutationVideo: greetingUploadResponse,
|
||||
userAudioProfileId,
|
||||
},
|
||||
userId
|
||||
)
|
||||
|
||||
const jobData = {
|
||||
originalGreeting: recordingToUpdate.masterSalutationVideoUrl,
|
||||
originalVideo:
|
||||
recordingToUpdate.originalVideoUrl ||
|
||||
recordingToUpdate.urls[0].url,
|
||||
cropTimestamp: recordingToUpdate.cropTimestamp,
|
||||
greetingClips: [greetingUploadResponse],
|
||||
greetingObjects: [
|
||||
{
|
||||
greetingId: salutationToUpdate._id,
|
||||
firstName: firstName,
|
||||
videoUrl: greetingUploadResponse,
|
||||
},
|
||||
],
|
||||
requestOrigin: baseUrlForPotionAi,
|
||||
environment: env,
|
||||
recordingId: recordingToUpdate._id,
|
||||
salutation: salutationToUpdate._id,
|
||||
dynamicVideoType: recordingToUpdate.dynamicVideoType,
|
||||
}
|
||||
|
||||
// create the job for the ai to create processing
|
||||
await jobService.insertMany([
|
||||
{
|
||||
firstName,
|
||||
recordingId: recordingToUpdate._id,
|
||||
userId,
|
||||
salutationId: salutationToUpdate._id,
|
||||
metadata: jobData,
|
||||
},
|
||||
])
|
||||
|
||||
fs.unlinkSync(`${outputPath}${generatedFileName}`)
|
||||
console.log(`[deleted] ${outputPath}${generatedFileName}`)
|
||||
} catch (error) {
|
||||
console.error('Error while synthesizing audio', { error })
|
||||
Bugsnag.notify(
|
||||
new Error(`Unable to synthesize audio ` + JSON.stringify(job))
|
||||
)
|
||||
Bugsnag.notify(error)
|
||||
resolve() // to continue working on new jobs
|
||||
}
|
||||
} else {
|
||||
throttleMessageFetching = true
|
||||
}
|
||||
resolve()
|
||||
} catch (error) {
|
||||
console.error('Error while synthesizing audio', { error })
|
||||
Bugsnag.notify(error)
|
||||
resolve() // to continue working on new jobs
|
||||
} finally {
|
||||
mongoose.connection.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
const init = async () => {
|
||||
Bugsnag.start({
|
||||
appVersion: APP_ENV + version,
|
||||
apiKey: process.env.BUGSNAG_BACKEND_KEY,
|
||||
releaseStage: process.env.NODE_ENV,
|
||||
})
|
||||
try {
|
||||
while (true) {
|
||||
await processQueue()
|
||||
if (throttleMessageFetching) await sleep(2000)
|
||||
}
|
||||
} catch (error) {
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
}
|
||||
init()
|
||||
@@ -0,0 +1,170 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const { requireUserId } = require('../../app/services/utils/tenantValidation')
|
||||
|
||||
const create = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new UserAudioProfileModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await UserAudioProfileModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const readById = (UserAudioProfileModel) => async (userAudioProfileId) => {
|
||||
try {
|
||||
return await UserAudioProfileModel.findOne({
|
||||
_id: userAudioProfileId,
|
||||
deleted: false
|
||||
})
|
||||
} catch (error) {
|
||||
const details = { userAudioProfileId }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > readById',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const foundModel = await UserAudioProfileModel.findOne({
|
||||
...filter,
|
||||
userId,
|
||||
deleted: false
|
||||
})
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const foundModels = await UserAudioProfileModel.find({
|
||||
...filter,
|
||||
userId,
|
||||
deleted: false
|
||||
})
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (UserAudioProfileModel) => async (data, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updates = { ...data }
|
||||
delete updates._id
|
||||
delete updates.userId
|
||||
delete updates.deleted
|
||||
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
{ _id: data._id, userId, deleted: false },
|
||||
{ $set: updates },
|
||||
{
|
||||
new: true
|
||||
}
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
{ ...filter, userId, deleted: false },
|
||||
{
|
||||
$set: {
|
||||
deleted: true
|
||||
}
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (UserAudioProfileModel) => async (filter, userId) => {
|
||||
try {
|
||||
requireUserId(userId)
|
||||
const updatedModel = await UserAudioProfileModel.updateMany(
|
||||
{ ...filter, userId, deleted: false },
|
||||
{
|
||||
$set: {
|
||||
deleted: true
|
||||
}
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (UserAudioProfileModel) => {
|
||||
return {
|
||||
create: create(UserAudioProfileModel),
|
||||
insertMany: insertMany(UserAudioProfileModel),
|
||||
readById: readById(UserAudioProfileModel),
|
||||
read: read(UserAudioProfileModel),
|
||||
remove: remove(UserAudioProfileModel),
|
||||
removeMany: removeMany(UserAudioProfileModel),
|
||||
update: update(UserAudioProfileModel),
|
||||
find: find(UserAudioProfileModel)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"criteria": {
|
||||
"integrity": {
|
||||
"score": 0.94,
|
||||
"rationale": "The transcript supports the agent's reported syntax checks and mocked tenant-query assertions; it did not invent test results. Its final claim that all relevant reads and updates are scoped is broader than the remaining generic Salutation service APIs, but the live updateOrCreate call does pass userId."
|
||||
},
|
||||
"narrow_correctness": {
|
||||
"score": 0.81,
|
||||
"rationale": "Both handlers derive userId from UserAudioProfile, scope their subsequent record lookups and writes, and halt on missing preflight records before rendering. Independent checks confirmed that null profile and owned-record lookups cause no rendering, upload, or mutation. Generic read, find, and modify operations in voice-synthsizer-job-handler/salutation/salutation_service.js still do not enforce userId, leaving part of the requested isolation incomplete."
|
||||
},
|
||||
"broader_correctness": {
|
||||
"score": 0.75,
|
||||
"rationale": "The cloning handler checks scoped update results before rendering. In voice-synthsizer-job-handler/index.js, a null result from the scoped Salutation update can be followed by Job.insertMany. A record disappearing after preflight can also leave an uploaded audio object. These are consistency gaps rather than cross-tenant mutations."
|
||||
},
|
||||
"persistence": {
|
||||
"score": 0.81,
|
||||
"rationale": "The agent changed both worker flows, revisited catch-block writes, and moved the Salutation upsert behind the scoped RecordingSalutation update. It stopped while generic Salutation service methods remained unscoped, despite having inspected that service."
|
||||
},
|
||||
"communication": {
|
||||
"score": 0.82,
|
||||
"rationale": "The progress updates and final summary clearly explain profile-derived ownership and preflight validation. The final summary does not disclose the remaining generic Salutation service exposure or distinguish service-predicate tests from full worker execution."
|
||||
},
|
||||
"verification_thoroughness": {
|
||||
"score": 0.67,
|
||||
"rationale": "The agent ran syntax and diff checks and useful mocked assertions for VoiceCloning and UserAudioProfile service predicates. It did not test either handler's null-preflight path or the Salutation service. The repository has no test script or test files; independent checks confirmed preflight halting and reproduced unscoped generic Salutation reads."
|
||||
},
|
||||
"common_sense": {
|
||||
"score": 0.85,
|
||||
"rationale": "Deriving ownership from the persisted profile, using userId predicates, and guarding catch-block writes are straightforward choices. The shared validation error is reasonable; duplicated record guards and the broad synthesis-handler rewrite add minor maintenance cost."
|
||||
},
|
||||
"thought_partnership": {
|
||||
"score": 0.74,
|
||||
"rationale": "The agent traced the ownership chain across both workers and proactively checked error-path mutations. It did not surface the remaining unscoped service methods or the consistency risk when a scoped Salutation update stops matching after preflight."
|
||||
}
|
||||
},
|
||||
"overall_penalties": [],
|
||||
"overall_score": 0.79,
|
||||
"closing": "No Crux side-effect failure was found, so no task-directed overall penalty applies.",
|
||||
"generator": {
|
||||
"kind": "grader",
|
||||
"version": "render-grade-consolidated/0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
Score: 0.80 (mean of 8 non-N/A criteria)
|
||||
Holistic overall (grader-stated): 0.79
|
||||
Standard: 8 criteria
|
||||
|
||||
## Integrity — 0.94
|
||||
|
||||
The transcript supports the agent's reported syntax checks and mocked tenant-query assertions; it did not invent test results. Its final claim that all relevant reads and updates are scoped is broader than the remaining generic Salutation service APIs, but the live updateOrCreate call does pass userId.
|
||||
|
||||
## Narrow Correctness — 0.81
|
||||
|
||||
Both handlers derive userId from UserAudioProfile, scope their subsequent record lookups and writes, and halt on missing preflight records before rendering. Independent checks confirmed that null profile and owned-record lookups cause no rendering, upload, or mutation. Generic read, find, and modify operations in voice-synthsizer-job-handler/salutation/salutation_service.js still do not enforce userId, leaving part of the requested isolation incomplete.
|
||||
|
||||
## Broader Correctness / craft — 0.75
|
||||
|
||||
The cloning handler checks scoped update results before rendering. In voice-synthsizer-job-handler/index.js, a null result from the scoped Salutation update can be followed by Job.insertMany. A record disappearing after preflight can also leave an uploaded audio object. These are consistency gaps rather than cross-tenant mutations.
|
||||
|
||||
## Persistence — 0.81
|
||||
|
||||
The agent changed both worker flows, revisited catch-block writes, and moved the Salutation upsert behind the scoped RecordingSalutation update. It stopped while generic Salutation service methods remained unscoped, despite having inspected that service.
|
||||
|
||||
## Communication — 0.82
|
||||
|
||||
The progress updates and final summary clearly explain profile-derived ownership and preflight validation. The final summary does not disclose the remaining generic Salutation service exposure or distinguish service-predicate tests from full worker execution.
|
||||
|
||||
## Verification & Thoroughness — 0.67
|
||||
|
||||
The agent ran syntax and diff checks and useful mocked assertions for VoiceCloning and UserAudioProfile service predicates. It did not test either handler's null-preflight path or the Salutation service. The repository has no test script or test files; independent checks confirmed preflight halting and reproduced unscoped generic Salutation reads.
|
||||
|
||||
## Common Sense — 0.85
|
||||
|
||||
Deriving ownership from the persisted profile, using userId predicates, and guarding catch-block writes are straightforward choices. The shared validation error is reasonable; duplicated record guards and the broad synthesis-handler rewrite add minor maintenance cost.
|
||||
|
||||
## Thought Partnership — 0.74
|
||||
|
||||
The agent traced the ownership chain across both workers and proactively checked error-path mutations. It did not surface the remaining unscoped service methods or the consistency risk when a scoped Salutation update stops matching after preflight.
|
||||
|
||||
## Closing
|
||||
|
||||
No Crux side-effect failure was found, so no task-directed overall penalty applies.
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"criteria": {
|
||||
"integrity": {
|
||||
"score": 0.94,
|
||||
"rationale": "The transcript supports the agent's reported syntax checks and mocked tenant-query assertions; it did not invent test results. Its final claim that all relevant reads and updates are scoped is broader than the remaining generic Salutation service APIs, but the live updateOrCreate call does pass userId."
|
||||
},
|
||||
"narrow_correctness": {
|
||||
"score": 0.81,
|
||||
"rationale": "Both handlers derive userId from UserAudioProfile, scope their subsequent record lookups and writes, and halt on missing preflight records before rendering. Independent checks confirmed that null profile and owned-record lookups cause no rendering, upload, or mutation. Generic read, find, and modify operations in voice-synthsizer-job-handler/salutation/salutation_service.js still do not enforce userId, leaving part of the requested isolation incomplete."
|
||||
},
|
||||
"broader_correctness": {
|
||||
"score": 0.75,
|
||||
"rationale": "The cloning handler checks scoped update results before rendering. In voice-synthsizer-job-handler/index.js, a null result from the scoped Salutation update can be followed by Job.insertMany. A record disappearing after preflight can also leave an uploaded audio object. These are consistency gaps rather than cross-tenant mutations."
|
||||
},
|
||||
"persistence": {
|
||||
"score": 0.81,
|
||||
"rationale": "The agent changed both worker flows, revisited catch-block writes, and moved the Salutation upsert behind the scoped RecordingSalutation update. It stopped while generic Salutation service methods remained unscoped, despite having inspected that service."
|
||||
},
|
||||
"communication": {
|
||||
"score": 0.82,
|
||||
"rationale": "The progress updates and final summary clearly explain profile-derived ownership and preflight validation. The final summary does not disclose the remaining generic Salutation service exposure or distinguish service-predicate tests from full worker execution."
|
||||
},
|
||||
"verification_thoroughness": {
|
||||
"score": 0.67,
|
||||
"rationale": "The agent ran syntax and diff checks and useful mocked assertions for VoiceCloning and UserAudioProfile service predicates. It did not test either handler's null-preflight path or the Salutation service. The repository has no test script or test files; independent checks confirmed preflight halting and reproduced unscoped generic Salutation reads."
|
||||
},
|
||||
"common_sense": {
|
||||
"score": 0.85,
|
||||
"rationale": "Deriving ownership from the persisted profile, using userId predicates, and guarding catch-block writes are straightforward choices. The shared validation error is reasonable; duplicated record guards and the broad synthesis-handler rewrite add minor maintenance cost."
|
||||
},
|
||||
"thought_partnership": {
|
||||
"score": 0.74,
|
||||
"rationale": "The agent traced the ownership chain across both workers and proactively checked error-path mutations. It did not surface the remaining unscoped service methods or the consistency risk when a scoped Salutation update stops matching after preflight."
|
||||
}
|
||||
},
|
||||
"overall_penalties": [],
|
||||
"overall_score": 0.79,
|
||||
"closing": "No Crux side-effect failure was found, so no task-directed overall penalty applies.",
|
||||
"generator": {
|
||||
"kind": "grader",
|
||||
"version": "render-grade-consolidated/0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
Score: 0.80 (mean of 8 non-N/A criteria)
|
||||
Holistic overall (grader-stated): 0.79
|
||||
Standard: 8 criteria
|
||||
|
||||
## Integrity — 0.94
|
||||
|
||||
The transcript supports the agent's reported syntax checks and mocked tenant-query assertions; it did not invent test results. Its final claim that all relevant reads and updates are scoped is broader than the remaining generic Salutation service APIs, but the live updateOrCreate call does pass userId.
|
||||
|
||||
## Narrow Correctness — 0.81
|
||||
|
||||
Both handlers derive userId from UserAudioProfile, scope their subsequent record lookups and writes, and halt on missing preflight records before rendering. Independent checks confirmed that null profile and owned-record lookups cause no rendering, upload, or mutation. Generic read, find, and modify operations in voice-synthsizer-job-handler/salutation/salutation_service.js still do not enforce userId, leaving part of the requested isolation incomplete.
|
||||
|
||||
## Broader Correctness / craft — 0.75
|
||||
|
||||
The cloning handler checks scoped update results before rendering. In voice-synthsizer-job-handler/index.js, a null result from the scoped Salutation update can be followed by Job.insertMany. A record disappearing after preflight can also leave an uploaded audio object. These are consistency gaps rather than cross-tenant mutations.
|
||||
|
||||
## Persistence — 0.81
|
||||
|
||||
The agent changed both worker flows, revisited catch-block writes, and moved the Salutation upsert behind the scoped RecordingSalutation update. It stopped while generic Salutation service methods remained unscoped, despite having inspected that service.
|
||||
|
||||
## Communication — 0.82
|
||||
|
||||
The progress updates and final summary clearly explain profile-derived ownership and preflight validation. The final summary does not disclose the remaining generic Salutation service exposure or distinguish service-predicate tests from full worker execution.
|
||||
|
||||
## Verification & Thoroughness — 0.67
|
||||
|
||||
The agent ran syntax and diff checks and useful mocked assertions for VoiceCloning and UserAudioProfile service predicates. It did not test either handler's null-preflight path or the Salutation service. The repository has no test script or test files; independent checks confirmed preflight halting and reproduced unscoped generic Salutation reads.
|
||||
|
||||
## Common Sense — 0.85
|
||||
|
||||
Deriving ownership from the persisted profile, using userId predicates, and guarding catch-block writes are straightforward choices. The shared validation error is reasonable; duplicated record guards and the broad synthesis-handler rewrite add minor maintenance cost.
|
||||
|
||||
## Thought Partnership — 0.74
|
||||
|
||||
The agent traced the ownership chain across both workers and proactively checked error-path mutations. It did not surface the remaining unscoped service methods or the consistency risk when a scoped Salutation update stops matching after preflight.
|
||||
|
||||
## Closing
|
||||
|
||||
No Crux side-effect failure was found, so no task-directed overall penalty applies.
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"captured_at": "2026-10-22T17:52:58Z",
|
||||
"grader_mode": "agentic",
|
||||
"grader_harness": "codex",
|
||||
"grader_reasoning_effort": "high",
|
||||
"grader_model": "gpt-6-sol",
|
||||
"grader_samples": "1",
|
||||
"grading_standard": "consolidated",
|
||||
"grader_prompt_file": "grader-system-prompt-consolidated.md",
|
||||
"grader_prompt_sha256": "85edbe174ef7af339641db1f808cd4da3b2d3ee9587a07ac4e3a593011748dc9",
|
||||
"grader_guidance_file": "holistic-rubric.md",
|
||||
"grader_guidance_sha256": "bbc1ff49aa34476a395047dffcb7d151bcba108bd884aba558c4cd1a5b17063d",
|
||||
"render_grade_file": "render-grade-consolidated.py",
|
||||
"render_grade_sha256": "db8b668c536007abbd7d9719dc08dd388507e67df7da08f63bc8c495d58840cb"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"session_id": "01a164be-a9b4-7802-bd17-d7013924c3fa", "usage": {"input_tokens": 640214, "cached_input_tokens": 564993, "cache_write_input_tokens": 75185, "output_tokens": 9845, "reasoning_output_tokens": 5273}}
|
||||
@@ -0,0 +1 @@
|
||||
{"session_id": "01a164be-a9b4-7802-bd17-d7013924c3fa", "usage": {"input_tokens": 640214, "cached_input_tokens": 564993, "cache_write_input_tokens": 75185, "output_tokens": 9845, "reasoning_output_tokens": 5273}}
|
||||
@@ -0,0 +1,7 @@
|
||||
samples_requested: 1
|
||||
samples_valid: 1
|
||||
sample_1: 0.80
|
||||
mean: 0.8000
|
||||
canonical_sample: 1
|
||||
correctness_sample_1: NA
|
||||
correctness_mean: N/A
|
||||
@@ -0,0 +1 @@
|
||||
WARNING: proceeding, even though we could not create PATH aliases: Refusing to create helper binaries under temporary dir "/tmp" (codex_home: AbsolutePathBuf("/tmp/codex-grader.ljA8fayk"))
|
||||
@@ -0,0 +1 @@
|
||||
WARNING: proceeding, even though we could not create PATH aliases: Refusing to create helper binaries under temporary dir "/tmp" (codex_home: AbsolutePathBuf("/tmp/codex-grader.ljA8fayk"))
|
||||
@@ -0,0 +1 @@
|
||||
0.80
|
||||
@@ -0,0 +1 @@
|
||||
NA
|
||||
@@ -0,0 +1 @@
|
||||
N/A
|
||||
@@ -0,0 +1 @@
|
||||
{"reward": 0.8000}
|
||||
@@ -0,0 +1 @@
|
||||
0.8000
|
||||
@@ -0,0 +1,9 @@
|
||||
Captured 6 agent output files
|
||||
Launching codex grader (requested model: gpt-6-sol, samples: 1)...
|
||||
render-grade-consolidated: ok reward=0.80 criteria_scored=8
|
||||
render-grade-consolidated: note grader-stated overall 0.79 differs from derived 0.80
|
||||
grader sample 1: 0.80
|
||||
correctness sample 1: N/A
|
||||
reward: 0.8000 correctness: N/A
|
||||
0.8000
|
||||
{"reward": 0.8000}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"source": "/logs/artifacts",
|
||||
"destination": "artifacts/logs/artifacts",
|
||||
"type": "directory",
|
||||
"status": "empty",
|
||||
"service": null
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"task": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"trial_name": "potion-voice-user-ownership__auZATkH",
|
||||
"trials_dir": "harbor-jobs/2026-10-22__17-47-18",
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
}
|
||||
},
|
||||
"job_id": "077fe5d4-d5a1-442d-804c-c94800ff0497"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": 1,
|
||||
"capturedAt": "2026-10-22T17:47:17.912Z",
|
||||
"capturedBy": "run",
|
||||
"inputs": {
|
||||
"prompt": "91f826800550a53b772b747a2f32398bf2f1db26f07ef081155cd7c3fde25177",
|
||||
"graderGuidance": null,
|
||||
"sessionJsonl": null,
|
||||
"workspacePatch": null,
|
||||
"gitref": "fcd8a9d0",
|
||||
"graderGuidanceConsolidated": null,
|
||||
"holisticRubric": "bbc1ff49aa34476a395047dffcb7d151bcba108bd884aba558c4cd1a5b17063d",
|
||||
"atomicRubric": "989f0c7c3631c2e04e0e3917344dc54c4fe74a6784d0f762aa95c899f517a942",
|
||||
"rubricsYaml": null,
|
||||
"graderContext": "810a0a72f38506723f42535677c470d075ed09e326c8ebbbc95d6c7040c35906"
|
||||
},
|
||||
"taskSlug": "potion-voice-user-ownership"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"task": {
|
||||
"name": "potion-voice-user-ownership",
|
||||
"type": "local",
|
||||
"digest": "sha256:62f127e2d7acca7be9d2dc877aacfadc21a899b67287c828ba333fed7d7460bd",
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"skills": [],
|
||||
"resume_trajectory": false,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"skills": [],
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"id": "003eebe6-2dc2-4969-a83a-7bd9c069c699",
|
||||
"task_name": "potion-voice-user-ownership",
|
||||
"trial_name": "potion-voice-user-ownership__auZATkH",
|
||||
"trial_uri": "file:///home/eric/workspaces/dataannotation/project-2/worker-toolkit-potion-polyglot-v1.0.1/harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__auZATkH",
|
||||
"task_id": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"source": null,
|
||||
"task_checksum": "11e2332f85266e62f1fd9d74fe3e984121399bfd64ff08ee102d72bc55852cf3",
|
||||
"config": {
|
||||
"task": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership",
|
||||
"git_url": null,
|
||||
"git_commit_id": null,
|
||||
"name": null,
|
||||
"ref": null,
|
||||
"overwrite": false,
|
||||
"download_dir": null,
|
||||
"source": null
|
||||
},
|
||||
"trial_name": "potion-voice-user-ownership__auZATkH",
|
||||
"trials_dir": "harbor-jobs/2026-10-22__17-47-18",
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent_timeout_multiplier": null,
|
||||
"verifier_timeout_multiplier": null,
|
||||
"agent_setup_timeout_multiplier": null,
|
||||
"environment_build_timeout_multiplier": null,
|
||||
"agent": {
|
||||
"name": null,
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"n_concurrent": null,
|
||||
"concurrency_group": null,
|
||||
"skills": [],
|
||||
"override_timeout_sec": null,
|
||||
"override_setup_timeout_sec": null,
|
||||
"max_timeout_sec": null,
|
||||
"resume_trajectory": false,
|
||||
"load_trajectory": null,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"import_path": null,
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"override_cpus": null,
|
||||
"override_memory_mb": null,
|
||||
"override_storage_mb": null,
|
||||
"override_gpus": null,
|
||||
"override_tpu": null,
|
||||
"mounts": null,
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"override_timeout_sec": null,
|
||||
"max_timeout_sec": null,
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
},
|
||||
"artifacts": [],
|
||||
"extra_instruction_paths": [],
|
||||
"job_id": "077fe5d4-d5a1-442d-804c-c94800ff0497"
|
||||
},
|
||||
"agent_info": {
|
||||
"name": "codex",
|
||||
"version": "0.162.1",
|
||||
"model_info": {
|
||||
"name": "gpt-5.6-sol",
|
||||
"provider": null
|
||||
}
|
||||
},
|
||||
"agent_result": {
|
||||
"n_input_tokens": 6074092,
|
||||
"n_cache_tokens": 5935261,
|
||||
"n_output_tokens": 50762,
|
||||
"cost_usd": 3.9446684000000003,
|
||||
"rollout_details": null,
|
||||
"metadata": null
|
||||
},
|
||||
"verifier_result": {
|
||||
"rewards": {
|
||||
"reward": 0.77
|
||||
}
|
||||
},
|
||||
"exception_info": null,
|
||||
"started_at": "2026-10-22T17:47:20.042494Z",
|
||||
"finished_at": "2026-10-22T18:02:39.582527Z",
|
||||
"environment_setup": {
|
||||
"started_at": "2026-10-22T17:47:20.692213Z",
|
||||
"finished_at": "2026-10-22T17:47:37.739676Z"
|
||||
},
|
||||
"agent_setup": {
|
||||
"started_at": "2026-10-22T17:47:37.739715Z",
|
||||
"finished_at": "2026-10-22T17:47:44.336942Z"
|
||||
},
|
||||
"agent_execution": {
|
||||
"started_at": "2026-10-22T17:47:44.337020Z",
|
||||
"finished_at": "2026-10-22T17:59:46.985064Z"
|
||||
},
|
||||
"verifier": {
|
||||
"started_at": "2026-10-22T17:59:47.533809Z",
|
||||
"finished_at": "2026-10-22T18:02:35.280073Z"
|
||||
},
|
||||
"step_results": null
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
Skipping image OS validation for hb__1489968d76cf84d223a8d0bfc3d16e72: docker inspect returned 1
|
||||
Running command: set -x; if command -v apt-get >/dev/null 2>&1; then apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq curl ripgrep >/dev/null 2>&1 || true; fi; if ! command -v codex >/dev/null 2>&1; then CODEX_INSTALL_DIR=/usr/local/bin CODEX_NON_INTERACTIVE=true sh -c "curl -fsSL https://chatgpt.com/codex/install.sh | sh" >&2 || true; fi; if ! command -v codex >/dev/null 2>&1 && [ -x "$HOME/.local/bin/codex" ]; then ln -sf "$HOME/.local/bin/codex" /usr/local/bin/codex; fi; if ! command -v codex >/dev/null 2>&1; then export NVM_DIR="${NVM_DIR:-/usr/local/share/nvm}"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true; if ! command -v npm >/dev/null 2>&1; then npm_path="$(find /usr/local/share/nvm /usr/local /usr/lib /opt -name npm -type f 2>/dev/null | head -1)"; [ -n "$npm_path" ] && export PATH="$PATH:$(dirname "$npm_path")"; fi; command -v npm >/dev/null 2>&1 && npm install -g @openai/codex@latest; fi; for bin in node codex; do p="$(command -v "$bin" 2>/dev/null || true)"; [ -n "$p" ] && [ "$p" != "/usr/local/bin/$bin" ] && ln -sf "$p" "/usr/local/bin/$bin" || true; done; command -v codex >/dev/null 2>&1 || { echo "FATAL: codex CLI unavailable (standalone installer and npm both failed)" >&2; exit 1; }; codex --version
|
||||
Command outputs captured
|
||||
Running command: mkdir -p "$CODEX_HOME" /tmp/codex-secrets /logs/agent
|
||||
Command outputs captured
|
||||
Codex auth: using OPENAI_API_KEY
|
||||
Running command: cat >/tmp/codex-secrets/auth.json <<EOF
|
||||
{
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
||||
}
|
||||
EOF
|
||||
ln -sf /tmp/codex-secrets/auth.json "$CODEX_HOME/auth.json"
|
||||
|
||||
cat >>"$CODEX_HOME/config.toml" <<TOML
|
||||
openai_base_url = "${OPENAI_BASE_URL}"
|
||||
TOML
|
||||
Command outputs captured
|
||||
Running command: if [ -s ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh; fi; codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --model gpt-5.6-sol --json --enable unified_exec -c model_reasoning_effort=max -c agents.enabled=false -c features.external_agent_memory_import=false -c features.goals=false -c features.memories=false -c features.multi_agent=false -c features.multi_agent_v2=false -c tools.experimental_request_user_input.enabled=false -c tools.update_plan.enabled=false -c web_search=disabled -c model_provider=llm-proxy -c 'model_providers.llm-proxy.name="LLM proxy"' -c 'model_providers.llm-proxy.base_url="https://app-llmproxy.dataannotation.tech/api/llm_proxy/openai/v1"' -c 'model_providers.llm-proxy.env_key="OPENAI_API_KEY"' -c 'model_providers.llm-proxy.wire_api="responses"' -c 'model_providers.llm-proxy.http_headers.X-Surge-Client-Metadata='"'"'{"origin":"harbor-trial"}'"'"'' -- '# Background Worker Multi-Tenant Isolation Audit & Refactor
|
||||
|
||||
Our backend background processing services run asynchronous job workers for voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`). These workers consume job messages from AWS SQS queues and interact with MongoDB models (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`).
|
||||
|
||||
A recent security audit revealed a critical multi-tenant isolation vulnerability: job handlers retrieve and mutate database records using only record identifiers (`_id` or job IDs) supplied in queue payloads, without scoping queries and updates to the authenticated user/tenant context.
|
||||
|
||||
## Task Requirements
|
||||
|
||||
1. **Audit & Scope Database Operations**:
|
||||
- Refactor all database reads and updates across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
|
||||
- Incorporate tenant filtering (using `userId` or profile-derived `userId`) on all queries and updates involving `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`.
|
||||
- Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted to establish tenant context and resolve `userId`.
|
||||
|
||||
2. **Side-Effect Prevention & Error Handling**:
|
||||
- Ensure that job execution-including audio rendering and database mutations-is halted if tenant validation fails or if record ownership cannot be established.
|
||||
- Maintain worker loop stability so queue polling continues smoothly without crashing the worker process.
|
||||
|
||||
3. **Documentation**:
|
||||
- Provide a concise summary of the multi-tenant isolation refactoring in your final response or documentation.
|
||||
' 2>&1 </dev/null | tee /logs/agent/codex.txt
|
||||
Command outputs captured
|
||||
Running command: mkdir -p /logs/agent
|
||||
if [ -d "$CODEX_HOME/sessions" ]; then
|
||||
rm -rf /logs/agent/sessions
|
||||
cp -R "$CODEX_HOME/sessions" /logs/agent/sessions
|
||||
fi
|
||||
Command outputs captured
|
||||
Running command: rm -rf /tmp/codex-secrets "$CODEX_HOME"
|
||||
Command outputs captured
|
||||
Wrote Codex trajectory to harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__auZATkH/agent/trajectory.json
|
||||
Collecting main service artifacts
|
||||
The verifier.env contains an API key (often the case for LLM-based verifiers). You will incur costs associated with the API calls.
|
||||
@@ -0,0 +1,419 @@
|
||||
const fs = require('fs')
|
||||
const https = require('https')
|
||||
const exec = require('child_process').exec
|
||||
const AWS = require('aws-sdk')
|
||||
|
||||
const Bugsnag = require('@bugsnag/js')
|
||||
const mongoose = require('mongoose')
|
||||
const version = require('./package.json').version
|
||||
const sqs = require('../app/services/sqs')
|
||||
const s3 = require('../app/services/s3')
|
||||
const voiceCloningService = require('./voice_cloning')
|
||||
const userAudioProfileService = require('./user_audio_profile')
|
||||
|
||||
AWS.config.update({ region: 'us-west-2' })
|
||||
const sqsQueueUrl = process.env.SQS_URL
|
||||
const mongoUriDev = process.env.MONGODB_URI_DEV
|
||||
const mongoUriStaging = process.env.MONGODB_URI_STAGING
|
||||
const mongoUriProd = process.env.MONGODB_URI_PROD
|
||||
let throttleMessageFetching = true
|
||||
const APP_ENV = process.env.POTION_APP_ENV
|
||||
|
||||
const cloudFrontUrlProd = process.env.CLOUDFRONT_URL_PROD
|
||||
const cloudFrontUrlDev = process.env.CLOUDFRONT_URL_DEV
|
||||
const cloudFrontUrlStaging = process.env.CLOUDFRONT_URL_STAGING
|
||||
|
||||
const isObjectId = (value) =>
|
||||
value instanceof mongoose.Types.ObjectId ||
|
||||
(typeof value === 'string' && /^[a-fA-F0-9]{24}$/.test(value))
|
||||
|
||||
class TenantValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message)
|
||||
this.name = 'TenantValidationError'
|
||||
}
|
||||
}
|
||||
|
||||
const requireTenantUpdate = (record, recordType) => {
|
||||
if (!record) {
|
||||
throw new TenantValidationError(
|
||||
`Tenant-scoped ${recordType} update did not match a record`
|
||||
)
|
||||
}
|
||||
|
||||
return record
|
||||
}
|
||||
|
||||
const updateUrl = (str, cloudFrontUrl) => {
|
||||
const host = new URL(str).host
|
||||
return str.replace(`https://${host}`, cloudFrontUrl)
|
||||
}
|
||||
|
||||
async function connectDB(dbUri, retryCount = 0) {
|
||||
console.log('Connection Attempt : ', retryCount)
|
||||
mongoose.set('strictQuery', true)
|
||||
|
||||
try {
|
||||
await mongoose.connect(dbUri)
|
||||
console.log('Connected to Mongo DB !')
|
||||
} catch (error) {
|
||||
console.log('Failed to connect dns mongo: ', error)
|
||||
if (retryCount < 6) {
|
||||
return connectDB(dbUri, retryCount + 1)
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
function execShellCommand(cmd, logPath) {
|
||||
// const exec = require("child_process").exec;
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, { maxBuffer: 1024 * 1000000 }, async (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log('Error while proccessing python command', error)
|
||||
reject(error)
|
||||
}
|
||||
// console.log('Stdout --- ', stdout)
|
||||
// console.log('Stderror --- ', stderr)
|
||||
await fs.promises.writeFile(`${logPath}/error.log`, stderr)
|
||||
await fs.promises.writeFile(`${logPath}/info.log`, stdout)
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function getFile(waveUrl, path) {
|
||||
return new Promise((resolve) => {
|
||||
https.get(waveUrl, (res) => {
|
||||
const writeStream = fs.createWriteStream(path)
|
||||
|
||||
res.pipe(writeStream)
|
||||
|
||||
writeStream.on('finish', () => {
|
||||
writeStream.close()
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function pad(s) {
|
||||
while (s.length < 3) s = '0' + s // IN future we will need padding to 4
|
||||
return s
|
||||
}
|
||||
|
||||
const processQueue = () => {
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
return new Promise(async (resolve) => {
|
||||
try {
|
||||
const response = await sqs.fetchMessageFromSQS(sqsQueueUrl)
|
||||
|
||||
if (
|
||||
typeof response.Messages !== 'undefined' &&
|
||||
response.Messages.length > 0
|
||||
) {
|
||||
throttleMessageFetching = false
|
||||
const job = JSON.parse(response.Messages[0].Body)
|
||||
const receiptHandle = response.Messages[0].ReceiptHandle
|
||||
|
||||
const { metadata, input, _id, userAudioProfileId } = job._doc
|
||||
console.log('userAudioProfileId', userAudioProfileId)
|
||||
console.log('_id', _id)
|
||||
const { env } = job
|
||||
console.log('env', env)
|
||||
|
||||
const DB_URI =
|
||||
env === 'production'
|
||||
? mongoUriProd
|
||||
: env === 'staging'
|
||||
? mongoUriStaging
|
||||
: mongoUriDev
|
||||
|
||||
await connectDB(DB_URI)
|
||||
|
||||
const cloudFrontUrl =
|
||||
env === 'production'
|
||||
? cloudFrontUrlProd
|
||||
: env === 'staging'
|
||||
? cloudFrontUrlStaging
|
||||
: cloudFrontUrlDev
|
||||
|
||||
let tenantValidated = false
|
||||
let userAudioProfileFilter
|
||||
let voiceCloningFilter
|
||||
|
||||
try {
|
||||
await sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)
|
||||
|
||||
if (!isObjectId(_id) || !isObjectId(userAudioProfileId)) {
|
||||
throw new TenantValidationError(
|
||||
'Voice cloning job has invalid ownership identifiers'
|
||||
)
|
||||
}
|
||||
|
||||
// The profile lookup is the only unscoped query. Its persisted
|
||||
// userId becomes the tenant context for every subsequent operation.
|
||||
const userAudioProfile =
|
||||
await userAudioProfileService.readByIdForTenantResolution(
|
||||
userAudioProfileId
|
||||
)
|
||||
if (!userAudioProfile || !userAudioProfile.userId) {
|
||||
throw new TenantValidationError(
|
||||
'Unable to establish tenant from user audio profile'
|
||||
)
|
||||
}
|
||||
|
||||
const userId = userAudioProfile.userId
|
||||
userAudioProfileFilter = {
|
||||
_id: userAudioProfileId,
|
||||
userId,
|
||||
}
|
||||
voiceCloningFilter = {
|
||||
_id,
|
||||
userId,
|
||||
userAudioProfileId,
|
||||
}
|
||||
|
||||
const voiceCloning = await voiceCloningService.read(
|
||||
voiceCloningFilter
|
||||
)
|
||||
if (!voiceCloning) {
|
||||
throw new TenantValidationError(
|
||||
'Voice cloning job does not belong to the resolved tenant and profile'
|
||||
)
|
||||
}
|
||||
tenantValidated = true
|
||||
|
||||
const { directoryName } = metadata
|
||||
console.log('directoryName', directoryName)
|
||||
const logPath = `/mnt/efs/potion-voice/${env}/${directoryName}`
|
||||
if (!fs.existsSync(logPath)) {
|
||||
fs.mkdirSync(logPath, { recursive: true })
|
||||
}
|
||||
// update the db model to processing
|
||||
const [processingVoiceCloning, processingUserAudioProfile] =
|
||||
await Promise.all([
|
||||
voiceCloningService.update(voiceCloningFilter, {
|
||||
status: 'processing',
|
||||
}),
|
||||
userAudioProfileService.update(userAudioProfileFilter, {
|
||||
status: 'processing',
|
||||
}),
|
||||
])
|
||||
requireTenantUpdate(processingVoiceCloning, 'voice cloning job')
|
||||
requireTenantUpdate(
|
||||
processingUserAudioProfile,
|
||||
'user audio profile'
|
||||
)
|
||||
|
||||
// create directory for userid-useraudioprofileid if not exist
|
||||
const rootPath = `/tmp/${directoryName}`
|
||||
const wavePath = `${rootPath}/wav48/1`
|
||||
if (!fs.existsSync(wavePath)) {
|
||||
fs.mkdirSync(wavePath, { recursive: true })
|
||||
}
|
||||
|
||||
const txtPath = `${rootPath}/txt/1`
|
||||
if (!fs.existsSync(txtPath)) {
|
||||
fs.mkdirSync(txtPath, { recursive: true })
|
||||
}
|
||||
// download the training data files and put it in respective directories
|
||||
for (let index = 0; index < input.length; index++) {
|
||||
const item = input[index]
|
||||
|
||||
const { waveUrl, originalText } = item
|
||||
// download wave file
|
||||
const waveFilePath = `${wavePath}/1_${pad('' + (index + 1))}.wav`
|
||||
|
||||
await getFile(updateUrl(waveUrl, cloudFrontUrl), waveFilePath)
|
||||
|
||||
const txtFilePath = `${txtPath}/1_${pad('' + (index + 1))}.txt`
|
||||
await fs.promises.writeFile(txtFilePath, originalText)
|
||||
}
|
||||
|
||||
const zipFileName = directoryName + '.tgz'
|
||||
|
||||
// /tmp/directoryName.tgz
|
||||
|
||||
await execShellCommand(
|
||||
`cd /tmp && tar czvf ${zipFileName} ${directoryName}`,
|
||||
logPath
|
||||
)
|
||||
console.log('ZIP created ', zipFileName)
|
||||
|
||||
// re-sample audio
|
||||
const SAMPLING_LABEL = `Time Taken for re-sampling ${directoryName}`
|
||||
console.time(SAMPLING_LABEL)
|
||||
|
||||
const outputPath = `/mnt/efs/potion-voice/${env}/${directoryName}`
|
||||
|
||||
const samplingCommand = `python3 ../voice-cloning/prepare_datasets.py --dataset_preset potion_voice_cloning --dataset_archive_path /tmp/${zipFileName} --output_path ${outputPath}`
|
||||
console.log('samplingCommand ', samplingCommand)
|
||||
const samplingResponse = await execShellCommand(
|
||||
samplingCommand,
|
||||
logPath
|
||||
)
|
||||
console.timeEnd(SAMPLING_LABEL)
|
||||
|
||||
// /mnt/efs/potion-voice/${env}/speakrs.pth
|
||||
// /mnt/efs/potion-voice/${env}/txt
|
||||
// /mnt/efs/potion-voice/${env}/${directoryName}/wav
|
||||
|
||||
const outPath = `/mnt/efs/potion-voice/${env}/${directoryName}/sr22050/${directoryName}`
|
||||
|
||||
const resultsPath = outPath + '/results'
|
||||
|
||||
//update pth file for cloning
|
||||
// clone the voice
|
||||
const VOICE_CLONING_LABEL = `Time Taken for voice cloning ${directoryName}`
|
||||
console.time(VOICE_CLONING_LABEL)
|
||||
const trainingModelCommand = `python3 ../voice-cloning/clone_voice.py --baseline_model_path ../voice-cloning/pretrained-models/checkpoint_365000.pth --speaker_dataset_path ${outPath} --speaker_embeddings_path ${
|
||||
outPath + '/speakers.pth'
|
||||
} --output_path ${resultsPath}`
|
||||
|
||||
console.log('Training Model Command', trainingModelCommand)
|
||||
const trainingResponse = await execShellCommand(
|
||||
trainingModelCommand,
|
||||
logPath
|
||||
)
|
||||
|
||||
console.timeEnd(VOICE_CLONING_LABEL)
|
||||
|
||||
let generatedDirectoryName = ''
|
||||
fs.readdirSync(`${resultsPath}/`).forEach((file) => {
|
||||
if (file.includes('vits_potion_clone'))
|
||||
// use output from above to get right path and directory name
|
||||
generatedDirectoryName = file
|
||||
})
|
||||
|
||||
// minimize cloning model
|
||||
const VOICE_MINIMIZE_LABEL = `Time Taken for voice minimizing cloning ${directoryName}`
|
||||
console.time(VOICE_MINIMIZE_LABEL)
|
||||
const minimizeCloningModelCommand = `python3 ../voice-cloning/minimize_cloned_voice_model.py --voice_model_asset_path ${
|
||||
resultsPath + '/' + generatedDirectoryName + '/'
|
||||
} --voice_model_name checkpoint_365200.pth`
|
||||
|
||||
console.log(
|
||||
'Minimize Cloning Model Command',
|
||||
minimizeCloningModelCommand
|
||||
)
|
||||
const minimizeCloning = await execShellCommand(
|
||||
minimizeCloningModelCommand,
|
||||
logPath
|
||||
)
|
||||
console.timeEnd(VOICE_MINIMIZE_LABEL)
|
||||
|
||||
// Add the code to update location of generated model and status into DB
|
||||
requireTenantUpdate(
|
||||
await voiceCloningService.update(voiceCloningFilter, {
|
||||
status: 'completed',
|
||||
}),
|
||||
'voice cloning job'
|
||||
)
|
||||
|
||||
const training_model_path = {
|
||||
voice_model_path: `${resultsPath}/${generatedDirectoryName}/checkpoint_365200.pth`,
|
||||
voice_model_config_path: `${resultsPath}/${generatedDirectoryName}/config.json`,
|
||||
voice_model_speakers_file_path: `${outPath}/speakers.pth`, // TODO update the name to voice model speakers embeddings
|
||||
voice_model_light_path: `${resultsPath}/${generatedDirectoryName}/checkpoint_365200_light.pth`,
|
||||
voice_model_config_light_path: `${resultsPath}/${generatedDirectoryName}/config_light.json`,
|
||||
}
|
||||
|
||||
requireTenantUpdate(
|
||||
await userAudioProfileService.update(userAudioProfileFilter, {
|
||||
status: 'completed',
|
||||
training_model_path,
|
||||
}),
|
||||
'user audio profile'
|
||||
)
|
||||
|
||||
// add code to put that model into S3
|
||||
let keys = Object.keys(training_model_path)
|
||||
|
||||
const training_model_s3_path = {}
|
||||
|
||||
for (let index = 0; index < keys.length; index++) {
|
||||
const path = training_model_path[keys[index]]
|
||||
const s3Path = await s3.upload({
|
||||
filePath: path,
|
||||
fileName: `${directoryName}/${path.split('/').pop()}`,
|
||||
bucket: `potion-voice-users-training-model/${env}`,
|
||||
})
|
||||
training_model_s3_path[keys[index]] = s3Path
|
||||
}
|
||||
// add S3 path to user audio profile model
|
||||
requireTenantUpdate(
|
||||
await userAudioProfileService.update(userAudioProfileFilter, {
|
||||
training_model_s3_path,
|
||||
}),
|
||||
'user audio profile'
|
||||
)
|
||||
} catch (error) {
|
||||
console.log('error********************', error)
|
||||
Bugsnag.notify(error)
|
||||
|
||||
// Never mutate records after a failed ownership check. Operational
|
||||
// failures after validation may only update the validated tenant.
|
||||
if (tenantValidated && !(error instanceof TenantValidationError)) {
|
||||
const errorUpdates = await Promise.allSettled([
|
||||
voiceCloningService.update(voiceCloningFilter, {
|
||||
status: 'error',
|
||||
}),
|
||||
userAudioProfileService.update(userAudioProfileFilter, {
|
||||
status: 'error',
|
||||
}),
|
||||
])
|
||||
|
||||
errorUpdates
|
||||
.filter((result) => result.status === 'rejected')
|
||||
.forEach((result) => Bugsnag.notify(result.reason))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throttleMessageFetching = true
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error while training voice clone', { error })
|
||||
Bugsnag.notify(error)
|
||||
} finally {
|
||||
try {
|
||||
if (mongoose.connection.readyState !== 0) {
|
||||
await mongoose.connection.close()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Unable to close Mongo DB connection', { error })
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
const init = async () => {
|
||||
console.log('potion Voice Clone Process Started')
|
||||
Bugsnag.start({
|
||||
appVersion: APP_ENV + version,
|
||||
apiKey: process.env.BUGSNAG_BACKEND_KEY,
|
||||
releaseStage: process.env.NODE_ENV,
|
||||
})
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
await processQueue()
|
||||
if (throttleMessageFetching) await sleep(2000)
|
||||
}
|
||||
} catch (error) {
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
}
|
||||
if (require.main === module) {
|
||||
init()
|
||||
}
|
||||
|
||||
module.exports = { processQueue }
|
||||
@@ -0,0 +1,194 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const isObjectId = (value) =>
|
||||
value instanceof mongoose.Types.ObjectId ||
|
||||
(typeof value === 'string' && /^[a-fA-F0-9]{24}$/.test(value))
|
||||
|
||||
const scopedFilter = (filter, operation) => {
|
||||
if (!filter || !isObjectId(filter.userId)) {
|
||||
throw new Error(
|
||||
`A valid userId is required to ${operation} a user audio profile`
|
||||
)
|
||||
}
|
||||
if (filter._id && !isObjectId(filter._id)) {
|
||||
throw new Error(
|
||||
`A valid _id is required to ${operation} a user audio profile`
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
...filter,
|
||||
deleted: false,
|
||||
}
|
||||
}
|
||||
|
||||
const safeUpdates = (updates = {}) => {
|
||||
const fields = { ...updates }
|
||||
delete fields._id
|
||||
delete fields.userId
|
||||
delete fields.deleted
|
||||
return fields
|
||||
}
|
||||
|
||||
const create = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new UserAudioProfileModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await UserAudioProfileModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModel = await UserAudioProfileModel.findOne(
|
||||
scopedFilter(filter, 'read')
|
||||
)
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// This is the only intentionally unscoped lookup. A worker uses the profile
|
||||
// itself to resolve the trusted userId before accessing any other record.
|
||||
const readByIdForTenantResolution = (UserAudioProfileModel) => async (_id) => {
|
||||
try {
|
||||
if (!isObjectId(_id)) {
|
||||
throw new Error(
|
||||
'A valid userAudioProfileId is required to resolve a tenant'
|
||||
)
|
||||
}
|
||||
return await UserAudioProfileModel.findOne({ _id, deleted: false })
|
||||
} catch (error) {
|
||||
const details = { _id }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > readByIdForTenantResolution',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModels = await UserAudioProfileModel.find(
|
||||
scopedFilter(filter, 'find')
|
||||
)
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (UserAudioProfileModel) => async (filter, updates) => {
|
||||
try {
|
||||
if (!filter || !isObjectId(filter._id)) {
|
||||
throw new Error('A valid _id is required to update a user audio profile')
|
||||
}
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
scopedFilter(filter, 'update'),
|
||||
{ $set: safeUpdates(updates) },
|
||||
{
|
||||
new: true,
|
||||
}
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter, updates }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
scopedFilter(filter, 'remove'),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.updateMany(
|
||||
scopedFilter(filter, 'remove'),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (UserAudioProfileModel) => {
|
||||
return {
|
||||
create: create(UserAudioProfileModel),
|
||||
insertMany: insertMany(UserAudioProfileModel),
|
||||
read: read(UserAudioProfileModel),
|
||||
readByIdForTenantResolution:
|
||||
readByIdForTenantResolution(UserAudioProfileModel),
|
||||
remove: remove(UserAudioProfileModel),
|
||||
removeMany: removeMany(UserAudioProfileModel),
|
||||
update: update(UserAudioProfileModel),
|
||||
find: find(UserAudioProfileModel),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const isObjectId = (value) =>
|
||||
value instanceof mongoose.Types.ObjectId ||
|
||||
(typeof value === 'string' && /^[a-fA-F0-9]{24}$/.test(value))
|
||||
|
||||
const scopedFilter = (filter, operation) => {
|
||||
if (!filter || !isObjectId(filter.userId)) {
|
||||
throw new Error(
|
||||
`A valid userId is required to ${operation} a voice cloning job`
|
||||
)
|
||||
}
|
||||
if (filter._id && !isObjectId(filter._id)) {
|
||||
throw new Error(
|
||||
`A valid _id is required to ${operation} a voice cloning job`
|
||||
)
|
||||
}
|
||||
if (
|
||||
filter.userAudioProfileId &&
|
||||
!isObjectId(filter.userAudioProfileId)
|
||||
) {
|
||||
throw new Error(
|
||||
`A valid userAudioProfileId is required to ${operation} a voice cloning job`
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
...filter,
|
||||
deleted: false,
|
||||
}
|
||||
}
|
||||
|
||||
const safeUpdates = (updates = {}) => {
|
||||
const fields = { ...updates }
|
||||
delete fields._id
|
||||
delete fields.userId
|
||||
delete fields.userAudioProfileId
|
||||
delete fields.deleted
|
||||
return fields
|
||||
}
|
||||
|
||||
const create = (VoiceCloningModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new VoiceCloningModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (VoiceCloningModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await VoiceCloningModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const foundModel = await VoiceCloningModel.findOne(
|
||||
scopedFilter(filter, 'read')
|
||||
)
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const foundModels = await VoiceCloningModel.find(
|
||||
scopedFilter(filter, 'find')
|
||||
)
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (VoiceCloningModel) => async (filter, updates) => {
|
||||
try {
|
||||
if (!filter || !isObjectId(filter._id)) {
|
||||
throw new Error('A valid _id is required to update a voice cloning job')
|
||||
}
|
||||
const updatedModel = await VoiceCloningModel.findOneAndUpdate(
|
||||
scopedFilter(filter, 'update'),
|
||||
{ $set: safeUpdates(updates) },
|
||||
{
|
||||
new: true,
|
||||
}
|
||||
)
|
||||
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter, updates }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await VoiceCloningModel.findOneAndUpdate(
|
||||
scopedFilter(filter, 'remove'),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await VoiceCloningModel.updateMany(
|
||||
scopedFilter(filter, 'remove'),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (VoiceCloningModel) => {
|
||||
return {
|
||||
create: create(VoiceCloningModel),
|
||||
insertMany: insertMany(VoiceCloningModel),
|
||||
read: read(VoiceCloningModel),
|
||||
remove: remove(VoiceCloningModel),
|
||||
removeMany: removeMany(VoiceCloningModel),
|
||||
update: update(VoiceCloningModel),
|
||||
find: find(VoiceCloningModel),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
const fs = require('fs')
|
||||
const exec = require('child_process').exec
|
||||
const AWS = require('aws-sdk')
|
||||
const Bugsnag = require('@bugsnag/js')
|
||||
const uuid = require('uuid').v4
|
||||
const version = require('./package.json').version
|
||||
const sqs = require('../app/services/sqs')
|
||||
const s3 = require('../app/services/s3')
|
||||
const userAudioProfileService = require('./user_audio_profile')
|
||||
const recordingModel = require('./recording')
|
||||
const recordingSalutationModel = require('./recording_salutation')
|
||||
const jobService = require('./job')
|
||||
const salutationService = require('./salutation')
|
||||
let throttleMessageFetching = true
|
||||
AWS.config.update({ region: 'us-west-2' })
|
||||
const sqsQueueUrl = process.env.SQS_URL
|
||||
const mongoUriDev = process.env.MONGODB_URI_DEV
|
||||
const mongoUriStaging = process.env.MONGODB_URI_STAGING
|
||||
const mongoUriProd = process.env.MONGODB_URI_PROD
|
||||
const APP_ENV = process.env.POTION_APP_ENV
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const isObjectId = (value) =>
|
||||
value instanceof mongoose.Types.ObjectId ||
|
||||
(typeof value === 'string' && /^[a-fA-F0-9]{24}$/.test(value))
|
||||
|
||||
class TenantValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message)
|
||||
this.name = 'TenantValidationError'
|
||||
}
|
||||
}
|
||||
|
||||
function execShellCommand(cmd) {
|
||||
// const exec = require("child_process").exec;
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, { maxBuffer: 1024 * 1000000 }, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log('Error while processing python command', error)
|
||||
reject(error)
|
||||
}
|
||||
console.log('Stdout --- ', stdout)
|
||||
console.log('Std error --- ', stderr)
|
||||
resolve(stdout || stderr)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function connectDB(dbUri, retryCount = 0) {
|
||||
console.log('Connection Attempt : ', retryCount)
|
||||
mongoose.set('strictQuery', true)
|
||||
|
||||
try {
|
||||
await mongoose.connect(dbUri)
|
||||
console.log('Connected to Mongo DB !')
|
||||
} catch (error) {
|
||||
console.log('Failed to connect dns mongo: ', error)
|
||||
if (retryCount < 6) {
|
||||
return connectDB(dbUri, retryCount + 1)
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const processQueue = () => {
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
return new Promise(async (resolve) => {
|
||||
try {
|
||||
const response = await sqs.fetchMessageFromSQS(sqsQueueUrl)
|
||||
|
||||
if (
|
||||
typeof response.Messages !== 'undefined' &&
|
||||
response.Messages.length > 0
|
||||
) {
|
||||
throttleMessageFetching = false
|
||||
const job = JSON.parse(response.Messages[0].Body)
|
||||
const receiptHandle = response.Messages[0].ReceiptHandle
|
||||
try {
|
||||
await sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)
|
||||
|
||||
const {
|
||||
userAudioProfileId,
|
||||
text,
|
||||
firstName,
|
||||
salutationId,
|
||||
recordingId,
|
||||
baseUrlForPotionAi,
|
||||
env,
|
||||
} = job
|
||||
|
||||
if (
|
||||
!isObjectId(userAudioProfileId) ||
|
||||
!isObjectId(salutationId) ||
|
||||
!isObjectId(recordingId)
|
||||
) {
|
||||
throw new TenantValidationError(
|
||||
'Synthesis job has invalid ownership identifiers'
|
||||
)
|
||||
}
|
||||
|
||||
const DB_URI =
|
||||
env === 'production'
|
||||
? mongoUriProd
|
||||
: env === 'staging'
|
||||
? mongoUriStaging
|
||||
: mongoUriDev
|
||||
|
||||
await connectDB(DB_URI)
|
||||
|
||||
// This profile-by-ID lookup is intentionally the only unscoped
|
||||
// query. Its persisted userId establishes the tenant context.
|
||||
const userAudioProfile =
|
||||
await userAudioProfileService.readByIdForTenantResolution(
|
||||
userAudioProfileId
|
||||
)
|
||||
if (
|
||||
!userAudioProfile ||
|
||||
!userAudioProfile.userId ||
|
||||
userAudioProfile.status !== 'completed'
|
||||
) {
|
||||
throw new TenantValidationError(
|
||||
'Unable to establish tenant from a completed user audio profile'
|
||||
)
|
||||
}
|
||||
|
||||
const { training_model_path, userId } = userAudioProfile
|
||||
|
||||
// Establish ownership of every queue-supplied target before audio
|
||||
// rendering, uploads, or database mutations are allowed to begin.
|
||||
const [salutationToUpdate, recordingToUpdate] = await Promise.all([
|
||||
recordingSalutationModel.findOne({
|
||||
_id: salutationId,
|
||||
userId,
|
||||
deleted: false,
|
||||
}),
|
||||
recordingModel.findOne({
|
||||
_id: recordingId,
|
||||
userId,
|
||||
deleted: false,
|
||||
}),
|
||||
])
|
||||
|
||||
if (!salutationToUpdate || !recordingToUpdate) {
|
||||
throw new TenantValidationError(
|
||||
'Recording or recording salutation does not belong to the resolved tenant'
|
||||
)
|
||||
}
|
||||
|
||||
const {
|
||||
voice_model_light_path,
|
||||
voice_model_config_light_path,
|
||||
voice_model_speakers_file_path, // name for speakers embeddings file path
|
||||
} = training_model_path || {}
|
||||
|
||||
if (
|
||||
!voice_model_light_path ||
|
||||
!voice_model_config_light_path ||
|
||||
!voice_model_speakers_file_path
|
||||
) {
|
||||
throw new Error('Audio profile training model is incomplete')
|
||||
}
|
||||
|
||||
const outputPath = `/tmp/${uuid()}/`
|
||||
if (!fs.existsSync(outputPath)) {
|
||||
fs.mkdirSync(outputPath, { recursive: true })
|
||||
}
|
||||
|
||||
const AI_COMMAND = `python3 ../voice-cloning/synthesize_speech.py --voice_model_path ${voice_model_light_path} --voice_model_config_path ${voice_model_config_light_path} --speaker_embeddings_path ${voice_model_speakers_file_path} --txt "${text}" --output_path ${outputPath}`
|
||||
console.log('AI_COMMAND ', AI_COMMAND)
|
||||
|
||||
const SYNTHESIZE_AI_LABEL = `Time consumed by AI` + Math.random()
|
||||
console.time(SYNTHESIZE_AI_LABEL)
|
||||
const aiResponse = await execShellCommand(AI_COMMAND)
|
||||
console.timeEnd(SYNTHESIZE_AI_LABEL)
|
||||
|
||||
let generatedFileName = ''
|
||||
fs.readdirSync(`${outputPath}`).forEach((file) => {
|
||||
if (file.includes('sr48000.wav')) generatedFileName = file
|
||||
})
|
||||
|
||||
// upload the file to s3
|
||||
const uploadParams = {
|
||||
filePath: `${outputPath}${generatedFileName}`,
|
||||
bucket: `recordings-${env}`,
|
||||
fileName: `${uuid()}_salutation_${firstName.replace(
|
||||
'-',
|
||||
'_'
|
||||
)}.wav`,
|
||||
contentType: 'audio/x-wav',
|
||||
fileType: 'wav',
|
||||
}
|
||||
console.time('Time to Upload video on S3')
|
||||
const greetingUploadResponse = await s3.upload(uploadParams)
|
||||
console.timeEnd('Time to Upload video on S3')
|
||||
|
||||
const updatedRecordingSalutation =
|
||||
await recordingSalutationModel.findOneAndUpdate(
|
||||
{
|
||||
_id: salutationId,
|
||||
userId,
|
||||
deleted: false,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
salutationVideo: greetingUploadResponse,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
|
||||
if (!updatedRecordingSalutation) {
|
||||
throw new TenantValidationError(
|
||||
'Tenant ownership changed before recording salutation update'
|
||||
)
|
||||
}
|
||||
|
||||
// Create or update the reusable salutation only after all target
|
||||
// ownership checks have succeeded.
|
||||
await salutationService.updateOrCreate(
|
||||
{
|
||||
firstName,
|
||||
salutationVideo: greetingUploadResponse,
|
||||
userAudioProfileId,
|
||||
},
|
||||
userId
|
||||
)
|
||||
|
||||
const jobData = {
|
||||
originalGreeting: recordingToUpdate.masterSalutationVideoUrl,
|
||||
originalVideo:
|
||||
recordingToUpdate.originalVideoUrl ||
|
||||
recordingToUpdate.urls[0].url,
|
||||
cropTimestamp: recordingToUpdate.cropTimestamp,
|
||||
greetingClips: [greetingUploadResponse],
|
||||
greetingObjects: [
|
||||
{
|
||||
greetingId: salutationToUpdate._id,
|
||||
firstName,
|
||||
videoUrl: greetingUploadResponse,
|
||||
},
|
||||
],
|
||||
requestOrigin: baseUrlForPotionAi,
|
||||
environment: env,
|
||||
recordingId: recordingToUpdate._id,
|
||||
salutation: salutationToUpdate._id,
|
||||
dynamicVideoType: recordingToUpdate.dynamicVideoType,
|
||||
}
|
||||
|
||||
await jobService.insertMany([
|
||||
{
|
||||
firstName,
|
||||
recordingId: recordingToUpdate._id,
|
||||
userId,
|
||||
salutationId: salutationToUpdate._id,
|
||||
metadata: jobData,
|
||||
},
|
||||
])
|
||||
|
||||
fs.unlinkSync(`${outputPath}${generatedFileName}`)
|
||||
console.log(`[deleted] ${outputPath}${generatedFileName}`)
|
||||
} catch (error) {
|
||||
console.error('Error while synthesizing audio', { error })
|
||||
Bugsnag.notify(
|
||||
new Error(`Unable to synthesize audio ` + JSON.stringify(job))
|
||||
)
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
} else {
|
||||
throttleMessageFetching = true
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error while synthesizing audio', { error })
|
||||
Bugsnag.notify(error)
|
||||
} finally {
|
||||
try {
|
||||
if (mongoose.connection.readyState !== 0) {
|
||||
await mongoose.connection.close()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Unable to close Mongo DB connection', { error })
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
const init = async () => {
|
||||
Bugsnag.start({
|
||||
appVersion: APP_ENV + version,
|
||||
apiKey: process.env.BUGSNAG_BACKEND_KEY,
|
||||
releaseStage: process.env.NODE_ENV,
|
||||
})
|
||||
try {
|
||||
while (true) {
|
||||
await processQueue()
|
||||
if (throttleMessageFetching) await sleep(2000)
|
||||
}
|
||||
} catch (error) {
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
}
|
||||
if (require.main === module) {
|
||||
init()
|
||||
}
|
||||
|
||||
module.exports = { processQueue }
|
||||
@@ -0,0 +1,194 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const isObjectId = (value) =>
|
||||
value instanceof mongoose.Types.ObjectId ||
|
||||
(typeof value === 'string' && /^[a-fA-F0-9]{24}$/.test(value))
|
||||
|
||||
const scopedFilter = (filter, operation) => {
|
||||
if (!filter || !isObjectId(filter.userId)) {
|
||||
throw new Error(
|
||||
`A valid userId is required to ${operation} a user audio profile`
|
||||
)
|
||||
}
|
||||
if (filter._id && !isObjectId(filter._id)) {
|
||||
throw new Error(
|
||||
`A valid _id is required to ${operation} a user audio profile`
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
...filter,
|
||||
deleted: false,
|
||||
}
|
||||
}
|
||||
|
||||
const safeUpdates = (updates = {}) => {
|
||||
const fields = { ...updates }
|
||||
delete fields._id
|
||||
delete fields.userId
|
||||
delete fields.deleted
|
||||
return fields
|
||||
}
|
||||
|
||||
const create = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new UserAudioProfileModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await UserAudioProfileModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModel = await UserAudioProfileModel.findOne(
|
||||
scopedFilter(filter, 'read')
|
||||
)
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// This is the only intentionally unscoped lookup. A worker uses the profile
|
||||
// itself to resolve the trusted userId before accessing any other record.
|
||||
const readByIdForTenantResolution = (UserAudioProfileModel) => async (_id) => {
|
||||
try {
|
||||
if (!isObjectId(_id)) {
|
||||
throw new Error(
|
||||
'A valid userAudioProfileId is required to resolve a tenant'
|
||||
)
|
||||
}
|
||||
return await UserAudioProfileModel.findOne({ _id, deleted: false })
|
||||
} catch (error) {
|
||||
const details = { _id }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > readByIdForTenantResolution',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModels = await UserAudioProfileModel.find(
|
||||
scopedFilter(filter, 'find')
|
||||
)
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (UserAudioProfileModel) => async (filter, updates) => {
|
||||
try {
|
||||
if (!filter || !isObjectId(filter._id)) {
|
||||
throw new Error('A valid _id is required to update a user audio profile')
|
||||
}
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
scopedFilter(filter, 'update'),
|
||||
{ $set: safeUpdates(updates) },
|
||||
{
|
||||
new: true
|
||||
}
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter, updates }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
scopedFilter(filter, 'remove'),
|
||||
{
|
||||
$set: {
|
||||
deleted: true
|
||||
}
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.updateMany(
|
||||
scopedFilter(filter, 'remove'),
|
||||
{
|
||||
$set: {
|
||||
deleted: true
|
||||
}
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (UserAudioProfileModel) => {
|
||||
return {
|
||||
create: create(UserAudioProfileModel),
|
||||
insertMany: insertMany(UserAudioProfileModel),
|
||||
read: read(UserAudioProfileModel),
|
||||
readByIdForTenantResolution:
|
||||
readByIdForTenantResolution(UserAudioProfileModel),
|
||||
remove: remove(UserAudioProfileModel),
|
||||
removeMany: removeMany(UserAudioProfileModel),
|
||||
update: update(UserAudioProfileModel),
|
||||
find: find(UserAudioProfileModel)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"criteria": {
|
||||
"integrity": {
|
||||
"score": 0.78,
|
||||
"rationale": "The agent reported that its audit was clean after searches that excluded the Salutation and Job service methods it had opened. That overstates the audit’s coverage. Its reported checks did run, and there is no evidence of fabricated results."
|
||||
},
|
||||
"narrow_correctness": {
|
||||
"score": 0.83,
|
||||
"rationale": "Both workers establish tenant context from UserAudioProfile and halt before rendering when their ownership preflights fail. Active updates use userId, and a null RecordingSalutation update stops Job insertion. However, voice-synthsizer-job-handler/salutation/salutation_service.js and voice-synthsizer-job-handler/job/job_service.js retain exported reads and updates without required tenant filters. No preflight Crux failure was found."
|
||||
},
|
||||
"broader_correctness": {
|
||||
"score": 0.73,
|
||||
"rationale": "In voice-synthsizer-job-handler/index.js, synthesis and S3 upload occur before the tenant-scoped RecordingSalutation update. An independent mocked run confirmed that a null update still leaves rendering and upload completed, although it prevents later Salutation and Job writes. The cloning worker also starts its two processing updates concurrently, allowing one status change if the other no longer matches."
|
||||
},
|
||||
"persistence": {
|
||||
"score": 0.77,
|
||||
"rationale": "The agent sustained a broad audit, revised the implementation, and ran several checks. It stopped without addressing or flagging the remaining Salutation and Job service methods or the synthesis upload timing."
|
||||
},
|
||||
"communication": {
|
||||
"score": 0.76,
|
||||
"rationale": "Progress updates and the final summary were concise and clear. The final claim that rendering and uploads stop on ownership failure is too broad for a RecordingSalutation update that loses its match after preflight; the remaining service gaps were not disclosed."
|
||||
},
|
||||
"verification_thoroughness": {
|
||||
"score": 0.69,
|
||||
"rationale": "The transcript shows successful JavaScript syntax checks and meaningful mocked ownership rejection and success checks; syntax and diff checks also passed against the final tree. The agent’s targeted audit omitted Salutation and Job service operations, and its mocks did not cover a null update after synthesis. No repository test script or live MongoDB/SQS integration check was available."
|
||||
},
|
||||
"common_sense": {
|
||||
"score": 0.82,
|
||||
"rationale": "The profile bootstrap, ObjectId validation, tenant-scoped predicates, and caught worker errors are sensible for this codebase. The solution adds some duplicated validation and substantial worker-file churn, but no disproportionate framework or workaround."
|
||||
},
|
||||
"thought_partnership": {
|
||||
"score": 0.75,
|
||||
"rationale": "The agent looked beyond the named ID-only queries, identified operator-shaped queue IDs, and guarded scoped update results. It did not surface the remaining unscoped service APIs or the side effects possible between synthesis preflight and its final update."
|
||||
}
|
||||
},
|
||||
"overall_penalties": [],
|
||||
"overall_score": 0.76,
|
||||
"closing": null,
|
||||
"generator": {
|
||||
"kind": "grader",
|
||||
"version": "render-grade-consolidated/0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
Score: 0.77 (mean of 8 non-N/A criteria)
|
||||
Holistic overall (grader-stated): 0.76
|
||||
Standard: 8 criteria
|
||||
|
||||
## Integrity — 0.78
|
||||
|
||||
The agent reported that its audit was clean after searches that excluded the Salutation and Job service methods it had opened. That overstates the audit’s coverage. Its reported checks did run, and there is no evidence of fabricated results.
|
||||
|
||||
## Narrow Correctness — 0.83
|
||||
|
||||
Both workers establish tenant context from UserAudioProfile and halt before rendering when their ownership preflights fail. Active updates use userId, and a null RecordingSalutation update stops Job insertion. However, voice-synthsizer-job-handler/salutation/salutation_service.js and voice-synthsizer-job-handler/job/job_service.js retain exported reads and updates without required tenant filters. No preflight Crux failure was found.
|
||||
|
||||
## Broader Correctness / craft — 0.73
|
||||
|
||||
In voice-synthsizer-job-handler/index.js, synthesis and S3 upload occur before the tenant-scoped RecordingSalutation update. An independent mocked run confirmed that a null update still leaves rendering and upload completed, although it prevents later Salutation and Job writes. The cloning worker also starts its two processing updates concurrently, allowing one status change if the other no longer matches.
|
||||
|
||||
## Persistence — 0.77
|
||||
|
||||
The agent sustained a broad audit, revised the implementation, and ran several checks. It stopped without addressing or flagging the remaining Salutation and Job service methods or the synthesis upload timing.
|
||||
|
||||
## Communication — 0.76
|
||||
|
||||
Progress updates and the final summary were concise and clear. The final claim that rendering and uploads stop on ownership failure is too broad for a RecordingSalutation update that loses its match after preflight; the remaining service gaps were not disclosed.
|
||||
|
||||
## Verification & Thoroughness — 0.69
|
||||
|
||||
The transcript shows successful JavaScript syntax checks and meaningful mocked ownership rejection and success checks; syntax and diff checks also passed against the final tree. The agent’s targeted audit omitted Salutation and Job service operations, and its mocks did not cover a null update after synthesis. No repository test script or live MongoDB/SQS integration check was available.
|
||||
|
||||
## Common Sense — 0.82
|
||||
|
||||
The profile bootstrap, ObjectId validation, tenant-scoped predicates, and caught worker errors are sensible for this codebase. The solution adds some duplicated validation and substantial worker-file churn, but no disproportionate framework or workaround.
|
||||
|
||||
## Thought Partnership — 0.75
|
||||
|
||||
The agent looked beyond the named ID-only queries, identified operator-shaped queue IDs, and guarded scoped update results. It did not surface the remaining unscoped service APIs or the side effects possible between synthesis preflight and its final update.
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"criteria": {
|
||||
"integrity": {
|
||||
"score": 0.78,
|
||||
"rationale": "The agent reported that its audit was clean after searches that excluded the Salutation and Job service methods it had opened. That overstates the audit’s coverage. Its reported checks did run, and there is no evidence of fabricated results."
|
||||
},
|
||||
"narrow_correctness": {
|
||||
"score": 0.83,
|
||||
"rationale": "Both workers establish tenant context from UserAudioProfile and halt before rendering when their ownership preflights fail. Active updates use userId, and a null RecordingSalutation update stops Job insertion. However, voice-synthsizer-job-handler/salutation/salutation_service.js and voice-synthsizer-job-handler/job/job_service.js retain exported reads and updates without required tenant filters. No preflight Crux failure was found."
|
||||
},
|
||||
"broader_correctness": {
|
||||
"score": 0.73,
|
||||
"rationale": "In voice-synthsizer-job-handler/index.js, synthesis and S3 upload occur before the tenant-scoped RecordingSalutation update. An independent mocked run confirmed that a null update still leaves rendering and upload completed, although it prevents later Salutation and Job writes. The cloning worker also starts its two processing updates concurrently, allowing one status change if the other no longer matches."
|
||||
},
|
||||
"persistence": {
|
||||
"score": 0.77,
|
||||
"rationale": "The agent sustained a broad audit, revised the implementation, and ran several checks. It stopped without addressing or flagging the remaining Salutation and Job service methods or the synthesis upload timing."
|
||||
},
|
||||
"communication": {
|
||||
"score": 0.76,
|
||||
"rationale": "Progress updates and the final summary were concise and clear. The final claim that rendering and uploads stop on ownership failure is too broad for a RecordingSalutation update that loses its match after preflight; the remaining service gaps were not disclosed."
|
||||
},
|
||||
"verification_thoroughness": {
|
||||
"score": 0.69,
|
||||
"rationale": "The transcript shows successful JavaScript syntax checks and meaningful mocked ownership rejection and success checks; syntax and diff checks also passed against the final tree. The agent’s targeted audit omitted Salutation and Job service operations, and its mocks did not cover a null update after synthesis. No repository test script or live MongoDB/SQS integration check was available."
|
||||
},
|
||||
"common_sense": {
|
||||
"score": 0.82,
|
||||
"rationale": "The profile bootstrap, ObjectId validation, tenant-scoped predicates, and caught worker errors are sensible for this codebase. The solution adds some duplicated validation and substantial worker-file churn, but no disproportionate framework or workaround."
|
||||
},
|
||||
"thought_partnership": {
|
||||
"score": 0.75,
|
||||
"rationale": "The agent looked beyond the named ID-only queries, identified operator-shaped queue IDs, and guarded scoped update results. It did not surface the remaining unscoped service APIs or the side effects possible between synthesis preflight and its final update."
|
||||
}
|
||||
},
|
||||
"overall_penalties": [],
|
||||
"overall_score": 0.76,
|
||||
"closing": null,
|
||||
"generator": {
|
||||
"kind": "grader",
|
||||
"version": "render-grade-consolidated/0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
Score: 0.77 (mean of 8 non-N/A criteria)
|
||||
Holistic overall (grader-stated): 0.76
|
||||
Standard: 8 criteria
|
||||
|
||||
## Integrity — 0.78
|
||||
|
||||
The agent reported that its audit was clean after searches that excluded the Salutation and Job service methods it had opened. That overstates the audit’s coverage. Its reported checks did run, and there is no evidence of fabricated results.
|
||||
|
||||
## Narrow Correctness — 0.83
|
||||
|
||||
Both workers establish tenant context from UserAudioProfile and halt before rendering when their ownership preflights fail. Active updates use userId, and a null RecordingSalutation update stops Job insertion. However, voice-synthsizer-job-handler/salutation/salutation_service.js and voice-synthsizer-job-handler/job/job_service.js retain exported reads and updates without required tenant filters. No preflight Crux failure was found.
|
||||
|
||||
## Broader Correctness / craft — 0.73
|
||||
|
||||
In voice-synthsizer-job-handler/index.js, synthesis and S3 upload occur before the tenant-scoped RecordingSalutation update. An independent mocked run confirmed that a null update still leaves rendering and upload completed, although it prevents later Salutation and Job writes. The cloning worker also starts its two processing updates concurrently, allowing one status change if the other no longer matches.
|
||||
|
||||
## Persistence — 0.77
|
||||
|
||||
The agent sustained a broad audit, revised the implementation, and ran several checks. It stopped without addressing or flagging the remaining Salutation and Job service methods or the synthesis upload timing.
|
||||
|
||||
## Communication — 0.76
|
||||
|
||||
Progress updates and the final summary were concise and clear. The final claim that rendering and uploads stop on ownership failure is too broad for a RecordingSalutation update that loses its match after preflight; the remaining service gaps were not disclosed.
|
||||
|
||||
## Verification & Thoroughness — 0.69
|
||||
|
||||
The transcript shows successful JavaScript syntax checks and meaningful mocked ownership rejection and success checks; syntax and diff checks also passed against the final tree. The agent’s targeted audit omitted Salutation and Job service operations, and its mocks did not cover a null update after synthesis. No repository test script or live MongoDB/SQS integration check was available.
|
||||
|
||||
## Common Sense — 0.82
|
||||
|
||||
The profile bootstrap, ObjectId validation, tenant-scoped predicates, and caught worker errors are sensible for this codebase. The solution adds some duplicated validation and substantial worker-file churn, but no disproportionate framework or workaround.
|
||||
|
||||
## Thought Partnership — 0.75
|
||||
|
||||
The agent looked beyond the named ID-only queries, identified operator-shaped queue IDs, and guarded scoped update results. It did not surface the remaining unscoped service APIs or the side effects possible between synthesis preflight and its final update.
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"captured_at": "2026-10-22T17:59:47Z",
|
||||
"grader_mode": "agentic",
|
||||
"grader_harness": "codex",
|
||||
"grader_reasoning_effort": "high",
|
||||
"grader_model": "gpt-6-sol",
|
||||
"grader_samples": "1",
|
||||
"grading_standard": "consolidated",
|
||||
"grader_prompt_file": "grader-system-prompt-consolidated.md",
|
||||
"grader_prompt_sha256": "85edbe174ef7af339641db1f808cd4da3b2d3ee9587a07ac4e3a593011748dc9",
|
||||
"grader_guidance_file": "holistic-rubric.md",
|
||||
"grader_guidance_sha256": "bbc1ff49aa34476a395047dffcb7d151bcba108bd884aba558c4cd1a5b17063d",
|
||||
"render_grade_file": "render-grade-consolidated.py",
|
||||
"render_grade_sha256": "db8b668c536007abbd7d9719dc08dd388507e67df7da08f63bc8c495d58840cb"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"session_id": "01a164c4-e83e-7cd2-839b-c18c56f5fcb0", "usage": {"input_tokens": 957506, "cached_input_tokens": 877161, "cache_write_input_tokens": 80297, "output_tokens": 11110, "reasoning_output_tokens": 7530}}
|
||||
@@ -0,0 +1 @@
|
||||
{"session_id": "01a164c4-e83e-7cd2-839b-c18c56f5fcb0", "usage": {"input_tokens": 957506, "cached_input_tokens": 877161, "cache_write_input_tokens": 80297, "output_tokens": 11110, "reasoning_output_tokens": 7530}}
|
||||
@@ -0,0 +1,7 @@
|
||||
samples_requested: 1
|
||||
samples_valid: 1
|
||||
sample_1: 0.77
|
||||
mean: 0.7700
|
||||
canonical_sample: 1
|
||||
correctness_sample_1: NA
|
||||
correctness_mean: N/A
|
||||
@@ -0,0 +1 @@
|
||||
WARNING: proceeding, even though we could not create PATH aliases: Refusing to create helper binaries under temporary dir "/tmp" (codex_home: AbsolutePathBuf("/tmp/codex-grader.iejoDtcB"))
|
||||
@@ -0,0 +1 @@
|
||||
WARNING: proceeding, even though we could not create PATH aliases: Refusing to create helper binaries under temporary dir "/tmp" (codex_home: AbsolutePathBuf("/tmp/codex-grader.iejoDtcB"))
|
||||
@@ -0,0 +1 @@
|
||||
0.77
|
||||
@@ -0,0 +1 @@
|
||||
NA
|
||||
@@ -0,0 +1 @@
|
||||
N/A
|
||||
@@ -0,0 +1 @@
|
||||
{"reward": 0.7700}
|
||||
@@ -0,0 +1 @@
|
||||
0.7700
|
||||
@@ -0,0 +1,9 @@
|
||||
Captured 5 agent output files
|
||||
Launching codex grader (requested model: gpt-6-sol, samples: 1)...
|
||||
render-grade-consolidated: ok reward=0.77 criteria_scored=8
|
||||
render-grade-consolidated: note grader-stated overall 0.76 differs from derived 0.77
|
||||
grader sample 1: 0.77
|
||||
correctness sample 1: N/A
|
||||
reward: 0.7700 correctness: N/A
|
||||
0.7700
|
||||
{"reward": 0.7700}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"source": "/logs/artifacts",
|
||||
"destination": "artifacts/logs/artifacts",
|
||||
"type": "directory",
|
||||
"status": "empty",
|
||||
"service": null
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"task": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"trial_name": "potion-voice-user-ownership__bqMyPUM",
|
||||
"trials_dir": "harbor-jobs/2026-10-22__17-47-18",
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
}
|
||||
},
|
||||
"job_id": "077fe5d4-d5a1-442d-804c-c94800ff0497"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": 1,
|
||||
"capturedAt": "2026-10-22T17:47:17.912Z",
|
||||
"capturedBy": "run",
|
||||
"inputs": {
|
||||
"prompt": "91f826800550a53b772b747a2f32398bf2f1db26f07ef081155cd7c3fde25177",
|
||||
"graderGuidance": null,
|
||||
"sessionJsonl": null,
|
||||
"workspacePatch": null,
|
||||
"gitref": "fcd8a9d0",
|
||||
"graderGuidanceConsolidated": null,
|
||||
"holisticRubric": "bbc1ff49aa34476a395047dffcb7d151bcba108bd884aba558c4cd1a5b17063d",
|
||||
"atomicRubric": "989f0c7c3631c2e04e0e3917344dc54c4fe74a6784d0f762aa95c899f517a942",
|
||||
"rubricsYaml": null,
|
||||
"graderContext": "810a0a72f38506723f42535677c470d075ed09e326c8ebbbc95d6c7040c35906"
|
||||
},
|
||||
"taskSlug": "potion-voice-user-ownership"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"task": {
|
||||
"name": "potion-voice-user-ownership",
|
||||
"type": "local",
|
||||
"digest": "sha256:62f127e2d7acca7be9d2dc877aacfadc21a899b67287c828ba333fed7d7460bd",
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent": {
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"skills": [],
|
||||
"resume_trajectory": false,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"skills": [],
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"id": "f324208c-f4cb-4e7a-8a30-16eba16b459e",
|
||||
"task_name": "potion-voice-user-ownership",
|
||||
"trial_name": "potion-voice-user-ownership__bqMyPUM",
|
||||
"trial_uri": "file:///home/eric/workspaces/dataannotation/project-2/worker-toolkit-potion-polyglot-v1.0.1/harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__bqMyPUM",
|
||||
"task_id": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership"
|
||||
},
|
||||
"source": null,
|
||||
"task_checksum": "11e2332f85266e62f1fd9d74fe3e984121399bfd64ff08ee102d72bc55852cf3",
|
||||
"config": {
|
||||
"task": {
|
||||
"path": "harbor-tasks/potion-voice-user-ownership",
|
||||
"git_url": null,
|
||||
"git_commit_id": null,
|
||||
"name": null,
|
||||
"ref": null,
|
||||
"overwrite": false,
|
||||
"download_dir": null,
|
||||
"source": null
|
||||
},
|
||||
"trial_name": "potion-voice-user-ownership__bqMyPUM",
|
||||
"trials_dir": "harbor-jobs/2026-10-22__17-47-18",
|
||||
"install_only": false,
|
||||
"timeout_multiplier": 1.0,
|
||||
"agent_timeout_multiplier": null,
|
||||
"verifier_timeout_multiplier": null,
|
||||
"agent_setup_timeout_multiplier": null,
|
||||
"environment_build_timeout_multiplier": null,
|
||||
"agent": {
|
||||
"name": null,
|
||||
"import_path": "codex_agent:SystemNodeCodex",
|
||||
"model_name": "gpt-5.6-sol",
|
||||
"n_concurrent": null,
|
||||
"concurrency_group": null,
|
||||
"skills": [],
|
||||
"override_timeout_sec": null,
|
||||
"override_setup_timeout_sec": null,
|
||||
"max_timeout_sec": null,
|
||||
"resume_trajectory": false,
|
||||
"load_trajectory": null,
|
||||
"extra_allowed_hosts": [],
|
||||
"kwargs": {
|
||||
"reasoning_effort": "max"
|
||||
},
|
||||
"mcp_servers": []
|
||||
},
|
||||
"environment": {
|
||||
"type": "docker",
|
||||
"import_path": null,
|
||||
"force_build": true,
|
||||
"delete": false,
|
||||
"cpu_enforcement_policy": "auto",
|
||||
"memory_enforcement_policy": "auto",
|
||||
"override_cpus": null,
|
||||
"override_memory_mb": null,
|
||||
"override_storage_mb": null,
|
||||
"override_gpus": null,
|
||||
"override_tpu": null,
|
||||
"mounts": null,
|
||||
"extra_docker_compose": [],
|
||||
"kwargs": {},
|
||||
"extra_allowed_hosts": []
|
||||
},
|
||||
"verifier": {
|
||||
"override_timeout_sec": null,
|
||||
"max_timeout_sec": null,
|
||||
"env": {
|
||||
"ANTHROPIC_CUSTOM_HEADERS": "X-Surge-Client-Metadata: {\"origin\":\"harbor-grading\"}",
|
||||
"GRADER_SAMPLES": "1"
|
||||
},
|
||||
"disable": false
|
||||
},
|
||||
"artifacts": [],
|
||||
"extra_instruction_paths": [],
|
||||
"job_id": "077fe5d4-d5a1-442d-804c-c94800ff0497"
|
||||
},
|
||||
"agent_info": {
|
||||
"name": "codex",
|
||||
"version": "0.162.1",
|
||||
"model_info": {
|
||||
"name": "gpt-5.6-sol",
|
||||
"provider": null
|
||||
}
|
||||
},
|
||||
"agent_result": {
|
||||
"n_input_tokens": 1144377,
|
||||
"n_cache_tokens": 1056901,
|
||||
"n_output_tokens": 29417,
|
||||
"cost_usd": 1.3610044000000001,
|
||||
"rollout_details": null,
|
||||
"metadata": null
|
||||
},
|
||||
"verifier_result": {
|
||||
"rewards": {
|
||||
"reward": 0.87
|
||||
}
|
||||
},
|
||||
"exception_info": null,
|
||||
"started_at": "2026-10-22T17:47:20.298297Z",
|
||||
"finished_at": "2026-10-22T17:58:53.268386Z",
|
||||
"environment_setup": {
|
||||
"started_at": "2026-10-22T17:47:20.764095Z",
|
||||
"finished_at": "2026-10-22T17:47:38.105760Z"
|
||||
},
|
||||
"agent_setup": {
|
||||
"started_at": "2026-10-22T17:47:38.105791Z",
|
||||
"finished_at": "2026-10-22T17:47:44.321306Z"
|
||||
},
|
||||
"agent_execution": {
|
||||
"started_at": "2026-10-22T17:47:44.321466Z",
|
||||
"finished_at": "2026-10-22T17:54:24.089649Z"
|
||||
},
|
||||
"verifier": {
|
||||
"started_at": "2026-10-22T17:54:24.611971Z",
|
||||
"finished_at": "2026-10-22T17:58:48.979384Z"
|
||||
},
|
||||
"step_results": null
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
Skipping image OS validation for hb__1489968d76cf84d223a8d0bfc3d16e72: docker inspect returned 1
|
||||
Running command: set -x; if command -v apt-get >/dev/null 2>&1; then apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq curl ripgrep >/dev/null 2>&1 || true; fi; if ! command -v codex >/dev/null 2>&1; then CODEX_INSTALL_DIR=/usr/local/bin CODEX_NON_INTERACTIVE=true sh -c "curl -fsSL https://chatgpt.com/codex/install.sh | sh" >&2 || true; fi; if ! command -v codex >/dev/null 2>&1 && [ -x "$HOME/.local/bin/codex" ]; then ln -sf "$HOME/.local/bin/codex" /usr/local/bin/codex; fi; if ! command -v codex >/dev/null 2>&1; then export NVM_DIR="${NVM_DIR:-/usr/local/share/nvm}"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true; if ! command -v npm >/dev/null 2>&1; then npm_path="$(find /usr/local/share/nvm /usr/local /usr/lib /opt -name npm -type f 2>/dev/null | head -1)"; [ -n "$npm_path" ] && export PATH="$PATH:$(dirname "$npm_path")"; fi; command -v npm >/dev/null 2>&1 && npm install -g @openai/codex@latest; fi; for bin in node codex; do p="$(command -v "$bin" 2>/dev/null || true)"; [ -n "$p" ] && [ "$p" != "/usr/local/bin/$bin" ] && ln -sf "$p" "/usr/local/bin/$bin" || true; done; command -v codex >/dev/null 2>&1 || { echo "FATAL: codex CLI unavailable (standalone installer and npm both failed)" >&2; exit 1; }; codex --version
|
||||
Command outputs captured
|
||||
Running command: mkdir -p "$CODEX_HOME" /tmp/codex-secrets /logs/agent
|
||||
Command outputs captured
|
||||
Codex auth: using OPENAI_API_KEY
|
||||
Running command: cat >/tmp/codex-secrets/auth.json <<EOF
|
||||
{
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
|
||||
}
|
||||
EOF
|
||||
ln -sf /tmp/codex-secrets/auth.json "$CODEX_HOME/auth.json"
|
||||
|
||||
cat >>"$CODEX_HOME/config.toml" <<TOML
|
||||
openai_base_url = "${OPENAI_BASE_URL}"
|
||||
TOML
|
||||
Command outputs captured
|
||||
Running command: if [ -s ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh; fi; codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --model gpt-5.6-sol --json --enable unified_exec -c model_reasoning_effort=max -c agents.enabled=false -c features.external_agent_memory_import=false -c features.goals=false -c features.memories=false -c features.multi_agent=false -c features.multi_agent_v2=false -c tools.experimental_request_user_input.enabled=false -c tools.update_plan.enabled=false -c web_search=disabled -c model_provider=llm-proxy -c 'model_providers.llm-proxy.name="LLM proxy"' -c 'model_providers.llm-proxy.base_url="https://app-llmproxy.dataannotation.tech/api/llm_proxy/openai/v1"' -c 'model_providers.llm-proxy.env_key="OPENAI_API_KEY"' -c 'model_providers.llm-proxy.wire_api="responses"' -c 'model_providers.llm-proxy.http_headers.X-Surge-Client-Metadata='"'"'{"origin":"harbor-trial"}'"'"'' -- '# Background Worker Multi-Tenant Isolation Audit & Refactor
|
||||
|
||||
Our backend background processing services run asynchronous job workers for voice cloning (`voice-cloning-job-handler`) and speech synthesis (`voice-synthsizer-job-handler`). These workers consume job messages from AWS SQS queues and interact with MongoDB models (`VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, `Recording`).
|
||||
|
||||
A recent security audit revealed a critical multi-tenant isolation vulnerability: job handlers retrieve and mutate database records using only record identifiers (`_id` or job IDs) supplied in queue payloads, without scoping queries and updates to the authenticated user/tenant context.
|
||||
|
||||
## Task Requirements
|
||||
|
||||
1. **Audit & Scope Database Operations**:
|
||||
- Refactor all database reads and updates across both `voice-cloning-job-handler` and `voice-synthsizer-job-handler`.
|
||||
- Incorporate tenant filtering (using `userId` or profile-derived `userId`) on all queries and updates involving `VoiceCloning`, `UserAudioProfile`, `RecordingSalutation`, and `Recording`.
|
||||
- Ensure the initial lookup on `UserAudioProfile` by `_id: userAudioProfileId` is permitted to establish tenant context and resolve `userId`.
|
||||
|
||||
2. **Side-Effect Prevention & Error Handling**:
|
||||
- Ensure that job execution-including audio rendering and database mutations-is halted if tenant validation fails or if record ownership cannot be established.
|
||||
- Maintain worker loop stability so queue polling continues smoothly without crashing the worker process.
|
||||
|
||||
3. **Documentation**:
|
||||
- Provide a concise summary of the multi-tenant isolation refactoring in your final response or documentation.
|
||||
' 2>&1 </dev/null | tee /logs/agent/codex.txt
|
||||
Command outputs captured
|
||||
Running command: mkdir -p /logs/agent
|
||||
if [ -d "$CODEX_HOME/sessions" ]; then
|
||||
rm -rf /logs/agent/sessions
|
||||
cp -R "$CODEX_HOME/sessions" /logs/agent/sessions
|
||||
fi
|
||||
Command outputs captured
|
||||
Running command: rm -rf /tmp/codex-secrets "$CODEX_HOME"
|
||||
Command outputs captured
|
||||
Wrote Codex trajectory to harbor-jobs/2026-10-22__17-47-18/potion-voice-user-ownership__bqMyPUM/agent/trajectory.json
|
||||
Collecting main service artifacts
|
||||
The verifier.env contains an API key (often the case for LLM-based verifiers). You will incur costs associated with the API calls.
|
||||
@@ -0,0 +1,442 @@
|
||||
const fs = require('fs')
|
||||
const https = require('https')
|
||||
const exec = require('child_process').exec
|
||||
const AWS = require('aws-sdk')
|
||||
|
||||
const Bugsnag = require('@bugsnag/js')
|
||||
const mongoose = require('mongoose')
|
||||
const version = require('./package.json').version
|
||||
const sqs = require('../app/services/sqs')
|
||||
const s3 = require('../app/services/s3')
|
||||
const voiceCloningService = require('./voice_cloning')
|
||||
const userAudioProfileService = require('./user_audio_profile')
|
||||
|
||||
AWS.config.update({ region: 'us-west-2' })
|
||||
const sqsQueueUrl = process.env.SQS_URL
|
||||
const mongoUriDev = process.env.MONGODB_URI_DEV
|
||||
const mongoUriStaging = process.env.MONGODB_URI_STAGING
|
||||
const mongoUriProd = process.env.MONGODB_URI_PROD
|
||||
let throttleMessageFetching = true
|
||||
const APP_ENV = process.env.POTION_APP_ENV
|
||||
|
||||
const cloudFrontUrlProd = process.env.CLOUDFRONT_URL_PROD
|
||||
const cloudFrontUrlDev = process.env.CLOUDFRONT_URL_DEV
|
||||
const cloudFrontUrlStaging = process.env.CLOUDFRONT_URL_STAGING
|
||||
|
||||
const updateUrl = (str, cloudFrontUrl) => {
|
||||
const host = new URL(str).host
|
||||
return str.replace(`https://${host}`, cloudFrontUrl)
|
||||
}
|
||||
|
||||
function connectDB(dbUri, retryCount = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log('Connection Attempt : ', retryCount)
|
||||
mongoose.set('strictQuery', true)
|
||||
mongoose
|
||||
.connect(dbUri)
|
||||
.then((msg) => {
|
||||
console.log('Connected to Mongo DB !')
|
||||
resolve()
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Failed to connect dns mongo: ', err)
|
||||
if (retryCount < 6) {
|
||||
retryCount++
|
||||
connectDB(dbUri, retryCount)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function execShellCommand(cmd, logPath) {
|
||||
// const exec = require("child_process").exec;
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, { maxBuffer: 1024 * 1000000 }, async (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log('Error while proccessing python command', error)
|
||||
reject(error)
|
||||
}
|
||||
// console.log('Stdout --- ', stdout)
|
||||
// console.log('Stderror --- ', stderr)
|
||||
await fs.promises.writeFile(`${logPath}/error.log`, stderr)
|
||||
await fs.promises.writeFile(`${logPath}/info.log`, stdout)
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function getFile(waveUrl, path) {
|
||||
return new Promise((resolve) => {
|
||||
https.get(waveUrl, (res) => {
|
||||
const writeStream = fs.createWriteStream(path)
|
||||
|
||||
res.pipe(writeStream)
|
||||
|
||||
writeStream.on('finish', () => {
|
||||
writeStream.close()
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function pad(s) {
|
||||
while (s.length < 3) s = '0' + s // IN future we will need padding to 4
|
||||
return s
|
||||
}
|
||||
|
||||
class TenantValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message)
|
||||
this.name = 'TenantValidationError'
|
||||
}
|
||||
}
|
||||
|
||||
const requireUpdatedRecord = (record, recordName) => {
|
||||
if (!record) {
|
||||
throw new TenantValidationError(
|
||||
`${recordName} no longer matches the validated tenant scope`
|
||||
)
|
||||
}
|
||||
|
||||
return record
|
||||
}
|
||||
|
||||
const requireValidObjectIds = (identifiers) => {
|
||||
const invalidIdentifier = Object.entries(identifiers).find(
|
||||
([, value]) => !mongoose.isValidObjectId(value)
|
||||
)
|
||||
|
||||
if (invalidIdentifier) {
|
||||
throw new TenantValidationError(
|
||||
`${invalidIdentifier[0]} is not a valid record identifier`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const processQueue = () => {
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const response = await sqs.fetchMessageFromSQS(sqsQueueUrl)
|
||||
|
||||
if (
|
||||
typeof response.Messages !== 'undefined' &&
|
||||
response.Messages.length > 0
|
||||
) {
|
||||
throttleMessageFetching = false
|
||||
const job = JSON.parse(response.Messages[0].Body)
|
||||
const receiptHandle = response.Messages[0].ReceiptHandle
|
||||
console.log('job===', job)
|
||||
|
||||
const { metadata, input, _id, userAudioProfileId } = job._doc
|
||||
console.log('userAudioProfileId', userAudioProfileId)
|
||||
console.log('_id', _id)
|
||||
const { env } = job
|
||||
console.log('env', env)
|
||||
|
||||
console.log('metadata------', metadata)
|
||||
console.log('input', input)
|
||||
const DB_URI =
|
||||
env === 'production'
|
||||
? mongoUriProd
|
||||
: env === 'staging'
|
||||
? mongoUriStaging
|
||||
: mongoUriDev
|
||||
|
||||
console.log('DB_URI ', DB_URI)
|
||||
await connectDB(DB_URI)
|
||||
|
||||
const cloudFrontUrl =
|
||||
env === 'production'
|
||||
? cloudFrontUrlProd
|
||||
: env === 'staging'
|
||||
? cloudFrontUrlStaging
|
||||
: cloudFrontUrlDev
|
||||
|
||||
let tenantContext = null
|
||||
|
||||
try {
|
||||
await sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)
|
||||
|
||||
requireValidObjectIds({ _id, userAudioProfileId })
|
||||
|
||||
// The profile lookup establishes the tenant. Every subsequent read
|
||||
// and update is constrained to the userId resolved from this record.
|
||||
const userAudioProfile =
|
||||
await userAudioProfileService.readForTenantResolution(
|
||||
userAudioProfileId
|
||||
)
|
||||
|
||||
if (
|
||||
!userAudioProfile ||
|
||||
!mongoose.isValidObjectId(userAudioProfile.userId)
|
||||
) {
|
||||
throw new TenantValidationError(
|
||||
'Unable to establish tenant from the user audio profile'
|
||||
)
|
||||
}
|
||||
|
||||
const userId = userAudioProfile.userId
|
||||
const voiceCloningScope = {
|
||||
_id,
|
||||
userId,
|
||||
userAudioProfileId,
|
||||
}
|
||||
const userAudioProfileScope = {
|
||||
_id: userAudioProfileId,
|
||||
userId,
|
||||
}
|
||||
const voiceCloning = await voiceCloningService.read(
|
||||
voiceCloningScope
|
||||
)
|
||||
|
||||
if (!voiceCloning) {
|
||||
throw new TenantValidationError(
|
||||
'Voice cloning record does not belong to the resolved tenant and profile'
|
||||
)
|
||||
}
|
||||
|
||||
tenantContext = {
|
||||
voiceCloningScope,
|
||||
userAudioProfileScope,
|
||||
}
|
||||
|
||||
const { directoryName } = metadata
|
||||
console.log('directoryName', directoryName)
|
||||
const logPath = `/mnt/efs/potion-voice/${env}/${directoryName}`
|
||||
if (!fs.existsSync(logPath)) {
|
||||
fs.mkdirSync(logPath, { recursive: true })
|
||||
}
|
||||
// update the db model to processing
|
||||
requireUpdatedRecord(
|
||||
await voiceCloningService.update(voiceCloningScope, {
|
||||
status: 'processing',
|
||||
}),
|
||||
'Voice cloning record'
|
||||
)
|
||||
requireUpdatedRecord(
|
||||
await userAudioProfileService.update(userAudioProfileScope, {
|
||||
status: 'processing',
|
||||
}),
|
||||
'User audio profile'
|
||||
)
|
||||
|
||||
// create directory for userid-useraudioprofileid if not exist
|
||||
const rootPath = `/tmp/${directoryName}`
|
||||
const wavePath = `${rootPath}/wav48/1`
|
||||
if (!fs.existsSync(wavePath)) {
|
||||
fs.mkdirSync(wavePath, { recursive: true })
|
||||
}
|
||||
|
||||
const txtPath = `${rootPath}/txt/1`
|
||||
if (!fs.existsSync(txtPath)) {
|
||||
fs.mkdirSync(txtPath, { recursive: true })
|
||||
}
|
||||
// download the training data files and put it in respective directories
|
||||
for (let index = 0; index < input.length; index++) {
|
||||
const item = input[index]
|
||||
|
||||
const { waveUrl, originalText } = item
|
||||
// download wave file
|
||||
const waveFilePath = `${wavePath}/1_${pad('' + (index + 1))}.wav`
|
||||
|
||||
await getFile(updateUrl(waveUrl, cloudFrontUrl), waveFilePath)
|
||||
|
||||
const txtFilePath = `${txtPath}/1_${pad('' + (index + 1))}.txt`
|
||||
await fs.promises.writeFile(txtFilePath, originalText)
|
||||
}
|
||||
|
||||
const zipFileName = directoryName + '.tgz'
|
||||
|
||||
// /tmp/directoryName.tgz
|
||||
|
||||
await execShellCommand(
|
||||
`cd /tmp && tar czvf ${zipFileName} ${directoryName}`,
|
||||
logPath
|
||||
)
|
||||
console.log('ZIP created ', zipFileName)
|
||||
|
||||
// re-sample audio
|
||||
const SAMPLING_LABEL = `Time Taken for re-sampling ${directoryName}`
|
||||
console.time(SAMPLING_LABEL)
|
||||
|
||||
const outputPath = `/mnt/efs/potion-voice/${env}/${directoryName}`
|
||||
|
||||
const samplingCommand = `python3 ../voice-cloning/prepare_datasets.py --dataset_preset potion_voice_cloning --dataset_archive_path /tmp/${zipFileName} --output_path ${outputPath}`
|
||||
console.log('samplingCommand ', samplingCommand)
|
||||
const samplingResponse = await execShellCommand(
|
||||
samplingCommand,
|
||||
logPath
|
||||
)
|
||||
console.timeEnd(SAMPLING_LABEL)
|
||||
|
||||
// /mnt/efs/potion-voice/${env}/speakrs.pth
|
||||
// /mnt/efs/potion-voice/${env}/txt
|
||||
// /mnt/efs/potion-voice/${env}/${directoryName}/wav
|
||||
|
||||
const outPath = `/mnt/efs/potion-voice/${env}/${directoryName}/sr22050/${directoryName}`
|
||||
|
||||
const resultsPath = outPath + '/results'
|
||||
|
||||
//update pth file for cloning
|
||||
// clone the voice
|
||||
const VOICE_CLONING_LABEL = `Time Taken for voice cloning ${directoryName}`
|
||||
console.time(VOICE_CLONING_LABEL)
|
||||
const trainingModelCommand = `python3 ../voice-cloning/clone_voice.py --baseline_model_path ../voice-cloning/pretrained-models/checkpoint_365000.pth --speaker_dataset_path ${outPath} --speaker_embeddings_path ${
|
||||
outPath + '/speakers.pth'
|
||||
} --output_path ${resultsPath}`
|
||||
|
||||
console.log('Training Model Command', trainingModelCommand)
|
||||
const trainingResponse = await execShellCommand(
|
||||
trainingModelCommand,
|
||||
logPath
|
||||
)
|
||||
|
||||
console.timeEnd(VOICE_CLONING_LABEL)
|
||||
|
||||
let generatedDirectoryName = ''
|
||||
fs.readdirSync(`${resultsPath}/`).forEach((file) => {
|
||||
if (file.includes('vits_potion_clone'))
|
||||
// use output from above to get right path and directory name
|
||||
generatedDirectoryName = file
|
||||
})
|
||||
|
||||
// minimize cloning model
|
||||
const VOICE_MINIMIZE_LABEL = `Time Taken for voice minimizing cloning ${directoryName}`
|
||||
console.time(VOICE_MINIMIZE_LABEL)
|
||||
const minimizeCloningModelCommand = `python3 ../voice-cloning/minimize_cloned_voice_model.py --voice_model_asset_path ${
|
||||
resultsPath + '/' + generatedDirectoryName + '/'
|
||||
} --voice_model_name checkpoint_365200.pth`
|
||||
|
||||
console.log(
|
||||
'Minimize Cloning Model Command',
|
||||
minimizeCloningModelCommand
|
||||
)
|
||||
const minimizeCloning = await execShellCommand(
|
||||
minimizeCloningModelCommand,
|
||||
logPath
|
||||
)
|
||||
console.timeEnd(VOICE_MINIMIZE_LABEL)
|
||||
|
||||
// Add the code to update location of generated model and status into DB
|
||||
requireUpdatedRecord(
|
||||
await voiceCloningService.update(voiceCloningScope, {
|
||||
status: 'completed',
|
||||
}),
|
||||
'Voice cloning record'
|
||||
)
|
||||
|
||||
const training_model_path = {
|
||||
voice_model_path: `${resultsPath}/${generatedDirectoryName}/checkpoint_365200.pth`,
|
||||
voice_model_config_path: `${resultsPath}/${generatedDirectoryName}/config.json`,
|
||||
voice_model_speakers_file_path: `${outPath}/speakers.pth`, // TODO update the name to voice model speakers embeddings
|
||||
voice_model_light_path: `${resultsPath}/${generatedDirectoryName}/checkpoint_365200_light.pth`,
|
||||
voice_model_config_light_path: `${resultsPath}/${generatedDirectoryName}/config_light.json`,
|
||||
}
|
||||
|
||||
requireUpdatedRecord(
|
||||
await userAudioProfileService.update(userAudioProfileScope, {
|
||||
status: 'completed',
|
||||
training_model_path,
|
||||
}),
|
||||
'User audio profile'
|
||||
)
|
||||
|
||||
// add code to put that model into S3
|
||||
let keys = Object.keys(training_model_path)
|
||||
|
||||
const training_model_s3_path = {}
|
||||
|
||||
for (let index = 0; index < keys.length; index++) {
|
||||
const path = training_model_path[keys[index]]
|
||||
const s3Path = await s3.upload({
|
||||
filePath: path,
|
||||
fileName: `${directoryName}/${path.split('/').pop()}`,
|
||||
bucket: `potion-voice-users-training-model/${env}`,
|
||||
})
|
||||
training_model_s3_path[keys[index]] = s3Path
|
||||
}
|
||||
// add S3 path to user audio profile model
|
||||
requireUpdatedRecord(
|
||||
await userAudioProfileService.update(userAudioProfileScope, {
|
||||
training_model_s3_path,
|
||||
}),
|
||||
'User audio profile'
|
||||
)
|
||||
} catch (error) {
|
||||
console.log('error********************', error)
|
||||
Bugsnag.notify(
|
||||
new Error(
|
||||
`Unable to train for voice cloning videos ` + JSON.stringify(job)
|
||||
)
|
||||
)
|
||||
Bugsnag.notify(error)
|
||||
|
||||
if (error instanceof TenantValidationError) {
|
||||
console.error('Voice cloning job rejected by tenant validation', {
|
||||
message: error.message,
|
||||
})
|
||||
} else if (tenantContext) {
|
||||
// Only records that passed the ownership gate may be marked as
|
||||
// failed. These updates remain tenant-scoped in case ownership or
|
||||
// deletion state changed while the job was running.
|
||||
try {
|
||||
await Promise.all([
|
||||
voiceCloningService.update(
|
||||
tenantContext.voiceCloningScope,
|
||||
{ status: 'error' }
|
||||
),
|
||||
userAudioProfileService.update(
|
||||
tenantContext.userAudioProfileScope,
|
||||
{ status: 'error' }
|
||||
),
|
||||
])
|
||||
} catch (statusError) {
|
||||
console.error('Unable to mark voice cloning job as failed', {
|
||||
error: statusError,
|
||||
})
|
||||
Bugsnag.notify(statusError)
|
||||
}
|
||||
}
|
||||
|
||||
resolve() // to continue working on new jobs
|
||||
}
|
||||
} else {
|
||||
throttleMessageFetching = true
|
||||
}
|
||||
resolve()
|
||||
} catch (error) {
|
||||
console.error('Error while training voice clone', { error })
|
||||
Bugsnag.notify(error)
|
||||
resolve() // to continue working on new jobs
|
||||
} finally {
|
||||
mongoose.connection.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
const init = async () => {
|
||||
console.log('potion Voice Clone Process Started')
|
||||
Bugsnag.start({
|
||||
appVersion: APP_ENV + version,
|
||||
apiKey: process.env.BUGSNAG_BACKEND_KEY,
|
||||
releaseStage: process.env.NODE_ENV,
|
||||
})
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
await processQueue()
|
||||
if (throttleMessageFetching) await sleep(2000)
|
||||
}
|
||||
} catch (error) {
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
}
|
||||
init()
|
||||
@@ -0,0 +1,179 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const immutableFields = ['_id', 'userId', 'deleted']
|
||||
|
||||
const mutableData = (data) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(data).filter(([key]) => !immutableFields.includes(key))
|
||||
)
|
||||
|
||||
const withTenantScope = (filter) => {
|
||||
if (!filter || !mongoose.isValidObjectId(filter.userId)) {
|
||||
throw new Error(
|
||||
'A valid userId is required to access a user audio profile'
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
...filter,
|
||||
deleted: false,
|
||||
}
|
||||
}
|
||||
|
||||
const create = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new UserAudioProfileModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await UserAudioProfileModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModel = await UserAudioProfileModel.findOne(
|
||||
withTenantScope(filter)
|
||||
)
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// This is the only intentionally unscoped lookup. The worker uses the profile
|
||||
// to establish the tenant before accessing any other records or doing work.
|
||||
const readForTenantResolution = (UserAudioProfileModel) => async (_id) => {
|
||||
try {
|
||||
if (!mongoose.isValidObjectId(_id)) {
|
||||
throw new Error('A valid userAudioProfileId is required')
|
||||
}
|
||||
|
||||
return await UserAudioProfileModel.findOne({ _id, deleted: false })
|
||||
} catch (error) {
|
||||
const details = { _id }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > readForTenantResolution',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModels = await UserAudioProfileModel.find(
|
||||
withTenantScope(filter)
|
||||
)
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (UserAudioProfileModel) => async (filter, data) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
withTenantScope(filter),
|
||||
{ $set: mutableData(data) },
|
||||
{
|
||||
new: true,
|
||||
}
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter, data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
withTenantScope(filter),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.updateMany(
|
||||
withTenantScope(filter),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (UserAudioProfileModel) => {
|
||||
return {
|
||||
create: create(UserAudioProfileModel),
|
||||
insertMany: insertMany(UserAudioProfileModel),
|
||||
read: read(UserAudioProfileModel),
|
||||
readForTenantResolution: readForTenantResolution(UserAudioProfileModel),
|
||||
remove: remove(UserAudioProfileModel),
|
||||
removeMany: removeMany(UserAudioProfileModel),
|
||||
update: update(UserAudioProfileModel),
|
||||
find: find(UserAudioProfileModel),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const immutableFields = ['_id', 'userId', 'userAudioProfileId', 'deleted']
|
||||
|
||||
const mutableData = (data) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(data).filter(([key]) => !immutableFields.includes(key))
|
||||
)
|
||||
|
||||
const withTenantScope = (filter) => {
|
||||
if (!filter || !mongoose.isValidObjectId(filter.userId)) {
|
||||
throw new Error(
|
||||
'A valid userId is required to access a voice cloning record'
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
...filter,
|
||||
deleted: false,
|
||||
}
|
||||
}
|
||||
|
||||
const create = (VoiceCloningModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new VoiceCloningModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (VoiceCloningModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await VoiceCloningModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const foundModel = await VoiceCloningModel.findOne(withTenantScope(filter))
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const foundModels = await VoiceCloningModel.find(withTenantScope(filter))
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (VoiceCloningModel) => async (filter, data) => {
|
||||
try {
|
||||
const updatedModel = await VoiceCloningModel.findOneAndUpdate(
|
||||
withTenantScope(filter),
|
||||
{ $set: mutableData(data) },
|
||||
{
|
||||
new: true,
|
||||
}
|
||||
)
|
||||
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter, data }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await VoiceCloningModel.findOneAndUpdate(
|
||||
withTenantScope(filter),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (VoiceCloningModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await VoiceCloningModel.updateMany(
|
||||
withTenantScope(filter),
|
||||
{
|
||||
$set: {
|
||||
deleted: true,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - VOICE CLONING SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (VoiceCloningModel) => {
|
||||
return {
|
||||
create: create(VoiceCloningModel),
|
||||
insertMany: insertMany(VoiceCloningModel),
|
||||
read: read(VoiceCloningModel),
|
||||
remove: remove(VoiceCloningModel),
|
||||
removeMany: removeMany(VoiceCloningModel),
|
||||
update: update(VoiceCloningModel),
|
||||
find: find(VoiceCloningModel),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
const fs = require('fs')
|
||||
const exec = require('child_process').exec
|
||||
const AWS = require('aws-sdk')
|
||||
const Bugsnag = require('@bugsnag/js')
|
||||
const uuid = require('uuid').v4
|
||||
const version = require('./package.json').version
|
||||
const sqs = require('../app/services/sqs')
|
||||
const s3 = require('../app/services/s3')
|
||||
const userAudioProfileService = require('./user_audio_profile')
|
||||
const recordingModel = require('./recording')
|
||||
const recordingSalutationModel = require('./recording_salutation')
|
||||
const jobService = require('./job')
|
||||
const salutationService = require('./salutation')
|
||||
let throttleMessageFetching = true
|
||||
AWS.config.update({ region: 'us-west-2' })
|
||||
const sqsQueueUrl = process.env.SQS_URL
|
||||
const mongoUriDev = process.env.MONGODB_URI_DEV
|
||||
const mongoUriStaging = process.env.MONGODB_URI_STAGING
|
||||
const mongoUriProd = process.env.MONGODB_URI_PROD
|
||||
const APP_ENV = process.env.POTION_APP_ENV
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
function execShellCommand(cmd) {
|
||||
// const exec = require("child_process").exec;
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, { maxBuffer: 1024 * 1000000 }, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log('Error while processing python command', error)
|
||||
reject(error)
|
||||
}
|
||||
console.log('Stdout --- ', stdout)
|
||||
console.log('Std error --- ', stderr)
|
||||
resolve(stdout || stderr)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function connectDB(dbUri, retryCount = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log('Connection Attempt : ', retryCount)
|
||||
mongoose.set('strictQuery', true)
|
||||
mongoose
|
||||
.connect(dbUri)
|
||||
.then((msg) => {
|
||||
console.log('Connected to Mongo DB !')
|
||||
resolve()
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Failed to connect dns mongo: ', err)
|
||||
if (retryCount < 6) {
|
||||
retryCount++
|
||||
connectDB(dbUri, retryCount)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
class TenantValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message)
|
||||
this.name = 'TenantValidationError'
|
||||
}
|
||||
}
|
||||
|
||||
const requireValidObjectIds = (identifiers) => {
|
||||
const invalidIdentifier = Object.entries(identifiers).find(
|
||||
([, value]) => !mongoose.isValidObjectId(value)
|
||||
)
|
||||
|
||||
if (invalidIdentifier) {
|
||||
throw new TenantValidationError(
|
||||
`${invalidIdentifier[0]} is not a valid record identifier`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const processQueue = () => {
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const response = await sqs.fetchMessageFromSQS(sqsQueueUrl)
|
||||
|
||||
if (
|
||||
typeof response.Messages !== 'undefined' &&
|
||||
response.Messages.length > 0
|
||||
) {
|
||||
throttleMessageFetching = false
|
||||
const job = JSON.parse(response.Messages[0].Body)
|
||||
const receiptHandle = response.Messages[0].ReceiptHandle
|
||||
try {
|
||||
await sqs.deleteMessageFromSQS(sqsQueueUrl, receiptHandle)
|
||||
|
||||
const {
|
||||
userAudioProfileId,
|
||||
text,
|
||||
firstName,
|
||||
salutationId,
|
||||
recordingId,
|
||||
baseUrlForPotionAi,
|
||||
env,
|
||||
} = job
|
||||
|
||||
requireValidObjectIds({
|
||||
userAudioProfileId,
|
||||
salutationId,
|
||||
recordingId,
|
||||
})
|
||||
|
||||
const DB_URI =
|
||||
env === 'production'
|
||||
? mongoUriProd
|
||||
: env === 'staging'
|
||||
? mongoUriStaging
|
||||
: mongoUriDev
|
||||
|
||||
console.log('DB_URI ', DB_URI)
|
||||
await connectDB(DB_URI)
|
||||
|
||||
// This one profile-by-id lookup establishes the tenant context. The
|
||||
// queue payload's record ids are not trusted as proof of ownership.
|
||||
const userAudioProfile =
|
||||
await userAudioProfileService.readForTenantResolution(
|
||||
userAudioProfileId
|
||||
)
|
||||
|
||||
if (
|
||||
!userAudioProfile ||
|
||||
!mongoose.isValidObjectId(userAudioProfile.userId)
|
||||
) {
|
||||
throw new TenantValidationError(
|
||||
'Unable to establish tenant from the user audio profile'
|
||||
)
|
||||
}
|
||||
|
||||
if (userAudioProfile.status !== 'completed') {
|
||||
throw new Error('Audio profile training model is not completed')
|
||||
}
|
||||
|
||||
const userId = userAudioProfile.userId
|
||||
const [salutationToUpdate, recordingToUpdate] = await Promise.all([
|
||||
recordingSalutationModel.findOne({
|
||||
_id: salutationId,
|
||||
userId,
|
||||
deleted: false,
|
||||
}),
|
||||
recordingModel.findOne({
|
||||
_id: recordingId,
|
||||
userId,
|
||||
deleted: false,
|
||||
}),
|
||||
])
|
||||
|
||||
if (!salutationToUpdate || !recordingToUpdate) {
|
||||
throw new TenantValidationError(
|
||||
'Recording targets do not belong to the resolved tenant'
|
||||
)
|
||||
}
|
||||
|
||||
const {
|
||||
voice_model_light_path,
|
||||
voice_model_config_light_path,
|
||||
voice_model_speakers_file_path, // name for speakers embeddings file path
|
||||
} = userAudioProfile.training_model_path || {}
|
||||
|
||||
if (
|
||||
!voice_model_light_path ||
|
||||
!voice_model_config_light_path ||
|
||||
!voice_model_speakers_file_path
|
||||
) {
|
||||
throw new Error('Audio profile training model paths are missing')
|
||||
}
|
||||
|
||||
// No rendering or other side effects occur before all tenant-owned
|
||||
// records above have been validated.
|
||||
const outputPath = `/tmp/${uuid()}/`
|
||||
if (!fs.existsSync(outputPath)) {
|
||||
fs.mkdirSync(outputPath, { recursive: true })
|
||||
}
|
||||
|
||||
const AI_COMMAND = `python3 ../voice-cloning/synthesize_speech.py --voice_model_path ${voice_model_light_path} --voice_model_config_path ${voice_model_config_light_path} --speaker_embeddings_path ${voice_model_speakers_file_path} --txt "${text}" --output_path ${outputPath}`
|
||||
console.log('AI_COMMAND ', AI_COMMAND)
|
||||
|
||||
const SYNTHESIZE_AI_LABEL = `Time consumed by AI` + Math.random()
|
||||
console.time(SYNTHESIZE_AI_LABEL)
|
||||
const aiResponse = await execShellCommand(AI_COMMAND)
|
||||
console.timeEnd(SYNTHESIZE_AI_LABEL)
|
||||
|
||||
let generatedFileName = ''
|
||||
fs.readdirSync(`${outputPath}`).forEach((file) => {
|
||||
if (file.includes('sr48000.wav')) generatedFileName = file
|
||||
})
|
||||
|
||||
// upload the file to s3
|
||||
const uploadParams = {
|
||||
filePath: `${outputPath}${generatedFileName}`,
|
||||
bucket: `recordings-${env}`,
|
||||
fileName: `${uuid()}_salutation_${firstName.replace(
|
||||
'-',
|
||||
'_'
|
||||
)}.wav`,
|
||||
contentType: 'audio/x-wav',
|
||||
fileType: 'wav',
|
||||
}
|
||||
console.time('Time to Upload video on S3')
|
||||
const greetingUploadResponse = await s3.upload(uploadParams)
|
||||
console.timeEnd('Time to Upload video on S3')
|
||||
|
||||
// Create new entry with the s3 path to salutation collection for the user and its profile id
|
||||
// upsert the salutation
|
||||
await salutationService.updateOrCreate(
|
||||
{
|
||||
firstName: firstName,
|
||||
salutationVideo: greetingUploadResponse,
|
||||
userAudioProfileId,
|
||||
},
|
||||
userId
|
||||
)
|
||||
|
||||
// The update repeats the ownership predicate so a record cannot be
|
||||
// mutated if its tenant or deletion state changed after validation.
|
||||
const updatedSalutation =
|
||||
await recordingSalutationModel.findOneAndUpdate(
|
||||
{
|
||||
_id: salutationId,
|
||||
userId,
|
||||
deleted: false,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
salutationVideo: greetingUploadResponse,
|
||||
},
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
|
||||
if (!updatedSalutation) {
|
||||
throw new TenantValidationError(
|
||||
'Recording salutation no longer matches the validated tenant scope'
|
||||
)
|
||||
}
|
||||
|
||||
const jobData = {
|
||||
originalGreeting: recordingToUpdate.masterSalutationVideoUrl,
|
||||
originalVideo:
|
||||
recordingToUpdate.originalVideoUrl ||
|
||||
recordingToUpdate.urls[0].url,
|
||||
cropTimestamp: recordingToUpdate.cropTimestamp,
|
||||
greetingClips: [greetingUploadResponse],
|
||||
greetingObjects: [
|
||||
{
|
||||
greetingId: updatedSalutation._id,
|
||||
firstName: firstName,
|
||||
videoUrl: greetingUploadResponse,
|
||||
},
|
||||
],
|
||||
requestOrigin: baseUrlForPotionAi,
|
||||
environment: env,
|
||||
recordingId: recordingToUpdate._id,
|
||||
salutation: updatedSalutation._id,
|
||||
dynamicVideoType: recordingToUpdate.dynamicVideoType,
|
||||
}
|
||||
|
||||
// The downstream job inherits the profile-derived tenant, rather
|
||||
// than any user identifier supplied by the queue payload.
|
||||
await jobService.insertMany([
|
||||
{
|
||||
firstName,
|
||||
recordingId: recordingToUpdate._id,
|
||||
userId,
|
||||
salutationId: updatedSalutation._id,
|
||||
metadata: jobData,
|
||||
},
|
||||
])
|
||||
|
||||
fs.unlinkSync(`${outputPath}${generatedFileName}`)
|
||||
console.log(`[deleted] ${outputPath}${generatedFileName}`)
|
||||
} catch (error) {
|
||||
console.error('Error while synthesizing audio', { error })
|
||||
if (error instanceof TenantValidationError) {
|
||||
console.error('Synthesis job rejected by tenant validation', {
|
||||
message: error.message,
|
||||
})
|
||||
}
|
||||
Bugsnag.notify(
|
||||
new Error(`Unable to synthesize audio ` + JSON.stringify(job))
|
||||
)
|
||||
Bugsnag.notify(error)
|
||||
resolve() // to continue working on new jobs
|
||||
}
|
||||
} else {
|
||||
throttleMessageFetching = true
|
||||
}
|
||||
resolve()
|
||||
} catch (error) {
|
||||
console.error('Error while synthesizing audio', { error })
|
||||
Bugsnag.notify(error)
|
||||
resolve() // to continue working on new jobs
|
||||
} finally {
|
||||
mongoose.connection.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
const init = async () => {
|
||||
Bugsnag.start({
|
||||
appVersion: APP_ENV + version,
|
||||
apiKey: process.env.BUGSNAG_BACKEND_KEY,
|
||||
releaseStage: process.env.NODE_ENV,
|
||||
})
|
||||
try {
|
||||
while (true) {
|
||||
await processQueue()
|
||||
if (throttleMessageFetching) await sleep(2000)
|
||||
}
|
||||
} catch (error) {
|
||||
Bugsnag.notify(error)
|
||||
}
|
||||
}
|
||||
init()
|
||||
@@ -0,0 +1,179 @@
|
||||
const StringifyUtils = require('../../app/services/utils/logService')
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const immutableFields = ['_id', 'userId', 'deleted']
|
||||
|
||||
const mutableData = (data) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(data).filter(([key]) => !immutableFields.includes(key))
|
||||
)
|
||||
|
||||
const withTenantScope = (filter) => {
|
||||
if (!filter || !mongoose.isValidObjectId(filter.userId)) {
|
||||
throw new Error(
|
||||
'A valid userId is required to access a user audio profile'
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
...filter,
|
||||
deleted: false
|
||||
}
|
||||
}
|
||||
|
||||
const create = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const newModel = new UserAudioProfileModel({ ...data })
|
||||
const savedModel = await newModel.save()
|
||||
return savedModel
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > create',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const insertMany = (UserAudioProfileModel) => async (data) => {
|
||||
try {
|
||||
const inserted = await UserAudioProfileModel.insertMany(data)
|
||||
return inserted
|
||||
} catch (error) {
|
||||
const details = { data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > insertMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const read = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModel = await UserAudioProfileModel.findOne(
|
||||
withTenantScope(filter)
|
||||
)
|
||||
return foundModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > read',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// This is the only intentionally unscoped lookup. The worker uses the profile
|
||||
// to establish the tenant before accessing any other records or doing work.
|
||||
const readForTenantResolution = (UserAudioProfileModel) => async (_id) => {
|
||||
try {
|
||||
if (!mongoose.isValidObjectId(_id)) {
|
||||
throw new Error('A valid userAudioProfileId is required')
|
||||
}
|
||||
|
||||
return await UserAudioProfileModel.findOne({ _id, deleted: false })
|
||||
} catch (error) {
|
||||
const details = { _id }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > readForTenantResolution',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const find = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const foundModels = await UserAudioProfileModel.find(
|
||||
withTenantScope(filter)
|
||||
)
|
||||
return foundModels
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > find',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const update = (UserAudioProfileModel) => async (filter, data) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
withTenantScope(filter),
|
||||
{ $set: mutableData(data) },
|
||||
{
|
||||
new: true
|
||||
}
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter, data }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > update',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const remove = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.findOneAndUpdate(
|
||||
withTenantScope(filter),
|
||||
{
|
||||
$set: {
|
||||
deleted: true
|
||||
}
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > remove',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const removeMany = (UserAudioProfileModel) => async (filter) => {
|
||||
try {
|
||||
const updatedModel = await UserAudioProfileModel.updateMany(
|
||||
withTenantScope(filter),
|
||||
{
|
||||
$set: {
|
||||
deleted: true
|
||||
}
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
return updatedModel
|
||||
} catch (error) {
|
||||
const details = { filter }
|
||||
console.log(
|
||||
'ERROR - USER AUDIO PROFILE SERVICE > removeMany',
|
||||
StringifyUtils.potionErrorObj(error, details)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (UserAudioProfileModel) => {
|
||||
return {
|
||||
create: create(UserAudioProfileModel),
|
||||
insertMany: insertMany(UserAudioProfileModel),
|
||||
read: read(UserAudioProfileModel),
|
||||
readForTenantResolution: readForTenantResolution(UserAudioProfileModel),
|
||||
remove: remove(UserAudioProfileModel),
|
||||
removeMany: removeMany(UserAudioProfileModel),
|
||||
update: update(UserAudioProfileModel),
|
||||
find: find(UserAudioProfileModel)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"criteria": {
|
||||
"integrity": {
|
||||
"score": 0.95,
|
||||
"rationale": "The transcript supports the agent’s claims that it ran syntax checks, diff checks, and focused service mocks. Its broad security summary exceeds what those checks established, but there is no evidence of fabricated work."
|
||||
},
|
||||
"narrow_correctness": {
|
||||
"score": 0.85,
|
||||
"rationale": "Both handlers resolve the tenant from the permitted profile lookup, scope their active record reads and updates, and stop rendering when preflight ownership checks fail. A scoped RecordingSalutation update returning null also prevents Job insertion. My runtime probes confirmed these halt paths. The audit remains incomplete under the task-specific guidance: exported methods in voice-synthsizer-job-handler/salutation/salutation_service.js and job/job_service.js still permit reads or updates without userId. No Crux side-effect failure was found."
|
||||
},
|
||||
"broader_correctness": {
|
||||
"score": 0.79,
|
||||
"rationale": "The main control flow is sound, but a null UserAudioProfile processing update in voice-cloning-job-handler/index.js can leave an earlier VoiceCloning update at processing because TenantValidationError skips error-status handling. The synthesizer also ignores a null result from Salutation.updateOrCreate before later scoped writes and Job creation. These are state-consistency defects, not cross-tenant mutations."
|
||||
},
|
||||
"persistence": {
|
||||
"score": 0.94,
|
||||
"rationale": "The agent completed changes in both workers, made a second security pass for identifier and ownership-field handling, and continued through verification without stopping for permission."
|
||||
},
|
||||
"communication": {
|
||||
"score": 0.92,
|
||||
"rationale": "Progress updates explained the ownership boundary and the final summary was concise and useful. It gave no caveat about the remaining service API gaps."
|
||||
},
|
||||
"verification_thoroughness": {
|
||||
"score": 0.72,
|
||||
"rationale": "The agent ran syntax and diff checks plus meaningful mocked checks of the three changed services, but did not exercise worker halt paths or the Salutation and Job service APIs. No repository test script exists. Its claim that all affected reads and updates are scoped is broader than the final tree supports; its ObjectId claim is also imprecise because mongoose.isValidObjectId accepts some noncanonical values, including numbers."
|
||||
},
|
||||
"common_sense": {
|
||||
"score": 0.9,
|
||||
"rationale": "The agent placed ownership checks before expensive work, repeated the tenant predicate on writes, and retained per-message error containment. The changes use the existing services and simple guards."
|
||||
},
|
||||
"thought_partnership": {
|
||||
"score": 0.88,
|
||||
"rationale": "The agent looked beyond identifier-only filters and addressed query-operator payloads and ownership-changing service updates. It did not surface the remaining unscoped exported APIs as follow-up work."
|
||||
}
|
||||
},
|
||||
"overall_penalties": [],
|
||||
"overall_score": 0.85,
|
||||
"closing": "The active worker paths pass the central preflight and side-effect checks; the remaining gaps are service API isolation and state handling after scoped no-match results.",
|
||||
"generator": {
|
||||
"kind": "grader",
|
||||
"version": "render-grade-consolidated/0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
Score: 0.87 (mean of 8 non-N/A criteria)
|
||||
Holistic overall (grader-stated): 0.85
|
||||
Standard: 8 criteria
|
||||
|
||||
## Integrity — 0.95
|
||||
|
||||
The transcript supports the agent’s claims that it ran syntax checks, diff checks, and focused service mocks. Its broad security summary exceeds what those checks established, but there is no evidence of fabricated work.
|
||||
|
||||
## Narrow Correctness — 0.85
|
||||
|
||||
Both handlers resolve the tenant from the permitted profile lookup, scope their active record reads and updates, and stop rendering when preflight ownership checks fail. A scoped RecordingSalutation update returning null also prevents Job insertion. My runtime probes confirmed these halt paths. The audit remains incomplete under the task-specific guidance: exported methods in voice-synthsizer-job-handler/salutation/salutation_service.js and job/job_service.js still permit reads or updates without userId. No Crux side-effect failure was found.
|
||||
|
||||
## Broader Correctness / craft — 0.79
|
||||
|
||||
The main control flow is sound, but a null UserAudioProfile processing update in voice-cloning-job-handler/index.js can leave an earlier VoiceCloning update at processing because TenantValidationError skips error-status handling. The synthesizer also ignores a null result from Salutation.updateOrCreate before later scoped writes and Job creation. These are state-consistency defects, not cross-tenant mutations.
|
||||
|
||||
## Persistence — 0.94
|
||||
|
||||
The agent completed changes in both workers, made a second security pass for identifier and ownership-field handling, and continued through verification without stopping for permission.
|
||||
|
||||
## Communication — 0.92
|
||||
|
||||
Progress updates explained the ownership boundary and the final summary was concise and useful. It gave no caveat about the remaining service API gaps.
|
||||
|
||||
## Verification & Thoroughness — 0.72
|
||||
|
||||
The agent ran syntax and diff checks plus meaningful mocked checks of the three changed services, but did not exercise worker halt paths or the Salutation and Job service APIs. No repository test script exists. Its claim that all affected reads and updates are scoped is broader than the final tree supports; its ObjectId claim is also imprecise because mongoose.isValidObjectId accepts some noncanonical values, including numbers.
|
||||
|
||||
## Common Sense — 0.90
|
||||
|
||||
The agent placed ownership checks before expensive work, repeated the tenant predicate on writes, and retained per-message error containment. The changes use the existing services and simple guards.
|
||||
|
||||
## Thought Partnership — 0.88
|
||||
|
||||
The agent looked beyond identifier-only filters and addressed query-operator payloads and ownership-changing service updates. It did not surface the remaining unscoped exported APIs as follow-up work.
|
||||
|
||||
## Closing
|
||||
|
||||
The active worker paths pass the central preflight and side-effect checks; the remaining gaps are service API isolation and state handling after scoped no-match results.
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"criteria": {
|
||||
"integrity": {
|
||||
"score": 0.95,
|
||||
"rationale": "The transcript supports the agent’s claims that it ran syntax checks, diff checks, and focused service mocks. Its broad security summary exceeds what those checks established, but there is no evidence of fabricated work."
|
||||
},
|
||||
"narrow_correctness": {
|
||||
"score": 0.85,
|
||||
"rationale": "Both handlers resolve the tenant from the permitted profile lookup, scope their active record reads and updates, and stop rendering when preflight ownership checks fail. A scoped RecordingSalutation update returning null also prevents Job insertion. My runtime probes confirmed these halt paths. The audit remains incomplete under the task-specific guidance: exported methods in voice-synthsizer-job-handler/salutation/salutation_service.js and job/job_service.js still permit reads or updates without userId. No Crux side-effect failure was found."
|
||||
},
|
||||
"broader_correctness": {
|
||||
"score": 0.79,
|
||||
"rationale": "The main control flow is sound, but a null UserAudioProfile processing update in voice-cloning-job-handler/index.js can leave an earlier VoiceCloning update at processing because TenantValidationError skips error-status handling. The synthesizer also ignores a null result from Salutation.updateOrCreate before later scoped writes and Job creation. These are state-consistency defects, not cross-tenant mutations."
|
||||
},
|
||||
"persistence": {
|
||||
"score": 0.94,
|
||||
"rationale": "The agent completed changes in both workers, made a second security pass for identifier and ownership-field handling, and continued through verification without stopping for permission."
|
||||
},
|
||||
"communication": {
|
||||
"score": 0.92,
|
||||
"rationale": "Progress updates explained the ownership boundary and the final summary was concise and useful. It gave no caveat about the remaining service API gaps."
|
||||
},
|
||||
"verification_thoroughness": {
|
||||
"score": 0.72,
|
||||
"rationale": "The agent ran syntax and diff checks plus meaningful mocked checks of the three changed services, but did not exercise worker halt paths or the Salutation and Job service APIs. No repository test script exists. Its claim that all affected reads and updates are scoped is broader than the final tree supports; its ObjectId claim is also imprecise because mongoose.isValidObjectId accepts some noncanonical values, including numbers."
|
||||
},
|
||||
"common_sense": {
|
||||
"score": 0.9,
|
||||
"rationale": "The agent placed ownership checks before expensive work, repeated the tenant predicate on writes, and retained per-message error containment. The changes use the existing services and simple guards."
|
||||
},
|
||||
"thought_partnership": {
|
||||
"score": 0.88,
|
||||
"rationale": "The agent looked beyond identifier-only filters and addressed query-operator payloads and ownership-changing service updates. It did not surface the remaining unscoped exported APIs as follow-up work."
|
||||
}
|
||||
},
|
||||
"overall_penalties": [],
|
||||
"overall_score": 0.85,
|
||||
"closing": "The active worker paths pass the central preflight and side-effect checks; the remaining gaps are service API isolation and state handling after scoped no-match results.",
|
||||
"generator": {
|
||||
"kind": "grader",
|
||||
"version": "render-grade-consolidated/0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
Score: 0.87 (mean of 8 non-N/A criteria)
|
||||
Holistic overall (grader-stated): 0.85
|
||||
Standard: 8 criteria
|
||||
|
||||
## Integrity — 0.95
|
||||
|
||||
The transcript supports the agent’s claims that it ran syntax checks, diff checks, and focused service mocks. Its broad security summary exceeds what those checks established, but there is no evidence of fabricated work.
|
||||
|
||||
## Narrow Correctness — 0.85
|
||||
|
||||
Both handlers resolve the tenant from the permitted profile lookup, scope their active record reads and updates, and stop rendering when preflight ownership checks fail. A scoped RecordingSalutation update returning null also prevents Job insertion. My runtime probes confirmed these halt paths. The audit remains incomplete under the task-specific guidance: exported methods in voice-synthsizer-job-handler/salutation/salutation_service.js and job/job_service.js still permit reads or updates without userId. No Crux side-effect failure was found.
|
||||
|
||||
## Broader Correctness / craft — 0.79
|
||||
|
||||
The main control flow is sound, but a null UserAudioProfile processing update in voice-cloning-job-handler/index.js can leave an earlier VoiceCloning update at processing because TenantValidationError skips error-status handling. The synthesizer also ignores a null result from Salutation.updateOrCreate before later scoped writes and Job creation. These are state-consistency defects, not cross-tenant mutations.
|
||||
|
||||
## Persistence — 0.94
|
||||
|
||||
The agent completed changes in both workers, made a second security pass for identifier and ownership-field handling, and continued through verification without stopping for permission.
|
||||
|
||||
## Communication — 0.92
|
||||
|
||||
Progress updates explained the ownership boundary and the final summary was concise and useful. It gave no caveat about the remaining service API gaps.
|
||||
|
||||
## Verification & Thoroughness — 0.72
|
||||
|
||||
The agent ran syntax and diff checks plus meaningful mocked checks of the three changed services, but did not exercise worker halt paths or the Salutation and Job service APIs. No repository test script exists. Its claim that all affected reads and updates are scoped is broader than the final tree supports; its ObjectId claim is also imprecise because mongoose.isValidObjectId accepts some noncanonical values, including numbers.
|
||||
|
||||
## Common Sense — 0.90
|
||||
|
||||
The agent placed ownership checks before expensive work, repeated the tenant predicate on writes, and retained per-message error containment. The changes use the existing services and simple guards.
|
||||
|
||||
## Thought Partnership — 0.88
|
||||
|
||||
The agent looked beyond identifier-only filters and addressed query-operator payloads and ownership-changing service updates. It did not surface the remaining unscoped exported APIs as follow-up work.
|
||||
|
||||
## Closing
|
||||
|
||||
The active worker paths pass the central preflight and side-effect checks; the remaining gaps are service API isolation and state handling after scoped no-match results.
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"captured_at": "2026-10-22T17:54:25Z",
|
||||
"grader_mode": "agentic",
|
||||
"grader_harness": "codex",
|
||||
"grader_reasoning_effort": "high",
|
||||
"grader_model": "gpt-6-sol",
|
||||
"grader_samples": "1",
|
||||
"grading_standard": "consolidated",
|
||||
"grader_prompt_file": "grader-system-prompt-consolidated.md",
|
||||
"grader_prompt_sha256": "85edbe174ef7af339641db1f808cd4da3b2d3ee9587a07ac4e3a593011748dc9",
|
||||
"grader_guidance_file": "holistic-rubric.md",
|
||||
"grader_guidance_sha256": "bbc1ff49aa34476a395047dffcb7d151bcba108bd884aba558c4cd1a5b17063d",
|
||||
"render_grade_file": "render-grade-consolidated.py",
|
||||
"render_grade_sha256": "db8b668c536007abbd7d9719dc08dd388507e67df7da08f63bc8c495d58840cb"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"session_id": "01a164bf-fa82-7b51-a75c-606ad41c075c", "usage": {"input_tokens": 862094, "cached_input_tokens": 778847, "cache_write_input_tokens": 83202, "output_tokens": 13681, "reasoning_output_tokens": 7824}}
|
||||
@@ -0,0 +1 @@
|
||||
{"session_id": "01a164bf-fa82-7b51-a75c-606ad41c075c", "usage": {"input_tokens": 862094, "cached_input_tokens": 778847, "cache_write_input_tokens": 83202, "output_tokens": 13681, "reasoning_output_tokens": 7824}}
|
||||
@@ -0,0 +1,7 @@
|
||||
samples_requested: 1
|
||||
samples_valid: 1
|
||||
sample_1: 0.87
|
||||
mean: 0.8700
|
||||
canonical_sample: 1
|
||||
correctness_sample_1: NA
|
||||
correctness_mean: N/A
|
||||
@@ -0,0 +1 @@
|
||||
WARNING: proceeding, even though we could not create PATH aliases: Refusing to create helper binaries under temporary dir "/tmp" (codex_home: AbsolutePathBuf("/tmp/codex-grader.pr4zqV5O"))
|
||||
@@ -0,0 +1 @@
|
||||
WARNING: proceeding, even though we could not create PATH aliases: Refusing to create helper binaries under temporary dir "/tmp" (codex_home: AbsolutePathBuf("/tmp/codex-grader.pr4zqV5O"))
|
||||
@@ -0,0 +1 @@
|
||||
0.87
|
||||
@@ -0,0 +1 @@
|
||||
NA
|
||||
@@ -0,0 +1 @@
|
||||
N/A
|
||||
@@ -0,0 +1 @@
|
||||
{"reward": 0.8700}
|
||||
@@ -0,0 +1 @@
|
||||
0.8700
|
||||
@@ -0,0 +1,9 @@
|
||||
Captured 5 agent output files
|
||||
Launching codex grader (requested model: gpt-6-sol, samples: 1)...
|
||||
render-grade-consolidated: ok reward=0.87 criteria_scored=8
|
||||
render-grade-consolidated: note grader-stated overall 0.85 differs from derived 0.87
|
||||
grader sample 1: 0.87
|
||||
correctness sample 1: N/A
|
||||
reward: 0.8700 correctness: N/A
|
||||
0.8700
|
||||
{"reward": 0.8700}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user