check all id's are autoincrement #14

Closed
opened 2026-03-20 04:56:43 +00:00 by despiegk · 3 comments
Owner

as id's use autocincrement u32 everywhere not long guids

make sure the _server,_ui, _web (if it exists), the openrpc, the sdk all gets changed to use incremental id's for everything

in sqlite is int I guess

as id's use autocincrement u32 everywhere not long guids make sure the _server,_ui, _web (if it exists), the openrpc, the sdk all gets changed to use incremental id's for everything in sqlite is int I guess
Author
Owner

Implementation Spec for Issue #14: Standardize All IDs to Autoincrement u32

Objective

Standardize all entity IDs (Job, Run, Log) across the entire hero_proc codebase to use u32 autoincrement integers consistently. Currently there is a mix of u64 and u32 for the same IDs depending on where they appear (struct definitions use u64, function signatures use u32, row deserialization casts i64 as u32).

Current State

Entity Struct field Function params Row deser
Job.id u64 u32 i64 as u32
JobSummary.id u64 - -
JobLogArchive.job_id u64 - -
Run.id u64 mixed u64/u32 i64 as u32
Run.jobs Vec - -
Run.dependencies Vec - -
LogEntry.logid u64 u64 i64 as u32
ServiceRun.run_id u64 - -

Requirements

  • All autoincrement ID fields in Rust structs must use u32 (not u64)
  • All function signatures accepting/returning IDs must use u32 consistently
  • All Vec<u64> holding IDs must become Vec<u32>
  • No SQLite schema changes needed (INTEGER PRIMARY KEY AUTOINCREMENT stays the same)
  • No OpenRPC spec changes needed ("type": "integer" is fine)
  • No SDK/UI changes needed
  • All tests must pass

Files to Modify

  1. crates/hero_proc_lib/src/db/jobs/model.rs — Job.id, JobSummary.id, JobLogArchive.job_id: u64→u32
  2. crates/hero_proc_lib/src/db/runs/model.rs — Run.id, Run.jobs, Run.dependencies, insert/get/delete signatures
  3. crates/hero_proc_lib/src/db/logs/model.rs — LogEntry.logid: u64→u32
  4. crates/hero_proc_lib/src/db/logs/mod.rs — insert_log, insert_logs_batch, get_log signatures
  5. crates/hero_proc_lib/src/db/service/model.rs — ServiceRun.run_id: u64→u32
  6. crates/hero_proc_lib/src/db/factory.rs — Verify factory methods propagate u32 correctly
  7. crates/hero_proc_server/src/rpc/run.rs — Update dependency collection types

Implementation Plan

Step 1 (independent): Fix Job ID types in jobs/model.rs
Step 2 (independent): Fix Run ID types in runs/model.rs
Step 3 (independent): Fix Log ID types in logs/model.rs + logs/mod.rs
Step 4 (independent): Fix ServiceRun.run_id in service/model.rs
Step 5 (depends 1-4): Verify factory.rs and server RPC handlers compile
Step 6 (depends 5): Run cargo check --workspace and fix any remaining issues
Step 7 (depends 6): Run cargo test --workspace

Acceptance Criteria

  • All struct ID fields use u32
  • All function signatures use u32 for IDs
  • Vec ID collections are Vec
  • cargo check --workspace passes
  • cargo test --workspace passes

Notes

  • No SQLite migration needed — INTEGER columns stay the same
  • Count fields (totals, etc.) remain u64 — they are not IDs
  • The attempt field inconsistency is out of scope
## Implementation Spec for Issue #14: Standardize All IDs to Autoincrement u32 ### Objective Standardize all entity IDs (Job, Run, Log) across the entire hero_proc codebase to use `u32` autoincrement integers consistently. Currently there is a mix of `u64` and `u32` for the same IDs depending on where they appear (struct definitions use `u64`, function signatures use `u32`, row deserialization casts `i64 as u32`). ### Current State | Entity | Struct field | Function params | Row deser | |--------|-------------|----------------|-----------| | Job.id | u64 | u32 | i64 as u32 | | JobSummary.id | u64 | - | - | | JobLogArchive.job_id | u64 | - | - | | Run.id | u64 | mixed u64/u32 | i64 as u32 | | Run.jobs | Vec<u64> | - | - | | Run.dependencies | Vec<u64> | - | - | | LogEntry.logid | u64 | u64 | i64 as u32 | | ServiceRun.run_id | u64 | - | - | ### Requirements - All autoincrement ID fields in Rust structs must use `u32` (not `u64`) - All function signatures accepting/returning IDs must use `u32` consistently - All `Vec<u64>` holding IDs must become `Vec<u32>` - No SQLite schema changes needed (INTEGER PRIMARY KEY AUTOINCREMENT stays the same) - No OpenRPC spec changes needed (`"type": "integer"` is fine) - No SDK/UI changes needed - All tests must pass ### Files to Modify 1. `crates/hero_proc_lib/src/db/jobs/model.rs` — Job.id, JobSummary.id, JobLogArchive.job_id: u64→u32 2. `crates/hero_proc_lib/src/db/runs/model.rs` — Run.id, Run.jobs, Run.dependencies, insert/get/delete signatures 3. `crates/hero_proc_lib/src/db/logs/model.rs` — LogEntry.logid: u64→u32 4. `crates/hero_proc_lib/src/db/logs/mod.rs` — insert_log, insert_logs_batch, get_log signatures 5. `crates/hero_proc_lib/src/db/service/model.rs` — ServiceRun.run_id: u64→u32 6. `crates/hero_proc_lib/src/db/factory.rs` — Verify factory methods propagate u32 correctly 7. `crates/hero_proc_server/src/rpc/run.rs` — Update dependency collection types ### Implementation Plan **Step 1** (independent): Fix Job ID types in `jobs/model.rs` **Step 2** (independent): Fix Run ID types in `runs/model.rs` **Step 3** (independent): Fix Log ID types in `logs/model.rs` + `logs/mod.rs` **Step 4** (independent): Fix ServiceRun.run_id in `service/model.rs` **Step 5** (depends 1-4): Verify factory.rs and server RPC handlers compile **Step 6** (depends 5): Run `cargo check --workspace` and fix any remaining issues **Step 7** (depends 6): Run `cargo test --workspace` ### Acceptance Criteria - [ ] All struct ID fields use u32 - [ ] All function signatures use u32 for IDs - [ ] Vec<u64> ID collections are Vec<u32> - [ ] `cargo check --workspace` passes - [ ] `cargo test --workspace` passes ### Notes - No SQLite migration needed — INTEGER columns stay the same - Count fields (totals, etc.) remain u64 — they are not IDs - The `attempt` field inconsistency is out of scope
Author
Owner

