Skip to main content

spawn

Function spawn 

Source
pub async fn spawn(
    pool: Pool<Sqlite>,
    key: SigningKey,
    service_did: String,
    retention_days: Option<u32>,
    retention: RetentionConfig,
    reason_vocabulary: ReasonVocabulary,
    strike_policy: StrikePolicy,
    label_emission_policy: LabelEmissionPolicy,
    policy_automation_policy: PolicyAutomationPolicy,
) -> Result<WriterHandle>
Expand description

Start the writer task. Acquires the instance lease, bootstraps the signing_keys row if empty, and spawns the event loop + heartbeat.

service_did stamps labels.src on every emitted event. key must be the private key whose public form is recorded (or will be recorded) in signing_keys.

retention_days is the §F4 retention cutoff in days. None disables the retention sweep entirely (WriteCommand::Sweep becomes a no-op returning rows_deleted = 0); Some(N) lets the sweep delete labels whose created_at is older than now - N days. Source of truth is crate::SubscribeConfig::retention_days — pass it through verbatim.

retention is the sweep execution policy (schedule + batching); distinct from retention_days per the §F4 split.

reason_vocabulary and strike_policy are the resolved v1.4 moderation surface (#47 / #48). The recorder (#51 RecordAction handler) consults them at action time to validate reason codes and compute strike values. They’re held by the writer task so the recorder doesn’t have to thread them through every call. Operators restart cairn serve to change either — same posture as [labeler] config.

label_emission_policy is the resolved [label_emission] surface (#58, v1.5). The recorder (#60) consults it post-INSERT to translate the freshly-recorded action into ATProto labels emitted in the same transaction. Held by the writer task for the same reason as the v1.4 surfaces above.