Bundles
The AssessmentBundleRepository stores algorithm bundles that power the adaptive assessment engine. Bundles are fetched from the Go diagnostics service via gRPC and cached in PostgreSQL.
pub struct AssessmentBundleRow { pub id: String, pub network_index: i32, pub curriculum_index: i32, pub data: serde_json::Value, // AlgorithmBundle JSON pub version: i32, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>,}
pub struct AssessmentBundleSummaryRow { pub id: String, pub network_index: i32, pub curriculum_index: i32, pub version: i32, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>,}Bundles are keyed by (network_index, curriculum_index) — each pair identifies a specific skill graph and curriculum combination.
Repository Methods
Section titled “Repository Methods”| Method | Purpose |
|---|---|
get_by_position(network, curriculum) | Fetch full bundle data |
upsert(network, curriculum, data) | Insert or update (UPSERT) |
list() | List all bundles (metadata only, no data blob) |
delete_by_position(network, curriculum) | Delete bundle |
get_version(network, curriculum) | Check bundle version without fetching data |
UPSERT
Section titled “UPSERT”pub async fn upsert( &self, network_index: i32, curriculum_index: i32, data: serde_json::Value,) -> Result<()> { // INSERT INTO assessment_bundles (id, network_index, curriculum_index, data, version) // ON CONFLICT (network_index, curriculum_index) // DO UPDATE SET data = $4, version = version + 1, updated_at = now()}Each upsert increments the version number, allowing clients to check if their cached bundle is stale.
Data Flow
Section titled “Data Flow”Go Diagnostics → gRPC → GrpcBundleFetcher → upsert() → PostgreSQL ↓Client ← GraphQL query ← get_by_position() ← ─────────────┘ ↓ AlgorithmBundle::from_json() ↓ AlgorithmEngine (in-memory)The data column stores the full AlgorithmBundle as JSON — including sparse distance/heuristic matrices and the question pool. See Algorithm for how this data is used.
Migration
Section titled “Migration”| Migration | Purpose |
|---|---|
005 | Create assessment_bundles table with unique (network_index, curriculum_index) constraint |