HiggsImplemented

One request context across the stack

Server functions load the signed-in user and Valence through Higgs::from_request(). Enqueue a Boson task (or a Chronon job, or a Photon publish) and the worker rebuilds that same user context.
Higgs · src/server.rs
use boson_core::ExecutionContext;
use boson_macros::task;
use boson_valence_identity::valence_from_context;
use higgs::Higgs;
use leptos::prelude::*;

// `auth` rejects callers who aren't signed in.
#[higgs_macros::server(auth)]
pub async fn queue_profile_rebuild() -> Result<(), ServerFnError> {
    let ctx = Higgs::from_request().await?;
    let valence = ctx.valence().map_err(ServerFnError::new)?;
    let user_id = valence
        .actor()
        .user_id()
        .ok_or_else(|| ServerFnError::new("expected a signed-in user"))?
        .to_string();

    RebuildProfile::send_with(
        serde_json::json!({ "User": { "user_id": user_id } }),
        RebuildProfileParams {
            user_id: user_id.clone(),
        },
    )
    .await
    .map_err(ServerFnError::new)?;
    Ok(())
}

#[task(name = "rebuild_profile")]
async fn rebuild_profile(
    ctx: Box<dyn ExecutionContext>,
    user_id: String,
) -> boson_core::Result<()> {
    // Same user as the server function. Chronon scripts and Photon
    // subscribers rebuild context from the same ValenceFactory.
    let valence = valence_from_context(ctx.as_ref())?;
    tracing::info!(rebuilt_user = valence.actor().user_id(), %user_id);
    Ok(())
}

Why it exists

Background work shouldn't run as System just because it left the HTTP request. Higgs hands the actor to Boson, Chronon, and Photon, so valence_from_context() inside a task sees the original user.

In both templates

Both templates provide HiggsConfig at boot, so every server function on this site gets the same request context.
Request context
Implemented
Load the current session and platform handles in Leptos server functions through Higgs::from_request().
Authenticated entry points
Implemented
#[higgs_macros::server(auth)] rejects callers who aren't signed in before your code runs.
User-scoped Valence
Implemented
Build Valence with the request actor so schema policies evaluate the signed-in user.
Actor-aware background work
Implemented
Boson, Chronon, and Photon handlers rebuild Valence from captured actor context through the shared factory.
Startup preflight
Implemented
Register checks that run at boot and report pass, warning or failure for each dependency.
Explicit system access
Implemented
Keep privacy-bypassing system Valence behind a deliberately unsafe control-plane API.

Code sample

Taken from the getting-started docs. See all code samples on Resources.
Higgs + BosonHiggs
Server function enqueues a task; the task rebuilds the user
use boson_core::ExecutionContext;
use boson_macros::task;
use boson_valence_identity::valence_from_context;
use higgs::Higgs;
use leptos::prelude::*;

// `auth` rejects callers who aren't signed in.
#[higgs_macros::server(auth)]
pub async fn queue_profile_rebuild() -> Result<(), ServerFnError> {
    let ctx = Higgs::from_request().await?;
    let valence = ctx.valence().map_err(ServerFnError::new)?;
    let user_id = valence
        .actor()
        .user_id()
        .ok_or_else(|| ServerFnError::new("expected a signed-in user"))?
        .to_string();

    RebuildProfile::send_with(
        serde_json::json!({ "User": { "user_id": user_id } }),
        RebuildProfileParams {
            user_id: user_id.clone(),
        },
    )
    .await
    .map_err(ServerFnError::new)?;
    Ok(())
}

#[task(name = "rebuild_profile")]
async fn rebuild_profile(
    ctx: Box<dyn ExecutionContext>,
    user_id: String,
) -> boson_core::Result<()> {
    // Same user as the server function. Chronon scripts and Photon
    // subscribers rebuild context from the same ValenceFactory.
    let valence = valence_from_context(ctx.as_ref())?;
    tracing::info!(rebuilt_user = valence.actor().user_id(), %user_id);
    Ok(())
}