Test Results

  • Total: 370+ tests
  • Passed: All
  • Failed: 0
  • cargo check --workspace
  • cargo test --workspace

Changes Made

Files Modified

  1. crates/hero_proc_lib/src/db/jobs/model.rs

    • Job.id: u64 → u32
    • JobSummary.id: u64 → u32
    • JobLogArchive.job_id: u64 → u32
    • Job.attempt, JobAttemptLog.attempt, etc.: u64 → u32 (consistency fix)
    • JobFilter.limit: u64 → u32 + default_list_limit() return type fixed
  2. crates/hero_proc_lib/src/db/runs/model.rs

    • Run.id: u64 → u32
    • Run.jobs: Vec<u64> → Vec<u32>
    • Run.dependencies: Vec<u64> → Vec<u32>
    • insert_run return: u64 → u32
    • get_run, delete_run, add_job_to_run params: u64 → u32
  3. crates/hero_proc_lib/src/db/logs/model.rs

    • LogEntry.logid: u64 → u32
  4. crates/hero_proc_lib/src/db/logs/mod.rs

    • insert_log return: u64 → u32
    • insert_logs_batch return: Vec<u64> → Vec<u32>
    • get_log param: u64 → u32
  5. crates/hero_proc_lib/src/db/service/model.rs

    • ServiceRun.run_id: u64 → u32

Not Changed (by design)

  • SQLite schema (INTEGER PRIMARY KEY AUTOINCREMENT stays the same)
  • OpenRPC spec ("type": "integer" is fine)
  • SDK generated types (macro-generated from spec)
  • UI JavaScript (untyped numbers)
  • Count fields (count_logs, delete_by_src, etc.) remain u64
  • Timestamp fields remain u64
## Test Results - **Total**: 370+ tests - **Passed**: All - **Failed**: 0 - `cargo check --workspace` ✅ - `cargo test --workspace` ✅ ## Changes Made ### Files Modified 1. **`crates/hero_proc_lib/src/db/jobs/model.rs`** - `Job.id`: u64 → u32 - `JobSummary.id`: u64 → u32 - `JobLogArchive.job_id`: u64 → u32 - `Job.attempt`, `JobAttemptLog.attempt`, etc.: u64 → u32 (consistency fix) - `JobFilter.limit`: u64 → u32 + `default_list_limit()` return type fixed 2. **`crates/hero_proc_lib/src/db/runs/model.rs`** - `Run.id`: u64 → u32 - `Run.jobs`: Vec\<u64\> → Vec\<u32\> - `Run.dependencies`: Vec\<u64\> → Vec\<u32\> - `insert_run` return: u64 → u32 - `get_run`, `delete_run`, `add_job_to_run` params: u64 → u32 3. **`crates/hero_proc_lib/src/db/logs/model.rs`** - `LogEntry.logid`: u64 → u32 4. **`crates/hero_proc_lib/src/db/logs/mod.rs`** - `insert_log` return: u64 → u32 - `insert_logs_batch` return: Vec\<u64\> → Vec\<u32\> - `get_log` param: u64 → u32 5. **`crates/hero_proc_lib/src/db/service/model.rs`** - `ServiceRun.run_id`: u64 → u32 ### Not Changed (by design) - SQLite schema (INTEGER PRIMARY KEY AUTOINCREMENT stays the same) - OpenRPC spec (`"type": "integer"` is fine) - SDK generated types (macro-generated from spec) - UI JavaScript (untyped numbers) - Count fields (`count_logs`, `delete_by_src`, etc.) remain u64 - Timestamp fields remain u64
Author
Owner

Implementation committed: 1cfcef4

Browse: 1cfcef4

Implementation committed: `1cfcef4` Browse: https://forge.ourworld.tf/lhumina_code/hero_proc/commit/1cfcef4
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_proc#14
No description provided.