Skip to content

Commit f0d8d0b

Browse files
committed
Fix UUID type in evaluation_jobs table and make signature optional
- Change evaluation_jobs.id and submission_id to UUID type - Update queries to use proper Uuid type for database operations - Make signature optional in SubmitAgentRequest for dev mode - Fixes DB schema type mismatch
1 parent 4c18e44 commit f0d8d0b

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

crates/platform-server/src/db/queries.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,8 @@ pub async fn create_job(
888888
challenge_id: &str,
889889
) -> Result<EvaluationJob> {
890890
let client = pool.get().await?;
891-
let job_id = Uuid::new_v4().to_string();
891+
let job_uuid = Uuid::new_v4();
892+
let sub_uuid = Uuid::parse_str(submission_id)?;
892893
let now = chrono::Utc::now().timestamp();
893894

894895
// Get submission details
@@ -902,8 +903,8 @@ pub async fn create_job(
902903
source_code, api_key, api_provider, challenge_id, status, created_at)
903904
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, 'pending', NOW())",
904905
&[
905-
&job_id,
906-
&submission_id,
906+
&job_uuid,
907+
&sub_uuid,
907908
&sub.agent_hash,
908909
&sub.miner_hotkey,
909910
&sub.source_code,
@@ -915,7 +916,7 @@ pub async fn create_job(
915916
.await?;
916917

917918
Ok(EvaluationJob {
918-
id: job_id,
919+
id: job_uuid.to_string(),
919920
submission_id: submission_id.to_string(),
920921
agent_hash: sub.agent_hash,
921922
miner_hotkey: sub.miner_hotkey,
@@ -961,8 +962,8 @@ pub async fn claim_next_job(
961962
.await?;
962963

963964
Ok(row.map(|r| EvaluationJob {
964-
id: r.get(0),
965-
submission_id: r.get(1),
965+
id: r.get::<_, Uuid>(0).to_string(),
966+
submission_id: r.get::<_, Uuid>(1).to_string(),
966967
agent_hash: r.get(2),
967968
miner_hotkey: r.get(3),
968969
source_code: r.get::<_, Option<String>>(4).unwrap_or_default(),
@@ -979,6 +980,7 @@ pub async fn claim_next_job(
979980
/// Get a job by ID
980981
pub async fn get_job(pool: &Pool, job_id: &str) -> Result<Option<EvaluationJob>> {
981982
let client = pool.get().await?;
983+
let job_uuid = Uuid::parse_str(job_id)?;
982984
let row = client
983985
.query_opt(
984986
"SELECT id, submission_id, agent_hash, miner_hotkey, source_code,
@@ -987,15 +989,15 @@ pub async fn get_job(pool: &Pool, job_id: &str) -> Result<Option<EvaluationJob>>
987989
status, assigned_validator,
988990
EXTRACT(EPOCH FROM assigned_at)::BIGINT as assigned_at
989991
FROM evaluation_jobs WHERE id = $1",
990-
&[&job_id],
992+
&[&job_uuid],
991993
)
992994
.await?;
993995

994996
Ok(row.map(|r| {
995997
let status_str: String = r.get(9);
996998
EvaluationJob {
997-
id: r.get(0),
998-
submission_id: r.get(1),
999+
id: r.get::<_, Uuid>(0).to_string(),
1000+
submission_id: r.get::<_, Uuid>(1).to_string(),
9991001
agent_hash: r.get(2),
10001002
miner_hotkey: r.get(3),
10011003
source_code: r.get::<_, Option<String>>(4).unwrap_or_default(),
@@ -1025,6 +1027,7 @@ pub async fn update_job_progress(
10251027
status: &str,
10261028
) -> Result<()> {
10271029
let client = pool.get().await?;
1030+
let job_uuid = Uuid::parse_str(job_id)?;
10281031
client
10291032
.execute(
10301033
"UPDATE evaluation_jobs SET
@@ -1033,7 +1036,7 @@ pub async fn update_job_progress(
10331036
last_progress = $3,
10341037
updated_at = NOW()
10351038
WHERE id = $1",
1036-
&[&job_id, &(task_index as i32), &status],
1039+
&[&job_uuid, &(task_index as i32), &status],
10371040
)
10381041
.await?;
10391042
Ok(())
@@ -1042,10 +1045,11 @@ pub async fn update_job_progress(
10421045
/// Mark job as completed
10431046
pub async fn complete_job(pool: &Pool, job_id: &str) -> Result<()> {
10441047
let client = pool.get().await?;
1048+
let job_uuid = Uuid::parse_str(job_id)?;
10451049
client
10461050
.execute(
10471051
"UPDATE evaluation_jobs SET status = 'completed', updated_at = NOW() WHERE id = $1",
1048-
&[&job_id],
1052+
&[&job_uuid],
10491053
)
10501054
.await?;
10511055
Ok(())

crates/platform-server/src/db/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ CREATE INDEX IF NOT EXISTS idx_challenges_status ON challenges(status);
188188
189189
-- Evaluation jobs queue
190190
CREATE TABLE IF NOT EXISTS evaluation_jobs (
191-
id VARCHAR(64) PRIMARY KEY,
192-
submission_id VARCHAR(64) NOT NULL REFERENCES submissions(id) ON DELETE CASCADE,
191+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
192+
submission_id UUID NOT NULL REFERENCES submissions(id) ON DELETE CASCADE,
193193
agent_hash VARCHAR(128) NOT NULL,
194194
miner_hotkey VARCHAR(128) NOT NULL,
195195
source_code TEXT,

crates/platform-server/src/models/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ impl From<&str> for SubmissionStatus {
8888
pub struct SubmitAgentRequest {
8989
pub source_code: String,
9090
pub miner_hotkey: String,
91-
pub signature: String,
91+
/// Signature for verification (optional in dev mode)
92+
#[serde(default)]
93+
pub signature: Option<String>,
9294
pub name: Option<String>,
9395
/// API key for LLM inferences (plaintext - server handles securely)
9496
pub api_key: Option<String>,

0 commit comments

Comments
 (0)