Skip to main content

seed_starter_skills

Function seed_starter_skills 

Source
pub(crate) fn seed_starter_skills(
    mstore: &Arc<Store>,
) -> Result<usize, StoreError>
Expand description

Parse the embedded manifest and insert every entry as a global skill via the validated skill_upsert_unique_global path. Does NOT check whether the catalog is already populated — the caller (migrations::m0015_seed_starter_skills) owns run-once gating via db_migrations tracking, not catalog contents. Exposed at pub(crate) so the migration and tests can call it directly.

All-or-nothing: skill_upsert_unique_global commits each insert in its own transaction (it isn’t StoreTx-composable — see its own doc comment), so a mid-loop failure can’t be rolled back by the database itself. If any insert fails, this compensates by deleting every skill already inserted in THIS call before returning the error — otherwise a retry (the migration framework re-runs up() on the next boot when a migration returns Err, since it’s never marked applied) would hit skill_upsert_unique_global’s name-uniqueness rejection on the skills already stranded from the failed attempt (reagent P2, PR #2141 round 1).